summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-01-12 23:22:15 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-01-12 23:22:15 +0000
commit6ee254699bf787d78835419be2b3241fb037d444 (patch)
tree07fe67dab517e4990f344fe2c00e65cef4d25b81 /lib
parent0b62f5dc36fc7203a74cdc812c4234ae188fdfd2 (diff)
Update to ncurses 5.7, with local changes reapplied.
This is around eight years worth of changes (previously we were around ncurses 5.2), too many to list - many bug fixes and also a few new functions. A major bump for libcurses, libpanel, libform and libmenu. ok deraadt
Diffstat (limited to 'lib')
-rw-r--r--lib/libcurses/Caps1379
-rw-r--r--lib/libcurses/Makefile146
-rw-r--r--lib/libcurses/SigAction.h16
-rw-r--r--lib/libcurses/base/MKkeyname.awk157
-rw-r--r--lib/libcurses/base/MKlib_gen.sh310
-rw-r--r--lib/libcurses/base/MKunctrl.awk151
-rw-r--r--lib/libcurses/base/define_key.c30
-rw-r--r--lib/libcurses/base/key_defined.c (renamed from lib/libcurses/base/sigaction.c)116
-rw-r--r--lib/libcurses/base/keybound.c19
-rw-r--r--lib/libcurses/base/keyok.c47
-rw-r--r--lib/libcurses/base/legacy_coding.c50
-rw-r--r--lib/libcurses/base/lib_adabind.c220
-rw-r--r--lib/libcurses/base/lib_addch.c433
-rw-r--r--lib/libcurses/base/lib_addstr.c172
-rw-r--r--lib/libcurses/base/lib_beep.c11
-rw-r--r--lib/libcurses/base/lib_bkgd.c118
-rw-r--r--lib/libcurses/base/lib_box.c92
-rw-r--r--lib/libcurses/base/lib_chgat.c21
-rw-r--r--lib/libcurses/base/lib_clear.c4
-rw-r--r--lib/libcurses/base/lib_clearok.c4
-rw-r--r--lib/libcurses/base/lib_clrbot.c16
-rw-r--r--lib/libcurses/base/lib_clreol.c12
-rw-r--r--lib/libcurses/base/lib_color.c433
-rw-r--r--lib/libcurses/base/lib_colorset.c17
-rw-r--r--lib/libcurses/base/lib_delch.c14
-rw-r--r--lib/libcurses/base/lib_delwin.c38
-rw-r--r--lib/libcurses/base/lib_dft_fgbg.c24
-rw-r--r--lib/libcurses/base/lib_echo.c4
-rw-r--r--lib/libcurses/base/lib_endwin.c4
-rw-r--r--lib/libcurses/base/lib_erase.c31
-rw-r--r--lib/libcurses/base/lib_flash.c4
-rw-r--r--lib/libcurses/base/lib_freeall.c112
-rw-r--r--lib/libcurses/base/lib_getch.c489
-rw-r--r--lib/libcurses/base/lib_getstr.c62
-rw-r--r--lib/libcurses/base/lib_hline.c15
-rw-r--r--lib/libcurses/base/lib_immedok.c4
-rw-r--r--lib/libcurses/base/lib_inchstr.c10
-rw-r--r--lib/libcurses/base/lib_initscr.c48
-rw-r--r--lib/libcurses/base/lib_insch.c115
-rw-r--r--lib/libcurses/base/lib_insdel.c10
-rw-r--r--lib/libcurses/base/lib_insnstr.c (renamed from lib/libcurses/base/lib_insstr.c)29
-rw-r--r--lib/libcurses/base/lib_instr.c54
-rw-r--r--lib/libcurses/base/lib_isendwin.c4
-rw-r--r--lib/libcurses/base/lib_leaveok.c4
-rw-r--r--lib/libcurses/base/lib_mouse.c1180
-rw-r--r--lib/libcurses/base/lib_move.c11
-rw-r--r--lib/libcurses/base/lib_mvwin.c15
-rw-r--r--lib/libcurses/base/lib_newterm.c259
-rw-r--r--lib/libcurses/base/lib_newwin.c172
-rw-r--r--lib/libcurses/base/lib_nl.c4
-rw-r--r--lib/libcurses/base/lib_overlay.c181
-rw-r--r--lib/libcurses/base/lib_pad.c64
-rw-r--r--lib/libcurses/base/lib_printw.c73
-rw-r--r--lib/libcurses/base/lib_redrawln.c27
-rw-r--r--lib/libcurses/base/lib_refresh.c159
-rw-r--r--lib/libcurses/base/lib_restart.c71
-rw-r--r--lib/libcurses/base/lib_scanw.c14
-rw-r--r--lib/libcurses/base/lib_screen.c158
-rw-r--r--lib/libcurses/base/lib_scroll.c86
-rw-r--r--lib/libcurses/base/lib_scrollok.c4
-rw-r--r--lib/libcurses/base/lib_scrreg.c4
-rw-r--r--lib/libcurses/base/lib_set_term.c527
-rw-r--r--lib/libcurses/base/lib_slk.c161
-rw-r--r--lib/libcurses/base/lib_slkatr_set.c22
-rw-r--r--lib/libcurses/base/lib_slkatrof.c17
-rw-r--r--lib/libcurses/base/lib_slkatron.c17
-rw-r--r--lib/libcurses/base/lib_slkatrset.c12
-rw-r--r--lib/libcurses/base/lib_slkattr.c14
-rw-r--r--lib/libcurses/base/lib_slkclear.c35
-rw-r--r--lib/libcurses/base/lib_slkcolor.c16
-rw-r--r--lib/libcurses/base/lib_slkinit.c18
-rw-r--r--lib/libcurses/base/lib_slklab.c8
-rw-r--r--lib/libcurses/base/lib_slkrefr.c44
-rw-r--r--lib/libcurses/base/lib_slkset.c113
-rw-r--r--lib/libcurses/base/lib_slktouch.c4
-rw-r--r--lib/libcurses/base/lib_touch.c4
-rw-r--r--lib/libcurses/base/lib_ungetch.c49
-rw-r--r--lib/libcurses/base/lib_vline.c15
-rw-r--r--lib/libcurses/base/lib_wattroff.c21
-rw-r--r--lib/libcurses/base/lib_wattron.c23
-rw-r--r--lib/libcurses/base/lib_winch.c9
-rw-r--r--lib/libcurses/base/lib_window.c125
-rw-r--r--lib/libcurses/base/nc_panel.c4
-rw-r--r--lib/libcurses/base/resizeterm.c431
-rw-r--r--lib/libcurses/base/safe_sprintf.c92
-rw-r--r--lib/libcurses/base/tries.c39
-rw-r--r--lib/libcurses/base/use_window.c50
-rw-r--r--lib/libcurses/base/version.c13
-rw-r--r--lib/libcurses/base/vsscanf.c358
-rw-r--r--lib/libcurses/base/wresize.c199
-rw-r--r--lib/libcurses/capdefaults.c17
-rw-r--r--lib/libcurses/curs_addch.3tbl76
-rw-r--r--lib/libcurses/curs_addchstr.340
-rw-r--r--lib/libcurses/curs_addstr.347
-rw-r--r--lib/libcurses/curs_attr.3tbl115
-rw-r--r--lib/libcurses/curs_beep.312
-rw-r--r--lib/libcurses/curs_bkgd.348
-rw-r--r--lib/libcurses/curs_bkgrnd.3108
-rw-r--r--lib/libcurses/curs_border.3101
-rw-r--r--lib/libcurses/curs_border_set.3209
-rw-r--r--lib/libcurses/curs_clear.351
-rw-r--r--lib/libcurses/curs_color.374
-rw-r--r--lib/libcurses/curs_delch.38
-rw-r--r--lib/libcurses/curs_deleteln.320
-rw-r--r--lib/libcurses/curs_extend.320
-rw-r--r--lib/libcurses/curs_getch.3tbl146
-rw-r--r--lib/libcurses/curs_getstr.345
-rw-r--r--lib/libcurses/curs_getyx.364
-rw-r--r--lib/libcurses/curs_inch.3tbl18
-rw-r--r--lib/libcurses/curs_inchstr.321
-rw-r--r--lib/libcurses/curs_initscr.334
-rw-r--r--lib/libcurses/curs_inopts.374
-rw-r--r--lib/libcurses/curs_insch.314
-rw-r--r--lib/libcurses/curs_insstr.354
-rw-r--r--lib/libcurses/curs_instr.318
-rw-r--r--lib/libcurses/curs_kernel.371
-rw-r--r--lib/libcurses/curs_legacy.395
-rw-r--r--lib/libcurses/curs_mouse.3tbl231
-rw-r--r--lib/libcurses/curs_move.324
-rw-r--r--lib/libcurses/curs_opaque.3135
-rw-r--r--lib/libcurses/curs_outopts.3151
-rw-r--r--lib/libcurses/curs_overlay.325
-rw-r--r--lib/libcurses/curs_pad.3102
-rw-r--r--lib/libcurses/curs_print.318
-rw-r--r--lib/libcurses/curs_printw.348
-rw-r--r--lib/libcurses/curs_refresh.377
-rw-r--r--lib/libcurses/curs_scanw.346
-rw-r--r--lib/libcurses/curs_scr_dump.330
-rw-r--r--lib/libcurses/curs_scroll.347
-rw-r--r--lib/libcurses/curs_slk.3104
-rw-r--r--lib/libcurses/curs_termattrs.369
-rw-r--r--lib/libcurses/curs_touch.334
-rw-r--r--lib/libcurses/curs_util.3198
-rw-r--r--lib/libcurses/curs_window.367
-rw-r--r--lib/libcurses/curses.3tbl786
-rw-r--r--lib/libcurses/curses.h1404
-rw-r--r--lib/libcurses/curses.priv.h1407
-rw-r--r--lib/libcurses/default_colors.343
-rw-r--r--lib/libcurses/define_key.323
-rw-r--r--lib/libcurses/doc/hackguide.html36
-rw-r--r--lib/libcurses/doc/ncurses-intro.html102
-rw-r--r--lib/libcurses/fifo_defs.h20
-rw-r--r--lib/libcurses/hashed_db.h69
-rw-r--r--lib/libcurses/hashsize.h6
-rw-r--r--lib/libcurses/key_defined.362
-rw-r--r--lib/libcurses/keybound.323
-rw-r--r--lib/libcurses/keyok.316
-rw-r--r--lib/libcurses/nc_alloc.h43
-rw-r--r--lib/libcurses/nc_panel.h13
-rw-r--r--lib/libcurses/nc_tparm.h67
-rw-r--r--lib/libcurses/ncurses_cfg.h63
-rw-r--r--lib/libcurses/ncurses_def.h250
-rw-r--r--lib/libcurses/parametrized.h91
-rw-r--r--lib/libcurses/resizeterm.363
-rw-r--r--lib/libcurses/shlib_version2
-rw-r--r--lib/libcurses/term.5tbl113
-rw-r--r--lib/libcurses/term.729
-rw-r--r--lib/libcurses/term.h123
-rw-r--r--lib/libcurses/term_entry.h26
-rw-r--r--lib/libcurses/termcap.372
-rw-r--r--lib/libcurses/termcap.h16
-rw-r--r--lib/libcurses/terminfo.3238
-rw-r--r--lib/libcurses/terminfo.5tbl1336
-rw-r--r--lib/libcurses/tic.h117
-rw-r--r--lib/libcurses/tinfo/MKcaptab.awk161
-rw-r--r--lib/libcurses/tinfo/MKcaptab.sh150
-rw-r--r--lib/libcurses/tinfo/MKcodes.awk165
-rw-r--r--lib/libcurses/tinfo/MKfallback.sh32
-rw-r--r--lib/libcurses/tinfo/MKkeys_list.sh63
-rw-r--r--lib/libcurses/tinfo/MKnames.awk256
-rw-r--r--lib/libcurses/tinfo/access.c114
-rw-r--r--lib/libcurses/tinfo/add_tries.c41
-rw-r--r--lib/libcurses/tinfo/alloc_entry.c182
-rw-r--r--lib/libcurses/tinfo/alloc_ttype.c61
-rw-r--r--lib/libcurses/tinfo/captoinfo.c85
-rw-r--r--lib/libcurses/tinfo/comp_error.c53
-rw-r--r--lib/libcurses/tinfo/comp_expand.c37
-rw-r--r--lib/libcurses/tinfo/comp_hash.c398
-rw-r--r--lib/libcurses/tinfo/comp_parse.c214
-rw-r--r--lib/libcurses/tinfo/comp_scan.c619
-rw-r--r--lib/libcurses/tinfo/db_iterator.c227
-rw-r--r--lib/libcurses/tinfo/doalloc.c8
-rw-r--r--lib/libcurses/tinfo/entries.c147
-rw-r--r--lib/libcurses/tinfo/free_ttype.c17
-rw-r--r--lib/libcurses/tinfo/getenv_num.c4
-rw-r--r--lib/libcurses/tinfo/hashed_db.c262
-rw-r--r--lib/libcurses/tinfo/home_terminfo.c34
-rw-r--r--lib/libcurses/tinfo/init_keytry.c65
-rw-r--r--lib/libcurses/tinfo/keys.list159
-rw-r--r--lib/libcurses/tinfo/lib_acs.c195
-rw-r--r--lib/libcurses/tinfo/lib_baudrate.c82
-rw-r--r--lib/libcurses/tinfo/lib_cur_term.c55
-rw-r--r--lib/libcurses/tinfo/lib_data.c265
-rw-r--r--lib/libcurses/tinfo/lib_has_cap.c7
-rw-r--r--lib/libcurses/tinfo/lib_kernel.c46
-rw-r--r--lib/libcurses/tinfo/lib_longname.c4
-rw-r--r--lib/libcurses/tinfo/lib_napms.c45
-rw-r--r--lib/libcurses/tinfo/lib_options.c210
-rw-r--r--lib/libcurses/tinfo/lib_print.c12
-rw-r--r--lib/libcurses/tinfo/lib_raw.c236
-rw-r--r--lib/libcurses/tinfo/lib_setup.c489
-rw-r--r--lib/libcurses/tinfo/lib_termcap.c154
-rw-r--r--lib/libcurses/tinfo/lib_termname.c21
-rw-r--r--lib/libcurses/tinfo/lib_tgoto.c25
-rw-r--r--lib/libcurses/tinfo/lib_ti.c12
-rw-r--r--lib/libcurses/tinfo/lib_tparm.c592
-rw-r--r--lib/libcurses/tinfo/lib_tputs.c131
-rw-r--r--lib/libcurses/tinfo/lib_ttyflags.c164
-rw-r--r--lib/libcurses/tinfo/make_keys.c28
-rw-r--r--lib/libcurses/tinfo/name_match.c40
-rw-r--r--lib/libcurses/tinfo/parse_entry.c120
-rw-r--r--lib/libcurses/tinfo/read_bsd_terminfo.c13
-rw-r--r--lib/libcurses/tinfo/read_entry.c463
-rw-r--r--lib/libcurses/tinfo/read_termcap.c235
-rw-r--r--lib/libcurses/tinfo/setbuf.c60
-rw-r--r--lib/libcurses/tinfo/strings.c27
-rw-r--r--lib/libcurses/tinfo/trim_sgr0.c328
-rw-r--r--lib/libcurses/tinfo/use_screen.c60
-rw-r--r--lib/libcurses/tinfo/write_entry.c417
-rw-r--r--lib/libcurses/trace/lib_trace.c322
-rw-r--r--lib/libcurses/trace/lib_traceatr.c338
-rw-r--r--lib/libcurses/trace/lib_tracebits.c124
-rw-r--r--lib/libcurses/trace/lib_tracechr.c55
-rw-r--r--lib/libcurses/trace/lib_tracedmp.c157
-rw-r--r--lib/libcurses/trace/lib_tracemse.c129
-rw-r--r--lib/libcurses/trace/trace_buf.c106
-rw-r--r--lib/libcurses/trace/trace_tries.c34
-rw-r--r--lib/libcurses/trace/trace_xnames.c4
-rw-r--r--lib/libcurses/trace/varargs.c186
-rw-r--r--lib/libcurses/trace/visbuf.c333
-rw-r--r--lib/libcurses/tty/MKexpanded.sh8
-rw-r--r--lib/libcurses/tty/hardscroll.c52
-rw-r--r--lib/libcurses/tty/hashmap.c102
-rw-r--r--lib/libcurses/tty/lib_mvcur.c304
-rw-r--r--lib/libcurses/tty/lib_tstp.c193
-rw-r--r--lib/libcurses/tty/lib_twait.c308
-rw-r--r--lib/libcurses/tty/lib_vidattr.c97
-rw-r--r--lib/libcurses/tty/tty_display.h13
-rw-r--r--lib/libcurses/tty/tty_input.h4
-rw-r--r--lib/libcurses/tty/tty_update.c827
-rw-r--r--lib/libcurses/unctrl.h12
-rw-r--r--lib/libcurses/wresize.318
-rw-r--r--lib/libform/Makefile7
-rw-r--r--lib/libform/READ.ME33
-rw-r--r--lib/libform/f_trace.c (renamed from lib/libform/frm_adabind.c)65
-rw-r--r--lib/libform/fld_arg.c48
-rw-r--r--lib/libform/fld_attr.c56
-rw-r--r--lib/libform/fld_current.c82
-rw-r--r--lib/libform/fld_def.c360
-rw-r--r--lib/libform/fld_dup.c71
-rw-r--r--lib/libform/fld_ftchoice.c19
-rw-r--r--lib/libform/fld_ftlink.c34
-rw-r--r--lib/libform/fld_info.c59
-rw-r--r--lib/libform/fld_just.c29
-rw-r--r--lib/libform/fld_link.c67
-rw-r--r--lib/libform/fld_max.c24
-rw-r--r--lib/libform/fld_move.c17
-rw-r--r--lib/libform/fld_newftyp.c84
-rw-r--r--lib/libform/fld_opts.c40
-rw-r--r--lib/libform/fld_pad.c25
-rw-r--r--lib/libform/fld_page.c22
-rw-r--r--lib/libform/fld_stat.c22
-rw-r--r--lib/libform/fld_type.c27
-rw-r--r--lib/libform/fld_user.c19
-rw-r--r--lib/libform/form.3tbl100
-rw-r--r--lib/libform/form.h212
-rw-r--r--lib/libform/form.priv.h184
-rw-r--r--lib/libform/form_cursor.319
-rw-r--r--lib/libform/form_data.38
-rw-r--r--lib/libform/form_driver.3121
-rw-r--r--lib/libform/form_field.341
-rw-r--r--lib/libform/form_field_attributes.325
-rw-r--r--lib/libform/form_field_buffer.385
-rw-r--r--lib/libform/form_field_info.323
-rw-r--r--lib/libform/form_field_just.318
-rw-r--r--lib/libform/form_field_new.340
-rw-r--r--lib/libform/form_field_opts.336
-rw-r--r--lib/libform/form_field_userptr.324
-rw-r--r--lib/libform/form_field_validation.331
-rw-r--r--lib/libform/form_fieldtype.372
-rw-r--r--lib/libform/form_hook.334
-rw-r--r--lib/libform/form_new.332
-rw-r--r--lib/libform/form_new_page.318
-rw-r--r--lib/libform/form_opts.326
-rw-r--r--lib/libform/form_page.323
-rw-r--r--lib/libform/form_post.337
-rw-r--r--lib/libform/form_requestname.37
-rw-r--r--lib/libform/form_userptr.324
-rw-r--r--lib/libform/form_win.322
-rw-r--r--lib/libform/frm_cursor.c17
-rw-r--r--lib/libform/frm_data.c116
-rw-r--r--lib/libform/frm_def.c274
-rw-r--r--lib/libform/frm_driver.c3265
-rw-r--r--lib/libform/frm_hook.c62
-rw-r--r--lib/libform/frm_opts.c29
-rw-r--r--lib/libform/frm_page.c36
-rw-r--r--lib/libform/frm_post.c39
-rw-r--r--lib/libform/frm_req_name.c175
-rw-r--r--lib/libform/frm_scale.c24
-rw-r--r--lib/libform/frm_sub.c28
-rw-r--r--lib/libform/frm_user.c17
-rw-r--r--lib/libform/frm_win.c29
-rw-r--r--lib/libform/fty_alnum.c178
-rw-r--r--lib/libform/fty_alpha.c179
-rw-r--r--lib/libform/fty_enum.c251
-rw-r--r--lib/libform/fty_int.c208
-rw-r--r--lib/libform/fty_ipv4.c66
-rw-r--r--lib/libform/fty_num.c283
-rw-r--r--lib/libform/fty_regex.c181
-rw-r--r--lib/libform/shlib_version2
-rw-r--r--lib/libmenu/Makefile4
-rw-r--r--lib/libmenu/READ.ME42
-rw-r--r--lib/libmenu/eti.h12
-rw-r--r--lib/libmenu/m_attribs.c28
-rw-r--r--lib/libmenu/m_cursor.c41
-rw-r--r--lib/libmenu/m_driver.c670
-rw-r--r--lib/libmenu/m_format.c72
-rw-r--r--lib/libmenu/m_global.c429
-rw-r--r--lib/libmenu/m_hook.c28
-rw-r--r--lib/libmenu/m_item_cur.c34
-rw-r--r--lib/libmenu/m_item_nam.c20
-rw-r--r--lib/libmenu/m_item_new.c133
-rw-r--r--lib/libmenu/m_item_opt.c61
-rw-r--r--lib/libmenu/m_item_top.c45
-rw-r--r--lib/libmenu/m_item_use.c18
-rw-r--r--lib/libmenu/m_item_val.c30
-rw-r--r--lib/libmenu/m_item_vis.c27
-rw-r--r--lib/libmenu/m_items.c38
-rw-r--r--lib/libmenu/m_new.c38
-rw-r--r--lib/libmenu/m_opts.c53
-rw-r--r--lib/libmenu/m_pad.c29
-rw-r--r--lib/libmenu/m_pattern.c59
-rw-r--r--lib/libmenu/m_post.c273
-rw-r--r--lib/libmenu/m_req_name.c80
-rw-r--r--lib/libmenu/m_scale.c21
-rw-r--r--lib/libmenu/m_spacing.c43
-rw-r--r--lib/libmenu/m_sub.c24
-rw-r--r--lib/libmenu/m_trace.c (renamed from lib/libmenu/m_adabind.c)62
-rw-r--r--lib/libmenu/m_userptr.c18
-rw-r--r--lib/libmenu/m_win.c24
-rw-r--r--lib/libmenu/menu.3tbl73
-rw-r--r--lib/libmenu/menu.h18
-rw-r--r--lib/libmenu/menu.priv.h44
-rw-r--r--lib/libmenu/menu_attributes.322
-rw-r--r--lib/libmenu/menu_cursor.314
-rw-r--r--lib/libmenu/menu_driver.3105
-rw-r--r--lib/libmenu/menu_format.323
-rw-r--r--lib/libmenu/menu_hook.334
-rw-r--r--lib/libmenu/menu_items.338
-rw-r--r--lib/libmenu/menu_mark.330
-rw-r--r--lib/libmenu/menu_new.325
-rw-r--r--lib/libmenu/menu_opts.328
-rw-r--r--lib/libmenu/menu_pattern.339
-rw-r--r--lib/libmenu/menu_post.324
-rw-r--r--lib/libmenu/menu_requestname.314
-rw-r--r--lib/libmenu/menu_spacing.312
-rw-r--r--lib/libmenu/menu_userptr.324
-rw-r--r--lib/libmenu/menu_win.322
-rw-r--r--lib/libmenu/mf_common.h40
-rw-r--r--lib/libmenu/mitem_current.335
-rw-r--r--lib/libmenu/mitem_name.313
-rw-r--r--lib/libmenu/mitem_new.327
-rw-r--r--lib/libmenu/mitem_opts.326
-rw-r--r--lib/libmenu/mitem_userptr.324
-rw-r--r--lib/libmenu/mitem_value.314
-rw-r--r--lib/libmenu/mitem_visible.34
-rw-r--r--lib/libmenu/shlib_version2
-rw-r--r--lib/libpanel/Makefile4
-rw-r--r--lib/libpanel/p_above.c17
-rw-r--r--lib/libpanel/p_below.c17
-rw-r--r--lib/libpanel/p_bottom.c50
-rw-r--r--lib/libpanel/p_delete.c17
-rw-r--r--lib/libpanel/p_hidden.c17
-rw-r--r--lib/libpanel/p_hide.c21
-rw-r--r--lib/libpanel/p_move.c26
-rw-r--r--lib/libpanel/p_new.c65
-rw-r--r--lib/libpanel/p_replace.c29
-rw-r--r--lib/libpanel/p_show.c32
-rw-r--r--lib/libpanel/p_top.c11
-rw-r--r--lib/libpanel/p_update.c15
-rw-r--r--lib/libpanel/p_user.c24
-rw-r--r--lib/libpanel/p_win.c15
-rw-r--r--lib/libpanel/panel.352
-rw-r--r--lib/libpanel/panel.c91
-rw-r--r--lib/libpanel/panel.h12
-rw-r--r--lib/libpanel/panel.priv.h46
-rw-r--r--lib/libpanel/shlib_version2
387 files changed, 28213 insertions, 14963 deletions
diff --git a/lib/libcurses/Caps b/lib/libcurses/Caps
index 4e415b489e8..b24520ba66c 100644
--- a/lib/libcurses/Caps
+++ b/lib/libcurses/Caps
@@ -1,5 +1,7 @@
+# $OpenBSD: Caps,v 1.6 2010/01/12 23:21:58 nicm Exp $
+
##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -29,8 +31,7 @@
# Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995
# and: Eric S. Raymond <esr@snark.thyrsus.com>
#
-# $OpenBSD: Caps,v 1.5 2000/10/22 18:27:18 millert Exp $
-# $From: Caps,v 1.30 2000/10/14 17:36:14 tom Exp $
+# $Id: Caps,v 1.6 2010/01/12 23:21:58 nicm Exp $
#
# This is the master termcap/terminfo capability table.
#
@@ -50,11 +51,13 @@
# Column 2: terminfo capability name
# Column 3: capability type (boolean, numeric, or string)
# Column 4: termcap capability name
-# Column 5: Lead with `Y' if capability should be emitted in termcap
+# Column 5: KEY_xxx name, if any, `-' otherwise
+# Column 6: value for KEY_xxx name, if any, `-' otherwise
+# Column 7: Lead with `Y' if capability should be emitted in termcap
# translations, `-' otherwise
-# Column 6: capability description
+# Column 8: capability description
#
-# The codes following [Y-] in column 5 describe the versions of termcap which
+# The codes following [Y-] in column 7 describe the versions of termcap which
# use the given capability. This information is not used by the curses library
# proper; rather, it's there to help the terminfo maintainer avoid emitting
# termcap entry translations that are more than 1023 bytes long (and tank a
@@ -68,7 +71,7 @@
# translation if possible. The problem is that preserving all such caps may
# lead to some termcap translations being too long. The termcap maintainer
# has a bit of a juggling act to do...potential problem cases are marked with
-# a * or **.
+# an asterisk (*).
#
# The aliases section has the following format:
#
@@ -208,43 +211,43 @@
#%lw25 lw6 lw2 lw20.
#%\fBVariable Cap- TCap Description\fR
#%\fBBooleans name Code\fR
-auto_left_margin bw bool bw YB-G- cub1 wraps from column 0 to last column
-auto_right_margin am bool am YBCGE terminal has automatic margins
-no_esc_ctlc xsb bool xb YBCG- beehive (f1=escape, f2=ctrl C)
-ceol_standout_glitch xhp bool xs YBCGE standout not erased by overwriting (hp)
-eat_newline_glitch xenl bool xn YBCGE newline ignored after 80 cols (concept)
-erase_overstrike eo bool eo YBCG- can erase overstrikes with a blank
-generic_type gn bool gn YB-G- generic line type
-hard_copy hc bool hc YBCG- hardcopy terminal
-has_meta_key km bool km YB-GE Has a meta key (i.e., sets 8th-bit)
-has_status_line hs bool hs YB-G- has extra status line
-insert_null_glitch in bool in YBCGE insert mode distinguishes nulls
-memory_above da bool da YBCG- display may be retained above the screen
-memory_below db bool db YB-GE display may be retained below the screen
-move_insert_mode mir bool mi YBCGE safe to move while in insert mode
-move_standout_mode msgr bool ms YBCGE safe to move while in standout mode
-over_strike os bool os YBCG- terminal can overstrike
-status_line_esc_ok eslok bool es YB-G- escape can be used on the status line
-dest_tabs_magic_smso xt bool xt YBCGE tabs destructive, magic so char (t1061)
-tilde_glitch hz bool hz YB-GE can't print ~'s (hazeltine)
-transparent_underline ul bool ul YBCGE underline character overstrikes
-xon_xoff xon bool xo YB--- terminal uses xon/xoff handshaking
-needs_xon_xoff nxon bool nx ----- padding won't work, xon/xoff required
-prtr_silent mc5i bool 5i ----- printer won't echo on screen
-hard_cursor chts bool HC ----- cursor is hard to see
-non_rev_rmcup nrrmc bool NR ----- smcup does not reverse rmcup
-no_pad_char npc bool NP ----- pad character does not exist
-non_dest_scroll_region ndscr bool ND ----- scrolling region is non-destructive
-can_change ccc bool cc ----- terminal can re-define existing colors
-back_color_erase bce bool ut ----- screen erased with background color
-hue_lightness_saturation hls bool hl ----- terminal uses only HLS color notation (Tektronix)
-col_addr_glitch xhpa bool YA ----- only positive motion for hpa/mhpa caps
-cr_cancels_micro_mode crxm bool YB ----- using cr turns off micro mode
-has_print_wheel daisy bool YC ----- printer needs operator to change character set
-row_addr_glitch xvpa bool YD ----- only positive motion for vpa/mvpa caps
-semi_auto_right_margin sam bool YE ----- printing in last column causes cr
-cpi_changes_res cpix bool YF ----- changing character pitch changes resolution
-lpi_changes_res lpix bool YG ----- changing line pitch changes resolution
+auto_left_margin bw bool bw - - YB-G- cub1 wraps from column 0 to last column
+auto_right_margin am bool am - - YBCGE terminal has automatic margins
+no_esc_ctlc xsb bool xb - - YBCG- beehive (f1=escape, f2=ctrl C)
+ceol_standout_glitch xhp bool xs - - YBCGE standout not erased by overwriting (hp)
+eat_newline_glitch xenl bool xn - - YBCGE newline ignored after 80 cols (concept)
+erase_overstrike eo bool eo - - YBCG- can erase overstrikes with a blank
+generic_type gn bool gn - - YB-G- generic line type
+hard_copy hc bool hc - - YBCG- hardcopy terminal
+has_meta_key km bool km - - YB-GE Has a meta key (i.e., sets 8th-bit)
+has_status_line hs bool hs - - YB-G- has extra status line
+insert_null_glitch in bool in - - YBCGE insert mode distinguishes nulls
+memory_above da bool da - - YBCG- display may be retained above the screen
+memory_below db bool db - - YB-GE display may be retained below the screen
+move_insert_mode mir bool mi - - YBCGE safe to move while in insert mode
+move_standout_mode msgr bool ms - - YBCGE safe to move while in standout mode
+over_strike os bool os - - YBCG- terminal can overstrike
+status_line_esc_ok eslok bool es - - YB-G- escape can be used on the status line
+dest_tabs_magic_smso xt bool xt - - YBCGE tabs destructive, magic so char (t1061)
+tilde_glitch hz bool hz - - YB-GE cannot print ~'s (hazeltine)
+transparent_underline ul bool ul - - YBCGE underline character overstrikes
+xon_xoff xon bool xo - - YB--- terminal uses xon/xoff handshaking
+needs_xon_xoff nxon bool nx - - ----- padding will not work, xon/xoff required
+prtr_silent mc5i bool 5i - - ----- printer will not echo on screen
+hard_cursor chts bool HC - - ----- cursor is hard to see
+non_rev_rmcup nrrmc bool NR - - ----- smcup does not reverse rmcup
+no_pad_char npc bool NP - - ----- pad character does not exist
+non_dest_scroll_region ndscr bool ND - - ----- scrolling region is non-destructive
+can_change ccc bool cc - - ----- terminal can re-define existing colors
+back_color_erase bce bool ut - - ----- screen erased with background color
+hue_lightness_saturation hls bool hl - - ----- terminal uses only HLS color notation (Tektronix)
+col_addr_glitch xhpa bool YA - - ----- only positive motion for hpa/mhpa caps
+cr_cancels_micro_mode crxm bool YB - - ----- using cr turns off micro mode
+has_print_wheel daisy bool YC - - ----- printer needs operator to change character set
+row_addr_glitch xvpa bool YD - - ----- only positive motion for vpa/mvpa caps
+semi_auto_right_margin sam bool YE - - ----- printing in last column causes cr
+cpi_changes_res cpix bool YF - - ----- changing character pitch changes resolution
+lpi_changes_res lpix bool YG - - ----- changing line pitch changes resolution
#%.TE
#%.ad
#%
@@ -258,23 +261,23 @@ lpi_changes_res lpix bool YG ----- changing line pitch changes resolution
#%lw25 lw6 lw2 lw20.
#%\fBVariable Cap- TCap Description\fR
#%\fBNumeric name Code\fR
-columns cols num co YBCGE number of columns in a line
-init_tabs it num it YB-G- tabs initially every # spaces
-lines lines num li YBCGE number of lines on screen or page
-lines_of_memory lm num lm YB-G- lines of memory if > line. 0 means varies
-magic_cookie_glitch xmc num sg YBCGE number of blank characters left by smso or rmso
-padding_baud_rate pb num pb YB-GE lowest baud rate where padding needed
-virtual_terminal vt num vt YB--- virtual terminal number (CB/unix)
-width_status_line wsl num ws YB-G- number of columns in status line
-num_labels nlab num Nl ----- number of labels on screen
-label_height lh num lh ----- rows in each label
-label_width lw num lw ----- columns in each label
-max_attributes ma num ma YBC-- maximum combined attributes terminal can handle
-maximum_windows wnum num MW ----- maximum number of defineable windows
+columns cols num co - - YBCGE number of columns in a line
+init_tabs it num it - - YB-G- tabs initially every # spaces
+lines lines num li - - YBCGE number of lines on screen or page
+lines_of_memory lm num lm - - YB-G- lines of memory if > line. 0 means varies
+magic_cookie_glitch xmc num sg - - YBCGE number of blank characters left by smso or rmso
+padding_baud_rate pb num pb - - YB-GE lowest baud rate where padding needed
+virtual_terminal vt num vt - - YB--- virtual terminal number (CB/unix)
+width_status_line wsl num ws - - YB-G- number of columns in status line
+num_labels nlab num Nl - - ----- number of labels on screen
+label_height lh num lh - - ----- rows in each label
+label_width lw num lw - - ----- columns in each label
+max_attributes ma num ma - - YBC-- maximum combined attributes terminal can handle
+maximum_windows wnum num MW - - ----- maximum number of defineable windows
# These came in with SVr4's color support
-max_colors colors num Co ----- maximum number of colors on screen
-max_pairs pairs num pa ----- maximum number of color-pairs on the screen
-no_color_video ncv num NC ----- video attributes that can't be used with colors
+max_colors colors num Co - - ----- maximum number of colors on screen
+max_pairs pairs num pa - - ----- maximum number of color-pairs on the screen
+no_color_video ncv num NC - - ----- video attributes that cannot be used with colors
#%.TE
#%.ad
#%
@@ -290,23 +293,23 @@ no_color_video ncv num NC ----- video attributes that can't be used with color
#%lw25 lw6 lw2 lw20.
#%\fBVariable Cap- TCap Description\fR
#%\fBNumeric name Code\fR
-buffer_capacity bufsz num Ya ----- numbers of bytes buffered before printing
-dot_vert_spacing spinv num Yb ----- spacing of pins vertically in pins per inch
-dot_horz_spacing spinh num Yc ----- spacing of dots horizontally in dots per inch
-max_micro_address maddr num Yd ----- maximum value in micro_..._address
-max_micro_jump mjump num Ye ----- maximum value in parm_..._micro
-micro_col_size mcs num Yf ----- character step size when in micro mode
-micro_line_size mls num Yg ----- line step size when in micro mode
-number_of_pins npins num Yh ----- numbers of pins in print-head
-output_res_char orc num Yi ----- horizontal resolution in units per line
-output_res_line orl num Yj ----- vertical resolution in units per line
-output_res_horz_inch orhi num Yk ----- horizontal resolution in units per inch
-output_res_vert_inch orvi num Yl ----- vertical resolution in units per inch
-print_rate cps num Ym ----- print rate in characters per second
-wide_char_size widcs num Yn ----- character step size when in double wide mode
-buttons btns num BT ----- number of buttons on mouse
-bit_image_entwining bitwin num Yo ----- number of passes for each bit-image row
-bit_image_type bitype num Yp ----- type of bit-image device
+buffer_capacity bufsz num Ya - - ----- numbers of bytes buffered before printing
+dot_vert_spacing spinv num Yb - - ----- spacing of pins vertically in pins per inch
+dot_horz_spacing spinh num Yc - - ----- spacing of dots horizontally in dots per inch
+max_micro_address maddr num Yd - - ----- maximum value in micro_..._address
+max_micro_jump mjump num Ye - - ----- maximum value in parm_..._micro
+micro_col_size mcs num Yf - - ----- character step size when in micro mode
+micro_line_size mls num Yg - - ----- line step size when in micro mode
+number_of_pins npins num Yh - - ----- numbers of pins in print-head
+output_res_char orc num Yi - - ----- horizontal resolution in units per line
+output_res_line orl num Yj - - ----- vertical resolution in units per line
+output_res_horz_inch orhi num Yk - - ----- horizontal resolution in units per inch
+output_res_vert_inch orvi num Yl - - ----- vertical resolution in units per inch
+print_rate cps num Ym - - ----- print rate in characters per second
+wide_char_size widcs num Yn - - ----- character step size when in double wide mode
+buttons btns num BT - - ----- number of buttons on mouse
+bit_image_entwining bitwin num Yo - - ----- number of passes for each bit-image row
+bit_image_type bitype num Yp - - ----- type of bit-image device
#%.TE
#%.ad
#%
@@ -320,370 +323,370 @@ bit_image_type bitype num Yp ----- type of bit-image device
#%lw25 lw6 lw2 lw20.
#%\fBVariable Cap- TCap Description\fR
#%\fBString name Code\fR
-back_tab cbt str bt YBCGE back tab (P)
-bell bel str bl YB-GE audible signal (bell) (P)
-carriage_return cr str cr YBCGE carriage return (P*) (P*)
-change_scroll_region csr str cs YBCGE change region to line #1 to line #2 (P)
-clear_all_tabs tbc str ct YB-G- clear all tab stops (P)
-clear_screen clear str cl YBCGE clear screen and home cursor (P*)
-clr_eol el str ce YBCGE clear to end of line (P)
-clr_eos ed str cd YBCGE clear to end of screen (P*)
-column_address hpa str ch -B-GE** horizontal position #1, absolute (P)
-command_character cmdch str CC YB-G- terminal settable cmd character in prototype !?
-cursor_address cup str cm YBCGE move to row #1 columns #2
-cursor_down cud1 str do YBCGE down one line
-cursor_home home str ho YBCGE home cursor (if no cup)
-cursor_invisible civis str vi YB-G- make cursor invisible
-cursor_left cub1 str le YBCGE move left one space
-cursor_mem_address mrcup str CM YB-G- memory relative cursor addressing, move to row #1 columns #2
-cursor_normal cnorm str ve YBCGE make cursor appear normal (undo civis/cvvis)
-cursor_right cuf1 str nd YBCGE non-destructive space (move right one space)
-cursor_to_ll ll str ll YBCGE last line, first column (if no cup)
-cursor_up cuu1 str up YBCGE up one line
-cursor_visible cvvis str vs YBCGE make cursor very visible
-delete_character dch1 str dc YBCGE delete character (P*)
-delete_line dl1 str dl YBCGE delete line (P*)
-dis_status_line dsl str ds YB-G- disable status line
-down_half_line hd str hd YB-G- half a line down
-enter_alt_charset_mode smacs str as YB-G- start alternate character set (P)
-enter_blink_mode blink str mb YB-G- turn on blinking
-enter_bold_mode bold str md YB-G- turn on bold (extra bright) mode
-enter_ca_mode smcup str ti YBCGE string to start programs using cup
-enter_delete_mode smdc str dm YBCGE enter delete mode
-enter_dim_mode dim str mh YB-G- turn on half-bright mode
-enter_insert_mode smir str im YBCGE enter insert mode
-enter_secure_mode invis str mk -B-G-* turn on blank mode (characters invisible)
-enter_protected_mode prot str mp -B-G-* turn on protected mode
-enter_reverse_mode rev str mr YB-G- turn on reverse video mode
-enter_standout_mode smso str so YBCGE begin standout mode
-enter_underline_mode smul str us YBCGE begin underline mode
-erase_chars ech str ec YB-G- erase #1 characters (P)
-exit_alt_charset_mode rmacs str ae YB-G- end alternate character set (P)
-exit_attribute_mode sgr0 str me YB-GE turn off all attributes
-exit_ca_mode rmcup str te YBCGE strings to end programs using cup
-exit_delete_mode rmdc str ed YBCGE end delete mode
-exit_insert_mode rmir str ei YBCGE exit insert mode
-exit_standout_mode rmso str se YBCGE exit standout mode
-exit_underline_mode rmul str ue YBCGE exit underline mode
-flash_screen flash str vb YBCGE visible bell (may not move cursor)
-form_feed ff str ff YB-G- hardcopy terminal page eject (P*)
-from_status_line fsl str fs YB-G- return from status line
-init_1string is1 str i1 YB-G- initialization string
-init_2string is2 str is YB-G- initialization string
-init_3string is3 str i3 YB-G- initialization string
-init_file if str if YB-G- name of initialization file
-insert_character ich1 str ic YBCGE insert character (P)
-insert_line il1 str al YBCGE insert line (P*)
-insert_padding ip str ip YBCGE insert padding after inserted character
-key_backspace kbs str kb YB-G- backspace key
-key_catab ktbc str ka -B-G-* clear-all-tabs key
-key_clear kclr str kC -B-G-* clear-screen or erase key
-key_ctab kctab str kt -B-G-* clear-tab key
-key_dc kdch1 str kD YB-G- delete-character key
-key_dl kdl1 str kL -B-G-* delete-line key
-key_down kcud1 str kd YBCGE down-arrow key
-key_eic krmir str kM -B-G-* sent by rmir or smir in insert mode
-key_eol kel str kE -B-G-* clear-to-end-of-line key
-key_eos ked str kS -B-G-* clear-to-end-of-screen key
-key_f0 kf0 str k0 YBCGE F0 function key
-key_f1 kf1 str k1 YBCGE F1 function key
-key_f10 kf10 str k; ----E F10 function key
-key_f2 kf2 str k2 YBCGE F2 function key
-key_f3 kf3 str k3 YBCGE F3 function key
-key_f4 kf4 str k4 YBCGE F4 function key
-key_f5 kf5 str k5 YBCGE F5 function key
-key_f6 kf6 str k6 YBCGE F6 function key
-key_f7 kf7 str k7 YBCGE F7 function key
-key_f8 kf8 str k8 YBCGE F8 function key
-key_f9 kf9 str k9 YBCGE F9 function key
-key_home khome str kh YBCGE home key
-key_ic kich1 str kI YB-GE insert-character key
-key_il kil1 str kA -B-G-* insert-line key
-key_left kcub1 str kl YBCGE left-arrow key
-key_ll kll str kH YB-G- lower-left key (home down)
-key_npage knp str kN YB-GE next-page key
-key_ppage kpp str kP YB-GE previous-page key
-key_right kcuf1 str kr YBCGE right-arrow key
-key_sf kind str kF -B-G-* scroll-forward key
-key_sr kri str kR -B-G-* scroll-backward key
-key_stab khts str kT -B-G-* set-tab key
-key_up kcuu1 str ku YBCGE up-arrow key
-keypad_local rmkx str ke YBCGE leave 'keyboard_transmit' mode
-keypad_xmit smkx str ks YBCGE enter 'keyboard_transmit' mode
-lab_f0 lf0 str l0 -B-G-* label on function key f0 if not f0
-lab_f1 lf1 str l1 -B-G-* label on function key f1 if not f1
-lab_f10 lf10 str la ----- label on function key f10 if not f10
-lab_f2 lf2 str l2 -B-G-* label on function key f2 if not f2
-lab_f3 lf3 str l3 -B-G-* label on function key f3 if not f3
-lab_f4 lf4 str l4 -B-G-* label on function key f4 if not f4
-lab_f5 lf5 str l5 -B-G-* label on function key f5 if not f5
-lab_f6 lf6 str l6 -B-G-* label on function key f6 if not f6
-lab_f7 lf7 str l7 -B-G-* label on function key f7 if not f7
-lab_f8 lf8 str l8 -B-G-* label on function key f8 if not f8
-lab_f9 lf9 str l9 -B-G-* label on function key f9 if not f9
-meta_off rmm str mo YB-G-* turn off meta mode
-meta_on smm str mm YB-G-* turn on meta mode (8th-bit on)
-newline nel str nw YB-G-* newline (behave like cr followed by lf)
-pad_char pad str pc YBCGE padding char (instead of null)
-parm_dch dch str DC YB-GE delete #1 characters (P*)
-parm_delete_line dl str DL YBCGE delete #1 lines (P*)
-parm_down_cursor cud str DO YBCGE down #1 lines (P*)
-parm_ich ich str IC YB-GE insert #1 characters (P*)
-parm_index indn str SF YBCG- scroll forward #1 lines (P)
-parm_insert_line il str AL YBCGE insert #1 lines (P*)
-parm_left_cursor cub str LE YBCGE move #1 characters to the left (P)
-parm_right_cursor cuf str RI YBCGE move #1 characters to the right (P*)
-parm_rindex rin str SR YBCG- scroll back #1 lines (P)
-parm_up_cursor cuu str UP YBCGE up #1 lines (P*)
-pkey_key pfkey str pk -B--- program function key #1 to type string #2
-pkey_local pfloc str pl -B--- program function key #1 to execute string #2
-pkey_xmit pfx str px -B--- program function key #1 to transmit string #2
-print_screen mc0 str ps -B-G-* print contents of screen
-prtr_off mc4 str pf -B-G-* turn off printer
-prtr_on mc5 str po -B-G-* turn on printer
-repeat_char rep str rp YB-GE repeat char #1 #2 times (P*)
-reset_1string rs1 str r1 -B--- reset string
-reset_2string rs2 str r2 -B--- reset string
-reset_3string rs3 str r3 -B--- reset string
-reset_file rf str rf -B--- name of reset file
-restore_cursor rc str rc YBCG- restore cursor to position of last save_cursor
-row_address vpa str cv -B-GE** vertical position #1 absolute (P)
-save_cursor sc str sc YBCG- save current cursor position (P)
-scroll_forward ind str sf YBCGE scroll text up (P)
-scroll_reverse ri str sr YBCGE scroll text down (P)
-set_attributes sgr str sa YB-G- define video attributes #1-#9 (PG9)
-set_tab hts str st YB-G- set a tab in every row, current columns
-set_window wind str wi -B-GE current window is lines #1-#2 cols #3-#4
-tab ht str ta YBCGE tab to next 8-space hardware tab stop
-to_status_line tsl str ts YB-G- move to status line, column #1
-underline_char uc str uc YBCG- underline char and move past it
-up_half_line hu str hu YB-G- half a line up
-init_prog iprog str iP -B--- path name of program for initialization
-key_a1 ka1 str K1 YB-GE upper left of keypad
-key_a3 ka3 str K3 YB-GE upper right of keypad
-key_b2 kb2 str K2 YB-GE center of keypad
-key_c1 kc1 str K4 YB-GE lower left of keypad
-key_c3 kc3 str K5 YB-GE lower right of keypad
-prtr_non mc5p str pO -B-G-* turn on printer for #1 bytes
+back_tab cbt str bt - - YBCGE back tab (P)
+bell bel str bl - - YB-GE audible signal (bell) (P)
+carriage_return cr str cr - - YBCGE carriage return (P*) (P*)
+change_scroll_region csr str cs - - YBCGE change region to line #1 to line #2 (P)
+clear_all_tabs tbc str ct - - YB-G- clear all tab stops (P)
+clear_screen clear str cl - - YBCGE clear screen and home cursor (P*)
+clr_eol el str ce - - YBCGE clear to end of line (P)
+clr_eos ed str cd - - YBCGE clear to end of screen (P*)
+column_address hpa str ch - - -B-GE* horizontal position #1, absolute (P)
+command_character cmdch str CC - - YB-G- terminal settable cmd character in prototype !?
+cursor_address cup str cm - - YBCGE move to row #1 columns #2
+cursor_down cud1 str do - - YBCGE down one line
+cursor_home home str ho - - YBCGE home cursor (if no cup)
+cursor_invisible civis str vi - - YB-G- make cursor invisible
+cursor_left cub1 str le - - YBCGE move left one space
+cursor_mem_address mrcup str CM - - YB-G- memory relative cursor addressing, move to row #1 columns #2
+cursor_normal cnorm str ve - - YBCGE make cursor appear normal (undo civis/cvvis)
+cursor_right cuf1 str nd - - YBCGE non-destructive space (move right one space)
+cursor_to_ll ll str ll - - YBCGE last line, first column (if no cup)
+cursor_up cuu1 str up - - YBCGE up one line
+cursor_visible cvvis str vs - - YBCGE make cursor very visible
+delete_character dch1 str dc - - YBCGE delete character (P*)
+delete_line dl1 str dl - - YBCGE delete line (P*)
+dis_status_line dsl str ds - - YB-G- disable status line
+down_half_line hd str hd - - YB-G- half a line down
+enter_alt_charset_mode smacs str as - - YB-G- start alternate character set (P)
+enter_blink_mode blink str mb - - YB-G- turn on blinking
+enter_bold_mode bold str md - - YB-G- turn on bold (extra bright) mode
+enter_ca_mode smcup str ti - - YBCGE string to start programs using cup
+enter_delete_mode smdc str dm - - YBCGE enter delete mode
+enter_dim_mode dim str mh - - YB-G- turn on half-bright mode
+enter_insert_mode smir str im - - YBCGE enter insert mode
+enter_secure_mode invis str mk - - -B-G-* turn on blank mode (characters invisible)
+enter_protected_mode prot str mp - - -B-G-* turn on protected mode
+enter_reverse_mode rev str mr - - YB-G- turn on reverse video mode
+enter_standout_mode smso str so - - YBCGE begin standout mode
+enter_underline_mode smul str us - - YBCGE begin underline mode
+erase_chars ech str ec - - YB-G- erase #1 characters (P)
+exit_alt_charset_mode rmacs str ae - - YB-G- end alternate character set (P)
+exit_attribute_mode sgr0 str me - - YB-GE turn off all attributes
+exit_ca_mode rmcup str te - - YBCGE strings to end programs using cup
+exit_delete_mode rmdc str ed - - YBCGE end delete mode
+exit_insert_mode rmir str ei - - YBCGE exit insert mode
+exit_standout_mode rmso str se - - YBCGE exit standout mode
+exit_underline_mode rmul str ue - - YBCGE exit underline mode
+flash_screen flash str vb - - YBCGE visible bell (may not move cursor)
+form_feed ff str ff - - YB-G- hardcopy terminal page eject (P*)
+from_status_line fsl str fs - - YB-G- return from status line
+init_1string is1 str i1 - - YB-G- initialization string
+init_2string is2 str is - - YB-G- initialization string
+init_3string is3 str i3 - - YB-G- initialization string
+init_file if str if - - YB-G- name of initialization file
+insert_character ich1 str ic - - YBCGE insert character (P)
+insert_line il1 str al - - YBCGE insert line (P*)
+insert_padding ip str ip - - YBCGE insert padding after inserted character
+key_backspace kbs str kb KEY_BACKSPACE 0407 YB-G- backspace key
+key_catab ktbc str ka KEY_CATAB 0526 -B-G-* clear-all-tabs key
+key_clear kclr str kC KEY_CLEAR 0515 -B-G-* clear-screen or erase key
+key_ctab kctab str kt KEY_CTAB 0525 -B-G-* clear-tab key
+key_dc kdch1 str kD KEY_DC 0512 YB-G- delete-character key
+key_dl kdl1 str kL KEY_DL 0510 -B-G-* delete-line key
+key_down kcud1 str kd KEY_DOWN 0402 YBCGE down-arrow key
+key_eic krmir str kM KEY_EIC 0514 -B-G-* sent by rmir or smir in insert mode
+key_eol kel str kE KEY_EOL 0517 -B-G-* clear-to-end-of-line key
+key_eos ked str kS KEY_EOS 0516 -B-G-* clear-to-end-of-screen key
+key_f0 kf0 str k0 KEY_F(0) 0410 YBCGE F0 function key
+key_f1 kf1 str k1 KEY_F(1) - YBCGE F1 function key
+key_f10 kf10 str k; KEY_F(10) - ----E F10 function key
+key_f2 kf2 str k2 KEY_F(2) - YBCGE F2 function key
+key_f3 kf3 str k3 KEY_F(3) - YBCGE F3 function key
+key_f4 kf4 str k4 KEY_F(4) - YBCGE F4 function key
+key_f5 kf5 str k5 KEY_F(5) - YBCGE F5 function key
+key_f6 kf6 str k6 KEY_F(6) - YBCGE F6 function key
+key_f7 kf7 str k7 KEY_F(7) - YBCGE F7 function key
+key_f8 kf8 str k8 KEY_F(8) - YBCGE F8 function key
+key_f9 kf9 str k9 KEY_F(9) - YBCGE F9 function key
+key_home khome str kh KEY_HOME 0406 YBCGE home key
+key_ic kich1 str kI KEY_IC 0513 YB-GE insert-character key
+key_il kil1 str kA KEY_IL 0511 -B-G-* insert-line key
+key_left kcub1 str kl KEY_LEFT 0404 YBCGE left-arrow key
+key_ll kll str kH KEY_LL 0533 YB-G- lower-left key (home down)
+key_npage knp str kN KEY_NPAGE 0522 YB-GE next-page key
+key_ppage kpp str kP KEY_PPAGE 0523 YB-GE previous-page key
+key_right kcuf1 str kr KEY_RIGHT 0405 YBCGE right-arrow key
+key_sf kind str kF KEY_SF 0520 -B-G-* scroll-forward key
+key_sr kri str kR KEY_SR 0521 -B-G-* scroll-backward key
+key_stab khts str kT KEY_STAB 0524 -B-G-* set-tab key
+key_up kcuu1 str ku KEY_UP 0403 YBCGE up-arrow key
+keypad_local rmkx str ke - - YBCGE leave 'keyboard_transmit' mode
+keypad_xmit smkx str ks - - YBCGE enter 'keyboard_transmit' mode
+lab_f0 lf0 str l0 - - -B-G-* label on function key f0 if not f0
+lab_f1 lf1 str l1 - - -B-G-* label on function key f1 if not f1
+lab_f10 lf10 str la - - ----- label on function key f10 if not f10
+lab_f2 lf2 str l2 - - -B-G-* label on function key f2 if not f2
+lab_f3 lf3 str l3 - - -B-G-* label on function key f3 if not f3
+lab_f4 lf4 str l4 - - -B-G-* label on function key f4 if not f4
+lab_f5 lf5 str l5 - - -B-G-* label on function key f5 if not f5
+lab_f6 lf6 str l6 - - -B-G-* label on function key f6 if not f6
+lab_f7 lf7 str l7 - - -B-G-* label on function key f7 if not f7
+lab_f8 lf8 str l8 - - -B-G-* label on function key f8 if not f8
+lab_f9 lf9 str l9 - - -B-G-* label on function key f9 if not f9
+meta_off rmm str mo - - YB-G-* turn off meta mode
+meta_on smm str mm - - YB-G-* turn on meta mode (8th-bit on)
+newline nel str nw - - YB-G-* newline (behave like cr followed by lf)
+pad_char pad str pc - - YBCGE padding char (instead of null)
+parm_dch dch str DC - - YB-GE delete #1 characters (P*)
+parm_delete_line dl str DL - - YBCGE delete #1 lines (P*)
+parm_down_cursor cud str DO - - YBCGE down #1 lines (P*)
+parm_ich ich str IC - - YB-GE insert #1 characters (P*)
+parm_index indn str SF - - YBCG- scroll forward #1 lines (P)
+parm_insert_line il str AL - - YBCGE insert #1 lines (P*)
+parm_left_cursor cub str LE - - YBCGE move #1 characters to the left (P)
+parm_right_cursor cuf str RI - - YBCGE move #1 characters to the right (P*)
+parm_rindex rin str SR - - YBCG- scroll back #1 lines (P)
+parm_up_cursor cuu str UP - - YBCGE up #1 lines (P*)
+pkey_key pfkey str pk - - -B--- program function key #1 to type string #2
+pkey_local pfloc str pl - - -B--- program function key #1 to execute string #2
+pkey_xmit pfx str px - - -B--- program function key #1 to transmit string #2
+print_screen mc0 str ps - - -B-G-* print contents of screen
+prtr_off mc4 str pf - - -B-G-* turn off printer
+prtr_on mc5 str po - - -B-G-* turn on printer
+repeat_char rep str rp - - YB-GE repeat char #1 #2 times (P*)
+reset_1string rs1 str r1 - - -B--- reset string
+reset_2string rs2 str r2 - - -B--- reset string
+reset_3string rs3 str r3 - - -B--- reset string
+reset_file rf str rf - - -B--- name of reset file
+restore_cursor rc str rc - - YBCG- restore cursor to position of last save_cursor
+row_address vpa str cv - - -B-GE* vertical position #1 absolute (P)
+save_cursor sc str sc - - YBCG- save current cursor position (P)
+scroll_forward ind str sf - - YBCGE scroll text up (P)
+scroll_reverse ri str sr - - YBCGE scroll text down (P)
+set_attributes sgr str sa - - YB-G- define video attributes #1-#9 (PG9)
+set_tab hts str st - - YB-G- set a tab in every row, current columns
+set_window wind str wi - - -B-GE current window is lines #1-#2 cols #3-#4
+tab ht str ta - - YBCGE tab to next 8-space hardware tab stop
+to_status_line tsl str ts - - YB-G- move to status line, column #1
+underline_char uc str uc - - YBCG- underline char and move past it
+up_half_line hu str hu - - YB-G- half a line up
+init_prog iprog str iP - - -B--- path name of program for initialization
+key_a1 ka1 str K1 KEY_A1 0534 YB-GE upper left of keypad
+key_a3 ka3 str K3 KEY_A3 0535 YB-GE upper right of keypad
+key_b2 kb2 str K2 KEY_B2 0536 YB-GE center of keypad
+key_c1 kc1 str K4 KEY_C1 0537 YB-GE lower left of keypad
+key_c3 kc3 str K5 KEY_C3 0540 YB-GE lower right of keypad
+prtr_non mc5p str pO - - -B-G-* turn on printer for #1 bytes
#
# SVr1 capabilities stop here. IBM's version of terminfo is the same as
# SVr4 up to this point, but has a different set afterwards.
#
-char_padding rmp str rP ----- like ip but when in insert mode
-acs_chars acsc str ac ----- graphics charset pairs, based on vt100
-plab_norm pln str pn ----- program label #1 to show string #2
-key_btab kcbt str kB ----- back-tab key
-enter_xon_mode smxon str SX ----- turn on xon/xoff handshaking
-exit_xon_mode rmxon str RX ----- turn off xon/xoff handshaking
-enter_am_mode smam str SA ----- turn on automatic margins
-exit_am_mode rmam str RA ----- turn off automatic margins
-xon_character xonc str XN ----- XON character
-xoff_character xoffc str XF ----- XOFF character
-ena_acs enacs str eA ----- enable alternate char set
-label_on smln str LO ----- turn on soft labels
-label_off rmln str LF ----- turn off soft labels
-key_beg kbeg str @1 ----- begin key
-key_cancel kcan str @2 ----- cancel key
-key_close kclo str @3 ----- close key
-key_command kcmd str @4 ----- command key
-key_copy kcpy str @5 ----- copy key
-key_create kcrt str @6 ----- create key
-key_end kend str @7 ----- end key
-key_enter kent str @8 ----- enter/send key
-key_exit kext str @9 ----- exit key
-key_find kfnd str @0 ----- find key
-key_help khlp str %1 ----- help key
-key_mark kmrk str %2 ----- mark key
-key_message kmsg str %3 ----- message key
-key_move kmov str %4 ----- move key
-key_next knxt str %5 ----- next key
-key_open kopn str %6 ----- open key
-key_options kopt str %7 ----- options key
-key_previous kprv str %8 ----- previous key
-key_print kprt str %9 ----- print key
-key_redo krdo str %0 ----- redo key
-key_reference kref str &1 ----- reference key
-key_refresh krfr str &2 ----- refresh key
-key_replace krpl str &3 ----- replace key
-key_restart krst str &4 ----- restart key
-key_resume kres str &5 ----- resume key
-key_save ksav str &6 ----- save key
-key_suspend kspd str &7 ----- suspend key
-key_undo kund str &8 ----- undo key
-key_sbeg kBEG str &9 ----- shifted begin key
-key_scancel kCAN str &0 ----- shifted cancel key
-key_scommand kCMD str *1 ----- shifted command key
-key_scopy kCPY str *2 ----- shifted copy key
-key_screate kCRT str *3 ----- shifted create key
-key_sdc kDC str *4 ----- shifted delete-character key
-key_sdl kDL str *5 ----- shifted delete-line key
-key_select kslt str *6 ----- select key
-key_send kEND str *7 ----- shifted end key
-key_seol kEOL str *8 ----- shifted clear-to-end-of-line key
-key_sexit kEXT str *9 ----- shifted exit key
-key_sfind kFND str *0 ----- shifted find key
-key_shelp kHLP str #1 ----- shifted help key
-key_shome kHOM str #2 ----- shifted home key
-key_sic kIC str #3 ----- shifted insert-character key
-key_sleft kLFT str #4 ----- shifted left-arrow key
-key_smessage kMSG str %a ----- shifted message key
-key_smove kMOV str %b ----- shifted move key
-key_snext kNXT str %c ----- shifted next key
-key_soptions kOPT str %d ----- shifted options key
-key_sprevious kPRV str %e ----- shifted previous key
-key_sprint kPRT str %f ----- shifted print key
-key_sredo kRDO str %g ----- shifted redo key
-key_sreplace kRPL str %h ----- shifted replace key
-key_sright kRIT str %i ----- shifted right-arrow key
-key_srsume kRES str %j ----- shifted resume key
-key_ssave kSAV str !1 ----- shifted save key
-key_ssuspend kSPD str !2 ----- shifted suspend key
-key_sundo kUND str !3 ----- shifted undo key
-req_for_input rfi str RF ----- send next input char (for ptys)
-key_f11 kf11 str F1 ----E F11 function key
-key_f12 kf12 str F2 ----E F12 function key
-key_f13 kf13 str F3 ----E F13 function key
-key_f14 kf14 str F4 ----E F14 function key
-key_f15 kf15 str F5 ----E F15 function key
-key_f16 kf16 str F6 ----E F16 function key
-key_f17 kf17 str F7 ----E F17 function key
-key_f18 kf18 str F8 ----E F18 function key
-key_f19 kf19 str F9 ----E F19 function key
-key_f20 kf20 str FA ----E F20 function key
-key_f21 kf21 str FB ----E F21 function key
-key_f22 kf22 str FC ----E F22 function key
-key_f23 kf23 str FD ----E F23 function key
-key_f24 kf24 str FE ----E F24 function key
-key_f25 kf25 str FF ----E F25 function key
-key_f26 kf26 str FG ----E F26 function key
-key_f27 kf27 str FH ----E F27 function key
-key_f28 kf28 str FI ----E F28 function key
-key_f29 kf29 str FJ ----E F29 function key
-key_f30 kf30 str FK ----E F30 function key
-key_f31 kf31 str FL ----E F31 function key
-key_f32 kf32 str FM ----E F32 function key
-key_f33 kf33 str FN ----E F33 function key
-key_f34 kf34 str FO ----E F34 function key
-key_f35 kf35 str FP ----E F35 function key
-key_f36 kf36 str FQ ----E F36 function key
-key_f37 kf37 str FR ----E F37 function key
-key_f38 kf38 str FS ----E F38 function key
-key_f39 kf39 str FT ----E F39 function key
-key_f40 kf40 str FU ----E F40 function key
-key_f41 kf41 str FV ----E F41 function key
-key_f42 kf42 str FW ----E F42 function key
-key_f43 kf43 str FX ----E F43 function key
-key_f44 kf44 str FY ----E F44 function key
-key_f45 kf45 str FZ ----E F45 function key
-key_f46 kf46 str Fa ----E F46 function key
-key_f47 kf47 str Fb ----E F47 function key
-key_f48 kf48 str Fc ----E F48 function key
-key_f49 kf49 str Fd ----E F49 function key
-key_f50 kf50 str Fe ----E F50 function key
-key_f51 kf51 str Ff ----E F51 function key
-key_f52 kf52 str Fg ----E F52 function key
-key_f53 kf53 str Fh ----E F53 function key
-key_f54 kf54 str Fi ----E F54 function key
-key_f55 kf55 str Fj ----E F55 function key
-key_f56 kf56 str Fk ----E F56 function key
-key_f57 kf57 str Fl ----E F57 function key
-key_f58 kf58 str Fm ----E F58 function key
-key_f59 kf59 str Fn ----E F59 function key
-key_f60 kf60 str Fo ----E F60 function key
-key_f61 kf61 str Fp ----E F61 function key
-key_f62 kf62 str Fq ----E F62 function key
-key_f63 kf63 str Fr ----E F63 function key
-clr_bol el1 str cb ----- Clear to beginning of line
-clear_margins mgc str MC ----- clear right and left soft margins
-set_left_margin smgl str ML ----- set left soft margin at current column. See smgl. (ML is not in BSD termcap).
-set_right_margin smgr str MR ----- set right soft margin at current column
-label_format fln str Lf ----- label format
-set_clock sclk str SC ----- set clock, #1 hrs #2 mins #3 secs
-display_clock dclk str DK ----- display clock
-remove_clock rmclk str RC ----- remove clock
-create_window cwin str CW ----- define a window #1 from #2,#3 to #4,#5
-goto_window wingo str WG ----- go to window #1
-hangup hup str HU ----- hang-up phone
-dial_phone dial str DI ----- dial number #1
-quick_dial qdial str QD ----- dial number #1 without checking
-tone tone str TO ----- select touch tone dialing
-pulse pulse str PU ----- select pulse dialing
-flash_hook hook str fh ----- flash switch hook
-fixed_pause pause str PA ----- pause for 2-3 seconds
-wait_tone wait str WA ----- wait for dial-tone
-user0 u0 str u0 ----- User string #0
-user1 u1 str u1 ----- User string #1
-user2 u2 str u2 ----- User string #2
-user3 u3 str u3 ----- User string #3
-user4 u4 str u4 ----- User string #4
-user5 u5 str u5 ----- User string #5
-user6 u6 str u6 ----- User string #6
-user7 u7 str u7 ----- User string #7
-user8 u8 str u8 ----- User string #8
-user9 u9 str u9 ----- User string #9
+char_padding rmp str rP - - ----- like ip but when in insert mode
+acs_chars acsc str ac - - ----- graphics charset pairs, based on vt100
+plab_norm pln str pn - - ----- program label #1 to show string #2
+key_btab kcbt str kB KEY_BTAB 0541 ----- back-tab key
+enter_xon_mode smxon str SX - - ----- turn on xon/xoff handshaking
+exit_xon_mode rmxon str RX - - ----- turn off xon/xoff handshaking
+enter_am_mode smam str SA - - ----- turn on automatic margins
+exit_am_mode rmam str RA - - ----- turn off automatic margins
+xon_character xonc str XN - - ----- XON character
+xoff_character xoffc str XF - - ----- XOFF character
+ena_acs enacs str eA - - ----- enable alternate char set
+label_on smln str LO - - ----- turn on soft labels
+label_off rmln str LF - - ----- turn off soft labels
+key_beg kbeg str @1 KEY_BEG 0542 ----- begin key
+key_cancel kcan str @2 KEY_CANCEL 0543 ----- cancel key
+key_close kclo str @3 KEY_CLOSE 0544 ----- close key
+key_command kcmd str @4 KEY_COMMAND 0545 ----- command key
+key_copy kcpy str @5 KEY_COPY 0546 ----- copy key
+key_create kcrt str @6 KEY_CREATE 0547 ----- create key
+key_end kend str @7 KEY_END 0550 ----- end key
+key_enter kent str @8 KEY_ENTER 0527 ----- enter/send key
+key_exit kext str @9 KEY_EXIT 0551 ----- exit key
+key_find kfnd str @0 KEY_FIND 0552 ----- find key
+key_help khlp str %1 KEY_HELP 0553 ----- help key
+key_mark kmrk str %2 KEY_MARK 0554 ----- mark key
+key_message kmsg str %3 KEY_MESSAGE 0555 ----- message key
+key_move kmov str %4 KEY_MOVE 0556 ----- move key
+key_next knxt str %5 KEY_NEXT 0557 ----- next key
+key_open kopn str %6 KEY_OPEN 0560 ----- open key
+key_options kopt str %7 KEY_OPTIONS 0561 ----- options key
+key_previous kprv str %8 KEY_PREVIOUS 0562 ----- previous key
+key_print kprt str %9 KEY_PRINT 0532 ----- print key
+key_redo krdo str %0 KEY_REDO 0563 ----- redo key
+key_reference kref str &1 KEY_REFERENCE 0564 ----- reference key
+key_refresh krfr str &2 KEY_REFRESH 0565 ----- refresh key
+key_replace krpl str &3 KEY_REPLACE 0566 ----- replace key
+key_restart krst str &4 KEY_RESTART 0567 ----- restart key
+key_resume kres str &5 KEY_RESUME 0570 ----- resume key
+key_save ksav str &6 KEY_SAVE 0571 ----- save key
+key_suspend kspd str &7 KEY_SUSPEND 0627 ----- suspend key
+key_undo kund str &8 KEY_UNDO 0630 ----- undo key
+key_sbeg kBEG str &9 KEY_SBEG 0572 ----- shifted begin key
+key_scancel kCAN str &0 KEY_SCANCEL 0573 ----- shifted cancel key
+key_scommand kCMD str *1 KEY_SCOMMAND 0574 ----- shifted command key
+key_scopy kCPY str *2 KEY_SCOPY 0575 ----- shifted copy key
+key_screate kCRT str *3 KEY_SCREATE 0576 ----- shifted create key
+key_sdc kDC str *4 KEY_SDC 0577 ----- shifted delete-character key
+key_sdl kDL str *5 KEY_SDL 0600 ----- shifted delete-line key
+key_select kslt str *6 KEY_SELECT 0601 ----- select key
+key_send kEND str *7 KEY_SEND 0602 ----- shifted end key
+key_seol kEOL str *8 KEY_SEOL 0603 ----- shifted clear-to-end-of-line key
+key_sexit kEXT str *9 KEY_SEXIT 0604 ----- shifted exit key
+key_sfind kFND str *0 KEY_SFIND 0605 ----- shifted find key
+key_shelp kHLP str #1 KEY_SHELP 0606 ----- shifted help key
+key_shome kHOM str #2 KEY_SHOME 0607 ----- shifted home key
+key_sic kIC str #3 KEY_SIC 0610 ----- shifted insert-character key
+key_sleft kLFT str #4 KEY_SLEFT 0611 ----- shifted left-arrow key
+key_smessage kMSG str %a KEY_SMESSAGE 0612 ----- shifted message key
+key_smove kMOV str %b KEY_SMOVE 0613 ----- shifted move key
+key_snext kNXT str %c KEY_SNEXT 0614 ----- shifted next key
+key_soptions kOPT str %d KEY_SOPTIONS 0615 ----- shifted options key
+key_sprevious kPRV str %e KEY_SPREVIOUS 0616 ----- shifted previous key
+key_sprint kPRT str %f KEY_SPRINT 0617 ----- shifted print key
+key_sredo kRDO str %g KEY_SREDO 0620 ----- shifted redo key
+key_sreplace kRPL str %h KEY_SREPLACE 0621 ----- shifted replace key
+key_sright kRIT str %i KEY_SRIGHT 0622 ----- shifted right-arrow key
+key_srsume kRES str %j KEY_SRSUME 0623 ----- shifted resume key
+key_ssave kSAV str !1 KEY_SSAVE 0624 ----- shifted save key
+key_ssuspend kSPD str !2 KEY_SSUSPEND 0625 ----- shifted suspend key
+key_sundo kUND str !3 KEY_SUNDO 0626 ----- shifted undo key
+req_for_input rfi str RF - - ----- send next input char (for ptys)
+key_f11 kf11 str F1 KEY_F(11) - ----E F11 function key
+key_f12 kf12 str F2 KEY_F(12) - ----E F12 function key
+key_f13 kf13 str F3 KEY_F(13) - ----E F13 function key
+key_f14 kf14 str F4 KEY_F(14) - ----E F14 function key
+key_f15 kf15 str F5 KEY_F(15) - ----E F15 function key
+key_f16 kf16 str F6 KEY_F(16) - ----E F16 function key
+key_f17 kf17 str F7 KEY_F(17) - ----E F17 function key
+key_f18 kf18 str F8 KEY_F(18) - ----E F18 function key
+key_f19 kf19 str F9 KEY_F(19) - ----E F19 function key
+key_f20 kf20 str FA KEY_F(20) - ----E F20 function key
+key_f21 kf21 str FB KEY_F(21) - ----E F21 function key
+key_f22 kf22 str FC KEY_F(22) - ----E F22 function key
+key_f23 kf23 str FD KEY_F(23) - ----E F23 function key
+key_f24 kf24 str FE KEY_F(24) - ----E F24 function key
+key_f25 kf25 str FF KEY_F(25) - ----E F25 function key
+key_f26 kf26 str FG KEY_F(26) - ----E F26 function key
+key_f27 kf27 str FH KEY_F(27) - ----E F27 function key
+key_f28 kf28 str FI KEY_F(28) - ----E F28 function key
+key_f29 kf29 str FJ KEY_F(29) - ----E F29 function key
+key_f30 kf30 str FK KEY_F(30) - ----E F30 function key
+key_f31 kf31 str FL KEY_F(31) - ----E F31 function key
+key_f32 kf32 str FM KEY_F(32) - ----E F32 function key
+key_f33 kf33 str FN KEY_F(33) - ----E F33 function key
+key_f34 kf34 str FO KEY_F(34) - ----E F34 function key
+key_f35 kf35 str FP KEY_F(35) - ----E F35 function key
+key_f36 kf36 str FQ KEY_F(36) - ----E F36 function key
+key_f37 kf37 str FR KEY_F(37) - ----E F37 function key
+key_f38 kf38 str FS KEY_F(38) - ----E F38 function key
+key_f39 kf39 str FT KEY_F(39) - ----E F39 function key
+key_f40 kf40 str FU KEY_F(40) - ----E F40 function key
+key_f41 kf41 str FV KEY_F(41) - ----E F41 function key
+key_f42 kf42 str FW KEY_F(42) - ----E F42 function key
+key_f43 kf43 str FX KEY_F(43) - ----E F43 function key
+key_f44 kf44 str FY KEY_F(44) - ----E F44 function key
+key_f45 kf45 str FZ KEY_F(45) - ----E F45 function key
+key_f46 kf46 str Fa KEY_F(46) - ----E F46 function key
+key_f47 kf47 str Fb KEY_F(47) - ----E F47 function key
+key_f48 kf48 str Fc KEY_F(48) - ----E F48 function key
+key_f49 kf49 str Fd KEY_F(49) - ----E F49 function key
+key_f50 kf50 str Fe KEY_F(50) - ----E F50 function key
+key_f51 kf51 str Ff KEY_F(51) - ----E F51 function key
+key_f52 kf52 str Fg KEY_F(52) - ----E F52 function key
+key_f53 kf53 str Fh KEY_F(53) - ----E F53 function key
+key_f54 kf54 str Fi KEY_F(54) - ----E F54 function key
+key_f55 kf55 str Fj KEY_F(55) - ----E F55 function key
+key_f56 kf56 str Fk KEY_F(56) - ----E F56 function key
+key_f57 kf57 str Fl KEY_F(57) - ----E F57 function key
+key_f58 kf58 str Fm KEY_F(58) - ----E F58 function key
+key_f59 kf59 str Fn KEY_F(59) - ----E F59 function key
+key_f60 kf60 str Fo KEY_F(60) - ----E F60 function key
+key_f61 kf61 str Fp KEY_F(61) - ----E F61 function key
+key_f62 kf62 str Fq KEY_F(62) - ----E F62 function key
+key_f63 kf63 str Fr KEY_F(63) - ----E F63 function key
+clr_bol el1 str cb - - ----- Clear to beginning of line
+clear_margins mgc str MC - - ----- clear right and left soft margins
+set_left_margin smgl str ML - - ----- set left soft margin at current column. See smgl. (ML is not in BSD termcap).
+set_right_margin smgr str MR - - ----- set right soft margin at current column
+label_format fln str Lf - - ----- label format
+set_clock sclk str SC - - ----- set clock, #1 hrs #2 mins #3 secs
+display_clock dclk str DK - - ----- display clock
+remove_clock rmclk str RC - - ----- remove clock
+create_window cwin str CW - - ----- define a window #1 from #2,#3 to #4,#5
+goto_window wingo str WG - - ----- go to window #1
+hangup hup str HU - - ----- hang-up phone
+dial_phone dial str DI - - ----- dial number #1
+quick_dial qdial str QD - - ----- dial number #1 without checking
+tone tone str TO - - ----- select touch tone dialing
+pulse pulse str PU - - ----- select pulse dialing
+flash_hook hook str fh - - ----- flash switch hook
+fixed_pause pause str PA - - ----- pause for 2-3 seconds
+wait_tone wait str WA - - ----- wait for dial-tone
+user0 u0 str u0 - - ----- User string #0
+user1 u1 str u1 - - ----- User string #1
+user2 u2 str u2 - - ----- User string #2
+user3 u3 str u3 - - ----- User string #3
+user4 u4 str u4 - - ----- User string #4
+user5 u5 str u5 - - ----- User string #5
+user6 u6 str u6 - - ----- User string #6
+user7 u7 str u7 - - ----- User string #7
+user8 u8 str u8 - - ----- User string #8
+user9 u9 str u9 - - ----- User string #9
#
# SVr4 added these capabilities to support color
#
-orig_pair op str op ----- Set default pair to its original value
-orig_colors oc str oc ----- Set all color pairs to the original ones
-initialize_color initc str Ic ----- initialize color #1 to (#2,#3,#4)
-initialize_pair initp str Ip ----- Initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7)
-set_color_pair scp str sp ----- Set current color pair to #1
-set_foreground setf str Sf ----- Set foreground color #1
-set_background setb str Sb ----- Set background color #1
+orig_pair op str op - - ----- Set default pair to its original value
+orig_colors oc str oc - - ----- Set all color pairs to the original ones
+initialize_color initc str Ic - - ----- initialize color #1 to (#2,#3,#4)
+initialize_pair initp str Ip - - ----- Initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7)
+set_color_pair scp str sp - - ----- Set current color pair to #1
+set_foreground setf str Sf - - ----- Set foreground color #1
+set_background setb str Sb - - ----- Set background color #1
#
# SVr4 added these capabilities to support printers
#
-change_char_pitch cpi str ZA ----- Change number of characters per inch to #1
-change_line_pitch lpi str ZB ----- Change number of lines per inch to #1
-change_res_horz chr str ZC ----- Change horizontal resolution to #1
-change_res_vert cvr str ZD ----- Change vertical resolution to #1
-define_char defc str ZE ----- Define a character #1, #2 dots wide, descender #3
-enter_doublewide_mode swidm str ZF ----- Enter double-wide mode
-enter_draft_quality sdrfq str ZG ----- Enter draft-quality mode
-enter_italics_mode sitm str ZH ----- Enter italic mode
-enter_leftward_mode slm str ZI ----- Start leftward carriage motion
-enter_micro_mode smicm str ZJ ----- Start micro-motion mode
-enter_near_letter_quality snlq str ZK ----- Enter NLQ mode
-enter_normal_quality snrmq str ZL ----- Enter normal-quality mode
-enter_shadow_mode sshm str ZM ----- Enter shadow-print mode
-enter_subscript_mode ssubm str ZN ----- Enter subscript mode
-enter_superscript_mode ssupm str ZO ----- Enter superscript mode
-enter_upward_mode sum str ZP ----- Start upward carriage motion
-exit_doublewide_mode rwidm str ZQ ----- End double-wide mode
-exit_italics_mode ritm str ZR ----- End italic mode
-exit_leftward_mode rlm str ZS ----- End left-motion mode
-exit_micro_mode rmicm str ZT ----- End micro-motion mode
-exit_shadow_mode rshm str ZU ----- End shadow-print mode
-exit_subscript_mode rsubm str ZV ----- End subscript mode
-exit_superscript_mode rsupm str ZW ----- End superscript mode
-exit_upward_mode rum str ZX ----- End reverse character motion
-micro_column_address mhpa str ZY ----- Like column_address in micro mode
-micro_down mcud1 str ZZ ----- Like cursor_down in micro mode
-micro_left mcub1 str Za ----- Like cursor_left in micro mode
-micro_right mcuf1 str Zb ----- Like cursor_right in micro mode
-micro_row_address mvpa str Zc ----- Like row_address #1 in micro mode
-micro_up mcuu1 str Zd ----- Like cursor_up in micro mode
-order_of_pins porder str Ze ----- Match software bits to print-head pins
-parm_down_micro mcud str Zf ----- Like parm_down_cursor in micro mode
-parm_left_micro mcub str Zg ----- Like parm_left_cursor in micro mode
-parm_right_micro mcuf str Zh ----- Like parm_right_cursor in micro mode
-parm_up_micro mcuu str Zi ----- Like parm_up_cursor in micro mode
-select_char_set scs str Zj ----- Select character set, #1
-set_bottom_margin smgb str Zk ----- Set bottom margin at current line
-set_bottom_margin_parm smgbp str Zl ----- Set bottom margin at line #1 or (if smgtp is not given) #2 lines from bottom
-set_left_margin_parm smglp str Zm ----- Set left (right) margin at column #1
-set_right_margin_parm smgrp str Zn ----- Set right margin at column #1
-set_top_margin smgt str Zo ----- Set top margin at current line
-set_top_margin_parm smgtp str Zp ----- Set top (bottom) margin at row #1
-start_bit_image sbim str Zq ----- Start printing bit image graphics
-start_char_set_def scsd str Zr ----- Start character set definition #1, with #2 characters in the set
-stop_bit_image rbim str Zs ----- Stop printing bit image graphics
-stop_char_set_def rcsd str Zt ----- End definition of character set #1
-subscript_characters subcs str Zu ----- List of subscriptable characters
-superscript_characters supcs str Zv ----- List of superscriptable characters
-these_cause_cr docr str Zw ----- Printing any of these characters causes CR
-zero_motion zerom str Zx ----- No motion for subsequent character
+change_char_pitch cpi str ZA - - ----- Change number of characters per inch to #1
+change_line_pitch lpi str ZB - - ----- Change number of lines per inch to #1
+change_res_horz chr str ZC - - ----- Change horizontal resolution to #1
+change_res_vert cvr str ZD - - ----- Change vertical resolution to #1
+define_char defc str ZE - - ----- Define a character #1, #2 dots wide, descender #3
+enter_doublewide_mode swidm str ZF - - ----- Enter double-wide mode
+enter_draft_quality sdrfq str ZG - - ----- Enter draft-quality mode
+enter_italics_mode sitm str ZH - - ----- Enter italic mode
+enter_leftward_mode slm str ZI - - ----- Start leftward carriage motion
+enter_micro_mode smicm str ZJ - - ----- Start micro-motion mode
+enter_near_letter_quality snlq str ZK - - ----- Enter NLQ mode
+enter_normal_quality snrmq str ZL - - ----- Enter normal-quality mode
+enter_shadow_mode sshm str ZM - - ----- Enter shadow-print mode
+enter_subscript_mode ssubm str ZN - - ----- Enter subscript mode
+enter_superscript_mode ssupm str ZO - - ----- Enter superscript mode
+enter_upward_mode sum str ZP - - ----- Start upward carriage motion
+exit_doublewide_mode rwidm str ZQ - - ----- End double-wide mode
+exit_italics_mode ritm str ZR - - ----- End italic mode
+exit_leftward_mode rlm str ZS - - ----- End left-motion mode
+exit_micro_mode rmicm str ZT - - ----- End micro-motion mode
+exit_shadow_mode rshm str ZU - - ----- End shadow-print mode
+exit_subscript_mode rsubm str ZV - - ----- End subscript mode
+exit_superscript_mode rsupm str ZW - - ----- End superscript mode
+exit_upward_mode rum str ZX - - ----- End reverse character motion
+micro_column_address mhpa str ZY - - ----- Like column_address in micro mode
+micro_down mcud1 str ZZ - - ----- Like cursor_down in micro mode
+micro_left mcub1 str Za - - ----- Like cursor_left in micro mode
+micro_right mcuf1 str Zb - - ----- Like cursor_right in micro mode
+micro_row_address mvpa str Zc - - ----- Like row_address #1 in micro mode
+micro_up mcuu1 str Zd - - ----- Like cursor_up in micro mode
+order_of_pins porder str Ze - - ----- Match software bits to print-head pins
+parm_down_micro mcud str Zf - - ----- Like parm_down_cursor in micro mode
+parm_left_micro mcub str Zg - - ----- Like parm_left_cursor in micro mode
+parm_right_micro mcuf str Zh - - ----- Like parm_right_cursor in micro mode
+parm_up_micro mcuu str Zi - - ----- Like parm_up_cursor in micro mode
+select_char_set scs str Zj - - ----- Select character set, #1
+set_bottom_margin smgb str Zk - - ----- Set bottom margin at current line
+set_bottom_margin_parm smgbp str Zl - - ----- Set bottom margin at line #1 or (if smgtp is not given) #2 lines from bottom
+set_left_margin_parm smglp str Zm - - ----- Set left (right) margin at column #1
+set_right_margin_parm smgrp str Zn - - ----- Set right margin at column #1
+set_top_margin smgt str Zo - - ----- Set top margin at current line
+set_top_margin_parm smgtp str Zp - - ----- Set top (bottom) margin at row #1
+start_bit_image sbim str Zq - - ----- Start printing bit image graphics
+start_char_set_def scsd str Zr - - ----- Start character set definition #1, with #2 characters in the set
+stop_bit_image rbim str Zs - - ----- Stop printing bit image graphics
+stop_char_set_def rcsd str Zt - - ----- End definition of character set #1
+subscript_characters subcs str Zu - - ----- List of subscriptable characters
+superscript_characters supcs str Zv - - ----- List of superscriptable characters
+these_cause_cr docr str Zw - - ----- Printing any of these characters causes CR
+zero_motion zerom str Zx - - ----- No motion for subsequent character
#%.TE
#%.ad
#%
@@ -698,41 +701,41 @@ zero_motion zerom str Zx ----- No motion for subsequent character
#%lw25 lw6 lw2 lw18.
#%\fBVariable Cap- TCap Description\fR
#%\fBString name Code\fR
-char_set_names csnm str Zy ----- Produce #1'th item from list of character set names
-key_mouse kmous str Km ----- Mouse event has occurred
-mouse_info minfo str Mi ----- Mouse status information
-req_mouse_pos reqmp str RQ ----- Request mouse position
-get_mouse getm str Gm ----- Curses should get button events, parameter #1 not documented.
-set_a_foreground setaf str AF ----- Set foreground color to #1, using ANSI escape
-set_a_background setab str AB ----- Set background color to #1, using ANSI escape
-pkey_plab pfxl str xl ----- Program function key #1 to type string #2 and show string #3
-device_type devt str dv ----- Indicate language/codeset support
-code_set_init csin str ci ----- Init sequence for multiple codesets
-set0_des_seq s0ds str s0 ----- Shift to code set 0 (EUC set 0, ASCII)
-set1_des_seq s1ds str s1 ----- Shift to code set 1
-set2_des_seq s2ds str s2 ----- Shift to code set 2
-set3_des_seq s3ds str s3 ----- Shift to code set 3
-set_lr_margin smglr str ML ----- Set both left and right margins to #1, #2. (ML is not in BSD termcap).
-set_tb_margin smgtb str MT ----- Sets both top and bottom margins to #1, #2
-bit_image_repeat birep str Xy ----- Repeat bit image cell #1 #2 times
-bit_image_newline binel str Zz ----- Move to next row of the bit image
-bit_image_carriage_return bicr str Yv ----- Move to beginning of same row
-color_names colornm str Yw ----- Give name for color #1
-define_bit_image_region defbi str Yx ----- Define rectangualar bit image region
-end_bit_image_region endbi str Yy ----- End a bit-image region
-set_color_band setcolor str Yz ----- Change to ribbon color #1
-set_page_length slines str YZ ----- Set page length to #1 lines
+char_set_names csnm str Zy - - ----- Produce #1'th item from list of character set names
+key_mouse kmous str Km KEY_MOUSE 0631 ----- Mouse event has occurred
+mouse_info minfo str Mi - - ----- Mouse status information
+req_mouse_pos reqmp str RQ - - ----- Request mouse position
+get_mouse getm str Gm - - ----- Curses should get button events, parameter #1 not documented.
+set_a_foreground setaf str AF - - ----- Set foreground color to #1, using ANSI escape
+set_a_background setab str AB - - ----- Set background color to #1, using ANSI escape
+pkey_plab pfxl str xl - - ----- Program function key #1 to type string #2 and show string #3
+device_type devt str dv - - ----- Indicate language/codeset support
+code_set_init csin str ci - - ----- Init sequence for multiple codesets
+set0_des_seq s0ds str s0 - - ----- Shift to codeset 0 (EUC set 0, ASCII)
+set1_des_seq s1ds str s1 - - ----- Shift to codeset 1
+set2_des_seq s2ds str s2 - - ----- Shift to codeset 2
+set3_des_seq s3ds str s3 - - ----- Shift to codeset 3
+set_lr_margin smglr str ML - - ----- Set both left and right margins to #1, #2. (ML is not in BSD termcap).
+set_tb_margin smgtb str MT - - ----- Sets both top and bottom margins to #1, #2
+bit_image_repeat birep str Xy - - ----- Repeat bit image cell #1 #2 times
+bit_image_newline binel str Zz - - ----- Move to next row of the bit image
+bit_image_carriage_return bicr str Yv - - ----- Move to beginning of same row
+color_names colornm str Yw - - ----- Give name for color #1
+define_bit_image_region defbi str Yx - - ----- Define rectangualar bit image region
+end_bit_image_region endbi str Yy - - ----- End a bit-image region
+set_color_band setcolor str Yz - - ----- Change to ribbon color #1
+set_page_length slines str YZ - - ----- Set page length to #1 lines
#
# SVr4 added these capabilities for direct PC-clone support
#
-display_pc_char dispc str S1 ----- Display PC character #1
-enter_pc_charset_mode smpch str S2 ----- Enter PC character display mode
-exit_pc_charset_mode rmpch str S3 ----- Exit PC character display mode
-enter_scancode_mode smsc str S4 ----- Enter PC scancode mode
-exit_scancode_mode rmsc str S5 ----- Exit PC scancode mode
-pc_term_options pctrm str S6 ----- PC terminal options
-scancode_escape scesc str S7 ----- Escape for scancode emulation
-alt_scancode_esc scesa str S8 ----- Alternate escape for scancode emulation
+display_pc_char dispc str S1 - - ----- Display PC character #1
+enter_pc_charset_mode smpch str S2 - - ----- Enter PC character display mode
+exit_pc_charset_mode rmpch str S3 - - ----- Exit PC character display mode
+enter_scancode_mode smsc str S4 - - ----- Enter PC scancode mode
+exit_scancode_mode rmsc str S5 - - ----- Exit PC scancode mode
+pc_term_options pctrm str S6 - - ----- PC terminal options
+scancode_escape scesc str S7 - - ----- Escape for scancode emulation
+alt_scancode_esc scesa str S8 - - ----- Alternate escape for scancode emulation
#%.TE
#%.ad
#%
@@ -752,14 +755,14 @@ alt_scancode_esc scesa str S8 ----- Alternate escape for scancode emulation
#%lw25 lw6 lw2 lw20.
#%\fBVariable Cap- TCap Description\fR
#%\fBString name Code\fR
-enter_horizontal_hl_mode ehhlm str Xh ----- Enter horizontal highlight mode
-enter_left_hl_mode elhlm str Xl ----- Enter left highlight mode
-enter_low_hl_mode elohlm str Xo ----- Enter low highlight mode
-enter_right_hl_mode erhlm str Xr ----- Enter right highlight mode
-enter_top_hl_mode ethlm str Xt ----- Enter top highlight mode
-enter_vertical_hl_mode evhlm str Xv ----- Enter vertical highlight mode
-set_a_attributes sgr1 str sA ----- Define second set of video attributes #1-#6
-set_pglen_inch slength str sL ----- YI Set page length to #1 hundredth of an inch
+enter_horizontal_hl_mode ehhlm str Xh - - ----- Enter horizontal highlight mode
+enter_left_hl_mode elhlm str Xl - - ----- Enter left highlight mode
+enter_low_hl_mode elohlm str Xo - - ----- Enter low highlight mode
+enter_right_hl_mode erhlm str Xr - - ----- Enter right highlight mode
+enter_top_hl_mode ethlm str Xt - - ----- Enter top highlight mode
+enter_vertical_hl_mode evhlm str Xv - - ----- Enter vertical highlight mode
+set_a_attributes sgr1 str sA - - ----- Define second set of video attributes #1-#6
+set_pglen_inch slength str sL - - ----- YI Set page length to #1 hundredth of an inch
#%.TE
#%.ad
#
@@ -796,34 +799,34 @@ set_pglen_inch slength str sL ----- YI Set page length to #1 hundredth of an i
# The ug capability is thrown away, but assumed to be whatever sg is if the
# latter is nonzero and we're dumping in termcap format.
#
-termcap_init2 OTi2 str i2 YB--- secondary initialization string
-termcap_reset OTrs str rs YB-G- terminal reset string
-magic_cookie_glitch_ul OTug num ug YBCGE number of blanks left by ul
+termcap_init2 OTi2 str i2 - - YB--- secondary initialization string
+termcap_reset OTrs str rs - - YB-G- terminal reset string
+magic_cookie_glitch_ul OTug num ug - - YBCGE number of blanks left by ul
#
# Obsolete termcap capabilities. Some are used for termcap translation. The
# code uses the 'OT' prefix we put on obsolete capabilities to suppress
# printing them in terminfo source dumps of compiled entries.
#
-backspaces_with_bs OTbs bool bs YBCGE uses ^H to move left
-crt_no_scrolling OTns bool ns YBCG- crt cannot scroll
-no_correctly_working_cr OTnc bool nc YBCG- no way to go to start of line
-carriage_return_delay OTdC num dC YB-G- pad needed for CR
-new_line_delay OTdN num dN YB-G- pad needed for LF
-linefeed_if_not_lf OTnl str nl YBCGE use to move down
-backspace_if_not_bs OTbc str bc YBCGE move left, if not ^H
+backspaces_with_bs OTbs bool bs - - YBCGE uses ^H to move left
+crt_no_scrolling OTns bool ns - - YBCG- crt cannot scroll
+no_correctly_working_cr OTnc bool nc - - YBCG- no way to go to start of line
+carriage_return_delay OTdC num dC - - YB-G- pad needed for CR
+new_line_delay OTdN num dN - - YB-G- pad needed for LF
+linefeed_if_not_lf OTnl str nl - - YBCGE use to move down
+backspace_if_not_bs OTbc str bc - - YBCGE move left, if not ^H
#
# GNU termcap library extensions. The GNU termcap file distributed with
# Emacs no longer uses these, but MT showed up in pre-9.0 versions of the
# BSD termcap file. The name clash with terminfo MT is resolved by type
# info; MT is converted to km.
#
-gnu_has_meta_key OTMT bool MT ----E has meta key
-# gnu_tab_width OTtw num tw ----E tab width in spaces
+gnu_has_meta_key OTMT bool MT - - ----E has meta key
+# gnu_tab_width OTtw num tw - - ----E tab width in spaces
#
# GNU termcap *does* include the following extended capability, Only the
# now-obsolete Ann Arbor terminals used it.
#
-# gnu_change_scroll_region OTcS str cS ---GE alternate set scrolling region
+# gnu_change_scroll_region OTcS str cS - - ---GE alternate set scrolling region
#
# The following comments describe capnames so ancient that I believe no
# software uses them any longer. Some of these have to go because they
@@ -856,50 +859,50 @@ gnu_has_meta_key OTMT bool MT ----E has meta key
# Applications that use terminfo are supposed to behave as though xr is
# always true.
#
-linefeed_is_newline OTNL bool NL YB--- move down with \n
-# even_parity OTEP bool EP -B--- terminal requires even parity
-# odd_parity OTOP bool OP -B--- terminal requires odd parity
-# half_duplex OTHD bool HD -B--- terminal is half-duplex
-# lower_case_only OTLC bool LC -B--- terminal has only lower case
-# upper_case_only OTUC bool UC -B--- terminal has only upper case
-backspace_delay OTdB num dB YB-G- padding required for ^H
-# form_feed_delay OTdF num dF -B-G- padding required for ^L
-horizontal_tab_delay OTdT num dT YB-G- padding required for ^I
-# vertical_tab_delay OTdV num dV -B--- padding required for ^V
-number_of_function_keys OTkn num kn -B-G- count of function keys
-other_non_function_keys OTko str ko -B-G- list of self-mapped keycaps
-arrow_key_map OTma str ma YBC-- map arrow keys rogue(1) motion keys
-# memory_lock_above OTml str ml -B--- lock visible screen memory above the current line
-# memory_unlock OTmu str mu -B--- unlock visible screen memory above the current line
-has_hardware_tabs OTpt bool pt YB--- has 8-char tabs invoked with ^I
-return_does_clr_eol OTxr bool xr YB--- return clears the line
-# tek_4025_insert_line OTxx bool xx -BC-- Tektronix 4025 insert-line glitch
+linefeed_is_newline OTNL bool NL - - YB--- move down with \n
+# even_parity OTEP bool EP - - -B--- terminal requires even parity
+# odd_parity OTOP bool OP - - -B--- terminal requires odd parity
+# half_duplex OTHD bool HD - - -B--- terminal is half-duplex
+# lower_case_only OTLC bool LC - - -B--- terminal has only lower case
+# upper_case_only OTUC bool UC - - -B--- terminal has only upper case
+backspace_delay OTdB num dB - - YB-G- padding required for ^H
+# form_feed_delay OTdF num dF - - -B-G- padding required for ^L
+horizontal_tab_delay OTdT num dT - - YB-G- padding required for ^I
+# vertical_tab_delay OTdV num dV - - -B--- padding required for ^V
+number_of_function_keys OTkn num kn - - -B-G- count of function keys
+other_non_function_keys OTko str ko - - -B-G- list of self-mapped keycaps
+arrow_key_map OTma str ma - - YBC-- map arrow keys rogue(1) motion keys
+# memory_lock_above OTml str ml - - -B--- lock visible screen memory above the current line
+# memory_unlock OTmu str mu - - -B--- unlock visible screen memory above the current line
+has_hardware_tabs OTpt bool pt - - YB--- has 8-char tabs invoked with ^I
+return_does_clr_eol OTxr bool xr - - YB--- return clears the line
+# tek_4025_insert_line OTxx bool xx - - -BC-- Tektronix 4025 insert-line glitch
#
# mytinfo described this as a termcap capability, but it's not listed in the
# 4.4BSD man pages, and not found in the 4.4BSD termcap file. The ncurses
# package, like System V, behaves as though it is always true.
#
-# rind_only_at_top OTxq bool xq ----- reverse index only works from top line
+# rind_only_at_top OTxq bool xq - - ----- reverse index only works from top line
#
# University of Waterloo termcap extensions (as described in mytinfo).
# The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
# be resolved by a type check. The descriptions are guesses from what was
# in the mytinfo tables.
#
-# key_interrupt_char OTki str ki ----- string set by interrupt key (?)
-# key_kill_char OTkk str kk ----- string set by kill key (?)
-# key_suspend_char OTkz str kz ----- string set by suspend key (?)
-# initialization_messy OTxc bool xc ----- initialization leaves garbage on the screen (?)
-# ind_at_bottom_does_cr OTxl bool xl ----- index does a carriage return
+# key_interrupt_char OTki str ki - - ----- string set by interrupt key (?)
+# key_kill_char OTkk str kk - - ----- string set by kill key (?)
+# key_suspend_char OTkz str kz - - ----- string set by suspend key (?)
+# initialization_messy OTxc bool xc - - ----- initialization leaves garbage on the screen (?)
+# ind_at_bottom_does_cr OTxl bool xl - - ----- index does a carriage return
#
# Nonstandard capabilities unique to Ross Ridge's `mytinfo' package.
# SR clashes with a terminfo name; this ambiguity cannot be resolved by a type
# check.
#
-# scroll_left OTsl1 str Sl ----- scroll screen leftward
-# scroll_right OTsr1 str Sr ----- scroll screen rightward
-# parm_scroll_left OTsl str SL ----- scroll screen leftward #1 characters
-# parm_scroll_right OTsr str SR ----- scroll screen rightward #1 characters
+# scroll_left OTsl1 str Sl - - ----- scroll screen leftward
+# scroll_right OTsr1 str Sr - - ----- scroll screen rightward
+# parm_scroll_left OTsl str SL - - ----- scroll screen leftward #1 characters
+# parm_scroll_right OTsr str SR - - ----- scroll screen rightward #1 characters
#
# The mytinfo capabilities end here.
#
@@ -939,17 +942,17 @@ return_does_clr_eol OTxr bool xr YB--- return clears the line
# that detects the acs_ prefix and uses it to suppress pad translation.
# These terminfo names are invented.
#
-acs_ulcorner OTG2 str G2 ----- single upper left
-acs_llcorner OTG3 str G3 ----- single lower left
-acs_urcorner OTG1 str G1 ----- single upper right
-acs_lrcorner OTG4 str G4 ----- single lower right
-acs_ltee OTGR str GR ----- tee pointing right
-acs_rtee OTGL str GL ----- tee pointing left
-acs_btee OTGU str GU ----- tee pointing up
-acs_ttee OTGD str GD ----- tee pointing down
-acs_hline OTGH str GH ----- single horizontal line
-acs_vline OTGV str GV ----- single vertical line
-acs_plus OTGC str GC ----- single intersection
+acs_ulcorner OTG2 str G2 - - ----- single upper left
+acs_llcorner OTG3 str G3 - - ----- single lower left
+acs_urcorner OTG1 str G1 - - ----- single upper right
+acs_lrcorner OTG4 str G4 - - ----- single lower right
+acs_ltee OTGR str GR - - ----- tee pointing right
+acs_rtee OTGL str GL - - ----- tee pointing left
+acs_btee OTGU str GU - - ----- tee pointing up
+acs_ttee OTGD str GD - - ----- tee pointing down
+acs_hline OTGH str GH - - ----- single horizontal line
+acs_vline OTGV str GV - - ----- single vertical line
+acs_plus OTGC str GC - - ----- single intersection
#
#############################################################################
#
@@ -966,64 +969,64 @@ acs_plus OTGC str GC ----- single intersection
# functionally identical to SVr4 extensions, but they make the binary format
# different. Grrr....
#
-memory_lock meml str ml ----K memory lock above
-memory_unlock memu str mu ----K memory unlock
-#plab_norm pln str pn ----- program label #1 to show string #2
-#label_on smln str LO ----- turn on soft labels
-#label_off rmln str LF ----- turn off soft labels
-#key_f11 kf11 str F1 ----- F11 function key
-#key_f12 kf12 str F2 ----- F12 function key
-#key_f13 kf13 str F3 ----- F13 function key
-#key_f14 kf14 str F4 ----- F14 function key
-#key_f15 kf15 str F5 ----- F15 function key
-#key_f16 kf16 str F6 ----- F16 function key
-#key_f17 kf17 str F7 ----- F17 function key
-#key_f18 kf18 str F8 ----- F18 function key
-#key_f19 kf19 str F9 ----- F19 function key
-#key_f20 kf20 str FA ----- F20 function key
-#key_f21 kf21 str FB ----- F21 function key
-#key_f22 kf22 str FC ----- F22 function key
-#key_f23 kf23 str FD ----- F23 function key
-#key_f24 kf24 str FE ----- F24 function key
-#key_f25 kf25 str FF ----- F25 function key
-#key_f26 kf26 str FG ----- F26 function key
-#key_f27 kf27 str FH ----- F27 function key
-#key_f28 kf28 str FI ----- F28 function key
-#key_f29 kf29 str FJ ----- F29 function key
-#key_f30 kf30 str FK ----- F30 function key
-#key_f31 kf31 str FL ----- F31 function key
-#key_f32 kf32 str FM ----- F32 function key
-#key_f33 kf33 str FN ----- F33 function key
-#key_f34 kf34 str FO ----- F34 function key
-#key_f35 kf35 str FP ----- F35 function key
-#key_f36 kf36 str FQ ----- F36 function key
-#key_f37 kf37 str FR ----- F37 function key
-#key_f38 kf38 str FS ----- F38 function key
-#key_f39 kf39 str FT ----- F39 function key
-#key_f40 kf40 str FU ----- F40 function key
-#key_f41 kf41 str FV ----- F41 function key
-#key_f42 kf42 str FW ----- F42 function key
-#key_f43 kf43 str FX ----- F43 function key
-#key_f44 kf44 str FY ----- F44 function key
-#key_f45 kf45 str FZ ----- F45 function key
-#key_f46 kf46 str Fa ----- F46 function key
-#key_f47 kf47 str Fb ----- F47 function key
-#key_f48 kf48 str Fc ----- F48 function key
-#key_f49 kf49 str Fd ----- F49 function key
-#key_f50 kf50 str Fe ----- F50 function key
-#key_f51 kf51 str Ff ----- F51 function key
-#key_f52 kf52 str Fg ----- F52 function key
-#key_f53 kf53 str Fh ----- F53 function key
-#key_f54 kf54 str Fi ----- F54 function key
-#key_f55 kf55 str Fj ----- F55 function key
-#key_f56 kf56 str Fk ----- F56 function key
-#key_f57 kf57 str Fl ----- F57 function key
-#key_f58 kf58 str Fm ----- F58 function key
-#key_f59 kf59 str Fn ----- F59 function key
-#key_f60 kf60 str Fo ----- F60 function key
-#key_f61 kf61 str Fp ----- F61 function key
-#key_f62 kf62 str Fq ----- F62 function key
-#key_f63 kf63 str Fr ----- F63 function key
+memory_lock meml str ml - - ----K lock memory above cursor
+memory_unlock memu str mu - - ----K unlock memory
+#plab_norm pln str pn - - ----- program label #1 to show string #2
+#label_on smln str LO - - ----- turn on soft labels
+#label_off rmln str LF - - ----- turn off soft labels
+#key_f11 kf11 str F1 - - ----- F11 function key
+#key_f12 kf12 str F2 - - ----- F12 function key
+#key_f13 kf13 str F3 - - ----- F13 function key
+#key_f14 kf14 str F4 - - ----- F14 function key
+#key_f15 kf15 str F5 - - ----- F15 function key
+#key_f16 kf16 str F6 - - ----- F16 function key
+#key_f17 kf17 str F7 - - ----- F17 function key
+#key_f18 kf18 str F8 - - ----- F18 function key
+#key_f19 kf19 str F9 - - ----- F19 function key
+#key_f20 kf20 str FA - - ----- F20 function key
+#key_f21 kf21 str FB - - ----- F21 function key
+#key_f22 kf22 str FC - - ----- F22 function key
+#key_f23 kf23 str FD - - ----- F23 function key
+#key_f24 kf24 str FE - - ----- F24 function key
+#key_f25 kf25 str FF - - ----- F25 function key
+#key_f26 kf26 str FG - - ----- F26 function key
+#key_f27 kf27 str FH - - ----- F27 function key
+#key_f28 kf28 str FI - - ----- F28 function key
+#key_f29 kf29 str FJ - - ----- F29 function key
+#key_f30 kf30 str FK - - ----- F30 function key
+#key_f31 kf31 str FL - - ----- F31 function key
+#key_f32 kf32 str FM - - ----- F32 function key
+#key_f33 kf33 str FN - - ----- F33 function key
+#key_f34 kf34 str FO - - ----- F34 function key
+#key_f35 kf35 str FP - - ----- F35 function key
+#key_f36 kf36 str FQ - - ----- F36 function key
+#key_f37 kf37 str FR - - ----- F37 function key
+#key_f38 kf38 str FS - - ----- F38 function key
+#key_f39 kf39 str FT - - ----- F39 function key
+#key_f40 kf40 str FU - - ----- F40 function key
+#key_f41 kf41 str FV - - ----- F41 function key
+#key_f42 kf42 str FW - - ----- F42 function key
+#key_f43 kf43 str FX - - ----- F43 function key
+#key_f44 kf44 str FY - - ----- F44 function key
+#key_f45 kf45 str FZ - - ----- F45 function key
+#key_f46 kf46 str Fa - - ----- F46 function key
+#key_f47 kf47 str Fb - - ----- F47 function key
+#key_f48 kf48 str Fc - - ----- F48 function key
+#key_f49 kf49 str Fd - - ----- F49 function key
+#key_f50 kf50 str Fe - - ----- F50 function key
+#key_f51 kf51 str Ff - - ----- F51 function key
+#key_f52 kf52 str Fg - - ----- F52 function key
+#key_f53 kf53 str Fh - - ----- F53 function key
+#key_f54 kf54 str Fi - - ----- F54 function key
+#key_f55 kf55 str Fj - - ----- F55 function key
+#key_f56 kf56 str Fk - - ----- F56 function key
+#key_f57 kf57 str Fl - - ----- F57 function key
+#key_f58 kf58 str Fm - - ----- F58 function key
+#key_f59 kf59 str Fn - - ----- F59 function key
+#key_f60 kf60 str Fo - - ----- F60 function key
+#key_f61 kf61 str Fp - - ----- F61 function key
+#key_f62 kf62 str Fq - - ----- F62 function key
+#key_f63 kf63 str Fr - - ----- F63 function key
#
# IBM extensions
#
@@ -1047,146 +1050,94 @@ memory_unlock memu str mu ----K memory unlock
#
# The box2 characters are the double-line versions of these forms graphics.
#
-box_chars_1 box1 str bx ----K box characters primary set
-#box_chars_2 box2 str by ----K box characters secondary set
-#box_attr_1 batt1 str Bx ----K attributes for box1
-#box_attr_2 batt2 str By ----K attributes for box2
-#color_bg_0 colb0 str d0 ----K background color 0
-#color_bg_1 colb1 str d1 ----K background color 1
-#color_bg_2 colb2 str d2 ----K background color 2
-#color_bg_3 colb3 str d3 ----K background color 3
-#color_bg_4 colb4 str d4 ----K background color 4
-#color_bg_5 colb5 str d5 ----K background color 5
-#color_bg_6 colb6 str d6 ----K background color 6
-#color_bg_7 colb7 str d7 ----K background color 7
-#color_fg_0 colf0 str c0 ----K foreground color 0
-#color_fg_1 colf1 str c1 ----K foreground color 1
-#color_fg_2 colf2 str c2 ----K foreground color 2
-#color_fg_3 colf3 str c3 ----K foreground color 3
-#color_fg_4 colf4 str c4 ----K foreground color 4
-#color_fg_5 colf5 str c5 ----K foreground color 5
-#color_fg_6 colf6 str c6 ----K foreground color 6
-#color_fg_7 colf7 str c7 ----K foreground color 7
-#font_0 font0 str f0 ----- select font 0
-#font_1 font1 str f1 ----- select font 1
-#font_2 font2 str f2 ----- select font 2
-#font_3 font3 str f3 ----- select font 3
-#font_4 font4 str f4 ----K select font 4
-#font_5 font5 str f5 ----K select font 5
-#font_6 font6 str f6 ----K select font 6
-#font_7 font7 str f7 ----K select font 7
-#key_back_tab kbtab str k0 ----- backtab key
-#key_do kdo str ki ----K do request key
-#key_command kcmd str kd ----K command-request key
-#key_command_pane kcpn str kW ----K command-pane key
-#key_end kend str kw ----- end key
-#key_help khlp str kq ----- help key
-#key_newline knl str nl ----K newline key
-#key_next_pane knpn str kv ----K next-pane key
-#key_prev_cmd kppn str kp ----K previous-command key
-#key_prev_pane kppn str kV ----K previous-pane key
-#key_quit kquit str kQ ----K quit key
-#key_select ksel str kU ----- select key
-#key_scroll_left kscl str kz ----K scroll left
-#key_scroll_right kscr str kZ ----K scroll right
-#key_tab ktab str ko ----K tab key
-#key_smap_in1 kmpf1 str Kv ----K special mapped key 1 input
-#key_smap_out1 kmpt1 str KV ----K special mapped key 1 output
-#key_smap_in2 kmpf2 str Kw ----K special mapped key 2 input
-#key_smap_out2 kmpt2 str KW ----K special mapped key 2 output
-#key_smap_in3 kmpf3 str Kx ----K special mapped key 3 input
-#key_smap_out3 kmpt3 str KX ----K special mapped key 3 output
-#key_smap_in4 kmpf4 str Ky ----K special mapped key 4 input
-#key_smap_out4 kmpt4 str KY ----K special mapped key 4 output
-#key_smap_in5 kmpf5 str Kz ----K special mapped key 5 input
-#key_smap_out5 kmpt5 str KZ ----K special mapped key 5 output
-#appl_defined_str apstr str za ----K application-defined string
+box_chars_1 box1 str bx - - ----K box characters primary set
+#box_chars_2 box2 str by - - ----K box characters secondary set
+#box_attr_1 batt1 str Bx - - ----K attributes for box1
+#box_attr_2 batt2 str By - - ----K attributes for box2
+#color_bg_0 colb0 str d0 - - ----K background color 0
+#color_bg_1 colb1 str d1 - - ----K background color 1
+#color_bg_2 colb2 str d2 - - ----K background color 2
+#color_bg_3 colb3 str d3 - - ----K background color 3
+#color_bg_4 colb4 str d4 - - ----K background color 4
+#color_bg_5 colb5 str d5 - - ----K background color 5
+#color_bg_6 colb6 str d6 - - ----K background color 6
+#color_bg_7 colb7 str d7 - - ----K background color 7
+#color_fg_0 colf0 str c0 - - ----K foreground color 0
+#color_fg_1 colf1 str c1 - - ----K foreground color 1
+#color_fg_2 colf2 str c2 - - ----K foreground color 2
+#color_fg_3 colf3 str c3 - - ----K foreground color 3
+#color_fg_4 colf4 str c4 - - ----K foreground color 4
+#color_fg_5 colf5 str c5 - - ----K foreground color 5
+#color_fg_6 colf6 str c6 - - ----K foreground color 6
+#color_fg_7 colf7 str c7 - - ----K foreground color 7
+#font_0 font0 str f0 - - ----- select font 0
+#font_1 font1 str f1 - - ----- select font 1
+#font_2 font2 str f2 - - ----- select font 2
+#font_3 font3 str f3 - - ----- select font 3
+#font_4 font4 str f4 - - ----K select font 4
+#font_5 font5 str f5 - - ----K select font 5
+#font_6 font6 str f6 - - ----K select font 6
+#font_7 font7 str f7 - - ----K select font 7
+#key_back_tab kbtab str k0 - - ----- backtab key
+#key_do kdo str ki - - ----K do request key
+#key_command kcmd str kd - - ----K command-request key
+#key_command_pane kcpn str kW - - ----K command-pane key
+#key_end kend str kw - - ----- end key
+#key_help khlp str kq - - ----- help key
+#key_newline knl str nl - - ----K newline key
+#key_next_pane knpn str kv - - ----K next-pane key
+#key_prev_cmd kppn str kp - - ----K previous-command key
+#key_prev_pane kppn str kV - - ----K previous-pane key
+#key_quit kquit str kQ - - ----K quit key
+#key_select ksel str kU - - ----- select key
+#key_scroll_left kscl str kz - - ----K scroll left
+#key_scroll_right kscr str kZ - - ----K scroll right
+#key_tab ktab str ko - - ----K tab key
+#key_smap_in1 kmpf1 str Kv - - ----K special mapped key 1 input
+#key_smap_out1 kmpt1 str KV - - ----K special mapped key 1 output
+#key_smap_in2 kmpf2 str Kw - - ----K special mapped key 2 input
+#key_smap_out2 kmpt2 str KW - - ----K special mapped key 2 output
+#key_smap_in3 kmpf3 str Kx - - ----K special mapped key 3 input
+#key_smap_out3 kmpt3 str KX - - ----K special mapped key 3 output
+#key_smap_in4 kmpf4 str Ky - - ----K special mapped key 4 input
+#key_smap_out4 kmpt4 str KY - - ----K special mapped key 4 output
+#key_smap_in5 kmpf5 str Kz - - ----K special mapped key 5 input
+#key_smap_out5 kmpt5 str KZ - - ----K special mapped key 5 output
+#appl_defined_str apstr str za - - ----K application-defined string
# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
# the IBM manual pages, so the cap name strings are guesses. The terminfo
# names are almost certainly right, the termcap ones almost certainly wrong.
-#key_smap_in6 kmpf6 str k! ----K special mapped key 6 input
-#key_smap_out6 kmpt6 str K@ ----K special mapped key 6 output
-#key_smap_in7 kmpf7 str k# ----K special mapped key 7 input
-#key_smap_out7 kmpt7 str K$ ----K special mapped key 7 output
-#key_smap_in8 kmpf8 str k% ----K special mapped key 8 input
-#key_smap_out8 kmpt8 str K^ ----K special mapped key 8 output
-#key_smap_in9 kmpf9 str k& ----K special mapped key 9 input
-#key_smap_out9 kmpt9 str K* ----K special mapped key 9 output
+#key_smap_in6 kmpf6 str k! - - ----K special mapped key 6 input
+#key_smap_out6 kmpt6 str K@ - - ----K special mapped key 6 output
+#key_smap_in7 kmpf7 str k# - - ----K special mapped key 7 input
+#key_smap_out7 kmpt7 str K$ - - ----K special mapped key 7 output
+#key_smap_in8 kmpf8 str k% - - ----K special mapped key 8 input
+#key_smap_out8 kmpt8 str K^ - - ----K special mapped key 8 output
+#key_smap_in9 kmpf9 str k& - - ----K special mapped key 9 input
+#key_smap_out9 kmpt9 str K* - - ----K special mapped key 9 output
# Undocumented capabilities end here
-#key_sf1 ksf1 str S1 ----K special function key 1
-#key_sf2 ksf2 str S2 ----K special function key 2
-#key_sf3 ksf3 str S3 ----K special function key 3
-#key_sf4 ksf4 str S4 ----K special function key 4
-#key_sf5 ksf5 str S5 ----K special function key 5
-#key_sf6 ksf6 str S6 ----K special function key 6
-#key_sf7 ksf7 str S7 ----K special function key 7
-#key_sf8 ksf8 str S8 ----K special function key 8
-#key_sf9 ksf9 str S9 ----K special function key 9
-#key_sf10 ksf10 str SA ----K special function key 10
-#key_f11 kf11 str k< ----- function key 11
-#key_f12 kf12 str k> ----- function key 12
-# The key_f13 through key_f64 capabilities aren't described in
-# the IBM manual pages, so the cap name strings are guesses. The terminfo
-# names are almost certainly right, the termcap ones certainly wrong.
-#key_f13 kf13 str k+ ----- function key 13
-#key_f14 kf14 str k+ ----- function key 14
-#key_f15 kf15 str k+ ----- function key 15
-#key_f16 kf16 str k+ ----- function key 16
-#key_f17 kf17 str k+ ----- function key 17
-#key_f18 kf18 str k+ ----- function key 18
-#key_f19 kf19 str k+ ----- function key 19
-#key_f20 kf20 str k+ ----- function key 20
-#key_f21 kf21 str k+ ----- function key 21
-#key_f22 kf22 str k+ ----- function key 22
-#key_f23 kf23 str k+ ----- function key 23
-#key_f24 kf24 str k+ ----- function key 24
-#key_f25 kf25 str k+ ----- function key 25
-#key_f26 kf26 str k+ ----- function key 26
-#key_f27 kf26 str k+ ----- function key 26
-#key_f28 kf28 str k+ ----- function key 28
-#key_f29 kf29 str k+ ----- function key 29
-#key_f30 kf30 str k+ ----- function key 30
-#key_f31 kf31 str k+ ----- function key 31
-#key_f32 kf31 str k+ ----- function key 32
-#key_f33 kf33 str k+ ----- function key 33
-#key_f34 kf34 str k+ ----- function key 34
-#key_f35 kf35 str k+ ----- function key 35
-#key_f36 kf36 str k+ ----- function key 36
-#key_f37 kf37 str k+ ----- function key 37
-#key_f38 kf38 str k+ ----- function key 38
-#key_f39 kf39 str k+ ----- function key 39
-#key_f40 kf40 str k+ ----- function key 40
-#key_f41 kf41 str k+ ----- function key 41
-#key_f42 kf42 str k+ ----- function key 42
-#key_f43 kf43 str k+ ----- function key 43
-#key_f44 kf44 str k+ ----- function key 44
-#key_f45 kf45 str k+ ----- function key 45
-#key_f46 kf46 str k+ ----- function key 46
-#key_f47 kf47 str k+ ----- function key 47
-#key_f48 kf48 str k+ ----- function key 48
-#key_f49 kf49 str k+ ----- function key 49
-#key_f50 kf50 str k+ ----- function key 50
-#key_f51 kf51 str k+ ----- function key 51
-#key_f52 kf52 str k+ ----- function key 52
-#key_f53 kf53 str k+ ----- function key 53
-#key_f54 kf54 str k+ ----- function key 54
-#key_f55 kf55 str k+ ----- function key 55
-#key_f56 kf56 str k+ ----- function key 56
-#key_f57 kf57 str k+ ----- function key 57
-#key_f58 kf58 str k+ ----- function key 58
-#key_f59 kf59 str k+ ----- function key 59
-#key_f60 kf60 str k+ ----- function key 60
-#key_f61 kf61 str k+ ----- function key 61
-#key_f62 kf62 str k+ ----- function key 62
-#key_f63 kf63 str k+ ----- function key 63
+#key_sf1 ksf1 str S1 - - ----K special function key 1
+#key_sf2 ksf2 str S2 - - ----K special function key 2
+#key_sf3 ksf3 str S3 - - ----K special function key 3
+#key_sf4 ksf4 str S4 - - ----K special function key 4
+#key_sf5 ksf5 str S5 - - ----K special function key 5
+#key_sf6 ksf6 str S6 - - ----K special function key 6
+#key_sf7 ksf7 str S7 - - ----K special function key 7
+#key_sf8 ksf8 str S8 - - ----K special function key 8
+#key_sf9 ksf9 str S9 - - ----K special function key 9
+#key_sf10 ksf10 str SA - - ----K special function key 10
+# AIX version 3 documents different codes for F11, F12 and does not mention
+# F13-F64. AIX version 4 uses the same naming for F0-F63 as above.
+#key_f11 kf11 str k< - - ----- function key 11
+#key_f12 kf12 str k> - - ----- function key 12
# Undocumented capabilities end here.
-#key_action kact str kJ ----K sent by action key
+#key_action kact str kJ - - ----K sent by action key
# The IBM docs say these capabilities are for table-drawing, and are
# valid only for aixterm descriptions.
-#enter_topline_mode topl str tp ----K start top-line mode
-#enter_bottom_mode btml str bm ----K start bottom-line mode
-#enter_rvert_mode rvert str rv ----K start right-vertical mode
-#enter_lvert_mode lvert str lv ----K start left-vertical mode
+#enter_topline_mode topl str tp - - ----K start top-line mode
+#enter_bottom_mode btml str bm - - ----K start bottom-line mode
+#enter_rvert_mode rvert str rv - - ----K start right-vertical mode
+#enter_lvert_mode lvert str lv - - ----K start left-vertical mode
#
#############################################################################
#
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile
index cf63dceaaac..9414ea4e646 100644
--- a/lib/libcurses/Makefile
+++ b/lib/libcurses/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.58 2009/08/13 19:54:58 jmc Exp $
+# $OpenBSD: Makefile,v 1.59 2010/01/12 23:21:58 nicm Exp $
# Uncomment this to enable tracing in libcurses
#CURSESTRACE=-DTRACE
@@ -17,13 +17,13 @@ WANTLINT=
SRCS= codes.c comp_captab.c expanded.c fallback.c lib_gen.c lib_keyname.c \
names.c unctrl.c
# base
-SRCS+= define_key.c keybound.c keyok.c lib_adabind.c lib_addch.c lib_addstr.c \
- lib_beep.c lib_bkgd.c lib_box.c lib_chgat.c lib_clear.c \
- lib_clearok.c lib_clrbot.c lib_clreol.c lib_color.c \
- lib_colorset.c lib_delch.c lib_delwin.c lib_dft_fgbg.c \
- lib_echo.c lib_endwin.c lib_erase.c lib_flash.c lib_freeall.c \
- lib_getch.c lib_getstr.c lib_hline.c lib_immedok.c lib_inchstr.c \
- lib_initscr.c lib_insch.c lib_insdel.c lib_insstr.c lib_instr.c \
+SRCS+= define_key.c key_defined.c keybound.c keyok.c legacy_coding.c \
+ lib_addch.c lib_addstr.c lib_beep.c lib_bkgd.c lib_box.c lib_chgat.c \
+ lib_clear.c lib_clearok.c lib_clrbot.c lib_clreol.c lib_color.c \
+ lib_colorset.c lib_delch.c lib_delwin.c lib_dft_fgbg.c lib_echo.c \
+ lib_endwin.c lib_erase.c lib_flash.c lib_freeall.c lib_getch.c \
+ lib_getstr.c lib_hline.c lib_immedok.c lib_inchstr.c lib_initscr.c \
+ lib_insnstr.c lib_insch.c lib_insdel.c lib_instr.c \
lib_isendwin.c lib_leaveok.c lib_mouse.c lib_move.c lib_mvwin.c \
lib_newterm.c lib_newwin.c lib_nl.c lib_overlay.c lib_pad.c \
lib_printw.c lib_redrawln.c lib_refresh.c lib_restart.c \
@@ -34,20 +34,22 @@ SRCS+= define_key.c keybound.c keyok.c lib_adabind.c lib_addch.c lib_addstr.c \
lib_slkrefr.c lib_slkset.c lib_slktouch.c lib_touch.c \
lib_ungetch.c lib_vline.c lib_wattroff.c lib_wattron.c \
lib_winch.c lib_window.c nc_panel.c resizeterm.c safe_sprintf.c \
- sigaction.c tries.c version.c wresize.c
+ tries.c use_window.c version.c vsscanf.c wresize.c
# tinfo
SRCS+= access.c add_tries.c alloc_entry.c alloc_ttype.c captoinfo.c \
comp_error.c comp_expand.c comp_hash.c comp_parse.c comp_scan.c \
- doalloc.c free_ttype.c getenv_num.c home_terminfo.c init_keytry.c \
- lib_acs.c lib_baudrate.c lib_cur_term.c lib_data.c lib_has_cap.c \
- lib_kernel.c lib_longname.c lib_napms.c lib_options.c lib_print.c \
- lib_raw.c lib_setup.c lib_termcap.c lib_termname.c lib_tgoto.c \
- lib_ti.c lib_tparm.c lib_tputs.c lib_ttyflags.c name_match.c \
- parse_entry.c read_bsd_terminfo.c read_entry.c read_termcap.c \
- setbuf.c strings.c write_entry.c
+ db_iterator.c doalloc.c entries.c free_ttype.c getenv_num.c \
+ hashed_db.c home_terminfo.c init_keytry.c lib_acs.c lib_baudrate.c \
+ lib_cur_term.c lib_data.c lib_has_cap.c lib_kernel.c lib_longname.c \
+ lib_napms.c lib_options.c lib_print.c lib_raw.c lib_setup.c \
+ lib_termcap.c lib_termname.c lib_tgoto.c lib_ti.c lib_tparm.c \
+ lib_tputs.c lib_ttyflags.c name_match.c parse_entry.c \
+ read_bsd_terminfo.c read_entry.c read_termcap.c setbuf.c strings.c \
+ trim_sgr0.c use_screen.c write_entry.c
# trace
SRCS+= lib_trace.c lib_traceatr.c lib_tracebits.c lib_tracechr.c \
- lib_tracedmp.c lib_tracemse.c trace_buf.c trace_tries.c trace_xnames.c
+ lib_tracedmp.c lib_tracemse.c trace_buf.c trace_tries.c trace_xnames.c \
+ varargs.c visbuf.c
# tty
SRCS+= hardscroll.c hashmap.c lib_mvcur.c lib_tstp.c lib_twait.c \
lib_vidattr.c tty_update.c
@@ -57,16 +59,30 @@ HOSTLDFLAGS?= ${LDFLAGS}
HOSTCFLAGS+= -I. -I${.CURDIR} ${CURSESTRACE}
CFLAGS+= -I. -I${.CURDIR} ${CURSESTRACE}
-MAN= curs_addch.3 curs_addchstr.3 curs_addstr.3 curs_attr.3 curs_beep.3 \
- curs_bkgd.3 curs_border.3 curs_clear.3 curs_color.3 curs_delch.3 \
- curs_deleteln.3 curs_extend.3 curs_getch.3 curs_getstr.3 curs_getyx.3 \
- curs_inch.3 curs_inchstr.3 curs_initscr.3 curs_inopts.3 curs_insch.3 \
- curs_insstr.3 curs_instr.3 curs_kernel.3 curs_mouse.3 curs_move.3 \
- curs_outopts.3 curs_overlay.3 curs_pad.3 curs_print.3 curs_printw.3 \
- curs_refresh.3 curs_scanw.3 curs_scr_dump.3 curs_scroll.3 curs_slk.3 \
- curs_termattrs.3 curs_touch.3 curs_util.3 curs_window.3 \
- curses.3 define_key.3 default_colors.3 keybound.3 keyok.3 resizeterm.3 \
- wresize.3 termcap.3 terminfo.3 terminfo.5 term.5 term.7
+MAN= curs_addch.3tbl curs_addchstr.3 curs_addstr.3 curs_attr.3tbl \
+ curs_beep.3 curs_bkgd.3 curs_bkgrnd.3 curs_border.3 curs_border_set.3 \
+ curs_clear.3 curs_color.3 \
+ curs_delch.3 curs_deleteln.3 \
+ curs_extend.3 \
+ curs_getch.3tbl curs_getstr.3 curs_getyx.3 \
+ curs_inch.3tbl curs_inchstr.3 curs_initscr.3 curs_inopts.3 curs_insch.3 curs_insstr.3 curs_instr.3 \
+ curs_kernel.3 \
+ curs_legacy.3 \
+ curs_mouse.3tbl curs_move.3 \
+ curs_opaque.3 curs_outopts.3 curs_overlay.3 \
+ curs_pad.3 curs_print.3 curs_printw.3 \
+ curs_refresh.3 \
+ curs_scanw.3 curs_scr_dump.3 curs_scroll.3 curs_slk.3 \
+ curs_termattrs.3 curs_touch.3 \
+ curs_util.3 \
+ curs_window.3 \
+ default_colors.3 define_key.3 \
+ key_defined.3 keybound.3 keyok.3 \
+ curses.3tbl \
+ resizeterm.3 \
+ term.5tbl term.7 termcap.3 terminfo.3 terminfo.5tbl \
+ wresize.3
+
MLINKS+=curses.3 ncurses.3
MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 mvaddch.3 \
curs_addch.3 mvwaddch.3 curs_addch.3 echochar.3 curs_addch.3 \
@@ -186,9 +202,28 @@ MLINKS+= terminfo.3 setupterm.3 terminfo.3 setterm.3 terminfo.3 set_curterm.3 \
terminfo.3 tigetflag.3 terminfo.3 tigetnum.3 terminfo.3 tigetstr.3
MLINKS+= termcap.3 tgetent.3 termcap.3 tgetflag.3 termcap.3 tgetnum.3 \
termcap.3 tgetstr.3 termcap.3 tgoto.3 termcap.3 tputs.3
+MLINKS+= curs_bkgrnd.3 bkgrnd.3 curs_bkgrnd.3 wbkgrnd.3 \
+ curs_bkgrnd.3 bkgrndset.3 curs_bkgrnd.3 wbkgrndset.3 \
+ curs_bkgrnd.3 getbkgrnd.3 curs_bkgrnd.3 wgetbkgrnd.3
+MLINKS+= curs_border_set.3 border_set.3 curs_border_set.3 wborder_set.3 \
+ curs_border_set.3 box_set.3 curs_border_set.3 hline_set.3 \
+ curs_border_set.3 whline_set.3 curs_border_set.3 mvhline_set.3 \
+ curs_border_set.3 mvhline_set.3 curs_border_set.3 mvwhline_set.3 \
+ curs_border_set.3 vline_set.3 curs_border_set.3 wvline_set.3 \
+ curs_border_set.3 mvvline_set.3 curs_border_set.3 mvwvline_set.3
+MLINKS+= curs_legacy.3 getbegx.3 curs_legacy.3 getbegy.3 \
+ curs_legacy.3 getcurx.3 curs_legacy.3 getcury.3 \
+ curs_legacy.3 getmaxx.3 curs_legacy.3 getmaxy.3 \
+ curs_legacy.3 getparx.3 curs_legacy.3 getpary.3
+MLINKS+= curs_opaque.3 is_cleared.3 curs_opaque.3 is_idcok.3 \
+ curs_opaque.3 is_idlok.3 curs_opaque.3 is_immedok.3 \
+ curs_opaque.3 is_keypad.3 curs_opaque.3 is_leaveok.3 \
+ curs_opaque.3 is_nodelay.3 curs_opaque.3 is_notimeout.3 \
+ curs_opaque.3 is_scrollok.3 curs_opaque.3 is_syncok.3 \
+ curs_opaque.3 wgetparent.3 curs_opaque.3 wgetscrreg.3
-GENERATED= init_keytry.h nomacros.h codes.c comp_captab.c expanded.c \
- fallback.c lib_gen.c lib_keyname.c names.c unctrl.c make_hash make_keys
+GENERATED= init_keytry.h codes.c comp_captab.c expanded.c fallback.c \
+ keys.list lib_gen.c lib_keyname.c names.c unctrl.c make_hash make_keys
CLEANFILES+= ${GENERATED} stamp_namebuild
.if make(install)
@@ -208,44 +243,51 @@ includes:
${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) $$i \
${DESTDIR}/usr/include; done
-fallback.c: ${.CURDIR}/term.h ${.CURDIR}/curses.priv.h ${.CURDIR}/tinfo/MKfallback.sh
- sh ${.CURDIR}/tinfo/MKfallback.sh $(FALLBACK_LIST) > ${.TARGET}
+keys.list: ${.CURDIR}/tinfo/MKkeys_list.sh
+ sh ${.CURDIR}/tinfo/MKkeys_list.sh ${.CURDIR}/Caps | sort > ${.TARGET}
-lib_gen.c: ${.CURDIR}/curses.h ${.CURDIR}/base/MKlib_gen.sh
- sh ${.CURDIR}/base/MKlib_gen.sh "${CPP} -I${.CURDIR}" "${AWK}" < ${.CURDIR}/curses.h > lib_gen.c
+fallback.c: ${.CURDIR}/tinfo/MKfallback.sh
+ sh ${.CURDIR}/tinfo/MKfallback.sh $(FALLBACK_LIST) > ${.TARGET}
-nomacros.h: ${.CURDIR}/base/MKlib_gen.sh lib_gen.c
- fgrep undef lib_gen.c > ${.TARGET}
+lib_gen.c: ${.CURDIR}/base/MKlib_gen.sh
+ sh ${.CURDIR}/base/MKlib_gen.sh "${CPP} -I${.CURDIR}" \
+ "${AWK}" generated < ${.CURDIR}/curses.h > lib_gen.c
-init_keytry.h: make_keys ${.CURDIR}/tinfo/keys.list
- ./make_keys ${.CURDIR}/tinfo/keys.list > ${.TARGET}
+init_keytry.h: make_keys keys.list
+ ./make_keys keys.list > ${.TARGET}
-make_keys: ${.CURDIR}/tinfo/make_keys.c names.c
- ${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} ${HOSTLDFLAGS} -o ${.TARGET} ${.CURDIR}/tinfo/make_keys.c ${LDADD}
+make_keys: ${.CURDIR}/tinfo/make_keys.c ${.CURDIR}/curses.priv.h names.c
+ ${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} ${HOSTLDFLAGS} \
+ -o ${.TARGET} ${.CURDIR}/tinfo/make_keys.c ${LDADD}
-make_hash: ${.CURDIR}/tinfo/comp_hash.c ${.CURDIR}/hashsize.h
- ${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} -DMAIN_PROGRAM ${HOSTLDFLAGS} -o ${.TARGET} ${.CURDIR}/tinfo/comp_hash.c ${LDADD}
+make_hash: ${.CURDIR}/tinfo/comp_hash.c ${.CURDIR}/curses.priv.h \
+ ${.CURDIR}/hashsize.h
+ ${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} -DMAIN_PROGRAM ${HOSTLDFLAGS} \
+ -o ${.TARGET} ${.CURDIR}/tinfo/comp_hash.c ${LDADD}
-expanded.c: ${.CURDIR}/term.h ${.CURDIR}/curses.priv.h ${.CURDIR}/tty/MKexpanded.sh
+expanded.c: ${.CURDIR}/term.h ${.CURDIR}/curses.priv.h \
+ ${.CURDIR}/ncurses_cfg.h ${.CURDIR}/tty/MKexpanded.sh
sh ${.CURDIR}/tty/MKexpanded.sh "${CPP}" ${CPPFLAGS} > ${.TARGET}
-comp_captab.c: make_hash ${.CURDIR}/ncurses_cfg.h ${.CURDIR}/tic.h ${.CURDIR}/term.h
- sh ${.CURDIR}/tinfo/MKcaptab.awk ${AWK} ${.CURDIR}/Caps > ${.TARGET}
+comp_captab.c: make_hash
+ sh ${.CURDIR}/tinfo/MKcaptab.sh ${AWK} 1 \
+ ${.CURDIR}/tinfo/MKcaptab.awk ${.CURDIR}/Caps > ${.TARGET}
-lib_keyname.c: ${.CURDIR}/ncurses_cfg.h ${.CURDIR}/curses.h ${.CURDIR}/term.h ${.CURDIR}/tinfo/keys.list ${.CURDIR}/base/MKkeyname.awk
- ${AWK} -f ${.CURDIR}/base/MKkeyname.awk ${.CURDIR}/tinfo/keys.list > ${.TARGET}
+lib_keyname.c: keys.list ${.CURDIR}/base/MKkeyname.awk
+ ${AWK} -f ${.CURDIR}/base/MKkeyname.awk bigstrings=1 \
+ keys.list > ${.TARGET}
names.c codes.c: stamp_namebuild
-stamp_namebuild: ${.CURDIR}/tinfo/MKnames.awk
- ${AWK} -f ${.CURDIR}/tinfo/MKnames.awk ${.CURDIR}/Caps
- cat namehdr boolnames boolfnames numnames numfnames strnames strfnames nameftr > names.c
- cat namehdr boolcodes numcodes strcodes codeftr > codes.c
- -rm -f namehdr nameftr codeftr boolnames boolfnames boolcodes numnames numfnames numcodes strnames strfnames strcodes
+stamp_namebuild: ${.CURDIR}/tinfo/MKnames.awk ${.CURDIR}/tinfo/MKcodes.awk
+ ${AWK} -f ${.CURDIR}/tinfo/MKnames.awk \
+ ${.CURDIR}/Caps > names.c
+ ${AWK} -f ${.CURDIR}/tinfo/MKcodes.awk \
+ bigstrings=1 ${.CURDIR}/Caps > codes.c
touch $@
unctrl.c: ${.CURDIR}/base/MKunctrl.awk
- echo | ${AWK} -f ${.CURDIR}/base/MKunctrl.awk > ${.TARGET}
+ echo | ${AWK} -f ${.CURDIR}/base/MKunctrl.awk bigstrings=1 > ${.TARGET}
.include <bsd.own.mk>
diff --git a/lib/libcurses/SigAction.h b/lib/libcurses/SigAction.h
index 5faf7c43e53..3a2783284d1 100644
--- a/lib/libcurses/SigAction.h
+++ b/lib/libcurses/SigAction.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: SigAction.h,v 1.3 2001/01/22 18:01:32 millert Exp $ */
+/* $OpenBSD: SigAction.h,v 1.4 2010/01/12 23:21:58 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -34,7 +34,7 @@
****************************************************************************/
/*
- * $From: SigAction.h,v 1.6 2000/12/10 02:36:10 tom Exp $
+ * $Id: SigAction.h,v 1.4 2010/01/12 23:21:58 nicm Exp $
*
* This file exists to handle non-POSIX systems which don't have <unistd.h>,
* and usually no sigaction() nor <termios.h>
@@ -61,10 +61,6 @@ typedef struct sigaction sigaction_t;
#if HAVE_SIGVEC
-#if HAVE_LIBC_H
-#include <libc.h>
-#endif
-
#undef SIG_BLOCK
#define SIG_BLOCK 00
@@ -107,12 +103,8 @@ typedef unsigned long sigset_t;
#undef sigaddset
#define sigaddset _nc_sigaddset
-extern NCURSES_EXPORT(int) sigaction (int sig, sigaction_t * sigact, sigaction_t * osigact);
-extern NCURSES_EXPORT(int) sigprocmask (int how, sigset_t *mask, sigset_t *omask);
-extern NCURSES_EXPORT(int) sigemptyset (sigset_t *mask);
-extern NCURSES_EXPORT(int) sigsuspend (sigset_t *mask);
-extern NCURSES_EXPORT(int) sigdelset (sigset_t *mask, int sig);
-extern NCURSES_EXPORT(int) sigaddset (sigset_t *mask, int sig);
+/* tty/lib_tstp.c is the only user */
+#include <base/sigaction.c>
#endif /* HAVE_SIGVEC */
#endif /* HAVE_SIGACTION */
diff --git a/lib/libcurses/base/MKkeyname.awk b/lib/libcurses/base/MKkeyname.awk
index 5c45e22cc6e..9f98264a0ca 100644
--- a/lib/libcurses/base/MKkeyname.awk
+++ b/lib/libcurses/base/MKkeyname.awk
@@ -1,7 +1,7 @@
-# $OpenBSD: MKkeyname.awk,v 1.4 2003/03/17 21:54:44 millert Exp $
-# $From: MKkeyname.awk,v 1.18 2000/12/10 02:25:23 tom Exp $
+# $OpenBSD: MKkeyname.awk,v 1.5 2010/01/12 23:22:05 nicm Exp $
+# $Id: MKkeyname.awk,v 1.5 2010/01/12 23:22:05 nicm Exp $
##############################################################################
-# Copyright (c) 1999,2000 Free Software Foundation, Inc. #
+# Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -30,49 +30,136 @@
BEGIN {
print "/* generated by MKkeyname.awk */"
print ""
- print "#include <ncurses_cfg.h>"
- print "#include <stdlib.h>"
- print "#include <string.h>"
- print "#include <curses.h>"
+ print "#include <curses.priv.h>"
print "#include <tic.h>"
+ print "#include <term_entry.h>"
print ""
- print "const struct kn _nc_key_names[] = {"
+ first = 1;
}
/^[^#]/ {
- printf "\t{ \"%s\", %s },\n", $1, $1;
+ if (bigstrings) {
+ if (first) {
+ print "struct kn { short offset; int code; };"
+ print "static const struct kn _nc_key_names[] = {"
+ }
+ printf "\t{ %d, %s },\n", offset, $1
+ offset += length($1) + 1
+ names = names"\n\t\""$1"\\0\""
+ } else {
+ if (first) {
+ print "struct kn { const char *name; int code; };"
+ print "static const struct kn _nc_key_names[] = {"
+ }
+ printf "\t{ \"%s\", %s },\n", $1, $1;
+ }
+ first = 0;
}
END {
- printf "\t{ 0, 0 }};\n"
+ if (bigstrings) {
+ printf "\t{ -1, 0 }};\n"
+ print ""
+ print "static const char key_names[] = "names";"
+ } else {
+ printf "\t{ 0, 0 }};\n"
+ }
+ print ""
+ print "#define SIZEOF_TABLE 256"
+ print "#define MyTable _nc_globals.keyname_table"
+ print ""
+ print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *sp, int c)"
+ print "{"
+ print " int i;"
+ print " char name[20];"
+ print " char *p;"
+ print " size_t psize;"
+ print " NCURSES_CONST char *result = 0;"
+ print ""
+ print " if (c == -1) {"
+ print " result = \"-1\";"
+ print " } else {"
+ if (bigstrings) {
+ print " for (i = 0; _nc_key_names[i].offset != -1; i++) {"
+ print " if (_nc_key_names[i].code == c) {"
+ print " result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset;"
+ print " break;"
+ print " }"
+ print " }"
+ } else {
+ print " for (i = 0; _nc_key_names[i].name != 0; i++) {"
+ print " if (_nc_key_names[i].code == c) {"
+ print " result = (NCURSES_CONST char *)_nc_key_names[i].name;"
+ print " break;"
+ print " }"
+ print " }"
+ }
+ print ""
+ print " if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {"
+ print " if (MyTable == 0)"
+ print " MyTable = typeCalloc(char *, SIZEOF_TABLE);"
+ print " if (MyTable != 0) {"
+ print " if (MyTable[c] == 0) {"
+ print " int cc = c;"
+ print " p = name;"
+ print " psize = sizeof(name);"
+ print " if (cc >= 128 && (sp == 0 || sp->_use_meta)) {"
+ print " strlcpy(p, \"M-\", psize);"
+ print " p += 2;"
+ print " psize -= 2;"
+ print " cc -= 128;"
+ print " }"
+ print " if (cc < 32)"
+ print " snprintf(p, psize, \"^%c\", cc + '@');"
+ print " else if (cc == 127)"
+ print " strlcpy(p, \"^?\", psize);"
+ print " else"
+ print " snprintf(p, psize, \"%c\", cc);"
+ print " MyTable[c] = strdup(name);"
+ print " }"
+ print " result = MyTable[c];"
+ print " }"
+ print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES"
+ print " } else if (result == 0 && cur_term != 0) {"
+ print " int j, k;"
+ print " char * bound;"
+ print " TERMTYPE *tp = &(cur_term->type);"
+ print " int save_trace = _nc_tracing;"
+ print ""
+ print " _nc_tracing = 0; /* prevent recursion via keybound() */"
+ print " for (j = 0; (bound = keybound(c, j)) != 0; ++j) {"
+ print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {"
+ print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {"
+ print " result = ExtStrname(tp, k, strnames);"
+ print " break;"
+ print " }"
+ print " }"
+ print " free(bound);"
+ print " if (result != 0)"
+ print " break;"
+ print " }"
+ print " _nc_tracing = save_trace;"
+ print "#endif"
+ print " }"
+ print " }"
+ print " return result;"
+ print "}"
print ""
print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
print "{"
- print "\tint i;"
- print "\tstatic char name[20];"
- print "\tchar *p;"
- print "\tsize_t psize;"
+ print "\treturn _nc_keyname(SP, c);"
+ print "}"
print ""
- print "\tfor (i = 0; _nc_key_names[i].name != 0; i++)"
- print "\t\tif (_nc_key_names[i].code == c)"
- print "\t\t\treturn (NCURSES_CONST char *)_nc_key_names[i].name;"
- print "\tif (c >= 256) return \"UNKNOWN KEY\";"
- print "\tp = name;"
- print "\tpsize = sizeof(name);"
- print "\tif (c >= 128) {"
- print "\t\tstrlcpy(p, \"M-\", psize);"
- print "\t\tp += 2;"
- print "\t\tpsize -= 2;"
- print "\t\tc -= 128;"
- print "\t}"
- print "\tif (c < 0)"
- print "\t\tsnprintf(p, psize, \"%d\", c);"
- print "\telse if (c < 32)"
- print "\t\tsnprintf(p, psize, \"^%c\", c + '@');"
- print "\telse if (c == 127)"
- print "\t\tstrlcpy(p, \"^?\", psize);"
- print "\telse"
- print "\t\tsnprintf(p, psize, \"%c\", c);"
- print "\treturn (NCURSES_CONST char *)name;"
+ print "#if NO_LEAKS"
+ print "void _nc_keyname_leaks(void)"
+ print "{"
+ print " int j;"
+ print " if (MyTable != 0) {"
+ print " for (j = 0; j < SIZEOF_TABLE; ++j) {"
+ print " FreeIfNeeded(MyTable[j]);"
+ print " }"
+ print " FreeAndNull(MyTable);"
+ print " }"
print "}"
+ print "#endif /* NO_LEAKS */"
}
diff --git a/lib/libcurses/base/MKlib_gen.sh b/lib/libcurses/base/MKlib_gen.sh
index ad30cb2b149..1c183621da8 100644
--- a/lib/libcurses/base/MKlib_gen.sh
+++ b/lib/libcurses/base/MKlib_gen.sh
@@ -2,8 +2,36 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# $OpenBSD: MKlib_gen.sh,v 1.3 2001/01/22 18:01:36 millert Exp $
-# ($From: MKlib_gen.sh,v 1.13 2000/12/10 00:30:25 tom Exp $)
+# $OpenBSD: MKlib_gen.sh,v 1.4 2010/01/12 23:22:05 nicm Exp $
+# ($Id: MKlib_gen.sh,v 1.4 2010/01/12 23:22:05 nicm Exp $)
+#
+##############################################################################
+# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
#
# The XSI Curses standard requires all curses entry points to exist as
# functions, even though many definitions would normally be shadowed
@@ -12,14 +40,14 @@
#
# This script accepts a file of prototypes on standard input. It discards
# any that don't have a `generated' comment attached. It then parses each
-# prototype (relying on the fact that none of the macros take function
+# prototype (relying on the fact that none of the macros take function
# pointer or array arguments) and generates C source from it.
#
# Here is what the pipeline stages are doing:
#
# 1. sed: extract prototypes of generated functions
# 2. sed: decorate prototypes with generated arguments a1. a2,...z
-# 3. awk: generate the calls with args matching the formals
+# 3. awk: generate the calls with args matching the formals
# 4. sed: prefix function names in prototypes so the preprocessor won't expand
# them.
# 5. cpp: macro-expand the file so the macro calls turn into C calls
@@ -27,32 +55,62 @@
# 7. sed: squeeze spaces, strip off gen_ prefix, create needed #undef
#
-preprocessor="$1 -I../include"
+# keep the editing independent of locale:
+if test "${LANGUAGE+set}" = set; then LANGUAGE=C; export LANGUAGE; fi
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+if test "${LC_COLLATE+set}" = set; then LC_COLLATE=C; export LC_COLLATE; fi
+
+preprocessor="$1 -DNCURSES_INTERNALS -I../include"
AWK="$2"
-ED1=sed1$$.sed
-ED2=sed2$$.sed
-ED3=sed3$$.sed
-AW1=awk1$$.awk
-TMP=gen$$.c
-trap "rm -f $ED1 $ED2 $ED3 $AW1 $TMP" 0 1 2 5 15
+USE="$3"
-(cat <<EOF
-#include <ncurses_cfg.h>
-#include <curses.h>
+PID=$$
+ED1=sed1_${PID}.sed
+ED2=sed2_${PID}.sed
+ED3=sed3_${PID}.sed
+ED4=sed4_${PID}.sed
+AW1=awk1_${PID}.awk
+AW2=awk2_${PID}.awk
+TMP=gen__${PID}.c
+trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0 1 2 5 15
-DECLARATIONS
-
-EOF
-cat >$ED1 <<EOF1
+ALL=$USE
+if test "$USE" = implemented ; then
+ CALL="call_"
+ cat >$ED1 <<EOF1
+/^extern.*implemented/{
+ h
+ s/^.*implemented:\([^ *]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
+ g
+ s/^extern \([^;]*\);.*/\1/p
+ g
+ s/^.*implemented:\([^ *]*\).*/P_POUNDCendif/p
+}
/^extern.*generated/{
h
- s/^.*generated:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p
+ s/^.*generated:\([^ *]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
+ g
+ s/^extern \([^;]*\);.*/\1/p
+ g
+ s/^.*generated:\([^ *]*\).*/P_POUNDCendif/p
+}
+EOF1
+else
+ CALL=""
+ cat >$ED1 <<EOF1
+/^extern.*${ALL}/{
+ h
+ s/^.*${ALL}:\([^ *]*\).*/P_POUNDCif_USE_\1_SUPPORT/p
g
s/^extern \([^;]*\);.*/\1/p
g
- s/^.*generated:\([^ *]*\).*/P_#endif/p
+ s/^.*${ALL}:\([^ *]*\).*/P_POUNDCendif/p
}
EOF1
+fi
cat >$ED2 <<EOF2
/^P_/b nc
@@ -75,55 +133,102 @@ cat >$ED2 <<EOF2
s/*/ * /g
s/%/ , /g
s/)/ z)/
+ s/\.\.\. z)/...)/
:nc
- /(/s// ( /
+ s/(/ ( /
s/)/ )/
EOF2
cat >$ED3 <<EOF3
/^P_/{
- s/^P_#if_/#if /
+ s/^P_POUNDCif_/#if /
+ s/^P_POUNDCendif/#endif/
s/^P_//
b done
}
s/ */ /g
s/ */ /g
s/ ,/,/g
+ s/( /(/g
s/ )/)/g
s/ gen_/ /
s/^M_/#undef /
- /^%%/s// /
+ s/^[ ]*@[ ]*@[ ]*/ /
:done
EOF3
+if test "$USE" = generated ; then
+cat >$ED4 <<EOF
+ s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) \2 (\3)/
+EOF
+else
+cat >$ED4 <<EOF
+/^\(.*\) \(.*\) (\(.*\))\$/ {
+ h
+ s/^\(.*\) \(.*\) (\(.*\))\$/extern \1 call_\2 (\3);/
+ p
+ g
+ s/^\(.*\) \(.*\) (\(.*\))\$/\1 call_\2 (\3)/
+ }
+EOF
+fi
+
cat >$AW1 <<\EOF1
BEGIN {
skip=0;
}
- /^P_#if/ {
+/^P_POUNDCif/ {
print "\n"
print $0
skip=0;
- }
- /^P_#endif/ {
+}
+/^P_POUNDCendif/ {
print $0
skip=1;
- }
- $0 !~ /^P_/ {
+}
+$0 !~ /^P_/ {
if (skip)
print "\n"
skip=1;
- if ( $1 == "chtype" ) {
+ first=$1
+ for (i = 1; i <= NF; i++) {
+ if ( $i != "NCURSES_CONST" ) {
+ first = i;
+ break;
+ }
+ }
+ second = first + 1;
+ if ( $first == "chtype" ) {
returnType = "Char";
+ } else if ( $first == "SCREEN" ) {
+ returnType = "SP";
+ } else if ( $first == "WINDOW" ) {
+ returnType = "Win";
+ } else if ( $first == "attr_t" || $second == "attrset" || $second == "standout" || $second == "standend" || $second == "wattrset" || $second == "wstandout" || $second == "wstandend" ) {
+ returnType = "Attr";
+ } else if ( $first == "bool" || $first == "NCURSES_BOOL" ) {
+ returnType = "Bool";
+ } else if ( $second == "*" ) {
+ returnType = "Ptr";
} else {
returnType = "Code";
}
- print "M_" $2
+ myfunc = second;
+ for (i = second; i <= NF; i++) {
+ if ($i != "*") {
+ myfunc = i;
+ break;
+ }
+ }
+ if (using == "generated") {
+ print "M_" $myfunc
+ }
print $0;
print "{";
argcount = 1;
- if (NF == 5 && $4 == "void")
+ check = NF - 1;
+ if ($check == "void")
argcount = 0;
if (argcount != 0) {
for (i = 1; i <= NF; i++)
@@ -134,21 +239,36 @@ BEGIN {
# suppress trace-code for functions that we cannot do properly here,
# since they return data.
dotrace = 1;
- if ($2 == "innstr")
+ if ($myfunc ~ /innstr/)
+ dotrace = 0;
+ if ($myfunc ~ /innwstr/)
dotrace = 0;
- call = "%%T((T_CALLED(\""
+ # workaround functions that we do not parse properly
+ if ($myfunc ~ /ripoffline/) {
+ dotrace = 0;
+ argcount = 2;
+ }
+ if ($myfunc ~ /wunctrl/) {
+ dotrace = 0;
+ }
+
+ call = "@@T((T_CALLED(\""
args = ""
comma = ""
num = 0;
pointer = 0;
+ va_list = 0;
+ varargs = 0;
argtype = ""
- for (i = 1; i <= NF; i++) {
+ for (i = myfunc; i <= NF; i++) {
ch = $i;
if ( ch == "*" )
pointer = 1;
else if ( ch == "va_list" )
- pointer = 1;
+ va_list = 1;
+ else if ( ch == "..." )
+ varargs = 1;
else if ( ch == "char" )
argtype = "char";
else if ( ch == "int" )
@@ -161,7 +281,11 @@ BEGIN {
argtype = "attr";
if ( ch == "," || ch == ")" ) {
- if (pointer) {
+ if (va_list) {
+ call = call "%s"
+ } else if (varargs) {
+ call = call "%s"
+ } else if (pointer) {
if ( argtype == "char" ) {
call = call "%s"
comma = comma "_nc_visbuf2(" num ","
@@ -180,10 +304,17 @@ BEGIN {
comma = comma "(long)"
}
}
- if (ch == ",")
+ if (ch == ",") {
args = args comma "a" ++num;
- else if (argcount != 0)
- args = args comma "z"
+ } else if ( argcount != 0 ) {
+ if ( va_list ) {
+ args = args comma "\"va_list\""
+ } else if ( varargs ) {
+ args = args comma "\"...\""
+ } else {
+ args = args comma "z"
+ }
+ }
call = call ch
if (pointer == 0 && argcount != 0 && argtype != "" )
args = args ")"
@@ -208,13 +339,19 @@ BEGIN {
else if (dotrace)
call = sprintf("return%s( ", returnType);
else
- call = "%%return ";
+ call = "@@return ";
- call = call $2 "(";
- for (i = 1; i < argcount; i++)
- call = call "a" i ", ";
- if (argcount != 0)
+ call = call $myfunc "(";
+ for (i = 1; i < argcount; i++) {
+ if (i != 1)
+ call = call ", ";
+ call = call "a" i;
+ }
+ if ( argcount != 0 && $check != "..." ) {
+ if (argcount != 1)
+ call = call ", ";
call = call "z";
+ }
if (!match($0, "^void"))
call = call ") ";
if (dotrace)
@@ -222,43 +359,72 @@ BEGIN {
print call ";"
if (match($0, "^void"))
- print "%%returnVoid;"
+ print "@@returnVoid;"
print "}";
}
EOF1
+cat >$AW2 <<EOF1
+BEGIN {
+ print "/*"
+ print " * DO NOT EDIT THIS FILE BY HAND!"
+ printf " * It is generated by $0 %s.\n", "$USE"
+ if ( "$USE" == "generated" ) {
+ print " *"
+ print " * This is a file of trivial functions generated from macro"
+ print " * definitions in curses.h to satisfy the XSI Curses requirement"
+ print " * that every macro also exist as a callable function."
+ print " *"
+ print " * It will never be linked unless you call one of the entry"
+ print " * points with its normal macro definition disabled. In that"
+ print " * case, if you have no shared libraries, it will indirectly"
+ print " * pull most of the rest of the library into your link image."
+ }
+ print " */"
+ print "#define NCURSES_ATTR_T int"
+ print "#include <curses.priv.h>"
+ print ""
+ }
+/^DECLARATIONS/ {start = 1; next;}
+ {if (start) print \$0;}
+END {
+ if ( "$USE" != "generated" ) {
+ print "int main(void) { return 0; }"
+ }
+ }
+EOF1
+
+cat >$TMP <<EOF
+#include <ncurses_cfg.h>
+#undef NCURSES_NOMACROS
+#include <curses.h>
+
+DECLARATIONS
+
+EOF
+
sed -n -f $ED1 \
| sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \
| sed -f $ED2 \
-| $AWK -f $AW1 ) \
+| $AWK -f $AW1 using=$USE \
| sed \
- -e '/^\([a-z_][a-z_]*\) /s//\1 gen_/' >$TMP
- $preprocessor $TMP 2>/dev/null \
-| $AWK '
-BEGIN {
- print "/*"
- print " * DO NOT EDIT THIS FILE BY HAND!"
- print " * It is generated by MKlib_gen.sh."
- print " *"
- print " * This is a file of trivial functions generated from macro"
- print " * definitions in curses.h to satisfy the XSI Curses requirement"
- print " * that every macro also exist as a callable function."
- print " *"
- print " * It will never be linked unless you call one of the entry"
- print " * points with its normal macro definition disabled. In that"
- print " * case, if you have no shared libraries, it will indirectly"
- print " * pull most of the rest of the library into your link image."
- print " */"
- print "#include <curses.priv.h>"
- print ""
- }
-/^DECLARATIONS/ {start = 1; next;}
- {if (start) print $0;}
-' \
+ -e 's/ [ ]*$//g' \
+ -e 's/^\([a-zA-Z_][a-zA-Z_]*[ *]*\)/\1 gen_/' \
+ -e 's/gen_$//' \
+ -e 's/ / /g' >>$TMP
+
+$preprocessor $TMP 2>/dev/null \
+| sed \
+ -e 's/ / /g' \
+ -e 's/^ //' \
+ -e 's/_Bool/NCURSES_BOOL/g' \
+| $AWK -f $AW2 \
| sed -f $ED3 \
| sed \
-e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \
-e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/' \
-| sed \
- -e 's/^\(.*\) \(.*\) (\(.*\))$/NCURSES_EXPORT(\1) \2 (\3)/'
-
+ -e 's/gen_//' \
+ -e 's/^[ ]*#/#/' \
+ -e '/#ident/d' \
+ -e '/#line/d' \
+| sed -f $ED4
diff --git a/lib/libcurses/base/MKunctrl.awk b/lib/libcurses/base/MKunctrl.awk
index ee9423558c5..506443a6512 100644
--- a/lib/libcurses/base/MKunctrl.awk
+++ b/lib/libcurses/base/MKunctrl.awk
@@ -1,7 +1,7 @@
-# $OpenBSD: MKunctrl.awk,v 1.3 2001/01/22 18:01:36 millert Exp $
-# $From: MKunctrl.awk,v 1.8 2000/12/10 02:25:37 tom Exp $
+# $OpenBSD: MKunctrl.awk,v 1.4 2010/01/12 23:22:05 nicm Exp $
+# $Id: MKunctrl.awk,v 1.4 2010/01/12 23:22:05 nicm Exp $
##############################################################################
-# Copyright (c) 1998,2000 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -28,43 +28,166 @@
# authorization. #
##############################################################################
#
-# Author: Thomas E. Dickey <dickey@clark.net> 1997
+# Author: Thomas E. Dickey (1997-on)
#
BEGIN {
print "/* generated by MKunctrl.awk */"
print ""
print "#include <curses.priv.h>"
+ print "#include <ctype.h>"
+ print ""
+ print "#if USE_WIDEC_SUPPORT"
+ print "#if HAVE_WCTYPE_H"
+ print "#include <wctype.h>"
+ print "#endif"
+ print "#endif"
print ""
print "#undef unctrl"
print ""
}
END {
- print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (register chtype ch)"
+ print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *sp, chtype ch)"
print "{"
- printf "static const char* const table[] = {"
+
+ blob=""
+ offset=0
+ if (bigstrings) {
+ printf "static const short unctrl_table[] = {"
+ } else {
+ printf "static const char* const unctrl_table[] = {"
+ }
for ( ch = 0; ch < 256; ch++ ) {
gap = ","
- if ((ch % 8) == 0)
+ part=""
+ if ((ch % 8) == 0) {
printf "\n "
+ if (ch != 0)
+ blob = blob "\""
+ blob = blob "\n \""
+ }
+ if (bigstrings)
+ printf "%4d%s", offset, gap;
if (ch < 32) {
- printf "\"^\\%03o\"", ch + 64
+ part = sprintf ("^\\%03o", ch + 64);
+ offset = offset + 3;
} else if (ch == 127) {
- printf "\"^?\""
+ part = "^?";
+ offset = offset + 3;
} else if (ch >= 128 && ch < 160) {
- printf "\"~\\%03o\"", ch - 64
+ part = sprintf("~\\%03o", ch - 64);
+ offset = offset + 3;
+ } else if (ch == 255) {
+ part = "~?";
+ offset = offset + 3;
+ } else if (ch >= 160) {
+ part = sprintf("M-\\%03o", ch - 128);
+ offset = offset + 4;
} else {
- printf "\"\\%03o\"", ch
gap = gap " "
+ part = sprintf("\\%03o", ch);
+ offset = offset + 2;
}
if (ch == 255)
gap = "\n"
else if (((ch + 1) % 8) != 0)
gap = gap " "
- printf "%s", gap
+ if (bigstrings) {
+ blob = blob part "\\0";
+ } else {
+ printf "\"%s\"%s", part, gap
+ }
+ }
+ print "};"
+ blob = blob "\"";
+
+ print ""
+ printf "#if NCURSES_EXT_FUNCS\n";
+ if (bigstrings) {
+ blob = blob "\n/* printable values in 128-255 range */"
+ printf "static const short unctrl_c1[] = {"
+ } else {
+ printf "static const char* const unctrl_c1[] = {"
+ }
+ for ( ch = 128; ch < 256; ch++ ) {
+ gap = ","
+ if ((ch % 8) == 0) {
+ if (ch != 128)
+ blob = blob "\""
+ printf "\n "
+ blob = blob "\n \""
+ }
+ if (bigstrings) {
+ printf "%4d%s", offset, gap;
+ part = sprintf("\\%03o\\0", ch);
+ blob = blob part
+ offset = offset + 2;
+ if (((ch + 1) % 8) != 0)
+ gap = gap " "
+ } else {
+ if (ch >= 128) {
+ printf "\"\\%03o\"", ch
+ gap = gap " "
+ }
+ if (ch == 255)
+ gap = "\n"
+ else if (((ch + 1) % 8) != 0)
+ gap = gap " "
+ printf "%s", gap
+ }
}
print "};"
+ print "#endif /* NCURSES_EXT_FUNCS */"
+ blob = blob "\"\n"
+
print ""
- print "\treturn (NCURSES_CONST char *)table[TextOf(ch)];"
- print "}"
+ if (bigstrings) {
+ print "static const char unctrl_blob[] = "blob";"
+ print ""
+ stringname = "unctrl_blob + unctrl"
+ } else {
+ stringname = "unctrl"
+ }
+ print "\tint check = ChCharOf(ch);"
+ print "\tconst char *result;"
+ print ""
+ print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
+ print "#if NCURSES_EXT_FUNCS"
+ print "\t\tif ((sp != 0)"
+ print "\t\t && (sp->_legacy_coding > 1)"
+ print "\t\t && (check >= 128)"
+ print "\t\t && (check < 160))"
+ printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
+ print "\t\telse"
+ print "#if USE_WIDEC_SUPPORT"
+ print "\t\tif ((check >= 160)"
+ print "\t\t && (check < 256)"
+ print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp->_legacy_coding > 0)"
+ print "\t\t || (sp->_legacy_coding == 0"
+ print "\t\t && (isprint(check) || iswprint(check))))))"
+ printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
+ print "\t\telse"
+ print "#else"
+ print "\t\tif ((check >= 160)"
+ print "\t\t && (check < 256)"
+ print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp->_legacy_coding > 0)"
+ print "\t\t || (sp->_legacy_coding == 0"
+ print "\t\t && isprint(check)))))"
+ printf "\t\t\tresult = %s_c1[check - 128];\n", stringname;
+ print "\t\telse"
+ print "#endif /* USE_WIDEC_SUPPORT */"
+ print "#endif /* NCURSES_EXT_FUNCS */"
+ printf "\t\t\tresult = %s_table[check];\n", stringname;
+ print "\t} else {"
+ print "\t\tresult = 0;"
+ print "\t}"
+ print "\treturn (NCURSES_CONST char *)result;"
+ print "}"
+ print ""
+ print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)"
+ print "{"
+ print "\treturn _nc_unctrl(SP, ch);"
+ print "}"
}
diff --git a/lib/libcurses/base/define_key.c b/lib/libcurses/base/define_key.c
index 5dd6dcda7ea..001287859cb 100644
--- a/lib/libcurses/base/define_key.c
+++ b/lib/libcurses/base/define_key.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: define_key.c,v 1.4 2001/01/22 18:01:36 millert Exp $ */
+/* $OpenBSD: define_key.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,30 +29,40 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$From: define_key.c,v 1.6 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: define_key.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
-define_key
-(char *str, int keycode)
+define_key(const char *str, int keycode)
{
int code = ERR;
T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode));
- if (keycode > 0) {
+ if (SP == 0) {
+ code = ERR;
+ } else if (keycode > 0) {
+ unsigned ukey = (unsigned) keycode;
+
if (str != 0) {
define_key(str, 0);
} else if (has_key(keycode)) {
- while (_nc_remove_key(&(SP->_keytry), keycode))
+ while (_nc_remove_key(&(SP->_keytry), ukey))
code = OK;
}
if (str != 0) {
- (void) _nc_add_to_try(&(SP->_keytry), str, keycode);
- code = OK;
+ if (key_defined(str) == 0) {
+ if (_nc_add_to_try(&(SP->_keytry), str, ukey) == OK) {
+ code = OK;
+ } else {
+ code = ERR;
+ }
+ } else {
+ code = ERR;
+ }
}
} else {
while (_nc_remove_string(&(SP->_keytry), str))
diff --git a/lib/libcurses/base/sigaction.c b/lib/libcurses/base/key_defined.c
index f25543c4dea..65f66486dec 100644
--- a/lib/libcurses/base/sigaction.c
+++ b/lib/libcurses/base/key_defined.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: sigaction.c,v 1.4 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: key_defined.c,v 1.1 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2003,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,92 +29,52 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Thomas E. Dickey, 2003 *
****************************************************************************/
#include <curses.priv.h>
-#include <signal.h>
-#include <SigAction.h>
+MODULE_ID("$Id: key_defined.c,v 1.1 2010/01/12 23:22:05 nicm Exp $")
-/* This file provides sigaction() emulation using sigvec() */
-/* Use only if this is non POSIX system */
-
-#if !HAVE_SIGACTION && HAVE_SIGVEC
-
-MODULE_ID("$From: sigaction.c,v 1.11 2000/12/10 02:43:28 tom Exp $")
-
-NCURSES_EXPORT(int)
-sigaction
-(int sig, sigaction_t * sigact, sigaction_t * osigact)
-{
- return sigvec(sig, sigact, osigact);
-}
-
-NCURSES_EXPORT(int)
-sigemptyset
-(sigset_t * mask)
+static int
+find_definition(TRIES * tree, const char *str)
{
- *mask = 0;
- return 0;
+ TRIES *ptr;
+ int result = OK;
+
+ if (str != 0 && *str != '\0') {
+ for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
+ if (UChar(*str) == UChar(ptr->ch)) {
+ if (str[1] == '\0' && ptr->child != 0) {
+ result = ERR;
+ } else if ((result = find_definition(ptr->child, str + 1))
+ == OK) {
+ result = ptr->value;
+ } else if (str[1] == '\0') {
+ result = ERR;
+ }
+ }
+ if (result != OK)
+ break;
+ }
+ }
+ return (result);
}
+/*
+ * Returns the keycode associated with the given string. If none is found,
+ * return OK. If the string is only a prefix to other strings, return ERR.
+ * Otherwise, return the keycode's value (neither OK/ERR).
+ */
NCURSES_EXPORT(int)
-sigprocmask
-(int mode, sigset_t * mask, sigset_t * omask)
+key_defined(const char *str)
{
- sigset_t current = sigsetmask(0);
-
- if (omask)
- *omask = current;
+ int code = ERR;
- if (mode == SIG_BLOCK)
- current |= *mask;
- else if (mode == SIG_UNBLOCK)
- current &= ~*mask;
- else if (mode == SIG_SETMASK)
- current = *mask;
+ T((T_CALLED("key_defined(%s)"), _nc_visbuf(str)));
+ if (SP != 0 && str != 0) {
+ code = find_definition(SP->_keytry, str);
+ }
- sigsetmask(current);
- return 0;
+ returnCode(code);
}
-
-NCURSES_EXPORT(int)
-sigsuspend(sigset_t * mask)
-{
- return sigpause(*mask);
-}
-
-NCURSES_EXPORT(int)
-sigdelset
-(sigset_t * mask, int sig)
-{
- *mask &= ~sigmask(sig);
- return 0;
-}
-
-NCURSES_EXPORT(int)
-sigaddset
-(sigset_t * mask, int sig)
-{
- *mask |= sigmask(sig);
- return 0;
-}
-
-NCURSES_EXPORT(int)
-sigismember
-(sigset_t * mask, int sig)
-{
- return (*mask & sigmask(sig)) != 0;
-}
-
-#else
-extern
-NCURSES_EXPORT(void)
-_nc_sigaction(void); /* quiet's gcc warning */
-NCURSES_EXPORT(void)
-_nc_sigaction(void)
-{
-} /* nonempty for strict ANSI compilers */
-#endif
diff --git a/lib/libcurses/base/keybound.c b/lib/libcurses/base/keybound.c
index 7bb74aad505..e8f1c34f860 100644
--- a/lib/libcurses/base/keybound.c
+++ b/lib/libcurses/base/keybound.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: keybound.c,v 1.4 2007/10/17 20:10:44 chl Exp $ */
+/* $OpenBSD: keybound.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,25 +29,26 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
#include <curses.priv.h>
#include <limits.h>
-MODULE_ID("$From: keybound.c,v 1.3 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: keybound.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
/*
* Returns the count'th string definition which is associated with the
* given keycode. The result is malloc'd, must be freed by the caller.
*/
-
NCURSES_EXPORT(char *)
keybound(int code, int count)
{
- if (code < 0 || code > (int)USHRT_MAX) {
- return NULL;
- } else {
- return _nc_expand_try(SP->_key_ok, (unsigned short)code, &count, 0);
+ char *result = 0;
+
+ T((T_CALLED("keybound(%d,%d)"), code, count));
+ if (SP != 0 && code >= 0) {
+ result = _nc_expand_try(SP->_keytry, (unsigned) code, &count, 0);
}
+ returnPtr(result);
}
diff --git a/lib/libcurses/base/keyok.c b/lib/libcurses/base/keyok.c
index e486969237c..0eb646984a4 100644
--- a/lib/libcurses/base/keyok.c
+++ b/lib/libcurses/base/keyok.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: keyok.c,v 1.4 2006/05/14 09:01:06 espie Exp $ */
+/* $OpenBSD: keyok.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,13 +29,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
#include <curses.priv.h>
-#include <limits.h>
-MODULE_ID("$From: keyok.c,v 1.5 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: keyok.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
/*
* Enable (or disable) ncurses' interpretation of a keycode by adding (or
@@ -55,25 +54,27 @@ keyok(int c, bool flag)
char *s;
T((T_CALLED("keyok(%d,%d)"), c, flag));
- if (c >= 0 && c <= (int)USHRT_MAX) {
- unsigned short k = (unsigned short) c;
- if (flag) {
- while ((s = _nc_expand_try(SP->_key_ok, k, &count, 0)) != 0
- && _nc_remove_key(&(SP->_key_ok), k)) {
- _nc_add_to_try(&(SP->_keytry), s, k);
- free(s);
- code = OK;
- count = 0;
- }
- } else {
- while ((s = _nc_expand_try(SP->_keytry, k, &count, 0)) != 0
- && _nc_remove_key(&(SP->_keytry), k)) {
- _nc_add_to_try(&(SP->_key_ok), s, k);
- free(s);
- code = OK;
- count = 0;
- }
+ if (c >= 0) {
+ unsigned ch = (unsigned) c;
+ if (flag) {
+ while ((s = _nc_expand_try(SP->_key_ok, ch, &count, 0)) != 0
+ && _nc_remove_key(&(SP->_key_ok), ch)) {
+ code = _nc_add_to_try(&(SP->_keytry), s, ch);
+ free(s);
+ count = 0;
+ if (code != OK)
+ break;
}
+ } else {
+ while ((s = _nc_expand_try(SP->_keytry, ch, &count, 0)) != 0
+ && _nc_remove_key(&(SP->_keytry), ch)) {
+ code = _nc_add_to_try(&(SP->_key_ok), s, ch);
+ free(s);
+ count = 0;
+ if (code != OK)
+ break;
+ }
+ }
}
returnCode(code);
}
diff --git a/lib/libcurses/base/legacy_coding.c b/lib/libcurses/base/legacy_coding.c
new file mode 100644
index 00000000000..f88d1b8ddc4
--- /dev/null
+++ b/lib/libcurses/base/legacy_coding.c
@@ -0,0 +1,50 @@
+/* $OpenBSD: legacy_coding.c,v 1.1 2010/01/12 23:22:05 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2005 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: legacy_coding.c,v 1.1 2010/01/12 23:22:05 nicm Exp $")
+
+NCURSES_EXPORT(int)
+use_legacy_coding(int level)
+{
+ int result = ERR;
+
+ T((T_CALLED("use_legacy_coding(%d)"), level));
+ if (level >= 0 && level <= 2 && SP != 0) {
+ result = SP->_legacy_coding;
+ SP->_legacy_coding = level;
+ }
+ returnCode(result);
+}
diff --git a/lib/libcurses/base/lib_adabind.c b/lib/libcurses/base/lib_adabind.c
deleted file mode 100644
index 2fd7faa23ed..00000000000
--- a/lib/libcurses/base/lib_adabind.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* $OpenBSD: lib_adabind.c,v 1.1 1999/01/18 19:09:34 millert Exp $ */
-
-/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining a *
- * copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, distribute with modifications, sublicense, and/or sell *
- * copies of the Software, and to permit persons to whom the Software is *
- * furnished to do so, subject to the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be included *
- * in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
- * *
- * Except as contained in this notice, the name(s) of the above copyright *
- * holders shall not be used in advertising or otherwise to promote the *
- * sale, use or other dealings in this Software without prior written *
- * authorization. *
- ****************************************************************************/
-
-/****************************************************************************
- * Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1996,1997 *
- ****************************************************************************/
-
-/*
-// lib_adabind.c
-//
-// Some small wrappers to ease the implementation of an Ada95
-// binding. Especially functionalities only available as macros
-// in (n)curses are wrapped here by functions.
-// See the documentation and copyright notices in the ../Ada95
-// subdirectory.
-*/
-#include "curses.priv.h"
-
-MODULE_ID("$From: lib_adabind.c,v 1.10 1998/12/06 04:30:32 juergen Exp $")
-
-/* In (n)curses are a few functionalities that can't be expressed as
-// functions, because for historic reasons they use as macro argument
-// variable names that are "out" parameters. For those macros we provide
-// small wrappers.
-*/
-
-/* Prototypes for the functions in this module */
-int _nc_ada_getmaxyx (const WINDOW *win, int *y, int *x);
-int _nc_ada_getbegyx (const WINDOW *win, int *y, int *x);
-int _nc_ada_getyx (const WINDOW *win, int *y, int *x);
-int _nc_ada_getparyx (const WINDOW *win, int *y, int *x);
-int _nc_ada_isscroll (const WINDOW *win);
-int _nc_ada_coord_transform (const WINDOW *win, int *Y, int *X, int dir);
-void _nc_ada_mouse_event (mmask_t m, int *b, int *s);
-int _nc_ada_mouse_mask (int button, int state, mmask_t *mask);
-void _nc_ada_unregister_mouse (void);
-int _nc_ada_vcheck (int major, int minor);
-
-int _nc_ada_getmaxyx (const WINDOW *win, int *y, int *x)
-{
- if (win && y && x)
- {
- getmaxyx(win,*y,*x);
- return OK;
- }
- else
- return ERR;
-}
-
-int _nc_ada_getbegyx (const WINDOW *win, int *y, int *x)
-{
- if (win && y && x)
- {
- getbegyx(win,*y,*x);
- return OK;
- }
- else
- return ERR;
-}
-
-int _nc_ada_getyx (const WINDOW *win, int *y, int *x)
-{
- if (win && y && x)
- {
- getyx(win,*y,*x);
- return OK;
- }
- else
- return ERR;
-}
-
-int _nc_ada_getparyx (const WINDOW *win, int *y, int *x)
-{
- if (win && y && x)
- {
- getparyx(win,*y,*x);
- return OK;
- }
- else
- return ERR;
-}
-
-int _nc_ada_isscroll (const WINDOW *win)
-{
- return win ? (win->_scroll ? TRUE : FALSE) : ERR;
-}
-
-#define BUTTON1_EVENTS (BUTTON1_RELEASED |\
- BUTTON1_PRESSED |\
- BUTTON1_CLICKED |\
- BUTTON1_DOUBLE_CLICKED |\
- BUTTON1_TRIPLE_CLICKED |\
- BUTTON1_RESERVED_EVENT )
-
-#define BUTTON2_EVENTS (BUTTON2_RELEASED |\
- BUTTON2_PRESSED |\
- BUTTON2_CLICKED |\
- BUTTON2_DOUBLE_CLICKED |\
- BUTTON2_TRIPLE_CLICKED |\
- BUTTON2_RESERVED_EVENT )
-
-#define BUTTON3_EVENTS (BUTTON3_RELEASED |\
- BUTTON3_PRESSED |\
- BUTTON3_CLICKED |\
- BUTTON3_DOUBLE_CLICKED |\
- BUTTON3_TRIPLE_CLICKED |\
- BUTTON3_RESERVED_EVENT )
-
-#define BUTTON4_EVENTS (BUTTON4_RELEASED |\
- BUTTON4_PRESSED |\
- BUTTON4_CLICKED |\
- BUTTON4_DOUBLE_CLICKED |\
- BUTTON4_TRIPLE_CLICKED |\
- BUTTON4_RESERVED_EVENT )
-
-void _nc_ada_mouse_event( mmask_t m, int *b, int *s )
-{
- int k = 0;
-
- if ( m & BUTTON1_EVENTS)
- {
- k = 1;
- }
- else if ( m & BUTTON2_EVENTS)
- {
- k = 2;
- }
- else if ( m & BUTTON3_EVENTS)
- {
- k = 3;
- }
- else if ( m & BUTTON4_EVENTS)
- {
- k = 4;
- }
-
- if (k)
- {
- *b = k-1;
- if (BUTTON_RELEASE(m,k)) *s = 0;
- else if (BUTTON_PRESS(m,k)) *s = 1;
- else if (BUTTON_CLICK(m,k)) *s = 2;
- else if (BUTTON_DOUBLE_CLICK(m,k)) *s = 3;
- else if (BUTTON_TRIPLE_CLICK(m,k)) *s = 4;
- else if (BUTTON_RESERVED_EVENT(m,k)) *s = 5;
- else
- {
- *s = -1;
- }
- }
- else
- {
- *s = 1;
- if (m & BUTTON_CTRL) *b = 4;
- else if (m & BUTTON_SHIFT) *b = 5;
- else if (m & BUTTON_ALT) *b = 6;
- else
- {
- *b = -1;
- }
- }
-}
-
-int _nc_ada_mouse_mask ( int button, int state, mmask_t *mask )
-{
- mmask_t b = (button<4) ? ((1<<6*button) << state) :
- (BUTTON_CTRL << (button-4));
-
- if (button>=4 && state!=1)
- return ERR;
-
- *mask |= b;
- return OK;
-}
-
-/*
- * Allow Ada to check whether or not we are the correct library version
- * for the binding. It calls this routine with the version it requests
- * and this routine returns a 1 if it is a correct version, a 2 if the
- * major version is correct but the minor version of the library differs
- * and a 0 if the versions don't match.
- */
-int _nc_ada_vcheck (int major, int minor)
-{
- if (major==NCURSES_VERSION_MAJOR) {
- if (minor==NCURSES_VERSION_MINOR)
- return 1;
- else
- return 2;
- }
- else
- return 0;
-}
diff --git a/lib/libcurses/base/lib_addch.c b/lib/libcurses/base/lib_addch.c
index 4408a6cc43c..055ca39306b 100644
--- a/lib/libcurses/base/lib_addch.c
+++ b/lib/libcurses/base/lib_addch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_addch.c,v 1.4 2001/01/22 18:01:37 millert Exp $ */
+/* $OpenBSD: lib_addch.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -28,11 +28,6 @@
* authorization. *
****************************************************************************/
-/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
- ****************************************************************************/
-
/*
** lib_addch.c
**
@@ -43,7 +38,9 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_addch.c,v 1.47 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
+
+static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
/*
* Ugly microtweaking alert. Everything from here to end of module is
@@ -56,41 +53,56 @@ MODULE_ID("$From: lib_addch.c,v 1.47 2000/12/10 02:43:26 tom Exp $")
*/
/* Return bit mask for clearing color pair number if given ch has color */
-#define COLOR_MASK(ch) (~(chtype)((ch)&A_COLOR?A_COLOR:0))
+#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
-static inline chtype
-render_char(WINDOW *win, chtype ch)
+static NCURSES_INLINE NCURSES_CH_T
+render_char(WINDOW *win, NCURSES_CH_T ch)
/* compute a rendition of the given char correct for the current context */
{
- chtype a = win->_attrs;
-
- if (ch == ' ') {
- /* color in attrs has precedence over bkgd */
- ch = a | (win->_bkgd & COLOR_MASK(a));
+ attr_t a = WINDOW_ATTRS(win);
+ int pair = GetPair(ch);
+
+ if (ISBLANK(ch)
+ && AttrOf(ch) == A_NORMAL
+ && pair == 0) {
+ /* color/pair in attrs has precedence over bkgrnd */
+ ch = win->_nc_bkgd;
+ SetAttr(ch, a | AttrOf(win->_nc_bkgd));
+ if ((pair = GET_WINDOW_PAIR(win)) == 0)
+ pair = GetPair(win->_nc_bkgd);
+ SetPair(ch, pair);
} else {
- /* color in attrs has precedence over bkgd */
- a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a);
+ /* color in attrs has precedence over bkgrnd */
+ a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a);
/* color in ch has precedence */
- ch |= (a & COLOR_MASK(ch));
+ if (pair == 0) {
+ if ((pair = GET_WINDOW_PAIR(win)) == 0)
+ pair = GetPair(win->_nc_bkgd);
+ }
+#if 0
+ if (pair > 255) {
+ NCURSES_CH_T fixme = ch;
+ SetPair(fixme, pair);
+ }
+#endif
+ AddAttr(ch, (a & COLOR_MASK(AttrOf(ch))));
+ SetPair(ch, pair);
}
- TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd,
- win->_attrs, ch));
+ TR(TRACE_VIRTPUT,
+ ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)",
+ _tracech_t2(1, CHREF(win->_nc_bkgd)),
+ GetPair(win->_nc_bkgd),
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win),
+ _tracech_t2(3, CHREF(ch)),
+ GetPair(ch)));
return (ch);
}
-NCURSES_EXPORT(chtype)
-_nc_background
-(WINDOW *win)
-/* make render_char() visible while still allowing us to inline it below */
-{
- return (win->_bkgd);
-}
-
-NCURSES_EXPORT(chtype)
-_nc_render
-(WINDOW *win, chtype ch)
+NCURSES_EXPORT(NCURSES_CH_T)
+_nc_render(WINDOW *win, NCURSES_CH_T ch)
/* make render_char() visible while still allowing us to inline it below */
{
return render_char(win, ch);
@@ -112,77 +124,306 @@ _nc_render
#define CHECK_POSITION(win, x, y) /* nothing */
#endif
-static inline int
-waddch_literal(WINDOW *win, chtype ch)
+static bool
+newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos)
{
- int x;
- struct ldat *line;
-
- x = win->_curx;
+ bool result = FALSE;
- CHECK_POSITION(win, x, win->_cury);
+ if (*ypos >= win->_regtop && *ypos == win->_regbottom) {
+ *ypos = win->_regbottom;
+ result = TRUE;
+ } else {
+ *ypos += 1;
+ }
+ return result;
+}
- /*
- * If we're trying to add a character at the lower-right corner more
- * than once, fail. (Moving the cursor will clear the flag).
- */
-#if 0 /* Solaris 2.6 allows updating the corner more than once */
- if (win->_flags & _WRAPPED) {
- if (x >= win->_maxx)
+/*
+ * The _WRAPPED flag is useful only for telling an application that we've just
+ * wrapped the cursor. We don't do anything with this flag except set it when
+ * wrapping, and clear it whenever we move the cursor. If we try to wrap at
+ * the lower-right corner of a window, we cannot move the cursor (since that
+ * wouldn't be legal). So we return an error (which is what SVr4 does).
+ * Unlike SVr4, we can successfully add a character to the lower-right corner
+ * (Solaris 2.6 does this also, however).
+ */
+static int
+wrap_to_next_line(WINDOW *win)
+{
+ win->_flags |= _WRAPPED;
+ if (newline_forces_scroll(win, &(win->_cury))) {
+ win->_curx = win->_maxx;
+ if (!win->_scroll)
return (ERR);
- win->_flags &= ~_WRAPPED;
+ scroll(win);
+ }
+ win->_curx = 0;
+ return (OK);
+}
+
+#if USE_WIDEC_SUPPORT
+static int waddch_literal(WINDOW *, NCURSES_CH_T);
+/*
+ * Fill the given number of cells with blanks using the current background
+ * rendition. This saves/restores the current x-position.
+ */
+static void
+fill_cells(WINDOW *win, int count)
+{
+ NCURSES_CH_T blank = blankchar;
+ int save_x = win->_curx;
+ int save_y = win->_cury;
+
+ while (count-- > 0) {
+ if (waddch_literal(win, blank) == ERR)
+ break;
}
+ win->_curx = save_x;
+ win->_cury = save_y;
+}
#endif
+/*
+ * Build up the bytes for a multibyte character, returning the length when
+ * complete (a positive number), -1 for error and -2 for incomplete.
+ */
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int)
+_nc_build_wch(WINDOW *win, ARG_CH_T ch)
+{
+ char *buffer = WINDOW_EXT(win, addch_work);
+ int len;
+ int x = win->_curx;
+ int y = win->_cury;
+ mbstate_t state;
+ wchar_t result;
+
+ if ((WINDOW_EXT(win, addch_used) != 0) &&
+ (WINDOW_EXT(win, addch_x) != x ||
+ WINDOW_EXT(win, addch_y) != y)) {
+ /* discard the incomplete multibyte character */
+ WINDOW_EXT(win, addch_used) = 0;
+ TR(TRACE_VIRTPUT,
+ ("Alert discarded multibyte on move (%d,%d) -> (%d,%d)",
+ WINDOW_EXT(win, addch_y), WINDOW_EXT(win, addch_x),
+ y, x));
+ }
+ WINDOW_EXT(win, addch_x) = x;
+ WINDOW_EXT(win, addch_y) = y;
+
+ init_mb(state);
+ buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch));
+ WINDOW_EXT(win, addch_used) += 1;
+ buffer[WINDOW_EXT(win, addch_used)] = '\0';
+ if ((len = mbrtowc(&result,
+ buffer,
+ WINDOW_EXT(win, addch_used), &state)) > 0) {
+ attr_t attrs = AttrOf(CHDEREF(ch));
+ if_EXT_COLORS(int pair = GetPair(CHDEREF(ch)));
+ SetChar(CHDEREF(ch), result, attrs);
+ if_EXT_COLORS(SetPair(CHDEREF(ch), pair));
+ WINDOW_EXT(win, addch_used) = 0;
+ } else if (len == -1) {
+ /*
+ * An error occurred. We could either discard everything,
+ * or assume that the error was in the previous input.
+ * Try the latter.
+ */
+ TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
+ /* handle this with unctrl() */
+ WINDOW_EXT(win, addch_used) = 0;
+ }
+ return len;
+}
+#endif /* USE_WIDEC_SUPPORT */
+
+static
+#if !USE_WIDEC_SUPPORT /* cannot be inline if it is recursive */
+NCURSES_INLINE
+#endif
+int
+waddch_literal(WINDOW *win, NCURSES_CH_T ch)
+{
+ int x;
+ int y;
+ struct ldat *line;
+
+ x = win->_curx;
+ y = win->_cury;
+
+ CHECK_POSITION(win, x, y);
+
ch = render_char(win, ch);
- TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
- line = win->_line + win->_cury;
+ line = win->_line + y;
CHANGED_CELL(line, x);
+ /*
+ * Build up multibyte characters until we have a wide-character.
+ */
+ if_WIDEC({
+ if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
+ int len = _nc_build_wch(win, CHREF(ch));
+
+ if (len >= -1) {
+ /* handle EILSEQ */
+ if (is8bits(CharOf(ch))) {
+ const char *s = unctrl((chtype) CharOf(ch));
+ if (s[1] != 0) {
+ return waddstr(win, s);
+ }
+ }
+ if (len == -1)
+ return waddch(win, ' ');
+ } else {
+ return OK;
+ }
+ }
+ });
+
+ /*
+ * Non-spacing characters are added to the current cell.
+ *
+ * Spacing characters that are wider than one column require some display
+ * adjustments.
+ */
+ if_WIDEC({
+ int len = wcwidth(CharOf(ch));
+ int i;
+ int j;
+ wchar_t *chars;
+
+ if (len == 0) { /* non-spacing */
+ if ((x > 0 && y >= 0)
+ || (win->_maxx >= 0 && win->_cury >= 1)) {
+ if (x > 0 && y >= 0)
+ chars = (win->_line[y].text[x - 1].chars);
+ else
+ chars = (win->_line[y - 1].text[win->_maxx].chars);
+ for (i = 0; i < CCHARW_MAX; ++i) {
+ if (chars[i] == 0) {
+ TR(TRACE_VIRTPUT,
+ ("added non-spacing %d: %x",
+ x, (int) CharOf(ch)));
+ chars[i] = CharOf(ch);
+ break;
+ }
+ }
+ }
+ goto testwrapping;
+ } else if (len > 1) { /* multi-column characters */
+ /*
+ * Check if the character will fit on the current line. If it does
+ * not fit, fill in the remainder of the line with blanks. and
+ * move to the next line.
+ */
+ if (len > win->_maxx + 1) {
+ TR(TRACE_VIRTPUT, ("character will not fit"));
+ return ERR;
+ } else if (x + len > win->_maxx + 1) {
+ int count = win->_maxx + 1 - x;
+ TR(TRACE_VIRTPUT, ("fill %d remaining cells", count));
+ fill_cells(win, count);
+ if (wrap_to_next_line(win) == ERR)
+ return ERR;
+ x = win->_curx;
+ y = win->_cury;
+ }
+ /*
+ * Check for cells which are orphaned by adding this character, set
+ * those to blanks.
+ *
+ * FIXME: this actually could fill j-i cells, more complicated to
+ * setup though.
+ */
+ for (i = 0; i < len; ++i) {
+ if (isWidecBase(win->_line[y].text[x + i])) {
+ break;
+ } else if (isWidecExt(win->_line[y].text[x + i])) {
+ for (j = i; x + j <= win->_maxx; ++j) {
+ if (!isWidecExt(win->_line[y].text[x + j])) {
+ TR(TRACE_VIRTPUT, ("fill %d orphan cells", j));
+ fill_cells(win, j);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ /*
+ * Finally, add the cells for this character.
+ */
+ for (i = 0; i < len; ++i) {
+ NCURSES_CH_T value = ch;
+ SetWidecExt(value, i);
+ TR(TRACE_VIRTPUT, ("multicolumn %d:%d (%d,%d)",
+ i + 1, len,
+ win->_begy + y, win->_begx + x));
+ line->text[x] = value;
+ CHANGED_CELL(line, x);
+ ++x;
+ }
+ goto testwrapping;
+ }
+ });
+
+ /*
+ * Single-column characters.
+ */
line->text[x++] = ch;
+ /*
+ * This label is used only for wide-characters.
+ */
+ if_WIDEC(
+ testwrapping:
+ );
+
+ TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s",
+ (long) win->_cury, (long) win->_curx, x - 1,
+ _tracech_t(CHREF(ch))));
- TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch)));
if (x > win->_maxx) {
- /*
- * The _WRAPPED flag is useful only for telling an application that
- * we've just wrapped the cursor. We don't do anything with this flag
- * except set it when wrapping, and clear it whenever we move the
- * cursor. If we try to wrap at the lower-right corner of a window, we
- * cannot move the cursor (since that wouldn't be legal). So we return
- * an error (which is what SVr4 does). Unlike SVr4, we can
- * successfully add a character to the lower-right corner (Solaris 2.6
- * does this also, however).
- */
- win->_flags |= _WRAPPED;
- if (++win->_cury > win->_regbottom) {
- win->_cury = win->_regbottom;
- win->_curx = win->_maxx;
- if (!win->_scroll)
- return (ERR);
- scroll(win);
- }
- win->_curx = 0;
- return (OK);
+ return wrap_to_next_line(win);
}
win->_curx = x;
return OK;
}
-static inline int
-waddch_nosync(WINDOW *win, const chtype ch)
+static NCURSES_INLINE int
+waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
/* the workhorse function -- add a character to the given window */
{
- int x, y;
- chtype t = 0;
- const char *s = 0;
+ NCURSES_SIZE_T x, y;
+ chtype t = CharOf(ch);
+ const char *s = unctrl(t);
- if ((ch & A_ALTCHARSET)
- || ((t = TextOf(ch)) > 127)
- || ((s = unctrl(t))[1] == 0))
+ /*
+ * If we are using the alternate character set, forget about locale.
+ * Otherwise, if unctrl() returns a single-character or the locale
+ * claims the code is printable, treat it that way.
+ */
+ if ((AttrOf(ch) & A_ALTCHARSET)
+ || (
+#if USE_WIDEC_SUPPORT
+ (SP != 0 && SP->_legacy_coding) &&
+#endif
+ s[1] == 0
+ )
+ || (
+ isprint(t)
+#if USE_WIDEC_SUPPORT
+ || ((SP == 0 || !SP->_legacy_coding) &&
+ (WINDOW_EXT(win, addch_used)
+ || !_nc_is_charable(CharOf(ch))))
+#endif
+ ))
return waddch_literal(win, ch);
+ /*
+ * Handle carriage control and other codes that are not printable, or are
+ * known to expand to more than one character according to unctrl().
+ */
x = win->_curx;
y = win->_cury;
@@ -196,7 +437,8 @@ waddch_nosync(WINDOW *win, const chtype ch)
*/
if ((!win->_scroll && (y == win->_regbottom))
|| (x <= win->_maxx)) {
- chtype blank = (' ' | AttrOf(ch));
+ NCURSES_CH_T blank = blankchar;
+ AddAttr(blank, AttrOf(ch));
while (win->_curx < x) {
if (waddch_literal(win, blank) == ERR)
return (ERR);
@@ -205,9 +447,8 @@ waddch_nosync(WINDOW *win, const chtype ch)
} else {
wclrtoeol(win);
win->_flags |= _WRAPPED;
- if (++y > win->_regbottom) {
+ if (newline_forces_scroll(win, &y)) {
x = win->_maxx;
- y--;
if (win->_scroll) {
scroll(win);
x = 0;
@@ -219,8 +460,7 @@ waddch_nosync(WINDOW *win, const chtype ch)
break;
case '\n':
wclrtoeol(win);
- if (++y > win->_regbottom) {
- y--;
+ if (newline_forces_scroll(win, &y)) {
if (win->_scroll)
scroll(win);
else
@@ -238,9 +478,13 @@ waddch_nosync(WINDOW *win, const chtype ch)
win->_flags &= ~_WRAPPED;
break;
default:
- while (*s)
- if (waddch_literal(win, (*s++) | AttrOf(ch)) == ERR)
+ while (*s) {
+ NCURSES_CH_T sch;
+ SetChar(sch, *s++, AttrOf(ch));
+ if_EXT_COLORS(SetPair(sch, GetPair(ch)));
+ if (waddch_literal(win, sch) == ERR)
return ERR;
+ }
return (OK);
}
@@ -251,15 +495,14 @@ waddch_nosync(WINDOW *win, const chtype ch)
}
NCURSES_EXPORT(int)
-_nc_waddch_nosync
-(WINDOW *win, const chtype c)
+_nc_waddch_nosync(WINDOW *win, const NCURSES_CH_T c)
/* export copy of waddch_nosync() so the string-put functions can use it */
{
return (waddch_nosync(win, c));
}
/*
- * The versions below call _nc_synhook(). We wanted to avoid this in the
+ * The versions below call _nc_synchook(). We wanted to avoid this in the
* version exported for string puts; they'll call _nc_synchook once at end
* of run.
*/
@@ -267,15 +510,16 @@ _nc_waddch_nosync
/* These are actual entry points */
NCURSES_EXPORT(int)
-waddch
-(WINDOW *win, const chtype ch)
+waddch(WINDOW *win, const chtype ch)
{
int code = ERR;
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win,
_tracechtype(ch)));
- if (win && (waddch_nosync(win, ch) != ERR)) {
+ if (win && (waddch_nosync(win, wch) != ERR)) {
_nc_synchook(win);
code = OK;
}
@@ -285,15 +529,16 @@ waddch
}
NCURSES_EXPORT(int)
-wechochar
-(WINDOW *win, const chtype ch)
+wechochar(WINDOW *win, const chtype ch)
{
int code = ERR;
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win,
_tracechtype(ch)));
- if (win && (waddch_nosync(win, ch) != ERR)) {
+ if (win && (waddch_nosync(win, wch) != ERR)) {
bool save_immed = win->_immed;
win->_immed = TRUE;
_nc_synchook(win);
diff --git a/lib/libcurses/base/lib_addstr.c b/lib/libcurses/base/lib_addstr.c
index 79e9f9eec87..7f038d83e4a 100644
--- a/lib/libcurses/base/lib_addstr.c
+++ b/lib/libcurses/base/lib_addstr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_addstr.c,v 1.4 2001/01/22 18:01:37 millert Exp $ */
+/* $OpenBSD: lib_addstr.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,10 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * *
+ * Rewritten 2001-2004 to support wide-characters by *
+ * Sven Verdoolaege *
+ * Thomas Dickey *
****************************************************************************/
/*
@@ -42,27 +46,29 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_addstr.c,v 1.19 2000/12/10 01:24:50 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
-waddnstr
-(WINDOW *win, const char *const astr, int n)
+waddnstr(WINDOW *win, const char *astr, int n)
{
- unsigned const char *str = (unsigned const char *) astr;
+ const char *str = astr;
int code = ERR;
- T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
+ T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbufn(astr, n), n));
if (win && (str != 0)) {
- TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
- TR(TRACE_VIRTPUT, ("str is not null"));
+ TR(TRACE_VIRTPUT | TRACE_ATTRS,
+ ("... current %s", _traceattr(WINDOW_ATTRS(win))));
code = OK;
if (n < 0)
n = (int) strlen(astr);
+ TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
while ((n-- > 0) && (*str != '\0')) {
- TR(TRACE_VIRTPUT, ("*str = %#x", *str));
- if (_nc_waddch_nosync(win, (chtype) * str++) == ERR) {
+ NCURSES_CH_T ch;
+ TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str)));
+ SetChar(ch, UChar(*str++), A_NORMAL);
+ if (_nc_waddch_nosync(win, ch) == ERR) {
code = ERR;
break;
}
@@ -74,12 +80,11 @@ waddnstr
}
NCURSES_EXPORT(int)
-waddchnstr
-(WINDOW *win, const chtype * const astr, int n)
+waddchnstr(WINDOW *win, const chtype *astr, int n)
{
- NCURSES_SIZE_T y = win->_cury;
- NCURSES_SIZE_T x = win->_curx;
+ NCURSES_SIZE_T y, x;
int code = OK;
+ int i;
struct ldat *line;
T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
@@ -87,6 +92,8 @@ waddchnstr
if (!win)
returnCode(ERR);
+ y = win->_cury;
+ x = win->_curx;
if (n < 0) {
const chtype *str;
n = 0;
@@ -99,9 +106,142 @@ waddchnstr
returnCode(code);
line = &(win->_line[y]);
- memcpy(line->text + x, astr, n * sizeof(*astr));
+ for (i = 0; i < n && ChCharOf(astr[i]) != '\0'; ++i) {
+ SetChar2(line->text[i + x], astr[i]);
+ }
CHANGED_RANGE(line, x, x + n - 1);
_nc_synchook(win);
returnCode(code);
}
+
+#if USE_WIDEC_SUPPORT
+
+NCURSES_EXPORT(int)
+_nc_wchstrlen(const cchar_t *s)
+{
+ int result = 0;
+ while (CharOf(s[result]) != L'\0') {
+ result++;
+ }
+ return result;
+}
+
+NCURSES_EXPORT(int)
+wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
+{
+ static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+ NCURSES_SIZE_T y;
+ NCURSES_SIZE_T x;
+ int code = OK;
+ struct ldat *line;
+ int i, j, start, len, end;
+
+ T((T_CALLED("wadd_wchnstr(%p,%s,%d)"), win, _nc_viscbuf(astr, n), n));
+
+ if (!win)
+ returnCode(ERR);
+
+ y = win->_cury;
+ x = win->_curx;
+ if (n < 0) {
+ n = _nc_wchstrlen(astr);
+ }
+ if (n > win->_maxx - x + 1)
+ n = win->_maxx - x + 1;
+ if (n == 0)
+ returnCode(code);
+
+ line = &(win->_line[y]);
+ start = x;
+ end = x + n - 1;
+
+ /*
+ * Reset orphaned cells of multi-column characters that extend up to the
+ * new string's location to blanks.
+ */
+ if (x > 0 && isWidecExt(line->text[x])) {
+ for (i = 0; i <= x; ++i) {
+ if (!isWidecExt(line->text[x - i])) {
+ /* must be isWidecBase() */
+ start -= i;
+ while (i > 0) {
+ line->text[x - i--] = _nc_render(win, blank);
+ }
+ break;
+ }
+ }
+ }
+
+ /*
+ * Copy the new string to the window.
+ */
+ for (i = 0; i < n && CharOf(astr[i]) != L'\0' && x <= win->_maxx; ++i) {
+ if (isWidecExt(astr[i]))
+ continue;
+
+ len = wcwidth(CharOf(astr[i]));
+
+ if (x + len - 1 <= win->_maxx) {
+ line->text[x] = _nc_render(win, astr[i]);
+ if (len > 1) {
+ for (j = 0; j < len; ++j) {
+ if (j != 0) {
+ line->text[x + j] = line->text[x];
+ }
+ SetWidecExt(line->text[x + j], j);
+ }
+ }
+ x += len;
+ end += len - 1;
+ } else {
+ break;
+ }
+ }
+
+ /*
+ * Set orphaned cells of multi-column characters which lie after the new
+ * string to blanks.
+ */
+ while (x <= win->_maxx && isWidecExt(line->text[x])) {
+ line->text[x] = _nc_render(win, blank);
+ ++end;
+ ++x;
+ }
+ CHANGED_RANGE(line, start, end);
+
+ _nc_synchook(win);
+ returnCode(code);
+}
+
+NCURSES_EXPORT(int)
+waddnwstr(WINDOW *win, const wchar_t *str, int n)
+{
+ int code = ERR;
+
+ T((T_CALLED("waddnwstr(%p,%s,%d)"), win, _nc_viswbufn(str, n), n));
+
+ if (win && (str != 0)) {
+ TR(TRACE_VIRTPUT | TRACE_ATTRS,
+ ("... current %s", _traceattr(WINDOW_ATTRS(win))));
+ code = OK;
+ if (n < 0)
+ n = (int) wcslen(str);
+
+ TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
+ while ((n-- > 0) && (*str != L('\0'))) {
+ NCURSES_CH_T ch;
+ TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str));
+ SetChar(ch, *str++, A_NORMAL);
+ if (wadd_wch(win, &ch) == ERR) {
+ code = ERR;
+ break;
+ }
+ }
+ _nc_synchook(win);
+ }
+ TR(TRACE_VIRTPUT, ("waddnwstr returns %d", code));
+ returnCode(code);
+}
+
+#endif
diff --git a/lib/libcurses/base/lib_beep.c b/lib/libcurses/base/lib_beep.c
index fa30974bbeb..99d8dd65844 100644
--- a/lib/libcurses/base/lib_beep.c
+++ b/lib/libcurses/base/lib_beep.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_beep.c,v 1.3 2001/01/22 18:01:37 millert Exp $ */
+/* $OpenBSD: lib_beep.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -43,7 +44,7 @@
#include <curses.priv.h>
#include <term.h> /* beep, flash */
-MODULE_ID("$From: lib_beep.c,v 1.9 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_beep.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
/*
* beep()
@@ -61,7 +62,9 @@ beep(void)
T((T_CALLED("beep()")));
/* FIXME: should make sure that we are not in altchar mode */
- if (bell) {
+ if (cur_term == 0) {
+ res = ERR;
+ } else if (bell) {
TPUTS_TRACE("bell");
res = putp(bell);
_nc_flush();
diff --git a/lib/libcurses/base/lib_bkgd.c b/lib/libcurses/base/lib_bkgd.c
index 88a7461eb0e..34adf40fe2c 100644
--- a/lib/libcurses/base/lib_bkgd.c
+++ b/lib/libcurses/base/lib_bkgd.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_bkgd.c,v 1.2 2001/01/22 18:01:37 millert Exp $ */
+/* $OpenBSD: lib_bkgd.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,55 +31,115 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Juergen Pfeifer 1997 *
+ * and: Sven Verdoolaege 2000 *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$From: lib_bkgd.c,v 1.14 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
+/*
+ * Set the window's background information.
+ */
+#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(void)
-wbkgdset(WINDOW *win, chtype ch)
+#else
+static NCURSES_INLINE void
+#endif
+wbkgrndset(WINDOW *win, const ARG_CH_T ch)
{
- T((T_CALLED("wbkgdset(%p,%s)"), win, _tracechtype(ch)));
+ T((T_CALLED("wbkgdset(%p,%s)"), win, _tracech_t(ch)));
if (win) {
- chtype off = AttrOf(win->_bkgd);
- chtype on = AttrOf(ch);
+ attr_t off = AttrOf(win->_nc_bkgd);
+ attr_t on = AttrOf(CHDEREF(ch));
+
+ toggle_attr_off(WINDOW_ATTRS(win), off);
+ toggle_attr_on(WINDOW_ATTRS(win), on);
- toggle_attr_off(win->_attrs, off);
- toggle_attr_on(win->_attrs, on);
+#if NCURSES_EXT_COLORS
+ {
+ int pair;
- if (TextOf(ch) == 0)
- ch |= BLANK;
- win->_bkgd = ch;
+ if ((pair = GetPair(win->_nc_bkgd)) != 0)
+ SET_WINDOW_PAIR(win, 0);
+ if ((pair = GetPair(CHDEREF(ch))) != 0)
+ SET_WINDOW_PAIR(win, pair);
+ }
+#endif
+
+ if (CharOf(CHDEREF(ch)) == L('\0')) {
+ SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
+ if_EXT_COLORS(SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch))));
+ } else {
+ win->_nc_bkgd = CHDEREF(ch);
+ }
+#if USE_WIDEC_SUPPORT
+ /*
+ * If we're compiled for wide-character support, _bkgrnd is the
+ * preferred location for the background information since it stores
+ * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the
+ * macro getbkgd() will work.
+ */
+ {
+ cchar_t wch;
+ int tmp;
+
+ wgetbkgrnd(win, &wch);
+ tmp = _nc_to_char((wint_t) CharOf(wch));
+
+ win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp)
+ | (AttrOf(wch) & ALL_BUT_COLOR)
+ | COLOR_PAIR(GET_WINDOW_PAIR(win)));
+ }
+#endif
}
returnVoid;
}
+NCURSES_EXPORT(void)
+wbkgdset(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ wbkgrndset(win, CHREF(wch));
+}
+
+/*
+ * Set the window's background information and apply it to each cell.
+ */
+#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(int)
-wbkgd(WINDOW *win, const chtype ch)
+#else
+static NCURSES_INLINE int
+#undef wbkgrnd
+#endif
+wbkgrnd(WINDOW *win, const ARG_CH_T ch)
{
int code = ERR;
int x, y;
- chtype new_bkgd = ch;
+ NCURSES_CH_T new_bkgd = CHDEREF(ch);
- T((T_CALLED("wbkgd(%p,%s)"), win, _tracechtype(new_bkgd)));
+ T((T_CALLED("wbkgd(%p,%s)"), win, _tracech_t(ch)));
if (win) {
- chtype old_bkgd = getbkgd(win);
+ NCURSES_CH_T old_bkgrnd;
+ wgetbkgrnd(win, &old_bkgrnd);
- wbkgdset(win, new_bkgd);
- wattrset(win, AttrOf(win->_bkgd));
+ wbkgrndset(win, CHREF(new_bkgd));
+ wattrset(win, AttrOf(win->_nc_bkgd));
for (y = 0; y <= win->_maxy; y++) {
for (x = 0; x <= win->_maxx; x++) {
- if (win->_line[y].text[x] == old_bkgd)
- win->_line[y].text[x] = win->_bkgd;
- else
- win->_line[y].text[x] =
- _nc_render(win, (A_ALTCHARSET &
- AttrOf(win->_line[y].text[x]))
- | TextOf(win->_line[y].text[x]));
+ if (CharEq(win->_line[y].text[x], old_bkgrnd)) {
+ win->_line[y].text[x] = win->_nc_bkgd;
+ } else {
+ NCURSES_CH_T wch = win->_line[y].text[x];
+ RemAttr(wch, (~(A_ALTCHARSET | A_CHARTEXT)));
+ win->_line[y].text[x] = _nc_render(win, wch);
+ }
}
}
touchwin(win);
@@ -88,3 +148,11 @@ wbkgd(WINDOW *win, const chtype ch)
}
returnCode(code);
}
+
+NCURSES_EXPORT(int)
+wbkgd(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ return wbkgrnd(win, CHREF(wch));
+}
diff --git a/lib/libcurses/base/lib_box.c b/lib/libcurses/base/lib_box.c
index f97ee247c99..6676b3b58a6 100644
--- a/lib/libcurses/base/lib_box.c
+++ b/lib/libcurses/base/lib_box.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_box.c,v 1.3 2001/01/22 18:01:37 millert Exp $ */
+/* $OpenBSD: lib_box.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
+ * and: Sven Verdoolaege 2001 *
****************************************************************************/
/*
@@ -42,16 +44,32 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_box.c,v 1.13 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_box.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
+
+#if USE_WIDEC_SUPPORT
+static NCURSES_INLINE chtype
+_my_render(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ wch = _nc_render(win, wch);
+ return CharOf(wch) | AttrOf(wch);
+}
+#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch)
+#else
+#define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch)
+#endif
NCURSES_EXPORT(int)
-wborder
-(WINDOW *win,
- chtype ls, chtype rs, chtype ts, chtype bs,
- chtype tl, chtype tr, chtype bl, chtype br)
+wborder(WINDOW *win,
+ chtype ls, chtype rs,
+ chtype ts, chtype bs,
+ chtype tl, chtype tr,
+ chtype bl, chtype br)
{
NCURSES_SIZE_T i;
NCURSES_SIZE_T endx, endy;
+ chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
win,
@@ -67,55 +85,45 @@ wborder
if (!win)
returnCode(ERR);
- if (ls == 0)
- ls = ACS_VLINE;
- if (rs == 0)
- rs = ACS_VLINE;
- if (ts == 0)
- ts = ACS_HLINE;
- if (bs == 0)
- bs = ACS_HLINE;
- if (tl == 0)
- tl = ACS_ULCORNER;
- if (tr == 0)
- tr = ACS_URCORNER;
- if (bl == 0)
- bl = ACS_LLCORNER;
- if (br == 0)
- br = ACS_LRCORNER;
-
- ls = _nc_render(win, ls);
- rs = _nc_render(win, rs);
- ts = _nc_render(win, ts);
- bs = _nc_render(win, bs);
- tl = _nc_render(win, tl);
- tr = _nc_render(win, tr);
- bl = _nc_render(win, bl);
- br = _nc_render(win, br);
+ RENDER_WITH_DEFAULT(ls, ACS_VLINE);
+ RENDER_WITH_DEFAULT(rs, ACS_VLINE);
+ RENDER_WITH_DEFAULT(ts, ACS_HLINE);
+ RENDER_WITH_DEFAULT(bs, ACS_HLINE);
+ RENDER_WITH_DEFAULT(tl, ACS_ULCORNER);
+ RENDER_WITH_DEFAULT(tr, ACS_URCORNER);
+ RENDER_WITH_DEFAULT(bl, ACS_LLCORNER);
+ RENDER_WITH_DEFAULT(br, ACS_LRCORNER);
- T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx",
- ls, rs, ts, bs, tl, tr, bl, br));
+ T(("using %s, %s, %s, %s, %s, %s, %s, %s",
+ _tracechtype2(1, wls),
+ _tracechtype2(2, wrs),
+ _tracechtype2(3, wts),
+ _tracechtype2(4, wbs),
+ _tracechtype2(5, wtl),
+ _tracechtype2(6, wtr),
+ _tracechtype2(7, wbl),
+ _tracechtype2(8, wbr)));
endx = win->_maxx;
endy = win->_maxy;
for (i = 0; i <= endx; i++) {
- win->_line[0].text[i] = ts;
- win->_line[endy].text[i] = bs;
+ SetChar2(win->_line[0].text[i], wts);
+ SetChar2(win->_line[endy].text[i], wbs);
}
win->_line[endy].firstchar = win->_line[0].firstchar = 0;
win->_line[endy].lastchar = win->_line[0].lastchar = endx;
for (i = 0; i <= endy; i++) {
- win->_line[i].text[0] = ls;
- win->_line[i].text[endx] = rs;
+ SetChar2(win->_line[i].text[0], wls);
+ SetChar2(win->_line[i].text[endx], wrs);
win->_line[i].firstchar = 0;
win->_line[i].lastchar = endx;
}
- win->_line[0].text[0] = tl;
- win->_line[0].text[endx] = tr;
- win->_line[endy].text[0] = bl;
- win->_line[endy].text[endx] = br;
+ SetChar2(win->_line[0].text[0], wtl);
+ SetChar2(win->_line[0].text[endx], wtr);
+ SetChar2(win->_line[endy].text[0], wbl);
+ SetChar2(win->_line[endy].text[endx], wbr);
_nc_synchook(win);
returnCode(OK);
diff --git a/lib/libcurses/base/lib_chgat.c b/lib/libcurses/base/lib_chgat.c
index d48c9aba297..5762785c207 100644
--- a/lib/libcurses/base/lib_chgat.c
+++ b/lib/libcurses/base/lib_chgat.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_chgat.c,v 1.2 2001/01/22 18:01:37 millert Exp $ */
+/* $OpenBSD: lib_chgat.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Sven Verdoolaege 2001 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -42,22 +44,25 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_chgat.c,v 1.4 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_chgat.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
-wchgat
-(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
+wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
{
int i;
T((T_CALLED("wchgat(%p,%d,%s,%d)"), win, n, _traceattr(attr), color));
if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
+
toggle_attr_on(attr, COLOR_PAIR(color));
- for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++)
- win->_line[win->_cury].text[i]
- = TextOf(win->_line[win->_cury].text[i]) | attr;
+ for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) {
+ SetAttr(line->text[i], attr);
+ SetPair(line->text[i], color);
+ CHANGED_CELL(line, i);
+ }
returnCode(OK);
} else
diff --git a/lib/libcurses/base/lib_clear.c b/lib/libcurses/base/lib_clear.c
index 6cb0a2f7929..10dab985fbc 100644
--- a/lib/libcurses/base/lib_clear.c
+++ b/lib/libcurses/base/lib_clear.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_clear.c,v 1.2 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_clear.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_clear.c,v 1.7 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_clear.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
wclear(WINDOW *win)
diff --git a/lib/libcurses/base/lib_clearok.c b/lib/libcurses/base/lib_clearok.c
index ccf11335497..d0746956fa6 100644
--- a/lib/libcurses/base/lib_clearok.c
+++ b/lib/libcurses/base/lib_clearok.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_clearok.c,v 1.2 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_clearok.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_clearok.c,v 1.4 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_clearok.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
clearok(WINDOW *win, bool flag)
diff --git a/lib/libcurses/base/lib_clrbot.c b/lib/libcurses/base/lib_clrbot.c
index c947b668613..f0b86d921f1 100644
--- a/lib/libcurses/base/lib_clrbot.c
+++ b/lib/libcurses/base/lib_clrbot.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_clrbot.c,v 1.3 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_clrbot.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_clrbot.c,v 1.17 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_clrbot.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
wclrtobot(WINDOW *win)
@@ -54,15 +54,15 @@ wclrtobot(WINDOW *win)
if (win) {
NCURSES_SIZE_T y;
NCURSES_SIZE_T startx = win->_curx;
- chtype blank = _nc_background(win);
+ NCURSES_CH_T blank = win->_nc_bkgd;
- T(("clearing from y = %d to y = %d with maxx = %d",
- win->_cury, win->_maxy, win->_maxx));
+ T(("clearing from y = %ld to y = %ld with maxx = %ld",
+ (long) win->_cury, (long) win->_maxy, (long) win->_maxx));
for (y = win->_cury; y <= win->_maxy; y++) {
struct ldat *line = &(win->_line[y]);
- chtype *ptr = &(line->text[startx]);
- chtype *end = &(line->text[win->_maxx]);
+ NCURSES_CH_T *ptr = &(line->text[startx]);
+ NCURSES_CH_T *end = &(line->text[win->_maxx]);
CHANGED_TO_EOL(line, startx, win->_maxx);
diff --git a/lib/libcurses/base/lib_clreol.c b/lib/libcurses/base/lib_clreol.c
index 7c00cd16d5b..2b9a48bf417 100644
--- a/lib/libcurses/base/lib_clreol.c
+++ b/lib/libcurses/base/lib_clreol.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_clreol.c,v 1.3 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_clreol.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_clreol.c,v 1.19 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_clreol.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
wclrtoeol(WINDOW *win)
@@ -52,8 +52,8 @@ wclrtoeol(WINDOW *win)
T((T_CALLED("wclrtoeol(%p)"), win));
if (win) {
- chtype blank;
- chtype *ptr, *end;
+ NCURSES_CH_T blank;
+ NCURSES_CH_T *ptr, *end;
struct ldat *line;
NCURSES_SIZE_T y = win->_cury;
NCURSES_SIZE_T x = win->_curx;
@@ -76,7 +76,7 @@ wclrtoeol(WINDOW *win)
|| x > win->_maxx)
returnCode(ERR);
- blank = _nc_background(win);
+ blank = win->_nc_bkgd;
line = &win->_line[y];
CHANGED_TO_EOL(line, x, win->_maxx);
diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c
index 06b88fe43e5..d1c4ce7f0d5 100644
--- a/lib/libcurses/base/lib_color.c
+++ b/lib/libcurses/base/lib_color.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_color.c,v 1.10 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_color.c,v 1.11 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/* lib_color.c
@@ -43,17 +44,37 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: lib_color.c,v 1.55 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.11 2010/01/12 23:22:05 nicm Exp $")
/*
* These should be screen structure members. They need to be globals for
* historical reasons. So we assign them in start_color() and also in
* set_term()'s screen-switching logic.
*/
-NCURSES_EXPORT_VAR(int)
-COLOR_PAIRS = 0;
-NCURSES_EXPORT_VAR(int)
-COLORS = 0;
+#if USE_REENTRANT
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLOR_PAIRS) (void)
+{
+ return SP ? SP->_pair_count : -1;
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLORS) (void)
+{
+ return SP ? SP->_color_count : -1;
+}
+#else
+NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0;
+NCURSES_EXPORT_VAR(int) COLORS = 0;
+#endif
+
+#define DATA(r,g,b) {r,g,b, 0,0,0, 0}
+
+#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+
+#define MAX_PALETTE 8
+
+#define OkColorHi(n) (((n) < COLORS) && ((n) < max_colors))
+#define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE)
/*
* Given a RGB range of 0..1000, we'll normally set the individual values
@@ -65,27 +86,27 @@ COLORS = 0;
static const color_t cga_palette[] =
{
/* R G B */
- {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
- {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
- {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
- {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
- {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
- {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
- {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
- {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
+ DATA(RGB_OFF, RGB_OFF, RGB_OFF), /* COLOR_BLACK */
+ DATA(RGB_ON, RGB_OFF, RGB_OFF), /* COLOR_RED */
+ DATA(RGB_OFF, RGB_ON, RGB_OFF), /* COLOR_GREEN */
+ DATA(RGB_ON, RGB_ON, RGB_OFF), /* COLOR_YELLOW */
+ DATA(RGB_OFF, RGB_OFF, RGB_ON), /* COLOR_BLUE */
+ DATA(RGB_ON, RGB_OFF, RGB_ON), /* COLOR_MAGENTA */
+ DATA(RGB_OFF, RGB_ON, RGB_ON), /* COLOR_CYAN */
+ DATA(RGB_ON, RGB_ON, RGB_ON), /* COLOR_WHITE */
};
static const color_t hls_palette[] =
{
- /* H L S */
- { 0, 0, 0}, /* COLOR_BLACK */
- { 120, 50, 100}, /* COLOR_RED */
- { 240, 50, 100}, /* COLOR_GREEN */
- { 180, 50, 100}, /* COLOR_YELLOW */
- { 330, 50, 100}, /* COLOR_BLUE */
- { 60, 50, 100}, /* COLOR_MAGENTA */
- { 300, 50, 100}, /* COLOR_CYAN */
- { 0, 50, 100}, /* COLOR_WHITE */
+ /* H L S */
+ DATA( 0, 0, 0), /* COLOR_BLACK */
+ DATA( 120, 50, 100), /* COLOR_RED */
+ DATA( 240, 50, 100), /* COLOR_GREEN */
+ DATA( 180, 50, 100), /* COLOR_YELLOW */
+ DATA( 330, 50, 100), /* COLOR_BLUE */
+ DATA( 60, 50, 100), /* COLOR_MAGENTA */
+ DATA( 300, 50, 100), /* COLOR_CYAN */
+ DATA( 0, 50, 100), /* COLOR_WHITE */
};
/* *INDENT-ON* */
@@ -94,8 +115,8 @@ static const color_t hls_palette[] =
* These are called from _nc_do_color(), which in turn is called from
* vidattr - so we have to assume that SP may be null.
*/
- static int
- default_fg(void)
+static int
+default_fg(void)
{
return (SP != 0) ? SP->_default_fg : COLOR_WHITE;
}
@@ -115,8 +136,8 @@ default_bg(void)
* to maintain compatibility with a pre-ANSI scheme. The same scheme is
* also used in the FreeBSD syscons.
*/
- static int
- toggled_colors(int c)
+static int
+toggled_colors(int c)
{
if (c < 16) {
static const int table[] =
@@ -132,10 +153,10 @@ set_background_color(int bg, int (*outc) (int))
{
if (set_a_background) {
TPUTS_TRACE("set_a_background");
- tputs(tparm(set_a_background, bg), 1, outc);
+ tputs(TPARM_1(set_a_background, bg), 1, outc);
} else {
TPUTS_TRACE("set_background");
- tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
+ tputs(TPARM_1(set_background, toggled_colors(bg)), 1, outc);
}
}
@@ -144,62 +165,25 @@ set_foreground_color(int fg, int (*outc) (int))
{
if (set_a_foreground) {
TPUTS_TRACE("set_a_foreground");
- tputs(tparm(set_a_foreground, fg), 1, outc);
+ tputs(TPARM_1(set_a_foreground, fg), 1, outc);
} else {
TPUTS_TRACE("set_foreground");
- tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
+ tputs(TPARM_1(set_foreground, toggled_colors(fg)), 1, outc);
}
}
-static bool
-set_original_colors(void)
-{
- if (orig_pair != 0) {
- TPUTS_TRACE("orig_pair");
- putp(orig_pair);
- return TRUE;
- } else if (orig_colors != NULL) {
- TPUTS_TRACE("orig_colors");
- putp(orig_colors);
- return TRUE;
- }
- return FALSE;
-}
-
-NCURSES_EXPORT(int)
-start_color(void)
+static void
+init_color_table(void)
{
- int n;
const color_t *tp;
+ int n;
- T((T_CALLED("start_color()")));
-
- if (set_original_colors() != TRUE) {
- set_foreground_color(default_fg(), _nc_outch);
- set_background_color(default_bg(), _nc_outch);
- }
-
- if (VALID_NUMERIC(max_pairs))
- COLOR_PAIRS = SP->_pair_count = max_pairs;
- else
- returnCode(ERR);
- if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
- returnCode(ERR);
- SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
- if (VALID_NUMERIC(max_colors))
- COLORS = SP->_color_count = max_colors;
- else
- returnCode(ERR);
- SP->_coloron = 1;
-
- if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
- returnCode(ERR);
tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
for (n = 0; n < COLORS; n++) {
- if (n < 8) {
+ if (InPalette(n)) {
SP->_color_table[n] = tp[n];
} else {
- SP->_color_table[n] = tp[n % 8];
+ SP->_color_table[n] = tp[n % MAX_PALETTE];
if (hue_lightness_saturation) {
SP->_color_table[n].green = 100;
} else {
@@ -212,10 +196,95 @@ start_color(void)
}
}
}
+}
- T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+/*
+ * Reset the color pair, e.g., to whatever color pair 0 is.
+ */
+static bool
+reset_color_pair(void)
+{
+ bool result = FALSE;
- returnCode(OK);
+ if (orig_pair != 0) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ result = TRUE;
+ }
+ return result;
+}
+
+/*
+ * Reset color pairs and definitions. Actually we do both more to accommodate
+ * badly-written terminal descriptions than for the relatively rare case where
+ * someone has changed the color definitions.
+ */
+bool
+_nc_reset_colors(void)
+{
+ int result = FALSE;
+
+ T((T_CALLED("_nc_reset_colors()")));
+ if (SP->_color_defs > 0)
+ SP->_color_defs = -(SP->_color_defs);
+
+ if (reset_color_pair())
+ result = TRUE;
+ if (orig_colors != 0) {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ result = TRUE;
+ }
+ returnBool(result);
+}
+
+NCURSES_EXPORT(int)
+start_color(void)
+{
+ int result = ERR;
+
+ T((T_CALLED("start_color()")));
+
+ if (SP == 0) {
+ result = ERR;
+ } else if (SP->_coloron) {
+ result = OK;
+ } else {
+
+ if (reset_color_pair() != TRUE) {
+ set_foreground_color(default_fg(), _nc_outch);
+ set_background_color(default_bg(), _nc_outch);
+ }
+
+ if (max_pairs > 0 && max_colors > 0) {
+ SP->_pair_count = max_pairs;
+ SP->_color_count = max_colors;
+#if !USE_REENTRANT
+ COLOR_PAIRS = max_pairs;
+ COLORS = max_colors;
+#endif
+
+ if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
+ max_pairs)) != 0) {
+ if ((SP->_color_table = TYPE_CALLOC(color_t,
+ max_colors)) != 0) {
+ SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
+ init_color_table();
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d",
+ COLORS, COLOR_PAIRS));
+
+ SP->_coloron = 1;
+ result = OK;
+ } else if (SP->_color_pairs != 0) {
+ FreeAndNull(SP->_color_pairs);
+ }
+ }
+ } else {
+ result = OK;
+ }
+ }
+ returnCode(result);
}
/* This function was originally written by Daniel Weaver <danw@znyx.com> */
@@ -261,30 +330,29 @@ rgb2hls(short r, short g, short b, short *h, short *l, short *s)
* values.
*/
NCURSES_EXPORT(int)
-init_pair
-(short pair, short f, short b)
+init_pair(short pair, short f, short b)
{
- unsigned result;
+ colorpair_t result;
T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
- if ((pair < 0) || (pair >= COLOR_PAIRS))
+ if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron)
returnCode(ERR);
#if NCURSES_EXT_FUNCS
if (SP->_default_color) {
if (f < 0)
- f = C_MASK;
+ f = COLOR_DEFAULT;
if (b < 0)
- b = C_MASK;
- if (f >= COLORS && f != C_MASK)
+ b = COLOR_DEFAULT;
+ if (!OkColorHi(f) && !isDefaultColor(f))
returnCode(ERR);
- if (b >= COLORS && b != C_MASK)
+ if (!OkColorHi(b) && !isDefaultColor(b))
returnCode(ERR);
} else
#endif
{
- if ((f < 0) || (f >= COLORS)
- || (b < 0) || (b >= COLORS)
+ if ((f < 0) || !OkColorHi(f)
+ || (b < 0) || !OkColorHi(b)
|| (pair < 1))
returnCode(ERR);
}
@@ -298,16 +366,15 @@ init_pair
if (SP->_color_pairs[pair] != 0
&& SP->_color_pairs[pair] != result) {
int y, x;
- attr_t z = COLOR_PAIR(pair);
for (y = 0; y <= curscr->_maxy; y++) {
struct ldat *ptr = &(curscr->_line[y]);
bool changed = FALSE;
for (x = 0; x <= curscr->_maxx; x++) {
- if ((ptr->text[x] & A_COLOR) == z) {
+ if (GetPair(ptr->text[x]) == pair) {
/* Set the old cell to zero to ensure it will be
updated on the next doupdate() */
- ptr->text[x] = 0;
+ SetChar(ptr->text[x], 0, 0);
CHANGED_CELL(ptr, x);
changed = TRUE;
}
@@ -317,59 +384,65 @@ init_pair
}
}
SP->_color_pairs[pair] = result;
- if ((int) (SP->_current_attr & A_COLOR) == COLOR_PAIR(pair))
- SP->_current_attr |= A_COLOR; /* force attribute update */
+ if (GET_SCREEN_PAIR(SP) == pair)
+ SET_SCREEN_PAIR(SP, (chtype) (~0)); /* force attribute update */
- if (initialize_pair) {
+ if (initialize_pair && InPalette(f) && InPalette(b)) {
const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
- T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
-
- if (initialize_pair) {
- TPUTS_TRACE("initialize_pair");
- putp(tparm(initialize_pair,
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
- }
+ TR(TRACE_ATTRS,
+ ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+
+ TPUTS_TRACE("initialize_pair");
+ putp(TPARM_7(initialize_pair,
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
}
returnCode(OK);
}
+#define okRGB(n) ((n) >= 0 && (n) <= 1000)
+
NCURSES_EXPORT(int)
-init_color
-(short color, short r, short g, short b)
+init_color(short color, short r, short g, short b)
{
- T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
-
- if (initialize_color == NULL)
- returnCode(ERR);
+ int result = ERR;
- if (color < 0 || color >= COLORS)
- returnCode(ERR);
- if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
- returnCode(ERR);
+ T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
- if (hue_lightness_saturation)
- rgb2hls(r, g, b,
- &SP->_color_table[color].red,
- &SP->_color_table[color].green,
- &SP->_color_table[color].blue);
- else {
- SP->_color_table[color].red = r;
- SP->_color_table[color].green = g;
- SP->_color_table[color].blue = b;
- }
+ if (initialize_color != NULL
+ && SP != 0
+ && SP->_coloron
+ && (color >= 0 && OkColorHi(color))
+ && (okRGB(r) && okRGB(g) && okRGB(b))) {
+
+ SP->_color_table[color].init = 1;
+ SP->_color_table[color].r = r;
+ SP->_color_table[color].g = g;
+ SP->_color_table[color].b = b;
+
+ if (hue_lightness_saturation) {
+ rgb2hls(r, g, b,
+ &SP->_color_table[color].red,
+ &SP->_color_table[color].green,
+ &SP->_color_table[color].blue);
+ } else {
+ SP->_color_table[color].red = r;
+ SP->_color_table[color].green = g;
+ SP->_color_table[color].blue = b;
+ }
- if (initialize_color) {
TPUTS_TRACE("initialize_color");
- putp(tparm(initialize_color, color, r, g, b));
+ putp(TPARM_4(initialize_color, color, r, g, b));
+ SP->_color_defs = max(color + 1, SP->_color_defs);
+ result = OK;
}
- returnCode(OK);
+ returnCode(result);
}
NCURSES_EXPORT(bool)
@@ -392,43 +465,68 @@ has_colors(void)
}
NCURSES_EXPORT(int)
-color_content
-(short color, short *r, short *g, short *b)
+color_content(short color, short *r, short *g, short *b)
{
- T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
- if (color < 0 || color >= COLORS)
- returnCode(ERR);
+ int result;
- if (r)
- *r = SP->_color_table[color].red;
- if (g)
- *g = SP->_color_table[color].green;
- if (b)
- *b = SP->_color_table[color].blue;
- returnCode(OK);
+ T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
+ if (color < 0 || !OkColorHi(color) || SP == 0 || !SP->_coloron) {
+ result = ERR;
+ } else {
+ NCURSES_COLOR_T c_r = SP->_color_table[color].red;
+ NCURSES_COLOR_T c_g = SP->_color_table[color].green;
+ NCURSES_COLOR_T c_b = SP->_color_table[color].blue;
+
+ if (r)
+ *r = c_r;
+ if (g)
+ *g = c_g;
+ if (b)
+ *b = c_b;
+
+ TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
+ color, c_r, c_g, c_b));
+ result = OK;
+ }
+ returnCode(result);
}
NCURSES_EXPORT(int)
-pair_content
-(short pair, short *f, short *b)
+pair_content(short pair, short *f, short *b)
{
+ int result;
+
T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
- if ((pair < 0) || (pair >= COLOR_PAIRS))
- returnCode(ERR);
- if (f)
- *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
- if (b)
- *b = (SP->_color_pairs[pair] & C_MASK);
+ if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron) {
+ result = ERR;
+ } else {
+ NCURSES_COLOR_T fg = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+ NCURSES_COLOR_T bg = (SP->_color_pairs[pair] & C_MASK);
- returnCode(OK);
+#if NCURSES_EXT_FUNCS
+ if (fg == COLOR_DEFAULT)
+ fg = -1;
+ if (bg == COLOR_DEFAULT)
+ bg = -1;
+#endif
+
+ if (f)
+ *f = fg;
+ if (b)
+ *b = bg;
+
+ TR(TRACE_ATTRS, ("...pair_content(%d,%d,%d)", pair, fg, bg));
+ result = OK;
+ }
+ returnCode(result);
}
NCURSES_EXPORT(void)
-_nc_do_color
-(int old_pair, int pair, bool reverse, int (*outc) (int))
+_nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int))
{
- NCURSES_COLOR_T fg = C_MASK, bg = C_MASK;
+ NCURSES_COLOR_T fg = COLOR_DEFAULT;
+ NCURSES_COLOR_T bg = COLOR_DEFAULT;
NCURSES_COLOR_T old_fg, old_bg;
if (pair < 0 || pair >= COLOR_PAIRS) {
@@ -436,41 +534,46 @@ _nc_do_color
} else if (pair != 0) {
if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
- tputs(tparm(set_color_pair, pair), 1, outc);
+ tputs(TPARM_1(set_color_pair, pair), 1, outc);
return;
} else if (SP != 0) {
- pair_content(pair, &fg, &bg);
+ pair_content((short) pair, &fg, &bg);
}
}
- if (old_pair >= 0 && SP != 0) {
- pair_content(old_pair, &old_fg, &old_bg);
- if ((fg == C_MASK && old_fg != C_MASK)
- || (bg == C_MASK && old_bg != C_MASK)) {
+ if (old_pair >= 0
+ && SP != 0
+ && pair_content(old_pair, &old_fg, &old_bg) != ERR) {
+ if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
+ || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
#if NCURSES_EXT_FUNCS
/*
* A minor optimization - but extension. If "AX" is specified in
* the terminal description, treat it as screen's indicator of ECMA
* SGR 39 and SGR 49, and assume the two sequences are independent.
*/
- if (SP->_has_sgr_39_49 && old_bg == C_MASK && old_fg != C_MASK) {
+ if (SP->_has_sgr_39_49
+ && isDefaultColor(old_bg)
+ && !isDefaultColor(old_fg)) {
tputs("\033[39m", 1, outc);
- } else if (SP->_has_sgr_39_49 && old_fg == C_MASK && old_bg != C_MASK) {
+ } else if (SP->_has_sgr_39_49
+ && isDefaultColor(old_fg)
+ && !isDefaultColor(old_bg)) {
tputs("\033[49m", 1, outc);
} else
#endif
- set_original_colors();
+ reset_color_pair();
}
} else {
- set_original_colors();
+ reset_color_pair();
if (old_pair < 0)
return;
}
#if NCURSES_EXT_FUNCS
- if (fg == C_MASK)
+ if (isDefaultColor(fg))
fg = default_fg();
- if (bg == C_MASK)
+ if (isDefaultColor(bg))
bg = default_bg();
#endif
@@ -483,10 +586,10 @@ _nc_do_color
TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair,
fg, bg));
- if (fg != C_MASK) {
+ if (!isDefaultColor(fg)) {
set_foreground_color(fg, outc);
}
- if (bg != C_MASK) {
+ if (!isDefaultColor(bg)) {
set_background_color(bg, outc);
}
}
diff --git a/lib/libcurses/base/lib_colorset.c b/lib/libcurses/base/lib_colorset.c
index 73cd69e609c..039587de146 100644
--- a/lib/libcurses/base/lib_colorset.c
+++ b/lib/libcurses/base/lib_colorset.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_colorset.c,v 1.4 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_colorset.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ * Author: Juergen Pfeifer, 1998 *
+ * and: Thomas E. Dickey, 2005 *
****************************************************************************/
/*
@@ -42,19 +43,19 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_colorset.c,v 1.7 2000/12/10 01:24:50 tom Exp $")
+MODULE_ID("$Id: lib_colorset.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
-wcolor_set
-(WINDOW *win, short color_pair_number, void *opts)
+wcolor_set(WINDOW *win, short color_pair_number, void *opts)
{
T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
if (win
&& !opts
&& (color_pair_number >= 0)
&& (color_pair_number < COLOR_PAIRS)) {
- TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
- toggle_attr_on(win->_attrs, COLOR_PAIR(color_pair_number));
+ TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win)));
+ SET_WINDOW_PAIR(win, color_pair_number);
+ if_EXT_COLORS(win->_color = color_pair_number);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_delch.c b/lib/libcurses/base/lib_delch.c
index d07198c60a4..42efa5cabfe 100644
--- a/lib/libcurses/base/lib_delch.c
+++ b/lib/libcurses/base/lib_delch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_delch.c,v 1.2 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_delch.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_delch.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_delch.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
wdelch(WINDOW *win)
@@ -52,11 +52,11 @@ wdelch(WINDOW *win)
T((T_CALLED("wdelch(%p)"), win));
if (win) {
- chtype blank = _nc_background(win);
+ NCURSES_CH_T blank = win->_nc_bkgd;
struct ldat *line = &(win->_line[win->_cury]);
- chtype *end = &(line->text[win->_maxx]);
- chtype *temp2 = &(line->text[win->_curx + 1]);
- chtype *temp1 = temp2 - 1;
+ NCURSES_CH_T *end = &(line->text[win->_maxx]);
+ NCURSES_CH_T *temp2 = &(line->text[win->_curx + 1]);
+ NCURSES_CH_T *temp1 = temp2 - 1;
CHANGED_TO_EOL(line, win->_curx, win->_maxx);
while (temp1 < end)
diff --git a/lib/libcurses/base/lib_delwin.c b/lib/libcurses/base/lib_delwin.c
index 5358ae94f00..15a52a36953 100644
--- a/lib/libcurses/base/lib_delwin.c
+++ b/lib/libcurses/base/lib_delwin.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_delwin.c,v 1.2 2001/01/22 18:01:38 millert Exp $ */
+/* $OpenBSD: lib_delwin.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_delwin.c,v 1.12 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
static bool
cannot_delete(WINDOW *win)
@@ -50,11 +50,11 @@ cannot_delete(WINDOW *win)
WINDOWLIST *p;
bool result = TRUE;
- for (p = _nc_windows; p != 0; p = p->next) {
- if (p->win == win) {
+ for (each_window(p)) {
+ if (&(p->win) == win) {
result = FALSE;
- } else if ((p->win->_flags & _SUBWIN) != 0
- && p->win->_parent == win) {
+ } else if ((p->win._flags & _SUBWIN) != 0
+ && p->win._parent == win) {
result = TRUE;
break;
}
@@ -65,16 +65,24 @@ cannot_delete(WINDOW *win)
NCURSES_EXPORT(int)
delwin(WINDOW *win)
{
+ int result = ERR;
+
T((T_CALLED("delwin(%p)"), win));
- if (win == 0
- || cannot_delete(win))
- returnCode(ERR);
+ if (_nc_try_global(curses) == 0) {
+ if (win == 0
+ || cannot_delete(win)) {
+ result = ERR;
+ } else {
- if (win->_flags & _SUBWIN)
- touchwin(win->_parent);
- else if (curscr != 0)
- touchwin(curscr);
+ if (win->_flags & _SUBWIN)
+ touchwin(win->_parent);
+ else if (curscr != 0)
+ touchwin(curscr);
- returnCode(_nc_freewin(win));
+ result = _nc_freewin(win);
+ }
+ _nc_unlock_global(curses);
+ }
+ returnCode(result);
}
diff --git a/lib/libcurses/base/lib_dft_fgbg.c b/lib/libcurses/base/lib_dft_fgbg.c
index 45aeac0c4dd..d051dcd414d 100644
--- a/lib/libcurses/base/lib_dft_fgbg.c
+++ b/lib/libcurses/base/lib_dft_fgbg.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_dft_fgbg.c,v 1.7 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_dft_fgbg.c,v 1.8 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,13 +29,13 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997,1999 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_dft_fgbg.c,v 1.15 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.8 2010/01/12 23:22:05 nicm Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -45,7 +45,7 @@ NCURSES_EXPORT(int)
use_default_colors(void)
{
T((T_CALLED("use_default_colors()")));
- returnCode(assume_default_colors(C_MASK, C_MASK));
+ returnCode(assume_default_colors(-1, -1));
}
/*
@@ -63,11 +63,15 @@ assume_default_colors(int fg, int bg)
if (initialize_pair) /* don't know how to handle this */
returnCode(ERR);
- SP->_default_color = (fg < 0 || fg == C_MASK) || (bg < 0 || bg == C_MASK);
+ SP->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
- SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
- SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
- if (SP->_color_pairs != 0)
- init_pair(0, fg, bg);
+ SP->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
+ SP->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
+ if (SP->_color_pairs != 0) {
+ bool save = SP->_default_color;
+ SP->_default_color = TRUE;
+ init_pair(0, (short) fg, (short) bg);
+ SP->_default_color = save;
+ }
returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_echo.c b/lib/libcurses/base/lib_echo.c
index 6f101ba3399..3a73b349c9a 100644
--- a/lib/libcurses/base/lib_echo.c
+++ b/lib/libcurses/base/lib_echo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_echo.c,v 1.2 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_echo.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -44,7 +44,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_echo.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_echo.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
echo(void)
diff --git a/lib/libcurses/base/lib_endwin.c b/lib/libcurses/base/lib_endwin.c
index 971bc9a06c8..281569ea043 100644
--- a/lib/libcurses/base/lib_endwin.c
+++ b/lib/libcurses/base/lib_endwin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_endwin.c,v 1.3 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_endwin.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_endwin.c,v 1.19 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_endwin.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
endwin(void)
diff --git a/lib/libcurses/base/lib_erase.c b/lib/libcurses/base/lib_erase.c
index 44e51e8ce27..9bc4aadf120 100644
--- a/lib/libcurses/base/lib_erase.c
+++ b/lib/libcurses/base/lib_erase.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_erase.c,v 1.2 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_erase.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,24 +43,42 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_erase.c,v 1.13 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_erase.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
werase(WINDOW *win)
{
int code = ERR;
int y;
- chtype blank;
- chtype *sp, *end, *start;
+ NCURSES_CH_T blank;
+ NCURSES_CH_T *sp, *end, *start;
T((T_CALLED("werase(%p)"), win));
if (win) {
- blank = _nc_background(win);
+ blank = win->_nc_bkgd;
for (y = 0; y <= win->_maxy; y++) {
start = win->_line[y].text;
end = &start[win->_maxx];
+ /*
+ * If this is a derived window, we have to handle the case where
+ * a multicolumn character extends into the window that we are
+ * erasing.
+ */
+ if_WIDEC({
+ if (isWidecExt(start[0])) {
+ int x = (win->_parent != 0) ? (win->_begx) : 0;
+ while (x-- > 0) {
+ if (isWidecBase(start[-1])) {
+ --start;
+ break;
+ }
+ --start;
+ }
+ }
+ });
+
for (sp = start; sp <= end; sp++)
*sp = blank;
diff --git a/lib/libcurses/base/lib_flash.c b/lib/libcurses/base/lib_flash.c
index fd4c3c07658..9f66c4cebd4 100644
--- a/lib/libcurses/base/lib_flash.c
+++ b/lib/libcurses/base/lib_flash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_flash.c,v 1.3 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_flash.c,v 1.4 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
#include <term.h> /* beep, flash */
-MODULE_ID("$From: lib_flash.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_flash.c,v 1.4 2010/01/12 23:22:05 nicm Exp $")
/*
* flash()
diff --git a/lib/libcurses/base/lib_freeall.c b/lib/libcurses/base/lib_freeall.c
index 5fc67234223..dd3a9449815 100644
--- a/lib/libcurses/base/lib_freeall.c
+++ b/lib/libcurses/base/lib_freeall.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_freeall.c,v 1.4 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_freeall.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +29,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
#include <term_entry.h>
+#include <tic.h>
#if HAVE_NC_FREEALL
@@ -41,31 +42,7 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$From: lib_freeall.c,v 1.18 2000/12/10 02:43:27 tom Exp $")
-
-static void
-free_slk(SLK * p)
-{
- if (p != 0) {
- FreeIfNeeded(p->ent);
- FreeIfNeeded(p->buffer);
- free(p);
- }
-}
-
-static void
-free_tries(struct tries *p)
-{
- struct tries *q;
-
- while (p != 0) {
- q = p->sibling;
- if (p->child != 0)
- free_tries(p->child);
- free(p);
- p = q;
- }
-}
+MODULE_ID("$Id: lib_freeall.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
/*
* Free all ncurses data. This is used for testing only (there's no practical
@@ -75,61 +52,92 @@ NCURSES_EXPORT(void)
_nc_freeall(void)
{
WINDOWLIST *p, *q;
+ static va_list empty_va;
+ T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
- _nc_free_tparm();
+ if (SP != 0) {
+ if (SP->_oldnum_list != 0) {
+ FreeAndNull(SP->_oldnum_list);
+ }
+ if (SP->_panelHook.destroy != 0) {
+ SP->_panelHook.destroy(SP->_panelHook.stdscr_pseudo_panel);
+ }
+ }
#endif
if (SP != 0) {
+ _nc_lock_global(curses);
+
while (_nc_windows != 0) {
+ bool deleted = FALSE;
+
/* Delete only windows that're not a parent */
- for (p = _nc_windows; p != 0; p = p->next) {
+ for (each_window(p)) {
bool found = FALSE;
- for (q = _nc_windows; q != 0; q = q->next) {
+ for (each_window(q)) {
if ((p != q)
- && (q->win->_flags & _SUBWIN)
- && (p->win == q->win->_parent)) {
+ && (q->win._flags & _SUBWIN)
+ && (&(p->win) == q->win._parent)) {
found = TRUE;
break;
}
}
if (!found) {
- delwin(p->win);
+ if (delwin(&(p->win)) != ERR)
+ deleted = TRUE;
break;
}
}
- }
- free_tries(SP->_keytry);
- free_tries(SP->_key_ok);
- free_slk(SP->_slk);
- FreeIfNeeded(SP->_color_pairs);
- FreeIfNeeded(SP->_color_table);
-#if !BROKEN_LINKER
- FreeAndNull(SP);
-#endif
+ /*
+ * Don't continue to loop if the list is trashed.
+ */
+ if (!deleted)
+ break;
+ }
+ delscreen(SP);
+ _nc_unlock_global(curses);
}
+ if (cur_term != 0)
+ del_curterm(cur_term);
- if (cur_term != 0) {
- _nc_free_termtype(&(cur_term->type));
- free(cur_term);
- }
+ (void) _nc_printf_string(0, empty_va);
#ifdef TRACE
(void) _nc_trace_buf(-1, 0);
#endif
+#if USE_WIDEC_SUPPORT
+ FreeIfNeeded(_nc_wacs);
+#endif
+ _nc_leaks_tinfo();
+
#if HAVE_LIBDBMALLOC
malloc_dump(malloc_errfd);
#elif HAVE_LIBDMALLOC
+#elif HAVE_LIBMPATROL
+ __mp_summary();
#elif HAVE_PURIFY
purify_all_inuse();
#endif
+ returnVoid;
}
NCURSES_EXPORT(void)
_nc_free_and_exit(int code)
{
+ char *last_setbuf = (SP != 0) ? SP->_setbuf : 0;
+
_nc_freeall();
+#ifdef TRACE
+ trace(0); /* close trace file, freeing its setbuf */
+ {
+ static va_list fake;
+ free(_nc_varargs("?", fake));
+ }
+#endif
+ fclose(stdout);
+ FreeIfNeeded(last_setbuf);
exit(code);
}
@@ -138,4 +146,14 @@ NCURSES_EXPORT(void)
_nc_freeall(void)
{
}
+
+NCURSES_EXPORT(void)
+_nc_free_and_exit(int code)
+{
+ if (SP)
+ delscreen(SP);
+ if (cur_term != 0)
+ del_curterm(cur_term);
+ exit(code);
+}
#endif
diff --git a/lib/libcurses/base/lib_getch.c b/lib/libcurses/base/lib_getch.c
index 0b17a36d043..db35bc803dc 100644
--- a/lib/libcurses/base/lib_getch.c
+++ b/lib/libcurses/base/lib_getch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_getch.c,v 1.10 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_getch.c,v 1.11 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,29 +43,96 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_getch.c,v 1.54 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.11 2010/01/12 23:22:05 nicm Exp $")
#include <fifo_defs.h>
+#if USE_REENTRANT
+#define GetEscdelay(sp) (sp)->_ESCDELAY
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(ESCDELAY) (void)
+{
+ return SP ? GetEscdelay(SP) : 1000;
+}
+#else
+#define GetEscdelay(sp) ESCDELAY
NCURSES_EXPORT_VAR(int)
ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
+#endif
+
+#if NCURSES_EXT_FUNCS
+NCURSES_EXPORT(int)
+set_escdelay(int value)
+{
+ int code = OK;
+#if USE_REENTRANT
+ if (SP) {
+ SP->_ESCDELAY = value;
+ } else {
+ code = ERR;
+ }
+#else
+ ESCDELAY = value;
+#endif
+ return code;
+}
+#endif
+
+static int
+_nc_use_meta(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ return (sp ? sp->_use_meta : 0);
+}
+
+#ifdef NCURSES_WGETCH_EVENTS
+#define TWAIT_MASK 7
+#else
+#define TWAIT_MASK 3
+#endif
+
+/*
+ * Check for mouse activity, returning nonzero if we find any.
+ */
+static int
+check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
+{
+ int rc;
+
+#if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)) {
+ return 2;
+ }
+#endif
+ rc = _nc_timed_wait(sp, TWAIT_MASK, delay, (int *) 0 EVENTLIST_2nd(evl));
+#if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)
+ && (rc == 0)
+ && (errno == EINTR)) {
+ rc |= 2;
+ }
+#endif
+ return rc;
+}
- static inline int
- fifo_peek(void)
+static NCURSES_INLINE int
+fifo_peek(SCREEN *sp)
{
- int ch = SP->_fifo[peek];
+ int ch = sp->_fifo[peek];
TR(TRACE_IEVENT, ("peeking at %d", peek));
p_inc();
return ch;
}
-static inline int
-fifo_pull(void)
+static NCURSES_INLINE int
+fifo_pull(SCREEN *sp)
{
int ch;
- ch = SP->_fifo[head];
- TR(TRACE_IEVENT, ("pulling %d from %d", ch, head));
+ ch = sp->_fifo[head];
+ TR(TRACE_IEVENT, ("pulling %s from %d", _nc_tracechar(sp, ch), head));
if (peek == head) {
h_inc();
@@ -73,18 +141,22 @@ fifo_pull(void)
h_inc();
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- _nc_fifo_dump();
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _nc_fifo_dump(sp);
+ _nc_unlock_global(tracef);
+ }
#endif
return ch;
}
-static inline int
-fifo_push(void)
+static NCURSES_INLINE int
+fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
{
int n;
- int ch;
+ int ch = 0;
+ int mask = 0;
+ (void) mask;
if (tail == -1)
return ERR;
@@ -93,18 +165,51 @@ fifo_push(void)
errno = 0;
#endif
-#if USE_GPM_SUPPORT || defined(USE_EMX_MOUSE)
- if ((SP->_mouse_fd >= 0)
- && (_nc_timed_wait(3, -1, (int *) 0) & 2)) {
- SP->_mouse_event(SP);
+#ifdef NCURSES_WGETCH_EVENTS
+ if (evl
+#if USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE
+ || (sp->_mouse_fd >= 0)
+#endif
+ ) {
+ mask = check_mouse_activity(sp, -1 EVENTLIST_2nd(evl));
+ } else
+ mask = 0;
+
+ if (mask & 4) {
+ T(("fifo_push: ungetch KEY_EVENT"));
+ _nc_ungetch(sp, KEY_EVENT);
+ return KEY_EVENT;
+ }
+#elif USE_GPM_SUPPORT || USE_EMX_MOUSE || USE_SYSMOUSE
+ if (sp->_mouse_fd >= 0) {
+ mask = check_mouse_activity(sp, -1 EVENTLIST_2nd(evl));
+ }
+#endif
+
+#if USE_GPM_SUPPORT || USE_EMX_MOUSE
+ if ((sp->_mouse_fd >= 0) && (mask & 2)) {
+ sp->_mouse_event(sp);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else
+#endif
+#if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)) {
+ sp->_mouse_event(sp);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else if ((sp->_mouse_type == M_SYSMOUSE)
+ && (mask <= 0) && errno == EINTR) {
+ sp->_mouse_event(sp);
ch = KEY_MOUSE;
n = 1;
} else
#endif
- {
+ { /* Can block... */
unsigned char c2 = 0;
- n = read(SP->_ifd, &c2, 1);
- ch = CharOf(c2);
+ n = read(sp->_ifd, &c2, 1);
+ ch = c2;
}
#ifdef HIDE_EINTR
@@ -122,96 +227,192 @@ fifo_push(void)
#endif
if ((n == -1) || (n == 0)) {
- TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", sp->_ifd, n, errno));
ch = ERR;
}
TR(TRACE_IEVENT, ("read %d characters", n));
- SP->_fifo[tail] = ch;
- SP->_fifohold = 0;
+ sp->_fifo[tail] = ch;
+ sp->_fifohold = 0;
if (head == -1)
head = peek = tail;
t_inc();
- TR(TRACE_IEVENT, ("pushed %#x at %d", ch, tail));
+ TR(TRACE_IEVENT, ("pushed %s at %d", _nc_tracechar(sp, ch), tail));
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- _nc_fifo_dump();
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _nc_fifo_dump(sp);
+ _nc_unlock_global(tracef);
+ }
#endif
return ch;
}
-static inline void
-fifo_clear(void)
+static NCURSES_INLINE void
+fifo_clear(SCREEN *sp)
{
- int i;
- for (i = 0; i < FIFO_SIZE; i++)
- SP->_fifo[i] = 0;
+ memset(sp->_fifo, 0, sizeof(sp->_fifo));
head = -1;
tail = peek = 0;
}
-static int kgetch(WINDOW *);
+static int kgetch(SCREEN *EVENTLIST_2nd(_nc_eventlist * evl));
+
+static void
+recur_wrefresh(WINDOW *win)
+{
+#ifdef USE_PTHREADS
+ SCREEN *sp = _nc_screen_of(win);
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to check/refresh */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ _nc_set_screen(sp);
+ recur_wrefresh(win);
+ _nc_set_screen(save_SP);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ if ((is_wintouched(win) || (win->_flags & _HASMOVED))
+ && !(win->_flags & _ISPAD)) {
+ wrefresh(win);
+ }
+}
-#define wgetch_should_refresh(win) (\
- (is_wintouched(win) || (win->_flags & _HASMOVED)) \
- && !(win->_flags & _ISPAD))
+static int
+recur_wgetnstr(WINDOW *win, char *buf)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ int rc;
+
+ if (sp != 0) {
+#ifdef USE_PTHREADS
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to get cooked input */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ _nc_set_screen(sp);
+ rc = recur_wgetnstr(win, buf);
+ _nc_set_screen(save_SP);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ {
+ sp->_called_wgetch = TRUE;
+ rc = wgetnstr(win, buf, MAXCOLUMNS);
+ sp->_called_wgetch = FALSE;
+ }
+ } else {
+ rc = ERR;
+ }
+ return rc;
+}
NCURSES_EXPORT(int)
-wgetch(WINDOW *win)
+_nc_wgetch(WINDOW *win,
+ unsigned long *result,
+ int use_meta
+ EVENTLIST_2nd(_nc_eventlist * evl))
{
+ SCREEN *sp;
int ch;
+#ifdef NCURSES_WGETCH_EVENTS
+ long event_delay = -1;
+#endif
- T((T_CALLED("wgetch(%p)"), win));
+ T((T_CALLED("_nc_wgetch(%p)"), win));
- if (!win)
+ *result = 0;
+
+ sp = _nc_screen_of(win);
+ if (win == 0 || sp == 0) {
returnCode(ERR);
+ }
if (cooked_key_in_fifo()) {
- if (wgetch_should_refresh(win))
- wrefresh(win);
-
- ch = fifo_pull();
- T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch)));
- returnCode(ch);
+ recur_wrefresh(win);
+ *result = fifo_pull(sp);
+ returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
+#ifdef NCURSES_WGETCH_EVENTS
+ if (evl && (evl->count == 0))
+ evl = NULL;
+ event_delay = _nc_eventlist_timeout(evl);
+#endif
/*
* Handle cooked mode. Grab a string from the screen,
* stuff its contents in the FIFO queue, and pop off
* the first character to return it.
*/
- if (head == -1 && !SP->_raw && !SP->_cbreak) {
- char buf[MAXCOLUMNS], *sp;
+ if (head == -1 &&
+ !sp->_notty &&
+ !sp->_raw &&
+ !sp->_cbreak &&
+ !sp->_called_wgetch) {
+ char buf[MAXCOLUMNS], *bufp;
+ int rc;
TR(TRACE_IEVENT, ("filling queue in cooked mode"));
- wgetnstr(win, buf, MAXCOLUMNS);
+ rc = recur_wgetnstr(win, buf);
/* ungetch in reverse order */
- ungetch('\n');
- for (sp = buf + strlen(buf); sp > buf; sp--)
- ungetch(sp[-1]);
-
- returnCode(fifo_pull());
+#ifdef NCURSES_WGETCH_EVENTS
+ if (rc != KEY_EVENT)
+#endif
+ _nc_ungetch(sp, '\n');
+ for (bufp = buf + strlen(buf); bufp > buf; bufp--)
+ _nc_ungetch(sp, bufp[-1]);
+
+#ifdef NCURSES_WGETCH_EVENTS
+ /* Return it first */
+ if (rc == KEY_EVENT) {
+ *result = rc;
+ } else
+#endif
+ *result = fifo_pull(sp);
+ returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ if (win->_use_keypad != sp->_keypad_on)
+ _nc_keypad(sp, win->_use_keypad);
+
+ recur_wrefresh(win);
+
+ if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) {
+ if (head == -1) { /* fifo is empty */
+ int delay;
+ int rc;
- if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
- int delay;
+ TR(TRACE_IEVENT, ("timed delay in wgetch()"));
+ if (sp->_cbreak > 1)
+ delay = (sp->_cbreak - 1) * 100;
+ else
+ delay = win->_delay;
+
+#ifdef NCURSES_WGETCH_EVENTS
+ if (event_delay >= 0 && delay > event_delay)
+ delay = event_delay;
+#endif
- TR(TRACE_IEVENT, ("timed delay in wgetch()"));
- if (SP->_cbreak > 1)
- delay = (SP->_cbreak - 1) * 100;
- else
- delay = win->_delay;
+ TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
- TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
+ rc = check_mouse_activity(sp, delay EVENTLIST_2nd(evl));
- if (head == -1) /* fifo is empty */
- if (!_nc_timed_wait(3, delay, (int *) 0))
+#ifdef NCURSES_WGETCH_EVENTS
+ if (rc & 4) {
+ *result = KEY_EVENT;
+ returnCode(KEY_CODE_YES);
+ }
+#endif
+ if (!rc) {
returnCode(ERR);
+ }
+ }
/* else go on to read data available */
}
@@ -228,42 +429,59 @@ wgetch(WINDOW *win)
* increase the wait with mouseinterval().
*/
int runcount = 0;
+ int rc;
do {
- ch = kgetch(win);
+ ch = kgetch(sp EVENTLIST_2nd(evl));
if (ch == KEY_MOUSE) {
++runcount;
- if (SP->_mouse_inline(SP))
+ if (sp->_mouse_inline(sp))
break;
}
+ if (sp->_maxclick < 0)
+ break;
} while
(ch == KEY_MOUSE
- && (_nc_timed_wait(3, SP->_maxclick, (int *) 0)
- || !SP->_mouse_parse(runcount)));
+ && (((rc = check_mouse_activity(sp, sp->_maxclick
+ EVENTLIST_2nd(evl))) != 0
+ && !(rc & 4))
+ || !sp->_mouse_parse(sp, runcount)));
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((rc & 4) && !ch == KEY_EVENT) {
+ _nc_ungetch(sp, ch);
+ ch = KEY_EVENT;
+ }
+#endif
if (runcount > 0 && ch != KEY_MOUSE) {
- /* mouse event sequence ended by keystroke, push it */
- ungetch(ch);
- ch = KEY_MOUSE;
+#ifdef NCURSES_WGETCH_EVENTS
+ /* mouse event sequence ended by an event, report event */
+ if (ch == KEY_EVENT) {
+ _nc_ungetch(sp, KEY_MOUSE); /* FIXME This interrupts a gesture... */
+ } else
+#endif
+ {
+ /* mouse event sequence ended by keystroke, store keystroke */
+ _nc_ungetch(sp, ch);
+ ch = KEY_MOUSE;
+ }
}
} else {
if (head == -1)
- fifo_push();
- ch = fifo_pull();
+ fifo_push(sp EVENTLIST_2nd(evl));
+ ch = fifo_pull(sp);
}
if (ch == ERR) {
#if USE_SIZECHANGE
- if (SP->_sig_winch) {
- _nc_update_screensize();
+ if (_nc_handle_sigwinch(sp)) {
+ _nc_update_screensize(sp);
/* resizeterm can push KEY_RESIZE */
if (cooked_key_in_fifo()) {
- ch = fifo_pull();
- T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch)));
- returnCode(ch);
+ *result = fifo_pull(sp);
+ returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
}
}
#endif
- T(("wgetch returning ERR"));
returnCode(ERR);
}
@@ -285,7 +503,7 @@ wgetch(WINDOW *win)
* However, we provide the same visual result as Solaris, moving the
* cursor to the left.
*/
- if (SP->_echo && !(win->_flags & _ISPAD)) {
+ if (sp->_echo && !(win->_flags & _ISPAD)) {
chtype backup = (ch == KEY_BACKSPACE) ? '\b' : ch;
if (backup < KEY_MIN)
wechochar(win, backup);
@@ -294,7 +512,7 @@ wgetch(WINDOW *win)
/*
* Simulate ICRNL mode
*/
- if ((ch == '\r') && SP->_nl)
+ if ((ch == '\r') && sp->_nl)
ch = '\n';
/* Strip 8th-bit if so desired. We do this only for characters that
@@ -302,13 +520,48 @@ wgetch(WINDOW *win)
* that display only 7-bit characters. Note that 'ch' may be a
* function key at this point, so we mustn't strip _those_.
*/
- if ((ch < KEY_MIN) && (ch & 0x80))
- if (!SP->_use_meta)
+ if (!use_meta)
+ if ((ch < KEY_MIN) && (ch & 0x80))
ch &= 0x7f;
- T(("wgetch returning : %#x = %s", ch, _trace_key(ch)));
+ T(("wgetch returning : %s", _nc_tracechar(sp, ch)));
+
+ *result = ch;
+ returnCode(ch >= KEY_MIN ? KEY_CODE_YES : OK);
+}
+
+#ifdef NCURSES_WGETCH_EVENTS
+NCURSES_EXPORT(int)
+wgetch_events(WINDOW *win, _nc_eventlist * evl)
+{
+ int code;
+ unsigned long value;
+
+ T((T_CALLED("wgetch_events(%p,%p)"), win, evl));
+ code = _nc_wgetch(win,
+ &value,
+ _nc_use_meta(win)
+ EVENTLIST_2nd(evl));
+ if (code != ERR)
+ code = value;
+ returnCode(code);
+}
+#endif
+
+NCURSES_EXPORT(int)
+wgetch(WINDOW *win)
+{
+ int code;
+ unsigned long value;
- returnCode(ch);
+ T((T_CALLED("wgetch(%p)"), win));
+ code = _nc_wgetch(win,
+ &value,
+ _nc_use_meta(win)
+ EVENTLIST_2nd((_nc_eventlist *) 0));
+ if (code != ERR)
+ code = value;
+ returnCode(code);
}
/*
@@ -321,55 +574,66 @@ wgetch(WINDOW *win)
** sequence is received by the time the alarm goes off, pass through
** the sequence gotten so far.
**
-** This function must be called when there is no cooked keys in queue.
+** This function must be called when there are no cooked keys in queue.
** (that is head==-1 || peek==head)
**
*/
static int
-kgetch(WINDOW *win GCC_UNUSED)
+kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
{
- struct tries *ptr;
+ TRIES *ptr;
int ch = 0;
- int timeleft = ESCDELAY;
+ int timeleft = GetEscdelay(sp);
- TR(TRACE_IEVENT, ("kgetch(%p) called", win));
+ TR(TRACE_IEVENT, ("kgetch() called"));
- ptr = SP->_keytry;
+ ptr = sp->_keytry;
for (;;) {
- if (!raw_key_in_fifo()) {
- if (fifo_push() == ERR) {
+ if (cooked_key_in_fifo() && sp->_fifo[head] >= KEY_MIN) {
+ break;
+ } else if (!raw_key_in_fifo()) {
+ ch = fifo_push(sp EVENTLIST_2nd(evl));
+ if (ch == ERR) {
peek = head; /* the keys stay uninterpreted */
return ERR;
}
+#ifdef NCURSES_WGETCH_EVENTS
+ else if (ch == KEY_EVENT) {
+ peek = head; /* the keys stay uninterpreted */
+ return fifo_pull(sp); /* Remove KEY_EVENT from the queue */
+ }
+#endif
}
- ch = fifo_peek();
+
+ ch = fifo_peek(sp);
if (ch >= KEY_MIN) {
+ /* If not first in queue, somebody put this key there on purpose in
+ * emergency. Consider it higher priority than the unfinished
+ * keysequence we are parsing.
+ */
peek = head;
/* assume the key is the last in fifo */
t_dec(); /* remove the key */
return ch;
}
- TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char) ch)));
+ TR(TRACE_IEVENT, ("ch: %s", _nc_tracechar(sp, (unsigned char) ch)));
while ((ptr != NULL) && (ptr->ch != (unsigned char) ch))
ptr = ptr->sibling;
-#ifdef TRACE
+
if (ptr == NULL) {
TR(TRACE_IEVENT, ("ptr is null"));
- } else
- TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
- ptr, ptr->ch, ptr->value));
-#endif /* TRACE */
-
- if (ptr == NULL)
break;
+ }
+ TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
+ ptr, ptr->ch, ptr->value));
if (ptr->value != 0) { /* sequence terminated */
TR(TRACE_IEVENT, ("end of sequence"));
if (peek == tail)
- fifo_clear();
+ fifo_clear(sp);
else
head = peek;
return (ptr->value);
@@ -378,14 +642,25 @@ kgetch(WINDOW *win GCC_UNUSED)
ptr = ptr->child;
if (!raw_key_in_fifo()) {
+ int rc;
+
TR(TRACE_IEVENT, ("waiting for rest of sequence"));
- if (!_nc_timed_wait(3, timeleft, &timeleft)) {
+ rc = check_mouse_activity(sp, timeleft EVENTLIST_2nd(evl));
+#ifdef NCURSES_WGETCH_EVENTS
+ if (rc & 4) {
+ TR(TRACE_IEVENT, ("interrupted by a user event"));
+ /* FIXME Should have preserved remainder timeleft for reuse... */
+ peek = head; /* Restart interpreting later */
+ return KEY_EVENT;
+ }
+#endif
+ if (!rc) {
TR(TRACE_IEVENT, ("ran out of time"));
break;
}
}
}
- ch = fifo_pull();
+ ch = fifo_pull(sp);
peek = head;
return ch;
}
diff --git a/lib/libcurses/base/lib_getstr.c b/lib/libcurses/base/lib_getstr.c
index 0744f96f40e..b83a0523e63 100644
--- a/lib/libcurses/base/lib_getstr.c
+++ b/lib/libcurses/base/lib_getstr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_getstr.c,v 1.2 2001/01/22 18:01:39 millert Exp $ */
+/* $OpenBSD: lib_getstr.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_getstr.c,v 1.23 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
/*
* This wipes out the last character, no matter whether it was a tab, control
@@ -72,8 +72,12 @@ WipeOut(WINDOW *win, int y, int x, char *first, char *last, bool echoed)
}
NCURSES_EXPORT(int)
-wgetnstr(WINDOW *win, char *str, int maxlen)
+wgetnstr_events(WINDOW *win,
+ char *str,
+ int maxlen,
+ EVENTLIST_1st(_nc_eventlist * evl))
{
+ SCREEN *sp = _nc_screen_of(win);
TTY buf;
bool oldnl, oldecho, oldraw, oldcbreak;
char erasec;
@@ -89,10 +93,10 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
_nc_get_tty_mode(&buf);
- oldnl = SP->_nl;
- oldecho = SP->_echo;
- oldraw = SP->_raw;
- oldcbreak = SP->_cbreak;
+ oldnl = sp->_nl;
+ oldecho = sp->_echo;
+ oldraw = sp->_raw;
+ oldcbreak = sp->_cbreak;
nl();
noecho();
noraw();
@@ -107,7 +111,7 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
if (is_wintouched(win) || (win->_flags & _HASMOVED))
wrefresh(win);
- while ((ch = wgetch(win)) != ERR) {
+ while ((ch = wgetch_events(win, evl)) != ERR) {
/*
* Some terminals (the Wyse-50 is the most common) generate
* a \n from the down-arrow key. With this logic, it's the
@@ -124,6 +128,14 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
wechochar(win, (chtype) '\n');
break;
}
+#ifdef KEY_EVENT
+ if (ch == KEY_EVENT)
+ break;
+#endif
+#ifdef KEY_RESIZE
+ if (ch == KEY_RESIZE)
+ break;
+#endif
if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
if (str > oldstr) {
str = WipeOut(win, y, x, oldstr, str, oldecho);
@@ -136,7 +148,7 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
|| (maxlen >= 0 && str - oldstr >= maxlen)) {
beep();
} else {
- *str++ = ch;
+ *str++ = (char) ch;
if (oldecho == TRUE) {
int oldy = win->_cury;
if (waddch(win, (chtype) ch) == ERR) {
@@ -178,18 +190,38 @@ wgetnstr(WINDOW *win, char *str, int maxlen)
/* Restore with a single I/O call, to fix minor asymmetry between
* raw/noraw, etc.
*/
- SP->_nl = oldnl;
- SP->_echo = oldecho;
- SP->_raw = oldraw;
- SP->_cbreak = oldcbreak;
+ sp->_nl = oldnl;
+ sp->_echo = oldecho;
+ sp->_raw = oldraw;
+ sp->_cbreak = oldcbreak;
_nc_set_tty_mode(&buf);
*str = '\0';
if (ch == ERR)
- returnCode(ERR);
+ returnCode(ch);
T(("wgetnstr returns %s", _nc_visbuf(oldstr)));
+#ifdef KEY_EVENT
+ if (ch == KEY_EVENT)
+ returnCode(ch);
+#endif
+#ifdef KEY_RESIZE
+ if (ch == KEY_RESIZE)
+ returnCode(ch);
+#endif
+
returnCode(OK);
}
+
+#ifdef NCURSES_WGETCH_EVENTS
+NCURSES_EXPORT(int)
+wgetnstr(WINDOW *win, char *str, int maxlen)
+{
+ returnCode(wgetnstr_events(win,
+ str,
+ maxlen,
+ EVENTLIST_1st((_nc_eventlist *) 0)));
+}
+#endif
diff --git a/lib/libcurses/base/lib_hline.c b/lib/libcurses/base/lib_hline.c
index 6854c5a61a1..58d83488068 100644
--- a/lib/libcurses/base/lib_hline.c
+++ b/lib/libcurses/base/lib_hline.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_hline.c,v 1.4 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_hline.c,v 1.5 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_hline.c,v 1.8 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_hline.c,v 1.5 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
whline(WINDOW *win, chtype ch, int n)
@@ -55,6 +55,7 @@ whline(WINDOW *win, chtype ch, int n)
if (win) {
struct ldat *line = &(win->_line[win->_cury]);
+ NCURSES_CH_T wch;
start = win->_curx;
end = start + n - 1;
@@ -64,11 +65,13 @@ whline(WINDOW *win, chtype ch, int n)
CHANGED_RANGE(line, start, end);
if (ch == 0)
- ch = ACS_HLINE;
- ch = _nc_render(win, ch);
+ SetChar2(wch, ACS_HLINE);
+ else
+ SetChar2(wch, ch);
+ wch = _nc_render(win, wch);
while (end >= start) {
- line->text[end] = ch;
+ line->text[end] = wch;
end--;
}
diff --git a/lib/libcurses/base/lib_immedok.c b/lib/libcurses/base/lib_immedok.c
index f5925446e8d..53effcbad16 100644
--- a/lib/libcurses/base/lib_immedok.c
+++ b/lib/libcurses/base/lib_immedok.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_immedok.c,v 1.2 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_immedok.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_immedok.c,v 1.4 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_immedok.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(void)
immedok(WINDOW *win, bool flag)
diff --git a/lib/libcurses/base/lib_inchstr.c b/lib/libcurses/base/lib_inchstr.c
index 0965de4ffdb..87fddea809f 100644
--- a/lib/libcurses/base/lib_inchstr.c
+++ b/lib/libcurses/base/lib_inchstr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_inchstr.c,v 1.2 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_inchstr.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_inchstr.c,v 1.9 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_inchstr.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
winchnstr(WINDOW *win, chtype * str, int n)
@@ -56,7 +56,9 @@ winchnstr(WINDOW *win, chtype * str, int n)
if (win) {
for (; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
- str[i] = win->_line[win->_cury].text[win->_curx + i];
+ str[i] =
+ CharOf(win->_line[win->_cury].text[win->_curx + i]) |
+ AttrOf(win->_line[win->_cury].text[win->_curx + i]);
}
str[i] = (chtype) 0;
diff --git a/lib/libcurses/base/lib_initscr.c b/lib/libcurses/base/lib_initscr.c
index c3fa8fecbdd..6f8fa785065 100644
--- a/lib/libcurses/base/lib_initscr.c
+++ b/lib/libcurses/base/lib_initscr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_initscr.c,v 1.2 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_initscr.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-2003 *
****************************************************************************/
/*
@@ -41,41 +42,60 @@
*/
#include <curses.priv.h>
-#include <tic.h> /* for MAX_ALIAS */
#if HAVE_SYS_TERMIO_H
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$From: lib_initscr.c,v 1.28 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(WINDOW *)
initscr(void)
{
- static bool initialized = FALSE;
+ WINDOW *result;
+
NCURSES_CONST char *name;
- int value;
+ START_TRACE();
T((T_CALLED("initscr()")));
+
+ _nc_init_pthreads();
+ _nc_lock_global(curses);
+
/* Portable applications must not call initscr() more than once */
- if (!initialized) {
- initialized = TRUE;
+ if (!_nc_globals.init_screen) {
+ _nc_globals.init_screen = TRUE;
if ((name = getenv("TERM")) == 0
|| *name == '\0')
name = "unknown";
+#ifdef __CYGWIN__
+ /*
+ * 2002/9/21
+ * Work around a bug in Cygwin. Full-screen subprocesses run from
+ * bash, in turn spawned from another full-screen process, will dump
+ * core when attempting to write to stdout. Opening /dev/tty
+ * explicitly seems to fix the problem.
+ */
+ if (isatty(fileno(stdout))) {
+ FILE *fp = fopen("/dev/tty", "w");
+ if (fp != 0 && isatty(fileno(fp))) {
+ fclose(stdout);
+ dup2(fileno(fp), STDOUT_FILENO);
+ stdout = fdopen(STDOUT_FILENO, "w");
+ }
+ }
+#endif
if (newterm(name, stdout, stdin) == 0) {
fprintf(stderr, "Error opening terminal: %s.\n", name);
exit(EXIT_FAILURE);
}
- /* allow user to set maximum escape delay from the environment */
- if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
- ESCDELAY = value;
- }
-
/* def_shell_mode - done in newterm/_nc_setupscreen */
def_prog_mode();
}
- returnWin(stdscr);
+ result = stdscr;
+ _nc_unlock_global(curses);
+
+ returnWin(result);
}
diff --git a/lib/libcurses/base/lib_insch.c b/lib/libcurses/base/lib_insch.c
index 5d6ef421df9..d0b7404c331 100644
--- a/lib/libcurses/base/lib_insch.c
+++ b/lib/libcurses/base/lib_insch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_insch.c,v 1.2 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_insch.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Sven Verdoolaege *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
@@ -41,28 +43,115 @@
*/
#include <curses.priv.h>
+#include <ctype.h>
-MODULE_ID("$From: lib_insch.c,v 1.12 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
+
+/*
+ * Insert the given character, updating the current location to simplify
+ * inserting a string.
+ */
+NCURSES_EXPORT(int)
+_nc_insert_ch(WINDOW *win, chtype ch)
+{
+ int code = OK;
+ NCURSES_CH_T wch;
+ int count;
+ NCURSES_CONST char *s;
+
+ switch (ch) {
+ case '\t':
+ for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--) {
+ if ((code = _nc_insert_ch(win, ' ')) != OK)
+ break;
+ }
+ break;
+ case '\n':
+ case '\r':
+ case '\b':
+ SetChar2(wch, ch);
+ _nc_waddch_nosync(win, wch);
+ break;
+ default:
+ if (
+#if USE_WIDEC_SUPPORT
+ WINDOW_EXT(win, addch_used) == 0 &&
+#endif
+ is8bits(ChCharOf(ch)) &&
+ isprint(ChCharOf(ch))) {
+ if (win->_curx <= win->_maxx) {
+ struct ldat *line = &(win->_line[win->_cury]);
+ NCURSES_CH_T *end = &(line->text[win->_curx]);
+ NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+ NCURSES_CH_T *temp2 = temp1 - 1;
+
+ SetChar2(wch, ch);
+
+ CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = _nc_render(win, wch);
+ win->_curx++;
+ }
+ } else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
+ s = unctrl(ChCharOf(ch));
+ while (*s != '\0') {
+ code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
+ if (code != OK)
+ break;
+ ++s;
+ }
+ }
+#if USE_WIDEC_SUPPORT
+ else {
+ /*
+ * Handle multibyte characters here
+ */
+ SetChar2(wch, ch);
+ wch = _nc_render(win, wch);
+ count = _nc_build_wch(win, &wch);
+ if (count > 0) {
+ code = wins_wch(win, &wch);
+ } else if (count == -1) {
+ /* handle EILSEQ */
+ if (is8bits(ch)) {
+ s = unctrl(ChCharOf(ch));
+ while (*s != '\0') {
+ code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
+ if (code != OK)
+ break;
+ ++s;
+ }
+ } else {
+ code = ERR;
+ }
+ }
+ }
+#endif
+ break;
+ }
+ return code;
+}
NCURSES_EXPORT(int)
winsch(WINDOW *win, chtype c)
{
+ NCURSES_SIZE_T oy;
+ NCURSES_SIZE_T ox;
int code = ERR;
T((T_CALLED("winsch(%p, %s)"), win, _tracechtype(c)));
- if (win) {
- struct ldat *line = &(win->_line[win->_cury]);
- chtype *end = &(line->text[win->_curx]);
- chtype *temp1 = &(line->text[win->_maxx]);
- chtype *temp2 = temp1 - 1;
+ if (win != 0) {
+ oy = win->_cury;
+ ox = win->_curx;
- CHANGED_TO_EOL(line, win->_curx, win->_maxx);
- while (temp1 > end)
- *temp1-- = *temp2--;
+ code = _nc_insert_ch(win, c);
- *temp1 = _nc_render(win, c);
- code = OK;
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
}
returnCode(code);
}
diff --git a/lib/libcurses/base/lib_insdel.c b/lib/libcurses/base/lib_insdel.c
index 9c02cfda019..dc121093809 100644
--- a/lib/libcurses/base/lib_insdel.c
+++ b/lib/libcurses/base/lib_insdel.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_insdel.c,v 1.2 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_insdel.c,v 1.3 2010/01/12 23:22:05 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -44,19 +44,19 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_insdel.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_insdel.c,v 1.3 2010/01/12 23:22:05 nicm Exp $")
NCURSES_EXPORT(int)
winsdelln(WINDOW *win, int n)
{
int code = ERR;
- T((T_CALLED("winsdel(%p,%d)"), win, n));
+ T((T_CALLED("winsdelln(%p,%d)"), win, n));
if (win) {
if (n != 0) {
_nc_scroll_window(win, -n, win->_cury, win->_maxy,
- _nc_background(win));
+ win->_nc_bkgd);
_nc_synchook(win);
}
code = OK;
diff --git a/lib/libcurses/base/lib_insstr.c b/lib/libcurses/base/lib_insnstr.c
index 20ed15f9f60..3929d148699 100644
--- a/lib/libcurses/base/lib_insstr.c
+++ b/lib/libcurses/base/lib_insnstr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_insstr.c,v 1.4 2001/01/22 18:01:40 millert Exp $ */
+/* $OpenBSD: lib_insnstr.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +29,11 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
-** lib_insstr.c
+** lib_insnstr.c
**
** The routine winsnstr().
**
@@ -43,7 +42,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_insstr.c,v 1.17 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_insnstr.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
winsnstr(WINDOW *win, const char *s, int n)
@@ -54,26 +53,14 @@ winsnstr(WINDOW *win, const char *s, int n)
const unsigned char *str = (const unsigned char *) s;
const unsigned char *cp;
- T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
+ T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n));
- if (win && str) {
+ if (win != 0 && str != 0) {
oy = win->_cury;
ox = win->_curx;
for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
- if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
- _nc_waddch_nosync(win, (chtype) (*cp));
- else if (is7bits(*cp) && iscntrl(*cp)) {
- winsch(win, ' ' + (chtype) (*cp));
- winsch(win, (chtype) '^');
- win->_curx += 2;
- } else {
- winsch(win, (chtype) (*cp));
- win->_curx++;
- }
- if (win->_curx > win->_maxx)
- win->_curx = win->_maxx;
+ _nc_insert_ch(win, (chtype) UChar(*cp));
}
-
win->_curx = ox;
win->_cury = oy;
_nc_synchook(win);
diff --git a/lib/libcurses/base/lib_instr.c b/lib/libcurses/base/lib_instr.c
index 8977e40484a..bf943ad4b24 100644
--- a/lib/libcurses/base/lib_instr.c
+++ b/lib/libcurses/base/lib_instr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_instr.c,v 1.2 2001/01/22 18:01:41 millert Exp $ */
+/* $OpenBSD: lib_instr.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_instr.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
winnstr(WINDOW *win, char *str, int n)
@@ -61,14 +62,53 @@ winnstr(WINDOW *win, char *str, int n)
n = win->_maxx - win->_curx + 1;
for (; i < n;) {
- str[i++] = TextOf(win->_line[row].text[col]);
+#if USE_WIDEC_SUPPORT
+ cchar_t *cell = &(win->_line[row].text[col]);
+ wchar_t *wch;
+ attr_t attrs;
+ short pair;
+ int n2;
+ bool done = FALSE;
+ mbstate_t state;
+ size_t i3, n3;
+ char *tmp;
+
+ if (!isWidecExt(*cell)) {
+ n2 = getcchar(cell, 0, 0, 0, 0);
+ if (n2 > 0
+ && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != 0) {
+ if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
+
+ init_mb(state);
+ n3 = wcstombs(0, wch, 0);
+ if (isEILSEQ(n3) || (n3 == 0)) {
+ ;
+ } else if ((int) (n3 + i) > n) {
+ done = TRUE;
+ } else if ((tmp = typeCalloc(char, n3 + 10)) == 0) {
+ done = TRUE;
+ } else {
+ init_mb(state);
+ wcstombs(tmp, wch, n3);
+ for (i3 = 0; i3 < n3; ++i3)
+ str[i++] = tmp[i3];
+ free(tmp);
+ }
+ }
+ free(wch);
+ if (done)
+ break;
+ }
+ }
+#else
+ str[i++] = (char) CharOf(win->_line[row].text[col]);
+#endif
if (++col > win->_maxx) {
- col = 0;
- if (++row > win->_maxy)
- break;
+ break;
}
}
}
str[i] = '\0'; /* SVr4 does not seem to count the null */
+ T(("winnstr returns %s", _nc_visbuf(str)));
returnCode(i);
}
diff --git a/lib/libcurses/base/lib_isendwin.c b/lib/libcurses/base/lib_isendwin.c
index 55495476584..2c8421e5298 100644
--- a/lib/libcurses/base/lib_isendwin.c
+++ b/lib/libcurses/base/lib_isendwin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_isendwin.c,v 1.2 2001/01/22 18:01:41 millert Exp $ */
+/* $OpenBSD: lib_isendwin.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_isendwin.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_isendwin.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(bool)
isendwin(void)
diff --git a/lib/libcurses/base/lib_leaveok.c b/lib/libcurses/base/lib_leaveok.c
index a496d226c42..8edde4dc459 100644
--- a/lib/libcurses/base/lib_leaveok.c
+++ b/lib/libcurses/base/lib_leaveok.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_leaveok.c,v 1.2 2001/01/22 18:01:41 millert Exp $ */
+/* $OpenBSD: lib_leaveok.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_leaveok.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_leaveok.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
leaveok(WINDOW *win, bool flag)
diff --git a/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c
index a6108e32517..fe5278dd0df 100644
--- a/lib/libcurses/base/lib_mouse.c
+++ b/lib/libcurses/base/lib_mouse.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_mouse.c,v 1.13 2001/01/22 18:01:41 millert Exp $ */
+/* $OpenBSD: lib_mouse.c,v 1.14 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,14 +31,18 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* This module is intended to encapsulate ncurses's interface to pointing
* devices.
*
- * The first method used is xterm's internal mouse-tracking facility.
- * The second is Alessandro Rubini's GPM server.
+ * The primary method used is xterm's internal mouse-tracking facility.
+ * Additional methods depend on the platform:
+ * Alessandro Rubini's GPM server (Linux)
+ * sysmouse (FreeBSD)
+ * special-purpose mouse interface for OS/2 EMX.
*
* Notes for implementors of new mouse-interface methods:
*
@@ -76,82 +80,131 @@
#endif
#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_mouse.c,v 1.14 2010/01/12 23:22:06 nicm Exp $")
+
#include <term.h>
+#include <tic.h>
#if USE_GPM_SUPPORT
-#ifndef LINT /* don't need this for llib-lncurses */
-#undef buttons /* term.h defines this, and gpm uses it! */
-#include <gpm.h>
#include <linux/keyboard.h> /* defines KG_* macros */
+
+#ifdef HAVE_LIBDL
+/* use dynamic loader to avoid linkage dependency */
+#include <dlfcn.h>
+
+#ifdef RTLD_NOW
+#define my_RTLD RTLD_NOW
+#else
+#ifdef RTLD_LAZY
+#define my_RTLD RTLD_LAZY
+#else
+make an error
#endif
+#endif /* RTLD_NOW */
+#endif /* HAVE_LIBDL */
+
+#endif /* USE_GPM_SUPPORT */
+
+#if USE_SYSMOUSE
+#undef buttons /* symbol conflict in consio.h */
+#undef mouse_info /* symbol conflict in consio.h */
+#include <osreldate.h>
+#if (__FreeBSD_version >= 400017)
+#include <sys/consio.h>
+#include <sys/fbio.h>
+#else
+#include <machine/console.h>
#endif
-
-MODULE_ID("$From: lib_mouse.c,v 1.57 2000/12/10 02:43:27 tom Exp $")
+#endif /* use_SYSMOUSE */
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
-#define INVALID_EVENT -1
+#define MASK_RELEASE(x) NCURSES_MOUSE_MASK(x, 001)
+#define MASK_PRESS(x) NCURSES_MOUSE_MASK(x, 002)
+#define MASK_CLICK(x) NCURSES_MOUSE_MASK(x, 004)
+#define MASK_DOUBLE_CLICK(x) NCURSES_MOUSE_MASK(x, 010)
+#define MASK_TRIPLE_CLICK(x) NCURSES_MOUSE_MASK(x, 020)
+#define MASK_RESERVED_EVENT(x) NCURSES_MOUSE_MASK(x, 040)
+
+#if NCURSES_MOUSE_VERSION == 1
+#define BUTTON_CLICKED (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED)
+#define BUTTON_PRESSED (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED)
+#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED | BUTTON4_RELEASED)
+#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED)
+#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED)
+#define MAX_BUTTONS 4
+#else
+#define BUTTON_CLICKED (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED | BUTTON5_CLICKED)
+#define BUTTON_PRESSED (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED)
+#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED | BUTTON4_RELEASED | BUTTON5_RELEASED)
+#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED | BUTTON5_DOUBLE_CLICKED)
+#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED | BUTTON5_TRIPLE_CLICKED)
+#define MAX_BUTTONS 5
+#endif
-static int mousetype;
-#define M_XTERM -1 /* use xterm's mouse tracking? */
-#define M_NONE 0 /* no mouse device */
-#define M_GPM 1 /* use GPM */
-#define M_QNX 2 /* QNX mouse on console */
-#define M_QNX_TERM 3 /* QNX mouse on pterm/xterm (using qansi-m) */
+#define INVALID_EVENT -1
+#define NORMAL_EVENT 0
#if USE_GPM_SUPPORT
-#ifndef LINT
-static Gpm_Connect gpm_connect;
-#endif
+
+#ifndef LIBGPM_SONAME
+#define LIBGPM_SONAME "libgpm.so"
#endif
-static mmask_t eventmask; /* current event mask */
+#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(SP->_dlopen_gpm, #name))
-static bool _nc_mouse_parse(int);
+#endif /* USE_GPM_SUPPORT */
+
+static bool _nc_mouse_parse(SCREEN *, int);
static void _nc_mouse_resume(SCREEN *);
static void _nc_mouse_wrap(SCREEN *);
/* maintain a circular list of mouse events */
-/* The definition of the circular list size (EV_MAX), is in curses.priv.h, so
- * wgetch() may refer to the size and call _nc_mouse_parse() before circular
- * list overflow.
- */
-static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
-static MEVENT *eventp = events; /* next free slot in event queue */
-#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
-#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
+#define FirstEV(sp) ((sp)->_mouse_events)
+#define LastEV(sp) ((sp)->_mouse_events + EV_MAX - 1)
+
+#undef NEXT
+#define NEXT(ep) ((ep >= LastEV(sp)) \
+ ? FirstEV(sp) \
+ : ep + 1)
+
+#undef PREV
+#define PREV(ep) ((ep <= FirstEV(sp)) \
+ ? LastEV(sp) \
+ : ep - 1)
+
+#define IndexEV(sp, ep) (ep - FirstEV(sp))
+
+#define RunParams(sp, eventp, runp) \
+ (long) IndexEV(sp, runp), \
+ (long) (IndexEV(sp, eventp) + (EV_MAX - 1)) % EV_MAX
#ifdef TRACE
static void
-_trace_slot(const char *tag)
+_trace_slot(SCREEN *sp, const char *tag)
{
MEVENT *ep;
_tracef(tag);
- for (ep = events; ep < events + EV_MAX; ep++)
+ for (ep = FirstEV(sp); ep <= LastEV(sp); ep++)
_tracef("mouse event queue slot %ld = %s",
- (long) (ep - events),
- _tracemouse(ep));
+ (long) IndexEV(sp, ep),
+ _nc_tracemouse(sp, ep));
}
#endif
-#ifdef USE_EMX_MOUSE
+#if USE_EMX_MOUSE
# define TOP_ROW 0
# define LEFT_COL 0
-static int mouse_wfd;
-static int mouse_thread;
-static int mouse_activated;
-static char mouse_buttons[] =
-{0, 1, 3, 2};
-
# define M_FD(sp) sp->_mouse_fd
static void
-write_event(int down, int button, int x, int y)
+write_event(SCREEN *sp, int down, int button, int x, int y)
{
char buf[6];
unsigned long ignore;
@@ -160,12 +213,13 @@ write_event(int down, int button, int x, int y)
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
- DosWrite(mouse_wfd, buf, 6, &ignore);
+ DosWrite(sp->_emxmouse_wfd, buf, 6, &ignore);
}
static void
-mouse_server(unsigned long ignored GCC_UNUSED)
+mouse_server(unsigned long param)
{
+ SCREEN *sp = (SCREEN *) param;
unsigned short fWait = MOU_WAIT;
/* NOPTRRECT mourt = { 0,0,24,79 }; */
MOUEVENTINFO mouev;
@@ -189,11 +243,10 @@ mouse_server(unsigned long ignored GCC_UNUSED)
/* sit and wait on the event queue */
rc = MouReadEventQue(&mouev, &fWait, hmou);
if (rc) {
- snprintf(err, sizeof(err),
- "Error reading mouse queue, rc=%lu.\r\n", rc);
+ snprintf(err, sizeof(err), "Error reading mouse queue, rc=%lu.\r\n", rc);
break;
}
- if (!mouse_activated)
+ if (!sp->_emxmouse_activated)
goto finish;
/*
@@ -204,22 +257,21 @@ mouse_server(unsigned long ignored GCC_UNUSED)
* 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
- write_event(mouev.fs & MOUSE_BN1_DOWN,
- mouse_buttons[1], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN1_DOWN,
+ sp->_emxmouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
- write_event(mouev.fs & MOUSE_BN2_DOWN,
- mouse_buttons[3], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN2_DOWN,
+ sp->_emxmouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
- write_event(mouev.fs & MOUSE_BN3_DOWN,
- mouse_buttons[2], mouev.col, mouev.row);
+ write_event(sp, mouev.fs & MOUSE_BN3_DOWN,
+ sp->_emxmouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
}
} else
- snprintf(err, sizeof(err),
- "Error setting event mask, buttons=%d, rc=%lu.\r\n",
- nbuttons, rc);
+ snprintf(err, sizeof(err), "Error setting event mask, buttons=%d, rc=%lu.\r\n",
+ nbuttons, rc);
DosWrite(2, err, strlen(err), &rc);
MouClose(hmou);
@@ -227,185 +279,508 @@ mouse_server(unsigned long ignored GCC_UNUSED)
DosExit(EXIT_THREAD, 0L);
}
+#endif /* USE_EMX_MOUSE */
+
+#if USE_SYSMOUSE
static void
-server_state(const int state)
-{ /* It would be nice to implement pointer-off and stop looping... */
- mouse_activated = state;
+sysmouse_server(SCREEN *sp)
+{
+ struct mouse_info the_mouse;
+ MEVENT *work;
+
+ the_mouse.operation = MOUSE_GETINFO;
+ if (sp != 0
+ && sp->_mouse_fd >= 0
+ && sp->_sysmouse_tail < FIFO_SIZE
+ && ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+
+ if (sp->_sysmouse_head > sp->_sysmouse_tail) {
+ sp->_sysmouse_tail = 0;
+ sp->_sysmouse_head = 0;
+ }
+ work = &(sp->_sysmouse_fifo[sp->_sysmouse_tail]);
+ memset(work, 0, sizeof(*work));
+ work->id = NORMAL_EVENT; /* there's only one mouse... */
+
+ sp->_sysmouse_old_buttons = sp->_sysmouse_new_buttons;
+ sp->_sysmouse_new_buttons = the_mouse.u.data.buttons & 0x7;
+
+ if (sp->_sysmouse_new_buttons) {
+ if (sp->_sysmouse_new_buttons & 1)
+ work->bstate |= BUTTON1_PRESSED;
+ if (sp->_sysmouse_new_buttons & 2)
+ work->bstate |= BUTTON2_PRESSED;
+ if (sp->_sysmouse_new_buttons & 4)
+ work->bstate |= BUTTON3_PRESSED;
+ } else {
+ if (sp->_sysmouse_old_buttons & 1)
+ work->bstate |= BUTTON1_RELEASED;
+ if (sp->_sysmouse_old_buttons & 2)
+ work->bstate |= BUTTON2_RELEASED;
+ if (sp->_sysmouse_old_buttons & 4)
+ work->bstate |= BUTTON3_RELEASED;
+ }
+
+ /* for cosmetic bug in syscons.c on FreeBSD 3.[34] */
+ the_mouse.operation = MOUSE_HIDE;
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+ the_mouse.operation = MOUSE_SHOW;
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+
+ /*
+ * We're only interested if the button is pressed or released.
+ * FIXME: implement continuous event-tracking.
+ */
+ if (sp->_sysmouse_new_buttons != sp->_sysmouse_old_buttons) {
+ sp->_sysmouse_tail += 1;
+ }
+ work->x = the_mouse.u.data.x / sp->_sysmouse_char_width;
+ work->y = the_mouse.u.data.y / sp->_sysmouse_char_height;
+ }
}
+static void
+handle_sysmouse(int sig GCC_UNUSED)
+{
+ sysmouse_server(SP);
+}
+#endif /* USE_SYSMOUSE */
+
+static void
+init_xterm_mouse(SCREEN *sp)
+{
+ sp->_mouse_type = M_XTERM;
+ sp->_mouse_xtermcap = tigetstr("XM");
+ if (!VALID_STRING(sp->_mouse_xtermcap))
+ sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
+}
+
+static void
+enable_xterm_mouse(SCREEN *sp, int enable)
+{
+#if USE_EMX_MOUSE
+ sp->_emxmouse_activated = enable;
+#else
+ putp(TPARM_1(sp->_mouse_xtermcap, enable));
#endif
+ sp->_mouse_active = enable;
+}
-static int initialized;
+#if USE_GPM_SUPPORT
+static bool
+allow_gpm_mouse(void)
+{
+ bool result = FALSE;
+ /* GPM does printf's without checking if stdout is a terminal */
+ if (isatty(fileno(stdout))) {
+ char *list = getenv("NCURSES_GPM_TERMS");
+ char *env = getenv("TERM");
+ if (list != 0) {
+ if (env != 0) {
+ result = _nc_name_match(list, env, "|:");
+ }
+ } else {
+ /* GPM checks the beginning of the $TERM variable to decide if it
+ * should pass xterm events through. There is no real advantage in
+ * allowing GPM to do this. Recent versions relax that check, and
+ * pretend that GPM can work with any terminal having the kmous
+ * capability. Perhaps that works for someone. If so, they can
+ * set the environment variable (above).
+ */
+ if (env != 0 && strstr(env, "linux") != 0) {
+ result = TRUE;
+ }
+ }
+ }
+ return result;
+}
+
+#ifdef HAVE_LIBDL
static void
-initialize_mousetype(void)
+unload_gpm_library(SCREEN *sp)
{
- static const char *xterm_kmous = "\033[M";
+ if (SP->_dlopen_gpm != 0) {
+ T(("unload GPM library"));
+ sp->_mouse_gpm_loaded = FALSE;
+ sp->_mouse_fd = -1;
+ dlclose(sp->_dlopen_gpm);
+ sp->_dlopen_gpm = 0;
+ }
+}
+
+static void
+load_gpm_library(SCREEN *sp)
+{
+ sp->_mouse_gpm_found = FALSE;
+ if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+ if (GET_DLSYM(gpm_fd) == 0 ||
+ GET_DLSYM(Gpm_Open) == 0 ||
+ GET_DLSYM(Gpm_Close) == 0 ||
+ GET_DLSYM(Gpm_GetEvent) == 0) {
+ T(("GPM initialization failed: %s", dlerror()));
+ unload_gpm_library(sp);
+ } else {
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
+ }
+ }
+}
+#endif
+
+static bool
+enable_gpm_mouse(SCREEN *sp, bool enable)
+{
+ bool result;
+
+ T((T_CALLED("enable_gpm_mouse(%d)"), enable));
+
+ if (enable && !sp->_mouse_active) {
+#ifdef HAVE_LIBDL
+ if (sp->_mouse_gpm_found && !sp->_mouse_gpm_loaded) {
+ load_gpm_library(sp);
+ }
+#endif
+ if (sp->_mouse_gpm_loaded) {
+ /* GPM: initialize connection to gpm server */
+ sp->_mouse_gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ sp->_mouse_gpm_connect.defaultMask =
+ (unsigned short) (~(sp->_mouse_gpm_connect.eventMask | GPM_HARD));
+ sp->_mouse_gpm_connect.minMod = 0;
+ sp->_mouse_gpm_connect.maxMod =
+ (unsigned short) (~((1 << KG_SHIFT) |
+ (1 << KG_SHIFTL) |
+ (1 << KG_SHIFTR)));
+ /*
+ * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
+ * The former is recognized by wscons (SunOS), and the latter by
+ * xterm. Those will not show up in ncurses' traces.
+ */
+ result = (my_Gpm_Open(&sp->_mouse_gpm_connect, 0) >= 0);
+ } else {
+ result = FALSE;
+ }
+ sp->_mouse_active = result;
+ T(("GPM open %s", result ? "succeeded" : "failed"));
+ } else {
+ if (!enable && sp->_mouse_active) {
+ /* GPM: close connection to gpm server */
+ my_Gpm_Close();
+ sp->_mouse_active = FALSE;
+ T(("GPM closed"));
+ }
+ result = enable;
+ }
+#ifdef HAVE_LIBDL
+ if (!result) {
+ unload_gpm_library(sp);
+ }
+#endif
+ returnBool(result);
+}
+#endif /* USE_GPM_SUPPORT */
+
+#define xterm_kmous "\033[M"
+
+static void
+initialize_mousetype(SCREEN *sp)
+{
+ T((T_CALLED("initialize_mousetype()")));
/* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
- /* GPM: initialize connection to gpm server */
- gpm_connect.eventMask = GPM_DOWN | GPM_UP;
- gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
- gpm_connect.minMod = 0;
- gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
- if (Gpm_Open(&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
- mousetype = M_GPM;
- SP->_mouse_fd = gpm_fd;
- return;
- }
+ if (allow_gpm_mouse()) {
+ if (!sp->_mouse_gpm_loaded) {
+#ifdef HAVE_LIBDL
+ load_gpm_library(sp);
+#else /* !HAVE_LIBDL */
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
#endif
+ }
+
+ /*
+ * The gpm_fd file-descriptor may be negative (xterm). So we have to
+ * maintain our notion of whether the mouse connection is active
+ * without testing the file-descriptor.
+ */
+ if (sp->_mouse_gpm_found && enable_gpm_mouse(sp, TRUE)) {
+ sp->_mouse_type = M_GPM;
+ sp->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", sp->_mouse_fd));
+ returnVoid;
+ }
+ }
+#endif /* USE_GPM_SUPPORT */
/* OS/2 VIO */
-#ifdef USE_EMX_MOUSE
- if (!mouse_thread
+#if USE_EMX_MOUSE
+ if (!sp->_emxmouse_thread
&& strstr(cur_term->type.term_names, "xterm") == 0
&& key_mouse) {
int handles[2];
if (pipe(handles) < 0) {
perror("mouse pipe error");
- return;
+ returnVoid;
} else {
int rc;
- if (!mouse_buttons[0]) {
+ if (!sp->_emxmouse_buttons[0]) {
char *s = getenv("MOUSE_BUTTONS_123");
- mouse_buttons[0] = 1;
+ sp->_emxmouse_buttons[0] = 1;
if (s && strlen(s) >= 3) {
- mouse_buttons[1] = s[0] - '0';
- mouse_buttons[2] = s[1] - '0';
- mouse_buttons[3] = s[2] - '0';
+ sp->_emxmouse_buttons[1] = s[0] - '0';
+ sp->_emxmouse_buttons[2] = s[1] - '0';
+ sp->_emxmouse_buttons[3] = s[2] - '0';
+ } else {
+ sp->_emxmouse_buttons[1] = 1;
+ sp->_emxmouse_buttons[2] = 3;
+ sp->_emxmouse_buttons[3] = 2;
}
}
- mouse_wfd = handles[1];
- M_FD(SP) = handles[0];
+ sp->_emxmouse_wfd = handles[1];
+ M_FD(sp) = handles[0];
/* Needed? */
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
- rc = DosCreateThread((unsigned long *) &mouse_thread,
- mouse_server, 0, 0, 8192);
+ rc = DosCreateThread((unsigned long *) &sp->_emxmouse_thread,
+ mouse_server, (long) sp, 0, 8192);
if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
- return;
} else {
- mousetype = M_XTERM;
- return;
+ sp->_mouse_type = M_XTERM;
}
+ returnVoid;
}
}
-#endif
+#endif /* USE_EMX_MOUSE */
+
+#if USE_SYSMOUSE
+ {
+ struct mouse_info the_mouse;
+ char *the_device = 0;
+
+ if (isatty(sp->_ifd))
+ the_device = ttyname(sp->_ifd);
+ if (the_device == 0)
+ the_device = "/dev/tty";
+
+ sp->_mouse_fd = open(the_device, O_RDWR);
+
+ if (sp->_mouse_fd >= 0) {
+ /*
+ * sysmouse does not have a usable user interface for obtaining
+ * mouse events. The logical way to proceed (reading data on a
+ * stream) only works if one opens the device as root. Even in
+ * that mode, careful examination shows we lose events
+ * occasionally. The interface provided for user programs is to
+ * establish a signal handler. really.
+ *
+ * Take over SIGUSR2 for this purpose since SIGUSR1 is more
+ * likely to be used by an application. getch() will have to
+ * handle the misleading EINTR's.
+ */
+ signal(SIGUSR2, SIG_IGN);
+ the_mouse.operation = MOUSE_MODE;
+ the_mouse.u.mode.mode = 0;
+ the_mouse.u.mode.signal = SIGUSR2;
+ if (ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
+ signal(SIGUSR2, handle_sysmouse);
+ the_mouse.operation = MOUSE_SHOW;
+ ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
+
+#if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) /* FreeBSD > 2.x */
+ {
+#ifndef FBIO_GETMODE /* FreeBSD 3.x */
+#define FBIO_GETMODE CONS_GET
+#define FBIO_MODEINFO CONS_MODEINFO
+#endif /* FBIO_GETMODE */
+ video_info_t the_video;
+
+ if (ioctl(sp->_mouse_fd,
+ FBIO_GETMODE,
+ &the_video.vi_mode) != -1
+ && ioctl(sp->_mouse_fd,
+ FBIO_MODEINFO,
+ &the_video) != -1) {
+ sp->_sysmouse_char_width = the_video.vi_cwidth;
+ sp->_sysmouse_char_height = the_video.vi_cheight;
+ }
+ }
+#endif /* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) */
+
+ if (sp->_sysmouse_char_width <= 0)
+ sp->_sysmouse_char_width = 8;
+ if (sp->_sysmouse_char_height <= 0)
+ sp->_sysmouse_char_height = 16;
+ sp->_mouse_type = M_SYSMOUSE;
+ returnVoid;
+ }
+ }
+ }
+#endif /* USE_SYSMOUSE */
/* we know how to recognize mouse events under "xterm" */
if (key_mouse != 0) {
- if (!strcmp(key_mouse, xterm_kmous)) {
- mousetype = M_XTERM;
- return;
+ if (!strcmp(key_mouse, xterm_kmous)
+ || strstr(cur_term->type.term_names, "xterm") != 0) {
+ init_xterm_mouse(sp);
}
} else if (strstr(cur_term->type.term_names, "xterm") != 0) {
- (void) _nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE);
- mousetype = M_XTERM;
- return;
+ if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
+ init_xterm_mouse(sp);
}
+ returnVoid;
}
-static void
-_nc_mouse_init(void)
+static bool
+_nc_mouse_init(SCREEN *sp)
/* initialize the mouse */
{
+ bool result = FALSE;
int i;
- if (!initialized) {
- initialized = TRUE;
+ if (sp != 0) {
+ if (!sp->_mouse_initialized) {
+ sp->_mouse_initialized = TRUE;
- TR(MY_TRACE, ("_nc_mouse_init() called"));
+ TR(MY_TRACE, ("_nc_mouse_init() called"));
- for (i = 0; i < EV_MAX; i++)
- events[i].id = INVALID_EVENT;
+ sp->_mouse_eventp = FirstEV(sp);
+ for (i = 0; i < EV_MAX; i++)
+ sp->_mouse_events[i].id = INVALID_EVENT;
- initialize_mousetype();
+ initialize_mousetype(sp);
- T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type));
+ }
+ result = sp->_mouse_initialized;
}
+ return result;
}
+/*
+ * Query to see if there is a pending mouse event. This is called from
+ * fifo_push() in lib_getch.c
+ */
static bool
-_nc_mouse_event(SCREEN * sp GCC_UNUSED)
-/* query to see if there is a pending mouse event */
+_nc_mouse_event(SCREEN *sp GCC_UNUSED)
{
-#if USE_GPM_SUPPORT
- /* GPM: query server for event, return TRUE if we find one */
- Gpm_Event ev;
+ MEVENT *eventp = sp->_mouse_eventp;
+ bool result = FALSE;
- if (gpm_fd >= 0
- && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0
- && Gpm_GetEvent(&ev) == 1) {
- eventp->id = 0; /* there's only one mouse... */
+ (void) eventp;
- eventp->bstate = 0;
- switch (ev.type & 0x0f) {
- case (GPM_DOWN):
- if (ev.buttons & GPM_B_LEFT)
- eventp->bstate |= BUTTON1_PRESSED;
- if (ev.buttons & GPM_B_MIDDLE)
- eventp->bstate |= BUTTON2_PRESSED;
- if (ev.buttons & GPM_B_RIGHT)
- eventp->bstate |= BUTTON3_PRESSED;
- break;
- case (GPM_UP):
- if (ev.buttons & GPM_B_LEFT)
- eventp->bstate |= BUTTON1_RELEASED;
- if (ev.buttons & GPM_B_MIDDLE)
- eventp->bstate |= BUTTON2_RELEASED;
- if (ev.buttons & GPM_B_RIGHT)
- eventp->bstate |= BUTTON3_RELEASED;
- break;
- default:
- break;
+ switch (sp->_mouse_type) {
+ case M_XTERM:
+ /* xterm: never have to query, mouse events are in the keyboard stream */
+#if USE_EMX_MOUSE
+ {
+ char kbuf[3];
+
+ int i, res = read(M_FD(sp), &kbuf, 3); /* Eat the prefix */
+ if (res != 3)
+ printf("Got %d chars instead of 3 for prefix.\n", res);
+ for (i = 0; i < res; i++) {
+ if (kbuf[i] != key_mouse[i])
+ printf("Got char %d instead of %d for prefix.\n",
+ (int) kbuf[i], (int) key_mouse[i]);
+ }
+ result = TRUE;
}
+#endif /* USE_EMX_MOUSE */
+ break;
+
+#if USE_GPM_SUPPORT
+ case M_GPM:
+ {
+ /* query server for event, return TRUE if we find one */
+ Gpm_Event ev;
+
+ if (my_Gpm_GetEvent(&ev) == 1) {
+ /* there's only one mouse... */
+ eventp->id = NORMAL_EVENT;
+
+ eventp->bstate = 0;
+ switch (ev.type & 0x0f) {
+ case (GPM_DOWN):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_PRESSED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_PRESSED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_PRESSED;
+ break;
+ case (GPM_UP):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_RELEASED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_RELEASED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_RELEASED;
+ break;
+ default:
+ break;
+ }
- eventp->x = ev.x - 1;
- eventp->y = ev.y - 1;
- eventp->z = 0;
+ eventp->x = ev.x - 1;
+ eventp->y = ev.y - 1;
+ eventp->z = 0;
- /* bump the next-free pointer into the circular list */
- eventp = NEXT(eventp);
- return (TRUE);
- }
+ /* bump the next-free pointer into the circular list */
+ sp->_mouse_eventp = eventp = NEXT(eventp);
+ result = TRUE;
+ }
+ }
+ break;
#endif
-#ifdef USE_EMX_MOUSE
- if (SP->_mouse_fd >= 0
- && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0) {
- char kbuf[3];
-
- int i, res = read(M_FD(sp), &kbuf, 3); /* Eat the prefix */
- if (res != 3)
- printf("Got %d chars instead of 3 for prefix.\n", res);
- for (i = 0; i < res; i++) {
- if (kbuf[i] != key_mouse[i])
- printf("Got char %d instead of %d for prefix.\n",
- (int) kbuf[i], (int) key_mouse[i]);
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ if (sp->_sysmouse_head < sp->_sysmouse_tail) {
+ *eventp = sp->_sysmouse_fifo[sp->_sysmouse_head];
+
+ /*
+ * Point the fifo-head to the next possible location. If there
+ * are none, reset the indices. This may be interrupted by the
+ * signal handler, doing essentially the same reset.
+ */
+ sp->_sysmouse_head += 1;
+ if (sp->_sysmouse_head == sp->_sysmouse_tail) {
+ sp->_sysmouse_tail = 0;
+ sp->_sysmouse_head = 0;
+ }
+
+ /* bump the next-free pointer into the circular list */
+ sp->_mouse_eventp = eventp = NEXT(eventp);
+ result = TRUE;
}
- return TRUE;
+ break;
+#endif /* USE_SYSMOUSE */
+
+ case M_NONE:
+ break;
}
-#endif /* USE_EMX_MOUSE */
- /* xterm: never have to query, mouse events are in the keyboard stream */
- return (FALSE); /* no event waiting */
+ return result; /* true if we found an event */
}
static bool
-_nc_mouse_inline(SCREEN * sp)
+_nc_mouse_inline(SCREEN *sp)
/* mouse report received in the keyboard stream -- parse its info */
{
+ int b;
+ bool result = FALSE;
+ MEVENT *eventp = sp->_mouse_eventp;
+
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (mousetype == M_XTERM) {
+ if (sp->_mouse_type == M_XTERM) {
unsigned char kbuf[4];
- MEVENT *prev;
+ mmask_t prev;
size_t grabbed;
int res;
@@ -436,13 +811,15 @@ _nc_mouse_inline(SCREEN * sp)
* (End quote) By the time we get here, we've eaten the
* key prefix. FYI, the loop below is necessary because
* mouse click info isn't guaranteed to present as a
- * single clist item. It always does under Linux but often
- * fails to under Solaris.
+ * single clist item.
+ *
+ * Wheel mice may return buttons 4 and 5 when the wheel is turned.
+ * We encode those as button presses.
*/
- for (grabbed = 0; grabbed < 3; grabbed += res) {
+ for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) {
/* For VIO mouse we add extra bit 64 to disambiguate button-up. */
-#ifdef USE_EMX_MOUSE
+#if USE_EMX_MOUSE
res = read(M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
#else
res = read(sp->_ifd, kbuf + grabbed, 3 - grabbed);
@@ -455,59 +832,71 @@ _nc_mouse_inline(SCREEN * sp)
TR(TRACE_IEVENT,
("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
- eventp->id = 0; /* there's only one mouse... */
+ /* there's only one mouse... */
+ eventp->id = NORMAL_EVENT;
/* processing code goes here */
eventp->bstate = 0;
+ prev = PREV(eventp)->bstate;
+
+#if USE_EMX_MOUSE
+#define PRESS_POSITION(n) \
+ eventp->bstate = MASK_PRESS(n); \
+ if (kbuf[0] & 0x40) \
+ eventp->bstate = MASK_RELEASE(n)
+#else
+#define PRESS_POSITION(n) \
+ eventp->bstate = (mmask_t) (prev & MASK_PRESS(n) \
+ ? REPORT_MOUSE_POSITION \
+ : MASK_PRESS(n))
+#endif
+
switch (kbuf[0] & 0x3) {
case 0x0:
- eventp->bstate = BUTTON1_PRESSED;
-#ifdef USE_EMX_MOUSE
- if (kbuf[0] & 0x40)
- eventp->bstate = BUTTON1_RELEASED;
-#endif
+ if (kbuf[0] & 64)
+ eventp->bstate = MASK_PRESS(4);
+ else
+ PRESS_POSITION(1);
break;
case 0x1:
- eventp->bstate = BUTTON2_PRESSED;
-#ifdef USE_EMX_MOUSE
- if (kbuf[0] & 0x40)
- eventp->bstate = BUTTON2_RELEASED;
+#if NCURSES_MOUSE_VERSION == 2
+ if (kbuf[0] & 64)
+ eventp->bstate = MASK_PRESS(5);
+ else
#endif
+ PRESS_POSITION(2);
break;
case 0x2:
- eventp->bstate = BUTTON3_PRESSED;
-#ifdef USE_EMX_MOUSE
- if (kbuf[0] & 0x40)
- eventp->bstate = BUTTON3_RELEASED;
-#endif
+ PRESS_POSITION(3);
break;
case 0x3:
/*
- * Release events aren't reported for individual buttons,
- * just for the button set as a whole...
- */
- eventp->bstate =
- (BUTTON1_RELEASED |
- BUTTON2_RELEASED |
- BUTTON3_RELEASED);
- /*
- * ...however, because there are no kinds of mouse events under
- * xterm that can intervene between press and release, we can
- * deduce which buttons were actually released by looking at the
- * previous event.
+ * Release events aren't reported for individual buttons, just for
+ * the button set as a whole. However, because there are normally
+ * no mouse events under xterm that intervene between press and
+ * release, we can infer the button actually released by looking at
+ * the previous event.
*/
- prev = PREV(eventp);
- if (!(prev->bstate & BUTTON1_PRESSED))
- eventp->bstate &= ~BUTTON1_RELEASED;
- if (!(prev->bstate & BUTTON2_PRESSED))
- eventp->bstate &= ~BUTTON2_RELEASED;
- if (!(prev->bstate & BUTTON3_PRESSED))
- eventp->bstate &= ~BUTTON3_RELEASED;
+ if (prev & (BUTTON_PRESSED | BUTTON_RELEASED)) {
+ eventp->bstate = BUTTON_RELEASED;
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if (!(prev & MASK_PRESS(b)))
+ eventp->bstate &= ~MASK_RELEASE(b);
+ }
+ } else {
+ /*
+ * XFree86 xterm will return a stream of release-events to
+ * let the application know where the mouse is going, if the
+ * private mode 1002 or 1003 is enabled.
+ */
+ eventp->bstate = REPORT_MOUSE_POSITION;
+ }
break;
}
+ result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;
if (kbuf[0] & 4) {
eventp->bstate |= BUTTON_SHIFT;
@@ -523,71 +912,83 @@ _nc_mouse_inline(SCREEN * sp)
eventp->y = (kbuf[2] - ' ') - 1;
TR(MY_TRACE,
("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
- _tracemouse(eventp),
- (long) (eventp - events)));
+ _nc_tracemouse(sp, eventp),
+ (long) IndexEV(sp, eventp)));
/* bump the next-free pointer into the circular list */
- eventp = NEXT(eventp);
+ sp->_mouse_eventp = NEXT(eventp);
#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
return (TRUE);
#endif
}
- return (FALSE);
+ return (result);
}
static void
-mouse_activate(bool on)
+mouse_activate(SCREEN *sp, bool on)
{
- if (!on && !initialized)
+ if (!on && !sp->_mouse_initialized)
return;
- _nc_mouse_init();
+ if (!_nc_mouse_init(sp))
+ return;
if (on) {
- switch (mousetype) {
+ switch (sp->_mouse_type) {
case M_XTERM:
#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
-#ifdef USE_EMX_MOUSE
- server_state(1);
-#else
- putp("\033[?1000h");
-#endif
+ enable_xterm_mouse(sp, 1);
break;
#if USE_GPM_SUPPORT
case M_GPM:
- SP->_mouse_fd = gpm_fd;
+ if (enable_gpm_mouse(sp, TRUE)) {
+ sp->_mouse_fd = *(my_gpm_fd);
+ T(("GPM mouse_fd %d", sp->_mouse_fd));
+ }
break;
#endif
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ signal(SIGUSR2, handle_sysmouse);
+ sp->_mouse_active = TRUE;
+ break;
+#endif
+ case M_NONE:
+ return;
}
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
*/
- SP->_mouse_event = _nc_mouse_event;
- SP->_mouse_inline = _nc_mouse_inline;
- SP->_mouse_parse = _nc_mouse_parse;
- SP->_mouse_resume = _nc_mouse_resume;
- SP->_mouse_wrap = _nc_mouse_wrap;
-
+ sp->_mouse_event = _nc_mouse_event;
+ sp->_mouse_inline = _nc_mouse_inline;
+ sp->_mouse_parse = _nc_mouse_parse;
+ sp->_mouse_resume = _nc_mouse_resume;
+ sp->_mouse_wrap = _nc_mouse_wrap;
} else {
- switch (mousetype) {
+ switch (sp->_mouse_type) {
case M_XTERM:
TPUTS_TRACE("xterm mouse deinitialization");
-#ifdef USE_EMX_MOUSE
- server_state(0);
-#else
- putp("\033[?1000l");
-#endif
+ enable_xterm_mouse(sp, 0);
break;
#if USE_GPM_SUPPORT
case M_GPM:
+ enable_gpm_mouse(sp, FALSE);
+ break;
+#endif
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ signal(SIGUSR2, SIG_IGN);
+ sp->_mouse_active = FALSE;
break;
#endif
+ case M_NONE:
+ return;
}
}
_nc_flush();
@@ -600,11 +1001,13 @@ mouse_activate(bool on)
**************************************************************************/
static bool
-_nc_mouse_parse(int runcount)
+_nc_mouse_parse(SCREEN *sp, int runcount)
/* parse a run of atomic mouse events into a gesture */
{
+ MEVENT *eventp = sp->_mouse_eventp;
MEVENT *ep, *runp, *next, *prev = PREV(eventp);
int n;
+ int b;
bool merge;
TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
@@ -613,7 +1016,7 @@ _nc_mouse_parse(int runcount)
* When we enter this routine, the event list next-free pointer
* points just past a run of mouse events that we know were separated
* in time by less than the critical click interval. The job of this
- * routine is to collaps this run into a single higher-level event
+ * routine is to collapse this run into a single higher-level event
* or gesture.
*
* We accomplish this in two passes. The first pass merges press/release
@@ -633,10 +1036,10 @@ _nc_mouse_parse(int runcount)
if (runcount == 1) {
TR(MY_TRACE,
("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
- return (prev->id >= 0)
- ? ((prev->bstate & eventmask) ? TRUE : FALSE)
+ _nc_tracemouse(sp, prev),
+ (long) IndexEV(sp, prev)));
+ return (prev->id >= NORMAL_EVENT)
+ ? ((prev->bstate & sp->_mouse_mask) ? TRUE : FALSE)
: FALSE;
}
@@ -647,45 +1050,40 @@ _nc_mouse_parse(int runcount)
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
- _trace_slot("before mouse press/release merge:");
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _trace_slot(sp, "before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
/* first pass; merge press/release pairs */
do {
merge = FALSE;
- for (ep = runp; next = NEXT(ep), next != eventp; ep = next) {
+ for (ep = runp; (next = NEXT(ep)) != eventp; ep = next) {
+
+#define MASK_CHANGED(x) (!(ep->bstate & MASK_PRESS(x)) \
+ == !(next->bstate & MASK_RELEASE(x)))
+
if (ep->x == next->x && ep->y == next->y
- && (ep->bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED))
- && (!(ep->bstate & BUTTON1_PRESSED)
- == !(next->bstate & BUTTON1_RELEASED))
- && (!(ep->bstate & BUTTON2_PRESSED)
- == !(next->bstate & BUTTON2_RELEASED))
- && (!(ep->bstate & BUTTON3_PRESSED)
- == !(next->bstate & BUTTON3_RELEASED))
+ && (ep->bstate & BUTTON_PRESSED)
+ && MASK_CHANGED(1)
+ && MASK_CHANGED(2)
+ && MASK_CHANGED(3)
+ && MASK_CHANGED(4)
+#if NCURSES_MOUSE_VERSION == 2
+ && MASK_CHANGED(5)
+#endif
) {
- if ((eventmask & BUTTON1_CLICKED)
- && (ep->bstate & BUTTON1_PRESSED)) {
- ep->bstate &= ~BUTTON1_PRESSED;
- ep->bstate |= BUTTON1_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON2_CLICKED)
- && (ep->bstate & BUTTON2_PRESSED)) {
- ep->bstate &= ~BUTTON2_PRESSED;
- ep->bstate |= BUTTON2_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON3_CLICKED)
- && (ep->bstate & BUTTON3_PRESSED)) {
- ep->bstate &= ~BUTTON3_PRESSED;
- ep->bstate |= BUTTON3_CLICKED;
- merge = TRUE;
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if ((sp->_mouse_mask & MASK_CLICK(b))
+ && (ep->bstate & MASK_PRESS(b))) {
+ ep->bstate &= ~MASK_PRESS(b);
+ ep->bstate |= MASK_CLICK(b);
+ merge = TRUE;
+ }
}
if (merge)
next->id = INVALID_EVENT;
@@ -695,12 +1093,12 @@ _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
- _trace_slot("before mouse click merge:");
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _trace_slot(sp, "before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -724,7 +1122,7 @@ _nc_mouse_parse(int runcount)
MEVENT *follower;
merge = FALSE;
- for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
+ for (ep = runp; (next = NEXT(ep)) != eventp; ep = next)
if (ep->id != INVALID_EVENT) {
if (next->id != INVALID_EVENT)
continue;
@@ -733,56 +1131,30 @@ _nc_mouse_parse(int runcount)
continue;
/* merge click events forward */
- if ((ep->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
- && (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
- if ((eventmask & BUTTON1_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED)) {
- follower->bstate &= ~BUTTON1_CLICKED;
- follower->bstate |= BUTTON1_DOUBLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON2_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED)) {
- follower->bstate &= ~BUTTON2_CLICKED;
- follower->bstate |= BUTTON2_DOUBLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON3_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED)) {
- follower->bstate &= ~BUTTON3_CLICKED;
- follower->bstate |= BUTTON3_DOUBLE_CLICKED;
- merge = TRUE;
+ if ((ep->bstate & BUTTON_CLICKED)
+ && (follower->bstate & BUTTON_CLICKED)) {
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if ((sp->_mouse_mask & MASK_DOUBLE_CLICK(b))
+ && (follower->bstate & MASK_CLICK(b))) {
+ follower->bstate &= ~MASK_CLICK(b);
+ follower->bstate |= MASK_DOUBLE_CLICK(b);
+ merge = TRUE;
+ }
}
if (merge)
ep->id = INVALID_EVENT;
}
/* merge double-click events forward */
- if ((ep->bstate &
- (BUTTON1_DOUBLE_CLICKED
- | BUTTON2_DOUBLE_CLICKED
- | BUTTON3_DOUBLE_CLICKED))
- && (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
- if ((eventmask & BUTTON1_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED)) {
- follower->bstate &= ~BUTTON1_CLICKED;
- follower->bstate |= BUTTON1_TRIPLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON2_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED)) {
- follower->bstate &= ~BUTTON2_CLICKED;
- follower->bstate |= BUTTON2_TRIPLE_CLICKED;
- merge = TRUE;
- }
- if ((eventmask & BUTTON3_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED)) {
- follower->bstate &= ~BUTTON3_CLICKED;
- follower->bstate |= BUTTON3_TRIPLE_CLICKED;
- merge = TRUE;
+ if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON_CLICKED)) {
+ for (b = 1; b <= MAX_BUTTONS; ++b) {
+ if ((sp->_mouse_mask & MASK_TRIPLE_CLICK(b))
+ && (follower->bstate & MASK_CLICK(b))) {
+ follower->bstate &= ~MASK_CLICK(b);
+ follower->bstate |= MASK_TRIPLE_CLICK(b);
+ merge = TRUE;
+ }
}
if (merge)
ep->id = INVALID_EVENT;
@@ -792,12 +1164,12 @@ _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
- _trace_slot("before mouse event queue compaction:");
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _trace_slot(sp, "before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -806,23 +1178,23 @@ _nc_mouse_parse(int runcount)
* don't match the current event mask.
*/
for (; runcount; prev = PREV(eventp), runcount--)
- if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask)) {
- eventp = prev;
+ if (prev->id == INVALID_EVENT || !(prev->bstate & sp->_mouse_mask)) {
+ sp->_mouse_eventp = eventp = prev;
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) {
- _trace_slot("after mouse event queue compaction:");
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _trace_slot(sp, "after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
- (long) (runp - events),
- (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
+ RunParams(sp, eventp, runp),
runcount);
+ _nc_unlock_global(tracef);
}
for (ep = runp; ep != eventp; ep = NEXT(ep))
if (ep->id != INVALID_EVENT)
TR(MY_TRACE,
("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
- _tracemouse(ep),
- (long) (ep - events)));
+ _nc_tracemouse(sp, ep),
+ (long) IndexEV(sp, ep)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
@@ -830,35 +1202,62 @@ _nc_mouse_parse(int runcount)
}
static void
-_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
+_nc_mouse_wrap(SCREEN *sp)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
- switch (mousetype) {
+ switch (sp->_mouse_type) {
case M_XTERM:
- if (eventmask)
- mouse_activate(FALSE);
+ if (sp->_mouse_mask)
+ mouse_activate(sp, FALSE);
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
case M_GPM:
+ if (sp->_mouse_mask)
+ mouse_activate(sp, FALSE);
+ break;
+#endif
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ mouse_activate(sp, FALSE);
break;
#endif
+ case M_NONE:
+ break;
}
}
static void
-_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
+_nc_mouse_resume(SCREEN *sp)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
- /* xterm: re-enable reporting */
- if (mousetype == M_XTERM && eventmask)
- mouse_activate(TRUE);
+ switch (sp->_mouse_type) {
+ case M_XTERM:
+ /* xterm: re-enable reporting */
+ if (sp->_mouse_mask)
+ mouse_activate(sp, TRUE);
+ break;
- /* GPM: reclaim our event set */
+#if USE_GPM_SUPPORT
+ case M_GPM:
+ /* GPM: reclaim our event set */
+ if (sp->_mouse_mask)
+ mouse_activate(sp, TRUE);
+ break;
+#endif
+
+#if USE_SYSMOUSE
+ case M_SYSMOUSE:
+ mouse_activate(sp, TRUE);
+ break;
+#endif
+ case M_NONE:
+ break;
+ }
}
/**************************************************************************
@@ -867,13 +1266,13 @@ _nc_mouse_resume(SCREEN * sp GCC_UNUSED)
*
**************************************************************************/
-NCURSES_EXPORT(int)
-getmouse(MEVENT * aevent)
-/* grab a copy of the current mouse event */
+static int
+_nc_getmouse(SCREEN *sp, MEVENT * aevent)
{
T((T_CALLED("getmouse(%p)"), aevent));
- if (aevent && (mousetype != M_NONE)) {
+ if ((aevent != 0) && (sp != 0) && (sp->_mouse_type != M_NONE)) {
+ MEVENT *eventp = sp->_mouse_eventp;
/* compute the current-event pointer */
MEVENT *prev = PREV(eventp);
@@ -881,8 +1280,8 @@ getmouse(MEVENT * aevent)
*aevent = *prev;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ _nc_tracemouse(sp, prev),
+ (long) IndexEV(sp, prev)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -890,18 +1289,40 @@ getmouse(MEVENT * aevent)
returnCode(ERR);
}
+/* grab a copy of the current mouse event */
NCURSES_EXPORT(int)
-ungetmouse(MEVENT * aevent)
-/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+getmouse(MEVENT * aevent)
{
- /* stick the given event in the next-free slot */
- *eventp = *aevent;
+ return _nc_getmouse(SP, aevent);
+}
+
+static int
+_nc_ungetmouse(SCREEN *sp, MEVENT * aevent)
+{
+ int result = ERR;
+
+ T((T_CALLED("ungetmouse(%p)"), aevent));
+
+ if (aevent != 0 && sp != 0) {
+ MEVENT *eventp = sp->_mouse_eventp;
+
+ /* stick the given event in the next-free slot */
+ *eventp = *aevent;
+
+ /* bump the next-free pointer into the circular list */
+ sp->_mouse_eventp = NEXT(eventp);
- /* bump the next-free pointer into the circular list */
- eventp = NEXT(eventp);
+ /* push back the notification event on the keyboard queue */
+ result = _nc_ungetch(sp, KEY_MOUSE);
+ }
+ returnCode(result);
+}
- /* push back the notification event on the keyboard queue */
- return ungetch(KEY_MOUSE);
+/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+NCURSES_EXPORT(int)
+ungetmouse(MEVENT * aevent)
+{
+ return _nc_ungetmouse(SP, aevent);
}
NCURSES_EXPORT(mmask_t)
@@ -910,45 +1331,51 @@ mousemask(mmask_t newmask, mmask_t * oldmask)
{
mmask_t result = 0;
- T((T_CALLED("mousemask(%#lx,%p)"), newmask, oldmask));
-
- if (oldmask)
- *oldmask = eventmask;
+ T((T_CALLED("mousemask(%#lx,%p)"), (unsigned long) newmask, oldmask));
- if (!newmask && !initialized)
- returnCode(0);
-
- _nc_mouse_init();
- if (mousetype != M_NONE) {
- eventmask = newmask &
- (BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
- | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
- | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
- | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
- | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
- | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
- | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
-
- mouse_activate(eventmask != 0);
-
- result = eventmask;
+ if (SP != 0) {
+ if (oldmask)
+ *oldmask = SP->_mouse_mask;
+
+ if (newmask || SP->_mouse_initialized) {
+ _nc_mouse_init(SP);
+ if (SP->_mouse_type != M_NONE) {
+ result = newmask &
+ (REPORT_MOUSE_POSITION
+ | BUTTON_ALT
+ | BUTTON_CTRL
+ | BUTTON_SHIFT
+ | BUTTON_PRESSED
+ | BUTTON_RELEASED
+ | BUTTON_CLICKED
+ | BUTTON_DOUBLE_CLICKED
+ | BUTTON_TRIPLE_CLICKED);
+
+ mouse_activate(SP, (bool) (result != 0));
+
+ SP->_mouse_mask = result;
+ }
+ }
}
-
- returnCode(result);
+ returnBits(result);
}
NCURSES_EXPORT(bool)
wenclose(const WINDOW *win, int y, int x)
/* check to see if given window encloses given screen location */
{
- if (win) {
+ bool result = FALSE;
+
+ T((T_CALLED("wenclose(%p,%d,%d)"), win, y, x));
+
+ if (win != 0) {
y -= win->_yoffset;
- return ((win->_begy <= y &&
- win->_begx <= x &&
- (win->_begx + win->_maxx) >= x &&
- (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+ result = ((win->_begy <= y &&
+ win->_begx <= x &&
+ (win->_begx + win->_maxx) >= x &&
+ (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
}
- return FALSE;
+ returnBool(result);
}
NCURSES_EXPORT(int)
@@ -957,6 +1384,8 @@ mouseinterval(int maxclick)
{
int oldval;
+ T((T_CALLED("mouseinterval(%d)"), maxclick));
+
if (SP != 0) {
oldval = SP->_maxclick;
if (maxclick >= 0)
@@ -965,7 +1394,7 @@ mouseinterval(int maxclick)
oldval = DEFAULT_MAXCLICK;
}
- return (oldval);
+ returnCode(oldval);
}
/* This may be used by other routines to ask for the existence of mouse
@@ -973,15 +1402,16 @@ mouseinterval(int maxclick)
NCURSES_EXPORT(int)
_nc_has_mouse(void)
{
- return (mousetype == M_NONE ? 0 : 1);
+ return (SP->_mouse_type == M_NONE ? 0 : 1);
}
NCURSES_EXPORT(bool)
-wmouse_trafo
-(const WINDOW *win, int *pY, int *pX, bool to_screen)
+wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
{
bool result = FALSE;
+ T((T_CALLED("wmouse_trafo(%p,%p,%p,%d)"), win, pY, pX, to_screen));
+
if (win && pY && pX) {
int y = *pY;
int x = *pX;
@@ -1003,7 +1433,5 @@ wmouse_trafo
*pY = y;
}
}
- return (result);
+ returnBool(result);
}
-
-/* lib_mouse.c ends here */
diff --git a/lib/libcurses/base/lib_move.c b/lib/libcurses/base/lib_move.c
index 629dacbd719..a2f2f793b72 100644
--- a/lib/libcurses/base/lib_move.c
+++ b/lib/libcurses/base/lib_move.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_move.c,v 1.3 2001/01/22 18:01:41 millert Exp $ */
+/* $OpenBSD: lib_move.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,16 +43,14 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_move.c,v 1.11 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_move.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
wmove(WINDOW *win, int y, int x)
{
T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
- if (win &&
- x >= 0 && x <= win->_maxx &&
- y >= 0 && y <= win->_maxy) {
+ if (LEGALYX(win, y, x)) {
win->_curx = (NCURSES_SIZE_T) x;
win->_cury = (NCURSES_SIZE_T) y;
diff --git a/lib/libcurses/base/lib_mvwin.c b/lib/libcurses/base/lib_mvwin.c
index dbd28576f1b..3a6e9d54fb3 100644
--- a/lib/libcurses/base/lib_mvwin.c
+++ b/lib/libcurses/base/lib_mvwin.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_mvwin.c,v 1.2 2001/01/22 18:01:41 millert Exp $ */
+/* $OpenBSD: lib_mvwin.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_mvwin.c,v 1.9 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_mvwin.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
mvwin(WINDOW *win, int by, int bx)
@@ -52,6 +52,11 @@ mvwin(WINDOW *win, int by, int bx)
if (!win || (win->_flags & _ISPAD))
returnCode(ERR);
+ /*
+ * mvwin() should only modify the indices. See test/demo_menus.c and
+ * test/movewindow.c for examples.
+ */
+#if 0
/* Copying subwindows is allowed, but it is expensive... */
if (win->_flags & _SUBWIN) {
int err = ERR;
@@ -71,7 +76,8 @@ mvwin(WINDOW *win, int by, int bx)
/* now we have the clone, so relocate win */
werase(win); /* Erase the original place */
- wbkgd(win, parent->_bkgd); /* fill with parents background */
+ /* fill with parents background */
+ wbkgrnd(win, CHREF(parent->_nc_bkgd));
wsyncup(win); /* Tell the parent(s) */
err = mvderwin(win,
@@ -90,6 +96,7 @@ mvwin(WINDOW *win, int by, int bx)
}
returnCode(err);
}
+#endif
if (by + win->_maxy > screen_lines - 1
|| bx + win->_maxx > screen_columns - 1
diff --git a/lib/libcurses/base/lib_newterm.c b/lib/libcurses/base/lib_newterm.c
index 0dc1f85592d..18e26bfeea4 100644
--- a/lib/libcurses/base/lib_newterm.c
+++ b/lib/libcurses/base/lib_newterm.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_newterm.c,v 1.12 2001/01/22 18:01:42 millert Exp $ */
+/* $OpenBSD: lib_newterm.c,v 1.13 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -49,7 +50,7 @@
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_newterm.c,v 1.50 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.13 2010/01/12 23:22:06 nicm Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -63,21 +64,30 @@ MODULE_ID("$From: lib_newterm.c,v 1.50 2000/12/10 02:43:27 tom Exp $")
* The newterm function also initializes terminal settings, and since initscr
* is supposed to behave as if it calls newterm, we do it here.
*/
-static inline int
+static NCURSES_INLINE int
_nc_initscr(void)
{
+ int result = ERR;
+
/* for extended XPG4 conformance requires cbreak() at this point */
/* (SVr4 curses does this anyway) */
- cbreak();
+ if (cbreak() == OK) {
+ TTY buf;
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- cur_term->Nttyb.c_lflag &= ~(ECHO | ECHONL);
- cur_term->Nttyb.c_iflag &= ~(ICRNL | INLCR | IGNCR);
- cur_term->Nttyb.c_oflag &= ~(ONLCR);
+ buf.c_lflag &= ~(ECHO | ECHONL);
+ buf.c_iflag &= ~(ICRNL | INLCR | IGNCR);
+ buf.c_oflag &= ~(ONLCR);
+#elif HAVE_SGTTY_H
+ buf.sg_flags &= ~(ECHO | CRMOD);
#else
- cur_term->Nttyb.sg_flags &= ~(ECHO | CRMOD);
+ memset(&buf, 0, sizeof(buf));
#endif
- return _nc_set_tty_mode(&cur_term->Nttyb);
+ if ((result = _nc_set_tty_mode(&buf)) == OK)
+ cur_term->Nttyb = buf;
+ }
+ return result;
}
/*
@@ -86,145 +96,142 @@ _nc_initscr(void)
* aside from possibly delaying a filter() call until some terminals have been
* initialized.
*/
-static int filter_mode = FALSE;
-
NCURSES_EXPORT(void)
filter(void)
{
- filter_mode = TRUE;
+ START_TRACE();
+ T((T_CALLED("filter")));
+ _nc_prescreen.filter_mode = TRUE;
+ returnVoid;
}
+#if NCURSES_EXT_FUNCS
+/*
+ * An extension, allowing the application to open a new screen without
+ * requiring it to also be filtered.
+ */
+NCURSES_EXPORT(void)
+nofilter(void)
+{
+ START_TRACE();
+ T((T_CALLED("nofilter")));
+ _nc_prescreen.filter_mode = FALSE;
+ returnVoid;
+}
+#endif
+
NCURSES_EXPORT(SCREEN *)
-newterm
-(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
+newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
{
+ int value;
int errret;
- int slk_format = _nc_slk_format;
SCREEN *current;
-#ifdef TRACE
- int t = _nc_getenv_num("NCURSES_TRACE");
-
- if (t >= 0)
- trace(t);
-#endif
+ SCREEN *result = 0;
+ TERMINAL *its_term;
+ START_TRACE();
T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- /* this loads the capability entry, then sets LINES and COLS */
- if (setupterm(name, fileno(ofp), &errret) == ERR)
- return 0;
-
- /* implement filter mode */
- if (filter_mode) {
- LINES = 1;
-
- if (VALID_NUMERIC(init_tabs))
- TABSIZE = init_tabs;
- else
- TABSIZE = 8;
+ _nc_init_pthreads();
+ _nc_lock_global(curses);
- T(("TABSIZE = %d", TABSIZE));
-
- clear_screen = 0;
- cursor_down = parm_down_cursor = 0;
- cursor_address = 0;
- cursor_up = parm_up_cursor = 0;
- row_address = 0;
-
- cursor_home = carriage_return;
- }
-
- /* If we must simulate soft labels, grab off the line to be used.
- We assume that we must simulate, if it is none of the standard
- formats (4-4 or 3-2-3) for which there may be some hardware
- support. */
- if (num_labels <= 0 || !SLK_STDFMT(slk_format))
- if (slk_format) {
- if (ERR == _nc_ripoffline(-SLK_LINES(slk_format),
- _nc_slk_initialize))
- return 0;
- }
- /* this actually allocates the screen structure, and saves the
- * original terminal settings.
- */
current = SP;
- _nc_set_screen(0);
- if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
- _nc_set_screen(current);
- return 0;
- }
+ its_term = (SP ? SP->_term : 0);
- /* if the terminal type has real soft labels, set those up */
- if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
- _nc_slk_initialize(stdscr, COLS);
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(name, fileno(ofp), &errret) != ERR) {
+ int slk_format = _nc_globals.slk_format;
+
+ /*
+ * This actually allocates the screen structure, and saves the original
+ * terminal settings.
+ */
+ _nc_set_screen(0);
+
+ /* allow user to set maximum escape delay from the environment */
+ if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
+ set_escdelay(value);
+ }
- SP->_ifd = fileno(ifp);
- SP->_checkfd = fileno(ifp);
- typeahead(fileno(ifp));
+ if (_nc_setupscreen(LINES,
+ COLS,
+ ofp,
+ _nc_prescreen.filter_mode,
+ slk_format) == ERR) {
+ _nc_set_screen(current);
+ result = 0;
+ } else {
+ assert(SP != 0);
+ /*
+ * In setupterm() we did a set_curterm(), but it was before we set
+ * SP. So the "current" screen's terminal pointer was overwritten
+ * with a different terminal. Later, in _nc_setupscreen(), we set
+ * SP and the terminal pointer in the new screen.
+ *
+ * Restore the terminal-pointer for the pre-existing screen, if
+ * any.
+ */
+ if (current)
+ current->_term = its_term;
+
+ /* if the terminal type has real soft labels, set those up */
+ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
+ _nc_slk_initialize(stdscr, COLS);
+
+ SP->_ifd = fileno(ifp);
+ typeahead(fileno(ifp));
#ifdef TERMIOS
- SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
- !(cur_term->Ottyb.c_iflag & ISTRIP));
+ SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
+ !(cur_term->Ottyb.c_iflag & ISTRIP));
#else
- SP->_use_meta = FALSE;
+ SP->_use_meta = FALSE;
#endif
- SP->_endwin = FALSE;
-
- /* Check whether we can optimize scrolling under dumb terminals in case
- * we do not have any of these capabilities, scrolling optimization
- * will be useless.
- */
- SP->_scrolling = ((scroll_forward && scroll_reverse) ||
- ((parm_rindex || parm_insert_line || insert_line) &&
- (parm_index || parm_delete_line || delete_line)));
-
- baudrate(); /* sets a field in the SP structure */
-
- SP->_keytry = 0;
-
- /*
- * Check for mismatched graphic-rendition capabilities. Most SVr4
- * terminfo trees contain entries that have rmul or rmso equated to
- * sgr0 (Solaris curses copes with those entries). We do this only for
- * curses, since many termcap applications assume that smso/rmso and
- * smul/rmul are paired, and will not function properly if we remove
- * rmso or rmul. Curses applications shouldn't be looking at this
- * detail.
- */
+ SP->_endwin = FALSE;
+
+ /*
+ * Check whether we can optimize scrolling under dumb terminals in
+ * case we do not have any of these capabilities, scrolling
+ * optimization will be useless.
+ */
+ SP->_scrolling = ((scroll_forward && scroll_reverse) ||
+ ((parm_rindex ||
+ parm_insert_line ||
+ insert_line) &&
+ (parm_index ||
+ parm_delete_line ||
+ delete_line)));
+
+ baudrate(); /* sets a field in the SP structure */
+
+ SP->_keytry = 0;
+
+ /*
+ * Check for mismatched graphic-rendition capabilities. Most SVr4
+ * terminfo trees contain entries that have rmul or rmso equated to
+ * sgr0 (Solaris curses copes with those entries). We do this only
+ * for curses, since many termcap applications assume that
+ * smso/rmso and smul/rmul are paired, and will not function
+ * properly if we remove rmso or rmul. Curses applications
+ * shouldn't be looking at this detail.
+ */
#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
- SP->_use_rmso = SGR0_TEST(exit_standout_mode);
- SP->_use_rmul = SGR0_TEST(exit_underline_mode);
-
-#if USE_WIDEC_SUPPORT
- /*
- * XFree86 xterm can be configured to support UTF-8 based on environment
- * variable settings.
- */
- {
- char *s;
- s = getenv("LC_ALL");
- if (s == NULL || *s == '\0') {
- s = getenv("LC_CTYPE");
- if (s == NULL || *s == '\0') {
- s = getenv("LANG");
- }
- }
- if (s != NULL && *s != '\0' && strstr(s, "UTF-8") != NULL) {
- SP->_outch = _nc_utf8_outch;
- }
- }
-#endif
+ SP->_use_rmso = SGR0_TEST(exit_standout_mode);
+ SP->_use_rmul = SGR0_TEST(exit_underline_mode);
- /* compute movement costs so we can do better move optimization */
- _nc_mvcur_init();
+ /* compute movement costs so we can do better move optimization */
+ _nc_mvcur_init();
- /* initialize terminal to a sane state */
- _nc_screen_init();
+ /* initialize terminal to a sane state */
+ _nc_screen_init();
- /* Initialize the terminal line settings. */
- _nc_initscr();
+ /* Initialize the terminal line settings. */
+ _nc_initscr();
- _nc_signal_handler(TRUE);
+ _nc_signal_handler(TRUE);
- T((T_RETURN("%p"), SP));
- return (SP);
+ result = SP;
+ }
+ }
+ _nc_unlock_global(curses);
+ returnSP(result);
}
diff --git a/lib/libcurses/base/lib_newwin.c b/lib/libcurses/base/lib_newwin.c
index 5e25d33f3cb..64fca59d06a 100644
--- a/lib/libcurses/base/lib_newwin.c
+++ b/lib/libcurses/base/lib_newwin.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_newwin.c,v 1.5 2009/11/11 18:34:10 deraadt Exp $ */
+/* $OpenBSD: lib_newwin.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -41,8 +42,40 @@
*/
#include <curses.priv.h>
+#include <stddef.h>
-MODULE_ID("$From: lib_newwin.c,v 1.27 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
+
+#define window_is(name) ((sp)->_##name == win)
+
+#if USE_REENTRANT
+#define remove_window(name) \
+ sp->_##name = 0
+#else
+#define remove_window(name) \
+ sp->_##name = 0; \
+ if (win == name) \
+ name = 0
+#endif
+
+static void
+remove_window_from_screen(WINDOW *win)
+{
+ SCREEN *sp;
+
+ for (each_screen(sp)) {
+ if (window_is(curscr)) {
+ remove_window(curscr);
+ break;
+ } else if (window_is(stdscr)) {
+ remove_window(stdscr);
+ break;
+ } else if (window_is(newscr)) {
+ remove_window(newscr);
+ break;
+ }
+ }
+}
NCURSES_EXPORT(int)
_nc_freewin(WINDOW *win)
@@ -51,44 +84,43 @@ _nc_freewin(WINDOW *win)
int i;
int result = ERR;
+ T((T_CALLED("_nc_freewin(%p)"), win));
+
if (win != 0) {
- for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
- if (p->win == win) {
- if (q == 0)
- _nc_windows = p->next;
- else
- q->next = p->next;
- free(p);
-
- if (!(win->_flags & _SUBWIN)) {
- for (i = 0; i <= win->_maxy; i++)
- FreeIfNeeded(win->_line[i].text);
+ if (_nc_try_global(curses) == 0) {
+ q = 0;
+ for (each_window(p)) {
+ if (&(p->win) == win) {
+ remove_window_from_screen(win);
+ if (q == 0)
+ _nc_windows = p->next;
+ else
+ q->next = p->next;
+
+ if (!(win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy; i++)
+ FreeIfNeeded(win->_line[i].text);
+ }
+ free(win->_line);
+ free(p);
+
+ result = OK;
+ T(("...deleted win=%p", win));
+ break;
}
- free(win->_line);
- free(win);
-
- if (win == curscr)
- curscr = 0;
- if (win == stdscr)
- stdscr = 0;
- if (win == newscr)
- newscr = 0;
-
- result = OK;
- T(("...deleted win=%p", win));
- break;
+ q = p;
}
+ _nc_unlock_global(curses);
}
}
- return result;
+ returnCode(result);
}
NCURSES_EXPORT(WINDOW *)
-newwin
-(int num_lines, int num_columns, int begy, int begx)
+newwin(int num_lines, int num_columns, int begy, int begx)
{
WINDOW *win;
- chtype *ptr;
+ NCURSES_CH_T *ptr;
int i;
T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
@@ -101,31 +133,26 @@ newwin
if (num_columns == 0)
num_columns = screen_columns - begx;
- if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
- returnWin(0);
-
if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
returnWin(0);
for (i = 0; i < num_lines; i++) {
- win->_line[i].text = typeCalloc(chtype, (unsigned) num_columns);
+ win->_line[i].text = typeCalloc(NCURSES_CH_T, (unsigned) num_columns);
if (win->_line[i].text == 0) {
(void) _nc_freewin(win);
returnWin(0);
}
- for (ptr = win->_line[i].text; ptr < win->_line[i].text +
- num_columns;)
- *ptr++ = ' ';
+ for (ptr = win->_line[i].text;
+ ptr < win->_line[i].text + num_columns;
+ ptr++)
+ SetChar(*ptr, BLANK_TEXT, BLANK_ATTR);
}
- T(("newwin: returned window is %p", win));
-
returnWin(win);
}
NCURSES_EXPORT(WINDOW *)
-derwin
-(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
+derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
{
WINDOW *win;
int i;
@@ -135,7 +162,7 @@ derwin
begy, begx));
/*
- ** make sure window fits inside the original one
+ * make sure window fits inside the original one
*/
if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
returnWin(0);
@@ -158,25 +185,22 @@ derwin
win->_pary = begy;
win->_parx = begx;
- win->_attrs = orig->_attrs;
- win->_bkgd = orig->_bkgd;
+ WINDOW_ATTRS(win) = WINDOW_ATTRS(orig);
+ win->_nc_bkgd = orig->_nc_bkgd;
for (i = 0; i < num_lines; i++)
win->_line[i].text = &orig->_line[begy++].text[begx];
win->_parent = orig;
- T(("derwin: returned window is %p", win));
-
returnWin(win);
}
NCURSES_EXPORT(WINDOW *)
-subwin
-(WINDOW *w, int l, int c, int y, int x)
+subwin(WINDOW *w, int l, int c, int y, int x)
{
T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x));
- T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+ T(("parent has begy = %ld, begx = %ld", (long) w->_begy, (long) w->_begx));
returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
}
@@ -189,33 +213,33 @@ dimension_limit(int value)
}
NCURSES_EXPORT(WINDOW *)
-_nc_makenew
-(int num_lines, int num_columns, int begy, int begx, int flags)
+_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
{
int i;
WINDOWLIST *wp;
WINDOW *win;
bool is_pad = (flags & _ISPAD);
- T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+ T((T_CALLED("_nc_makenew(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
+
+ if (SP == 0)
+ returnWin(0);
if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
- return 0;
+ returnWin(0);
if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
- return 0;
+ returnWin(0);
- if ((win = typeCalloc(WINDOW, 1)) == 0) {
- free(wp);
- return 0;
- }
+ win = &(wp->win);
if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
free(wp);
- free(win);
- return 0;
+ returnWin(0);
}
+ _nc_lock_global(curses);
+
win->_curx = 0;
win->_cury = 0;
win->_maxy = num_lines - 1;
@@ -225,8 +249,8 @@ _nc_makenew
win->_yoffset = SP->_topstolen;
win->_flags = flags;
- win->_attrs = A_NORMAL;
- win->_bkgd = BLANK;
+ WINDOW_ATTRS(win) = A_NORMAL;
+ SetChar(win->_nc_bkgd, BLANK_TEXT, BLANK_ATTR);
win->_clear = is_pad ? FALSE : (num_lines == screen_lines
&& num_columns == screen_columns);
@@ -289,10 +313,28 @@ _nc_makenew
}
wp->next = _nc_windows;
- wp->win = win;
+ wp->screen = SP;
_nc_windows = wp;
T((T_CREATE("window %p"), win));
- return (win);
+ _nc_unlock_global(curses);
+ returnWin(win);
+}
+
+/*
+ * wgetch() and other functions with a WINDOW* parameter may use a SCREEN*
+ * internally, and it is useful to allow those to be invoked without switching
+ * SCREEN's, e.g., for multi-threaded applications.
+ */
+NCURSES_EXPORT(SCREEN *)
+_nc_screen_of(WINDOW *win)
+{
+ SCREEN *sp = 0;
+
+ if (win != 0) {
+ WINDOWLIST *wp = (WINDOWLIST *) win;
+ sp = wp->screen;
+ }
+ return (sp);
}
diff --git a/lib/libcurses/base/lib_nl.c b/lib/libcurses/base/lib_nl.c
index b24cb3ec14e..74ac920ed53 100644
--- a/lib/libcurses/base/lib_nl.c
+++ b/lib/libcurses/base/lib_nl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_nl.c,v 1.5 2001/01/22 18:01:42 millert Exp $ */
+/* $OpenBSD: lib_nl.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -44,7 +44,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_nl.c,v 1.8 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_nl.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
#ifdef __EMX__
#include <io.h>
diff --git a/lib/libcurses/base/lib_overlay.c b/lib/libcurses/base/lib_overlay.c
index 7e3c169f08c..a61ebf3f1fc 100644
--- a/lib/libcurses/base/lib_overlay.c
+++ b/lib/libcurses/base/lib_overlay.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_overlay.c,v 1.2 2001/01/22 18:01:42 millert Exp $ */
+/* $OpenBSD: lib_overlay.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,30 +42,61 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_overlay.c,v 1.14 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
static int
-overlap(const WINDOW *const s, WINDOW *const d, int const flag)
+overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
{
- int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
-
- T(("overlap : sby %d, sbx %d, smy %d, smx %d, dby %d, dbx %d, dmy %d, dmx %d",
- s->_begy, s->_begx, s->_maxy, s->_maxx,
- d->_begy, d->_begx, d->_maxy, d->_maxx));
-
- if (!s || !d)
- returnCode(ERR);
-
- sminrow = max(s->_begy, d->_begy) - s->_begy;
- smincol = max(s->_begx, d->_begx) - s->_begx;
- dminrow = max(s->_begy, d->_begy) - d->_begy;
- dmincol = max(s->_begx, d->_begx) - d->_begx;
- dmaxrow = min(s->_maxy + s->_begy, d->_maxy + d->_begy) - d->_begy;
- dmaxcol = min(s->_maxx + s->_begx, d->_maxx + d->_begx) - d->_begx;
-
- return (copywin(s, d,
- sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol,
- flag));
+ int rc = ERR;
+ int sx1, sy1, sx2, sy2;
+ int dx1, dy1, dx2, dy2;
+ int sminrow, smincol;
+ int dminrow, dmincol;
+ int dmaxrow, dmaxcol;
+
+ T((T_CALLED("overlap(%p,%p,%d)"), src, dst, flag));
+
+ if (src != 0 && dst != 0) {
+ _nc_lock_global(curses);
+
+ T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
+ (long) src->_begy,
+ (long) src->_begx,
+ (long) src->_maxy,
+ (long) src->_maxx));
+ T(("dst : begy %ld, begx %ld, maxy %ld, maxx %ld",
+ (long) dst->_begy,
+ (long) dst->_begx,
+ (long) dst->_maxy,
+ (long) dst->_maxx));
+
+ sx1 = src->_begx;
+ sy1 = src->_begy;
+ sx2 = sx1 + src->_maxx;
+ sy2 = sy1 + src->_maxy;
+
+ dx1 = dst->_begx;
+ dy1 = dst->_begy;
+ dx2 = dx1 + dst->_maxx;
+ dy2 = dy1 + dst->_maxy;
+
+ if (dx2 >= sx1 && dx1 <= sx2 && dy2 >= sy1 && dy1 <= sy2) {
+ sminrow = max(sy1, dy1) - sy1;
+ smincol = max(sx1, dx1) - sx1;
+ dminrow = max(sy1, dy1) - dy1;
+ dmincol = max(sx1, dx1) - dx1;
+ dmaxrow = min(sy2, dy2) - dy1;
+ dmaxcol = min(sx2, dx2) - dx1;
+
+ rc = copywin(src, dst,
+ sminrow, smincol,
+ dminrow, dmincol,
+ dmaxrow, dmaxcol,
+ flag);
+ }
+ _nc_unlock_global(curses);
+ }
+ returnCode(rc);
}
/*
@@ -103,59 +134,75 @@ overwrite(const WINDOW *win1, WINDOW *win2)
}
NCURSES_EXPORT(int)
-copywin
-(const WINDOW *src, WINDOW *dst,
- int sminrow, int smincol,
- int dminrow, int dmincol, int dmaxrow, int dmaxcol,
- int over)
+copywin(const WINDOW *src, WINDOW *dst,
+ int sminrow, int smincol,
+ int dminrow, int dmincol,
+ int dmaxrow, int dmaxcol,
+ int over)
{
+ int rc = ERR;
int sx, sy, dx, dy;
bool touched;
- chtype bk = AttrOf(dst->_bkgd);
- chtype mask = ~(chtype) ((bk & A_COLOR) ? A_COLOR : 0);
+ attr_t bk;
+ attr_t mask;
T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"),
src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));
- if (!src || !dst)
- returnCode(ERR);
-
- /* make sure rectangle exists in source */
- if ((sminrow + dmaxrow - dminrow) > (src->_maxy + 1) ||
- (smincol + dmaxcol - dmincol) > (src->_maxx + 1)) {
- returnCode(ERR);
- }
-
- T(("rectangle exists in source"));
-
- /* make sure rectangle fits in destination */
- if (dmaxrow > dst->_maxy || dmaxcol > dst->_maxx) {
- returnCode(ERR);
- }
-
- T(("rectangle fits in destination"));
-
- for (dy = dminrow, sy = sminrow; dy <= dmaxrow; sy++, dy++) {
- touched = FALSE;
- for (dx = dmincol, sx = smincol; dx <= dmaxcol; sx++, dx++) {
- if (over) {
- if ((TextOf(src->_line[sy].text[sx]) != ' ') &&
- (dst->_line[dy].text[dx] != src->_line[sy].text[sx])) {
- dst->_line[dy].text[dx] =
- (src->_line[sy].text[sx] & mask) | bk;
- touched = TRUE;
- }
- } else {
- if (dst->_line[dy].text[dx] != src->_line[sy].text[sx]) {
- dst->_line[dy].text[dx] = src->_line[sy].text[sx];
- touched = TRUE;
+ if (src && dst) {
+ _nc_lock_global(curses);
+
+ bk = AttrOf(dst->_nc_bkgd);
+ mask = ~(attr_t) ((bk & A_COLOR) ? A_COLOR : 0);
+
+ /* make sure rectangle exists in source */
+ if ((sminrow + dmaxrow - dminrow) <= (src->_maxy + 1) &&
+ (smincol + dmaxcol - dmincol) <= (src->_maxx + 1)) {
+
+ T(("rectangle exists in source"));
+
+ /* make sure rectangle fits in destination */
+ if (dmaxrow <= dst->_maxy && dmaxcol <= dst->_maxx) {
+
+ T(("rectangle fits in destination"));
+
+ for (dy = dminrow, sy = sminrow;
+ dy <= dmaxrow;
+ sy++, dy++) {
+
+ touched = FALSE;
+ for (dx = dmincol, sx = smincol;
+ dx <= dmaxcol;
+ sx++, dx++) {
+ if (over) {
+ if ((CharOf(src->_line[sy].text[sx]) != L(' ')) &&
+ (!CharEq(dst->_line[dy].text[dx],
+ src->_line[sy].text[sx]))) {
+ dst->_line[dy].text[dx] =
+ src->_line[sy].text[sx];
+ SetAttr(dst->_line[dy].text[dx],
+ ((AttrOf(src->_line[sy].text[sx]) &
+ mask) | bk));
+ touched = TRUE;
+ }
+ } else {
+ if (!CharEq(dst->_line[dy].text[dx],
+ src->_line[sy].text[sx])) {
+ dst->_line[dy].text[dx] =
+ src->_line[sy].text[sx];
+ touched = TRUE;
+ }
+ }
+ }
+ if (touched) {
+ touchline(dst, dminrow, (dmaxrow - dminrow + 1));
+ }
}
+ T(("finished copywin"));
+ rc = OK;
}
}
- if (touched) {
- touchline(dst, 0, getmaxy(dst));
- }
+ _nc_unlock_global(curses);
}
- T(("finished copywin"));
- returnCode(OK);
+ returnCode(rc);
}
diff --git a/lib/libcurses/base/lib_pad.c b/lib/libcurses/base/lib_pad.c
index f53f6a0f2a6..50463e24a23 100644
--- a/lib/libcurses/base/lib_pad.c
+++ b/lib/libcurses/base/lib_pad.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_pad.c,v 1.4 2001/01/22 18:01:42 millert Exp $ */
+/* $OpenBSD: lib_pad.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,13 +42,13 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_pad.c,v 1.32 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(WINDOW *)
newpad(int l, int c)
{
WINDOW *win;
- chtype *ptr;
+ NCURSES_CH_T *ptr;
int i;
T((T_CALLED("newpad(%d, %d)"), l, c));
@@ -61,20 +61,19 @@ newpad(int l, int c)
for (i = 0; i < l; i++) {
if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
- if ((win->_line[i].text = typeCalloc(chtype, ((size_t) c))) == 0) {
+ if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == 0) {
(void) _nc_freewin(win);
returnWin(0);
}
- for (ptr = win->_line[i].text; ptr < win->_line[i].text + c;)
- *ptr++ = ' ';
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ptr++)
+ SetChar(*ptr, BLANK_TEXT, BLANK_ATTR);
}
returnWin(win);
}
NCURSES_EXPORT(WINDOW *)
-subpad
-(WINDOW *orig, int l, int c, int begy, int begx)
+subpad(WINDOW *orig, int l, int c, int begy, int begx)
{
WINDOW *win = (WINDOW *) 0;
@@ -89,9 +88,13 @@ subpad
}
NCURSES_EXPORT(int)
-prefresh
-(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+prefresh(WINDOW *win,
+ int pminrow,
+ int pmincol,
+ int sminrow,
+ int smincol,
+ int smaxrow,
+ int smaxcol)
{
T((T_CALLED("prefresh()")));
if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow,
@@ -103,9 +106,13 @@ prefresh
}
NCURSES_EXPORT(int)
-pnoutrefresh
-(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+pnoutrefresh(WINDOW *win,
+ int pminrow,
+ int pmincol,
+ int sminrow,
+ int smincol,
+ int smaxrow,
+ int smaxcol)
{
NCURSES_SIZE_T i, j;
NCURSES_SIZE_T m, n;
@@ -140,8 +147,10 @@ pnoutrefresh
pmaxrow = pminrow + smaxrow - sminrow;
pmaxcol = pmincol + smaxcol - smincol;
- T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
- T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+ T((" pminrow + smaxrow - sminrow %ld, win->_maxy %ld",
+ (long) pmaxrow, (long) win->_maxy));
+ T((" pmincol + smaxcol - smincol %ld, win->_maxx %ld",
+ (long) pmaxcol, (long) win->_maxx));
/*
* Trim the caller's screen size back to the actual limits.
@@ -155,8 +164,8 @@ pnoutrefresh
pmaxcol = pmincol + smaxcol - smincol;
}
- if (smaxrow > screen_lines
- || smaxcol > screen_columns
+ if (smaxrow >= screen_lines
+ || smaxcol >= screen_columns
|| sminrow > smaxrow
|| smincol > smaxcol)
returnCode(ERR);
@@ -195,10 +204,21 @@ pnoutrefresh
i++, m++) {
register struct ldat *nline = &newscr->_line[m];
register struct ldat *oline = &win->_line[i];
-
for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
- if (oline->text[j] != nline->text[n]) {
- nline->text[n] = oline->text[j];
+ NCURSES_CH_T ch = oline->text[j];
+#if USE_WIDEC_SUPPORT
+ /*
+ * Special case for leftmost character of the displayed area.
+ * Only half of a double-width character may be visible.
+ */
+ if (j == pmincol
+ && j > 0
+ && isWidecExt(ch)) {
+ SetChar(ch, L(' '), AttrOf(oline->text[j - 1]));
+ }
+#endif
+ if (!CharEq(ch, nline->text[n])) {
+ nline->text[n] = ch;
CHANGED_CELL(nline, n);
}
}
diff --git a/lib/libcurses/base/lib_printw.c b/lib/libcurses/base/lib_printw.c
index 3a567584b0e..165d6ae719c 100644
--- a/lib/libcurses/base/lib_printw.c
+++ b/lib/libcurses/base/lib_printw.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_printw.c,v 1.2 2001/01/22 18:01:42 millert Exp $ */
+/* $OpenBSD: lib_printw.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,79 +41,100 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_printw.c,v 1.9 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_printw.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
-printw(NCURSES_CONST char *fmt,...)
+printw(const char *fmt,...)
{
va_list argp;
int code;
- T(("printw(%s,...) called", _nc_visbuf(fmt)));
+#ifdef TRACE
+ va_start(argp, fmt);
+ T((T_CALLED("printw(%s%s)"),
+ _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
+ va_end(argp);
+#endif
va_start(argp, fmt);
code = vwprintw(stdscr, fmt, argp);
va_end(argp);
- return code;
+ returnCode(code);
}
NCURSES_EXPORT(int)
-wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
+wprintw(WINDOW *win, const char *fmt,...)
{
va_list argp;
int code;
- T(("wprintw(%p,%s,...) called", win, _nc_visbuf(fmt)));
+#ifdef TRACE
+ va_start(argp, fmt);
+ T((T_CALLED("wprintw(%p,%s%s)"),
+ win, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
+ va_end(argp);
+#endif
va_start(argp, fmt);
code = vwprintw(win, fmt, argp);
va_end(argp);
- return code;
+ returnCode(code);
}
NCURSES_EXPORT(int)
-mvprintw(int y, int x, NCURSES_CONST char *fmt,...)
+mvprintw(int y, int x, const char *fmt,...)
{
va_list argp;
- int code = move(y, x);
+ int code;
+
+#ifdef TRACE
+ va_start(argp, fmt);
+ T((T_CALLED("mvprintw(%d,%d,%s%s)"),
+ y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
+ va_end(argp);
+#endif
- if (code != ERR) {
+ if ((code = move(y, x)) != ERR) {
va_start(argp, fmt);
code = vwprintw(stdscr, fmt, argp);
va_end(argp);
}
- return code;
+ returnCode(code);
}
NCURSES_EXPORT(int)
-mvwprintw
-(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
+mvwprintw(WINDOW *win, int y, int x, const char *fmt,...)
{
va_list argp;
- int code = wmove(win, y, x);
+ int code;
- if (code != ERR) {
+#ifdef TRACE
+ va_start(argp, fmt);
+ T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"),
+ y, x, win, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
+ va_end(argp);
+#endif
+
+ if ((code = wmove(win, y, x)) != ERR) {
va_start(argp, fmt);
code = vwprintw(win, fmt, argp);
va_end(argp);
}
- return code;
+ returnCode(code);
}
NCURSES_EXPORT(int)
-vwprintw
-(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
+vwprintw(WINDOW *win, const char *fmt, va_list argp)
{
- char *buf = _nc_printf_string(fmt, argp);
+ char *buf;
int code = ERR;
- if (buf != 0) {
+ T((T_CALLED("vwprintw(%p,%s,va_list)"), win, _nc_visbuf(fmt)));
+
+ if ((buf = _nc_printf_string(fmt, argp)) != 0) {
code = waddstr(win, buf);
-#if USE_SAFE_SPRINTF
- free(buf);
-#endif
}
- return code;
+ returnCode(code);
}
diff --git a/lib/libcurses/base/lib_redrawln.c b/lib/libcurses/base/lib_redrawln.c
index 82ce92b216b..d300a7c7ee0 100644
--- a/lib/libcurses/base/lib_redrawln.c
+++ b/lib/libcurses/base/lib_redrawln.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_redrawln.c,v 1.2 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_redrawln.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,30 +41,45 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_redrawln.c,v 1.9 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_redrawln.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
wredrawln(WINDOW *win, int beg, int num)
{
int i;
int end;
- size_t len = (win->_maxx + 1) * sizeof(chtype);
+ size_t len;
T((T_CALLED("wredrawln(%p,%d,%d)"), win, beg, num));
+ if (win == 0)
+ returnCode(ERR);
+
if (beg < 0)
beg = 0;
if (touchline(win, beg, num) == ERR)
returnCode(ERR);
+ if (touchline(curscr, beg + win->_begy, num) == ERR)
+ returnCode(ERR);
+
end = beg + num;
+ if (end > curscr->_maxy + 1)
+ end = curscr->_maxy + 1;
if (end > win->_maxy + 1)
end = win->_maxy + 1;
+ len = (win->_maxx + 1);
+ if (len > (size_t) (curscr->_maxx + 1))
+ len = (size_t) (curscr->_maxx + 1);
+ len *= sizeof(curscr->_line[0].text[0]);
+
for (i = beg; i < end; i++) {
- memset(curscr->_line[i + win->_begy].text + win->_begx, 0, len);
- _nc_make_oldhash(i + win->_begy);
+ int crow = i + win->_begy;
+
+ memset(curscr->_line[crow].text + win->_begx, 0, len);
+ _nc_make_oldhash(crow);
}
returnCode(OK);
diff --git a/lib/libcurses/base/lib_refresh.c b/lib/libcurses/base/lib_refresh.c
index d3d65e7434a..d0571b99212 100644
--- a/lib/libcurses/base/lib_refresh.c
+++ b/lib/libcurses/base/lib_refresh.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_refresh.c,v 1.4 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_refresh.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_refresh.c,v 1.28 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
wrefresh(WINDOW *win)
@@ -51,7 +52,9 @@ wrefresh(WINDOW *win)
T((T_CALLED("wrefresh(%p)"), win));
- if (win == curscr) {
+ if (win == 0) {
+ code = ERR;
+ } else if (win == curscr) {
curscr->_clear = TRUE;
code = doupdate();
} else if ((code = wnoutrefresh(win)) == OK) {
@@ -73,18 +76,20 @@ NCURSES_EXPORT(int)
wnoutrefresh(WINDOW *win)
{
NCURSES_SIZE_T limit_x;
- NCURSES_SIZE_T i, j;
+ NCURSES_SIZE_T src_row, src_col;
NCURSES_SIZE_T begx;
NCURSES_SIZE_T begy;
- NCURSES_SIZE_T m, n;
+ NCURSES_SIZE_T dst_row, dst_col;
#if USE_SCROLL_HINTS
bool wide;
#endif
T((T_CALLED("wnoutrefresh(%p)"), win));
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("...win", win);
+ _nc_unlock_global(tracef);
+ }
#endif /* TRACE */
/*
@@ -98,8 +103,8 @@ wnoutrefresh(WINDOW *win)
begx = win->_begx;
begy = win->_begy;
- newscr->_bkgd = win->_bkgd;
- newscr->_attrs = win->_attrs;
+ newscr->_nc_bkgd = win->_nc_bkgd;
+ WINDOW_ATTRS(newscr) = WINDOW_ATTRS(win);
/* merge in change information from all subwindows of this window */
wsyncdown(win);
@@ -131,28 +136,121 @@ wnoutrefresh(WINDOW *win)
* so we'll force the issue.
*/
- /* limit(n) */
+ /* limit(dst_col) */
limit_x = win->_maxx;
- /* limit(j) */
- if (limit_x > win->_maxx)
- limit_x = win->_maxx;
+ /* limit(src_col) */
+ if (limit_x > newscr->_maxx - begx)
+ limit_x = newscr->_maxx - begx;
- for (i = 0, m = begy + win->_yoffset;
- i <= win->_maxy && m <= newscr->_maxy;
- i++, m++) {
- register struct ldat *nline = &newscr->_line[m];
- register struct ldat *oline = &win->_line[i];
+ for (src_row = 0, dst_row = begy + win->_yoffset;
+ src_row <= win->_maxy && dst_row <= newscr->_maxy;
+ src_row++, dst_row++) {
+ register struct ldat *nline = &newscr->_line[dst_row];
+ register struct ldat *oline = &win->_line[src_row];
if (oline->firstchar != _NOCHANGE) {
- int last = oline->lastchar;
+ int last_src = oline->lastchar;
+
+ if (last_src > limit_x)
+ last_src = limit_x;
+
+ src_col = oline->firstchar;
+ dst_col = src_col + begx;
+
+ if_WIDEC({
+ register int j;
+
+ /*
+ * Ensure that we will copy complete multi-column characters
+ * on the left-boundary.
+ */
+ if (isWidecExt(oline->text[src_col])) {
+ j = 1 + dst_col - WidecExt(oline->text[src_col]);
+ if (j < 0)
+ j = 0;
+ if (dst_col > j) {
+ src_col -= (dst_col - j);
+ dst_col = j;
+ }
+ }
+
+ /*
+ * Ensure that we will copy complete multi-column characters
+ * on the right-boundary.
+ */
+ j = last_src;
+ if (WidecExt(oline->text[j])) {
+ ++j;
+ while (j <= limit_x) {
+ if (isWidecBase(oline->text[j])) {
+ break;
+ } else {
+ last_src = j;
+ }
+ ++j;
+ }
+ }
+ });
- if (last > limit_x)
- last = limit_x;
+ if_WIDEC({
+ static cchar_t blank = BLANK;
+ int last_dst = begx + ((last_src < win->_maxx)
+ ? last_src
+ : win->_maxx);
+ int fix_left = dst_col;
+ int fix_right = last_dst;
+ register int j;
- for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
- if (oline->text[j] != nline->text[n]) {
- nline->text[n] = oline->text[j];
- CHANGED_CELL(nline, n);
+ /*
+ * Check for boundary cases where we may overwrite part of a
+ * multi-column character. For those, wipe the remainder of
+ * the character to blanks.
+ */
+ j = dst_col;
+ if (isWidecExt(nline->text[j])) {
+ /*
+ * On the left, we only care about multi-column characters
+ * that extend into the changed region.
+ */
+ fix_left = 1 + j - WidecExt(nline->text[j]);
+ if (fix_left < 0)
+ fix_left = 0; /* only if cell is corrupt */
+ }
+
+ j = last_dst;
+ if (WidecExt(nline->text[j]) != 0) {
+ /*
+ * On the right, any multi-column character is a problem,
+ * unless it happens to be contained in the change, and
+ * ending at the right boundary of the change. The
+ * computation for 'fix_left' accounts for the left-side of
+ * this character. Find the end of the character.
+ */
+ ++j;
+ while (j <= newscr->_maxx && isWidecExt(nline->text[j])) {
+ fix_right = j++;
+ }
+ }
+
+ /*
+ * The analysis is simpler if we do the clearing afterwards.
+ * Do that now.
+ */
+ if (fix_left < dst_col || fix_right > last_dst) {
+ for (j = fix_left; j <= fix_right; ++j) {
+ nline->text[j] = blank;
+ CHANGED_CELL(nline, j);
+ }
+ }
+ });
+
+ /*
+ * Copy the changed text.
+ */
+ for (; src_col <= last_src; src_col++, dst_col++) {
+ if (!CharEq(oline->text[src_col], nline->text[dst_col])) {
+ nline->text[dst_col] = oline->text[src_col];
+ CHANGED_CELL(nline, dst_col);
}
}
@@ -161,13 +259,14 @@ wnoutrefresh(WINDOW *win)
if (wide) {
int oind = oline->oldindex;
- nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind
- + win->_yoffset;
+ nline->oldindex = ((oind == _NEWINDEX)
+ ? _NEWINDEX
+ : (begy + oind + win->_yoffset));
}
#endif /* USE_SCROLL_HINTS */
oline->firstchar = oline->lastchar = _NOCHANGE;
- if_USE_SCROLL_HINTS(oline->oldindex = i);
+ if_USE_SCROLL_HINTS(oline->oldindex = src_row);
}
if (win->_clear) {
@@ -182,8 +281,10 @@ wnoutrefresh(WINDOW *win)
newscr->_leaveok = win->_leaveok;
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("newscr", newscr);
+ _nc_unlock_global(tracef);
+ }
#endif /* TRACE */
returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_restart.c b/lib/libcurses/base/lib_restart.c
index c7a2797b7d1..b017010bc8f 100644
--- a/lib/libcurses/base/lib_restart.c
+++ b/lib/libcurses/base/lib_restart.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_restart.c,v 1.4 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_restart.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,14 +31,13 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* Terminfo-only terminal setup routines:
*
* int restartterm(const char *, int, int *)
- * TERMINAL *set_curterm(TERMINAL *)
- * int del_curterm(TERMINAL *)
*/
#include <curses.priv.h>
@@ -49,46 +48,52 @@
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$From: lib_restart.c,v 1.4 2000/12/10 01:26:52 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
-restartterm
-(NCURSES_CONST char *termp, int filenum, int *errret)
+restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
{
- int saveecho = SP->_echo;
- int savecbreak = SP->_cbreak;
- int saveraw = SP->_raw;
- int savenl = SP->_nl;
+ int result;
T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
- setupterm(termp, filenum, errret);
+ if (setupterm(termp, filenum, errret) != OK) {
+ result = ERR;
+ } else if (SP != 0) {
+ int saveecho = SP->_echo;
+ int savecbreak = SP->_cbreak;
+ int saveraw = SP->_raw;
+ int savenl = SP->_nl;
- if (saveecho)
- echo();
- else
- noecho();
+ if (saveecho)
+ echo();
+ else
+ noecho();
- if (savecbreak) {
- cbreak();
- noraw();
- } else if (saveraw) {
- nocbreak();
- raw();
- } else {
- nocbreak();
- noraw();
- }
- if (savenl)
- nl();
- else
- nonl();
+ if (savecbreak) {
+ cbreak();
+ noraw();
+ } else if (saveraw) {
+ nocbreak();
+ raw();
+ } else {
+ nocbreak();
+ noraw();
+ }
+ if (savenl)
+ nl();
+ else
+ nonl();
- reset_prog_mode();
+ reset_prog_mode();
#if USE_SIZECHANGE
- _nc_update_screensize();
+ _nc_update_screensize(SP);
#endif
- returnCode(OK);
+ result = OK;
+ } else {
+ result = ERR;
+ }
+ returnCode(result);
}
diff --git a/lib/libcurses/base/lib_scanw.c b/lib/libcurses/base/lib_scanw.c
index 057f57adee0..852573c83c5 100644
--- a/lib/libcurses/base/lib_scanw.c
+++ b/lib/libcurses/base/lib_scanw.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_scanw.c,v 1.2 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_scanw.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,15 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_scanw.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
-
-#if !HAVE_VSSCANF
-#if defined(__QNX__)
-extern int vsscanf(const char *str, const char *format, __va_list __arg);
-#else
-extern int vsscanf(const char *str, const char *format,...);
-#endif
-#endif
+MODULE_ID("$Id: lib_scanw.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
diff --git a/lib/libcurses/base/lib_screen.c b/lib/libcurses/base/lib_screen.c
index 8f7f830a708..de9e4dc8196 100644
--- a/lib/libcurses/base/lib_screen.c
+++ b/lib/libcurses/base/lib_screen.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_screen.c,v 1.3 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_screen.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,92 +31,111 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
#include <curses.priv.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <term.h> /* exit_ca_mode, non_rev_rmcup */
+MODULE_ID("$Id: lib_screen.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
-MODULE_ID("$From: lib_screen.c,v 1.17 2000/12/10 02:43:27 tom Exp $")
-
-static time_t dumptime;
+#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
NCURSES_EXPORT(WINDOW *)
-getwin(FILE * filep)
+getwin(FILE *filep)
{
WINDOW tmp, *nwin;
int n;
T((T_CALLED("getwin(%p)"), filep));
+ clearerr(filep);
(void) fread(&tmp, sizeof(WINDOW), 1, filep);
- if (ferror(filep))
+ if (ferror(filep)
+ || tmp._maxy == 0
+ || tmp._maxy > MAX_SIZE
+ || tmp._maxx == 0
+ || tmp._maxx > MAX_SIZE)
returnWin(0);
- if ((nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0)) == 0)
- returnWin(0);
+ if (tmp._flags & _ISPAD) {
+ nwin = newpad(tmp._maxy + 1, tmp._maxx + 1);
+ } else {
+ nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0);
+ }
/*
* We deliberately do not restore the _parx, _pary, or _parent
* fields, because the window hierarchy within which they
* made sense is probably gone.
*/
- nwin->_curx = tmp._curx;
- nwin->_cury = tmp._cury;
- nwin->_maxy = tmp._maxy;
- nwin->_maxx = tmp._maxx;
- nwin->_begy = tmp._begy;
- nwin->_begx = tmp._begx;
- nwin->_yoffset = tmp._yoffset;
- nwin->_flags = tmp._flags & ~(_SUBWIN | _ISPAD);
-
- nwin->_attrs = tmp._attrs;
- nwin->_bkgd = tmp._bkgd;
-
- nwin->_clear = tmp._clear;
- nwin->_scroll = tmp._scroll;
- nwin->_leaveok = tmp._leaveok;
- nwin->_use_keypad = tmp._use_keypad;
- nwin->_delay = tmp._delay;
- nwin->_immed = tmp._immed;
- nwin->_sync = tmp._sync;
-
- nwin->_regtop = tmp._regtop;
- nwin->_regbottom = tmp._regbottom;
-
- for (n = 0; n < nwin->_maxy + 1; n++) {
- (void) fread(nwin->_line[n].text,
- sizeof(chtype), (size_t) (nwin->_maxx + 1), filep);
- if (ferror(filep)) {
- delwin(nwin);
- returnWin(0);
+ if (nwin != 0) {
+ nwin->_curx = tmp._curx;
+ nwin->_cury = tmp._cury;
+ nwin->_maxy = tmp._maxy;
+ nwin->_maxx = tmp._maxx;
+ nwin->_begy = tmp._begy;
+ nwin->_begx = tmp._begx;
+ nwin->_yoffset = tmp._yoffset;
+ nwin->_flags = tmp._flags & ~(_SUBWIN);
+
+ WINDOW_ATTRS(nwin) = WINDOW_ATTRS(&tmp);
+ nwin->_nc_bkgd = tmp._nc_bkgd;
+
+ nwin->_notimeout = tmp._notimeout;
+ nwin->_clear = tmp._clear;
+ nwin->_leaveok = tmp._leaveok;
+ nwin->_idlok = tmp._idlok;
+ nwin->_idcok = tmp._idcok;
+ nwin->_immed = tmp._immed;
+ nwin->_scroll = tmp._scroll;
+ nwin->_sync = tmp._sync;
+ nwin->_use_keypad = tmp._use_keypad;
+ nwin->_delay = tmp._delay;
+
+ nwin->_regtop = tmp._regtop;
+ nwin->_regbottom = tmp._regbottom;
+
+ if (tmp._flags & _ISPAD)
+ nwin->_pad = tmp._pad;
+
+ for (n = 0; n <= nwin->_maxy; n++) {
+ clearerr(filep);
+ (void) fread(nwin->_line[n].text,
+ sizeof(NCURSES_CH_T),
+ (size_t) (nwin->_maxx + 1),
+ filep);
+ if (ferror(filep)) {
+ delwin(nwin);
+ returnWin(0);
+ }
}
+ touchwin(nwin);
}
- touchwin(nwin);
-
returnWin(nwin);
}
NCURSES_EXPORT(int)
-putwin(WINDOW *win, FILE * filep)
+putwin(WINDOW *win, FILE *filep)
{
int code = ERR;
int n;
T((T_CALLED("putwin(%p,%p)"), win, filep));
- if (win) {
- (void) fwrite(win, sizeof(WINDOW), 1, filep);
- if (ferror(filep))
- returnCode(code);
+ if (win != 0) {
+ size_t len = (size_t) (win->_maxx + 1);
+
+ clearerr(filep);
+ if (fwrite(win, sizeof(WINDOW), 1, filep) != 1
+ || ferror(filep))
+ returnCode(code);
- for (n = 0; n < win->_maxy + 1; n++) {
- (void) fwrite(win->_line[n].text,
- sizeof(chtype), (size_t) (win->_maxx + 1), filep);
- if (ferror(filep))
+ for (n = 0; n <= win->_maxy; n++) {
+ if (fwrite(win->_line[n].text,
+ sizeof(NCURSES_CH_T), len, filep) != len
+ || ferror(filep)) {
returnCode(code);
+ }
}
code = OK;
}
@@ -131,11 +150,14 @@ scr_restore(const char *file)
T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file)));
if (_nc_access(file, R_OK) < 0
- || (fp = fopen(file, "rb")) == 0)
+ || (fp = fopen(file, "rb")) == 0) {
returnCode(ERR);
- else {
+ } else {
delwin(newscr);
- newscr = getwin(fp);
+ SP->_newscr = getwin(fp);
+#if !USE_REENTRANT
+ newscr = SP->_newscr;
+#endif
(void) fclose(fp);
returnCode(OK);
}
@@ -149,12 +171,11 @@ scr_dump(const char *file)
T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
if (_nc_access(file, W_OK) < 0
- || (fp = fopen(file, "wb")) == 0)
+ || (fp = fopen(file, "wb")) == 0) {
returnCode(ERR);
- else {
+ } else {
(void) putwin(newscr, fp);
(void) fclose(fp);
- dumptime = time((time_t *) 0);
returnCode(OK);
}
}
@@ -163,7 +184,6 @@ NCURSES_EXPORT(int)
scr_init(const char *file)
{
FILE *fp = 0;
- struct stat stb;
T((T_CALLED("scr_init(%s)"), _nc_visbuf(file)));
@@ -171,13 +191,14 @@ scr_init(const char *file)
returnCode(ERR);
if (_nc_access(file, R_OK) < 0
- || (fp = fopen(file, "rb")) == 0)
- returnCode(ERR);
- else if (fstat(STDOUT_FILENO, &stb) || stb.st_mtime > dumptime)
+ || (fp = fopen(file, "rb")) == 0) {
returnCode(ERR);
- else {
+ } else {
delwin(curscr);
- curscr = getwin(fp);
+ SP->_curscr = getwin(fp);
+#if !USE_REENTRANT
+ curscr = SP->_curscr;
+#endif
(void) fclose(fp);
returnCode(OK);
}
@@ -188,11 +209,14 @@ scr_set(const char *file)
{
T((T_CALLED("scr_set(%s)"), _nc_visbuf(file)));
- if (scr_init(file) == ERR)
+ if (scr_init(file) == ERR) {
returnCode(ERR);
- else {
+ } else {
delwin(newscr);
- newscr = dupwin(curscr);
+ SP->_newscr = dupwin(curscr);
+#if !USE_REENTRANT
+ newscr = SP->_newscr;
+#endif
returnCode(OK);
}
}
diff --git a/lib/libcurses/base/lib_scroll.c b/lib/libcurses/base/lib_scroll.c
index 8f9b3c5e17b..c3fc784958c 100644
--- a/lib/libcurses/base/lib_scroll.c
+++ b/lib/libcurses/base/lib_scroll.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_scroll.c,v 1.3 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_scroll.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * Author: Thomas E. Dickey 1996-2003 *
+ * and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -44,17 +45,29 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_scroll.c,v 1.20 2000/12/10 02:54:03 tom Exp $")
+MODULE_ID("$Id: lib_scroll.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(void)
-_nc_scroll_window
-(WINDOW *win, int const n, NCURSES_SIZE_T const top,
- NCURSES_SIZE_T const bottom, chtype blank)
+_nc_scroll_window(WINDOW *win,
+ int const n,
+ NCURSES_SIZE_T const top,
+ NCURSES_SIZE_T const bottom,
+ NCURSES_CH_T blank)
{
- int line, j;
- size_t to_copy = (size_t) (sizeof(chtype) * (win->_maxx + 1));
-
- TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top, bottom));
+ int limit;
+ int line;
+ int j;
+ size_t to_copy = (size_t) (sizeof(NCURSES_CH_T) * (win->_maxx + 1));
+
+ TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %ld, %ld)",
+ win, n, (long) top, (long) bottom));
+
+ if (top < 0
+ || bottom < top
+ || bottom > win->_maxy) {
+ TR(TRACE_MOVE, ("nothing to scroll"));
+ return;
+ }
/*
* This used to do a line-text pointer-shuffle instead of text copies.
@@ -69,15 +82,17 @@ _nc_scroll_window
/* shift n lines downwards */
if (n < 0) {
- for (line = bottom; line >= top - n; line--) {
+ limit = top - n;
+ for (line = bottom; line >= limit && line >= 0; line--) {
+ TR(TRACE_MOVE, ("...copying %d to %d", line + n, line));
memcpy(win->_line[line].text,
win->_line[line + n].text,
to_copy);
- if_USE_SCROLL_HINTS(
- win->_line[line].oldindex =
- win->_line[line + n].oldindex);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex =
+ win->_line[line + n].oldindex);
}
- for (line = top; line < top - n; line++) {
+ for (line = top; line < limit && line <= win->_maxy; line++) {
+ TR(TRACE_MOVE, ("...filling %d", line));
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
@@ -86,20 +101,37 @@ _nc_scroll_window
/* shift n lines upwards */
if (n > 0) {
- for (line = top; line <= bottom - n; line++) {
+ limit = bottom - n;
+ for (line = top; line <= limit && line <= win->_maxy; line++) {
memcpy(win->_line[line].text,
win->_line[line + n].text,
to_copy);
if_USE_SCROLL_HINTS(win->_line[line].oldindex =
win->_line[line + n].oldindex);
}
- for (line = bottom; line > bottom - n; line--) {
+ for (line = bottom; line > limit && line >= 0; line--) {
for (j = 0; j <= win->_maxx; j++)
win->_line[line].text[j] = blank;
if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
}
}
touchline(win, top, bottom - top + 1);
+
+ if_WIDEC({
+ if (WINDOW_EXT(win, addch_used) != 0) {
+ int next = WINDOW_EXT(win, addch_y) + n;
+ if (next < 0 || next > win->_maxy) {
+ TR(TRACE_VIRTPUT,
+ ("Alert discarded multibyte on scroll"));
+ WINDOW_EXT(win, addch_y) = 0;
+ } else {
+ TR(TRACE_VIRTPUT, ("scrolled working position to %d,%d",
+ WINDOW_EXT(win, addch_y),
+ WINDOW_EXT(win, addch_x)));
+ WINDOW_EXT(win, addch_y) = next;
+ }
+ }
+ })
}
NCURSES_EXPORT(int)
@@ -107,18 +139,14 @@ wscrl(WINDOW *win, int n)
{
T((T_CALLED("wscrl(%p,%d)"), win, n));
- if (!win || !win->_scroll)
+ if (!win || !win->_scroll) {
+ TR(TRACE_MOVE, ("...scrollok is false"));
returnCode(ERR);
+ }
- if (n == 0)
- returnCode(OK);
-
- if ((n > (win->_regbottom - win->_regtop)) ||
- (-n > (win->_regbottom - win->_regtop)))
- returnCode(ERR);
-
- _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win));
-
- _nc_synchook(win);
+ if (n != 0) {
+ _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd);
+ _nc_synchook(win);
+ }
returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_scrollok.c b/lib/libcurses/base/lib_scrollok.c
index 3cd16dc0891..a3bfc155ddf 100644
--- a/lib/libcurses/base/lib_scrollok.c
+++ b/lib/libcurses/base/lib_scrollok.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_scrollok.c,v 1.2 2001/01/22 18:01:43 millert Exp $ */
+/* $OpenBSD: lib_scrollok.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_scrollok.c,v 1.4 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_scrollok.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
scrollok(WINDOW *win, bool flag)
diff --git a/lib/libcurses/base/lib_scrreg.c b/lib/libcurses/base/lib_scrreg.c
index d7f8fa7a91a..d70a0ac88a9 100644
--- a/lib/libcurses/base/lib_scrreg.c
+++ b/lib/libcurses/base/lib_scrreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_scrreg.c,v 1.3 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_scrreg.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_scrreg.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_scrreg.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
wsetscrreg(WINDOW *win, int top, int bottom)
diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c
index d9653821351..0c4af8a2673 100644
--- a/lib/libcurses/base/lib_set_term.c
+++ b/lib/libcurses/base/lib_set_term.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_set_term.c,v 1.12 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_set_term.c,v 1.13 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -45,32 +46,50 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_set_term.c,v 1.61 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.13 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(SCREEN *)
-set_term(SCREEN * screenp)
+set_term(SCREEN *screenp)
{
SCREEN *oldSP;
+ SCREEN *newSP;
T((T_CALLED("set_term(%p)"), screenp));
+ _nc_lock_global(curses);
+
oldSP = SP;
_nc_set_screen(screenp);
+ newSP = SP;
+
+ if (newSP != 0) {
+ set_curterm(newSP->_term);
+#if !USE_REENTRANT
+ curscr = newSP->_curscr;
+ newscr = newSP->_newscr;
+ stdscr = newSP->_stdscr;
+ COLORS = newSP->_color_count;
+ COLOR_PAIRS = newSP->_pair_count;
+#endif
+ } else {
+ set_curterm(0);
+#if !USE_REENTRANT
+ curscr = 0;
+ newscr = 0;
+ stdscr = 0;
+ COLORS = 0;
+ COLOR_PAIRS = 0;
+#endif
+ }
- set_curterm(SP->_term);
- curscr = SP->_curscr;
- newscr = SP->_newscr;
- stdscr = SP->_stdscr;
- COLORS = SP->_color_count;
- COLOR_PAIRS = SP->_pair_count;
- memcpy(acs_map, SP->_acs_map, sizeof(chtype) * ACS_LEN);
+ _nc_unlock_global(curses);
T((T_RETURN("%p"), oldSP));
return (oldSP);
}
static void
-_nc_free_keytry(struct tries *kt)
+_nc_free_keytry(TRIES * kt)
{
if (kt != 0) {
_nc_free_keytry(kt->child);
@@ -79,97 +98,135 @@ _nc_free_keytry(struct tries *kt)
}
}
+static bool
+delink_screen(SCREEN *sp)
+{
+ SCREEN *last = 0;
+ SCREEN *temp;
+ bool result = FALSE;
+
+ for (each_screen(temp)) {
+ if (temp == sp) {
+ if (last)
+ last = sp->_next_screen;
+ else
+ _nc_screen_chain = sp->_next_screen;
+ result = TRUE;
+ break;
+ }
+ last = temp;
+ }
+ return result;
+}
+
/*
* Free the storage associated with the given SCREEN sp.
*/
NCURSES_EXPORT(void)
-delscreen(SCREEN * sp)
+delscreen(SCREEN *sp)
{
- SCREEN **scan = &_nc_screen_chain;
+ int i;
T((T_CALLED("delscreen(%p)"), sp));
- while (*scan) {
- if (*scan == sp) {
- *scan = sp->_next_screen;
- break;
+ _nc_lock_global(curses);
+ if (delink_screen(sp)) {
+
+ (void) _nc_freewin(sp->_curscr);
+ (void) _nc_freewin(sp->_newscr);
+ (void) _nc_freewin(sp->_stdscr);
+
+ if (sp->_slk != 0) {
+ if (sp->_slk->ent != 0) {
+ for (i = 0; i < sp->_slk->labcnt; ++i) {
+ FreeIfNeeded(sp->_slk->ent[i].ent_text);
+ FreeIfNeeded(sp->_slk->ent[i].form_text);
+ }
+ free(sp->_slk->ent);
+ }
+ free(sp->_slk);
+ sp->_slk = 0;
}
- scan = &(*scan)->_next_screen;
- }
- (void) _nc_freewin(sp->_curscr);
- (void) _nc_freewin(sp->_newscr);
- (void) _nc_freewin(sp->_stdscr);
- _nc_free_keytry(sp->_keytry);
- _nc_free_keytry(sp->_key_ok);
+ _nc_free_keytry(sp->_keytry);
+ sp->_keytry = 0;
- FreeIfNeeded(sp->_color_table);
- FreeIfNeeded(sp->_color_pairs);
+ _nc_free_keytry(sp->_key_ok);
+ sp->_key_ok = 0;
- FreeIfNeeded(sp->oldhash);
- FreeIfNeeded(sp->newhash);
+ FreeIfNeeded(sp->_current_attr);
- del_curterm(sp->_term);
+ FreeIfNeeded(sp->_color_table);
+ FreeIfNeeded(sp->_color_pairs);
- /*
- * If the associated output stream has been closed, we can discard the
- * set-buffer. Limit the error check to EBADF, since fflush may fail
- * for other reasons than trying to operate upon a closed stream.
- */
- if (sp->_ofp != 0
- && sp->_setbuf != 0
- && fflush(sp->_ofp) != 0
- && errno == EBADF) {
- free(sp->_setbuf);
- }
+ FreeIfNeeded(sp->oldhash);
+ FreeIfNeeded(sp->newhash);
+ FreeIfNeeded(sp->hashtab);
- free(sp);
+ FreeIfNeeded(sp->_acs_map);
+ FreeIfNeeded(sp->_screen_acs_map);
- /*
- * If this was the current screen, reset everything that the
- * application might try to use (except cur_term, which may have
- * multiple references in different screens).
- */
- if (sp == SP) {
- curscr = 0;
- newscr = 0;
- stdscr = 0;
- COLORS = 0;
- COLOR_PAIRS = 0;
- _nc_set_screen(0);
+ /*
+ * If the associated output stream has been closed, we can discard the
+ * set-buffer. Limit the error check to EBADF, since fflush may fail
+ * for other reasons than trying to operate upon a closed stream.
+ */
+ if (sp->_ofp != 0
+ && sp->_setbuf != 0
+ && fflush(sp->_ofp) != 0
+ && errno == EBADF) {
+ free(sp->_setbuf);
+ }
+
+ del_curterm(sp->_term);
+ free(sp);
+
+ /*
+ * If this was the current screen, reset everything that the
+ * application might try to use (except cur_term, which may have
+ * multiple references in different screens).
+ */
+ if (sp == SP) {
+#if !USE_REENTRANT
+ curscr = 0;
+ newscr = 0;
+ stdscr = 0;
+ COLORS = 0;
+ COLOR_PAIRS = 0;
+#endif
+ _nc_set_screen(0);
+ }
}
+ _nc_unlock_global(curses);
+
returnVoid;
}
-static ripoff_t rippedoff[5];
-static ripoff_t *rsp = rippedoff;
-#define N_RIPS SIZEOF(rippedoff)
-
static bool
-no_mouse_event(SCREEN * sp GCC_UNUSED)
+no_mouse_event(SCREEN *sp GCC_UNUSED)
{
return FALSE;
}
static bool
-no_mouse_inline(SCREEN * sp GCC_UNUSED)
+no_mouse_inline(SCREEN *sp GCC_UNUSED)
{
return FALSE;
}
static bool
-no_mouse_parse(int code GCC_UNUSED)
+no_mouse_parse(SCREEN *sp GCC_UNUSED, int code GCC_UNUSED)
{
return TRUE;
}
static void
-no_mouse_resume(SCREEN * sp GCC_UNUSED)
+no_mouse_resume(SCREEN *sp GCC_UNUSED)
{
}
static void
-no_mouse_wrap(SCREEN * sp GCC_UNUSED)
+no_mouse_wrap(SCREEN *sp GCC_UNUSED)
{
}
@@ -183,7 +240,7 @@ extract_fgbg(char *src, int *result)
if (dst == 0) {
dst = src;
} else if (value >= 0) {
- *result = value % max_colors;
+ *result = value;
}
while (*dst != 0 && *dst != ';')
dst++;
@@ -193,21 +250,64 @@ extract_fgbg(char *src, int *result)
}
#endif
-NCURSES_EXPORT(int)
-_nc_setupscreen
-(short slines, short const scolumns, FILE * output)
/* OS-independent screen initializations */
+NCURSES_EXPORT(int)
+_nc_setupscreen(int slines GCC_UNUSED,
+ int scolumns GCC_UNUSED,
+ FILE *output,
+ bool filtered,
+ int slk_format)
{
+ char *env;
int bottom_stolen = 0;
- size_t i;
+ bool support_cookies = USE_XMC_SUPPORT;
+ ripoff_t *rop;
+
+ T((T_CALLED("_nc_setupscreen(%d, %d, %p, %d, %d)"),
+ slines, scolumns, output, filtered, slk_format));
assert(SP == 0); /* has been reset in newterm() ! */
- if (!_nc_alloc_screen())
- return ERR;
+ if (!_nc_alloc_screen()
+ || ((SP->_acs_map = typeCalloc(chtype, ACS_LEN)) == 0)
+ || ((SP->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == 0)) {
+ returnCode(ERR);
+ }
+ T(("created SP %p", SP));
SP->_next_screen = _nc_screen_chain;
_nc_screen_chain = SP;
+ if ((SP->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
+ returnCode(ERR);
+
+ /*
+ * We should always check the screensize, just in case.
+ */
+ _nc_get_screensize(SP, &slines, &scolumns);
+ SET_LINES(slines);
+ SET_COLS(scolumns);
+ T((T_CREATE("screen %s %dx%d"), termname(), LINES, COLS));
+
+ SP->_filtered = filtered;
+
+ /* implement filter mode */
+ if (filtered) {
+ slines = 1;
+ SET_LINES(slines);
+ clear_screen = 0;
+ cursor_down = parm_down_cursor = 0;
+ cursor_address = 0;
+ cursor_up = parm_up_cursor = 0;
+ row_address = 0;
+
+ cursor_home = carriage_return;
+ T(("filter screensize %dx%d", LINES, COLS));
+ }
+#ifdef __DJGPP__
+ T(("setting output mode to binary"));
+ fflush(output);
+ setmode(output, O_BINARY);
+#endif
_nc_set_buffer(output, TRUE);
SP->_term = cur_term;
SP->_lines = slines;
@@ -224,11 +324,7 @@ _nc_setupscreen
SP->_ofp = output;
SP->_cursor = -1; /* cannot know real cursor shape */
-#if NCURSES_NO_PADDING
- SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
- TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
- SP->_no_padding ? " not" : ""));
-#endif
+ SetNoPadding(SP);
#if NCURSES_EXT_FUNCS
SP->_default_color = FALSE;
@@ -261,6 +357,25 @@ _nc_setupscreen
SP->_default_bg = C_MASK;
#endif
+ /*
+ * Allow those assumed/default color assumptions to be overridden at
+ * runtime:
+ */
+ if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) {
+ int fg, bg;
+ char sep1, sep2;
+ int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
+ if (count >= 1) {
+ SP->_default_fg = (fg >= 0 && fg < max_colors) ? fg : C_MASK;
+ if (count >= 3) {
+ SP->_default_bg = (bg >= 0 && bg < max_colors) ? bg : C_MASK;
+ }
+ TR(TRACE_CHARPUT | TRACE_MOVE,
+ ("from environment assumed fg=%d, bg=%d",
+ SP->_default_fg,
+ SP->_default_bg));
+ }
+ }
#if USE_COLORFGBG
/*
* If rxvt's $COLORFGBG variable is set, use it to specify the assumed
@@ -270,8 +385,29 @@ _nc_setupscreen
*/
if (getenv("COLORFGBG") != 0) {
char *p = getenv("COLORFGBG");
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("decoding COLORFGBG %s", p));
p = extract_fgbg(p, &(SP->_default_fg));
p = extract_fgbg(p, &(SP->_default_bg));
+ if (*p) /* assume rxvt was compiled with xpm support */
+ p = extract_fgbg(p, &(SP->_default_bg));
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("decoded fg=%d, bg=%d",
+ SP->_default_fg, SP->_default_bg));
+ if (SP->_default_fg >= max_colors) {
+ if (set_a_foreground != ABSENT_STRING
+ && !strcmp(set_a_foreground, "\033[3%p1%dm")) {
+ set_a_foreground = "\033[3%?%p1%{8}%>%t9%e%p1%d%;m";
+ } else {
+ SP->_default_fg %= max_colors;
+ }
+ }
+ if (SP->_default_bg >= max_colors) {
+ if (set_a_background != ABSENT_STRING
+ && !strcmp(set_a_background, "\033[4%p1%dm")) {
+ set_a_background = "\033[4%?%p1%{8}%>%t9%e%p1%d%;m";
+ } else {
+ SP->_default_bg %= max_colors;
+ }
+ }
}
#endif
#endif /* NCURSES_EXT_FUNCS */
@@ -284,64 +420,133 @@ _nc_setupscreen
SP->_mouse_wrap = no_mouse_wrap;
SP->_mouse_fd = -1;
- /* initialize the panel hooks */
- SP->_panelHook.top_panel = (struct panel *) 0;
- SP->_panelHook.bottom_panel = (struct panel *) 0;
- SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
-
/*
- * If we've no magic cookie support, we suppress attributes that xmc
- * would affect, i.e., the attributes that affect the rendition of a
- * space. Note that this impacts the alternate character set mapping
- * as well.
+ * If we've no magic cookie support, we suppress attributes that xmc would
+ * affect, i.e., the attributes that affect the rendition of a space.
+ */
+ SP->_ok_attributes = termattrs();
+ if (has_colors()) {
+ SP->_ok_attributes |= A_COLOR;
+ }
+#if USE_XMC_SUPPORT
+ /*
+ * If we have no magic-cookie support compiled-in, or if it is suppressed
+ * in the environment, reset the support-flag.
*/
- if (magic_cookie_glitch > 0) {
-
- SP->_xmc_triggers = termattrs() & (
- A_ALTCHARSET |
- A_BLINK |
- A_BOLD |
- A_REVERSE |
- A_STANDOUT |
- A_UNDERLINE
+ if (magic_cookie_glitch >= 0) {
+ if (getenv("NCURSES_NO_MAGIC_COOKIE") != 0) {
+ support_cookies = FALSE;
+ }
+ }
+#endif
+
+ if (!support_cookies && magic_cookie_glitch >= 0) {
+ T(("will disable attributes to work w/o magic cookies"));
+ }
+
+ if (magic_cookie_glitch > 0) { /* tvi, wyse */
+
+ SP->_xmc_triggers = SP->_ok_attributes & (
+ A_STANDOUT |
+ A_UNDERLINE |
+ A_REVERSE |
+ A_BLINK |
+ A_DIM |
+ A_BOLD |
+ A_INVIS |
+ A_PROTECT
);
- SP->_xmc_suppress = SP->_xmc_triggers & (chtype) ~ (A_BOLD);
+#if 0
+ /*
+ * We "should" treat colors as an attribute. The wyse350 (and its
+ * clones) appear to be the only ones that have both colors and magic
+ * cookies.
+ */
+ if (has_colors()) {
+ SP->_xmc_triggers |= A_COLOR;
+ }
+#endif
+ SP->_xmc_suppress = SP->_xmc_triggers & (chtype) ~(A_BOLD);
T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
+ /*
+ * Supporting line-drawing may be possible. But make the regular
+ * video attributes work first.
+ */
+ acs_chars = ABSENT_STRING;
+ ena_acs = ABSENT_STRING;
+ enter_alt_charset_mode = ABSENT_STRING;
+ exit_alt_charset_mode = ABSENT_STRING;
#if USE_XMC_SUPPORT
/*
- * To keep this simple, suppress all of the optimization hooks
- * except for clear_screen and the cursor addressing.
+ * To keep the cookie support simple, suppress all of the optimization
+ * hooks except for clear_screen and the cursor addressing.
*/
- clr_eol = 0;
- clr_eos = 0;
- set_attributes = 0;
-#else
- magic_cookie_glitch = ABSENT_NUMERIC;
- acs_chars = 0;
+ if (support_cookies) {
+ clr_eol = ABSENT_STRING;
+ clr_eos = ABSENT_STRING;
+ set_attributes = ABSENT_STRING;
+ }
#endif
+ } else if (magic_cookie_glitch == 0) { /* hpterm */
+ }
+
+ /*
+ * If magic cookies are not supported, cancel the strings that set
+ * video attributes.
+ */
+ if (!support_cookies && magic_cookie_glitch >= 0) {
+ magic_cookie_glitch = ABSENT_NUMERIC;
+ set_attributes = ABSENT_STRING;
+ enter_blink_mode = ABSENT_STRING;
+ enter_bold_mode = ABSENT_STRING;
+ enter_dim_mode = ABSENT_STRING;
+ enter_reverse_mode = ABSENT_STRING;
+ enter_standout_mode = ABSENT_STRING;
+ enter_underline_mode = ABSENT_STRING;
+ }
+
+ /* initialize normal acs before wide, since we use mapping in the latter */
+#if !USE_WIDEC_SUPPORT
+ if (_nc_unicode_locale() && _nc_locale_breaks_acs(cur_term)) {
+ acs_chars = NULL;
+ ena_acs = NULL;
+ enter_alt_charset_mode = NULL;
+ exit_alt_charset_mode = NULL;
+ set_attributes = NULL;
}
+#endif
_nc_init_acs();
- memcpy(SP->_acs_map, acs_map, sizeof(chtype) * ACS_LEN);
+#if USE_WIDEC_SUPPORT
+ _nc_init_wacs();
+
+ SP->_screen_acs_fix = (_nc_unicode_locale()
+ && _nc_locale_breaks_acs(cur_term));
+#endif
+ env = _nc_get_locale();
+ SP->_legacy_coding = ((env == 0)
+ || !strcmp(env, "C")
+ || !strcmp(env, "POSIX"));
+ T(("legacy-coding %d", SP->_legacy_coding));
_nc_idcok = TRUE;
_nc_idlok = FALSE;
- _nc_windows = 0; /* no windows yet */
-
SP->oldhash = 0;
SP->newhash = 0;
T(("creating newscr"));
- if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ if ((SP->_newscr = newwin(slines, scolumns, 0, 0)) == 0)
+ returnCode(ERR);
T(("creating curscr"));
- if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ if ((SP->_curscr = newwin(slines, scolumns, 0, 0)) == 0)
+ returnCode(ERR);
- SP->_newscr = newscr;
- SP->_curscr = curscr;
+#if !USE_REENTRANT
+ newscr = SP->_newscr;
+ curscr = SP->_curscr;
+#endif
#if USE_SIZECHANGE
SP->_resize = resizeterm;
#endif
@@ -349,70 +554,92 @@ _nc_setupscreen
newscr->_clear = TRUE;
curscr->_clear = FALSE;
- for (i = 0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
- if (rsp->hook) {
+ def_shell_mode();
+ def_prog_mode();
+
+ for (rop = ripoff_stack;
+ rop != ripoff_sp && (rop - ripoff_stack) < N_RIPS;
+ rop++) {
+
+ /* If we must simulate soft labels, grab off the line to be used.
+ We assume that we must simulate, if it is none of the standard
+ formats (4-4 or 3-2-3) for which there may be some hardware
+ support. */
+ if (rop->hook == _nc_slk_initialize)
+ if (!(num_labels <= 0 || !SLK_STDFMT(slk_format)))
+ continue;
+ if (rop->hook) {
+ int count;
WINDOW *w;
- int count = (rsp->line < 0) ? -rsp->line : rsp->line;
-
- if (rsp->line < 0) {
- w = newwin(count, scolumns, SP->_lines_avail - count, 0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- bottom_stolen += count;
- } else
- return ERR;
+
+ count = (rop->line < 0) ? -rop->line : rop->line;
+ T(("ripping off %i lines at %s", count,
+ ((rop->line < 0)
+ ? "bottom"
+ : "top")));
+
+ w = newwin(count, scolumns,
+ ((rop->line < 0)
+ ? SP->_lines_avail - count
+ : 0),
+ 0);
+ if (w) {
+ rop->win = w;
+ rop->hook(w, scolumns);
} else {
- w = newwin(count, scolumns, 0, 0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- SP->_topstolen += count;
- } else
- return ERR;
+ returnCode(ERR);
}
+ if (rop->line < 0)
+ bottom_stolen += count;
+ else
+ SP->_topstolen += count;
SP->_lines_avail -= count;
}
- rsp->line = 0;
}
/* reset the stack */
- rsp = rippedoff;
+ ripoff_sp = ripoff_stack;
T(("creating stdscr"));
assert((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
- if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
- return ERR;
- SP->_stdscr = stdscr;
+ if ((SP->_stdscr = newwin(SP->_lines_avail, scolumns, 0, 0)) == 0)
+ returnCode(ERR);
- def_shell_mode();
- def_prog_mode();
+ SET_LINES(SP->_lines_avail);
+#if !USE_REENTRANT
+ stdscr = SP->_stdscr;
+#endif
- return OK;
+ returnCode(OK);
}
-/* The internal implementation interprets line as the number of
- lines to rip off from the top or bottom.
- */
+/*
+ * The internal implementation interprets line as the number of lines to rip
+ * off from the top or bottom.
+ */
NCURSES_EXPORT(int)
_nc_ripoffline(int line, int (*init) (WINDOW *, int))
{
- if (line == 0)
- return (OK);
+ T((T_CALLED("_nc_ripoffline(%d, %p)"), line, init));
+
+ if (line != 0) {
- if (rsp >= rippedoff + N_RIPS)
- return (ERR);
+ if (ripoff_sp == 0)
+ ripoff_sp = ripoff_stack;
+ if (ripoff_sp >= ripoff_stack + N_RIPS)
+ returnCode(ERR);
- rsp->line = line;
- rsp->hook = init;
- rsp->w = 0;
- rsp++;
+ ripoff_sp->line = line;
+ ripoff_sp->hook = init;
+ ripoff_sp++;
+ }
- return (OK);
+ returnCode(OK);
}
NCURSES_EXPORT(int)
ripoffline(int line, int (*init) (WINDOW *, int))
{
+ START_TRACE();
T((T_CALLED("ripoffline(%d,%p)"), line, init));
if (line == 0)
diff --git a/lib/libcurses/base/lib_slk.c b/lib/libcurses/base/lib_slk.c
index 7b72ce85844..c9abb8038f0 100644
--- a/lib/libcurses/base/lib_slk.c
+++ b/lib/libcurses/base/lib_slk.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slk.c,v 1.4 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_slk.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,8 +29,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Authors: *
+ * Gerhard Fuernkranz 1993 (original) *
+ * Zeyd M. Ben-Halim 1992,1995 (sic) *
+ * Eric S. Raymond *
+ * Juergen Pfeifer 1996-on *
+ * Thomas E. Dickey *
****************************************************************************/
/*
@@ -43,40 +47,20 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$From: lib_slk.c,v 1.20 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
/*
- * We'd like to move these into the screen context structure, but cannot,
- * because slk_init() is called before initscr()/newterm().
+ * Free any memory related to soft labels, return an error.
*/
-NCURSES_EXPORT_VAR(int)
-_nc_slk_format = 0; /* one more than format specified in slk_init() */
-
-/*
- * Paint the info line for the PC style SLK emulation.
- *
- */
- static void
- slk_paint_info(WINDOW *win)
+static int
+slk_failed(void)
{
- if (win && SP->slk_format == 4) {
- int i;
-
- mvwhline(win, 0, 0, 0, getmaxx(win));
- wmove(win, 0, 0);
-
- for (i = 0; i < SP->_slk->maxlab; i++) {
- if (win && SP->slk_format == 4) {
- mvwaddch(win, 0, SP->_slk->ent[i].x, (chtype) 'F');
- if (i < 9)
- waddch(win, (chtype) '1' + i);
- else {
- waddch(win, (chtype) '1');
- waddch(win, (chtype) '0' + (i - 9));
- }
- }
- }
+ if (SP->_slk) {
+ FreeIfNeeded(SP->_slk->ent);
+ free(SP->_slk);
+ SP->_slk = (SLK *) 0;
}
+ return ERR;
}
/*
@@ -88,101 +72,108 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
{
int i, x;
int res = OK;
- char *p;
+ unsigned max_length;
- T(("slk_initialize()"));
+ T((T_CALLED("_nc_slk_initialize()")));
if (SP->_slk) { /* we did this already, so simply return */
- return (OK);
+ returnCode(OK);
} else if ((SP->_slk = typeCalloc(SLK, 1)) == 0)
- return (ERR);
+ returnCode(ERR);
SP->_slk->ent = NULL;
- SP->_slk->buffer = NULL;
- SP->_slk->attr = A_STANDOUT;
- SP->_slk->maxlab = (num_labels > 0) ?
- num_labels : MAX_SKEY(_nc_slk_format);
- SP->_slk->maxlen = (num_labels > 0) ?
- label_width * label_height : MAX_SKEY_LEN(_nc_slk_format);
- SP->_slk->labcnt = (SP->_slk->maxlab < MAX_SKEY(_nc_slk_format)) ?
- MAX_SKEY(_nc_slk_format) : SP->_slk->maxlab;
+ /*
+ * If we use colors, vidputs() will suppress video attributes that conflict
+ * with colors. In that case, we're still guaranteed that "reverse" would
+ * work.
+ */
+ if ((no_color_video & 1) == 0)
+ SetAttr(SP->_slk->attr, A_STANDOUT);
+ else
+ SetAttr(SP->_slk->attr, A_REVERSE);
+
+ SP->_slk->maxlab = ((num_labels > 0)
+ ? num_labels
+ : MAX_SKEY(_nc_globals.slk_format));
+ SP->_slk->maxlen = ((num_labels > 0)
+ ? label_width * label_height
+ : MAX_SKEY_LEN(_nc_globals.slk_format));
+ SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_globals.slk_format))
+ ? MAX_SKEY(_nc_globals.slk_format)
+ : SP->_slk->maxlab);
+
+ if (SP->_slk->maxlen <= 0
+ || SP->_slk->labcnt <= 0
+ || (SP->_slk->ent = typeCalloc(slk_ent,
+ (unsigned) SP->_slk->labcnt)) == NULL)
+ returnCode(slk_failed());
+
+ max_length = SP->_slk->maxlen;
+ for (i = 0; i < SP->_slk->labcnt; i++) {
+ size_t used = max_length + 1;
- SP->_slk->ent = typeCalloc(slk_ent, SP->_slk->labcnt);
- if (SP->_slk->ent == NULL)
- goto exception;
+ if ((SP->_slk->ent[i].ent_text = (char *) _nc_doalloc(0, used)) == 0)
+ returnCode(slk_failed());
+ memset(SP->_slk->ent[i].ent_text, 0, used);
- p = SP->_slk->buffer = (char *) calloc(2 * SP->_slk->labcnt, (1 + SP->_slk->maxlen));
- if (SP->_slk->buffer == NULL)
- goto exception;
+ if ((SP->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used)) == 0)
+ returnCode(slk_failed());
+ memset(SP->_slk->ent[i].form_text, 0, used);
- for (i = 0; i < SP->_slk->labcnt; i++) {
- SP->_slk->ent[i].text = p;
- p += (1 + SP->_slk->maxlen);
- SP->_slk->ent[i].form_text = p;
- p += (1 + SP->_slk->maxlen);
- memset(SP->_slk->ent[i].form_text, ' ', (unsigned) (SP->_slk->maxlen));
- SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
+ memset(SP->_slk->ent[i].form_text, ' ', max_length);
+ SP->_slk->ent[i].visible = (char) (i < SP->_slk->maxlab);
}
- if (_nc_slk_format >= 3) { /* PC style */
- int gap = (cols - 3 * (3 + 4 * SP->_slk->maxlen)) / 2;
+ if (_nc_globals.slk_format >= 3) { /* PC style */
+ int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
if (gap < 1)
gap = 1;
for (i = x = 0; i < SP->_slk->maxlab; i++) {
- SP->_slk->ent[i].x = x;
- x += SP->_slk->maxlen;
+ SP->_slk->ent[i].ent_x = x;
+ x += max_length;
x += (i == 3 || i == 7) ? gap : 1;
}
- if (_nc_slk_format == 4)
- slk_paint_info(stwin);
} else {
- if (_nc_slk_format == 2) { /* 4-4 */
- int gap = cols - (SP->_slk->maxlab * SP->_slk->maxlen) - 6;
+ if (_nc_globals.slk_format == 2) { /* 4-4 */
+ int gap = cols - (SP->_slk->maxlab * max_length) - 6;
if (gap < 1)
gap = 1;
for (i = x = 0; i < SP->_slk->maxlab; i++) {
- SP->_slk->ent[i].x = x;
- x += SP->_slk->maxlen;
+ SP->_slk->ent[i].ent_x = x;
+ x += max_length;
x += (i == 3) ? gap : 1;
}
} else {
- if (_nc_slk_format == 1) { /* 1 -> 3-2-3 */
- int gap = (cols - (SP->_slk->maxlab * SP->_slk->maxlen) - 5)
+ if (_nc_globals.slk_format == 1) { /* 1 -> 3-2-3 */
+ int gap = (cols - (SP->_slk->maxlab * max_length) - 5)
/ 2;
if (gap < 1)
gap = 1;
for (i = x = 0; i < SP->_slk->maxlab; i++) {
- SP->_slk->ent[i].x = x;
- x += SP->_slk->maxlen;
+ SP->_slk->ent[i].ent_x = x;
+ x += max_length;
x += (i == 2 || i == 4) ? gap : 1;
}
} else
- goto exception;
+ returnCode(slk_failed());
}
}
SP->_slk->dirty = TRUE;
if ((SP->_slk->win = stwin) == NULL) {
- exception:
- if (SP->_slk) {
- FreeIfNeeded(SP->_slk->buffer);
- FreeIfNeeded(SP->_slk->ent);
- free(SP->_slk);
- SP->_slk = (SLK *) 0;
- res = (ERR);
- }
+ returnCode(slk_failed());
}
/* We now reset the format so that the next newterm has again
* per default no SLK keys and may call slk_init again to
* define a new layout. (juergen 03-Mar-1999)
*/
- SP->slk_format = _nc_slk_format;
- _nc_slk_format = 0;
- return (res);
+ SP->slk_format = _nc_globals.slk_format;
+ _nc_globals.slk_format = 0;
+ returnCode(res);
}
/*
@@ -197,8 +188,6 @@ slk_restore(void)
return (ERR);
SP->_slk->hidden = FALSE;
SP->_slk->dirty = TRUE;
- /* we have to repaint info line eventually */
- slk_paint_info(SP->_slk->win);
returnCode(slk_refresh());
}
diff --git a/lib/libcurses/base/lib_slkatr_set.c b/lib/libcurses/base/lib_slkatr_set.c
index 403ec288aab..523eadfdf3e 100644
--- a/lib/libcurses/base/lib_slkatr_set.c
+++ b/lib/libcurses/base/lib_slkatr_set.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkatr_set.c,v 1.3 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_slkatr_set.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,28 +29,32 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ * Author: Juergen Pfeifer, 1998 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
* lib_slkatr_set.c
* Soft key routines.
- * Set the labels attributes
+ * Set the label's attributes
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkatr_set.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatr_set.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
-slk_attr_set
-(const attr_t attr, short color_pair_number, void *opts)
+slk_attr_set(const attr_t attr, short color_pair_number, void *opts)
{
T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number));
if (SP != 0 && SP->_slk != 0 && !opts &&
color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
- SP->_slk->attr = attr;
- toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
+ TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+ SetAttr(SP->_slk->attr, attr);
+ if (color_pair_number > 0) {
+ SetPair(SP->_slk->attr, color_pair_number);
+ }
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_slkatrof.c b/lib/libcurses/base/lib_slkatrof.c
index 36e2c128e80..e760fa62001 100644
--- a/lib/libcurses/base/lib_slkatrof.c
+++ b/lib/libcurses/base/lib_slkatrof.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkatrof.c,v 1.2 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_slkatrof.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,8 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -40,7 +40,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkatrof.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatrof.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_attroff(const chtype attr)
@@ -48,7 +48,12 @@ slk_attroff(const chtype attr)
T((T_CALLED("slk_attroff(%s)"), _traceattr(attr)));
if (SP != 0 && SP->_slk != 0) {
- toggle_attr_off(SP->_slk->attr, attr);
+ TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+ RemAttr(SP->_slk->attr, attr);
+ if ((attr & A_COLOR) != 0) {
+ SetPair(SP->_slk->attr, 0);
+ }
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_slkatron.c b/lib/libcurses/base/lib_slkatron.c
index f12bd7ad20f..deef29f7326 100644
--- a/lib/libcurses/base/lib_slkatron.c
+++ b/lib/libcurses/base/lib_slkatron.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkatron.c,v 1.2 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_slkatron.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,8 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -40,7 +40,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkatron.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatron.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_attron(const chtype attr)
@@ -48,7 +48,12 @@ slk_attron(const chtype attr)
T((T_CALLED("slk_attron(%s)"), _traceattr(attr)));
if (SP != 0 && SP->_slk != 0) {
- toggle_attr_on(SP->_slk->attr, attr);
+ TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+ AddAttr(SP->_slk->attr, attr);
+ if ((attr & A_COLOR) != 0) {
+ SetPair(SP->_slk->attr, PAIR_NUMBER(attr));
+ }
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_slkatrset.c b/lib/libcurses/base/lib_slkatrset.c
index 3d3fb73d5e1..17dc4a2097f 100644
--- a/lib/libcurses/base/lib_slkatrset.c
+++ b/lib/libcurses/base/lib_slkatrset.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkatrset.c,v 1.2 2001/01/22 18:01:44 millert Exp $ */
+/* $OpenBSD: lib_slkatrset.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,8 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -40,7 +40,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkatrset.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatrset.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_attrset(const chtype attr)
@@ -48,7 +48,7 @@ slk_attrset(const chtype attr)
T((T_CALLED("slk_attrset(%s)"), _traceattr(attr)));
if (SP != 0 && SP->_slk != 0) {
- SP->_slk->attr = attr;
+ SetAttr(SP->_slk->attr, attr);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_slkattr.c b/lib/libcurses/base/lib_slkattr.c
index 2ddc36f926c..fadcbe0afe2 100644
--- a/lib/libcurses/base/lib_slkattr.c
+++ b/lib/libcurses/base/lib_slkattr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_slkattr.c,v 1.2 2001/01/22 18:01:46 millert Exp $ */
+/* $OpenBSD: lib_slkattr.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -29,8 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer, 1997 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
@@ -40,7 +40,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkattr.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkattr.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(attr_t)
slk_attr(void)
@@ -48,7 +48,11 @@ slk_attr(void)
T((T_CALLED("slk_attr()")));
if (SP != 0 && SP->_slk != 0) {
- returnAttr(SP->_slk->attr);
+ attr_t result = AttrOf(SP->_slk->attr) & ALL_BUT_COLOR;
+ int pair = GetPair(SP->_slk->attr);
+
+ result |= COLOR_PAIR(pair);
+ returnAttr(result);
} else
returnAttr(0);
}
diff --git a/lib/libcurses/base/lib_slkclear.c b/lib/libcurses/base/lib_slkclear.c
index 729ece1f185..44a542ef0c4 100644
--- a/lib/libcurses/base/lib_slkclear.c
+++ b/lib/libcurses/base/lib_slkclear.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkclear.c,v 1.3 2001/01/22 18:01:46 millert Exp $ */
+/* $OpenBSD: lib_slkclear.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Juergen Pfeifer 1996-1999 *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,24 +42,27 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkclear.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkclear.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_clear(void)
{
+ int rc = ERR;
+
T((T_CALLED("slk_clear()")));
- if (SP == NULL || SP->_slk == NULL)
- returnCode(ERR);
- SP->_slk->hidden = TRUE;
- /* For simulated SLK's it's looks much more natural to
- inherit those attributes from the standard screen */
- SP->_slk->win->_bkgd = stdscr->_bkgd;
- SP->_slk->win->_attrs = stdscr->_attrs;
- if (SP->_slk->win == stdscr) {
- returnCode(OK);
- } else {
- werase(SP->_slk->win);
- returnCode(wrefresh(SP->_slk->win));
+ if (SP != NULL && SP->_slk != NULL) {
+ SP->_slk->hidden = TRUE;
+ /* For simulated SLK's it looks much more natural to
+ inherit those attributes from the standard screen */
+ SP->_slk->win->_nc_bkgd = stdscr->_nc_bkgd;
+ WINDOW_ATTRS(SP->_slk->win) = WINDOW_ATTRS(stdscr);
+ if (SP->_slk->win == stdscr) {
+ rc = OK;
+ } else {
+ werase(SP->_slk->win);
+ rc = wrefresh(SP->_slk->win);
+ }
}
+ returnCode(rc);
}
diff --git a/lib/libcurses/base/lib_slkcolor.c b/lib/libcurses/base/lib_slkcolor.c
index 6b06426dbbe..1fcf42647d6 100644
--- a/lib/libcurses/base/lib_slkcolor.c
+++ b/lib/libcurses/base/lib_slkcolor.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkcolor.c,v 1.3 2001/01/22 18:01:46 millert Exp $ */
+/* $OpenBSD: lib_slkcolor.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,15 +29,18 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ * Author: Juergen Pfeifer, 1998 *
+ * and: Thomas E. Dickey 2005 *
****************************************************************************/
/*
* lib_slkcolor.c
+ * Soft key routines.
+ * Set the label's color
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkcolor.c,v 1.7 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkcolor.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_color(short color_pair_number)
@@ -46,8 +49,9 @@ slk_color(short color_pair_number)
if (SP != 0 && SP->_slk != 0 &&
color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
- T(("... current %ld", (long) PAIR_NUMBER(SP->_slk->attr)));
- toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
+ TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(SP->_slk->attr))));
+ SetPair(SP->_slk->attr, color_pair_number);
+ TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_slkinit.c b/lib/libcurses/base/lib_slkinit.c
index 6159dc6a209..ea1ce623c60 100644
--- a/lib/libcurses/base/lib_slkinit.c
+++ b/lib/libcurses/base/lib_slkinit.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkinit.c,v 1.2 2001/01/22 18:01:46 millert Exp $ */
+/* $OpenBSD: lib_slkinit.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -40,14 +41,17 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slkinit.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkinit.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_init(int format)
{
+ int code = ERR;
+
T((T_CALLED("slk_init(%d)"), format));
- if (format < 0 || format > 3)
- returnCode(ERR);
- _nc_slk_format = 1 + format;
- returnCode(OK);
+ if (format >= 0 && format <= 3 && !_nc_globals.slk_format) {
+ _nc_globals.slk_format = 1 + format;
+ code = _nc_ripoffline(-SLK_LINES(_nc_globals.slk_format), _nc_slk_initialize);
+ }
+ returnCode(code);
}
diff --git a/lib/libcurses/base/lib_slklab.c b/lib/libcurses/base/lib_slklab.c
index 2eb3ff6e0d0..4df19d35dcf 100644
--- a/lib/libcurses/base/lib_slklab.c
+++ b/lib/libcurses/base/lib_slklab.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slklab.c,v 1.2 2001/01/22 18:01:46 millert Exp $ */
+/* $OpenBSD: lib_slklab.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,7 +40,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slklab.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slklab.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(char *)
slk_label(int n)
@@ -49,5 +49,5 @@ slk_label(int n)
if (SP == NULL || SP->_slk == NULL || n < 1 || n > SP->_slk->labcnt)
returnPtr(0);
- returnPtr(SP->_slk->ent[n - 1].text);
+ returnPtr(SP->_slk->ent[n - 1].ent_text);
}
diff --git a/lib/libcurses/base/lib_slkrefr.c b/lib/libcurses/base/lib_slkrefr.c
index 80cdec3e66a..4c58f9dbac6 100644
--- a/lib/libcurses/base/lib_slkrefr.c
+++ b/lib/libcurses/base/lib_slkrefr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkrefr.c,v 1.4 2001/01/22 18:01:46 millert Exp $ */
+/* $OpenBSD: lib_slkrefr.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Juergen Pfeifer 1996-on *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
@@ -40,7 +42,27 @@
#include <curses.priv.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$From: lib_slkrefr.c,v 1.10 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
+
+/*
+ * Paint the info line for the PC style SLK emulation.
+ */
+static void
+slk_paint_info(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+
+ if (win && sp && (sp->slk_format == 4)) {
+ int i;
+
+ mvwhline(win, 0, 0, 0, getmaxx(win));
+ wmove(win, 0, 0);
+
+ for (i = 0; i < sp->_slk->maxlab; i++) {
+ mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1);
+ }
+ }
+}
/*
* Write the soft labels to the soft-key window.
@@ -57,18 +79,20 @@ slk_intern_refresh(SLK * slk)
if (num_labels > 0 && SLK_STDFMT(fmt)) {
if (i < num_labels) {
TPUTS_TRACE("plab_norm");
- putp(tparm(plab_norm, i + 1, slk->ent[i].form_text));
+ putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text));
}
} else {
- wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].x);
- if (SP && SP->_slk)
- wattrset(slk->win, SP->_slk->attr);
- waddnstr(slk->win, slk->ent[i].form_text,
- MAX_SKEY_LEN(fmt));
+ if (fmt == 4)
+ slk_paint_info(slk->win);
+ wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
+ if (SP->_slk) {
+ wattrset(slk->win, AttrOf(SP->_slk->attr));
+ }
+ waddstr(slk->win, slk->ent[i].form_text);
/* if we simulate SLK's, it's looking much more
natural to use the current ATTRIBUTE also
for the label window */
- wattrset(slk->win, stdscr->_attrs);
+ wattrset(slk->win, WINDOW_ATTRS(stdscr));
}
}
slk->ent[i].dirty = FALSE;
diff --git a/lib/libcurses/base/lib_slkset.c b/lib/libcurses/base/lib_slkset.c
index a8360d60f49..6958f8d2a9a 100644
--- a/lib/libcurses/base/lib_slkset.c
+++ b/lib/libcurses/base/lib_slkset.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_slkset.c,v 1.3 2001/01/22 18:05:43 millert Exp $ */
+/* $OpenBSD: lib_slkset.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,8 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
@@ -40,59 +40,112 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_slkset.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#endif
+
+MODULE_ID("$Id: lib_slkset.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_set(int i, const char *astr, int format)
{
- SLK *slk = SP->_slk;
- size_t len;
+ SLK *slk;
+ int offset;
+ int numchrs;
+ int numcols;
+ int limit;
const char *str = astr;
const char *p;
T((T_CALLED("slk_set(%d, \"%s\", %d)"), i, str, format));
- if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2)
+ if (SP == 0
+ || (slk = SP->_slk) == 0
+ || i < 1
+ || i > slk->labcnt
+ || format < 0
+ || format > 2)
returnCode(ERR);
if (str == NULL)
str = "";
+ --i; /* Adjust numbering of labels */
- while (isspace(CharOf(*str)))
+ limit = MAX_SKEY_LEN(SP->slk_format);
+ while (isspace(UChar(*str)))
str++; /* skip over leading spaces */
p = str;
- while (isprint(CharOf(*p)))
+
+#if USE_WIDEC_SUPPORT
+ numcols = 0;
+ while (*p != 0) {
+ mbstate_t state;
+ wchar_t wc;
+ size_t need;
+
+ init_mb(state);
+ need = mbrtowc(0, p, strlen(p), &state);
+ if (need == (size_t) -1)
+ break;
+ mbrtowc(&wc, p, need, &state);
+ if (!iswprint((wint_t) wc))
+ break;
+ if (wcwidth(wc) + numcols > limit)
+ break;
+ numcols += wcwidth(wc);
+ p += need;
+ }
+ numchrs = (p - str);
+#else
+ while (isprint(UChar(*p)))
p++; /* The first non-print stops */
- --i; /* Adjust numbering of labels */
+ numcols = (p - str);
+ if (numcols > limit)
+ numcols = limit;
+ numchrs = numcols;
+#endif
- len = (size_t) (p - str);
- if (len > (unsigned) slk->maxlen)
- len = slk->maxlen;
- if (len == 0)
- slk->ent[i].text[0] = 0;
- else
- (void) strlcpy(slk->ent[i].text, str, len+1);
- memset(slk->ent[i].form_text, ' ', (unsigned) slk->maxlen);
- /* len = strlen(slk->ent[i].text); */
+ FreeIfNeeded(slk->ent[i].ent_text);
+ if ((slk->ent[i].ent_text = strdup(str)) == 0)
+ returnCode(ERR);
+ slk->ent[i].ent_text[numchrs] = '\0';
+
+ if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
+ (unsigned) (limit +
+ numchrs + 1))
+ ) == 0)
+ returnCode(ERR);
switch (format) {
+ default:
case 0: /* left-justified */
- memcpy(slk->ent[i].form_text,
- slk->ent[i].text,
- len);
+ offset = 0;
break;
case 1: /* centered */
- memcpy(slk->ent[i].form_text + (slk->maxlen - len) / 2,
- slk->ent[i].text,
- len);
+ offset = (limit - numcols) / 2;
break;
case 2: /* right-justified */
- memcpy(slk->ent[i].form_text + slk->maxlen - len,
- slk->ent[i].text,
- len);
+ offset = limit - numcols;
break;
}
- slk->ent[i].form_text[slk->maxlen] = 0;
+ if (offset <= 0)
+ offset = 0;
+ else
+ memset(slk->ent[i].form_text, ' ', (unsigned) offset);
+
+ memcpy(slk->ent[i].form_text + offset,
+ slk->ent[i].ent_text,
+ (unsigned) numchrs);
+
+ if (offset < limit) {
+ memset(slk->ent[i].form_text + offset + numchrs,
+ ' ',
+ (unsigned) (limit - (offset + numcols)));
+ }
+
+ slk->ent[i].form_text[numchrs - numcols + limit] = 0;
slk->ent[i].dirty = TRUE;
returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_slktouch.c b/lib/libcurses/base/lib_slktouch.c
index 34f4fde8261..7137ec44b01 100644
--- a/lib/libcurses/base/lib_slktouch.c
+++ b/lib/libcurses/base/lib_slktouch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_slktouch.c,v 1.2 2001/01/22 18:01:47 millert Exp $ */
+/* $OpenBSD: lib_slktouch.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -40,7 +40,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_slktouch.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slktouch.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
slk_touch(void)
diff --git a/lib/libcurses/base/lib_touch.c b/lib/libcurses/base/lib_touch.c
index c883fc6b91f..a19fb982320 100644
--- a/lib/libcurses/base/lib_touch.c
+++ b/lib/libcurses/base/lib_touch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_touch.c,v 1.2 2001/01/22 18:01:47 millert Exp $ */
+/* $OpenBSD: lib_touch.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -45,7 +45,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_touch.c,v 1.9 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_touch.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(bool)
is_linetouched(WINDOW *win, int line)
diff --git a/lib/libcurses/base/lib_ungetch.c b/lib/libcurses/base/lib_ungetch.c
index 3837f645b3a..122776d8ff4 100644
--- a/lib/libcurses/base/lib_ungetch.c
+++ b/lib/libcurses/base/lib_ungetch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_ungetch.c,v 1.2 2001/01/22 18:01:47 millert Exp $ */
+/* $OpenBSD: lib_ungetch.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,38 +43,50 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_ungetch.c,v 1.4 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
#include <fifo_defs.h>
#ifdef TRACE
NCURSES_EXPORT(void)
-_nc_fifo_dump(void)
+_nc_fifo_dump(SCREEN *sp)
{
int i;
T(("head = %d, tail = %d, peek = %d", head, tail, peek));
for (i = 0; i < 10; i++)
- T(("char %d = %s", i, _trace_key(SP->_fifo[i])));
+ T(("char %d = %s", i, _nc_tracechar(sp, sp->_fifo[i])));
}
#endif /* TRACE */
NCURSES_EXPORT(int)
-ungetch(int ch)
+_nc_ungetch(SCREEN *sp, int ch)
{
- if (tail == -1)
- return ERR;
- if (head == -1) {
- head = 0;
- t_inc()
+ int rc = ERR;
+
+ if (tail != -1) {
+ if (head == -1) {
+ head = 0;
+ t_inc();
peek = tail; /* no raw keys */
- } else
- h_dec();
+ } else
+ h_dec();
- SP->_fifo[head] = ch;
- T(("ungetch %#x ok", ch));
+ sp->_fifo[head] = ch;
+ T(("ungetch %s ok", _nc_tracechar(sp, ch)));
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- _nc_fifo_dump();
+ if (USE_TRACEF(TRACE_IEVENT)) {
+ _nc_fifo_dump(sp);
+ _nc_unlock_global(tracef);
+ }
#endif
- return OK;
+ rc = OK;
+ }
+ return rc;
+}
+
+NCURSES_EXPORT(int)
+ungetch(int ch)
+{
+ T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP, ch)));
+ returnCode(_nc_ungetch(SP, ch));
}
diff --git a/lib/libcurses/base/lib_vline.c b/lib/libcurses/base/lib_vline.c
index 03dee2977ae..03fcac6b2dc 100644
--- a/lib/libcurses/base/lib_vline.c
+++ b/lib/libcurses/base/lib_vline.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_vline.c,v 1.3 2001/01/22 18:01:47 millert Exp $ */
+/* $OpenBSD: lib_vline.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_vline.c,v 1.7 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_vline.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
wvline(WINDOW *win, chtype ch, int n)
@@ -54,6 +54,7 @@ wvline(WINDOW *win, chtype ch, int n)
T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n));
if (win) {
+ NCURSES_CH_T wch;
row = win->_cury;
col = win->_curx;
end = row + n - 1;
@@ -61,12 +62,14 @@ wvline(WINDOW *win, chtype ch, int n)
end = win->_maxy;
if (ch == 0)
- ch = ACS_VLINE;
- ch = _nc_render(win, ch);
+ SetChar2(wch, ACS_VLINE);
+ else
+ SetChar2(wch, ch);
+ wch = _nc_render(win, wch);
while (end >= row) {
struct ldat *line = &(win->_line[end]);
- line->text[col] = ch;
+ line->text[col] = wch;
CHANGED_CELL(line, col);
end--;
}
diff --git a/lib/libcurses/base/lib_wattroff.c b/lib/libcurses/base/lib_wattroff.c
index 38d5cfb0d31..9dfdb95a929 100644
--- a/lib/libcurses/base/lib_wattroff.c
+++ b/lib/libcurses/base/lib_wattroff.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_wattroff.c,v 1.2 2001/01/22 18:01:47 millert Exp $ */
+/* $OpenBSD: lib_wattroff.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -43,16 +44,22 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_wattroff.c,v 1.6 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_wattroff.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
-wattr_off
-(WINDOW *win, NCURSES_CONST attr_t at, void *opts GCC_UNUSED)
+wattr_off(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
{
T((T_CALLED("wattr_off(%p,%s)"), win, _traceattr(at)));
if (win) {
- T(("... current %s", _traceattr(win->_attrs)));
- toggle_attr_off(win->_attrs, at);
+ T(("... current %s (%d)",
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win)));
+
+ if_EXT_COLORS({
+ if (at & A_COLOR)
+ win->_color = 0;
+ });
+ toggle_attr_off(WINDOW_ATTRS(win), at);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_wattron.c b/lib/libcurses/base/lib_wattron.c
index b788582bc19..cadbae69980 100644
--- a/lib/libcurses/base/lib_wattron.c
+++ b/lib/libcurses/base/lib_wattron.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_wattron.c,v 1.2 2001/01/22 18:01:47 millert Exp $ */
+/* $OpenBSD: lib_wattron.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -43,16 +44,22 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_wattron.c,v 1.6 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_wattron.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
-wattr_on
-(WINDOW *win, NCURSES_CONST attr_t at, void *opts GCC_UNUSED)
+wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
{
T((T_CALLED("wattr_on(%p,%s)"), win, _traceattr(at)));
- if (win) {
- T(("... current %s", _traceattr(win->_attrs)));
- toggle_attr_on(win->_attrs, at);
+ if (win != 0) {
+ T(("... current %s (%d)",
+ _traceattr(WINDOW_ATTRS(win)),
+ GET_WINDOW_PAIR(win)));
+
+ if_EXT_COLORS({
+ if (at & A_COLOR)
+ win->_color = PAIR_NUMBER(at);
+ });
+ toggle_attr_on(WINDOW_ATTRS(win), at);
returnCode(OK);
} else
returnCode(ERR);
diff --git a/lib/libcurses/base/lib_winch.c b/lib/libcurses/base/lib_winch.c
index 9dc58e732b9..870ebea83a2 100644
--- a/lib/libcurses/base/lib_winch.c
+++ b/lib/libcurses/base/lib_winch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_winch.c,v 1.3 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: lib_winch.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,14 +41,15 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_winch.c,v 1.4 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_winch.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(chtype)
winch(WINDOW *win)
{
T((T_CALLED("winch(%p)"), win));
if (win != 0) {
- returnChar(win->_line[win->_cury].text[win->_curx]);
+ returnChar(CharOf(win->_line[win->_cury].text[win->_curx]) |
+ AttrOf(win->_line[win->_cury].text[win->_curx]));
} else {
returnChar(0);
}
diff --git a/lib/libcurses/base/lib_window.c b/lib/libcurses/base/lib_window.c
index 6cfe4ac6fc4..1143622c938 100644
--- a/lib/libcurses/base/lib_window.c
+++ b/lib/libcurses/base/lib_window.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_window.c,v 1.2 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: lib_window.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_window.c,v 1.15 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(void)
_nc_synchook(WINDOW *win)
@@ -100,7 +100,8 @@ wsyncup(WINDOW *win)
{
WINDOW *wp;
- if (win && win->_parent)
+ T((T_CALLED("wsyncup(%p)"), win));
+ if (win && win->_parent) {
for (wp = win; wp->_parent; wp = wp->_parent) {
int y;
WINDOW *pp = wp->_parent;
@@ -120,6 +121,8 @@ wsyncup(WINDOW *win)
}
}
}
+ }
+ returnVoid;
}
NCURSES_EXPORT(void)
@@ -127,6 +130,8 @@ wsyncdown(WINDOW *win)
/* mark changed every cell in win that is changed in any of its ancestors */
/* Rewritten by J. Pfeifer, 1-Apr-96 (don't even think that...) */
{
+ T((T_CALLED("wsyncdown(%p)"), win));
+
if (win && win->_parent) {
WINDOW *pp = win->_parent;
int y;
@@ -146,7 +151,7 @@ wsyncdown(WINDOW *win)
/* left and right character in child coordinates */
int left = pp->_line[win->_pary + y].firstchar - win->_parx;
int right = pp->_line[win->_pary + y].lastchar - win->_parx;
- /* The change maybe outside the childs range */
+ /* The change may be outside the child's range */
if (left < 0)
left = 0;
if (right > win->_maxx)
@@ -155,6 +160,7 @@ wsyncdown(WINDOW *win)
}
}
}
+ returnVoid;
}
NCURSES_EXPORT(void)
@@ -162,64 +168,85 @@ wcursyncup(WINDOW *win)
/* sync the cursor in all derived windows to its value in the base window */
{
WINDOW *wp;
+
+ T((T_CALLED("wcursyncup(%p)"), win));
for (wp = win; wp && wp->_parent; wp = wp->_parent) {
wmove(wp->_parent, wp->_pary + wp->_cury, wp->_parx + wp->_curx);
}
+ returnVoid;
}
NCURSES_EXPORT(WINDOW *)
dupwin(WINDOW *win)
/* make an exact duplicate of the given window */
{
- WINDOW *nwin;
+ WINDOW *nwin = 0;
size_t linesize;
int i;
T((T_CALLED("dupwin(%p)"), win));
- if ((win == NULL) ||
- ((nwin = newwin(win->_maxy + 1, win->_maxx + 1, win->_begy,
- win->_begx)) == NULL))
- returnWin(0);
-
- nwin->_curx = win->_curx;
- nwin->_cury = win->_cury;
- nwin->_maxy = win->_maxy;
- nwin->_maxx = win->_maxx;
- nwin->_begy = win->_begy;
- nwin->_begx = win->_begx;
- nwin->_yoffset = win->_yoffset;
-
- nwin->_flags = win->_flags & ~_SUBWIN;
- /* Due to the use of newwin(), the clone is not a subwindow.
- * The text is really copied into the clone.
- */
-
- nwin->_attrs = win->_attrs;
- nwin->_bkgd = win->_bkgd;
-
- nwin->_clear = win->_clear;
- nwin->_scroll = win->_scroll;
- nwin->_leaveok = win->_leaveok;
- nwin->_use_keypad = win->_use_keypad;
- nwin->_delay = win->_delay;
- nwin->_immed = win->_immed;
- nwin->_sync = win->_sync;
-
- nwin->_parx = 0;
- nwin->_pary = 0;
- nwin->_parent = (WINDOW *) 0;
- /* See above: the clone isn't a subwindow! */
-
- nwin->_regtop = win->_regtop;
- nwin->_regbottom = win->_regbottom;
-
- linesize = (win->_maxx + 1) * sizeof(chtype);
- for (i = 0; i <= nwin->_maxy; i++) {
- memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
- nwin->_line[i].firstchar = win->_line[i].firstchar;
- nwin->_line[i].lastchar = win->_line[i].lastchar;
- }
+ if (win != 0) {
+
+ _nc_lock_global(curses);
+ if (win->_flags & _ISPAD) {
+ nwin = newpad(win->_maxy + 1,
+ win->_maxx + 1);
+ } else {
+ nwin = newwin(win->_maxy + 1,
+ win->_maxx + 1,
+ win->_begy,
+ win->_begx);
+ }
+ if (nwin != 0) {
+
+ nwin->_curx = win->_curx;
+ nwin->_cury = win->_cury;
+ nwin->_maxy = win->_maxy;
+ nwin->_maxx = win->_maxx;
+ nwin->_begy = win->_begy;
+ nwin->_begx = win->_begx;
+ nwin->_yoffset = win->_yoffset;
+
+ nwin->_flags = win->_flags & ~_SUBWIN;
+ /* Due to the use of newwin(), the clone is not a subwindow.
+ * The text is really copied into the clone.
+ */
+
+ WINDOW_ATTRS(nwin) = WINDOW_ATTRS(win);
+ nwin->_nc_bkgd = win->_nc_bkgd;
+
+ nwin->_notimeout = win->_notimeout;
+ nwin->_clear = win->_clear;
+ nwin->_leaveok = win->_leaveok;
+ nwin->_scroll = win->_scroll;
+ nwin->_idlok = win->_idlok;
+ nwin->_idcok = win->_idcok;
+ nwin->_immed = win->_immed;
+ nwin->_sync = win->_sync;
+ nwin->_use_keypad = win->_use_keypad;
+ nwin->_delay = win->_delay;
+
+ nwin->_parx = 0;
+ nwin->_pary = 0;
+ nwin->_parent = (WINDOW *) 0;
+ /* See above: the clone isn't a subwindow! */
+
+ nwin->_regtop = win->_regtop;
+ nwin->_regbottom = win->_regbottom;
+
+ if (win->_flags & _ISPAD)
+ nwin->_pad = win->_pad;
+
+ linesize = (win->_maxx + 1) * sizeof(NCURSES_CH_T);
+ for (i = 0; i <= nwin->_maxy; i++) {
+ memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
+ nwin->_line[i].firstchar = win->_line[i].firstchar;
+ nwin->_line[i].lastchar = win->_line[i].lastchar;
+ }
+ }
+ _nc_unlock_global(curses);
+ }
returnWin(nwin);
}
diff --git a/lib/libcurses/base/nc_panel.c b/lib/libcurses/base/nc_panel.c
index 00bbda062f8..452153859c9 100644
--- a/lib/libcurses/base/nc_panel.c
+++ b/lib/libcurses/base/nc_panel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nc_panel.c,v 1.2 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: nc_panel.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: nc_panel.c,v 1.4 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: nc_panel.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(struct panelhook *)
_nc_panelhook(void)
diff --git a/lib/libcurses/base/resizeterm.c b/lib/libcurses/base/resizeterm.c
index 829f9148820..8f8c7131b83 100644
--- a/lib/libcurses/base/resizeterm.c
+++ b/lib/libcurses/base/resizeterm.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: resizeterm.c,v 1.2 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: resizeterm.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
@@ -43,69 +43,319 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: resizeterm.c,v 1.9 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
+
+#define stolen_lines (screen_lines - SP->_lines_avail)
/*
- * This function reallocates NCURSES window structures. It is invoked in
- * response to a SIGWINCH interrupt. Other user-defined windows may also need
- * to be reallocated.
- *
- * Because this performs memory allocation, it should not (in general) be
- * invoked directly from the signal handler.
+ * If we're trying to be reentrant, do not want any local statics.
+ */
+#if USE_REENTRANT
+#define EXTRA_ARGS , CurLines, CurCols
+#define EXTRA_DCLS , int CurLines, int CurCols
+#else
+static int current_lines;
+static int current_cols;
+#define CurLines current_lines
+#define CurCols current_cols
+#define EXTRA_ARGS /* nothing */
+#define EXTRA_DCLS /* nothing */
+#endif
+
+#ifdef TRACE
+static void
+show_window_sizes(const char *name)
+{
+ WINDOWLIST *wp;
+
+ _nc_lock_global(curses);
+ _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
+ screen_lines, screen_columns);
+ for (each_window(wp)) {
+ _tracef(" window %p is %2ld x %2ld at %2ld,%2ld",
+ &(wp->win),
+ (long) wp->win._maxy + 1,
+ (long) wp->win._maxx + 1,
+ (long) wp->win._begy,
+ (long) wp->win._begx);
+ }
+ _nc_unlock_global(curses);
+}
+#endif
+
+/*
+ * Return true if the given dimensions do not match the internal terminal
+ * structure's size.
+ */
+NCURSES_EXPORT(bool)
+is_term_resized(int ToLines, int ToCols)
+{
+ T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols));
+ returnCode(ToLines > 0
+ && ToCols > 0
+ && (ToLines != screen_lines
+ || ToCols != screen_columns));
+}
+
+/*
+ */
+static ripoff_t *
+ripped_window(WINDOW *win)
+{
+ ripoff_t *result = 0;
+ ripoff_t *rop;
+
+ if (win != 0) {
+ for (each_ripoff(rop)) {
+ if (rop->win == win && rop->line != 0) {
+ result = rop;
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+/*
+ * Returns the number of lines from the bottom for the beginning of a ripped
+ * off window.
+ */
+static int
+ripped_bottom(WINDOW *win)
+{
+ int result = 0;
+ ripoff_t *rop;
+
+ if (win != 0) {
+ for (each_ripoff(rop)) {
+ if (rop->line < 0) {
+ result -= rop->line;
+ if (rop->win == win) {
+ break;
+ }
+ }
+ }
+ }
+ return result;
+}
+
+/*
+ * Return the number of levels of child-windows under the current window.
+ */
+static int
+child_depth(WINDOW *cmp)
+{
+ int depth = 0;
+
+ if (cmp != 0) {
+ WINDOWLIST *wp;
+
+ for (each_window(wp)) {
+ WINDOW *tst = &(wp->win);
+ if (tst->_parent == cmp) {
+ depth = 1 + child_depth(tst);
+ break;
+ }
+ }
+ }
+ return depth;
+}
+
+/*
+ * Return the number of levels of parent-windows above the current window.
+ */
+static int
+parent_depth(WINDOW *cmp)
+{
+ int depth = 0;
+
+ if (cmp != 0) {
+ WINDOW *tst;
+ while ((tst = cmp->_parent) != 0) {
+ ++depth;
+ cmp = tst;
+ }
+ }
+ return depth;
+}
+
+/*
+ * FIXME: must adjust position so it's within the parent!
+ */
+static int
+adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
+{
+ int result;
+ int bottom = CurLines + SP->_topstolen - stolen;
+ int myLines = win->_maxy + 1;
+ int myCols = win->_maxx + 1;
+ ripoff_t *rop = ripped_window(win);
+
+ T((T_CALLED("adjust_window(%p,%d,%d)%s depth %d/%d currently %ldx%ld at %ld,%ld"),
+ win, ToLines, ToCols,
+ (rop != 0) ? " (rip)" : "",
+ parent_depth(win),
+ child_depth(win),
+ (long) getmaxy(win), (long) getmaxx(win),
+ (long) getbegy(win) + win->_yoffset, (long) getbegx(win)));
+
+ if (rop != 0 && rop->line < 0) {
+ /*
+ * If it is a ripped-off window at the bottom of the screen, simply
+ * move it to the same relative position.
+ */
+ win->_begy = ToLines - ripped_bottom(win) - 0 - win->_yoffset;
+ } else if (win->_begy >= bottom) {
+ /*
+ * If it is below the bottom of the new screen, move up by the same
+ * amount that the screen shrank.
+ */
+ win->_begy += (ToLines - CurLines);
+ } else {
+ if (myLines == (CurLines - stolen)
+ && ToLines != CurLines) {
+ myLines = ToLines - stolen;
+ } else if (myLines == CurLines
+ && ToLines != CurLines) {
+ myLines = ToLines;
+ }
+ }
+
+ if (myLines > ToLines) {
+ myLines = ToLines;
+ }
+
+ if (myCols > ToCols)
+ myCols = ToCols;
+
+ if (myCols == CurCols
+ && ToCols != CurCols)
+ myCols = ToCols;
+
+ result = wresize(win, myLines, myCols);
+ returnCode(result);
+}
+
+/*
+ * If we're decreasing size, recursively search for windows that have no
+ * children, decrease those to fit, then decrease the containing window, etc.
+ */
+static int
+decrease_size(int ToLines, int ToCols, int stolen EXTRA_DCLS)
+{
+ bool found;
+ int depth = 0;
+ WINDOWLIST *wp;
+
+ T((T_CALLED("decrease_size(%d, %d)"), ToLines, ToCols));
+
+ do {
+ found = FALSE;
+ TR(TRACE_UPDATE, ("decreasing size of windows to %dx%d, depth=%d",
+ ToLines, ToCols, depth));
+ for (each_window(wp)) {
+ WINDOW *win = &(wp->win);
+
+ if (!(win->_flags & _ISPAD)) {
+ if (child_depth(win) == depth) {
+ found = TRUE;
+ if (adjust_window(win, ToLines, ToCols,
+ stolen EXTRA_ARGS) != OK)
+ returnCode(ERR);
+ }
+ }
+ }
+ ++depth;
+ } while (found);
+ returnCode(OK);
+}
+
+/*
+ * If we're increasing size, recursively search for windows that have no
+ * parent, increase those to fit, then increase the contained window, etc.
+ */
+static int
+increase_size(int ToLines, int ToCols, int stolen EXTRA_DCLS)
+{
+ bool found;
+ int depth = 0;
+ WINDOWLIST *wp;
+
+ T((T_CALLED("increase_size(%d, %d)"), ToLines, ToCols));
+
+ do {
+ found = FALSE;
+ TR(TRACE_UPDATE, ("increasing size of windows to %dx%d, depth=%d",
+ ToLines, ToCols, depth));
+ for (each_window(wp)) {
+ WINDOW *win = &(wp->win);
+
+ if (!(win->_flags & _ISPAD)) {
+ if (parent_depth(win) == depth) {
+ found = TRUE;
+ if (adjust_window(win, ToLines, ToCols,
+ stolen EXTRA_ARGS) != OK)
+ returnCode(ERR);
+ }
+ }
+ }
+ ++depth;
+ } while (found);
+ returnCode(OK);
+}
+
+/*
+ * This function reallocates NCURSES window structures, with no side-effects
+ * such as ungetch().
*/
NCURSES_EXPORT(int)
-resizeterm(int ToLines, int ToCols)
+resize_term(int ToLines, int ToCols)
{
- int stolen = screen_lines - SP->_lines_avail;
- int bottom = screen_lines + SP->_topstolen - stolen;
+ int result = OK EXTRA_ARGS;
+ int was_stolen;
- T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
+ T((T_CALLED("resize_term(%d,%d) old(%d,%d)"),
ToLines, ToCols,
screen_lines, screen_columns));
- SP->_sig_winch = FALSE;
+ if (SP == 0) {
+ returnCode(ERR);
+ }
- if (ToLines != screen_lines
- || ToCols != screen_columns) {
- WINDOWLIST *wp;
+ _nc_lock_global(curses);
-#if USE_SIGWINCH
- ungetch(KEY_RESIZE); /* so application can know this */
- clearok(curscr, TRUE); /* screen contents are unknown */
-#endif
+ was_stolen = (screen_lines - SP->_lines_avail);
+ if (is_term_resized(ToLines, ToCols)) {
+ int myLines = CurLines = screen_lines;
+ int myCols = CurCols = screen_columns;
- for (wp = _nc_windows; wp != 0; wp = wp->next) {
- WINDOW *win = wp->win;
- int myLines = win->_maxy + 1;
- int myCols = win->_maxx + 1;
-
- /* pads aren't treated this way */
- if (win->_flags & _ISPAD)
- continue;
-
- if (win->_begy >= bottom) {
- win->_begy += (ToLines - screen_lines);
- } else {
- if (myLines == screen_lines - stolen
- && ToLines != screen_lines)
- myLines = ToLines - stolen;
- else if (myLines == screen_lines
- && ToLines != screen_lines)
- myLines = ToLines;
- }
+#ifdef TRACE
+ if (USE_TRACEF(TRACE_UPDATE)) {
+ show_window_sizes("before");
+ _nc_unlock_global(tracef);
+ }
+#endif
+ if (ToLines > screen_lines) {
+ increase_size(myLines = ToLines, myCols, was_stolen EXTRA_ARGS);
+ CurLines = myLines;
+ CurCols = myCols;
+ }
- if (myCols == screen_columns
- && ToCols != screen_columns)
- myCols = ToCols;
+ if (ToCols > screen_columns) {
+ increase_size(myLines, myCols = ToCols, was_stolen EXTRA_ARGS);
+ CurLines = myLines;
+ CurCols = myCols;
+ }
- if (wresize(win, myLines, myCols) != OK)
- returnCode(ERR);
+ if (ToLines < myLines ||
+ ToCols < myCols) {
+ decrease_size(ToLines, ToCols, was_stolen EXTRA_ARGS);
}
screen_lines = lines = ToLines;
screen_columns = columns = ToCols;
- SP->_lines_avail = lines - stolen;
+ SP->_lines_avail = lines - was_stolen;
if (SP->oldhash) {
FreeAndNull(SP->oldhash);
@@ -113,14 +363,95 @@ resizeterm(int ToLines, int ToCols)
if (SP->newhash) {
FreeAndNull(SP->newhash);
}
+#ifdef TRACE
+ if (USE_TRACEF(TRACE_UPDATE)) {
+ SET_LINES(ToLines - was_stolen);
+ SET_COLS(ToCols);
+ show_window_sizes("after");
+ _nc_unlock_global(tracef);
+ }
+#endif
}
/*
* Always update LINES, to allow for call from lib_doupdate.c which
* needs to have the count adjusted by the stolen (ripped off) lines.
*/
- LINES = ToLines - stolen;
- COLS = ToCols;
+ SET_LINES(ToLines - was_stolen);
+ SET_COLS(ToCols);
- returnCode(OK);
+ _nc_unlock_global(curses);
+
+ returnCode(result);
+}
+
+/*
+ * This function reallocates NCURSES window structures. It is invoked in
+ * response to a SIGWINCH interrupt. Other user-defined windows may also need
+ * to be reallocated.
+ *
+ * Because this performs memory allocation, it should not (in general) be
+ * invoked directly from the signal handler.
+ */
+NCURSES_EXPORT(int)
+resizeterm(int ToLines, int ToCols)
+{
+ int result = ERR;
+
+ T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
+ ToLines, ToCols,
+ screen_lines, screen_columns));
+
+ if (SP != 0) {
+ result = OK;
+ SP->_sig_winch = FALSE;
+
+ if (is_term_resized(ToLines, ToCols)) {
+#if USE_SIGWINCH
+ ripoff_t *rop;
+ bool slk_visible = (SP != 0
+ && SP->_slk != 0
+ && !(SP->_slk->hidden));
+
+ if (slk_visible) {
+ slk_clear();
+ }
+#endif
+ result = resize_term(ToLines, ToCols);
+
+#if USE_SIGWINCH
+ _nc_ungetch(SP, KEY_RESIZE); /* so application can know this */
+ clearok(curscr, TRUE); /* screen contents are unknown */
+
+ /* ripped-off lines are a special case: if we did not lengthen
+ * them, we haven't moved them either. repaint them, too.
+ *
+ * for the rest - stdscr and other windows - the client has to
+ * decide which to repaint, since without panels, ncurses does
+ * not know which are really on top.
+ */
+ for (each_ripoff(rop)) {
+ if (rop->win != stdscr
+ && rop->win != 0
+ && rop->line < 0) {
+
+ if (rop->hook != _nc_slk_initialize) {
+ touchwin(rop->win);
+ wnoutrefresh(rop->win);
+ }
+ }
+ }
+
+ /* soft-keys are a special case: we _know_ how to repaint them */
+ if (slk_visible) {
+ slk_restore();
+ slk_touch();
+
+ slk_refresh();
+ }
+#endif
+ }
+ }
+
+ returnCode(result);
}
diff --git a/lib/libcurses/base/safe_sprintf.c b/lib/libcurses/base/safe_sprintf.c
index 616a50127c7..4173a32ee77 100644
--- a/lib/libcurses/base/safe_sprintf.c
+++ b/lib/libcurses/base/safe_sprintf.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: safe_sprintf.c,v 1.4 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: safe_sprintf.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -35,7 +35,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: safe_sprintf.c,v 1.13 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
#if USE_SAFE_SPRINTF
@@ -58,10 +58,13 @@ _nc_printf_length(const char *fmt, va_list ap)
char *buffer;
char *format;
int len = 0;
+ size_t fmt_len;
+ char fmt_arg[BUFSIZ];
if (fmt == 0 || *fmt == '\0')
- return -1;
- if ((format = typeMalloc(char, strlen(fmt) + 1)) == 0)
+ return 0;
+ fmt_len = strlen(fmt) + 1;
+ if ((format = typeMalloc(char, fmt_len)) == 0)
return -1;
if ((buffer = typeMalloc(char, length)) == 0) {
free(format);
@@ -86,7 +89,7 @@ _nc_printf_length(const char *fmt, va_list ap)
while (*++fmt != '\0' && len >= 0 && !done) {
format[f++] = *fmt;
- if (isdigit(*fmt)) {
+ if (isdigit(UChar(*fmt))) {
int num = *fmt - '0';
if (state == Flags && num != 0)
state = Width;
@@ -108,9 +111,14 @@ _nc_printf_length(const char *fmt, va_list ap)
} else if (state == Prec) {
prec = ival;
}
- sprintf(&format[--f], "%d", ival);
+ sprintf(fmt_arg, "%d", ival);
+ fmt_len += strlen(fmt_arg);
+ if ((format = realloc(format, fmt_len)) == 0) {
+ return -1;
+ }
+ strcpy(&format[--f], fmt_arg);
f = strlen(format);
- } else if (isalpha(*fmt)) {
+ } else if (isalpha(UChar(*fmt))) {
done = TRUE;
switch (*fmt) {
case 'Z': /* FALLTHRU */
@@ -201,46 +209,58 @@ _nc_printf_length(const char *fmt, va_list ap)
}
#endif
+#define my_buffer _nc_globals.safeprint_buf
+#define my_length _nc_globals.safeprint_used
+
/*
* Wrapper for vsprintf that allocates a buffer big enough to hold the result.
*/
NCURSES_EXPORT(char *)
-_nc_printf_string
-(const char *fmt, va_list ap)
+_nc_printf_string(const char *fmt, va_list ap)
{
+ char *result = 0;
+
+ if (fmt != 0) {
#if USE_SAFE_SPRINTF
- char *buf = 0;
- int len = _nc_printf_length(fmt, ap);
+ int len = _nc_printf_length(fmt, ap);
- if (len > 0) {
- if ((buf = typeMalloc(char, len + 1)) == 0)
- return (0);
- vsprintf(buf, fmt, ap);
- }
+ if ((int) my_length < len + 1) {
+ my_length = 2 * (len + 1);
+ my_buffer = typeRealloc(char, my_length, my_buffer);
+ }
+ if (my_buffer != 0) {
+ *my_buffer = '\0';
+ if (len >= 0) {
+ vsprintf(my_buffer, fmt, ap);
+ }
+ result = my_buffer;
+ }
#else
- static int rows, cols;
- static char *buf;
- static size_t len;
-
- if (screen_lines > rows || screen_columns > cols) {
- if (screen_lines > rows)
- rows = screen_lines;
- if (screen_columns > cols)
- cols = screen_columns;
- len = (rows * (cols + 1)) + 1;
- buf = typeRealloc(char, len, buf);
- if (buf == 0) {
- return (0);
+#define MyCols _nc_globals.safeprint_cols
+#define MyRows _nc_globals.safeprint_rows
+
+ if (screen_lines > MyRows || screen_columns > MyCols) {
+ if (screen_lines > MyRows)
+ MyRows = screen_lines;
+ if (screen_columns > MyCols)
+ MyCols = screen_columns;
+ my_length = (MyRows * (MyCols + 1)) + 1;
+ my_buffer = typeRealloc(char, my_length, my_buffer);
}
- }
- if (buf != 0) {
+ if (my_buffer != 0) {
# if HAVE_VSNPRINTF
- vsnprintf(buf, len, fmt, ap); /* GNU extension */
+ vsnprintf(my_buffer, my_length, fmt, ap); /* GNU extension */
# else
- vsprintf(buf, fmt, ap); /* ANSI */
+ vsprintf(my_buffer, fmt, ap); /* ANSI */
# endif
- }
+ result = my_buffer;
+ }
#endif
- return buf;
+ } else if (my_buffer != 0) { /* see _nc_freeall() */
+ free(my_buffer);
+ my_buffer = 0;
+ my_length = 0;
+ }
+ return result;
}
diff --git a/lib/libcurses/base/tries.c b/lib/libcurses/base/tries.c
index 15d48289d49..704498044b0 100644
--- a/lib/libcurses/base/tries.c
+++ b/lib/libcurses/base/tries.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tries.c,v 1.4 2001/01/22 18:01:48 millert Exp $ */
+/* $OpenBSD: tries.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,17 +41,16 @@
#include <curses.priv.h>
-MODULE_ID("$From: tries.c,v 1.14 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
/*
* Expand a keycode into the string that it corresponds to, returning null if
* no match was found, otherwise allocating a string of the result.
*/
NCURSES_EXPORT(char *)
-_nc_expand_try
-(struct tries *tree, unsigned short code, int *count, size_t len)
+_nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
{
- struct tries *ptr = tree;
+ TRIES *ptr = tree;
char *result = 0;
if (code != 0) {
@@ -71,11 +70,13 @@ _nc_expand_try
}
}
if (result != 0) {
- if ((result[len] = ptr->ch) == 0)
+ if (ptr != 0 && (result[len] = (char) ptr->ch) == 0)
*((unsigned char *) (result + len)) = 128;
#ifdef TRACE
- if (len == 0)
- _tracef("expand_key %s %s", _trace_key(code), _nc_visbuf(result));
+ if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
+ _tracef("expand_key %s %s", _nc_tracechar(SP, code), _nc_visbuf(result));
+ _nc_unlock_global(tracef);
+ }
#endif
}
return result;
@@ -86,8 +87,7 @@ _nc_expand_try
* true if the code was found/removed.
*/
NCURSES_EXPORT(int)
-_nc_remove_key
-(struct tries **tree, unsigned short code)
+_nc_remove_key(TRIES ** tree, unsigned code)
{
T((T_CALLED("_nc_remove_key(%p,%d)"), tree, code));
@@ -103,7 +103,7 @@ _nc_remove_key
/* don't cut the whole sub-tree */
(*tree)->value = 0;
} else {
- struct tries *to_free = *tree;
+ TRIES *to_free = *tree;
*tree = (*tree)->sibling;
free(to_free);
}
@@ -119,7 +119,7 @@ _nc_remove_key
* true if the string was found/removed.
*/
NCURSES_EXPORT(int)
-_nc_remove_string(struct tries **tree, char *string)
+_nc_remove_string(TRIES ** tree, const char *string)
{
T((T_CALLED("_nc_remove_string(%p,%s)"), tree, _nc_visbuf(string)));
@@ -127,18 +127,17 @@ _nc_remove_string(struct tries **tree, char *string)
returnCode(FALSE);
while (*tree != 0) {
- if ((unsigned char) (*tree)->ch == (unsigned char) *string) {
+ if (UChar((*tree)->ch) == UChar(*string)) {
if (string[1] != 0)
returnCode(_nc_remove_string(&(*tree)->child, string + 1));
- if ((*tree)->child) {
- /* don't cut the whole sub-tree */
- (*tree)->value = 0;
- } else {
- struct tries *to_free = *tree;
+ if ((*tree)->child == 0) {
+ TRIES *to_free = *tree;
*tree = (*tree)->sibling;
free(to_free);
+ returnCode(TRUE);
+ } else {
+ returnCode(FALSE);
}
- returnCode(TRUE);
}
tree = &(*tree)->sibling;
}
diff --git a/lib/libcurses/base/use_window.c b/lib/libcurses/base/use_window.c
new file mode 100644
index 00000000000..ead06ec1440
--- /dev/null
+++ b/lib/libcurses/base/use_window.c
@@ -0,0 +1,50 @@
+/* $OpenBSD: use_window.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2007,2008 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2007 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: use_window.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+NCURSES_EXPORT(int)
+use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
+{
+ int code = OK;
+
+ T((T_CALLED("use_window(%p,%p,%p)"), win, func, data));
+ _nc_lock_global(curses);
+ code = func(win, data);
+ _nc_unlock_global(curses);
+
+ returnCode(code);
+}
diff --git a/lib/libcurses/base/version.c b/lib/libcurses/base/version.c
index 99cd40934e4..7387797accf 100644
--- a/lib/libcurses/base/version.c
+++ b/lib/libcurses/base/version.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: version.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
+
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -32,16 +34,11 @@
#include <curses.priv.h>
-MODULE_ID("$From: version.c,v 1.4 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: version.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(const char *)
curses_version(void)
{
- static char my_version[80];
-
T((T_CALLED("curses_version()")));
- snprintf(my_version, sizeof(my_version), "ncurses %s.%d",
- NCURSES_VERSION,
- NCURSES_VERSION_PATCH);
- returnPtr(my_version);
+ returnCPtr("ncurses " NCURSES_VERSION_STRING);
}
diff --git a/lib/libcurses/base/vsscanf.c b/lib/libcurses/base/vsscanf.c
new file mode 100644
index 00000000000..0a283e30c9c
--- /dev/null
+++ b/lib/libcurses/base/vsscanf.c
@@ -0,0 +1,358 @@
+/* $OpenBSD: vsscanf.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * State-machine fallback written by Thomas E. Dickey 2002 *
+ ****************************************************************************/
+
+/*
+ * This function is needed to support vwscanw
+ */
+
+#include <curses.priv.h>
+
+#if !HAVE_VSSCANF
+
+MODULE_ID("$Id: vsscanf.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+#if !(HAVE_VFSCANF || HAVE__DOSCAN)
+
+#include <ctype.h>
+
+#define L_SQUARE '['
+#define R_SQUARE ']'
+
+typedef enum {
+ cUnknown
+ ,cError /* anything that isn't ANSI */
+ ,cAssigned
+ ,cChar
+ ,cInt
+ ,cFloat
+ ,cDouble
+ ,cPointer
+ ,cLong
+ ,cShort
+ ,cRange
+ ,cString
+} ChunkType;
+
+typedef enum {
+ oUnknown
+ ,oShort
+ ,oLong
+} OtherType;
+
+typedef enum {
+ sUnknown
+ ,sPercent /* last was '%' beginning a format */
+ ,sNormal /* ...somewhere in the middle */
+ ,sLeft /* last was left square bracket beginning a range */
+ ,sRange /* ...somewhere in the middle */
+ ,sFinal /* last finished a format */
+} ScanState;
+
+static ChunkType
+final_ch(int ch, OtherType other)
+{
+ ChunkType result = cUnknown;
+
+ switch (ch) {
+ case 'c':
+ if (other == oUnknown)
+ result = cChar;
+ else
+ result = cError;
+ break;
+ case 'd':
+ case 'i':
+ case 'X':
+ case 'x':
+ switch (other) {
+ case oUnknown:
+ result = cInt;
+ break;
+ case oShort:
+ result = cShort;
+ break;
+ case oLong:
+ result = cLong;
+ break;
+ }
+ break;
+ case 'E':
+ case 'e':
+ case 'f':
+ case 'g':
+ switch (other) {
+ case oUnknown:
+ result = cFloat;
+ break;
+ case oShort:
+ result = cError;
+ break;
+ case oLong:
+ result = cDouble;
+ break;
+ }
+ break;
+ case 'n':
+ if (other == oUnknown)
+ result = cAssigned;
+ else
+ result = cError;
+ break;
+ case 'p':
+ if (other == oUnknown)
+ result = cPointer;
+ else
+ result = cError;
+ break;
+ case 's':
+ if (other == oUnknown)
+ result = cString;
+ else
+ result = cError;
+ break;
+ }
+ return result;
+}
+
+static OtherType
+other_ch(int ch)
+{
+ OtherType result = oUnknown;
+ switch (ch) {
+ case 'h':
+ result = oShort;
+ break;
+ case 'l':
+ result = oLong;
+ break;
+ }
+ return result;
+}
+#endif
+
+/*VARARGS2*/
+NCURSES_EXPORT(int)
+vsscanf(const char *str, const char *format, va_list ap)
+{
+#if HAVE_VFSCANF || HAVE__DOSCAN
+ /*
+ * This code should work on anything descended from AT&T SVr1.
+ */
+ FILE strbuf;
+
+ strbuf._flag = _IOREAD;
+ strbuf._ptr = strbuf._base = (unsigned char *) str;
+ strbuf._cnt = strlen(str);
+ strbuf._file = _NFILE;
+
+#if HAVE_VFSCANF
+ return (vfscanf(&strbuf, format, ap));
+#else
+ return (_doscan(&strbuf, format, ap));
+#endif
+#else
+ static int can_convert = -1;
+
+ int assigned = 0;
+ int consumed = 0;
+
+ T((T_CALLED("vsscanf(%s,%s,...)"),
+ _nc_visbuf2(1, str),
+ _nc_visbuf2(2, format)));
+
+ /*
+ * This relies on having a working "%n" format conversion. Check if it
+ * works. Only very old C libraries do not support it.
+ *
+ * FIXME: move this check into the configure script.
+ */
+ if (can_convert < 0) {
+ int check1;
+ int check2;
+ if (sscanf("123", "%d%n", &check1, &check2) > 0
+ && check1 == 123
+ && check2 == 3) {
+ can_convert = 1;
+ } else {
+ can_convert = 0;
+ }
+ }
+
+ if (can_convert) {
+ size_t len_fmt = strlen(format) + 32;
+ char *my_fmt = malloc(len_fmt);
+ ChunkType chunk, ctest;
+ OtherType other, otest;
+ ScanState state;
+ unsigned n;
+ int eaten;
+ void *pointer;
+
+ if (my_fmt != 0) {
+ /*
+ * Split the original format into chunks, adding a "%n" to the end
+ * of each (except of course if it used %n), and use that
+ * information to decide where to start scanning the next chunk.
+ *
+ * FIXME: does %n count bytes or characters? If the latter, this
+ * will require further work for multibyte strings.
+ */
+ while (*format != '\0') {
+ /* find a chunk */
+ state = sUnknown;
+ chunk = cUnknown;
+ other = oUnknown;
+ pointer = 0;
+ for (n = 0; format[n] != 0 && state != sFinal; ++n) {
+ my_fmt[n] = format[n];
+ switch (state) {
+ case sUnknown:
+ if (format[n] == '%')
+ state = sPercent;
+ break;
+ case sPercent:
+ if (format[n] == '%') {
+ state = sUnknown;
+ } else if (format[n] == L_SQUARE) {
+ state = sLeft;
+ } else {
+ state = sNormal;
+ --n;
+ }
+ break;
+ case sLeft:
+ state = sRange;
+ if (format[n] == '^') {
+ ++n;
+ my_fmt[n] = format[n];
+ }
+ break;
+ case sRange:
+ if (format[n] == R_SQUARE) {
+ state = sFinal;
+ chunk = cRange;
+ }
+ break;
+ case sNormal:
+ if (format[n] == '*') {
+ state = sUnknown;
+ } else {
+ if ((ctest = final_ch(format[n], other)) != cUnknown) {
+ state = sFinal;
+ chunk = ctest;
+ } else if ((otest = other_ch(format[n])) != oUnknown) {
+ other = otest;
+ } else if (isalpha(UChar(format[n]))) {
+ state = sFinal;
+ chunk = cError;
+ }
+ }
+ break;
+ case sFinal:
+ break;
+ }
+ }
+ my_fmt[n] = '\0';
+ format += n;
+
+ if (chunk == cUnknown
+ || chunk == cError) {
+ if (assigned == 0)
+ assigned = EOF;
+ break;
+ }
+
+ /* add %n, if the format was not that */
+ if (chunk != cAssigned) {
+ strlcat(my_fmt, "%n", len_fmt);
+ }
+
+ switch (chunk) {
+ case cAssigned:
+ strlcat(my_fmt, "%n", len_fmt);
+ pointer = &eaten;
+ break;
+ case cInt:
+ pointer = va_arg(ap, int *);
+ break;
+ case cShort:
+ pointer = va_arg(ap, short *);
+ break;
+ case cFloat:
+ pointer = va_arg(ap, float *);
+ break;
+ case cDouble:
+ pointer = va_arg(ap, double *);
+ break;
+ case cLong:
+ pointer = va_arg(ap, long *);
+ break;
+ case cPointer:
+ pointer = va_arg(ap, void *);
+ break;
+ case cChar:
+ case cRange:
+ case cString:
+ pointer = va_arg(ap, char *);
+ break;
+ case cError:
+ case cUnknown:
+ break;
+ }
+ /* do the conversion */
+ T(("...converting chunk #%d type %d(%s,%s)",
+ assigned + 1, chunk,
+ _nc_visbuf2(1, str + consumed),
+ _nc_visbuf2(2, my_fmt)));
+ if (sscanf(str + consumed, my_fmt, pointer, &eaten) > 0)
+ consumed += eaten;
+ else
+ break;
+ ++assigned;
+ }
+ free(my_fmt);
+ }
+ }
+ returnCode(assigned);
+#endif
+}
+#else
+extern
+NCURSES_EXPORT(void)
+_nc_vsscanf(void); /* quiet's gcc warning */
+NCURSES_EXPORT(void)
+_nc_vsscanf(void)
+{
+} /* nonempty for strict ANSI compilers */
+#endif /* !HAVE_VSSCANF */
diff --git a/lib/libcurses/base/wresize.c b/lib/libcurses/base/wresize.c
index d513f29b9d3..ef4a91e7150 100644
--- a/lib/libcurses/base/wresize.c
+++ b/lib/libcurses/base/wresize.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: wresize.c,v 1.4 2001/01/22 18:01:49 millert Exp $ */
+/* $OpenBSD: wresize.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,40 +29,82 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey 1996-2002 *
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$From: wresize.c,v 1.18 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
+
+static int
+cleanup_lines(struct ldat *data, int length)
+{
+ while (--length >= 0)
+ free(data[length].text);
+ free(data);
+ return ERR;
+}
+
+/*
+ * If we have reallocated the ldat structs, we will have to repair pointers
+ * used in subwindows.
+ */
+static void
+repair_subwindows(WINDOW *cmp)
+{
+ WINDOWLIST *wp;
+ struct ldat *pline = cmp->_line;
+ int row;
+
+ _nc_lock_global(curses);
+
+ for (each_window(wp)) {
+ WINDOW *tst = &(wp->win);
+
+ if (tst->_parent == cmp) {
+
+ if (tst->_pary > cmp->_maxy)
+ tst->_pary = cmp->_maxy;
+ if (tst->_parx > cmp->_maxx)
+ tst->_parx = cmp->_maxx;
+
+ if (tst->_maxy + tst->_pary > cmp->_maxy)
+ tst->_maxy = cmp->_maxy - tst->_pary;
+ if (tst->_maxx + tst->_parx > cmp->_maxx)
+ tst->_maxx = cmp->_maxx - tst->_parx;
+
+ for (row = 0; row <= tst->_maxy; ++row) {
+ tst->_line[row].text = &pline[tst->_pary + row].text[tst->_parx];
+ }
+ repair_subwindows(tst);
+ }
+ }
+ _nc_unlock_global(curses);
+}
/*
* Reallocate a curses WINDOW struct to either shrink or grow to the specified
* new lines/columns. If it grows, the new character cells are filled with
* blanks. The application is responsible for repainting the blank area.
*/
-
-#define DOALLOC(p,t,n) typeRealloc(t, n, p)
-#define ld_ALLOC(p,n) DOALLOC(p,struct ldat,n)
-#define c_ALLOC(p,n) DOALLOC(p,chtype,n)
-
NCURSES_EXPORT(int)
wresize(WINDOW *win, int ToLines, int ToCols)
{
- register int row;
- int size_x, size_y;
+ int col, row, size_x, size_y;
struct ldat *pline;
- chtype blank;
+ struct ldat *new_lines = 0;
#ifdef TRACE
T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
if (win) {
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
+ TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)",
+ (long) win->_begy, (long) win->_begx,
+ (long) win->_maxy, (long) win->_maxx,
+ (long) win->_regtop, (long) win->_regbottom));
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("...before", win);
+ _nc_unlock_global(tracef);
+ }
}
#endif
@@ -92,65 +134,82 @@ wresize(WINDOW *win, int ToLines, int ToCols)
}
/*
- * If the number of lines has changed, adjust the size of the overall
- * vector:
+ * Allocate new memory as needed. Do the allocations without modifying
+ * the original window, in case an allocation fails. Always allocate
+ * (at least temporarily) the array pointing to the individual lines.
*/
- if (ToLines != size_y) {
+ new_lines = typeCalloc(struct ldat, (unsigned) (ToLines + 1));
+ if (new_lines == 0)
+ returnCode(ERR);
+
+ /*
+ * For each line in the target, allocate or adjust pointers for the
+ * corresponding text, depending on whether this is a window or a
+ * subwindow.
+ */
+ for (row = 0; row <= ToLines; ++row) {
+ int begin = (row > size_y) ? 0 : (size_x + 1);
+ int end = ToCols;
+ NCURSES_CH_T *s;
+
if (!(win->_flags & _SUBWIN)) {
- for (row = ToLines + 1; row <= size_y; row++)
- free((char *) (win->_line[row].text));
+ if (row <= size_y) {
+ if (ToCols != size_x) {
+ if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0)
+ returnCode(cleanup_lines(new_lines, row));
+ for (col = 0; col <= ToCols; ++col) {
+ s[col] = (col <= size_x
+ ? win->_line[row].text[col]
+ : win->_nc_bkgd);
+ }
+ } else {
+ s = win->_line[row].text;
+ }
+ } else {
+ if ((s = typeMalloc(NCURSES_CH_T, ToCols + 1)) == 0)
+ returnCode(cleanup_lines(new_lines, row));
+ for (col = 0; col <= ToCols; ++col)
+ s[col] = win->_nc_bkgd;
+ }
+ } else {
+ s = &pline[win->_pary + row].text[win->_parx];
}
- win->_line = ld_ALLOC(win->_line, ToLines + 1);
- if (win->_line == 0)
- returnCode(ERR);
-
- for (row = size_y + 1; row <= ToLines; row++) {
- win->_line[row].text = 0;
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
- if ((win->_flags & _SUBWIN)) {
- win->_line[row].text =
- &pline[win->_pary + row].text[win->_parx];
+ if_USE_SCROLL_HINTS(new_lines[row].oldindex = row);
+ if (row <= size_y) {
+ new_lines[row].firstchar = win->_line[row].firstchar;
+ new_lines[row].lastchar = win->_line[row].lastchar;
+ }
+ if ((ToCols != size_x) || (row > size_y)) {
+ if (end >= begin) { /* growing */
+ if (new_lines[row].firstchar < begin)
+ new_lines[row].firstchar = begin;
+ } else { /* shrinking */
+ new_lines[row].firstchar = 0;
}
+ new_lines[row].lastchar = ToCols;
}
+ new_lines[row].text = s;
}
/*
- * Adjust the width of the columns:
+ * Dispose of unwanted memory.
*/
- blank = _nc_background(win);
- for (row = 0; row <= ToLines; row++) {
- chtype *s = win->_line[row].text;
- int begin = (s == 0) ? 0 : size_x + 1;
- int end = ToCols;
-
- if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
-
- if (ToCols != size_x || s == 0) {
- if (!(win->_flags & _SUBWIN)) {
- win->_line[row].text = s = c_ALLOC(s, ToCols + 1);
- if (win->_line[row].text == 0)
- returnCode(ERR);
- } else if (s == 0) {
- win->_line[row].text = s =
- &pline[win->_pary + row].text[win->_parx];
+ if (!(win->_flags & _SUBWIN)) {
+ if (ToCols == size_x) {
+ for (row = ToLines + 1; row <= size_y; row++) {
+ free(win->_line[row].text);
}
-
- if (end >= begin) { /* growing */
- if (win->_line[row].firstchar < begin)
- win->_line[row].firstchar = begin;
- win->_line[row].lastchar = ToCols;
- do {
- s[end] = blank;
- } while (--end >= begin);
- } else { /* shrinking */
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
+ } else {
+ for (row = 0; row <= size_y; row++) {
+ free(win->_line[row].text);
}
}
}
+ free(win->_line);
+ win->_line = new_lines;
+
/*
* Finally, adjust the parameters showing screen size and cursor
* position:
@@ -169,13 +228,21 @@ wresize(WINDOW *win, int ToLines, int ToCols)
if (win->_cury > win->_maxy)
win->_cury = win->_maxy;
+ /*
+ * Check for subwindows of this one, and readjust pointers to our text,
+ * if needed.
+ */
+ repair_subwindows(win);
+
#ifdef TRACE
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
+ TR(TRACE_UPDATE, ("...beg (%ld, %ld), max(%ld,%ld), reg(%ld,%ld)",
+ (long) win->_begy, (long) win->_begx,
+ (long) win->_maxy, (long) win->_maxx,
+ (long) win->_regtop, (long) win->_regbottom));
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracedump("...after:", win);
+ _nc_unlock_global(tracef);
+ }
#endif
returnCode(OK);
}
diff --git a/lib/libcurses/capdefaults.c b/lib/libcurses/capdefaults.c
index 4f1ec7e5e42..95c21c7d4a4 100644
--- a/lib/libcurses/capdefaults.c
+++ b/lib/libcurses/capdefaults.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: capdefaults.c,v 1.3 2010/01/12 23:21:58 nicm Exp $ */
+
/****************************************************************************
- * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,10 +31,10 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $OpenBSD: capdefaults.c,v 1.2 2000/01/02 22:06:50 millert Exp $ */
-/* $From: capdefaults.c,v 1.12 2000/01/02 02:34:56 tom Exp $ */
+/* $Id: capdefaults.c,v 1.3 2010/01/12 23:21:58 nicm Exp $ */
/*
* Compute obsolete capabilities. The reason this is an include file is
@@ -45,9 +47,10 @@
*/
{
char *sp;
- int capval;
+ short capval;
-#define EXTRACT_DELAY(str) (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0)
+#define EXTRACT_DELAY(str) \
+ (short) (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0)
/* current (4.4BSD) capabilities marked obsolete */
if (VALID_STRING(carriage_return)
@@ -74,8 +77,8 @@
magic_cookie_glitch_ul = magic_cookie_glitch;
/* totally obsolete capabilities */
- linefeed_is_newline = VALID_STRING(newline)
- && (strcmp("\n", newline) == 0);
+ linefeed_is_newline = (char) (VALID_STRING(newline)
+ && (strcmp("\n", newline) == 0));
if (VALID_STRING(cursor_left)
&& (capval = EXTRACT_DELAY(cursor_left)))
backspace_delay = capval;
diff --git a/lib/libcurses/curs_addch.3tbl b/lib/libcurses/curs_addch.3tbl
index 4405acbd180..dfb44b95320 100644
--- a/lib/libcurses/curs_addch.3tbl
+++ b/lib/libcurses/curs_addch.3tbl
@@ -1,8 +1,8 @@
-'\" t
-.\" $OpenBSD: curs_addch.3tbl,v 1.10 2003/05/12 11:06:49 jmc Exp $
-.\"
+'\" t
+.\" $OpenBSD: curs_addch.3tbl,v 1.11 2010/01/12 23:21:58 nicm Exp $
+.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_addch.3x,v 1.17 2000/07/01 19:53:01 tom Exp $
+.\" $Id: curs_addch.3tbl,v 1.11 2010/01/12 23:21:58 nicm Exp $
.TH curs_addch 3 ""
.SH NAME
\fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR,
@@ -37,18 +37,18 @@
\fBwechochar\fR - add a character (with attributes) to a \fBcurses\fR window, then advance the cursor
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
-\fBint addch(chtype ch);\fR
+.PP
+\fBint addch(const chtype ch);\fR
.br
-\fBint waddch(WINDOW *win, chtype ch);\fR
+\fBint waddch(WINDOW *win, const chtype ch);\fR
.br
-\fBint mvaddch(int y, int x, chtype ch);\fR
+\fBint mvaddch(int y, int x, const chtype ch);\fR
.br
-\fBint mvwaddch(WINDOW *win, int y, int x, chtype ch);\fR
+\fBint mvwaddch(WINDOW *win, int y, int x, const chtype ch);\fR
.br
-\fBint echochar(chtype ch);\fR
+\fBint echochar(const chtype ch);\fR
.br
-\fBint wechochar(WINDOW *win, chtype ch);\fR
+\fBint wechochar(WINDOW *win, const chtype ch);\fR
.br
.SH DESCRIPTION
The \fBaddch\fR, \fBwaddch\fR, \fBmvaddch\fR and \fBmvwaddch\fR routines put
@@ -57,25 +57,29 @@ which is then advanced. They are analogous to \fBputchar\fR in \fBstdio\fR(3).
If the advance is at the right margin, the cursor automatically wraps to the
beginning of the next line. At the bottom of the current scrolling region, if
\fBscrollok\fR is enabled, the scrolling region is scrolled up one line.
-
-If \fIch\fR is a tab, newline, or backspace, the cursor is moved appropriately
-within the window. Backspace moves the cursor one character left; at the left
-edge of a window it does nothing. Newline does a \fBclrtoeol\fR, then moves
-the cursor to the window left margin on the next line, scrolling the window if
-on the last line. Tabs are considered to be at every eighth column.
-
+.PP
+If \fIch\fR is a tab, newline, or backspace,
+the cursor is moved appropriately within the window.
+Backspace moves the cursor one character left; at the left
+edge of a window it does nothing.
+Newline does a \fBclrtoeol\fR,
+then moves the cursor to the window left margin on the next line,
+scrolling the window if on the last line.
+Tabs are considered to be at every eighth column.
+The tab interval may be altered by setting the \fBTABSIZE\fR variable.
+.PP
If \fIch\fR is any control character other than tab, newline, or backspace, it
is drawn in \fB^\fR\fIX\fR notation. Calling \fBwinch\fR after adding a
control character does not return the character itself, but instead returns
the ^-representation of the control character.
-
+.PP
Video attributes can be combined with a character argument passed to
\fBaddch\fR or related functions by logical-ORing them into the character.
(Thus, text, including attributes, can be copied from one place to another
using \fBinch\fR and \fBaddch\fR.) See the \fBcurs_attr\fR(3) page for
values of predefined video attribute constants that can be usefully OR'ed
into characters.
-
+.PP
The \fBechochar\fR and \fBwechochar\fR routines are equivalent to a call to
\fBaddch\fR followed by a call to \fBrefresh\fR, or a call to \fBwaddch\fR
followed by a call to \fBwrefresh\fR. The knowledge that only a single
@@ -85,10 +89,10 @@ their equivalents.
.SS Line Graphics
The following variables may be used to add line drawing characters to the
screen with routines of the \fBaddch\fR family. The default character listed
-below is used if the \fBacsc\fR capability doesn't define a terminal-specific
-replacement for it (but see the EXTENSIONS section below). The names are
-taken from VT100 nomenclature.
-
+below is used if the \fBacsc\fR capability does not define a terminal-specific
+replacement for it.
+The names are taken from VT100 nomenclature.
+.PP
.TS
l l l
_ _ _
@@ -127,7 +131,6 @@ ACS_ULCORNER + upper left-hand corner
ACS_URCORNER + upper right-hand corner
ACS_VLINE | vertical line
.TE
-
.SH RETURN VALUE
All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
@@ -139,7 +142,7 @@ Note that \fBaddch\fR, \fBmvaddch\fR, \fBmvwaddch\fR, and
.SH PORTABILITY
All these functions are described in the XSI Curses standard, Issue 4.
The defaults specified for forms-drawing characters apply in the POSIX locale.
-
+.LP
Some ACS symbols
(ACS_S3,
ACS_S7,
@@ -153,10 +156,25 @@ any publicly released System V. However, many publicly available terminfos
include \fBacsc\fR strings in which their key characters (pryz{|}) are
embedded, and a second-hand list of their character descriptions has come
to light. The ACS-prefixed names for them were invented for \fBncurses\fR(3).
+.LP
+The \fBTABSIZE\fR variable is implemented in some versions of curses,
+but is not part of X/Open curses.
+.LP
+If \fIch\fR is a carriage return,
+the cursor is moved to the beginning of the current row of the window.
+This is true of other implementations, but is not documented.
.SH SEE ALSO
-\fBcurses\fR(3), \fBcurs_attr\fR(3), \fBcurs_clear\fR(3),
-\fBcurs_inch\fR(3), \fBcurs_outopts\fR(3), \fBcurs_refresh\fR(3),
+\fBcurses\fR(3),
+\fBcurs_attr\fR(3),
+\fBcurs_clear\fR(3),
+\fBcurs_inch\fR(3),
+\fBcurs_outopts\fR(3),
+\fBcurs_refresh\fR(3),
\fBputc\fR(3).
+.PP
+Comparable functions in the wide-character (ncursesw) library are
+described in
+\fBcurs_add_wch\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_addchstr.3 b/lib/libcurses/curs_addchstr.3
index f58a9021406..d291af1c54d 100644
--- a/lib/libcurses/curs_addchstr.3
+++ b/lib/libcurses/curs_addchstr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_addchstr.3,v 1.8 2004/12/10 03:54:19 jaredy Exp $
+.\" $OpenBSD: curs_addchstr.3,v 1.9 2010/01/12 23:21:58 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,15 +28,24 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_addchstr.3x,v 1.7 2000/07/01 19:53:33 tom Exp $
+.\" $Id: curs_addchstr.3,v 1.9 2010/01/12 23:21:58 nicm Exp $
.TH curs_addchstr 3 ""
+.na
+.hy 0
.SH NAME
-\fBaddchstr\fR, \fBaddchnstr\fR, \fBwaddchstr\fR,
-\fBwaddchnstr\fR, \fBmvaddchstr\fR, \fBmvaddchnstr\fR, \fBmvwaddchstr\fR,
+\fBaddchstr\fR,
+\fBaddchnstr\fR,
+\fBwaddchstr\fR,
+\fBwaddchnstr\fR,
+\fBmvaddchstr\fR,
+\fBmvaddchnstr\fR,
+\fBmvwaddchstr\fR,
\fBmvwaddchnstr\fR - add a string of characters (and attributes) to a \fBcurses\fR window
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.PP
\fBint addchstr(const chtype *chstr);\fR
.br
\fBint addchnstr(const chtype *chstr, int n);\fR
@@ -58,25 +67,32 @@ the current cursor position. The four routines with \fIn\fR as the last
argument copy at most \fIn\fR elements, but no more than will fit on the line.
If \fBn\fR=\fB-1\fR then the whole string is copied, to the maximum number of
characters that will fit on the line.
-
+.PP
The window cursor is \fInot\fR advanced, and these routines work faster than
-\fBwaddnstr\fR. On the other hand, they don't perform any kind of checking
-(such as for the newline, backspace, or carriage return characters), they don't
-advance the current cursor position, they don't expand other control characters
+\fBwaddnstr\fR. On the other hand, they do not perform any kind of checking
+(such as for the newline, backspace, or carriage return characters), they do not
+advance the current cursor position, they do not expand other control characters
to ^-escapes, and they truncate the string if it crosses the right margin,
rather than wrapping it around to the new line.
-
.SH RETURN VALUES
All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
successful completion, unless otherwise noted in the preceding routine
descriptions.
+.PP
+X/Open does not define any error conditions.
+This implementation returns an error
+if the window pointer is null.
.SH NOTES
Note that all routines except \fBwaddchnstr\fR may be macros.
.SH PORTABILITY
-All these entry points are described in the XSI Curses standard, Issue 4.
+These entry points are described in the XSI Curses standard, Issue 4.
.SH SEE ALSO
\fBcurses\fR(3).
+.PP
+Comparable functions in the wide-character (ncursesw) library are
+described in
+\fBcurs_add_wchstr\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_addstr.3 b/lib/libcurses/curs_addstr.3
index 33541a4de2d..d1815f117c0 100644
--- a/lib/libcurses/curs_addstr.3
+++ b/lib/libcurses/curs_addstr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_addstr.3,v 1.6 2000/07/10 03:06:04 millert Exp $
+.\" $OpenBSD: curs_addstr.3,v 1.7 2010/01/12 23:21:58 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_addstr.3x,v 1.9 2000/07/01 19:54:05 tom Exp $
+.\" $Id: curs_addstr.3,v 1.7 2010/01/12 23:21:58 nicm Exp $
.TH curs_addstr 3 ""
+.na
+.hy 0
.SH NAME
\fBaddstr\fR,
\fBaddnstr\fR,
@@ -39,34 +41,47 @@
\fBmvaddnstr\fR,
\fBmvwaddstr\fR,
\fBmvwaddnstr\fR - add a string of characters to a \fBcurses\fR window and advance cursor
+.ad
+.hy
.SH SYNOPSIS
+.nf
\fB#include <curses.h>\fR
-
-\fBint addstr(const char *str);\fR
+.PP
+\fBint addstr(const char *\fR\fIstr\fR\fB);\fR
.br
-\fBint addnstr(const char *str, int n);\fR
+\fBint addnstr(const char *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR
.br
-\fBint waddstr(WINDOW *win, const char *str);\fR
+\fBint waddstr(WINDOW *\fR\fIwin\fR\fB, const char *\fR\fIstr\fR\fB);\fR
.br
-\fBint waddnstr(WINDOW *win, const char *str, int n);\fR
+\fBint waddnstr(WINDOW *\fR\fIwin\fR\fB, const char *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR
.br
-\fBint mvaddstr(int y, int x, const char *str);\fR
+\fBint mvaddstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr\fR\fB);\fR
.br
-\fBint mvaddnstr(int y, int x, const char *str, int n);\fR
+\fBint mvaddnstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr\fR\fB, int \fR\fIn\fR\fB);\fR
.br
-\fBint mvwaddstr(WINDOW *win, int y, int x, const char *str);\fR
+\fBint mvwaddstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr\fR\fB);\fR
.br
-\fBint mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);\fR
+\fBint mvwaddnstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const char *\fR\fIstr, int \fR\fIn\fR\fB);\fR
+.fi
.SH DESCRIPTION
These routines write the characters of the (null-terminated) character string
-\fIstr\fR on the given window. It is similar to calling \fBwaddch\fR once for
-each character in the string. The four routines with \fIn\fR as the last
-argument write at most \fIn\fR characters. If \fIn\fR is -1, then the
-entire string will be added.
+\fIstr\fR on the given window.
+It is similar to calling \fBwaddch\fR once for each character in the string.
+The four routines with \fIn\fR as the last argument
+write at most \fIn\fR characters.
+If \fIn\fR is -1, then the entire string will be added,
+up to the maximum number of characters that will fit on the line,
+or until a terminating null is reached.
.SH RETURN VALUE
All routines return the integer \fBERR\fR upon failure and \fBOK\fR on success
(the SVr4 manuals specify only "an integer value other than \fBERR\fR") upon
successful completion.
+.PP
+X/Open does not define any error conditions.
+This implementation returns an error
+if the window pointer is null or
+if the string pointer is null or
+if the corresponding calls to \fBwaddch\fP return an error.
.SH NOTES
Note that all of these routines except \fBwaddstr\fR and \fBwaddnstr\fR may be
macros.
diff --git a/lib/libcurses/curs_attr.3tbl b/lib/libcurses/curs_attr.3tbl
index 0882fa30732..faa8b3e6f44 100644
--- a/lib/libcurses/curs_attr.3tbl
+++ b/lib/libcurses/curs_attr.3tbl
@@ -1,8 +1,8 @@
-'\" t
-.\" $OpenBSD: curs_attr.3tbl,v 1.9 2000/07/10 03:06:04 millert Exp $
+'\" t
+.\" $OpenBSD: curs_attr.3tbl,v 1.10 2010/01/12 23:21:58 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,19 +29,38 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_attr.3x,v 1.22 2000/07/08 11:59:58 tom Exp $
+.\" $Id: curs_attr.3tbl,v 1.10 2010/01/12 23:21:58 nicm Exp $
.TH curs_attr 3 ""
+.na
+.hy 0
.SH NAME
-\fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
-\fBattrset\fR, \fBwattrset\fR, \fBcolor_set\fR, \fBwcolor_set\fR,
-\fBstandend\fR, \fBwstandend\fR, \fBstandout\fR, \fBwstandout\fR,
-\fBattr_get\fR, \fBwattr_get\fR,
-\fBattr_off\fR, \fBwattr_off\fR,
-\fBattr_on\fR, \fBwattr_on\fR,
-\fBattr_set\fR, \fBwattr_set\fR,
-\fBchgat\fR, \fBwchgat\fR,
-\fBmvchgat\fR, \fBmvwchgat\fR,
+\fBattroff\fR,
+\fBwattroff\fR,
+\fBattron\fR,
+\fBwattron\fR,
+\fBattrset\fR,
+\fBwattrset\fR,
+\fBcolor_set\fR,
+\fBwcolor_set\fR,
+\fBstandend\fR,
+\fBwstandend\fR,
+\fBstandout\fR,
+\fBwstandout\fR,
+\fBattr_get\fR,
+\fBwattr_get\fR,
+\fBattr_off\fR,
+\fBwattr_off\fR,
+\fBattr_on\fR,
+\fBwattr_on\fR,
+\fBattr_set\fR,
+\fBwattr_set\fR,
+\fBchgat\fR,
+\fBwchgat\fR,
+\fBmvchgat\fR,
+\fBmvwchgat\fR,
\fBPAIR_NUMBER\fR - \fBcurses\fR character and window attribute control routines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
.br
@@ -107,7 +126,7 @@ a property of the character, and move with the character through any scrolling
and insert/delete line/character operations. To the extent possible, they are
displayed as appropriate modifications to the graphic rendition of characters
put on the screen.
-
+.PP
The routine \fBattrset\fR sets the current attributes of the given window to
\fIattrs\fR. The routine \fBattroff\fR turns off the named attributes without
turning any other attributes on or off. The routine \fBattron\fR turns on the
@@ -115,19 +134,24 @@ named attributes without affecting any others. The routine \fBstandout\fR is
the same as \fBattron(A_STANDOUT)\fR. The routine \fBstandend\fR is the same
as \fBattrset(A_NORMAL)\fR or \fBattrset(0)\fR, that is, it turns off all
attributes.
-
+.PP
+The \fBattrset\fR and related routines do not affect the attributes used
+when erasing portions of the window.
+See \fBcurs_bkgd\fR(3) for functions which modify the attributes used for
+erasing and clearing.
+.PP
The routine \fBcolor_set\fR sets the current color of the given window to the
foreground/background combination described by the color_pair_number. The
parameter opts is reserved for future use, applications must supply a null
pointer.
-
+.PP
The routine \fBwattr_get\fR returns the current attribute and color pair for
the given window; \fBattr_get\fR returns the current attribute and color pair
for \fBstdscr\fR.
The remaining \fBattr_\fR* functions operate exactly like the corresponding
\fBattr\fR* functions, except that they take arguments of type \fBattr_t\fR
rather than \fBint\fR.
-
+.PP
The routine \fBchgat\fR changes the attributes of a given number of characters
starting at the current cursor location of \fBstdscr\fR. It does not update
the cursor and does not perform wrapping. A character count of -1 or greater
@@ -139,9 +163,9 @@ of \fIinit_pair\fR, see \fBcurs_color\fR(3)). The \fBopts\fR argument is not
presently used, but is reserved for the future (leave it \fBNULL\fR).
.SS Attributes
The following video attributes, defined in \fB<curses.h>\fR, can be passed to
-the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR'ed with the
+the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR'd with the
characters passed to \fBaddch\fR.
-
+.PP
.TS
center ;
l l .
@@ -158,39 +182,49 @@ l l .
\fBA_CHARTEXT\fR Bit-mask to extract a character
\fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR Color-pair number \fIn\fR
.TE
-
+.PP
The following macro is the reverse of \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR:
-
-.DS C
+.PP
+.br
\fBPAIR_NUMBER(\fR\fIattrs\fR) Returns the pair number associated
with the \fBCOLOR_PAIR(\fR\fIn\fR\fB)\fR attribute.
-.DE
-
+.br
+.PP
The return values of many of these routines are not meaningful (they are
implemented as macro-expanded assignments and simply return their argument).
The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
-
.SH NOTES
Note that \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
\fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR may be macros.
+.PP
+\fBCOLOR_PAIR\fP values can only be OR'd with attributes if the pair
+number is less than 256.
+The alternate functions such as \fBcolor_set\fP can pass a color pair
+value directly.
+However, ncurses ABI 4 and 5 simply OR this value within the alternate functions.
+You must use ncurses ABI 6 to support more than 256 color pairs.
.SH PORTABILITY
-All these functions are supported in the XSI Curses standard, Issue 4. The
+These functions are supported in the XSI Curses standard, Issue 4. The
standard defined the dedicated type for highlights, \fBattr_t\fR, which is not
defined in SVr4 curses. The functions taking \fBattr_t\fR arguments are
not supported under SVr4.
-
+.PP
The XSI Curses standard states that whether the traditional functions
\fBattron\fR/\fBattroff\fR/\fBattrset\fR can manipulate attributes other than
\fBA_BLINK\fR, \fBA_BOLD\fR, \fBA_DIM\fR, \fBA_REVERSE\fR, \fBA_STANDOUT\fR, or
\fBA_UNDERLINE\fR is "unspecified". Under this implementation as well as
SVr4 curses, these functions correctly manipulate all other highlights
(specifically, \fBA_ALTCHARSET\fR, \fBA_PROTECT\fR, and \fBA_INVIS\fR).
-
+.PP
XSI Curses added the new entry points, \fBattr_get\fR, \fBattr_on\fR,
\fBattr_off\fR, \fBattr_set\fR, \fBwattr_on\fR, \fBwattr_off\fR,
\fBwattr_get\fR, \fBwattr_set\fR. These are intended to work with
a new series of highlight macros prefixed with \fBWA_\fR.
-
+.PP
+Older versions of this library did not force an update of the screen
+when changing the attributes.
+Use \fBtouchwin\fR to force the screen to match the updated attributes.
+.PP
.TS
center ;
l l .
@@ -203,17 +237,32 @@ l l .
\fBWA_BOLD\fR Extra bright or bold
\fBWA_ALTCHARSET\fR Alternate character set
.TE
-
+.PP
The XSI curses standard specifies that each pair of corresponding \fBA_\fR
and \fBWA_\fR-using functions operates on the same current-highlight
information.
-
+.PP
The XSI standard extended conformance level adds new highlights
\fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
\fBA_VERTICAL\fR (and corresponding \fBWA_\fR macros for each) which this
-curses does not yet support.
+implementation does not yet support.
+.SH RETURN VALUE
+All routines return the integer \fBOK\fR on success, or \fBERR\fP on failure.
+.PP
+X/Open does not define any error conditions.
+.PP
+This implementation returns an error
+if the window pointer is null.
+The \fBwcolor_set\fP function returns an error if the color pair parameter
+is outside the range 0..COLOR_PAIRS-1.
+This implementation also provides
+\fBgetattrs\fR
+for compatibility with older versions of curses.
.SH SEE ALSO
-\fBcurses\fR(3), \fBcurs_addch\fR(3), \fBcurs_addstr\fR(3),
+\fBcurses\fR(3),
+\fBcurs_addch\fR(3),
+\fBcurs_addstr\fR(3),
+\fBcurs_bkgd\fR(3),
\fBcurs_printw\fR(3)
.\"#
.\"# The following sets edit modes for GNU EMACS
diff --git a/lib/libcurses/curs_beep.3 b/lib/libcurses/curs_beep.3
index 720ef140c81..66849875d19 100644
--- a/lib/libcurses/curs_beep.3
+++ b/lib/libcurses/curs_beep.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_beep.3,v 1.6 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_beep.3,v 1.7 2010/01/12 23:21:58 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,13 +28,13 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_beep.3x,v 1.7 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_beep.3,v 1.7 2010/01/12 23:21:58 nicm Exp $
.TH curs_beep 3 ""
.SH NAME
\fBbeep\fR, \fBflash\fR - \fBcurses\fR bell and screen flash routines
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.PP
\fBint beep(void);\fR
.br
\fBint flash(void);\fR
@@ -53,8 +53,8 @@ These routines return \fBOK\fR if they succeed in beeping or flashing,
SVr4's beep and flash routines always returned \fBOK\fR, so it was not
possible to tell when the beep or flash failed.
.SH PORTABILITY
-These functions are defined in the XSI Curses standard, Issue 4. Like SVr4, it
-specifies that they always return \fBOK\fR.
+These functions are described in the XSI Curses standard, Issue 4.
+Like SVr4, it specifies that they always return \fBOK\fR.
.SH SEE ALSO
\fBcurses\fR(3)
.\"#
diff --git a/lib/libcurses/curs_bkgd.3 b/lib/libcurses/curs_bkgd.3
index 024acb4da2c..6e1fc34fbea 100644
--- a/lib/libcurses/curs_bkgd.3
+++ b/lib/libcurses/curs_bkgd.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_bkgd.3,v 1.7 2000/07/10 03:06:05 millert Exp $
+.\" $OpenBSD: curs_bkgd.3,v 1.8 2010/01/12 23:21:58 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,27 +28,25 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_bkgd.3x,v 1.14 2000/07/01 17:39:31 tom Exp $
+.\" $Id: curs_bkgd.3,v 1.8 2010/01/12 23:21:58 nicm Exp $
.TH curs_bkgd 3 ""
.SH NAME
\fBbkgdset\fR, \fBwbkgdset\fR,
\fBbkgd\fR, \fBwbkgd\fR,
\fBgetbkgd\fR - \fBcurses\fR window background manipulation routines
-..
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
-\fBvoid bkgdset(const chtype ch);\fR
+.PP
+\fBvoid bkgdset(chtype ch);\fR
.br
-\fBvoid wbkgdset(WINDOW *win, const chtype ch);\fR
+\fBvoid wbkgdset(WINDOW *win, chtype ch);\fR
.br
-\fBint bkgd(const chtype ch);\fR
+\fBint bkgd(chtype ch);\fR
.br
-\fBint wbkgd(WINDOW *win, const chtype ch);\fR
+\fBint wbkgd(WINDOW *win, chtype ch);\fR
.br
\fBchtype getbkgd(WINDOW *win);\fR
.br
-..
.SH DESCRIPTION
The \fBbkgdset\fR and \fBwbkgdset\fR routines manipulate the
background of the named window.
@@ -60,42 +58,40 @@ the character and attribute parts of the background are combined with
the blank characters. The background becomes a property of the
character and moves with the character through any scrolling and
insert/delete line/character operations.
-
-To the extent possible on a
-particular terminal, the attribute part of the background is displayed
+.PP
+To the extent possible on a particular terminal,
+the attribute part of the background is displayed
as the graphic rendition of the character put on the screen.
-
+.PP
The \fBbkgd\fR and \fBwbkgd\fR functions
set the background property of the current or specified window
and then apply this setting to every character position in that window:
-
+.PP
.RS
The rendition of every character on the screen is changed to
the new background rendition.
-
+.PP
Wherever the former background character
appears, it is changed to the new background character.
.RE
-
+.PP
The \fBgetbkgd\fR function returns the given window's current background
character/attribute pair.
-..
.SH RETURN VALUE
The routines \fBbkgd\fR and \fBwbkgd\fR return the integer \fBOK\fR.
The SVr4.0 manual says "or a non-negative integer if \fBimmedok\fR is set",
but this appears to be an error.
-..
.SH NOTES
Note that \fBbkgdset\fR and \fBbkgd\fR may be macros.
-..
.SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4. The draft
-does not include \fBconst\fR qualifiers on the arguments. The standard
-specifies that \fBbkgd\fR and \fBwbkgd\fR return \fBERR\fR, on failure. but
-gives no failure conditions.
-..
+These functions are described in the XSI Curses standard, Issue 4.
+It specifies that \fBbkgd\fR and \fBwbkgd\fR return \fBERR\fR on failure.
+but gives no failure conditions.
.SH SEE ALSO
-\fBcurses\fR(3), \fBcurs_addch\fR(3), \fBcurs_outopts\fR(3)
+\fBcurses\fR(3),
+\fBcurs_addch\fR(3),
+\fBcurs_attr\fR(3),
+\fBcurs_outopts\fR(3)
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_bkgrnd.3 b/lib/libcurses/curs_bkgrnd.3
new file mode 100644
index 00000000000..89260b6ea5b
--- /dev/null
+++ b/lib/libcurses/curs_bkgrnd.3
@@ -0,0 +1,108 @@
+.\" $OpenBSD: curs_bkgrnd.3,v 1.1 2010/01/12 23:21:58 nicm Exp $
+.\"
+.\"***************************************************************************
+.\" Copyright (c) 2002-2004,2006 Free Software Foundation, Inc. *
+.\" *
+.\" Permission is hereby granted, free of charge, to any person obtaining a *
+.\" copy of this software and associated documentation files (the *
+.\" "Software"), to deal in the Software without restriction, including *
+.\" without limitation the rights to use, copy, modify, merge, publish, *
+.\" distribute, distribute with modifications, sublicense, and/or sell *
+.\" copies of the Software, and to permit persons to whom the Software is *
+.\" furnished to do so, subject to the following conditions: *
+.\" *
+.\" The above copyright notice and this permission notice shall be included *
+.\" in all copies or substantial portions of the Software. *
+.\" *
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+.\" *
+.\" Except as contained in this notice, the name(s) of the above copyright *
+.\" holders shall not be used in advertising or otherwise to promote the *
+.\" sale, use or other dealings in this Software without prior written *
+.\" authorization. *
+.\"***************************************************************************
+.\"
+.\" $Id: curs_bkgrnd.3,v 1.1 2010/01/12 23:21:58 nicm Exp $
+.TH curs_bkgrnd 3 ""
+.SH NAME
+\fBbkgrnd\fR,
+\fBwbkgrnd\fR,
+\fBbkgrndset\fR,
+\fBwbkgrndset\fR,
+\fBgetbkgrnd\fR,
+\fBwgetbkgrnd\fR \- \fBcurses\fR window complex background manipulation routines
+.SH SYNOPSIS
+.PP
+.B #include <curses.h>
+.sp
+\fBint bkgrnd(\fR\fB const cchar_t *\fR\fIwch\fR\fB);\fR
+.br
+\fBint wbkgrnd(\fR\fB WINDOW *\fR\fIwin\fR\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
+.br
+\fBvoid bkgrndset(const cchar_t *\fR\fIwch\fR \fB);\fR
+.br
+\fBvoid wbkgrndset(WINDOW *\fR\fIwin\fR\fB, const cchar_t *\fR\fIwch\fR\fB);\fR
+.br
+\fBint getbkgrnd(cchar_t *\fR\fIwch\fR\fB);\fR
+.br
+\fBint wgetbkgrnd(WINDOW *\fR\fIwin\fR\fB, cchar_t *\fR\fIwch\fR\fB);\fR
+.br
+.SH DESCRIPTION
+The \fBbkgrndset\fR and \fBwbkgrndset\fR routines manipulate the
+background of the named window.
+The window background is a \fBcchar_t\fR consisting of
+any combination of attributes (i.e., rendition) and a complex character.
+The attribute part of the background is combined (OR'ed) with all non-blank
+characters that are written into the window with \fBwaddch\fR. Both
+the character and attribute parts of the background are combined with
+the blank characters.
+The background becomes a property of the
+character and moves with the character through any scrolling and
+insert/delete line/character operations.
+.PP
+To the extent possible on a
+particular terminal, the attribute part of the background is displayed
+as the graphic rendition of the character put on the screen.
+.PP
+The \fBbkgrnd\fR and \fBwbkgrnd\fR functions
+set the background property of the current or specified window
+and then apply this setting to every character position in that window:
+.RS
+.PP
+The rendition of every character on the screen is changed to
+the new background rendition.
+.PP
+Wherever the former background character
+appears, it is changed to the new background character.
+.RE
+.PP
+The \fBgetbkgrnd\fR function returns the given window's current background
+character/attribute pair via the \fBwch\fR pointer.
+.
+.SH NOTES
+Note that
+\fBbkgrnd\fR,
+\fBbkgrndset\fR, and
+\fBgetbkgrnd\fR
+may be macros.
+.SH RETURN VALUES
+The \fBbkgrndset\fR and \fBwbkgrndset\fR routines do not return a value.
+.PP
+Upon successful completion, the other functions return \fBOK\fR.
+Otherwise, they return \fBERR\fR.
+A null window pointer is treated as an error.
+.SH SEE ALSO
+\fBcurses\fR(3),
+\fBcurs_bkgd\fR(3)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_border.3 b/lib/libcurses/curs_border.3
index 6bc6aecaed5..1ea0dc53044 100644
--- a/lib/libcurses/curs_border.3
+++ b/lib/libcurses/curs_border.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_border.3,v 1.10 2000/07/10 03:06:05 millert Exp $
+.\" $OpenBSD: curs_border.3,v 1.11 2010/01/12 23:21:58 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,14 +28,24 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_border.3x,v 1.14 2000/07/01 19:54:58 tom Exp $
+.\" $Id: curs_border.3,v 1.11 2010/01/12 23:21:58 nicm Exp $
.TH curs_border 3 ""
+.na
+.hy 0
.SH NAME
-\fBborder\fR, \fBwborder\fR, \fBbox\fR,
-\fBhline\fR, \fBwhline\fR,
-\fBvline\fR, \fBwvline\fR,
-\fBmvhline\fR, \fBmvwhline\fR,
-\fBmvvline\fR, \fBmvwvline\fR - create \fBcurses\fR borders, horizontal and vertical lines
+\fBborder\fR,
+\fBwborder\fR,
+\fBbox\fR,
+\fBhline\fR,
+\fBwhline\fR,
+\fBvline\fR,
+\fBwvline\fR,
+\fBmvhline\fR,
+\fBmvwhline\fR,
+\fBmvvline\fR,
+\fBmvwvline\fR - create \fBcurses\fR borders, horizontal and vertical lines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
.br
@@ -56,34 +66,67 @@
.br
\fBint wvline(WINDOW *win, chtype ch, int n);\fR
.br
-\fBmvhline(int y, int x, chtype ch, int n);\fR
+\fBint mvhline(int y, int x, chtype ch, int n);\fR
.br
-\fBmvwhline(WINDOW *, int y, int x, chtype ch, int n);\fR
+\fBint mvwhline(WINDOW *, int y, int x, chtype ch, int n);\fR
.br
\fBint mvvline(int y, int x, chtype ch, int n);\fR
.br
\fBint mvwvline(WINDOW *, int y, int x, chtype ch, int n);\fR
.br
.SH DESCRIPTION
-The \fBborder\fR, \fBwborder\fR and \fBbox\fR routines draw a box around the
-edges of a window. The argument \fIls\fR is a character and attributes used
-for the left side of the border, \fIrs\fR - right side, \fIts\fR - top side,
-\fIbs\fR - bottom side, \fItl\fR - top left-hand corner, \fItr\fR - top
-right-hand corner, \fIbl\fR - bottom left-hand corner, and \fIbr\fR - bottom
-right-hand corner. If any of these arguments is zero, then the following
-default values (defined in \fBcurses.h\fR) are used instead: \fBACS_VLINE\fR,
-\fBACS_VLINE\fR, \fBACS_HLINE\fR, \fBACS_HLINE\fR, \fB\fBACS_ULCORNER\fR,
-\fBACS_URCORNER\fR, \fBACS_LLCORNER\fR, \fBACS_LRCORNER\fR.
-
+The \fBborder\fR, \fBwborder\fR and \fBbox\fR routines
+draw a box around the edges of a window.
+Other than the window, each argument is a character with attributes:
+.sp
+.RS
+\fIls\fR - left side,
+.br
+\fIrs\fR - right side,
+.br
+\fIts\fR - top side,
+.br
+\fIbs\fR - bottom side,
+.br
+\fItl\fR - top left-hand corner,
+.br
+\fItr\fR - top right-hand corner,
+.br
+\fIbl\fR - bottom left-hand corner, and
+.br
+\fIbr\fR - bottom right-hand corner.
+.RE
+.PP
+If any of these arguments is zero, then the corresponding
+default values (defined in \fBcurses.h\fR) are used instead:
+.sp
+.RS
+\fBACS_VLINE\fR,
+.br
+\fBACS_VLINE\fR,
+.br
+\fBACS_HLINE\fR,
+.br
+\fBACS_HLINE\fR,
+.br
+\fBACS_ULCORNER\fR,
+.br
+\fBACS_URCORNER\fR,
+.br
+\fBACS_LLCORNER\fR,
+.br
+\fBACS_LRCORNER\fR.
+.RE
+.PP
\fBbox(\fR\fIwin\fR\fB, \fR\fIverch\fR\fB, \fR\fIhorch\fR\fB)\fR is a shorthand
for the following call: \fBwborder(\fR\fIwin\fR\fB,\fR \fIverch\fR\fB,\fR
\fIverch\fR\fB,\fR \fIhorch\fR\fB,\fR \fIhorch\fR\fB, 0, 0, 0, 0)\fR.
-
+.PP
The \fBhline\fR and \fBwhline\fR functions draw a horizontal (left to right)
line using \fIch\fR starting at the current cursor position in the window. The
current cursor position is not changed. The line is at most \fIn\fR characters
long, or as many as fit into the window.
-
+.PP
The \fBvline\fR and \fBwvline\fR functions draw a vertical (top to bottom) line
using \fIch\fR starting at the current cursor position in the window. The
current cursor position is not changed. The line is at most \fIn\fR characters
@@ -91,17 +134,19 @@ long, or as many as fit into the window.
.SH RETURN VALUE
All routines return the integer \fBOK\fR. The SVr4.0 manual says "or a
non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
+.PP
+X/Open does not define any error conditions.
+This implementation returns an error
+if the window pointer is null.
.SH NOTES
The borders generated by these functions are \fIinside\fR borders (this
is also true of SVr4 curses, though the fact is not documented).
-
+.PP
Note that \fBborder\fR and \fBbox\fR may be macros.
.SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4. Additional
-functions \fBmvhline\fR, \fBmvvline\fR, \fBmvwhline\fR, and \fBmvwvline\fR are
-described there which this implementation does not yet support. The standard
-specifies that they return \fBERR\fR on failure, but specifies no error
-conditions.
+These functions are described in the XSI Curses standard, Issue 4.
+The standard specifies that they return \fBERR\fR on failure,
+but specifies no error conditions.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_outopts\fR(3).
.\"#
diff --git a/lib/libcurses/curs_border_set.3 b/lib/libcurses/curs_border_set.3
new file mode 100644
index 00000000000..68194312be9
--- /dev/null
+++ b/lib/libcurses/curs_border_set.3
@@ -0,0 +1,209 @@
+.\" $OpenBSD: curs_border_set.3,v 1.1 2010/01/12 23:21:58 nicm Exp $
+.\"
+.\"***************************************************************************
+.\" Copyright (c) 2002-2004,2005 Free Software Foundation, Inc. *
+.\" *
+.\" Permission is hereby granted, free of charge, to any person obtaining a *
+.\" copy of this software and associated documentation files (the *
+.\" "Software"), to deal in the Software without restriction, including *
+.\" without limitation the rights to use, copy, modify, merge, publish, *
+.\" distribute, distribute with modifications, sublicense, and/or sell *
+.\" copies of the Software, and to permit persons to whom the Software is *
+.\" furnished to do so, subject to the following conditions: *
+.\" *
+.\" The above copyright notice and this permission notice shall be included *
+.\" in all copies or substantial portions of the Software. *
+.\" *
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+.\" *
+.\" Except as contained in this notice, the name(s) of the above copyright *
+.\" holders shall not be used in advertising or otherwise to promote the *
+.\" sale, use or other dealings in this Software without prior written *
+.\" authorization. *
+.\"***************************************************************************
+.\"
+.\" $Id: curs_border_set.3,v 1.1 2010/01/12 23:21:58 nicm Exp $
+.TH curs_border_set 3 ""
+.na
+.hy 0
+.SH NAME
+\fBborder_set\fR,
+\fBwborder_set\fR,
+\fBbox_set\fR,
+\fBhline_set\fR,
+\fBwhline_set\fR,
+\fBmvhline_set\fR,
+\fBmvwhline_set\fR,
+\fBvline_set\fR,
+\fBwvline_set\fR,
+\fBmvvline_set\fR,
+\fBmvwvline_set\fR \- create \fBcurses\fR borders or lines using complex characters and renditions
+.ad
+.hy
+.SH SYNOPSIS
+.PP
+\fB#include <curses.h>\fR
+.sp
+\fBint border_set(\fR
+ \fBconst cchar_t *\fR\fIls\fR, \fBconst cchar_t *\fR\fIrs\fR,
+ \fBconst cchar_t *\fR\fIts\fR, \fBconst cchar_t *\fR\fIbs\fR,
+ \fBconst cchar_t *\fR\fItl\fR, \fBconst cchar_t *\fR\fItr\fR,
+ \fBconst cchar_t *\fR\fIbl\fR, \fBconst cchar_t *\fR\fIbr\fR
+\fB);\fR
+.br
+\fBint wborder_set(\fR
+ \fBWINDOW *win\fR,
+ \fBconst cchar_t *\fR\fIls\fR, \fBconst cchar_t *\fR\fIrs\fR,
+ \fBconst cchar_t *\fR\fIts\fR, \fBconst cchar_t *\fR\fIbs\fR,
+ \fBconst cchar_t *\fR\fItl\fR, \fBconst cchar_t *\fR\fItr\fR,
+ \fBconst cchar_t *\fR\fIbl\fR, \fBconst cchar_t *\fR\fIbr\fR\fB);\fR
+.br
+\fBint box_set(\fR
+ \fBWINDOW *win\fR,
+ \fBconst cchar_t *\fR\fIverch\fR,
+ \fBconst cchar_t *\fR\fIhorch\fR\fB);\fR
+.br
+\fBint hline_set(\fR
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint whline_set(\fR
+ \fBWINDOW *\fR\fIwin\fR,
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint mvhline_set(\fR
+ \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint mvwhline_set(\fR
+ \fBWINDOW *\fR\fIwin\fR,
+ \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint vline_set(\fR
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint wvline_set(\fR
+ \fBWINDOW *\fR\fIwin\fR,
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint mvvline_set(\fR
+ \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+\fBint mvwvline_set(\fR
+ \fBWINDOW *\fR\fIwin\fR,
+ \fBint \fR\fIy\fR, \fBint \fR\fIx\fR,
+ \fBconst cchar_t *\fR\fIwch\fR, \fBint \fR\fIn\fR\fB);\fR
+.br
+.SH DESCRIPTION
+.PP
+The
+\fBborder_set\fR
+and
+\fBwborder_set\fR
+functions draw a border around the edges of the current or specified window.
+These functions do not change the cursor position, and do not wrap.
+.PP
+Other than the window, each argument is a complex character with attributes:
+.RS
+\fIls\fR - left side,
+.br
+\fIrs\fR - right side,
+.br
+\fIts\fR - top side,
+.br
+\fIbs\fR - bottom side,
+.br
+\fItl\fR - top left-hand corner,
+.br
+\fItr\fR - top right-hand corner,
+.br
+\fIbl\fR - bottom left-hand corner, and
+.br
+\fIbr\fR - bottom right-hand corner.
+.RE
+.PP
+If any of these arguments is zero, then the corresponding
+default values (defined in \fBcurses.h\fR) are used instead:
+.RS
+\fBWACS_VLINE\fR,
+.br
+\fBWACS_VLINE\fR,
+.br
+\fBWACS_HLINE\fR,
+.br
+\fBWACS_HLINE\fR,
+.br
+\fBWACS_ULCORNER\fR,
+.br
+\fBWACS_URCORNER\fR,
+.br
+\fBWACS_LLCORNER\fR, and
+.br
+\fBWACS_LRCORNER\fR.
+.RE
+.PP
+\fBbox_set(\fR\fIwin\fR, \fIverch\fR\fB, \fR\fIhorch\fR\fB);\fR
+is a shorthand for the following call:
+.PP
+\fBwborder_set(\fR\fIwin\fR\fB, \fR\fIverch\fR\fB, \fR\fIverch\fR\fB,\fR
+ \fIhorch\fR\fB, \fR\fIhorch\fR\fB, NULL, NULL, NULL, NULL);\fR
+.PP
+The
+\fB*line_set\fR
+functions use
+\fIwch\fR
+to draw a line starting at the current cursor position in the window.
+The line is at most \fIn\fR characters long or as many as fit into the window.
+The current cursor position is not changed.
+.PP
+The
+\fBhline_set\fR,
+\fBmvhline_set\fR,
+\fBmvwhline_set\fR, and
+\fBwhline_set\fR
+functions draw a line proceeding toward the last column of the same line.
+.PP
+The
+\fBvline_set\fR,
+\fBmvvline_set\fR,
+\fBmvwvline_set\fR, and
+\fBwvline_set\fR
+functions draw a line proceeding toward the last line of the window.
+.br
+.SH NOTES
+.PP
+Note that
+\fBborder_set\fR,
+\fBhline_set\fR,
+\fBmvhline_set\fR,
+\fBmvvline_set\fR,
+\fBmvwhline_set\fR,
+\fBmvwvline_set\fR, and
+\fBvline_set\fR
+may be macros.
+.br
+.SH RETURN VALUES
+.PP
+Upon successful completion, these functions return
+\fBOK\fR.
+Otherwise, they return
+\fBERR\fR.
+.PP
+Functions using a window parameter return an error if it is null.
+.SH SEE ALSO
+\fBncurses\fR(3),
+\fBcurs_border\fR(3),
+\fBcurs_outopts\fR(3)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_clear.3 b/lib/libcurses/curs_clear.3
index 063e709e717..cdf6af8dd70 100644
--- a/lib/libcurses/curs_clear.3
+++ b/lib/libcurses/curs_clear.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_clear.3,v 1.6 1998/09/13 19:16:17 millert Exp $
+.\" $OpenBSD: curs_clear.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,15 +28,24 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_clear.3x,v 1.7 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_clear.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.TH curs_clear 3 ""
+.na
+.hy 0
.SH NAME
-\fBerase\fR, \fBwerase\fR, \fBclear\fR,
-\fBwclear\fR, \fBclrtobot\fR, \fBwclrtobot\fR, \fBclrtoeol\fR,
+\fBerase\fR,
+\fBwerase\fR,
+\fBclear\fR,
+\fBwclear\fR,
+\fBclrtobot\fR,
+\fBwclrtobot\fR,
+\fBclrtoeol\fR,
\fBwclrtoeol\fR - clear all or part of a \fBcurses\fR window
+.ad
+.hy
.SH SYNOPSIS
\fB# include <curses.h>\fR
-
+.sp
\fBint erase(void);\fR
.br
\fBint werase(WINDOW *win);\fR
@@ -56,24 +65,29 @@
.SH DESCRIPTION
The \fBerase\fR and \fBwerase\fR routines copy blanks to every
position in the window, clearing the screen.
-
+.PP
The \fBclear\fR and \fBwclear\fR routines are like \fBerase\fR and
\fBwerase\fR, but they also call \fBclearok\fR, so that the screen is
cleared completely on the next call to \fBwrefresh\fR for that window
and repainted from scratch.
-
+.PP
The \fBclrtobot\fR and \fBwclrtobot\fR routines erase from the cursor to the
end of screen. That is, they erase all lines below the cursor in the window.
Also, the current line to the right of the cursor, inclusive, is erased.
-
+.PP
The \fBclrtoeol\fR and \fBwclrtoeol\fR routines erase the current line
to the right of the cursor, inclusive, to the end of the current line.
-
+.PP
Blanks created by erasure have the current background rendition (as set
by \fBwbkgdset\fR) merged into them.
.SH RETURN VALUE
-All routines return the integer \fBOK\fR. The SVr4.0 manual says "or a
+All routines return the integer \fBOK\fR on success and \fBERR\fP on failure.
+The SVr4.0 manual says "or a
non-negative integer if \fBimmedok\fR is set", but this appears to be an error.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+functions using a window pointer parameter return an error if it is null.
.SH NOTES
Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
\fBclrtobot\fR, and \fBclrtoeol\fR may be macros.
@@ -81,11 +95,24 @@ Note that \fBerase\fR, \fBwerase\fR, \fBclear\fR, \fBwclear\fR,
These functions are described in the XSI Curses standard, Issue 4. The
standard specifies that they return \fBERR\fR on failure, but specifies no
error conditions.
-
+.PP
Some historic curses implementations had, as an undocumented feature, the
ability to do the equivalent of \fBclearok(..., 1)\fR by saying
\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR. This will not work under
ncurses.
+.PP
+This implementation, and others such as Solaris,
+sets the current position to 0,0 after erasing
+via \fBwerase()\fP and \fBwclear()\fP.
+That fact is not documented in other implementations,
+and may not be true of implementations
+which were not derived from SVr4 source.
+.PP
+Not obvious from the description,
+most implementations clear the screen after \fBwclear\fP
+even for a subwindow or derived window.
+If you do not want to clear the screen during the next \fBwrefresh\fP,
+use \fBwerase\fP instead.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_outopts\fR(3), \fBcurs_refresh\fR(3)
.\"#
diff --git a/lib/libcurses/curs_color.3 b/lib/libcurses/curs_color.3
index db447938918..7aa05201098 100644
--- a/lib/libcurses/curs_color.3
+++ b/lib/libcurses/curs_color.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_color.3,v 1.9 2000/07/24 04:06:09 millert Exp $
+.\" $OpenBSD: curs_color.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_color.3x,v 1.16 2000/07/15 22:57:03 tom Exp $
+.\" $Id: curs_color.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH curs_color 3 ""
+.na
+.hy 0
.SH NAME
\fBstart_color\fR,
\fBinit_pair\fR,
@@ -39,6 +41,8 @@
\fBcolor_content\fR,
\fBpair_content\fR,
\fBCOLOR_PAIR\fR - \fBcurses\fR color manipulation routines
+.ad
+.hy
.SH SYNOPSIS
\fB# include <curses.h>\fR
.br
@@ -66,7 +70,7 @@ color (for the blank field on which the characters are displayed). A
programmer initializes a color-pair with the routine \fBinit_pair\fR. After it
has been initialized, \fBCOLOR_PAIR\fR(\fIn\fR), a macro defined in
\fB<curses.h>\fR, can be used as a new video attribute.
-
+.PP
If a terminal is capable of redefining colors, the programmer can use the
routine \fBinit_color\fR to change the definition of a color. The routines
\fBhas_colors\fR and \fBcan_change_color\fR return \fBTRUE\fR or \fBFALSE\fR,
@@ -86,7 +90,7 @@ and white), and two global variables, \fBCOLORS\fR and
and color-pairs the terminal can support). It also restores the
colors on the terminal to the values they had when the terminal was
just turned on.
-
+.PP
The \fBinit_pair\fR routine changes the definition of a color-pair. It takes
three arguments: the number of the color-pair to be changed, the foreground
color number, and the background color number.
@@ -98,18 +102,20 @@ must be between \fB1\fR and \fBCOLOR_PAIRS-1\fR.
.TP 5
-
The value of the second and
-third arguments must be between 0 and \fBCOLORS\fR (the 0 color pair is wired
-to white on black and cannot be changed).
+third arguments must be between 0 and \fBCOLORS\fR.
+Color pair 0 is assumed to be white on black,
+but is actually whatever the terminal implements before color is initialized.
+It cannot be modified by the application.
.PP
If the color-pair was previously
-initialized, the screen is refreshed and all occurrences of that color-pair is
-changed to the new definition.
-
+initialized, the screen is refreshed and all occurrences of that color-pair
+are changed to the new definition.
+.PP
As an extension, ncurses allows you to set color pair 0 via
the \fBassume_default_colors\fR routine, or to specify the use of
default colors (color number \fB-1\fR) if you first invoke the
\fBuse_default_colors\fR routine.
-
+.PP
The \fBinit_color\fR routine changes the definition of a color. It takes four
arguments: the number of the color to be changed followed by three RGB values
(for the amounts of red, green, and blue components). The value of the first
@@ -118,18 +124,18 @@ argument must be between \fB0\fR and \fBCOLORS\fR. (See the section
must be a value between 0 and 1000. When \fBinit_color\fR is used, all
occurrences of that color on the screen immediately change to the new
definition.
-
+.PP
The \fBhas_colors\fR routine requires no arguments. It returns \fBTRUE\fR if
the terminal can manipulate colors; otherwise, it returns \fBFALSE\fR. This
routine facilitates writing terminal-independent programs. For example, a
programmer can use it to decide whether to use color or some other video
attribute.
-
+.PP
The \fBcan_change_color\fR routine requires no arguments. It returns
\fBTRUE\fR if the terminal supports colors and can change their definitions;
other, it returns \fBFALSE\fR. This routine facilitates writing
terminal-independent programs.
-
+.PP
The \fBcolor_content\fR routine gives programmers a way to find the intensity
of the red, green, and blue (RGB) components in a color. It requires four
arguments: the color number, and three addresses of \fBshort\fRs for storing
@@ -138,7 +144,7 @@ given color. The value of the first argument must be between 0 and
\fBCOLORS\fR. The values that are stored at the addresses pointed to by the
last three arguments are between 0 (no component) and 1000 (maximum amount of
component).
-
+.PP
The \fBpair_content\fR routine allows programmers to find out what colors a
given color-pair consists of. It requires three arguments: the color-pair
number, and two addresses of \fBshort\fRs for storing the foreground and the
@@ -149,7 +155,7 @@ to by the second and third arguments are between 0 and \fBCOLORS\fR.
In \fB<curses.h>\fR the following macros are defined. These are the default
colors. \fBcurses\fR also assumes that \fBCOLOR_BLACK\fR is the default
background color for all terminals.
-
+.PP
.nf
\fBCOLOR_BLACK\fR
\fBCOLOR_RED\fR
@@ -163,22 +169,44 @@ background color for all terminals.
.SH RETURN VALUE
The routines \fBcan_change_color()\fR and \fBhas_colors()\fR return \fBTRUE\fR
or \fBFALSE\fR.
-
+.PP
All other routines return the integer \fBERR\fR upon failure and an \fBOK\fR
(SVr4 specifies only "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+X/Open defines no error conditions.
+This implementation will return \fBERR\fR on attempts to
+use color values outside the range 0 to COLORS-1
+(except for the default colors extension),
+or use color pairs outside the range 0 to COLOR_PAIR-1.
+Color values used in \fBinit_color\fP must be in the range 0 to 1000.
+An error is returned from all functions
+if the terminal has not been initialized.
+An error is returned from secondary functions such as \fBinit_pair\fP
+if \fBstart_color\fP was not called.
+.RS
+.TP 5
+\fBinit_color\fP
+returns an error if the terminal does not support
+this feature, e.g., if the \fIinitialize_color\fP capability is absent
+from the terminal description.
+.TP 5
+\fBstart_color\fP
+returns an error
+If the color table cannot be allocated.
+.RE
.SH NOTES
In the \fIncurses\fR implementation, there is a separate color activation flag,
color palette, color pairs table, and associated COLORS and COLOR_PAIRS counts
for each screen; the \fBstart_color\fR function only affects the current
screen. The SVr4/XSI interface is not really designed with this in mind, and
historical implementations may use a single shared color palette.
-
+.PP
Note that setting an implicit background color via a color pair affects only
character cells that a character write operation explicitly touches. To change
the background color used when parts of a window are blanked by erasing or
scrolling operations, see \fBcurs_bkgd\fR(3).
-
+.PP
Several caveats apply on 386 and 486 machines with VGA-compatible graphics:
.TP 5
-
@@ -203,8 +231,12 @@ but only if that routine has been first invoked.
.PP
The assumption that \fBCOLOR_BLACK\fR is the default
background color for all terminals can be modified using the
-\fBassume_default_colors\fP extension,
-..
+\fBassume_default_colors\fP extension.
+.PP
+This implementation checks the pointers,
+e.g., for the values returned by
+\fBcolor_content\fP and \fBpair_content\fP,
+and will treat those as optional parameters when null.
.SH SEE ALSO
\fBcurses\fR(3),
\fBcurs_initscr\fR(3),
diff --git a/lib/libcurses/curs_delch.3 b/lib/libcurses/curs_delch.3
index 17ac6bd95b5..143fbcc0f12 100644
--- a/lib/libcurses/curs_delch.3
+++ b/lib/libcurses/curs_delch.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_delch.3,v 1.6 2000/07/10 03:06:05 millert Exp $
+.\" $OpenBSD: curs_delch.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_delch.3x,v 1.7 2000/07/01 19:55:37 tom Exp $
+.\" $Id: curs_delch.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.TH curs_delch 3 ""
.SH NAME
\fBdelch\fR,
@@ -37,7 +37,7 @@
\fBmvwdelch\fR - delete character under the cursor in a \fBcurses\fR window
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint delch(void);\fR
.br
\fBint wdelch(WINDOW *win);\fR
diff --git a/lib/libcurses/curs_deleteln.3 b/lib/libcurses/curs_deleteln.3
index 26f04cdfff2..cf34da5b26f 100644
--- a/lib/libcurses/curs_deleteln.3
+++ b/lib/libcurses/curs_deleteln.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_deleteln.3,v 1.9 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_deleteln.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_deleteln.3x,v 1.7 2000/11/11 20:43:20 Bernhard.Rosenkraenzer Exp $
+.\" $Id: curs_deleteln.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH curs_deleteln 3 ""
.SH NAME
\fBdeleteln\fR,
@@ -39,7 +39,7 @@
\fBwinsertln\fR - delete and insert lines in a \fBcurses\fR window
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint deleteln(void);\fR
.br
\fBint wdeleteln(WINDOW *win);\fR
@@ -56,28 +56,32 @@
The \fBdeleteln\fR and \fBwdeleteln\fR routines delete the line under the
cursor in the window; all lines below the current line are moved up one line.
The bottom line of the window is cleared. The cursor position does not change.
-
+.PP
The \fBinsdelln\fR and \fBwinsdelln\fR routines, for positive \fIn\fR, insert
\fIn\fR lines into the specified window above the current line. The \fIn\fR
bottom lines are lost. For negative \fIn\fR, delete \fIn\fR lines (starting
with the one under the cursor), and move the remaining lines up. The bottom
\fIn\fR lines are cleared. The current cursor position remains the same.
-
+.PP
The \fBinsertln\fR and \fBwinsertln\fR routines insert a blank line above the
current line and the bottom line is lost.
.SH RETURN VALUE
All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
specifies only "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+if the window parameter is null, an error is returned.
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4. The
standard specifies that they return \fBERR\fR on failure, but specifies no
error conditions.
.SH NOTES
Note that all but \fBwinsdelln\fR may be macros.
-
+.PP
These routines do not require a hardware line delete or insert feature in the
-terminal. In fact, they won't use hardware line delete/insert unless
+terminal. In fact, they will not use hardware line delete/insert unless
\fBidlok(..., TRUE)\fR has been set on the current window.
.SH SEE ALSO
\fBcurses\fR(3)
diff --git a/lib/libcurses/curs_extend.3 b/lib/libcurses/curs_extend.3
index d33fb1ec949..f8629c72438 100644
--- a/lib/libcurses/curs_extend.3
+++ b/lib/libcurses/curs_extend.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_extend.3,v 1.5 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_extend.3,v 1.6 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1999-2004,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,22 +28,20 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1999
+.\" Author: Thomas E. Dickey 1999-on
.\"
-.\" $From: curs_extend.3x,v 1.6 2000/07/15 22:57:20 tom Exp $
+.\" $Id: curs_extend.3,v 1.6 2010/01/12 23:21:59 nicm Exp $
.TH curs_extend 3 ""
.SH NAME
-\fBcurs_extend\fR,
\fBcurses_version\fP,
\fBuse_extended_names\fP \- miscellaneous curses extensions
-..
+.
.SH SYNOPSIS
\fB#include <curses.h>\fP
-
+.sp
\fBconst char * curses_version(void);\fP
.br
\fBint use_extended_names(bool enable);\fP
-..
.SH DESCRIPTION
These functions are extensions to the curses library
which do not fit easily into other categories.
@@ -60,27 +58,25 @@ is able to use user-defined or nonstandard names
which may be compiled into the terminfo
description, i.e., via the terminfo or termcap interfaces.
Normally these names are available for use, since the essential decision
-is made by using the \fB-x\fP option of \fItic\fP to compile
+is made by using the \fB-x\fP option of \fBtic\fP to compile
extended terminal definitions.
However you can disable this feature
to ensure compatibility with other implementations of curses.
-..
.SH PORTABILITY
These routines are specific to ncurses. They were not supported on
Version 7, BSD or System V implementations. It is recommended that
any code depending on them be conditioned using NCURSES_VERSION.
-..
.SH SEE ALSO
\fBcurs_getch\fR(3),
\fBcurs_mouse\fR(3),
\fBcurs_print\fR(3),
+\fBcurs_util\fR(3),
\fBdefault_colors\fR(3),
\fBdefine_key\fR(3),
\fBkeybound\fR(3),
\fBkeyok\fR(3),
\fBresizeterm\fR(3),
\fBwresize\fR(3).
-..
.SH AUTHOR
Thomas Dickey.
.\"#
diff --git a/lib/libcurses/curs_getch.3tbl b/lib/libcurses/curs_getch.3tbl
index 978b261e616..92d06582845 100644
--- a/lib/libcurses/curs_getch.3tbl
+++ b/lib/libcurses/curs_getch.3tbl
@@ -1,8 +1,8 @@
-'\" t
-.\" $OpenBSD: curs_getch.3tbl,v 1.11 2003/05/12 11:06:49 jmc Exp $
+'\" t
+.\" $OpenBSD: curs_getch.3tbl,v 1.12 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,8 +29,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_getch.3x,v 1.18 2001/02/25 00:20:30 tom Exp $
+.\" $Id: curs_getch.3tbl,v 1.12 2010/01/12 23:21:59 nicm Exp $
.TH curs_getch 3 ""
+.na
+.hy 0
.SH NAME
\fBgetch\fR,
\fBwgetch\fR,
@@ -38,9 +40,11 @@
\fBmvwgetch\fR,
\fBungetch\fR,
\fBhas_key\fR \- get (or push back) characters from \fBcurses\fR terminal keyboard
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.PP
\fBint getch(void);\fR
.br
\fBint wgetch(WINDOW *win);\fR
@@ -55,14 +59,19 @@
.br
.SH DESCRIPTION
The \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR and \fBmvwgetch\fR, routines read
-a character from the window. In no-delay mode, if no input is waiting, the
-value \fBERR\fR is returned. In delay mode, the program waits until the system
-passes text through to the program. Depending on the setting of \fBcbreak\fR,
-this is after one character (cbreak mode), or after the first newline (nocbreak
-mode). In half-delay mode, the program waits until a character is typed or the
+a character from the window.
+In no-delay mode, if no input is waiting, the value \fBERR\fR is returned.
+In delay mode, the program waits until the system
+passes text through to the program.
+Depending on the setting of \fBcbreak\fR,
+this is after one character (cbreak mode),
+or after the first newline (nocbreak mode).
+In half-delay mode,
+the program waits until a character is typed or the
specified timeout has been reached.
-
-Unless \fBnoecho\fR has been set, then the character will also be echoed into the
+.PP
+Unless \fBnoecho\fR has been set,
+then the character will also be echoed into the
designated window according to the following rules:
If the character is the current erase character, left arrow, or backspace,
the cursor is moved one space to the left and that screen position is erased
@@ -70,32 +79,36 @@ as if \fBdelch\fR had been called.
If the character value is any other \fBKEY_\fR define, the user is alerted
with a \fBbeep\fR call.
Otherwise the character is simply output to the screen.
-
+.PP
If the window is not a pad, and it has been moved or modified since the last
call to \fBwrefresh\fR, \fBwrefresh\fR will be called before another character
is read.
-
+.PP
If \fBkeypad\fR is \fBTRUE\fR, and a function key is pressed, the token for
-that function key is returned instead of the raw characters. Possible function
+that function key is returned instead of the raw characters.
+Possible function
keys are defined in \fB<curses.h>\fR as macros with values outside the range
of 8-bit characters whose names begin with \fBKEY_\fR. Thus, a variable
intended to hold the return value of a function key must be of short size or
larger.
-
+.PP
When a character that could be the beginning of a function key is received
-(which, on modern terminals, means an escape character), \fBcurses\fR sets a
-timer. If the remainder of the sequence does not come in within the designated
-time, the character is passed through; otherwise, the function key value is
-returned. For this reason, many terminals experience a delay between the time
+(which, on modern terminals, means an escape character),
+\fBcurses\fR sets a timer.
+If the remainder of the sequence does not come in within the designated
+time, the character is passed through;
+otherwise, the function key value is returned.
+For this reason, many terminals experience a delay between the time
a user presses the escape key and the escape is returned to the program.
-
+.PP
The \fBungetch\fR routine places \fIch\fR back onto the input queue to be
-returned by the next call to \fBwgetch\fR. Note that there is, in effect,
-just one input queue for all windows.
-
+returned by the next call to \fBwgetch\fR.
+There is just one input queue for all windows.
+.PP
.SS Function Keys
The following function keys, defined in \fB<curses.h>\fR, might be returned by
-\fBgetch\fR if \fBkeypad\fR has been enabled. Note that not all of these are
+\fBgetch\fR if \fBkeypad\fR has been enabled.
+Note that not all of these are
necessarily supported on any particular terminal.
.sp
.TS
@@ -103,7 +116,6 @@ center tab(/) ;
l l
l l .
\fIName\fR/\fIKey\fR \fIname\fR
-
KEY_BREAK/Break key
KEY_DOWN/The four arrow keys ...
KEY_UP
@@ -201,7 +213,7 @@ KEY_SUNDO/Shifted undo key
KEY_SUSPEND/Suspend key
KEY_UNDO/Undo key
.TE
-
+.PP
Keypad is arranged like this:
.sp
.TS
@@ -213,73 +225,103 @@ c c c .
.TE
.sp
The \fBhas_key\fR routine takes a key value from the above list, and
-returns TRUE or FALSE according to whether the current terminal type
-recognizes a key with that value.
-
+returns TRUE or FALSE according to whether
+the current terminal type recognizes a key with that value.
+Note that a few values do not correspond to a real key,
+e.g., \fBKEY_RESIZE\fP and \fBKEY_MOUSE\fP.
+See \fBresizeterm\fR(3) for more details about \fBKEY_RESIZE\fP, and
+\fBcurs_mouse\fR(3) for a discussion of \fBKEY_MOUSE\fP.
+.PP
.SH RETURN VALUE
All routines return the integer \fBERR\fR upon failure and an integer value
other than \fBERR\fR (\fBOK\fR in the case of ungetch()) upon successful
completion.
+.RS
+.TP 5
+\fBungetch\fP
+returns an error
+if there is no more room in the FIFO.
+.TP 5
+\fBwgetch\fP
+returns an error
+if the window pointer is null, or
+if its timeout expires without having any data.
+.RE
.SH NOTES
Use of the escape key by a programmer for a single character function is
discouraged, as it will cause a delay of up to one second while the
keypad code looks for a following function-key sequence.
-
+.PP
Note that some keys may be the same as commonly used control
-keys, e.g., KEY_ENTER versus control/M, KEY_BACKSPACE versus control/H.
+keys, e.g., \fBKEY_ENTER\fP versus control/M, \fBKEY_BACKSPACE\fP versus control/H.
Some curses implementations may differ according to whether they
treat these control keys specially (and ignore the terminfo), or
use the terminfo definitions.
\fBNcurses\fR uses the terminfo definition.
-If it says that KEY_ENTER is control/M, \fBgetch\fR will return KEY_ENTER
+If it says that \fBKEY_ENTER\fP is control/M,
+\fBgetch\fR will return \fBKEY_ENTER\fP
when you press control/M.
-
+.PP
When using \fBgetch\fR, \fBwgetch\fR, \fBmvgetch\fR, or
\fBmvwgetch\fR, nocbreak mode (\fBnocbreak\fR) and echo mode
-(\fBecho\fR) should not be used at the same time. Depending on the
+(\fBecho\fR) should not be used at the same time.
+Depending on the
state of the tty driver when each character is typed, the program may
produce undesirable results.
-
+.PP
Note that \fBgetch\fR, \fBmvgetch\fR, and \fBmvwgetch\fR may be macros.
-
+.PP
Historically, the set of keypad macros was largely defined by the extremely
-function-key-rich keyboard of the AT&T 7300, aka 3B1, aka Safari 4. Modern
-personal computers usually have only a small subset of these. IBM PC-style
+function-key-rich keyboard of the AT&T 7300, aka 3B1, aka Safari 4.
+Modern
+personal computers usually have only a small subset of these.
+IBM PC-style
consoles typically support little more than \fBKEY_UP\fR, \fBKEY_DOWN\fR,
\fBKEY_LEFT\fR, \fBKEY_RIGHT\fR, \fBKEY_HOME\fR, \fBKEY_END\fR,
-\fBKEY_NPAGE\fR, \fBKEY_PPAGE\fR, and function keys 1 through 12. The Ins key
+\fBKEY_NPAGE\fR, \fBKEY_PPAGE\fR, and function keys 1 through 12.
+The Ins key
is usually mapped to \fBKEY_IC\fR.
.SH PORTABILITY
-The *get* functions are described in the XSI Curses standard, Issue 4. They
-read single-byte characters only. The standard specifies that they return
+The *get* functions are described in the XSI Curses standard, Issue 4.
+They
+read single-byte characters only.
+The standard specifies that they return
\fBERR\fR on failure, but specifies no error conditions.
-
+.PP
The echo behavior of these functions on input of \fBKEY_\fR or backspace
-characters was not specified in the SVr4 documentation. This description is
+characters was not specified in the SVr4 documentation.
+This description is
adopted from the XSI Curses standard.
-
+.PP
The behavior of \fBgetch\fR and friends in the presence of handled signals is
-unspecified in the SVr4 and XSI Curses documentation. Under historical curses
+unspecified in the SVr4 and XSI Curses documentation.
+Under historical curses
implementations, it varied depending on whether the operating system's
implementation of handled signal receipt interrupts a \fBread\fR(2) call in
progress or not, and also (in some implementations) depending on whether an
-input timeout or non-blocking mode hsd been set.
-
+input timeout or non-blocking mode has been set.
+.PP
Programmers concerned about portability should be prepared for either of two
cases: (a) signal receipt does not interrupt \fBgetch\fR; (b) signal receipt
interrupts \fBgetch\fR and causes it to return ERR with \fBerrno\fR set to
-\fBEINTR\fR. Under the \fBncurses\fR implementation, handled signals never
+\fBEINTR\fR.
+Under the \fBncurses\fR implementation, handled signals never
interrupt \fBgetch\fR.
-
-The \fBhas_key\fR function is unique to \fBncurses\fR. We recommend that
+.PP
+The \fBhas_key\fR function is unique to \fBncurses\fR.
+We recommend that
any code using it be conditionalized on the \fBNCURSES_VERSION\fR feature macro.
.SH SEE ALSO
\fBcurses\fR(3),
\fBcurs_inopts\fR(3),
\fBcurs_mouse\fR(3),
\fBcurs_move\fR(3),
-\fBcurs_refresh\fR(3).
+\fBcurs_refresh\fR(3),
\fBresizeterm\fR(3).
+.PP
+Comparable functions in the wide-character (ncursesw) library are
+described in
+\fBcurs_get_wch\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_getstr.3 b/lib/libcurses/curs_getstr.3
index 2b082892fbd..7edf7fc2c65 100644
--- a/lib/libcurses/curs_getstr.3
+++ b/lib/libcurses/curs_getstr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_getstr.3,v 1.8 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_getstr.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_getstr.3x,v 1.9 2000/07/01 17:39:31 tom Exp $
+.\" $Id: curs_getstr.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.TH curs_getstr 3 ""
+.na
+.hy 0
.SH NAME
\fBgetstr\fR,
\fBgetnstr\fR,
@@ -39,9 +41,11 @@
\fBmvgetnstr\fR,
\fBmvwgetstr\fR,
\fBmvwgetnstr\fR - accept character strings from \fBcurses\fR terminal keyboard
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint getstr(char *str);\fR
.br
\fBint getnstr(char *str, int n);\fR
@@ -63,17 +67,17 @@ The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
until a newline or carriage return is received (the terminating character is
not included in the returned string). The resulting value is placed in the
area pointed to by the character pointer \fIstr\fR.
-
+.PP
\fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
overflow of the input buffer. Any attempt to enter more characters (other
than the terminating newline or carriage return) causes a beep. Function
keys also cause a beep and are ignored. The \fBgetnstr\fR function reads
from the \fIstdscr\fR default window.
-
+.PP
The user's erase and kill characters are interpreted. If keypad
mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
are both considered equivalent to the user's kill character.
-
+.PP
Characters input are echoed only if \fBecho\fR is currently on. In that case,
backspace is echoed as deletion of the previous character (typically a left
motion).
@@ -81,22 +85,33 @@ motion).
All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
specifies only "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+X/Open defines no error conditions.
+.PP
+In this implementation,
+these functions return an error
+if the window pointer is null, or
+if its timeout expires without having any data.
+.PP
+This implementation provides an extension as well.
+If a SIGWINCH interrupts the function, it will return \fBKEY_RESIZE\fP
+rather than \fBOK\fP or \fBERR\fP.
.SH NOTES
Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
.SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4. They read
-single-byte characters only. The standard specifies that they return \fBERR\fR
-on failure, but the single error condition \fBEOVERFLOW\fR associated with
-extended-level conformance is not yet returned (the XSI curses support for
-multi-byte characters is not yet present).
-
+These functions are described in the XSI Curses standard, Issue 4.
+They read single-byte characters only.
+The standard does not define any error conditions.
+This implementation returns ERR if the window pointer is null,
+or if the lower-level \fBwgetch\fR call returns an ERR.
+.PP
SVr3 and early SVr4 curses implementations did not reject function keys;
the SVr4.0 documentation claimed that "special keys" (such as function
-keys, "home" key, "clear" key, etc.) are "interpreted", without
+keys, "home" key, "clear" key, \fIetc\fR.) are "interpreted", without
giving details. It lied. In fact, the `character' value appended to the
string by those implementations was predictable but not useful
(being, in fact, the low-order eight bits of the key's KEY_ value).
-
+.PP
The functions \fBgetnstr\fR, \fBmvgetnstr\fR, and \fBmvwgetnstr\fR were
present but not documented in SVr4.
.SH SEE ALSO
diff --git a/lib/libcurses/curs_getyx.3 b/lib/libcurses/curs_getyx.3
index 95921476314..ee882cc497f 100644
--- a/lib/libcurses/curs_getyx.3
+++ b/lib/libcurses/curs_getyx.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_getyx.3,v 1.6 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_getyx.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,14 +28,16 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_getyx.3x,v 1.6 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_getyx.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.TH curs_getyx 3 ""
.SH NAME
-\fBgetyx\fR, \fBgetparyx\fR, \fBgetbegyx\fR,
+\fBgetyx\fR,
+\fBgetparyx\fR,
+\fBgetbegyx\fR,
\fBgetmaxyx\fR - get \fBcurses\fR cursor and window coordinates
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBvoid getyx(WINDOW *win, int y, int x);\fR
.br
\fBvoid getparyx(WINDOW *win, int y, int x);\fR
@@ -47,25 +49,57 @@
.SH DESCRIPTION
The \fBgetyx\fR macro places the current cursor position of the given window in
the two integer variables \fIy\fR and \fIx\fR.
-
+.PP
If \fIwin\fR is a subwindow, the \fBgetparyx\fR macro places the beginning
coordinates of the subwindow relative to the parent window into two integer
-variables \fIy\fR and \fIx\fR. Otherwise, \fB-1\fR is placed into \fIy\fR and
-\fIx\fR.
-
+variables \fIy\fR and \fIx\fR.
+Otherwise, \fB-1\fR is placed into \fIy\fR and \fIx\fR.
+.PP
Like \fBgetyx\fR, the \fBgetbegyx\fR and \fBgetmaxyx\fR macros store
the current beginning coordinates and size of the specified window.
.SH RETURN VALUE
The return values of these macros are undefined (i.e.,
-they should not be used as the right-hand side of assignment
-statements).
+they should not be used as the right-hand side of assignment statements).
.SH NOTES
-All of these interfaces are macros and that "\fB&\fR" is not
-necessary before the variables \fIy\fR and \fIx\fR.
+All of these interfaces are macros.
+A "\fB&\fR" is not necessary before the variables \fIy\fR and \fIx\fR.
.SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4.
+The
+\fBgetyx\fR,
+\fBgetparyx\fR,
+\fBgetbegyx\fR and
+\fBgetmaxyx\fR
+macros are described in the XSI Curses standard, Issue 4.
+.PP
+This implementation also provides functions
+\fBgetbegx\fR,
+\fBgetbegy\fR,
+\fBgetcurx\fR,
+\fBgetcury\fR,
+\fBgetmaxx\fR,
+\fBgetmaxy\fR,
+\fBgetparx\fR and
+\fBgetpary\fR
+for compatibility with older versions of curses.
+.PP
+Although X/Open Curses does not address this,
+many implementations provide members of the WINDOW structure
+containing values corresponding to these macros.
+For best portability, do not rely on using the data in WINDOW,
+since some implementations make WINDOW opaque (do not allow
+direct use of its members).
+.PP
+Besides the problem of opaque structures,
+the data stored in like-named members may not have like-values in
+different implementations.
+For example, the WINDOW._maxx and WINDOW._maxy values in ncurses
+have (at least since release 1.8.1) differed by one from some
+other implementations.
+The difference is hidden by means of the macro \fBgetmaxyx\fP.
.SH SEE ALSO
-\fBcurses\fR(3)
+\fBcurses\fR(3),
+\fBcurs_legacy\fR(3),
+\fBcurs_opaque\fR(3)
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_inch.3tbl b/lib/libcurses/curs_inch.3tbl
index d29aac44a90..9a65becd6a6 100644
--- a/lib/libcurses/curs_inch.3tbl
+++ b/lib/libcurses/curs_inch.3tbl
@@ -1,8 +1,8 @@
-'\" t
-.\" $OpenBSD: curs_inch.3tbl,v 1.7 1999/01/18 19:07:13 millert Exp $
+'\" t
+.\" $OpenBSD: curs_inch.3tbl,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,14 +29,14 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_inch.3x,v 1.11 1998/11/29 01:04:34 Rick.Ohnemus Exp $
+.\" $Id: curs_inch.3tbl,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_inch 3 ""
.SH NAME
\fBinch\fR, \fBwinch\fR, \fBmvinch\fR, \fBmvwinch\fR
- get a character and attributes from a \fBcurses\fR window
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBchtype inch(void);\fR
.br
\fBchtype winch(WINDOW *win);\fR
@@ -51,10 +51,10 @@ position in the named window. If any attributes are set for that position,
their values are OR'ed into the value returned. Constants defined in
\fB<curses.h>\fR can be used with the \fB&\fR (logical AND) operator to
extract the character or attributes alone.
-
+.
.SS Attributes
The following bit-masks may be AND-ed with characters returned by \fBwinch\fR.
-
+.
.TS
l l .
\fBA_CHARTEXT\fR Bit-mask to extract character
@@ -67,6 +67,10 @@ Note that all of these routines may be macros.
These functions are described in the XSI Curses standard, Issue 4.
.SH SEE ALSO
\fBcurses\fR(3).
+.PP
+Comparable functions in the wide-character (ncursesw) library are
+described in
+\fBcurs_in_wch\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_inchstr.3 b/lib/libcurses/curs_inchstr.3
index 4bf3827b29a..f9f2907fc42 100644
--- a/lib/libcurses/curs_inchstr.3
+++ b/lib/libcurses/curs_inchstr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_inchstr.3,v 1.7 2000/07/10 03:06:07 millert Exp $
+.\" $OpenBSD: curs_inchstr.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_inchstr.3x,v 1.8 2000/07/01 20:16:18 tom Exp $
+.\" $Id: curs_inchstr.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_inchstr 3 ""
+.na
+.hy 0
.SH NAME
\fBinchstr\fR,
\fBinchnstr\fR,
@@ -39,9 +41,11 @@
\fBmvinchnstr\fR,
\fBmvwinchstr\fR,
\fBmvwinchnstr\fR - get a string of characters (and attributes) from a \fBcurses\fR window
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint inchstr(chtype *chstr);\fR
.br
\fBint inchnstr(chtype *chstr, int n);\fR
@@ -71,6 +75,11 @@ in the \fIchstr\fR [see \fBcurs_inch\fR(3)].
All routines return the integer \fBERR\fR upon failure and an integer value
other than \fBERR\fR upon successful completion (the number of characters
retrieved, exclusive of the trailing 0).
+.PP
+No error conditions are defined.
+If the \fIchstr\fP parameter is null,
+no data is returned,
+and the return value is zero.
.SH NOTES
Note that all routines except \fBwinchnstr\fR may be macros. SVr4 does not
document whether the result string is 0-terminated; it does not document
@@ -82,6 +91,10 @@ more specific than the SVr4 documentation on the trailing 0. It does specify
that the successful return of the functions is \fBOK\fR.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_inch\fR(3).
+.PP
+Comparable functions in the wide-character (ncursesw) library are
+described in
+\fBcurs_in_wchstr\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_initscr.3 b/lib/libcurses/curs_initscr.3
index fb57f12a83e..61de6f22c00 100644
--- a/lib/libcurses/curs_initscr.3
+++ b/lib/libcurses/curs_initscr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_initscr.3,v 1.8 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_initscr.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_initscr.3x,v 1.10 2000/07/08 12:47:39 tom Exp $
+.\" $Id: curs_initscr.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.TH curs_initscr 3 ""
+.na
+.hy 0
.SH NAME
\fBinitscr\fR,
\fBnewterm\fR,
@@ -37,16 +39,18 @@
\fBisendwin\fR,
\fBset_term\fR,
\fBdelscreen\fR - \fBcurses\fR screen initialization and manipulation routines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBWINDOW *initscr(void);\fR
.br
\fBint endwin(void);\fR
.br
\fBbool isendwin(void);\fR
.br
-\fBSCREEN *newterm(const char *type, FILE *outfd, FILE *infd);\fR
+\fBSCREEN *newterm(char *type, FILE *outfd, FILE *infd);\fR
.br
\fBSCREEN *set_term(SCREEN *new);\fR
.br
@@ -58,13 +62,13 @@ initializing a program. A few special routines sometimes need to be
called before it; these are \fBslk_init\fR, \fBfilter\fR, \fBripoffline\fR,
\fBuse_env\fR. For multiple-terminal applications, \fBnewterm\fR may be
called before \fBinitscr\fR.
-
+.PP
The initscr code determines the terminal type and initializes all \fBcurses\fR
data structures. \fBinitscr\fR also causes the first call to \fBrefresh\fR to
clear the screen. If errors occur, \fBinitscr\fR writes an appropriate error
message to standard error and exits; otherwise, a pointer is returned to
\fBstdscr\fR.
-
+.PP
A program that outputs to more than one terminal should use the \fBnewterm\fR
routine for each terminal instead of \fBinitscr\fR. A program that needs to
inspect capabilities, so it can continue to run in a line-oriented mode if the
@@ -78,23 +82,23 @@ is \fBNULL\fR, \fB$TERM\fR will be used). The program must also call
\fBendwin\fR for each terminal being used before exiting from \fBcurses\fR.
If \fBnewterm\fR is called more than once for the same terminal, the first
terminal referred to must be the last one for which \fBendwin\fR is called.
-
+.PP
A program should always call \fBendwin\fR before exiting or escaping from
\fBcurses\fR mode temporarily. This routine restores tty modes, moves the
cursor to the lower left-hand corner of the screen and resets the terminal into
the proper non-visual mode. Calling \fBrefresh\fR or \fBdoupdate\fR after a
temporary escape causes the program to resume visual mode.
-
+.PP
The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
called without any subsequent calls to \fBwrefresh\fR, and \fBFALSE\fR
otherwise.
-
+.PP
The \fBset_term\fR routine is used to switch between different
terminals. The screen reference \fBnew\fR becomes the new current
terminal. The previous terminal is returned by the routine. This is
the only routine which manipulates \fBSCREEN\fR pointers; all other
routines affect only the current terminal.
-
+.PP
The \fBdelscreen\fR routine frees storage associated with the
\fBSCREEN\fR data structure. The \fBendwin\fR routine does not do
this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
@@ -102,15 +106,19 @@ particular \fBSCREEN\fR is no longer needed.
.SH RETURN VALUE
\fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
upon successful completion.
-
+.PP
Routines that return pointers always return \fBNULL\fR on error.
+.PP
+X/Open defines no error conditions.
+In this implementation
+\fBendwin\fP returns an error if the terminal was not initialized.
.SH NOTES
Note that \fBinitscr\fR and \fBnewterm\fR may be macros.
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4. It
specifies that portable applications must not call \fBinitscr\fR more than
once.
-
+.PP
Old versions of curses, e.g., BSD 4.4, may have returned a null pointer
from \fBinitscr\fR when an error is detected, rather than exiting.
It is safe but redundant to check the return value of \fBinitscr\fR
diff --git a/lib/libcurses/curs_inopts.3 b/lib/libcurses/curs_inopts.3
index 05fe55c9815..4172ca9fbae 100644
--- a/lib/libcurses/curs_inopts.3
+++ b/lib/libcurses/curs_inopts.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_inopts.3,v 1.7 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_inopts.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,17 +28,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_inopts.3x,v 1.8 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_inopts.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_inopts 3 ""
+.na
+.hy 0
.SH NAME
-\fBcbreak\fR, \fBnocbreak\fR, \fBecho\fR,
-\fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR, \fBkeypad\fR,
-\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBraw\fR, \fBnoraw\fR,
-\fBnoqiflush\fR, \fBqiflush\fR, \fBtimeout\fR, \fBwtimeout\fR,
+\fBcbreak\fR,
+\fBnocbreak\fR,
+\fBecho\fR,
+\fBnoecho\fR,
+\fBhalfdelay\fR,
+\fBintrflush\fR,
+\fBkeypad\fR,
+\fBmeta\fR,
+\fBnodelay\fR,
+\fBnotimeout\fR,
+\fBraw\fR,
+\fBnoraw\fR,
+\fBnoqiflush\fR,
+\fBqiflush\fR,
+\fBtimeout\fR,
+\fBwtimeout\fR,
\fBtypeahead\fR - \fBcurses\fR input options
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.PP
\fBint cbreak(void);\fR
.br
\fBint nocbreak(void);\fR
@@ -80,14 +96,14 @@ erase/kill character-processing (interrupt and flow control characters are
unaffected), making characters typed by the user immediately available to the
program. The \fBnocbreak\fR routine returns the terminal to normal (cooked)
mode.
-
+.PP
Initially the terminal may or may not be in \fBcbreak\fR mode, as the mode is
inherited; therefore, a program should call \fBcbreak\fR or \fBnocbreak\fR
explicitly. Most interactive programs using \fBcurses\fR set the \fBcbreak\fR
mode. Note that \fBcbreak\fR overrides \fBraw\fR.
[See \fBcurs_getch\fR(3) for a
discussion of how these routines interact with \fBecho\fR and \fBnoecho\fR.]
-
+.PP
The \fBecho\fR and \fBnoecho\fR routines control whether characters typed by
the user are echoed by \fBgetch\fR as they are typed. Echoing by the tty
driver is always disabled, but initially \fBgetch\fR is in echo mode, so
@@ -97,14 +113,14 @@ they disable echoing by calling \fBnoecho\fR.
[See \fBcurs_getch\fR(3) for a
discussion of how these routines interact with \fBcbreak\fR and
\fBnocbreak\fR.]
-
+.PP
The \fBhalfdelay\fR routine is used for half-delay mode, which is similar to
\fBcbreak\fR mode in that characters typed by the user are immediately
available to the program. However, after blocking for \fItenths\fR tenths of
seconds, ERR is returned if nothing has been typed. The value of \fBtenths\fR
must be a number between 1 and 255. Use \fBnocbreak\fR to leave half-delay
mode.
-
+.PP
If the \fBintrflush\fR option is enabled, (\fIbf\fR is \fBTRUE\fR), when an
interrupt key is pressed on the keyboard (interrupt, break, quit) all output in
the tty driver queue will be flushed, giving the effect of faster response to
@@ -112,7 +128,7 @@ the interrupt, but causing \fBcurses\fR to have the wrong idea of what is on
the screen. Disabling (\fIbf\fR is \fBFALSE\fR), the option prevents the
flush. The default for the option is inherited from the tty driver settings.
The window argument is ignored.
-
+.PP
The \fBkeypad\fR option enables the keypad of the user's terminal. If
enabled (\fIbf\fR is \fBTRUE\fR), the user can press a function key
(such as an arrow key) and \fBwgetch\fR returns a single value
@@ -123,30 +139,30 @@ itself. If the keypad in the terminal can be turned on (made to
transmit) and off (made to work locally), turning on this option
causes the terminal keypad to be turned on when \fBwgetch\fR is
called. The default value for keypad is false.
-
+.PP
Initially, whether the terminal returns 7 or 8 significant bits on
input depends on the control mode of the tty driver [see termio(7)].
To force 8 bits to be returned, invoke \fBmeta\fR(\fIwin\fR,
\fBTRUE\fR); this is equivalent, under POSIX, to setting the CS8 flag
on the terminal. To force 7 bits to be returned, invoke
\fBmeta\fR(\fIwin\fR, \fBFALSE\fR); this is equivalent, under POSIX,
-to setting the CS8 flag on the terminal. The window argument,
+to setting the CS7 flag on the terminal. The window argument,
\fIwin\fR, is always ignored. If the terminfo capabilities \fBsmm\fR
(meta_on) and \fBrmm\fR (meta_off) are defined for the terminal,
\fBsmm\fR is sent to the terminal when \fBmeta\fR(\fIwin\fR,
\fBTRUE\fR) is called and \fBrmm\fR is sent when \fBmeta\fR(\fIwin\fR,
\fBFALSE\fR) is called.
-
+.PP
The \fBnodelay\fR option causes \fBgetch\fR to be a non-blocking call.
If no input is ready, \fBgetch\fR returns \fBERR\fR. If disabled
(\fIbf\fR is \fBFALSE\fR), \fBgetch\fR waits until a key is pressed.
-
+.PP
While interpreting an input escape sequence, \fBwgetch\fR sets a timer
while waiting for the next character. If \fBnotimeout(\fR\fIwin\fR,
\fBTRUE\fR) is called, then \fBwgetch\fR does not set a timer. The
purpose of the timeout is to differentiate between sequences received
from a function key and those typed by a user.
-
+.PP
The \fBraw\fR and \fBnoraw\fR routines place the terminal into or out of raw
mode. Raw mode is similar to \fBcbreak\fR mode, in that characters typed are
immediately passed through to the user program. The differences are that in
@@ -154,7 +170,7 @@ raw mode, the interrupt, quit, suspend, and flow control characters are all
passed through uninterpreted, instead of generating a signal. The behavior of
the BREAK key depends on other bits in the tty driver that are not set by
\fBcurses\fR.
-
+.PP
When the \fBnoqiflush\fR routine is used, normal flush of input and
output queues associated with the \fBINTR\fR, \fBQUIT\fR and
\fBSUSP\fR characters will not be done [see termio(7)]. When
@@ -162,7 +178,7 @@ output queues associated with the \fBINTR\fR, \fBQUIT\fR and
characters are read. You may want to call \fBnoqiflush()\fR in a signal
handler if you want output to continue as though the interrupt
had not occurred, after the handler exits.
-
+.PP
The \fBtimeout\fR and \fBwtimeout\fR routines set blocking or
non-blocking read for a given window. If \fIdelay\fR is negative,
blocking read is used (i.e., waits indefinitely for
@@ -173,7 +189,7 @@ milliseconds, and returns \fBERR\fR if there is still no input.
Hence, these routines provide the same functionality as \fBnodelay\fR,
plus the additional capability of being able to block for only
\fIdelay\fR milliseconds (where \fIdelay\fR is positive).
-
+.PP
The \fBcurses\fR library does ``line-breakout optimization'' by looking for
typeahead periodically while updating the screen. If input is found,
and it is coming from a tty, the current update is postponed until
@@ -188,9 +204,21 @@ The \fBtypeahead\fR routine specifies that the file descriptor
All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
specifies only "an integer value other than \fBERR\fR") upon successful
completion, unless otherwise noted in the preceding routine descriptions.
+.PP
+X/Open does not define any error conditions.
+In this implementation,
+functions with a window parameter will return an error if it is null.
+Any function will also return an error if the terminal was not initialized.
+Also,
+.RS
+.TP 5
+\fBhalfdelay\fP
+returns an error
+if its parameter is outside the range 1..255.
+.RE
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4.
-
+.PP
The ncurses library obeys the XPG4 standard and the historical practice of the
AT&T curses implementations, in that the echo bit is cleared when curses
initializes the terminal state. BSD curses differed from this slightly; it
@@ -201,7 +229,7 @@ just after initialization, even if your program remains in cooked mode.
Note that \fBecho\fR, \fBnoecho\fR, \fBhalfdelay\fR, \fBintrflush\fR,
\fBmeta\fR, \fBnodelay\fR, \fBnotimeout\fR, \fBnoqiflush\fR,
\fBqiflush\fR, \fBtimeout\fR, and \fBwtimeout\fR may be macros.
-
+.PP
The \fBnoraw\fR and \fBnocbreak\fR calls follow historical practice in that
they attempt to restore to normal (`cooked') mode from raw and cbreak modes
respectively. Mixing raw/noraw and cbreak/nocbreak calls leads to tty driver
diff --git a/lib/libcurses/curs_insch.3 b/lib/libcurses/curs_insch.3
index 57099f36dbe..4895ebce40d 100644
--- a/lib/libcurses/curs_insch.3
+++ b/lib/libcurses/curs_insch.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_insch.3,v 1.7 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_insch.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_insch.3x,v 1.7 2000/07/01 19:57:21 tom Exp $
+.\" $Id: curs_insch.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_insch 3 ""
.SH NAME
\fBinsch\fR,
@@ -37,7 +37,7 @@
\fBmvwinsch\fR - insert a character before cursor in a \fBcurses\fR window
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint insch(chtype ch);\fR
.br
\fBint winsch(WINDOW *win, chtype ch);\fR
@@ -58,12 +58,16 @@ completion, unless otherwise noted in the preceding routine descriptions.
.SH NOTES
These routines do not necessarily imply use of a hardware insert character
feature.
-
+.PP
Note that \fBinsch\fR, \fBmvinsch\fR, and \fBmvwinsch\fR may be macros.
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4.
.SH SEE ALSO
\fBcurses\fR(3).
+.PP
+Comparable functions in the wide-character (ncursesw) library are
+described in
+\fBcurs_ins_wch\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_insstr.3 b/lib/libcurses/curs_insstr.3
index abc21ff7598..e5d824f99fd 100644
--- a/lib/libcurses/curs_insstr.3
+++ b/lib/libcurses/curs_insstr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_insstr.3,v 1.9 2000/07/10 03:06:07 millert Exp $
+.\" $OpenBSD: curs_insstr.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_insstr.3x,v 1.11 2000/07/01 19:57:49 tom Exp $
+.\" $Id: curs_insstr.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH curs_insstr 3 ""
.SH NAME
\fBinsstr\fR,
@@ -59,36 +59,42 @@
\fBint mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);\fR
.br
.SH DESCRIPTION
-These routines insert a character string (as many characters as will fit on the
-line) before the character under the cursor. All characters to the right of
-the cursor are shifted right, with the possibility of the rightmost characters
-on the line being lost. The cursor position does not change (after moving to
-\fIy\fR, \fIx\fR, if specified). The four routines with \fIn\fR as the last
-argument insert a leading substring of at most \fIn\fR characters. If
-\fIn\fR<=0, then the entire string is inserted.
-
-If a character in \fIstr\fR is a tab, newline, carriage return or
-backspace, the cursor is moved appropriately within the window. A
-newline also does a \fBclrtoeol\fR before moving. Tabs are considered
-to be at every eighth column. If a character in \fIstr\fR is another
-control character, it is drawn in the \fB^\fR\fIX\fR notation.
-Calling \fBwinch\fR after adding a control character (and moving to
-it, if necessary) does not return the control character, but instead
-returns a character in the ^-representation of the control character.
+These routines insert a character string
+(as many characters as will fit on the line)
+before the character under the cursor.
+All characters to the right of the cursor are shifted right
+with the possibility of the rightmost characters on the line being lost.
+The cursor position does not change
+(after moving to \fIy\fR, \fIx\fR, if specified).
+The functions with \fIn\fR as the last argument
+insert a leading substring of at most \fIn\fR characters.
+If \fIn\fR<=0, then the entire string is inserted.
+.PP
+Special characters are handled as in \fBaddch\fP.
.SH RETURN VALUE
All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
specifies only "an integer value other than \fBERR\fR") upon successful
completion, unless otherwise noted in the preceding routine descriptions.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+if the window parameter is null or the str parameter is null,
+an error is returned.
.SH NOTES
Note that all but \fBwinsnstr\fR may be macros.
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4, which adds
-const qualifiers to the arguments. The XSI Curses error conditions
-\fBEILSEQ\fR and \fBEILOVERFLOW\fR associated with extended-level conformance
-are not yet detected (this implementation does not yet support XPG4 multi-byte
-characters).
+const qualifiers to the arguments.
+.LP
+The Single Unix Specification, Version 2 states that
+\fBinsnstr\fP and \fBwinsnstr\fP perform wrapping.
+This is probably an error, since it makes this group of functions inconsistent.
+Also, no implementation of curses documents this inconsistency.
.SH SEE ALSO
-\fBcurses\fR(3), \fBcurs_clear\fR(3), \fBcurs_inch\fR(3).
+\fBcurses\fR(3),
+\fBcurs_util\fR(3),
+\fBcurs_clear\fR(3),
+\fBcurs_inch\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_instr.3 b/lib/libcurses/curs_instr.3
index dcf93b6e030..140ffcde798 100644
--- a/lib/libcurses/curs_instr.3
+++ b/lib/libcurses/curs_instr.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_instr.3,v 1.7 2000/07/10 03:06:07 millert Exp $
+.\" $OpenBSD: curs_instr.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_instr.3x,v 1.9 2000/07/01 20:05:03 tom Exp $
+.\" $Id: curs_instr.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_instr 3 ""
.SH NAME
\fBinstr\fR,
@@ -41,7 +41,7 @@
\fBmvwinnstr\fR - get a string of characters from a \fBcurses\fR window
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint instr(char *str);\fR
.br
\fBint innstr(char *str, int n);\fR
@@ -67,13 +67,14 @@ functions with \fIn\fR as the last argument return a leading substring at most
.SH RETURN VALUE
All of the functions return \fBERR\fR upon failure,
or the number of characters actually read into the string.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+if the window parameter is null or the str parameter is null,
+a zero is returned.
.SH NOTES
Note that all routines except \fBwinnstr\fR may be macros.
.SH PORTABILITY
-The XSI Curses
-error conditions \fBEILSEQ\fR and \fBEILOVERFLOW\fR associated with
-extended-level conformance are not yet detected (this implementation does not
-yet support XPG4 multi-byte characters).
SVr4 does not
document whether a length limit includes or excludes the trailing NUL.
.PP
@@ -88,4 +89,3 @@ In this case, the functions return the string ending at the right margin.
.\"# mode:nroff
.\"# fill-column:79
.\"# End:
-
diff --git a/lib/libcurses/curs_kernel.3 b/lib/libcurses/curs_kernel.3
index 32affd776c9..4a69f9aab1f 100644
--- a/lib/libcurses/curs_kernel.3
+++ b/lib/libcurses/curs_kernel.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_kernel.3,v 1.8 2000/03/10 01:35:01 millert Exp $
+.\" $OpenBSD: curs_kernel.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2001,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,16 +28,27 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_kernel.3x,v 1.12 2000/02/27 01:37:46 tom Exp $
+.\" $Id: curs_kernel.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.TH curs_kernel 3 ""
+.na
+.hy 0
.SH NAME
-\fBdef_prog_mode\fR, \fBdef_shell_mode\fR,
-\fBreset_prog_mode\fR, \fBreset_shell_mode\fR, \fBresetty\fR,
-\fBsavetty\fR, \fBgetsyx\fR, \fBsetsyx\fR, \fBripoffline\fR,
-\fBcurs_set\fR, \fBnapms\fR - low-level \fBcurses\fR routines
+\fBdef_prog_mode\fR,
+\fBdef_shell_mode\fR,
+\fBreset_prog_mode\fR,
+\fBreset_shell_mode\fR,
+\fBresetty\fR,
+\fBsavetty\fR,
+\fBgetsyx\fR,
+\fBsetsyx\fR,
+\fBripoffline\fR,
+\fBcurs_set\fR,
+\fBnapms\fR - low-level \fBcurses\fR routines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint def_prog_mode(void);\fR
.br
\fBint def_shell_mode(void);\fR
@@ -64,32 +75,32 @@
The following routines give low-level access to various \fBcurses\fR
capabilities. Theses routines typically are used inside library
routines.
-
+.PP
The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
current terminal modes as the "program" (in \fBcurses\fR) or "shell"
(not in \fBcurses\fR) state for use by the \fBreset_prog_mode\fR and
\fBreset_shell_mode\fR routines. This is done automatically by
\fBinitscr\fR. There is one such save area for each screen context
allocated by \fBnewterm()\fR.
-
+.PP
The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
the terminal to "program" (in \fBcurses\fR) or "shell" (out of
\fBcurses\fR) state. These are done automatically by \fBendwin\fR
and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
not called.
-
+.PP
The \fBresetty\fR and \fBsavetty\fR routines save and restore the
state of the terminal modes. \fBsavetty\fR saves the current state in
a buffer and \fBresetty\fR restores the state to what it was at the
last call to \fBsavetty\fR.
-
+.PP
The \fBgetsyx\fR routine returns the current coordinates of the virtual screen
cursor in \fIy\fR and \fIx\fR. If \fBleaveok\fR is currently \fBTRUE\fR, then
\fB-1\fR,\fB-1\fR is returned. If lines have been removed from the top of the
screen, using \fBripoffline\fR, \fIy\fR and \fIx\fR include these lines;
therefore, \fIy\fR and \fIx\fR should be used only as arguments for
\fBsetsyx\fR.
-
+.PP
The \fBsetsyx\fR routine sets the virtual screen cursor to
\fIy\fR, \fIx\fR. If \fIy\fR and \fIx\fR are both \fB-1\fR, then
\fBleaveok\fR is set. The two routines \fBgetsyx\fR and \fBsetsyx\fR
@@ -99,7 +110,7 @@ of the program's cursor. The library routine would call \fBgetsyx\fR
at the beginning, do its manipulation of its own windows, do a
\fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
\fBdoupdate\fR.
-
+.PP
The \fBripoffline\fR routine provides access to the same facility that
\fBslk_init\fR [see \fBcurs_slk\fR(3)] uses to reduce the size of the
screen. \fBripoffline\fR must be called before \fBinitscr\fR or
@@ -114,39 +125,55 @@ and \fBCOLS\fR (defined in \fB<curses.h>\fR) are not guaranteed to be
accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called. It
is allowable to call \fBwnoutrefresh\fR during the initialization
routine.
-
+.PP
\fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
\fBnewterm\fR.
-
+.PP
The \fBcurs_set\fR routine sets the cursor state is set to invisible,
normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
\fB1\fR, or \fB2\fR respectively. If the terminal supports the
\fIvisibility\fR requested, the previous \fIcursor\fR state is
returned; otherwise, \fBERR\fR is returned.
-
+.PP
The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
.SH RETURN VALUE
Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
-\fBcurs_set\fR returns the previous cursor state, or \fBERR\fR if the
+.PP
+\fBcurs_set\fR
+returns the previous cursor state, or \fBERR\fR if the
requested \fIvisibility\fR is not supported.
+.PP
+X/Open defines no error conditions.
+In this implementation
+.RS
+.TP 5
+\fBdef_prog_mode\fR, \fBdef_shell_mode\fR, \fBreset_prog_mode\fR, \fBreset_shell_mode\fR
+return an error
+if the terminal was not initialized, or
+if the I/O call to obtain the terminal settings fails.
+.TP 5
+\fBripoffline\fP
+returns an error if the maximum number of ripped-off lines
+exceeds the maximum (NRIPS = 5).
+.RE
.SH NOTES
Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
the variables \fIy\fR and \fIx\fR.
-
+.PP
Older SVr4 man pages warn that the return value of \fBcurs_set\fR "is currently
incorrect". This implementation gets it right, but it may be unwise to count
on the correctness of the return value anywhere else.
-
+.PP
Both ncurses and SVr4 will call \fBcurs_set\fR in \fBendwin\fR
if \fBcurs_set\fR
has been called to make the cursor other than normal, i.e., either
-visible or very visible.
+invisible or very visible.
There is no way for ncurses to determine the initial cursor state to
restore that.
.SH PORTABILITY
The functions \fBsetsyx\fR and \fBgetsyx\fR are not described in the XSI
Curses standard, Issue 4. All other functions are as described in XSI Curses.
-
+.PP
The SVr4 documentation describes \fBsetsyx\fR and \fBgetsyx\fR as having return
type int. This is misleading, as they are macros with no documented semantics
for the return value.
diff --git a/lib/libcurses/curs_legacy.3 b/lib/libcurses/curs_legacy.3
new file mode 100644
index 00000000000..21ac9e5db77
--- /dev/null
+++ b/lib/libcurses/curs_legacy.3
@@ -0,0 +1,95 @@
+.\" $OpenBSD: curs_legacy.3,v 1.1 2010/01/12 23:21:59 nicm Exp $
+.\"
+.\"***************************************************************************
+.\" Copyright (c) 2007 Free Software Foundation, Inc. *
+.\" *
+.\" Permission is hereby granted, free of charge, to any person obtaining a *
+.\" copy of this software and associated documentation files (the *
+.\" "Software"), to deal in the Software without restriction, including *
+.\" without limitation the rights to use, copy, modify, merge, publish, *
+.\" distribute, distribute with modifications, sublicense, and/or sell *
+.\" copies of the Software, and to permit persons to whom the Software is *
+.\" furnished to do so, subject to the following conditions: *
+.\" *
+.\" The above copyright notice and this permission notice shall be included *
+.\" in all copies or substantial portions of the Software. *
+.\" *
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+.\" *
+.\" Except as contained in this notice, the name(s) of the above copyright *
+.\" holders shall not be used in advertising or otherwise to promote the *
+.\" sale, use or other dealings in this Software without prior written *
+.\" authorization. *
+.\"***************************************************************************
+.\"
+.\" $Id: curs_legacy.3,v 1.1 2010/01/12 23:21:59 nicm Exp $
+.TH curs_legacy 3 ""
+.SH NAME
+\fBgetbegx\fR,
+\fBgetbegy\fR,
+\fBgetcurx\fR,
+\fBgetcury\fR,
+\fBgetmaxx\fR,
+\fBgetmaxy\fR,
+\fBgetparx\fR,
+\fBgetpary\fR - get \fBcurses\fR cursor and window coordinates
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.sp
+\fBint getbegx(WINDOW *win);\fR
+.br
+\fBint getbegy(WINDOW *win);\fR
+.br
+\fBint getcurx(WINDOW *win);\fR
+.br
+\fBint getcury(WINDOW *win);\fR
+.br
+\fBint getmaxx(WINDOW *win);\fR
+.br
+\fBint getmaxy(WINDOW *win);\fR
+.br
+\fBint getparx(WINDOW *win);\fR
+.br
+\fBint getpary(WINDOW *win);\fR
+.br
+.SH DESCRIPTION
+The \fBgetbegy\fR and \fBgetbegx\fR functions return the same
+data as \fBgetbegyx\fR.
+.PP
+The \fBgetcury\fR and \fBgetcurx\fR functions return the same
+data as \fBgetyx\fR.
+.PP
+The \fBgetmaxy\fR and \fBgetmaxx\fR functions return the same
+data as \fBgetmaxyx\fR.
+.PP
+The \fBgetpary\fR and \fBgetparx\fR functions return the same
+data as \fBgetparyx\fR.
+.SH RETURN VALUE
+These functions return an integer,
+or ERR if the window parameter is null.
+.SH NOTES
+All of these interfaces are provided as macros and functions.
+The macros are suppressed (and only the functions provided)
+when \fBNCURSES_OPAQUE\fR is defined.
+The standard forms such as \fBgetyx\fP must be implemented as macros,
+and (in this implementation) are defined in terms of the functions
+described here,
+to avoid reliance on internal details of the WINDOW structure.
+.SH PORTABILITY
+These functions were supported on Version 7, BSD or System V implementations.
+.SH SEE ALSO
+\fBcurses\fR(3),
+\fBcurs_getyx\fR(3),
+\fBcurs_opaque\fR(3)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_mouse.3tbl b/lib/libcurses/curs_mouse.3tbl
index 8c06b5aca66..802fd0c8560 100644
--- a/lib/libcurses/curs_mouse.3tbl
+++ b/lib/libcurses/curs_mouse.3tbl
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: curs_mouse.3tbl,v 1.9 2000/07/10 03:06:08 millert Exp $
+.\" $OpenBSD: curs_mouse.3tbl,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,19 +29,23 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: curs_mouse.3x,v 1.15 2000/07/08 12:50:08 tom Exp $
+.\" $Id: curs_mouse.3tbl,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH curs_mouse 3 ""
+.na
+.hy 0
.SH NAME
\fBgetmouse\fR, \fBungetmouse\fR,
\fBmousemask\fR, \fBwenclose\fR,
\fBmouse_trafo\fR, \fBwmouse_trafo\fR,
\fBmouseinterval\fR - mouse interface through curses
+.ad
+.hy
.SH SYNOPSIS
.nf
-\fB#include <curses.h>\fR
-
+\fB#include <curses.h>
+.PP
\fBtypedef unsigned long mmask_t;
-
+.PP
typedef struct
{
short id; \fI/* ID to distinguish multiple devices */\fB
@@ -57,7 +61,7 @@ MEVENT;\fR
.br
\fBmmask_t mousemask(mmask_t newmask, mmask_t *oldmask);\fR
.br
-\fBbool wenclose(WINDOW *win, int y, int x);\fR
+\fBbool wenclose(const WINDOW *win, int y, int x);\fR
.br
\fBbool mouse_trafo(int* pY, int* pX, bool to_screen);\fR
.br
@@ -69,22 +73,26 @@ MEVENT;\fR
.br
.SH DESCRIPTION
These functions provide an interface to mouse events from
-\fBcurses\fR(3). Mouse events are represented by \fBKEY_MOUSE\fR
+\fBncurses\fR(3).
+Mouse events are represented by \fBKEY_MOUSE\fR
pseudo-key values in the \fBwgetch\fR input stream.
-
-To make mouse events visible, use the \fBmousemask\fR function. This will set
-the mouse events to be reported. By default, no mouse events are reported.
+.PP
+To make mouse events visible, use the \fBmousemask\fR function.
+This will set
+the mouse events to be reported.
+By default, no mouse events are reported.
The function will return a mask to indicate which of the specified mouse events
-can be reported; on complete failure it returns 0. If oldmask is non-NULL,
+can be reported; on complete failure it returns 0.
+If oldmask is non-NULL,
this function fills the indicated location with the previous value of the given
window's mouse event mask.
-
+.PP
As a side effect, setting a zero mousemask may turn off the mouse pointer;
-setting a nonzero mask may turn it on. Whether this happens is
-device-dependent.
-
-Here are the mouse event type masks:
-
+setting a nonzero mask may turn it on.
+Whether this happens is device-dependent.
+.PP
+Here are the mouse event type masks which may be defined:
+.PP
.TS
l l
_ _
@@ -95,122 +103,207 @@ BUTTON1_RELEASED mouse button 1 up
BUTTON1_CLICKED mouse button 1 clicked
BUTTON1_DOUBLE_CLICKED mouse button 1 double clicked
BUTTON1_TRIPLE_CLICKED mouse button 1 triple clicked
+_
BUTTON2_PRESSED mouse button 2 down
BUTTON2_RELEASED mouse button 2 up
BUTTON2_CLICKED mouse button 2 clicked
BUTTON2_DOUBLE_CLICKED mouse button 2 double clicked
BUTTON2_TRIPLE_CLICKED mouse button 2 triple clicked
+_
BUTTON3_PRESSED mouse button 3 down
BUTTON3_RELEASED mouse button 3 up
BUTTON3_CLICKED mouse button 3 clicked
BUTTON3_DOUBLE_CLICKED mouse button 3 double clicked
BUTTON3_TRIPLE_CLICKED mouse button 3 triple clicked
+_
BUTTON4_PRESSED mouse button 4 down
BUTTON4_RELEASED mouse button 4 up
BUTTON4_CLICKED mouse button 4 clicked
BUTTON4_DOUBLE_CLICKED mouse button 4 double clicked
BUTTON4_TRIPLE_CLICKED mouse button 4 triple clicked
+_
+BUTTON5_PRESSED mouse button 5 down
+BUTTON5_RELEASED mouse button 5 up
+BUTTON5_CLICKED mouse button 5 clicked
+BUTTON5_DOUBLE_CLICKED mouse button 5 double clicked
+BUTTON5_TRIPLE_CLICKED mouse button 5 triple clicked
+_
BUTTON_SHIFT shift was down during button state change
BUTTON_CTRL control was down during button state change
BUTTON_ALT alt was down during button state change
ALL_MOUSE_EVENTS report all button state changes
REPORT_MOUSE_POSITION report mouse movement
+_
.TE
-
+.PP
Once a class of mouse events have been made visible in a window,
calling the \fBwgetch\fR function on that window may return
\fBKEY_MOUSE\fR as an indicator that a mouse event has been queued.
To read the event data and pop the event off the queue, call
-\fBgetmouse\fR. This function will return \fBOK\fR if a mouse event
+\fBgetmouse\fR.
+This function will return \fBOK\fR if a mouse event
is actually visible in the given window, \fBERR\fR otherwise.
When \fBgetmouse\fR returns \fBOK\fR, the data deposited as y and
x in the event structure coordinates will be screen-relative character-cell
-coordinates. The returned state mask will have exactly one bit set to
+coordinates.
+The returned state mask will have exactly one bit set to
indicate the event type.
-
-The \fBungetmouse\fR function behaves analogously to \fBungetch\fR. It pushes
+.PP
+The \fBungetmouse\fR function behaves analogously to \fBungetch\fR.
+It pushes
a \fBKEY_MOUSE\fR event onto the input queue, and associates with that event
the given state data and screen-relative character-cell coordinates.
-
+.PP
The \fBwenclose\fR function tests whether a given pair of screen-relative
character-cell coordinates is enclosed by a given window, returning TRUE
-if it is and FALSE otherwise. It is useful for determining what subset of
+if it is and FALSE otherwise.
+It is useful for determining what subset of
the screen windows enclose the location of a mouse event.
-
-The \fBwmouse_trafo\fR function transforms a given pair of coordinates from
-stdscr-relative coordinates to screen-relative coordinates or vice versa.
+.PP
+The \fBwmouse_trafo\fR function transforms a given pair of coordinates
+from stdscr-relative coordinates
+to coordinates relative to the given window or vice versa.
Please remember, that stdscr-relative coordinates are not always identical
-to screen-relative coordinates due to the mechanism to reserve lines on top
-or bottom of the screen for other purposes (ripoff() call, see also slk_...
-functions). If the parameter \fBto_screen\fR is \fBTRUE\fR, the pointers
-\fBpY, pX\fR must reference the coordinates of a location inside the window
-\fBwin\fR. They are converted to screen-relative coordinates and returned
-through the pointers. If the conversion was successful, the function
-returns \fBTRUE\fR. If one of the parameters was NULL or the location is
-not inside the window, \fBFALSE\fR is returned. If \fBto_screen\fR is
-\fBFALSE\fR, the pointers \fBpY, pX\fR must reference screen-relative
-coordinates. They are converted to stdscr-relative coordinates if the
-window \fBwin\fR encloses this point. In this case the function returns
-\fBTRUE\fR. If one of the parameters is NULL or the point is not inside the
-window, \fBFALSE\fR is returned. Please notice, that the referenced coordinates
+to window-relative coordinates due to the mechanism to reserve lines on top
+or bottom of the screen for other purposes
+(see the \fBripoffline()\fP and \fBslk_init\fR calls, for example).
+If the parameter \fBto_screen\fR is \fBTRUE\fR, the pointers
+\fBpY, pX\fR must reference the coordinates of a location
+inside the window \fBwin\fR.
+They are converted to window-relative coordinates and returned
+through the pointers.
+If the conversion was successful, the function returns \fBTRUE\fR.
+If one of the parameters was NULL or the location is
+not inside the window, \fBFALSE\fR is returned.
+If \fBto_screen\fR is
+\fBFALSE\fR, the pointers \fBpY, pX\fR must reference window-relative
+coordinates.
+They are converted to stdscr-relative coordinates if the
+window \fBwin\fR encloses this point.
+In this case the function returns \fBTRUE\fR.
+If one of the parameters is NULL or the point is not inside the
+window, \fBFALSE\fR is returned.
+Please notice, that the referenced coordinates
are only replaced by the converted coordinates if the transformation was
successful.
-
+.PP
+The \fBmouse_trafo\fR function performs the same translation
+as \fBwmouse_trafo\fR,
+using stdscr for \fBwin\fR.
+.PP
The \fBmouseinterval\fR function sets the maximum time (in thousands of a
-second) that can elapse between press and release events in order for them to
-be recognized as a click. This function returns the previous interval value.
-The default is one fifth of a second.
-
+second) that can elapse between press and release events for them to
+be recognized as a click.
+Use \fBmouseinterval(0)\fR to disable click resolution.
+This function returns the previous interval value.
+Use \fBmouseinterval(-1)\fR to obtain the interval without altering it.
+The default is one sixth of a second.
+.PP
Note that mouse events will be ignored when input is in cooked mode, and will
cause an error beep when cooked mode is being simulated in a window by a
function such as \fBgetstr\fR that expects a linefeed for input-loop
termination.
-
.SH RETURN VALUE
-\fBgetmouse\fR, \fBungetmouse\fR and \fBmouseinterval\fR
+\fBgetmouse\fR and \fBungetmouse\fR
return the integer \fBERR\fR upon failure or \fBOK\fR
-upon successful completion. \fBmousemask\fR returns the
-mask of reportable events. \fBwenclose\fR and \fBwmouse_trafo\fR
+upon successful completion.
+.RS
+.TP 5
+\fBgetmouse\fP
+returns an error.
+If no mouse driver was initialized, or
+if the mask parameter is zero,
+.TP 5
+\fBungetmouse\fP
+returns an error if the FIFO is full.
+.RE
+.PP
+\fBmousemask\fR
+returns the mask of reportable events.
+.PP
+\fBmouseinterval\fR
+returns the previous interval value, unless
+the terminal was not initialized.
+In that case, it returns the maximum interval value (166).
+.PP
+\fBwenclose\fR and \fBwmouse_trafo\fR
are boolean functions returning \fBTRUE\fR or \fBFALSE\fR depending
on their test result.
.SH PORTABILITY
-These calls were designed for \fBncurses\fR, and are not found in SVr4
+These calls were designed for \fBncurses\fR(3), and are not found in SVr4
curses, 4.4BSD curses, or any other previous version of curses.
-
+.PP
The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
-can be used to test whether these features are present (its value is 1).
+can be used to test whether these features are present.
If the interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
incremented.
-
+These values for \fBNCURSES_MOUSE_VERSION\fR may be
+specified when configuring ncurses:
+.RS
+.TP 3
+1
+has definitions for reserved events.
+The mask uses 28 bits.
+.TP 3
+2
+adds definitions for button 5,
+removes the definitions for reserved events.
+The mask uses 29 bits.
+.RE
+.PP
The order of the \fBMEVENT\fR structure members is not guaranteed.
Additional fields may be added to the structure in the future.
-
-Under \fBncurses\fR, these calls are implemented using either
-xterm's built-in mouse-tracking API or Alessandro Rubini's gpm server.
-If you are using something other than xterm and there is no gpm daemon
-running on your machine, mouse events will not be visible to
-\fBcurses\fR(3) (and the \fBwmousemask\fR function will always
+.PP
+Under \fBncurses\fR(3), these calls are implemented using either
+xterm's built-in mouse-tracking API or
+platform-specific drivers including
+.RS
+Alessandro Rubini's gpm server.
+.br
+FreeBSD sysmouse
+.br
+OS/2 EMX
+.RE
+If you are using an unsupported configuration,
+mouse events will not be visible to
+\fBncurses\fR(3) (and the \fBmousemask\fR function will always
return \fB0\fR).
-
-The z member in the event structure is not presently used. It is intended
+.PP
+If the terminfo entry contains a \fBXM\fR string,
+this is used in the xterm mouse driver to control the
+way the terminal is initialized for mouse operation.
+The default, if \fBXM\fR is not found,
+corresponds to private mode 1000 of xterm:
+.RS
+\\E[?1000%?%p1%{1}%=%th%el%;
+.RE
+The z member in the event structure is not presently used.
+It is intended
for use with touch screens (which may be pressure-sensitive) or with
3D-mice/trackballs/power gloves.
.SH BUGS
Mouse events under xterm will not in fact be ignored during cooked mode,
-if they have been enabled by \fBwmousemask\fR. Instead, the xterm mouse
+if they have been enabled by \fBmousemask\fR.
+Instead, the xterm mouse
report sequence will appear in the string read.
-
+.PP
Mouse events under xterm will not be detected correctly in a window with
its keypad bit off, since they are interpreted as a variety of function key.
-Your terminfo description must have \fBkmous\fR set to "\\E[M" (the beginning
-of the response from xterm for mouse clicks).
-
+Your terminfo description should have \fBkmous\fR set to "\\E[M"
+(the beginning of the response from xterm for mouse clicks).
+Other values for \fBkmous\fR are permitted,
+but under the same assumption,
+i.e., it is the beginning of the response.
+.PP
Because there are no standard terminal responses that would serve to identify
terminals which support the xterm mouse protocol, \fBncurses\fR assumes that
-if your $DISPLAY environment variable is set, and \fBkmous\fR is defined in
+if your $TERM environment variable contains "xterm",
+or \fBkmous\fR is defined in
the terminal description, then the terminal may send mouse events.
.SH SEE ALSO
-\fBcurses\fR(3).
+\fBcurses\fR(3),
+\fBcurs_kernel\fR(3),
+\fBcurs_slk\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_move.3 b/lib/libcurses/curs_move.3
index 271c1f7a7a1..9244f61405f 100644
--- a/lib/libcurses/curs_move.3
+++ b/lib/libcurses/curs_move.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_move.3,v 1.5 1998/09/13 19:16:20 millert Exp $
+.\" $OpenBSD: curs_move.3,v 1.6 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,13 +28,18 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_move.3x,v 1.6 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_move.3,v 1.6 2010/01/12 23:21:59 nicm Exp $
.TH curs_move 3 ""
+.na
+.hy 0
.SH NAME
-\fBmove\fR, \fBwmove\fR - move \fBcurses\fR window cursor
+\fBmove\fR,
+\fBwmove\fR - move \fBcurses\fR window cursor
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint move(int y, int x);\fR
.br
\fBint wmove(WINDOW *win, int y, int x);\fR
@@ -48,13 +53,14 @@ left-hand corner of the window, which is (0,0).
These routines return \fBERR\fR upon failure and OK (SVr4
specifies only "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+Specifically, they return an error
+if the window pointer is null, or
+if the position is outside the window.
.SH NOTES
Note that \fBmove\fR may be a macro.
.SH PORTABILITY
-These functions are described in the XSI Curses standard, Issue 4. The
-standard specifies that if (y,x) is within a multi-column character, the cursor
-is moved to the first column of that character; however, this implementation
-does not yet support the extended-level XSI multi-byte characters.
+These functions are described in the XSI Curses standard, Issue 4.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_refresh\fR(3)
.\"#
diff --git a/lib/libcurses/curs_opaque.3 b/lib/libcurses/curs_opaque.3
new file mode 100644
index 00000000000..5985f01d03c
--- /dev/null
+++ b/lib/libcurses/curs_opaque.3
@@ -0,0 +1,135 @@
+.\" $OpenBSD: curs_opaque.3,v 1.1 2010/01/12 23:21:59 nicm Exp $
+.\"
+.\"***************************************************************************
+.\" Copyright (c) 2007 Free Software Foundation, Inc. *
+.\" *
+.\" Permission is hereby granted, free of charge, to any person obtaining a *
+.\" copy of this software and associated documentation files (the *
+.\" "Software"), to deal in the Software without restriction, including *
+.\" without limitation the rights to use, copy, modify, merge, publish, *
+.\" distribute, distribute with modifications, sublicense, and/or sell *
+.\" copies of the Software, and to permit persons to whom the Software is *
+.\" furnished to do so, subject to the following conditions: *
+.\" *
+.\" The above copyright notice and this permission notice shall be included *
+.\" in all copies or substantial portions of the Software. *
+.\" *
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+.\" *
+.\" Except as contained in this notice, the name(s) of the above copyright *
+.\" holders shall not be used in advertising or otherwise to promote the *
+.\" sale, use or other dealings in this Software without prior written *
+.\" authorization. *
+.\"***************************************************************************
+.\"
+.\" $Id: curs_opaque.3,v 1.1 2010/01/12 23:21:59 nicm Exp $
+.TH curs_opaque 3 ""
+.na
+.hy 0
+.SH NAME
+\fBis_cleared\fR,
+\fBis_idlok\fR,
+\fBis_idcok\fR,
+\fBis_immedok\fR,
+\fBis_keypad\fR,
+\fBis_leaveok\fR,
+\fBis_nodelay\fR,
+\fBis_timeout\fR,
+\fBis_scrollok\fR,
+\fBis_syncok\fR - \fBcurses\fR window properties
+.ad
+.hy
+.SH SYNOPSIS
+\fB#include <curses.h>\fR
+.sp
+\fBbool is_cleared(const WINDOW *win);\fR
+.br
+\fBbool is_idcok(const WINDOW *win);\fR
+.br
+\fBbool is_idlok(const WINDOW *win);\fR
+.br
+\fBbool is_immedok(const WINDOW *win);\fR
+.br
+\fBbool is_keypad(const WINDOW *win);\fR
+.br
+\fBbool is_leaveok(const WINDOW *win);\fR
+.br
+\fBbool is_nodelay(const WINDOW *win);\fR
+.br
+\fBbool is_notimeout(const WINDOW *win);\fR
+.br
+\fBbool is_scrollok(const WINDOW *win);\fR
+.br
+\fBbool is_syncok(const WINDOW *win);\fR
+.br
+\fBWINDOW * wgetparent(const WINDOW *win);\fR
+.br
+\fBint wgetscrreg(const WINDOW *win, int *top, int *bottom);\fR
+.br
+.SH DESCRIPTION
+This implementation provides functions which return properties
+set in the WINDOW structure, allowing it to be ``opaque'' if
+the symbol \fBNCURSES_OPAQUE\fR is defined:
+.TP 5
+\fBis_cleared\fR
+returns the value set in \fBclearok\fR
+.TP 5
+\fBis_idcok\fR
+returns the value set in \fBidcok\fR
+.TP 5
+\fBis_idlok\fR
+returns the value set in \fBidlok\fR
+.TP 5
+\fBis_immedok\fR
+returns the value set in \fBimmedok\fR
+.TP 5
+\fBis_keypad\fR
+returns the value set in \fBkeypad\fR
+.TP 5
+\fBis_leaveok\fR
+returns the value set in \fBleaveok\fR
+.TP 5
+\fBis_nodelay\fR
+returns the value set in \fBnodelay\fR
+.TP 5
+\fBis_notimeout\fR
+returns the value set in \fBnotimeout\fR
+.TP 5
+\fBis_scrollok\fR
+returns the value set in \fBscrollok\fR
+.TP 5
+\fBis_syncok\fR
+returns the value set in \fBsyncok\fR
+.TP 5
+\fBwgetparent\fR
+returns the parent WINDOW pointer for subwindows,
+or NULL for windows having no parent.
+.TP 5
+\fBwgetscrreg\fR
+returns the top and bottom rows for the scrolling margin as set in \fBwsetscrreg\fP.
+.SH RETURN VALUE
+These functions all return TRUE or FALSE, except as noted.
+.SH NOTES
+Both a macro and a function are provided for each name.
+.SH PORTABILITY
+These routines are specific to ncurses.
+They were not supported on Version 7, BSD or System V implementations.
+It is recommended that any code depending on ncurses extensions
+be conditioned using NCURSES_VERSION.
+.SH SEE ALSO
+\fBcurses\fR(3),
+\fBcurs_inopts\fR(3),
+\fBcurs_outopts\fR(3),
+\fBcurs_window\fR(3)
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/curs_outopts.3 b/lib/libcurses/curs_outopts.3
index f4067e387f9..302b40891a2 100644
--- a/lib/libcurses/curs_outopts.3
+++ b/lib/libcurses/curs_outopts.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_outopts.3,v 1.11 2003/05/12 11:06:49 jmc Exp $
+.\" $OpenBSD: curs_outopts.3,v 1.12 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,15 +28,26 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_outopts.3x,v 1.14 2000/02/27 01:41:58 tom Exp $
+.\" $Id: curs_outopts.3,v 1.12 2010/01/12 23:21:59 nicm Exp $
.TH curs_outopts 3 ""
+.na
+.hy 0
.SH NAME
-\fBclearok\fR, \fBidlok\fR, \fBidcok\fR, \fBimmedok\fR,
-\fBleaveok\fR, \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBscrollok\fR,
-\fBnl\fR, \fBnonl\fR - \fBcurses\fR output options
+\fBclearok\fR,
+\fBidlok\fR,
+\fBidcok\fR,
+\fBimmedok\fR,
+\fBleaveok\fR,
+\fBsetscrreg\fR,
+\fBwsetscrreg\fR,
+\fBscrollok\fR,
+\fBnl\fR,
+\fBnonl\fR - \fBcurses\fR output options
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint clearok(WINDOW *win, bool bf);\fR
.br
\fBint idlok(WINDOW *win, bool bf);\fR
@@ -59,97 +70,139 @@
.br
.SH DESCRIPTION
These routines set options that change the style of output within
-\fBcurses\fR. All options are initially \fBFALSE\fR, unless otherwise stated.
+\fBcurses\fR.
+All options are initially \fBFALSE\fR, unless otherwise stated.
It is not necessary to turn these options off before calling \fBendwin\fR.
-
+.PP
If \fBclearok\fR is called with \fBTRUE\fR as argument, the next
call to \fBwrefresh\fR with this window will clear the screen completely and
-redraw the entire screen from scratch. This is useful when the contents of the
-screen are uncertain, or in some cases for a more pleasing visual effect. If
+redraw the entire screen from scratch.
+This is useful when the contents of the
+screen are uncertain, or in some cases for a more pleasing visual effect.
+If
the \fIwin\fR argument to \fBclearok\fR is the global variable \fBcurscr\fR,
the next call to \fBwrefresh\fR with any window causes the screen to be cleared
and repainted from scratch.
-
+.PP
If \fBidlok\fR is called with \fBTRUE\fR as second argument, \fBcurses\fR
considers using the hardware insert/delete line feature of terminals so
-equipped. Calling \fBidlok\fR with \fBFALSE\fR as second argument disables use
-of line insertion and deletion. This option should be enabled only if the
-application needs insert/delete line, for example, for a screen editor. It is
+equipped.
+Calling \fBidlok\fR with \fBFALSE\fR as second argument disables use
+of line insertion and deletion.
+This option should be enabled only if the
+application needs insert/delete line, for example, for a screen editor.
+It is
disabled by default because insert/delete line tends to be visually annoying
-when used in applications where it isn't really needed. If insert/delete line
+when used in applications where it is not really needed.
+If insert/delete line
cannot be used, \fBcurses\fR redraws the changed portions of all lines.
-
+.PP
If \fBidcok\fR is called with \fBFALSE\fR as second argument, \fBcurses\fR
no longer considers using the hardware insert/delete character feature of
-terminals so equipped. Use of character insert/delete is enabled by default.
+terminals so equipped.
+Use of character insert/delete is enabled by default.
Calling \fBidcok\fR with \fBTRUE\fR as second argument re-enables use
of character insertion and deletion.
-
-If \fBimmedok\fR is called with \fBTRUE\fR as argument, any change
+.PP
+If \fBimmedok\fR is called with \fBTRUE as argument\fR, any change
in the window image, such as the ones caused by \fBwaddch, wclrtobot, wscrl\fR,
-etc., automatically cause a call to \fBwrefresh\fR. However, it may
+etc., automatically cause a call to \fBwrefresh\fR.
+However, it may
degrade performance considerably, due to repeated calls to \fBwrefresh\fR.
It is disabled by default.
-
+.PP
Normally, the hardware cursor is left at the location of the window cursor
-being refreshed. The \fBleaveok\fR option allows the cursor to be left
-wherever the update happens to leave it. It is useful for applications where
-the cursor is not used, since it reduces the need for cursor motions. If
-possible, the cursor is made invisible when this option is enabled.
-
+being refreshed.
+The \fBleaveok\fR option allows the cursor to be left
+wherever the update happens to leave it.
+It is useful for applications where
+the cursor is not used, since it reduces the need for cursor motions.
+.PP
The \fBsetscrreg\fR and \fBwsetscrreg\fR routines allow the application
-programmer to set a software scrolling region in a window. \fItop\fR and
+programmer to set a software scrolling region in a window.
+\fItop\fR and
\fIbot\fR are the line numbers of the top and bottom margin of the scrolling
-region. (Line 0 is the top line of the window.) If this option and
+region.
+(Line 0 is the top line of the window.) If this option and
\fBscrollok\fR are enabled, an attempt to move off the bottom margin line
causes all lines in the scrolling region to scroll one line in the direction
-of the first line. Only the text of the window is scrolled. (Note that this
+of the first line.
+Only the text of the window is scrolled.
+(Note that this
has nothing to do with the use of a physical scrolling region capability in the
-terminal, like that in the VT100. If \fBidlok\fR is enabled and the terminal
+terminal, like that in the VT100.
+If \fBidlok\fR is enabled and the terminal
has either a scrolling region or insert/delete line capability, they will
probably be used by the output routines.)
-
+.PP
The \fBscrollok\fR option controls what happens when the cursor of a window is
moved off the edge of the window or scrolling region, either as a result of a
newline action on the bottom line, or typing the last character of the last
-line. If disabled, (\fIbf\fR is \fBFALSE\fR), the cursor is left on the bottom
-line. If enabled, (\fIbf\fR is \fBTRUE\fR), the window is scrolled up one line
-(Note that in order to get the physical scrolling effect on the terminal, it is
+line.
+If disabled, (\fIbf\fR is \fBFALSE\fR), the cursor is left on the bottom
+line.
+If enabled, (\fIbf\fR is \fBTRUE\fR), the window is scrolled up one line
+(Note that to get the physical scrolling effect on the terminal, it is
also necessary to call \fBidlok\fR).
-
+.PP
The \fBnl\fR and \fBnonl\fR routines control whether the underlying display
device translates the return key into newline on input, and whether it
translates newline into return and line-feed on output (in either case, the
call \fBaddch('\\n')\fR does the equivalent of return and line feed on the
-virtual screen). Initially, these translations do occur. If you disable them
+virtual screen).
+Initially, these translations do occur.
+If you disable them
using \fBnonl\fR, \fBcurses\fR will be able to make better use of the line-feed
-capability, resulting in faster cursor motion. Also, \fBcurses\fR will then be
+capability, resulting in faster cursor motion.
+Also, \fBcurses\fR will then be
able to detect the return key.
.SH RETURN VALUE
The functions \fBsetscrreg\fR and \fBwsetscrreg\fR return \fBOK\fR upon success
-and \fBERR\fR upon failure. All other routines that return an integer always
+and \fBERR\fR upon failure.
+All other routines that return an integer always
return \fBOK\fR.
+.PP
+X/Open does not define any error conditions.
+.PP
+In this implementation, those functions that have a window pointer
+will return an error if the window pointer is null.
+.RS
+.TP 5
+.B wclrtoeol
+returns an error
+if the cursor position is about to wrap.
+.TP 5
+.B wsetscrreg
+returns an error if the scrolling region limits extend outside the window.
+.RE
+.PP
+X/Open does not define any error conditions.
+This implementation returns an error
+if the window pointer is null.
.SH PORTABILITY
These functions are described in the XSI Curses standard, Issue 4.
-
+.PP
The XSI Curses standard is ambiguous on the question of whether \fBraw\fR()
should disable the CRLF translations controlled by \fBnl\fR() and \fBnonl\fR().
BSD curses did turn off these translations; AT&T curses (at least as late as
-SVr1) did not. We choose to do so, on the theory that a programmer requesting
+SVr1) did not.
+We choose to do so, on the theory that a programmer requesting
raw input wants a clean (ideally 8-bit clean) connection that the operating
-system does not mess with.
-
+system will not alter.
+.PP
Some historic curses implementations had, as an undocumented feature, the
ability to do the equivalent of \fBclearok(..., 1)\fR by saying
-\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR. This will not work under
+\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR.
+This will not work under
ncurses.
-
+.PP
Earlier System V curses implementations specified that with \fBscrollok\fR
enabled, any window modification triggering a scroll also forced a physical
-refresh. XSI Curses does not require this, and \fBncurses\fR avoids doing
-it in order to perform better vertical-motion optimization at \fBwrefresh\fR
+refresh.
+XSI Curses does not require this, and \fBncurses\fR avoids doing
+it to perform better vertical-motion optimization at \fBwrefresh\fR
time.
-
+.PP
The XSI Curses standard does not mention that the cursor should be
made invisible as a side-effect of \fBleaveok\fR.
SVr4 curses documentation does this, but the code does not.
@@ -157,7 +210,7 @@ Use \fBcurs_set\fR to make the cursor invisible.
.SH NOTES
Note that \fBclearok\fR, \fBleaveok\fR, \fBscrollok\fR, \fBidcok\fR, \fBnl\fR,
\fBnonl\fR and \fBsetscrreg\fR may be macros.
-
+.PP
The \fBimmedok\fR routine is useful for windows that are used as terminal
emulators.
.SH SEE ALSO
diff --git a/lib/libcurses/curs_overlay.3 b/lib/libcurses/curs_overlay.3
index 4a3a31627b2..1c82f91bc93 100644
--- a/lib/libcurses/curs_overlay.3
+++ b/lib/libcurses/curs_overlay.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_overlay.3,v 1.7 2000/07/10 03:06:08 millert Exp $
+.\" $OpenBSD: curs_overlay.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,20 +28,24 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_overlay.3x,v 1.9 2000/07/01 20:05:31 tom Exp $
+.\" $Id: curs_overlay.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_overlay 3 ""
+.na
+.hy 0
.SH NAME
\fBoverlay\fR,
\fBoverwrite\fR,
\fBcopywin\fR - overlay and manipulate overlapped \fBcurses\fR windows
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint overlay(const WINDOW *srcwin, WINDOW *dstwin);\fR
.br
\fBint overwrite(const WINDOW *srcwin, WINDOW *dstwin);\fR
.br
-\fBint copywin(WINDOW *srcwin, WINDOW *dstwin, int sminrow,\fR
+\fBint copywin(const WINDOW *srcwin, WINDOW *dstwin, int sminrow,\fR
\fBint smincol, int dminrow, int dmincol, int dmaxrow,\fR
\fBint dmaxcol, int overlay);\fR
.SH DESCRIPTION
@@ -50,7 +54,7 @@ top of \fIdstwin\fR. \fIscrwin\fR and \fIdstwin\fR are not required
to be the same size; only text where the two windows overlap is
copied. The difference is that \fBoverlay\fR is non-destructive
(blanks are not copied) whereas \fBoverwrite\fR is destructive.
-
+.PP
The \fBcopywin\fR routine provides a finer granularity of control over the
\fBoverlay\fR and \fBoverwrite\fR routines. Like in the \fBprefresh\fR
routine, a rectangle is specified in the destination window, (\fIdminrow\fR,
@@ -62,12 +66,19 @@ argument \fIoverlay\fR is \fBtrue\fR, then copying is non-destructive, as in
Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+\fBcopywin\fP,
+\fBoverlay\fP and \fBoverwrite\fP return an error
+if either of the window pointers are null, or
+if some part of the window would be placed off-screen.
.SH NOTES
Note that \fBoverlay\fR and \fBoverwrite\fR may be macros.
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions (adding the const
qualifiers). It further specifies their behavior in the presence of characters
-with multi-byte renditions (not yet supported in this implementation).
+with multibyte renditions (not yet supported in this implementation).
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_pad\fR(3), \fBcurs_refresh\fR(3)
.\"#
diff --git a/lib/libcurses/curs_pad.3 b/lib/libcurses/curs_pad.3
index 9544c759a33..8562f93d035 100644
--- a/lib/libcurses/curs_pad.3
+++ b/lib/libcurses/curs_pad.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_pad.3,v 1.8 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: curs_pad.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,14 +28,22 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_pad.3x,v 1.9 2000/07/04 22:38:13 tom Exp $
+.\" $Id: curs_pad.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.TH curs_pad 3 ""
+.na
+.hy 0
.SH NAME
-\fBnewpad\fR, \fBsubpad\fR, \fBprefresh\fR,
-\fBpnoutrefresh\fR, \fBpechochar\fR - create and display \fBcurses\fR pads
+\fBnewpad\fR,
+\fBsubpad\fR,
+\fBprefresh\fR,
+\fBpnoutrefresh\fR,
+\fBpechochar\fR,
+\fBpecho_wchar\fR - create and display \fBcurses\fR pads
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBWINDOW *newpad(int nlines, int ncols);\fR
.br
\fBWINDOW *subpad(WINDOW *orig, int nlines, int ncols,\fR
@@ -48,56 +56,100 @@
\fBint sminrow, int smincol, int smaxrow, int smaxcol);\fR
.br
\fBint pechochar(WINDOW *pad, chtype ch);\fR
+.br
+\fBint pecho_wchar(WINDOW *pad, const cchar_t *wch);\fR
.SH DESCRIPTION
The \fBnewpad\fR routine creates and returns a pointer to a new pad data
structure with the given number of lines, \fInlines\fR, and columns,
-\fIncols\fR. A pad is like a window, except that it is not restricted by the
+\fIncols\fR.
+A pad is like a window, except that it is not restricted by the
screen size, and is not necessarily associated with a particular part of the
-screen. Pads can be used when a large window is needed, and only a part of the
-window will be on the screen at one time. Automatic refreshes of pads
-(e.g., from scrolling or echoing of input) do not occur. It is not
+screen.
+Pads can be used when a large window is needed, and only a part of the
+window will be on the screen at one time.
+Automatic refreshes of pads
+(e.g., from scrolling or echoing of input) do not occur.
+It is not
legal to call \fBwrefresh\fR with a \fIpad\fR as an argument; the routines
-\fBprefresh\fR or \fBpnoutrefresh\fR should be called instead. Note that these
+\fBprefresh\fR or \fBpnoutrefresh\fR should be called instead.
+Note that these
routines require additional parameters to specify the part of the pad to be
displayed and the location on the screen to be used for the display.
-
+.PP
The \fBsubpad\fR routine creates and returns a pointer to a subwindow within a
pad with the given number of lines, \fInlines\fR, and columns, \fIncols\fR.
Unlike \fBsubwin\fR, which uses screen coordinates, the window is at position
-(\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad. The window is
+(\fIbegin\fR_\fIx\fR\fB,\fR \fIbegin\fR_\fIy\fR) on the pad.
+The window is
made in the middle of the window \fIorig\fR, so that changes made to one window
-affect both windows. During the use of this routine, it will often be
+affect both windows.
+During the use of this routine, it will often be
necessary to call \fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before
calling \fBprefresh\fR.
-
+.PP
The \fBprefresh\fR and \fBpnoutrefresh\fR routines are analogous to
\fBwrefresh\fR and \fBwnoutrefresh\fR except that they relate to pads instead
-of windows. The additional parameters are needed to indicate what part of the
-pad and screen are involved. \fIpminrow\fR and \fIpmincol\fR specify the upper
-left-hand corner of the rectangle to be displayed in the pad. \fIsminrow\fR,
+of windows.
+The additional parameters are needed to indicate what part of the
+pad and screen are involved.
+\fIpminrow\fR and \fIpmincol\fR specify the upper
+left-hand corner of the rectangle to be displayed in the pad.
+\fIsminrow\fR,
\fIsmincol\fR, \fIsmaxrow\fR, and \fIsmaxcol\fR specify the edges of the
-rectangle to be displayed on the screen. The lower right-hand corner of the
+rectangle to be displayed on the screen.
+The lower right-hand corner of the
rectangle to be displayed in the pad is calculated from the screen coordinates,
-since the rectangles must be the same size. Both rectangles must be entirely
-contained within their respective structures. Negative values of
+since the rectangles must be the same size.
+Both rectangles must be entirely
+contained within their respective structures.
+Negative values of
\fIpminrow\fR, \fIpmincol\fR, \fIsminrow\fR, or \fIsmincol\fR are treated as if
they were zero.
-
+.PP
The \fBpechochar\fR routine is functionally equivalent to a call to \fBaddch\fR
followed by a call to \fBrefresh\fR, a call to \fBwaddch\fR followed by a call
to \fBwrefresh\fR, or a call to \fBwaddch\fR followed by a call to
-\fBprefresh\fR. The knowledge that only a single character is being output is
+\fBprefresh\fR.
+The knowledge that only a single character is being output is
taken into consideration and, for non-control characters, a considerable
performance gain might be seen by using these routines instead of their
-equivalents. In the case of \fBpechochar\fR, the last location of the pad on
+equivalents.
+In the case of \fBpechochar\fR, the last location of the pad on
the screen is reused for the arguments to \fBprefresh\fR.
+.PP
+The \fBpecho_wchar\fR function is the analogous wide-character
+form of \fBpechochar\fR.
+It outputs one character to a pad and immediately refreshes the pad.
+It does this by a call to \fBwadd_wch\fR followed by a call to \fBprefresh\fR.
.SH RETURN VALUE
Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion.
-
+.PP
Routines that return pointers return \fBNULL\fR on error, and set \fBerrno\fR
to \fBENOMEM\fR.
+.PP
+X/Open does not define any error conditions.
+In this implementation
+.RS
+.TP 5
+\fBprefresh\fP and \fBpnoutrefresh\fP
+return an error
+if the window pointer is null, or
+if the window is not really a pad or
+if the area to refresh extends off-screen or
+if the minimum coordinates are greater than the maximum.
+.TP 5
+\fBpechochar\fP
+returns an error
+if the window is not really a pad, and the associated call
+to \fBwechochar\fP returns an error.
+.TP 5
+\fBpecho_wchar\fP
+returns an error
+if the window is not really a pad, and the associated call
+to \fBwecho_wchar\fP returns an error.
+.RE
.SH NOTES
Note that \fBpechochar\fR may be a macro.
.SH PORTABILITY
diff --git a/lib/libcurses/curs_print.3 b/lib/libcurses/curs_print.3
index b598ef04575..ad2c33f5fbc 100644
--- a/lib/libcurses/curs_print.3
+++ b/lib/libcurses/curs_print.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_print.3,v 1.8 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: curs_print.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,40 +28,40 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: curs_print.3x,v 1.3 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_print.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.TH curs_print 3 ""
.SH NAME
\fBmcprint\fR - ship binary data to printer
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint mcprint(char *data, int len);\fR
.SH DESCRIPTION
This function uses the \fBmc5p\fR or \fBmc4\fR and \fBmc5\fR capabilities,
if they are present, to ship given data to a printer attached to the terminal.
-
+.PP
Note that the \fBmcprint\fR code has no way to do flow control with the printer
or to know how much buffering it has. Your application is responsible for
keeping the rate of writes to the printer below its continuous throughput rate
(typically about half of its nominal cps rating). Dot-matrix printers and
6-page-per-minute lasers can typically handle 80cps, so a good conservative
rule of thumb is to sleep for a second after shipping each 80-character line.
-
+.
.SH RETURN VALUE
The \fBmcprint\fR function returns \fBERR\fR if the write operation aborted
for some reason. In this case, errno will contain either an error associated
with \fBwrite(2)\fR or one of the following:
.TP 5
ENODEV
-Capabilities for printer redirection don't exist.
+Capabilities for printer redirection do not exist.
.TP 5
ENOMEM
Couldn't allocate sufficient memory to buffer the printer write.
-
+.PP
When \fBmcprint\fR succeeds, it returns the number of characters actually
sent to the printer.
.SH PORTABILITY
-The \fBmcprint\fR call was designed for \fBncurses\fR, and is not found
+The \fBmcprint\fR call was designed for \fBncurses\fR(3), and is not found
in SVr4 curses, 4.4BSD curses, or any other previous version of curses.
.SH BUGS
Padding in the \fBmc5p\fR, \fBmc4\fR and \fBmc5\fR capabilities will not be
diff --git a/lib/libcurses/curs_printw.3 b/lib/libcurses/curs_printw.3
index 1b1fefc2644..02333f945aa 100644
--- a/lib/libcurses/curs_printw.3
+++ b/lib/libcurses/curs_printw.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_printw.3,v 1.10 2001/07/27 05:32:05 millert Exp $
+.\" $OpenBSD: curs_printw.3,v 1.11 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,50 +28,64 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_printw.3x,v 1.11 2000/07/01 20:11:32 tom Exp $
+.\" $Id: curs_printw.3,v 1.11 2010/01/12 23:21:59 nicm Exp $
.TH curs_printw 3 ""
+.na
+.hy 0
.SH NAME
\fBprintw\fR,
\fBwprintw\fR,
\fBmvprintw\fR,
\fBmvwprintw\fR,
\fBvwprintw\fR, \fBvw_printw\fR - print formatted output in \fBcurses\fR windows
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
-\fBint printw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.sp
+\fBint printw(const char *fmt, ...);\fR
.br
-\fBint wprintw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+\fBint wprintw(WINDOW *win, const char *fmt, ...);\fR
.br
-\fBint mvprintw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+\fBint mvprintw(int y, int x, const char *fmt, ...);\fR
.br
-\fBint mvwprintw(WINDOW *win, int y, int x,\fR
- \fBchar *fmt\fR [\fB, arg]\fR ...);
-
-\fB#include <stdarg.h>\fR
+\fBint mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...);\fR
.br
-\fBint vwprintw(WINDOW *win, char *fmt, varglist);\fR
+\fBint vwprintw(WINDOW *win, const char *fmt, va_list varglist);\fR
.br
-\fBint vw_printw(WINDOW *win, char *fmt, varglist);\fR
+\fBint vw_printw(WINDOW *win, const char *fmt, va_list varglist);\fR
.br
.SH DESCRIPTION
The \fBprintw\fR, \fBwprintw\fR, \fBmvprintw\fR and \fBmvwprintw\fR
routines are analogous to \fBprintf\fR [see \fBprintf\fR(3)]. In
effect, the string that would be output by \fBprintf\fR is output
instead as though \fBwaddstr\fR were used on the given window.
-
-The \fBvwprintw\fR routine is analogous to \fBvprintf\fR [see
-\fBprintf\fR(3)] and performs a \fBwprintw\fR using a variable
-argument list. The third argument is a \fBva_list\fR, a pointer to a
+.PP
+The \fBvwprintw\fR and \fBwv_printw\fR routines are analogous
+to \fBvprintf\fR [see \fBprintf\fR(3)]
+and perform a \fBwprintw\fR using a variable argument list.
+The third argument is a \fBva_list\fR, a pointer to a
list of arguments, as defined in \fB<stdarg.h>\fR.
.SH RETURN VALUE
Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+an error may be returned if it cannot allocate enough memory for the
+buffer used to format the results.
+It will return an error if the window pointer is null.
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions. The function
\fBvwprintw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
\fBvw_printw\fR using the \fB<stdarg.h>\fR interface.
+The Single Unix Specification, Version 2 states that
+\fBvw_printw\fR is preferred to \fBvwprintw\fR since the latter requires
+including \fB<varargs.h>\fR, which
+cannot be used in the same file as \fB<stdarg.h>\fR.
+This implementation uses \fB<stdarg.h>\fR for both, because that header
+is included in \fB<curses.h\fR>.
.SH SEE ALSO
\fBcurses\fR(3), \fBprintf\fR(3), \fBvprintf(3)\fR
.\"#
diff --git a/lib/libcurses/curs_refresh.3 b/lib/libcurses/curs_refresh.3
index 3968930ce13..b9c53bd85a4 100644
--- a/lib/libcurses/curs_refresh.3
+++ b/lib/libcurses/curs_refresh.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_refresh.3,v 1.6 2000/07/10 03:06:08 millert Exp $
+.\" $OpenBSD: curs_refresh.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2001,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,18 +28,22 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_refresh.3x,v 1.8 2000/07/01 20:06:14 tom Exp $
+.\" $Id: curs_refresh.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.TH curs_refresh 3 ""
+.na
+.hy 0
.SH NAME
-\fBrefresh\fR,
-\fBwrefresh\fR,
-\fBwnoutrefresh\fR,
\fBdoupdate\fR,
\fBredrawwin\fR,
-\fBwredrawln\fR - refresh \fBcurses\fR windows and lines
+\fBrefresh\fR,
+\fBwnoutrefresh\fR,
+\fBwredrawln\fR,
+\fBwrefresh\fR - refresh \fBcurses\fR windows and lines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint refresh(void);\fR
.br
\fBint wrefresh(WINDOW *win);\fR
@@ -55,39 +59,48 @@
.SH DESCRIPTION
The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
\fBdoupdate\fR) must be called to get actual output to the terminal, as other
-routines merely manipulate data structures. The routine \fBwrefresh\fR copies
+routines merely manipulate data structures.
+The routine \fBwrefresh\fR copies
the named window to the physical terminal screen, taking into account what is
-already there in order to do optimizations. The \fBrefresh\fR routine is the
-same, using \fBstdscr\fR as the default window. Unless \fBleaveok\fR has been
+already there to do optimizations.
+The \fBrefresh\fR routine is the
+same, using \fBstdscr\fR as the default window.
+Unless \fBleaveok\fR has been
enabled, the physical cursor of the terminal is left at the location of the
cursor for that window.
-
+.PP
The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
-more efficiency than \fBwrefresh\fR alone. In addition to all the window
+more efficiency than \fBwrefresh\fR alone.
+In addition to all the window
structures, \fBcurses\fR keeps two data structures representing the terminal
screen: a physical screen, describing what is actually on the screen, and a
virtual screen, describing what the programmer wants to have on the screen.
-
+.PP
The routine \fBwrefresh\fR works by first calling \fBwnoutrefresh\fR, which
copies the named window to the virtual screen, and then calling \fBdoupdate\fR,
which compares the virtual screen to the physical screen and does the actual
-update. If the programmer wishes to output several windows at once, a series
+update.
+If the programmer wishes to output several windows at once, a series
of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
-and \fBdoupdate\fR, causing several bursts of output to the screen. By first
+and \fBdoupdate\fR, causing several bursts of output to the screen.
+By first
calling \fBwnoutrefresh\fR for each window, it is then possible to call
\fBdoupdate\fR once, resulting in only one burst of output, with fewer total
-characters transmitted and less CPU time used. If the \fIwin\fR argument to
+characters transmitted and less CPU time used.
+If the \fIwin\fR argument to
\fBwrefresh\fR is the global variable \fBcurscr\fR, the screen is immediately
cleared and repainted from scratch.
-
+.PP
The phrase "copies the named window to the virtual screen" above is ambiguous.
What actually happens is that all \fItouched\fR (changed) lines in the window
-are copied to the virtual screen. This affects programs that use overlapping
+are copied to the virtual screen.
+This affects programs that use overlapping
windows; it means that if two windows overlap, you can refresh them in either
order and the overlap region will be modified only when it is explicitly
-changed. (But see the section on \fBPORTABILITY\fR below for a warning about
+changed.
+(But see the section on \fBPORTABILITY\fR below for a warning about
exploiting this behavior.)
-
+.PP
The \fBwredrawln\fR routine indicates to \fBcurses\fR that some screen lines
are corrupted and should be thrown away before anything is written over them.
It touches the indicated lines (marking them changed).
@@ -96,16 +109,32 @@ The routine \fBredrawwin\fR() touches the entire window.
Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion.
+.PP
+X/Open does not define any error conditions.
+In this implementation
+.RS
+.TP 5
+\fBwnoutrefresh\fP
+returns an error
+if the window pointer is null, or
+if the window is really a pad.
+.TP 5
+\fBwredrawln\fP
+returns an error
+if the associated call to \fBtouchln\fP returns an error.
+.RE
.SH NOTES
Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions.
-
+.PP
Whether \fBwnoutrefresh()\fR copies to the virtual screen the entire contents
of a window or just its changed portions has never been well-documented in
-historic curses versions (including SVr4). It might be unwise to rely on
+historic curses versions (including SVr4).
+It might be unwise to rely on
either behavior in programs that might have to be linked with other curses
-implementations. Instead, you can do an explicit \fBtouchwin()\fR before the
+implementations.
+Instead, you can do an explicit \fBtouchwin()\fR before the
\fBwnoutrefresh()\fR call to guarantee an entire-contents copy anywhere.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_outopts\fR(3)
diff --git a/lib/libcurses/curs_scanw.3 b/lib/libcurses/curs_scanw.3
index 0509a3e9b88..4e287ec0aea 100644
--- a/lib/libcurses/curs_scanw.3
+++ b/lib/libcurses/curs_scanw.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_scanw.3,v 1.10 2001/07/27 05:32:05 millert Exp $
+.\" $OpenBSD: curs_scanw.3,v 1.11 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2000,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_scanw.3x,v 1.11 2000/07/15 21:48:17 tom Exp $
+.\" $Id: curs_scanw.3,v 1.11 2010/01/12 23:21:59 nicm Exp $
.TH curs_scanw 3 ""
.SH NAME
\fBscanw\fR,
@@ -38,15 +38,14 @@
\fBvwscanw\fR, \fBvw_scanw\fR - convert formatted input from a \fBcurses\fR window
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
-\fBint scanw(char *fmt\fR [\fB, arg\fR] \fB...);\fR
+.sp
+\fBint scanw(char *fmt, ...);\fR
.br
-\fBint wscanw(WINDOW *win, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+\fBint wscanw(WINDOW *win, char *fmt, ...);\fR
.br
-\fBint mvscanw(int y, int x, char *fmt\fR [\fB, arg\fR] \fB...);\fR
+\fBint mvscanw(int y, int x, char *fmt, ...);\fR
.br
-\fBint mvwscanw(WINDOW *win, int y, int x,\fR
- \fBchar *fmt\fR [\fB, arg]\fR \fB...);\fR
+\fBint mvwscanw(WINDOW *win, int y, int x, char *fmt, ...);\fR
.br
\fBint vw_scanw(WINDOW *win, char *fmt, va_list varglist);\fR
.br
@@ -57,15 +56,15 @@ The \fBscanw\fR, \fBwscanw\fR and \fBmvscanw\fR routines are analogous to
\fBwgetstr\fR were called on the window, and the resulting line used as input
for \fBsscanf\fR(3). Fields which do not map to a variable in the \fIfmt\fR
field are lost.
-
-The \fBvwscanw\fR routine is similar to \fBvwprintw\fR in that it performs a
-\fBwscanw\fR using a variable argument list. The third argument is a
-\fIva\fR_\fIlist\fR, a pointer to a list of arguments, as defined in
-\fB<stdarg.h>\fR.
+.PP
+The \fBvwscanw\fR and \fBvw_scanw\fR routines are analogous to \fBvscanf\fR.
+They perform a \fBwscanw\fR using a variable argument list.
+The third argument is a \fIva_list\fR,
+a pointer to a list of arguments, as defined in \fB<stdarg.h>\fR.
.SH RETURN VALUE
\fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
number of fields scanned on success.
-
+.PP
Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
\fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
which were mapped in the call.
@@ -73,6 +72,23 @@ which were mapped in the call.
The XSI Curses standard, Issue 4 describes these functions. The function
\fBvwscanw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
\fBvw_scanw\fR using the \fB<stdarg.h>\fR interface.
+The Single Unix Specification, Version 2 states that
+\fBvw_scanw\fR is preferred to \fBvwscanw\fR since the latter requires
+including \fB<varargs.h>\fR, which
+cannot be used in the same file as \fB<stdarg.h>\fR.
+This implementation uses \fB<stdarg.h>\fR for both, because that header
+is included in \fB<curses.h\fR>.
+.LP
+Both XSI and The Single Unix Specification, Version 2 state that these
+functions return ERR or OK.
+Since the underlying \fBscanf\fR can return the number of items scanned,
+and the SVr4 code was documented to use this feature,
+this is probably an editing error which was introduced in XSI,
+rather than being done intentionally.
+Portable applications should only test if the return value is ERR,
+since the OK value (zero) is likely to be misleading.
+One possible way to get useful results would be to use a "%n" conversion
+at the end of the format string to ensure that something was processed.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_getstr\fR(3), \fBcurs_printw\fR(3), \fBscanf\fR(3)
.\"#
diff --git a/lib/libcurses/curs_scr_dump.3 b/lib/libcurses/curs_scr_dump.3
index 4026e87ec1a..168ae84f75b 100644
--- a/lib/libcurses/curs_scr_dump.3
+++ b/lib/libcurses/curs_scr_dump.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_scr_dump.3,v 1.2 2000/07/10 03:06:08 millert Exp $
+.\" $OpenBSD: curs_scr_dump.3,v 1.3 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,16 +28,20 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_scr_dump.3x,v 1.2 2000/07/01 20:06:53 tom Exp $
+.\" $Id: curs_scr_dump.3,v 1.3 2010/01/12 23:21:59 nicm Exp $
.TH curs_scr_dump 3 ""
+.na
+.hy 0
.SH NAME
\fBscr_dump\fR,
\fBscr_restore\fR,
\fBscr_init\fR,
\fBscr_set\fR - read (write) a \fBcurses\fR screen from (to) a file
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint scr_dump(const char *filename);\fR
.br
\fBint scr_restore(const char *filename);\fR
@@ -49,41 +53,45 @@
.SH DESCRIPTION
The \fBscr_dump\fR routine dumps the current contents of the virtual screen
to the file \fIfilename\fR.
-
+.PP
The \fBscr_restore\fR routine sets the virtual screen to the contents
of \fIfilename\fR, which must have been written using \fBscr_dump\fR. The next
call to \fBdoupdate\fR restores the screen to the way it looked in the dump
file.
-
+.PP
The \fBscr_init\fR routine reads in the contents of \fIfilename\fR and uses
them to initialize the \fBcurses\fR data structures about what the terminal
currently has on its screen. If the data is determined to be valid,
\fBcurses\fR bases its next update of the screen on this information rather
than clearing the screen and starting from scratch. \fBscr_init\fR is used
-after \fBinitscr\fR or a \fBsystem\fR [see \fBsystem\fR(BA_LIB)] call to share
+after \fBinitscr\fR or a \fBsystem\fR call to share
the screen with another process which has done a \fBscr_dump\fR after its
\fBendwin\fR call. The data is declared invalid if the terminfo capabilities
\fBrmcup\fR and \fBnrrmc\fR exist; also if the terminal has been written to
since the preceding \fBscr_dump\fR call.
-
+.PP
The \fBscr_set\fR routine is a combination of \fBscr_restore\fR and
\fBscr_init\fR. It tells the program that the information in \fIfilename\fR is
what is currently on the screen, and also what the program wants on the screen.
This can be thought of as a screen inheritance function.
-
+.PP
To read (write) a window from (to) a file, use the \fBgetwin\fR and
\fBputwin\fR routines [see \fBcurs_util\fR(3)].
.SH RETURN VALUE
All routines return the integer \fBERR\fR upon failure and \fBOK\fR
upon success.
+.PP
+X/Open defines no error conditions.
+In this implementation,
+each will return an error if the file cannot be opened.
.SH NOTES
Note that \fBscr_init\fR, \fBscr_set\fR, and \fBscr_restore\fR may be macros.
.SH PORTABILITY
The XSI Curses standard, Issue 4, describes these functions (adding the const
qualifiers).
-
+.PP
The SVr4 docs merely say under \fBscr_init\fR that the dump data is also
-considered invalid "if the time-stamp of the tty is old" but don't define
+considered invalid "if the time-stamp of the tty is old" but do not define
"old".
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_refresh\fR(3),
diff --git a/lib/libcurses/curs_scroll.3 b/lib/libcurses/curs_scroll.3
index df86d4792c9..b88c95ed1ea 100644
--- a/lib/libcurses/curs_scroll.3
+++ b/lib/libcurses/curs_scroll.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_scroll.3,v 1.8 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: curs_scroll.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,13 +28,19 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_scroll.3x,v 1.8 2000/07/01 17:54:23 tom Exp $
+.\" $Id: curs_scroll.3,v 1.9 2010/01/12 23:21:59 nicm Exp $
.TH curs_scroll 3 ""
+.na
+.hy 0
.SH NAME
-\fBscroll\fR, \fBscrl\fR, \fBwscrl\fR - scroll a \fBcurses\fR window
+\fBscroll\fR,
+\fBscrl\fR,
+\fBwscrl\fR - scroll a \fBcurses\fR window
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint scroll(WINDOW *win);\fR
.br
\fBint scrl(int n);\fR
@@ -42,29 +48,40 @@
\fBint wscrl(WINDOW *win, int n);\fR
.br
.SH DESCRIPTION
-The \fBscroll\fR routine scrolls the window up one line. This involves moving
-the lines in the window data structure. As an optimization, if the scrolling
+The \fBscroll\fR routine scrolls the window up one line.
+This involves moving
+the lines in the window data structure.
+As an optimization, if the scrolling
region of the window is the entire screen, the physical screen may be scrolled
at the same time.
-
+.PP
For positive \fIn\fR, the \fBscrl\fR and \fBwscrl\fR routines scroll the
window up \fIn\fR lines (line \fIi\fR+\fIn\fR becomes \fIi\fR); otherwise
-scroll the window down \fIn\fR lines. This involves moving the lines in the
-window character image structure. The current cursor position is not changed.
-
+scroll the window down \fIn\fR lines.
+This involves moving the lines in the
+window character image structure.
+The current cursor position is not changed.
+.PP
For these functions to work, scrolling must be enabled via \fBscrollok\fR.
.SH RETURN VALUE
These routines return \fBERR\fR upon failure, and \fBOK\fR (SVr4 only specifies
"an integer value other than \fBERR\fR") upon successful completion.
+.PP
+X/Open defines no error conditions.
+.PP
+This implementation returns an error
+if the window pointer is null, or
+if scrolling is not enabled in the window, e.g., with \fBscrollok\fP.
.SH NOTES
Note that \fBscrl\fR and \fBscroll\fR may be macros.
-
+.PP
The SVr4 documentation says that the optimization of physically scrolling
immediately if the scroll region is the entire screen "is" performed, not
-"may be" performed. This implementation deliberately does not guarantee
-that this will occur, in order to leave open the possibility of smarter
+"may be" performed.
+This implementation deliberately does not guarantee
+that this will occur, to leave open the possibility of smarter
optimization of multiple scroll actions on the next update.
-
+.PP
Neither the SVr4 nor the XSI documentation specify whether the current
attribute or
current color-pair of blanks generated by the scroll function is zeroed.
diff --git a/lib/libcurses/curs_slk.3 b/lib/libcurses/curs_slk.3
index 41f21ead54a..ff4dc2cc90c 100644
--- a/lib/libcurses/curs_slk.3
+++ b/lib/libcurses/curs_slk.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_slk.3,v 1.9 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: curs_slk.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,18 +28,32 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_slk.3x,v 1.10 2000/07/01 17:52:44 tom Exp $
+.\" $Id: curs_slk.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH curs_slk 3 ""
+.na
+.hy 0
.SH NAME
-\fBslk_init\fR, \fBslk_set\fR, \fBslk_refresh\fR,
-\fBslk_noutrefresh\fR, \fBslk_label\fR,
-\fBslk_clear\fR, \fBslk_restore\fR, \fBslk_touch\fR,
-\fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR,
-\fBslk_attr_on\fR, \fBslk_attr_set\fR, \fBslk_attr_off\fR,
-\fBslk_attr\fR, \fBslk_color\fR - \fBcurses\fR soft label routines
+\fBslk_init\fR,
+\fBslk_set\fR,
+\fBslk_refresh\fR,
+\fBslk_noutrefresh\fR,
+\fBslk_label\fR,
+\fBslk_clear\fR,
+\fBslk_restore\fR,
+\fBslk_touch\fR,
+\fBslk_attron\fR,
+\fBslk_attrset\fR,
+\fBslk_attroff\fR,
+\fBslk_attr_on\fR,
+\fBslk_attr_set\fR,
+\fBslk_attr_off\fR,
+\fBslk_attr\fR,
+\fBslk_color\fR - \fBcurses\fR soft label routines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint slk_init(int fmt);\fR
.br
\fBint slk_set(int labnum, const char *label, int fmt);\fR
@@ -83,9 +97,9 @@ labels of up to eight characters each. In addition to this, the ncurses
implementation supports a mode where it simulates 12 labels of up to five
characters each. This is most common for todays PC like enduser devices.
Please note that ncurses simulates this mode by taking over up to two lines at
-the bottom of the screen, it doesn't try to use any hardware support for this
+the bottom of the screen, it does not try to use any hardware support for this
mode.
-
+.PP
The \fBslk_init\fR routine must be called before \fBinitscr\fR or \fBnewterm\fR
is called. If \fBinitscr\fR eventually uses a line from \fBstdscr\fR to
emulate the soft labels, then \fIfmt\fR determines how the labels are arranged
@@ -94,7 +108,7 @@ the labels, \fB1\fR indicates a 4-4 arrangement and \fB2\fR indicates the
PC like 4-4-4 mode. If \fBfmt\fR is set to \fB3\fR, it is again the PC like
4-4-4 mode, but in addition an index line is generated, helping the user to
identify the key numbers easily.
-
+.PP
The \fBslk_set\fR routine requires \fIlabnum\fR to be a label number,
from \fB1\fR to \fB8\fR (resp. \fB12\fR); \fIlabel\fR must be the string
to be put on the label, up to eight (resp. five) characters in length.
@@ -102,36 +116,78 @@ A null string or a null pointer sets up a blank label. \fIfmt\fR is either
\fB0\fR, \fB1\fR, or \fB2\fR, indicating whether the label is to be
left-justified, centered, or right-justified, respectively, within the
label.
-
+.PP
The \fBslk_refresh\fR and \fBslk_noutrefresh\fR routines correspond to
the \fBwrefresh\fR and \fBwnoutrefresh\fR routines.
-
+.PP
The \fBslk_label\fR routine returns the current label for label number
\fIlabnum\fR, with leading and trailing blanks stripped.
-
+.PP
The \fBslk_clear\fR routine clears the soft labels from the screen.
-
+.PP
The \fBslk_restore\fR routine restores the soft labels to the screen
after a \fBslk_clear\fR has been performed.
-
+.PP
The \fBslk_touch\fR routine forces all the soft labels to be output
the next time a \fBslk_noutrefresh\fR is performed.
-
+.PP
The \fBslk_attron\fR, \fBslk_attrset\fR, \fBslk_attroff\fR and \fBslk_attr\fR
routines correspond to \fBattron\fR, \fBattrset\fR, \fBattroff\fR and \fBattr_get\fR.
They have an effect only if soft labels are simulated on the bottom line of
the screen. The default highlight for soft keys is A_STANDOUT (as in
System V curses, which does not document this fact).
-
+.PP
The \fBslk_color\fR routine corresponds to \fBcolor_set\fR. It has an effect only
if soft labels are simulated on the bottom line of the screen.
-
+.
.SH RETURN VALUE
These routines return \fBERR\fR upon failure and OK (SVr4 specifies only "an
-integer value other than \fBERR\fR") upon successful completion. \fBslk_attr\fR
+integer value other than \fBERR\fR") upon successful completion.
+.PP
+X/Open defines no error conditions.
+In this implementation
+.RS
+.TP 5
+\fBslk_attr\fR
returns the attribute used for the soft keys.
-
-\fBslk_label\fR returns \fBNULL\fR on error.
+.TP 5
+.na
+.hy 0
+\fBslk_attroff\fP, \fBslk_attron\fP, \fBslk_clear\fP, \fBslk_noutrefresh\fP, \fBslk_refresh\fP, \fBslk_touch\fP
+.ad
+.hy
+return an error
+if the terminal or the softkeys were not initialized.
+.TP 5
+\fBslk_attrset\fP
+returns an error
+if the terminal or the softkeys were not initialized.
+.TP 5
+\fBslk_attr_set\fP
+returns an error
+if the terminal or the softkeys were not initialized, or
+the color pair is outside the range 0..COLOR_PAIRS-1,
+or opts is not null.
+.TP 5
+\fBslk_color\fP
+returns an error
+if the terminal or the softkeys were not initialized, or
+the color pair is outside the range 0..COLOR_PAIRS-1.
+.TP 5
+\fBslk_init\fR
+returns an error
+if the format parameter is outside the range 0..3.
+.TP 5
+\fBslk_label\fR
+returns \fBNULL\fR on error.
+.TP 5
+\fBslk_set\fP
+returns an error
+if the terminal or the softkeys were not initialized, or
+the \fIlabnum\fP parameter is outside the range of label counts, or
+if the format parameter is outside the range 0..2, or if
+memory for the labels cannot be allocated.
+.RE
.SH NOTES
Most applications would use \fBslk_noutrefresh\fR because a
\fBwrefresh\fR is likely to follow soon.
diff --git a/lib/libcurses/curs_termattrs.3 b/lib/libcurses/curs_termattrs.3
index 49c1720dd27..bbc9a1ffc8a 100644
--- a/lib/libcurses/curs_termattrs.3
+++ b/lib/libcurses/curs_termattrs.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_termattrs.3,v 1.7 2000/07/10 03:06:09 millert Exp $
+.\" $OpenBSD: curs_termattrs.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,28 +28,42 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_termattrs.3x,v 1.6 2000/07/08 12:53:34 tom Exp $
+.\" $Id: curs_termattrs.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH curs_termattrs 3 ""
.SH NAME
-\fBbaudrate\fR, \fBerasechar\fR, \fBhas_ic\fR,
-\fBhas_il\fR, \fBkillchar\fR, \fBlongname\fR, \fBtermattrs\fR,
+\fBbaudrate\fR,
+\fBerasechar\fR,
+\fBerasewchar\fR,
+\fBhas_ic\fR,
+\fBhas_il\fR,
+\fBkillchar\fR,
+\fBkillwchar\fR,
+\fBlongname\fR,
+\fBterm_attrs\fR,
+\fBtermattrs\fR,
\fBtermname\fR - \fBcurses\fR environment query routines
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.PP
\fBint baudrate(void);\fR
.br
\fBchar erasechar(void);\fR
.br
+\fBint erasewchar(wchar_t *\fR\fIch\fR\fB);\fR
+.br
\fBbool has_ic(void);\fR
.br
\fBbool has_il(void);\fR
.br
\fBchar killchar(void);\fR
.br
+\fBint killwchar(wchar_t *\fR\fIch\fR\fB);\fR
+.br
\fBchar *longname(void);\fR
.br
-\fBattr_t termattrs(void);\fR
+\fBattr_t term_attrs(void);\fR
+.br
+\fBchtype termattrs(void);\fR
.br
\fBchar *termname(void);\fR
.br
@@ -57,19 +71,29 @@
The \fBbaudrate\fR routine returns the output speed of the terminal. The
number returned is in bits per second, for example \fB9600\fR, and is an
integer.
-
+.PP
The \fBerasechar\fR routine returns the user's current erase character.
-
+.PP
+The \fBerasewchar\fR routine stores the current erase character
+in the location referenced by \fIch\fR.
+If no erase character has been defined, the routine fails
+and the location referenced by \fIch\fR is not changed.
+.PP
The \fBhas_ic\fR routine is true if the terminal has insert- and delete-
character capabilities.
-
+.PP
The \fBhas_il\fR routine is true if the terminal has insert- and delete-line
capabilities, or can simulate them using scrolling regions. This might
be used to determine if it would be appropriate to turn on physical
scrolling using \fBscrollok\fR.
-
+.PP
The \fBkillchar\fR routine returns the user's current line kill character.
-
+.PP
+The \fBkillwchar\fR routine stores the current line-kill character
+in the location referenced by \fIch\fR.
+If no line-kill character has been defined,
+the routine fails and the location referenced by \fIch\fR is not changed.
+.PP
The \fBlongname\fR routine returns a pointer to a static area
containing a verbose description of the current terminal. The maximum
length of a verbose description is 128 characters. It is defined only
@@ -78,19 +102,20 @@ overwritten by each call to \fBnewterm\fR and is not restored by
\fBset_term\fR, so the value should be saved between calls to
\fBnewterm\fR if \fBlongname\fR is going to be used with multiple
terminals.
-
-If a given terminal doesn't support a video attribute that an
+.PP
+If a given terminal does not support a video attribute that an
application program is trying to use, \fBcurses\fR may substitute a
-different video attribute for it. The \fBtermattrs\fR function
-returns a logical \fBOR\fR of all video attributes supported by the
-terminal. This information is useful when a \fBcurses\fR program
+different video attribute for it.
+The \fBtermattrs\fR and \fBterm_attrs\fR functions
+return a logical \fBOR\fR of all video attributes supported by the
+terminal using \fIA_\fR and \fIWA_\fR constants respectively.
+This information is useful when a \fBcurses\fR program
needs complete control over the appearance of the screen.
-
-The \fBtermname\fR routine returns the value of the environmental
-variable \fBTERM\fR (truncated to 14 characters).
+.PP
+The \fBtermname\fR routine returns the terminal name used by \fBsetupterm\fR.
.SH RETURN VALUE
\fBlongname\fR and \fBtermname\fR return \fBNULL\fR on error.
-
+.PP
Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion.
@@ -99,6 +124,8 @@ Note that \fBtermattrs\fR may be a macro.
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions. It changes the
return type of \fBtermattrs\fR to the new type \fBattr_t\fR.
+Most versions of curses truncate the result returned by \fBtermname\fR to
+14 characters.
.SH SEE ALSO
\fBcurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_outopts\fR(3)
.\"#
diff --git a/lib/libcurses/curs_touch.3 b/lib/libcurses/curs_touch.3
index 1cd02bc1f26..e18a0bf7e42 100644
--- a/lib/libcurses/curs_touch.3
+++ b/lib/libcurses/curs_touch.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_touch.3,v 1.6 2000/07/10 03:06:09 millert Exp $
+.\" $OpenBSD: curs_touch.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_touch.3x,v 1.8 2000/07/08 11:07:57 tom Exp $
+.\" $Id: curs_touch.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.TH curs_touch 3 ""
+.na
+.hy 0
.SH NAME
\fBtouchwin\fR,
\fBtouchline\fR,
@@ -37,6 +39,8 @@
\fBwtouchln\fR,
\fBis_linetouched\fR,
\fBis_wintouched\fR - \fBcurses\fR refresh control routines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
.br
@@ -61,15 +65,15 @@ to one window affects the other window, but the records of which lines
have been changed in the other window do not reflect the change. The
routine \fBtouchline\fR only pretends that \fIcount\fR lines have been
changed, beginning with line \fIstart\fR.
-
+.PP
The \fBuntouchwin\fR routine marks all lines in the window as unchanged since
the last call to \fBwrefresh\fR.
-
+.PP
The \fBwtouchln\fR routine makes \fIn\fR lines in the window, starting
at line \fIy\fR, look as if they have (\fIchanged\fR\fB=1\fR) or have
not (\fIchanged\fR\fB=0\fR) been changed since the last call to
\fBwrefresh\fR.
-
+.PP
The \fBis_linetouched\fR and \fBis_wintouched\fR routines return
\fBTRUE\fR if the specified line/window was modified since the last
call to \fBwrefresh\fR; otherwise they return \fBFALSE\fR. In
@@ -79,9 +83,25 @@ valid for the given window.
All routines return the integer \fBERR\fR upon failure and an integer value
other than \fBERR\fR upon successful completion, unless otherwise noted in the
preceding routine descriptions.
+.PP
+X/Open does not define any error conditions.
+In this implementation
+.RS
+.TP 5
+\fBis_linetouched\fP
+returns an error
+if the window pointer is null, or
+if the line number is outside the window.
+Note that ERR is distinct from TRUE and FALSE, which are the normal return values of this function.
+.TP 5
+\fBwtouchln\fP
+returns an error
+if the window pointer is null, or
+if the line number is outside the window.
+.RE
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions.
-
+.PP
Some historic curses implementations had, as an undocumented feature, the
ability to do the equivalent of \fBclearok(..., 1)\fR by saying
\fBtouchwin(stdscr)\fR or \fBclear(stdscr)\fR. This will not work under
diff --git a/lib/libcurses/curs_util.3 b/lib/libcurses/curs_util.3
index d0eb4bf34b4..d88cc4c5bc7 100644
--- a/lib/libcurses/curs_util.3
+++ b/lib/libcurses/curs_util.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_util.3,v 1.5 1998/09/13 19:16:23 millert Exp $
+.\" $OpenBSD: curs_util.3,v 1.6 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,22 +28,40 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_util.3x,v 1.6 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: curs_util.3,v 1.6 2010/01/12 23:21:59 nicm Exp $
.TH curs_util 3 ""
+.na
+.hy 0
.SH NAME
-\fBunctrl\fR, \fBkeyname\fR, \fBfilter\fR,
-\fBuse_env\fR, \fBputwin\fR, \fBgetwin\fR, \fBdelay_output\fR,
-\fBflushinp\fR - miscellaneous \fBcurses\fR utility routines
+\fBdelay_output\fR,
+\fBfilter\fR,
+\fBflushinp\fR,
+\fBgetwin\fR,
+\fBkey_name\fR,
+\fBkeyname\fR,
+\fBnofilter\fR,
+\fBputwin\fR,
+\fBunctrl\fR,
+\fBuse_env\fR,
+\fBwunctrl\fR - miscellaneous \fBcurses\fR utility routines
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBchar *unctrl(chtype c);\fR
.br
+\fBwchar_t *wunctrl(cchar_t *c);\fR
+.br
\fBchar *keyname(int c);\fR
.br
+\fBchar *key_name(wchar_t w);\fR
+.br
\fBvoid filter(void);\fR
.br
-\fBvoid use_env(char bool);\fR
+\fBvoid nofilter(void);\fR
+.br
+\fBvoid use_env(bool f);\fR
.br
\fBint putwin(WINDOW *win, FILE *filep);\fR
.br
@@ -54,19 +72,62 @@
\fBint flushinp(void);\fR
.br
.SH DESCRIPTION
-The \fBunctrl\fR macro expands to a character string which is a printable
-representation of the character \fIc\fR. Control characters are displayed in
-the \fB^\fR\fIX\fR notation. Printing characters are displayed as is.
-
-The \fBkeyname\fR routine returns a character string corresponding to
-the key \fIc\fR.
-
+The \fBunctrl\fR routine returns a character string which is a printable
+representation of the character \fIc\fR, ignoring attributes.
+Control characters are displayed in the \fB^\fR\fIX\fR notation.
+Printing characters are displayed as is.
+The corresponding \fBwunctrl\fR returns a printable representation of
+a wide-character.
+.PP
+The \fBkeyname\fR routine returns a character string corresponding to the key \fIc\fR:
+.RS 3
+.TP 3
+-
+Printable characters are displayed as themselves, e.g., a one-character string containing the key.
+.TP 3
+-
+Control characters are displayed in the \fB^\fR\fIX\fR notation.
+.TP 3
+-
+DEL (character 127) is displayed as \fB^?\fP.
+.TP 3
+-
+Values above 128 are either meta characters
+(if the screen has not been initialized,
+or if \fBmeta\fP has been called with a TRUE parameter),
+shown in the \fBM-\fR\fIX\fR notation,
+or are displayed as themselves.
+In the latter case, the values may not be printable;
+this follows the X/Open specification.
+.TP 3
+-
+Values above 256 may be the names of the names of function keys.
+.TP 3
+-
+Otherwise (if there is no corresponding name) the function returns null,
+to denote an error.
+X/Open also lists an "UNKNOWN KEY" return value, which some implementations
+return rather than null.
+.RE
+.LP
+The corresponding \fBkey_name\fR returns a character string corresponding
+to the wide-character value \fIw\fR.
+The two functions do not return the same set of strings;
+the latter returns null where the former would display a meta character.
+.PP
The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or
\fBnewterm\fR are called. The effect is that, during those calls, \fBLINES\fR
is set to 1; the capabilities \fBclear\fR, \fBcup\fR, \fBcud\fR, \fBcud1\fR,
\fBcuu1\fR, \fBcuu\fR, \fBvpa\fR are disabled; and the \fBhome\fR string is
set to the value of \fBcr\fR.
-
+.PP
+The \fBnofilter\fP routine cancels the effect of a preceding \fBfilter\fP
+call.
+That allows the caller to initialize a screen on a different device,
+using a different value of \fB$TERM\fP.
+The limitation arises because the \fBfilter\fP routine modifies the
+in-memory copy of the terminal information.
+.PP
The \fBuse_env\fR routine, if used, is called before \fBinitscr\fR or
\fBnewterm\fR are called. When called with \fBFALSE\fR as an
argument, the values of \fBlines\fR and \fBcolumns\fR specified in the
@@ -75,39 +136,122 @@ argument, the values of \fBlines\fR and \fBcolumns\fR specified in the
\fBcurses\fR is running in a window (in which case default behavior
would be to use the window size if \fBLINES\fR and \fBCOLUMNS\fR are
not set).
-
+Note that setting \fBLINES\fR or \fBCOLUMNS\fR overrides the
+corresponding size which may be obtained from the operating system.
+.PP
The \fBputwin\fR routine writes all data associated with window \fIwin\fR into
the file to which \fIfilep\fR points. This information can be later retrieved
using the \fBgetwin\fR function.
-
+.PP
The \fBgetwin\fR routine reads window related data stored in the file by
\fBputwin\fR. The routine then creates and initializes a new window using that
data. It returns a pointer to the new window.
-
+.PP
The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause
in output. This routine should not be used extensively because
padding characters are used rather than a CPU pause.
-
+If no padding character is specified, this uses \fBnapms\fR to perform the delay.
+.PP
The \fBflushinp\fR routine throws away any typeahead that has been typed by the
user and has not yet been read by the program.
.SH RETURN VALUE
Except for \fBflushinp\fR, routines that return an integer return \fBERR\fR
upon failure and \fBOK\fR (SVr4 specifies only "an integer value other than
\fBERR\fR") upon successful completion.
-
-\fBflushinp\fR always returns \fBOK\fR.
-
+.PP
Routines that return pointers return \fBNULL\fR on error.
+.PP
+X/Open does not define any error conditions.
+In this implementation
+.RS 3
+.TP 5
+\fBflushinp\fR
+returns an error if the terminal was not initialized.
+.TP 5
+\fBmeta\fR
+returns an error if the terminal was not initialized.
+.TP 5
+\fBputwin\fP
+returns an error if the associated \fBfwrite\fP calls return an error.
+.RE
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions.
-
+It states that \fBunctrl\fR and \fBwunctrl\fR will return a null pointer if
+unsuccessful, but does not define any error conditions.
+This implementation checks for three cases:
+.RS
+.TP 5
+-
+the parameter is a 7-bit US-ASCII code.
+This is the case that X/Open Curses documented.
+.TP 5
+-
+the parameter is in the range 128-159, i.e., a C1 control code.
+If \fBuse_legacy_coding\fP has been called with a \fB2\fP parameter,
+\fBunctrl\fP returns the parameter, i.e., a one-character string with
+the parameter as the first character.
+Otherwise, it returns ``~@'', ``~A'', etc., analogous to ``^@'', ``^A'', C0 controls.
+.IP
+X/Open Curses does not document whether \fBunctrl\fP can be called before
+initializing curses.
+This implementation permits that,
+and returns the ``~@'', etc., values in that case.
+.TP 5
+-
+parameter values outside the 0 to 255 range.
+\fBunctrl\fP returns a null pointer.
+.RE
+.PP
The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest
terms. The description here is adapted from the XSI Curses standard (which
erroneously fails to describe the disabling of \fBcuu\fR).
-.SH NOTES
-Note that \fBunctrl\fR is a macro, which is defined in <\fBunctrl.h\fR>.
+.PP
+The strings returned by \fBunctrl\fR in this implementation are determined
+at compile time,
+showing C1 controls from the upper-128 codes with a `~' prefix rather than `^'.
+Other implementations have different conventions.
+For example, they may show both sets of control characters with `^',
+and strip the parameter to 7 bits.
+Or they may ignore C1 controls and treat all of the upper-128 codes as
+printable.
+This implementation uses 8 bits but does not modify the string to reflect
+locale.
+The \fBuse_legacy_coding\fP function allows the caller to
+change the output of \fBunctrl\fP.
+.PP
+Likewise, the \fBmeta\fP function allows the caller to change the
+output of \fBkeyname\fP, i.e.,
+it determines whether to use the `M-' prefix
+for ``meta'' keys (codes in the range 128 to 255).
+Both \fBuse_legacy_coding\fP and \fBmeta\fP succeed only after
+curses is initialized.
+X/Open Curses does not document the treatment of codes 128 to 159.
+When treating them as ``meta'' keys
+(or if \fBkeyname\fP is called before initializing curses),
+this implementation returns strings ``M-^@'', ``M-^A'', etc.
+.PP
+The \fBkeyname\fP function may return the names of user-defined
+string capabilities which are defined in the terminfo entry via the \fB-x\fP
+option of \fBtic\fP.
+This implementation automatically assigns at run-time keycodes to
+user-defined strings which begin with "k".
+The keycodes start at KEY_MAX, but are not guaranteed to be
+the same value for different runs because user-defined codes are
+merged from all terminal descriptions which have been loaded.
+The \fBuse_extended_names\fP function controls whether this data is
+loaded when the terminal description is read by the library.
+.PP
+The \fBnofilter\fP routine is specific to ncurses.
+It was not supported on Version 7, BSD or System V implementations.
+It is recommended that any code depending on ncurses extensions
+be conditioned using NCURSES_VERSION.
.SH SEE ALSO
-\fBcurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_scr_dump\fR(3).
+\fBlegacy_coding\fR(3),
+\fBcurses\fR(3),
+\fBcurs_initscr\fR(3),
+\fBcurs_kernel\fR(3),
+\fBcurs_scr_dump\fR(3),
+\fBlegacy_coding\fR(3).
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/curs_window.3 b/lib/libcurses/curs_window.3
index ac75191a5ad..f4d112bc6b4 100644
--- a/lib/libcurses/curs_window.3
+++ b/lib/libcurses/curs_window.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: curs_window.3,v 1.9 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: curs_window.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,8 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_window.3x,v 1.9 2000/07/01 20:08:37 tom Exp $
+.\" $Id: curs_window.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH curs_window 3 ""
+.na
+.hy 0
.SH NAME
\fBnewwin\fR,
\fBdelwin\fR,
@@ -42,9 +44,11 @@
\fBsyncok\fR,
\fBwcursyncup\fR,
\fBwsyncdown\fR - create \fBcurses\fR windows
+.ad
+.hy
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBWINDOW *newwin(int nlines, int ncols, int begin_y,\fR
\fBint begin_x);\fR
.br
@@ -77,17 +81,17 @@ at line \fIbegin\fR_\fIy\fR, column \fIbegin\fR_\fIx\fR. If either
\fInlines\fR or \fIncols\fR is zero, they default to \fBLINES -\fR
\fIbegin\fR_\fIy\fR and \fBCOLS -\fR \fIbegin\fR_\fIx\fR. A new full-screen
window is created by calling \fBnewwin(0,0,0,0)\fR.
-
+.PP
Calling \fBdelwin\fR deletes the named window, freeing all memory
associated with it (it does not actually erase the window's screen
image). Subwindows must be deleted before the main window can be
deleted.
-
+.PP
Calling \fBmvwin\fR moves the window so that the upper left-hand
corner is at position (\fIx\fR, \fIy\fR). If the move would cause the
window to be off the screen, it is an error and the window is not
moved. Moving subwindows is allowed, but should be avoided.
-
+.PP
Calling \fBsubwin\fR creates and returns a pointer to a new window
with the given number of lines, \fInlines\fR, and columns,
\fIncols\fR. The window is at position (\fIbegin\fR_\fIy\fR,
@@ -98,29 +102,29 @@ will affect both windows. The subwindow shares memory with the window
\fIorig\fR. When using this routine, it is necessary to call
\fBtouchwin\fR or \fBtouchline\fR on \fIorig\fR before calling
\fBwrefresh\fR on the subwindow.
-
+.PP
Calling \fBderwin\fR is the same as calling \fBsubwin,\fR except that
\fIbegin\fR_\fIy\fR and \fIbegin\fR_\fIx\fR are relative to the origin
of the window \fIorig\fR rather than the screen. There is no
difference between the subwindows and the derived windows.
-
+.PP
Calling \fBmvderwin\fR moves a derived window (or subwindow)
inside its parent window. The screen-relative parameters of the
window are not changed. This routine is used to display different
parts of the parent window at the same physical position on the
screen.
-
+.PP
Calling \fBdupwin\fR creates an exact duplicate of the window \fIwin\fR.
-
+.PP
Calling \fBwsyncup\fR touches all locations in ancestors of \fIwin\fR that are
changed in \fIwin\fR. If \fBsyncok\fR is called with second argument
\fBTRUE\fR then \fBwsyncup\fR is called automatically whenever there is a
change in the window.
-
+.PP
The \fBwsyncdown\fR routine touches each location in \fIwin\fR that has been
touched in any of its ancestor windows. This routine is called by
\fBwrefresh\fR, so it should almost never be necessary to call it manually.
-
+.PP
The routine \fBwcursyncup\fR updates the current cursor position of all the
ancestors of the window to reflect the current cursor position of the
window.
@@ -128,21 +132,46 @@ window.
Routines that return an integer return the integer \fBERR\fR upon failure and
\fBOK\fR (SVr4 only specifies "an integer value other than \fBERR\fR") upon
successful completion.
-
-\fBdelwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
-upon successful completion.
-
+.PP
Routines that return pointers return \fBNULL\fR on error.
+.PP
+X/Open defines no error conditions.
+In this implementation
+.RS
+.TP 5
+\fBdelwin\fR
+returns an error if the window pointer is null, or
+if the window is the parent of another window.
+.IP
+This implementation also maintains a list of windows,
+and checks that the pointer passed to \fBdelwin\fP is one that
+it created, returning an error if it was not..
+.TP 5
+\fBmvderwin\fP
+returns an error
+if the window pointer is null, or
+if some part of the window would be placed off-screen.
+.TP 5
+\fBmvwin\fP
+returns an error
+if the window pointer is null, or
+if the window is really a pad, or
+if some part of the window would be placed off-screen.
+.TP 5
+\fBsyncok\fP
+returns an error
+if the window pointer is null.
+.RE
.SH NOTES
If many small changes are made to the window, the \fBwsyncup\fR option could
degrade performance.
-
+.PP
Note that \fBsyncok\fR may be a macro.
.SH BUGS
The subwindow functions (\fIsubwin\fR, \fIderwin\fR, \fImvderwin\fR,
\fBwsyncup\fR, \fBwsyncdown\fR, \fBwcursyncup\fR, \fBsyncok\fR) are flaky,
incompletely implemented, and not well tested.
-
+.PP
The System V curses documentation is very unclear about what \fBwsyncup\fR
and \fBwsyncdown\fR actually do. It seems to imply that they are only
supposed to touch exactly those lines that are affected by ancestor changes.
diff --git a/lib/libcurses/curses.3tbl b/lib/libcurses/curses.3tbl
index 7595cd82d17..13bf0c7adfa 100644
--- a/lib/libcurses/curses.3tbl
+++ b/lib/libcurses/curses.3tbl
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: curses.3tbl,v 1.19 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: curses.3tbl,v 1.20 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,165 +29,260 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: ncurses.3x,v 1.46 2000/11/25 21:58:45 tom Exp $
+.\" $Id: curses.3tbl,v 1.20 2010/01/12 23:21:59 nicm Exp $
+.hy 0
.TH ncurses 3 ""
.ds n 5
-.ds d /usr/share/terminfo
+.ds d /usr/share/misc/terminfo
.SH NAME
-\fBcurses\fR - CRT screen handling and optimization package
+\fBncurses\fR - CRT screen handling and optimization package
.SH SYNOPSIS
\fB#include <curses.h>\fR
.br
.SH DESCRIPTION
-The \fBcurses\fR library routines give the user a terminal-independent method
-of updating character screens with reasonable optimization. This
-implementation is ``new curses'' (ncurses) and is the approved replacement for
+The \fBncurses\fR library routines give the user a terminal-independent method
+of updating character screens with reasonable optimization.
+This implementation is ``new curses'' (ncurses) and
+is the approved replacement for
4.4BSD classic curses, which has been discontinued.
-
-The \fBncurses\fR routines emulate the \fBcurses\fR(3) library of System V
-Release 4 UNIX, and the XPG4 curses standard (XSI curses) but the \fBncurses\fR
-library is freely redistributable in source form. Differences from the SVr4
-curses are summarized under the EXTENSIONS and BUGS sections below and
-described in detail in the EXTENSIONS and BUGS sections of individual man
-pages.
-
-A program using these routines must be linked with the \fB-lcurses\fR option.
-
-The \fBcurses\fR package supports: overall screen, window and pad
+This describes \fBncurses\fR
+version 5.7.
+.PP
+The \fBncurses\fR library emulates the \fBcurses\fR(3) library of
+System V Release 4 UNIX,
+and XPG4 (X/Open Portability Guide) curses (also known as XSI curses).
+XSI stands for X/Open System Interfaces Extension.
+The \fBncurses\fR library is freely redistributable in source form.
+Differences from the SVr4
+curses are summarized under the \fBEXTENSIONS\fP and \fBPORTABILITY\fP sections below and
+described in detail in the respective \fBEXTENSIONS\fP, \fBPORTABILITY\fP and \fBBUGS\fP sections
+of individual man pages.
+.PP
+The \fBncurses\fR library also provides many useful extensions,
+i.e., features which cannot be implemented by a simple add-on library
+but which require access to the internals of the library.
+.PP
+A program using these routines must be linked with the \fB-lncurses\fR option.
+.PP
+The \fBncurses\fR package supports: overall screen, window and pad
manipulation; output to windows and pads; reading terminal input; control over
terminal and \fBcurses\fR input and output options; environment query
routines; color manipulation; use of soft label keys; terminfo capabilities;
and access to low-level terminal-manipulation routines.
-
-To initialize the routines, the routine \fBinitscr\fR or \fBnewterm\fR
-must be called before any of the other routines that deal with windows
-and screens are used. The routine \fBendwin\fR must be called before
-exiting. To get character-at-a-time input without echoing (most
+.PP
+The library uses the locale which the calling program has initialized.
+That is normally done with \fBsetlocale\fP:
+.sp
+ \fBsetlocale(LC_ALL, "");\fP
+.sp
+If the locale is not initialized,
+the library assumes that characters are printable as in ISO-8859-1,
+to work with certain legacy programs.
+You should initialize the locale and not rely on specific details of
+the library when the locale has not been setup.
+.PP
+The function \fBinitscr\fR or \fBnewterm\fR
+must be called to initialize the library
+before any of the other routines that deal with windows
+and screens are used.
+The routine \fBendwin\fR must be called before exiting.
+.PP
+To get character-at-a-time input without echoing (most
interactive, screen oriented programs want this), the following
sequence should be used:
-
+.sp
\fBinitscr(); cbreak(); noecho();\fR
-
+.sp
Most programs would additionally use the sequence:
-
+.sp
\fBnonl();\fR
\fBintrflush(stdscr, FALSE);\fR
\fBkeypad(stdscr, TRUE);\fR
-
+.sp
Before a \fBcurses\fR program is run, the tab stops of the terminal
-should be set and its initialization strings, if defined, must be
-output. This can be done by executing the \fBtput init\fR command
+should be set and its initialization strings, if defined, must be output.
+This can be done by executing the \fBtput init\fR command
after the shell environment variable \fBTERM\fR has been exported.
\fBtset(1)\fR is usually responsible for doing this.
[See \fBterminfo\fR(\*n) for further details.]
-
-The \fBcurses\fR library permits manipulation of data structures,
+.PP
+The \fBncurses\fR library permits manipulation of data structures,
called \fIwindows\fR, which can be thought of as two-dimensional
-arrays of characters representing all or part of a CRT screen. A
-default window called \fBstdscr\fR, which is the size of the terminal
-screen, is supplied. Others may be created with \fBnewwin\fR.
-
+arrays of characters representing all or part of a CRT screen.
+A default window called \fBstdscr\fR, which is the size of the terminal
+screen, is supplied.
+Others may be created with \fBnewwin\fR.
+.PP
Note that \fBcurses\fR does not handle overlapping windows, that's done by
-the \fBpanel\fR(3) library. This means that you can either use
+the \fBpanel\fR(3) library.
+This means that you can either use
\fBstdscr\fR or divide the screen into tiled windows and not using
-\fBstdscr\fR at all. Mixing the two will result in unpredictable, and
-undesired, effects.
-
+\fBstdscr\fR at all.
+Mixing the two will result in unpredictable, and undesired, effects.
+.PP
Windows are referred to by variables declared as \fBWINDOW *\fR.
These data structures are manipulated with routines described here and
-elsewhere in the \fBcurses\fR manual pages. Among which the most basic
-routines are \fBmove\fR and \fBaddch\fR. More general versions of
+elsewhere in the \fBncurses\fR manual pages.
+Among those, the most basic
+routines are \fBmove\fR and \fBaddch\fR.
+More general versions of
these routines are included with names beginning with \fBw\fR,
-allowing the user to specify a window. The routines not beginning
-with \fBw\fR affect \fBstdscr\fR.)
-
+allowing the user to specify a window.
+The routines not beginning
+with \fBw\fR affect \fBstdscr\fR.
+.PP
After using routines to manipulate a window, \fBrefresh\fR is called,
telling \fBcurses\fR to make the user's CRT screen look like
-\fBstdscr\fR. The characters in a window are actually of type
+\fBstdscr\fR.
+The characters in a window are actually of type
\fBchtype\fR, (character and attribute data) so that other information
about the character may also be stored with each character.
-
-Special windows called \fIpads\fR may also be manipulated. These are windows
+.PP
+Special windows called \fIpads\fR may also be manipulated.
+These are windows
which are not constrained to the size of the screen and whose contents need not
-be completely displayed. See \fBcurs_pad\fR(3) for more information.
-
+be completely displayed.
+See \fBcurs_pad\fR(3) for more information.
+.PP
In addition to drawing characters on the screen, video attributes and colors
may be supported, causing the characters to show up in such modes as
underlined, in reverse video, or in color on terminals that support such
-display enhancements. Line drawing characters may be specified to be output.
+display enhancements.
+Line drawing characters may be specified to be output.
On input, \fBcurses\fR is also able to translate arrow and function keys that
-transmit escape sequences into single values. The video attributes, line
+transmit escape sequences into single values.
+The video attributes, line
drawing characters, and input values use names, defined in \fB<curses.h>\fR,
such as \fBA_REVERSE\fR, \fBACS_HLINE\fR, and \fBKEY_LEFT\fR.
-
+.PP
If the environment variables \fBLINES\fR and \fBCOLUMNS\fR are set, or if the
program is executing in a window environment, line and column information in
-the environment will override information read by \fIterminfo\fR. This would
-effect a program running in an AT&T 630 layer, for example, where the size of a
+the environment will override information read by \fIterminfo\fR.
+This would affect a program running in an AT&T 630 layer,
+for example, where the size of a
screen is changeable (see \fBENVIRONMENT\fR).
-
+.PP
If the environment variable \fBTERMINFO\fR is defined, any program using
\fBcurses\fR checks for a local terminal definition before checking in the
-standard place. For example, if \fBTERM\fR is set to \fBatt4424\fR, then the
+standard place.
+For example, if \fBTERM\fR is set to \fBatt4424\fR, then the
compiled terminal definition is found in
-
+.sp
\fB\*d/a/att4424\fR.
-
+.sp
(The \fBa\fR is copied from the first letter of \fBatt4424\fR to avoid
creation of huge directories.) However, if \fBTERMINFO\fR is set to
\fB$HOME/myterms\fR, \fBcurses\fR first checks
-
+.sp
\fB$HOME/myterms/a/att4424\fR,
-
+.sp
and if that fails, it then checks
-
+.sp
\fB\*d/a/att4424\fR.
-
+.sp
This is useful for developing experimental definitions or when write
permission in \fB\*d\fR is not available.
-
+.PP
The integer variables \fBLINES\fR and \fBCOLS\fR are defined in
\fB<curses.h>\fR and will be filled in by \fBinitscr\fR with the size of the
-screen. The constants \fBTRUE\fR and \fBFALSE\fR have the values \fB1\fR and
+screen.
+The constants \fBTRUE\fR and \fBFALSE\fR have the values \fB1\fR and
\fB0\fR, respectively.
-
+.PP
The \fBcurses\fR routines also define the \fBWINDOW *\fR variable \fBcurscr\fR
which is used for certain low-level operations like clearing and redrawing a
-screen containing garbage. The \fBcurscr\fR can be used in only a few
-routines.
-
+screen containing garbage.
+The \fBcurscr\fR can be used in only a few routines.
+.\"
.SS Routine and Argument Names
-Many \fBcurses\fR routines have two or more versions. The routines prefixed
-with \fBw\fR require a window argument. The routines prefixed with \fBp\fR
-require a pad argument. Those without a prefix generally use \fBstdscr\fR.
-
+Many \fBcurses\fR routines have two or more versions.
+The routines prefixed with \fBw\fR require a window argument.
+The routines prefixed with \fBp\fR require a pad argument.
+Those without a prefix generally use \fBstdscr\fR.
+.PP
The routines prefixed with \fBmv\fR require a \fIy\fR and \fIx\fR
-coordinate to move to before performing the appropriate action. The
-\fBmv\fR routines imply a call to \fBmove\fR before the call to the
-other routine. The coordinate \fIy\fR always refers to the row (of
-the window), and \fIx\fR always refers to the column. The upper
-left-hand corner is always (0,0), not (1,1).
-
+coordinate to move to before performing the appropriate action.
+The \fBmv\fR routines imply a call to \fBmove\fR before the call to the
+other routine.
+The coordinate \fIy\fR always refers to the row (of
+the window), and \fIx\fR always refers to the column.
+The upper left-hand corner is always (0,0), not (1,1).
+.PP
The routines prefixed with \fBmvw\fR take both a window argument and
-\fIx\fR and \fIy\fR coordinates. The window argument is always
-specified before the coordinates.
-
+\fIx\fR and \fIy\fR coordinates.
+The window argument is always specified before the coordinates.
+.PP
In each case, \fIwin\fR is the window affected, and \fIpad\fR is the
pad affected; \fIwin\fR and \fIpad\fR are always pointers to type
\fBWINDOW\fR.
-
+.PP
Option setting routines require a Boolean flag \fIbf\fR with the value
-\fBTRUE\fR or \fBFALSE\fR; \fIbf\fR is always of type \fBbool\fR. The
-variables \fIch\fR and \fIattrs\fR below are always of type
-\fBchtype\fR. The types \fBWINDOW\fR, \fBSCREEN\fR, \fBbool\fR, and
-\fBchtype\fR are defined in \fB<curses.h>\fR. The type \fBTERMINAL\fR
-is defined in \fB<term.h>\fR. All other arguments are integers.
-
+\fBTRUE\fR or \fBFALSE\fR; \fIbf\fR is always of type \fBbool\fR.
+Most of the data types used in the library routines,
+such as \fBWINDOW\fR, \fBSCREEN\fR, \fBbool\fR, and \fBchtype\fR
+are defined in \fB<curses.h>\fR.
+Types used for the terminfo routines such as
+\fBTERMINAL\fR are defined in \fB<term.h>\fR.
+.PP
+This manual page describes functions which may appear in any configuration
+of the library.
+There are two common configurations of the library:
+.RS
+.TP 5
+ncurses
+the "normal" library, which handles 8-bit characters.
+The normal (8-bit) library stores characters combined with attributes
+in \fBchtype\fP data.
+.IP
+Attributes alone (no corresponding character) may be stored in \fBchtype\fP
+or the equivalent \fBattr_t\fP data.
+In either case, the data is stored in something like an integer.
+.IP
+Each cell (row and column) in a \fBWINDOW\fP is stored as a \fBchtype\fP.
+.TP 5
+ncursesw
+the so-called "wide" library, which handles multibyte characters
+The "wide" library includes all of the calls from the "normal" library.
+The "wide" library includes all of the calls from the "normal" library.
+It adds about one third more calls using data types which store
+multibyte characters:
+.RS
+.TP 5
+.B cchar_t
+corresponds to \fBchtype\fP.
+However it is a structure, because more data is stored than can fit into
+an integer.
+The characters are large enough to require a full integer value - and there
+may be more than one character per cell.
+The video attributes and color are stored in separate fields of the structure.
+.IP
+Each cell (row and column) in a \fBWINDOW\fP is stored as a \fBcchar_t\fP.
+.TP 5
+.B wchar_t
+stores a "wide" character.
+Like \fBchtype\fP, this may be an integer.
+.TP 5
+.B wint_t
+stores a \fBwchar_t\fP or \fBWEOF\fP - not the same, though both may have
+the same size.
+.RE
+.IP
+The "wide" library provides new functions which are analogous to
+functions in the "normal" library.
+There is a naming convention which relates many of the normal/wide variants:
+a "_w" is inserted into the name.
+For example, \fBwaddch\fP becomes \fBwadd_wch\fP.
+.IP
+ncursesw is not currently supported on OpenBSD.
+.RE
+.PP
+.\"
.SS Routine Name Index
The following table lists each \fBcurses\fR routine and the name of
-the manual page on which it is described. Routines flagged with `*'
+the manual page on which it is described.
+Routines flagged with `*'
are ncurses-specific, not described by XPG4 or present in SVr4.
-
+.PP
.TS
center tab(/);
l l
@@ -196,16 +291,32 @@ l l .
=
COLOR_PAIR/\fBcurs_color\fR(3)
PAIR_NUMBER/\fBcurs_attr\fR(3)
+_nc_free_and_exit/\fBcurs_memleaks\fR(3)*
+_nc_freeall/\fBcurs_memleaks\fR(3)*
+_nc_tracebits/\fBcurs_trace\fR(3)*
+_traceattr/\fBcurs_trace\fR(3)*
+_traceattr2/\fBcurs_trace\fR(3)*
+_tracechar/\fBcurs_trace\fR(3)*
+_tracechtype/\fBcurs_trace\fR(3)*
+_tracechtype2/\fBcurs_trace\fR(3)*
+_tracedump/\fBcurs_trace\fR(3)*
+_tracef/\fBcurs_trace\fR(3)*
+_tracemouse/\fBcurs_trace\fR(3)*
+add_wch/\fBcurs_add_wch\fR(3)
+add_wchnstr/\fBcurs_add_wchstr\fR(3)
+add_wchstr/\fBcurs_add_wchstr\fR(3)
addch/\fBcurs_addch\fR(3)
addchnstr/\fBcurs_addchstr\fR(3)
addchstr/\fBcurs_addchstr\fR(3)
addnstr/\fBcurs_addstr\fR(3)
+addnwstr/\fBcurs_addwstr\fR(3)
+addstr/\fBcurs_addstr\fR(3)
+addwstr/\fBcurs_addwstr\fR(3)
assume_default_colors/\fBdefault_colors\fR(3)*
attr_get/\fBcurs_attr\fR(3)
attr_off/\fBcurs_attr\fR(3)
attr_on/\fBcurs_attr\fR(3)
attr_set/\fBcurs_attr\fR(3)
-addstr/\fBcurs_addstr\fR(3)
attroff/\fBcurs_attr\fR(3)
attron/\fBcurs_attr\fR(3)
attrset/\fBcurs_attr\fR(3)
@@ -213,8 +324,12 @@ baudrate/\fBcurs_termattrs\fR(3)
beep/\fBcurs_beep\fR(3)
bkgd/\fBcurs_bkgd\fR(3)
bkgdset/\fBcurs_bkgd\fR(3)
+bkgrnd/\fBcurs_bkgrnd\fR(3)
+bkgrndset/\fBcurs_bkgrnd\fR(3)
border/\fBcurs_border\fR(3)
+border_set/\fBcurs_border_set\fR(3)
box/\fBcurs_border\fR(3)
+box_set/\fBcurs_border_set\fR(3)
can_change_color/\fBcurs_color\fR(3)
cbreak/\fBcurs_inopts\fR(3)
chgat/\fBcurs_attr\fR(3)
@@ -240,19 +355,35 @@ derwin/\fBcurs_window\fR(3)
doupdate/\fBcurs_refresh\fR(3)
dupwin/\fBcurs_window\fR(3)
echo/\fBcurs_inopts\fR(3)
+echo_wchar/\fBcurs_add_wch\fR(3)
echochar/\fBcurs_addch\fR(3)
endwin/\fBcurs_initscr\fR(3)
erase/\fBcurs_clear\fR(3)
erasechar/\fBcurs_termattrs\fR(3)
+erasewchar/\fBcurs_termattrs\fR(3)
filter/\fBcurs_util\fR(3)
flash/\fBcurs_beep\fR(3)
flushinp/\fBcurs_util\fR(3)
+get_wch/\fBcurs_get_wch\fR(3)
+get_wstr/\fBcurs_get_wstr\fR(3)
+getattrs/\fBcurs_attr\fR(3)
+getbegx/\fBcurs_legacy\fR(3)*
+getbegy/\fBcurs_legacy\fR(3)*
getbegyx/\fBcurs_getyx\fR(3)
getbkgd/\fBcurs_bkgd\fR(3)
+getbkgrnd/\fBcurs_bkgrnd\fR(3)
+getcchar/\fBcurs_getcchar\fR(3)
getch/\fBcurs_getch\fR(3)
+getcurx/\fBcurs_legacy\fR(3)*
+getcury/\fBcurs_legacy\fR(3)*
+getmaxx/\fBcurs_legacy\fR(3)*
+getmaxy/\fBcurs_legacy\fR(3)*
getmaxyx/\fBcurs_getyx\fR(3)
getmouse/\fBcurs_mouse\fR(3)*
+getn_wstr/\fBcurs_get_wstr\fR(3)
getnstr/\fBcurs_getstr\fR(3)
+getparx/\fBcurs_legacy\fR(3)*
+getpary/\fBcurs_legacy\fR(3)*
getparyx/\fBcurs_getyx\fR(3)
getstr/\fBcurs_getstr\fR(3)
getsyx/\fBcurs_kernel\fR(3)
@@ -264,9 +395,13 @@ has_ic/\fBcurs_termattrs\fR(3)
has_il/\fBcurs_termattrs\fR(3)
has_key/\fBcurs_getch\fR(3)*
hline/\fBcurs_border\fR(3)
+hline_set/\fBcurs_border_set\fR(3)
idcok/\fBcurs_outopts\fR(3)
idlok/\fBcurs_outopts\fR(3)
immedok/\fBcurs_outopts\fR(3)
+in_wch/\fBcurs_in_wch\fR(3)
+in_wchnstr/\fBcurs_in_wchstr\fR(3)
+in_wchstr/\fBcurs_in_wchstr\fR(3)
inch/\fBcurs_inch\fR(3)
inchnstr/\fBcurs_inchstr\fR(3)
inchstr/\fBcurs_inchstr\fR(3)
@@ -274,6 +409,10 @@ init_color/\fBcurs_color\fR(3)
init_pair/\fBcurs_color\fR(3)
initscr/\fBcurs_initscr\fR(3)
innstr/\fBcurs_instr\fR(3)
+innwstr/\fBcurs_inwstr\fR(3)
+ins_nwstr/\fBcurs_ins_wstr\fR(3)
+ins_wch/\fBcurs_ins_wch\fR(3)
+ins_wstr/\fBcurs_ins_wstr\fR(3)
insch/\fBcurs_insch\fR(3)
insdelln/\fBcurs_deleteln\fR(3)
insertln/\fBcurs_deleteln\fR(3)
@@ -281,14 +420,29 @@ insnstr/\fBcurs_insstr\fR(3)
insstr/\fBcurs_insstr\fR(3)
instr/\fBcurs_instr\fR(3)
intrflush/\fBcurs_inopts\fR(3)
+inwstr/\fBcurs_inwstr\fR(3)
+is_cleared/\fBcurs_opaque\fR(3)*
+is_idcok/\fBcurs_opaque\fR(3)*
+is_idlok/\fBcurs_opaque\fR(3)*
+is_immedok/\fBcurs_opaque\fR(3)*
+is_keypad/\fBcurs_opaque\fR(3)*
+is_leaveok/\fBcurs_opaque\fR(3)*
is_linetouched/\fBcurs_touch\fR(3)
+is_nodelay/\fBcurs_opaque\fR(3)*
+is_notimeout/\fBcurs_opaque\fR(3)*
+is_scrollok/\fBcurs_opaque\fR(3)*
+is_syncok/\fBcurs_opaque\fR(3)*
+is_term_resized/\fBresizeterm\fR(3)*
is_wintouched/\fBcurs_touch\fR(3)
isendwin/\fBcurs_initscr\fR(3)
+key_defined/\fBkey_defined\fR(3)*
+key_name/\fBcurs_util\fR(3)
keybound/\fBkeybound\fR(3)*
keyname/\fBcurs_util\fR(3)
keyok/\fBkeyok\fR(3)*
keypad/\fBcurs_inopts\fR(3)
killchar/\fBcurs_termattrs\fR(3)
+killwchar/\fBcurs_termattrs\fR(3)
leaveok/\fBcurs_outopts\fR(3)
longname/\fBcurs_termattrs\fR(3)
mcprint/\fBcurs_print\fR(3)*
@@ -297,53 +451,89 @@ mouse_trafo/\fBcurs_mouse\fR(3)*
mouseinterval/\fBcurs_mouse\fR(3)*
mousemask/\fBcurs_mouse\fR(3)*
move/\fBcurs_move\fR(3)
+mvadd_wch/\fBcurs_add_wch\fR(3)
+mvadd_wchnstr/\fBcurs_add_wchstr\fR(3)
+mvadd_wchstr/\fBcurs_add_wchstr\fR(3)
mvaddch/\fBcurs_addch\fR(3)
mvaddchnstr/\fBcurs_addchstr\fR(3)
mvaddchstr/\fBcurs_addchstr\fR(3)
mvaddnstr/\fBcurs_addstr\fR(3)
+mvaddnwstr/\fBcurs_addwstr\fR(3)
mvaddstr/\fBcurs_addstr\fR(3)
+mvaddwstr/\fBcurs_addwstr\fR(3)
mvchgat/\fBcurs_attr\fR(3)
mvcur/\fBterminfo\fR(3)
mvdelch/\fBcurs_delch\fR(3)
mvderwin/\fBcurs_window\fR(3)
+mvget_wch/\fBcurs_get_wch\fR(3)
+mvget_wstr/\fBcurs_get_wstr\fR(3)
mvgetch/\fBcurs_getch\fR(3)
+mvgetn_wstr/\fBcurs_get_wstr\fR(3)
mvgetnstr/\fBcurs_getstr\fR(3)
mvgetstr/\fBcurs_getstr\fR(3)
mvhline/\fBcurs_border\fR(3)
+mvhline_set/\fBcurs_border_set\fR(3)
+mvin_wch/\fBcurs_in_wch\fR(3)
+mvin_wchnstr/\fBcurs_in_wchstr\fR(3)
+mvin_wchstr/\fBcurs_in_wchstr\fR(3)
mvinch/\fBcurs_inch\fR(3)
mvinchnstr/\fBcurs_inchstr\fR(3)
mvinchstr/\fBcurs_inchstr\fR(3)
mvinnstr/\fBcurs_instr\fR(3)
+mvinnwstr/\fBcurs_inwstr\fR(3)
+mvins_nwstr/\fBcurs_ins_wstr\fR(3)
+mvins_wch/\fBcurs_ins_wch\fR(3)
+mvins_wstr/\fBcurs_ins_wstr\fR(3)
mvinsch/\fBcurs_insch\fR(3)
mvinsnstr/\fBcurs_insstr\fR(3)
mvinsstr/\fBcurs_insstr\fR(3)
mvinstr/\fBcurs_instr\fR(3)
+mvinwstr/\fBcurs_inwstr\fR(3)
mvprintw/\fBcurs_printw\fR(3)
mvscanw/\fBcurs_scanw\fR(3)
mvvline/\fBcurs_border\fR(3)
+mvvline_set/\fBcurs_border_set\fR(3)
+mvwadd_wch/\fBcurs_add_wch\fR(3)
+mvwadd_wchnstr/\fBcurs_add_wchstr\fR(3)
+mvwadd_wchstr/\fBcurs_add_wchstr\fR(3)
mvwaddch/\fBcurs_addch\fR(3)
mvwaddchnstr/\fBcurs_addchstr\fR(3)
mvwaddchstr/\fBcurs_addchstr\fR(3)
mvwaddnstr/\fBcurs_addstr\fR(3)
+mvwaddnwstr/\fBcurs_addwstr\fR(3)
mvwaddstr/\fBcurs_addstr\fR(3)
+mvwaddwstr/\fBcurs_addwstr\fR(3)
mvwchgat/\fBcurs_attr\fR(3)
mvwdelch/\fBcurs_delch\fR(3)
+mvwget_wch/\fBcurs_get_wch\fR(3)
+mvwget_wstr/\fBcurs_get_wstr\fR(3)
mvwgetch/\fBcurs_getch\fR(3)
+mvwgetn_wstr/\fBcurs_get_wstr\fR(3)
mvwgetnstr/\fBcurs_getstr\fR(3)
mvwgetstr/\fBcurs_getstr\fR(3)
mvwhline/\fBcurs_border\fR(3)
+mvwhline_set/\fBcurs_border_set\fR(3)
mvwin/\fBcurs_window\fR(3)
+mvwin_wch/\fBcurs_in_wch\fR(3)
+mvwin_wchnstr/\fBcurs_in_wchstr\fR(3)
+mvwin_wchstr/\fBcurs_in_wchstr\fR(3)
mvwinch/\fBcurs_inch\fR(3)
mvwinchnstr/\fBcurs_inchstr\fR(3)
mvwinchstr/\fBcurs_inchstr\fR(3)
mvwinnstr/\fBcurs_instr\fR(3)
+mvwinnwstr/\fBcurs_inwstr\fR(3)
+mvwins_nwstr/\fBcurs_ins_wstr\fR(3)
+mvwins_wch/\fBcurs_ins_wch\fR(3)
+mvwins_wstr/\fBcurs_ins_wstr\fR(3)
mvwinsch/\fBcurs_insch\fR(3)
mvwinsnstr/\fBcurs_insstr\fR(3)
mvwinsstr/\fBcurs_insstr\fR(3)
mvwinstr/\fBcurs_instr\fR(3)
+mvwinwstr/\fBcurs_inwstr\fR(3)
mvwprintw/\fBcurs_printw\fR(3)
mvwscanw/\fBcurs_scanw\fR(3)
mvwvline/\fBcurs_border\fR(3)
+mvwvline_set/\fBcurs_border_set\fR(3)
napms/\fBcurs_kernel\fR(3)
newpad/\fBcurs_pad\fR(3)
newterm/\fBcurs_initscr\fR(3)
@@ -352,6 +542,7 @@ nl/\fBcurs_outopts\fR(3)
nocbreak/\fBcurs_inopts\fR(3)
nodelay/\fBcurs_inopts\fR(3)
noecho/\fBcurs_inopts\fR(3)
+nofilter/\fBcurs_util\fR(3)*
nonl/\fBcurs_outopts\fR(3)
noqiflush/\fBcurs_inopts\fR(3)
noraw/\fBcurs_inopts\fR(3)
@@ -386,6 +577,7 @@ scroll/\fBcurs_scroll\fR(3)
scrollok/\fBcurs_outopts\fR(3)
set_curterm/\fBterminfo\fR(3)
set_term/\fBcurs_initscr\fR(3)
+setcchar/\fBcurs_getcchar\fR(3)
setscrreg/\fBcurs_outopts\fR(3)
setsyx/\fBcurs_kernel\fR(3)
setterm/\fBterminfo\fR(3)
@@ -412,6 +604,7 @@ start_color/\fBcurs_color\fR(3)
subpad/\fBcurs_pad\fR(3)
subwin/\fBcurs_window\fR(3)
syncok/\fBcurs_window\fR(3)
+term_attrs/\fBcurs_termattrs\fR(3)
termattrs/\fBcurs_termattrs\fR(3)
termname/\fBcurs_termattrs\fR(3)
tgetent/\fBtermcap\fR(3)
@@ -428,26 +621,37 @@ touchwin/\fBcurs_touch\fR(3)
tparm/\fBterminfo\fR(3)
tputs/\fBtermcap\fR(3)
tputs/\fBterminfo\fR(3)
+trace/\fBcurs_trace\fR(3)*
typeahead/\fBcurs_inopts\fR(3)
unctrl/\fBcurs_util\fR(3)
+unget_wch/\fBcurs_get_wch\fR(3)
ungetch/\fBcurs_getch\fR(3)
ungetmouse/\fBcurs_mouse\fR(3)*
untouchwin/\fBcurs_touch\fR(3)
use_default_colors/\fBdefault_colors\fR(3)*
use_env/\fBcurs_util\fR(3)
use_extended_names/\fBcurs_extend\fR(3)*
+use_legacy_coding/\fBlegacy_coding\fR(3)*
+vid_attr/\fBterminfo\fR(3)
+vid_puts/\fBterminfo\fR(3)
vidattr/\fBterminfo\fR(3)
vidputs/\fBterminfo\fR(3)
vline/\fBcurs_border\fR(3)
+vline_set/\fBcurs_border_set\fR(3)
vw_printw/\fBcurs_printw\fR(3)
vw_scanw/\fBcurs_scanw\fR(3)
vwprintw/\fBcurs_printw\fR(3)
vwscanw/\fBcurs_scanw\fR(3)
+wadd_wch/\fBcurs_add_wch\fR(3)
+wadd_wchnstr/\fBcurs_add_wchstr\fR(3)
+wadd_wchstr/\fBcurs_add_wchstr\fR(3)
waddch/\fBcurs_addch\fR(3)
waddchnstr/\fBcurs_addchstr\fR(3)
waddchstr/\fBcurs_addchstr\fR(3)
waddnstr/\fBcurs_addstr\fR(3)
+waddnwstr/\fBcurs_addwstr\fR(3)
waddstr/\fBcurs_addstr\fR(3)
+waddwstr/\fBcurs_addwstr\fR(3)
wattr_get/\fBcurs_attr\fR(3)
wattr_off/\fBcurs_attr\fR(3)
wattr_on/\fBcurs_attr\fR(3)
@@ -457,7 +661,10 @@ wattron/\fBcurs_attr\fR(3)
wattrset/\fBcurs_attr\fR(3)
wbkgd/\fBcurs_bkgd\fR(3)
wbkgdset/\fBcurs_bkgd\fR(3)
+wbkgrnd/\fBcurs_bkgrnd\fR(3)
+wbkgrndset/\fBcurs_bkgrnd\fR(3)
wborder/\fBcurs_border\fR(3)
+wborder_set/\fBcurs_border_set\fR(3)
wchgat/\fBcurs_attr\fR(3)
wclear/\fBcurs_clear\fR(3)
wclrtobot/\fBcurs_clear\fR(3)
@@ -466,23 +673,37 @@ wcolor_set/\fBcurs_attr\fR(3)
wcursyncup/\fBcurs_window\fR(3)
wdelch/\fBcurs_delch\fR(3)
wdeleteln/\fBcurs_deleteln\fR(3)
+wecho_wchar/\fBcurs_add_wch\fR(3)
wechochar/\fBcurs_addch\fR(3)
wenclose/\fBcurs_mouse\fR(3)*
werase/\fBcurs_clear\fR(3)
+wget_wch/\fBcurs_get_wch\fR(3)
+wget_wstr/\fBcurs_get_wstr\fR(3)
+wgetbkgrnd/\fBcurs_bkgrnd\fR(3)
wgetch/\fBcurs_getch\fR(3)
+wgetn_wstr/\fBcurs_get_wstr\fR(3)
wgetnstr/\fBcurs_getstr\fR(3)
wgetstr/\fBcurs_getstr\fR(3)
whline/\fBcurs_border\fR(3)
+whline_set/\fBcurs_border_set\fR(3)
+win_wch/\fBcurs_in_wch\fR(3)
+win_wchnstr/\fBcurs_in_wchstr\fR(3)
+win_wchstr/\fBcurs_in_wchstr\fR(3)
winch/\fBcurs_inch\fR(3)
winchnstr/\fBcurs_inchstr\fR(3)
winchstr/\fBcurs_inchstr\fR(3)
winnstr/\fBcurs_instr\fR(3)
+winnwstr/\fBcurs_inwstr\fR(3)
+wins_nwstr/\fBcurs_ins_wstr\fR(3)
+wins_wch/\fBcurs_ins_wch\fR(3)
+wins_wstr/\fBcurs_ins_wstr\fR(3)
winsch/\fBcurs_insch\fR(3)
winsdelln/\fBcurs_deleteln\fR(3)
winsertln/\fBcurs_deleteln\fR(3)
winsnstr/\fBcurs_insstr\fR(3)
winsstr/\fBcurs_insstr\fR(3)
winstr/\fBcurs_instr\fR(3)
+winwstr/\fBcurs_inwstr\fR(3)
wmouse_trafo/\fBcurs_mouse\fR(3)*
wmove/\fBcurs_move\fR(3)
wnoutrefresh/\fBcurs_refresh\fR(3)
@@ -499,30 +720,32 @@ wsyncdown/\fBcurs_window\fR(3)
wsyncup/\fBcurs_window\fR(3)
wtimeout/\fBcurs_inopts\fR(3)
wtouchln/\fBcurs_touch\fR(3)
+wunctrl/\fBcurs_util\fR(3)
wvline/\fBcurs_border\fR(3)
+wvline_set/\fBcurs_border_set\fR(3)
.TE
.SH RETURN VALUE
Routines that return an integer return \fBERR\fR upon failure and an
integer value other than \fBERR\fR upon successful completion, unless
otherwise noted in the routine descriptions.
-
+.PP
All macros return the value of the \fBw\fR version, except \fBsetscrreg\fR,
-\fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, and \fBgetmaxyx\fR. The return
-values of \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, and
+\fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, and \fBgetmaxyx\fR.
+The return values of \fBsetscrreg\fR, \fBwsetscrreg\fR, \fBgetyx\fR, \fBgetbegyx\fR, and
\fBgetmaxyx\fR are undefined (i.e., these should not be used as the
right-hand side of assignment statements).
-
+.PP
Routines that return pointers return \fBNULL\fR on error.
.SH ENVIRONMENT
The following environment symbols are useful for customizing the
-runtime behavior of the \fBcurses\fR library. The most important
-ones have already been discussed in detail.
+runtime behavior of the \fBncurses\fR library.
+The most important ones have been already discussed in detail.
.TP 5
BAUDRATE
The debugging library checks this environment symbol when the application
has redirected output to a file.
The symbol's numeric value is used for the baudrate.
-If no value is found, \fBcurses\fR uses 9600.
+If no value is found, \fBncurses\fR uses 9600.
This allows testers to construct repeatable test-cases
that take into account costs that depend on baudrate.
.TP 5
@@ -536,45 +759,55 @@ COLUMNS
Specify the width of the screen in characters.
Applications running in a windowing environment usually are able to
obtain the width of the window in which they are executing.
-If neither the $COLUMNS value nor the terminal's screen size is available,
-\fBcurses\fR uses the size which may be specified in the terminfo database
+If neither the \fBCOLUMNS\fP value nor the terminal's screen size is available,
+\fBncurses\fR uses the size which may be specified in the terminfo database
(i.e., the \fBcols\fR capability).
-
+.IP
It is important that your application use a correct size for the screen.
-However, this is not always possible because your application may be
+This is not always possible because your application may be
running on a host which does not honor NAWS (Negotiations About Window
Size), or because you are temporarily running as another user.
-
-Either COLUMNS or LINES symbols may be specified independently.
+However, setting \fBCOLUMNS\fP and/or \fBLINES\fP overrides the library's
+use of the screen size obtained from the operating system.
+.IP
+Either \fBCOLUMNS\fP or \fBLINES\fP symbols may be specified independently.
This is mainly useful to circumvent legacy misfeatures of terminal descriptions,
e.g., xterm which commonly specifies a 65 line screen.
For best results, \fBlines\fR and \fBcols\fR should not be specified in
a terminal description for terminals which are run as emulations.
-
-Use the \fBuse_env\fR function to disable this feature.
+.IP
+Use the \fBuse_env\fR function to disable all use of external environment
+(including system calls) to determine the screen size.
.TP 5
ESCDELAY
-Specifies the total time, in milliseconds, for which curses will
+Specifies the total time, in milliseconds, for which ncurses will
await a character sequence, e.g., a function key.
The default value, 1000 milliseconds, is enough for most uses.
However, it is made a variable to accommodate unusual applications.
-
+.IP
The most common instance where you may wish to change this value
is to work with slow hosts, e.g., running on a network.
If the host cannot read characters rapidly enough, it will have the same
effect as if the terminal did not send characters rapidly enough.
The library will still see a timeout.
-
+.IP
Note that xterm mouse events are built up from character sequences
received from the xterm.
If your application makes heavy use of multiple-clicking, you may
wish to lengthen this default value because the timeout applies
to the composed multi-click event as well as the individual clicks.
+.IP
+In addition to the environment variable,
+this implementation provides a global variable with the same name.
+Portable applications should not rely upon the presence of ESCDELAY
+in either form,
+but setting the environment variable rather than the global variable
+does not create problems when compiling an application.
.TP 5
HOME
-Tells \fBcurses\fR where your home directory is.
+Tells \fBncurses\fR where your home directory is.
That is where it may read and write auxiliary terminal descriptions:
-
+.IP
$HOME/.termcap
.br
$HOME/.terminfo
@@ -588,16 +821,52 @@ This applies only to the OS/2 EMX port.
It specifies the order of buttons on the mouse.
OS/2 numbers a 3-button mouse inconsistently from other
platforms:
-
+.sp
1 = left
.br
2 = right
.br
3 = middle.
-
+.sp
This symbol lets you customize the mouse.
The symbol must be three numeric digits 1-3 in any order, e.g., 123 or 321.
-If it is not specified, \fBcurses\fR uses 132.
+If it is not specified, \fBncurses\fR uses 132.
+.TP 5
+NCURSES_ASSUMED_COLORS
+Override the compiled-in assumption that the
+terminal's default colors are white-on-black
+(see \fBdefault_colors\fR(3)).
+You may set the foreground and background color values with this environment
+variable by proving a 2-element list: foreground,background.
+For example, to tell ncurses to not assume anything
+about the colors, set this to "-1,-1".
+To make it green-on-black, set it to "2,0".
+Any positive value from zero to the terminfo \fBmax_colors\fR value is allowed.
+.TP 5
+NCURSES_GPM_TERMS
+This applies only to ncurses configured to use the GPM interface.
+.IP
+If present,
+the environment variable is a list of one or more terminal names
+against which the TERM environment variable is matched.
+Setting it to an empty value disables the GPM interface;
+using the built-in support for xterm, etc.
+.IP
+If the environment variable is absent,
+ncurses will attempt to open GPM if TERM contains "linux".
+.TP 5
+NCURSES_NO_HARD_TABS
+\fBNcurses\fP may use tabs as part of the cursor movement optimization.
+In some cases,
+your terminal driver may not handle these properly.
+Set this environment variable to disable the feature.
+You can also adjust your \fBstty\fP settings to avoid the problem.
+.TP 5
+NCURSES_NO_MAGIC_COOKIES
+Some terminals use a magic-cookie feature which requires special handling
+to make highlighting and other video attributes display properly.
+You can suppress the highlighting entirely for these terminals by
+setting this environment variable.
.TP 5
NCURSES_NO_PADDING
Most of the terminal descriptions in the terminfo database are written
@@ -615,29 +884,50 @@ it (or your application) must manage dataflow, preventing overruns.
The cheapest solution (no hardware cost)
is for your program to do this by pausing after
operations that the terminal does slowly, such as clearing the display.
-
+.IP
As a result, many terminal descriptions (including the vt100)
-have delay times embedded. You may wish to use these descriptions,
+have delay times embedded.
+You may wish to use these descriptions,
but not want to pay the performance penalty.
-
+.IP
Set the NCURSES_NO_PADDING symbol to disable all but mandatory
-padding. Mandatory padding is used as a part of special control
+padding.
+Mandatory padding is used as a part of special control
sequences such as \fIflash\fR.
.TP 5
NCURSES_NO_SETBUF
-Normally \fBcurses\fR enables buffered output during terminal initialization.
+Normally \fBncurses\fR enables buffered output during terminal initialization.
This is done (as in SVr4 curses) for performance reasons.
-For testing purposes, both of \fBcurses\fR and certain applications,
-this feature is made optional. Setting the NCURSES_NO_SETBUF variable
+For testing purposes, both of \fBncurses\fR and certain applications,
+this feature is made optional.
+Setting the NCURSES_NO_SETBUF variable
disables output buffering, leaving the output in the original (usually
line buffered) mode.
.TP 5
+NCURSES_NO_UTF8_ACS
+During initialization, the \fBncurses\fR library
+checks for special cases where VT100 line-drawing (and the corresponding
+alternate character set capabilities) described in the terminfo are known
+to be missing.
+Specifically, when running in a UTF-8 locale,
+the Linux console emulator and the GNU screen program ignore these.
+Ncurses checks the TERM environment variable for these.
+For other special cases, you should set this environment variable.
+Doing this tells ncurses to use Unicode values which correspond to
+the VT100 line-drawing glyphs.
+That works for the special cases cited,
+and is likely to work for terminal emulators.
+.IP
+When setting this variable, you should set it to a nonzero value.
+Setting it to zero (or to a nonnumber)
+disables the special check for Linux and screen.
+.TP 5
NCURSES_TRACE
-During initialization, the \fBcurses\fR debugging library
+During initialization, the \fBncurses\fR debugging library
checks the NCURSES_TRACE symbol.
-If it is defined, to a numeric value, \fBcurses\fR calls the \fBtrace\fR
+If it is defined, to a numeric value, \fBncurses\fR calls the \fBtrace\fR
function, using that value as the argument.
-
+.IP
The argument values, which are defined in \fBcurses.h\fR, provide several
types of information.
When running with traces enabled, your application will write the
@@ -648,25 +938,25 @@ Denotes your terminal type.
Each terminal type is distinct, though many are similar.
.TP 5
TERMCAP
-If the \fBcurses\fR library has been configured with \fItermcap\fR
-support, \fBcurses\fR will check for a terminal's description in
+If the \fBncurses\fR library has been configured with \fItermcap\fR
+support, \fBncurses\fR will check for a terminal's description in
termcap form if it is not available in the terminfo database.
-
+.IP
The TERMCAP symbol contains either a terminal description (with
newlines stripped out),
or a file name telling where the information denoted by the TERM symbol exists.
-In either case, setting it directs \fBcurses\fR to ignore
+In either case, setting it directs \fBncurses\fR to ignore
the usual place for this information, e.g., /etc/termcap.
.TP 5
TERMINFO
-Overrides the directory in which \fBcurses\fR searches for your terminal
+Overrides the directory in which \fBncurses\fR searches for your terminal
description.
This is the simplest, but not the only way to change the list of directories.
The complete list of directories in order follows:
.RS
.TP 3
-
-the last directory to which \fBcurses\fR wrote, if any, is searched first
+the last directory to which \fBncurses\fR wrote, if any, is searched first
.TP 3
-
the directory specified by the TERMINFO symbol
@@ -679,35 +969,36 @@ directories listed in the TERMINFO_DIRS symbol
.TP 3
-
one or more directories whose names are configured and compiled into the
-curses library, e.g.,
-/usr/share/terminfo
+ncurses library, e.g.,
+/usr/share/misc/terminfo
.RE
.TP 5
TERMINFO_DIRS
Specifies a list of directories to search for terminal descriptions.
-The list is separated by colons (i.e., ":").
+The list is separated by colons (i.e., ":") on Unix, semicolons on OS/2 EMX.
All of the terminal descriptions are in terminfo form, which makes
a subdirectory named for the first letter of the terminal names therein.
.TP 5
TERMPATH
-If TERMCAP does not hold a file name then \fBcurses\fR checks
+If TERMCAP does not hold a file name then \fBncurses\fR checks
the TERMPATH symbol.
-This is a list of filenames separated by colons (i.e., ":").
-If the TERMPATH symbol is not set, \fBcurses\fR looks in the files
-/etc/termcap, /usr/share/termcap and $HOME/.termcap, in that order.
+This is a list of filenames separated by spaces or colons (i.e., ":") on Unix, semicolons on OS/2 EMX.
+If the TERMPATH symbol is not set, \fBncurses\fR looks in the files
+/etc/termcap, /usr/share/misc/termcap and $HOME/.termcap, in that order.
.PP
-The library will disregard the following variables when the
-application uses setuid or setgid permissions:
-$TERMCAP, $TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
+The library may be configured to disregard the following variables when the
+current user is the superuser (root), or if the application uses setuid or
+setgid permissions:
+$TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
.SH FILES
.TP 5
/usr/share/tabset
directory containing initialization files for the terminal capability database
-/usr/share/terminfo
+/usr/share/misc/terminfo
terminal capability database
.SH SEE ALSO
-\fBterminfo\fR(\*n), \fBterminfo\fR(3), and 3 pages whose names begin with
-"curs_" for detailed routine descriptions.
+\fBterminfo\fR(\*n) and related pages whose names begin "curs_" for detailed routine
+descriptions.
.TP
/usr/share/doc/html/curses/ncurses-intro.html
intro to ncurses.
@@ -715,198 +1006,91 @@ intro to ncurses.
/usr/share/doc/html/curses/hackguide.html
ncurses hacker's guide.
.SH EXTENSIONS
-The \fBcurses\fR library can be compiled with an option (\fB-DUSE_GETCAP\fR)
+The \fBncurses\fR library can be compiled with an option (\fB-DUSE_GETCAP\fR)
that falls back to the old-style /etc/termcap file if the terminal setup code
-cannot find a terminfo entry corresponding to \fBTERM\fR. Use of this feature
+cannot find a terminfo entry corresponding to \fBTERM\fR.
+Use of this feature
is not recommended, as it essentially includes an entire termcap compiler in
-the \fBcurses\fR startup code, at significant cost in core and startup cycles.
-
-The \fBcurses\fR library includes facilities for capturing mouse events on
-certain terminals (including xterm). See the \fBcurs_mouse\fR(3)
+the \fBncurses\fR startup code, at significant cost in core and startup cycles.
+.PP
+The \fBncurses\fR library includes facilities for capturing mouse events on
+certain terminals (including xterm).
+See the \fBcurs_mouse\fR(3)
manual page for details.
-
-The \fBcurses\fR library includes facilities for responding to window
+.PP
+The \fBncurses\fR library includes facilities for responding to window
resizing events, e.g., when running in an xterm.
See the \fBresizeterm\fR(3)
and \fBwresize\fR(3) manual pages for details.
In addition, the library may be configured with a SIGWINCH handler.
-
-The \fBcurses\fR library extends the fixed set of function key capabilities
+.PP
+The \fBncurses\fR library extends the fixed set of function key capabilities
of terminals by allowing the application designer to define additional
key sequences at runtime.
See the \fBdefine_key\fR(3)
+\fBkey_defined\fR(3),
and \fBkeyok\fR(3) manual pages for details.
-
-The \fBcurses\fR library can exploit the capabilities of terminals which
+.PP
+The \fBncurses\fR library can exploit the capabilities of terminals which
implement the ISO-6429 SGR 39 and SGR 49 controls, which allow an application
to reset the terminal to its original foreground and background colors.
From the users' perspective, the application is able to draw colored
text on a background whose color is set independently, providing better
control over color contrasts.
-See the \fBuse_default_colors\fR(3) manual page for details.
-
-The \fBcurses\fR library includes a function for directing application output
-to a printer attached to the terminal device. See the \fBcurs_print\fR(3)
-manual page for details.
+See the \fBdefault_colors\fR(3) manual page for details.
+.PP
+The \fBncurses\fR library includes a function for directing application output
+to a printer attached to the terminal device.
+See the \fBcurs_print\fR(3) manual page for details.
.SH PORTABILITY
-The \fBcurses\fR library is intended to be BASE-level conformant with the XSI
-Curses standard. Certain portions of the EXTENDED XSI Curses functionality
-(including color support) are supported. The following EXTENDED XSI Curses
-calls in support of wide (multibyte) characters are not yet implemented:
-\fBadd_wch\fP,
-\fBadd_wchnstr\fP,
-\fBadd_wchstr\fP,
-\fBaddnwstr\fP,
-\fBaddwstr\fP,
-\fBbkgrnd\fP,
-\fBbkgrndset\fP,
-\fBborder_set\fP,
-\fBbox_set\fP,
-\fBecho_wchar\fP,
-\fBerasewchar\fP,
-\fBget_wch\fP,
-\fBget_wstr\fP,
-\fBgetbkgrnd\fP,
-\fBgetcchar\fP,
-\fBgetn_wstr\fP,
-\fBgetwchtype\fP,
-\fBhline_set\fP,
-\fBin_wch\fP,
-\fBin_wchnstr\fP,
-\fBin_wchstr\fP,
-\fBinnwstr\fP,
-\fBins_nwstr\fP,
-\fBins_wch\fP,
-\fBins_wstr\fP,
-\fBinwchnstr\fP,
-\fBinwchstr\fP,
-\fBinwstr\fP,
-\fBkey_name\fP,
-\fBkillwchar\fP,
-\fBmvadd_wch\fP,
-\fBmvadd_wchnstr\fP,
-\fBmvadd_wchstr\fP,
-\fBmvaddnwstr\fP,
-\fBmvaddwstr\fP,
-\fBmvget_wch\fP,
-\fBmvget_wstr\fP,
-\fBmvgetn_wstr\fP,
-\fBmvhline_set\fP,
-\fBmvin_wch\fP,
-\fBmvinnwstr\fP,
-\fBmvins_nwstr\fP,
-\fBmvins_wch\fP,
-\fBmvins_wstr\fP,
-\fBmvinwchnstr\fP,
-\fBmvinwchstr\fP,
-\fBmvinwchstr\fP,
-\fBmvinwstr\fP,
-\fBmvvline_set\fP,
-\fBmvwadd_wch\fP,
-\fBmvwadd_wchnstr\fP,
-\fBmvwadd_wchstr\fP,
-\fBmvwaddnwstr\fP,
-\fBmvwaddwstr\fP,
-\fBmvwget_ch\fP,
-\fBmvwget_wch\fP,
-\fBmvwget_wstr\fP,
-\fBmvwgetn_wstr\fP,
-\fBmvwhline_set\fP,
-\fBmvwin_wch\fP,
-\fBmvwin_wchnstr\fP,
-\fBmvwin_wchstr\fP,
-\fBmvwinnwstr\fP,
-\fBmvwins_nwstr\fP,
-\fBmvwins_wch\fP,
-\fBmvwins_wstr\fP,
-\fBmvwinwchnstr\fP,
-\fBmvwinwstr\fP,
-\fBmvwvline_set\fP,
-\fBpecho_wchar\fP,
-\fBsetcchar\fP,
-\fBslk_wset\fP,
-\fBterm_attrs\fP,
-\fBunget_wch\fP,
-\fBvhline_set\fP,
-\fBvid_attr\fP,
-\fBvid_puts\fP,
-\fBvline_set\fP,
-\fBwadd_wch\fP,
-\fBwadd_wchnstr\fP,
-\fBwadd_wchstr\fP,
-\fBwaddnwstr\fP,
-\fBwaddwstr\fP,
-\fBwaddwstr\fP,
-\fBwbkgrnd\fP,
-\fBwbkgrndset\fP,
-\fBwbkgrndset\fP,
-\fBwborder_set\fP,
-\fBwecho_wchar\fP,
-\fBwecho_wchar\fP,
-\fBwget_wch\fP,
-\fBwget_wstr\fP,
-\fBwgetbkgrnd\fP,
-\fBwgetn_wstr\fP,
-\fBwhline_set\fP,
-\fBwin_wch\fP,
-\fBwin_wchnstr\fP,
-\fBwin_wchstr\fP,
-\fBwinnwstr\fP,
-\fBwins_nwstr\fP,
-\fBwins_wch\fP,
-\fBwins_wstr\fP,
-\fBwinwchnstr\fP,
-\fBwinwchstr\fP,
-\fBwinwstr\fP,
-\fBwunctrl\fP,
-\fBwvline_set\fP,
+The \fBncurses\fR library is intended to be BASE-level conformant with XSI
+Curses.
+The EXTENDED XSI Curses functionality
+(including color support) is supported.
.PP
A small number of local differences (that is, individual differences between
-the XSI Curses and \fBcurses\fR calls) are described in \fBPORTABILITY\fR
+the XSI Curses and \fBncurses\fR calls) are described in \fBPORTABILITY\fR
sections of the library man pages.
.PP
-The routine \fBhas_key\fR is not part of XPG4, nor is it present in SVr4. See
-the \fBcurs_getch\fR(3) manual page for details.
+This implementation also contains several extensions:
+.RS 5
+.PP
+The routine \fBhas_key\fR is not part of XPG4, nor is it present in SVr4.
+See the \fBcurs_getch\fR(3) manual page for details.
.PP
-The routine \fBslk_attr\fR is not part of XPG4, nor is it present in SVr4. See
-the \fBcurs_slk\fR(3) manual page for details.
+The routine \fBslk_attr\fR is not part of XPG4, nor is it present in SVr4.
+See the \fBcurs_slk\fR(3) manual page for details.
.PP
The routines \fBgetmouse\fR, \fBmousemask\fR, \fBungetmouse\fR,
\fBmouseinterval\fR, and \fBwenclose\fR relating to mouse interfacing are not
-part of XPG4, nor are they present in SVr4. See the \fBcurs_mouse\fR(3)
-manual page for details.
+part of XPG4, nor are they present in SVr4.
+See the \fBcurs_mouse\fR(3) manual page for details.
.PP
-The routine \fBmcprint\fR was not present in any previous curses
-implementation. See the \fBcurs_print\fR(3) manual page for details.
+The routine \fBmcprint\fR was not present in any previous curses implementation.
+See the \fBcurs_print\fR(3) manual page for details.
.PP
-The routine \fBwresize\fR is not part of XPG4, nor is it present in SVr4. See
-the \fBwresize\fR(3) manual page for details.
+The routine \fBwresize\fR is not part of XPG4, nor is it present in SVr4.
+See the \fBwresize\fR(3) manual page for details.
+.PP
+The WINDOW structure's internal details can be hidden from application
+programs.
+See \fBcurs_opaque\fR(3) for the discussion of \fBis_scrollok\fR, etc.
+.RE
.PP
In historic curses versions, delays embedded in the capabilities \fBcr\fR,
\fBind\fR, \fBcub1\fR, \fBff\fR and \fBtab\fR activated corresponding delay
-bits in the UNIX tty driver. In this implementation, all padding is done by
-NUL sends. This method is slightly more expensive, but narrows the interface
+bits in the UNIX tty driver.
+In this implementation, all padding is done by sending NUL bytes.
+This method is slightly more expensive, but narrows the interface
to the UNIX kernel significantly and increases the package's portability
correspondingly.
-.PP
-In the XSI standard and SVr4 manual pages, many entry points have prototype
-arguments of the for \fBchar *const\fR (or \fBcchar_t *const\fR, or
-\fBwchar_t *const\fR, or \fBvoid *const\fR). Depending on one's interpretation of the
-ANSI C standard (see section 3.5.4.1), these declarations are either (a)
-meaningless, or (b) meaningless and illegal. The declaration
-\fBconst char *x\fR is a modifiable pointer to unmodifiable data, but
-\fBchar *const x\fR' is
-an unmodifiable pointer to modifiable data. Given that C passes arguments by
-value, \fB<type> *const\fR as a formal type is at best dubious. Some compilers
-choke on the prototypes. Therefore, in this implementation, they have been
-changed to \fBconst <type> *\fR globally.
.SH NOTES
The header file \fB<curses.h>\fR automatically includes the header files
\fB<stdio.h>\fR and \fB<unctrl.h>\fR.
-
-If standard output from a \fBcurses\fR program is re-directed to something
-which is not a tty, screen updates will be directed to standard error. This
-was an undocumented feature of AT&T System V Release 3 curses.
+.PP
+If standard output from a \fBncurses\fR program is re-directed to something
+which is not a tty, screen updates will be directed to standard error.
+This was an undocumented feature of AT&T System V Release 3 curses.
.SH AUTHORS
Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
Based on pcurses by Pavel Curtis.
diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h
index d632b4eb468..574b6906abb 100644
--- a/lib/libcurses/curses.h
+++ b/lib/libcurses/curses.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: curses.h,v 1.59 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: curses.h,v 1.60 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,9 +31,10 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $From: curses.h.in,v 1.97 2000/12/10 02:00:24 tom Exp $ */
+/* $Id: curses.h,v 1.60 2010/01/12 23:21:59 nicm Exp $ */
#ifndef __NCURSES_H
#define __NCURSES_H
@@ -42,19 +43,19 @@
#define CURSES_H 1
/* This should be defined for the enhanced functionality to be visible.
- * However, none of the wide-character (enhanced) functionality is implemented.
+ * However, some of the wide-character (enhanced) functionality is missing.
* So we do not define it (yet).
#define _XOPEN_CURSES 1
*/
/* These are defined only in curses.h, and are used for conditional compiles */
#define NCURSES_VERSION_MAJOR 5
-#define NCURSES_VERSION_MINOR 2
-#define NCURSES_VERSION_PATCH 20010224
+#define NCURSES_VERSION_MINOR 7
+#define NCURSES_VERSION_PATCH 20081102
/* This is defined in more than one ncurses header, for identification */
#undef NCURSES_VERSION
-#define NCURSES_VERSION "5.2"
+#define NCURSES_VERSION "5.7"
#if !defined(NCURSES_IMPEXP)
# define NCURSES_IMPEXP /* nothing */
@@ -69,24 +70,82 @@
# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
#endif
+/*
+ * Identify the mouse encoding version.
+ */
+#define NCURSES_MOUSE_VERSION 1
+
+/*
+ * User-definable tweak to disable the include of <stdbool.h>.
+ */
+#ifndef NCURSES_ENABLE_STDBOOL_H
+#define NCURSES_ENABLE_STDBOOL_H 1
+#endif
+
+/*
+ * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
+ * configured using --disable-macros.
+ */
#ifdef NCURSES_NOMACROS
+#ifndef NCURSES_ATTR_T
#define NCURSES_ATTR_T attr_t
#endif
+#endif /* NCURSES_NOMACROS */
#ifndef NCURSES_ATTR_T
#define NCURSES_ATTR_T int
#endif
+/*
+ * Expands to 'const' if ncurses is configured using --enable-const. Note that
+ * doing so makes it incompatible with other implementations of X/Open Curses.
+ */
#undef NCURSES_CONST
#define NCURSES_CONST /*nothing*/
+#undef NCURSES_INLINE
+#define NCURSES_INLINE inline
+
+/*
+ * The internal type used for color values
+ */
#undef NCURSES_COLOR_T
#define NCURSES_COLOR_T short
+/*
+ * Definition used to make WINDOW and similar structs opaque.
+ */
+#ifndef NCURSES_OPAQUE
+#define NCURSES_OPAQUE 0
+#endif
+
+/*
+ * The internal type used for window dimensions.
+ */
#undef NCURSES_SIZE_T
#define NCURSES_SIZE_T short
-typedef unsigned long chtype;
+/*
+ * Control whether tparm() supports varargs or fixed-parameter list.
+ */
+#undef NCURSES_TPARM_VARARGS
+#define NCURSES_TPARM_VARARGS 1
+
+/*
+ * NCURSES_CH_T is used in building the library, but not used otherwise in
+ * this header file, since that would make the normal/wide-character versions
+ * of the header incompatible.
+ */
+#undef NCURSES_CH_T
+#define NCURSES_CH_T chtype
+
+#if 0 && defined(_LP64)
+typedef unsigned chtype;
+typedef unsigned mmask_t;
+#else
+typedef unsigned int chtype;
+typedef unsigned long mmask_t;
+#endif
#include <stdio.h>
#include <unctrl.h>
@@ -95,9 +154,16 @@ typedef unsigned long chtype;
#include <stddef.h> /* we want wchar_t */
#endif /* _XOPEN_SOURCE_EXTENDED */
-/* XSI and SVr4 specify that curses implements 'bool'. However, C++ may also
+/* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also
* implement it. If so, we must use the C++ compiler's type to avoid conflict
* with other interfaces.
+ *
+ * A further complication is that <stdbool.h> may declare 'bool' to be a
+ * different type, such as an enum which is not necessarily compatible with
+ * C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
+ * Otherwise, let it remain a typedef to avoid conflicts with other #define's.
+ * In either case, make a typedef for NCURSES_BOOL which can be used if needed
+ * from either C or C++.
*/
#undef TRUE
@@ -106,17 +172,36 @@ typedef unsigned long chtype;
#undef FALSE
#define FALSE 0
-#if !defined(__cplusplus)
+typedef unsigned char NCURSES_BOOL;
+
+#if defined(__cplusplus) /* __cplusplus, etc. */
+
+/* use the C++ compiler's bool type */
+#define NCURSES_BOOL bool
+
+#else /* c89, c99, etc. */
+
+#if NCURSES_ENABLE_STDBOOL_H
+#include <stdbool.h>
+/* use whatever the C compiler decides bool really is */
+#define NCURSES_BOOL bool
+#else
+/* there is no predefined bool - use our own */
#undef bool
-typedef unsigned char bool;
+#define bool NCURSES_BOOL
#endif
+#endif /* !__cplusplus, etc. */
+
#ifdef __cplusplus
extern "C" {
+#define NCURSES_CAST(type,value) static_cast<type>(value)
+#else
+#define NCURSES_CAST(type,value) (type)(value)
#endif
/*
- * XSI attributes. In the ncurses implementation, they are identical to the
+ * X/Open attributes. In the ncurses implementation, they are identical to the
* A_ attributes.
*/
#define WA_ATTRIBUTES A_ATTRIBUTES
@@ -138,9 +223,6 @@ extern "C" {
#define WA_VERTICAL A_VERTICAL
/* colors */
-extern NCURSES_EXPORT_VAR(int) COLORS;
-extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
-
#define COLOR_BLACK 0
#define COLOR_RED 1
#define COLOR_GREEN 2
@@ -152,47 +234,54 @@ extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
/* line graphics */
+#if 0 || 0
+NCURSES_WRAPPED_VAR(chtype*, acs_map);
+#define acs_map (_nc_acs_map())
+#else
extern NCURSES_EXPORT_VAR(chtype) acs_map[];
+#endif
+
+#define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,c)])
/* VT100 symbols begin here */
-#define ACS_ULCORNER (acs_map['l']) /* upper left corner */
-#define ACS_LLCORNER (acs_map['m']) /* lower left corner */
-#define ACS_URCORNER (acs_map['k']) /* upper right corner */
-#define ACS_LRCORNER (acs_map['j']) /* lower right corner */
-#define ACS_LTEE (acs_map['t']) /* tee pointing right */
-#define ACS_RTEE (acs_map['u']) /* tee pointing left */
-#define ACS_BTEE (acs_map['v']) /* tee pointing up */
-#define ACS_TTEE (acs_map['w']) /* tee pointing down */
-#define ACS_HLINE (acs_map['q']) /* horizontal line */
-#define ACS_VLINE (acs_map['x']) /* vertical line */
-#define ACS_PLUS (acs_map['n']) /* large plus or crossover */
-#define ACS_S1 (acs_map['o']) /* scan line 1 */
-#define ACS_S9 (acs_map['s']) /* scan line 9 */
-#define ACS_DIAMOND (acs_map['`']) /* diamond */
-#define ACS_CKBOARD (acs_map['a']) /* checker board (stipple) */
-#define ACS_DEGREE (acs_map['f']) /* degree symbol */
-#define ACS_PLMINUS (acs_map['g']) /* plus/minus */
-#define ACS_BULLET (acs_map['~']) /* bullet */
+#define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */
+#define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */
+#define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */
+#define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */
+#define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */
+#define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */
+#define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */
+#define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */
+#define ACS_HLINE NCURSES_ACS('q') /* horizontal line */
+#define ACS_VLINE NCURSES_ACS('x') /* vertical line */
+#define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */
+#define ACS_S1 NCURSES_ACS('o') /* scan line 1 */
+#define ACS_S9 NCURSES_ACS('s') /* scan line 9 */
+#define ACS_DIAMOND NCURSES_ACS('`') /* diamond */
+#define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */
+#define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */
+#define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */
+#define ACS_BULLET NCURSES_ACS('~') /* bullet */
/* Teletype 5410v1 symbols begin here */
-#define ACS_LARROW (acs_map[',']) /* arrow pointing left */
-#define ACS_RARROW (acs_map['+']) /* arrow pointing right */
-#define ACS_DARROW (acs_map['.']) /* arrow pointing down */
-#define ACS_UARROW (acs_map['-']) /* arrow pointing up */
-#define ACS_BOARD (acs_map['h']) /* board of squares */
-#define ACS_LANTERN (acs_map['i']) /* lantern symbol */
-#define ACS_BLOCK (acs_map['0']) /* solid square block */
+#define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */
+#define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */
+#define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */
+#define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */
+#define ACS_BOARD NCURSES_ACS('h') /* board of squares */
+#define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */
+#define ACS_BLOCK NCURSES_ACS('0') /* solid square block */
/*
* These aren't documented, but a lot of System Vs have them anyway
* (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
* The ACS_names may not match AT&T's, our source didn't know them.
*/
-#define ACS_S3 (acs_map['p']) /* scan line 3 */
-#define ACS_S7 (acs_map['r']) /* scan line 7 */
-#define ACS_LEQUAL (acs_map['y']) /* less/equal */
-#define ACS_GEQUAL (acs_map['z']) /* greater/equal */
-#define ACS_PI (acs_map['{']) /* Pi */
-#define ACS_NEQUAL (acs_map['|']) /* not equal */
-#define ACS_STERLING (acs_map['}']) /* UK pound sign */
+#define ACS_S3 NCURSES_ACS('p') /* scan line 3 */
+#define ACS_S7 NCURSES_ACS('r') /* scan line 7 */
+#define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */
+#define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */
+#define ACS_PI NCURSES_ACS('{') /* Pi */
+#define ACS_NEQUAL NCURSES_ACS('|') /* not equal */
+#define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */
/*
* Line drawing ACS names are of the form ACS_trbl, where t is the top, r
@@ -212,13 +301,11 @@ extern NCURSES_EXPORT_VAR(chtype) acs_map[];
#define ACS_SBSB ACS_VLINE
#define ACS_SSSS ACS_PLUS
-#if !defined(ERR) || ((ERR) != -1)
+#undef ERR
#define ERR (-1)
-#endif
-#if !defined(OK) || ((OK) != 0)
+#undef OK
#define OK (0)
-#endif
/* values for the _flags member */
#define _SUBWIN 0x01 /* is this a sub-window? */
@@ -247,29 +334,43 @@ typedef struct _win_st WINDOW;
typedef chtype attr_t; /* ...must be at least as wide as chtype */
#ifdef _XOPEN_SOURCE_EXTENDED
-#ifndef _WCHAR_T
-typedef unsigned long wchar_t;
-#endif /* _WCHAR_T */
-#ifndef _WINT_T
-typedef long int wint_t;
-#endif /* _WINT_T */
+
+#if 0
+#ifdef mblen /* libutf8.h defines it w/o undefining first */
+#undef mblen
+#endif
+#include <libutf8.h>
+#endif
+
+#if 0
+#include <wchar.h> /* ...to get mbstate_t, etc. */
+#endif
+
+#if 0
+typedef unsigned short wchar_t;
+#endif
+
+#if 0
+typedef unsigned int wint_t;
+#endif
#define CCHARW_MAX 5
typedef struct
{
attr_t attr;
wchar_t chars[CCHARW_MAX];
+#if 0
+#undef NCURSES_EXT_COLORS
+#define NCURSES_EXT_COLORS 20081102
+ int ext_color; /* color pair, must be more than 16-bits */
+#endif
}
cchar_t;
+
#endif /* _XOPEN_SOURCE_EXTENDED */
-struct ldat
-{
- chtype *text; /* text of the line */
- NCURSES_SIZE_T firstchar; /* first changed character in the line */
- NCURSES_SIZE_T lastchar; /* last changed character in the line */
- NCURSES_SIZE_T oldindex; /* index of the line at last update */
-};
+#if !NCURSES_OPAQUE
+struct ldat;
struct _win_st
{
@@ -287,14 +388,14 @@ struct _win_st
/* option values set by user */
bool _notimeout; /* no time out on function-key entry? */
- bool _clear; /* consider all data in the window invalid? */
- bool _leaveok; /* OK to not reset cursor on exit? */
- bool _scroll; /* OK to scroll this window? */
- bool _idlok; /* OK to use insert/delete line? */
- bool _idcok; /* OK to use insert/delete char? */
+ bool _clear; /* consider all data in the window invalid? */
+ bool _leaveok; /* OK to not reset cursor on exit? */
+ bool _scroll; /* OK to scroll this window? */
+ bool _idlok; /* OK to use insert/delete line? */
+ bool _idcok; /* OK to use insert/delete char? */
bool _immed; /* window in immed mode? (not yet used) */
bool _sync; /* window in sync mode? */
- bool _use_keypad; /* process function keys into KEY_ symbols? */
+ bool _use_keypad; /* process function keys into KEY_ symbols? */
int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */
struct ldat *_line; /* the actual line data */
@@ -317,72 +418,99 @@ struct _win_st
} _pad;
NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
-};
-
-extern NCURSES_EXPORT_VAR(WINDOW *) stdscr;
-extern NCURSES_EXPORT_VAR(WINDOW *) curscr;
-extern NCURSES_EXPORT_VAR(WINDOW *) newscr;
-extern NCURSES_EXPORT_VAR(int) LINES;
-extern NCURSES_EXPORT_VAR(int) COLS;
-extern NCURSES_EXPORT_VAR(int) TABSIZE;
+#ifdef _XOPEN_SOURCE_EXTENDED
+ cchar_t _bkgrnd; /* current background char/attribute pair */
+#if 0
+ int _color; /* current color-pair for non-space character */
+#endif
+#endif
+};
+#endif /* NCURSES_OPAQUE */
/*
- * This global was an undocumented feature under AIX curses.
+ * This is an extension to support events...
*/
-extern NCURSES_EXPORT_VAR(int) ESCDELAY; /* ESC expire time in milliseconds */
-
-extern NCURSES_EXPORT_VAR(char) ttytype[]; /* needed for backward compatibility */
+#if 1
+#ifdef NCURSES_WGETCH_EVENTS
+#if !defined(__BEOS__) || defined(__HAIKU__)
+ /* Fix _nc_timed_wait() on BEOS... */
+# define NCURSES_EVENT_VERSION 1
+#endif /* !defined(__BEOS__) */
/*
- * These functions are extensions - not in XSI Curses.
+ * Bits to set in _nc_event.data.flags
*/
-extern NCURSES_EXPORT(char *) keybound (int, int);
-extern NCURSES_EXPORT(const char *) curses_version (void);
-extern NCURSES_EXPORT(int) assume_default_colors (int, int);
-extern NCURSES_EXPORT(int) define_key (char *, int);
-extern NCURSES_EXPORT(int) keyok (int, bool);
-extern NCURSES_EXPORT(int) resizeterm (int, int);
-extern NCURSES_EXPORT(int) use_default_colors (void);
-extern NCURSES_EXPORT(int) use_extended_names (bool);
-extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
+# define _NC_EVENT_TIMEOUT_MSEC 1
+# define _NC_EVENT_FILE 2
+# define _NC_EVENT_FILE_READABLE 2
+# if 0 /* Not supported yet... */
+# define _NC_EVENT_FILE_WRITABLE 4
+# define _NC_EVENT_FILE_EXCEPTION 8
+# endif
+
+typedef struct
+{
+ int type;
+ union
+ {
+ long timeout_msec; /* _NC_EVENT_TIMEOUT_MSEC */
+ struct
+ {
+ unsigned int flags;
+ int fd;
+ unsigned int result;
+ } fev; /* _NC_EVENT_FILE */
+ } data;
+} _nc_event;
+
+typedef struct
+{
+ int count;
+ int result_flags; /* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
+ _nc_event *events[1];
+} _nc_eventlist;
+
+extern NCURSES_EXPORT(int) wgetch_events(WINDOW *, _nc_eventlist *); /* experimental */
+extern NCURSES_EXPORT(int) wgetnstr_events(WINDOW *,char *,int,_nc_eventlist *);/* experimental */
+
+#endif /* NCURSES_WGETCH_EVENTS */
+#endif /* NCURSES_EXT_FUNCS */
/*
* GCC (and some other compilers) define '__attribute__'; we're using this
* macro to alert the compiler to flag inconsistencies in printf/scanf-like
* function calls. Just in case '__attribute__' isn't defined, make a dummy.
- * G++ doesn't accept it anyway.
+ * Old versions of G++ do not accept it anyway, at least not consistently with
+ * GCC.
*/
-#if !defined(__GNUC__) && !defined(__attribute__)
+#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__))
#define __attribute__(p) /* nothing */
#endif
/*
- * For g++, turn off our macros that use __attribute__ (g++ recognizes some
- * of them, but not at the same version levels as gcc).
- */
-#ifdef __cplusplus
-#undef GCC_NORETURN
-#undef GCC_PRINTF
-#undef GCC_SCANF
-#undef GCC_UNUSED
-#endif
-
-/*
* We cannot define these in ncurses_cfg.h, since they require parameters to be
- * passed (that's non-portable).
+ * passed (that is non-portable). If you happen to be using gcc with warnings
+ * enabled, define
+ * GCC_PRINTF
+ * GCC_SCANF
+ * to improve checking of calls to printw(), etc.
*/
-#ifdef GCC_PRINTF
+#ifndef GCC_PRINTFLIKE
+#if defined(GCC_PRINTF) && !defined(printf)
#define GCC_PRINTFLIKE(fmt,var) __attribute__((__format__(printf,fmt,var)))
#else
#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
#endif
+#endif
-#ifdef GCC_SCANF
+#ifndef GCC_SCANFLIKE
+#if defined(GCC_SCANF) && !defined(scanf)
#define GCC_SCANFLIKE(fmt,var) __attribute__((__format__(scanf,fmt,var)))
#else
#define GCC_SCANFLIKE(fmt,var) /*nothing*/
#endif
+#endif
#ifndef GCC_NORETURN
#define GCC_NORETURN /* nothing */
@@ -393,7 +521,7 @@ extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
#endif
/*
- * Function prototypes. This is the complete XSI Curses list of required
+ * Function prototypes. This is the complete X/Open Curses list of required
* functions. Those marked `generated' will have sources generated from the
* macro definitions later in this file, in order to satisfy XPG4.2
* requirements.
@@ -404,13 +532,6 @@ extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */
extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */
extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */
extern NCURSES_EXPORT(int) addstr (const char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */
extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */
extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */
@@ -422,18 +543,8 @@ extern NCURSES_EXPORT(int) baudrate (void); /* implemented */
extern NCURSES_EXPORT(int) beep (void); /* implemented */
extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */
extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */
extern NCURSES_EXPORT(int) cbreak (void); /* implemented */
extern NCURSES_EXPORT(int) chgat (int, attr_t, short, const void *); /* generated */
@@ -459,41 +570,21 @@ extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) echo (void); /* implemented */
extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */
extern NCURSES_EXPORT(int) erase (void); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) endwin (void); /* implemented */
extern NCURSES_EXPORT(char) erasechar (void); /* implemented */
extern NCURSES_EXPORT(void) filter (void); /* implemented */
extern NCURSES_EXPORT(int) flash (void); /* implemented */
extern NCURSES_EXPORT(int) flushinp (void); /* implemented */
extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, short*, void*); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) getch (void); /* generated */
extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) getstr (char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) get_wch (wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */
extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */
extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */
extern NCURSES_EXPORT(bool) has_il (void); /* implemented */
extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */
@@ -504,39 +595,19 @@ extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */
extern NCURSES_EXPORT(int) init_color (short,short,short,short); /* implemented */
extern NCURSES_EXPORT(int) init_pair (short,short,short); /* implemented */
extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) insch (chtype); /* generated */
extern NCURSES_EXPORT(int) insdelln (int); /* generated */
extern NCURSES_EXPORT(int) insertln (void); /* generated */
extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */
extern NCURSES_EXPORT(int) insstr (const char *); /* generated */
extern NCURSES_EXPORT(int) instr (char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) in_wch (NCURSES_CONST cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) in_wchstr (NCURSES_CONST cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) in_wchnstr (NCURSES_CONST cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */
extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */
extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(char *) key_name (wchar_t); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(char) killchar (void); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(char *) longname (void); /* implemented */
extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */
@@ -546,120 +617,52 @@ extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* gener
extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */
extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* missing */
-extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, short, const void *); /* generated */
extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */
extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */
extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */
extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */
extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */
extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */
extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */
extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */
extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */
extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvin_wch (int, int, NCURSES_CONST cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvin_wchstr (int, int, NCURSES_CONST cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, NCURSES_CONST cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
-extern NCURSES_EXPORT(int) mvprintw (int,int, NCURSES_CONST char *,...) /* implemented */
+extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */
GCC_PRINTFLIKE(3,4);
extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(3,4);
extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */
extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */
extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */
extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* missing */
-extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, short, const void *);/* generated */
extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */
extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */
extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */
extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */
extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */
extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* missing */
-extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, NCURSES_CONST cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, NCURSES_CONST cchar_t *,int); /* missing */
-extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, NCURSES_CONST cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
-extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, NCURSES_CONST char *,...) /* implemented */
+extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */
GCC_PRINTFLIKE(4,5);
extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(4,5);
extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) napms (int); /* implemented */
extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */
extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *); /* implemented */
@@ -677,14 +680,10 @@ extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented *
extern NCURSES_EXPORT(int) pair_content (short,short*,short*); /* implemented */
extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */
extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */
extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */
-extern NCURSES_EXPORT(int) printw (NCURSES_CONST char *,...) /* implemented */
+extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */
GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(int) putp (const char *); /* implemented */
extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */
extern NCURSES_EXPORT(void) qiflush (void); /* implemented */
extern NCURSES_EXPORT(int) raw (void); /* implemented */
@@ -693,7 +692,7 @@ extern NCURSES_EXPORT(int) refresh (void); /* generated */
extern NCURSES_EXPORT(int) resetty (void); /* implemented */
extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */
extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */
-extern NCURSES_EXPORT(int) ripoffline (int, int (*init)(WINDOW *, int)); /* implemented */
+extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */
extern NCURSES_EXPORT(int) savetty (void); /* implemented */
extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...) /* implemented */
GCC_SCANFLIKE(1,2);
@@ -704,9 +703,6 @@ extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */
extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */
extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, short, const void *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */
extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */
extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */
@@ -725,75 +721,43 @@ extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */
extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */
extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */
extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) standout (void); /* generated */
extern NCURSES_EXPORT(int) standend (void); /* generated */
extern NCURSES_EXPORT(int) start_color (void); /* implemented */
extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */
-extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *,int,int,int,int); /* implemented */
+extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */
extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */
extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */
-extern NCURSES_EXPORT(attr_t) term_attrs (void); /* missing */
extern NCURSES_EXPORT(char *) termname (void); /* implemented */
-extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *); /* implemented */
-extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *); /* implemented */
-extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *); /* implemented */
extern NCURSES_EXPORT(void) timeout (int); /* generated */
extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */
extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* implemented */
extern NCURSES_EXPORT(int) typeahead (int); /* implemented */
extern NCURSES_EXPORT(int) ungetch (int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */
extern NCURSES_EXPORT(void) use_env (bool); /* implemented */
extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */
-extern NCURSES_EXPORT(int) vid_attr (attr_t, short, void *); /* generated:WIDEC */
extern NCURSES_EXPORT(int) vidputs (chtype, int (*)(int)); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) vid_puts (attr_t, short, void *, int (*)(int)); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
-extern NCURSES_EXPORT(int) vwprintw (WINDOW *, NCURSES_CONST char *,va_list); /* implemented */
-extern NCURSES_EXPORT(int) vw_printw (WINDOW *, NCURSES_CONST char *,va_list); /* generated */
+extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list); /* implemented */
+extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* generated */
extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list); /* implemented */
extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list); /* generated */
extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */
-extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *const,int); /* implemented */
+extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */
extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */
-extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *const,int); /* implemented */
+extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */
extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* missing */
-extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* missing */
-extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */
extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */
extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */
extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, short *, void *); /* generated */
-extern NCURSES_EXPORT(int) wattr_on (WINDOW *, NCURSES_CONST attr_t, void *); /* implemented */
-extern NCURSES_EXPORT(int) wattr_off (WINDOW *, NCURSES_CONST attr_t, void *); /* implemented */
-extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, short, void *); /* generated */
-extern NCURSES_EXPORT(int) wbkgd (WINDOW *,const chtype); /* implemented */
+extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */
+extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */
+extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, short, void *); /* generated */
+extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */
extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, short, const void *);/* implemented */
extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */
@@ -803,52 +767,24 @@ extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *,wint_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* missing */
-extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */
extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */
extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */
extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */
extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */
extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */
extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */
extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* missing */
-extern NCURSES_EXPORT(int) win_wch (WINDOW *, NCURSES_CONST cchar_t *); /* missing */
-extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, NCURSES_CONST cchar_t *, int); /* missing */
-extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, NCURSES_CONST cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */
-extern NCURSES_EXPORT(int) wprintw (WINDOW *, NCURSES_CONST char *,...) /* implemented */
+extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */
GCC_PRINTFLIKE(2,3);
extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */
extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */
@@ -862,60 +798,155 @@ extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */
extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */
extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */
extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(wchar_t *) wunctrl (cchar_t *); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
-extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */
+/*
+ * These are also declared in <term.h>:
+ */
+extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *); /* implemented */
+extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *); /* implemented */
+extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *); /* implemented */
+extern NCURSES_EXPORT(int) putp (const char *); /* implemented */
-/* attributes */
+#if NCURSES_TPARM_VARARGS
+extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */
+#else
+extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */
+extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */
+#endif
+
+/*
+ * These functions are not in X/Open, but we use them in macro definitions:
+ */
+extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */
+
+/*
+ * vid_attr() was implemented originally based on a draft of X/Open curses.
+ */
+#ifndef _XOPEN_SOURCE_EXTENDED
+#define vid_attr(a,pair,opts) vidattr(a)
+#endif
+
+/*
+ * These functions are extensions - not in X/Open Curses.
+ */
+#if 1
+#undef NCURSES_EXT_FUNCS
+#define NCURSES_EXT_FUNCS 20081102
+typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
+typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
+extern NCURSES_EXPORT(bool) is_term_resized (int, int);
+extern NCURSES_EXPORT(char *) keybound (int, int);
+extern NCURSES_EXPORT(const char *) curses_version (void);
+extern NCURSES_EXPORT(int) assume_default_colors (int, int);
+extern NCURSES_EXPORT(int) define_key (const char *, int);
+extern NCURSES_EXPORT(int) key_defined (const char *);
+extern NCURSES_EXPORT(int) keyok (int, bool);
+extern NCURSES_EXPORT(int) resize_term (int, int);
+extern NCURSES_EXPORT(int) resizeterm (int, int);
+extern NCURSES_EXPORT(int) set_escdelay (int);
+extern NCURSES_EXPORT(int) set_tabsize (int);
+extern NCURSES_EXPORT(int) use_default_colors (void);
+extern NCURSES_EXPORT(int) use_extended_names (bool);
+extern NCURSES_EXPORT(int) use_legacy_coding (int);
+extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *);
+extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *);
+extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
+extern NCURSES_EXPORT(void) nofilter(void);
-#define NCURSES_BITS(mask,shift) ((mask) << ((shift) + 8))
-
-#define A_NORMAL 0L
-#define A_ATTRIBUTES NCURSES_BITS(~(1UL - 1UL),0)
-#define A_CHARTEXT (NCURSES_BITS(1UL,0) - 1UL)
-#define A_COLOR NCURSES_BITS(((1UL) << 8) - 1UL,0)
-#define A_STANDOUT NCURSES_BITS(1UL,8)
-#define A_UNDERLINE NCURSES_BITS(1UL,9)
-#define A_REVERSE NCURSES_BITS(1UL,10)
-#define A_BLINK NCURSES_BITS(1UL,11)
-#define A_DIM NCURSES_BITS(1UL,12)
-#define A_BOLD NCURSES_BITS(1UL,13)
-#define A_ALTCHARSET NCURSES_BITS(1UL,14)
-#define A_INVIS NCURSES_BITS(1UL,15)
-
-/* Tradeoff on 32-bit machines ('protect' vs widec). The others (e.g., left
- * highlight are not implemented in any terminal descriptions, anyway.
+/*
+ * These extensions provide access to information stored in the WINDOW even
+ * when NCURSES_OPAQUE is set:
*/
-#if ((16 + 8) < 32)
-#define A_PROTECT NCURSES_BITS(1UL,16)
-#define A_HORIZONTAL NCURSES_BITS(1UL,17)
-#define A_LEFT NCURSES_BITS(1UL,18)
-#define A_LOW NCURSES_BITS(1UL,19)
-#define A_RIGHT NCURSES_BITS(1UL,20)
-#define A_TOP NCURSES_BITS(1UL,21)
-#define A_VERTICAL NCURSES_BITS(1UL,22)
+extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */
+extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */
+
#else
-#define A_PROTECT 0L
-#define A_HORIZONTAL 0L
-#define A_LEFT 0L
-#define A_LOW 0L
-#define A_RIGHT 0L
-#define A_TOP 0L
-#define A_VERTICAL 0L
+#define curses_version() NCURSES_VERSION
#endif
-#define COLOR_PAIR(n) NCURSES_BITS(n, 0)
-#define PAIR_NUMBER(a) (((a) & A_COLOR) >> 8)
+/* attributes */
+
+#define NCURSES_ATTR_SHIFT 8
+#define NCURSES_BITS(mask,shift) ((mask) << ((shift) + NCURSES_ATTR_SHIFT))
+
+#define A_NORMAL (1U - 1U)
+#define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0)
+#define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U)
+#define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0)
+#define A_STANDOUT NCURSES_BITS(1U,8)
+#define A_UNDERLINE NCURSES_BITS(1U,9)
+#define A_REVERSE NCURSES_BITS(1U,10)
+#define A_BLINK NCURSES_BITS(1U,11)
+#define A_DIM NCURSES_BITS(1U,12)
+#define A_BOLD NCURSES_BITS(1U,13)
+#define A_ALTCHARSET NCURSES_BITS(1U,14)
+#define A_INVIS NCURSES_BITS(1U,15)
+#define A_PROTECT NCURSES_BITS(1U,16)
+#define A_HORIZONTAL NCURSES_BITS(1U,17)
+#define A_LEFT NCURSES_BITS(1U,18)
+#define A_LOW NCURSES_BITS(1U,19)
+#define A_RIGHT NCURSES_BITS(1U,20)
+#define A_TOP NCURSES_BITS(1U,21)
+#define A_VERTICAL NCURSES_BITS(1U,22)
/*
- * pseudo functions
+ * Most of the pseudo functions are macros that either provide compatibility
+ * with older versions of curses, or provide inline functionality to improve
+ * performance.
*/
+
+/*
+ * These pseudo functions are always implemented as macros:
+ */
+
+#define getyx(win,y,x) (y = getcury(win), x = getcurx(win))
+#define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win))
+#define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win))
+#define getparyx(win,y,x) (y = getpary(win), x = getparx(win))
+
+#define getsyx(y,x) do { if (newscr) { \
+ if (is_leaveok(newscr)) \
+ (y) = (x) = -1; \
+ else \
+ getyx(newscr,(y), (x)); \
+ } \
+ } while(0)
+
+#define setsyx(y,x) do { if (newscr) { \
+ if ((y) == -1 && (x) == -1) \
+ leaveok(newscr, TRUE); \
+ else { \
+ leaveok(newscr, FALSE); \
+ wmove(newscr, (y), (x)); \
+ } \
+ } \
+ } while(0)
+
+#ifndef NCURSES_NOMACROS
+
+/*
+ * These miscellaneous pseudo functions are provided for compatibility:
+ */
+
#define wgetstr(w, s) wgetnstr(w, s, -1)
#define getnstr(s, n) wgetnstr(stdscr, s, n)
@@ -928,35 +959,33 @@ extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* gene
#define nocrmode() nocbreak()
#define gettmode()
-#define getyx(win,y,x) (y = (win)?(win)->_cury:ERR, x = (win)?(win)->_curx:ERR)
-#define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
-#define getmaxyx(win,y,x) (y = (win)?((win)->_maxy + 1):ERR, x = (win)?((win)->_maxx + 1):ERR)
-#define getparyx(win,y,x) (y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
-#define getsyx(y,x) do { if(newscr->_leaveok) (y)=(x)=-1; \
- else getyx(newscr,(y),(x)); \
- } while(0)
-#define setsyx(y,x) do { if((y)==-1 && (x)==-1) newscr->_leaveok=TRUE; \
- else {newscr->_leaveok=FALSE;wmove(newscr,(y),(x));} \
- } while(0)
-
/* It seems older SYSV curses versions define these */
-#define getattrs(win) ((win)?(win)->_attrs:A_NORMAL)
-#define getcurx(win) ((win)?(win)->_curx:ERR)
-#define getcury(win) ((win)?(win)->_cury:ERR)
-#define getbegx(win) ((win)?(win)->_begx:ERR)
-#define getbegy(win) ((win)?(win)->_begy:ERR)
-#define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
-#define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
-#define getparx(win) ((win)?(win)->_parx:ERR)
-#define getpary(win) ((win)?(win)->_pary:ERR)
+#if !NCURSES_OPAQUE
+#define getattrs(win) ((win) ? (win)->_attrs : A_NORMAL)
+#define getcurx(win) ((win) ? (win)->_curx : ERR)
+#define getcury(win) ((win) ? (win)->_cury : ERR)
+#define getbegx(win) ((win) ? (win)->_begx : ERR)
+#define getbegy(win) ((win) ? (win)->_begy : ERR)
+#define getmaxx(win) ((win) ? ((win)->_maxx + 1) : ERR)
+#define getmaxy(win) ((win) ? ((win)->_maxy + 1) : ERR)
+#define getparx(win) ((win) ? (win)->_parx : ERR)
+#define getpary(win) ((win) ? (win)->_pary : ERR)
+#endif /* NCURSES_OPAQUE */
#define wstandout(win) (wattrset(win,A_STANDOUT))
#define wstandend(win) (wattrset(win,A_NORMAL))
-#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
-#define wattron(win,at) wattr_on(win, at, (void *)0)
-#define wattroff(win,at) wattr_off(win, at, (void *)0)
-#define wattrset(win,at) ((win)->_attrs = (at))
+#define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
+#define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
+
+#if !NCURSES_OPAQUE
+#if defined(_XOPEN_SOURCE_EXTENDED) && 0
+#define wattrset(win,at) ((win)->_color = PAIR_NUMBER(at), \
+ (win)->_attrs = (at))
+#else
+#define wattrset(win,at) ((win)->_attrs = (at))
+#endif
+#endif /* NCURSES_OPAQUE */
#define scroll(win) wscrl(win,1)
@@ -973,183 +1002,142 @@ extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* gene
#define winchstr(w, s) winchnstr(w, s, -1)
#define winsstr(w, s) winsnstr(w, s, -1)
+#if !NCURSES_OPAQUE
#define redrawwin(win) wredrawln(win, 0, (win)->_maxy+1)
+#endif /* NCURSES_OPAQUE */
+
#define waddstr(win,str) waddnstr(win,str,-1)
#define waddchstr(win,str) waddchnstr(win,str,-1)
/*
+ * These apply to the first 256 color pairs.
+ */
+#define COLOR_PAIR(n) NCURSES_BITS(n, 0)
+#define PAIR_NUMBER(a) (NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
+
+/*
* pseudo functions for standard screen
*/
-#define addch(ch) waddch(stdscr,ch)
+#define addch(ch) waddch(stdscr,ch)
#define addchnstr(str,n) waddchnstr(stdscr,str,n)
#define addchstr(str) waddchstr(stdscr,str)
#define addnstr(str,n) waddnstr(stdscr,str,n)
-#define addstr(str) waddnstr(stdscr,str,-1)
-#define attroff(at) wattroff(stdscr,at)
-#define attron(at) wattron(stdscr,at)
-#define attrset(at) wattrset(stdscr,at)
+#define addstr(str) waddnstr(stdscr,str,-1)
+#define attroff(at) wattroff(stdscr,at)
+#define attron(at) wattron(stdscr,at)
+#define attrset(at) wattrset(stdscr,at)
+#define attr_get(ap,cp,o) wattr_get(stdscr,ap,cp,o)
+#define attr_off(a,o) wattr_off(stdscr,a,o)
+#define attr_on(a,o) wattr_on(stdscr,a,o)
+#define attr_set(a,c,o) wattr_set(stdscr,a,c,o)
#define bkgd(ch) wbkgd(stdscr,ch)
#define bkgdset(ch) wbkgdset(stdscr,ch)
-#define clear() wclear(stdscr)
-#define clrtobot() wclrtobot(stdscr)
-#define clrtoeol() wclrtoeol(stdscr)
+#define chgat(n,a,c,o) wchgat(stdscr,n,a,c,o)
+#define clear() wclear(stdscr)
+#define clrtobot() wclrtobot(stdscr)
+#define clrtoeol() wclrtoeol(stdscr)
#define color_set(c,o) wcolor_set(stdscr,c,o)
-#define delch() wdelch(stdscr)
-#define deleteln() winsdelln(stdscr,-1)
+#define delch() wdelch(stdscr)
+#define deleteln() winsdelln(stdscr,-1)
#define echochar(c) wechochar(stdscr,c)
-#define erase() werase(stdscr)
-#define getch() wgetch(stdscr)
-#define getstr(str) wgetstr(stdscr,str)
-#define inch() winch(stdscr)
+#define erase() werase(stdscr)
+#define getch() wgetch(stdscr)
+#define getstr(str) wgetstr(stdscr,str)
+#define inch() winch(stdscr)
#define inchnstr(s,n) winchnstr(stdscr,s,n)
#define inchstr(s) winchstr(stdscr,s)
#define innstr(s,n) winnstr(stdscr,s,n)
-#define insch(c) winsch(stdscr,c)
+#define insch(c) winsch(stdscr,c)
#define insdelln(n) winsdelln(stdscr,n)
-#define insertln() winsdelln(stdscr,1)
+#define insertln() winsdelln(stdscr,1)
#define insnstr(s,n) winsnstr(stdscr,s,n)
#define insstr(s) winsstr(stdscr,s)
#define instr(s) winstr(stdscr,s)
-#define move(y,x) wmove(stdscr,y,x)
-#define refresh() wrefresh(stdscr)
+#define move(y,x) wmove(stdscr,y,x)
+#define refresh() wrefresh(stdscr)
#define scrl(n) wscrl(stdscr,n)
-#define setscrreg(t,b) wsetscrreg(stdscr,t,b)
-#define standend() wstandend(stdscr)
-#define standout() wstandout(stdscr)
+#define setscrreg(t,b) wsetscrreg(stdscr,t,b)
+#define standend() wstandend(stdscr)
+#define standout() wstandout(stdscr)
#define timeout(delay) wtimeout(stdscr,delay)
-#define wdeleteln(win) winsdelln(win,-1)
-#define winsertln(win) winsdelln(win,1)
+#define wdeleteln(win) winsdelln(win,-1)
+#define winsertln(win) winsdelln(win,1)
/*
* mv functions
*/
-#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
+#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
#define mvwaddchnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,n))
-#define mvwaddchstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
+#define mvwaddchstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
#define mvwaddnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,n))
-#define mvwaddstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
-#define mvwdelch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wdelch(win))
-#define mvwgetch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wgetch(win))
-#define mvwgetnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : wgetnstr(win,str,n))
-#define mvwgetstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
-#define mvwhline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
-#define mvwinch(win,y,x) (wmove(win,y,x) == ERR ? (chtype)ERR : winch(win))
+#define mvwaddstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
+#define mvwdelch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wdelch(win))
+#define mvwchgat(win,y,x,n,a,c,o) (wmove(win,y,x) == ERR ? ERR : wchgat(win,n,a,c,o))
+#define mvwgetch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wgetch(win))
+#define mvwgetnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : wgetnstr(win,str,n))
+#define mvwgetstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
+#define mvwhline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
+#define mvwinch(win,y,x) (wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
#define mvwinchnstr(win,y,x,s,n) (wmove(win,y,x) == ERR ? ERR : winchnstr(win,s,n))
#define mvwinchstr(win,y,x,s) (wmove(win,y,x) == ERR ? ERR : winchstr(win,s))
#define mvwinnstr(win,y,x,s,n) (wmove(win,y,x) == ERR ? ERR : winnstr(win,s,n))
-#define mvwinsch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
+#define mvwinsch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
#define mvwinsnstr(win,y,x,s,n) (wmove(win,y,x) == ERR ? ERR : winsnstr(win,s,n))
#define mvwinsstr(win,y,x,s) (wmove(win,y,x) == ERR ? ERR : winsstr(win,s))
#define mvwinstr(win,y,x,s) (wmove(win,y,x) == ERR ? ERR : winstr(win,s))
-#define mvwvline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline(win,c,n))
+#define mvwvline(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline(win,c,n))
-#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
+#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
#define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,y,x,str,n)
#define mvaddchstr(y,x,str) mvwaddchstr(stdscr,y,x,str)
#define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,y,x,str,n)
-#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
-#define mvdelch(y,x) mvwdelch(stdscr,y,x)
-#define mvgetch(y,x) mvwgetch(stdscr,y,x)
+#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
+#define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,y,x,n,a,c,o)
+#define mvdelch(y,x) mvwdelch(stdscr,y,x)
+#define mvgetch(y,x) mvwgetch(stdscr,y,x)
#define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,y,x,str,n)
-#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
+#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
#define mvhline(y,x,c,n) mvwhline(stdscr,y,x,c,n)
-#define mvinch(y,x) mvwinch(stdscr,y,x)
+#define mvinch(y,x) mvwinch(stdscr,y,x)
#define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,y,x,s,n)
#define mvinchstr(y,x,s) mvwinchstr(stdscr,y,x,s)
#define mvinnstr(y,x,s,n) mvwinnstr(stdscr,y,x,s,n)
-#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
+#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
#define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,y,x,s,n)
#define mvinsstr(y,x,s) mvwinsstr(stdscr,y,x,s)
#define mvinstr(y,x,s) mvwinstr(stdscr,y,x,s)
#define mvvline(y,x,c,n) mvwvline(stdscr,y,x,c,n)
/*
- * XSI curses macros for XPG4 conformance.
- * The underlying functions needed to make these work are:
- * waddnwstr(), waddchnwstr(), wadd_wch(), wborder_set(), wchgat(),
- * wecho_wchar(), wgetn_wstr(), wget_wch(), whline_set(), vhline_set(),
- * winnwstr(), wins_nwstr(), wins_wch(), win_wch(), win_wchnstr().
- * Except for wchgat(), these are not yet implemented. They will be someday.
+ * Some wide-character functions can be implemented without the extensions.
*/
-#define add_wch(c) wadd_wch(stdscr,c)
-#define addnwstr(wstr,n) waddnwstr(stdscr,wstr,n)
-#define addwstr(wstr,n) waddnwstr(stdscr,wstr,-1)
-#define attr_get(a,pair,opts) wattr_get(stdscr,a,pair,opts)
-#define attr_off(a,opts) wattr_off(stdscr,a,opts)
-#define attr_on(a,opts) wattr_on(stdscr,a,opts)
-#define attr_set(a,pair,opts) wattr_set(stdscr,a,pair,opts)
-#define box_set(w,v,h) wborder_set(w,v,v,h,h,0,0,0,0)
-#define chgat(n,a,c,o) wchgat(stdscr,n,a,c,o)
-#define echo_wchar(c) wecho_wchar(stdscr,c)
-#define getbkgd(win) ((win)->_bkgd)
-#define get_wch(c) wget_wch(stdscr,c)
-#define get_wstr(t) wgetn_wstr(stdscr,t,-1)
-#define getn_wstr(t,n) wgetn_wstr(stdscr,t,n)
-#define hline_set(c,n) whline_set(stdscr,c,n)
-#define in_wch(c) win_wch(stdscr,c)
-#define in_wchnstr(c,n) win_wchnstr(stdscr,c,n)
-#define in_wchstr(c) win_wchnstr(stdscr,c,-1)
-#define innwstr(c,n) winnwstr(stdscr,c,n)
-#define ins_nwstr(t,n) wins_nwstr(stdscr,t,n)
-#define ins_wch(c) wins_wch(stdscr,c)
-#define ins_wstr(t) wins_nwstr(stdscr,t,-1)
-#define inwstr(c) winnwstr(stdscr,c,-1)
-
-#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,y,x,c)
-#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,y,x,wstr,n)
-#define mvaddwstr(y,x,wstr,n) mvwaddnwstr(stdscr,y,x,wstr,-1)
-#define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,y,x,n,a,c,o)
-#define mvget_wch(y,x,c) mvwget_wch(stdscr,y,x,c)
-#define mvget_wstr(y,x,t) mvwgetn_wstr(stdscr,y,x,t,-1)
-#define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,y,x,t,n)
-#define mvhline_set(y,x,c,n) mvwhline_set(stdscr,y,x,c,n)
-#define mvin_wch(y,x,c) mvwin_wch(stdscr,y,x,c)
-#define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,y,x,c,n)
-#define mvin_wchstr(y,x,c) mvwin_wchnstr(stdscr,y,x,c,-1)
-#define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,y,x,c,n)
-#define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,y,x,t,n)
-#define mvins_wch(y,x,c) mvwins_wch(stdscr,y,x,c)
-#define mvins_wstr(y,x,t) mvwins_nwstr(stdscr,y,x,t,-1)
-#define mvinwstr(y,x,c) mvwinnwstr(stdscr,y,x,c,-1)
-#define mvvline_set(y,x,c,n) mvwvline_set(stdscr,y,x,c,n)
-
-#define mvwadd_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wadd_wch(stdscr,c))
-#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,y,x) == ERR ? ERR : waddnwstr(stdscr,wstr,n))
-#define mvwaddwstr(win,y,x,wstr,n) (wmove(win,y,x) == ERR ? ERR : waddnwstr(stdscr,wstr,-1))
-#define mvwchgat(win,y,x,n,a,c,o) (wmove(win,y,x) == ERR ? ERR : wchgat(win,n,a,c,o))
-#define mvwget_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wget_wch(win,c))
-#define mvwget_wstr(win,y,x,t) (wmove(win,y,x) == ERR ? ERR : wgetn_wstr(win,t,-1))
-#define mvwgetn_wstr(win,y,x,t,n) (wmove(win,y,x) == ERR ? ERR : wgetn_wstr(win,t,n))
-#define mvwhline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline_set(win,c,n))
-#define mvwin_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : win_wch(win,c))
-#define mvwin_wchnstr(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : win_wchnstr(stdscr,c,n))
-#define mvwin_wchstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : win_wchnstr(stdscr,c,-1))
-#define mvwinnwstr(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : winnwstr(stdscr,c,n))
-#define mvwins_nwstr(win,y,x,t,n) (wmove(win,y,x) == ERR ? ERR : wins_nwstr(stdscr,t,n))
-#define mvwins_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wins_wch(stdscr,c))
-#define mvwins_wstr(win,y,x,t) (wmove(win,y,x) == ERR ? ERR : wins_nwstr(stdscr,t,-1))
-#define mvwinwstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winnwstr(stdscr,c,-1))
-#define mvwvline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline_set(win,c,n))
+#if !NCURSES_OPAQUE
+#define getbkgd(win) ((win)->_bkgd)
+#endif /* NCURSES_OPAQUE */
#define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a))
#define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a))
-#define vid_attr(a,pair,opts) vidattr(a)
-#define vline_set(c,n) wvline_set(stdscr,c,n)
-#define waddwstr(win,wstr,n) waddnwstr(win,wstr,-1)
-#define wattr_get(win,a,p,opts) ((void)((a) != 0 && (*(a) = (win)->_attrs)), \
- (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
+#if !NCURSES_OPAQUE
+#if defined(_XOPEN_SOURCE_EXTENDED) && 0
+#define wattr_set(win,a,p,opts) ((win)->_attrs = ((a) & ~A_COLOR), \
+ (win)->_color = (p), \
OK)
-#define wget_wstr(w,t) wgetn_wstr(w,t,-1)
-#define win_wchstr(w,c) win_wchnstr(w,c,-1)
-#define wins_wstr(w,t) wins_nwstr(w,t,-1)
-#define winwstr(w,c) winnwstr(w,c,-1)
-
+#define wattr_get(win,a,p,opts) ((void)((a) != (void *)0 && (*(a) = (win)->_attrs)), \
+ (void)((p) != (void *)0 && (*(p) = (win)->_color)), \
+ OK)
+#else
+#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
+#define wattr_get(win,a,p,opts) ((void)((a) != (void *)0 && (*(a) = (win)->_attrs)), \
+ (void)((p) != (void *)0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
+ OK)
+#endif
+#endif /* NCURSES_OPAQUE */
/*
- * XSI curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
+ * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
* varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to
* use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already
* use stdarg.h, so...
@@ -1158,155 +1146,281 @@ extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* gene
#define vw_scanw vwscanw
/*
+ * Export fallback function for use in C++ binding.
+ */
+#if !1
+#define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
+NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
+#endif
+
+/*
+ * These macros are extensions - not in X/Open Curses.
+ */
+#if 1
+#if !NCURSES_OPAQUE
+#define is_cleared(win) ((win)->_clear)
+#define is_idcok(win) ((win)->_idcok)
+#define is_idlok(win) ((win)->_idlok)
+#define is_immedok(win) ((win)->_immed)
+#define is_keypad(win) ((win)->_use_keypad)
+#define is_leaveok(win) ((win)->_leaveok)
+#define is_nodelay(win) ((win)->_delay == 0)
+#define is_notimeout(win) ((win)->_notimeout)
+#define is_scrollok(win) ((win)->_scroll)
+#define is_syncok(win) ((win)->_sync)
+#define wgetparent(win) ((win) ? (win)->_parent : 0)
+#define wgetscrreg(win,t,b) ((win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
+#endif
+#endif
+
+#endif /* NCURSES_NOMACROS */
+
+/*
+ * Public variables.
+ *
+ * Notes:
+ * a. ESCDELAY was an undocumented feature under AIX curses.
+ * It gives the ESC expire time in milliseconds.
+ * b. ttytype is needed for backward compatibility
+ */
+#if 0
+
+NCURSES_WRAPPED_VAR(WINDOW *, curscr);
+NCURSES_WRAPPED_VAR(WINDOW *, newscr);
+NCURSES_WRAPPED_VAR(WINDOW *, stdscr);
+NCURSES_WRAPPED_VAR(char *, ttytype);
+NCURSES_WRAPPED_VAR(int, COLORS);
+NCURSES_WRAPPED_VAR(int, COLOR_PAIRS);
+NCURSES_WRAPPED_VAR(int, COLS);
+NCURSES_WRAPPED_VAR(int, ESCDELAY);
+NCURSES_WRAPPED_VAR(int, LINES);
+NCURSES_WRAPPED_VAR(int, TABSIZE);
+
+#define curscr NCURSES_PUBLIC_VAR(curscr())
+#define newscr NCURSES_PUBLIC_VAR(newscr())
+#define stdscr NCURSES_PUBLIC_VAR(stdscr())
+#define ttytype NCURSES_PUBLIC_VAR(ttytype())
+#define COLORS NCURSES_PUBLIC_VAR(COLORS())
+#define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS())
+#define COLS NCURSES_PUBLIC_VAR(COLS())
+#define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY())
+#define LINES NCURSES_PUBLIC_VAR(LINES())
+#define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE())
+
+#else
+
+extern NCURSES_EXPORT_VAR(WINDOW *) curscr;
+extern NCURSES_EXPORT_VAR(WINDOW *) newscr;
+extern NCURSES_EXPORT_VAR(WINDOW *) stdscr;
+extern NCURSES_EXPORT_VAR(char) ttytype[];
+extern NCURSES_EXPORT_VAR(int) COLORS;
+extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
+extern NCURSES_EXPORT_VAR(int) COLS;
+extern NCURSES_EXPORT_VAR(int) ESCDELAY;
+extern NCURSES_EXPORT_VAR(int) LINES;
+extern NCURSES_EXPORT_VAR(int) TABSIZE;
+
+#endif
+
+/*
* Pseudo-character tokens outside ASCII range. The curses wgetch() function
* will return any given one of these only if the corresponding k- capability
* is defined in your terminal's terminfo entry.
+ *
+ * Some keys (KEY_A1, etc) are arranged like this:
+ * a1 up a3
+ * left b2 right
+ * c1 down c3
+ *
+ * A few key codes do not depend upon the terminfo entry.
*/
#define KEY_CODE_YES 0400 /* A wchar_t contains a key code */
#define KEY_MIN 0401 /* Minimum curses key */
-#define KEY_BREAK 0401 /* Break key (unreliable) */
-#define KEY_DOWN 0402 /* Down-arrow */
-#define KEY_UP 0403 /* Up-arrow */
-#define KEY_LEFT 0404 /* Left-arrow */
-#define KEY_RIGHT 0405 /* Right-arrow */
-#define KEY_HOME 0406 /* Home key (upward+left arrow) */
-#define KEY_BACKSPACE 0407 /* Backspace (unreliable) */
-#define KEY_F0 0410 /* Function keys. Space for 64 */
-#define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */
-#define KEY_DL 0510 /* Delete line */
-#define KEY_IL 0511 /* Insert line */
-#define KEY_DC 0512 /* Delete character */
-#define KEY_IC 0513 /* Insert char or enter insert mode */
-#define KEY_EIC 0514 /* Exit insert char mode */
-#define KEY_CLEAR 0515 /* Clear screen */
-#define KEY_EOS 0516 /* Clear to end of screen */
-#define KEY_EOL 0517 /* Clear to end of line */
-#define KEY_SF 0520 /* Scroll 1 line forward */
-#define KEY_SR 0521 /* Scroll 1 line backward (reverse) */
-#define KEY_NPAGE 0522 /* Next page */
-#define KEY_PPAGE 0523 /* Previous page */
-#define KEY_STAB 0524 /* Set tab */
-#define KEY_CTAB 0525 /* Clear tab */
-#define KEY_CATAB 0526 /* Clear all tabs */
-#define KEY_ENTER 0527 /* Enter or send (unreliable) */
-#define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */
-#define KEY_RESET 0531 /* Reset or hard reset (unreliable) */
-#define KEY_PRINT 0532 /* Print */
-#define KEY_LL 0533 /* Home down or bottom (lower left) */
-
-/* The keypad is arranged like this: */
-/* a1 up a3 */
-/* left b2 right */
-/* c1 down c3 */
-
-#define KEY_A1 0534 /* Upper left of keypad */
-#define KEY_A3 0535 /* Upper right of keypad */
-#define KEY_B2 0536 /* Center of keypad */
-#define KEY_C1 0537 /* Lower left of keypad */
-#define KEY_C3 0540 /* Lower right of keypad */
-#define KEY_BTAB 0541 /* Back tab */
-#define KEY_BEG 0542 /* Beg (beginning) */
-#define KEY_CANCEL 0543 /* Cancel */
-#define KEY_CLOSE 0544 /* Close */
-#define KEY_COMMAND 0545 /* Cmd (command) */
-#define KEY_COPY 0546 /* Copy */
-#define KEY_CREATE 0547 /* Create */
-#define KEY_END 0550 /* End */
-#define KEY_EXIT 0551 /* Exit */
-#define KEY_FIND 0552 /* Find */
-#define KEY_HELP 0553 /* Help */
-#define KEY_MARK 0554 /* Mark */
-#define KEY_MESSAGE 0555 /* Message */
-#define KEY_MOVE 0556 /* Move */
-#define KEY_NEXT 0557 /* Next */
-#define KEY_OPEN 0560 /* Open */
-#define KEY_OPTIONS 0561 /* Options */
-#define KEY_PREVIOUS 0562 /* Prev (previous) */
-#define KEY_REDO 0563 /* Redo */
-#define KEY_REFERENCE 0564 /* Ref (reference) */
-#define KEY_REFRESH 0565 /* Refresh */
-#define KEY_REPLACE 0566 /* Replace */
-#define KEY_RESTART 0567 /* Restart */
-#define KEY_RESUME 0570 /* Resume */
-#define KEY_SAVE 0571 /* Save */
-#define KEY_SBEG 0572 /* Shifted Beg (beginning) */
-#define KEY_SCANCEL 0573 /* Shifted Cancel */
-#define KEY_SCOMMAND 0574 /* Shifted Command */
-#define KEY_SCOPY 0575 /* Shifted Copy */
-#define KEY_SCREATE 0576 /* Shifted Create */
-#define KEY_SDC 0577 /* Shifted Delete char */
-#define KEY_SDL 0600 /* Shifted Delete line */
-#define KEY_SELECT 0601 /* Select */
-#define KEY_SEND 0602 /* Shifted End */
-#define KEY_SEOL 0603 /* Shifted Clear line */
-#define KEY_SEXIT 0604 /* Shifted Dxit */
-#define KEY_SFIND 0605 /* Shifted Find */
-#define KEY_SHELP 0606 /* Shifted Help */
-#define KEY_SHOME 0607 /* Shifted Home */
-#define KEY_SIC 0610 /* Shifted Input */
-#define KEY_SLEFT 0611 /* Shifted Left arrow */
-#define KEY_SMESSAGE 0612 /* Shifted Message */
-#define KEY_SMOVE 0613 /* Shifted Move */
-#define KEY_SNEXT 0614 /* Shifted Next */
-#define KEY_SOPTIONS 0615 /* Shifted Options */
-#define KEY_SPREVIOUS 0616 /* Shifted Prev */
-#define KEY_SPRINT 0617 /* Shifted Print */
-#define KEY_SREDO 0620 /* Shifted Redo */
-#define KEY_SREPLACE 0621 /* Shifted Replace */
-#define KEY_SRIGHT 0622 /* Shifted Right arrow */
-#define KEY_SRSUME 0623 /* Shifted Resume */
-#define KEY_SSAVE 0624 /* Shifted Save */
-#define KEY_SSUSPEND 0625 /* Shifted Suspend */
-#define KEY_SUNDO 0626 /* Shifted Undo */
-#define KEY_SUSPEND 0627 /* Suspend */
-#define KEY_UNDO 0630 /* Undo */
+#define KEY_BREAK 0401 /* Break key (unreliable) */
+#define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */
+#define KEY_RESET 0531 /* Reset or hard reset (unreliable) */
+/*
+ * These definitions were generated by ./MKkey_defs.sh ./Caps
+ */
+#define KEY_DOWN 0402 /* down-arrow key */
+#define KEY_UP 0403 /* up-arrow key */
+#define KEY_LEFT 0404 /* left-arrow key */
+#define KEY_RIGHT 0405 /* right-arrow key */
+#define KEY_HOME 0406 /* home key */
+#define KEY_BACKSPACE 0407 /* backspace key */
+#define KEY_F0 0410 /* Function keys. Space for 64 */
+#define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */
+#define KEY_DL 0510 /* delete-line key */
+#define KEY_IL 0511 /* insert-line key */
+#define KEY_DC 0512 /* delete-character key */
+#define KEY_IC 0513 /* insert-character key */
+#define KEY_EIC 0514 /* sent by rmir or smir in insert mode */
+#define KEY_CLEAR 0515 /* clear-screen or erase key */
+#define KEY_EOS 0516 /* clear-to-end-of-screen key */
+#define KEY_EOL 0517 /* clear-to-end-of-line key */
+#define KEY_SF 0520 /* scroll-forward key */
+#define KEY_SR 0521 /* scroll-backward key */
+#define KEY_NPAGE 0522 /* next-page key */
+#define KEY_PPAGE 0523 /* previous-page key */
+#define KEY_STAB 0524 /* set-tab key */
+#define KEY_CTAB 0525 /* clear-tab key */
+#define KEY_CATAB 0526 /* clear-all-tabs key */
+#define KEY_ENTER 0527 /* enter/send key */
+#define KEY_PRINT 0532 /* print key */
+#define KEY_LL 0533 /* lower-left key (home down) */
+#define KEY_A1 0534 /* upper left of keypad */
+#define KEY_A3 0535 /* upper right of keypad */
+#define KEY_B2 0536 /* center of keypad */
+#define KEY_C1 0537 /* lower left of keypad */
+#define KEY_C3 0540 /* lower right of keypad */
+#define KEY_BTAB 0541 /* back-tab key */
+#define KEY_BEG 0542 /* begin key */
+#define KEY_CANCEL 0543 /* cancel key */
+#define KEY_CLOSE 0544 /* close key */
+#define KEY_COMMAND 0545 /* command key */
+#define KEY_COPY 0546 /* copy key */
+#define KEY_CREATE 0547 /* create key */
+#define KEY_END 0550 /* end key */
+#define KEY_EXIT 0551 /* exit key */
+#define KEY_FIND 0552 /* find key */
+#define KEY_HELP 0553 /* help key */
+#define KEY_MARK 0554 /* mark key */
+#define KEY_MESSAGE 0555 /* message key */
+#define KEY_MOVE 0556 /* move key */
+#define KEY_NEXT 0557 /* next key */
+#define KEY_OPEN 0560 /* open key */
+#define KEY_OPTIONS 0561 /* options key */
+#define KEY_PREVIOUS 0562 /* previous key */
+#define KEY_REDO 0563 /* redo key */
+#define KEY_REFERENCE 0564 /* reference key */
+#define KEY_REFRESH 0565 /* refresh key */
+#define KEY_REPLACE 0566 /* replace key */
+#define KEY_RESTART 0567 /* restart key */
+#define KEY_RESUME 0570 /* resume key */
+#define KEY_SAVE 0571 /* save key */
+#define KEY_SBEG 0572 /* shifted begin key */
+#define KEY_SCANCEL 0573 /* shifted cancel key */
+#define KEY_SCOMMAND 0574 /* shifted command key */
+#define KEY_SCOPY 0575 /* shifted copy key */
+#define KEY_SCREATE 0576 /* shifted create key */
+#define KEY_SDC 0577 /* shifted delete-character key */
+#define KEY_SDL 0600 /* shifted delete-line key */
+#define KEY_SELECT 0601 /* select key */
+#define KEY_SEND 0602 /* shifted end key */
+#define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */
+#define KEY_SEXIT 0604 /* shifted exit key */
+#define KEY_SFIND 0605 /* shifted find key */
+#define KEY_SHELP 0606 /* shifted help key */
+#define KEY_SHOME 0607 /* shifted home key */
+#define KEY_SIC 0610 /* shifted insert-character key */
+#define KEY_SLEFT 0611 /* shifted left-arrow key */
+#define KEY_SMESSAGE 0612 /* shifted message key */
+#define KEY_SMOVE 0613 /* shifted move key */
+#define KEY_SNEXT 0614 /* shifted next key */
+#define KEY_SOPTIONS 0615 /* shifted options key */
+#define KEY_SPREVIOUS 0616 /* shifted previous key */
+#define KEY_SPRINT 0617 /* shifted print key */
+#define KEY_SREDO 0620 /* shifted redo key */
+#define KEY_SREPLACE 0621 /* shifted replace key */
+#define KEY_SRIGHT 0622 /* shifted right-arrow key */
+#define KEY_SRSUME 0623 /* shifted resume key */
+#define KEY_SSAVE 0624 /* shifted save key */
+#define KEY_SSUSPEND 0625 /* shifted suspend key */
+#define KEY_SUNDO 0626 /* shifted undo key */
+#define KEY_SUSPEND 0627 /* suspend key */
+#define KEY_UNDO 0630 /* undo key */
#define KEY_MOUSE 0631 /* Mouse event has occurred */
#define KEY_RESIZE 0632 /* Terminal resize event */
-#define KEY_MAX 0777 /* Maximum key value */
+#define KEY_EVENT 0633 /* We were interrupted by an event */
+
+#define KEY_MAX 0777 /* Maximum key value is 0633 */
+/* $Id: curses.h,v 1.60 2010/01/12 23:21:59 nicm Exp $ */
+/*
+ * vile:cmode:
+ * This file is part of ncurses, designed to be appended after curses.h.in
+ * (see that file for the relevant copyright).
+ */
/* mouse interface */
-#define NCURSES_MOUSE_VERSION 1
+
+#if NCURSES_MOUSE_VERSION > 1
+#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
+#else
+#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
+#endif
+
+#define NCURSES_BUTTON_RELEASED 001L
+#define NCURSES_BUTTON_PRESSED 002L
+#define NCURSES_BUTTON_CLICKED 004L
+#define NCURSES_DOUBLE_CLICKED 010L
+#define NCURSES_TRIPLE_CLICKED 020L
+#define NCURSES_RESERVED_EVENT 040L
/* event masks */
-#define BUTTON1_RELEASED 000000000001L
-#define BUTTON1_PRESSED 000000000002L
-#define BUTTON1_CLICKED 000000000004L
-#define BUTTON1_DOUBLE_CLICKED 000000000010L
-#define BUTTON1_TRIPLE_CLICKED 000000000020L
-#define BUTTON1_RESERVED_EVENT 000000000040L
-#define BUTTON2_RELEASED 000000000100L
-#define BUTTON2_PRESSED 000000000200L
-#define BUTTON2_CLICKED 000000000400L
-#define BUTTON2_DOUBLE_CLICKED 000000001000L
-#define BUTTON2_TRIPLE_CLICKED 000000002000L
-#define BUTTON2_RESERVED_EVENT 000000004000L
-#define BUTTON3_RELEASED 000000010000L
-#define BUTTON3_PRESSED 000000020000L
-#define BUTTON3_CLICKED 000000040000L
-#define BUTTON3_DOUBLE_CLICKED 000000100000L
-#define BUTTON3_TRIPLE_CLICKED 000000200000L
-#define BUTTON3_RESERVED_EVENT 000000400000L
-#define BUTTON4_RELEASED 000001000000L
-#define BUTTON4_PRESSED 000002000000L
-#define BUTTON4_CLICKED 000004000000L
-#define BUTTON4_DOUBLE_CLICKED 000010000000L
-#define BUTTON4_TRIPLE_CLICKED 000020000000L
-#define BUTTON4_RESERVED_EVENT 000040000000L
-#define BUTTON_CTRL 000100000000L
-#define BUTTON_SHIFT 000200000000L
-#define BUTTON_ALT 000400000000L
-#define ALL_MOUSE_EVENTS 000777777777L
-#define REPORT_MOUSE_POSITION 001000000000L
+#define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
+#define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
+#define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
+#define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
+#define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
+#define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
+#define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
+#define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
+#define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
+#define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
+#define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
+#define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
+#define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
+#define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
+#define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
+#define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
+#define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
-/* macros to extract single event-bits from masks */
-#define BUTTON_RELEASE(e, x) ((e) & (001 << (6 * ((x) - 1))))
-#define BUTTON_PRESS(e, x) ((e) & (002 << (6 * ((x) - 1))))
-#define BUTTON_CLICK(e, x) ((e) & (004 << (6 * ((x) - 1))))
-#define BUTTON_DOUBLE_CLICK(e, x) ((e) & (010 << (6 * ((x) - 1))))
-#define BUTTON_TRIPLE_CLICK(e, x) ((e) & (020 << (6 * ((x) - 1))))
-#define BUTTON_RESERVED_EVENT(e, x) ((e) & (040 << (6 * ((x) - 1))))
+/*
+ * In 32 bits the version-1 scheme does not provide enough space for a 5th
+ * button, unless we choose to change the ABI by omitting the reserved-events.
+ */
+#if NCURSES_MOUSE_VERSION > 1
-typedef unsigned long mmask_t;
+#define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
+#define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
+#define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
+#define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
+#define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
+
+#define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L)
+#define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L)
+#define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L)
+#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L)
+
+#else
+
+#define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
+#define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
+#define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
+#define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
+
+#define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L)
+#define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L)
+#define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L)
+#define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L)
+
+#endif
+
+#define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1)
+
+/* macros to extract single event-bits from masks */
+#define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001))
+#define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002))
+#define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004))
+#define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010))
+#define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020))
+#define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040))
typedef struct
{
@@ -1321,7 +1435,8 @@ extern NCURSES_EXPORT(int) ungetmouse (MEVENT *);
extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
extern NCURSES_EXPORT(int) mouseinterval (int);
-extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW* win,int* y, int* x, bool to_screen);
+extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
+extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
@@ -1337,9 +1452,18 @@ extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *);
extern NCURSES_EXPORT(char *) _traceattr (attr_t);
extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype);
extern NCURSES_EXPORT(char *) _nc_tracebits (void);
-extern NCURSES_EXPORT(char *) _tracechar (const unsigned char);
+extern NCURSES_EXPORT(char *) _tracechar (int);
extern NCURSES_EXPORT(char *) _tracechtype (chtype);
extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype);
+#ifdef _XOPEN_SOURCE_EXTENDED
+#define _tracech_t _tracecchar_t
+extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *);
+#define _tracech_t2 _tracecchar_t2
+extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *);
+#else
+#define _tracech_t _tracechtype
+#define _tracech_t2 _tracechtype2
+#endif
extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *);
extern NCURSES_EXPORT(void) trace (const unsigned int);
@@ -1359,7 +1483,9 @@ extern NCURSES_EXPORT(void) trace (const unsigned int);
#define TRACE_CCALLS 0x0400 /* trace per-character calls */
#define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */
#define TRACE_ATTRS 0x1000 /* trace attribute updates */
-#define TRACE_MAXIMUM 0xffff /* maximum trace level */
+
+#define TRACE_SHIFT 13 /* number of bits in the trace masks */
+#define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */
#if defined(TRACE) || defined(NCURSES_TEST)
extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */
@@ -1372,6 +1498,8 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
#ifdef __cplusplus
+#ifndef NCURSES_NOMACROS
+
/* these names conflict with STL */
#undef box
#undef clear
@@ -1379,6 +1507,8 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
#undef move
#undef refresh
+#endif /* NCURSES_NOMACROS */
+
}
#endif
diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h
index 989a5158751..1b63370a674 100644
--- a/lib/libcurses/curses.priv.h
+++ b/lib/libcurses/curses.priv.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: curses.priv.h,v 1.32 2003/04/13 11:20:47 jmc Exp $ */
+/* $OpenBSD: curses.priv.h,v 1.33 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,11 +31,12 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
- * $From: curses.priv.h,v 1.171 2000/12/10 00:13:52 tom Exp $
+ * $Id: curses.priv.h,v 1.33 2010/01/12 23:21:59 nicm Exp $
*
* curses.priv.h
*
@@ -90,6 +91,11 @@ extern "C" {
# include <sys/param.h>
#endif
+#include <assert.h>
+#include <stdio.h>
+
+#include <errno.h>
+
#ifndef PATH_MAX
# if defined(_POSIX_PATH_MAX)
# define PATH_MAX _POSIX_PATH_MAX
@@ -100,11 +106,6 @@ extern "C" {
# endif
#endif
-#include <assert.h>
-#include <stdio.h>
-
-#include <errno.h>
-
#if DECL_ERRNO
extern int errno;
#endif
@@ -123,6 +124,9 @@ extern int errno;
#define USE_FUNC_POLL 0
#endif
+/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
+#include <signal.h>
+
/* Alessandro Rubini's GPM (general-purpose mouse) */
#if HAVE_LIBGPM && HAVE_GPM_H
#define USE_GPM_SUPPORT 1
@@ -139,7 +143,9 @@ extern int errno;
/* EMX mouse support */
#ifdef __EMX__
-#define USE_EMX_MOUSE
+#define USE_EMX_MOUSE 1
+#else
+#define USE_EMX_MOUSE 0
#endif
#define DEFAULT_MAXCLICK 166
@@ -151,12 +157,15 @@ extern int errno;
*/
#if !NCURSES_EXT_FUNCS
#undef HAVE_SIZECHANGE
+#define HAVE_SIZECHANGE 0
#endif
-#if HAVE_SIZECHANGE
+#if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH)
#define USE_SIZECHANGE 1
#else
+#define USE_SIZECHANGE 0
#undef USE_SIGWINCH
+#define USE_SIGWINCH 0
#endif
/*
@@ -210,27 +219,26 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
* delays and expansion in raw mode.
*/
-struct tries {
- struct tries *child; /* ptr to child. NULL if none */
- struct tries *sibling; /* ptr to sibling. NULL if none */
+#define TRIES struct tries
+typedef TRIES {
+ TRIES *child; /* ptr to child. NULL if none */
+ TRIES *sibling; /* ptr to sibling. NULL if none */
unsigned char ch; /* character at this node */
unsigned short value; /* code of string so far. 0 if none. */
-};
-
-/*
- * Definitions for color pairs
- */
-#define C_SHIFT 8 /* we need more bits than there are colors */
-#define C_MASK ((1 << C_SHIFT) - 1)
-
-#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+#undef TRIES
+} TRIES;
/*
* Common/troublesome character definitions
*/
+#define StringOf(ch) {ch, 0}
+
#define L_BRACE '{'
#define R_BRACE '}'
#define S_QUOTE '\''
+#define D_QUOTE '"'
+
+#define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
/*
* Structure for palette tables
@@ -238,7 +246,9 @@ struct tries {
typedef struct
{
- short red, green, blue;
+ short red, green, blue; /* what color_content() returns */
+ short r, g, b; /* params to init_color() */
+ int init; /* true if we called init_color() */
}
color_t;
@@ -250,136 +260,574 @@ color_t;
#define WINDOWLIST struct _win_list
+#if USE_WIDEC_SUPPORT
+#define _nc_bkgd _bkgrnd
+#else
+#undef _XOPEN_SOURCE_EXTENDED
+#define _nc_bkgd _bkgd
+#define wgetbkgrnd(win, wch) *wch = win->_bkgd
+#define wbkgrnd wbkgd
+#endif
+
+#undef NCURSES_OPAQUE
+#define NCURSES_INTERNALS 1
+#define NCURSES_OPAQUE 0
+
#include <curses.h> /* we'll use -Ipath directive to get the right one! */
+#include <term.h>
+#include <term_entry.h>
+#include <nc_tparm.h>
+
+#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
+#define if_EXT_COLORS(stmt) stmt
+#define NetPair(value,p) (value).ext_color = (p), \
+ AttrOf(value) &= ALL_BUT_COLOR, \
+ AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
+#define SetPair(value,p) (value).ext_color = (p)
+#define GetPair(value) (value).ext_color
+#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
+#define GET_WINDOW_PAIR(w) (w)->_color
+#define SET_WINDOW_PAIR(w,p) (w)->_color = (p)
+#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
+#define VIDATTR(attr, pair) vid_attr(attr, pair, 0)
+#else
+#define if_EXT_COLORS(stmt) /* nothing */
+#define SetPair(value,p) RemAttr(value, A_COLOR), \
+ SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
+#define GetPair(value) PAIR_NUMBER(AttrOf(value))
+#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
+#define GET_WINDOW_PAIR(w) PAIR_NUMBER(WINDOW_ATTRS(w))
+#define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
+ WINDOW_ATTRS(w) |= (A_COLOR & COLOR_PAIR(p))
+#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))
+#define VIDATTR(attr, pair) vidattr(attr)
+#endif
+
+#if NCURSES_NO_PADDING
+#define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding)
+#define SetNoPadding(sp) _nc_set_no_padding(sp)
+extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *);
+#else
+#define GetNoPadding(sp) FALSE
+#define SetNoPadding(sp) /*nothing*/
+#endif
+
+#define WINDOW_ATTRS(w) ((w)->_attrs)
+
+#define SCREEN_ATTRS(s) (*((s)->_current_attr))
+#define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s))
+#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
+
+#if USE_REENTRANT
+NCURSES_EXPORT(int *) _nc_ptr_Lines (void);
+NCURSES_EXPORT(int *) _nc_ptr_Cols (void);
+#define ptrLines() (SP ? &(SP->_LINES) : &(_nc_prescreen._LINES))
+#define ptrCols() (SP ? &(SP->_COLS) : &(_nc_prescreen._COLS))
+#define SET_LINES(value) *_nc_ptr_Lines() = value
+#define SET_COLS(value) *_nc_ptr_Cols() = value
+#else
+#define ptrLines() &LINES
+#define ptrCols() &COLS
+#define SET_LINES(value) LINES = value
+#define SET_COLS(value) COLS = value
+#endif
+
+#define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
+ __FILE__, __LINE__, \
+ (unsigned long) (pthread_self()), \
+ data.__data.__lock, \
+ data.__data.__count, \
+ data.__data.__owner, \
+ data.__data.__kind, \
+ (data.__data.__nusers > 5) ? " OOPS " : "", \
+ data.__data.__nusers)
+#define TR_GLOBAL_MUTEX(name) TR_MUTEX(_nc_globals.mutex_##name)
+
+#ifdef USE_PTHREADS
+
+#if USE_REENTRANT
+#include <pthread.h>
+extern NCURSES_EXPORT(void) _nc_init_pthreads(void);
+extern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *);
+extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *);
+extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *);
+extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *);
+#define _nc_lock_global(name) _nc_mutex_lock(&_nc_globals.mutex_##name)
+#define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name)
+#define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name)
+
+#else
+#error POSIX threads requires --enable-reentrant option
+#endif
+
+#if USE_WEAK_SYMBOLS
+#if defined(__GNUC__)
+# if defined __USE_ISOC99
+# define _cat_pragma(exp) _Pragma(#exp)
+# define _weak_pragma(exp) _cat_pragma(weak name)
+# else
+# define _weak_pragma(exp)
+# endif
+# define _declare(name) __extension__ extern __typeof__(name) name
+# define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak))
+#endif
+#endif
+
+#ifdef USE_PTHREADS
+# if USE_WEAK_SYMBOLS
+weak_symbol(pthread_sigmask);
+weak_symbol(pthread_self);
+weak_symbol(pthread_equal);
+weak_symbol(pthread_mutex_init);
+weak_symbol(pthread_mutex_lock);
+weak_symbol(pthread_mutex_unlock);
+weak_symbol(pthread_mutex_trylock);
+weak_symbol(pthread_mutexattr_settype);
+weak_symbol(pthread_mutexattr_init);
+extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
+# undef sigprocmask
+# define sigprocmask _nc_sigprocmask
+# endif
+#endif
+
+#if HAVE_NANOSLEEP
+#undef HAVE_NANOSLEEP
+#define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */
+#endif
+
+#else /* !USE_PTHREADS */
+
+#define _nc_init_pthreads() /* nothing */
+#define _nc_mutex_init(obj) /* nothing */
+
+#define _nc_lock_global(name) /* nothing */
+#define _nc_try_global(name) 0
+#define _nc_unlock_global(name) /* nothing */
+
+#endif /* USE_PTHREADS */
+
+#if HAVE_GETTIMEOFDAY
+# define PRECISE_GETTIME 1
+# define TimeType struct timeval
+#else
+# define PRECISE_GETTIME 0
+# define TimeType time_t
+#endif
/*
- * Structure for soft labels.
+ * Definitions for color pairs
*/
+typedef unsigned colorpair_t; /* type big enough to store PAIR_OF() */
+#define C_SHIFT 9 /* we need more bits than there are colors */
+#define C_MASK ((1 << C_SHIFT) - 1)
+#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+#define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0)
+
+#define COLOR_DEFAULT C_MASK
+
+#if defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)
+
+#undef NCURSES_CH_T /* this is not a termlib feature */
+#define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */
+
+#endif /* USE_TERMLIB */
+
+#ifndef USE_TERMLIB
+struct ldat
+{
+ NCURSES_CH_T *text; /* text of the line */
+ NCURSES_SIZE_T firstchar; /* first changed character in the line */
+ NCURSES_SIZE_T lastchar; /* last changed character in the line */
+ NCURSES_SIZE_T oldindex; /* index of the line at last update */
+};
+#endif /* USE_TERMLIB */
+
+typedef enum {
+ M_XTERM = -1 /* use xterm's mouse tracking? */
+ ,M_NONE = 0 /* no mouse device */
+#if USE_GPM_SUPPORT
+ ,M_GPM /* use GPM */
+#endif
+#if USE_SYSMOUSE
+ ,M_SYSMOUSE /* FreeBSD sysmouse on console */
+#endif
+} MouseType;
+
+/*
+ * Structures for scrolling.
+ */
+
+typedef struct {
+ unsigned long hashval;
+ int oldcount, newcount;
+ int oldindex, newindex;
+} HASHMAP;
+
+/*
+ * Structures for soft labels.
+ */
+
+struct _SLK;
+
+#ifndef USE_TERMLIB
typedef struct
{
- char *text; /* text for the label */
- char *form_text; /* formatted text (left/center/...) */
- int x; /* x coordinate of this field */
- char dirty; /* this label has changed */
- char visible; /* field is visible */
+ char *ent_text; /* text for the label */
+ char *form_text; /* formatted text (left/center/...) */
+ int ent_x; /* x coordinate of this field */
+ char dirty; /* this label has changed */
+ char visible; /* field is visible */
} slk_ent;
-typedef struct {
- char dirty; /* all labels have changed */
- char hidden; /* soft labels are hidden */
- struct _win_st *win;
+typedef struct _SLK {
+ char dirty; /* all labels have changed */
+ char hidden; /* soft labels are hidden */
+ WINDOW *win;
slk_ent *ent;
- char* buffer; /* buffer for labels */
- short maxlab; /* number of available labels */
- short labcnt; /* number of allocated labels */
- short maxlen; /* length of labels */
- chtype attr; /* soft label attribute */
+ short maxlab; /* number of available labels */
+ short labcnt; /* number of allocated labels */
+ short maxlen; /* length of labels */
+ NCURSES_CH_T attr; /* soft label attribute */
} SLK;
+#endif /* USE_TERMLIB */
+
+typedef struct {
+ WINDOW *win; /* the window used in the hook */
+ int line; /* lines to take, < 0 => from bottom*/
+ int (*hook)(WINDOW *, int); /* callback for user */
+} ripoff_t;
+
+#if USE_GPM_SUPPORT
+#undef buttons /* term.h defines this, and gpm uses it! */
+#include <gpm.h>
+
+#ifdef HAVE_LIBDL
+/* link dynamically to GPM */
+typedef int *TYPE_gpm_fd;
+typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
+typedef int (*TYPE_Gpm_Close) (void);
+typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
+
+#define my_gpm_fd SP->_mouse_gpm_fd
+#define my_Gpm_Open SP->_mouse_Gpm_Open
+#define my_Gpm_Close SP->_mouse_Gpm_Close
+#define my_Gpm_GetEvent SP->_mouse_Gpm_GetEvent
+#else
+/* link statically to GPM */
+#define my_gpm_fd &gpm_fd
+#define my_Gpm_Open Gpm_Open
+#define my_Gpm_Close Gpm_Close
+#define my_Gpm_GetEvent Gpm_GetEvent
+#endif /* HAVE_LIBDL */
+#endif /* USE_GPM_SUPPORT */
+
+typedef struct {
+ long sequence;
+ bool last_used;
+ char *fix_sgr0; /* this holds the filtered sgr0 string */
+ char *last_bufp; /* help with fix_sgr0 leak */
+ TERMINAL *last_term;
+} TGETENT_CACHE;
+
+#define TGETENT_MAX 4
+
+/*
+ * State of tparm().
+ */
+#define STACKSIZE 20
+
+typedef struct {
+ union {
+ int num;
+ char *str;
+ } data;
+ bool num_type;
+} STACK_FRAME;
+
+#define NUM_VARS 26
+
+typedef struct {
+#ifdef TRACE
+ const char *tname;
+#endif
+ const char *tparam_base;
+
+ STACK_FRAME stack[STACKSIZE];
+ int stack_ptr;
+
+ char *out_buff;
+ size_t out_size;
+ size_t out_used;
+
+ char *fmt_buff;
+ size_t fmt_size;
+
+ int dynamic_var[NUM_VARS];
+ int static_vars[NUM_VARS];
+} TPARM_STATE;
+
+typedef struct {
+ char *text;
+ size_t size;
+} TRACEBUF;
+
+/*
+ * The filesystem database normally uses a single-letter for the lower level
+ * of directories. Use a hexadecimal code for filesystems which do not
+ * preserve mixed-case names.
+ */
+#if MIXEDCASE_FILENAMES
+#define LEAF_FMT "%c"
+#else
+#define LEAF_FMT "%02x"
+#endif
+
+/*
+ * TRACEMSE_FMT is no longer than 80 columns, there are 5 numbers that
+ * could at most have 10 digits, and the mask contains no more than 32 bits
+ * with each bit representing less than 15 characters. Usually the whole
+ * string is less than 80 columns, but this buffer size is an absolute
+ * limit.
+ */
+#define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15))
+#define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */
+
+/*
+ * Global data which is not specific to a screen.
+ */
+typedef struct {
+ SIG_ATOMIC_T have_sigwinch;
+ SIG_ATOMIC_T cleanup_nested;
+
+ bool init_signals;
+ bool init_screen;
+
+ const char *comp_sourcename;
+ char *comp_termtype;
+
+ bool have_tic_directory;
+ bool keep_tic_directory;
+ const char *tic_directory;
+
+ char *dbi_list;
+ int dbi_size;
+
+ char *first_name;
+ char **keyname_table;
+
+ int slk_format;
+
+ char *safeprint_buf;
+ size_t safeprint_used;
+
+ TGETENT_CACHE tgetent_cache[TGETENT_MAX];
+ int tgetent_index;
+ long tgetent_sequence;
+
+ WINDOWLIST *_nc_windowlist;
+#define _nc_windows _nc_globals._nc_windowlist
+
+#if USE_HOME_TERMINFO
+ char *home_terminfo;
+#endif
+
+#if !USE_SAFE_SPRINTF
+ int safeprint_cols;
+ int safeprint_rows;
+#endif
+
+#ifdef TRACE
+ bool init_trace;
+ char trace_fname[PATH_MAX];
+ int trace_level;
+ FILE *trace_fp;
+
+ char *tracearg_buf;
+ size_t tracearg_used;
+
+ TRACEBUF *tracebuf_ptr;
+ size_t tracebuf_used;
+
+ char tracechr_buf[40];
+
+ char *tracedmp_buf;
+ size_t tracedmp_used;
+
+ unsigned char *tracetry_buf;
+ size_t tracetry_used;
+
+#define _nc_globals_traceatr_color_buf_size 80
+ char traceatr_color_buf[2][_nc_globals_traceatr_color_buf_size];
+ int traceatr_color_sel;
+ int traceatr_color_last;
+
+#endif /* TRACE */
+
+#ifdef USE_PTHREADS
+ pthread_mutex_t mutex_curses;
+ pthread_mutex_t mutex_tst_tracef;
+ pthread_mutex_t mutex_tracef;
+ int nested_tracef;
+ int use_pthreads;
+#define _nc_use_pthreads _nc_globals.use_pthreads
+#endif
+} NCURSES_GLOBALS;
+
+extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
+
+#define N_RIPS 5
+
+/*
+ * Global data which can be swept up into a SCREEN when one is created.
+ * It may be modified before the next SCREEN is created.
+ */
+typedef struct {
+ bool use_env;
+ bool filter_mode;
+ attr_t previous_attr;
+ ripoff_t rippedoff[N_RIPS];
+ ripoff_t *rsp;
+ TPARM_STATE tparm_state;
+ TTY *saved_tty; /* savetty/resetty information */
+#if NCURSES_NO_PADDING
+ bool _no_padding; /* flag to set if padding disabled */
+#endif
+#if BROKEN_LINKER || USE_REENTRANT
+ chtype *real_acs_map;
+ int _LINES;
+ int _COLS;
+ TERMINAL *_cur_term;
+#ifdef TRACE
+ long _outchars;
+ const char *_tputs_trace;
+#endif
+#endif
+} NCURSES_PRESCREEN;
+
+#define ripoff_sp _nc_prescreen.rsp
+#define ripoff_stack _nc_prescreen.rippedoff
+
+extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
+
+/*
+ * The SCREEN structure.
+ */
+
struct screen {
- int _ifd; /* input file ptr for screen */
- FILE *_ofp; /* output file ptr for screen */
- char *_setbuf; /* buffered I/O for output */
- int _buffered; /* setvbuf uses _setbuf data */
- int _checkfd; /* filedesc for typeahead check */
- struct term *_term; /* terminal type information */
- short _lines; /* screen lines */
- short _columns; /* screen columns */
- short _lines_avail; /* lines available for stdscr */
- short _topstolen; /* lines stolen from top */
-
- WINDOW *_curscr; /* current screen */
- WINDOW *_newscr; /* virtual screen to be updated to */
- WINDOW *_stdscr; /* screen's full-window context */
-
- struct tries *_keytry; /* "Try" for use with keypad mode */
- struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */
- int _tried; /* keypad mode was initialized */
-
- unsigned int _fifo[FIFO_SIZE]; /* input push-back buffer */
- short _fifohead, /* head of fifo queue */
- _fifotail, /* tail of fifo queue */
- _fifopeek, /* where to peek for next char */
- _fifohold; /* set if breakout marked */
-
- int _endwin; /* are we out of window mode? */
- unsigned long _current_attr; /* terminal attribute current set */
- int _coloron; /* is color enabled? */
- int _cursor; /* visibility of the cursor */
- int _cursrow; /* physical cursor row */
- int _curscol; /* physical cursor column */
- int _nl; /* True if NL -> CR/NL is on */
- int _raw; /* True if in raw mode */
- int _cbreak; /* 1 if in cbreak mode */
- /* > 1 if in halfdelay mode */
- int _echo; /* True if echo on */
- int _use_meta; /* use the meta key? */
- SLK *_slk; /* ptr to soft key struct / NULL */
- int slk_format; /* selected format for this screen */
+ int _ifd; /* input file ptr for screen */
+ FILE *_ofp; /* output file ptr for screen */
+ char *_setbuf; /* buffered I/O for output */
+ bool _filtered; /* filter() was called */
+ bool _buffered; /* setvbuf uses _setbuf data */
+ int _checkfd; /* filedesc for typeahead check */
+ TERMINAL *_term; /* terminal type information */
+ TTY _saved_tty; /* savetty/resetty information */
+ NCURSES_SIZE_T _lines; /* screen lines */
+ NCURSES_SIZE_T _columns; /* screen columns */
+
+ NCURSES_SIZE_T _lines_avail; /* lines available for stdscr */
+ NCURSES_SIZE_T _topstolen; /* lines stolen from top */
+
+ WINDOW *_curscr; /* current screen */
+ WINDOW *_newscr; /* virtual screen to be updated to */
+ WINDOW *_stdscr; /* screen's full-window context */
+
+ TRIES *_keytry; /* "Try" for use with keypad mode */
+ TRIES *_key_ok; /* Disabled keys via keyok(,FALSE) */
+ bool _tried; /* keypad mode was initialized */
+ bool _keypad_on; /* keypad mode is currently on */
+
+ bool _called_wgetch; /* check for recursion in wgetch() */
+ int _fifo[FIFO_SIZE]; /* input push-back buffer */
+ short _fifohead, /* head of fifo queue */
+ _fifotail, /* tail of fifo queue */
+ _fifopeek, /* where to peek for next char */
+ _fifohold; /* set if breakout marked */
+
+ int _endwin; /* are we out of window mode? */
+ NCURSES_CH_T *_current_attr; /* holds current attributes set */
+ int _coloron; /* is color enabled? */
+ int _color_defs; /* are colors modified */
+ int _cursor; /* visibility of the cursor */
+ int _cursrow; /* physical cursor row */
+ int _curscol; /* physical cursor column */
+ bool _notty; /* true if we cannot switch non-tty */
+ int _nl; /* True if NL -> CR/NL is on */
+ int _raw; /* True if in raw mode */
+ int _cbreak; /* 1 if in cbreak mode */
+ /* > 1 if in halfdelay mode */
+ int _echo; /* True if echo on */
+ int _use_meta; /* use the meta key? */
+ struct _SLK *_slk; /* ptr to soft key struct / NULL */
+ int slk_format; /* selected format for this screen */
/* cursor movement costs; units are 10ths of milliseconds */
#if NCURSES_NO_PADDING
- int _no_padding; /* flag to set if padding disabled */
+ bool _no_padding; /* flag to set if padding disabled */
#endif
- int _char_padding; /* cost of character put */
- int _cr_cost; /* cost of (carriage_return) */
- int _cup_cost; /* cost of (cursor_address) */
- int _home_cost; /* cost of (cursor_home) */
- int _ll_cost; /* cost of (cursor_to_ll) */
+ int _char_padding; /* cost of character put */
+ int _cr_cost; /* cost of (carriage_return) */
+ int _cup_cost; /* cost of (cursor_address) */
+ int _home_cost; /* cost of (cursor_home) */
+ int _ll_cost; /* cost of (cursor_to_ll) */
#if USE_HARD_TABS
- int _ht_cost; /* cost of (tab) */
- int _cbt_cost; /* cost of (backtab) */
+ int _ht_cost; /* cost of (tab) */
+ int _cbt_cost; /* cost of (backtab) */
#endif /* USE_HARD_TABS */
- int _cub1_cost; /* cost of (cursor_left) */
- int _cuf1_cost; /* cost of (cursor_right) */
- int _cud1_cost; /* cost of (cursor_down) */
- int _cuu1_cost; /* cost of (cursor_up) */
- int _cub_cost; /* cost of (parm_cursor_left) */
- int _cuf_cost; /* cost of (parm_cursor_right) */
- int _cud_cost; /* cost of (parm_cursor_down) */
- int _cuu_cost; /* cost of (parm_cursor_up) */
- int _hpa_cost; /* cost of (column_address) */
- int _vpa_cost; /* cost of (row_address) */
+ int _cub1_cost; /* cost of (cursor_left) */
+ int _cuf1_cost; /* cost of (cursor_right) */
+ int _cud1_cost; /* cost of (cursor_down) */
+ int _cuu1_cost; /* cost of (cursor_up) */
+ int _cub_cost; /* cost of (parm_cursor_left) */
+ int _cuf_cost; /* cost of (parm_cursor_right) */
+ int _cud_cost; /* cost of (parm_cursor_down) */
+ int _cuu_cost; /* cost of (parm_cursor_up) */
+ int _hpa_cost; /* cost of (column_address) */
+ int _vpa_cost; /* cost of (row_address) */
/* used in tty_update.c, must be chars */
- int _ed_cost; /* cost of (clr_eos) */
- int _el_cost; /* cost of (clr_eol) */
- int _el1_cost; /* cost of (clr_bol) */
- int _dch1_cost; /* cost of (delete_character) */
- int _ich1_cost; /* cost of (insert_character) */
- int _dch_cost; /* cost of (parm_dch) */
- int _ich_cost; /* cost of (parm_ich) */
- int _ech_cost; /* cost of (erase_chars) */
- int _rep_cost; /* cost of (repeat_char) */
- int _hpa_ch_cost; /* cost of (column_address) */
- int _cup_ch_cost; /* cost of (cursor_address) */
- int _cuf_ch_cost; /* cost of (parm_cursor_right) */
- int _inline_cost; /* cost of inline-move */
- int _smir_cost; /* cost of (enter_insert_mode) */
- int _rmir_cost; /* cost of (exit_insert_mode) */
- int _ip_cost; /* cost of (insert_padding) */
+ int _ed_cost; /* cost of (clr_eos) */
+ int _el_cost; /* cost of (clr_eol) */
+ int _el1_cost; /* cost of (clr_bol) */
+ int _dch1_cost; /* cost of (delete_character) */
+ int _ich1_cost; /* cost of (insert_character) */
+ int _dch_cost; /* cost of (parm_dch) */
+ int _ich_cost; /* cost of (parm_ich) */
+ int _ech_cost; /* cost of (erase_chars) */
+ int _rep_cost; /* cost of (repeat_char) */
+ int _hpa_ch_cost; /* cost of (column_address) */
+ int _cup_ch_cost; /* cost of (cursor_address) */
+ int _cuf_ch_cost; /* cost of (parm_cursor_right) */
+ int _inline_cost; /* cost of inline-move */
+ int _smir_cost; /* cost of (enter_insert_mode) */
+ int _rmir_cost; /* cost of (exit_insert_mode) */
+ int _ip_cost; /* cost of (insert_padding) */
/* used in lib_mvcur.c */
- char * _address_cursor;
+ char * _address_cursor;
/* used in tty_update.c */
- int _scrolling; /* 1 if terminal's smart enough to */
+ int _scrolling; /* 1 if terminal's smart enough to */
/* used in lib_color.c */
- color_t *_color_table; /* screen's color palette */
- int _color_count; /* count of colors in palette */
- unsigned short *_color_pairs; /* screen's color pair list */
- int _pair_count; /* count of color pairs */
+ color_t *_color_table; /* screen's color palette */
+ int _color_count; /* count of colors in palette */
+ colorpair_t *_color_pairs; /* screen's color pair list */
+ int _pair_count; /* count of color pairs */
#if NCURSES_EXT_FUNCS
- bool _default_color; /* use default colors */
- bool _has_sgr_39_49; /* has ECMA default color support */
- int _default_fg; /* assumed default foreground */
- int _default_bg; /* assumed default background */
+ bool _default_color; /* use default colors */
+ bool _has_sgr_39_49; /* has ECMA default color support */
+ int _default_fg; /* assumed default foreground */
+ int _default_bg; /* assumed default background */
#endif
- chtype _xmc_suppress; /* attributes to suppress if xmc */
- chtype _xmc_triggers; /* attributes to process if xmc */
- chtype _acs_map[ACS_LEN];
+ chtype _ok_attributes; /* valid attributes for terminal */
+ chtype _xmc_suppress; /* attributes to suppress if xmc */
+ chtype _xmc_triggers; /* attributes to process if xmc */
+ chtype * _acs_map; /* the real alternate-charset map */
+ bool * _screen_acs_map;
+
/* used in lib_vidattr.c */
- bool _use_rmso; /* true if we may use 'rmso' */
- bool _use_rmul; /* true if we may use 'rmul' */
+ bool _use_rmso; /* true if we may use 'rmso' */
+ bool _use_rmul; /* true if we may use 'rmul' */
/*
* These data correspond to the state of the idcok() and idlok()
@@ -388,21 +836,58 @@ struct screen {
* is given as an argument. However, ncurses implements this logic
* only for the newscr/curscr update process, _not_ per-window.
*/
- bool _nc_sp_idlok;
- bool _nc_sp_idcok;
+ bool _nc_sp_idlok;
+ bool _nc_sp_idcok;
#define _nc_idlok SP->_nc_sp_idlok
#define _nc_idcok SP->_nc_sp_idcok
/*
* These are the data that support the mouse interface.
*/
- int _maxclick;
- bool (*_mouse_event) (SCREEN *);
- bool (*_mouse_inline)(SCREEN *);
- bool (*_mouse_parse) (int);
- void (*_mouse_resume)(SCREEN *);
- void (*_mouse_wrap) (SCREEN *);
- int _mouse_fd; /* file-descriptor, if any */
+ bool _mouse_initialized;
+ MouseType _mouse_type;
+ int _maxclick;
+ bool (*_mouse_event) (SCREEN *);
+ bool (*_mouse_inline)(SCREEN *);
+ bool (*_mouse_parse) (SCREEN *, int);
+ void (*_mouse_resume)(SCREEN *);
+ void (*_mouse_wrap) (SCREEN *);
+ int _mouse_fd; /* file-descriptor, if any */
+ bool _mouse_active; /* true if initialized */
+ mmask_t _mouse_mask;
+ NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
+ MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */
+ MEVENT *_mouse_eventp; /* next free slot in event queue */
+
+#if USE_GPM_SUPPORT
+ bool _mouse_gpm_loaded;
+ bool _mouse_gpm_found;
+#ifdef HAVE_LIBDL
+ void *_dlopen_gpm;
+ TYPE_gpm_fd _mouse_gpm_fd;
+ TYPE_Gpm_Open _mouse_Gpm_Open;
+ TYPE_Gpm_Close _mouse_Gpm_Close;
+ TYPE_Gpm_GetEvent _mouse_Gpm_GetEvent;
+#endif
+ Gpm_Connect _mouse_gpm_connect;
+#endif /* USE_GPM_SUPPORT */
+
+#if USE_EMX_MOUSE
+ int _emxmouse_wfd;
+ int _emxmouse_thread;
+ int _emxmouse_activated;
+ char _emxmouse_buttons[4];
+#endif
+
+#if USE_SYSMOUSE
+ MEVENT _sysmouse_fifo[FIFO_SIZE];
+ int _sysmouse_head;
+ int _sysmouse_tail;
+ int _sysmouse_char_width; /* character width */
+ int _sysmouse_char_height; /* character height */
+ int _sysmouse_old_buttons;
+ int _sysmouse_new_buttons;
+#endif
/*
* This supports automatic resizing
@@ -411,48 +896,83 @@ struct screen {
int (*_resize)(int,int);
#endif
- /*
+ /*
* These are data that support the proper handling of the panel stack on an
* per screen basis.
*/
- struct panelhook _panelHook;
- /*
- * Linked-list of all windows, to support '_nc_resizeall()' and
- * '_nc_freeall()'
- */
- WINDOWLIST *_nc_sp_windows;
-#define _nc_windows SP->_nc_sp_windows
+ struct panelhook _panelHook;
- bool _sig_winch;
- SCREEN *_next_screen;
+ bool _sig_winch;
+ SCREEN *_next_screen;
/* hashes for old and new lines */
unsigned long *oldhash, *newhash;
+ HASHMAP *hashtab;
+ int hashtab_len;
+ int *_oldnum_list;
+ int _oldnum_size;
+
+ bool _cleanup; /* cleanup after int/quit signal */
+ int (*_outch)(int); /* output handler if not putc */
+
+ int _legacy_coding; /* see use_legacy_coding() */
+
+#if USE_REENTRANT
+ char _ttytype[NAMESIZE];
+ int _ESCDELAY;
+ int _TABSIZE;
+ int _LINES;
+ int _COLS;
+#ifdef TRACE
+ long _outchars;
+ const char *_tputs_trace;
+#endif
+#endif
- bool _cleanup; /* cleanup after int/quit signal */
- int (*_outch)(int); /* output handler if not putc */
+#ifdef TRACE
+#define _nc_screen_tracechr_buf_size 40
+ char tracechr_buf[_nc_screen_tracechr_buf_size];
+ char tracemse_buf[TRACEMSE_MAX];
+#endif
+ /*
+ * ncurses/ncursesw are the same up to this point.
+ */
+#if USE_WIDEC_SUPPORT
+ /* recent versions of 'screen' have partially-working support for
+ * UTF-8, but do not permit ACS at the same time (see tty_update.c).
+ */
+ bool _screen_acs_fix;
+#endif
};
extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
-
-#if NCURSES_NOMACROS
-#include <nomacros.h>
-#endif
+extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
WINDOWLIST {
+ WINDOW win; /* first, so WINDOW_EXT() works */
WINDOWLIST *next;
- WINDOW *win;
+ SCREEN *screen; /* screen containing the window */
+#ifdef _XOPEN_SOURCE_EXTENDED
+ char addch_work[(MB_LEN_MAX * 9) + 1];
+ unsigned addch_used; /* number of bytes in addch_work[] */
+ int addch_x; /* x-position for addch_work[] */
+ int addch_y; /* y-position for addch_work[] */
+#endif
};
-typedef struct {
- int line; /* lines to take, < 0 => from bottom*/
- int (*hook)(struct _win_st *, int); /* callback for user */
- struct _win_st *w; /* maybe we need this for cleanup */
-} ripoff_t;
+#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
+
+/* usually in <limits.h> */
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
/* The terminfo source is assumed to be 7-bit ASCII */
#define is7bits(c) ((unsigned)(c) < 128)
+/* Checks for isprint() should be done on 8-bit characters (non-wide) */
+#define is8bits(c) ((unsigned)(c) <= UCHAR_MAX)
+
#ifndef min
#define min(a,b) ((a) > (b) ? (b) : (a))
#endif
@@ -503,14 +1023,162 @@ typedef struct {
#define O_BINARY 0
#endif
-#define CharOf(c) ((unsigned char)(c))
-#define TextOf(c) ((c) & (chtype)A_CHARTEXT)
-#define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+#ifdef TRACE
+#if USE_REENTRANT
+#define COUNT_OUTCHARS(n) _nc_count_outchars(n);
+#else
+#define COUNT_OUTCHARS(n) _nc_outchars += (n);
+#endif
+#else
+#define COUNT_OUTCHARS(n) /* nothing */
+#endif
+
+#define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars)
+
+#define UChar(c) ((unsigned char)(c))
+#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
+#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
-#define BLANK (' '|A_NORMAL)
+#if USE_WIDEC_SUPPORT /* { */
+#define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ))
+
+#define init_mb(state) memset(&state, 0, sizeof(state))
+
+#if NCURSES_EXT_COLORS
+#define NulColor , 0
+#else
+#define NulColor /* nothing */
+#endif
+
+#define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */
+#define CharOf(c) ((c).chars[0])
+#define AttrOf(c) ((c).attr)
+
+#define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES)
+#define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES)
+#define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c)
+
+#define NewChar2(c,a) { a, { c, NulChar } NulColor }
+#define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch))
+
+#if CCHARW_MAX == 5
+#define CharEq(a,b) (((a).attr == (b).attr) \
+ && (a).chars[0] == (b).chars[0] \
+ && (a).chars[1] == (b).chars[1] \
+ && (a).chars[2] == (b).chars[2] \
+ && (a).chars[3] == (b).chars[3] \
+ && (a).chars[4] == (b).chars[4] \
+ if_EXT_COLORS(&& (a).ext_color == (b).ext_color))
+#else
+#define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a)))
+#endif
+
+#define SetChar(ch,c,a) do { \
+ NCURSES_CH_T *_cp = &ch; \
+ memset(_cp, 0, sizeof(ch)); \
+ _cp->chars[0] = (c); \
+ _cp->attr = (a); \
+ if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a))); \
+ } while (0)
+#define CHREF(wch) (&wch)
+#define CHDEREF(wch) (*wch)
+#define ARG_CH_T NCURSES_CH_T *
+#define CARG_CH_T const NCURSES_CH_T *
+#define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
+ mbstate_t PUT_st; wchar_t PUTC_ch
+#define PUTC_INIT init_mb (PUT_st)
+#define PUTC(ch,b) do { if(!isWidecExt(ch)) { \
+ if (Charable(ch)) { \
+ fputc(CharOf(ch), b); \
+ COUNT_OUTCHARS(1); \
+ } else { \
+ PUTC_INIT; \
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \
+ PUTC_ch = (ch).chars[PUTC_i]; \
+ if (PUTC_ch == L'\0') \
+ break; \
+ PUTC_n = wcrtomb(PUTC_buf, \
+ (ch).chars[PUTC_i], &PUT_st); \
+ if (PUTC_n <= 0) { \
+ if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
+ putc(PUTC_ch,b); \
+ break; \
+ } \
+ fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
+ } \
+ COUNT_OUTCHARS(PUTC_i); \
+ } } } while (0)
+
+#define BLANK NewChar2(' ', WA_NORMAL)
+#define ZEROS NewChar2('\0', WA_NORMAL)
+#define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
+
+ /*
+ * Wide characters cannot be represented in the A_CHARTEXT mask of
+ * attr_t's but an application might have set a narrow character there.
+ * But even in that case, it would only be a printable character, or
+ * zero. Otherwise we can use those bits to tell if a cell is the
+ * first or extension part of a wide character.
+ */
+#define WidecExt(ch) (AttrOf(ch) & A_CHARTEXT)
+#define isWidecBase(ch) (WidecExt(ch) == 1)
+#define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32)
+#define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \
+ AttrOf(dst) |= (ext + 1)
+
+#define if_WIDEC(code) code
+#define Charable(ch) ((SP != 0 && SP->_legacy_coding) \
+ || (AttrOf(ch) & A_ALTCHARSET) \
+ || (!isWidecExt(ch) && \
+ (ch).chars[1] == L'\0' && \
+ _nc_is_charable(CharOf(ch))))
+
+#define L(ch) L ## ch
+#else /* }{ */
+#define CharOf(c) ChCharOf(c)
+#define AttrOf(c) ChAttrOf(c)
+#define AddAttr(c,a) c |= (a)
+#define RemAttr(c,a) c &= ~((a) & A_ATTRIBUTES)
+#define SetAttr(c,a) c = ((c) & ~A_ATTRIBUTES) | (a)
+#define NewChar(ch) (ch)
+#define NewChar2(c,a) ((c) | (a))
+#define CharEq(a,b) ((a) == (b))
+#define SetChar(ch,c,a) ch = (c) | (a)
+#define CHREF(wch) wch
+#define CHDEREF(wch) wch
+#define ARG_CH_T NCURSES_CH_T
+#define CARG_CH_T NCURSES_CH_T
+#define PUTC_DATA int data = 0
+#define PUTC(ch,b) do { data = CharOf(ch); putc(data,b); } while (0)
+
+#define BLANK (' '|A_NORMAL)
+#define ZEROS ('\0'|A_NORMAL)
+#define ISBLANK(ch) (CharOf(ch) == ' ')
+
+#define isWidecExt(ch) (0)
+#define if_WIDEC(code) /* nothing */
+
+#define L(ch) ch
+#endif /* } */
+
+#define AttrOfD(ch) AttrOf(CHDEREF(ch))
+#define CharOfD(ch) CharOf(CHDEREF(ch))
+#define SetChar2(wch,ch) SetChar(wch,ChCharOf(ch),ChAttrOf(ch))
+
+#define BLANK_ATTR A_NORMAL
+#define BLANK_TEXT L(' ')
#define CHANGED -1
+#define LEGALYX(w, y, x) \
+ ((w) != 0 && \
+ ((x) >= 0 && (x) <= (w)->_maxx && \
+ (y) >= 0 && (y) <= (w)->_maxy))
+
#define CHANGED_CELL(line,col) \
if (line->firstchar == _NOCHANGE) \
line->firstchar = line->lastchar = col; \
@@ -545,75 +1213,176 @@ typedef struct {
#include <nc_alloc.h>
/*
+ * TTY bit definition for converting tabs to spaces.
+ */
+#ifdef TAB3
+# define OFLAGS_TABS TAB3 /* POSIX specifies TAB3 */
+#else
+# ifdef XTABS
+# define OFLAGS_TABS XTABS /* XTABS is usually the "same" */
+# else
+# ifdef OXTABS
+# define OFLAGS_TABS OXTABS /* the traditional BSD equivalent */
+# else
+# define OFLAGS_TABS 0
+# endif
+# endif
+#endif
+
+/*
+ * Standardize/simplify common loops
+ */
+#define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen
+#define each_window(p) p = _nc_windows; p != 0; p = (p)->next
+#define each_ripoff(p) p = ripoff_stack; (p - ripoff_stack) < N_RIPS; ++p
+
+/*
* Prefixes for call/return points of library function traces. We use these to
* instrument the public functions so that the traces can be easily transformed
* into regression scripts.
*/
-#define T_CALLED(fmt) "called " fmt
-#define T_CREATE(fmt) "create " fmt
-#define T_RETURN(fmt) "return " fmt
+#define T_CALLED(fmt) "called {" fmt
+#define T_CREATE(fmt) "create :" fmt
+#define T_RETURN(fmt) "return }" fmt
#ifdef TRACE
-#define TR(n, a) if (_nc_tracing & (n)) _tracef a
-#define T(a) TR(TRACE_CALLS, a)
+
+#if USE_REENTRANT
+#define TPUTS_TRACE(s) _nc_set_tputs_trace(s);
+#else
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
+#endif
+
+#define START_TRACE() \
+ if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
+ int t = _nc_getenv_num("NCURSES_TRACE"); \
+ if (t >= 0) \
+ trace((unsigned) t); \
+ }
+
+/*
+ * Many of the _tracef() calls use static buffers; lock the trace state before
+ * trying to fill them.
+ */
+#if USE_REENTRANT
+#define USE_TRACEF(mask) _nc_use_tracef(mask)
+extern NCURSES_EXPORT(int) _nc_use_tracef (unsigned);
+extern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
+#else
+#define USE_TRACEF(mask) (_nc_tracing & (mask))
+#define _nc_locked_tracef _tracef
+#endif
+
+#define TR(n, a) if (USE_TRACEF(n)) _nc_locked_tracef a
+#define T(a) TR(TRACE_CALLS, a)
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
-#define returnAttr(code) TRACE_RETURN(code,attr_t)
-#define returnChar(code) TRACE_RETURN(code,chtype)
-#define returnCode(code) TRACE_RETURN(code,int)
-#define returnPtr(code) TRACE_RETURN(code,ptr)
-#define returnVoid T((T_RETURN(""))); return
-#define returnWin(code) TRACE_RETURN(code,win)
-extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
-extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
-extern NCURSES_EXPORT(attr_t) _nc_retrace_chtype (chtype);
-extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
-extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
-extern NCURSES_EXPORT(int) _nc_retrace_int (int);
-extern NCURSES_EXPORT_VAR(long) _nc_outchars;
-extern NCURSES_EXPORT(void) _nc_fifo_dump (void);
+
+#define returnAttr(code) TRACE_RETURN(code,attr_t)
+#define returnBits(code) TRACE_RETURN(code,unsigned)
+#define returnBool(code) TRACE_RETURN(code,bool)
+#define returnCPtr(code) TRACE_RETURN(code,cptr)
+#define returnCVoidPtr(code) TRACE_RETURN(code,cvoid_ptr)
+#define returnChar(code) TRACE_RETURN(code,chtype)
+#define returnCode(code) TRACE_RETURN(code,int)
+#define returnPtr(code) TRACE_RETURN(code,ptr)
+#define returnSP(code) TRACE_RETURN(code,sp)
+#define returnVoid T((T_RETURN(""))); return
+#define returnVoidPtr(code) TRACE_RETURN(code,void_ptr)
+#define returnWin(code) TRACE_RETURN(code,win)
+
+extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (NCURSES_BOOL);
+extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
+extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
+extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
+extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
+extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
+extern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty);
+extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list);
+extern NCURSES_EXPORT(chtype) _nc_retrace_chtype (chtype);
+extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype);
+extern NCURSES_EXPORT(const char *) _nc_retrace_cptr (const char *);
+extern NCURSES_EXPORT(int) _nc_retrace_int (int);
+extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned);
+extern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *);
+extern NCURSES_EXPORT(void) _nc_fifo_dump (SCREEN *);
+
+#if USE_REENTRANT
+NCURSES_WRAPPED_VAR(long, _nc_outchars);
+NCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace);
+#define _nc_outchars NCURSES_PUBLIC_VAR(_nc_outchars())
+#define _nc_tputs_trace NCURSES_PUBLIC_VAR(_nc_tputs_trace())
+extern NCURSES_EXPORT(void) _nc_set_tputs_trace (const char *);
+extern NCURSES_EXPORT(void) _nc_count_outchars (long);
#else
+extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
+extern NCURSES_EXPORT_VAR(long) _nc_outchars;
+#endif
+
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
+extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int);
+#endif
+
+extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const NCURSES_CH_T *, int);
+extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
+
+#else /* !TRACE */
+
+#define START_TRACE() /* nothing */
+
#define T(a)
#define TR(n, a)
#define TPUTS_TRACE(s)
-#define returnAttr(code) return code
-#define returnChar(code) return code
-#define returnCode(code) return code
-#define returnPtr(code) return code
-#define returnVoid return
-#define returnWin(code) return code
-#endif
-extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+#define returnAttr(code) return code
+#define returnBits(code) return code
+#define returnBool(code) return code
+#define returnCPtr(code) return code
+#define returnCVoidPtr(code) return code
+#define returnChar(code) return code
+#define returnCode(code) return code
+#define returnPtr(code) return code
+#define returnSP(code) return code
+#define returnVoid return
+#define returnVoidPtr(code) return code
+#define returnWin(code) return code
+
+#endif /* TRACE/!TRACE */
+
+/*
+ * Return-codes for tgetent() and friends.
+ */
+#define TGETENT_YES 1 /* entry is found */
+#define TGETENT_NO 0 /* entry is not found */
+#define TGETENT_ERR -1 /* an error occurred */
+
extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
+extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
-#define _trace_key(ch) ((ch > KEY_MIN) ? keyname(ch) : _tracechar((unsigned char)ch))
+#define EMPTY_MODULE(name) \
+extern NCURSES_EXPORT(void) name (void); \
+ NCURSES_EXPORT(void) name (void) { }
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
-#define IGNORE_COLOR_OFF FALSE
-#define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK)
+#define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
#define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
-
#define toggle_attr_on(S,at) {\
- if (PAIR_NUMBER(at) > 0)\
+ if (PAIR_NUMBER(at) > 0) {\
(S) = ((S) & ALL_BUT_COLOR) | (at);\
- else\
+ } else {\
(S) |= (at);\
+ }\
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define toggle_attr_off(S,at) {\
- if (IGNORE_COLOR_OFF == TRUE) {\
- if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
- (S) &= ~(at);\
- else /* leave color alone */\
- (S) &= ~((at)&ALL_BUT_COLOR);\
+ if (PAIR_NUMBER(at) > 0) {\
+ (S) &= ~(at|A_COLOR);\
} else {\
- if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
- (S) &= ~(at|A_COLOR);\
- else /* leave color alone */\
- (S) &= ~(at);\
+ (S) &= ~(at);\
}\
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
@@ -630,17 +1399,16 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
: ((enter_insert_mode && exit_insert_mode) \
? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
: ((insert_character != 0) \
- ? (SP->_ich1_cost * count) \
+ ? ((SP->_ich1_cost + SP->_ip_cost) * count) \
: INFINITY)))
#if USE_XMC_SUPPORT
-#define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) { \
- attr_t chg = SP->_current_attr; \
- vidattr(AttrOf(c)); \
+#define UpdateAttrs(c) if (!SameAttrOf(SCREEN_ATTRS(SP), c)) { \
+ attr_t chg = AttrOf(SCREEN_ATTRS(SP)); \
+ VIDATTR(AttrOf(c), GetPair(c)); \
if (magic_cookie_glitch > 0 \
- && XMC_CHANGES((chg ^ SP->_current_attr))) { \
- TR(TRACE_ATTRS, \
- ("%s @%d before glitch %d,%d", \
+ && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(SP))))) { \
+ T(("%s @%d before glitch %d,%d", \
__FILE__, __LINE__, \
SP->_cursrow, \
SP->_curscol)); \
@@ -648,8 +1416,21 @@ extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
} \
}
#else
-#define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) \
- vidattr(AttrOf(c))
+#define UpdateAttrs(c) if (!SameAttrOf(SCREEN_ATTRS(SP), c)) \
+ VIDATTR(AttrOf(c), GetPair(c));
+#endif
+
+/*
+ * Macros to make additional parameter to implement wgetch_events()
+ */
+#ifdef NCURSES_WGETCH_EVENTS
+#define EVENTLIST_0th(param) param
+#define EVENTLIST_1st(param) param
+#define EVENTLIST_2nd(param) , param
+#else
+#define EVENTLIST_0th(param) void
+#define EVENTLIST_1st(param) /* nothing */
+#define EVENTLIST_2nd(param) /* nothing */
#endif
#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
@@ -672,7 +1453,7 @@ extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
#undef UpdateAttrs
#define UpdateAttrs(c) _nc_UpdateAttrs(c)
-extern NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype);
+extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
#else
@@ -680,10 +1461,36 @@ extern NCURSES_EXPORT(void) _nc_expanded (void);
#endif
+#if !NCURSES_EXT_FUNCS
+#define set_escdelay(value) ESCDELAY = value
+#endif
+
#if !HAVE_GETCWD
#define getcwd(buf,len) getwd(buf)
#endif
+/* charable.c */
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
+extern NCURSES_EXPORT(int) _nc_to_char(wint_t);
+extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int);
+#endif
+
+/* comp_captab.c */
+typedef struct {
+ short nte_name; /* offset of name to hash on */
+ int nte_type; /* BOOLEAN, NUMBER or STRING */
+ short nte_index; /* index of associated variable in its array */
+ short nte_link; /* index in table of next hash, or -1 */
+} name_table_data;
+
+typedef struct
+{
+ short from;
+ short to;
+ short source;
+} alias_table_data;
+
/* doupdate.c */
#if USE_XMC_SUPPORT
extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
@@ -698,6 +1505,25 @@ extern NCURSES_EXPORT(void) _nc_linedump (void);
extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
+/* lib_addch.c */
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
+#endif
+
+/* lib_addstr.c */
+#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
+extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
+#endif
+
+/* lib_color.c */
+extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
+
+/* lib_getch.c */
+extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
+
+/* lib_insch.c */
+extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
+
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
@@ -716,29 +1542,43 @@ extern NCURSES_EXPORT(int) _nc_has_mouse (void);
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
+#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
+
+/* lib_setup.c */
+extern NCURSES_EXPORT(char *) _nc_get_locale(void);
+extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
+extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *);
+extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
+extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
+
+/* lib_tstp.c */
+#if USE_SIGWINCH
+extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *);
+#else
+#define _nc_handle_sigwinch(a) /* nothing */
+#endif
+
+/* lib_ungetch.c */
+extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int);
+
+/* lib_wacs.c */
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(void) _nc_init_wacs(void);
+#endif
typedef struct {
- char *s_head;
- char *s_tail;
- size_t s_size;
+ char *s_head; /* beginning of the string (may be null) */
+ char *s_tail; /* end of the string (may be null) */
+ size_t s_size; /* current remaining size available */
+ size_t s_init; /* total size available */
} string_desc;
/* strings.c */
-extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc * dst, char *src, size_t len);
-extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc * dst, size_t len);
-extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc * dst, string_desc * src);
-extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc * dst, const char *src);
-extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc * dst, const char *src);
-
-extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
-extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
-extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
-
-extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
-
-extern NCURSES_EXPORT(void) _nc_screen_init (void);
-extern NCURSES_EXPORT(void) _nc_screen_resume (void);
-extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
+extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
+extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
+extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
+extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
+extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
#if !HAVE_STRSTR
#define strstr _nc_strstr
@@ -746,52 +1586,93 @@ extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
#endif
/* safe_sprintf.c */
-extern NCURSES_EXPORT(char *) _nc_printf_string (const char *fmt, va_list ap);
+extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list);
/* tries.c */
-extern NCURSES_EXPORT(void) _nc_add_to_try (struct tries **tree, const char *str, unsigned short code);
-extern NCURSES_EXPORT(char *) _nc_expand_try (struct tries *tree, unsigned short code, int *count, size_t len);
-extern NCURSES_EXPORT(int) _nc_remove_key (struct tries **tree, unsigned short code);
-extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **tree, char *string);
+extern NCURSES_EXPORT(int) _nc_add_to_try (TRIES **, const char *, unsigned);
+extern NCURSES_EXPORT(char *) _nc_expand_try (TRIES *, unsigned, int *, size_t);
+extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned);
+extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
/* elsewhere ... */
+extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
+extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
-extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
-extern NCURSES_EXPORT(chtype) _nc_background (WINDOW *);
-extern NCURSES_EXPORT(chtype) _nc_render (WINDOW *, chtype);
-extern NCURSES_EXPORT(int) _nc_access (const char *, int);
+extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
+extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
+extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
+extern NCURSES_EXPORT(int) _nc_access (const char *, int);
extern NCURSES_EXPORT(int) _nc_baudrate (int);
-extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *win);
+extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
-extern NCURSES_EXPORT(int) _nc_keypad (bool);
+extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, bool);
extern NCURSES_EXPORT(int) _nc_ospeed (int);
extern NCURSES_EXPORT(int) _nc_outch (int);
-extern NCURSES_EXPORT(int) _nc_setupscreen (short, short const, FILE *);
-extern NCURSES_EXPORT(int) _nc_timed_wait (int, int, int *);
-extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const chtype);
-extern NCURSES_EXPORT(void) _nc_do_color (int, int, bool, int (*)(int));
+extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
+extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
+extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
extern NCURSES_EXPORT(void) _nc_flush (void);
+extern NCURSES_EXPORT(void) _nc_free_and_exit (int);
+extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *);
extern NCURSES_EXPORT(void) _nc_freeall (void);
extern NCURSES_EXPORT(void) _nc_hash_map (void);
-extern NCURSES_EXPORT(void) _nc_init_keytry (void);
+extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
-extern NCURSES_EXPORT(void) _nc_outstr (const char *str);
extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
-extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, chtype);
extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
-extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *win);
-extern NCURSES_EXPORT(void) _nc_trace_tries (struct tries *tree);
+extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
+extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *);
+
+#if NO_LEAKS
+extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void);
+extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);
+extern NCURSES_EXPORT(void) _nc_codes_leaks(void);
+extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void);
+extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
+extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
+extern NCURSES_EXPORT(void) _nc_names_leaks(void);
+extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
+#endif
+
+#ifndef USE_TERMLIB
+extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
+extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
+extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T);
+#endif
+
+#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
+extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
+#endif
#if USE_SIZECHANGE
-extern NCURSES_EXPORT(void) _nc_update_screensize (void);
+extern NCURSES_EXPORT(void) _nc_update_screensize (SCREEN *);
#endif
-#if USE_WIDEC_SUPPORT
-extern NCURSES_EXPORT(int) _nc_utf8_outch (int);
+#if HAVE_RESIZETERM
+extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *);
+#else
+#define _nc_resize_margins(wp) /* nothing */
+#endif
+
+#ifdef NCURSES_WGETCH_EVENTS
+extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *);
+#else
+#define wgetch_events(win, evl) wgetch(win)
+#define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen)
+#endif
+
+/*
+ * Not everyone has vsscanf(), but we'd like to use it for scanw().
+ */
+#if !HAVE_VSSCANF
+extern int vsscanf(const char *str, const char *format, va_list __arg);
#endif
/* scroll indices */
@@ -799,9 +1680,7 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
#define USE_SETBUF_0 0
-#define NC_BUFFERED(flag) \
- if ((SP->_buffered != 0) != flag) \
- _nc_set_buffer(SP->_ofp, flag)
+#define NC_BUFFERED(flag) _nc_set_buffer(SP->_ofp, flag)
#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
@@ -822,15 +1701,13 @@ extern NCURSES_EXPORT_VAR(SCREEN *) SP;
#endif
/*
- * We don't want to use the lines or columns capabilities internally,
- * because if the application is running multiple screens under
- * the X Window System, it's quite possible they could all have type xterm
- * but have different sizes! So...
+ * We don't want to use the lines or columns capabilities internally, because
+ * if the application is running multiple screens under X, it's quite possible
+ * they could all have type xterm but have different sizes! So...
*/
#define screen_lines SP->_lines
#define screen_columns SP->_columns
-extern NCURSES_EXPORT_VAR(int) _nc_slk_format; /* != 0 if slk_init() called */
extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
/*
@@ -851,6 +1728,12 @@ extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
+/*
+ * Common error messages
+ */
+#define MSG_NO_MEMORY "Out of memory"
+#define MSG_NO_INPUTS "Premature EOF"
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/libcurses/default_colors.3 b/lib/libcurses/default_colors.3
index 16e224d2c4c..e0848a8e824 100644
--- a/lib/libcurses/default_colors.3
+++ b/lib/libcurses/default_colors.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: default_colors.3,v 1.1 2000/07/24 04:06:10 millert Exp $
+.\" $OpenBSD: default_colors.3,v 1.2 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,22 +28,19 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1997,1999,2000
+.\" Author: Thomas E. Dickey 1997,1999,2000,2005
.\"
-.\" $From: default_colors.3x,v 1.13 2000/07/15 22:06:50 tom Exp $
+.\" $Id: default_colors.3,v 1.2 2010/01/12 23:21:59 nicm Exp $
.TH default_colors 3 ""
.SH NAME
-\fBdefault_colors\fR,
\fBuse_default_colors\fR,
\fBassume_default_colors\fR \- use terminal's default colors
-..
.SH SYNOPSIS
\fB#include <curses.h>\fP
-
+.sp
\fBint use_default_colors(void);\fP
.br
\fBint assume_default_colors(int fg, int bg);\fP
-..
.SH DESCRIPTION
The
.I use_default_colors()
@@ -102,28 +99,42 @@ or
.I assume_default_colors()
ncurses will paint a white foreground (text) with black background
for color pair 0.
-..
.SH RETURN VALUE
These functions return the integer \fBERR\fP upon failure and \fBOK\fP on success.
They will fail if either the terminal does not support
the \fIorig_pair\fP or \fIorig_colors\fP capability.
If the \fIinitialize_pair\fP capability is found, this causes an
error as well.
-..
.SH NOTES
-Associated with this extension, the \fBinit_pair\fR(3) function accepts
-negative arguments to specify default foreground or background
-colors.
-..
+Associated with this extension, the \fBinit_pair\fR function accepts
+negative arguments to specify default foreground or background colors.
+.PP
+The \fIuse_default_colors()\fP function was added to support \fIded\fP.
+This is a full-screen application which uses curses to manage only part
+of the screen. The bottom portion of the screen, which is of adjustable
+size, is left uncolored to display the results from shell commands.
+The top portion of the screen colors filenames using a scheme like the
+"color ls" programs.
+Attempting to manage the background color of the screen for this application
+would give unsatisfactory results for a variety of reasons.
+This extension was devised after
+noting that color xterm (and similar programs) provides a background color
+which does not necessarily correspond to any of the ANSI colors.
+While a special terminfo entry could be constructed using nine colors,
+there was no mechanism provided within curses to account for the related
+\fIorig_pair\fP and \fIback_color_erase\fP capabilities.
+.PP
+The \fIassume_default_colors()\fP function was added to solve
+a different problem: support for applications which would use
+environment variables and other configuration to bypass curses'
+notion of the terminal's default colors, setting specific values.
.SH PORTABILITY
These routines are specific to ncurses. They were not supported on
Version 7, BSD or System V implementations. It is recommended that
any code depending on them be conditioned using NCURSES_VERSION.
-..
.SH SEE ALSO
\fBcurs_color\fR(3),
\fBded\fP(1).
-..
.SH AUTHOR
Thomas Dickey (from an analysis of the requirements for color xterm
for XFree86 3.1.2C, February 1996).
diff --git a/lib/libcurses/define_key.3 b/lib/libcurses/define_key.3
index c0e10afb70c..9104ca26fd7 100644
--- a/lib/libcurses/define_key.3
+++ b/lib/libcurses/define_key.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: define_key.3,v 1.4 1999/05/08 20:28:58 millert Exp $
+.\" $OpenBSD: define_key.3,v 1.5 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,40 +28,35 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1997
+.\" Author: Thomas E. Dickey 1997
.\"
-.\" $From: define_key.3x,v 1.6 1999/02/19 11:43:17 tom Exp $
+.\" $Id: define_key.3,v 1.5 2010/01/12 23:21:59 nicm Exp $
.TH define_key 3 ""
.SH NAME
\fBdefine_key\fP \- define a keycode
-..
.SH SYNOPSIS
\fB#include <curses.h>\fP
-
-\fBint define_key(char *definition, int keycode);\fP
-..
+.sp
+\fBint define_key(const char *definition, int keycode);\fP
.SH DESCRIPTION
This is an extension to the curses library.
It permits an application to define keycodes with their corresponding control
-strings, so that the curses library will interpret them just as it would
+strings, so that the ncurses library will interpret them just as it would
the predefined codes in the terminfo database.
.PP
If the given string is null, any existing definition for the keycode is
removed.
Similarly, if the given keycode is negative or zero, any existing string
for the given definition is removed.
-..
.SH RETURN VALUE
The keycode must be greater than zero, else ERR is returned.
-..
.SH PORTABILITY
These routines are specific to ncurses. They were not supported on
Version 7, BSD or System V implementations. It is recommended that
any code depending on them be conditioned using NCURSES_VERSION.
-..
.SH SEE ALSO
-\fBkeyok\fR(3).
-..
+\fBkeyok\fR(3),
+\fBkey_defined\fR(3).
.SH AUTHOR
Thomas Dickey.
.\"#
diff --git a/lib/libcurses/doc/hackguide.html b/lib/libcurses/doc/hackguide.html
index 4e1d237f3b7..938fa4c0969 100644
--- a/lib/libcurses/doc/hackguide.html
+++ b/lib/libcurses/doc/hackguide.html
@@ -1,11 +1,39 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<!--
- $From: hackguide.html,v 1.25 2000/03/25 18:45:21 tom Exp $
+ $Id: hackguide.html,v 1.6 2010/01/12 23:22:06 nicm Exp $
+ ****************************************************************************
+ * Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************
-->
<HTML>
<HEAD>
<TITLE>A Hacker's Guide to Ncurses Internals</TITLE>
<link rev="made" href="mailto:bugs-ncurses@gnu.org">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--
This document is self-contained, *except* that there is one relative link to
the ncurses-intro.html document, expected to be in the same directory with
@@ -286,10 +314,6 @@ header comments of <CODE>hardscroll.c</CODE> and <CODE>hashmap.c</CODE>; then tr
it out. You can also test the hardware-scrolling optimization separately
with <CODE>hardscroll</CODE>. <P>
-There's one other interactive tester, <CODE>tctest</CODE>, that exercises
-translation between termcap and terminfo formats. If you have a serious
-need to run this, you probably belong on our development team!
-
<H1><A NAME="ncurslib">A Tour of the Ncurses Library</A></H1>
<H2><A NAME="loverview">Library Overview</A></H2>
@@ -377,7 +401,7 @@ trace_buf.c
</code>
</blockquote>
It is rather unlikely you will ever need to change these, unless
-you want to introduce a new debug trace level for some reasoon.<P>
+you want to introduce a new debug trace level for some reason.<P>
There is another group of files that do direct I/O via <EM>tputs()</EM>,
computations on the terminal capabilities, or queries to the OS
diff --git a/lib/libcurses/doc/ncurses-intro.html b/lib/libcurses/doc/ncurses-intro.html
index f6d505a50ad..d0ccb74e719 100644
--- a/lib/libcurses/doc/ncurses-intro.html
+++ b/lib/libcurses/doc/ncurses-intro.html
@@ -1,11 +1,39 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<!--
- $From: ncurses-intro.html,v 1.34 2000/06/11 00:03:55 tom Exp $
+ $Id: ncurses-intro.html,v 1.7 2010/01/12 23:22:06 nicm Exp $
+ ****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************
-->
<HTML>
<HEAD>
<TITLE>Writing Programs with NCURSES</TITLE>
<link rev="made" href="mailto:bugs-ncurses@gnu.org">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
@@ -221,16 +249,11 @@ maintainer of this package is
&lt;esr@snark.thyrsus.com&gt;
wrote many of the new features in versions after 1.8.1
and wrote most of this introduction.
-<A HREF="mailto:juergen.pfeifer@gmx.net">J&uuml;rgen Pfeifer</A>
+J&uuml;rgen Pfeifer
wrote all of the menu and forms code as well as the
<A HREF="http://www.adahome.com">Ada95</A> binding.
Ongoing work is being done by
-<A HREF="mailto:dickey@herndon4.his.com">Thomas Dickey</A>
-and
-<A HREF="mailto:juergen.pfeifer@gmx.net">J&uuml;rgen Pfeifer</A>.
-<A HREF="mailto:florian@gnu.org">Florian La Roche</A>
-acts as the maintainer for the Free Software Foundation, which holds the
-copyright on ncurses.
+<A HREF="mailto:dickey@invisible-island.net">Thomas Dickey</A> (maintainer).
Contact the current maintainers at
<A HREF="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</A>.
<P>
@@ -613,6 +636,7 @@ Presently, mouse event reporting works in the following environments:
<li>xterm and similar programs such as rxvt.
<li>Linux console, when configured with <CODE>gpm</CODE>(1), Alessandro
Rubini's mouse server.
+<li>FreeBSD sysmouse (console)
<li>OS/2 EMX
</ul>
<P>
@@ -690,7 +714,7 @@ the first call to <CODE>refresh()</CODE> will clear the screen. If an error
occurs a message is written to standard error and the program
exits. Otherwise it returns a pointer to stdscr. A few functions may be
called before initscr (<CODE>slk_init()</CODE>, <CODE>filter()</CODE>,
-<CODE>ripofflines()</CODE>, <CODE>use_env()</CODE>, and, if you are using multiple
+<CODE>ripoffline()</CODE>, <CODE>use_env()</CODE>, and, if you are using multiple
terminals, <CODE>newterm()</CODE>.)
<DT> <CODE>endwin()</CODE>
<DD> Your program should always call <CODE>endwin()</CODE> before exiting or
@@ -704,7 +728,11 @@ restore the ncurses screen from before the escape.
<CODE>newterm()</CODE> instead of <CODE>initscr()</CODE>. <CODE>newterm()</CODE> should
be called once for each terminal. It returns a variable of type
<CODE>SCREEN *</CODE> which should be saved as a reference to that
-terminal. The arguments are the type of the terminal (a string) and
+terminal.
+(NOTE: a SCREEN variable is not a <em>screen</em> in the sense we
+are describing in this introduction, but a collection of
+parameters used to assist in optimizing the display.)
+The arguments are the type of the terminal (a string) and
<CODE>FILE</CODE> pointers for the output and input of the terminal. If
type is NULL then the environment variable <CODE>$TERM</CODE> is used.
<CODE>endwin()</CODE> should called once at wrapup time for each terminal
@@ -728,7 +756,7 @@ the terminal, as other routines merely manipulate data
structures. <CODE>wrefresh()</CODE> copies the named window to the physical
terminal screen, taking into account what is already
there in order to do optimizations. <CODE>refresh()</CODE> does a
-refresh of <CODE>stdscr()</CODE>. Unless <CODE>leaveok()</CODE> has been
+refresh of <CODE>stdscr</CODE>. Unless <CODE>leaveok()</CODE> has been
enabled, the physical cursor of the terminal is left at the
location of the window's cursor.
<DT> <CODE>doupdate()</CODE> and <CODE>wnoutrefresh(win)</CODE>
@@ -886,15 +914,14 @@ Here is some sample code for shellout:
<H3><A NAME="xterm">Using NCURSES under XTERM</A></H3>
-A resize operation in X sends SIGWINCH to the application running under xterm.
-The <CODE>ncurses</CODE> library provides an experimental signal
-handler, but in general does not catch this signal, because it cannot
-know how you want the screen re-painted. You will usually have to write the
-SIGWINCH handler yourself. Ncurses can give you some help. <P>
+A resize operation in X sends <CODE>SIGWINCH</CODE> to the application running
+under xterm.
-The easiest way to code your SIGWINCH handler is to have it do an
-<CODE>endwin</CODE>, followed by an <CODE>refresh</CODE> and a screen repaint you code
-yourself. The <CODE>refresh</CODE> will pick up the new screen size from the
+The easiest way to handle <CODE>SIGWINCH</CODE>
+is to do an <CODE>endwin</CODE>,
+followed by an <CODE>refresh</CODE> and a screen repaint you code
+yourself.
+The <CODE>refresh</CODE> will pick up the new screen size from the
xterm's environment. <P>
That is the standard way, of course (it even works with some vendor's curses
@@ -906,8 +933,17 @@ not resize subwindows which must be shrunk.
are limited to the new screen dimensions, and pads <CODE>stdscr</CODE>
with blanks if the screen is larger. <P>
-Finally, ncurses can be configured to provide its own SIGWINCH handler,
-based on <CODE>resizeterm</CODE>.
+The <CODE>ncurses</CODE> library provides a SIGWINCH signal handler,
+which pushes a <CODE>KEY_RESIZE</CODE> via the wgetch() calls.
+When <CODE>ncurses</CODE> returns that code,
+it calls <code>resizeterm</CODE>
+to update the size of the standard screen's window, repainting that
+(filling with blanks or truncating as needed).
+It also resizes other windows,
+but its effect may be less satisfactory because it cannot
+know how you want the screen re-painted.
+You will usually have to write special-purpose code to handle
+<CODE>KEY_RESIZE</CODE> yourself.
<H3><A NAME="screens">Handling Multiple Terminal Screens</A></H3>
@@ -1016,7 +1052,7 @@ guarantee an entire-contents copy anywhere. <P>
The really clean way to handle this is to use the panels library. If,
when you want a screen update, you do <CODE>update_panels()</CODE>, it will
-do all the necessary <CODE>wnoutrfresh()</CODE> calls for whatever panel
+do all the necessary <CODE>wnoutrefresh()</CODE> calls for whatever panel
stacking order you have defined. Then you can do one <CODE>doupdate()</CODE>
and there will be a <EM>single</EM> burst of physical I/O that will do
all your updates.
@@ -1218,10 +1254,10 @@ The general flow of control of a menu program looks like this:
<LI>Initialize <CODE>curses</CODE>.
<LI>Create the menu items, using <CODE>new_item()</CODE>.
<LI>Create the menu using <CODE>new_menu()</CODE>.
-<LI>Post the menu using <CODE>menu_post()</CODE>.
+<LI>Post the menu using <CODE>post_menu()</CODE>.
<LI>Refresh the screen.
<LI>Process user requests via an input loop.
-<LI>Unpost the menu using <CODE>menu_unpost()</CODE>.
+<LI>Unpost the menu using <CODE>unpost_menu()</CODE>.
<LI>Free the menu, using <CODE>free_menu()</CODE>.
<LI>Free the items using <CODE>free_item()</CODE>.
<LI>Terminate <CODE>curses</CODE>.
@@ -1304,8 +1340,8 @@ refreshed or erased at post/unpost time. The inner window or
By default, both windows are <CODE>stdscr</CODE>. You can set them with the
functions in <CODE>menu_win(3x)</CODE>. <P>
-When you call <CODE>menu_post()</CODE>, you write the menu to its
-subwindow. When you call <CODE>menu_unpost()</CODE>, you erase the
+When you call <CODE>post_menu()</CODE>, you write the menu to its
+subwindow. When you call <CODE>unpost_menu()</CODE>, you erase the
subwindow, However, neither of these actually modifies the screen. To
do that, call <CODE>wrefresh()</CODE> or some equivalent.
@@ -1437,10 +1473,10 @@ The general flow of control of a form program looks like this:
<LI>Initialize <CODE>curses</CODE>.
<LI>Create the form fields, using <CODE>new_field()</CODE>.
<LI>Create the form using <CODE>new_form()</CODE>.
-<LI>Post the form using <CODE>form_post()</CODE>.
+<LI>Post the form using <CODE>post_form()</CODE>.
<LI>Refresh the screen.
<LI>Process user requests via an input loop.
-<LI>Unpost the form using <CODE>form_unpost()</CODE>.
+<LI>Unpost the form using <CODE>unpost_form()</CODE>.
<LI>Free the form, using <CODE>free_form()</CODE>.
<LI>Free the fields using <CODE>free_field()</CODE>.
<LI>Terminate <CODE>curses</CODE>.
@@ -1476,7 +1512,7 @@ the screen (the third and fourth arguments, which must be zero or
greater). Note that these coordinates are relative to the form
subwindow, which will coincide with <CODE>stdscr</CODE> by default but
need not be <CODE>stdscr</CODE> if you've done an explicit
-<CODE>set_form_window()</CODE> call. <P>
+<CODE>set_form_win()</CODE> call. <P>
The fifth argument allows you to specify a number of off-screen rows. If
this is zero, the entire field will always be displayed. If it is
@@ -2156,7 +2192,7 @@ These requests treat the list as cyclic; that is, <CODE>REQ_NEXT_PAGE</CODE>
from the last page goes to the first, and <CODE>REQ_PREV_PAGE</CODE> from
the first page goes to the last.
-<H3><A NAME="#ffield">Inter-Field Navigation Requests</A></H3>
+<H3><A NAME="ffield">Inter-Field Navigation Requests</A></H3>
These requests handle navigation between fields on the same page.
@@ -2210,7 +2246,7 @@ of B and C to the right of B. A <CODE>REQ_MOVE_RIGHT</CODE> from A will
go to B only if A, B, and C <EM>all</EM> share the same first line;
otherwise it will skip over B to C.
-<H3><A NAME="#fifield">Intra-Field Navigation Requests</A></H3>
+<H3><A NAME="fifield">Intra-Field Navigation Requests</A></H3>
These requests drive movement of the edit cursor within the currently
selected field.
@@ -2515,13 +2551,13 @@ By default, all options are on. Here are the available option bits:
<DL>
<DT> O_NL_OVERLOAD
<DD> Enable overloading of <CODE>REQ_NEW_LINE</CODE> as described in <A
-NAME="fedit">Editing Requests</A>. The value of this option is
+href="#fedit">Editing Requests</A>. The value of this option is
ignored on dynamic fields that have not reached their size limit;
these have no last line, so the circumstances for triggering a
<CODE>REQ_NEXT_FIELD</CODE> never arise.
<DT> O_BS_OVERLOAD
<DD> Enable overloading of <CODE>REQ_DEL_PREV</CODE> as described in
-<A NAME="fedit">Editing Requests</A>.
+<A href="#fedit">Editing Requests</A>.
</DL>
The option values are bit-masks and can be composed with logical-or in
diff --git a/lib/libcurses/fifo_defs.h b/lib/libcurses/fifo_defs.h
index 8fd487fd33c..babc3c05ad7 100644
--- a/lib/libcurses/fifo_defs.h
+++ b/lib/libcurses/fifo_defs.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: fifo_defs.h,v 1.2 1998/07/23 21:18:17 millert Exp $ */
+/* $OpenBSD: fifo_defs.h,v 1.3 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -36,25 +36,25 @@
/*
* Common macros for lib_getch.c, lib_ungetch.c
*
- * $From: fifo_defs.h,v 1.2 1998/02/11 12:13:56 tom Exp $
+ * $Id: fifo_defs.h,v 1.3 2010/01/12 23:21:59 nicm Exp $
*/
#ifndef FIFO_DEFS_H
#define FIFO_DEFS_H 1
-#define head SP->_fifohead
-#define tail SP->_fifotail
+#define head sp->_fifohead
+#define tail sp->_fifotail
/* peek points to next uninterpreted character */
-#define peek SP->_fifopeek
+#define peek sp->_fifopeek
#define h_inc() { head == FIFO_SIZE-1 ? head = 0 : head++; if (head == tail) head = -1, tail = 0;}
-#define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;}
+#define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;}
#define t_inc() { tail == FIFO_SIZE-1 ? tail = 0 : tail++; if (tail == head) tail = -1;}
-#define t_dec() { tail == 0 ? tail = FIFO_SIZE-1 : tail--; if (head == tail) fifo_clear();}
+#define t_dec() { tail == 0 ? tail = FIFO_SIZE-1 : tail--; if (head == tail) fifo_clear(sp);}
#define p_inc() { peek == FIFO_SIZE-1 ? peek = 0 : peek++;}
-#define cooked_key_in_fifo() (head!=-1 && peek!=head)
-#define raw_key_in_fifo() (head!=-1 && peek!=tail)
+#define cooked_key_in_fifo() ((head != -1) && (peek != head))
+#define raw_key_in_fifo() ((head != -1) && (peek != tail))
#undef HIDE_EINTR
diff --git a/lib/libcurses/hashed_db.h b/lib/libcurses/hashed_db.h
new file mode 100644
index 00000000000..c8557e5c9c2
--- /dev/null
+++ b/lib/libcurses/hashed_db.h
@@ -0,0 +1,69 @@
+/* $OpenBSD: hashed_db.h,v 1.1 2010/01/12 23:21:59 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2006 *
+ ****************************************************************************/
+
+/*
+ * $Id: hashed_db.h,v 1.1 2010/01/12 23:21:59 nicm Exp $
+ */
+
+#ifndef HASHED_DB_H
+#define HASHED_DB_H 1
+
+#include <curses.h>
+
+#if USE_HASHED_DB
+
+#include <db.h>
+
+#ifndef DBN_SUFFIX
+#define DBM_SUFFIX ".db"
+#endif
+
+#ifdef DB_VERSION_MAJOR
+#define HASHED_DB_API DB_VERSION_MAJOR
+#else
+#define HASHED_DB_API 1 /* e.g., db 1.8.5 */
+#endif
+
+extern NCURSES_EXPORT(DB *) _nc_db_open(const char * /* path */, bool /* modify */);
+extern NCURSES_EXPORT(bool) _nc_db_have_data(DBT * /* key */, DBT * /* data */, char ** /* buffer */, int * /* size */);
+extern NCURSES_EXPORT(bool) _nc_db_have_index(DBT * /* key */, DBT * /* data */, char ** /* buffer */, int * /* size */);
+extern NCURSES_EXPORT(int) _nc_db_close(DB * /* db */);
+extern NCURSES_EXPORT(int) _nc_db_first(DB * /* db */, DBT * /* key */, DBT * /* data */);
+extern NCURSES_EXPORT(int) _nc_db_next(DB * /* db */, DBT * /* key */, DBT * /* data */);
+extern NCURSES_EXPORT(int) _nc_db_get(DB * /* db */, DBT * /* key */, DBT * /* data */);
+extern NCURSES_EXPORT(int) _nc_db_put(DB * /* db */, DBT * /* key */, DBT * /* data */);
+
+#endif
+
+#endif /* HASHED_DB_H */
diff --git a/lib/libcurses/hashsize.h b/lib/libcurses/hashsize.h
index b6992abc67f..3e9e040ba9c 100644
--- a/lib/libcurses/hashsize.h
+++ b/lib/libcurses/hashsize.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: hashsize.h,v 1.2 1999/01/18 19:07:24 millert Exp $ */
+/* $OpenBSD: hashsize.h,v 1.3 2010/01/12 23:21:59 nicm Exp $ */
/*
* hashsize.h -- hash and token table constants
*/
-#define CAPTABSIZE 497
-#define HASHTABSIZE ( 497 * 2)
+#define CAPTABSIZE 497
+#define HASHTABSIZE ( 497 * 2)
diff --git a/lib/libcurses/key_defined.3 b/lib/libcurses/key_defined.3
new file mode 100644
index 00000000000..1ca4ddac1a7
--- /dev/null
+++ b/lib/libcurses/key_defined.3
@@ -0,0 +1,62 @@
+.\" $OpenBSD: key_defined.3,v 1.1 2010/01/12 23:21:59 nicm Exp $
+.\"
+.\"***************************************************************************
+.\" Copyright (c) 2003-2004,2006 Free Software Foundation, Inc. *
+.\" *
+.\" Permission is hereby granted, free of charge, to any person obtaining a *
+.\" copy of this software and associated documentation files (the *
+.\" "Software"), to deal in the Software without restriction, including *
+.\" without limitation the rights to use, copy, modify, merge, publish, *
+.\" distribute, distribute with modifications, sublicense, and/or sell *
+.\" copies of the Software, and to permit persons to whom the Software is *
+.\" furnished to do so, subject to the following conditions: *
+.\" *
+.\" The above copyright notice and this permission notice shall be included *
+.\" in all copies or substantial portions of the Software. *
+.\" *
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+.\" *
+.\" Except as contained in this notice, the name(s) of the above copyright *
+.\" holders shall not be used in advertising or otherwise to promote the *
+.\" sale, use or other dealings in this Software without prior written *
+.\" authorization. *
+.\"***************************************************************************
+.\"
+.\" Author: Thomas E. Dickey 2003
+.\"
+.\" $Id: key_defined.3,v 1.1 2010/01/12 23:21:59 nicm Exp $
+.TH key_defined 3 ""
+.SH NAME
+\fBkey_defined\fP \- check if a keycode is defined
+.SH SYNOPSIS
+\fB#include <curses.h>\fP
+.sp
+\fBint key_defined(const char *definition);\fP
+.SH DESCRIPTION
+This is an extension to the curses library.
+It permits an application to determine if a string is currently bound
+to any keycode.
+.SH RETURN VALUE
+If the string is bound to a keycode, its value (greater than zero) is returned.
+If no keycode is bound, zero is returned.
+If the string conflicts with longer strings which are bound to keys, -1 is returned.
+.SH PORTABILITY
+These routines are specific to ncurses. They were not supported on
+Version 7, BSD or System V implementations. It is recommended that
+any code depending on them be conditioned using NCURSES_VERSION.
+.SH SEE ALSO
+\fBdefine_key\fR(3).
+.SH AUTHOR
+Thomas Dickey.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libcurses/keybound.3 b/lib/libcurses/keybound.3
index bad5d9e4486..bd586434234 100644
--- a/lib/libcurses/keybound.3
+++ b/lib/libcurses/keybound.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: keybound.3,v 1.2 2008/12/07 08:59:22 jmc Exp $
+.\" $OpenBSD: keybound.3,v 1.3 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1999 Free Software Foundation, Inc. *
+.\" Copyright (c) 1999-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,37 +28,34 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1999
+.\" Author: Thomas E. Dickey 1999
.\"
-.\" $From: keybound.3x,v 1.1 1999/02/19 11:59:24 tom Exp $
+.\" $Id: keybound.3,v 1.3 2010/01/12 23:21:59 nicm Exp $
.TH keybound 3 ""
.SH NAME
\fBkeybound\fP \- return definition of keycode
-..
.SH SYNOPSIS
\fB#include <curses.h>\fP
-
+.sp
\fBchar * keybound(int keycode, int count);\fP
-..
.SH DESCRIPTION
This is an extension to the curses library.
It permits an application to determine the string which is defined
in the terminfo for specific keycodes.
-..
.SH RETURN VALUE
-The keycode must be greater than zero, else NULL is returned.
+The \fIkeycode\fP parameter must be greater than zero, else NULL is returned.
If it does not correspond to a defined key, then NULL is returned.
-Otherwise, the function returns a string, which must be freed by the caller.
-..
+The \fIcount\fP parameter is used to allow the application to iterate
+through multiple definitions, counting from zero.
+When successful,
+the function returns a string which must be freed by the caller.
.SH PORTABILITY
These routines are specific to ncurses. They were not supported on
Version 7, BSD or System V implementations. It is recommended that
any code depending on them be conditioned using NCURSES_VERSION.
-..
.SH SEE ALSO
\fBdefine_key\fR(3),
\fBkeyok\fR(3).
-..
.SH AUTHOR
Thomas Dickey.
.\"#
diff --git a/lib/libcurses/keyok.3 b/lib/libcurses/keyok.3
index 9d44325a6dd..4168f9d246b 100644
--- a/lib/libcurses/keyok.3
+++ b/lib/libcurses/keyok.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: keyok.3,v 1.3 1998/09/13 19:16:27 millert Exp $
+.\" $OpenBSD: keyok.3,v 1.4 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,39 +28,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1997
+.\" Author: Thomas E. Dickey 1997
.\"
-.\" $From: keyok.3x,v 1.5 1998/03/14 23:43:07 tom Exp $
+.\" $Id: keyok.3,v 1.4 2010/01/12 23:21:59 nicm Exp $
.TH keyok 3 ""
.SH NAME
\fBkeyok\fP \- enable or disable a keycode
-..
.SH SYNOPSIS
\fB#include <curses.h>\fP
-
+.sp
\fBint keyok(int keycode, bool enable);\fP
-..
.SH DESCRIPTION
This is an extension to the curses library.
It permits an application to disable specific keycodes, rather than
use the \fIkeypad\fP function to disable all keycodes.
Keys that have been disabled can be reenabled.
-..
.SH RETURN VALUE
The keycode must be greater than zero, else ERR is returned.
If it does not correspond to a defined key, then ERR is returned.
If the \fIenable\fP parameter is true, then the key must have been disabled,
and vice versa.
Otherwise, the function returns OK.
-..
.SH PORTABILITY
These routines are specific to ncurses. They were not supported on
Version 7, BSD or System V implementations. It is recommended that
any code depending on them be conditioned using NCURSES_VERSION.
-..
.SH SEE ALSO
\fBdefine_key\fR(3).
-..
.SH AUTHOR
Thomas Dickey.
.\"#
diff --git a/lib/libcurses/nc_alloc.h b/lib/libcurses/nc_alloc.h
index 525a0850e0d..93a12b3cdf6 100644
--- a/lib/libcurses/nc_alloc.h
+++ b/lib/libcurses/nc_alloc.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: nc_alloc.h,v 1.6 2000/06/19 03:53:36 millert Exp $ */
+/* $OpenBSD: nc_alloc.h,v 1.7 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,14 +29,20 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ * Author: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $From: nc_alloc.h,v 1.8 2000/04/08 23:42:57 tom Exp $ */
+/* $Id: nc_alloc.h,v 1.7 2010/01/12 23:21:59 nicm Exp $ */
#ifndef NC_ALLOC_included
#define NC_ALLOC_included 1
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if HAVE_LIBDMALLOC
+#include <string.h>
+#undef strndup /* workaround for #define in GLIBC 2.7 */
#include <dmalloc.h> /* Gray Watson's library */
#else
#undef HAVE_LIBDMALLOC
@@ -50,6 +56,13 @@
#define HAVE_LIBDBMALLOC 0
#endif
+#if HAVE_LIBMPATROL
+#include <mpatrol.h> /* Memory-Patrol library */
+#else
+#undef HAVE_LIBMPATROL
+#define HAVE_LIBMPATROL 0
+#endif
+
#ifndef NO_LEAKS
#define NO_LEAKS 0
#endif
@@ -57,9 +70,12 @@
#if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
#define HAVE_NC_FREEALL 1
struct termtype;
-extern void _nc_free_and_exit(int) GCC_NORETURN;
-extern void _nc_free_tparm(void);
-extern void _nc_leaks_dump_entry(void);
+extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
+extern NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_NORETURN;
+extern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN;
+extern NCURSES_EXPORT(void) _nc_free_tparm(void);
+extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
+extern NCURSES_EXPORT(void) _nc_leaks_tic(void);
#define ExitProgram(code) _nc_free_and_exit(code)
#endif
@@ -68,18 +84,25 @@ extern void _nc_leaks_dump_entry(void);
#endif
#ifndef ExitProgram
-#define ExitProgram(code) return code
+#define ExitProgram(code) exit(code)
#endif
/* doalloc.c */
-extern void *_nc_doalloc(void *, size_t);
+extern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t);
#if !HAVE_STRDUP
#define strdup _nc_strdup
-extern char *_nc_strdup(const char *);
+extern NCURSES_EXPORT(char *) _nc_strdup(const char *);
#endif
+/* entries.c */
+extern NCURSES_EXPORT(void) _nc_leaks_tinfo(void);
+
#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type))
#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type))
#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type))
+#ifdef __cplusplus
+}
+#endif
+
#endif /* NC_ALLOC_included */
diff --git a/lib/libcurses/nc_panel.h b/lib/libcurses/nc_panel.h
index 107f555d5e4..83c4e3a8ece 100644
--- a/lib/libcurses/nc_panel.h
+++ b/lib/libcurses/nc_panel.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: nc_panel.h,v 1.3 2001/01/22 18:01:34 millert Exp $ */
+/* $OpenBSD: nc_panel.h,v 1.4 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,13 +29,13 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
- * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * Author: Juergen Pfeifer 1997 *
+ * and: Thomas E. Dickey *
****************************************************************************/
/*
- * $From: nc_panel.h,v 1.3 2000/12/10 02:04:35 tom Exp $
+ * $Id: nc_panel.h,v 1.4 2010/01/12 23:21:59 nicm Exp $
*
* nc_panel.h
*
@@ -56,6 +56,9 @@ struct panelhook {
struct panel* top_panel;
struct panel* bottom_panel;
struct panel* stdscr_pseudo_panel;
+#if NO_LEAKS
+ int (*destroy)(struct panel *);
+#endif
};
/* Retrieve the panelhook of the current screen */
diff --git a/lib/libcurses/nc_tparm.h b/lib/libcurses/nc_tparm.h
new file mode 100644
index 00000000000..0100cd76e03
--- /dev/null
+++ b/lib/libcurses/nc_tparm.h
@@ -0,0 +1,67 @@
+/* $OpenBSD: nc_tparm.h,v 1.1 2010/01/12 23:21:59 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2006 *
+ ****************************************************************************/
+
+/* $Id: nc_tparm.h,v 1.1 2010/01/12 23:21:59 nicm Exp $ */
+
+/*
+ * Cast parameters past the formatting-string for tparm() to match the
+ * assumption of the varargs code.
+ */
+#define TPARM_ARG long
+#define TPARM_N(n) (TPARM_ARG)(n)
+
+#define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j))
+
+#if NCURSES_TPARM_VARARGS
+#define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i))
+#define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h))
+#define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g))
+#define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f))
+#define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e))
+#define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d))
+#define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c))
+#define TPARM_1(a,b) tparm(a,TPARM_N(b))
+#define TPARM_0(a) tparm(a)
+#else
+#define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0)
+#define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0)
+#define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0)
+#define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0)
+#define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0)
+#define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0)
+#define TPARM_2(a,b,c) TPARM_3(a,b,c,0)
+#define TPARM_1(a,b) TPARM_2(a,b,0)
+#define TPARM_1(a,b) TPARM_2(a,b,0)
+#define TPARM_0(a) TPARM_1(a,0)
+#endif
diff --git a/lib/libcurses/ncurses_cfg.h b/lib/libcurses/ncurses_cfg.h
index 493f1fcb2c4..24a1212830b 100644
--- a/lib/libcurses/ncurses_cfg.h
+++ b/lib/libcurses/ncurses_cfg.h
@@ -1,6 +1,8 @@
+/* $OpenBSD: ncurses_cfg.h,v 1.24 2010/01/12 23:21:59 nicm Exp $ */
+
/* include/ncurses_cfg.h. Generated automatically by configure. */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,7 +33,7 @@
* Author: Thomas E. Dickey <dickey@clark.net> 1997 *
****************************************************************************/
/*
- * $From: ncurses_cfg.hin,v 1.3 2000/09/02 17:13:32 tom Exp $
+ * $Id: ncurses_cfg.h,v 1.24 2010/01/12 23:21:59 nicm Exp $
*
* This is a template-file used to generate the "ncurses_cfg.h" file.
*
@@ -40,16 +42,16 @@
* 971222) to autoconf 2.12 or 2.13 to do this.
*
* See:
- * http://dickey.his.com/autoconf/
- * ftp://dickey.his.com/autoconf/
+ * http://invisible-island.net/autoconf/
+ * ftp://invisible-island.net/autoconf/
*/
#ifndef NC_CONFIG_H
#define NC_CONFIG_H
#define BSD_TPUTS 1
-#define CC_HAS_INLINE_FUNCS 1
#define CC_HAS_PROTOS 1
-#define CPP_HAS_PARAM_INIT 1
+#define CPP_HAS_STATIC_CAST 1
+#define ETIP_NEEDS_MATH_H 1
#define GCC_NORETURN __attribute__((__noreturn__))
#define GCC_PRINTF 1
#define GCC_SCANF 1
@@ -61,22 +63,24 @@
#define HAVE_ERRNO 1
#define HAVE_FCNTL_H 1
#define HAVE_FORM_H 1
+#define HAVE_FSEEKO 1
#define HAVE_GETCWD 1
#define HAVE_GETEGID 1
#define HAVE_GETEUID 1
+#define HAVE_GETOPT_H 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_GETTTYNAM 1
#define HAVE_HAS_KEY 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_IOSTREAM 1
#define HAVE_ISASCII 1
#define HAVE_ISSETUGID 1
-/* #define HAVE_LIBFORM 1 */
-/* #define HAVE_LIBMENU 1 */
-/* #define HAVE_LIBPANEL 1 */
+#define HAVE_LANGINFO_CODESET 1
#define HAVE_LIMITS_H 1
#define HAVE_LINK 1
#define HAVE_LOCALE_H 1
#define HAVE_LONG_FILE_NAMES 1
-#define HAVE_MEMCCPY 1
+#define HAVE_MEMORY_H 1
#define HAVE_MENU_H 1
#define HAVE_MKSTEMP 1
#define HAVE_NANOSLEEP 1
@@ -86,7 +90,9 @@
#define HAVE_POLL_H 1
#define HAVE_REGEX_H_FUNCS 1
#define HAVE_REMOVE 1
+#define HAVE_REMOVE 1
#define HAVE_RESIZETERM 1
+#define HAVE_RESIZE_TERM 1
#define HAVE_SELECT 1
#define HAVE_SETBUF 1
#define HAVE_SETBUFFER 1
@@ -94,16 +100,23 @@
#define HAVE_SIGACTION 1
#define HAVE_SIGVEC 1
#define HAVE_SIZECHANGE 1
+#define HAVE_SLK_COLOR 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
#define HAVE_STRDUP 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
#define HAVE_STRSTR 1
#define HAVE_SYMLINK 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIMES_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIME_SELECT 1
+#define HAVE_SYS_TYPES_H 1
#define HAVE_TCGETATTR 1
#define HAVE_TCGETPGRP 1
#define HAVE_TERMIOS_H 1
@@ -111,28 +124,44 @@
#define HAVE_TTYENT_H 1
#define HAVE_TYPEINFO 1
#define HAVE_UNISTD_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_UNISTD_H 1
#define HAVE_UNLINK 1
#define HAVE_USE_DEFAULT_COLORS 1
#define HAVE_VSNPRINTF 1
#define HAVE_VSSCANF 1
+#define HAVE_WCTYPE_H 1
#define HAVE_WORKING_POLL 1
#define HAVE_WRESIZE 1
+#define IOSTREAM_NAMESPACE 1
#define MIXEDCASE_FILENAMES 1
#define NCURSES_EXT_FUNCS 1
#define NCURSES_NO_PADDING 1
#define NCURSES_PATHSEP ':'
+#define NCURSES_VERSION_STRING "5.7.20081102"
#define NDEBUG 1
+#define PURE_TERMINFO 0
#define RETSIGTYPE void
+#define SIG_ATOMIC_T volatile sig_atomic_t
+#define SIZEOF_SIGNED_CHAR 1
#define STDC_HEADERS 1
-#define SYSTEM_NAME "openbsd2.8"
+#define SYSTEM_NAME "openbsd"
#define TERMINFO "/usr/share/terminfo"
#define TERMINFO_DIRS "/usr/share/terminfo"
+#define TIME_WITH_SYS_TIME 1
#define TYPEOF_CHTYPE long
#define USE_ASSUMED_COLOR 1
#define USE_DATABASE 1
-#define USE_GETCAP 1
+#define USE_GETCAP 1
#define USE_HASHMAP 1
+#define USE_HOME_TERMINFO 1
+#define USE_LINKS 1
+#define USE_OPENPTY_HEADER <util.h>
#define USE_ROOT_ENVIRON 1
+#define USE_XTERM_PTY 1
+/* #define HAVE_LIBFORM 1 */
+/* #define HAVE_LIBMENU 1 */
+/* #define HAVE_LIBPANEL 1 */
/* #define USE_SIGWINCH 1 */
#include <ncurses_def.h>
@@ -148,4 +177,14 @@
#endif
#endif
+ /* On HP-UX, the C compiler doesn't grok mbstate_t without
+ -D_XOPEN_SOURCE=500. However, this causes problems on
+ IRIX. So, we #define mbstate_t to int in configure.in
+ only for the C compiler if needed. */
+#ifndef __cplusplus
+#ifdef NEED_MBSTATE_T_DEF
+#define mbstate_t int
+#endif
+#endif
+
#endif /* NC_CONFIG_H */
diff --git a/lib/libcurses/ncurses_def.h b/lib/libcurses/ncurses_def.h
index 0be36557211..87ff0cc7393 100644
--- a/lib/libcurses/ncurses_def.h
+++ b/lib/libcurses/ncurses_def.h
@@ -1,3 +1,5 @@
+/* $OpenBSD: ncurses_def.h,v 1.2 2010/01/12 23:21:59 nicm Exp $ */
+
/*
* This file is generated by ./MKncurses_def.sh
*/
@@ -13,10 +15,6 @@
#define BSD_TPUTS 0
#endif
-#ifndef CC_HAS_INLINE_FUNCS
-#define CC_HAS_INLINE_FUNCS 0
-#endif
-
#ifndef CC_HAS_PROTOS
#define CC_HAS_PROTOS 0
#endif
@@ -25,6 +23,14 @@
#define CPP_HAS_PARAM_INIT 0
#endif
+#ifndef CURSES_ACS_ARRAY
+#define CURSES_ACS_ARRAY acs_map
+#endif
+
+#ifndef CURSES_WACS_ARRAY
+#define CURSES_WACS_ARRAY _nc_wacs
+#endif
+
#ifndef DECL_ERRNO
#define DECL_ERRNO 0
#endif
@@ -49,10 +55,26 @@
#define HAVE_BSD_CGETENT 0
#endif
+#ifndef HAVE_BSD_SIGNAL_H
+#define HAVE_BSD_SIGNAL_H 0
+#endif
+
+#ifndef HAVE_BTOWC
+#define HAVE_BTOWC 0
+#endif
+
#ifndef HAVE_BUILTIN_H
#define HAVE_BUILTIN_H 0
#endif
+#ifndef HAVE_CHGAT
+#define HAVE_CHGAT 1
+#endif
+
+#ifndef HAVE_COLOR_SET
+#define HAVE_COLOR_SET 1
+#endif
+
#ifndef HAVE_DIRENT_H
#define HAVE_DIRENT_H 0
#endif
@@ -65,10 +87,22 @@
#define HAVE_FCNTL_H 0
#endif
+#ifndef HAVE_FILTER
+#define HAVE_FILTER 1
+#endif
+
#ifndef HAVE_FORM_H
#define HAVE_FORM_H 0
#endif
+#ifndef HAVE_GETBEGX
+#define HAVE_GETBEGX 1
+#endif
+
+#ifndef HAVE_GETCURX
+#define HAVE_GETCURX 1
+#endif
+
#ifndef HAVE_GETCWD
#define HAVE_GETCWD 0
#endif
@@ -81,10 +115,22 @@
#define HAVE_GETEUID 0
#endif
+#ifndef HAVE_GETMAXX
+#define HAVE_GETMAXX 1
+#endif
+
+#ifndef HAVE_GETNSTR
+#define HAVE_GETNSTR 0
+#endif
+
#ifndef HAVE_GETOPT_H
#define HAVE_GETOPT_H 0
#endif
+#ifndef HAVE_GETPARX
+#define HAVE_GETPARX 1
+#endif
+
#ifndef HAVE_GETTIMEOFDAY
#define HAVE_GETTIMEOFDAY 0
#endif
@@ -93,6 +139,14 @@
#define HAVE_GETTTYNAM 0
#endif
+#ifndef HAVE_GETWIN
+#define HAVE_GETWIN 1
+#endif
+
+#ifndef HAVE_GPM_H
+#define HAVE_GPM_H 0
+#endif
+
#ifndef HAVE_GPP_BUILTIN_H
#define HAVE_GPP_BUILTIN_H 0
#endif
@@ -105,6 +159,10 @@
#define HAVE_HAS_KEY 0
#endif
+#ifndef HAVE_IOSTREAM
+#define HAVE_IOSTREAM 0
+#endif
+
#ifndef HAVE_ISASCII
#define HAVE_ISASCII 0
#endif
@@ -113,6 +171,14 @@
#define HAVE_ISSETUGID 0
#endif
+#ifndef HAVE_LANGINFO_CODESET
+#define HAVE_LANGINFO_CODESET 0
+#endif
+
+#ifndef HAVE_LIBC_H
+#define HAVE_LIBC_H 0
+#endif
+
#ifndef HAVE_LIBDBMALLOC
#define HAVE_LIBDBMALLOC 0
#endif
@@ -133,6 +199,10 @@
#define HAVE_LIBMENU 0
#endif
+#ifndef HAVE_LIBMPATROL
+#define HAVE_LIBMPATROL 0
+#endif
+
#ifndef HAVE_LIBPANEL
#define HAVE_LIBPANEL 0
#endif
@@ -153,8 +223,28 @@
#define HAVE_LONG_FILE_NAMES 0
#endif
-#ifndef HAVE_MEMCCPY
-#define HAVE_MEMCCPY 0
+#ifndef HAVE_MBLEN
+#define HAVE_MBLEN 0
+#endif
+
+#ifndef HAVE_MBRLEN
+#define HAVE_MBRLEN 0
+#endif
+
+#ifndef HAVE_MBRTOWC
+#define HAVE_MBRTOWC 0
+#endif
+
+#ifndef HAVE_MBSRTOWCS
+#define HAVE_MBSRTOWCS 0
+#endif
+
+#ifndef HAVE_MBSTOWCS
+#define HAVE_MBSTOWCS 0
+#endif
+
+#ifndef HAVE_MBTOWC
+#define HAVE_MBTOWC 0
#endif
#ifndef HAVE_MENU_H
@@ -165,6 +255,14 @@
#define HAVE_MKSTEMP 0
#endif
+#ifndef HAVE_MVVLINE
+#define HAVE_MVVLINE 1
+#endif
+
+#ifndef HAVE_MVWVLINE
+#define HAVE_MVWVLINE 1
+#endif
+
#ifndef HAVE_NANOSLEEP
#define HAVE_NANOSLEEP 0
#endif
@@ -185,6 +283,18 @@
#define HAVE_POLL_H 0
#endif
+#ifndef HAVE_PURIFY
+#define HAVE_PURIFY 0
+#endif
+
+#ifndef HAVE_PUTWC
+#define HAVE_PUTWC 0
+#endif
+
+#ifndef HAVE_PUTWIN
+#define HAVE_PUTWIN 1
+#endif
+
#ifndef HAVE_REGEXPR_H_FUNCS
#define HAVE_REGEXPR_H_FUNCS 0
#endif
@@ -205,6 +315,14 @@
#define HAVE_RESIZETERM 0
#endif
+#ifndef HAVE_RESIZE_TERM
+#define HAVE_RESIZE_TERM 0
+#endif
+
+#ifndef HAVE_RIPOFFLINE
+#define HAVE_RIPOFFLINE 1
+#endif
+
#ifndef HAVE_SELECT
#define HAVE_SELECT 0
#endif
@@ -217,6 +335,10 @@
#define HAVE_SETBUFFER 0
#endif
+#ifndef HAVE_SETUPTERM
+#define HAVE_SETUPTERM 1
+#endif
+
#ifndef HAVE_SETVBUF
#define HAVE_SETVBUF 0
#endif
@@ -233,6 +355,14 @@
#define HAVE_SIZECHANGE 0
#endif
+#ifndef HAVE_SLK_COLOR
+#define HAVE_SLK_COLOR 0
+#endif
+
+#ifndef HAVE_SLK_INIT
+#define HAVE_SLK_INIT 1
+#endif
+
#ifndef HAVE_STRDUP
#define HAVE_STRDUP 0
#endif
@@ -293,6 +423,10 @@
#define HAVE_TELL 0
#endif
+#ifndef HAVE_TERMATTRS
+#define HAVE_TERMATTRS 1
+#endif
+
#ifndef HAVE_TERMIOS_H
#define HAVE_TERMIOS_H 0
#endif
@@ -301,6 +435,26 @@
#define HAVE_TERMIO_H 0
#endif
+#ifndef HAVE_TERMNAME
+#define HAVE_TERMNAME 1
+#endif
+
+#ifndef HAVE_TERM_H
+#define HAVE_TERM_H 1
+#endif
+
+#ifndef HAVE_TGETENT
+#define HAVE_TGETENT 1
+#endif
+
+#ifndef HAVE_TIGETNUM
+#define HAVE_TIGETNUM 1
+#endif
+
+#ifndef HAVE_TIGETSTR
+#define HAVE_TIGETSTR 1
+#endif
+
#ifndef HAVE_TIMES
#define HAVE_TIMES 0
#endif
@@ -309,10 +463,18 @@
#define HAVE_TTYENT_H 0
#endif
+#ifndef HAVE_TYPEAHEAD
+#define HAVE_TYPEAHEAD 1
+#endif
+
#ifndef HAVE_TYPEINFO
#define HAVE_TYPEINFO 0
#endif
+#ifndef HAVE_TYPE_ATTR_T
+#define HAVE_TYPE_ATTR_T 0
+#endif
+
#ifndef HAVE_TYPE_SIGACTION
#define HAVE_TYPE_SIGACTION 0
#endif
@@ -341,6 +503,30 @@
#define HAVE_VSSCANF 0
#endif
+#ifndef HAVE_WCSRTOMBS
+#define HAVE_WCSRTOMBS 0
+#endif
+
+#ifndef HAVE_WCSTOMBS
+#define HAVE_WCSTOMBS 0
+#endif
+
+#ifndef HAVE_WCTOB
+#define HAVE_WCTOB 0
+#endif
+
+#ifndef HAVE_WCTOMB
+#define HAVE_WCTOMB 0
+#endif
+
+#ifndef HAVE_WCTYPE_H
+#define HAVE_WCTYPE_H 0
+#endif
+
+#ifndef HAVE_WINSSTR
+#define HAVE_WINSSTR 1
+#endif
+
#ifndef HAVE_WORKING_POLL
#define HAVE_WORKING_POLL 0
#endif
@@ -349,26 +535,38 @@
#define HAVE_WRESIZE 0
#endif
+#ifndef HAVE__DOSCAN
+#define HAVE__DOSCAN 0
+#endif
+
#ifndef MIXEDCASE_FILENAMES
#define MIXEDCASE_FILENAMES 0
#endif
+#ifndef NCURSES_CHAR_EQ
+#define NCURSES_CHAR_EQ 0
+#endif
+
#ifndef NCURSES_EXPANDED
#define NCURSES_EXPANDED 0
#endif
-#ifndef NCURSES_EXT_FUNCS
-#define NCURSES_EXT_FUNCS 0
+#ifndef NCURSES_EXT_COLORS
+#define NCURSES_EXT_COLORS 0
#endif
-#ifndef NCURSES_NOMACROS
-#define NCURSES_NOMACROS 0
+#ifndef NCURSES_EXT_FUNCS
+#define NCURSES_EXT_FUNCS 0
#endif
#ifndef NCURSES_NO_PADDING
#define NCURSES_NO_PADDING 0
#endif
+#ifndef NCURSES_PATHSEP
+#define NCURSES_PATHSEP ':'
+#endif
+
#ifndef NDEBUG
#define NDEBUG 0
#endif
@@ -409,6 +607,14 @@
#define TERMINFO "none"
#endif
+#ifndef TERMPATH
+#define TERMPATH "none"
+#endif
+
+#ifndef TIME_WITH_SYS_TIME
+#define TIME_WITH_SYS_TIME 0
+#endif
+
#ifndef TYPEOF_CHTYPE
#define TYPEOF_CHTYPE 0
#endif
@@ -433,10 +639,18 @@
#define USE_HARD_TABS 0
#endif
+#ifndef USE_HASHED_DB
+#define USE_HASHED_DB 0
+#endif
+
#ifndef USE_HASHMAP
#define USE_HASHMAP 0
#endif
+#ifndef USE_HOME_TERMINFO
+#define USE_HOME_TERMINFO 0
+#endif
+
#ifndef USE_LINKS
#define USE_LINKS 0
#endif
@@ -453,6 +667,10 @@
#define USE_RCS_IDS 0
#endif
+#ifndef USE_REENTRANT
+#define USE_REENTRANT 0
+#endif
+
#ifndef USE_SAFE_SPRINTF
#define USE_SAFE_SPRINTF 0
#endif
@@ -469,6 +687,18 @@
#define USE_SYMLINKS 0
#endif
+#ifndef USE_SYSMOUSE
+#define USE_SYSMOUSE 0
+#endif
+
+#ifndef USE_TERMCAP
+#define USE_TERMCAP 0
+#endif
+
+#ifndef USE_WEAK_SYMBOLS
+#define USE_WEAK_SYMBOLS 0
+#endif
+
#ifndef USE_WIDEC_SUPPORT
#define USE_WIDEC_SUPPORT 0
#endif
diff --git a/lib/libcurses/parametrized.h b/lib/libcurses/parametrized.h
index fefc00c0406..9d40a537a1b 100644
--- a/lib/libcurses/parametrized.h
+++ b/lib/libcurses/parametrized.h
@@ -1,9 +1,9 @@
-/* $OpenBSD: parametrized.h,v 1.2 1999/01/18 19:09:04 millert Exp $ */
+/* $OpenBSD: parametrized.h,v 1.3 2010/01/12 23:21:59 nicm Exp $ */
/*
* parametrized.h --- is a termcap capability parametrized?
*
- * Note: this file is generated using parametrized.sh, do not edit by hand.
+ * Note: this file is generated using MKparametrized.sh, do not edit by hand.
* A value of -1 in the table means suppress both pad and % translations.
* A value of 0 in the table means do pad but not % translations.
* A value of 1 in the table means do both pad and % translations.
@@ -25,7 +25,7 @@ static short const parametrized[] = {
0, /* home */
0, /* civis */
0, /* cub1 */
-0, /* mrcup */
+1, /* mrcup */
0, /* cnorm */
0, /* cuf1 */
0, /* ll */
@@ -145,7 +145,7 @@ static short const parametrized[] = {
0, /* hts */
1, /* wind */
0, /* ht */
-0, /* tsl */
+1, /* tsl */
0, /* uc */
0, /* hu */
0, /* iprog */
@@ -285,7 +285,7 @@ static short const parametrized[] = {
0, /* smgr */
0, /* fln */
1, /* sclk */
-1, /* dclk */
+0, /* dclk */
0, /* rmclk */
1, /* cwin */
1, /* wingo */
@@ -314,11 +314,11 @@ static short const parametrized[] = {
1, /* scp */
1, /* setf */
1, /* setb */
-0, /* cpi */
-0, /* lpi */
-0, /* chr */
-0, /* cvr */
-0, /* defc */
+1, /* cpi */
+1, /* lpi */
+1, /* chr */
+1, /* cvr */
+1, /* defc */
0, /* swidm */
0, /* sdrfq */
0, /* sitm */
@@ -342,14 +342,14 @@ static short const parametrized[] = {
0, /* mcud1 */
0, /* mcub1 */
0, /* mcuf1 */
-0, /* mvpa */
+1, /* mvpa */
0, /* mcuu1 */
0, /* porder */
0, /* mcud */
0, /* mcub */
0, /* mcuf */
0, /* mcuu */
-0, /* scs */
+1, /* scs */
0, /* smgb */
1, /* smgbp */
1, /* smglp */
@@ -357,20 +357,20 @@ static short const parametrized[] = {
0, /* smgt */
1, /* smgtp */
0, /* sbim */
-0, /* scsd */
+1, /* scsd */
0, /* rbim */
-0, /* rcsd */
+1, /* rcsd */
0, /* subcs */
0, /* supcs */
0, /* docr */
0, /* zerom */
-0, /* csnm */
+1, /* csnm */
0, /* kmous */
0, /* minfo */
0, /* reqmp */
-0, /* getm */
-0, /* setaf */
-0, /* setab */
+1, /* getm */
+1, /* setaf */
+1, /* setab */
1, /* pfxl */
0, /* devt */
0, /* csin */
@@ -388,7 +388,7 @@ static short const parametrized[] = {
0, /* endbi */
1, /* setcolor */
1, /* slines */
-0, /* dispc */
+1, /* dispc */
0, /* smpch */
0, /* rmpch */
0, /* smsc */
@@ -553,61 +553,10 @@ static short const parametrized[] = {
0, /* ksf10 */
0, /* kf11 */
0, /* kf12 */
-0, /* kf13 */
-0, /* kf14 */
-0, /* kf15 */
-0, /* kf16 */
-0, /* kf17 */
-0, /* kf18 */
-0, /* kf19 */
-0, /* kf20 */
-0, /* kf21 */
-0, /* kf22 */
-0, /* kf23 */
-0, /* kf24 */
-0, /* kf25 */
-0, /* kf26 */
-0, /* kf26 */
-0, /* kf28 */
-0, /* kf29 */
-0, /* kf30 */
-0, /* kf31 */
-0, /* kf31 */
-0, /* kf33 */
-0, /* kf34 */
-0, /* kf35 */
-0, /* kf36 */
-0, /* kf37 */
-0, /* kf38 */
-0, /* kf39 */
-0, /* kf40 */
-0, /* kf41 */
-0, /* kf42 */
-0, /* kf43 */
-0, /* kf44 */
-0, /* kf45 */
-0, /* kf46 */
-0, /* kf47 */
-0, /* kf48 */
-0, /* kf49 */
-0, /* kf50 */
-0, /* kf51 */
-0, /* kf52 */
-0, /* kf53 */
-0, /* kf54 */
-0, /* kf55 */
-0, /* kf56 */
-0, /* kf57 */
-0, /* kf58 */
-0, /* kf59 */
-0, /* kf60 */
-0, /* kf61 */
-0, /* kf62 */
-0, /* kf63 */
0, /* kact */
0, /* topl */
0, /* btml */
0, /* rvert */
0, /* lvert */
-} /* 599 entries */;
+} /* 548 entries */;
diff --git a/lib/libcurses/resizeterm.3 b/lib/libcurses/resizeterm.3
index 5b472cd6928..7b500cc8695 100644
--- a/lib/libcurses/resizeterm.3
+++ b/lib/libcurses/resizeterm.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: resizeterm.3,v 1.4 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: resizeterm.3,v 1.5 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,57 +28,70 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
+.\" Author: Thomas E. Dickey 1996-2005
.\"
-.\" $From: resizeterm.3x,v 1.7 1998/03/14 23:42:52 tom Exp $
+.\" $Id: resizeterm.3,v 1.5 2010/01/12 23:21:59 nicm Exp $
.TH resizeterm 3 ""
.SH NAME
+\fBis_term_resized\fR,
+\fBresize_term\fR,
\fBresizeterm\fR - change the curses terminal size
-..
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
+\fBbool is_term_resized(int lines, int columns);\fR
+.br
+\fBint resize_term(int lines, int columns);\fR
+.br
\fBint resizeterm(int lines, int columns);\fR
-..
.SH DESCRIPTION
This is an extension to the curses library.
-It provides callers with a hook into the \fBcurses\fR data to resize windows,
+It provides callers with a hook into the \fBncurses\fR data to resize windows,
primarily for use by programs running in an X Window terminal (e.g., xterm).
The function \fBresizeterm\fR resizes the standard and current windows
to the specified dimensions, and adjusts other bookkeeping data used by
-the \fBcurses\fR library that record the window dimensions.
-
-When resizing the windows, the function blank-fills the areas that are
-extended. The calling application should fill in these areas with
-appropriate data.
-
-The function attempts to resize all windows.
+the \fBncurses\fR library that record the window dimensions.
+.LP
+Most of the work is done by the inner function \fBresize_term\fR.
+The outer function \fBresizeterm\fR adds bookkeeping for the SIGWINCH handler.
+When resizing the windows,
+\fBresize_term\fR blank-fills the areas that are extended.
+The calling application should fill in these areas with appropriate data.
+The \fBresize_term\fR function attempts to resize all windows.
However, due to the calling convention of pads,
it is not possible to resize these
without additional interaction with the application.
-..
+.LP
+A support function \fBis_term_resized\fR is provided so that applications
+can check if the \fBresize_term\fR function would modify the window structures.
+It returns TRUE if the windows would be modified, and FALSE otherwise.
.SH RETURN VALUE
-The function returns the integer \fBERR\fR upon failure and \fBOK\fR on success.
-It will fail if either of the dimensions less than or equal to zero,
+Except as notes, these function return
+the integer \fBERR\fR upon failure and \fBOK\fR on success.
+They will fail if either of the dimensions are less than or equal to zero,
or if an error occurs while (re)allocating memory for the windows.
-..
.SH NOTES
-While this function is intended to be used to support a signal handler
-(i.e., for SIGWINCH), care should be taken to avoid invoking it in a
+While these functions are intended to be used to support a signal handler
+(i.e., for SIGWINCH), care should be taken to avoid invoking them in a
context where \fBmalloc\fR or \fBrealloc\fR may have been interrupted,
since it uses those functions.
-..
.PP
-If curses is configured to supply its own SIGWINCH handler,
+If ncurses is configured to supply its own SIGWINCH handler,
the \fBresizeterm\fR function ungetch's a \fBKEY_RESIZE\fR which
will be read on the next call to \fBgetch\fR.
This is used to alert an application that the screen size has changed,
and that it should repaint special features such as pads that cannot
be done automatically.
-..
+.PP
+If the environment variables \fBLINES\fP or \fBCOLUMNS\fP are set,
+this overrides the library's use of the window size obtained from
+the operating system.
+Thus, even if a SIGWINCH is received,
+no screen size change may be recorded.
+In that case, no \fBKEY_RESIZE\fP is queued for the next call to \fBgetch\fP;
+an \fBERR\fP will be returned instead.
.SH SEE ALSO
\fBwresize\fR(3).
-..
.SH AUTHOR
Thomas Dickey (from an equivalent function written in 1988 for BSD curses).
.\"#
diff --git a/lib/libcurses/shlib_version b/lib/libcurses/shlib_version
index c10074d52ae..f461c533903 100644
--- a/lib/libcurses/shlib_version
+++ b/lib/libcurses/shlib_version
@@ -1,2 +1,2 @@
-major=10
+major=11
minor=0
diff --git a/lib/libcurses/term.5tbl b/lib/libcurses/term.5tbl
index ebc5a1fef50..cebb5f4b891 100644
--- a/lib/libcurses/term.5tbl
+++ b/lib/libcurses/term.5tbl
@@ -1,5 +1,5 @@
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -26,24 +26,22 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: term.5,v 1.10 2000/08/13 01:56:45 tom Exp $
-.\" $OpenBSD: term.5tbl,v 1.5 2004/11/04 15:36:47 otto Exp $
-.TH TERM 5
+.\" $Id: term.5tbl,v 1.6 2010/01/12 23:21:59 nicm Exp $
+.TH term 5
.ds n 5
-.ds d /usr/share/terminfo
+.ds d /usr/share/misc/terminfo
.SH NAME
term \- format of compiled term file.
.SH SYNOPSIS
.B term
.SH DESCRIPTION
-.PP
-NOTE: OpenBSD uses a Berkeley DB-style terminfo database instead
-of the SVR4 method of one description per file described below.
-.PP
+.SS STORAGE LOCATION
Compiled terminfo descriptions are placed under the directory \fB\*d\fP.
-In order to avoid a linear search of a huge \s-1UNIX\s+1 system directory, a
-two-level scheme is used: \fB\*b/c/name\fP
-where
+Two configurations are supported (when building the ncurses libraries):
+.TP 5
+.B directory tree
+A two-level scheme is used to avoid a linear search
+of a huge \s-1UNIX\s+1 system directory: \fB\*d/c/name\fP where
.I name
is the name of the terminal, and
.I c
@@ -54,7 +52,23 @@ Thus,
can be found in the file \fB\*d/a/act4\fP.
Synonyms for the same terminal are implemented by multiple
links to the same compiled file.
-.PP
+.TP 5
+.B hashed database
+Using Berkeley database, two types of records are stored:
+the terminfo data in the same format as stored in a directory tree with
+the terminfo's primary name as a key,
+and records containing only aliases pointing to the primary name.
+.IP
+If built to write hashed databases,
+ncurses can still read terminfo databases organized as a directory tree,
+but cannot write entries into the directory tree.
+It can write (or rewrite) entries in the hashed database.
+.IP
+ncurses distinguishes the two cases in the TERMINFO and TERMINFO_DIRS
+environment variable by assuming a directory tree for entries that
+correspond to an existing directory,
+and hashed database otherwise.
+.SS STORAGE FORMAT
The format has been chosen so that it will be the same on all hardware.
An 8 or more bit byte is assumed, but no assumptions about byte ordering
or sign extension are made.
@@ -76,18 +90,26 @@ The header section begins the file.
This section contains six short integers in the format
described below.
These integers are
+.RS 5
+.TP 5
(1) the magic number (octal 0432);
+.TP 5
(2) the size, in bytes, of the names section;
+.TP 5
(3) the number of bytes in the boolean section;
+.TP 5
(4) the number of short integers in the numbers section;
+.TP 5
(5) the number of offsets (short integers) in the strings section;
+.TP 5
(6) the size, in bytes, of the string table.
+.RE
.PP
Short integers are stored in two 8-bit bytes.
The first byte contains the least significant 8 bits of the value,
and the second byte contains the most significant 8 bits.
(Thus, the value represented is 256*second+first.)
-The value \-1 is represented by the two bytes 0377, 0377; other negative
+The value -1 is represented by the two bytes 0377, 0377; other negative
values are illegal. This value generally
means that the corresponding capability is missing from this terminal.
Note that this format corresponds to the hardware of the \s-1VAX\s+1
@@ -116,11 +138,11 @@ All short integers are aligned on a short word boundary.
The numbers section is similar to the flags section.
Each capability takes up two bytes,
and is stored as a little-endian short integer.
-If the value represented is \-1, the capability is taken to be missing.
+If the value represented is -1, the capability is taken to be missing.
.PP
The strings section is also similar.
Each capability is stored as a short integer, in the format above.
-A value of \-1 means the capability is missing.
+A value of -1 means the capability is missing.
Otherwise, the value is taken as an offset from the beginning
of the string table.
Special characters in ^X or \ec notation are stored in their
@@ -132,7 +154,48 @@ The final section is the string table.
It contains all the values of string capabilities referenced in
the string section.
Each string is null terminated.
+.SS EXTENDED STORAGE FORMAT
+The previous section describes the conventional terminfo binary format.
+With some minor variations of the offsets (see PORTABILITY),
+the same binary format is used in all modern UNIX systems.
+Each system uses a predefined set of boolean, number or string capabilities.
+.PP
+The ncurses libraries and applications support extended terminfo binary format,
+allowing users to define capabilities which are loaded at runtime. This
+extension is made possible by using the fact that the other implementations
+stop reading the terminfo data when they have reached the end of the size given
+in the header.
+ncurses checks the size, and if it exceeds that due to the predefined data,
+continues to parse according to its own scheme.
+.PP
+First, it reads the extended header (5 short integers):
+.RS 5
+.TP 5
+(1)
+count of extended boolean capabilities
+.TP 5
+(2)
+count of extended numeric capabilities
+.TP 5
+(3)
+count of extended string capabilities
+.TP 5
+(4)
+size of the extended string table in bytes.
+.TP 5
+(5)
+last offset of the extended string table in bytes.
+.RE
.PP
+Using the counts and sizes, ncurses allocates arrays and reads data
+for the extended capabilties in the same order as the header information.
+.PP
+The extended string table contains values for string capabilities.
+After the end of these values, it contains the names for each of
+the extended capabilities in order, e.g., booleans, then numbers and
+finally strings.
+.
+.SH PORTABILITY
Note that it is possible for
.I setupterm
to expect a different set of capabilities
@@ -159,7 +222,7 @@ diverged from System V terminfo after SVr1, and have added extension
capabilities to the string table that (in the binary format) collide with
System V and XSI Curses extensions. See \fBterminfo\fR(\*n) for detailed
discussion of terminfo source compatibility issues.
-.PP
+.SH EXAMPLE
As an example, here is a hex dump of the description for the Lear-Siegler
ADM-3, a popular though rather stupid early terminal:
.nf
@@ -168,7 +231,7 @@ adm3a|lsi adm3a,
am,
cols#80, lines#24,
bel=^G, clear=\032$<1>, cr=^M, cub1=^H, cud1=^J,
- cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
+ cuf1=^L, cup=\\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
home=^^, ind=^J,
.sp
.ft CW
@@ -197,13 +260,21 @@ adm3a|lsi adm3a,
.ft R
.fi
.sp
-.PP
+.SH LIMITS
Some limitations: total compiled entries cannot exceed 4096 bytes.
The name field cannot exceed 128 bytes.
.SH FILES
-\*d/?/* compiled terminal capability data base
-.SH "SEE ALSO"
+\*d/?/* compiled terminal capability database
+.SH SEE ALSO
\fBcurses\fR(3), \fBterminfo\fR(\*n).
+.SH AUTHORS
+Thomas E. Dickey
+.br
+extended terminfo format for ncurses 5.0
+.br
+hashed database support for ncurses 5.6
+.sp
+Eric S. Raymond
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/term.7 b/lib/libcurses/term.7
index e30a1e67df6..cbe38e6d734 100644
--- a/lib/libcurses/term.7
+++ b/lib/libcurses/term.7
@@ -1,7 +1,7 @@
-.\" $OpenBSD: term.7,v 1.7 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: term.7,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,11 +28,10 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: term.7,v 1.12 2000/08/13 01:56:42 tom Exp $
-.\" $OpenBSD: term.7,v 1.7 2003/05/14 08:55:19 jmc Exp $
-.TH TERM 7
+.\" $Id: term.7,v 1.8 2010/01/12 23:21:59 nicm Exp $
+.TH term 7
.ds n 5
-.ds d /usr/share/terminfo
+.ds d /usr/share/misc/terminfo
.SH NAME
term \- conventions for naming terminal types
.SH DESCRIPTION
@@ -68,16 +67,16 @@ which you wish to override the system default type for your line.
.PP
Terminal type descriptions are stored as files of capability data underneath
\*d. To browse a list of all terminal names recognized by the system, do
-
+.sp
toe | more
-
+.sp
from your shell. These capability files are in a binary format optimized for
retrieval speed (unlike the old text-based \fBtermcap\fR format they replace);
-to examine an entry, you must use the \fBinfocmp\fR(1) command. Invoke it as
-follows:
-
+to examine an entry, you must use the \fBinfocmp\fR(1) command.
+Invoke it as follows:
+.sp
infocmp \fIentry-name\fR
-
+.sp
where \fIentry-name\fR is the name of the type you wish to examine (and the
name of its capability file the subdirectory of \*d named for its first
letter). This command dumps a capability file in the text format described by
@@ -99,7 +98,7 @@ terminals that also explains how to parse them:
First, choose a root name. The root will consist of a lower-case letter
followed by up to seven lower-case letters or digits. You need to avoid using
punctuation characters in root names, because they are used and interpreted as
-filenames, and shell meta-characters (such as !, $, *, ?, etc.) embedded in them
+filenames and shell meta-characters (such as !, $, *, ?, etc.) embedded in them
may cause odd and unhelpful behavior. The slash (/), or any other character
that may be interpreted by anyone's file system (\e, $, [, ]), is especially
dangerous (terminfo is platform-independent, and choosing names with special
@@ -122,7 +121,7 @@ i.e. \fBlinux\fR, \fBbsdos\fR, \fBfreebsd\fR, \fBnetbsd\fR. It should
multi-platform environment! If a model number follows, it should indicate
either the OS release level or the console driver release level.
.PP
-The root name for a terminal emulator (assuming it doesn't fit one of the
+The root name for a terminal emulator (assuming it does not fit one of the
standard ANSI or vt100 types) should be the program name or a readily
recognizable abbreviation of it (i.e. \fBversaterm\fR, \fBctrm\fR).
.PP
@@ -197,7 +196,7 @@ tty line initialization (AT&T-like UNIXes)
.TP 5
/etc/ttys
tty line initialization (BSD-like UNIXes)
-.SH "SEE ALSO"
+.SH SEE ALSO
\fBcurses\fR(3), \fBterminfo\fR(\*n), \fBterm\fR(\*n).
.\"#
.\"# The following sets edit modes for GNU EMACS
diff --git a/lib/libcurses/term.h b/lib/libcurses/term.h
index c912cfd5252..0942f33ad8f 100644
--- a/lib/libcurses/term.h
+++ b/lib/libcurses/term.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: term.h,v 1.13 2002/02/18 22:24:32 deraadt Exp $ */
+/* $OpenBSD: term.h,v 1.14 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,23 +31,24 @@
/****************************************************************************/
/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */
/* and: Eric S. Raymond <esr@snark.thyrsus.com> */
+/* and: Thomas E. Dickey 1995-on */
/****************************************************************************/
-/* $From: MKterm.h.awk.in,v 1.38 2000/12/09 23:54:00 tom Exp $ */
+/* $Id: term.h,v 1.14 2010/01/12 23:21:59 nicm Exp $ */
/*
** term.h -- Definition of struct term
*/
-#ifndef _NCU_TERM_H
-#define _NCU_TERM_H 1
+#ifndef NCURSES_TERM_H_incl
+#define NCURSES_TERM_H_incl 1
#ifdef _USE_OLD_CURSES_
#error Cannot mix ncurses term.h with old curses.h
#endif
#undef NCURSES_VERSION
-#define NCURSES_VERSION "5.2"
+#define NCURSES_VERSION "5.7"
#if !defined(NCURSES_IMPEXP)
# define NCURSES_IMPEXP /* nothing */
@@ -62,42 +63,20 @@
# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
#endif
-
#ifdef __cplusplus
extern "C" {
#endif
/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H
- * and BROKEN_LINKER definition (based on the system for which this was
- * configured).
+ * definition (based on the system for which this was configured).
*/
-#ifdef __OpenBSD__
-#define BROKEN_LINKER 0
-#define TERMIOS 1
-#define NCURSES_CONST /*nothing*/
-#define NCURSES_XNAMES 1
-
-#include <termios.h>
-#define TTY struct termios
-
-#else
-
-#undef HAVE_TERMIOS_H
-#define HAVE_TERMIOS_H 1
-
-#undef HAVE_TERMIO_H
-#define HAVE_TERMIO_H 0
-
-#undef HAVE_TCGETATTR
-#define HAVE_TCGETATTR 1
-
-#undef BROKEN_LINKER
-#define BROKEN_LINKER 0
-
#undef NCURSES_CONST
#define NCURSES_CONST /*nothing*/
+#undef NCURSES_SBOOL
+#define NCURSES_SBOOL signed char
+
#undef NCURSES_XNAMES
#define NCURSES_XNAMES 1
@@ -108,8 +87,9 @@ extern "C" {
#undef SET_TTY
#undef GET_TTY
-/* Assume Posix termio if we have the header and function */
-#if HAVE_TERMIOS_H && HAVE_TCGETATTR
+/* Assume POSIX termio if we have the header and function */
+/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */
+#if 1 && 1
#undef TERMIOS
#define TERMIOS 1
@@ -119,7 +99,8 @@ extern "C" {
#else /* !HAVE_TERMIOS_H */
-#if HAVE_TERMIO_H
+/* #if HAVE_TERMIO_H */
+#if 0
#undef TERMIOS
#define TERMIOS 1
@@ -173,8 +154,6 @@ extern "C" {
#endif /* HAVE_TERMIOS_H */
-#endif /* OpenBSD */
-
#ifdef TERMIOS
#define GET_TTY(fd, buf) tcgetattr(fd, buf)
#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)
@@ -706,12 +685,12 @@ extern "C" {
#define STRCOUNT 414
/* used by code for comparing entries */
-#define acs_chars_index 146
+#define acs_chars_index 146
typedef struct termtype { /* in-core form of terminfo data */
char *term_names; /* str_table offset of term names */
char *str_table; /* pointer to string table */
- signed char *Booleans; /* array of boolean values */
+ NCURSES_SBOOL *Booleans; /* array of boolean values */
short *Numbers; /* array of integer values */
char **Strings; /* array of string offsets */
@@ -732,37 +711,40 @@ typedef struct termtype { /* in-core form of terminfo data */
typedef struct term { /* describe an actual terminal */
TERMTYPE type; /* terminal type description */
- short Filedes; /* file description being written to */
+ short Filedes; /* file description being written to */
TTY Ottyb, /* original state of the terminal */
Nttyb; /* current state of the terminal */
int _baudrate; /* used to compute padding */
+ char * _termname; /* used for termname() */
} TERMINAL;
-extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
-
-#if BROKEN_LINKER
-#define boolnames _nc_boolnames()
-#define boolcodes _nc_boolcodes()
-#define boolfnames _nc_boolfnames()
-#define numnames _nc_numnames()
-#define numcodes _nc_numcodes()
-#define numfnames _nc_numfnames()
-#define strnames _nc_strnames()
-#define strcodes _nc_strcodes()
-#define strfnames _nc_strfnames()
-
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolnames (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolcodes (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolfnames (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numnames (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numcodes (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numfnames (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strnames (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strcodes (void);
-extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strfnames (void);
+#if 0 || 0
+NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);
+NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);
+
+#define cur_term NCURSES_PUBLIC_VAR(cur_term())
+#define boolnames NCURSES_PUBLIC_VAR(boolnames())
+#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())
+#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())
+#define numnames NCURSES_PUBLIC_VAR(numnames())
+#define numcodes NCURSES_PUBLIC_VAR(numcodes())
+#define numfnames NCURSES_PUBLIC_VAR(numfnames())
+#define strnames NCURSES_PUBLIC_VAR(strnames())
+#define strcodes NCURSES_PUBLIC_VAR(strcodes())
+#define strfnames NCURSES_PUBLIC_VAR(strfnames())
#else
+extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];
@@ -780,9 +762,9 @@ extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);
extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);
extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);
extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);
+extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);
extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);
extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);
-extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);
/* entry points */
@@ -796,25 +778,32 @@ extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);
/* terminfo entry points, also declared in curses.h */
#if !defined(__NCURSES_H)
extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);
extern NCURSES_EXPORT_VAR(char) ttytype[];
extern NCURSES_EXPORT(int) putp (const char *);
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);
+
+#if 1 /* NCURSES_TPARM_VARARGS */
+extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */
+#else
+extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */
+extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */
+#endif
+
#endif /* __NCURSES_H */
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
-#if !defined(_NCU_TERMCAP_H)
+#if !defined(NCURSES_TERMCAP_H_incl)
extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
-#endif /* _NCU_TERMCAP_H */
+#endif /* NCURSES_TERMCAP_H_incl */
#ifdef __cplusplus
}
#endif
-#endif /* _NCU_TERM_H */
+#endif /* NCURSES_TERM_H_incl */
diff --git a/lib/libcurses/term_entry.h b/lib/libcurses/term_entry.h
index d8d4b36c631..3cd0a59aa1c 100644
--- a/lib/libcurses/term_entry.h
+++ b/lib/libcurses/term_entry.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: term_entry.h,v 1.11 2001/01/22 18:01:35 millert Exp $ */
+/* $OpenBSD: term_entry.h,v 1.12 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,16 +31,17 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1998-on *
****************************************************************************/
-/* $From: term_entry.h,v 1.31 2001/01/13 22:44:41 tom Exp $ */
+/* $Id: term_entry.h,v 1.12 2010/01/12 23:21:59 nicm Exp $ */
/*
* term_entry.h -- interface to entry-manipulation code
*/
-#ifndef _TERM_ENTRY_H
-#define _TERM_ENTRY_H
+#ifndef NCURSES_TERM_ENTRY_H_incl
+#define NCURSES_TERM_ENTRY_H_incl 1
#ifdef __cplusplus
extern "C" {
@@ -53,12 +54,12 @@ extern "C" {
typedef struct entry {
TERMTYPE tterm;
- int nuses;
+ unsigned nuses;
struct
{
char *name;
struct entry *link;
- long line;
+ long line;
}
uses[MAX_USES];
int ncrosslinks;
@@ -135,6 +136,9 @@ extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
/* lib_acs.c */
extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
+/* lib_termcap.c: trim sgr0 string for termcap users */
+extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE *);
+
/* parse_entry.c: entry-parsing code */
#if NCURSES_XNAMES
extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
@@ -150,9 +154,11 @@ extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
/* comp_parse.c: entry list handling */
extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
-extern NCURSES_EXPORT(int) _nc_resolve_uses (bool);
+extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
+extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
-extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *);
+extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
+extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
/* trace_xnames.c */
extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
@@ -167,4 +173,4 @@ extern int _nc_read_bsd_terminfo_file(const char * const, TERMTYPE *const);
}
#endif
-#endif /* _TERM_ENTRY_H */
+#endif /* NCURSES_TERM_ENTRY_H_incl */
diff --git a/lib/libcurses/termcap.3 b/lib/libcurses/termcap.3
index 294515b5bb0..ac9d2fea6db 100644
--- a/lib/libcurses/termcap.3
+++ b/lib/libcurses/termcap.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: termcap.3,v 1.7 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: termcap.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_termcap.3x,v 1.14 2000/12/02 22:47:14 tom Exp $
+.\" $Id: termcap.3,v 1.8 2010/01/12 23:21:59 nicm Exp $
.TH termcap 3 ""
.ds n 5
.SH NAME
@@ -42,7 +42,15 @@
\fB#include <curses.h>\fR
.br
\fB#include <term.h>\fR
+.sp
+\fBextern char PC;\fR
.br
+\fBextern char * UP;\fR
+.br
+\fBextern char * BC;\fR
+.br
+\fBextern short ospeed;\fR
+.sp
\fBint tgetent(char *bp, const char *name);\fR
.br
\fBint tgetflag(char *id);\fR
@@ -61,64 +69,96 @@ the \fItermcap\fR library. Their parameters are the same and the
routines are emulated using the \fIterminfo\fR database. Thus, they
can only be used to query the capabilities of entries for which a
terminfo entry has been compiled.
-
+.PP
The \fBtgetent\fR routine loads the entry for \fIname\fR.
It returns 1 on success, 0 if there is no such entry, and -1 if the
terminfo database could not be found.
The emulation ignores the buffer pointer \fIbp\fR.
-
+.PP
The \fBtgetflag\fR routine gets the boolean entry for \fIid\fR,
or zero if it is not available.
-
+.PP
The \fBtgetnum\fR routine gets the numeric entry for \fIid\fR,
or -1 if it is not available.
-
+.PP
The \fBtgetstr\fR routine returns the string entry for \fIid\fR,
or zero if it is not available.
Use \fBtputs\fR to output the returned string.
The return value will also be copied to the buffer pointed to by \fIarea\fR,
and the \fIarea\fR value will be updated to point past the null ending
this value.
-
+.PP
Only the first two characters of the \fBid\fR parameter of
\fBtgetflag\fR,
\fBtgetnum\fR and
\fBtgetstr\fR are compared in lookups.
-
+.PP
The \fBtgoto\fR routine instantiates the parameters into the given capability.
The output from this routine is to be passed to \fBtputs\fR.
-
-The \fBtputs\fR routine is described in the \fBterminfo\fR(3) manual
+.PP
+The \fBtputs\fR routine is described on the \fBterminfo\fR(3) manual
page. It can retrieve capabilities by either termcap or terminfo name.
-
+.PP
+The variables
+\fBPC\fR,
+\fBUP\fR and
+\fBBC\fR
+are set by \fBtgetent\fR to the terminfo entry's data for
+\fBpad_char\fR,
+\fBcursor_up\fR and
+\fBbackspace_if_not_bs\fR,
+respectively.
+\fBUP\fR is not used by ncurses.
+\fBPC\fR is used in the \fBtdelay_output\fR function.
+\fBBC\fR is used in the \fBtgoto\fR emulation.
+The variable \fBospeed\fR is set by ncurses in a system-specific coding
+to reflect the terminal speed.
+.
.SH RETURN VALUE
Except where explicitly noted,
routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion.
-
+.PP
Routines that return pointers return \fBNULL\fR on error.
.SH BUGS
If you call \fBtgetstr\fR to fetch \fBca\fR or any other parameterized string,
be aware that it will be returned in terminfo notation, not the older and
-not-quite-compatible termcap notation. This won't cause problems if all
+not-quite-compatible termcap notation. This will not cause problems if all
you do with it is call \fBtgoto\fR or \fBtparm\fR, which both expand
terminfo-style strings as terminfo.
(The \fBtgoto\fR function, if configured to support termcap, will check
if the string is indeed terminfo-style by looking for "%p" parameters or
"$<..>" delays, and invoke a termcap-style parser if the string does not
appear to be terminfo).
-
+.PP
Because terminfo conventions for representing padding in string capabilities
differ from termcap's, \fBtputs("50");\fR will put out a literal "50" rather
than busy-waiting for 50 milliseconds. Cope with it.
+.PP
+Note that termcap has nothing analogous to terminfo's \fBsgr\fR string.
+One consequence of this is that termcap applications assume \fRme\fR
+(terminfo \fBsgr0\fR) does not reset the alternate character set.
+This implementation checks for, and modifies the data shown to the
+termcap interface to accommodate termcap's limitation in this respect.
.SH PORTABILITY
The XSI Curses standard, Issue 4 describes these functions. However, they
are marked TO BE WITHDRAWN and may be removed in future versions.
-
+.PP
Neither the XSI Curses standard nor the SVr4 man pages documented the return
values of \fBtgetent\fR correctly, though all three were in fact returned ever
since SVr1.
+In particular, an omission in the XSI Curses documentation has been
+misinterpreted to mean that \fBtgetent\fR returns \fBOK\fR or \fBERR\fR.
+Because the purpose of these functions is to provide compatibility with
+the \fItermcap\fR library, that is a defect in XCurses, Issue 4, Version 2
+rather than in ncurses.
+.PP
+External variables are provided for support of certain termcap applications.
+However, termcap applications' use of those variables is poorly documented,
+e.g., not distinguishing between input and output.
+In particular, some applications are reported to declare and/or
+modify \fBospeed\fR.
.SH SEE ALSO
\fBcurses\fR(3), \fBterminfo\fR(\*n), \fBputc\fR(3).
.\"#
diff --git a/lib/libcurses/termcap.h b/lib/libcurses/termcap.h
index f4e1a62ecd0..2020f138bf3 100644
--- a/lib/libcurses/termcap.h
+++ b/lib/libcurses/termcap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: termcap.h,v 1.8 2001/01/22 18:01:35 millert Exp $ */
+/* $OpenBSD: termcap.h,v 1.9 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -33,13 +33,13 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-/* $From: termcap.h.in,v 1.15 2000/12/10 02:01:50 tom Exp $ */
+/* $Id: termcap.h,v 1.9 2010/01/12 23:21:59 nicm Exp $ */
-#ifndef _NCU_TERMCAP_H
-#define _NCU_TERMCAP_H 1
+#ifndef NCURSES_TERMCAP_H_incl
+#define NCURSES_TERMCAP_H_incl 1
#undef NCURSES_VERSION
-#define NCURSES_VERSION "5.2"
+#define NCURSES_VERSION "5.7"
#if !defined(NCURSES_IMPEXP)
# define NCURSES_IMPEXP /* nothing */
@@ -62,7 +62,7 @@ extern "C"
#include <sys/types.h>
#undef NCURSES_CONST
-#define NCURSES_CONST
+#define NCURSES_CONST /*nothing*/
#undef NCURSES_OSPEED
#define NCURSES_OSPEED short
@@ -72,7 +72,7 @@ extern NCURSES_EXPORT_VAR(char *) UP;
extern NCURSES_EXPORT_VAR(char *) BC;
extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed;
-#if !defined(_NCU_TERM_H)
+#if !defined(NCURSES_TERM_H_incl)
extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
@@ -85,4 +85,4 @@ extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
}
#endif
-#endif /* _NCU_TERMCAP_H */
+#endif /* NCURSES_TERMCAP_H_incl */
diff --git a/lib/libcurses/terminfo.3 b/lib/libcurses/terminfo.3
index 6abb958638a..c2471742827 100644
--- a/lib/libcurses/terminfo.3
+++ b/lib/libcurses/terminfo.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: terminfo.3,v 1.9 2003/05/14 08:55:19 jmc Exp $
+.\" $OpenBSD: terminfo.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,90 +28,110 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: curs_terminfo.3x,v 1.14 2000/12/03 00:07:23 tom Exp $
+.\" $Id: terminfo.3,v 1.10 2010/01/12 23:21:59 nicm Exp $
.TH terminfo 3 ""
.ds n 5
+.na
+.hy 0
.SH NAME
-\fBsetupterm\fR,
-\fBsetterm\fR,
-\fBset_curterm\fR,
\fBdel_curterm\fR,
+\fBmvcur\fR,
+\fBputp\fR,
\fBrestartterm\fR,
+\fBset_curterm\fR,
+\fBsetterm\fR,
+\fBsetupterm\fR,
+\fBtigetflag\fR,
+\fBtigetnum\fR,
+\fBtigetstr\fR,
\fBtparm\fR,
\fBtputs\fR,
-\fBputp\fR,
-\fBvidputs\fR,
+\fBvid_attr\fR,
+\fBvid_puts\fR,
\fBvidattr\fR,
-\fBmvcur\fR,
-\fBtigetflag\fR,
-\fBtigetnum\fR,
-\fBtigetstr\fR - \fBcurses\fR interfaces to terminfo database
+\fBvidputs\fR - \fBcurses\fR interfaces to terminfo database
+.ad
+.hy
.SH SYNOPSIS
+.nf
\fB#include <curses.h>\fR
.br
\fB#include <term.h>\fR
-
-\fBint setupterm(const char *term, int fildes, int *errret);\fR
+.PP
+\fBint setupterm(char *\fR\fIterm\fR\fB, int \fR\fIfildes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
+.br
+\fBint setterm(char *\fR\fIterm\fR\fB);\fR
.br
-\fBint setterm(const char *term);\fR
+\fBTERMINAL *set_curterm(TERMINAL *\fR\fInterm\fR\fB);\fR
.br
-\fBTERMINAL *set_curterm(TERMINAL *nterm);\fR
+\fBint del_curterm(TERMINAL *\fR\fIoterm\fR\fB);\fR
.br
-\fBint del_curterm(TERMINAL *oterm);\fR
+\fBint restartterm(char *\fR\fIterm\fR\fB, int \fR\fIfildes\fR\fB, int *\fR\fIerrret\fR\fB);\fR
.br
-\fBint restartterm(const char *term, int fildes, int *errret);\fR
+\fBchar *tparm(char *\fR\fIstr\fR\fB, ...);\fR
.br
-\fBchar *tparm(const char *str, ...);\fR
+\fBint tputs(const char *\fR\fIstr\fR\fB, int \fR\fIaffcnt\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
.br
-\fBint tputs(const char *str, int affcnt, int (*putc)(int));\fR
+\fBint putp(const char *\fR\fIstr\fR\fB);\fR
.br
-\fBint putp(const char *str);\fR
+\fBint vidputs(chtype \fR\fIattrs\fR\fB, int (*\fR\fIputc\fR\fB)(int));\fR
.br
-\fBint vidputs(chtype attrs, int (*putc)(char));\fR
+\fBint vidattr(chtype \fR\fIattrs\fR\fB);\fR
.br
-\fBint vidattr(chtype attrs);\fR
+\fBint vid_puts(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB, int (*\fR\fIputc\fR\fB)(char));\fR
.br
-\fBint mvcur(int oldrow, int oldcol, int newrow, int newcol);\fR
+\fBint vid_attr(attr_t \fR\fIattrs\fR\fB, short \fR\fIpair\fR\fB, void *\fR\fIopts\fR\fB);\fR
.br
-\fBint tigetflag(const char *capname);\fR
+\fBint mvcur(int \fR\fIoldrow\fR\fB, int \fR\fIoldcol\fR\fB, int \fR\fInewrow\fR, int \fR\fInewcol\fR\fB);\fR
.br
-\fBint tigetnum(const char *capname);\fR
+\fBint tigetflag(char *\fR\fIcapname\fR\fB);\fR
.br
-\fBchar *tigetstr(const char *capname);\fR
+\fBint tigetnum(char *\fR\fIcapname\fR\fB);\fR
.br
+\fBchar *tigetstr(char *\fR\fIcapname\fR\fB);\fR
+.br
+.fi
.SH DESCRIPTION
These low-level routines must be called by programs that have to deal
directly with the \fBterminfo\fR database to handle certain terminal
capabilities, such as programming function keys. For all other
functionality, \fBcurses\fR routines are more suitable and their use is
recommended.
-
+.PP
Initially, \fBsetupterm\fR should be called. Note that
\fBsetupterm\fR is automatically called by \fBinitscr\fR and
\fBnewterm\fR. This defines the set of terminal-dependent variables
-[listed in \fBterminfo\fR(\*n)]. The \fBterminfo\fR variables
+[listed in \fBterminfo\fR(\*n)].
+The \fBterminfo\fR variables
\fBlines\fR and \fBcolumns\fR are initialized by \fBsetupterm\fR as
-follows: If \fBuse_env(FALSE)\fR has been called, values for
+follows:
+.RS
+.PP
+If \fBuse_env(FALSE)\fR has been called, values for
\fBlines\fR and \fBcolumns\fR specified in \fBterminfo\fR are used.
+.PP
Otherwise, if the environment variables \fBLINES\fR and \fBCOLUMNS\fR
exist, their values are used. If these environment variables do not
exist and the program is running in a window, the current window size
is used. Otherwise, if the environment variables do not exist, the
values for \fBlines\fR and \fBcolumns\fR specified in the
\fBterminfo\fR database are used.
-
+.RE
+.PP
The header files \fBcurses.h\fR and \fBterm.h\fR should be included (in this
order) to get the definitions for these strings, numbers, and flags.
-Parameterized strings should be passed through \fBtparm\fR to instantiate them.
+Parameterized strings should be passed through \fBtparm\fR to instantiate them.
All \fBterminfo\fR strings [including the output of \fBtparm\fR] should be printed
with \fBtputs\fR or \fBputp\fR. Call the \fBreset_shell_mode\fR to restore the
tty modes before exiting [see \fBcurs_kernel\fR(3)]. Programs which use
cursor addressing should output \fBenter_ca_mode\fR upon startup and should
output \fBexit_ca_mode\fR before exiting. Programs desiring shell escapes
-should call \fBreset_shell_mode\fR and output \fBexit_ca_mode\fR before the
-shell is called and should output \fBenter_ca_mode\fR and call
+should call
+.PP
+\fBreset_shell_mode\fR and output \fBexit_ca_mode\fR before the shell
+is called and should output \fBenter_ca_mode\fR and call
\fBreset_prog_mode\fR after returning from the shell.
-
+.PP
The \fBsetupterm\fR routine reads in the \fBterminfo\fR database,
initializing the \fBterminfo\fR structures, but does not set up the
output virtualization structures used by \fBcurses\fR. The terminal
@@ -142,88 +162,102 @@ means that the \fBterminfo\fR database could not be found.
If \fIerrret\fR is
null, \fBsetupterm\fR prints an error message upon finding an error
and exits. Thus, the simplest call is:
-
+.sp
\fBsetupterm((char *)0, 1, (int *)0);\fR,
-
+.sp
which uses all the defaults and sends the output to \fBstdout\fR.
-
+.PP
The \fBsetterm\fR routine is being replaced by \fBsetupterm\fR. The call:
-
+.sp
\fBsetupterm(\fR\fIterm\fR\fB, 1, (int *)0)\fR
-
+.sp
provides the same functionality as \fBsetterm(\fR\fIterm\fR\fB)\fR.
The \fBsetterm\fR routine is included here for BSD compatibility, and
is not recommended for new programs.
-
+.PP
The \fBset_curterm\fR routine sets the variable \fBcur_term\fR to
\fInterm\fR, and makes all of the \fBterminfo\fR boolean, numeric, and
string variables use the values from \fInterm\fR. It returns the old value
of \fBcur_term\fR.
-
+.PP
The \fBdel_curterm\fR routine frees the space pointed to by
\fIoterm\fR and makes it available for further use. If \fIoterm\fR is
the same as \fBcur_term\fR, references to any of the \fBterminfo\fR
boolean, numeric, and string variables thereafter may refer to invalid
memory locations until another \fBsetupterm\fR has been called.
-
+.PP
The \fBrestartterm\fR routine is similar to \fBsetupterm\fR and \fBinitscr\fR,
except that it is called after restoring memory to a previous state (for
example, when reloading a game saved as a core image dump). It assumes that
the windows and the input and output options are the same as when memory was
saved, but the terminal type and baud rate may be different. Accordingly,
-it saves various tty state bits, does a setupterm, and then restores the bits.
-
+it saves various tty state bits, calls \fBsetupterm\fP,
+and then restores the bits.
+.PP
The \fBtparm\fR routine instantiates the string \fIstr\fR with
parameters \fIpi\fR. A pointer is returned to the result of \fIstr\fR
with the parameters applied.
-
+.PP
The \fBtputs\fR routine applies padding information to the string
\fIstr\fR and outputs it. The \fIstr\fR must be a terminfo string
variable or the return value from \fBtparm\fR, \fBtgetstr\fR, or
\fBtgoto\fR. \fIaffcnt\fR is the number of lines affected, or 1 if
not applicable. \fIputc\fR is a \fBputchar\fR-like routine to which
the characters are passed, one at a time.
-
+.PP
The \fBputp\fR routine calls \fBtputs(\fR\fIstr\fR\fB, 1, putchar)\fR.
Note that the output of \fBputp\fR always goes to \fBstdout\fR, not to
the \fIfildes\fR specified in \fBsetupterm\fR.
-
+.PP
The \fBvidputs\fR routine displays the string on the terminal in the
video attribute mode \fIattrs\fR, which is any combination of the
attributes listed in \fBcurses\fR(3). The characters are passed to
the \fBputchar\fR-like routine \fIputc\fR.
-
+.PP
The \fBvidattr\fR routine is like the \fBvidputs\fR routine, except
that it outputs through \fBputchar\fR.
-
+.PP
+The \fBvid_attr\fR and \fBvid_puts\fR routines correspond to vidattr and vidputs,
+respectively.
+They use a set of arguments for representing the video attributes plus color,
+i.e.,
+one of type attr_t for the attributes and one of short for
+the color_pair number.
+The \fBvid_attr\fR and \fBvid_puts\fR routines
+are designed to use the attribute constants with the \fIWA_\fR prefix.
+The opts argument is reserved for future use.
+Currently, applications must provide a null pointer for that argument.
+.PP
The \fBmvcur\fR routine provides low-level cursor motion. It takes
effect immediately (rather than at the next refresh).
-
+.PP
The \fBtigetflag\fR, \fBtigetnum\fR and \fBtigetstr\fR routines return
the value of the capability corresponding to the \fBterminfo\fR
\fIcapname\fR passed to them, such as \fBxenl\fR.
-
+.PP
The \fBtigetflag\fR routine returns the value \fB-1\fR if
\fIcapname\fR is not a boolean capability,
or \fB0\fR if it is canceled or absent from the terminal description.
-
+.PP
The \fBtigetnum\fR routine returns the value \fB-2\fR if
\fIcapname\fR is not a numeric capability,
or \fB-1\fR if it is canceled or absent from the terminal description.
-
+.PP
The \fBtigetstr\fR routine returns the value \fB(char *)-1\fR
if \fIcapname\fR is not a string capability,
or \fB0\fR if it is canceled or absent from the terminal description.
-
+.PP
The \fIcapname\fR for each capability is given in the table column entitled
\fIcapname\fR code in the capabilities section of \fBterminfo\fR(\*n).
-
-\fBchar *boolnames\fR, \fB*boolcodes\fR, \fB*boolfnames\fR
-
-\fBchar *numnames\fR, \fB*numcodes\fR, \fB*numfnames\fR
-
-\fBchar *strnames\fR, \fB*strcodes\fR, \fB*strfnames\fR
-
+.sp
+.RS
+\fBchar *boolnames[]\fR, \fB*boolcodes[]\fR, \fB*boolfnames[]\fR
+.sp
+\fBchar *numnames[]\fR, \fB*numcodes[]\fR, \fB*numfnames[]\fR
+.sp
+\fBchar *strnames[]\fR, \fB*strcodes[]\fR, \fB*strfnames[]\fR
+.RE
+.PP
These null-terminated arrays contain the \fIcapnames\fR, the
\fBtermcap\fR codes, and the full C names, for each of the
\fBterminfo\fR variables.
@@ -231,43 +265,87 @@ These null-terminated arrays contain the \fIcapnames\fR, the
Routines that return an integer return \fBERR\fR upon failure and \fBOK\fR
(SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
completion, unless otherwise noted in the preceding routine descriptions.
-
+.PP
Routines that return pointers always return \fBNULL\fR on error.
+.PP
+X/Open defines no error conditions.
+In this implementation
+.RS
+.TP 5
+\fBdel_curterm\fP
+returns an error
+if its terminal parameter is null.
+.TP 5
+\fBputp\fP
+calls \fBtputs\fP, returning the same error-codes.
+.TP 5
+\fBrestartterm\fP
+returns an error
+if the associated call to \fBsetupterm\fP returns an error.
+.TP 5
+\fBsetupterm\fP
+returns an error
+if it cannot allocate enough memory, or
+create the initial windows (stdscr, curscr, newscr).
+Other error conditions are documented above.
+.TP 5
+\fBtputs\fP
+returns an error if the string parameter is null.
+It does not detect I/O errors:
+X/Open states that \fBtputs\fP ignores the return value
+of the output function \fIputc\fP.
+.RE
.SH NOTES
The \fBsetupterm\fR routine should be used in place of \fBsetterm\fR.
It may be useful when you want to test for terminal capabilities without
committing to the allocation of storage involved in \fBinitscr\fR.
-
+.PP
Note that \fBvidattr\fR and \fBvidputs\fR may be macros.
.SH PORTABILITY
-The function \fBsetterm\fR is not described in the XSI Curses standard and must
-be considered non-portable. All other functions are as described in the XSI
-curses standard.
-
+The function \fBsetterm\fR is not described by X/Open and must
+be considered non-portable. All other functions are as described by X/Open.
+.PP
+\fBsetupterm\fP copies the terminal name to the array \fBttytype\fP.
+This is not part of X/Open Curses, but is assumed by some applications.
+.PP
In System V Release 4, \fBset_curterm\fR has an \fBint\fR return type and
-returns \fBOK\fR or \fBERR\fR. We have chosen to implement the XSI Curses
+returns \fBOK\fR or \fBERR\fR. We have chosen to implement the X/Open Curses
semantics.
-
+.PP
In System V Release 4, the third argument of \fBtputs\fR has the type
\fBint (*putc)(char)\fR.
-
-The XSI Curses standard prototypes \fBtparm\fR with a fixed number of parameters,
+.PP
+At least one implementation of X/Open Curses (Solaris) returns a value
+other than OK/ERR from \fBtputs\fP.
+That returns the length of the string, and does no error-checking.
+.PP
+X/Open Curses prototypes \fBtparm\fR with a fixed number of parameters,
rather than a variable argument list.
-That prototype assumes that none of the parameters are strings
-(or if so, that a long is big enough to hold a pointer).
-The variable argument list implemented in ncurses does not rely on
-that assumption.
-
-XSI notes that after calling \fBmvcur\fR, the curses state may not match the
+This implementation uses a variable argument list.
+Portable applications should provide 9 parameters after the format;
+zeroes are fine for this purpose.
+.PP
+X/Open notes that after calling \fBmvcur\fR, the curses state may not match the
actual terminal state, and that an application should touch and refresh
the window before resuming normal curses calls.
Both ncurses and System V Release 4 curses implement \fBmvcur\fR using
the SCREEN data allocated in either \fBinitscr\fR or \fBnewterm\fR.
So though it is documented as a terminfo function,
\fBmvcur\fR is really a curses function which is not well specified.
+.PP
+X/Open states that the old location must be given for \fBmvcur\fP.
+This implementation allows the caller to use -1's for the old ordinates.
+In that case, the old location is unknown.
+.PP
+Extended terminal capability names, e.g., as defined by \fBtic\ -x\fP,
+are not stored in the arrays described in this section.
.SH SEE ALSO
-\fBcurses\fR(3), \fBcurs_initscr\fR(3), \fBcurs_kernel\fR(3), \fBtermcap\fR(3),
-\fBputc\fR(3), \fBterminfo\fR(\*n)
+\fBcurses\fR(3),
+\fBcurs_initscr\fR(3),
+\fBcurs_kernel\fR(3),
+\fBputc\fR(3),
+\fBtermcap\fR(3),
+\fBterminfo\fR(\*n)
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libcurses/terminfo.5tbl b/lib/libcurses/terminfo.5tbl
index f3b446ad18c..87a3e37bbb2 100644
--- a/lib/libcurses/terminfo.5tbl
+++ b/lib/libcurses/terminfo.5tbl
@@ -5,7 +5,7 @@
.\" Note: this must be run through tbl before nroff.
.\" The magic cookie on the first line triggers this under some man programs.
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -32,21 +32,18 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: terminfo.head,v 1.9 2000/08/13 01:56:40 tom Exp $
-.\" $OpenBSD: terminfo.5tbl,v 1.12 2004/11/04 15:36:47 otto Exp $
-.TH TERMINFO 5 "" "" "File Formats"
+.\" $Id: terminfo.5tbl,v 1.13 2010/01/12 23:21:59 nicm Exp $
+.TH terminfo 5 "" "" "File Formats"
.ds n 5
.ds d /usr/share/misc/terminfo
.SH NAME
-terminfo \- terminal capability data base
+terminfo \- terminal capability database
.SH SYNOPSIS
-\*d.db
-.br
-/usr/share/terminfo/?/*
+\*d/*/*
.SH DESCRIPTION
.I Terminfo
is a data base describing terminals, used by screen-oriented programs such as
-\fBvi\fR(1),
+\fBnvi\fR(1),
\fBrogue\fR(1)
and libraries such as
\fBcurses\fR(3).
@@ -54,11 +51,13 @@ and libraries such as
describes terminals by giving a set of capabilities which they
have, by specifying how to perform screen operations, and by
specifying padding requirements and initialization sequences.
+This describes \fBncurses\fR
+version 5.7.
.PP
Entries in
.I terminfo
consist of a sequence of `,' separated fields (embedded commas may be
-escaped with a backslash or notated as \e072).
+escaped with a backslash or notated as \\054).
White space after the `,' separator is ignored.
The first entry for each terminal gives the names which are known for the
terminal, separated by `|' characters.
@@ -68,6 +67,16 @@ and all others are understood as synonyms for the terminal name.
All names but the last should be in lower case and contain no blanks;
the last name may well contain upper case and blanks for readability.
.PP
+Lines beginning with a `#' in the first column are treated as comments.
+While comment lines are legal at any point, the output of \fBcaptoinfo\fP
+and \fBinfotocap\fP (aliases for \fBtic\fP)
+will move comments so they occur only between entries.
+.PP
+Newlines and leading tabs may be used for formatting entries for readability.
+These are removed from parsed entries.
+The \fBinfocmp\ -f\fP option relies on this to format if-then-else expressions:
+the result can be read by \fB@tic\fP.
+.PP
Terminal names (except for the last, verbose entry) should
be chosen using the following conventions.
The particular piece of hardware making up the terminal should
@@ -164,16 +173,16 @@ T}
back_color_erase bce ut T{
screen erased with background color
T}
-can_change ccc cc T{
+can_change ccc cc T{
terminal can re-define existing colors
T}
ceol_standout_glitch xhp xs T{
standout not erased by overwriting (hp)
T}
-col_addr_glitch xhpa YA T{
+col_addr_glitch xhpa YA T{
only positive motion for hpa/mhpa caps
T}
-cpi_changes_res cpix YF T{
+cpi_changes_res cpix YF T{
changing character pitch changes resolution
T}
cr_cancels_micro_mode crxm YB T{
@@ -188,22 +197,22 @@ T}
erase_overstrike eo eo T{
can erase overstrikes with a blank
T}
-generic_type gn gn T{
+generic_type gn gn T{
generic line type
T}
-hard_copy hc hc T{
+hard_copy hc hc T{
hardcopy terminal
T}
-hard_cursor chts HC T{
+hard_cursor chts HC T{
cursor is hard to see
T}
-has_meta_key km km T{
-Has a meta key (shift, sets parity bit)
+has_meta_key km km T{
+Has a meta key (i.e., sets 8th-bit)
T}
-has_print_wheel daisy YC T{
+has_print_wheel daisy YC T{
printer needs operator to change character set
T}
-has_status_line hs hs T{
+has_status_line hs hs T{
has extra status line
T}
hue_lightness_saturation hls hl T{
@@ -212,13 +221,13 @@ T}
insert_null_glitch in in T{
insert mode distinguishes nulls
T}
-lpi_changes_res lpix YG T{
+lpi_changes_res lpix YG T{
changing line pitch changes resolution
T}
-memory_above da da T{
+memory_above da da T{
display may be retained above the screen
T}
-memory_below db db T{
+memory_below db db T{
display may be retained below the screen
T}
move_insert_mode mir mi T{
@@ -227,28 +236,28 @@ T}
move_standout_mode msgr ms T{
safe to move while in standout mode
T}
-needs_xon_xoff nxon nx T{
-padding won't work, xon/xoff required
+needs_xon_xoff nxon nx T{
+padding will not work, xon/xoff required
T}
-no_esc_ctlc xsb xb T{
+no_esc_ctlc xsb xb T{
beehive (f1=escape, f2=ctrl C)
T}
-no_pad_char npc NP T{
+no_pad_char npc NP T{
pad character does not exist
T}
non_dest_scroll_region ndscr ND T{
scrolling region is non-destructive
T}
-non_rev_rmcup nrrmc NR T{
+non_rev_rmcup nrrmc NR T{
smcup does not reverse rmcup
T}
-over_strike os os T{
+over_strike os os T{
terminal can overstrike
T}
-prtr_silent mc5i 5i T{
-printer won't echo on screen
+prtr_silent mc5i 5i T{
+printer will not echo on screen
T}
-row_addr_glitch xvpa YD T{
+row_addr_glitch xvpa YD T{
only positive motion for vpa/mvpa caps
T}
semi_auto_right_margin sam YE T{
@@ -257,13 +266,13 @@ T}
status_line_esc_ok eslok es T{
escape can be used on the status line
T}
-tilde_glitch hz hz T{
-can't print ~'s (hazeltine)
+tilde_glitch hz hz T{
+cannot print ~'s (hazeltine)
T}
transparent_underline ul ul T{
underline character overstrikes
T}
-xon_xoff xon xo T{
+xon_xoff xon xo T{
terminal uses xon/xoff handshaking
T}
.TE
@@ -279,43 +288,43 @@ c l l c
lw25 lw6 lw2 lw20.
\fBVariable Cap- TCap Description\fR
\fBNumeric name Code\fR
-columns cols co T{
+columns cols co T{
number of columns in a line
T}
-init_tabs it it T{
+init_tabs it it T{
tabs initially every # spaces
T}
-label_height lh lh T{
+label_height lh lh T{
rows in each label
T}
-label_width lw lw T{
+label_width lw lw T{
columns in each label
T}
-lines lines li T{
+lines lines li T{
number of lines on screen or page
T}
-lines_of_memory lm lm T{
+lines_of_memory lm lm T{
lines of memory if > line. 0 means varies
T}
magic_cookie_glitch xmc sg T{
number of blank characters left by smso or rmso
T}
-max_attributes ma ma T{
+max_attributes ma ma T{
maximum combined attributes terminal can handle
T}
-max_colors colors Co T{
+max_colors colors Co T{
maximum number of colors on screen
T}
-max_pairs pairs pa T{
+max_pairs pairs pa T{
maximum number of color-pairs on the screen
T}
-maximum_windows wnum MW T{
+maximum_windows wnum MW T{
maximum number of defineable windows
T}
-no_color_video ncv NC T{
-video attributes that can't be used with colors
+no_color_video ncv NC T{
+video attributes that cannot be used with colors
T}
-num_labels nlab Nl T{
+num_labels nlab Nl T{
number of labels on screen
T}
padding_baud_rate pb pb T{
@@ -345,13 +354,13 @@ lw25 lw6 lw2 lw20.
bit_image_entwining bitwin Yo T{
number of passes for each bit-image row
T}
-bit_image_type bitype Yp T{
+bit_image_type bitype Yp T{
type of bit-image device
T}
-buffer_capacity bufsz Ya T{
+buffer_capacity bufsz Ya T{
numbers of bytes buffered before printing
T}
-buttons btns BT T{
+buttons btns BT T{
number of buttons on mouse
T}
dot_horz_spacing spinh Yc T{
@@ -363,34 +372,34 @@ T}
max_micro_address maddr Yd T{
maximum value in micro_..._address
T}
-max_micro_jump mjump Ye T{
+max_micro_jump mjump Ye T{
maximum value in parm_..._micro
T}
-micro_col_size mcs Yf T{
+micro_col_size mcs Yf T{
character step size when in micro mode
T}
-micro_line_size mls Yg T{
+micro_line_size mls Yg T{
line step size when in micro mode
T}
-number_of_pins npins Yh T{
+number_of_pins npins Yh T{
numbers of pins in print-head
T}
-output_res_char orc Yi T{
+output_res_char orc Yi T{
horizontal resolution in units per line
T}
output_res_horz_inch orhi Yk T{
horizontal resolution in units per inch
T}
-output_res_line orl Yj T{
+output_res_line orl Yj T{
vertical resolution in units per line
T}
output_res_vert_inch orvi Yl T{
vertical resolution in units per inch
T}
-print_rate cps Ym T{
+print_rate cps Ym T{
print rate in characters per second
T}
-wide_char_size widcs Yn T{
+wide_char_size widcs Yn T{
character step size when in double wide mode
T}
.TE
@@ -406,139 +415,139 @@ c l l c
lw25 lw6 lw2 lw20.
\fBVariable Cap- TCap Description\fR
\fBString name Code\fR
-acs_chars acsc ac T{
+acs_chars acsc ac T{
graphics charset pairs, based on vt100
T}
-back_tab cbt bt T{
+back_tab cbt bt T{
back tab (P)
T}
-bell bel bl T{
+bell bel bl T{
audible signal (bell) (P)
T}
-carriage_return cr cr T{
+carriage_return cr cr T{
carriage return (P*) (P*)
T}
change_char_pitch cpi ZA T{
-Change number of characters per inch
+Change number of characters per inch to #1
T}
change_line_pitch lpi ZB T{
-Change number of lines per inch
+Change number of lines per inch to #1
T}
-change_res_horz chr ZC T{
-Change horizontal resolution
+change_res_horz chr ZC T{
+Change horizontal resolution to #1
T}
-change_res_vert cvr ZD T{
-Change vertical resolution
+change_res_vert cvr ZD T{
+Change vertical resolution to #1
T}
change_scroll_region csr cs T{
change region to line #1 to line #2 (P)
T}
-char_padding rmp rP T{
+char_padding rmp rP T{
like ip but when in insert mode
T}
-clear_all_tabs tbc ct T{
+clear_all_tabs tbc ct T{
clear all tab stops (P)
T}
-clear_margins mgc MC T{
+clear_margins mgc MC T{
clear right and left soft margins
T}
-clear_screen clear cl T{
+clear_screen clear cl T{
clear screen and home cursor (P*)
T}
-clr_bol el1 cb T{
+clr_bol el1 cb T{
Clear to beginning of line
T}
-clr_eol el ce T{
+clr_eol el ce T{
clear to end of line (P)
T}
-clr_eos ed cd T{
+clr_eos ed cd T{
clear to end of screen (P*)
T}
-column_address hpa ch T{
+column_address hpa ch T{
horizontal position #1, absolute (P)
T}
command_character cmdch CC T{
terminal settable cmd character in prototype !?
T}
-create_window cwin CW T{
+create_window cwin CW T{
define a window #1 from #2,#3 to #4,#5
T}
-cursor_address cup cm T{
+cursor_address cup cm T{
move to row #1 columns #2
T}
-cursor_down cud1 do T{
+cursor_down cud1 do T{
down one line
T}
-cursor_home home ho T{
+cursor_home home ho T{
home cursor (if no cup)
T}
cursor_invisible civis vi T{
make cursor invisible
T}
-cursor_left cub1 le T{
+cursor_left cub1 le T{
move left one space
T}
cursor_mem_address mrcup CM T{
-memory relative cursor addressing
+memory relative cursor addressing, move to row #1 columns #2
T}
-cursor_normal cnorm ve T{
+cursor_normal cnorm ve T{
make cursor appear normal (undo civis/cvvis)
T}
-cursor_right cuf1 nd T{
+cursor_right cuf1 nd T{
non-destructive space (move right one space)
T}
-cursor_to_ll ll ll T{
+cursor_to_ll ll ll T{
last line, first column (if no cup)
T}
-cursor_up cuu1 up T{
+cursor_up cuu1 up T{
up one line
T}
-cursor_visible cvvis vs T{
+cursor_visible cvvis vs T{
make cursor very visible
T}
-define_char defc ZE T{
-Define a character
+define_char defc ZE T{
+Define a character #1, #2 dots wide, descender #3
T}
delete_character dch1 dc T{
delete character (P*)
T}
-delete_line dl1 dl T{
+delete_line dl1 dl T{
delete line (P*)
T}
-dial_phone dial DI T{
+dial_phone dial DI T{
dial number #1
T}
-dis_status_line dsl ds T{
+dis_status_line dsl ds T{
disable status line
T}
-display_clock dclk DK T{
-display clock at (#1,#2)
+display_clock dclk DK T{
+display clock
T}
-down_half_line hd hd T{
+down_half_line hd hd T{
half a line down
T}
-ena_acs enacs eA T{
+ena_acs enacs eA T{
enable alternate char set
T}
enter_alt_charset_mode smacs as T{
start alternate character set (P)
T}
-enter_am_mode smam SA T{
+enter_am_mode smam SA T{
turn on automatic margins
T}
enter_blink_mode blink mb T{
turn on blinking
T}
-enter_bold_mode bold md T{
+enter_bold_mode bold md T{
turn on bold (extra bright) mode
T}
-enter_ca_mode smcup ti T{
+enter_ca_mode smcup ti T{
string to start programs using cup
T}
enter_delete_mode smdc dm T{
enter delete mode
T}
-enter_dim_mode dim mh T{
+enter_dim_mode dim mh T{
turn on half-bright mode
T}
enter_doublewide_mode swidm ZF T{
@@ -592,22 +601,22 @@ T}
enter_upward_mode sum ZP T{
Start upward carriage motion
T}
-enter_xon_mode smxon SX T{
+enter_xon_mode smxon SX T{
turn on xon/xoff handshaking
T}
-erase_chars ech ec T{
+erase_chars ech ec T{
erase #1 characters (P)
T}
exit_alt_charset_mode rmacs ae T{
end alternate character set (P)
T}
-exit_am_mode rmam RA T{
+exit_am_mode rmam RA T{
turn off automatic margins
T}
exit_attribute_mode sgr0 me T{
turn off all attributes
T}
-exit_ca_mode rmcup te T{
+exit_ca_mode rmcup te T{
strings to end programs using cup
T}
exit_delete_mode rmdc ed T{
@@ -625,7 +634,7 @@ T}
exit_leftward_mode rlm ZS T{
End left-motion mode
T}
-exit_micro_mode rmicm ZT T{
+exit_micro_mode rmicm ZT T{
End micro-motion mode
T}
exit_shadow_mode rshm ZU T{
@@ -646,595 +655,595 @@ T}
exit_upward_mode rum ZX T{
End reverse character motion
T}
-exit_xon_mode rmxon RX T{
+exit_xon_mode rmxon RX T{
turn off xon/xoff handshaking
T}
-fixed_pause pause PA T{
+fixed_pause pause PA T{
pause for 2-3 seconds
T}
-flash_hook hook fh T{
+flash_hook hook fh T{
flash switch hook
T}
-flash_screen flash vb T{
+flash_screen flash vb T{
visible bell (may not move cursor)
T}
-form_feed ff ff T{
+form_feed ff ff T{
hardcopy terminal page eject (P*)
T}
from_status_line fsl fs T{
return from status line
T}
-goto_window wingo WG T{
+goto_window wingo WG T{
go to window #1
T}
-hangup hup HU T{
+hangup hup HU T{
hang-up phone
T}
-init_1string is1 i1 T{
+init_1string is1 i1 T{
initialization string
T}
-init_2string is2 is T{
+init_2string is2 is T{
initialization string
T}
-init_3string is3 i3 T{
+init_3string is3 i3 T{
initialization string
T}
-init_file if if T{
+init_file if if T{
name of initialization file
T}
-init_prog iprog iP T{
+init_prog iprog iP T{
path name of program for initialization
T}
initialize_color initc Ic T{
initialize color #1 to (#2,#3,#4)
T}
-initialize_pair initp Ip T{
+initialize_pair initp Ip T{
Initialize color pair #1 to fg=(#2,#3,#4), bg=(#5,#6,#7)
T}
insert_character ich1 ic T{
insert character (P)
T}
-insert_line il1 al T{
+insert_line il1 al T{
insert line (P*)
T}
-insert_padding ip ip T{
+insert_padding ip ip T{
insert padding after inserted character
T}
-key_a1 ka1 K1 T{
+key_a1 ka1 K1 T{
upper left of keypad
T}
-key_a3 ka3 K3 T{
+key_a3 ka3 K3 T{
upper right of keypad
T}
-key_b2 kb2 K2 T{
+key_b2 kb2 K2 T{
center of keypad
T}
-key_backspace kbs kb T{
+key_backspace kbs kb T{
backspace key
T}
-key_beg kbeg @1 T{
+key_beg kbeg @1 T{
begin key
T}
-key_btab kcbt kB T{
+key_btab kcbt kB T{
back-tab key
T}
-key_c1 kc1 K4 T{
+key_c1 kc1 K4 T{
lower left of keypad
T}
-key_c3 kc3 K5 T{
+key_c3 kc3 K5 T{
lower right of keypad
T}
-key_cancel kcan @2 T{
+key_cancel kcan @2 T{
cancel key
T}
-key_catab ktbc ka T{
+key_catab ktbc ka T{
clear-all-tabs key
T}
-key_clear kclr kC T{
+key_clear kclr kC T{
clear-screen or erase key
T}
-key_close kclo @3 T{
+key_close kclo @3 T{
close key
T}
-key_command kcmd @4 T{
+key_command kcmd @4 T{
command key
T}
-key_copy kcpy @5 T{
+key_copy kcpy @5 T{
copy key
T}
-key_create kcrt @6 T{
+key_create kcrt @6 T{
create key
T}
-key_ctab kctab kt T{
+key_ctab kctab kt T{
clear-tab key
T}
-key_dc kdch1 kD T{
+key_dc kdch1 kD T{
delete-character key
T}
-key_dl kdl1 kL T{
+key_dl kdl1 kL T{
delete-line key
T}
-key_down kcud1 kd T{
+key_down kcud1 kd T{
down-arrow key
T}
-key_eic krmir kM T{
+key_eic krmir kM T{
sent by rmir or smir in insert mode
T}
-key_end kend @7 T{
+key_end kend @7 T{
end key
T}
-key_enter kent @8 T{
+key_enter kent @8 T{
enter/send key
T}
-key_eol kel kE T{
+key_eol kel kE T{
clear-to-end-of-line key
T}
-key_eos ked kS T{
+key_eos ked kS T{
clear-to-end-of-screen key
T}
-key_exit kext @9 T{
+key_exit kext @9 T{
exit key
T}
-key_f0 kf0 k0 T{
+key_f0 kf0 k0 T{
F0 function key
T}
-key_f1 kf1 k1 T{
+key_f1 kf1 k1 T{
F1 function key
T}
-key_f10 kf10 k; T{
+key_f10 kf10 k; T{
F10 function key
T}
-key_f11 kf11 F1 T{
+key_f11 kf11 F1 T{
F11 function key
T}
-key_f12 kf12 F2 T{
+key_f12 kf12 F2 T{
F12 function key
T}
-key_f13 kf13 F3 T{
+key_f13 kf13 F3 T{
F13 function key
T}
-key_f14 kf14 F4 T{
+key_f14 kf14 F4 T{
F14 function key
T}
-key_f15 kf15 F5 T{
+key_f15 kf15 F5 T{
F15 function key
T}
-key_f16 kf16 F6 T{
+key_f16 kf16 F6 T{
F16 function key
T}
-key_f17 kf17 F7 T{
+key_f17 kf17 F7 T{
F17 function key
T}
-key_f18 kf18 F8 T{
+key_f18 kf18 F8 T{
F18 function key
T}
-key_f19 kf19 F9 T{
+key_f19 kf19 F9 T{
F19 function key
T}
-key_f2 kf2 k2 T{
+key_f2 kf2 k2 T{
F2 function key
T}
-key_f20 kf20 FA T{
+key_f20 kf20 FA T{
F20 function key
T}
-key_f21 kf21 FB T{
+key_f21 kf21 FB T{
F21 function key
T}
-key_f22 kf22 FC T{
+key_f22 kf22 FC T{
F22 function key
T}
-key_f23 kf23 FD T{
+key_f23 kf23 FD T{
F23 function key
T}
-key_f24 kf24 FE T{
+key_f24 kf24 FE T{
F24 function key
T}
-key_f25 kf25 FF T{
+key_f25 kf25 FF T{
F25 function key
T}
-key_f26 kf26 FG T{
+key_f26 kf26 FG T{
F26 function key
T}
-key_f27 kf27 FH T{
+key_f27 kf27 FH T{
F27 function key
T}
-key_f28 kf28 FI T{
+key_f28 kf28 FI T{
F28 function key
T}
-key_f29 kf29 FJ T{
+key_f29 kf29 FJ T{
F29 function key
T}
-key_f3 kf3 k3 T{
+key_f3 kf3 k3 T{
F3 function key
T}
-key_f30 kf30 FK T{
+key_f30 kf30 FK T{
F30 function key
T}
-key_f31 kf31 FL T{
+key_f31 kf31 FL T{
F31 function key
T}
-key_f32 kf32 FM T{
+key_f32 kf32 FM T{
F32 function key
T}
-key_f33 kf33 FN T{
+key_f33 kf33 FN T{
F33 function key
T}
-key_f34 kf34 FO T{
+key_f34 kf34 FO T{
F34 function key
T}
-key_f35 kf35 FP T{
+key_f35 kf35 FP T{
F35 function key
T}
-key_f36 kf36 FQ T{
+key_f36 kf36 FQ T{
F36 function key
T}
-key_f37 kf37 FR T{
+key_f37 kf37 FR T{
F37 function key
T}
-key_f38 kf38 FS T{
+key_f38 kf38 FS T{
F38 function key
T}
-key_f39 kf39 FT T{
+key_f39 kf39 FT T{
F39 function key
T}
-key_f4 kf4 k4 T{
+key_f4 kf4 k4 T{
F4 function key
T}
-key_f40 kf40 FU T{
+key_f40 kf40 FU T{
F40 function key
T}
-key_f41 kf41 FV T{
+key_f41 kf41 FV T{
F41 function key
T}
-key_f42 kf42 FW T{
+key_f42 kf42 FW T{
F42 function key
T}
-key_f43 kf43 FX T{
+key_f43 kf43 FX T{
F43 function key
T}
-key_f44 kf44 FY T{
+key_f44 kf44 FY T{
F44 function key
T}
-key_f45 kf45 FZ T{
+key_f45 kf45 FZ T{
F45 function key
T}
-key_f46 kf46 Fa T{
+key_f46 kf46 Fa T{
F46 function key
T}
-key_f47 kf47 Fb T{
+key_f47 kf47 Fb T{
F47 function key
T}
-key_f48 kf48 Fc T{
+key_f48 kf48 Fc T{
F48 function key
T}
-key_f49 kf49 Fd T{
+key_f49 kf49 Fd T{
F49 function key
T}
-key_f5 kf5 k5 T{
+key_f5 kf5 k5 T{
F5 function key
T}
-key_f50 kf50 Fe T{
+key_f50 kf50 Fe T{
F50 function key
T}
-key_f51 kf51 Ff T{
+key_f51 kf51 Ff T{
F51 function key
T}
-key_f52 kf52 Fg T{
+key_f52 kf52 Fg T{
F52 function key
T}
-key_f53 kf53 Fh T{
+key_f53 kf53 Fh T{
F53 function key
T}
-key_f54 kf54 Fi T{
+key_f54 kf54 Fi T{
F54 function key
T}
-key_f55 kf55 Fj T{
+key_f55 kf55 Fj T{
F55 function key
T}
-key_f56 kf56 Fk T{
+key_f56 kf56 Fk T{
F56 function key
T}
-key_f57 kf57 Fl T{
+key_f57 kf57 Fl T{
F57 function key
T}
-key_f58 kf58 Fm T{
+key_f58 kf58 Fm T{
F58 function key
T}
-key_f59 kf59 Fn T{
+key_f59 kf59 Fn T{
F59 function key
T}
-key_f6 kf6 k6 T{
+key_f6 kf6 k6 T{
F6 function key
T}
-key_f60 kf60 Fo T{
+key_f60 kf60 Fo T{
F60 function key
T}
-key_f61 kf61 Fp T{
+key_f61 kf61 Fp T{
F61 function key
T}
-key_f62 kf62 Fq T{
+key_f62 kf62 Fq T{
F62 function key
T}
-key_f63 kf63 Fr T{
+key_f63 kf63 Fr T{
F63 function key
T}
-key_f7 kf7 k7 T{
+key_f7 kf7 k7 T{
F7 function key
T}
-key_f8 kf8 k8 T{
+key_f8 kf8 k8 T{
F8 function key
T}
-key_f9 kf9 k9 T{
+key_f9 kf9 k9 T{
F9 function key
T}
-key_find kfnd @0 T{
+key_find kfnd @0 T{
find key
T}
-key_help khlp %1 T{
+key_help khlp %1 T{
help key
T}
-key_home khome kh T{
+key_home khome kh T{
home key
T}
-key_ic kich1 kI T{
+key_ic kich1 kI T{
insert-character key
T}
-key_il kil1 kA T{
+key_il kil1 kA T{
insert-line key
T}
-key_left kcub1 kl T{
+key_left kcub1 kl T{
left-arrow key
T}
-key_ll kll kH T{
+key_ll kll kH T{
lower-left key (home down)
T}
-key_mark kmrk %2 T{
+key_mark kmrk %2 T{
mark key
T}
-key_message kmsg %3 T{
+key_message kmsg %3 T{
message key
T}
-key_move kmov %4 T{
+key_move kmov %4 T{
move key
T}
-key_next knxt %5 T{
+key_next knxt %5 T{
next key
T}
-key_npage knp kN T{
+key_npage knp kN T{
next-page key
T}
-key_open kopn %6 T{
+key_open kopn %6 T{
open key
T}
-key_options kopt %7 T{
+key_options kopt %7 T{
options key
T}
-key_ppage kpp kP T{
+key_ppage kpp kP T{
previous-page key
T}
-key_previous kprv %8 T{
+key_previous kprv %8 T{
previous key
T}
-key_print kprt %9 T{
+key_print kprt %9 T{
print key
T}
-key_redo krdo %0 T{
+key_redo krdo %0 T{
redo key
T}
-key_reference kref &1 T{
+key_reference kref &1 T{
reference key
T}
-key_refresh krfr &2 T{
+key_refresh krfr &2 T{
refresh key
T}
-key_replace krpl &3 T{
+key_replace krpl &3 T{
replace key
T}
-key_restart krst &4 T{
+key_restart krst &4 T{
restart key
T}
-key_resume kres &5 T{
+key_resume kres &5 T{
resume key
T}
-key_right kcuf1 kr T{
+key_right kcuf1 kr T{
right-arrow key
T}
-key_save ksav &6 T{
+key_save ksav &6 T{
save key
T}
-key_sbeg kBEG &9 T{
+key_sbeg kBEG &9 T{
shifted begin key
T}
-key_scancel kCAN &0 T{
+key_scancel kCAN &0 T{
shifted cancel key
T}
-key_scommand kCMD *1 T{
+key_scommand kCMD *1 T{
shifted command key
T}
-key_scopy kCPY *2 T{
+key_scopy kCPY *2 T{
shifted copy key
T}
-key_screate kCRT *3 T{
+key_screate kCRT *3 T{
shifted create key
T}
-key_sdc kDC *4 T{
+key_sdc kDC *4 T{
shifted delete-character key
T}
-key_sdl kDL *5 T{
+key_sdl kDL *5 T{
shifted delete-line key
T}
-key_select kslt *6 T{
+key_select kslt *6 T{
select key
T}
-key_send kEND *7 T{
+key_send kEND *7 T{
shifted end key
T}
-key_seol kEOL *8 T{
+key_seol kEOL *8 T{
shifted clear-to-end-of-line key
T}
-key_sexit kEXT *9 T{
+key_sexit kEXT *9 T{
shifted exit key
T}
-key_sf kind kF T{
+key_sf kind kF T{
scroll-forward key
T}
-key_sfind kFND *0 T{
+key_sfind kFND *0 T{
shifted find key
T}
-key_shelp kHLP #1 T{
+key_shelp kHLP #1 T{
shifted help key
T}
-key_shome kHOM #2 T{
+key_shome kHOM #2 T{
shifted home key
T}
-key_sic kIC #3 T{
+key_sic kIC #3 T{
shifted insert-character key
T}
-key_sleft kLFT #4 T{
+key_sleft kLFT #4 T{
shifted left-arrow key
T}
-key_smessage kMSG %a T{
+key_smessage kMSG %a T{
shifted message key
T}
-key_smove kMOV %b T{
+key_smove kMOV %b T{
shifted move key
T}
-key_snext kNXT %c T{
+key_snext kNXT %c T{
shifted next key
T}
-key_soptions kOPT %d T{
+key_soptions kOPT %d T{
shifted options key
T}
-key_sprevious kPRV %e T{
+key_sprevious kPRV %e T{
shifted previous key
T}
-key_sprint kPRT %f T{
+key_sprint kPRT %f T{
shifted print key
T}
-key_sr kri kR T{
+key_sr kri kR T{
scroll-backward key
T}
-key_sredo kRDO %g T{
+key_sredo kRDO %g T{
shifted redo key
T}
-key_sreplace kRPL %h T{
+key_sreplace kRPL %h T{
shifted replace key
T}
-key_sright kRIT %i T{
+key_sright kRIT %i T{
shifted right-arrow key
T}
-key_srsume kRES %j T{
+key_srsume kRES %j T{
shifted resume key
T}
-key_ssave kSAV !1 T{
+key_ssave kSAV !1 T{
shifted save key
T}
-key_ssuspend kSPD !2 T{
+key_ssuspend kSPD !2 T{
shifted suspend key
T}
-key_stab khts kT T{
+key_stab khts kT T{
set-tab key
T}
-key_sundo kUND !3 T{
+key_sundo kUND !3 T{
shifted undo key
T}
-key_suspend kspd &7 T{
+key_suspend kspd &7 T{
suspend key
T}
-key_undo kund &8 T{
+key_undo kund &8 T{
undo key
T}
-key_up kcuu1 ku T{
+key_up kcuu1 ku T{
up-arrow key
T}
-keypad_local rmkx ke T{
+keypad_local rmkx ke T{
leave 'keyboard_transmit' mode
T}
-keypad_xmit smkx ks T{
+keypad_xmit smkx ks T{
enter 'keyboard_transmit' mode
T}
-lab_f0 lf0 l0 T{
+lab_f0 lf0 l0 T{
label on function key f0 if not f0
T}
-lab_f1 lf1 l1 T{
+lab_f1 lf1 l1 T{
label on function key f1 if not f1
T}
-lab_f10 lf10 la T{
+lab_f10 lf10 la T{
label on function key f10 if not f10
T}
-lab_f2 lf2 l2 T{
+lab_f2 lf2 l2 T{
label on function key f2 if not f2
T}
-lab_f3 lf3 l3 T{
+lab_f3 lf3 l3 T{
label on function key f3 if not f3
T}
-lab_f4 lf4 l4 T{
+lab_f4 lf4 l4 T{
label on function key f4 if not f4
T}
-lab_f5 lf5 l5 T{
+lab_f5 lf5 l5 T{
label on function key f5 if not f5
T}
-lab_f6 lf6 l6 T{
+lab_f6 lf6 l6 T{
label on function key f6 if not f6
T}
-lab_f7 lf7 l7 T{
+lab_f7 lf7 l7 T{
label on function key f7 if not f7
T}
-lab_f8 lf8 l8 T{
+lab_f8 lf8 l8 T{
label on function key f8 if not f8
T}
-lab_f9 lf9 l9 T{
+lab_f9 lf9 l9 T{
label on function key f9 if not f9
T}
-label_format fln Lf T{
+label_format fln Lf T{
label format
T}
-label_off rmln LF T{
+label_off rmln LF T{
turn off soft labels
T}
-label_on smln LO T{
+label_on smln LO T{
turn on soft labels
T}
-meta_off rmm mo T{
+meta_off rmm mo T{
turn off meta mode
T}
-meta_on smm mm T{
+meta_on smm mm T{
turn on meta mode (8th-bit on)
T}
micro_column_address mhpa ZY T{
Like column_address in micro mode
T}
-micro_down mcud1 ZZ T{
+micro_down mcud1 ZZ T{
Like cursor_down in micro mode
T}
-micro_left mcub1 Za T{
+micro_left mcub1 Za T{
Like cursor_left in micro mode
T}
-micro_right mcuf1 Zb T{
+micro_right mcuf1 Zb T{
Like cursor_right in micro mode
T}
micro_row_address mvpa Zc T{
-Like row_address in micro mode
+Like row_address #1 in micro mode
T}
-micro_up mcuu1 Zd T{
+micro_up mcuu1 Zd T{
Like cursor_up in micro mode
T}
-newline nel nw T{
+newline nel nw T{
newline (behave like cr followed by lf)
T}
-order_of_pins porder Ze T{
+order_of_pins porder Ze T{
Match software bits to print-head pins
T}
-orig_colors oc oc T{
+orig_colors oc oc T{
Set all color pairs to the original ones
T}
-orig_pair op op T{
+orig_pair op op T{
Set default pair to its original value
T}
-pad_char pad pc T{
+pad_char pad pc T{
padding char (instead of null)
T}
-parm_dch dch DC T{
+parm_dch dch DC T{
delete #1 characters (P*)
T}
parm_delete_line dl DL T{
@@ -1243,13 +1252,13 @@ T}
parm_down_cursor cud DO T{
down #1 lines (P*)
T}
-parm_down_micro mcud Zf T{
+parm_down_micro mcud Zf T{
Like parm_down_cursor in micro mode
T}
-parm_ich ich IC T{
+parm_ich ich IC T{
insert #1 characters (P*)
T}
-parm_index indn SF T{
+parm_index indn SF T{
scroll forward #1 lines (P)
T}
parm_insert_line il AL T{
@@ -1258,7 +1267,7 @@ T}
parm_left_cursor cub LE T{
move #1 characters to the left (P)
T}
-parm_left_micro mcub Zg T{
+parm_left_micro mcub Zg T{
Like parm_left_cursor in micro mode
T}
parm_right_cursor cuf RI T{
@@ -1267,110 +1276,110 @@ T}
parm_right_micro mcuf Zh T{
Like parm_right_cursor in micro mode
T}
-parm_rindex rin SR T{
+parm_rindex rin SR T{
scroll back #1 lines (P)
T}
-parm_up_cursor cuu UP T{
+parm_up_cursor cuu UP T{
up #1 lines (P*)
T}
-parm_up_micro mcuu Zi T{
+parm_up_micro mcuu Zi T{
Like parm_up_cursor in micro mode
T}
-pkey_key pfkey pk T{
+pkey_key pfkey pk T{
program function key #1 to type string #2
T}
-pkey_local pfloc pl T{
+pkey_local pfloc pl T{
program function key #1 to execute string #2
T}
-pkey_xmit pfx px T{
+pkey_xmit pfx px T{
program function key #1 to transmit string #2
T}
-plab_norm pln pn T{
+plab_norm pln pn T{
program label #1 to show string #2
T}
-print_screen mc0 ps T{
+print_screen mc0 ps T{
print contents of screen
T}
-prtr_non mc5p pO T{
+prtr_non mc5p pO T{
turn on printer for #1 bytes
T}
-prtr_off mc4 pf T{
+prtr_off mc4 pf T{
turn off printer
T}
-prtr_on mc5 po T{
+prtr_on mc5 po T{
turn on printer
T}
-pulse pulse PU T{
+pulse pulse PU T{
select pulse dialing
T}
-quick_dial qdial QD T{
+quick_dial qdial QD T{
dial number #1 without checking
T}
-remove_clock rmclk RC T{
+remove_clock rmclk RC T{
remove clock
T}
-repeat_char rep rp T{
+repeat_char rep rp T{
repeat char #1 #2 times (P*)
T}
-req_for_input rfi RF T{
+req_for_input rfi RF T{
send next input char (for ptys)
T}
-reset_1string rs1 r1 T{
+reset_1string rs1 r1 T{
reset string
T}
-reset_2string rs2 r2 T{
+reset_2string rs2 r2 T{
reset string
T}
-reset_3string rs3 r3 T{
+reset_3string rs3 r3 T{
reset string
T}
-reset_file rf rf T{
+reset_file rf rf T{
name of reset file
T}
-restore_cursor rc rc T{
+restore_cursor rc rc T{
restore cursor to position of last save_cursor
T}
-row_address vpa cv T{
+row_address vpa cv T{
vertical position #1 absolute (P)
T}
-save_cursor sc sc T{
+save_cursor sc sc T{
save current cursor position (P)
T}
-scroll_forward ind sf T{
+scroll_forward ind sf T{
scroll text up (P)
T}
-scroll_reverse ri sr T{
+scroll_reverse ri sr T{
scroll text down (P)
T}
-select_char_set scs Zj T{
-Select character set
+select_char_set scs Zj T{
+Select character set, #1
T}
-set_attributes sgr sa T{
+set_attributes sgr sa T{
define video attributes #1-#9 (PG9)
T}
-set_background setb Sb T{
+set_background setb Sb T{
Set background color #1
T}
set_bottom_margin smgb Zk T{
Set bottom margin at current line
T}
set_bottom_margin_parm smgbp Zl T{
-Set bottom margin at line #1 or #2 lines from bottom
+Set bottom margin at line #1 or (if smgtp is not given) #2 lines from bottom
T}
-set_clock sclk SC T{
+set_clock sclk SC T{
set clock, #1 hrs #2 mins #3 secs
T}
-set_color_pair scp sp T{
+set_color_pair scp sp T{
Set current color pair to #1
T}
-set_foreground setf Sf T{
+set_foreground setf Sf T{
Set foreground color #1
T}
-set_left_margin smgl ML T{
-set left soft margin at current column
+set_left_margin smgl ML T{
+set left soft margin at current column. See smgl. (ML is not in BSD termcap).
T}
set_left_margin_parm smglp Zm T{
-Set left (right) margin at column #1 (#2)
+Set left (right) margin at column #1
T}
set_right_margin smgr MR T{
set right soft margin at current column
@@ -1378,29 +1387,29 @@ T}
set_right_margin_parm smgrp Zn T{
Set right margin at column #1
T}
-set_tab hts st T{
+set_tab hts st T{
set a tab in every row, current columns
T}
-set_top_margin smgt Zo T{
+set_top_margin smgt Zo T{
Set top margin at current line
T}
set_top_margin_parm smgtp Zp T{
-Set top (bottom) margin at row #1 (#2)
+Set top (bottom) margin at row #1
T}
-set_window wind wi T{
+set_window wind wi T{
current window is lines #1-#2 cols #3-#4
T}
-start_bit_image sbim Zq T{
+start_bit_image sbim Zq T{
Start printing bit image graphics
T}
start_char_set_def scsd Zr T{
-Start character set definition
+Start character set definition #1, with #2 characters in the set
T}
-stop_bit_image rbim Zs T{
+stop_bit_image rbim Zs T{
Stop printing bit image graphics
T}
stop_char_set_def rcsd Zt T{
-End definition of character set
+End definition of character set #1
T}
subscript_characters subcs Zu T{
List of subscriptable characters
@@ -1408,64 +1417,64 @@ T}
superscript_characters supcs Zv T{
List of superscriptable characters
T}
-tab ht ta T{
+tab ht ta T{
tab to next 8-space hardware tab stop
T}
-these_cause_cr docr Zw T{
+these_cause_cr docr Zw T{
Printing any of these characters causes CR
T}
-to_status_line tsl ts T{
-move to status line
+to_status_line tsl ts T{
+move to status line, column #1
T}
-tone tone TO T{
+tone tone TO T{
select touch tone dialing
T}
-underline_char uc uc T{
+underline_char uc uc T{
underline char and move past it
T}
-up_half_line hu hu T{
+up_half_line hu hu T{
half a line up
T}
-user0 u0 u0 T{
+user0 u0 u0 T{
User string #0
T}
-user1 u1 u1 T{
+user1 u1 u1 T{
User string #1
T}
-user2 u2 u2 T{
+user2 u2 u2 T{
User string #2
T}
-user3 u3 u3 T{
+user3 u3 u3 T{
User string #3
T}
-user4 u4 u4 T{
+user4 u4 u4 T{
User string #4
T}
-user5 u5 u5 T{
+user5 u5 u5 T{
User string #5
T}
-user6 u6 u6 T{
+user6 u6 u6 T{
User string #6
T}
-user7 u7 u7 T{
+user7 u7 u7 T{
User string #7
T}
-user8 u8 u8 T{
+user8 u8 u8 T{
User string #8
T}
-user9 u9 u9 T{
+user9 u9 u9 T{
User string #9
T}
-wait_tone wait WA T{
+wait_tone wait WA T{
wait for dial-tone
T}
-xoff_character xoffc XF T{
+xoff_character xoffc XF T{
XOFF character
T}
-xon_character xonc XN T{
+xon_character xonc XN T{
XON character
T}
-zero_motion zerom Zx T{
+zero_motion zerom Zx T{
No motion for subsequent character
T}
.TE
@@ -1494,23 +1503,23 @@ T}
bit_image_repeat birep Xy T{
Repeat bit image cell #1 #2 times
T}
-char_set_names csnm Zy T{
-List of character set names
+char_set_names csnm Zy T{
+Produce #1'th item from list of character set names
T}
-code_set_init csin ci T{
+code_set_init csin ci T{
Init sequence for multiple codesets
T}
-color_names colornm Yw T{
+color_names colornm Yw T{
Give name for color #1
T}
define_bit_image_region defbi Yx T{
Define rectangualar bit image region
T}
-device_type devt dv T{
+device_type devt dv T{
Indicate language/codeset support
T}
-display_pc_char dispc S1 T{
-Display PC character
+display_pc_char dispc S1 T{
+Display PC character #1
T}
end_bit_image_region endbi Yy T{
End a bit-image region
@@ -1527,55 +1536,55 @@ T}
exit_scancode_mode rmsc S5 T{
Exit PC scancode mode
T}
-get_mouse getm Gm T{
-Curses should get button events
+get_mouse getm Gm T{
+Curses should get button events, parameter #1 not documented.
T}
-key_mouse kmous Km T{
+key_mouse kmous Km T{
Mouse event has occurred
T}
-mouse_info minfo Mi T{
+mouse_info minfo Mi T{
Mouse status information
T}
-pc_term_options pctrm S6 T{
+pc_term_options pctrm S6 T{
PC terminal options
T}
-pkey_plab pfxl xl T{
+pkey_plab pfxl xl T{
Program function key #1 to type string #2 and show string #3
T}
-req_mouse_pos reqmp RQ T{
+req_mouse_pos reqmp RQ T{
Request mouse position
T}
-scancode_escape scesc S7 T{
+scancode_escape scesc S7 T{
Escape for scancode emulation
T}
-set0_des_seq s0ds s0 T{
-Shift to code set 0 (EUC set 0, ASCII)
+set0_des_seq s0ds s0 T{
+Shift to codeset 0 (EUC set 0, ASCII)
T}
-set1_des_seq s1ds s1 T{
-Shift to code set 1
+set1_des_seq s1ds s1 T{
+Shift to codeset 1
T}
-set2_des_seq s2ds s2 T{
-Shift to code set 2
+set2_des_seq s2ds s2 T{
+Shift to codeset 2
T}
-set3_des_seq s3ds s3 T{
-Shift to code set 3
+set3_des_seq s3ds s3 T{
+Shift to codeset 3
T}
set_a_background setab AB T{
-Set background color using ANSI escape
+Set background color to #1, using ANSI escape
T}
set_a_foreground setaf AF T{
-Set foreground color using ANSI escape
+Set foreground color to #1, using ANSI escape
T}
-set_color_band setcolor Yz T{
+set_color_band setcolor Yz T{
Change to ribbon color #1
T}
-set_lr_margin smglr ML T{
-Set both left and right margins to #1, #2
+set_lr_margin smglr ML T{
+Set both left and right margins to #1, #2. (ML is not in BSD termcap).
T}
-set_page_length slines YZ T{
+set_page_length slines YZ T{
Set page length to #1 lines
T}
-set_tb_margin smgtb MT T{
+set_tb_margin smgtb MT T{
Sets both top and bottom margins to #1, #2
T}
.TE
@@ -1618,17 +1627,19 @@ T}
set_a_attributes sgr1 sA T{
Define second set of video attributes #1-#6
T}
-set_pglen_inch slength sL T{
+set_pglen_inch slength sL T{
YI Set page length to #1 hundredth of an inch
T}
.TE
.ad
-.\" $From: terminfo.tail,v 1.33 2000/10/14 14:06:50 tom Exp $
+.\" $Id: terminfo.5tbl,v 1.13 2010/01/12 23:21:59 nicm Exp $
.\" Beginning of terminfo.tail file
+.\" This file is part of ncurses.
+.\" See "terminfo.head" for copyright.
.ps +1
-.PP
+.
.SS A Sample Entry
-.PP
+.
The following entry, describing an ANSI-standard terminal, is representative
of what a \fBterminfo\fR entry for a modern terminal typically looks like.
.PP
@@ -1674,7 +1685,8 @@ terminal operations.
.PP
.SS Types of Capabilities
.PP
-All capabilities have names. For instance, the fact that
+All capabilities have names.
+For instance, the fact that
ANSI-standard terminals have
.I "automatic margins"
(i.e., an automatic return and line-feed
@@ -1691,7 +1703,8 @@ sequence) are given by the two-character code, an `=', and then a string
ending at the next following `,'.
.PP
A number of escape sequences are provided in the string valued capabilities
-for easy encoding of characters there. Both \fB\eE\fR and \fB\ee\fR
+for easy encoding of characters there.
+Both \fB\eE\fR and \fB\ee\fR
map to an \s-1ESCAPE\s0 character,
\fB^x\fR maps to a control-x for any appropriate x, and the sequences
\fB\en \el \er \et \eb \ef \es\fR give
@@ -1702,21 +1715,26 @@ Other escapes include \fB\e^\fR for \fB^\fR,
\fB\e:\fR for \fB:\fR,
and \fB\e0\fR for null.
(\fB\e0\fR will produce \e200, which does not terminate a string but behaves
-as a null character on most terminals, providing CS7 is specified. See stty(1).)
+as a null character on most terminals, providing CS7 is specified.
+See stty(1).)
Finally, characters may be given as three octal digits after a \fB\e\fR.
.PP
A delay in milliseconds may appear anywhere in a string capability, enclosed in
$<..> brackets, as in \fBel\fP=\eEK$<5>, and padding characters are supplied by
.I tputs
-to provide this delay. The delay must be a number with at most one decimal
-place of precision; it may be followed by suffixes `*' or '/' or both. A `*'
+to provide this delay.
+The delay must be a number with at most one decimal
+place of precision; it may be followed by suffixes `*' or '/' or both.
+A `*'
indicates that the padding required is proportional to the number of lines
affected by the operation, and the amount given is the per-affected-unit
-padding required. (In the case of insert character, the factor is still the
+padding required.
+(In the case of insert character, the factor is still the
number of
.IR lines
affected.) Normally, padding is advisory if the device has the \fBxon\fR
-capability; it is used for cost computation but does not trigger delays. A `/'
+capability; it is used for cost computation but does not trigger delays.
+A `/'
suffix indicates that the padding is mandatory and forces a delay of the given
number of milliseconds even on devices for which \fBxon\fR is present to
indicate flow control.
@@ -1732,7 +1750,8 @@ in the example above.
.SS Fetching Compiled Descriptions
.PP
If the environment variable TERMINFO is set, it is interpreted as the pathname
-of a directory containing the compiled description you are working on. Only
+of a directory containing the compiled description you are working on.
+Only
that directory is searched.
.PP
If TERMINFO is not set, the \fBncurses\fR version of the terminfo reader code
@@ -1741,7 +1760,8 @@ for a compiled description.
If it fails to find one there, and the environment variable TERMINFO_DIRS is
set, it will interpret the contents of that variable as a list of colon-
separated directories to be searched (an empty entry is interpreted as a
-command to search \fI\*d\fR). If no description is found in any of the
+command to search \fI\*d\fR).
+If no description is found in any of the
TERMINFO_DIRS directories, the fetch fails.
.PP
If neither TERMINFO nor TERMINFO_DIRS is set, the last place tried will be the
@@ -1776,7 +1796,8 @@ A similar test can be used for insert character.
.SS Basic Capabilities
.PP
The number of columns on each line for the terminal is given by the
-\fBcols\fR numeric capability. If the terminal is a \s-1CRT\s0, then the
+\fBcols\fR numeric capability.
+If the terminal is a \s-1CRT\s0, then the
number of lines on the screen is given by the \fBlines\fR capability.
If the terminal wraps around to the beginning of the next line when
it reaches the right margin, then it should have the \fBam\fR capability.
@@ -1886,22 +1907,22 @@ Thus the model 33 teletype is described as
.DT
.nf
.ft CW
-.in -7
- \s-133\||\|tty33\||\|tty\||\|model 33 teletype,
+.\".in -2
+\s-133\||\|tty33\||\|tty\||\|model 33 teletype,
bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
-.in +7
+.\".in +2
.ft R
.PP
-while the Lear Siegler \s-1ADM\-3\s0 is described as
+while the Lear Siegler \s-1ADM-3\s0 is described as
.PP
.DT
.nf
.ft CW
-.in -7
- \s-1adm3\||\|3\||\|lsi adm3,
+.\".in -2
+\s-1adm3\||\|3\||\|lsi adm3,
am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
ind=^J, lines#24,\s+1
-.in +7
+.\".in +2
.ft R
.fi
.PP
@@ -1910,7 +1931,7 @@ while the Lear Siegler \s-1ADM\-3\s0 is described as
Cursor addressing and other strings requiring parameters
in the terminal are described by a
parameterized string capability, with
-.IR printf (3
+.IR printf (3)
like escapes \fB%x\fR in it.
For example, to address the cursor, the
.B cup
@@ -1923,51 +1944,107 @@ that can be indicated by
.BR mrcup .
.PP
The parameter mechanism uses a stack and special \fB%\fP codes
-to manipulate it. Typically a sequence will push one of the
+to manipulate it.
+Typically a sequence will push one of the
parameters onto the stack and then print it in some format.
-Often more complex operations are necessary.
+Print (e.g., "%d") is a special case.
+Other operations, including "%t" pop their operand from the stack.
+It is noted that more complex operations are often necessary,
+e.g., in the \fBsgr\fP string.
.PP
The \fB%\fR encodings have the following meanings:
.PP
-.DT
-.nf
-.ta .5i 1.5i
- \s-1%% outputs `%'
- %\fI[[\fP:\fI]flags][width[.precision]][\fPdoxXs\fI]\fP
- as in \fBprintf\fP, flags are [-+#] and space
- %c print pop() like %c in printf()
- %s print pop() like %s in printf()
-
- %p[1-9] push \fIi\fP'th parm
- %P[a-z] set dynamic variable [a-z] to pop()
- %g[a-z] get dynamic variable [a-z] and push it
- %P[A-Z] set static variable [a-z] to pop()
- %g[A-Z] get static variable [a-z] and push it
- %'\fIc\fP' char constant \fIc\fP
- %{\fInn\fP} integer constant \fInn\fP
- %l push strlen(pop)
-
- %+ %- %* %/ %m
- arithmetic (%m is mod): push(pop() op pop())
- %& %| %^ bit operations: push(pop() op pop())
- %= %> %< logical operations: push(pop() op pop())
- %A, %O logical and & or operations (for conditionals)
- %! %~ unary operations push(op pop())
- %i add 1 to first two parameters (for ANSI terminals)
-
- %? expr %t thenpart %e elsepart %;
- if-then-else, %e elsepart is optional.
- else-if's are possible a la Algol 68:
- %? c\d1\u %t b\d1\u %e c\d2\u %t b\d2\u %e c\d3\u %t b\d3\u %e c\d4\u %t b\d4\u %e %;
-\s+1 c\di\u are conditions, b\di\u are bodies.
-.fi
+.TP 5
+\s-1%%
+outputs `%'
+.TP
+%\fI[[\fP:\fI]flags][width[.precision]][\fPdoxXs\fI]\fP
+as in \fBprintf\fP, flags are [-+#] and space.
+Use a `:' to allow the next character to be a `-' flag,
+avoiding interpreting "%-" as an operator.
+.TP
+%c
+print pop() like %c in \fBprintf\fP
+.TP
+%s
+print pop() like %s in \fBprintf\fP
+.TP
+%p[1-9]
+push \fIi\fP'th parameter
+.TP
+%P[a-z]
+set dynamic variable [a-z] to pop()
+.TP
+%g[a-z]
+get dynamic variable [a-z] and push it
+.TP
+%P[A-Z]
+set static variable [a-z] to pop()
+.TP
+%g[A-Z]
+get static variable [a-z] and push it
+.IP
+The terms "static" and "dynamic" are misleading.
+Historically, these are simply two different sets of variables,
+whose values are not reset between calls to \fBtparm\fP.
+However, that fact is not documented in other implementations.
+Relying on it will adversely impact portability to other implementations.
+.TP
+%'\fIc\fP'
+char constant \fIc\fP
+.TP
+%{\fInn\fP}
+integer constant \fInn\fP
+.TP
+%l
+push strlen(pop)
+.TP
+%+ %- %* %/ %m
+arithmetic (%m is mod): push(pop() op pop())
+.TP
+%& %| %^
+bit operations (AND, OR and exclusive-OR): push(pop() op pop())
+.TP
+%= %> %<
+logical operations: push(pop() op pop())
+.TP
+%A, %O
+logical AND and OR operations (for conditionals)
+.TP
+%! %~
+unary operations (logical and bit complement): push(op pop())
+.TP
+%i
+add 1 to first two parameters (for ANSI terminals)
+.TP
+%? \fIexpr\fP %t \fIthenpart\fP %e \fIelsepart\fP %;
+This forms an if-then-else.
+The %e \fIelsepart\fP is optional.
+Usually the %? \fIexpr\fP part pushes a value onto the stack,
+and %t pops it from the stack, testing if it is nonzero (true).
+If it is zero (false), control passes to the %e (else) part.
+.IP
+It is possible to form else-if's a la Algol 68:
+.RS
+%? c\d1\u %t b\d1\u %e c\d2\u %t b\d2\u %e c\d3\u %t b\d3\u %e c\d4\u %t b\d4\u %e %;
+.RE
+.IP
+where c\di\u are conditions, b\di\u are bodies.
+.IP
+Use the \fB-f\fP option of \fBtic\fP or \fBinfocmp\fP to see
+the structure of if-the-else's.
+Some strings, e.g., \fBsgr\fP can be very complicated when written
+on one line.
+The \fB-f\fP option splits the string into lines with the parts indented.
.PP
Binary operations are in postfix form with the operands in the usual order.
-That is, to get x-5 one would use "%gx%{5}%-". %P and %g variables are
+That is, to get x-5 one would use "%gx%{5}%-".
+%P and %g variables are
persistent across escape-string evaluations.
.PP
Consider the HP2645, which, to get to row 3 and column 12, needs
-to be sent \eE&a12c03Y padded for 6 milliseconds. Note that the order
+to be sent \eE&a12c03Y padded for 6 milliseconds.
+Note that the order
of the rows and columns is inverted here, and that the row and column
are printed as two digits.
Thus its \fBcup\fR capability is \*(lqcup=6\eE&%p2%2dc%p1%2dY\*(rq.
@@ -2064,7 +2141,8 @@ is not available.)
.PP
If the terminal can open a new blank line before the line where the cursor
is, this should be given as \fBil1\fR; this is done only from the first
-position of a line. The cursor must then appear on the newly blank line.
+position of a line.
+The cursor must then appear on the newly blank line.
If the terminal can delete the line which the cursor is on, then this
should be given as \fBdl1\fR; this is done only from the first position on
the line to be deleted.
@@ -2110,12 +2188,15 @@ on many terminals without a true insert/delete line,
and is often faster even on terminals with those features.
.PP
The boolean \fBnon_dest_scroll_region\fR should be set if each scrolling
-window is effectively a view port on a screen-sized canvas. To test for
+window is effectively a view port on a screen-sized canvas.
+To test for
this capability, create a scrolling region in the middle of the screen,
write something to the bottom line, move the cursor to the top of the region,
-and do \fBri\fR followed by \fBdl1\fR or \fBind\fR. If the data scrolled
+and do \fBri\fR followed by \fBdl1\fR or \fBind\fR.
+If the data scrolled
off the bottom of the region by the \fBri\fR re-appears, then scrolling
-is non-destructive. System V and XSI Curses expect that \fBind\fR, \fBri\fR,
+is non-destructive.
+System V and XSI Curses expect that \fBind\fR, \fBri\fR,
\fBindn\fR, and \fBrin\fR will simulate destructive scrolling; their
documentation cautions you not to define \fBcsr\fR unless this is true.
This \fBcurses\fR implementation is more liberal and will do explicit erases
@@ -2130,7 +2211,8 @@ and the starting and ending columns in memory, in that order.
.PP
If the terminal can retain display memory above, then the
\fBda\fR capability should be given; if display memory can be retained
-below, then \fBdb\fR should be given. These indicate
+below, then \fBdb\fR should be given.
+These indicate
that deleting a line or scrolling may bring non-blank lines up from below
or that scrolling back with \fBri\fR may bring down non-blank lines.
.PP
@@ -2144,19 +2226,23 @@ on the current line and shift characters off the end of the line rigidly.
Other terminals, such as the Concept 100 and the Perkin Elmer Owl, make
a distinction between typed and untyped blanks on the screen, shifting
upon an insert or delete only to an untyped blank on the screen which is
-either eliminated, or expanded to two untyped blanks. You can determine the
+either eliminated, or expanded to two untyped blanks.
+You can determine the
kind of terminal you have by clearing the screen and then typing
-text separated by cursor motions. Type \*(lqabc\ \ \ \ def\*(rq using local
+text separated by cursor motions.
+Type \*(lqabc\ \ \ \ def\*(rq using local
cursor motions (not spaces) between the \*(lqabc\*(rq and the \*(lqdef\*(rq.
Then position the cursor before the \*(lqabc\*(rq and put the terminal in insert
-mode. If typing characters causes the rest of the line to shift
+mode.
+If typing characters causes the rest of the line to shift
rigidly and characters to fall off the end, then your terminal does
-not distinguish between blanks and untyped positions. If the \*(lqabc\*(rq
+not distinguish between blanks and untyped positions.
+If the \*(lqabc\*(rq
shifts over to the \*(lqdef\*(rq which then move together around the end of the
current line and onto the next as you insert, you have the second type of
terminal, and should give the capability \fBin\fR, which stands for
\*(lqinsert null\*(rq.
-While these are two logically separate attributes (one line vs. multi-line
+While these are two logically separate attributes (one line versus multi-line
insert mode, and special treatment of untyped spaces) we have seen no
terminals whose insert mode cannot be described with the single attribute.
.PP
@@ -2165,24 +2251,30 @@ which send a simple sequence to open a blank position on the current line.
Give as \fBsmir\fR the sequence to get into insert mode.
Give as \fBrmir\fR the sequence to leave insert mode.
Now give as \fBich1\fR any sequence needed to be sent just before sending
-the character to be inserted. Most terminals with a true insert mode
+the character to be inserted.
+Most terminals with a true insert mode
will not give \fBich1\fR; terminals which send a sequence to open a screen
position should give it here.
.PP
If your terminal has both, insert mode is usually preferable to \fBich1\fR.
Technically, you should not give both unless the terminal actually requires
-both to be used in combination. Accordingly, some non-curses applications get
+both to be used in combination.
+Accordingly, some non-curses applications get
confused if both are present; the symptom is doubled characters in an update
-using insert. This requirement is now rare; most \fBich\fR sequences do not
+using insert.
+This requirement is now rare; most \fBich\fR sequences do not
require previous smir, and most smir insert modes do not require \fBich1\fR
-before each character. Therefore, the new \fBcurses\fR actually assumes this
+before each character.
+Therefore, the new \fBcurses\fR actually assumes this
is the case and uses either \fBrmir\fR/\fBsmir\fR or \fBich\fR/\fBich1\fR as
-appropriate (but not both). If you have to write an entry to be used under
+appropriate (but not both).
+If you have to write an entry to be used under
new curses for a terminal old enough to need both, include the
\fBrmir\fR/\fBsmir\fR sequences in \fBich1\fR.
.PP
If post insert padding is needed, give this as a number of milliseconds
-in \fBip\fR (a string option). Any other sequence which may need to be
+in \fBip\fR (a string option).
+Any other sequence which may need to be
sent after an insert of a single character may also be given in \fBip\fR.
If your terminal needs both to be placed into an `insert mode' and
a special code to precede each inserted character, then both
@@ -2204,9 +2296,12 @@ in insert mode, give this as a number of milliseconds padding in \fBrmp\fP.
.PP
It is occasionally necessary to move around while in insert mode
to delete characters on the same line (e.g., if there is a tab after
-the insertion position). If your terminal allows motion while in
+the insertion position).
+If your terminal allows motion while in
insert mode you can give the capability \fBmir\fR to speed up inserting
-in this case. Omitting \fBmir\fR will affect only speed. Some terminals
+in this case.
+Omitting \fBmir\fR will affect only speed.
+Some terminals
(notably Datamedia's) must not have \fBmir\fR because of the way their
insert mode works.
.PP
@@ -2356,6 +2451,12 @@ Putting this all together into the sgr sequence gives:
.fi
.PP
Remember that if you specify sgr, you must also specify sgr0.
+Also, some implementations rely on sgr being given if sgr0 is,
+Not all terminfo entries necessarily have an sgr string, however.
+Many terminfo entries are derived from termcap entries
+which have no sgr string.
+The only drawback to adding an sgr string is that termcap also
+assumes that sgr0 does not exit alternate character set mode.
.PP
Terminals with the ``magic cookie'' glitch
.RB ( xmc )
@@ -2397,7 +2498,8 @@ then this should be indicated by giving \fBeo\fR.
.SS Keypad and Function Keys
.PP
If the terminal has a keypad that transmits codes when the keys are pressed,
-this information can be given. Note that it is not possible to handle
+this information can be given.
+Note that it is not possible to handle
terminals where the keypad only works in local (this applies, for example,
to the unshifted HP 2621 keys).
If the keypad can be set to transmit or not transmit,
@@ -2530,25 +2632,33 @@ option of the
.IR tput
program, each time the user logs in.
They will be printed in the following order:
+.RS
+.TP
run the program
-.BR iprog ;
+.BR iprog
+.TP
output
-.BR is1 ;
-.BR is2 ;
+.BR is1
+.BR is2
+.TP
set the margins using
.BR mgc ,
.BR smgl
and
-.BR smgr ;
+.BR smgr
+.TP
set tabs using
.B tbc
and
-.BR hts ;
+.BR hts
+.TP
print the file
-.BR if ;
+.BR if
+.TP
and finally
output
.BR is3 .
+.RE
.PP
Most initialization is done with
.BR is2 .
@@ -2559,17 +2669,21 @@ and special cases in
.B is1
and
.BR is3 .
-A pair of sequences that does a harder reset from a totally unknown state
-can be analogously given as
+.PP
+A set of sequences that does a harder reset from a totally unknown state
+can be given as
.BR rs1 ,
.BR rs2 ,
-.BR rf ,
+.BR rf
and
.BR rs3 ,
analogous to
-.B is2
+.B is1 ,
+.B is2 ,
+.B if
and
-.BR if .
+.BR is3
+respectively.
These strings are output by the
.IR reset
program, which is used when the terminal gets into a wedged state.
@@ -2587,6 +2701,28 @@ normally be part of
but it causes an annoying glitch of the screen and is not normally
needed since the terminal is usually already in 80 column mode.
.PP
+The
+.IR reset
+program writes strings
+including
+.BR iprog ,
+etc., in the same order as the
+.IR init
+program, using
+.BR rs1 ,
+etc., instead of
+.BR is1 ,
+etc.
+If any of
+.BR rs1 ,
+.BR rs2 ,
+.BR rs3 ,
+or
+.BR rf
+reset capability strings are missing, the
+.IR reset
+program falls back upon the corresponding initialization capability string.
+.PP
If there are commands to set and clear tab stops, they can be given as
.B tbc
(clear all tab stops)
@@ -2600,23 +2736,26 @@ or
.BR if .
.SS Delays and Padding
.PP
-Many older and slower terminals don't support either XON/XOFF or DTR
+Many older and slower terminals do not support either XON/XOFF or DTR
handshaking, including hard copy terminals and some very archaic CRTs
-(including, for example, DEC VT100s). These may require padding characters
+(including, for example, DEC VT100s).
+These may require padding characters
after certain cursor motions and screen changes.
.PP
If the terminal uses xon/xoff handshaking for flow control (that is,
it automatically emits ^S back to the host when its input buffers are
close to full), set
.BR xon .
-This capability suppresses the emission of padding. You can also set it
-for memory-mapped console devices effectively that don't have a speed limit.
+This capability suppresses the emission of padding.
+You can also set it
+for memory-mapped console devices effectively that do not have a speed limit.
Padding information should still be included so that routines can
make better decisions about relative costs, but actual pad characters will
not be transmitted.
.PP
If \fBpb\fR (padding baud rate) is given, padding is suppressed at baud rates
-below the value of \fBpb\fR. If the entry has no padding baud rate, then
+below the value of \fBpb\fR.
+If the entry has no padding baud rate, then
whether padding is emitted or not is completely controlled by \fBxon\fR.
.PP
If the terminal requires other than a null (zero) character as a pad,
@@ -2632,25 +2771,30 @@ software (and thus not counted in the terminal's \fBlines\fR capability).
The simplest case is a status line which is cursor-addressable but not
part of the main scrolling region on the screen; the Heathkit H19 has
a status line of this kind, as would a 24-line VT100 with a 23-line
-scrolling region set up on initialization. This situation is indicated
+scrolling region set up on initialization.
+This situation is indicated
by the \fBhs\fR capability.
.PP
Some terminals with status lines need special sequences to access the
-status line. These may be expressed as a string with single parameter
+status line.
+These may be expressed as a string with single parameter
\fBtsl\fR which takes the cursor to a given zero-origin column on the
-status line. The capability \fBfsl\fR must return to the main-screen
-cursor positions before the last \fBtsl\fR. You may need to embed the
+status line.
+The capability \fBfsl\fR must return to the main-screen
+cursor positions before the last \fBtsl\fR.
+You may need to embed the
string values of \fBsc\fR (save cursor) and \fBrc\fR (restore cursor)
in \fBtsl\fR and \fBfsl\fR to accomplish this.
.PP
The status line is normally assumed to be the same width as the width
-of the terminal. If this is untrue, you can specify it with the numeric
+of the terminal.
+If this is untrue, you can specify it with the numeric
capability \fBwsl\fR.
.PP
A command to erase or blank the status line may be specified as \fBdsl\fR.
.PP
The boolean capability \fBeslok\fR specifies that escape sequences, tabs,
-etc. work ordinarily in the status line.
+etc., work ordinarily in the status line.
.PP
The \fBncurses\fR implementation does not yet use any of these capabilities.
They are documented here in case they ever become important.
@@ -2707,25 +2851,33 @@ vertical line ACS_VLINE | x
The best way to define a new device's graphics set is to add a column
to a copy of this table for your terminal, giving the character which
(when emitted between \fBsmacs\fR/\fBrmacs\fR switches) will be rendered
-as the corresponding graphic. Then read off the VT100/your terminal
+as the corresponding graphic.
+Then read off the VT100/your terminal
character pairs right to left in sequence; these become the ACSC string.
.PP
.SS Color Handling
.PP
-Most color terminals are either `Tektronix-like' or `HP-like'. Tektronix-like
+Most color terminals are either `Tektronix-like' or `HP-like'.
+Tektronix-like
terminals have a predefined set of N colors (where N usually 8), and can set
character-cell foreground and background characters independently, mixing them
-into N * N color-pairs. On HP-like terminals, the use must set each color
+into N * N color-pairs.
+On HP-like terminals, the use must set each color
pair up separately (foreground and background are not independently settable).
-Up to M color-pairs may be set up from 2*M different colors. ANSI-compatible
+Up to M color-pairs may be set up from 2*M different colors.
+ANSI-compatible
terminals are Tektronix-like.
.PP
-Some basic color capabilities are independent of the color method. The numeric
+Some basic color capabilities are independent of the color method.
+The numeric
capabilities \fBcolors\fR and \fBpairs\fR specify the maximum numbers of colors
-and color-pairs that can be displayed simultaneously. The \fBop\fR (original
+and color-pairs that can be displayed simultaneously.
+The \fBop\fR (original
pair) string resets foreground and background colors to their default values
-for the terminal. The \fBoc\fR string resets all colors or color-pairs to
-their default values for the terminal. Some terminals (including many PC
+for the terminal.
+The \fBoc\fR string resets all colors or color-pairs to
+their default values for the terminal.
+Some terminals (including many PC
terminal emulators) erase screen areas with the current background color rather
than the power-up default background; these should have the boolean capability
\fBbce\fR.
@@ -2733,19 +2885,24 @@ than the power-up default background; these should have the boolean capability
To change the current foreground or background color on a Tektronix-type
terminal, use \fBsetaf\fR (set ANSI foreground) and \fBsetab\fR (set ANSI
background) or \fBsetf\fR (set foreground) and \fBsetb\fR (set background).
-These take one parameter, the color number. The SVr4 documentation describes
+These take one parameter, the color number.
+The SVr4 documentation describes
only \fBsetaf\fR/\fBsetab\fR; the XPG4 draft says that "If the terminal
supports ANSI escape sequences to set background and foreground, they should
-be coded as \fBsetaf\fR and \fBsetab\fR, respectively. If the terminal
+be coded as \fBsetaf\fR and \fBsetab\fR, respectively.
+If the terminal
supports other escape sequences to set background and foreground, they should
-be coded as \fBsetf\fR and \fBsetb\fR, respectively. The \fIvidputs()\fR
+be coded as \fBsetf\fR and \fBsetb\fR, respectively.
+The \fIvidputs()\fR
function and the refresh functions use \fBsetaf\fR and \fBsetab\fR if they are
defined."
.PP
The \fBsetaf\fR/\fBsetab\fR and \fBsetf\fR/\fBsetb\fR capabilities take a
-single numeric argument each. Argument values 0-7 are portably defined as
+single numeric argument each.
+Argument values 0-7 of \fBsetaf\fR/\fBsetab\fR are portably defined as
follows (the middle column is the symbolic #define available in the header for
-the \fBcurses\fR or \fBncurses\fR libraries). The terminal hardware is free to
+the \fBcurses\fR or \fBncurses\fR libraries).
+The terminal hardware is free to
map these as it likes, but the RGB values indicate normal locations in color
space.
.PP
@@ -2764,26 +2921,54 @@ cyan \fBCOLOR_CYAN\fR 6 0,max,max
white \fBCOLOR_WHITE\fR 7 max,max,max
.TE
.PP
+The argument values of \fBsetf\fR/\fBsetb\fR historically correspond to
+a different mapping, i.e.,
+.TS H
+center;
+l c c c
+l l n l.
+\fBColor #define Value RGB\fR
+black \fBCOLOR_BLACK\fR 0 0, 0, 0
+blue \fBCOLOR_BLUE\fR 1 0,0,max
+green \fBCOLOR_GREEN\fR 2 0,max,0
+cyan \fBCOLOR_CYAN\fR 3 0,max,max
+red \fBCOLOR_RED\ \fR 4 max,0,0
+magenta \fBCOLOR_MAGENTA\fR 5 max,0,max
+yellow \fBCOLOR_YELLOW\fR 6 max,max,0
+white \fBCOLOR_WHITE\fR 7 max,max,max
+.TE
+It is important to not confuse the two sets of color capabilities;
+otherwise red/blue will be interchanged on the display.
+.PP
On an HP-like terminal, use \fBscp\fR with a color-pair number parameter to set
which color pair is current.
.PP
On a Tektronix-like terminal, the capability \fBccc\fR may be present to
-indicate that colors can be modified. If so, the \fBinitc\fR capability will
+indicate that colors can be modified.
+If so, the \fBinitc\fR capability will
take a color number (0 to \fBcolors\fR - 1)and three more parameters which
-describe the color. These three parameters default to being interpreted as RGB
-(Red, Green, Blue) values. If the boolean capability \fBhls\fR is present,
-they are instead as HLS (Hue, Lightness, Saturation) indices. The ranges are
+describe the color.
+These three parameters default to being interpreted as RGB
+(Red, Green, Blue) values.
+If the boolean capability \fBhls\fR is present,
+they are instead as HLS (Hue, Lightness, Saturation) indices.
+The ranges are
terminal-dependent.
.PP
On an HP-like terminal, \fBinitp\fR may give a capability for changing a
-color-pair value. It will take seven parameters; a color-pair number (0 to
+color-pair value.
+It will take seven parameters; a color-pair number (0 to
\fBmax_pairs\fR - 1), and two triples describing first background and then
-foreground colors. These parameters must be (Red, Green, Blue) or
+foreground colors.
+These parameters must be (Red, Green, Blue) or
(Hue, Lightness, Saturation) depending on \fBhls\fR.
.PP
-On some color terminals, colors collide with highlights. You can register
-these collisions with the \fBncv\fR capability. This is a bit-mask of
-attributes not to be used when colors are enabled. The correspondence with the
+On some color terminals, colors collide with highlights.
+You can register
+these collisions with the \fBncv\fR capability.
+This is a bit-mask of
+attributes not to be used when colors are enabled.
+The correspondence with the
attributes understood by \fBcurses\fR is as follows:
.PP
.TS
@@ -2803,7 +2988,8 @@ A_ALTCHARSET 8 256
.TE
.PP
For example, on many IBM PC consoles, the underline attribute collides with the
-foreground color blue and is not available in color mode. These should have
+foreground color blue and is not available in color mode.
+These should have
an \fBncv\fR capability of 2.
.PP
SVr4 curses does nothing with \fBncv\fR, ncurses recognizes it and optimizes
@@ -2938,7 +3124,8 @@ older versions, it was teleray_glitch.
This glitch is also taken to mean that it is not possible to position
the cursor on top of a ``magic cookie'',
that to erase standout mode it is instead necessary to use
-delete and insert line. The ncurses implementation ignores this glitch.
+delete and insert line.
+The ncurses implementation ignores this glitch.
.PP
The Beehive Superbee, which is unable to correctly transmit the escape
or control C characters, has
@@ -2954,15 +3141,18 @@ capabilities of the form \fBx\fR\fIx\fR.
.SS Similar Terminals
.PP
If there are two very similar terminals, one (the variant) can be defined as
-being just like the other (the base) with certain exceptions. In the
+being just like the other (the base) with certain exceptions.
+In the
definition of the variant, the string capability \fBuse\fR can be given with
-the name of the base terminal. The capabilities given before
+the name of the base terminal.
+The capabilities given before
.B use
override those in the base type named by
.BR use .
If there are multiple \fBuse\fR capabilities, they are merged in reverse order.
That is, the rightmost \fBuse\fR reference is processed first, then the one to
-its left, and so forth. Capabilities given explicitly in the entry override
+its left, and so forth.
+Capabilities given explicitly in the entry override
those brought in by \fBuse\fR references.
.PP
A capability can be canceled by placing \fBxx@\fR to the left of the
@@ -2979,32 +3169,39 @@ user preferences.
.SS Pitfalls of Long Entries
.PP
Long terminfo entries are unlikely to be a problem; to date, no entry has even
-approached terminfo's 4K string-table maximum. Unfortunately, the termcap
-translations are much more strictly limited (to 1K), thus termcap translations
+approached terminfo's 4096-byte string-table maximum.
+Unfortunately, the termcap
+translations are much more strictly limited (to 1023 bytes), thus termcap translations
of long terminfo entries can cause problems.
.PP
-The man pages for 4.3BSD and older versions of tgetent() instruct the user to
-allocate a 1K buffer for the termcap entry. The entry gets null-terminated by
+The man pages for 4.3BSD and older versions of \fBtgetent()\fP instruct the user to
+allocate a 1024-byte buffer for the termcap entry.
+The entry gets null-terminated by
the termcap library, so that makes the maximum safe length for a termcap entry
-1k-1 (1023) bytes. Depending on what the application and the termcap library
-being used does, and where in the termcap file the terminal type that tgetent()
+1k-1 (1023) bytes.
+Depending on what the application and the termcap library
+being used does, and where in the termcap file the terminal type that \fBtgetent()\fP
is searching for is, several bad things can happen.
.PP
Some termcap libraries print a warning message or exit if they find an
-entry that's longer than 1023 bytes; others don't; others truncate the
-entries to 1023 bytes. Some application programs allocate more than
-the recommended 1K for the termcap entry; others don't.
+entry that's longer than 1023 bytes; others do not; others truncate the
+entries to 1023 bytes.
+Some application programs allocate more than
+the recommended 1K for the termcap entry; others do not.
.PP
Each termcap entry has two important sizes associated with it: before
-"tc" expansion, and after "tc" expansion. "tc" is the capability that
+"tc" expansion, and after "tc" expansion.
+"tc" is the capability that
tacks on another termcap entry to the end of the current one, to add
-on its capabilities. If a termcap entry doesn't use the "tc"
+on its capabilities.
+If a termcap entry does not use the "tc"
capability, then of course the two lengths are the same.
.PP
The "before tc expansion" length is the most important one, because it
-affects more than just users of that particular terminal. This is the
+affects more than just users of that particular terminal.
+This is the
length of the entry as it exists in /etc/termcap, minus the
-backslash-newline pairs, which tgetent() strips out while reading it.
+backslash-newline pairs, which \fBtgetent()\fP strips out while reading it.
Some termcap libraries strip off the final newline, too (GNU termcap does not).
Now suppose:
.TP 5
@@ -3017,70 +3214,81 @@ and the application has only allocated a 1k buffer,
*
and the termcap library (like the one in BSD/OS 1.1 and GNU) reads
the whole entry into the buffer, no matter what its length, to see
-if it's the entry it wants,
+if it is the entry it wants,
.TP 5
*
-and tgetent() is searching for a terminal type that either is the
+and \fBtgetent()\fP is searching for a terminal type that either is the
long entry, appears in the termcap file after the long entry, or
-doesn't appear in the file at all (so that tgetent() has to search
+does not appear in the file at all (so that \fBtgetent()\fP has to search
the whole termcap file).
.PP
-Then tgetent() will overwrite memory, perhaps its stack, and probably core dump
-the program. Programs like telnet are particularly vulnerable; modern telnets
-pass along values like the terminal type automatically. The results are almost
+Then \fBtgetent()\fP will overwrite memory, perhaps its stack, and probably core dump
+the program.
+Programs like telnet are particularly vulnerable; modern telnets
+pass along values like the terminal type automatically.
+The results are almost
as undesirable with a termcap library, like SunOS 4.1.3 and Ultrix 4.4, that
-prints warning messages when it reads an overly long termcap entry. If a
+prints warning messages when it reads an overly long termcap entry.
+If a
termcap library truncates long entries, like OSF/1 3.0, it is immune to dying
here but will return incorrect data for the terminal.
.PP
The "after tc expansion" length will have a similar effect to the
above, but only for people who actually set TERM to that terminal
-type, since tgetent() only does "tc" expansion once it's found the
+type, since \fBtgetent()\fP only does "tc" expansion once it is found the
terminal type it was looking for, not while searching.
.PP
In summary, a termcap entry that is longer than 1023 bytes can cause,
on various combinations of termcap libraries and applications, a core
-dump, warnings, or incorrect operation. If it's too long even before
+dump, warnings, or incorrect operation.
+If it is too long even before
"tc" expansion, it will have this effect even for users of some other
terminal types and users whose TERM variable does not have a termcap
entry.
.PP
When in -C (translate to termcap) mode, the \fBncurses\fR implementation of
\fBtic\fR(1) issues warning messages when the pre-tc length of a termcap
-translation is too long. The -c (check) option also checks resolved (after tc
+translation is too long.
+The -c (check) option also checks resolved (after tc
expansion) lengths.
.SS Binary Compatibility
It is not wise to count on portability of binary terminfo entries between
-commercial UNIX versions. The problem is that there are at least two versions
+commercial UNIX versions.
+The problem is that there are at least two versions
of terminfo (under HP-UX and AIX) which diverged from System V terminfo after
SVr1, and have added extension capabilities to the string table that (in the
binary format) collide with System V and XSI Curses extensions.
.SH EXTENSIONS
-Some SVr4 \fBcurses\fR implementations, and all previous to SVr4, don't
+Some SVr4 \fBcurses\fR implementations, and all previous to SVr4, do not
interpret the %A and %O operators in parameter strings.
.PP
SVr4/XPG4 do not specify whether \fBmsgr\fR licenses movement while in
an alternate-character-set mode (such modes may, among other things, map
-CR and NL to characters that don't trigger local motions).
+CR and NL to characters that do not trigger local motions).
The \fBncurses\fR implementation ignores \fBmsgr\fR in \fBALTCHARSET\fR
-mode. This raises the possibility that an XPG4
+mode.
+This raises the possibility that an XPG4
implementation making the opposite interpretation may need terminfo
entries made for \fBncurses\fR to have \fBmsgr\fR turned off.
.PP
The \fBncurses\fR library handles insert-character and insert-character modes
-in a slightly non-standard way in order to get better update efficiency. See
+in a slightly non-standard way to get better update efficiency.
+See
the \fBInsert/Delete Character\fR subsection above.
.PP
The parameter substitutions for \fBset_clock\fR and \fBdisplay_clock\fR are
-not documented in SVr4 or the XSI Curses standard. They are deduced from the
+not documented in SVr4 or the XSI Curses standard.
+They are deduced from the
documentation for the AT&T 505 terminal.
.PP
-Be careful assigning the \fBkmous\fR capability. The \fBncurses\fR wants to
+Be careful assigning the \fBkmous\fR capability.
+The \fBncurses\fR wants to
interpret it as \fBKEY_MOUSE\fR, for use by terminals and emulators like xterm
that can return mouse-tracking information in the keyboard-input stream.
.PP
Different commercial ports of terminfo and curses support different subsets of
-the XSI Curses standard and (in some cases) different extension sets. Here
+the XSI Curses standard and (in some cases) different extension sets.
+Here
is a summary, accurate as of October 1995:
.PP
\fBSVR4, Solaris, ncurses\fR --
@@ -3091,7 +3299,8 @@ Supports the SVr4 set, adds one undocumented extended string
capability (\fBset_pglen\fR).
.PP
\fBSVr1, Ultrix\fR --
-These support a restricted subset of terminfo capabilities. The booleans
+These support a restricted subset of terminfo capabilities.
+The booleans
end with \fBxon_xoff\fR; the numerics with \fBwidth_status_line\fR; and the
strings with \fBprtr_non\fR.
.PP
@@ -3109,13 +3318,14 @@ of incompatible string table extensions.
Supports both the SVr4 set and the AIX extensions.
.SH FILES
.TP 25
-\*d.db
-file containing terminal descriptions on OpenBSD
-.TP 25
-/usr/share/terminfo/?/*
-files containing terminal descriptions on other systems
-.SH "SEE ALSO"
-\fBcap_mkdb(1)\fR, \fBtic\fR(1M), \fBcurses\fR(3), \fBprintf\fR(3), \fBterm\fR(\*n).
+\*d/?/*
+files containing terminal descriptions
+.SH SEE ALSO
+\fBtic\fR(1),
+\fBinfocmp\fR(1),
+\fBcurses\fR(3),
+\fBprintf\fR(3),
+\fBterm\fR(\*n).
.SH AUTHORS
Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
Based on pcurses by Pavel Curtis.
diff --git a/lib/libcurses/tic.h b/lib/libcurses/tic.h
index 64943ee9068..97181a66132 100644
--- a/lib/libcurses/tic.h
+++ b/lib/libcurses/tic.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: tic.h,v 1.13 2002/02/18 22:24:32 deraadt Exp $ */
+/* $OpenBSD: tic.h,v 1.14 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,10 +31,11 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
/*
- * $From: tic.h,v 1.36 2000/12/10 02:03:28 tom Exp $
+ * $Id: tic.h,v 1.14 2010/01/12 23:21:59 nicm Exp $
* tic.h - Global variables and structures for the terminfo
* compiler.
*/
@@ -78,6 +79,15 @@ extern "C" {
#define MAGIC 0432 /* first two bytes of a compiled entry */
+#undef BYTE
+#define BYTE(p,n) (unsigned char)((p)[n])
+
+#define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377))
+#define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377))
+#define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1))
+
+#define IS_TIC_MAGIC(p) (LOW_MSB(p) == MAGIC)
+
/*
* The "maximum" here is misleading; XSI guarantees minimum values, which a
* given implementation may exceed.
@@ -85,13 +95,14 @@ extern "C" {
#define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */
#define MAX_ENTRY_SIZE 4096 /* maximum legal entry size */
-/* The maximum size of individual name or alias is guaranteed in XSI to
- * be 14, since that corresponds to the older filename lengths. Newer
- * systems allow longer aliases, though not many terminal descriptions
- * are written to use them.
+/*
+ * The maximum size of individual name or alias is guaranteed in XSI to be at
+ * least 14, since that corresponds to the older filename lengths. Newer
+ * systems allow longer aliases, though not many terminal descriptions are
+ * written to use them. The MAX_ALIAS symbol is used for warnings.
*/
#if HAVE_LONG_FILE_NAMES
-#define MAX_ALIAS 32 /* POSIX minimum for PATH_MAX */
+#define MAX_ALIAS 32 /* smaller than POSIX minimum for PATH_MAX */
#else
#define MAX_ALIAS 14 /* SVr3 filename length */
#endif
@@ -106,10 +117,10 @@ extern "C" {
*/
#define MAX_DEBUG_LEVEL 15
-#define DEBUG_LEVEL(n) ((n) << 12) /* see TRACE_MAXIMUM */
+#define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT)
#define set_trace_level(n) \
- _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
+ _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
_nc_tracing |= DEBUG_LEVEL(n)
#ifdef TRACE
@@ -121,6 +132,7 @@ extern "C" {
extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
extern NCURSES_EXPORT(void) _nc_tracef (char *, ...) GCC_PRINTFLIKE(1,2);
extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
+extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
/*
* These are the types of tokens returned by the scanner. The first
@@ -154,16 +166,6 @@ struct token
extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token;
/*
- * List of keynames with their corresponding code.
- */
-struct kn {
- const char *name;
- int code;
-};
-
-extern NCURSES_EXPORT_VAR(const struct kn) _nc_key_names[];
-
- /*
* Offsets to string capabilities, with the corresponding functionkey
* codes.
*/
@@ -175,11 +177,11 @@ struct tinfo_fkeys {
#if BROKEN_LINKER
#define _nc_tinfo_fkeys _nc_tinfo_fkeysf()
-extern NCURSES_EXPORT(struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
+extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
#else
-extern NCURSES_EXPORT_VAR(struct tinfo_fkeys) _nc_tinfo_fkeys[];
+extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[];
#endif
@@ -204,30 +206,25 @@ struct alias
const char *source;
};
-extern NCURSES_EXPORT_VAR(const struct name_table_entry * const) _nc_info_hash_table[];
-extern NCURSES_EXPORT_VAR(const struct name_table_entry * const) _nc_cap_hash_table[];
-
-extern NCURSES_EXPORT_VAR(const struct alias) _nc_capalias_table[];
-extern NCURSES_EXPORT_VAR(const struct alias) _nc_infoalias_table[];
-
extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
-extern NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_table (bool);
+extern NCURSES_EXPORT(const short *) _nc_get_hash_table (bool);
+extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool);
#define NOTFOUND ((struct name_table_entry *) 0)
/* out-of-band values for representing absent capabilities */
-#define ABSENT_BOOLEAN -1
-#define ABSENT_NUMERIC -1
+#define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
+#define ABSENT_NUMERIC (-1)
#define ABSENT_STRING (char *)0
/* out-of-band values for representing cancels */
-#define CANCELLED_BOOLEAN (signed char)(-2)
-#define CANCELLED_NUMERIC -2
-#define CANCELLED_STRING (char *)-1
+#define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
+#define CANCELLED_NUMERIC (-2)
+#define CANCELLED_STRING (char *)(-1)
-#define VALID_BOOLEAN(s) ((s) >= 0)
+#define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
#define VALID_NUMERIC(s) ((s) >= 0)
-#define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
+#define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
/* termcap entries longer than this may break old binaries */
#define MAX_TERMCAP_LENGTH 1023
@@ -240,11 +237,16 @@ extern NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_tabl
#endif
/* access.c */
+extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *);
+extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *);
+extern NCURSES_EXPORT(bool) _nc_is_dir_path (const char *);
+extern NCURSES_EXPORT(bool) _nc_is_file_path (const char *);
extern NCURSES_EXPORT(char *) _nc_basename (char *);
+extern NCURSES_EXPORT(char *) _nc_rootname (char *);
/* comp_hash.c: name lookup */
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
- (const char *, const struct name_table_entry *const *);
+ (const char *, const short *);
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry
(const char *, int, const struct name_table_entry *);
@@ -264,11 +266,12 @@ extern NCURSES_EXPORT_VAR(long) _nc_start_line;
#define SYN_TERMCAP 1
/* comp_error.c: warning & abort messages */
-extern NCURSES_EXPORT(void) _nc_set_source (const char *const name);
+extern NCURSES_EXPORT(const char *) _nc_get_source (void);
+extern NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
extern NCURSES_EXPORT(void) _nc_get_type (char *name);
-extern NCURSES_EXPORT(void) _nc_set_type (const char *const name);
+extern NCURSES_EXPORT(void) _nc_set_source (const char *const);
+extern NCURSES_EXPORT(void) _nc_set_type (const char *const);
extern NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
-extern NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2);
extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
@@ -276,20 +279,50 @@ extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
/* comp_scan.c: decode string from readable form */
-extern NCURSES_EXPORT(char) _nc_trans_string (char *, char *);
+extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
/* captoinfo.c: capability conversion */
extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const);
+/* home_terminfo.c */
+extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
+
+/* lib_tparm.c */
+#define NUM_PARM 9
+
+extern NCURSES_EXPORT_VAR(int) _nc_tparm_err;
+
+extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *);
+
/* lib_tputs.c */
extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */
/* comp_main.c: compiler main */
extern const char * _nc_progname;
-/* read_entry.c */
+/* db_iterator.c */
+typedef enum {
+ dbdTIC = 0,
+#if USE_DATABASE
+ dbdEnvOnce,
+ dbdHome,
+ dbdEnvList,
+ dbdCfgList,
+ dbdCfgOnce,
+#endif
+#if USE_TERMCAP
+ dbdEnvOnce2,
+ dbdEnvList2,
+ dbdCfgList2,
+#endif
+ dbdLAST
+} DBDIRS;
+
+extern NCURSES_EXPORT(const char *) _nc_next_db(DBDIRS *, int *);
extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *);
+extern NCURSES_EXPORT(void) _nc_first_db(DBDIRS *, int *);
+extern NCURSES_EXPORT(void) _nc_last_db(void);
/* write_entry.c */
extern NCURSES_EXPORT(int) _nc_tic_written (void);
diff --git a/lib/libcurses/tinfo/MKcaptab.awk b/lib/libcurses/tinfo/MKcaptab.awk
index 4f5df3afdb2..b105931c55d 100644
--- a/lib/libcurses/tinfo/MKcaptab.awk
+++ b/lib/libcurses/tinfo/MKcaptab.awk
@@ -1,72 +1,95 @@
-#!/bin/sh
-# $OpenBSD: MKcaptab.awk,v 1.3 2001/01/22 18:01:49 millert Exp $
-# $From: MKcaptab.awk,v 1.12 2000/12/10 00:14:12 tom Exp $
-AWK=${1-awk}
-DATA=${2-../include/Caps}
-
-cat <<'EOF'
-/*
- * comp_captab.c -- The names of the capabilities indexed via a hash
- * table for the compiler.
- *
- */
-
-#include <ncurses_cfg.h>
-#include <curses.priv.h>
-#include <tic.h>
-#include <term.h>
-
-EOF
-
-./make_hash 1 info <$DATA
-./make_hash 3 cap <$DATA
-
-cat <<'EOF'
-const struct alias _nc_capalias_table[] =
-{
-EOF
+# $OpenBSD: MKcaptab.awk,v 1.4 2010/01/12 23:22:06 nicm Exp $
+##############################################################################
+# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+# $Id: MKcaptab.awk,v 1.4 2010/01/12 23:22:06 nicm Exp $
+function add_string(text) {
+ if (text != "IGNORE") {
+ offsets[num_strings] = offset;
+ offset = offset + length(text) + 1;
+ printf "%s\\0", text;
+ } else {
+ offsets[num_strings] = -1;
+ }
+ num_strings = num_strings + 1;
+ if ((num_strings % 3) == 0) {
+ printf "\\\n";
+ }
+ return offsets[num_strings - 1];
+}
+BEGIN {
+ first = 1;
+ num_aliases = 0;
+ num_strings = 0;
+ offset = 0;
+}
-$AWK <$DATA '
-$1 == "capalias" {
- if ($3 == "IGNORE")
- to = "(char *)NULL";
- else
- to = "\"" $3 "\"";
- printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
- $2, to, $4, $5
+/^[^#]/ {
+ if (first) {
+ printf "/* generated by MKcaptab.awk %s(%d) */\n", tablename, bigstrings;
+ print ""
+ if (bigstrings) {
+ printf "static struct alias *_nc_%s_table = 0;\n", tablename;
+ print "";
+ printf "static const char %s_text[] = \"\\\n", tablename;
+ } else {
+ printf "static const struct alias _nc_%s_table[] =\n", tablename;
+ printf "{\n";
}
-'
-
-cat <<'EOF'
- {(char *)NULL, (char *)NULL, (char *)NULL}
-};
-
-const struct alias _nc_infoalias_table[] =
-{
-EOF
-
-$AWK <$DATA '
-$1 == "infoalias" {
- if ($3 == "IGNORE")
- to = "(char *)NULL";
- else
- to = "\"" $3 "\"";
- printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
- $2, to, $4, $5
+ first = 0;
+ }
+ if ($1 == tablename) {
+ if ($3 == "IGNORE") {
+ to = "(char *)NULL";
+ } else {
+ to = "\"" $3 "\"";
}
-'
-
-cat <<'EOF'
- {(char *)NULL, (char *)NULL, (char *)NULL}
-};
-
-NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
-{
- return termcap ? _nc_cap_table: _nc_info_table ;
-}
-
-NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_table (bool termcap)
-{
- return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
-}
-EOF
+ if (bigstrings) {
+ c1 = add_string($2);
+ c2 = add_string($3);
+ c3 = add_string($4);
+ aliases[num_aliases] = sprintf("\t{%5d, %5d, %5d},\t /* %s */", c1, c2, c3, $5);
+ num_aliases = num_aliases + 1;
+ } else {
+ printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n", $2, to, $4, $5;
+ }
+ }
+ }
+END {
+ if (bigstrings) {
+ printf "\";\n\n";
+ printf "static const alias_table_data %s_data[] = {\n", tablename;
+ for (n = 0; n < num_aliases; ++n) {
+ printf "%s\n", aliases[n];
+ }
+ printf "};\n\n";
+ } else {
+ printf "\t{(char *)NULL, (char *)NULL, (char *)NULL}\n";
+ printf "};\n\n";
+ }
+ }
+# vile:sw=4:
diff --git a/lib/libcurses/tinfo/MKcaptab.sh b/lib/libcurses/tinfo/MKcaptab.sh
new file mode 100644
index 00000000000..d7305f2f88e
--- /dev/null
+++ b/lib/libcurses/tinfo/MKcaptab.sh
@@ -0,0 +1,150 @@
+#!/bin/sh
+# $OpenBSD: MKcaptab.sh,v 1.1 2010/01/12 23:22:06 nicm Exp $
+##############################################################################
+# Copyright (c) 2007 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+# $Id: MKcaptab.sh,v 1.1 2010/01/12 23:22:06 nicm Exp $
+AWK=${1-awk}
+OPT1=${2-0}
+OPT2=${3-tinfo/MKcaptab.awk}
+DATA=${4-../include/Caps}
+
+cat <<'EOF'
+/*
+ * comp_captab.c -- The names of the capabilities indexed via a hash
+ * table for the compiler.
+ *
+ */
+
+#include <curses.priv.h>
+#include <tic.h>
+#include <hashsize.h>
+
+EOF
+
+./make_hash 1 info $OPT1 <$DATA
+./make_hash 3 cap $OPT1 <$DATA
+
+$AWK -f $OPT2 bigstrings=$OPT1 tablename=capalias <$DATA
+
+$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias <$DATA
+
+cat <<EOF
+
+#if $OPT1
+static void
+next_string(const char *strings, unsigned *offset)
+{
+ *offset += strlen(strings + *offset) + 1;
+}
+
+static const struct name_table_entry *
+_nc_build_names(struct name_table_entry **actual,
+ const name_table_data *source,
+ const char *strings)
+{
+ if (*actual == 0) {
+ *actual = typeCalloc(struct name_table_entry, CAPTABSIZE);
+ if (*actual != 0) {
+ unsigned n;
+ unsigned len = 0;
+ for (n = 0; n < CAPTABSIZE; ++n) {
+ (*actual)[n].nte_name = strings + len;
+ (*actual)[n].nte_type = source[n].nte_type;
+ (*actual)[n].nte_index = source[n].nte_index;
+ (*actual)[n].nte_link = source[n].nte_link;
+ next_string(strings, &len);
+ }
+ }
+ }
+ return *actual;
+}
+
+#define add_alias(field) \\
+ if (source[n].field >= 0) { \\
+ (*actual)[n].field = strings + source[n].field; \\
+ }
+
+static const struct alias *
+_nc_build_alias(struct alias **actual,
+ const alias_table_data *source,
+ const char *strings,
+ unsigned tablesize)
+{
+ if (*actual == 0) {
+ *actual = typeCalloc(struct alias, tablesize + 1);
+ if (*actual != 0) {
+ unsigned n;
+ for (n = 0; n < tablesize; ++n) {
+ add_alias(from);
+ add_alias(to);
+ add_alias(source);
+ }
+ }
+ }
+ return *actual;
+}
+
+#define build_names(root) _nc_build_names(&_nc_##root##_table, \\
+ root##_names_data, \\
+ root##_names_text)
+#define build_alias(root) _nc_build_alias(&_nc_##root##alias_table, \\
+ root##alias_data, \\
+ root##alias_text, \\
+ SIZEOF(root##alias_data))
+#else
+#define build_names(root) _nc_ ## root ## _table
+#define build_alias(root) _nc_ ## root ## alias_table
+#endif
+
+NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool termcap)
+{
+ return termcap ? build_names(cap) : build_names(info) ;
+}
+
+NCURSES_EXPORT(const short *) _nc_get_hash_table (bool termcap)
+{
+ return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
+}
+
+NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool termcap)
+{
+ return termcap ? build_alias(cap) : build_alias(info) ;
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void) _nc_comp_captab_leaks(void)
+{
+#if $OPT1
+ FreeIfNeeded(_nc_cap_table);
+ FreeIfNeeded(_nc_info_table);
+ FreeIfNeeded(_nc_capalias_table);
+ FreeIfNeeded(_nc_infoalias_table);
+#endif
+}
+#endif /* NO_LEAKS */
+EOF
diff --git a/lib/libcurses/tinfo/MKcodes.awk b/lib/libcurses/tinfo/MKcodes.awk
new file mode 100644
index 00000000000..669f673c91b
--- /dev/null
+++ b/lib/libcurses/tinfo/MKcodes.awk
@@ -0,0 +1,165 @@
+# $OpenBSD: MKcodes.awk,v 1.1 2010/01/12 23:22:06 nicm Exp $
+##############################################################################
+# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+# $Id: MKcodes.awk,v 1.1 2010/01/12 23:22:06 nicm Exp $
+function large_item(value) {
+ result = sprintf("%d,", offset);
+ offset = offset + length(value) + 1;
+ offcol = offcol + length(result) + 2;
+ if (offcol > 70) {
+ result = result "\n";
+ offcol = 0;
+ } else {
+ result = result " ";
+ }
+ bigstr = bigstr sprintf("\"%s\\0\" ", value);
+ bigcol = bigcol + length(value) + 5;
+ if (bigcol > 70) {
+ bigstr = bigstr "\\\n";
+ bigcol = 0;
+ }
+ return result;
+}
+
+function small_item(value) {
+ return sprintf("\t\t\"%s\",\n", value);
+}
+
+function print_strings(name,value) {
+ printf "DCL(%s) = {\n", name
+ print value
+ print "\t\t(NCURSES_CONST char *)0,"
+ print "};"
+ print ""
+}
+
+function print_offsets(name,value) {
+ printf "static const short _nc_offset_%s[] = {\n", name
+ printf "%s", value
+ print "};"
+ print ""
+ printf "static NCURSES_CONST char ** ptr_%s = 0;\n", name
+ print ""
+}
+
+BEGIN {
+ print "/* This file was generated by MKcodes.awk */"
+ print ""
+ print "#include <curses.priv.h>"
+ print ""
+ print "#define IT NCURSES_CONST char * const"
+ print ""
+ offset = 0;
+ offcol = 0;
+ bigcol = 0;
+ }
+
+$1 ~ /^#/ {next;}
+
+$1 == "SKIPWARN" {next;}
+
+$3 == "bool" {
+ small_boolcodes = small_boolcodes small_item($4);
+ large_boolcodes = large_boolcodes large_item($4);
+ }
+
+$3 == "num" {
+ small_numcodes = small_numcodes small_item($4);
+ large_numcodes = large_numcodes large_item($4);
+ }
+
+$3 == "str" {
+ small_strcodes = small_strcodes small_item($4);
+ large_strcodes = large_strcodes large_item($4);
+ }
+
+END {
+ print ""
+ print "#if BROKEN_LINKER || USE_REENTRANT"
+ print ""
+ print "#include <term.h>"
+ print ""
+ if (bigstrings) {
+ printf "static const char _nc_code_blob[] = \n"
+ printf "%s;\n", bigstr;
+ print_offsets("boolcodes", large_boolcodes);
+ print_offsets("numcodes", large_numcodes);
+ print_offsets("strcodes", large_strcodes);
+ print ""
+ print "static IT *"
+ print "alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)"
+ print "{"
+ print " if (*value == 0) {"
+ print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
+ print " unsigned n;"
+ print " for (n = 0; n < size; ++n) {"
+ print " (*value)[n] = _nc_code_blob + offsets[n];"
+ print " }"
+ print " }"
+ print " }"
+ print " return *value;"
+ print "}"
+ print ""
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }"
+ } else {
+ print "#define DCL(it) static IT data##it[]"
+ print ""
+ print_strings("boolcodes", small_boolcodes);
+ print_strings("numcodes", small_numcodes);
+ print_strings("strcodes", small_strcodes);
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }"
+ }
+ print ""
+ print "FIX(boolcodes)"
+ print "FIX(numcodes)"
+ print "FIX(strcodes)"
+ print ""
+ print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
+ print ""
+ print "#if NO_LEAKS"
+ print "NCURSES_EXPORT(void)"
+ print "_nc_codes_leaks(void)"
+ print "{"
+ if (bigstrings) {
+ print "FREE_FIX(boolcodes)"
+ print "FREE_FIX(numcodes)"
+ print "FREE_FIX(strcodes)"
+ }
+ print "}"
+ print "#endif"
+ print ""
+ print "#else"
+ print ""
+ print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"
+ print ""
+ print_strings("boolcodes", small_boolcodes);
+ print_strings("numcodes", small_numcodes);
+ print_strings("strcodes", small_strcodes);
+ print ""
+ print "#endif /* BROKEN_LINKER */"
+ }
diff --git a/lib/libcurses/tinfo/MKfallback.sh b/lib/libcurses/tinfo/MKfallback.sh
index ce7d14cb7a4..c33d8489e9f 100644
--- a/lib/libcurses/tinfo/MKfallback.sh
+++ b/lib/libcurses/tinfo/MKfallback.sh
@@ -1,6 +1,33 @@
#!/bin/sh
-# $OpenBSD: MKfallback.sh,v 1.3 2001/01/22 18:01:50 millert Exp $
-# $From: MKfallback.sh,v 1.10 2000/12/10 00:14:39 tom Exp $
+# $OpenBSD: MKfallback.sh,v 1.4 2010/01/12 23:22:06 nicm Exp $
+##############################################################################
+# Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+# $Id: MKfallback.sh,v 1.4 2010/01/12 23:22:06 nicm Exp $
#
# MKfallback.sh -- create fallback table for entry reads
#
@@ -9,6 +36,7 @@
# from an on-disk terminfo tree) tries to match the type with one of a
# specified list of types generated in.
#
+
cat <<EOF
/*
* DO NOT EDIT THIS FILE BY HAND! It is generated by MKfallback.sh.
diff --git a/lib/libcurses/tinfo/MKkeys_list.sh b/lib/libcurses/tinfo/MKkeys_list.sh
new file mode 100644
index 00000000000..e28d899fedf
--- /dev/null
+++ b/lib/libcurses/tinfo/MKkeys_list.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# $OpenBSD: MKkeys_list.sh,v 1.1 2010/01/12 23:22:06 nicm Exp $
+# $Id: MKkeys_list.sh,v 1.1 2010/01/12 23:22:06 nicm Exp $
+##############################################################################
+# Copyright (c) 2001,2003 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# MKkey_defs.sh -- generate list of function-keys for terminfo database
+#
+# Author: Thomas E. Dickey 2001
+#
+# Extract function-key names from the Caps file
+#
+: ${AWK-awk}
+DATA=${1-../../include/Caps}
+
+data=data$$
+trap 'rm -f $data' 0 1 2 5 15
+sed -e 's/[ ][ ]*/ /g' < $DATA >$data
+
+cat <<EOF
+# These definitions were generated by $0 $DATA
+KEY_BREAK
+KEY_SRESET
+KEY_RESET
+KEY_RESIZE
+EOF
+
+${AWK-awk} <$data '
+/^#/ {next;}
+/^capalias/ {next;}
+/^infoalias/ {next;}
+
+$5 != "-" {
+ if (substr($5, 1, 4) == "KEY_" ) {
+ printf "%s %s\n", $5, $1
+ }
+}
+'
diff --git a/lib/libcurses/tinfo/MKnames.awk b/lib/libcurses/tinfo/MKnames.awk
index 5fdb8c20690..64ce6431fb7 100644
--- a/lib/libcurses/tinfo/MKnames.awk
+++ b/lib/libcurses/tinfo/MKnames.awk
@@ -1,99 +1,187 @@
-# $OpenBSD: MKnames.awk,v 1.2 2001/01/22 18:01:50 millert Exp $
-# $From: MKnames.awk,v 1.11 2000/12/09 23:46:13 tom Exp $
-BEGIN {
- print "/* This file was generated by MKnames.awk */" > "namehdr"
- print "" > "namehdr"
- print "#include <curses.priv.h>" > "namehdr"
- print "" > "namehdr"
- print "#define IT NCURSES_CONST char * const" > "namehdr"
- print "" > "namehdr"
- print "#if BROKEN_LINKER" > "namehdr"
- print "#include <term.h>" > "namehdr"
- print "#define DCL(it) static IT data##it[]" > "namehdr"
- print "#else" > "namehdr"
- print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]" > "namehdr"
- print "#endif" > "namehdr"
- print "" > "namehdr"
- print "/*" > "boolnames"
- print " * names.c - Arrays of capability names and codes" > "boolnames"
- print " *" > "boolnames"
- print " */" > "boolnames"
- print "" > "boolnames"
- print "DCL(boolnames) = {" > "boolnames"
- print "DCL(boolfnames) = {" > "boolfnames"
- print "DCL(boolcodes) = {" > "boolcodes"
- print "DCL(numnames) = {" > "numnames"
- print "DCL(numfnames) = {" > "numfnames"
- print "DCL(numcodes) = {" > "numcodes"
- print "DCL(strnames) = {" > "strnames"
- print "DCL(strfnames) = {" > "strfnames"
- print "DCL(strcodes) = {" > "strcodes"
- }
+# $OpenBSD: MKnames.awk,v 1.3 2010/01/12 23:22:06 nicm Exp $
+##############################################################################
+# Copyright (c) 2007,2008 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+# $Id: MKnames.awk,v 1.3 2010/01/12 23:22:06 nicm Exp $
+function large_item(value) {
+ result = sprintf("%d,", offset);
+ offset = offset + length(value) + 1;
+ offcol = offcol + length(result) + 2;
+ if (offcol > 70) {
+ result = result "\n";
+ offcol = 0;
+ } else {
+ result = result " ";
+ }
+ bigstr = bigstr sprintf("\"%s\\0\" ", value);
+ bigcol = bigcol + length(value) + 5;
+ if (bigcol > 70) {
+ bigstr = bigstr "\\\n";
+ bigcol = 0;
+ }
+ return result;
+}
+
+function small_item(value) {
+ return sprintf("\t\t\"%s\",\n", value);
+}
+
+function print_strings(name,value) {
+ printf "DCL(%s) = {\n", name
+ print value
+ print "\t\t(NCURSES_CONST char *)0,"
+ print "};"
+ print ""
+}
+
+function print_offsets(name,value) {
+ printf "static const short _nc_offset_%s[] = {\n", name
+ printf "%s", value
+ print "};"
+ print ""
+ printf "static NCURSES_CONST char ** ptr_%s = 0;\n", name
+ print ""
+}
+
+BEGIN {
+ print "/* This file was generated by MKnames.awk */"
+ print ""
+ print "#include <curses.priv.h>"
+ print ""
+ print "#define IT NCURSES_CONST char * const"
+ print ""
+ offset = 0;
+ offcol = 0;
+ bigcol = 0;
+ }
$1 ~ /^#/ {next;}
$1 == "SKIPWARN" {next;}
$3 == "bool" {
- printf "\t\t\"%s\",\n", $2 > "boolnames"
- printf "\t\t\"%s\",\n", $1 > "boolfnames"
- printf "\t\t\"%s\",\n", $4 > "boolcodes"
+ small_boolnames = small_boolnames small_item($2);
+ large_boolnames = large_boolnames large_item($2);
+ small_boolfnames = small_boolfnames small_item($1);
+ large_boolfnames = large_boolfnames large_item($1);
}
$3 == "num" {
- printf "\t\t\"%s\",\n", $2 > "numnames"
- printf "\t\t\"%s\",\n", $1 > "numfnames"
- printf "\t\t\"%s\",\n", $4 > "numcodes"
+ small_numnames = small_numnames small_item($2);
+ large_numnames = large_numnames large_item($2);
+ small_numfnames = small_numfnames small_item($1);
+ large_numfnames = large_numfnames large_item($1);
}
$3 == "str" {
- printf "\t\t\"%s\",\n", $2 > "strnames"
- printf "\t\t\"%s\",\n", $1 > "strfnames"
- printf "\t\t\"%s\",\n", $4 > "strcodes"
+ small_strnames = small_strnames small_item($2);
+ large_strnames = large_strnames large_item($2);
+ small_strfnames = small_strfnames small_item($1);
+ large_strfnames = large_strfnames large_item($1);
}
-END {
- print "\t\t(NCURSES_CONST char *)0," > "boolnames"
- print "};" > "boolnames"
- print "" > "boolnames"
- print "\t\t(NCURSES_CONST char *)0," > "boolfnames"
- print "};" > "boolfnames"
- print "" > "boolfnames"
- print "\t\t(NCURSES_CONST char *)0," > "boolcodes"
- print "};" > "boolcodes"
- print "" > "boolcodes"
- print "\t\t(NCURSES_CONST char *)0," > "numnames"
- print "};" > "numnames"
- print "" > "numnames"
- print "\t\t(NCURSES_CONST char *)0," > "numfnames"
- print "};" > "numfnames"
- print "" > "numfnames"
- print "\t\t(NCURSES_CONST char *)0," > "numcodes"
- print "};" > "numcodes"
- print "" > "numcodes"
- print "\t\t(NCURSES_CONST char *)0," > "strnames"
- print "};" > "strnames"
- print "" > "strnames"
- print "\t\t(NCURSES_CONST char *)0," > "strfnames"
- print "};" > "strfnames"
- print "" > "strfnames"
- print "\t\t(NCURSES_CONST char *)0," > "strcodes"
- print "};" > "strcodes"
- print "" > "strcodes"
- print "#if BROKEN_LINKER" > "nameftr"
- print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }" > "nameftr"
- print "FIX(boolnames)" > "nameftr"
- print "FIX(boolfnames)" > "nameftr"
- print "FIX(numnames)" > "nameftr"
- print "FIX(numfnames)" > "nameftr"
- print "FIX(strnames)" > "nameftr"
- print "FIX(strfnames)" > "nameftr"
- print "#endif /* BROKEN_LINKER */" > "nameftr"
- print "" > "codeftr"
- print "#if BROKEN_LINKER" > "codeftr"
- print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }" > "codeftr"
- print "FIX(boolcodes)" > "codeftr"
- print "FIX(numcodes)" > "codeftr"
- print "FIX(strcodes)" > "codeftr"
- print "#endif /* BROKEN_LINKER */" > "codeftr"
+END {
+ print ""
+ print "#if BROKEN_LINKER || USE_REENTRANT"
+ print ""
+ print "#include <term.h>"
+ print ""
+ if (bigstrings) {
+ printf "static const char _nc_name_blob[] = \n"
+ printf "%s;\n", bigstr;
+ print_offsets("boolfnames", large_boolfnames);
+ print_offsets("boolnames", large_boolnames);
+ print_offsets("numfnames", large_numfnames);
+ print_offsets("numnames", large_numnames);
+ print_offsets("strfnames", large_strfnames);
+ print_offsets("strnames", large_strnames);
+ print ""
+ print "static IT *"
+ print "alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)"
+ print "{"
+ print " if (*value == 0) {"
+ print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
+ print " unsigned n;"
+ print " for (n = 0; n < size; ++n) {"
+ print " (*value)[n] = (NCURSES_CONST char *) _nc_name_blob + offsets[n];"
+ print " }"
+ print " }"
+ print " }"
+ print " return *value;"
+ print "}"
+ print ""
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return alloc_array(&ptr_##it, _nc_offset_##it, SIZEOF(_nc_offset_##it)); }"
+ } else {
+ print "#define DCL(it) static IT data##it[]"
+ print ""
+ print_strings("boolnames", small_boolnames);
+ print_strings("boolfnames", small_boolfnames);
+ print_strings("numnames", small_numnames);
+ print_strings("numfnames", small_numfnames);
+ print_strings("strnames", small_strnames);
+ print_strings("strfnames", small_strfnames);
+ print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API _nc_##it(void) { return data##it; }"
+ }
+ print ""
+ print "FIX(boolnames)"
+ print "FIX(boolfnames)"
+ print "FIX(numnames)"
+ print "FIX(numfnames)"
+ print "FIX(strnames)"
+ print "FIX(strfnames)"
+ print ""
+ print ""
+ print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }"
+ print ""
+ print "#if NO_LEAKS"
+ print "NCURSES_EXPORT(void)"
+ print "_nc_names_leaks(void)"
+ print "{"
+ if (bigstrings) {
+ print "FREE_FIX(boolnames)"
+ print "FREE_FIX(boolfnames)"
+ print "FREE_FIX(numnames)"
+ print "FREE_FIX(numfnames)"
+ print "FREE_FIX(strnames)"
+ print "FREE_FIX(strfnames)"
}
+ print "}"
+ print "#endif"
+ print ""
+ print "#else"
+ print ""
+ print "#define DCL(it) NCURSES_EXPORT_VAR(IT) it[]"
+ print ""
+ print_strings("boolnames", small_boolnames);
+ print_strings("boolfnames", small_boolfnames);
+ print_strings("numnames", small_numnames);
+ print_strings("numfnames", small_numfnames);
+ print_strings("strnames", small_strnames);
+ print_strings("strfnames", small_strfnames);
+ print ""
+ print "#endif /* BROKEN_LINKER */"
+ }
diff --git a/lib/libcurses/tinfo/access.c b/lib/libcurses/tinfo/access.c
index a4a184e699c..0ea39c1106c 100644
--- a/lib/libcurses/tinfo/access.c
+++ b/lib/libcurses/tinfo/access.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: access.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
+
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -27,27 +29,83 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
#include <curses.priv.h>
+
+#include <ctype.h>
+#include <sys/stat.h>
+
#include <tic.h>
+#include <nc_alloc.h>
-MODULE_ID("$From: access.c,v 1.7 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: access.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
+
+#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
NCURSES_EXPORT(char *)
-_nc_basename(char *path)
+_nc_rootname(char *path)
{
- char *result = strrchr(path, '/');
+ char *result = _nc_basename(path);
+#if !MIXEDCASE_FILENAMES || defined(PROG_EXT)
+ static char *temp;
+ char *s;
+
+ temp = strdup(result);
+ result = temp;
+#if !MIXEDCASE_FILENAMES
+ for (s = result; *s != '\0'; ++s) {
+ *s = LOWERCASE(*s);
+ }
+#endif
+#if defined(PROG_EXT)
+ if ((s = strrchr(result, '.')) != 0) {
+ if (!strcmp(s, PROG_EXT))
+ *s = '\0';
+ }
+#endif
+#endif
+ return result;
+}
+
+/*
+ * Check if a string appears to be an absolute pathname.
+ */
+NCURSES_EXPORT(bool)
+_nc_is_abs_path(const char *path)
+{
+#if defined(__EMX__) || defined(__DJGPP__)
+#define is_pathname(s) ((((s) != 0) && ((s)[0] == '/')) \
+ || (((s)[0] != 0) && ((s)[1] == ':')))
+#else
+#define is_pathname(s) ((s) != 0 && (s)[0] == '/')
+#endif
+ return is_pathname(path);
+}
+
+/*
+ * Return index of the basename
+ */
+NCURSES_EXPORT(unsigned)
+_nc_pathlast(const char *path)
+{
+ const char *test = strrchr(path, '/');
#ifdef __EMX__
- if (result == 0)
- result = strrchr(path, '\\');
+ if (test == 0)
+ test = strrchr(path, '\\');
#endif
- if (result == 0)
- result = path;
+ if (test == 0)
+ test = path;
else
- result++;
- return result;
+ test++;
+ return (test - path);
+}
+
+NCURSES_EXPORT(char *)
+_nc_basename(char *path)
+{
+ return path + _nc_pathlast(path);
}
NCURSES_EXPORT(int)
@@ -59,10 +117,10 @@ _nc_access(const char *path, int mode)
&& strlen(path) < PATH_MAX) {
char *leaf, head[PATH_MAX];
- strlcpy(head, path, sizeof(head));
- if ((leaf = _nc_basename(head)) == 0)
- leaf = head;
- *leaf = '\0';
+ strlcpy(head, path, sizeof(head));
+ if ((leaf = _nc_basename(head)) == 0)
+ leaf = head;
+ *leaf = '\0';
if (head == leaf)
(void) strlcpy(head, ".", sizeof(head));
@@ -73,6 +131,32 @@ _nc_access(const char *path, int mode)
return 0;
}
+NCURSES_EXPORT(bool)
+_nc_is_dir_path(const char *path)
+{
+ bool result = FALSE;
+ struct stat sb;
+
+ if (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFDIR) {
+ result = TRUE;
+ }
+ return result;
+}
+
+NCURSES_EXPORT(bool)
+_nc_is_file_path(const char *path)
+{
+ bool result = FALSE;
+ struct stat sb;
+
+ if (stat(path, &sb) == 0
+ && (sb.st_mode & S_IFMT) == S_IFREG) {
+ result = TRUE;
+ }
+ return result;
+}
+
#ifndef USE_ROOT_ENVIRON
/*
* Returns true if we allow application to use environment variables that are
diff --git a/lib/libcurses/tinfo/add_tries.c b/lib/libcurses/tinfo/add_tries.c
index 55ad69543d5..247087fd815 100644
--- a/lib/libcurses/tinfo/add_tries.c
+++ b/lib/libcurses/tinfo/add_tries.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: add_tries.c,v 1.3 2001/01/22 18:01:50 millert Exp $ */
+/* $OpenBSD: add_tries.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ * Author: Thomas E. Dickey 1998-on *
****************************************************************************/
/*
@@ -41,20 +41,20 @@
#include <curses.priv.h>
-MODULE_ID("$From: add_tries.c,v 1.4 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
#define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
#define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
-NCURSES_EXPORT(void)
-_nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
+NCURSES_EXPORT(int)
+_nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
{
- static bool out_of_memory = FALSE;
- struct tries *ptr, *savedptr;
+ TRIES *ptr, *savedptr;
unsigned const char *txt = (unsigned const char *) str;
- if (txt == 0 || *txt == '\0' || out_of_memory || code == 0)
- return;
+ T((T_CALLED("_nc_add_to_try(%p, %s, %u)"), *tree, _nc_visbuf(str), code));
+ if (txt == 0 || *txt == '\0' || code == 0)
+ returnCode(ERR);
if ((*tree) != 0) {
ptr = savedptr = (*tree);
@@ -69,16 +69,15 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
if (CMP_TRY(ptr->ch, cmp)) {
if (*(++txt) == '\0') {
ptr->value = code;
- return;
+ returnCode(OK);
}
if (ptr->child != 0)
ptr = ptr->child;
else
break;
} else {
- if ((ptr->sibling = typeCalloc(struct tries, 1)) == 0) {
- out_of_memory = TRUE;
- return;
+ if ((ptr->sibling = typeCalloc(TRIES, 1)) == 0) {
+ returnCode(ERR);
}
savedptr = ptr = ptr->sibling;
@@ -89,11 +88,10 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
}
} /* end for (;;) */
} else { /* (*tree) == 0 :: First sequence to be added */
- savedptr = ptr = (*tree) = typeCalloc(struct tries, 1);
+ savedptr = ptr = (*tree) = typeCalloc(TRIES, 1);
if (ptr == 0) {
- out_of_memory = TRUE;
- return;
+ returnCode(ERR);
}
SET_TRY(ptr, txt);
@@ -103,19 +101,16 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
/* at this point, we are adding to the try. ptr->child == 0 */
while (*txt) {
- ptr->child = typeCalloc(struct tries, 1);
+ ptr->child = typeCalloc(TRIES, 1);
ptr = ptr->child;
if (ptr == 0) {
- out_of_memory = TRUE;
-
while ((ptr = savedptr) != 0) {
savedptr = ptr->child;
free(ptr);
}
-
- return;
+ returnCode(ERR);
}
SET_TRY(ptr, txt);
@@ -123,5 +118,5 @@ _nc_add_to_try(struct tries **tree, const char *str, unsigned short code)
}
ptr->value = code;
- return;
+ returnCode(OK);
}
diff --git a/lib/libcurses/tinfo/alloc_entry.c b/lib/libcurses/tinfo/alloc_entry.c
index b0bab761de8..c0861482018 100644
--- a/lib/libcurses/tinfo/alloc_entry.c
+++ b/lib/libcurses/tinfo/alloc_entry.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: alloc_entry.c,v 1.5 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: alloc_entry.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -49,21 +50,31 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: alloc_entry.c,v 1.35 2001/01/13 22:40:17 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
#define ABSENT_OFFSET -1
#define CANCELLED_OFFSET -2
#define MAX_STRTAB 4096 /* documented maximum entry size */
-static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */
+static char *stringbuf; /* buffer for string capabilities */
static size_t next_free; /* next free character in stringbuf */
NCURSES_EXPORT(void)
-_nc_init_entry(TERMTYPE * const tp)
+_nc_init_entry(TERMTYPE *const tp)
/* initialize a terminal type data block */
{
- int i;
+ unsigned i;
+
+#if NO_LEAKS
+ if (tp == 0 && stringbuf != 0) {
+ FreeAndNull(stringbuf);
+ return;
+ }
+#endif
+
+ if (stringbuf == 0)
+ stringbuf = (char *) malloc(MAX_STRTAB);
#if NCURSES_XNAMES
tp->num_Booleans = BOOLCOUNT;
@@ -74,7 +85,7 @@ _nc_init_entry(TERMTYPE * const tp)
tp->ext_Strings = 0;
#endif
if (tp->Booleans == 0)
- tp->Booleans = typeMalloc(char, BOOLCOUNT);
+ tp->Booleans = typeMalloc(NCURSES_SBOOL, BOOLCOUNT);
if (tp->Numbers == 0)
tp->Numbers = typeMalloc(short, NUMCOUNT);
if (tp->Strings == 0)
@@ -104,28 +115,42 @@ _nc_copy_entry(ENTRY * oldp)
return newp;
}
+/* save a copy of string in the string buffer */
NCURSES_EXPORT(char *)
_nc_save_str(const char *const string)
-/* save a copy of string in the string buffer */
{
+ char *result = 0;
size_t old_next_free = next_free;
- size_t len;
-
- len = strlcpy(stringbuf + next_free, string, sizeof(stringbuf) - next_free);
- if (++len < sizeof(stringbuf) - next_free) {
+ size_t len = strlen(string) + 1;
+
+ if (len == 1 && next_free != 0) {
+ /*
+ * Cheat a little by making an empty string point to the end of the
+ * previous string.
+ */
+ if (next_free < MAX_STRTAB) {
+ result = (stringbuf + next_free - 1);
+ }
+ } else if (next_free + len < MAX_STRTAB) {
+ strlcpy(&stringbuf[next_free], string, MAX_STRTAB - next_free);
DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
DEBUG(7, ("at location %d", (int) next_free));
next_free += len;
+ result = (stringbuf + old_next_free);
+ } else {
+ _nc_warning("Too much data, some is lost");
}
- return (stringbuf + old_next_free);
+ return result;
}
NCURSES_EXPORT(void)
_nc_wrap_entry(ENTRY * const ep, bool copy_strings)
/* copy the string parts to allocated storage, preserving pointers to it */
{
- int offsets[MAX_ENTRY_SIZE / 2], useoffsets[MAX_USES];
- int i, n;
+ int offsets[MAX_ENTRY_SIZE / sizeof(short)];
+ int useoffsets[MAX_USES];
+ unsigned i, n;
+ unsigned nuses = ep->nuses;
TERMTYPE *tp = &(ep->tterm);
if (copy_strings) {
@@ -140,7 +165,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
}
- for (i = 0; i < ep->nuses; i++) {
+ for (i = 0; i < nuses; i++) {
if (ep->uses[i].name == 0) {
ep->uses[i].name = _nc_save_str(ep->uses[i].name);
}
@@ -149,17 +174,21 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
free(tp->str_table);
}
- n = tp->term_names - stringbuf;
+ assert(tp->term_names >= stringbuf);
+ n = (unsigned) (tp->term_names - stringbuf);
for_each_string(i, &(ep->tterm)) {
- if (tp->Strings[i] == ABSENT_STRING)
- offsets[i] = ABSENT_OFFSET;
- else if (tp->Strings[i] == CANCELLED_STRING)
- offsets[i] = CANCELLED_OFFSET;
- else
- offsets[i] = tp->Strings[i] - stringbuf;
+ if (i < SIZEOF(offsets)) {
+ if (tp->Strings[i] == ABSENT_STRING) {
+ offsets[i] = ABSENT_OFFSET;
+ } else if (tp->Strings[i] == CANCELLED_STRING) {
+ offsets[i] = CANCELLED_OFFSET;
+ } else {
+ offsets[i] = tp->Strings[i] - stringbuf;
+ }
+ }
}
- for (i = 0; i < ep->nuses; i++) {
+ for (i = 0; i < nuses; i++) {
if (ep->uses[i].name == 0)
useoffsets[i] = ABSENT_OFFSET;
else
@@ -167,43 +196,48 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
if ((tp->str_table = typeMalloc(char, next_free)) == (char *) 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
(void) memcpy(tp->str_table, stringbuf, next_free);
tp->term_names = tp->str_table + n;
for_each_string(i, &(ep->tterm)) {
- if (offsets[i] == ABSENT_OFFSET)
- tp->Strings[i] = ABSENT_STRING;
- else if (offsets[i] == CANCELLED_OFFSET)
- tp->Strings[i] = CANCELLED_STRING;
- else
- tp->Strings[i] = tp->str_table + offsets[i];
+ if (i < SIZEOF(offsets)) {
+ if (offsets[i] == ABSENT_OFFSET) {
+ tp->Strings[i] = ABSENT_STRING;
+ } else if (offsets[i] == CANCELLED_OFFSET) {
+ tp->Strings[i] = CANCELLED_STRING;
+ } else {
+ tp->Strings[i] = tp->str_table + offsets[i];
+ }
+ }
}
#if NCURSES_XNAMES
if (!copy_strings) {
- if ((n = NUM_EXT_NAMES(tp)) != 0) {
- size_t copied, length, strtabsize = 0;
- for (i = 0; i < n; i++) {
- strtabsize += strlen(tp->ext_Names[i]) + 1;
- offsets[i] = tp->ext_Names[i] - stringbuf;
- }
- if ((tp->ext_str_table = typeMalloc(char, strtabsize)) == 0)
- _nc_err_abort("Out of memory");
- for (i = 0, length = 0; i < n; i++) {
- tp->ext_Names[i] = tp->ext_str_table + length;
- copied = strlcpy(tp->ext_Names[i], stringbuf + offsets[i],
- strtabsize) + 1;
- if (copied > strtabsize)
- _nc_err_abort("Buffer overflow");
- length += copied;
- strtabsize -= copied;
+ if ((n = (unsigned) NUM_EXT_NAMES(tp)) != 0) {
+ if (n < SIZEOF(offsets)) {
+ size_t copied, length, strtabsize = 0;
+ for (i = 0; i < n; i++) {
+ strtabsize += strlen(tp->ext_Names[i]) + 1;
+ offsets[i] = tp->ext_Names[i] - stringbuf;
+ }
+ if ((tp->ext_str_table = typeMalloc(char, strtabsize)) == 0)
+ _nc_err_abort(MSG_NO_MEMORY);
+ for (i = 0, length = 0; i < n; i++) {
+ tp->ext_Names[i] = tp->ext_str_table + length;
+ copied = strlcpy(tp->ext_Names[i], stringbuf + offsets[i],
+ strtabsize) + 1;
+ if (copied > strtabsize)
+ _nc_err_abort("Buffer overflow");
+ length += copied;
+ strtabsize -= copied;
+ }
}
}
}
#endif
- for (i = 0; i < ep->nuses; i++) {
+ for (i = 0; i < nuses; i++) {
if (useoffsets[i] == ABSENT_OFFSET)
ep->uses[i].name = 0;
else
@@ -212,31 +246,34 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
NCURSES_EXPORT(void)
-_nc_merge_entry
-(TERMTYPE * const to, TERMTYPE * const from)
+_nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
/* merge capabilities from `from' entry into `to' entry */
{
- int i;
+ unsigned i;
#if NCURSES_XNAMES
_nc_align_termtype(to, from);
#endif
for_each_boolean(i, from) {
- int mergebool = from->Booleans[i];
+ if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) {
+ int mergebool = from->Booleans[i];
- if (mergebool == CANCELLED_BOOLEAN)
- to->Booleans[i] = FALSE;
- else if (mergebool == TRUE)
- to->Booleans[i] = mergebool;
+ if (mergebool == CANCELLED_BOOLEAN)
+ to->Booleans[i] = FALSE;
+ else if (mergebool == TRUE)
+ to->Booleans[i] = (char) mergebool;
+ }
}
for_each_number(i, from) {
- int mergenum = from->Numbers[i];
+ if (to->Numbers[i] != CANCELLED_NUMERIC) {
+ short mergenum = from->Numbers[i];
- if (mergenum == CANCELLED_NUMERIC)
- to->Numbers[i] = ABSENT_NUMERIC;
- else if (mergenum != ABSENT_NUMERIC)
- to->Numbers[i] = mergenum;
+ if (mergenum == CANCELLED_NUMERIC)
+ to->Numbers[i] = ABSENT_NUMERIC;
+ else if (mergenum != ABSENT_NUMERIC)
+ to->Numbers[i] = mergenum;
+ }
}
/*
@@ -245,11 +282,24 @@ _nc_merge_entry
* we ever want to deallocate entries.
*/
for_each_string(i, from) {
- char *mergestring = from->Strings[i];
+ if (to->Strings[i] != CANCELLED_STRING) {
+ char *mergestring = from->Strings[i];
+
+ if (mergestring == CANCELLED_STRING)
+ to->Strings[i] = ABSENT_STRING;
+ else if (mergestring != ABSENT_STRING)
+ to->Strings[i] = mergestring;
+ }
+ }
+}
- if (mergestring == CANCELLED_STRING)
- to->Strings[i] = ABSENT_STRING;
- else if (mergestring != ABSENT_STRING)
- to->Strings[i] = mergestring;
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_alloc_entry_leaks(void)
+{
+ if (stringbuf != 0) {
+ FreeAndNull(stringbuf);
}
+ next_free = 0;
}
+#endif
diff --git a/lib/libcurses/tinfo/alloc_ttype.c b/lib/libcurses/tinfo/alloc_ttype.c
index 43583824c0f..f474e502be4 100644
--- a/lib/libcurses/tinfo/alloc_ttype.c
+++ b/lib/libcurses/tinfo/alloc_ttype.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: alloc_ttype.c,v 1.5 2001/01/22 18:01:50 millert Exp $ */
+/* $OpenBSD: alloc_ttype.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1999-on *
****************************************************************************/
/*
@@ -45,7 +45,7 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: alloc_ttype.c,v 1.12 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
#if NCURSES_XNAMES
/*
@@ -94,15 +94,17 @@ find_name(char **table, int length, char *name)
}
static void
-realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
- ext_Numbers, int ext_Strings)
+realign_data(TERMTYPE *to, char **ext_Names,
+ int ext_Booleans,
+ int ext_Numbers,
+ int ext_Strings)
{
int n, m, base;
int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
if (to->ext_Booleans != ext_Booleans) {
to->num_Booleans += (ext_Booleans - to->ext_Booleans);
- to->Booleans = typeRealloc(char, to->num_Booleans, to->Booleans);
+ to->Booleans = typeRealloc(NCURSES_SBOOL, to->num_Booleans, to->Booleans);
for (n = to->ext_Booleans - 1,
m = ext_Booleans - 1,
base = to->num_Booleans - (m + 1); m >= 0; m--) {
@@ -148,7 +150,7 @@ realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int
* Returns the first index in ext_Names[] for the given token-type
*/
static int
-_nc_first_ext_name(TERMTYPE * tp, int token_type)
+_nc_first_ext_name(TERMTYPE *tp, int token_type)
{
int first;
@@ -173,7 +175,7 @@ _nc_first_ext_name(TERMTYPE * tp, int token_type)
* Returns the last index in ext_Names[] for the given token-type
*/
static int
-_nc_last_ext_name(TERMTYPE * tp, int token_type)
+_nc_last_ext_name(TERMTYPE *tp, int token_type)
{
int last;
@@ -196,7 +198,7 @@ _nc_last_ext_name(TERMTYPE * tp, int token_type)
* Lookup an entry from extended-names, returning -1 if not found
*/
static int
-_nc_find_ext_name(TERMTYPE * tp, char *name, int token_type)
+_nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
{
unsigned j;
unsigned first = _nc_first_ext_name(tp, token_type);
@@ -215,7 +217,7 @@ _nc_find_ext_name(TERMTYPE * tp, char *name, int token_type)
* (e.g., Booleans[]).
*/
static int
-_nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
+_nc_ext_data_index(TERMTYPE *tp, int n, int token_type)
{
switch (token_type) {
case BOOLEAN:
@@ -238,7 +240,7 @@ _nc_ext_data_index(TERMTYPE * tp, int n, int token_type)
* data.
*/
static bool
-_nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
+_nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
{
int j;
int first, last;
@@ -282,7 +284,7 @@ _nc_del_ext_name(TERMTYPE * tp, char *name, int token_type)
* index into the corresponding data array is returned.
*/
static int
-_nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
+_nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
{
unsigned first = _nc_first_ext_name(tp, token_type);
unsigned last = _nc_last_ext_name(tp, token_type);
@@ -293,7 +295,7 @@ _nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
int cmp = strcmp(name, tp->ext_Names[j]);
if (cmp == 0)
/* already present */
- return _nc_ext_data_index(tp, j, token_type);
+ return _nc_ext_data_index(tp, (int) j, token_type);
if (cmp < 0) {
break;
}
@@ -303,13 +305,13 @@ _nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
for (k = total - 1; k > j; k--)
tp->ext_Names[k] = tp->ext_Names[k - 1];
tp->ext_Names[j] = name;
- j = _nc_ext_data_index(tp, j, token_type);
+ j = _nc_ext_data_index(tp, (int) j, token_type);
switch (token_type) {
case BOOLEAN:
tp->ext_Booleans += 1;
tp->num_Booleans += 1;
- tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
+ tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
for (k = tp->num_Booleans - 1; k > j; k--)
tp->Booleans[k] = tp->Booleans[k - 1];
break;
@@ -337,7 +339,7 @@ _nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type)
* cancellation of a name that is inherited from another entry.
*/
static void
-adjust_cancels(TERMTYPE * to, TERMTYPE * from)
+adjust_cancels(TERMTYPE *to, TERMTYPE *from)
{
int first = to->ext_Booleans + to->ext_Numbers;
int last = first + to->ext_Strings;
@@ -365,6 +367,17 @@ adjust_cancels(TERMTYPE * to, TERMTYPE * from)
} else {
j++;
}
+ } else if ((k = _nc_find_ext_name(from, to->ext_Names[j],
+ STRING)) >= 0) {
+ if (_nc_del_ext_name(to, name, NUMBER)
+ || _nc_del_ext_name(to, name, BOOLEAN)) {
+ k = _nc_ins_ext_name(to, name, STRING);
+ to->Strings[k] = CANCELLED_STRING;
+ } else {
+ j++;
+ }
+ } else {
+ j++;
}
} else {
j++;
@@ -373,8 +386,7 @@ adjust_cancels(TERMTYPE * to, TERMTYPE * from)
}
NCURSES_EXPORT(void)
-_nc_align_termtype
-(TERMTYPE * to, TERMTYPE * from)
+_nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
{
int na = NUM_EXT_NAMES(to);
int nb = NUM_EXT_NAMES(from);
@@ -382,6 +394,7 @@ _nc_align_termtype
bool same;
char **ext_Names;
int ext_Booleans, ext_Numbers, ext_Strings;
+ bool used_ext_Names = FALSE;
DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names,
nb, from->term_names));
@@ -445,6 +458,7 @@ _nc_align_termtype
to->ext_Names = ext_Names;
DEBUG(2, ("realigned %d extended names for '%s' (to)",
NUM_EXT_NAMES(to), to->term_names));
+ used_ext_Names = TRUE;
}
if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
nb = (ext_Booleans + ext_Numbers + ext_Strings);
@@ -454,18 +468,19 @@ _nc_align_termtype
DEBUG(2, ("realigned %d extended names for '%s' (from)",
NUM_EXT_NAMES(from), from->term_names));
}
+ if (!used_ext_Names)
+ free(ext_Names);
}
}
#endif
NCURSES_EXPORT(void)
-_nc_copy_termtype
-(TERMTYPE * dst, TERMTYPE * src)
+_nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src)
{
- int i;
+ unsigned i;
*dst = *src; /* ...to copy the sizes and string-tables */
- dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst));
+ dst->Booleans = typeMalloc(NCURSES_SBOOL, NUM_BOOLEANS(dst));
dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst));
dst->Strings = typeMalloc(char *, NUM_STRINGS(dst));
diff --git a/lib/libcurses/tinfo/captoinfo.c b/lib/libcurses/tinfo/captoinfo.c
index 7c6a4587f58..6caf24560d1 100644
--- a/lib/libcurses/tinfo/captoinfo.c
+++ b/lib/libcurses/tinfo/captoinfo.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: captoinfo.c,v 1.15 2006/10/24 17:25:48 moritz Exp $ */
+/* $OpenBSD: captoinfo.c,v 1.16 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -41,7 +42,7 @@
*
* There is just one entry point:
*
- * char *_nc_captoinfo(n, s, parametrized)
+ * char *_nc_captoinfo(n, s, parameterized)
*
* Convert value s for termcap string capability named n into terminfo
* format.
@@ -94,7 +95,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$From: captoinfo.c,v 1.40 2000/11/05 00:22:36 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.16 2010/01/12 23:22:06 nicm Exp $")
#define MAX_PUSHED 16 /* max # args we can push onto the stack */
@@ -117,7 +118,7 @@ init_string(void)
if (my_string == 0)
my_string = typeMalloc(char, my_length = 256);
if (my_string == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
*my_string = '\0';
return my_string;
@@ -132,19 +133,19 @@ save_string(char *d, const char *const s)
if (need > my_length) {
my_string = (char *) realloc(my_string, my_length = (need + need));
if (my_string == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
d = my_string + have;
}
if ((copied = strlcpy(d, s, my_length - have)) >= my_length - have)
- _nc_err_abort("Buffer overflow");
+ _nc_err_abort("Buffer overflow");
return d + copied;
}
-static inline char *
-save_char(char *s, char c)
+static NCURSES_INLINE char *
+save_char(char *s, int c)
{
static char temp[2];
- temp[0] = c;
+ temp[0] = (char) c;
return save_string(s, temp);
}
@@ -152,7 +153,7 @@ static void
push(void)
/* push onstack on to the stack */
{
- if (stackptr > MAX_PUSHED)
+ if (stackptr >= MAX_PUSHED)
_nc_warning("string too complex to convert");
else
stack[stackptr++] = onstack;
@@ -186,7 +187,7 @@ cvtchar(register const char *sp)
case '$':
case '\\':
case '%':
- c = *sp;
+ c = (unsigned char) (*sp);
len = 2;
break;
case '\0':
@@ -198,13 +199,13 @@ cvtchar(register const char *sp)
case '2':
case '3':
len = 1;
- while (isdigit(CharOf(*sp))) {
+ while (isdigit(UChar(*sp))) {
c = 8 * c + (*sp++ - '0');
len++;
}
break;
default:
- c = *sp;
+ c = (unsigned char) (*sp);
len = 2;
break;
}
@@ -214,7 +215,7 @@ cvtchar(register const char *sp)
len = 2;
break;
default:
- c = *sp;
+ c = (unsigned char) (*sp);
len = 1;
}
if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
@@ -276,12 +277,12 @@ getparm(int parm, int n)
* Convert a termcap string to terminfo format.
* 'cap' is the relevant terminfo capability index.
* 's' is the string value of the capability.
- * 'parametrized' tells what type of translations to do:
+ * 'parameterized' tells what type of translations to do:
* % translations if 1
* pad translations if >=0
*/
-char *
-_nc_captoinfo(const char *cap, const char *s, int const parametrized)
+NCURSES_EXPORT(char *)
+_nc_captoinfo(const char *cap, const char *s, int const parameterized)
{
const char *capstart;
@@ -298,16 +299,16 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized)
capstart = 0;
if (s == 0)
s = "";
- if (parametrized >= 0 && isdigit(CharOf(*s)))
+ if (parameterized >= 0 && isdigit(UChar(*s)))
for (capstart = s;; s++)
- if (!(isdigit(CharOf(*s)) || *s == '*' || *s == '.'))
+ if (!(isdigit(UChar(*s)) || *s == '*' || *s == '.'))
break;
while (*s != '\0') {
switch (*s) {
case '%':
s++;
- if (parametrized < 1) {
+ if (parameterized < 1) {
dp = save_char(dp, '%');
break;
}
@@ -468,7 +469,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized)
dp = save_char(dp, '%');
s--;
_nc_warning("unknown %% code %s (%#x) in %s",
- unctrl((chtype) * s), CharOf(*s), cap);
+ unctrl((chtype) *s), UChar(*s), cap);
break;
}
break;
@@ -549,7 +550,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized)
if (capstart) {
dp = save_string(dp, "$<");
for (s = capstart;; s++)
- if (isdigit(CharOf(*s)) || *s == '*' || *s == '.')
+ if (isdigit(UChar(*s)) || *s == '*' || *s == '.')
dp = save_char(dp, *s);
else
break;
@@ -573,8 +574,8 @@ bcd_expression(const char *str)
char ch1, ch2;
if (sscanf(str, fmt, &ch1, &ch2) == 2
- && isdigit(CharOf(ch1))
- && isdigit(CharOf(ch2))
+ && isdigit(UChar(ch1))
+ && isdigit(UChar(ch2))
&& (ch1 == ch2)) {
len = 28;
#ifndef NDEBUG
@@ -640,8 +641,8 @@ save_tc_inequality(char *bufptr, int c1, int c2)
* Convert a terminfo string to termcap format. Parameters are as in
* _nc_captoinfo().
*/
-char *
-_nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrized)
+NCURSES_EXPORT(char *)
+_nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameterized)
{
int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
const char *padding;
@@ -655,13 +656,13 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
padding = str + strlen(str) - 1;
if (padding > str && *padding == '>' && *--padding == '/') {
--padding;
- while (isdigit(CharOf(*padding)) || *padding == '.' || *padding == '*')
+ while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*')
padding--;
if (padding > str && *padding == '<' && *--padding == '$')
trimmed = padding;
padding += 2;
- while (isdigit(CharOf(*padding)) || *padding == '.' || *padding == '*')
+ while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*')
bufptr = save_char(bufptr, *padding++);
}
@@ -673,7 +674,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
bufptr = save_char(bufptr, *++str);
} else if (str[0] == '$' && str[1] == '<') { /* discard padding */
str += 2;
- while (isdigit(CharOf(*str))
+ while (isdigit(UChar(*str))
|| *str == '.'
|| *str == '*'
|| *str == '/'
@@ -682,7 +683,8 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
--str;
} else if (str[0] == '%' && str[1] == '%') { /* escaped '%' */
bufptr = save_string(bufptr, "%%");
- } else if (*str != '%' || (parametrized < 1)) {
+ ++str;
+ } else if (*str != '%' || (parameterized < 1)) {
bufptr = save_char(bufptr, *str);
} else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1, &c2) == 2) {
str = strchr(str, ';');
@@ -741,7 +743,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
case '8':
case '9':
bufptr = save_char(bufptr, '%');
- while (isdigit(CharOf(*str)))
+ while (isdigit(UChar(*str)))
bufptr = save_char(bufptr, *str++);
if (strchr("doxX.", *str)) {
if (*str != 'd') /* termcap doesn't have octal, hex */
@@ -790,6 +792,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
} /* endswitch (*str) */
} /* endelse (*str == '%') */
+ /*
+ * 'str' always points to the end of what was scanned in this step,
+ * but that may not be the end of the string.
+ */
+ assert(str != 0);
if (*str == '\0')
break;
@@ -807,7 +814,7 @@ main(int argc, char *argv[])
{
int c, tc = FALSE;
- while ((c = getopt(argc, argv, "c")) != -1)
+ while ((c = getopt(argc, argv, "c")) != EOF)
switch (c) {
case 'c':
tc = TRUE;
@@ -817,7 +824,6 @@ main(int argc, char *argv[])
curr_line = 0;
for (;;) {
char buf[BUFSIZ];
- size_t buflen;
++curr_line;
if (fgets(buf, sizeof(buf), stdin) == NULL)
@@ -840,4 +846,13 @@ main(int argc, char *argv[])
}
#endif /* MAIN */
-/* captoinfo.c ends here */
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_captoinfo_leaks(void)
+{
+ if (my_string != 0) {
+ FreeAndNull(my_string);
+ }
+ my_length = 0;
+}
+#endif
diff --git a/lib/libcurses/tinfo/comp_error.c b/lib/libcurses/tinfo/comp_error.c
index 13259e1efc4..319bd5fb35b 100644
--- a/lib/libcurses/tinfo/comp_error.c
+++ b/lib/libcurses/tinfo/comp_error.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: comp_error.c,v 1.5 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: comp_error.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,48 +43,62 @@
#include <tic.h>
-MODULE_ID("$From: comp_error.c,v 1.21 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
-NCURSES_EXPORT_VAR(int)
-_nc_curr_line = 0; /* current line # in input */
-NCURSES_EXPORT_VAR(int)
-_nc_curr_col = 0; /* current column # in input */
+NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
+NCURSES_EXPORT_VAR(int) _nc_curr_col = 0; /* current column # in input */
- static const char *sourcename;
- static char termtype[MAX_NAME_SIZE + 1];
+#define SourceName _nc_globals.comp_sourcename
+#define TermType _nc_globals.comp_termtype
+
+NCURSES_EXPORT(const char *)
+_nc_get_source(void)
+{
+ return SourceName;
+}
NCURSES_EXPORT(void)
_nc_set_source(const char *const name)
{
- sourcename = name;
+ SourceName = name;
}
NCURSES_EXPORT(void)
_nc_set_type(const char *const name)
{
- if (name)
- strlcpy(termtype, name, sizeof(termtype));
- else
- termtype[0] = '\0';
+ if (TermType == 0)
+ TermType = typeMalloc(char, MAX_NAME_SIZE + 1);
+ if (TermType != 0) {
+ TermType[0] = '\0';
+ if (name)
+ strncat(TermType, name, MAX_NAME_SIZE);
+ }
}
NCURSES_EXPORT(void)
_nc_get_type(char *name)
{
- strlcpy(name, termtype, MAX_NAME_SIZE + 1);
+#if NO_LEAKS
+ if (name == 0 && TermType != 0) {
+ FreeAndNull(TermType);
+ return;
+ }
+#endif
+ if (name != 0)
+ strlcpy(name, TermType != 0 ? TermType : "", MAX_NAME_SIZE + 1);
}
-static inline void
+static NCURSES_INLINE void
where_is_problem(void)
{
- fprintf(stderr, "\"%s\"", sourcename);
+ fprintf(stderr, "\"%s\"", SourceName ? SourceName : "?");
if (_nc_curr_line >= 0)
fprintf(stderr, ", line %d", _nc_curr_line);
if (_nc_curr_col >= 0)
fprintf(stderr, ", col %d", _nc_curr_col);
- if (termtype[0])
- fprintf(stderr, ", terminal '%s'", termtype);
+ if (TermType != 0 && TermType[0] != '\0')
+ fprintf(stderr, ", terminal '%s'", TermType);
fputc(':', stderr);
fputc(' ', stderr);
}
diff --git a/lib/libcurses/tinfo/comp_expand.c b/lib/libcurses/tinfo/comp_expand.c
index e78d365168c..598592856da 100644
--- a/lib/libcurses/tinfo/comp_expand.c
+++ b/lib/libcurses/tinfo/comp_expand.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: comp_expand.c,v 1.6 2007/06/02 01:29:11 pvalchev Exp $ */
+/* $OpenBSD: comp_expand.c,v 1.7 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,7 +37,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$From: comp_expand.c,v 1.15 2000/12/10 01:30:10 tom Exp $")
+MODULE_ID("$Id: comp_expand.c,v 1.7 2010/01/12 23:22:06 nicm Exp $")
static int
trailing_spaces(const char *src)
@@ -48,30 +48,37 @@ trailing_spaces(const char *src)
}
/* this deals with differences over whether 0x7f and 0x80..0x9f are controls */
-#define CHAR_OF(s) (*(unsigned const char *)(s))
-#define REALCTL(s) (CHAR_OF(s) < 127 && iscntrl(CHAR_OF(s)))
-#define REALPRINT(s) (CHAR_OF(s) < 127 && isprint(CHAR_OF(s)))
+#define REALCTL(s) (UChar(*(s)) < 127 && iscntrl(UChar(*(s))))
+#define REALPRINT(s) (UChar(*(s)) < 127 && isprint(UChar(*(s))))
NCURSES_EXPORT(char *)
-_nc_tic_expand
-(const char *srcp, bool tic_format, int numbers)
+_nc_tic_expand(const char *srcp, bool tic_format, int numbers)
{
static char *buffer;
static size_t length;
int bufp;
- const char *str = VALID_STRING(srcp) ? srcp : "";
+ const char *str = VALID_STRING(srcp) ? srcp : "\0\0";
bool islong = (strlen(str) > 3);
size_t need = (2 + strlen(str)) * 4;
int ch;
+#if NO_LEAKS
+ if (srcp == 0) {
+ if (buffer != 0) {
+ FreeAndNull(buffer);
+ length = 0;
+ }
+ return 0;
+ }
+#endif
if (buffer == 0 || need > length) {
if ((buffer = typeRealloc(char, length = need, buffer)) == 0)
return 0;
}
bufp = 0;
- while ((ch = CharOf(*str)) != 0) {
+ while ((ch = UChar(*str)) != 0) {
if (ch == '%' && REALPRINT(str + 1)) {
buffer[bufp++] = *str++;
/*
@@ -101,7 +108,7 @@ _nc_tic_expand
*/
case 1:
if (str[0] == L_BRACE
- && isdigit(CharOf(str[1]))) {
+ && isdigit(UChar(str[1]))) {
char *dst = 0;
long value = strtol(str + 1, &dst, 0);
if (dst != 0
@@ -114,7 +121,7 @@ _nc_tic_expand
if (ch == '\\'
|| ch == S_QUOTE)
buffer[bufp++] = '\\';
- buffer[bufp++] = ch;
+ buffer[bufp++] = (char) ch;
buffer[bufp++] = S_QUOTE;
str = dst;
} else {
@@ -143,13 +150,13 @@ _nc_tic_expand
buffer[bufp++] = 's';
} else if ((ch == ',' || ch == ':' || ch == '^') && tic_format) {
buffer[bufp++] = '\\';
- buffer[bufp++] = ch;
+ buffer[bufp++] = (char) ch;
} else if (REALPRINT(str)
&& (ch != ','
&& ch != ':'
&& !(ch == '!' && !tic_format)
&& ch != '^'))
- buffer[bufp++] = ch;
+ buffer[bufp++] = (char) ch;
#if 0 /* FIXME: this would be more readable (in fact the whole 'islong' logic should be removed) */
else if (ch == '\b') {
buffer[bufp++] = '\\';
@@ -171,7 +178,7 @@ _nc_tic_expand
}
#define UnCtl(c) ((c) + '@')
else if (REALCTL(str) && ch != '\\'
- && (!islong || isdigit(CharOf(str[1])))) {
+ && (!islong || isdigit(UChar(str[1])))) {
(void) snprintf(buffer + bufp, length - bufp, "^%c", UnCtl(ch));
bufp += strlen(buffer + bufp);
} else {
diff --git a/lib/libcurses/tinfo/comp_hash.c b/lib/libcurses/tinfo/comp_hash.c
index a4b10f3c546..87856a7e040 100644
--- a/lib/libcurses/tinfo/comp_hash.c
+++ b/lib/libcurses/tinfo/comp_hash.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: comp_hash.c,v 1.7 2007/03/20 03:40:06 tedu Exp $ */
+/* $OpenBSD: comp_hash.c,v 1.8 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,15 +31,16 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
-
/*
* comp_hash.c --- Routines to deal with the hashtable of capability
* names.
*
*/
+#define USE_TERMLIB 1
#include <curses.priv.h>
#include <tic.h>
@@ -48,12 +49,12 @@
#ifdef MAIN_PROGRAM
#include <ctype.h>
#undef DEBUG
-#define DEBUG(level, params) /*nothing*/
+#define DEBUG(level, params) /*nothing */
#endif
-MODULE_ID("$From: comp_hash.c,v 1.21 1999/06/26 21:25:11 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.8 2010/01/12 23:22:06 nicm Exp $")
-static int hash_function(const char *);
+static int hash_function(const char *);
/*
* _nc_make_hash_table()
@@ -67,59 +68,61 @@ static int hash_function(const char *);
#ifdef MAIN_PROGRAM
#undef MODULE_ID
-#define MODULE_ID(id) /*nothing*/
+#define MODULE_ID(id) /*nothing */
#include <tinfo/doalloc.c>
-static void _nc_make_hash_table(struct name_table_entry *table,
- struct name_table_entry **hash_table)
+static void
+_nc_make_hash_table(struct name_table_entry *table,
+ short *hash_table)
{
-int i;
-int hashvalue;
-int collisions = 0;
-
- for (i = 0; i < CAPTABSIZE; i++) {
- hashvalue = hash_function(table[i].nte_name);
-
- if (hash_table[hashvalue] != (struct name_table_entry *) 0)
- collisions++;
-
- if (hash_table[hashvalue] != 0)
- table[i].nte_link = (short)(hash_table[hashvalue] - table);
- hash_table[hashvalue] = &table[i];
- }
-
- DEBUG(4, ("Hash table complete: %d collisions out of %d entries", collisions, CAPTABSIZE));
+ short i;
+ int hashvalue;
+ int collisions = 0;
+
+ for (i = 0; i < HASHTABSIZE; i++) {
+ hash_table[i] = -1;
+ }
+ for (i = 0; i < CAPTABSIZE; i++) {
+ hashvalue = hash_function(table[i].nte_name);
+
+ if (hash_table[hashvalue] >= 0)
+ collisions++;
+
+ if (hash_table[hashvalue] != 0)
+ table[i].nte_link = hash_table[hashvalue];
+ hash_table[hashvalue] = i;
+ }
+
+ DEBUG(4, ("Hash table complete: %d collisions out of %d entries",
+ collisions, CAPTABSIZE));
}
#endif
-
/*
* int hash_function(string)
*
* Computes the hashing function on the given string.
*
* The current hash function is the sum of each consectutive pair
- * of characters, taken as two-byte integers, mod Hashtabsize.
+ * of characters, taken as two-byte integers, mod HASHTABSIZE.
*
*/
-static
-int
+static int
hash_function(const char *string)
{
-long sum = 0;
+ long sum = 0;
- DEBUG(9, ("hashing %s", string));
- while (*string) {
- sum += (long)(*string + (*(string + 1) << 8));
- string++;
- }
+ DEBUG(9, ("hashing %s", string));
+ while (*string) {
+ sum += (long) (*string + (*(string + 1) << 8));
+ string++;
+ }
- DEBUG(9, ("sum is %ld", sum));
- return (int)(sum % HASHTABSIZE);
+ DEBUG(9, ("sum is %ld", sum));
+ return (int) (sum % HASHTABSIZE);
}
-
/*
* struct name_table_entry *
* find_entry(string)
@@ -130,23 +133,27 @@ long sum = 0;
*/
#ifndef MAIN_PROGRAM
-struct name_table_entry const *
-_nc_find_entry(const char *string, const struct name_table_entry *const *hash_table)
+NCURSES_EXPORT(struct name_table_entry const *)
+_nc_find_entry(const char *string,
+ const short *hash_table)
{
-int hashvalue;
-struct name_table_entry const *ptr;
-
- hashvalue = hash_function(string);
-
- if ((ptr = hash_table[hashvalue]) != 0) {
- while (strcmp(ptr->nte_name, string) != 0) {
- if (ptr->nte_link < 0)
- return 0;
- ptr = ptr->nte_link + hash_table[HASHTABSIZE];
- }
+ int hashvalue;
+ struct name_table_entry const *ptr = 0;
+ struct name_table_entry const *real_table;
+
+ hashvalue = hash_function(string);
+
+ if (hash_table[hashvalue] >= 0) {
+ real_table = _nc_get_table(hash_table != _nc_get_hash_table(FALSE));
+ ptr = real_table + hash_table[hashvalue];
+ while (strcmp(ptr->nte_name, string) != 0) {
+ if (ptr->nte_link < 0)
+ return 0;
+ ptr = real_table + (ptr->nte_link + hash_table[HASHTABSIZE]);
}
+ }
- return (ptr);
+ return (ptr);
}
/*
@@ -160,19 +167,19 @@ struct name_table_entry const *ptr;
* in the table or 0 if not found.
*/
-struct name_table_entry const *
+NCURSES_EXPORT(struct name_table_entry const *)
_nc_find_type_entry(const char *string,
int type,
const struct name_table_entry *table)
{
-struct name_table_entry const *ptr;
+ struct name_table_entry const *ptr;
- for (ptr = table; ptr < table + CAPTABSIZE; ptr++) {
- if (ptr->nte_type == type && strcmp(string, ptr->nte_name) == 0)
- return(ptr);
- }
+ for (ptr = table; ptr < table + CAPTABSIZE; ptr++) {
+ if (ptr->nte_type == type && strcmp(string, ptr->nte_name) == 0)
+ return (ptr);
+ }
- return ((struct name_table_entry *)NULL);
+ return ((struct name_table_entry *) NULL);
}
#endif
@@ -189,140 +196,177 @@ struct name_table_entry const *ptr;
#define MAX_COLUMNS BUFSIZ /* this _has_ to be worst-case */
-static char **parse_columns(char *buffer)
+static char **
+parse_columns(char *buffer)
{
- static char **list;
-
- int col = 0;
-
- if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
- return(0);
-
- if (*buffer != '#') {
- while (*buffer != '\0') {
- char *s;
- for (s = buffer; (*s != '\0') && !isspace(*s); s++)
- /*EMPTY*/;
- if (s != buffer) {
- char mark = *s;
- *s = '\0';
- if ((s - buffer) > 1
- && (*buffer == '"')
- && (s[-1] == '"')) { /* strip the quotes */
- buffer++;
- s[-1] = '\0';
- }
- list[col] = buffer;
- col++;
- if (mark == '\0')
- break;
- while (isspace(*++s))
- /*EMPTY*/;
- buffer = s;
- } else
- break;
+ static char **list;
+
+ int col = 0;
+
+ if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
+ return (0);
+
+ if (*buffer != '#') {
+ while (*buffer != '\0') {
+ char *s;
+ for (s = buffer; (*s != '\0') && !isspace(UChar(*s)); s++)
+ /*EMPTY */ ;
+ if (s != buffer) {
+ char mark = *s;
+ *s = '\0';
+ if ((s - buffer) > 1
+ && (*buffer == '"')
+ && (s[-1] == '"')) { /* strip the quotes */
+ assert(s > buffer + 1);
+ s[-1] = '\0';
+ buffer++;
}
+ list[col] = buffer;
+ col++;
+ if (mark == '\0')
+ break;
+ while (*++s && isspace(UChar(*s)))
+ /*EMPTY */ ;
+ buffer = s;
+ } else
+ break;
}
- return col ? list : 0;
+ }
+ return col ? list : 0;
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- struct name_table_entry *name_table = typeCalloc(struct name_table_entry, CAPTABSIZE);
- struct name_table_entry **hash_table = typeCalloc(struct name_table_entry *, HASHTABSIZE);
- const char *root_name = "";
- int column = 0;
- int n;
- char buffer[BUFSIZ];
-
- static const char * typenames[] = { "BOOLEAN", "NUMBER", "STRING" };
-
- short BoolCount = 0;
- short NumCount = 0;
- short StrCount = 0;
-
- /* The first argument is the column-number (starting with 0).
- * The second is the root name of the tables to generate.
- */
- if (argc <= 2
- || (column = atoi(argv[1])) <= 0
- || (column >= MAX_COLUMNS)
- || *(root_name = argv[2]) == 0) {
- fprintf(stderr, "usage: make_hash column root_name\n");
- exit(EXIT_FAILURE);
+ struct name_table_entry *name_table = typeCalloc(struct
+ name_table_entry, CAPTABSIZE);
+ short *hash_table = typeCalloc(short, HASHTABSIZE);
+ const char *root_name = "";
+ int column = 0;
+ int bigstring = 0;
+ int n;
+ char buffer[BUFSIZ];
+
+ static const char *typenames[] =
+ {"BOOLEAN", "NUMBER", "STRING"};
+
+ short BoolCount = 0;
+ short NumCount = 0;
+ short StrCount = 0;
+
+ /* The first argument is the column-number (starting with 0).
+ * The second is the root name of the tables to generate.
+ */
+ if (argc <= 3
+ || (column = atoi(argv[1])) <= 0
+ || (column >= MAX_COLUMNS)
+ || *(root_name = argv[2]) == 0
+ || (bigstring = atoi(argv[3])) < 0
+ || name_table == 0
+ || hash_table == 0) {
+ fprintf(stderr, "usage: make_hash column root_name bigstring\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Read the table into our arrays.
+ */
+ for (n = 0; (n < CAPTABSIZE) && fgets(buffer, BUFSIZ, stdin);) {
+ char **list, *nlp = strchr(buffer, '\n');
+ if (nlp)
+ *nlp = '\0';
+ list = parse_columns(buffer);
+ if (list == 0) /* blank or comment */
+ continue;
+ name_table[n].nte_link = -1; /* end-of-hash */
+ name_table[n].nte_name = strdup(list[column]);
+ if (!strcmp(list[2], "bool")) {
+ name_table[n].nte_type = BOOLEAN;
+ name_table[n].nte_index = BoolCount++;
+ } else if (!strcmp(list[2], "num")) {
+ name_table[n].nte_type = NUMBER;
+ name_table[n].nte_index = NumCount++;
+ } else if (!strcmp(list[2], "str")) {
+ name_table[n].nte_type = STRING;
+ name_table[n].nte_index = StrCount++;
+ } else {
+ fprintf(stderr, "Unknown type: %s\n", list[2]);
+ exit(EXIT_FAILURE);
}
-
- /*
- * Read the table into our arrays.
- */
- for (n = 0; (n < CAPTABSIZE) && fgets(buffer, BUFSIZ, stdin); ) {
- char **list, *nlp = strchr(buffer, '\n');
- if (nlp)
- *nlp = '\0';
- list = parse_columns(buffer);
- if (list == 0) /* blank or comment */
- continue;
- name_table[n].nte_link = -1; /* end-of-hash */
- name_table[n].nte_name = strdup(list[column]);
- if (!strcmp(list[2], "bool")) {
- name_table[n].nte_type = BOOLEAN;
- name_table[n].nte_index = BoolCount++;
- } else if (!strcmp(list[2], "num")) {
- name_table[n].nte_type = NUMBER;
- name_table[n].nte_index = NumCount++;
- } else if (!strcmp(list[2], "str")) {
- name_table[n].nte_type = STRING;
- name_table[n].nte_index = StrCount++;
- } else {
- fprintf(stderr, "Unknown type: %s\n", list[2]);
- exit(EXIT_FAILURE);
- }
- n++;
+ n++;
+ }
+ _nc_make_hash_table(name_table, hash_table);
+
+ /*
+ * Write the compiled tables to standard output
+ */
+ if (bigstring) {
+ int len = 0;
+ int nxt;
+
+ printf("static const char %s_names_text[] = \\\n", root_name);
+ for (n = 0; n < CAPTABSIZE; n++) {
+ nxt = (int) strlen(name_table[n].nte_name) + 5;
+ if (nxt + len > 72) {
+ printf("\\\n");
+ len = 0;
+ }
+ printf("\"%s\\0\" ", name_table[n].nte_name);
+ len += nxt;
}
- _nc_make_hash_table(name_table, hash_table);
+ printf(";\n\n");
- /*
- * Write the compiled tables to standard output
- */
- printf("static struct name_table_entry const _nc_%s_table[] =\n",
- root_name);
+ len = 0;
+ printf("static name_table_data const %s_names_data[] =\n",
+ root_name);
printf("{\n");
for (n = 0; n < CAPTABSIZE; n++) {
- snprintf(buffer, sizeof(buffer), "\"%s\"",
- name_table[n].nte_name);
- printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n",
- buffer,
- typenames[name_table[n].nte_type],
- name_table[n].nte_index,
- name_table[n].nte_link,
- n < CAPTABSIZE - 1 ? ',' : ' ');
+ printf("\t{ %15d,\t%10s,\t%3d, %3d }%c\n",
+ len,
+ typenames[name_table[n].nte_type],
+ name_table[n].nte_index,
+ name_table[n].nte_link,
+ n < CAPTABSIZE - 1 ? ',' : ' ');
+ len += (int) strlen(name_table[n].nte_name) + 1;
}
printf("};\n\n");
+ printf("static struct name_table_entry *_nc_%s_table = 0;\n\n", root_name);
+ } else {
- printf("const struct name_table_entry * const _nc_%s_hash_table[%d] =\n",
- root_name,
- HASHTABSIZE+1);
+ printf("static struct name_table_entry %s _nc_%s_table[] =\n",
+ bigstring ? "" : "const",
+ root_name);
printf("{\n");
- for (n = 0; n < HASHTABSIZE; n++) {
- if (hash_table[n] != 0) {
- snprintf(buffer, sizeof(buffer), "_nc_%s_table + %3ld",
- root_name,
- (long) (hash_table[n] - name_table));
- } else {
- buffer[0] = '0';
- buffer[1] = '\0';
- }
- printf("\t%s,\n", buffer);
+ for (n = 0; n < CAPTABSIZE; n++) {
+ snprintf(buffer, sizeof(buffer), "\"%s\"",
+ name_table[n].nte_name);
+ printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n",
+ buffer,
+ typenames[name_table[n].nte_type],
+ name_table[n].nte_index,
+ name_table[n].nte_link,
+ n < CAPTABSIZE - 1 ? ',' : ' ');
}
- printf("\t_nc_%s_table\t/* base-of-table */\n", root_name);
printf("};\n\n");
-
- printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",
- BoolCount, NumCount, StrCount);
- printf("#error\t--> term.h and comp_captab.c disagree about the <--\n");
- printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
- printf("#endif\n\n");
-
- return EXIT_SUCCESS;
+ }
+
+ printf("static const short _nc_%s_hash_table[%d] =\n",
+ root_name,
+ HASHTABSIZE + 1);
+ printf("{\n");
+ for (n = 0; n < HASHTABSIZE; n++) {
+ printf("\t%3d,\n", hash_table[n]);
+ }
+ printf("\t0\t/* base-of-table */\n");
+ printf("};\n\n");
+
+ printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n",
+ BoolCount, NumCount, StrCount);
+ printf("#error\t--> term.h and comp_captab.c disagree about the <--\n");
+ printf("#error\t--> numbers of booleans, numbers and/or strings <--\n");
+ printf("#endif\n\n");
+
+ free(hash_table);
+ return EXIT_SUCCESS;
}
#endif
diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c
index 4c9b83497d3..1cf53acb120 100644
--- a/lib/libcurses/tinfo/comp_parse.c
+++ b/lib/libcurses/tinfo/comp_parse.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: comp_parse.c,v 1.11 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: comp_parse.c,v 1.12 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,18 +31,19 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* comp_parse.c -- parser driver loop and use handling.
*
* _nc_read_entry_source(FILE *, literal, bool, bool (*hook)())
- * _nc_resolve_uses(void)
+ * _nc_resolve_uses2(void)
* _nc_free_entries(void)
*
* Use this code by calling _nc_read_entry_source() on as many source
* files as you like (either terminfo or termcap syntax). If you
- * want use-resolution, call _nc_resolve_uses(). To free the list
+ * want use-resolution, call _nc_resolve_uses2(). To free the list
* storage, do _nc_free_entries().
*
*/
@@ -54,43 +55,23 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: comp_parse.c,v 1.48 2001/01/15 00:44:51 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.12 2010/01/12 23:22:06 nicm Exp $")
+static void sanity_check2(TERMTYPE *, bool);
+NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
+
+/* obsolete: 20040705 */
static void sanity_check(TERMTYPE *);
NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
-/****************************************************************************
- *
- * Entry queue handling
- *
- ****************************************************************************/
-/*
- * The entry list is a doubly linked list with NULLs terminating the lists:
- *
- * --------- --------- ---------
- * | | | | | | offset
- * |-------| |-------| |-------|
- * | ----+-->| ----+-->| NULL | next
- * |-------| |-------| |-------|
- * | NULL |<--+---- |<--+---- | last
- * --------- --------- ---------
- * ^ ^
- * | |
- * | |
- * _nc_head _nc_tail
- */
-
-NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
-NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
-
- static void
- enqueue(ENTRY * ep)
+static void
+enqueue(ENTRY * ep)
/* add an entry to the in-core list */
{
ENTRY *newp = _nc_copy_entry(ep);
if (newp == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
newp->last = _nc_tail;
_nc_tail = newp;
@@ -100,43 +81,18 @@ NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
newp->last->next = newp;
}
-NCURSES_EXPORT(void)
-_nc_free_entries(ENTRY * headp)
-/* free the allocated storage consumed by list entries */
-{
- ENTRY *ep, *next;
-
- for (ep = headp; ep; ep = next) {
- /*
- * This conditional lets us disconnect storage from the list.
- * To do this, copy an entry out of the list, then null out
- * the string-table member in the original and any use entries
- * it references.
- */
- FreeIfNeeded(ep->tterm.str_table);
-
- next = ep->next;
-
- free(ep);
- if (ep == _nc_head)
- _nc_head = 0;
- if (ep == _nc_tail)
- _nc_tail = 0;
- }
-}
-
static char *
force_bar(char *dst, char *src, size_t siz)
{
if (strchr(src, '|') == 0) {
- size_t len;
-
- len = strlcpy(dst, src, siz);
- if (len > siz - 2)
- len = siz - 2;
- dst[len++] = '|';
- dst[len] = '\0';
- src = dst;
+ size_t len;
+
+ len = strlcpy(dst, src, siz);
+ if (len > siz - 2)
+ len = siz - 2;
+ dst[len++] = '|';
+ dst[len] = '\0';
+ src = dst;
}
return src;
}
@@ -167,7 +123,7 @@ _nc_entry_match(char *n1, char *n2)
****************************************************************************/
NCURSES_EXPORT(void)
-_nc_read_entry_source(FILE * fp, char *buf,
+_nc_read_entry_source(FILE *fp, char *buf,
int literal, bool silent,
bool(*hook) (ENTRY *))
/* slurp all entries in the given file into core */
@@ -184,18 +140,29 @@ _nc_read_entry_source(FILE * fp, char *buf,
memset(&thisentry, 0, sizeof(thisentry));
if (_nc_parse_entry(&thisentry, literal, silent) == ERR)
break;
- if (!isalnum(CharOf(thisentry.tterm.term_names[0])))
+ if (!isalnum(UChar(thisentry.tterm.term_names[0])))
_nc_err_abort("terminal names must start with letter or digit");
/*
- * This can be used for immediate compilation of entries with no
- * use references to disk, so as to avoid chewing up a lot of
- * core when the resolution code could fetch entries off disk.
+ * This can be used for immediate compilation of entries with no "use="
+ * references to disk. That avoids consuming a lot of memory when the
+ * resolution code could fetch entries off disk.
*/
- if (hook != NULLHOOK && (*hook) (&thisentry))
+ if (hook != NULLHOOK && (*hook) (&thisentry)) {
immediate++;
- else
+ } else {
enqueue(&thisentry);
+ /*
+ * The enqueued entry is copied with _nc_copy_termtype(), so we can
+ * free some of the data from thisentry, i.e., the arrays.
+ */
+ FreeIfNeeded(thisentry.tterm.Booleans);
+ FreeIfNeeded(thisentry.tterm.Numbers);
+ FreeIfNeeded(thisentry.tterm.Strings);
+#if NCURSES_XNAMES
+ FreeIfNeeded(thisentry.tterm.ext_Names);
+#endif
+ }
}
if (_nc_tail) {
@@ -215,12 +182,13 @@ _nc_read_entry_source(FILE * fp, char *buf,
}
NCURSES_EXPORT(int)
-_nc_resolve_uses(bool fullresolve)
+_nc_resolve_uses2(bool fullresolve, bool literal)
/* try to resolve all use capabilities */
{
ENTRY *qp, *rp, *lastread = 0;
bool keepgoing;
- int i, j, unresolved, total_unresolved, multiples;
+ unsigned i;
+ int unresolved, total_unresolved, multiples;
DEBUG(2, ("RESOLUTION BEGINNING"));
@@ -293,7 +261,7 @@ _nc_resolve_uses(bool fullresolve)
rp = typeMalloc(ENTRY, 1);
if (rp == 0)
- _nc_err_abort("Out of memory");
+ _nc_err_abort(MSG_NO_MEMORY);
rp->tterm = thisterm;
rp->nuses = 0;
rp->next = lastread;
@@ -324,8 +292,8 @@ _nc_resolve_uses(bool fullresolve)
DEBUG(2, ("NAME RESOLUTION COMPLETED OK"));
/*
- * OK, at this point all (char *) references in `name' mwmbers
- * have been successfully converred to (ENTRY *) pointers in
+ * OK, at this point all (char *) references in `name' members
+ * have been successfully converted to (ENTRY *) pointers in
* `link' members. Time to do the actual merges.
*/
if (fullresolve) {
@@ -351,10 +319,10 @@ _nc_resolve_uses(bool fullresolve)
}
/*
- * First, make sure there's no garbage in the
- * merge block. as a side effect, copy into
- * the merged entry the name field and string
- * table pointer.
+ * First, make sure there is no garbage in the
+ * merge block. As a side effect, copy into
+ * the merged entry the name field and string
+ * table pointer.
*/
_nc_copy_termtype(&merged, &(qp->tterm));
@@ -377,6 +345,9 @@ _nc_resolve_uses(bool fullresolve)
FreeIfNeeded(qp->tterm.Booleans);
FreeIfNeeded(qp->tterm.Numbers);
FreeIfNeeded(qp->tterm.Strings);
+#if NCURSES_XNAMES
+ FreeIfNeeded(qp->tterm.ext_Names);
+#endif
qp->tterm = merged;
_nc_wrap_entry(qp, TRUE);
@@ -393,26 +364,6 @@ _nc_resolve_uses(bool fullresolve)
(keepgoing);
DEBUG(2, ("MERGES COMPLETED OK"));
-
- /*
- * The exit condition of the loop above is such that all entries
- * must now be resolved. Now handle cancellations. In a resolved
- * entry there should be no cancellation markers.
- */
- for_entry_list(qp) {
- for_each_boolean(j, &(qp->tterm)) {
- if ((int) qp->tterm.Booleans[j] == CANCELLED_BOOLEAN)
- qp->tterm.Booleans[j] = ABSENT_BOOLEAN;
- }
- for_each_number(j, &(qp->tterm)) {
- if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC)
- qp->tterm.Numbers[j] = ABSENT_NUMERIC;
- }
- for_each_string(j, &(qp->tterm)) {
- if (qp->tterm.Strings[j] == CANCELLED_STRING)
- qp->tterm.Strings[j] = ABSENT_STRING;
- }
- }
}
/*
@@ -430,7 +381,7 @@ _nc_resolve_uses(bool fullresolve)
for_entry_list(qp) {
_nc_curr_line = qp->startline;
_nc_set_type(_nc_first_name(qp->tterm.term_names));
- _nc_check_termtype(&qp->tterm);
+ _nc_check_termtype2(&qp->tterm, literal);
}
DEBUG(2, ("SANITY CHECK FINISHED"));
}
@@ -438,6 +389,13 @@ _nc_resolve_uses(bool fullresolve)
return (TRUE);
}
+/* obsolete: 20040705 */
+NCURSES_EXPORT(int)
+_nc_resolve_uses(bool fullresolve)
+{
+ return _nc_resolve_uses2(fullresolve, FALSE);
+}
+
/*
* This bit of legerdemain turns all the terminfo variable names into
* references to locations in the arrays Booleans, Numbers, and Strings ---
@@ -448,7 +406,7 @@ _nc_resolve_uses(bool fullresolve)
#define CUR tp->
static void
-sanity_check(TERMTYPE * tp)
+sanity_check2(TERMTYPE *tp, bool literal)
{
if (!PRESENT(exit_attribute_mode)) {
#ifdef __UNUSED__ /* this casts too wide a net */
@@ -465,14 +423,24 @@ sanity_check(TERMTYPE * tp)
|| PRESENT(enter_reverse_mode)))
_nc_warning("no exit_attribute_mode");
#endif /* __UNUSED__ */
- PAIRED(enter_standout_mode, exit_standout_mode)
- PAIRED(enter_underline_mode, exit_underline_mode)
+ PAIRED(enter_standout_mode, exit_standout_mode);
+ PAIRED(enter_underline_mode, exit_underline_mode);
+ }
+
+ /* we do this check/fix in postprocess_termcap(), but some packagers
+ * prefer to bypass it...
+ */
+ if (!literal) {
+ if (acs_chars == 0
+ && enter_alt_charset_mode != 0
+ && exit_alt_charset_mode != 0)
+ acs_chars = strdup(VT_ACSC);
+ ANDMISSING(enter_alt_charset_mode, acs_chars);
+ ANDMISSING(exit_alt_charset_mode, acs_chars);
}
/* listed in structure-member order of first argument */
PAIRED(enter_alt_charset_mode, exit_alt_charset_mode);
- ANDMISSING(enter_alt_charset_mode, acs_chars);
- ANDMISSING(exit_alt_charset_mode, acs_chars);
ANDMISSING(enter_blink_mode, exit_attribute_mode);
ANDMISSING(enter_bold_mode, exit_attribute_mode);
PAIRED(exit_ca_mode, enter_ca_mode);
@@ -490,6 +458,38 @@ sanity_check(TERMTYPE * tp)
PAIRED(enter_xon_mode, exit_xon_mode);
PAIRED(enter_am_mode, exit_am_mode);
ANDMISSING(label_off, label_on);
+#ifdef remove_clock
PAIRED(display_clock, remove_clock);
+#endif
ANDMISSING(set_color_pair, initialize_pair);
}
+
+/* obsolete: 20040705 */
+static void
+sanity_check(TERMTYPE *tp)
+{
+ sanity_check2(tp, FALSE);
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_leaks_tic(void)
+{
+ _nc_alloc_entry_leaks();
+ _nc_captoinfo_leaks();
+ _nc_comp_captab_leaks();
+ _nc_comp_scan_leaks();
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_names_leaks();
+ _nc_codes_leaks();
+#endif
+ _nc_tic_expand(0, FALSE, 0);
+}
+
+NCURSES_EXPORT(void)
+_nc_free_tic(int code)
+{
+ _nc_leaks_tic();
+ _nc_free_tinfo(code);
+}
+#endif
diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c
index a241322f188..ff3b9ac7ff2 100644
--- a/lib/libcurses/tinfo/comp_scan.c
+++ b/lib/libcurses/tinfo/comp_scan.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: comp_scan.c,v 1.15 2010/01/12 23:22:06 nicm Exp $ */
+
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
/*
@@ -50,7 +53,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$From: comp_scan.c,v 1.54 2001/02/04 01:09:26 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.15 2010/01/12 23:22:06 nicm Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -84,23 +87,207 @@ _nc_curr_token =
*****************************************************************************/
static bool first_column; /* See 'next_char()' below */
+static bool had_newline;
static char separator; /* capability separator */
static int pushtype; /* type of pushback token */
-static char pushname[MAX_NAME_SIZE + 1];
+static char *pushname;
#if NCURSES_EXT_FUNCS
NCURSES_EXPORT_VAR(bool)
_nc_disable_period = FALSE; /* used by tic -a option */
#endif
-static int last_char(void);
-static int next_char(void);
-static long stream_pos(void);
-static bool end_of_stream(void);
-static void push_back(char c);
+/*****************************************************************************
+ *
+ * Character-stream handling
+ *
+ *****************************************************************************/
+
+#define LEXBUFSIZ 1024
+
+static char *bufptr; /* otherwise, the input buffer pointer */
+static char *bufstart; /* start of buffer so we can compute offsets */
+static FILE *yyin; /* scanner's input file descriptor */
+
+/*
+ * _nc_reset_input()
+ *
+ * Resets the input-reading routines. Used on initialization,
+ * or after a seek has been done. Exactly one argument must be
+ * non-null.
+ */
+
+NCURSES_EXPORT(void)
+_nc_reset_input(FILE *fp, char *buf)
+{
+ pushtype = NO_PUSHBACK;
+ if (pushname != 0)
+ pushname[0] = '\0';
+ yyin = fp;
+ bufstart = bufptr = buf;
+ _nc_curr_file_pos = 0L;
+ if (fp != 0)
+ _nc_curr_line = 0;
+ _nc_curr_col = 0;
+}
+
+/*
+ * int last_char()
+ *
+ * Returns the final nonblank character on the current input buffer
+ */
+static int
+last_char(void)
+{
+ size_t len = strlen(bufptr);
+ while (len--) {
+ if (!isspace(UChar(bufptr[len])))
+ return bufptr[len];
+ }
+ return 0;
+}
+
+/*
+ * int next_char()
+ *
+ * Returns the next character in the input stream. Comments and leading
+ * white space are stripped.
+ *
+ * The global state variable 'firstcolumn' is set TRUE if the character
+ * returned is from the first column of the input line.
+ *
+ * The global variable _nc_curr_line is incremented for each new line.
+ * The global variable _nc_curr_file_pos is set to the file offset of the
+ * beginning of each line.
+ */
+
+static int
+next_char(void)
+{
+ static char *result;
+ static size_t allocated;
+ int the_char;
+
+ if (!yyin) {
+ if (result != 0) {
+ FreeAndNull(result);
+ FreeAndNull(pushname);
+ allocated = 0;
+ }
+ /*
+ * An string with an embedded null will truncate the input. This is
+ * intentional (we don't read binary files here).
+ */
+ if (bufptr == 0 || *bufptr == '\0')
+ return (EOF);
+ if (*bufptr == '\n') {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ } else if (*bufptr == '\t') {
+ _nc_curr_col = (_nc_curr_col | 7);
+ }
+ } else if (!bufptr || !*bufptr) {
+ /*
+ * In theory this could be recoded to do its I/O one character at a
+ * time, saving the buffer space. In practice, this turns out to be
+ * quite hard to get completely right. Try it and see. If you
+ * succeed, don't forget to hack push_back() correspondingly.
+ */
+ size_t used;
+ size_t len;
+
+ do {
+ bufstart = 0;
+ used = 0;
+ do {
+ if (used + (LEXBUFSIZ / 4) >= allocated) {
+ allocated += (allocated + LEXBUFSIZ);
+ result = typeRealloc(char, allocated, result);
+ if (result == 0)
+ return (EOF);
+ bufstart = result;
+ }
+ if (used == 0)
+ _nc_curr_file_pos = ftell(yyin);
+
+ if (fgets(result + used, (int) (allocated - used), yyin) != 0) {
+ bufstart = result;
+ if (used == 0) {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ }
+ } else {
+ if (used != 0)
+ strlcat(result, "\n", allocated);
+ }
+ if ((bufptr = bufstart) != 0) {
+ used = strlen(bufptr);
+ while (iswhite(*bufptr)) {
+ if (*bufptr == '\t') {
+ _nc_curr_col = (_nc_curr_col | 7) + 1;
+ } else {
+ _nc_curr_col++;
+ }
+ bufptr++;
+ }
+
+ /*
+ * Treat a trailing <cr><lf> the same as a <newline> so we
+ * can read files on OS/2, etc.
+ */
+ if ((len = strlen(bufptr)) > 1) {
+ if (bufptr[len - 1] == '\n'
+ && bufptr[len - 2] == '\r') {
+ len--;
+ bufptr[len - 1] = '\n';
+ bufptr[len] = '\0';
+ }
+ }
+ } else {
+ return (EOF);
+ }
+ } while (bufptr[len - 1] != '\n'); /* complete a line */
+ } while (result[0] == '#'); /* ignore comments */
+ } else if (*bufptr == '\t') {
+ _nc_curr_col = (_nc_curr_col | 7);
+ }
+
+ first_column = (bufptr == bufstart);
+ if (first_column)
+ had_newline = FALSE;
+
+ _nc_curr_col++;
+ the_char = *bufptr++;
+ return UChar(the_char);
+}
+
+static void
+push_back(char c)
+/* push a character back onto the input stream */
+{
+ if (bufptr == bufstart)
+ _nc_syserr_abort("Can't backspace off beginning of line");
+ *--bufptr = c;
+ _nc_curr_col--;
+}
+
+static long
+stream_pos(void)
+/* return our current character position in the input stream */
+{
+ return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
+}
+
+static bool
+end_of_stream(void)
+/* are we at end of input? */
+{
+ return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
+ ? TRUE : FALSE);
+}
/* Assume we may be looking at a termcap-style continuation */
-static inline int
+static NCURSES_INLINE int
eat_escaped_newline(int ch)
{
if (ch == '\\')
@@ -109,6 +296,15 @@ eat_escaped_newline(int ch)
return ch;
}
+#define TOK_BUF_SIZE MAX_ENTRY_SIZE
+
+#define OkToAdd() \
+ ((tok_ptr - tok_buf) < (TOK_BUF_SIZE - 2))
+
+#define AddCh(ch) \
+ *tok_ptr++ = (char) ch; \
+ *tok_ptr = '\0'
+
/*
* int
* get_token()
@@ -146,41 +342,65 @@ NCURSES_EXPORT(int)
_nc_get_token(bool silent)
{
static const char terminfo_punct[] = "@%&*!#";
- long number;
- int type;
- int ch;
+ static char *tok_buf;
+
+ char *after_list;
+ char *after_name;
char *numchk;
+ char *tok_ptr;
+ char *s;
char numbuf[80];
- unsigned found;
- static char buffer[MAX_ENTRY_SIZE];
- char *ptr;
+ int ch;
int dot_flag = FALSE;
+ int type;
+ long number;
long token_start;
+ unsigned found;
+#ifdef TRACE
+ int old_line;
+ int old_col;
+#endif
if (pushtype != NO_PUSHBACK) {
int retval = pushtype;
- _nc_set_type(pushname);
+ _nc_set_type(pushname != 0 ? pushname : "");
DEBUG(3, ("pushed-back token: `%s', class %d",
_nc_curr_token.tk_name, pushtype));
pushtype = NO_PUSHBACK;
- pushname[0] = '\0';
+ if (pushname != 0)
+ pushname[0] = '\0';
/* currtok wasn't altered by _nc_push_token() */
return (retval);
}
- if (end_of_stream())
+ if (end_of_stream()) {
+ yyin = 0;
+ next_char(); /* frees its allocated memory */
+ if (tok_buf != 0) {
+ if (_nc_curr_token.tk_name == tok_buf)
+ _nc_curr_token.tk_name = 0;
+ FreeAndNull(tok_buf);
+ }
return (EOF);
+ }
start_token:
token_start = stream_pos();
- while ((ch = next_char()) == '\n' || iswhite(ch))
+ while ((ch = next_char()) == '\n' || iswhite(ch)) {
+ if (ch == '\n')
+ had_newline = TRUE;
continue;
+ }
ch = eat_escaped_newline(ch);
+#ifdef TRACE
+ old_line = _nc_curr_line;
+ old_col = _nc_curr_col;
+#endif
if (ch == EOF)
type = EOF;
else {
@@ -206,33 +426,44 @@ _nc_get_token(bool silent)
}
/* have to make some punctuation chars legal for terminfo */
- if (!isalnum(ch)
+ if (!isalnum(UChar(ch))
#if NCURSES_EXT_FUNCS
&& !(ch == '.' && _nc_disable_period)
#endif
&& !strchr(terminfo_punct, (char) ch)) {
if (!silent)
- _nc_warning("Illegal character (expected alphanumeric or %s) - %s",
+ _nc_warning("Illegal character (expected alphanumeric or %s) - '%s'",
terminfo_punct, unctrl((chtype) ch));
_nc_panic_mode(separator);
goto start_token;
}
- ptr = buffer;
- *(ptr++) = ch;
+ if (tok_buf == 0)
+ tok_buf = typeMalloc(char, TOK_BUF_SIZE);
- if (first_column) {
- char *desc;
+#ifdef TRACE
+ old_line = _nc_curr_line;
+ old_col = _nc_curr_col;
+#endif
+ tok_ptr = tok_buf;
+ AddCh(ch);
+ if (first_column) {
_nc_comment_start = token_start;
_nc_comment_end = _nc_curr_file_pos;
_nc_start_line = _nc_curr_line;
_nc_syntax = ERR;
+ after_name = 0;
+ after_list = 0;
while ((ch = next_char()) != '\n') {
- if (ch == EOF)
- _nc_err_abort("premature EOF");
- else if (ch == ':' && last_char() != ',') {
+ if (ch == EOF) {
+ _nc_err_abort(MSG_NO_INPUTS);
+ } else if (ch == '|') {
+ after_list = tok_ptr;
+ if (after_name == 0)
+ after_name = tok_ptr;
+ } else if (ch == ':' && last_char() != ',') {
_nc_syntax = SYN_TERMCAP;
separator = ':';
break;
@@ -240,20 +471,29 @@ _nc_get_token(bool silent)
_nc_syntax = SYN_TERMINFO;
separator = ',';
/*
- * Fall-through here is not an accident. The idea is that
- * if we see a comma, we figure this is terminfo unless we
- * subsequently run into a colon -- but we don't stop
- * looking for that colon until hitting a newline. This
+ * If we did not see a '|', then we found a name with no
+ * aliases or description.
+ */
+ if (after_name == 0)
+ break;
+ /*
+ * If we see a comma, we assume this is terminfo unless we
+ * subsequently run into a colon. But we don't stop
+ * looking for a colon until hitting a newline. This
* allows commas to be embedded in description fields of
* either syntax.
*/
- /* FALLTHRU */
} else
ch = eat_escaped_newline(ch);
- *ptr++ = ch;
+ if (OkToAdd()) {
+ AddCh(ch);
+ } else {
+ ch = EOF;
+ break;
+ }
}
- ptr[0] = '\0';
+ *tok_ptr = '\0';
if (_nc_syntax == ERR) {
/*
* Grrr...what we ought to do here is barf, complaining that
@@ -265,65 +505,71 @@ _nc_get_token(bool silent)
separator = ':';
} else if (_nc_syntax == SYN_TERMINFO) {
/* throw away trailing /, *$/ */
- for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
+ for (--tok_ptr;
+ iswhite(*tok_ptr) || *tok_ptr == ',';
+ tok_ptr--)
continue;
- ptr[1] = '\0';
+ tok_ptr[1] = '\0';
}
/*
* This is the soonest we have the terminal name fetched. Set up
- * for following warning messages.
+ * for following warning messages. If there's no '|', then there
+ * is no description.
*/
- ptr = strchr(buffer, '|');
- if (ptr == (char *) NULL)
- ptr = buffer + strlen(buffer);
- ch = *ptr;
- *ptr = '\0';
- _nc_set_type(buffer);
- *ptr = ch;
+ if (after_name != 0) {
+ ch = *after_name;
+ *after_name = '\0';
+ _nc_set_type(tok_buf);
+ *after_name = (char) ch;
+ }
/*
* Compute the boundary between the aliases and the description
* field for syntax-checking purposes.
*/
- desc = strrchr(buffer, '|');
- if (!silent && desc) {
- if (*desc == '\0')
- _nc_warning("empty longname field");
- else if (strchr(desc, ' ') == (char *) NULL)
- _nc_warning("older tic versions may treat the description field as an alias");
+ if (after_list != 0) {
+ if (!silent) {
+ if (*after_list == '\0')
+ _nc_warning("empty longname field");
+ else if (strchr(after_list, ' ') == 0)
+ _nc_warning("older tic versions may treat the description field as an alias");
+ }
+ } else {
+ after_list = tok_buf + strlen(tok_buf);
+ DEBUG(1, ("missing description"));
}
- if (!desc)
- desc = buffer + strlen(buffer);
/*
* Whitespace in a name field other than the long name can confuse
* rdist and some termcap tools. Slashes are a no-no. Other
* special characters can be dangerous due to shell expansion.
*/
- for (ptr = buffer; ptr < desc; ptr++) {
- if (isspace(CharOf(*ptr))) {
+ for (s = tok_buf; s < after_list; ++s) {
+ if (isspace(UChar(*s))) {
if (!silent)
_nc_warning("whitespace in name or alias field");
break;
- } else if (*ptr == '/') {
+ } else if (*s == '/') {
if (!silent)
_nc_warning("slashes aren't allowed in names or aliases");
break;
- } else if (strchr("$[]!*?", *ptr)) {
+ } else if (strchr("$[]!*?", *s)) {
if (!silent)
- _nc_warning("dubious character `%c' in name or alias field", *ptr);
+ _nc_warning("dubious character `%c' in name or alias field", *s);
break;
}
}
- ptr = buffer;
-
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
type = NAMES;
} else {
+ if (had_newline && _nc_syntax == SYN_TERMCAP) {
+ _nc_warning("Missing backslash before newline");
+ had_newline = FALSE;
+ }
while ((ch = next_char()) != EOF) {
- if (!isalnum(ch)) {
+ if (!isalnum(UChar(ch))) {
if (_nc_syntax == SYN_TERMINFO) {
if (ch != '_')
break;
@@ -332,30 +578,35 @@ _nc_get_token(bool silent)
break;
}
}
- *(ptr++) = ch;
+ if (OkToAdd()) {
+ AddCh(ch);
+ } else {
+ ch = EOF;
+ break;
+ }
}
- *ptr++ = '\0';
+ *tok_ptr++ = '\0'; /* separate name/value in buffer */
switch (ch) {
case ',':
case ':':
if (ch != separator)
_nc_err_abort("Separator inconsistent with syntax");
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
type = BOOLEAN;
break;
case '@':
if ((ch = next_char()) != separator && !silent)
_nc_warning("Missing separator after `%s', have %s",
- buffer, unctrl((chtype) ch));
- _nc_curr_token.tk_name = buffer;
+ tok_buf, unctrl((chtype) ch));
+ _nc_curr_token.tk_name = tok_buf;
type = CANCEL;
break;
case '#':
found = 0;
while (isalnum(ch = next_char())) {
- numbuf[found++] = ch;
+ numbuf[found++] = (char) ch;
if (found >= sizeof(numbuf) - 1)
break;
}
@@ -363,21 +614,21 @@ _nc_get_token(bool silent)
number = strtol(numbuf, &numchk, 0);
if (!silent) {
if (numchk == numbuf)
- _nc_warning("no value given for `%s'", buffer);
+ _nc_warning("no value given for `%s'", tok_buf);
if ((*numchk != '\0') || (ch != separator))
_nc_warning("Missing separator");
}
- _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_name = tok_buf;
_nc_curr_token.tk_valnumber = number;
type = NUMBER;
break;
case '=':
- ch = _nc_trans_string(ptr, buffer + sizeof(buffer));
+ ch = _nc_trans_string(tok_ptr, tok_buf + TOK_BUF_SIZE);
if (!silent && ch != separator)
_nc_warning("Missing separator");
- _nc_curr_token.tk_name = buffer;
- _nc_curr_token.tk_valstring = ptr;
+ _nc_curr_token.tk_name = tok_buf;
+ _nc_curr_token.tk_valstring = tok_ptr;
type = STRING;
break;
@@ -388,7 +639,7 @@ _nc_get_token(bool silent)
/* just to get rid of the compiler warning */
type = UNDEF;
if (!silent)
- _nc_warning("Illegal character - %s", unctrl((chtype) ch));
+ _nc_warning("Illegal character - '%s'", unctrl((chtype) ch));
}
} /* end else (first_column == FALSE) */
} /* end else (ch != EOF) */
@@ -399,6 +650,11 @@ _nc_get_token(bool silent)
if (dot_flag == TRUE)
DEBUG(8, ("Commented out "));
+ if (_nc_tracing >= DEBUG_LEVEL(8)) {
+ _tracef("parsed %d.%d to %d.%d",
+ old_line, old_col,
+ _nc_curr_line, _nc_curr_col);
+ }
if (_nc_tracing >= DEBUG_LEVEL(7)) {
switch (type) {
case BOOLEAN:
@@ -443,8 +699,9 @@ _nc_get_token(bool silent)
type = _nc_get_token(silent);
DEBUG(3, ("token: `%s', class %d",
- _nc_curr_token.tk_name != 0 ? _nc_curr_token.tk_name :
- "<null>",
+ ((_nc_curr_token.tk_name != 0)
+ ? _nc_curr_token.tk_name
+ : "<null>"),
type));
return (type);
@@ -469,7 +726,7 @@ _nc_get_token(bool silent)
*
*/
-NCURSES_EXPORT(char)
+NCURSES_EXPORT(int)
_nc_trans_string(char *ptr, char *last)
{
int count = 0;
@@ -480,17 +737,24 @@ _nc_trans_string(char *ptr, char *last)
bool long_warning = FALSE;
while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
- if (ptr == (last - 1))
+ if (ptr >= (last - 1)) {
+ if (c != EOF) {
+ while ((c = next_char()) != separator && c != EOF) {
+ ;
+ }
+ ch = c;
+ }
break;
+ }
if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
break;
if (ch == '^' && last_ch != '%') {
ch = c = next_char();
if (c == EOF)
- _nc_err_abort("Premature EOF");
+ _nc_err_abort(MSG_NO_INPUTS);
if (!(is7bits(ch) && isprint(ch))) {
- _nc_warning("Illegal ^ character - %s", unctrl(ch));
+ _nc_warning("Illegal ^ character - '%s'", unctrl(ch));
}
if (ch == '?') {
*(ptr++) = '\177';
@@ -504,14 +768,14 @@ _nc_trans_string(char *ptr, char *last)
} else if (ch == '\\') {
ch = c = next_char();
if (c == EOF)
- _nc_err_abort("Premature EOF");
+ _nc_err_abort(MSG_NO_INPUTS);
if (ch >= '0' && ch <= '7') {
number = ch - '0';
for (i = 0; i < 2; i++) {
ch = c = next_char();
if (c == EOF)
- _nc_err_abort("Premature EOF");
+ _nc_err_abort(MSG_NO_INPUTS);
if (c < '0' || c > '7') {
if (isdigit(c)) {
@@ -585,21 +849,31 @@ _nc_trans_string(char *ptr, char *last)
continue;
default:
- _nc_warning("Illegal character %s in \\ sequence",
+ _nc_warning("Illegal character '%s' in \\ sequence",
unctrl(ch));
+ /* FALLTHRU */
+ case '|':
*(ptr++) = (char) ch;
} /* endswitch (ch) */
} /* endelse (ch < '0' || ch > '7') */
}
/* end else if (ch == '\\') */
else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
- /* newlines embedded in a terminfo string are ignored */
+ /*
+ * Newlines embedded in a terminfo string are ignored, provided
+ * that the next line begins with whitespace.
+ */
ignored = TRUE;
} else {
*(ptr++) = (char) ch;
}
if (!ignored) {
+ if (_nc_curr_col <= 1) {
+ push_back((char) ch);
+ ch = '\n';
+ break;
+ }
last_ch = ch;
count++;
}
@@ -629,14 +903,19 @@ _nc_push_token(int tokclass)
/*
* This implementation is kind of bogus, it will fail if we ever do more
* than one pushback at a time between get_token() calls. It relies on the
- * fact that curr_tok is static storage that nothing but get_token()
- * touches.
+ * fact that _nc_curr_token is static storage that nothing but
+ * _nc_get_token() touches.
*/
pushtype = tokclass;
+ if (pushname == 0)
+ pushname = typeMalloc(char, MAX_NAME_SIZE + 1);
_nc_get_type(pushname);
DEBUG(3, ("pushing token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ ((_nc_curr_token.tk_name != 0)
+ ? _nc_curr_token.tk_name
+ : "<null>"),
+ pushtype));
}
/*
@@ -656,168 +935,12 @@ _nc_panic_mode(char ch)
}
}
-/*****************************************************************************
- *
- * Character-stream handling
- *
- *****************************************************************************/
-
-#define LEXBUFSIZ 1024
-
-static char *bufptr; /* otherwise, the input buffer pointer */
-static char *bufstart; /* start of buffer so we can compute offsets */
-static FILE *yyin; /* scanner's input file descriptor */
-
-/*
- * _nc_reset_input()
- *
- * Resets the input-reading routines. Used on initialization,
- * or after a seek has been done. Exactly one argument must be
- * non-null.
- */
-
+#if NO_LEAKS
NCURSES_EXPORT(void)
-_nc_reset_input(FILE * fp, char *buf)
-{
- pushtype = NO_PUSHBACK;
- pushname[0] = '\0';
- yyin = fp;
- bufstart = bufptr = buf;
- _nc_curr_file_pos = 0L;
- if (fp != 0)
- _nc_curr_line = 0;
- _nc_curr_col = 0;
-}
-
-/*
- * int last_char()
- *
- * Returns the final nonblank character on the current input buffer
- */
-static int
-last_char(void)
-{
- size_t len = strlen(bufptr);
- while (len--) {
- if (!isspace(CharOf(bufptr[len])))
- return bufptr[len];
- }
- return 0;
-}
-
-/*
- * int next_char()
- *
- * Returns the next character in the input stream. Comments and leading
- * white space are stripped.
- *
- * The global state variable 'firstcolumn' is set TRUE if the character
- * returned is from the first column of the input line.
- *
- * The global variable _nc_curr_line is incremented for each new line.
- * The global variable _nc_curr_file_pos is set to the file offset of the
- * beginning of each line.
- */
-
-static int
-next_char(void)
+_nc_comp_scan_leaks(void)
{
- if (!yyin) {
- /*
- * An string with an embedded null will truncate the input. This is
- * intentional (we don't read binary files here).
- */
- if (*bufptr == '\0')
- return (EOF);
- if (*bufptr == '\n') {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- } else if (!bufptr || !*bufptr) {
- /*
- * In theory this could be recoded to do its I/O one character at a
- * time, saving the buffer space. In practice, this turns out to be
- * quite hard to get completely right. Try it and see. If you
- * succeed, don't forget to hack push_back() correspondingly.
- */
- static char *result;
- static size_t allocated;
- size_t used;
- size_t len;
-
- do {
- bufstart = 0;
- used = 0;
- do {
- if (used + (LEXBUFSIZ / 4) >= allocated) {
- allocated += (allocated + LEXBUFSIZ);
- result = _nc_doalloc(result, allocated);
- if (result == 0)
- return (EOF);
- }
- if (used == 0)
- _nc_curr_file_pos = ftell(yyin);
-
- if (fgets(result + used, allocated - used, yyin) != NULL) {
- bufstart = result;
- if (used == 0) {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- } else {
- if (used != 0)
- strlcat(result, "\n", allocated);
- }
- if ((bufptr = bufstart) != 0) {
- used = strlen(bufptr);
- while (iswhite(*bufptr))
- bufptr++;
-
- /*
- * Treat a trailing <cr><lf> the same as a <newline> so we
- * can read files on OS/2, etc.
- */
- if ((len = strlen(bufptr)) > 1) {
- if (bufptr[len - 1] == '\n'
- && bufptr[len - 2] == '\r') {
- len--;
- bufptr[len - 1] = '\n';
- bufptr[len] = '\0';
- }
- }
- } else {
- return (EOF);
- }
- } while (bufptr[len - 1] != '\n'); /* complete a line */
- } while (result[0] == '#'); /* ignore comments */
+ if (pushname != 0) {
+ FreeAndNull(pushname);
}
-
- first_column = (bufptr == bufstart);
-
- _nc_curr_col++;
- return (*bufptr++);
-}
-
-static void
-push_back(char c)
-/* push a character back onto the input stream */
-{
- if (bufptr == bufstart)
- _nc_syserr_abort("Can't backspace off beginning of line");
- *--bufptr = c;
-}
-
-static long
-stream_pos(void)
-/* return our current character position in the input stream */
-{
- return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
-}
-
-static bool
-end_of_stream(void)
-/* are we at end of input? */
-{
- return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
- ? TRUE : FALSE);
}
+#endif
diff --git a/lib/libcurses/tinfo/db_iterator.c b/lib/libcurses/tinfo/db_iterator.c
new file mode 100644
index 00000000000..84418492672
--- /dev/null
+++ b/lib/libcurses/tinfo/db_iterator.c
@@ -0,0 +1,227 @@
+/* $OpenBSD: db_iterator.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+/*
+ * Iterators for terminal databases.
+ */
+
+#include <curses.priv.h>
+
+#include <tic.h>
+
+MODULE_ID("$Id: db_iterator.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+#define HaveTicDirectory _nc_globals.have_tic_directory
+#define KeepTicDirectory _nc_globals.keep_tic_directory
+#define TicDirectory _nc_globals.tic_directory
+
+/*
+ * Record the "official" location of the terminfo directory, according to
+ * the place where we're writing to, or the normal default, if not.
+ */
+NCURSES_EXPORT(const char *)
+_nc_tic_dir(const char *path)
+{
+ if (!KeepTicDirectory) {
+ if (path != 0) {
+ TicDirectory = path;
+ HaveTicDirectory = TRUE;
+ } else if (!HaveTicDirectory && use_terminfo_vars()) {
+ char *envp;
+ if ((envp = getenv("TERMINFO")) != 0)
+ return _nc_tic_dir(envp);
+ }
+ }
+ return TicDirectory;
+}
+
+/*
+ * Special fix to prevent the terminfo directory from being moved after tic
+ * has chdir'd to it. If we let it be changed, then if $TERMINFO has a
+ * relative path, we'll lose track of the actual directory.
+ */
+NCURSES_EXPORT(void)
+_nc_keep_tic_dir(const char *path)
+{
+ _nc_tic_dir(path);
+ KeepTicDirectory = TRUE;
+}
+
+/*
+ * Process the list of :-separated directories, looking for the terminal type.
+ * We don't use strtok because it does not show us empty tokens.
+ */
+#define ThisDbList _nc_globals.dbi_list
+#define ThisDbSize _nc_globals.dbi_size
+
+/*
+ * Cleanup.
+ */
+NCURSES_EXPORT(void)
+_nc_last_db(void)
+{
+ if (ThisDbList != 0) {
+ FreeAndNull(ThisDbList);
+ }
+ ThisDbSize = 0;
+}
+
+/* The TERMINFO_DIRS value, if defined by the configure script, begins with a
+ * ":", which will be interpreted as TERMINFO.
+ */
+static const char *
+next_list_item(const char *source, int *offset)
+{
+ if (source != 0) {
+ FreeIfNeeded(ThisDbList);
+ ThisDbList = strdup(source);
+ ThisDbSize = strlen(source);
+ }
+
+ if (ThisDbList != 0 && ThisDbSize && *offset < ThisDbSize) {
+ static char system_db[] = TERMINFO;
+ char *result = ThisDbList + *offset;
+ char *marker = strchr(result, NCURSES_PATHSEP);
+
+ /*
+ * Put a null on the marker if a separator was found. Set the offset
+ * to the next position after the marker so we can call this function
+ * again, using the data at the offset.
+ */
+ if (marker == 0) {
+ *offset += strlen(result) + 1;
+ marker = result + *offset;
+ } else {
+ *marker++ = 0;
+ *offset = marker - ThisDbList;
+ }
+ if (*result == 0 && result != (ThisDbList + ThisDbSize))
+ result = system_db;
+ return result;
+ }
+ return 0;
+}
+
+#define NEXT_DBD(var, offset) next_list_item((*offset == 0) ? var : 0, offset)
+
+/*
+ * This is a simple iterator which allows the caller to step through the
+ * possible locations for a terminfo directory. ncurses uses this to find
+ * terminfo files to read.
+ */
+NCURSES_EXPORT(const char *)
+_nc_next_db(DBDIRS * state, int *offset)
+{
+ const char *result;
+ char *envp;
+
+ while (*state < dbdLAST) {
+ DBDIRS next = (DBDIRS) ((int) (*state) + 1);
+
+ result = 0;
+
+ switch (*state) {
+ case dbdTIC:
+ if (HaveTicDirectory)
+ result = _nc_tic_dir(0);
+ break;
+#if USE_DATABASE
+ case dbdEnvOnce:
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMINFO")) != 0)
+ result = _nc_tic_dir(envp);
+ }
+ break;
+ case dbdHome:
+ if (use_terminfo_vars()) {
+ result = _nc_home_terminfo();
+ }
+ break;
+ case dbdEnvList:
+ if (use_terminfo_vars()) {
+ if ((result = NEXT_DBD(getenv("TERMINFO_DIRS"), offset)) != 0)
+ next = *state;
+ }
+ break;
+ case dbdCfgList:
+#ifdef TERMINFO_DIRS
+ if ((result = NEXT_DBD(TERMINFO_DIRS, offset)) != 0)
+ next = *state;
+#endif
+ break;
+ case dbdCfgOnce:
+#ifndef TERMINFO_DIRS
+ result = TERMINFO;
+#endif
+ break;
+#endif /* USE_DATABASE */
+#if USE_TERMCAP
+ case dbdEnvOnce2:
+ if (use_terminfo_vars()) {
+ if ((envp = getenv("TERMCAP")) != 0)
+ result = _nc_tic_dir(envp);
+ }
+ break;
+ case dbdEnvList2:
+ if (use_terminfo_vars()) {
+ if ((result = NEXT_DBD(getenv("TERMPATH"), offset)) != 0)
+ next = *state;
+ }
+ break;
+ case dbdCfgList2:
+ if ((result = NEXT_DBD(TERMPATH, offset)) != 0)
+ next = *state;
+ break;
+#endif /* USE_TERMCAP */
+ case dbdLAST:
+ break;
+ }
+ if (*state != next) {
+ *state = next;
+ *offset = 0;
+ _nc_last_db();
+ }
+ if (result != 0) {
+ return result;
+ }
+ }
+ return 0;
+}
+
+NCURSES_EXPORT(void)
+_nc_first_db(DBDIRS * state, int *offset)
+{
+ *state = dbdTIC;
+ *offset = 0;
+}
diff --git a/lib/libcurses/tinfo/doalloc.c b/lib/libcurses/tinfo/doalloc.c
index 54659f55888..a28a5cbdffb 100644
--- a/lib/libcurses/tinfo/doalloc.c
+++ b/lib/libcurses/tinfo/doalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: doalloc.c,v 1.6 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: doalloc.c,v 1.7 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: doalloc.c,v 1.7 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: doalloc.c,v 1.7 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(void *)
_nc_doalloc(void *oldp, size_t amount)
@@ -54,7 +54,7 @@ _nc_doalloc(void *oldp, size_t amount)
errno = ENOMEM; /* just in case 'free' reset */
}
} else {
- newp = typeMalloc(char, amount);
+ newp = malloc(amount);
}
return newp;
}
@@ -67,7 +67,7 @@ _nc_strdup(const char *src)
size_t dsize;
if (src != 0) {
dsize = strlen(src) + 1;
- dst = typeMalloc(char, dsize);
+ dst = typeMalloc(char, strlen(src) + 1);
if (dst != 0) {
(void) strlcpy(dst, src, dsize);
}
diff --git a/lib/libcurses/tinfo/entries.c b/lib/libcurses/tinfo/entries.c
new file mode 100644
index 00000000000..ad76fadfb83
--- /dev/null
+++ b/lib/libcurses/tinfo/entries.c
@@ -0,0 +1,147 @@
+/* $OpenBSD: entries.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2006-2007,2008 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+
+#include <tic.h>
+#include <term_entry.h>
+
+MODULE_ID("$Id: entries.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+/****************************************************************************
+ *
+ * Entry queue handling
+ *
+ ****************************************************************************/
+/*
+ * The entry list is a doubly linked list with NULLs terminating the lists:
+ *
+ * --------- --------- ---------
+ * | | | | | | offset
+ * |-------| |-------| |-------|
+ * | ----+-->| ----+-->| NULL | next
+ * |-------| |-------| |-------|
+ * | NULL |<--+---- |<--+---- | last
+ * --------- --------- ---------
+ * ^ ^
+ * | |
+ * | |
+ * _nc_head _nc_tail
+ */
+
+NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
+NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
+
+NCURSES_EXPORT(void)
+_nc_free_entry(ENTRY * headp, TERMTYPE *tterm)
+/* free the allocated storage consumed by the given list entry */
+{
+ ENTRY *ep;
+
+ if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
+ free(ep);
+ }
+}
+
+NCURSES_EXPORT(void)
+_nc_free_entries(ENTRY * headp)
+/* free the allocated storage consumed by list entries */
+{
+ (void) headp; /* unused - _nc_head is altered here! */
+
+ while (_nc_head != 0) {
+ _nc_free_termtype(&(_nc_head->tterm));
+ }
+}
+
+NCURSES_EXPORT(ENTRY *)
+_nc_delink_entry(ENTRY * headp, TERMTYPE *tterm)
+/* delink the allocated storage for the given list entry */
+{
+ ENTRY *ep, *last;
+
+ for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
+ if (&(ep->tterm) == tterm) {
+ if (last != 0) {
+ last->next = ep->next;
+ }
+ if (ep == _nc_head) {
+ _nc_head = ep->next;
+ }
+ if (ep == _nc_tail) {
+ _nc_tail = last;
+ }
+ break;
+ }
+ }
+ return ep;
+}
+
+NCURSES_EXPORT(void)
+_nc_leaks_tinfo(void)
+{
+#if NO_LEAKS
+ char *s;
+#endif
+
+ T((T_CALLED("_nc_free_tinfo()")));
+#if NO_LEAKS
+ _nc_free_tparm();
+ _nc_tgetent_leaks();
+ _nc_free_entries(_nc_head);
+ _nc_get_type(0);
+ _nc_first_name(0);
+ _nc_keyname_leaks();
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_names_leaks();
+ _nc_codes_leaks();
+ FreeIfNeeded(_nc_prescreen.real_acs_map);
+#endif
+
+ if ((s = _nc_home_terminfo()) != 0)
+ free(s);
+#endif /* NO_LEAKS */
+ returnVoid;
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_free_tinfo(int code)
+{
+ _nc_leaks_tinfo();
+ exit(code);
+}
+#endif
diff --git a/lib/libcurses/tinfo/free_ttype.c b/lib/libcurses/tinfo/free_ttype.c
index 3fac7bc6122..a506df3eadf 100644
--- a/lib/libcurses/tinfo/free_ttype.c
+++ b/lib/libcurses/tinfo/free_ttype.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: free_ttype.c,v 1.6 2007/04/16 11:53:38 otto Exp $ */
+/* $OpenBSD: free_ttype.c,v 1.7 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
/*
@@ -45,11 +45,13 @@
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: free_ttype.c,v 1.7 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: free_ttype.c,v 1.7 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(void)
-_nc_free_termtype(TERMTYPE * ptr)
+_nc_free_termtype(TERMTYPE *ptr)
{
+ T(("_nc_free_termtype(%s)", ptr->term_names));
+
FreeIfNeeded(ptr->str_table);
FreeIfNeeded(ptr->Booleans);
FreeIfNeeded(ptr->Numbers);
@@ -59,6 +61,7 @@ _nc_free_termtype(TERMTYPE * ptr)
FreeIfNeeded(ptr->ext_Names);
#endif
memset(ptr, 0, sizeof(TERMTYPE));
+ _nc_free_entry(_nc_head, ptr);
}
#if NCURSES_XNAMES
@@ -68,7 +71,9 @@ NCURSES_EXPORT(int)
use_extended_names(bool flag)
{
int oldflag = _nc_user_definable;
+
+ T((T_CALLED("use_extended_names(%d)"), flag));
_nc_user_definable = flag;
- return oldflag;
+ returnBool(oldflag);
}
#endif
diff --git a/lib/libcurses/tinfo/getenv_num.c b/lib/libcurses/tinfo/getenv_num.c
index 80723dbedf8..b4c91796ca5 100644
--- a/lib/libcurses/tinfo/getenv_num.c
+++ b/lib/libcurses/tinfo/getenv_num.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getenv_num.c,v 1.2 2001/01/22 18:01:51 millert Exp $ */
+/* $OpenBSD: getenv_num.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -38,7 +38,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: getenv_num.c,v 1.3 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: getenv_num.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
_nc_getenv_num(const char *name)
diff --git a/lib/libcurses/tinfo/hashed_db.c b/lib/libcurses/tinfo/hashed_db.c
new file mode 100644
index 00000000000..2ce463a707f
--- /dev/null
+++ b/lib/libcurses/tinfo/hashed_db.c
@@ -0,0 +1,262 @@
+/* $OpenBSD: hashed_db.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2006 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2006 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <tic.h>
+#include <hashed_db.h>
+
+#if USE_HASHED_DB
+
+MODULE_ID("$Id: hashed_db.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+#if HASHED_DB_API >= 2
+static DBC *cursor;
+#endif
+
+/*
+ * Open the database.
+ */
+NCURSES_EXPORT(DB *)
+_nc_db_open(const char *path, bool modify)
+{
+ DB *result = 0;
+
+#if HASHED_DB_API >= 4
+ db_create(&result, NULL, 0);
+ result->open(result,
+ NULL,
+ path,
+ NULL,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644);
+#elif HASHED_DB_API >= 3
+ db_create(&result, NULL, 0);
+ result->open(result,
+ path,
+ NULL,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644);
+#elif HASHED_DB_API >= 2
+ int code;
+
+ if ((code = db_open(path,
+ DB_HASH,
+ modify ? DB_CREATE : DB_RDONLY,
+ 0644,
+ (DB_ENV *) 0,
+ (DB_INFO *) 0,
+ &result)) != 0) {
+ T(("cannot open %s: %s", path, strerror(code)));
+ result = 0;
+ } else {
+ T(("opened %s", path));
+ }
+#else
+ result = dbopen(path,
+ modify ? (O_CREAT | O_RDWR) : O_RDONLY,
+ 0644,
+ DB_HASH,
+ NULL);
+ if (result != 0) {
+ T(("opened %s", path));
+ }
+#endif
+ return result;
+}
+
+/*
+ * Close the database. Do not attempt to use the 'db' handle after this call.
+ */
+NCURSES_EXPORT(int)
+_nc_db_close(DB * db)
+{
+ int result;
+
+#if HASHED_DB_API >= 2
+ result = db->close(db, 0);
+#else
+ result = db->close(db);
+#endif
+ return result;
+}
+
+/*
+ * Write a record to the database.
+ *
+ * Returns 0 on success.
+ *
+ * FIXME: the FreeBSD cap_mkdb program assumes the database could have
+ * duplicates. There appears to be no good reason for that (review/fix).
+ */
+NCURSES_EXPORT(int)
+_nc_db_put(DB * db, DBT * key, DBT * data)
+{
+ int result;
+#if HASHED_DB_API >= 2
+ /* remove any pre-existing value, since we do not want duplicates */
+ (void) db->del(db, NULL, key, 0);
+ result = db->put(db, NULL, key, data, DB_NOOVERWRITE);
+#else
+ result = db->put(db, key, data, R_NOOVERWRITE);
+#endif
+ return result;
+}
+
+/*
+ * Read a record from the database.
+ *
+ * Returns 0 on success.
+ */
+NCURSES_EXPORT(int)
+_nc_db_get(DB * db, DBT * key, DBT * data)
+{
+ int result;
+
+ memset(data, 0, sizeof(*data));
+#if HASHED_DB_API >= 2
+ result = db->get(db, NULL, key, data, 0);
+#else
+ result = db->get(db, key, data, 0);
+#endif
+ return result;
+}
+
+/*
+ * Read the first record from the database, ignoring order.
+ *
+ * Returns 0 on success.
+ */
+NCURSES_EXPORT(int)
+_nc_db_first(DB * db, DBT * key, DBT * data)
+{
+ int result;
+
+ memset(key, 0, sizeof(*key));
+ memset(data, 0, sizeof(*data));
+#if HASHED_DB_API >= 2
+ if ((result = db->cursor(db, NULL, &cursor, 0)) == 0) {
+ result = cursor->c_get(cursor, key, data, DB_FIRST);
+ }
+#else
+ result = db->seq(db, key, data, 0);
+#endif
+ return result;
+}
+
+/*
+ * Read the next record from the database, ignoring order.
+ *
+ * Returns 0 on success.
+ */
+NCURSES_EXPORT(int)
+_nc_db_next(DB * db, DBT * key, DBT * data)
+{
+ int result;
+
+#if HASHED_DB_API >= 2
+ (void) db;
+ if (cursor != 0) {
+ result = cursor->c_get(cursor, key, data, DB_NEXT);
+ } else {
+ result = -1;
+ }
+#else
+ result = db->seq(db, key, data, 0);
+#endif
+ return result;
+}
+
+/*
+ * Check if a record is a terminfo index record. Index records are those that
+ * contain only an alias pointing to a list of aliases.
+ */
+NCURSES_EXPORT(bool)
+_nc_db_have_index(DBT * key, DBT * data, char **buffer, int *size)
+{
+ bool result = FALSE;
+ int used = data->size - 1;
+ char *have = (char *) data->data;
+
+ (void) key;
+ if (*have++ == 2) {
+ result = TRUE;
+ }
+ /*
+ * Update params in any case for consistency with _nc_db_have_data().
+ */
+ *buffer = have;
+ *size = used;
+ return result;
+}
+
+/*
+ * Check if a record is the terminfo data record. Ignore index records, e.g.,
+ * those that contain only an alias pointing to a list of aliases.
+ */
+NCURSES_EXPORT(bool)
+_nc_db_have_data(DBT * key, DBT * data, char **buffer, int *size)
+{
+ bool result = FALSE;
+ int used = data->size - 1;
+ char *have = (char *) data->data;
+
+ if (*have++ == 0) {
+ if (data->size > key->size
+ && IS_TIC_MAGIC(have)) {
+ result = TRUE;
+ }
+ }
+ /*
+ * Update params in any case to make it simple to follow a index record
+ * to the data record.
+ */
+ *buffer = have;
+ *size = used;
+ return result;
+}
+
+#else
+
+extern
+NCURSES_EXPORT(void)
+_nc_hashed_db(void);
+
+NCURSES_EXPORT(void)
+_nc_hashed_db(void)
+{
+}
+
+#endif /* USE_HASHED_DB */
diff --git a/lib/libcurses/tinfo/home_terminfo.c b/lib/libcurses/tinfo/home_terminfo.c
index 955955484fc..a33924aa46a 100644
--- a/lib/libcurses/tinfo/home_terminfo.c
+++ b/lib/libcurses/tinfo/home_terminfo.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: home_terminfo.c,v 1.8 2003/03/17 19:16:59 millert Exp $ */
+/* $OpenBSD: home_terminfo.c,v 1.9 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
/*
@@ -39,29 +39,31 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$From: home_terminfo.c,v 1.6 2000/12/10 02:55:07 tom Exp $")
-
-#define my_length (strlen(home) + sizeof(PRIVATE_INFO))
+MODULE_ID("$Id: home_terminfo.c,v 1.9 2010/01/12 23:22:06 nicm Exp $")
/* ncurses extension...fall back on user's private directory */
+#define MyBuffer _nc_globals.home_terminfo
+
NCURSES_EXPORT(char *)
_nc_home_terminfo(void)
{
+ char *result = 0;
+#if USE_HOME_TERMINFO
char *home;
- static char *temp = 0;
if (use_terminfo_vars()) {
- if (temp == 0) {
- if ((home = getenv("HOME")) != 0 && *home != '\0'
- && my_length <= PATH_MAX) {
- temp = typeMalloc(char, my_length);
- if (temp == 0)
- _nc_err_abort("Out of memory");
- (void) snprintf(temp, my_length, PRIVATE_INFO, home);
+ if (MyBuffer == 0) {
+ if ((home = getenv("HOME")) != 0 && *home != '\0') {
+ size_t want = (strlen(home) + sizeof(PRIVATE_INFO));
+ MyBuffer = typeMalloc(char, want);
+ if (MyBuffer == 0)
+ _nc_err_abort(MSG_NO_MEMORY);
+ (void) snprintf(MyBuffer, want, PRIVATE_INFO, home);
}
}
- return temp;
+ result = MyBuffer;
}
- return 0;
+#endif
+ return result;
}
diff --git a/lib/libcurses/tinfo/init_keytry.c b/lib/libcurses/tinfo/init_keytry.c
index 083861d2690..05bc1b62343 100644
--- a/lib/libcurses/tinfo/init_keytry.c
+++ b/lib/libcurses/tinfo/init_keytry.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: init_keytry.c,v 1.5 2001/01/22 18:01:51 millert Exp $ */
+/* $OpenBSD: init_keytry.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -30,11 +30,15 @@
#include <curses.priv.h>
-#include <term.h> /* keypad_xmit, keypad_local, meta_on, meta_off */
- /* cursor_visible,cursor_normal,cursor_invisible */
+#include <term.h>
+/* keypad_xmit, keypad_local, meta_on, meta_off */
+/* cursor_visible,cursor_normal,cursor_invisible */
+
#include <tic.h> /* struct tinfo_fkeys */
-MODULE_ID("$From: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
+#include <term_entry.h>
+
+MODULE_ID("$Id: init_keytry.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
/*
** _nc_init_keytry()
@@ -43,6 +47,13 @@ MODULE_ID("$From: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
**
*/
+/*
+ * Internal entrypoints use SCREEN* parameter to obtain capabilities rather
+ * than cur_term.
+ */
+#undef CUR
+#define CUR (sp->_term)->type.
+
#if BROKEN_LINKER
#undef _nc_tinfo_fkeys
#endif
@@ -54,7 +65,7 @@ MODULE_ID("$From: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
#endif*/
#if BROKEN_LINKER
-struct tinfo_fkeys *
+const struct tinfo_fkeys *
_nc_tinfo_fkeysf(void)
{
return _nc_tinfo_fkeys;
@@ -62,21 +73,47 @@ _nc_tinfo_fkeysf(void)
#endif
NCURSES_EXPORT(void)
-_nc_init_keytry(void)
+_nc_init_keytry(SCREEN *sp)
{
size_t n;
- /* The SP->_keytry value is initialized in newterm(), where the SP
+ /* The sp->_keytry value is initialized in newterm(), where the sp
* structure is created, because we can not tell where keypad() or
* mouse_activate() (which will call keyok()) are first called.
*/
- for (n = 0; _nc_tinfo_fkeys[n].code; n++)
- if (_nc_tinfo_fkeys[n].offset < STRCOUNT)
- _nc_add_to_try(&(SP->_keytry),
- CUR Strings[_nc_tinfo_fkeys[n].offset],
- _nc_tinfo_fkeys[n].code);
+ if (sp != 0) {
+ for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
+ if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
+ (void) _nc_add_to_try(&(sp->_keytry),
+ CUR Strings[_nc_tinfo_fkeys[n].offset],
+ _nc_tinfo_fkeys[n].code);
+ }
+ }
+#if NCURSES_XNAMES
+ /*
+ * Add any of the extended strings to the tries if their name begins
+ * with 'k', i.e., they follow the convention of other terminfo key
+ * names.
+ */
+ {
+ TERMTYPE *tp = &(sp->_term->type);
+ for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
+ const char *name = ExtStrname(tp, n, strnames);
+ char *value = tp->Strings[n];
+ if (name != 0
+ && *name == 'k'
+ && value != 0
+ && key_defined(value) == 0) {
+ (void) _nc_add_to_try(&(sp->_keytry),
+ value,
+ n - STRCOUNT + KEY_MAX);
+ }
+ }
+ }
+#endif
#ifdef TRACE
- _nc_trace_tries(SP->_keytry);
+ _nc_trace_tries(sp->_keytry);
#endif
+ }
}
diff --git a/lib/libcurses/tinfo/keys.list b/lib/libcurses/tinfo/keys.list
deleted file mode 100644
index 078c4747aa5..00000000000
--- a/lib/libcurses/tinfo/keys.list
+++ /dev/null
@@ -1,159 +0,0 @@
-# $OpenBSD: keys.list,v 1.1 1999/01/18 19:10:15 millert Exp $
-# $From: keys.list,v 1.5 1997/10/25 21:05:24 tom Exp $
-# The first column is the #define symbol that is in curses.h
-# The second column is the term.h symbol, for terminfo
-# Not all keycodes have corresponding terminfo capabilities.
-KEY_A1 key_a1
-KEY_A3 key_a3
-KEY_B2 key_b2
-KEY_BACKSPACE key_backspace
-KEY_BEG key_beg
-KEY_BREAK
-KEY_BTAB key_btab
-KEY_C1 key_c1
-KEY_C3 key_c3
-KEY_CANCEL key_cancel
-KEY_CATAB key_catab
-KEY_CLEAR key_clear
-KEY_CLOSE key_close
-KEY_COMMAND key_command
-KEY_COPY key_copy
-KEY_CREATE key_create
-KEY_CTAB key_ctab
-KEY_DC key_dc
-KEY_DL key_dl
-KEY_DOWN key_down
-KEY_EIC key_eic
-KEY_END key_end
-KEY_ENTER key_enter
-KEY_EOL key_eol
-KEY_EOS key_eos
-KEY_EXIT key_exit
-KEY_F(0) key_f0
-KEY_F(1) key_f1
-KEY_F(10) key_f10
-KEY_F(11) key_f11
-KEY_F(12) key_f12
-KEY_F(13) key_f13
-KEY_F(14) key_f14
-KEY_F(15) key_f15
-KEY_F(16) key_f16
-KEY_F(17) key_f17
-KEY_F(18) key_f18
-KEY_F(19) key_f19
-KEY_F(2) key_f2
-KEY_F(20) key_f20
-KEY_F(21) key_f21
-KEY_F(22) key_f22
-KEY_F(23) key_f23
-KEY_F(24) key_f24
-KEY_F(25) key_f25
-KEY_F(26) key_f26
-KEY_F(27) key_f27
-KEY_F(28) key_f28
-KEY_F(29) key_f29
-KEY_F(3) key_f3
-KEY_F(30) key_f30
-KEY_F(31) key_f31
-KEY_F(32) key_f32
-KEY_F(33) key_f33
-KEY_F(34) key_f34
-KEY_F(35) key_f35
-KEY_F(36) key_f36
-KEY_F(37) key_f37
-KEY_F(38) key_f38
-KEY_F(39) key_f39
-KEY_F(4) key_f4
-KEY_F(40) key_f40
-KEY_F(41) key_f41
-KEY_F(42) key_f42
-KEY_F(43) key_f43
-KEY_F(44) key_f44
-KEY_F(45) key_f45
-KEY_F(46) key_f46
-KEY_F(47) key_f47
-KEY_F(48) key_f48
-KEY_F(49) key_f49
-KEY_F(5) key_f5
-KEY_F(50) key_f50
-KEY_F(51) key_f51
-KEY_F(52) key_f52
-KEY_F(53) key_f53
-KEY_F(54) key_f54
-KEY_F(55) key_f55
-KEY_F(56) key_f56
-KEY_F(57) key_f57
-KEY_F(58) key_f58
-KEY_F(59) key_f59
-KEY_F(6) key_f6
-KEY_F(60) key_f60
-KEY_F(61) key_f61
-KEY_F(62) key_f62
-KEY_F(63) key_f63
-KEY_F(7) key_f7
-KEY_F(8) key_f8
-KEY_F(9) key_f9
-KEY_FIND key_find
-KEY_HELP key_help
-KEY_HOME key_home
-KEY_IC key_ic
-KEY_IL key_il
-KEY_LEFT key_left
-KEY_LL key_ll
-KEY_MARK key_mark
-KEY_MESSAGE key_message
-KEY_MOUSE key_mouse
-KEY_MOVE key_move
-KEY_NEXT key_next
-KEY_NPAGE key_npage
-KEY_OPEN key_open
-KEY_OPTIONS key_options
-KEY_PPAGE key_ppage
-KEY_PREVIOUS key_previous
-KEY_PRINT key_print
-KEY_REDO key_redo
-KEY_REFERENCE key_reference
-KEY_REFRESH key_refresh
-KEY_REPLACE key_replace
-KEY_RESET
-KEY_RESIZE
-KEY_RESTART key_restart
-KEY_RESUME key_resume
-KEY_RIGHT key_right
-KEY_SAVE key_save
-KEY_SBEG key_sbeg
-KEY_SCANCEL key_scancel
-KEY_SCOMMAND key_scommand
-KEY_SCOPY key_scopy
-KEY_SCREATE key_screate
-KEY_SDC key_sdc
-KEY_SDL key_sdl
-KEY_SELECT key_select
-KEY_SEND key_send
-KEY_SEOL key_seol
-KEY_SEXIT key_sexit
-KEY_SF key_sf
-KEY_SFIND key_sfind
-KEY_SHELP key_shelp
-KEY_SHOME key_shome
-KEY_SIC key_sic
-KEY_SLEFT key_sleft
-KEY_SMESSAGE key_smessage
-KEY_SMOVE key_smove
-KEY_SNEXT key_snext
-KEY_SOPTIONS key_soptions
-KEY_SPREVIOUS key_sprevious
-KEY_SPRINT key_sprint
-KEY_SR key_sr
-KEY_SREDO key_sredo
-KEY_SREPLACE key_sreplace
-KEY_SRESET
-KEY_SRIGHT key_sright
-KEY_SRSUME key_srsume
-KEY_SSAVE key_ssave
-KEY_SSUSPEND key_ssuspend
-KEY_STAB key_stab
-KEY_SUNDO key_sundo
-KEY_SUSPEND key_suspend
-KEY_UNDO key_undo
-KEY_UP key_up
diff --git a/lib/libcurses/tinfo/lib_acs.c b/lib/libcurses/tinfo/lib_acs.c
index 9e406cf4d18..b5a5c12a4be 100644
--- a/lib/libcurses/tinfo/lib_acs.c
+++ b/lib/libcurses/tinfo/lib_acs.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_acs.c,v 1.4 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_acs.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,128 +31,158 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
#include <term.h> /* ena_acs, acs_chars */
-MODULE_ID("$From: lib_acs.c,v 1.18 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
+#if BROKEN_LINKER || USE_REENTRANT
+#define MyBuffer _nc_prescreen.real_acs_map
+NCURSES_EXPORT_VAR(chtype *)
+_nc_acs_map(void)
+{
+ if (MyBuffer == 0)
+ MyBuffer = typeCalloc(chtype, ACS_LEN);
+ return MyBuffer;
+}
+#undef MyBuffer
+#else
NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] =
{
0
};
+#endif
NCURSES_EXPORT(void)
_nc_init_acs(void)
{
+ chtype *fake_map = acs_map;
+ chtype *real_map = SP != 0 ? SP->_acs_map : fake_map;
+ int j;
+
T(("initializing ACS map"));
/*
+ * If we're using this from curses (rather than terminfo), we are storing
+ * the mapping information in the SCREEN struct so we can decide how to
+ * render it.
+ */
+ if (real_map != fake_map) {
+ for (j = 1; j < ACS_LEN; ++j) {
+ real_map[j] = 0;
+ fake_map[j] = A_ALTCHARSET | j;
+ if (SP)
+ SP->_screen_acs_map[j] = FALSE;
+ }
+ } else {
+ for (j = 1; j < ACS_LEN; ++j) {
+ real_map[j] = 0;
+ }
+ }
+
+ /*
* Initializations for a UNIX-like multi-terminal environment. Use
* ASCII chars and count on the terminfo description to do better.
*/
- ACS_ULCORNER = '+'; /* should be upper left corner */
- ACS_LLCORNER = '+'; /* should be lower left corner */
- ACS_URCORNER = '+'; /* should be upper right corner */
- ACS_LRCORNER = '+'; /* should be lower right corner */
- ACS_RTEE = '+'; /* should be tee pointing left */
- ACS_LTEE = '+'; /* should be tee pointing right */
- ACS_BTEE = '+'; /* should be tee pointing up */
- ACS_TTEE = '+'; /* should be tee pointing down */
- ACS_HLINE = '-'; /* should be horizontal line */
- ACS_VLINE = '|'; /* should be vertical line */
- ACS_PLUS = '+'; /* should be large plus or crossover */
- ACS_S1 = '~'; /* should be scan line 1 */
- ACS_S9 = '_'; /* should be scan line 9 */
- ACS_DIAMOND = '+'; /* should be diamond */
- ACS_CKBOARD = ':'; /* should be checker board (stipple) */
- ACS_DEGREE = '\''; /* should be degree symbol */
- ACS_PLMINUS = '#'; /* should be plus/minus */
- ACS_BULLET = 'o'; /* should be bullet */
- ACS_LARROW = '<'; /* should be arrow pointing left */
- ACS_RARROW = '>'; /* should be arrow pointing right */
- ACS_DARROW = 'v'; /* should be arrow pointing down */
- ACS_UARROW = '^'; /* should be arrow pointing up */
- ACS_BOARD = '#'; /* should be board of squares */
- ACS_LANTERN = '#'; /* should be lantern symbol */
- ACS_BLOCK = '#'; /* should be solid square block */
+ real_map['l'] = '+'; /* should be upper left corner */
+ real_map['m'] = '+'; /* should be lower left corner */
+ real_map['k'] = '+'; /* should be upper right corner */
+ real_map['j'] = '+'; /* should be lower right corner */
+ real_map['u'] = '+'; /* should be tee pointing left */
+ real_map['t'] = '+'; /* should be tee pointing right */
+ real_map['v'] = '+'; /* should be tee pointing up */
+ real_map['w'] = '+'; /* should be tee pointing down */
+ real_map['q'] = '-'; /* should be horizontal line */
+ real_map['x'] = '|'; /* should be vertical line */
+ real_map['n'] = '+'; /* should be large plus or crossover */
+ real_map['o'] = '~'; /* should be scan line 1 */
+ real_map['s'] = '_'; /* should be scan line 9 */
+ real_map['`'] = '+'; /* should be diamond */
+ real_map['a'] = ':'; /* should be checker board (stipple) */
+ real_map['f'] = '\''; /* should be degree symbol */
+ real_map['g'] = '#'; /* should be plus/minus */
+ real_map['~'] = 'o'; /* should be bullet */
+ real_map[','] = '<'; /* should be arrow pointing left */
+ real_map['+'] = '>'; /* should be arrow pointing right */
+ real_map['.'] = 'v'; /* should be arrow pointing down */
+ real_map['-'] = '^'; /* should be arrow pointing up */
+ real_map['h'] = '#'; /* should be board of squares */
+ real_map['i'] = '#'; /* should be lantern symbol */
+ real_map['0'] = '#'; /* should be solid square block */
/* these defaults were invented for ncurses */
- ACS_S3 = '-'; /* should be scan line 3 */
- ACS_S7 = '-'; /* should be scan line 7 */
- ACS_LEQUAL = '<'; /* should be less-than-or-equal-to */
- ACS_GEQUAL = '>'; /* should be greater-than-or-equal-to */
- ACS_PI = '*'; /* should be greek pi */
- ACS_NEQUAL = '!'; /* should be not-equal */
- ACS_STERLING = 'f'; /* should be pound-sterling symbol */
+ real_map['p'] = '-'; /* should be scan line 3 */
+ real_map['r'] = '-'; /* should be scan line 7 */
+ real_map['y'] = '<'; /* should be less-than-or-equal-to */
+ real_map['z'] = '>'; /* should be greater-than-or-equal-to */
+ real_map['{'] = '*'; /* should be greek pi */
+ real_map['|'] = '!'; /* should be not-equal */
+ real_map['}'] = 'f'; /* should be pound-sterling symbol */
if (ena_acs != NULL) {
TPUTS_TRACE("ena_acs");
putp(ena_acs);
}
-#define ALTCHAR(c) ((chtype)(((unsigned char)(c)) | A_ALTCHARSET))
+#if NCURSES_EXT_FUNCS
+ /*
+ * Linux console "supports" the "PC ROM" character set by the coincidence
+ * that smpch/rmpch and smacs/rmacs have the same values. ncurses has
+ * no codepage support (see SCO Merge for an example). Outside of the
+ * values defined in acsc, there are no definitions for the "PC ROM"
+ * character set (assumed by some applications to be codepage 437), but we
+ * allow those applications to use those codepoints.
+ *
+ * test/blue.c uses this feature.
+ */
+#define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b))
+ if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) &&
+ PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) {
+ size_t i;
+ for (i = 1; i < ACS_LEN; ++i) {
+ if (real_map[i] == 0) {
+ real_map[i] = i;
+ if (real_map != fake_map) {
+ if (SP != 0)
+ SP->_screen_acs_map[i] = TRUE;
+ }
+ }
+ }
+ }
+#endif
if (acs_chars != NULL) {
size_t i = 0;
size_t length = strlen(acs_chars);
- while (i < length)
- switch (acs_chars[i]) {
- case 'l':
- case 'm':
- case 'k':
- case 'j':
- case 'u':
- case 't':
- case 'v':
- case 'w':
- case 'q':
- case 'x':
- case 'n':
- case 'o':
- case 's':
- case '`':
- case 'a':
- case 'f':
- case 'g':
- case '~':
- case ',':
- case '+':
- case '.':
- case '-':
- case 'h':
- case 'i':
- case '0':
- case 'p':
- case 'r':
- case 'y':
- case 'z':
- case '{':
- case '|':
- case '}':
- acs_map[(unsigned int) acs_chars[i]] =
- ALTCHAR(acs_chars[i + 1]);
- i++;
- /* FALLTHRU */
- default:
- i++;
- break;
+ while (i + 1 < length) {
+ if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
+ real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
+ if (SP != 0)
+ SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
}
+ i += 2;
+ }
}
#ifdef TRACE
/* Show the equivalent mapping, noting if it does not match the
* given attribute, whether by re-ordering or duplication.
*/
- if (_nc_tracing & TRACE_CALLS) {
+ if (USE_TRACEF(TRACE_CALLS)) {
size_t n, m;
- char show[SIZEOF(acs_map) + 1];
- for (n = 1, m = 0; n < SIZEOF(acs_map); n++) {
- if (acs_map[n] != 0) {
+ char show[ACS_LEN * 2 + 1];
+ for (n = 1, m = 0; n < ACS_LEN; n++) {
+ if (real_map[n] != 0) {
show[m++] = (char) n;
- show[m++] = TextOf(acs_map[n]);
+ show[m++] = (char) ChCharOf(real_map[n]);
}
}
show[m] = 0;
+ if (acs_chars == NULL || strcmp(acs_chars, show))
+ _tracef("%s acs_chars %s",
+ (acs_chars == NULL) ? "NULL" : "READ",
+ _nc_visbuf(acs_chars));
_tracef("%s acs_chars %s",
(acs_chars == NULL)
? "NULL"
@@ -160,6 +190,7 @@ _nc_init_acs(void)
? "DIFF"
: "SAME"),
_nc_visbuf(show));
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
}
diff --git a/lib/libcurses/tinfo/lib_baudrate.c b/lib/libcurses/tinfo/lib_baudrate.c
index 39342dcb9ab..a171993945a 100644
--- a/lib/libcurses/tinfo/lib_baudrate.c
+++ b/lib/libcurses/tinfo/lib_baudrate.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_baudrate.c,v 1.4 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_baudrate.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -41,8 +42,47 @@
#include <curses.priv.h>
#include <term.h> /* cur_term, pad_char */
#include <termcap.h> /* ospeed */
+#if defined(__FreeBSD__)
+#include <sys/param.h>
+#endif
+
+/*
+ * These systems use similar header files, which define B1200 as 1200, etc.,
+ * but can be overridden by defining USE_OLD_TTY so B1200 is 9, which makes all
+ * of the indices up to B115200 fit nicely in a 'short', allowing us to retain
+ * ospeed's type for compatibility.
+ */
+#if (defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || defined(__NetBSD__) || defined(__OpenBSD__)
+#undef B0
+#undef B50
+#undef B75
+#undef B110
+#undef B134
+#undef B150
+#undef B200
+#undef B300
+#undef B600
+#undef B1200
+#undef B1800
+#undef B2400
+#undef B4800
+#undef B9600
+#undef B19200
+#undef EXTA
+#undef B38400
+#undef EXTB
+#undef B57600
+#undef B115200
+#undef B230400
+#undef B460800
+#undef B921600
+#define USE_OLD_TTY
+#include <sys/ttydev.h>
+#else
+#undef USE_OLD_TTY
+#endif /* USE_OLD_TTY */
-MODULE_ID("$From: lib_baudrate.c,v 1.19 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
/*
* int
@@ -99,21 +139,28 @@ static struct speed const speeds[] =
#ifdef B460800
{B460800, 460800},
#endif
+#ifdef B921600
+ {B921600, 921600},
+#endif
};
NCURSES_EXPORT(int)
_nc_baudrate(int OSpeed)
{
+#if !USE_REENTRANT
static int last_OSpeed;
static int last_baudrate;
+#endif
- int result;
+ int result = ERR;
unsigned i;
+#if !USE_REENTRANT
if (OSpeed == last_OSpeed) {
result = last_baudrate;
- } else {
- result = ERR;
+ }
+#endif
+ if (result == ERR) {
if (OSpeed >= 0) {
for (i = 0; i < SIZEOF(speeds); i++) {
if (speeds[i].s == OSpeed) {
@@ -122,7 +169,12 @@ _nc_baudrate(int OSpeed)
}
}
}
- last_baudrate = result;
+#if !USE_REENTRANT
+ if (OSpeed == last_OSpeed) {
+ last_OSpeed = OSpeed;
+ last_baudrate = result;
+ }
+#endif
}
return (result);
}
@@ -157,24 +209,32 @@ baudrate(void)
* that take into account costs that depend on baudrate.
*/
#ifdef TRACE
- if (SP && !isatty(fileno(SP->_ofp))
+ if (!isatty(fileno(SP ? SP->_ofp : stdout))
&& getenv("BAUDRATE") != 0) {
int ret;
if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
ret = 9600;
ospeed = _nc_ospeed(ret);
returnCode(ret);
- } else
+ }
#endif
+ if (cur_term != 0) {
+#ifdef USE_OLD_TTY
+ result = cfgetospeed(&cur_term->Nttyb);
+ ospeed = _nc_ospeed(result);
+#else /* !USE_OLD_TTY */
#ifdef TERMIOS
ospeed = cfgetospeed(&cur_term->Nttyb);
#else
ospeed = cur_term->Nttyb.sg_ospeed;
#endif
- result = _nc_baudrate(ospeed);
- if (cur_term != 0)
+ result = _nc_baudrate(ospeed);
+#endif
cur_term->_baudrate = result;
+ } else {
+ result = ERR;
+ }
returnCode(result);
}
diff --git a/lib/libcurses/tinfo/lib_cur_term.c b/lib/libcurses/tinfo/lib_cur_term.c
index 3fcf4abe47c..68bb567f793 100644
--- a/lib/libcurses/tinfo/lib_cur_term.c
+++ b/lib/libcurses/tinfo/lib_cur_term.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_cur_term.c,v 1.5 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_cur_term.c,v 1.6 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,33 +42,66 @@
#include <term_entry.h> /* TTY, cur_term */
#include <termcap.h> /* ospeed */
-MODULE_ID("$From: lib_cur_term.c,v 1.11 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.6 2010/01/12 23:22:06 nicm Exp $")
+#undef CUR
+#define CUR termp->type.
+
+#if BROKEN_LINKER || USE_REENTRANT
+NCURSES_EXPORT(TERMINAL *)
+NCURSES_PUBLIC_VAR(cur_term) (void)
+{
+ return (SP != 0 && SP->_term != 0) ? SP->_term : _nc_prescreen._cur_term;
+}
+#else
NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0;
+#endif
NCURSES_EXPORT(TERMINAL *)
set_curterm(TERMINAL * termp)
{
- TERMINAL *oldterm = cur_term;
+ TERMINAL *oldterm;
+
+ T((T_CALLED("set_curterm(%p)"), termp));
- if ((cur_term = termp) != 0) {
- ospeed = _nc_ospeed(cur_term->_baudrate);
- PC = (pad_char != NULL) ? pad_char[0] : 0;
+ _nc_lock_global(curses);
+ oldterm = cur_term;
+ if (SP)
+ SP->_term = termp;
+#if BROKEN_LINKER || USE_REENTRANT
+ _nc_prescreen._cur_term = termp;
+#else
+ cur_term = termp;
+#endif
+ if (termp != 0) {
+ ospeed = _nc_ospeed(termp->_baudrate);
+ if (termp->type.Strings) {
+ PC = (char) ((pad_char != NULL) ? pad_char[0] : 0);
+ }
}
- return oldterm;
+ _nc_unlock_global(curses);
+
+ T((T_RETURN("%p"), oldterm));
+ return (oldterm);
}
NCURSES_EXPORT(int)
del_curterm(TERMINAL * termp)
{
+ int rc = ERR;
+
T((T_CALLED("del_curterm(%p)"), termp));
+ _nc_lock_global(curses);
if (termp != 0) {
_nc_free_termtype(&(termp->type));
+ FreeIfNeeded(termp->_termname);
free(termp);
if (termp == cur_term)
- cur_term = 0;
- returnCode(OK);
+ set_curterm(0);
+ rc = OK;
}
- returnCode(ERR);
+ _nc_unlock_global(curses);
+
+ returnCode(rc);
}
diff --git a/lib/libcurses/tinfo/lib_data.c b/lib/libcurses/tinfo/lib_data.c
index cdc8044ab18..57e8d7e9a06 100644
--- a/lib/libcurses/tinfo/lib_data.c
+++ b/lib/libcurses/tinfo/lib_data.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_data.c,v 1.3 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_data.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,18 +43,33 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_data.c,v 1.16 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
/*
* OS/2's native linker complains if we don't initialize public data when
* constructing a dll (reported by J.J.G.Ripoll).
*/
-NCURSES_EXPORT_VAR(WINDOW *)
-stdscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *)
-curscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *)
-newscr = 0;
+#if USE_REENTRANT
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(stdscr) (void)
+{
+ return SP ? SP->_stdscr : 0;
+}
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(curscr) (void)
+{
+ return SP ? SP->_curscr : 0;
+}
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(newscr) (void)
+{
+ return SP ? SP->_newscr : 0;
+}
+#else
+NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
+#endif
NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
@@ -68,7 +84,7 @@ NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
* module coupling that increases the size of the executable.
*/
#if BROKEN_LINKER
- static SCREEN *my_screen;
+static SCREEN *my_screen;
NCURSES_EXPORT(SCREEN *)
_nc_screen(void)
@@ -83,11 +99,236 @@ _nc_alloc_screen(void)
}
NCURSES_EXPORT(void)
-_nc_set_screen(SCREEN * sp)
+_nc_set_screen(SCREEN *sp)
{
my_screen = sp;
}
#else
-NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
+NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
+#endif
+/* *INDENT-OFF* */
+#define CHARS_0s { '\0' }
+
+#define TGETENT_0 { 0L, FALSE, NULL, NULL, NULL }
+#define TGETENT_0s { TGETENT_0, TGETENT_0, TGETENT_0, TGETENT_0 }
+
+NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
+ 0, /* have_sigwinch */
+ 0, /* cleanup_nested */
+
+ FALSE, /* init_signals */
+ FALSE, /* init_screen */
+
+ NULL, /* comp_sourcename */
+ NULL, /* comp_termtype */
+
+ FALSE, /* have_tic_directory */
+ FALSE, /* keep_tic_directory */
+ TERMINFO, /* tic_directory */
+
+ NULL, /* dbi_list */
+ 0, /* dbi_size */
+
+ NULL, /* first_name */
+ NULL, /* keyname_table */
+
+ 0, /* slk_format */
+
+ NULL, /* safeprint_buf */
+ 0, /* safeprint_used */
+
+ TGETENT_0s, /* tgetent_cache */
+ 0, /* tgetent_index */
+ 0, /* tgetent_sequence */
+
+ 0, /* _nc_windowlist */
+
+#if USE_HOME_TERMINFO
+ NULL, /* home_terminfo */
+#endif
+
+#if !USE_SAFE_SPRINTF
+ 0, /* safeprint_cols */
+ 0, /* safeprint_rows */
+#endif
+
+#ifdef TRACE
+ FALSE, /* init_trace */
+ CHARS_0s, /* trace_fname */
+ 0, /* trace_level */
+ NULL, /* trace_fp */
+
+ NULL, /* tracearg_buf */
+ 0, /* tracearg_used */
+
+ NULL, /* tracebuf_ptr */
+ 0, /* tracebuf_used */
+
+ CHARS_0s, /* tracechr_buf */
+
+ NULL, /* tracedmp_buf */
+ 0, /* tracedmp_used */
+
+ NULL, /* tracetry_buf */
+ 0, /* tracetry_used */
+
+ { CHARS_0s, CHARS_0s }, /* traceatr_color_buf */
+ 0, /* traceatr_color_sel */
+ -1, /* traceatr_color_last */
+
+#endif /* TRACE */
+#ifdef USE_PTHREADS
+ PTHREAD_MUTEX_INITIALIZER, /* mutex_curses */
+ PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */
+ PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */
+ 0, /* nested_tracef */
+ 0, /* use_pthreads */
+#endif
+};
+
+#define STACK_FRAME_0 { { 0 }, 0 }
+#define STACK_FRAME_0s { STACK_FRAME_0 }
+#define NUM_VARS_0s { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+
+#define RIPOFF_0 { 0,0,0 }
+#define RIPOFF_0s { RIPOFF_0 }
+
+NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
+ TRUE, /* use_env */
+ FALSE, /* filter_mode */
+ A_NORMAL, /* previous_attr */
+ RIPOFF_0s, /* ripoff */
+ NULL, /* rsp */
+ { /* tparm_state */
+#ifdef TRACE
+ NULL, /* tname */
+#endif
+ NULL, /* tparam_base */
+
+ STACK_FRAME_0s, /* stack */
+ 0, /* stack_ptr */
+
+ NULL, /* out_buff */
+ 0, /* out_size */
+ 0, /* out_used */
+
+ NULL, /* fmt_buff */
+ 0, /* fmt_size */
+
+ NUM_VARS_0s, /* dynamic_var */
+ NUM_VARS_0s, /* static_vars */
+ },
+ NULL, /* saved_tty */
+#if NCURSES_NO_PADDING
+ FALSE, /* flag to set if padding disabled */
+#endif
+#if BROKEN_LINKER || USE_REENTRANT
+ NULL, /* real_acs_map */
+ 0, /* LINES */
+ 0, /* COLS */
+ 0, /* cur_term */
+#ifdef TRACE
+ 0L, /* _outchars */
+ NULL, /* _tputs_trace */
+#endif
+#endif
+};
+/* *INDENT-ON* */
+
+/******************************************************************************/
+#ifdef USE_PTHREADS
+static void
+init_global_mutexes(void)
+{
+ static bool initialized = FALSE;
+
+ if (!initialized) {
+ initialized = TRUE;
+ _nc_mutex_init(&_nc_globals.mutex_curses);
+ _nc_mutex_init(&_nc_globals.mutex_tst_tracef);
+ _nc_mutex_init(&_nc_globals.mutex_tracef);
+ }
+}
+
+NCURSES_EXPORT(void)
+_nc_init_pthreads(void)
+{
+ if (_nc_use_pthreads)
+ return;
+# if USE_WEAK_SYMBOLS
+ if ((pthread_mutex_init) == 0)
+ return;
+ if ((pthread_mutex_lock) == 0)
+ return;
+ if ((pthread_mutex_unlock) == 0)
+ return;
+ if ((pthread_mutex_trylock) == 0)
+ return;
+ if ((pthread_mutexattr_settype) == 0)
+ return;
+# endif
+ _nc_use_pthreads = 1;
+ init_global_mutexes();
+}
+
+/*
+ * Use recursive mutexes if we have them - they're part of Unix98.
+ * For the cases where we do not, _nc_mutex_trylock() is used to avoid a
+ * deadlock, at the expense of memory leaks and unexpected failures that
+ * may not be handled by typical clients.
+ *
+ * FIXME - need configure check for PTHREAD_MUTEX_RECURSIVE, define it to
+ * PTHREAD_MUTEX_NORMAL if not supported.
+ */
+NCURSES_EXPORT(void)
+_nc_mutex_init(pthread_mutex_t * obj)
+{
+ pthread_mutexattr_t recattr;
+
+ if (_nc_use_pthreads) {
+ pthread_mutexattr_init(&recattr);
+ pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(obj, &recattr);
+ }
+}
+
+NCURSES_EXPORT(int)
+_nc_mutex_lock(pthread_mutex_t * obj)
+{
+ if (_nc_use_pthreads == 0)
+ return 0;
+ return pthread_mutex_lock(obj);
+}
+
+NCURSES_EXPORT(int)
+_nc_mutex_trylock(pthread_mutex_t * obj)
+{
+ if (_nc_use_pthreads == 0)
+ return 0;
+ return pthread_mutex_trylock(obj);
+}
+
+NCURSES_EXPORT(int)
+_nc_mutex_unlock(pthread_mutex_t * obj)
+{
+ if (_nc_use_pthreads == 0)
+ return 0;
+ return pthread_mutex_unlock(obj);
+}
+
+#if USE_WEAK_SYMBOLS
+/*
+ * NB: sigprocmask(2) is global but pthread_sigmask(3p)
+ * only for the calling thread.
+ */
+NCURSES_EXPORT(int)
+_nc_sigprocmask(int how, const sigset_t * newmask, sigset_t * oldmask)
+{
+ if ((pthread_sigmask))
+ return pthread_sigmask(how, newmask, oldmask);
+ else
+ return sigprocmask(how, newmask, oldmask);
+}
#endif
+#endif /* USE_PTHREADS */
diff --git a/lib/libcurses/tinfo/lib_has_cap.c b/lib/libcurses/tinfo/lib_has_cap.c
index d95e3f908c7..6be944be979 100644
--- a/lib/libcurses/tinfo/lib_has_cap.c
+++ b/lib/libcurses/tinfo/lib_has_cap.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_has_cap.c,v 1.2 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_has_cap.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-2003 *
****************************************************************************/
/*
@@ -44,7 +45,7 @@
#include <term.h>
-MODULE_ID("$From: lib_has_cap.c,v 1.3 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_has_cap.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(bool)
has_ic(void)
diff --git a/lib/libcurses/tinfo/lib_kernel.c b/lib/libcurses/tinfo/lib_kernel.c
index 730ba1551fd..024227fdc03 100644
--- a/lib/libcurses/tinfo/lib_kernel.c
+++ b/lib/libcurses/tinfo/lib_kernel.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_kernel.c,v 1.2 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_kernel.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 2002 *
****************************************************************************/
/*
@@ -49,7 +50,28 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$From: lib_kernel.c,v 1.21 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
+
+static int
+_nc_vdisable(void)
+{
+ int value = -1;
+#if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
+ value = _POSIX_VDISABLE;
+#endif
+#if defined(_PC_VDISABLE)
+ if (value == -1) {
+ value = fpathconf(0, _PC_VDISABLE);
+ if (value == -1) {
+ value = 0377;
+ }
+ }
+#elif defined(VDISABLE)
+ if (value == -1)
+ value = VDISABLE;
+#endif
+ return value;
+}
/*
* erasechar()
@@ -61,16 +83,19 @@ MODULE_ID("$From: lib_kernel.c,v 1.21 2000/12/10 02:55:07 tom Exp $")
NCURSES_EXPORT(char)
erasechar(void)
{
+ int result = ERR;
T((T_CALLED("erasechar()")));
if (cur_term != 0) {
#ifdef TERMIOS
- returnCode(cur_term->Ottyb.c_cc[VERASE]);
+ result = cur_term->Ottyb.c_cc[VERASE];
+ if (result == _nc_vdisable())
+ result = ERR;
#else
- returnCode(cur_term->Ottyb.sg_erase);
+ result = cur_term->Ottyb.sg_erase;
#endif
}
- returnCode(ERR);
+ returnCode(result);
}
/*
@@ -83,16 +108,19 @@ erasechar(void)
NCURSES_EXPORT(char)
killchar(void)
{
+ int result = ERR;
T((T_CALLED("killchar()")));
if (cur_term != 0) {
#ifdef TERMIOS
- returnCode(cur_term->Ottyb.c_cc[VKILL]);
+ result = cur_term->Ottyb.c_cc[VKILL];
+ if (result == _nc_vdisable())
+ result = ERR;
#else
- returnCode(cur_term->Ottyb.sg_kill);
+ result = cur_term->Ottyb.sg_kill;
#endif
}
- returnCode(ERR);
+ returnCode(result);
}
/*
diff --git a/lib/libcurses/tinfo/lib_longname.c b/lib/libcurses/tinfo/lib_longname.c
index 9cbbf5fcbf5..74616fa7bc7 100644
--- a/lib/libcurses/tinfo/lib_longname.c
+++ b/lib/libcurses/tinfo/lib_longname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_longname.c,v 1.2 2001/01/22 18:01:52 millert Exp $ */
+/* $OpenBSD: lib_longname.c,v 1.3 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_longname.c,v 1.9 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_longname.c,v 1.3 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(char *)
longname(void)
diff --git a/lib/libcurses/tinfo/lib_napms.c b/lib/libcurses/tinfo/lib_napms.c
index bf29ef488f5..b92431d9701 100644
--- a/lib/libcurses/tinfo/lib_napms.c
+++ b/lib/libcurses/tinfo/lib_napms.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_napms.c,v 1.7 2001/01/22 18:01:53 millert Exp $ */
+/* $OpenBSD: lib_napms.c,v 1.8 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,6 +38,8 @@
*
* The routine napms.
*
+ * (This file was originally written by Eric Raymond; however except for
+ * comments, none of the original code remains - T.Dickey).
*/
#include <curses.priv.h>
@@ -47,20 +49,9 @@
#if HAVE_SYS_TIME_H
#include <sys/time.h> /* needed for MacOS X DP3 */
#endif
-#elif USE_FUNC_POLL
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#elif HAVE_SELECT
-#if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT
-#include <sys/time.h>
-#endif
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
#endif
-MODULE_ID("$From: lib_napms.c,v 1.11 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.8 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
napms(int ms)
@@ -69,23 +60,17 @@ napms(int ms)
#if HAVE_NANOSLEEP
{
- struct timespec ts;
- ts.tv_sec = ms / 1000;
- ts.tv_nsec = (ms % 1000) * 1000000;
- nanosleep(&ts, NULL);
- }
-#elif USE_FUNC_POLL
- {
- struct pollfd fds[1];
- poll(fds, 0, ms);
- }
-#elif HAVE_SELECT
- {
- struct timeval tval;
- tval.tv_sec = ms / 1000;
- tval.tv_usec = (ms % 1000) * 1000;
- select(0, NULL, NULL, NULL, &tval);
+ struct timespec request, remaining;
+ request.tv_sec = ms / 1000;
+ request.tv_nsec = (ms % 1000) * 1000000;
+ while (nanosleep(&request, &remaining) == -1
+ && errno == EINTR) {
+ request = remaining;
+ }
}
+#else
+ _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
#endif
+
returnCode(OK);
}
diff --git a/lib/libcurses/tinfo/lib_options.c b/lib/libcurses/tinfo/lib_options.c
index ca96bc3d7db..00e079fce5b 100644
--- a/lib/libcurses/tinfo/lib_options.c
+++ b/lib/libcurses/tinfo/lib_options.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_options.c,v 1.9 2001/01/22 18:01:53 millert Exp $ */
+/* $OpenBSD: lib_options.c,v 1.10 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -44,7 +45,10 @@
#include <term.h>
-MODULE_ID("$From: lib_options.c,v 1.42 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.10 2010/01/12 23:22:06 nicm Exp $")
+
+static int _nc_curs_set(SCREEN *, int);
+static int _nc_meta(SCREEN *, bool);
NCURSES_EXPORT(int)
idlok(WINDOW *win, bool flag)
@@ -74,7 +78,7 @@ halfdelay(int t)
{
T((T_CALLED("halfdelay(%d)"), t));
- if (t < 1 || t > 255)
+ if (t < 1 || t > 255 || SP == 0)
returnCode(ERR);
cbreak();
@@ -100,7 +104,7 @@ nodelay(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
notimeout(WINDOW *win, bool f)
{
- T((T_CALLED("notimout(%p,%d)"), win, f));
+ T((T_CALLED("notimeout(%p,%d)"), win, f));
if (win) {
win->_notimeout = f;
@@ -117,6 +121,7 @@ wtimeout(WINDOW *win, int delay)
if (win) {
win->_delay = delay;
}
+ returnVoid;
}
NCURSES_EXPORT(int)
@@ -126,7 +131,7 @@ keypad(WINDOW *win, bool flag)
if (win) {
win->_use_keypad = flag;
- returnCode(_nc_keypad(flag));
+ returnCode(_nc_keypad(SP, flag));
} else
returnCode(ERR);
}
@@ -134,19 +139,12 @@ keypad(WINDOW *win, bool flag)
NCURSES_EXPORT(int)
meta(WINDOW *win GCC_UNUSED, bool flag)
{
+ int result;
+
/* Ok, we stay relaxed and don't signal an error if win is NULL */
T((T_CALLED("meta(%p,%d)"), win, flag));
-
- SP->_use_meta = flag;
-
- if (flag && meta_on) {
- TPUTS_TRACE("meta_on");
- putp(meta_on);
- } else if (!flag && meta_off) {
- TPUTS_TRACE("meta_off");
- putp(meta_off);
- }
- returnCode(OK);
+ result = _nc_meta(SP, flag);
+ returnCode(result);
}
/* curs_set() moved here to narrow the kernel interface */
@@ -154,51 +152,23 @@ meta(WINDOW *win GCC_UNUSED, bool flag)
NCURSES_EXPORT(int)
curs_set(int vis)
{
- int cursor = SP->_cursor;
+ int result;
T((T_CALLED("curs_set(%d)"), vis));
-
- if (vis < 0 || vis > 2)
- returnCode(ERR);
-
- if (vis == cursor)
- returnCode(cursor);
-
- switch (vis) {
- case 2:
- if (cursor_visible) {
- TPUTS_TRACE("cursor_visible");
- putp(cursor_visible);
- } else
- returnCode(ERR);
- break;
- case 1:
- if (cursor_normal) {
- TPUTS_TRACE("cursor_normal");
- putp(cursor_normal);
- } else
- returnCode(ERR);
- break;
- case 0:
- if (cursor_invisible) {
- TPUTS_TRACE("cursor_invisible");
- putp(cursor_invisible);
- } else
- returnCode(ERR);
- break;
- }
- SP->_cursor = vis;
- _nc_flush();
-
- returnCode(cursor == -1 ? 1 : cursor);
+ result = _nc_curs_set(SP, vis);
+ returnCode(result);
}
NCURSES_EXPORT(int)
typeahead(int fd)
{
T((T_CALLED("typeahead(%d)"), fd));
- SP->_checkfd = fd;
- returnCode(OK);
+ if (SP != 0) {
+ SP->_checkfd = fd;
+ returnCode(OK);
+ } else {
+ returnCode(ERR);
+ }
}
/*
@@ -210,7 +180,7 @@ typeahead(int fd)
#if NCURSES_EXT_FUNCS
static int
-has_key_internal(int keycode, struct tries *tp)
+has_key_internal(int keycode, TRIES * tp)
{
if (tp == 0)
return (FALSE);
@@ -225,10 +195,39 @@ NCURSES_EXPORT(int)
has_key(int keycode)
{
T((T_CALLED("has_key(%d)"), keycode));
- returnCode(has_key_internal(keycode, SP->_keytry));
+ returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE);
}
#endif /* NCURSES_EXT_FUNCS */
+/*
+ * Internal entrypoints use SCREEN* parameter to obtain capabilities rather
+ * than cur_term.
+ */
+#undef CUR
+#define CUR (sp->_term)->type.
+
+static int
+_nc_putp(const char *name GCC_UNUSED, const char *value)
+{
+ int rc = ERR;
+
+ if (value) {
+ TPUTS_TRACE(name);
+ rc = putp(value);
+ }
+ return rc;
+}
+
+static int
+_nc_putp_flush(const char *name, const char *value)
+{
+ int rc = _nc_putp(name, value);
+ if (rc != ERR) {
+ _nc_flush();
+ }
+ return rc;
+}
+
/* Turn the keypad on/off
*
* Note: we flush the output because changing this mode causes some terminals
@@ -237,21 +236,94 @@ has_key(int keycode)
* the terminal state _before_ switching modes.
*/
NCURSES_EXPORT(int)
-_nc_keypad(bool flag)
+_nc_keypad(SCREEN *sp, bool flag)
{
- if (flag && keypad_xmit) {
- TPUTS_TRACE("keypad_xmit");
- putp(keypad_xmit);
- _nc_flush();
- } else if (!flag && keypad_local) {
- TPUTS_TRACE("keypad_local");
- putp(keypad_local);
- _nc_flush();
+ int rc = ERR;
+
+ if (sp != 0) {
+#ifdef USE_PTHREADS
+ /*
+ * We might have this situation in a multithreaded application that
+ * has wgetch() reading in more than one thread. putp() and below
+ * may use SP explicitly.
+ */
+ if (_nc_use_pthreads && sp != SP) {
+ SCREEN *save_sp;
+
+ /* cannot use use_screen(), since that is not in tinfo library */
+ _nc_lock_global(curses);
+ save_sp = SP;
+ _nc_set_screen(sp);
+ rc = _nc_keypad(sp, flag);
+ _nc_set_screen(save_sp);
+ _nc_unlock_global(curses);
+ } else
+#endif
+ {
+ if (flag) {
+ (void) _nc_putp_flush("keypad_xmit", keypad_xmit);
+ } else if (!flag && keypad_local) {
+ (void) _nc_putp_flush("keypad_local", keypad_local);
+ }
+
+ if (flag && !sp->_tried) {
+ _nc_init_keytry(sp);
+ sp->_tried = TRUE;
+ }
+ sp->_keypad_on = flag;
+ rc = OK;
+ }
+ }
+ return (rc);
+}
+
+static int
+_nc_curs_set(SCREEN *sp, int vis)
+{
+ int result = ERR;
+
+ T((T_CALLED("curs_set(%d)"), vis));
+ if (sp != 0 && vis >= 0 && vis <= 2) {
+ int cursor = sp->_cursor;
+
+ if (vis == cursor) {
+ result = cursor;
+ } else {
+ switch (vis) {
+ case 2:
+ result = _nc_putp_flush("cursor_visible", cursor_visible);
+ break;
+ case 1:
+ result = _nc_putp_flush("cursor_normal", cursor_normal);
+ break;
+ case 0:
+ result = _nc_putp_flush("cursor_invisible", cursor_invisible);
+ break;
+ }
+ if (result != ERR)
+ result = (cursor == -1 ? 1 : cursor);
+ sp->_cursor = vis;
+ }
}
+ returnCode(result);
+}
+
+static int
+_nc_meta(SCREEN *sp, bool flag)
+{
+ int result = ERR;
+
+ /* Ok, we stay relaxed and don't signal an error if win is NULL */
+
+ if (SP != 0) {
+ SP->_use_meta = flag;
- if (flag && !SP->_tried) {
- _nc_init_keytry();
- SP->_tried = TRUE;
+ if (flag) {
+ _nc_putp("meta_on", meta_on);
+ } else {
+ _nc_putp("meta_off", meta_off);
+ }
+ result = OK;
}
- return (OK);
+ return result;
}
diff --git a/lib/libcurses/tinfo/lib_print.c b/lib/libcurses/tinfo/lib_print.c
index 9a5b3157e07..5043c551004 100644
--- a/lib/libcurses/tinfo/lib_print.c
+++ b/lib/libcurses/tinfo/lib_print.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_print.c,v 1.4 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_print.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,7 +37,7 @@
#include <term.h>
-MODULE_ID("$From: lib_print.c,v 1.13 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_print.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
mcprint(char *data, int len)
@@ -53,7 +53,7 @@ mcprint(char *data, int len)
}
if (prtr_non) {
- switchon = tparm(prtr_non, len);
+ switchon = TPARM_1(prtr_non, len);
onsize = strlen(switchon);
offsize = 0;
} else {
@@ -63,13 +63,13 @@ mcprint(char *data, int len)
}
res = onsize + len + offsize + 1;
- if ((mybuf = typeMalloc(char, res)) == (char *) 0) {
+ if (switchon == 0 || (mybuf = typeMalloc(char, res)) == 0) {
errno = ENOMEM;
return (ERR);
}
(void) strlcpy(mybuf, switchon, res);
- memcpy(mybuf + onsize, data, len);
+ memcpy(mybuf + onsize, data, (unsigned) len);
if (offsize)
(void) strlcpy(mybuf + onsize + len, prtr_off, res - onsize - len);
diff --git a/lib/libcurses/tinfo/lib_raw.c b/lib/libcurses/tinfo/lib_raw.c
index eb10b64e30b..724ba92a4a2 100644
--- a/lib/libcurses/tinfo/lib_raw.c
+++ b/lib/libcurses/tinfo/lib_raw.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_raw.c,v 1.7 2001/01/22 18:01:53 millert Exp $ */
+/* $OpenBSD: lib_raw.c,v 1.8 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1998 on *
****************************************************************************/
/*
@@ -50,7 +51,7 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$From: lib_raw.c,v 1.10 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.8 2010/01/12 23:22:06 nicm Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -62,13 +63,16 @@ MODULE_ID("$From: lib_raw.c,v 1.10 2000/12/10 02:55:07 tom Exp $")
#ifdef __EMX__
#include <io.h>
+#define _nc_setmode(mode) setmode(SP->_ifd, mode)
+#else
+#define _nc_setmode(mode) /* nothing */
#endif
#define COOKED_INPUT (IXON|BRKINT|PARMRK)
#ifdef TRACE
-#define BEFORE(N) if (_nc_tracing&TRACE_BITS) _tracef("%s before bits: %s", N, _nc_tracebits())
-#define AFTER(N) if (_nc_tracing&TRACE_BITS) _tracef("%s after bits: %s", N, _nc_tracebits())
+#define BEFORE(N) if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s before bits: %s", N, _nc_tracebits())
+#define AFTER(N) if (USE_TRACEF(TRACE_BITS)) _nc_locked_tracef("%s after bits: %s", N, _nc_tracebits())
#else
#define BEFORE(s)
#define AFTER(s)
@@ -77,162 +81,218 @@ MODULE_ID("$From: lib_raw.c,v 1.10 2000/12/10 02:55:07 tom Exp $")
NCURSES_EXPORT(int)
raw(void)
{
+ int result = ERR;
+
T((T_CALLED("raw()")));
- if (SP != 0 && cur_term != 0) {
- SP->_raw = TRUE;
- SP->_cbreak = 1;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_BINARY);
-#endif
+ BEFORE("raw");
+ _nc_setmode(O_BINARY);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("raw");
- cur_term->Nttyb.c_lflag &= ~(ICANON | ISIG | IEXTEN);
- cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT);
- cur_term->Nttyb.c_cc[VMIN] = 1;
- cur_term->Nttyb.c_cc[VTIME] = 0;
- AFTER("raw");
+ buf.c_lflag &= ~(ICANON | ISIG | IEXTEN);
+ buf.c_iflag &= ~(COOKED_INPUT);
+ buf.c_cc[VMIN] = 1;
+ buf.c_cc[VTIME] = 0;
#else
- cur_term->Nttyb.sg_flags |= RAW;
+ buf.sg_flags |= RAW;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_raw = TRUE;
+ SP->_cbreak = 1;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("raw");
}
- returnCode(ERR);
+ returnCode(result);
}
NCURSES_EXPORT(int)
cbreak(void)
{
+ int result = ERR;
+
T((T_CALLED("cbreak()")));
- SP->_cbreak = 1;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_BINARY);
-#endif
+ BEFORE("cbreak");
+ _nc_setmode(O_BINARY);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("cbreak");
- cur_term->Nttyb.c_lflag &= ~ICANON;
- cur_term->Nttyb.c_iflag &= ~ICRNL;
- cur_term->Nttyb.c_lflag |= ISIG;
- cur_term->Nttyb.c_cc[VMIN] = 1;
- cur_term->Nttyb.c_cc[VTIME] = 0;
- AFTER("cbreak");
+ buf.c_lflag &= ~ICANON;
+ buf.c_iflag &= ~ICRNL;
+ buf.c_lflag |= ISIG;
+ buf.c_cc[VMIN] = 1;
+ buf.c_cc[VTIME] = 0;
#else
- cur_term->Nttyb.sg_flags |= CBREAK;
+ buf.sg_flags |= CBREAK;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_cbreak = 1;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("cbreak");
+ }
+ returnCode(result);
}
+/*
+ * Note:
+ * this implementation may be wrong. See the comment under intrflush().
+ */
NCURSES_EXPORT(void)
qiflush(void)
{
+ int result = ERR;
+
T((T_CALLED("qiflush()")));
- /*
- * Note: this implementation may be wrong. See the comment under
- * intrflush().
- */
+ if (cur_term != 0) {
+ TTY buf;
+ BEFORE("qiflush");
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("qiflush");
- cur_term->Nttyb.c_lflag &= ~(NOFLSH);
- AFTER("qiflush");
- (void) _nc_set_tty_mode(&cur_term->Nttyb);
- returnVoid;
+ buf.c_lflag &= ~(NOFLSH);
+ result = _nc_set_tty_mode(&buf);
+#else
+ /* FIXME */
#endif
+ if (result == OK)
+ cur_term->Nttyb = buf;
+ AFTER("qiflush");
+ }
+ returnVoid;
}
NCURSES_EXPORT(int)
noraw(void)
{
+ int result = ERR;
+
T((T_CALLED("noraw()")));
- SP->_raw = FALSE;
- SP->_cbreak = 0;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_TEXT);
-#endif
+ BEFORE("noraw");
+ _nc_setmode(O_TEXT);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("noraw");
- cur_term->Nttyb.c_lflag |= ISIG | ICANON |
- (cur_term->Ottyb.c_lflag & IEXTEN);
- cur_term->Nttyb.c_iflag |= COOKED_INPUT;
- AFTER("noraw");
+ buf.c_lflag |= ISIG | ICANON |
+ (cur_term->Ottyb.c_lflag & IEXTEN);
+ buf.c_iflag |= COOKED_INPUT;
#else
- cur_term->Nttyb.sg_flags &= ~(RAW | CBREAK);
+ buf.sg_flags &= ~(RAW | CBREAK);
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("noraw");
+ }
+ returnCode(result);
}
NCURSES_EXPORT(int)
nocbreak(void)
{
+ int result = ERR;
+
T((T_CALLED("nocbreak()")));
- SP->_cbreak = 0;
+ if (SP != 0 && cur_term != 0) {
+ TTY buf;
-#ifdef __EMX__
- setmode(SP->_ifd, O_TEXT);
-#endif
+ BEFORE("nocbreak");
+ _nc_setmode(O_TEXT);
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("nocbreak");
- cur_term->Nttyb.c_lflag |= ICANON;
- cur_term->Nttyb.c_iflag |= ICRNL;
- AFTER("nocbreak");
+ buf.c_lflag |= ICANON;
+ buf.c_iflag |= ICRNL;
#else
- cur_term->Nttyb.sg_flags &= ~CBREAK;
+ buf.sg_flags &= ~CBREAK;
#endif
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if ((result = _nc_set_tty_mode(&buf)) == OK) {
+ SP->_cbreak = 0;
+ cur_term->Nttyb = buf;
+ }
+ AFTER("nocbreak");
+ }
+ returnCode(result);
}
+/*
+ * Note:
+ * this implementation may be wrong. See the comment under intrflush().
+ */
NCURSES_EXPORT(void)
noqiflush(void)
{
+ int result = ERR;
+
T((T_CALLED("noqiflush()")));
- /*
- * Note: this implementation may be wrong. See the comment under
- * intrflush().
- */
+ if (cur_term != 0) {
+ TTY buf;
+ BEFORE("noqiflush");
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("noqiflush");
- cur_term->Nttyb.c_lflag |= NOFLSH;
- AFTER("noqiflush");
- (void) _nc_set_tty_mode(&cur_term->Nttyb);
- returnVoid;
+ buf.c_lflag |= NOFLSH;
+ result = _nc_set_tty_mode(&buf);
+#else
+ /* FIXME */
#endif
+ if (result == OK) {
+ cur_term->Nttyb = buf;
+ }
+ AFTER("noqiflush");
+ }
+ returnVoid;
}
+/*
+ * This call does the same thing as the qiflush()/noqiflush() pair. We know
+ * for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the other hand,
+ * the match (in the SVr4 man pages) between the language describing NOFLSH in
+ * termio(7) and the language describing qiflush()/noqiflush() in
+ * curs_inopts(3x) is too exact to be coincidence.
+ */
NCURSES_EXPORT(int)
intrflush(WINDOW *win GCC_UNUSED, bool flag)
{
+ int result = ERR;
+
T((T_CALLED("intrflush(%d)"), flag));
- /*
- * This call does the same thing as the qiflush()/noqiflush() pair. We
- * know for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the
- * other hand, the match (in the SVr4 man pages) between the language
- * describing NOFLSH in termio(7) and the language describing
- * qiflush()/noqiflush() in curs_inopts(3x) is too exact to be coincidence.
- */
+ if (cur_term != 0) {
+ TTY buf;
+ BEFORE("intrflush");
+ buf = cur_term->Nttyb;
#ifdef TERMIOS
- BEFORE("intrflush");
- if (flag)
- cur_term->Nttyb.c_lflag &= ~(NOFLSH);
- else
- cur_term->Nttyb.c_lflag |= (NOFLSH);
- AFTER("intrflush");
- returnCode(_nc_set_tty_mode(&cur_term->Nttyb));
+ if (flag)
+ buf.c_lflag &= ~(NOFLSH);
+ else
+ buf.c_lflag |= (NOFLSH);
+ result = _nc_set_tty_mode(&buf);
#else
- returnCode(ERR);
+ /* FIXME */
#endif
+ if (result == OK) {
+ cur_term->Nttyb = buf;
+ }
+ AFTER("intrflush");
+ }
+ returnCode(result);
}
diff --git a/lib/libcurses/tinfo/lib_setup.c b/lib/libcurses/tinfo/lib_setup.c
index 1db8a06bc1b..63643848a29 100644
--- a/lib/libcurses/tinfo/lib_setup.c
+++ b/lib/libcurses/tinfo/lib_setup.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_setup.c,v 1.11 2001/01/22 18:01:53 millert Exp $ */
+/* $OpenBSD: lib_setup.c,v 1.12 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -48,9 +49,13 @@
#define _POSIX_SOURCE
#endif
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$From: lib_setup.c,v 1.64 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.12 2010/01/12 23:22:06 nicm Exp $")
/****************************************************************************
*
@@ -74,6 +79,10 @@ MODULE_ID("$From: lib_setup.c,v 1.64 2000/12/10 02:55:07 tom Exp $")
# include <sys/ptem.h>
#endif
+#if HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
/*
* SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS,
* Solaris, IRIX) define TIOCGWINSZ and struct winsize.
@@ -92,31 +101,113 @@ MODULE_ID("$From: lib_setup.c,v 1.64 2000/12/10 02:55:07 tom Exp $")
# endif
#endif
-static int _use_env = TRUE;
+/*
+ * Reduce explicit use of "cur_term" global variable.
+ */
+#undef CUR
+#define CUR termp->type.
+
+/*
+ * Wrap global variables in this module.
+ */
+#if USE_REENTRANT
+NCURSES_EXPORT(char *)
+NCURSES_PUBLIC_VAR(ttytype) (void)
+{
+ static char empty[] = "";
+ return cur_term ? cur_term->type.term_names : empty;
+}
+NCURSES_EXPORT(int *)
+_nc_ptr_Lines(void)
+{
+ return ptrLines();
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(LINES) (void)
+{
+ return *_nc_ptr_Lines();
+}
+NCURSES_EXPORT(int *)
+_nc_ptr_Cols(void)
+{
+ return ptrCols();
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(COLS) (void)
+{
+ return *_nc_ptr_Cols();
+}
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(TABSIZE) (void)
+{
+ return SP ? SP->_TABSIZE : 8;
+}
+#else
+NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = "";
+NCURSES_EXPORT_VAR(int) LINES = 0;
+NCURSES_EXPORT_VAR(int) COLS = 0;
+NCURSES_EXPORT_VAR(int) TABSIZE = 0;
+#endif
+
+#if NCURSES_EXT_FUNCS
+NCURSES_EXPORT(int)
+set_tabsize(int value)
+{
+ int code = OK;
+#if USE_REENTRANT
+ if (SP) {
+ SP->_TABSIZE = value;
+ } else {
+ code = ERR;
+ }
+#else
+ TABSIZE = value;
+#endif
+ return code;
+}
+#endif
+
+#if USE_SIGWINCH
+/*
+ * If we have a pending SIGWINCH, set the flag in each screen.
+ */
+NCURSES_EXPORT(int)
+_nc_handle_sigwinch(SCREEN *sp)
+{
+ SCREEN *scan;
-static void do_prototype(void);
+ if (_nc_globals.have_sigwinch) {
+ _nc_globals.have_sigwinch = 0;
+
+ for (each_screen(scan)) {
+ scan->_sig_winch = TRUE;
+ }
+ }
+
+ return (sp ? sp->_sig_winch : 0);
+}
+
+#endif
NCURSES_EXPORT(void)
use_env(bool f)
{
- _use_env = f;
+ T((T_CALLED("use_env()")));
+ _nc_prescreen.use_env = f;
+ returnVoid;
}
-NCURSES_EXPORT_VAR(int)
-LINES = 0;
-NCURSES_EXPORT_VAR(int)
-COLS = 0;
-NCURSES_EXPORT_VAR(int)
-TABSIZE = 0;
-
- static void
- _nc_get_screensize(int *linep, int *colp)
+NCURSES_EXPORT(void)
+_nc_get_screensize(SCREEN *sp, int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
+ TERMINAL *termp = cur_term;
+ int my_tabsize;
+
/* figure out the size of the screen */
T(("screen size: terminfo lines = %d columns = %d", lines, columns));
- if (!_use_env) {
+ if (!_nc_prescreen.use_env) {
*linep = (int) lines;
*colp = (int) columns;
} else { /* usually want to query LINES and COLUMNS from environment */
@@ -162,7 +253,7 @@ TABSIZE = 0;
* environment variable.
*/
if (*linep <= 0)
- *linep = WINSIZE_ROWS(size);
+ *linep = (sp != 0 && sp->_filtered) ? 1 : WINSIZE_ROWS(size);
if (*colp <= 0)
*colp = WINSIZE_COLS(size);
}
@@ -180,8 +271,10 @@ TABSIZE = 0;
}
/* the ultimate fallback, assume fixed 24x80 size */
- if (*linep <= 0 || *colp <= 0) {
+ if (*linep <= 0) {
*linep = 24;
+ }
+ if (*colp <= 0) {
*colp = 80;
}
@@ -196,22 +289,42 @@ TABSIZE = 0;
T(("screen size is %dx%d", *linep, *colp));
if (VALID_NUMERIC(init_tabs))
- TABSIZE = (int) init_tabs;
+ my_tabsize = (int) init_tabs;
else
- TABSIZE = 8;
- T(("TABSIZE = %d", TABSIZE));
+ my_tabsize = 8;
+#if USE_REENTRANT
+ if (sp != 0)
+ sp->_TABSIZE = my_tabsize;
+#else
+ TABSIZE = my_tabsize;
+#endif
+ T(("TABSIZE = %d", TABSIZE));
}
#if USE_SIZECHANGE
NCURSES_EXPORT(void)
-_nc_update_screensize(void)
+_nc_update_screensize(SCREEN *sp)
{
- int my_lines, my_cols;
+ TERMINAL *termp = cur_term;
+ int old_lines = lines;
+ int new_lines;
+ int old_cols = columns;
+ int new_cols;
- _nc_get_screensize(&my_lines, &my_cols);
- if (SP != 0 && SP->_resize != 0)
- SP->_resize(my_lines, my_cols);
+ _nc_get_screensize(sp, &new_lines, &new_cols);
+
+ /*
+ * See is_term_resized() and resizeterm().
+ * We're doing it this way because those functions belong to the upper
+ * ncurses library, while this resides in the lower terminfo library.
+ */
+ if (sp != 0
+ && sp->_resize != 0) {
+ if ((new_lines != old_lines) || (new_cols != old_cols))
+ sp->_resize(new_lines, new_cols);
+ sp->_sig_winch = FALSE;
+ }
}
#endif
@@ -237,33 +350,16 @@ _nc_update_screensize(void)
exit(EXIT_FAILURE);\
}
-#if USE_DATABASE
+#if USE_DATABASE || USE_TERMCAP
+/*
+ * Return 1 if entry found, 0 if not found, -1 if database not accessible,
+ * just like tgetent().
+ */
static int
-grab_entry(const char *const tn, TERMTYPE * const tp)
-/* return 1 if entry found, 0 if not found, -1 if database not accessible */
+grab_entry(const char *const tn, TERMTYPE *const tp)
{
char filename[PATH_MAX];
- int status;
-
- /*
- * $TERM shouldn't contain pathname delimiters.
- */
- if (strchr(tn, '/'))
- return 0;
-
- if ((status = _nc_read_entry(tn, filename, tp)) != 1) {
-
-#if !PURE_TERMINFO
- /*
- * Try falling back on the termcap file.
- * Note: allowing this call links the entire terminfo/termcap
- * compiler into the startup code. It's preferable to build a
- * real terminfo database and use that.
- */
- status = _nc_read_termcap_entry(tn, tp);
-#endif /* PURE_TERMINFO */
-
- }
+ int status = _nc_read_entry(tn, filename, tp);
/*
* If we have an entry, force all of the cancelled strings to null
@@ -271,8 +367,8 @@ grab_entry(const char *const tn, TERMTYPE * const tp)
* (The terminfo compiler bypasses this logic, since it must know if
* a string is cancelled, for merging entries).
*/
- if (status == 1) {
- int n;
+ if (status == TGETENT_YES) {
+ unsigned n;
for_each_boolean(n, tp) {
if (!VALID_BOOLEAN(tp->Booleans[n]))
tp->Booleans[n] = FALSE;
@@ -286,139 +382,252 @@ grab_entry(const char *const tn, TERMTYPE * const tp)
}
#endif
-NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = "";
+/*
+** do_prototype()
+**
+** Take the real command character out of the CC environment variable
+** and substitute it in for the prototype given in 'command_character'.
+*/
+static void
+do_prototype(TERMINAL * termp)
+{
+ unsigned i;
+ char CC;
+ char proto;
+ char *tmp;
+
+ if ((tmp = getenv("CC")) != 0) {
+ if ((CC = *tmp) != 0) {
+ proto = *command_character;
+
+ for_each_string(i, &(termp->type)) {
+ for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
+ if (*tmp == proto)
+ *tmp = CC;
+ }
+ }
+ }
+ }
+}
/*
- * setupterm(termname, Filedes, errret)
- *
- * Find and read the appropriate object file for the terminal
- * Make cur_term point to the structure.
- *
+ * Find the locale which is in effect.
+ */
+NCURSES_EXPORT(char *)
+_nc_get_locale(void)
+{
+ char *env;
+#if HAVE_LOCALE_H
+ /*
+ * This is preferable to using getenv() since it ensures that we are using
+ * the locale which was actually initialized by the application.
+ */
+ env = setlocale(LC_CTYPE, 0);
+#else
+ if (((env = getenv("LC_ALL")) != 0 && *env != '\0')
+ || ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
+ || ((env = getenv("LANG")) != 0 && *env != '\0')) {
+ ;
+ }
+#endif
+ T(("_nc_get_locale %s", _nc_visbuf(env)));
+ return env;
+}
+
+/*
+ * Check if we are running in a UTF-8 locale.
+ */
+NCURSES_EXPORT(int)
+_nc_unicode_locale(void)
+{
+ int result = 0;
+#if HAVE_LANGINFO_CODESET
+ char *env = nl_langinfo(CODESET);
+ result = !strcmp(env, "UTF-8");
+ T(("_nc_unicode_locale(%s) ->%d", env, result));
+#else
+ char *env = _nc_get_locale();
+ if (env != 0) {
+ if (strstr(env, ".UTF-8") != 0) {
+ result = 1;
+ T(("_nc_unicode_locale(%s) ->%d", env, result));
+ }
+ }
+#endif
+ return result;
+}
+
+#define CONTROL_N(s) ((s) != 0 && strstr(s, "\016") != 0)
+#define CONTROL_O(s) ((s) != 0 && strstr(s, "\017") != 0)
+
+/*
+ * Check for known broken cases where a UTF-8 locale breaks the alternate
+ * character set.
*/
+NCURSES_EXPORT(int)
+_nc_locale_breaks_acs(TERMINAL * termp)
+{
+ char *env;
+
+ if ((env = getenv("NCURSES_NO_UTF8_ACS")) != 0) {
+ return atoi(env);
+ } else if ((env = getenv("TERM")) != 0) {
+ if (strstr(env, "linux"))
+ return 1; /* always broken */
+ if (strstr(env, "screen") != 0
+ && ((env = getenv("TERMCAP")) != 0
+ && strstr(env, "screen") != 0)
+ && strstr(env, "hhII00") != 0) {
+ if (CONTROL_N(enter_alt_charset_mode) ||
+ CONTROL_O(enter_alt_charset_mode) ||
+ CONTROL_N(set_attributes) ||
+ CONTROL_O(set_attributes))
+ return 1;
+ }
+ }
+ return 0;
+}
+/*
+ * This entrypoint is called from tgetent() to allow a special case of reusing
+ * the same TERMINAL data (see comment).
+ */
NCURSES_EXPORT(int)
-setupterm
-(NCURSES_CONST char *tname, int Filedes, int *errret)
+_nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
{
- struct term *term_ptr;
+ TERMINAL *termp;
int status;
+ START_TRACE();
T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, errret));
if (tname == 0) {
tname = getenv("TERM");
if (tname == 0 || *tname == '\0') {
- ret_error0(-1, "TERM environment variable not set.\n");
+ ret_error0(TGETENT_ERR, "TERM environment variable not set.\n");
}
}
+
if (strlen(tname) > MAX_NAME_SIZE) {
- ret_error(-1, "TERM environment must be <= %d characters.\n",
+ ret_error(TGETENT_ERR,
+ "TERM environment must be <= %d characters.\n",
MAX_NAME_SIZE);
}
T(("your terminal name is %s", tname));
- term_ptr = typeCalloc(TERMINAL, 1);
+ /*
+ * Allow output redirection. This is what SVr3 does. If stdout is
+ * directed to a file, screen updates go to standard error.
+ */
+ if (Filedes == STDOUT_FILENO && !isatty(Filedes))
+ Filedes = STDERR_FILENO;
- if (term_ptr == 0) {
- ret_error0(-1, "Not enough memory to create terminal structure.\n");
- }
-#if USE_DATABASE
- status = grab_entry(tname, &term_ptr->type);
+ /*
+ * Check if we have already initialized to use this terminal. If so, we
+ * do not need to re-read the terminfo entry, or obtain TTY settings.
+ *
+ * This is an improvement on SVr4 curses. If an application mixes curses
+ * and termcap calls, it may call both initscr and tgetent. This is not
+ * really a good thing to do, but can happen if someone tries using ncurses
+ * with the readline library. The problem we are fixing is that when
+ * tgetent calls setupterm, the resulting Ottyb struct in cur_term is
+ * zeroed. A subsequent call to endwin uses the zeroed terminal settings
+ * rather than the ones saved in initscr. So we check if cur_term appears
+ * to contain terminal settings for the same output file as our current
+ * call - and copy those terminal settings. (SVr4 curses does not do this,
+ * however applications that are working around the problem will still work
+ * properly with this feature).
+ */
+ if (reuse
+ && (termp = cur_term) != 0
+ && termp->Filedes == Filedes
+ && termp->_termname != 0
+ && !strcmp(termp->_termname, tname)
+ && _nc_name_match(termp->type.term_names, tname, "|")) {
+ T(("reusing existing terminal information and mode-settings"));
+ } else {
+
+ termp = typeCalloc(TERMINAL, 1);
+
+ if (termp == 0) {
+ ret_error0(TGETENT_ERR,
+ "Not enough memory to create terminal structure.\n");
+ }
+#if USE_DATABASE || USE_TERMCAP
+ status = grab_entry(tname, &termp->type);
#else
- status = 0;
+ status = TGETENT_NO;
#endif
- /* try fallback list if entry on disk */
- if (status != 1) {
- const TERMTYPE *fallback = _nc_fallback(tname);
+ /* try fallback list if entry on disk */
+ if (status != TGETENT_YES) {
+ const TERMTYPE *fallback = _nc_fallback(tname);
- if (fallback) {
- term_ptr->type = *fallback;
- status = 1;
+ if (fallback) {
+ termp->type = *fallback;
+ status = TGETENT_YES;
+ }
}
- }
- if (status == -1) {
- ret_error0(-1, "terminals database is inaccessible\n");
- } else if (status == 0) {
- ret_error(0, "'%s': unknown terminal type.\n", tname);
- }
+ if (status != TGETENT_YES) {
+ del_curterm(termp);
+ if (status == TGETENT_ERR) {
+ ret_error0(status, "terminals database is inaccessible\n");
+ } else if (status == TGETENT_NO) {
+ ret_error(status, "'%s': unknown terminal type.\n", tname);
+ }
+ }
+#if !USE_REENTRANT
+ strncpy(ttytype, termp->type.term_names, NAMESIZE - 1);
+ ttytype[NAMESIZE - 1] = '\0';
+#endif
- /*
- * Improve on SVr4 curses. If an application mixes curses and termcap
- * calls, it may call both initscr and tgetent. This is not really a
- * good thing to do, but can happen if someone tries using ncurses with
- * the readline library. The problem we are fixing is that when
- * tgetent calls setupterm, the resulting Ottyb struct in cur_term is
- * zeroed. A subsequent call to endwin uses the zeroed terminal
- * settings rather than the ones saved in initscr. So we check if
- * cur_term appears to contain terminal settings for the same output
- * file as our current call - and copy those terminal settings. (SVr4
- * curses does not do this, however applications that are working
- * around the problem will still work properly with this feature).
- */
- if (cur_term != 0) {
- if (cur_term->Filedes == Filedes)
- term_ptr->Ottyb = cur_term->Ottyb;
- }
+ termp->Filedes = Filedes;
+ termp->_termname = strdup(tname);
- set_curterm(term_ptr);
+ set_curterm(termp);
- if (command_character && getenv("CC"))
- do_prototype();
+ if (command_character && getenv("CC"))
+ do_prototype(termp);
- strlcpy(ttytype, cur_term->type.term_names, NAMESIZE);
+ /*
+ * If an application calls setupterm() rather than initscr() or
+ * newterm(), we will not have the def_prog_mode() call in
+ * _nc_setupscreen(). Do it now anyway, so we can initialize the
+ * baudrate.
+ */
+ if (isatty(Filedes)) {
+ def_prog_mode();
+ baudrate();
+ }
+ }
/*
- * Allow output redirection. This is what SVr3 does.
- * If stdout is directed to a file, screen updates go
- * to standard error.
+ * We should always check the screensize, just in case.
*/
- if (Filedes == STDOUT_FILENO && !isatty(Filedes))
- Filedes = STDERR_FILENO;
- cur_term->Filedes = Filedes;
-
- _nc_get_screensize(&LINES, &COLS);
+ _nc_get_screensize(SP, ptrLines(), ptrCols());
if (errret)
- *errret = 1;
-
- T((T_CREATE("screen %s %dx%d"), tname, LINES, COLS));
+ *errret = TGETENT_YES;
if (generic_type) {
- ret_error(0, "'%s': I need something more specific.\n", tname);
+ ret_error(TGETENT_NO, "'%s': I need something more specific.\n", tname);
}
if (hard_copy) {
- ret_error(1, "'%s': I can't handle hardcopy terminals.\n", tname);
+ ret_error(TGETENT_YES, "'%s': I can't handle hardcopy terminals.\n", tname);
}
returnCode(OK);
}
/*
-** do_prototype()
-**
-** Take the real command character out of the CC environment variable
-** and substitute it in for the prototype given in 'command_character'.
-**
-*/
-
-static void
-do_prototype(void)
+ * setupterm(termname, Filedes, errret)
+ *
+ * Find and read the appropriate object file for the terminal
+ * Make cur_term point to the structure.
+ */
+NCURSES_EXPORT(int)
+setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
{
- int i;
- char CC;
- char proto;
- char *tmp;
-
- tmp = getenv("CC");
- CC = *tmp;
- proto = *command_character;
-
- for_each_string(i, &(cur_term->type)) {
- for (tmp = cur_term->type.Strings[i]; *tmp; tmp++) {
- if (*tmp == proto)
- *tmp = CC;
- }
- }
+ return _nc_setupterm(tname, Filedes, errret, FALSE);
}
diff --git a/lib/libcurses/tinfo/lib_termcap.c b/lib/libcurses/tinfo/lib_termcap.c
index b307aac5754..66ccb8cf63d 100644
--- a/lib/libcurses/tinfo/lib_termcap.c
+++ b/lib/libcurses/tinfo/lib_termcap.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_termcap.c,v 1.9 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_termcap.c,v 1.10 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,27 +31,36 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
+ * *
+ * some of the code in here was contributed by: *
+ * Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93) *
+ * (but it has changed a lot) *
****************************************************************************/
+#define __INTERNAL_CAPS_VISIBLE
#include <curses.priv.h>
#include <termcap.h>
#include <tic.h>
+#include <ctype.h>
-#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$From: lib_termcap.c,v 1.39 2000/12/10 02:56:30 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.10 2010/01/12 23:22:06 nicm Exp $")
-/*
- some of the code in here was contributed by:
- Magnus Bengtsson, d6mbeng@dtek.chalmers.se
-*/
+NCURSES_EXPORT_VAR(char *) UP = 0;
+NCURSES_EXPORT_VAR(char *) BC = 0;
-NCURSES_EXPORT_VAR(char *)
-UP = 0;
-NCURSES_EXPORT_VAR(char *)
-BC = 0;
+#define MyCache _nc_globals.tgetent_cache
+#define CacheInx _nc_globals.tgetent_index
+#define CacheSeq _nc_globals.tgetent_sequence
+
+#define FIX_SGR0 MyCache[CacheInx].fix_sgr0
+#define LAST_TRM MyCache[CacheInx].last_term
+#define LAST_BUF MyCache[CacheInx].last_bufp
+#define LAST_USE MyCache[CacheInx].last_used
+#define LAST_SEQ MyCache[CacheInx].sequence
/***************************************************************************
*
@@ -69,19 +78,73 @@ BC = 0;
***************************************************************************/
NCURSES_EXPORT(int)
-tgetent
-(char *bufp GCC_UNUSED, const char *name)
+tgetent(char *bufp, const char *name)
{
int errcode;
+ int n;
+ bool found_cache = FALSE;
+ START_TRACE();
T((T_CALLED("tgetent()")));
- setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode);
+ _nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE);
+
+ /*
+ * In general we cannot tell if the fixed sgr0 is still used by the
+ * caller, but if tgetent() is called with the same buffer, that is
+ * good enough, since the previous data would be invalidated by the
+ * current call.
+ *
+ * bufp may be a null pointer, e.g., GNU termcap. That allocates data,
+ * which is good until the next tgetent() call. The conventional termcap
+ * is inconvenient because of the fixed buffer size, but because it uses
+ * caller-supplied buffers, can have multiple terminal descriptions in
+ * use at a given time.
+ */
+ for (n = 0; n < TGETENT_MAX; ++n) {
+ bool same_result = (MyCache[n].last_used && MyCache[n].last_bufp == bufp);
+ if (same_result) {
+ CacheInx = n;
+ if (FIX_SGR0 != 0) {
+ FreeAndNull(FIX_SGR0);
+ }
+ /*
+ * Also free the terminfo data that we loaded (much bigger leak).
+ */
+ if (LAST_TRM != 0 && LAST_TRM != cur_term) {
+ TERMINAL *trm = LAST_TRM;
+ del_curterm(LAST_TRM);
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx)
+ if (LAST_TRM == trm)
+ LAST_TRM = 0;
+ CacheInx = n;
+ }
+ found_cache = TRUE;
+ break;
+ }
+ }
+ if (!found_cache) {
+ int best = 0;
+
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
+ if (LAST_SEQ < MyCache[best].sequence) {
+ best = CacheInx;
+ }
+ }
+ CacheInx = best;
+ }
+ LAST_TRM = cur_term;
+ LAST_SEQ = ++CacheSeq;
+
+ PC = 0;
+ UP = 0;
+ BC = 0;
+ FIX_SGR0 = 0; /* don't free it - application may still use */
if (errcode == 1) {
if (cursor_left)
- if ((backspaces_with_bs = !strcmp(cursor_left, "\b")) == 0)
+ if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0)
backspace_if_not_bs = cursor_left;
/* we're required to export these */
@@ -92,6 +155,18 @@ tgetent
if (backspace_if_not_bs != NULL)
BC = backspace_if_not_bs;
+ if ((FIX_SGR0 = _nc_trim_sgr0(&(cur_term->type))) != 0) {
+ if (!strcmp(FIX_SGR0, exit_attribute_mode)) {
+ if (FIX_SGR0 != exit_attribute_mode) {
+ free(FIX_SGR0);
+ }
+ FIX_SGR0 = 0;
+ }
+ }
+ LAST_BUF = bufp;
+ LAST_USE = TRUE;
+
+ SetNoPadding(SP);
(void) baudrate(); /* sets ospeed as a side-effect */
/* LINT_PREPRO
@@ -116,7 +191,7 @@ tgetent
NCURSES_EXPORT(int)
tgetflag(NCURSES_CONST char *id)
{
- int i;
+ unsigned i;
T((T_CALLED("tgetflag(%s)"), id));
if (cur_term != 0) {
@@ -144,7 +219,7 @@ tgetflag(NCURSES_CONST char *id)
NCURSES_EXPORT(int)
tgetnum(NCURSES_CONST char *id)
{
- int i;
+ unsigned i;
T((T_CALLED("tgetnum(%s)"), id));
if (cur_term != 0) {
@@ -171,28 +246,49 @@ tgetnum(NCURSES_CONST char *id)
***************************************************************************/
NCURSES_EXPORT(char *)
-tgetstr
-(NCURSES_CONST char *id, char **area)
+tgetstr(NCURSES_CONST char *id, char **area)
{
- int i;
+ unsigned i;
+ char *result = NULL, *base;
+ if (area != 0 && *area != 0)
+ base = *area;
T((T_CALLED("tgetstr(%s,%p)"), id, area));
if (cur_term != 0) {
TERMTYPE *tp = &(cur_term->type);
for_each_string(i, tp) {
const char *capname = ExtStrname(tp, i, strcodes);
if (!strncmp(id, capname, 2)) {
- TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(tp->Strings[i])));
+ result = tp->Strings[i];
+ TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(result)));
/* setupterm forces canceled strings to null */
- if (area != 0
- && *area != 0
- && VALID_STRING(tp->Strings[i])) {
- (void) strlcpy(*area, tp->Strings[i], 1024);
- *area += strlen(*area) + 1;
+ if (VALID_STRING(result)) {
+ if (result == exit_attribute_mode
+ && FIX_SGR0 != 0) {
+ result = FIX_SGR0;
+ TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
+ }
+ if (area != 0 && *area != 0) {
+ (void) strlcpy(*area, result, 1024 - (*area - base));
+ result = *area;
+ *area += strlen(*area) + 1;
+ }
}
- returnPtr(tp->Strings[i]);
+ break;
}
}
}
- returnPtr(NULL);
+ returnPtr(result);
+}
+
+#if NO_LEAKS
+NCURSES_EXPORT(void)
+_nc_tgetent_leaks(void)
+{
+ for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
+ FreeIfNeeded(FIX_SGR0);
+ if (LAST_TRM != 0)
+ del_curterm(LAST_TRM);
+ }
}
+#endif
diff --git a/lib/libcurses/tinfo/lib_termname.c b/lib/libcurses/tinfo/lib_termname.c
index 8e744f1ed31..f4ddf8b334b 100644
--- a/lib/libcurses/tinfo/lib_termname.c
+++ b/lib/libcurses/tinfo/lib_termname.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_termname.c,v 1.4 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_termname.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,21 +29,18 @@
****************************************************************************/
#include <curses.priv.h>
-#include <tic.h> /* for MAX_ALIAS */
-MODULE_ID("$From: lib_termname.c,v 1.6 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: lib_termname.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(char *)
termname(void)
{
- char *name = getenv("TERM");
- static char ret[MAX_ALIAS + 1];
+ char *name = 0;
- T(("termname() called"));
+ T((T_CALLED("termname()")));
- if (name != 0) {
- (void) strlcpy(ret, name, sizeof(ret));
- name = ret;
- }
- return name;
+ if (cur_term != 0)
+ name = cur_term->_termname;
+
+ returnPtr(name);
}
diff --git a/lib/libcurses/tinfo/lib_tgoto.c b/lib/libcurses/tinfo/lib_tgoto.c
index bb7fb9c2670..536771fd17e 100644
--- a/lib/libcurses/tinfo/lib_tgoto.c
+++ b/lib/libcurses/tinfo/lib_tgoto.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tgoto.c,v 1.4 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_tgoto.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2000-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,7 +37,7 @@
#include <ctype.h>
#include <termcap.h>
-MODULE_ID("$From: lib_tgoto.c,v 1.5 2000/12/10 01:33:16 tom Exp $")
+MODULE_ID("$Id: lib_tgoto.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
#if !PURE_TERMINFO
static bool
@@ -91,13 +91,13 @@ tgoto_internal(const char *string, int x, int y)
while (*string != 0) {
if ((used + need) > length) {
length += (used + need);
- if ((result = _nc_doalloc(result, length)) == 0) {
+ if ((result = typeRealloc(char, length, result)) == 0) {
length = 0;
break;
}
}
if (*string == '%') {
- char *fmt = 0;
+ const char *fmt = 0;
switch (*++string) {
case '\0':
@@ -115,7 +115,7 @@ tgoto_internal(const char *string, int x, int y)
*value %= 1000;
break;
case '+':
- *value += CharOf(*++string);
+ *value += UChar(*++string);
/* FALLTHRU */
case '.':
/*
@@ -131,7 +131,7 @@ tgoto_internal(const char *string, int x, int y)
*value = 0200; /* tputs will treat this as \0 */
}
}
- result[used++] = *value++;
+ result[used++] = (char) *value++;
break;
case '%':
result[used++] = *string;
@@ -158,7 +158,7 @@ tgoto_internal(const char *string, int x, int y)
*value = 16 * (*value / 10) + (*value % 10);
break;
case 'D': /* Reverse coding (Delta Data) */
- *value -= 2 * (*value / 16);
+ *value -= 2 * (*value % 16);
break;
}
if (fmt != 0) {
@@ -175,14 +175,14 @@ tgoto_internal(const char *string, int x, int y)
}
string++;
}
- if (need_BC) {
+ if (result != 0) {
copied = strlcpy(result + used, BC, length - used);
if (copied < length - used)
used += copied;
else
used += length - used - 1;
+ result[used] = '\0';
}
- result[used] = '\0';
return result;
}
#endif
@@ -192,8 +192,7 @@ tgoto_internal(const char *string, int x, int y)
* the last two arguments when invoking tparm().
*/
NCURSES_EXPORT(char *)
-tgoto
-(const char *string, int x, int y)
+tgoto(const char *string, int x, int y)
{
char *result;
@@ -203,6 +202,6 @@ tgoto
result = tgoto_internal(string, x, y);
else
#endif
- result = tparm((NCURSES_CONST char *) string, y, x);
+ result = TPARM_2((NCURSES_CONST char *) string, y, x);
returnPtr(result);
}
diff --git a/lib/libcurses/tinfo/lib_ti.c b/lib/libcurses/tinfo/lib_ti.c
index 3c1595aef0c..9416c56cca9 100644
--- a/lib/libcurses/tinfo/lib_ti.c
+++ b/lib/libcurses/tinfo/lib_ti.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_ti.c,v 1.6 2001/01/22 18:01:54 millert Exp $ */
+/* $OpenBSD: lib_ti.c,v 1.7 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,12 +38,12 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$From: lib_ti.c,v 1.22 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: lib_ti.c,v 1.7 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
tigetflag(NCURSES_CONST char *str)
{
- int i;
+ unsigned i;
T((T_CALLED("tigetflag(%s)"), str));
@@ -64,7 +64,7 @@ tigetflag(NCURSES_CONST char *str)
NCURSES_EXPORT(int)
tigetnum(NCURSES_CONST char *str)
{
- int i;
+ unsigned i;
T((T_CALLED("tigetnum(%s)"), str));
@@ -86,7 +86,7 @@ tigetnum(NCURSES_CONST char *str)
NCURSES_EXPORT(char *)
tigetstr(NCURSES_CONST char *str)
{
- int i;
+ unsigned i;
T((T_CALLED("tigetstr(%s)"), str));
diff --git a/lib/libcurses/tinfo/lib_tparm.c b/lib/libcurses/tinfo/lib_tparm.c
index 3cdd7b915fc..45c07f01e06 100644
--- a/lib/libcurses/tinfo/lib_tparm.c
+++ b/lib/libcurses/tinfo/lib_tparm.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tparm.c,v 1.8 2003/03/17 19:16:59 millert Exp $ */
+/* $OpenBSD: lib_tparm.c,v 1.9 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey, 1996 on *
****************************************************************************/
/*
@@ -44,7 +45,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: lib_tparm.c,v 1.51 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.9 2010/01/12 23:22:06 nicm Exp $")
/*
* char *
@@ -106,57 +107,37 @@ MODULE_ID("$From: lib_tparm.c,v 1.51 2000/12/10 02:55:08 tom Exp $")
* resulting in x mod y, not the reverse.
*/
-#define STACKSIZE 20
+NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0;
-typedef struct {
- union {
- unsigned int num;
- char *str;
- } data;
- bool num_type;
-} stack_frame;
-
-static stack_frame stack[STACKSIZE];
-static int stack_ptr;
-
-#ifdef TRACE
-static const char *tname;
-#endif /* TRACE */
-
-static char *out_buff;
-static size_t out_size;
-static size_t out_used;
+#define TPS(var) _nc_prescreen.tparm_state.var
#if NO_LEAKS
NCURSES_EXPORT(void)
_nc_free_tparm(void)
{
- if (out_buff != 0) {
- FreeAndNull(out_buff);
- out_size = 0;
- out_used = 0;
+ if (TPS(out_buff) != 0) {
+ FreeAndNull(TPS(out_buff));
+ TPS(out_size) = 0;
+ TPS(out_used) = 0;
+ FreeAndNull(TPS(fmt_buff));
+ TPS(fmt_size) = 0;
}
}
#endif
-static void
-really_get_space(size_t need)
-{
- out_size = need * 2;
- out_buff = typeRealloc(char, out_size, out_buff);
- if (out_buff == 0)
- _nc_err_abort("Out of memory");
-}
-
-static inline void
+static NCURSES_INLINE void
get_space(size_t need)
{
- need += out_used;
- if (need > out_size)
- really_get_space(need);
+ need += TPS(out_used);
+ if (need > TPS(out_size)) {
+ TPS(out_size) = need * 2;
+ TPS(out_buff) = typeRealloc(char, TPS(out_size), TPS(out_buff));
+ if (TPS(out_buff) == 0)
+ _nc_err_abort(MSG_NO_MEMORY);
+ }
}
-static inline void
+static NCURSES_INLINE void
save_text(const char *fmt, const char *s, int len)
{
size_t s_len = strlen(s);
@@ -165,222 +146,223 @@ save_text(const char *fmt, const char *s, int len)
get_space(s_len + 1);
- (void) snprintf(out_buff + out_used, out_size - out_used, fmt, s);
- out_used += strlen(out_buff + out_used);
+ (void) snprintf(TPS(out_buff) + TPS(out_used), TPS(out_size) - TPS(out_used), fmt, s);
+ TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
}
-static inline void
+static NCURSES_INLINE void
save_number(const char *fmt, int number, int len)
{
if (len < 30)
len = 30; /* actually log10(MAX_INT)+1 */
- get_space(len + 1);
+ get_space((unsigned) len + 1);
- (void) snprintf(out_buff + out_used, out_size - out_used, fmt, number);
- out_used += strlen(out_buff + out_used);
+ (void) snprintf(TPS(out_buff) + TPS(out_used), TPS(out_size) - TPS(out_used), fmt, number);
+ TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
}
-static inline void
+static NCURSES_INLINE void
save_char(int c)
{
if (c == 0)
c = 0200;
get_space(1);
- out_buff[out_used++] = c;
+ TPS(out_buff)[TPS(out_used)++] = (char) c;
}
-static inline void
+static NCURSES_INLINE void
npush(int x)
{
- if (stack_ptr < STACKSIZE) {
- stack[stack_ptr].num_type = TRUE;
- stack[stack_ptr].data.num = x;
- stack_ptr++;
+ if (TPS(stack_ptr) < STACKSIZE) {
+ TPS(stack)[TPS(stack_ptr)].num_type = TRUE;
+ TPS(stack)[TPS(stack_ptr)].data.num = x;
+ TPS(stack_ptr)++;
+ } else {
+ DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
+ _nc_tparm_err++;
}
}
-static inline int
+static NCURSES_INLINE int
npop(void)
{
int result = 0;
- if (stack_ptr > 0) {
- stack_ptr--;
- if (stack[stack_ptr].num_type)
- result = stack[stack_ptr].data.num;
+ if (TPS(stack_ptr) > 0) {
+ TPS(stack_ptr)--;
+ if (TPS(stack)[TPS(stack_ptr)].num_type)
+ result = TPS(stack)[TPS(stack_ptr)].data.num;
+ } else {
+ DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
+ _nc_tparm_err++;
}
return result;
}
-static inline void
+static NCURSES_INLINE void
spush(char *x)
{
- if (stack_ptr < STACKSIZE) {
- stack[stack_ptr].num_type = FALSE;
- stack[stack_ptr].data.str = x;
- stack_ptr++;
+ if (TPS(stack_ptr) < STACKSIZE) {
+ TPS(stack)[TPS(stack_ptr)].num_type = FALSE;
+ TPS(stack)[TPS(stack_ptr)].data.str = x;
+ TPS(stack_ptr)++;
+ } else {
+ DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
+ _nc_tparm_err++;
}
}
-static inline char *
+static NCURSES_INLINE char *
spop(void)
{
static char dummy[] = ""; /* avoid const-cast */
char *result = dummy;
- if (stack_ptr > 0) {
- stack_ptr--;
- if (!stack[stack_ptr].num_type && stack[stack_ptr].data.str != 0)
- result = stack[stack_ptr].data.str;
+ if (TPS(stack_ptr) > 0) {
+ TPS(stack_ptr)--;
+ if (!TPS(stack)[TPS(stack_ptr)].num_type
+ && TPS(stack)[TPS(stack_ptr)].data.str != 0)
+ result = TPS(stack)[TPS(stack_ptr)].data.str;
+ } else {
+ DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
+ _nc_tparm_err++;
}
return result;
}
-static inline const char *
+static NCURSES_INLINE const char *
parse_format(const char *s, char *format, int *len)
{
- bool done = FALSE;
- bool allowminus = FALSE;
- bool dot = FALSE;
- bool err = FALSE;
- char *fmt = format;
- int prec = 0;
- int width = 0;
- int value = 0;
-
*len = 0;
- *format++ = '%';
- while (*s != '\0' && !done) {
- switch (*s) {
- case 'c': /* FALLTHRU */
- case 'd': /* FALLTHRU */
- case 'o': /* FALLTHRU */
- case 'x': /* FALLTHRU */
- case 'X': /* FALLTHRU */
- case 's':
- *format++ = *s;
- done = TRUE;
- break;
- case '.':
- *format++ = *s++;
- if (dot) {
- err = TRUE;
- } else {
- dot = TRUE;
- prec = value;
- }
- value = 0;
- break;
- case '#':
- *format++ = *s++;
- break;
- case ' ':
- *format++ = *s++;
- break;
- case ':':
- s++;
- allowminus = TRUE;
- break;
- case '-':
- if (allowminus) {
- *format++ = *s++;
- } else {
+ if (format != 0) {
+ bool done = FALSE;
+ bool allowminus = FALSE;
+ bool dot = FALSE;
+ bool err = FALSE;
+ char *fmt = format;
+ int my_width = 0;
+ int my_prec = 0;
+ int value = 0;
+
+ *len = 0;
+ *format++ = '%';
+ while (*s != '\0' && !done) {
+ switch (*s) {
+ case 'c': /* FALLTHRU */
+ case 'd': /* FALLTHRU */
+ case 'o': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ case 's':
+ *format++ = *s;
done = TRUE;
- }
- break;
- default:
- if (isdigit(CharOf(*s))) {
- value = (value * 10) + (*s - '0');
- if (value > 10000)
+ break;
+ case '.':
+ *format++ = *s++;
+ if (dot) {
err = TRUE;
+ } else { /* value before '.' is the width */
+ dot = TRUE;
+ my_width = value;
+ }
+ value = 0;
+ break;
+ case '#':
*format++ = *s++;
- } else {
- done = TRUE;
+ break;
+ case ' ':
+ *format++ = *s++;
+ break;
+ case ':':
+ s++;
+ allowminus = TRUE;
+ break;
+ case '-':
+ if (allowminus) {
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
+ break;
+ default:
+ if (isdigit(UChar(*s))) {
+ value = (value * 10) + (*s - '0');
+ if (value > 10000)
+ err = TRUE;
+ *format++ = *s++;
+ } else {
+ done = TRUE;
+ }
}
}
- }
-
- /*
- * If we found an error, ignore (and remove) the flags.
- */
- if (err) {
- prec = width = value = 0;
- format = fmt;
- *format++ = '%';
- *format++ = *s;
- }
- if (dot)
- width = value;
- else
- prec = value;
+ /*
+ * If we found an error, ignore (and remove) the flags.
+ */
+ if (err) {
+ my_width = my_prec = value = 0;
+ format = fmt;
+ *format++ = '%';
+ *format++ = *s;
+ }
- *format = '\0';
- /* return maximum string length in print */
- *len = (prec > width) ? prec : width;
+ /*
+ * Any value after '.' is the precision. If we did not see '.', then
+ * the value is the width.
+ */
+ if (dot)
+ my_prec = value;
+ else
+ my_width = value;
+
+ *format = '\0';
+ /* return maximum string length in print */
+ *len = (my_width > my_prec) ? my_width : my_prec;
+ }
return s;
}
#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
-static inline char *
-tparam_internal(const char *string, va_list ap)
+/*
+ * Analyze the string to see how many parameters we need from the varargs list,
+ * and what their types are. We will only accept string parameters if they
+ * appear as a %l or %s format following an explicit parameter reference (e.g.,
+ * %p2%s). All other parameters are numbers.
+ *
+ * 'number' counts coarsely the number of pop's we see in the string, and
+ * 'popcount' shows the highest parameter number in the string. We would like
+ * to simply use the latter count, but if we are reading termcap strings, there
+ * may be cases that we cannot see the explicit parameter numbers.
+ */
+NCURSES_EXPORT(int)
+_nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
{
-#define NUM_VARS 26
- char *p_is_s[9];
- int param[9];
- int lastpop;
- int popcount;
- int number;
- int len;
- int level;
- int x, y;
- int i;
size_t len2;
- register const char *cp;
- static size_t len_fmt;
+ int i;
+ int lastpop = -1;
+ int len;
+ int number = 0;
+ const char *cp = string;
static char dummy[] = "";
- static char *format;
- static int dynamic_var[NUM_VARS];
- static int static_vars[NUM_VARS];
- out_used = 0;
- if (string == NULL)
- return NULL;
+ if (cp == 0)
+ return 0;
- if ((len2 = strlen(string)) > len_fmt) {
- len_fmt = len2 + len_fmt + 2;
- if ((format = typeRealloc(char, len_fmt, format)) == 0)
- return 0;
+ if ((len2 = strlen(cp)) > TPS(fmt_size)) {
+ TPS(fmt_size) = len2 + TPS(fmt_size) + 2;
+ TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
+ if (TPS(fmt_buff) == 0)
+ return 0;
}
- /*
- * Find the highest parameter-number referred to in the format string.
- * Use this value to limit the number of arguments copied from the
- * variable-length argument list.
- */
-
- number = 0;
- lastpop = -1;
- popcount = 0;
- memset(p_is_s, 0, sizeof(p_is_s));
+ memset(p_is_s, 0, sizeof(p_is_s[0]) * NUM_PARM);
+ *popcount = 0;
- /*
- * Analyze the string to see how many parameters we need from the varargs
- * list, and what their types are. We will only accept string parameters
- * if they appear as a %l or %s format following an explicit parameter
- * reference (e.g., %p2%s). All other parameters are numbers.
- *
- * 'number' counts coarsely the number of pop's we see in the string, and
- * 'popcount' shows the highest parameter number in the string. We would
- * like to simply use the latter count, but if we are reading termcap
- * strings, there may be cases that we cannot see the explicit parameter
- * numbers.
- */
- for (cp = string; (cp - string) < (int) len2;) {
+ while ((cp - string) < (int) len2) {
if (*cp == '%') {
cp++;
- cp = parse_format(cp, format, &len);
+ cp = parse_format(cp, TPS(fmt_buff), &len);
switch (*cp) {
default:
break;
@@ -390,7 +372,8 @@ tparam_internal(const char *string, va_list ap)
case 'x': /* FALLTHRU */
case 'X': /* FALLTHRU */
case 'c': /* FALLTHRU */
- number++;
+ if (lastpop <= 0)
+ number++;
lastpop = -1;
break;
@@ -403,15 +386,19 @@ tparam_internal(const char *string, va_list ap)
case 'p':
cp++;
- i = (*cp - '0');
- if (i >= 0 && i <= 9) {
+ i = (UChar(*cp) - '0');
+ if (i >= 0 && i <= NUM_PARM) {
lastpop = i;
- if (lastpop > popcount)
- popcount = lastpop;
+ if (lastpop > *popcount)
+ *popcount = lastpop;
}
break;
case 'P':
+ ++number;
+ ++cp;
+ break;
+
case 'g':
cp++;
break;
@@ -423,7 +410,7 @@ tparam_internal(const char *string, va_list ap)
case L_BRACE:
cp++;
- while (*cp >= '0' && *cp <= '9') {
+ while (isdigit(UChar(*cp))) {
cp++;
}
break;
@@ -441,16 +428,18 @@ tparam_internal(const char *string, va_list ap)
case '=':
case '<':
case '>':
+ lastpop = -1;
+ number += 2;
+ break;
+
case '!':
case '~':
lastpop = -1;
- number += 2;
+ ++number;
break;
case 'i':
- lastpop = -1;
- if (popcount < 2)
- popcount = 2;
+ /* will add 1 to first (usually two) parameters */
break;
}
}
@@ -458,18 +447,52 @@ tparam_internal(const char *string, va_list ap)
cp++;
}
- if (number > 9)
- number = 9;
+ if (number > NUM_PARM)
+ number = NUM_PARM;
+ return number;
+}
+
+static NCURSES_INLINE char *
+tparam_internal(const char *string, va_list ap)
+{
+ char *p_is_s[NUM_PARM];
+ TPARM_ARG param[NUM_PARM];
+ int popcount;
+ int number;
+ int len;
+ int level;
+ int x, y;
+ int i;
+ const char *cp = string;
+ size_t len2;
+
+ if (cp == NULL)
+ return NULL;
+
+ TPS(out_used) = 0;
+ len2 = strlen(cp);
+
+ /*
+ * Find the highest parameter-number referred to in the format string.
+ * Use this value to limit the number of arguments copied from the
+ * variable-length argument list.
+ */
+ number = _nc_tparm_analyze(cp, p_is_s, &popcount);
+ if (TPS(fmt_buff) == 0)
+ return NULL;
+
for (i = 0; i < max(popcount, number); i++) {
/*
* A few caps (such as plab_norm) have string-valued parms.
* We'll have to assume that the caller knows the difference, since
- * a char* and an int may not be the same size on the stack.
+ * a char* and an int may not be the same size on the stack. The
+ * normal prototype for this uses 9 long's, which is consistent with
+ * our va_arg() usage.
*/
if (p_is_s[i] != 0) {
p_is_s[i] = va_arg(ap, char *);
} else {
- param[i] = va_arg(ap, int);
+ param[i] = va_arg(ap, TPARM_ARG);
}
}
@@ -480,32 +503,37 @@ tparam_internal(const char *string, va_list ap)
* the expansion of (for example) \E[%d;%dH work correctly in termcap
* style, which means tparam() will expand termcap strings OK.
*/
- stack_ptr = 0;
+ TPS(stack_ptr) = 0;
if (popcount == 0) {
popcount = number;
- for (i = number - 1; i >= 0; i--)
- npush(param[i]);
+ for (i = number - 1; i >= 0; i--) {
+ if (p_is_s[i])
+ spush(p_is_s[i]);
+ else
+ npush(param[i]);
+ }
}
#ifdef TRACE
- if (_nc_tracing & TRACE_CALLS) {
+ if (USE_TRACEF(TRACE_CALLS)) {
for (i = 0; i < popcount; i++) {
if (p_is_s[i] != 0)
save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
else
save_number(", %d", param[i], 0);
}
- _tracef(T_CALLED("%s(%s%s)"), tname, _nc_visbuf(string), out_buff);
- out_used = 0;
+ _tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
+ TPS(out_used) = 0;
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
- while (*string) {
- if (*string != '%') {
- save_char(*string);
+ while ((cp - string) < (int) len2) {
+ if (*cp != '%') {
+ save_char(UChar(*cp));
} else {
- string++;
- string = parse_format(string, format, &len);
- switch (*string) {
+ TPS(tparam_base) = cp++;
+ cp = parse_format(cp, TPS(fmt_buff), &len);
+ switch (*cp) {
default:
break;
case '%':
@@ -516,22 +544,25 @@ tparam_internal(const char *string, va_list ap)
case 'o': /* FALLTHRU */
case 'x': /* FALLTHRU */
case 'X': /* FALLTHRU */
+ save_number(TPS(fmt_buff), npop(), len);
+ break;
+
case 'c': /* FALLTHRU */
- save_number(format, npop(), len);
+ save_char(npop());
break;
case 'l':
- save_number("%d", strlen(spop()), 0);
+ save_number("%d", (int) strlen(spop()), 0);
break;
case 's':
- save_text(format, spop(), len);
+ save_text(TPS(fmt_buff), spop(), len);
break;
case 'p':
- string++;
- i = (*string - '1');
- if (i >= 0 && i < 9) {
+ cp++;
+ i = (UChar(*cp) - '1');
+ if (i >= 0 && i < NUM_PARM) {
if (p_is_s[i])
spush(p_is_s[i]);
else
@@ -540,39 +571,39 @@ tparam_internal(const char *string, va_list ap)
break;
case 'P':
- string++;
- if (isUPPER(*string)) {
- i = (*string - 'A');
- static_vars[i] = npop();
- } else if (isLOWER(*string)) {
- i = (*string - 'a');
- dynamic_var[i] = npop();
+ cp++;
+ if (isUPPER(*cp)) {
+ i = (UChar(*cp) - 'A');
+ TPS(static_vars)[i] = npop();
+ } else if (isLOWER(*cp)) {
+ i = (UChar(*cp) - 'a');
+ TPS(dynamic_var)[i] = npop();
}
break;
case 'g':
- string++;
- if (isUPPER(*string)) {
- i = (*string - 'A');
- npush(static_vars[i]);
- } else if (isLOWER(*string)) {
- i = (*string - 'a');
- npush(dynamic_var[i]);
+ cp++;
+ if (isUPPER(*cp)) {
+ i = (UChar(*cp) - 'A');
+ npush(TPS(static_vars)[i]);
+ } else if (isLOWER(*cp)) {
+ i = (UChar(*cp) - 'a');
+ npush(TPS(dynamic_var)[i]);
}
break;
case S_QUOTE:
- string++;
- npush(*string);
- string++;
+ cp++;
+ npush(UChar(*cp));
+ cp++;
break;
case L_BRACE:
number = 0;
- string++;
- while (*string >= '0' && *string <= '9') {
- number = number * 10 + *string - '0';
- string++;
+ cp++;
+ while (isdigit(UChar(*cp))) {
+ number = (number * 10) + (UChar(*cp) - '0');
+ cp++;
}
npush(number);
break;
@@ -663,38 +694,38 @@ tparam_internal(const char *string, va_list ap)
x = npop();
if (!x) {
/* scan forward for %e or %; at level zero */
- string++;
+ cp++;
level = 0;
- while (*string) {
- if (*string == '%') {
- string++;
- if (*string == '?')
+ while (*cp) {
+ if (*cp == '%') {
+ cp++;
+ if (*cp == '?')
level++;
- else if (*string == ';') {
+ else if (*cp == ';') {
if (level > 0)
level--;
else
break;
- } else if (*string == 'e' && level == 0)
+ } else if (*cp == 'e' && level == 0)
break;
}
- if (*string)
- string++;
+ if (*cp)
+ cp++;
}
}
break;
case 'e':
/* scan forward for a %; at level zero */
- string++;
+ cp++;
level = 0;
- while (*string) {
- if (*string == '%') {
- string++;
- if (*string == '?')
+ while (*cp) {
+ if (*cp == '%') {
+ cp++;
+ if (*cp == '?')
level++;
- else if (*string == ';') {
+ else if (*cp == ';') {
if (level > 0)
level--;
else
@@ -702,42 +733,65 @@ tparam_internal(const char *string, va_list ap)
}
}
- if (*string)
- string++;
+ if (*cp)
+ cp++;
}
break;
case ';':
break;
- } /* endswitch (*string) */
- } /* endelse (*string == '%') */
+ } /* endswitch (*cp) */
+ } /* endelse (*cp == '%') */
- if (*string == '\0')
+ if (*cp == '\0')
break;
- string++;
- } /* endwhile (*string) */
+ cp++;
+ } /* endwhile (*cp) */
get_space(1);
- out_buff[out_used] = '\0';
+ TPS(out_buff)[TPS(out_used)] = '\0';
- T((T_RETURN("%s"), _nc_visbuf(out_buff)));
- return (out_buff);
+ T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff))));
+ return (TPS(out_buff));
}
+#if NCURSES_TPARM_VARARGS
+#define tparm_varargs tparm
+#else
+#define tparm_proto tparm
+#endif
+
NCURSES_EXPORT(char *)
-tparm
-(NCURSES_CONST char *string,...)
+tparm_varargs(NCURSES_CONST char *string,...)
{
va_list ap;
char *result;
+ _nc_tparm_err = 0;
va_start(ap, string);
#ifdef TRACE
- tname = "tparm";
+ TPS(tname) = "tparm";
#endif /* TRACE */
result = tparam_internal(string, ap);
va_end(ap);
return result;
}
+
+#if !NCURSES_TPARM_VARARGS
+NCURSES_EXPORT(char *)
+tparm_proto(NCURSES_CONST char *string,
+ TPARM_ARG a1,
+ TPARM_ARG a2,
+ TPARM_ARG a3,
+ TPARM_ARG a4,
+ TPARM_ARG a5,
+ TPARM_ARG a6,
+ TPARM_ARG a7,
+ TPARM_ARG a8,
+ TPARM_ARG a9)
+{
+ return tparm_varargs(string, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+}
+#endif /* NCURSES_TPARM_VARARGS */
diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c
index 634d0317114..c085ecfb77f 100644
--- a/lib/libcurses/tinfo/lib_tputs.c
+++ b/lib/libcurses/tinfo/lib_tputs.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tputs.c,v 1.11 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_tputs.c,v 1.12 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -47,16 +48,30 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$From: lib_tputs.c,v 1.55 2000/12/10 02:55:08 tom Exp $");
+MODULE_ID("$Id: lib_tputs.c,v 1.12 2010/01/12 23:22:06 nicm Exp $")
-NCURSES_EXPORT_VAR(char)
-PC = 0; /* used by termcap library */
-NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
+NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
+NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
-NCURSES_EXPORT_VAR(int)
-_nc_nulls_sent = 0; /* used by 'tack' program */
+NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0; /* used by 'tack' program */
- static int (*my_outch) (int c) = _nc_outch;
+#if NCURSES_NO_PADDING
+NCURSES_EXPORT(void)
+_nc_set_no_padding(SCREEN *sp)
+{
+ bool no_padding = (getenv("NCURSES_NO_PADDING") != 0);
+
+ if (sp)
+ sp->_no_padding = no_padding;
+ else
+ _nc_prescreen._no_padding = no_padding;
+
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
+ GetNoPadding(sp) ? " not" : ""));
+}
+#endif
+
+static int (*my_outch) (int c) = _nc_outch;
NCURSES_EXPORT(int)
delay_output(int ms)
@@ -69,7 +84,7 @@ delay_output(int ms)
} else {
register int nullcount;
- nullcount = (ms * _nc_baudrate(ospeed)) / 10000;
+ nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000);
for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
my_outch(PC);
if (my_outch == _nc_outch)
@@ -88,9 +103,7 @@ _nc_flush(void)
NCURSES_EXPORT(int)
_nc_outch(int ch)
{
-#ifdef TRACE
- _nc_outchars++;
-#endif /* TRACE */
+ COUNT_OUTCHARS(1);
if (SP != 0
&& SP->_cleanup) {
@@ -106,72 +119,6 @@ _nc_outch(int ch)
return OK;
}
-#if USE_WIDEC_SUPPORT
-/*
- * Reference: The Unicode Standard 2.0
- *
- * No surrogates supported (we're storing only one 16-bit Unicode value per
- * cell).
- */
-NCURSES_EXPORT(int)
-_nc_utf8_outch(int ch)
-{
- static const unsigned byteMask = 0xBF;
- static const unsigned otherMark = 0x80;
- static const unsigned firstMark[] =
- {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
-
- int result[7], *ptr;
- int count = 0;
-
- if ((unsigned int) ch < 0x80)
- count = 1;
- else if ((unsigned int) ch < 0x800)
- count = 2;
- else if ((unsigned int) ch < 0x10000)
- count = 3;
- else if ((unsigned int) ch < 0x200000)
- count = 4;
- else if ((unsigned int) ch < 0x4000000)
- count = 5;
- else if ((unsigned int) ch <= 0x7FFFFFFF)
- count = 6;
- else {
- count = 3;
- ch = 0xFFFD;
- }
- ptr = result + count;
- switch (count) {
- case 6:
- *--ptr = (ch | otherMark) & byteMask;
- ch >>= 6;
- /* FALLTHRU */
- case 5:
- *--ptr = (ch | otherMark) & byteMask;
- ch >>= 6;
- /* FALLTHRU */
- case 4:
- *--ptr = (ch | otherMark) & byteMask;
- ch >>= 6;
- /* FALLTHRU */
- case 3:
- *--ptr = (ch | otherMark) & byteMask;
- ch >>= 6;
- /* FALLTHRU */
- case 2:
- *--ptr = (ch | otherMark) & byteMask;
- ch >>= 6;
- /* FALLTHRU */
- case 1:
- *--ptr = (ch | firstMark[count]);
- break;
- }
- while (count--)
- _nc_outch(*ptr++);
- return OK;
-}
-#endif
-
NCURSES_EXPORT(int)
putp(const char *string)
{
@@ -179,8 +126,7 @@ putp(const char *string)
}
NCURSES_EXPORT(int)
-tputs
-(const char *string, int affcnt, int (*outc) (int))
+tputs(const char *string, int affcnt, int (*outc) (int))
{
bool always_delay;
bool normal_delay;
@@ -192,7 +138,7 @@ tputs
#ifdef TRACE
char addrbuf[32];
- if (_nc_tracing & TRACE_TPUTS) {
+ if (USE_TRACEF(TRACE_TPUTS)) {
if (outc == _nc_outch)
(void) strlcpy(addrbuf, "_nc_outch", sizeof(addrbuf));
else
@@ -203,7 +149,8 @@ tputs
} else {
_tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
}
- _nc_tputs_trace = (char *) NULL;
+ TPUTS_TRACE(NULL);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -219,7 +166,7 @@ tputs
!xon_xoff
&& padding_baud_rate
#if NCURSES_NO_PADDING
- && (SP == 0 || !(SP->_no_padding))
+ && !GetNoPadding(SP)
#endif
&& (_nc_baudrate(ospeed) >= padding_baud_rate);
}
@@ -230,19 +177,19 @@ tputs
* (like nethack) actually do the likes of tputs("50") to get delays.
*/
trailpad = 0;
- if (isdigit(*string)) {
- while (isdigit(*string)) {
+ if (isdigit(UChar(*string))) {
+ while (isdigit(UChar(*string))) {
trailpad = trailpad * 10 + (*string - '0');
string++;
}
trailpad *= 10;
if (*string == '.') {
string++;
- if (isdigit(*string)) {
+ if (isdigit(UChar(*string))) {
trailpad += (*string - '0');
string++;
}
- while (isdigit(*string))
+ while (isdigit(UChar(*string)))
string++;
}
@@ -267,7 +214,7 @@ tputs
bool mandatory;
string++;
- if ((!isdigit(CharOf(*string)) && *string != '.')
+ if ((!isdigit(UChar(*string)) && *string != '.')
|| !strchr(string, '>')) {
(*outc) ('$');
(*outc) ('<');
@@ -275,18 +222,18 @@ tputs
}
number = 0;
- while (isdigit(CharOf(*string))) {
+ while (isdigit(UChar(*string))) {
number = number * 10 + (*string - '0');
string++;
}
number *= 10;
if (*string == '.') {
string++;
- if (isdigit(CharOf(*string))) {
+ if (isdigit(UChar(*string))) {
number += (*string - '0');
string++;
}
- while (isdigit(CharOf(*string)))
+ while (isdigit(UChar(*string)))
string++;
}
diff --git a/lib/libcurses/tinfo/lib_ttyflags.c b/lib/libcurses/tinfo/lib_ttyflags.c
index 615e0092564..ec604dcaa53 100644
--- a/lib/libcurses/tinfo/lib_ttyflags.c
+++ b/lib/libcurses/tinfo/lib_ttyflags.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_ttyflags.c,v 1.4 2001/01/22 18:01:54 millert Exp $ */
+/* $OpenBSD: lib_ttyflags.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -40,79 +40,114 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$From: lib_ttyflags.c,v 1.5 2000/12/10 02:55:08 tom Exp $")
-
-#undef tabs
-
-#ifdef TAB3
-# define tabs TAB3
-#else
-# ifdef XTABS
-# define tabs XTABS
-# else
-# ifdef OXTABS
-# define tabs OXTABS
-# else
-# define tabs 0
-# endif
-# endif
-#endif
+MODULE_ID("$Id: lib_ttyflags.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
NCURSES_EXPORT(int)
_nc_get_tty_mode(TTY * buf)
{
- if (cur_term == 0
- || GET_TTY(cur_term->Filedes, buf) != 0)
- return (ERR);
- TR(TRACE_BITS, ("_nc_get_tty_mode: %s", _nc_tracebits()));
- return (OK);
+ int result = OK;
+
+ if (buf == 0) {
+ result = ERR;
+ } else {
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (GET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ result = ERR;
+ }
+ break;
+ }
+ }
+
+ if (result == ERR)
+ memset(buf, 0, sizeof(*buf));
+
+ TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s",
+ cur_term ? cur_term->Filedes : -1,
+ _nc_trace_ttymode(buf)));
+ }
+ return (result);
}
NCURSES_EXPORT(int)
_nc_set_tty_mode(TTY * buf)
{
- if (cur_term == 0
- || SET_TTY(cur_term->Filedes, buf) != 0)
- return (ERR);
- TR(TRACE_BITS, ("_nc_set_tty_mode: %s", _nc_tracebits()));
- return (OK);
+ int result = OK;
+
+ if (buf == 0) {
+ result = ERR;
+ } else {
+ if (cur_term == 0) {
+ result = ERR;
+ } else {
+ for (;;) {
+ if (SET_TTY(cur_term->Filedes, buf) != 0) {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOTTY) && (SP != 0))
+ SP->_notty = TRUE;
+ result = ERR;
+ }
+ break;
+ }
+ }
+ TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s",
+ cur_term ? cur_term->Filedes : -1,
+ _nc_trace_ttymode(buf)));
+ }
+ return (result);
}
NCURSES_EXPORT(int)
def_shell_mode(void)
{
- T((T_CALLED("def_shell_mode()")));
+ int rc = ERR;
- /*
- * Turn off the XTABS bit in the tty structure if it was on. If XTABS
- * was on, remove the tab and backtab capabilities.
- */
+ T((T_CALLED("def_shell_mode()")));
- if (_nc_get_tty_mode(&cur_term->Ottyb) != OK)
- returnCode(ERR);
+ if (cur_term != 0) {
+ /*
+ * If XTABS was on, remove the tab and backtab capabilities.
+ */
+ if (_nc_get_tty_mode(&cur_term->Ottyb) == OK) {
#ifdef TERMIOS
- if (cur_term->Ottyb.c_oflag & tabs)
- tab = back_tab = NULL;
+ if (cur_term->Ottyb.c_oflag & OFLAGS_TABS)
+ tab = back_tab = NULL;
#else
- if (cur_term->Ottyb.sg_flags & XTABS)
- tab = back_tab = NULL;
+ if (cur_term->Ottyb.sg_flags & XTABS)
+ tab = back_tab = NULL;
#endif
- returnCode(OK);
+ rc = OK;
+ }
+ }
+ returnCode(rc);
}
NCURSES_EXPORT(int)
def_prog_mode(void)
{
+ int rc = ERR;
+
T((T_CALLED("def_prog_mode()")));
- if (_nc_get_tty_mode(&cur_term->Nttyb) != OK)
- returnCode(ERR);
+ if (cur_term != 0) {
+ /*
+ * Turn off the XTABS bit in the tty structure if it was on.
+ */
+ if (_nc_get_tty_mode(&cur_term->Nttyb) == OK) {
#ifdef TERMIOS
- cur_term->Nttyb.c_oflag &= ~tabs;
+ cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS;
#else
- cur_term->Nttyb.sg_flags &= ~XTABS;
+ cur_term->Nttyb.sg_flags &= ~XTABS;
#endif
- returnCode(OK);
+ rc = OK;
+ }
+ }
+ returnCode(rc);
}
NCURSES_EXPORT(int)
@@ -121,13 +156,14 @@ reset_prog_mode(void)
T((T_CALLED("reset_prog_mode()")));
if (cur_term != 0) {
- _nc_set_tty_mode(&cur_term->Nttyb);
- if (SP) {
- if (stdscr && stdscr->_use_keypad)
- _nc_keypad(TRUE);
- NC_BUFFERED(TRUE);
+ if (_nc_set_tty_mode(&cur_term->Nttyb) == OK) {
+ if (SP) {
+ if (SP->_keypad_on)
+ _nc_keypad(SP, TRUE);
+ NC_BUFFERED(TRUE);
+ }
+ returnCode(OK);
}
- returnCode(OK);
}
returnCode(ERR);
}
@@ -139,7 +175,7 @@ reset_shell_mode(void)
if (cur_term != 0) {
if (SP) {
- _nc_keypad(FALSE);
+ _nc_keypad(SP, FALSE);
_nc_flush();
NC_BUFFERED(FALSE);
}
@@ -148,19 +184,33 @@ reset_shell_mode(void)
returnCode(ERR);
}
+static TTY *
+saved_tty(void)
+{
+ TTY *result = 0;
+
+ if (SP != 0) {
+ result = &(SP->_saved_tty);
+ } else {
+ if (_nc_prescreen.saved_tty == 0) {
+ _nc_prescreen.saved_tty = typeCalloc(TTY, 1);
+ }
+ result = _nc_prescreen.saved_tty;
+ }
+ return result;
+}
+
/*
** savetty() and resetty()
**
*/
-static TTY buf;
-
NCURSES_EXPORT(int)
savetty(void)
{
T((T_CALLED("savetty()")));
- returnCode(_nc_get_tty_mode(&buf));
+ returnCode(_nc_get_tty_mode(saved_tty()));
}
NCURSES_EXPORT(int)
@@ -168,5 +218,5 @@ resetty(void)
{
T((T_CALLED("resetty()")));
- returnCode(_nc_set_tty_mode(&buf));
+ returnCode(_nc_set_tty_mode(saved_tty()));
}
diff --git a/lib/libcurses/tinfo/make_keys.c b/lib/libcurses/tinfo/make_keys.c
index 0b6697d0319..caec31c9ffc 100644
--- a/lib/libcurses/tinfo/make_keys.c
+++ b/lib/libcurses/tinfo/make_keys.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: make_keys.c,v 1.8 2006/10/10 21:38:16 cloder Exp $ */
+/* $OpenBSD: make_keys.c,v 1.9 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
@@ -37,9 +37,11 @@
* making the output show the indices into the TERMTYPE Strings array. Doing
* it that way lets us cut down on the size of the init_keytry() function.
*/
+
+#define USE_TERMLIB 1
#include <curses.priv.h>
-MODULE_ID("$From: make_keys.c,v 1.10 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.9 2010/01/12 23:22:06 nicm Exp $")
#include <names.c>
@@ -68,17 +70,23 @@ lookup(const char *name)
}
static void
-make_keys(FILE * ifp, FILE * ofp)
+make_keys(FILE *ifp, FILE *ofp)
{
char buffer[BUFSIZ];
- char from[BUFSIZ];
- char to[BUFSIZ];
+ char from[256];
+ char to[256];
int maxlen = 16;
+ int scanned;
while (fgets(buffer, sizeof(buffer), ifp) != NULL) {
if (*buffer == '#')
continue;
- if (sscanf(buffer, "%s %s", to, from) == 2) {
+
+ to[sizeof(to) - 1] = '\0';
+ from[sizeof(from) - 1] = '\0';
+
+ scanned = sscanf(buffer, "%255s %255s", to, from);
+ if (scanned == 2) {
int code = lookup(from);
if (code == UNKNOWN)
continue;
@@ -94,7 +102,7 @@ make_keys(FILE * ifp, FILE * ofp)
}
static void
-write_list(FILE * ofp, const char **list)
+write_list(FILE *ofp, const char **list)
{
while (*list != 0)
fprintf(ofp, "%s\n", *list++);
@@ -113,7 +121,7 @@ main(int argc, char *argv[])
"#if BROKEN_LINKER",
"static",
"#endif",
- "struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
+ "const struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
0
};
static const char *suffix[] =
diff --git a/lib/libcurses/tinfo/name_match.c b/lib/libcurses/tinfo/name_match.c
index 6db7ac7057f..1162430ee2f 100644
--- a/lib/libcurses/tinfo/name_match.c
+++ b/lib/libcurses/tinfo/name_match.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: name_match.c,v 1.3 2001/01/22 18:01:55 millert Exp $ */
+/* $OpenBSD: name_match.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,35 +29,48 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ * Author: Thomas E. Dickey 1999-on *
****************************************************************************/
#include <curses.priv.h>
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: name_match.c,v 1.10 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
/*
* _nc_first_name(char *names)
*
* Extract the primary name from a compiled entry.
*/
+#define FirstName _nc_globals.first_name
NCURSES_EXPORT(char *)
_nc_first_name(const char *const sp)
/* get the first name from the given name list */
{
- static char buf[MAX_NAME_SIZE + 1];
- register unsigned n;
+ unsigned n;
- for (n = 0; n < sizeof(buf) - 1; n++) {
- if ((buf[n] = sp[n]) == '\0'
- || (buf[n] == '|'))
- break;
+#if NO_LEAKS
+ if (sp == 0) {
+ if (FirstName != 0)
+ FreeAndNull(FirstName);
+ } else
+#endif
+ {
+ if (FirstName == 0)
+ FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
+
+ if (FirstName != 0) {
+ for (n = 0; n < MAX_NAME_SIZE; n++) {
+ if ((FirstName[n] = sp[n]) == '\0'
+ || (FirstName[n] == '|'))
+ break;
+ }
+ FirstName[n] = '\0';
+ }
}
- buf[n] = '\0';
- return (buf);
+ return (FirstName);
}
/*
@@ -67,8 +80,7 @@ _nc_first_name(const char *const sp)
*/
NCURSES_EXPORT(int)
-_nc_name_match
-(const char *const namelst, const char *const name, const char *const delim)
+_nc_name_match(const char *const namelst, const char *const name, const char *const delim)
{
const char *s, *d, *t;
int code, found;
diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c
index 4a42654d670..2270ad90c07 100644
--- a/lib/libcurses/tinfo/parse_entry.c
+++ b/lib/libcurses/tinfo/parse_entry.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: parse_entry.c,v 1.12 2003/03/17 19:16:59 millert Exp $ */
+/* $OpenBSD: parse_entry.c,v 1.13 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,14 +43,14 @@
* from the input stream.
*/
+#define __INTERNAL_CAPS_VISIBLE
#include <curses.priv.h>
#include <ctype.h>
#include <tic.h>
-#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$From: parse_entry.c,v 1.52 2001/01/13 22:44:29 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.13 2010/01/12 23:22:06 nicm Exp $")
#ifdef LINT
static short const parametrized[] =
@@ -143,7 +144,7 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
case BOOLEAN:
tp->ext_Booleans += 1;
tp->num_Booleans += 1;
- tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
+ tp->Booleans = typeRealloc(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans);
for (last = tp->num_Booleans - 1; last > tindex; last--)
tp->Booleans[last] = tp->Booleans[last - 1];
break;
@@ -197,13 +198,17 @@ _nc_extend_names(ENTRY * entryp, char *name, int token_type)
* push back token
*/
+#define BAD_TC_USAGE if (!bad_tc_usage) \
+ { bad_tc_usage = TRUE; \
+ _nc_warning("Legacy termcap allows only a trailing tc= clause"); }
+
NCURSES_EXPORT(int)
-_nc_parse_entry
-(struct entry *entryp, int literal, bool silent)
+_nc_parse_entry(struct entry *entryp, int literal, bool silent)
{
int token_type;
struct name_table_entry const *entry_ptr;
char *ptr, *base;
+ bool bad_tc_usage = FALSE;
token_type = _nc_get_token(silent);
@@ -219,15 +224,32 @@ _nc_parse_entry
entryp->startline = _nc_start_line;
DEBUG(2, ("Comment range is %ld to %ld", entryp->cstart, entryp->cend));
- /* junk the 2-character termcap name, if present */
+ /*
+ * Strip off the 2-character termcap name, if present. Originally termcap
+ * used that as an indexing aid. We can retain 2-character terminfo names,
+ * but note that they would be lost if we translate to/from termcap. This
+ * feature is supposedly obsolete since "newer" BSD implementations do not
+ * use it; however our reference for this feature is SunOS 4.x, which
+ * implemented it. Note that the resulting terminal type was never the
+ * 2-character name, but was instead the first alias after that.
+ */
ptr = _nc_curr_token.tk_name;
- if (ptr[2] == '|') {
- ptr = _nc_curr_token.tk_name + 3;
- _nc_curr_token.tk_name[2] = '\0';
+ if (_nc_syntax == SYN_TERMCAP
+#if NCURSES_XNAMES
+ && !_nc_user_definable
+#endif
+ ) {
+ if (ptr[2] == '|') {
+ ptr += 3;
+ _nc_curr_token.tk_name[2] = '\0';
+ }
}
entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
+ if (entryp->tterm.str_table == 0)
+ return (ERR);
+
DEBUG(1, ("Starting '%s'", ptr));
/*
@@ -245,7 +267,7 @@ _nc_parse_entry
(base == entryp->tterm.term_names)
? "primary name"
: "alias",
- ptr - base, base);
+ (int) (ptr - base), base);
}
}
@@ -254,15 +276,19 @@ _nc_parse_entry
for (token_type = _nc_get_token(silent);
token_type != EOF && token_type != NAMES;
token_type = _nc_get_token(silent)) {
- if (strcmp(_nc_curr_token.tk_name, "use") == 0
- || strcmp(_nc_curr_token.tk_name, "tc") == 0) {
+ bool is_use = (strcmp(_nc_curr_token.tk_name, "use") == 0);
+ bool is_tc = !is_use && (strcmp(_nc_curr_token.tk_name, "tc") == 0);
+ if (is_use || is_tc) {
entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
entryp->uses[entryp->nuses].line = _nc_curr_line;
entryp->nuses++;
+ if (entryp->nuses > 1 && is_tc) {
+ BAD_TC_USAGE
+ }
} else {
/* normal token lookup */
entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
- _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
+ _nc_get_hash_table(_nc_syntax));
/*
* Our kluge to handle aliasing. The reason it's done
@@ -276,7 +302,10 @@ _nc_parse_entry
const struct alias *ap;
if (_nc_syntax == SYN_TERMCAP) {
- for (ap = _nc_capalias_table; ap->from; ap++)
+ if (entryp->nuses != 0) {
+ BAD_TC_USAGE
+ }
+ for (ap = _nc_get_alias_table(TRUE); ap->from; ap++)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s termcap extension) ignored",
@@ -284,14 +313,15 @@ _nc_parse_entry
goto nexttok;
}
- entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
+ entry_ptr = _nc_find_entry(ap->to,
+ _nc_get_hash_table(TRUE));
if (entry_ptr && !silent)
_nc_warning("%s (%s termcap extension) aliased to %s",
ap->from, ap->source, ap->to);
break;
}
} else { /* if (_nc_syntax == SYN_TERMINFO) */
- for (ap = _nc_infoalias_table; ap->from; ap++)
+ for (ap = _nc_get_alias_table(FALSE); ap->from; ap++)
if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
if (ap->to == (char *) 0) {
_nc_warning("%s (%s terminfo extension) ignored",
@@ -299,7 +329,8 @@ _nc_parse_entry
goto nexttok;
}
- entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
+ entry_ptr = _nc_find_entry(ap->to,
+ _nc_get_hash_table(FALSE));
if (entry_ptr && !silent)
_nc_warning("%s (%s terminfo extension) aliased to %s",
ap->from, ap->source, ap->to);
@@ -346,23 +377,28 @@ _nc_parse_entry
* type, this will do the job.
*/
- /* tell max_attributes from arrow_key_map */
- if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
+ if (token_type == NUMBER
+ && !strcmp("ma", _nc_curr_token.tk_name)) {
+ /* tell max_attributes from arrow_key_map */
entry_ptr = _nc_find_type_entry("ma", NUMBER,
_nc_get_table(_nc_syntax
!= 0));
+ assert(entry_ptr != 0);
- /* map terminfo's string MT to MT */
- else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name))
+ } else if (token_type == STRING
+ && !strcmp("MT", _nc_curr_token.tk_name)) {
+ /* map terminfo's string MT to MT */
entry_ptr = _nc_find_type_entry("MT", STRING,
_nc_get_table(_nc_syntax
!= 0));
+ assert(entry_ptr != 0);
- /* treat strings without following "=" as empty strings */
- else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
+ } else if (token_type == BOOLEAN
+ && entry_ptr->nte_type == STRING) {
+ /* treat strings without following "=" as empty strings */
token_type = STRING;
- /* we couldn't recover; skip this token */
- else {
+ } else {
+ /* we couldn't recover; skip this token */
if (!silent) {
const char *type_name;
switch (entry_ptr->nte_type) {
@@ -425,7 +461,7 @@ _nc_parse_entry
default:
if (!silent)
_nc_warning("unknown token type");
- _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ',');
+ _nc_panic_mode((char) ((_nc_syntax == SYN_TERMCAP) ? ':' : ','));
continue;
}
} /* end else cur_token.name != "use" */
@@ -445,7 +481,7 @@ _nc_parse_entry
if (!literal) {
if (_nc_syntax == SYN_TERMCAP) {
bool has_base_entry = FALSE;
- int i;
+ unsigned i;
/*
* Don't insert defaults if this is a `+' entry meant only
@@ -484,7 +520,7 @@ _nc_capcmp(const char *s, const char *t)
for (;;) {
if (s[0] == '$' && s[1] == '<') {
for (s += 2;; s++)
- if (!(isdigit(CharOf(*s))
+ if (!(isdigit(UChar(*s))
|| *s == '.'
|| *s == '*'
|| *s == '/'
@@ -494,7 +530,7 @@ _nc_capcmp(const char *s, const char *t)
if (t[0] == '$' && t[1] == '<') {
for (t += 2;; t++)
- if (!(isdigit(CharOf(*t))
+ if (!(isdigit(UChar(*t))
|| *t == '.'
|| *t == '*'
|| *t == '/'
@@ -520,8 +556,8 @@ append_acs0(string_desc * dst, int code, int src)
{
if (src != 0) {
char temp[3];
- temp[0] = code;
- temp[1] = src;
+ temp[0] = (char) code;
+ temp[1] = (char) src;
temp[2] = 0;
_nc_safe_strcat(dst, temp);
}
@@ -596,7 +632,7 @@ static const char C_HT[] = "\t";
#define CUR tp->
static void
-postprocess_termcap(TERMTYPE * tp, bool has_base)
+postprocess_termcap(TERMTYPE *tp, bool has_base)
{
char buf[MAX_LINE * 2 + 2];
string_desc result;
@@ -619,7 +655,7 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
if (WANTED(carriage_return)) {
if (carriage_return_delay > 0) {
- snprintf(buf, sizeof(buf), "%s$<%d>", C_CR, carriage_return_delay);
+ snprintf(buf, sizeof(buf), "%s$<%d>", C_CR, carriage_return_delay);
carriage_return = _nc_save_str(buf);
} else
carriage_return = _nc_save_str(C_CR);
@@ -756,11 +792,12 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
base = cp + 1) {
size_t len = cp - base;
- for (ap = ko_xlate; ap->from; ap++)
+ for (ap = ko_xlate; ap->from; ap++) {
if (len == strlen(ap->from)
&& strncmp(ap->from, base, len) == 0)
break;
- if (!ap->to) {
+ }
+ if (!(ap->from && ap->to)) {
_nc_warning("unknown capability `%.*s' in ko string",
(int) len, base);
continue;
@@ -769,8 +806,8 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
/* now we know we found a match in ko_table, so... */
- from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
- to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
+ from_ptr = _nc_find_entry(ap->from, _nc_get_hash_table(TRUE));
+ to_ptr = _nc_find_entry(ap->to, _nc_get_hash_table(FALSE));
if (!from_ptr || !to_ptr) /* should never happen! */
_nc_err_abort("ko translation table is invalid, I give up");
@@ -871,13 +908,12 @@ postprocess_termcap(TERMTYPE * tp, bool has_base)
} else if (acs_chars == 0
&& enter_alt_charset_mode != 0
&& exit_alt_charset_mode != 0) {
- acs_chars =
- _nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
+ acs_chars = _nc_save_str(VT_ACSC);
}
}
static void
-postprocess_terminfo(TERMTYPE * tp)
+postprocess_terminfo(TERMTYPE *tp)
{
/*
* TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
diff --git a/lib/libcurses/tinfo/read_bsd_terminfo.c b/lib/libcurses/tinfo/read_bsd_terminfo.c
index dae8298ec69..9c34da830f1 100644
--- a/lib/libcurses/tinfo/read_bsd_terminfo.c
+++ b/lib/libcurses/tinfo/read_bsd_terminfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read_bsd_terminfo.c,v 1.17 2009/10/28 23:22:45 schwarze Exp $ */
+/* $OpenBSD: read_bsd_terminfo.c,v 1.18 2010/01/12 23:22:06 nicm Exp $ */
/*
* Copyright (c) 1998, 1999, 2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -245,13 +245,10 @@ _nc_lookup_bsd_terminfo_entry(tn, filename, tp)
goto done;
}
- /*
- * Save term entry and prevent _nc_free_entries() from freeing
- * up the string table (since we use it in tp).
- */
- *tp = _nc_head->tterm;
- _nc_head->tterm.str_table = NULL;
- _nc_free_entries(_nc_head);
+ /* Save term entry and free from _nc_head list. */
+ *tp = _nc_head->tterm;
+ _nc_free_entry(_nc_head, tp);
+ _nc_head = _nc_tail = NULL;
}
done:
diff --git a/lib/libcurses/tinfo/read_entry.c b/lib/libcurses/tinfo/read_entry.c
index 7bbf35a3a3a..f1b3179705d 100644
--- a/lib/libcurses/tinfo/read_entry.c
+++ b/lib/libcurses/tinfo/read_entry.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: read_entry.c,v 1.15 2008/01/29 13:02:31 krw Exp $ */
+/* $OpenBSD: read_entry.c,v 1.16 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,77 +31,24 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* read_entry.c -- Routine for reading in a compiled terminfo file
- *
*/
#include <curses.priv.h>
+#include <hashed_db.h>
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: read_entry.c,v 1.72 2000/12/10 02:55:08 tom Exp $")
-
-#if !HAVE_TELL
-#define tell(fd) 0 /* lseek() is POSIX, but not tell() - odd... */
-#endif
-
-/*
- * int
- * _nc_read_file_entry(filename, ptr)
- *
- * Read the compiled terminfo entry in the given file into the
- * structure pointed to by ptr, allocating space for the string
- * table.
- */
-
-#undef BYTE
-#define BYTE(p,n) (unsigned char)((p)[n])
+MODULE_ID("$Id: read_entry.c,v 1.16 2010/01/12 23:22:06 nicm Exp $")
-#define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377))
-#define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377))
-#define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1))
-
-static bool have_tic_directory = FALSE;
-static bool keep_tic_directory = FALSE;
-
-/*
- * Record the "official" location of the terminfo directory, according to
- * the place where we're writing to, or the normal default, if not.
- */
-NCURSES_EXPORT(const char *)
-_nc_tic_dir(const char *path)
-{
- static const char *result = TERMINFO;
-
- if (!keep_tic_directory) {
- if (path != 0) {
- result = path;
- have_tic_directory = TRUE;
- } else if (!have_tic_directory && use_terminfo_vars()) {
- char *envp;
- if ((envp = getenv("TERMINFO")) != 0)
- return _nc_tic_dir(envp);
- }
- }
- return result;
-}
-
-/*
- * Special fix to prevent the terminfo directory from being moved after tic
- * has chdir'd to it. If we let it be changed, then if $TERMINFO has a
- * relative path, we'll lose track of the actual directory.
- */
-NCURSES_EXPORT(void)
-_nc_keep_tic_dir(const char *path)
-{
- _nc_tic_dir(path);
- keep_tic_directory = TRUE;
-}
+#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+#if USE_DATABASE
static void
convert_shorts(char *buf, short *Numbers, int count)
{
@@ -128,7 +75,7 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
Strings[i] = ABSENT_STRING;
} else if (IS_NEG2(buf + 2 * i)) {
Strings[i] = CANCELLED_STRING;
- } else if (LOW_MSB(buf + 2 * i) > size) {
+ } else if ((int) LOW_MSB(buf + 2 * i) > size) {
Strings[i] = ABSENT_STRING;
} else {
Strings[i] = (LOW_MSB(buf + 2 * i) + table);
@@ -147,31 +94,51 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
}
}
-#define read_shorts(fd, buf, count) (read(fd, buf, (count)*2) == (count)*2)
+static int
+fake_read(char *src, int *offset, int limit, char *dst, unsigned want)
+{
+ int have = (limit - *offset);
+
+ if (have > 0) {
+ if ((int) want > have)
+ want = have;
+ memcpy(dst, src + *offset, want);
+ *offset += want;
+ } else {
+ want = 0;
+ }
+ return (int) want;
+}
+
+#define Read(buf, count) fake_read(buffer, &offset, limit, buf, count)
+
+#define read_shorts(buf, count) \
+ (Read(buf, (unsigned) (count)*2) == (int) (count)*2)
#define even_boundary(value) \
- if ((value) % 2 != 0) read(fd, buf, 1)
+ if ((value) % 2 != 0) Read(buf, 1)
-static int
-read_termtype(int fd, TERMTYPE * ptr)
+NCURSES_EXPORT(int)
+_nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit)
/* return 1 if read, 0 if not found or garbled */
{
+ int offset = 0;
int name_size, bool_count, num_count, str_count, str_size;
int i;
- size_t bsize;
- char buf[MAX_ENTRY_SIZE];
+ char buf[MAX_ENTRY_SIZE + 1];
+ char *string_table;
+ unsigned want, have;
- TR(TRACE_DATABASE, ("READ termtype header @%d", tell(fd)));
+ TR(TRACE_DATABASE, ("READ termtype header @%d", offset));
memset(ptr, 0, sizeof(*ptr));
/* grab the header */
- if (!read_shorts(fd, buf, 6)
- || LOW_MSB(buf) != MAGIC) {
- return (0);
+ if (!read_shorts(buf, 6)
+ || !IS_TIC_MAGIC(buf)) {
+ return (TGETENT_NO);
}
- _nc_free_termtype(ptr);
name_size = LOW_MSB(buf + 2);
bool_count = LOW_MSB(buf + 4);
num_count = LOW_MSB(buf + 6);
@@ -187,35 +154,41 @@ read_termtype(int fd, TERMTYPE * ptr)
|| num_count < 0
|| str_count < 0
|| str_size < 0) {
- return (0);
+ return (TGETENT_NO);
}
+ want = str_size + name_size + 1;
if (str_size) {
/* try to allocate space for the string table */
if (str_count * 2 >= (int) sizeof(buf)
- || (ptr->str_table = typeMalloc(char, (unsigned) str_size)) == 0) {
- return (0);
+ || (string_table = typeMalloc(char, want)) == 0) {
+ return (TGETENT_NO);
}
} else {
str_count = 0;
+ if ((string_table = typeMalloc(char, want)) == 0) {
+ return (TGETENT_NO);
+ }
}
- /* grab the name (a null-terminate string) */
- read(fd, buf, min(MAX_NAME_SIZE, (unsigned) name_size));
- buf[MAX_NAME_SIZE] = '\0';
- bsize = strlen(buf) + 1;
- ptr->term_names = typeCalloc(char, bsize);
- if (ptr->term_names == NULL) {
- return (0);
+ /* grab the name (a null-terminated string) */
+ want = min(MAX_NAME_SIZE, (unsigned) name_size);
+ ptr->str_table = string_table;
+ ptr->term_names = string_table;
+ if ((have = Read(ptr->term_names, want)) != want) {
+ memset(ptr->term_names + have, 0, want - have);
}
- (void) strlcpy(ptr->term_names, buf, bsize);
- if (name_size > MAX_NAME_SIZE)
- lseek(fd, (off_t) (name_size - MAX_NAME_SIZE), 1);
+ ptr->term_names[want] = '\0';
+ string_table += (want + 1);
+
+ if (have > MAX_NAME_SIZE)
+ offset = (have - MAX_NAME_SIZE);
/* grab the booleans */
- if ((ptr->Booleans = typeCalloc(char, max(BOOLCOUNT, bool_count))) == 0
- || read(fd, ptr->Booleans, (unsigned) bool_count) != bool_count) {
- return (0);
+ if ((ptr->Booleans = TYPE_CALLOC(NCURSES_SBOOL,
+ max(BOOLCOUNT, bool_count))) == 0
+ || Read(ptr->Booleans, (unsigned) bool_count) < bool_count) {
+ return (TGETENT_NO);
}
/*
@@ -227,24 +200,24 @@ read_termtype(int fd, TERMTYPE * ptr)
even_boundary(name_size + bool_count);
/* grab the numbers */
- if ((ptr->Numbers = typeCalloc(short, max(NUMCOUNT, num_count))) == 0
- || !read_shorts(fd, buf, num_count)) {
- return (0);
+ if ((ptr->Numbers = TYPE_CALLOC(short, max(NUMCOUNT, num_count))) == 0
+ || !read_shorts(buf, num_count)) {
+ return (TGETENT_NO);
}
convert_shorts(buf, ptr->Numbers, num_count);
- if ((ptr->Strings = typeCalloc(char *, max(STRCOUNT, str_count))) == 0)
- return (0);
+ if ((ptr->Strings = TYPE_CALLOC(char *, max(STRCOUNT, str_count))) == 0)
+ return (TGETENT_NO);
if (str_count) {
/* grab the string offsets */
- if (!read_shorts(fd, buf, str_count)) {
- return (0);
+ if (!read_shorts(buf, str_count)) {
+ return (TGETENT_NO);
}
/* finally, grab the string table itself */
- if (read(fd, ptr->str_table, (unsigned) str_size) != str_size)
- return (0);
- convert_strings(buf, ptr->Strings, str_count, str_size, ptr->str_table);
+ if (Read(string_table, (unsigned) str_size) != str_size)
+ return (TGETENT_NO);
+ convert_strings(buf, ptr->Strings, str_count, str_size, string_table);
}
#if NCURSES_XNAMES
@@ -256,17 +229,17 @@ read_termtype(int fd, TERMTYPE * ptr)
* Read extended entries, if any, after the normal end of terminfo data.
*/
even_boundary(str_size);
- TR(TRACE_DATABASE, ("READ extended_header @%d", tell(fd)));
- if (_nc_user_definable && read_shorts(fd, buf, 5)) {
+ TR(TRACE_DATABASE, ("READ extended_header @%d", offset));
+ if (_nc_user_definable && read_shorts(buf, 5)) {
int ext_bool_count = LOW_MSB(buf + 0);
int ext_num_count = LOW_MSB(buf + 2);
int ext_str_count = LOW_MSB(buf + 4);
int ext_str_size = LOW_MSB(buf + 6);
int ext_str_limit = LOW_MSB(buf + 8);
- int need = (ext_bool_count + ext_num_count + ext_str_count);
+ unsigned need = (ext_bool_count + ext_num_count + ext_str_count);
int base = 0;
- if (need >= (int) sizeof(buf)
+ if (need >= sizeof(buf)
|| ext_str_size >= (int) sizeof(buf)
|| ext_str_limit >= (int) sizeof(buf)
|| ext_bool_count < 0
@@ -274,13 +247,13 @@ read_termtype(int fd, TERMTYPE * ptr)
|| ext_str_count < 0
|| ext_str_size < 0
|| ext_str_limit < 0)
- return (0);
+ return (TGETENT_NO);
ptr->num_Booleans = BOOLCOUNT + ext_bool_count;
ptr->num_Numbers = NUMCOUNT + ext_num_count;
ptr->num_Strings = STRCOUNT + ext_str_count;
- ptr->Booleans = typeRealloc(char, ptr->num_Booleans, ptr->Booleans);
+ ptr->Booleans = typeRealloc(NCURSES_SBOOL, ptr->num_Booleans, ptr->Booleans);
ptr->Numbers = typeRealloc(short, ptr->num_Numbers, ptr->Numbers);
ptr->Strings = typeRealloc(char *, ptr->num_Strings, ptr->Strings);
@@ -289,36 +262,36 @@ read_termtype(int fd, TERMTYPE * ptr)
ext_str_size, ext_str_limit));
TR(TRACE_DATABASE, ("READ %d extended-booleans @%d",
- ext_bool_count, tell(fd)));
+ ext_bool_count, offset));
if ((ptr->ext_Booleans = ext_bool_count) != 0) {
- if (read(fd, ptr->Booleans + BOOLCOUNT, (unsigned)
+ if (Read(ptr->Booleans + BOOLCOUNT, (unsigned)
ext_bool_count) != ext_bool_count)
- return (0);
+ return (TGETENT_NO);
}
even_boundary(ext_bool_count);
TR(TRACE_DATABASE, ("READ %d extended-numbers @%d",
- ext_num_count, tell(fd)));
+ ext_num_count, offset));
if ((ptr->ext_Numbers = ext_num_count) != 0) {
- if (!read_shorts(fd, buf, ext_num_count))
- return (0);
+ if (!read_shorts(buf, ext_num_count))
+ return (TGETENT_NO);
TR(TRACE_DATABASE, ("Before converting extended-numbers"));
convert_shorts(buf, ptr->Numbers + NUMCOUNT, ext_num_count);
}
- TR(TRACE_DATABASE, ("READ extended-offsets @%d", tell(fd)));
+ TR(TRACE_DATABASE, ("READ extended-offsets @%d", offset));
if ((ext_str_count || need)
- && !read_shorts(fd, buf, ext_str_count + need))
- return (0);
+ && !read_shorts(buf, ext_str_count + need))
+ return (TGETENT_NO);
TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d",
- ext_str_limit, tell(fd)));
+ ext_str_limit, offset));
if (ext_str_limit) {
if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
- return (0);
- if (read(fd, ptr->ext_str_table, ext_str_limit) != ext_str_limit)
- return (0);
+ return (TGETENT_NO);
+ if (Read(ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit)
+ return (TGETENT_NO);
TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
}
@@ -342,12 +315,16 @@ read_termtype(int fd, TERMTYPE * ptr)
}
if (need) {
- if ((ptr->ext_Names = typeCalloc(char *, need)) == 0)
- return (0);
+ if (ext_str_count >= (MAX_ENTRY_SIZE * 2))
+ return (TGETENT_NO);
+ if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
+ return (TGETENT_NO);
TR(TRACE_DATABASE,
("ext_NAMES starting @%d in extended_strings, first = %s",
base, _nc_visbuf(ptr->ext_str_table + base)));
- convert_strings(buf + (2 * ext_str_count), ptr->ext_Names, need,
+ convert_strings(buf + (2 * ext_str_count),
+ ptr->ext_Names,
+ (int) need,
ext_str_limit, ptr->ext_str_table + base);
}
@@ -374,15 +351,24 @@ read_termtype(int fd, TERMTYPE * ptr)
for (i = str_count; i < STRCOUNT; i++)
ptr->Strings[i] = ABSENT_STRING;
- return (1);
+ return (TGETENT_YES);
}
+/*
+ * int
+ * _nc_read_file_entry(filename, ptr)
+ *
+ * Read the compiled terminfo entry in the given file into the
+ * structure pointed to by ptr, allocating space for the string
+ * table.
+ */
NCURSES_EXPORT(int)
-_nc_read_file_entry
-(const char *const filename, TERMTYPE * ptr)
+_nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
/* return 1 if read, 0 if not found or garbled */
{
int code, fd = -1;
+ int limit;
+ char buffer[MAX_ENTRY_SIZE + 1];
#ifdef __OpenBSD__
if (_nc_read_bsd_terminfo_file(filename, ptr) == 1)
@@ -392,73 +378,137 @@ _nc_read_file_entry
if (_nc_access(filename, R_OK) < 0
|| (fd = open(filename, O_RDONLY | O_BINARY)) < 0) {
T(("cannot open terminfo %s (errno=%d)", filename, errno));
- return (0);
- }
+ code = TGETENT_NO;
+ } else {
+ if ((limit = read(fd, buffer, sizeof(buffer))) > 0) {
- T(("read terminfo %s", filename));
- if ((code = read_termtype(fd, ptr)) == 0)
- _nc_free_termtype(ptr);
- close(fd);
+ T(("read terminfo %s", filename));
+ if ((code = _nc_read_termtype(ptr, buffer, limit)) == TGETENT_NO) {
+ _nc_free_termtype(ptr);
+ }
+ } else {
+ code = TGETENT_NO;
+ }
+ close(fd);
+ }
return (code);
}
/*
- * Build a terminfo pathname and try to read the data. Returns 1 on success,
- * 0 on failure.
+ * Build a terminfo pathname and try to read the data. Returns TGETENT_YES on
+ * success, TGETENT_NO on failure.
*/
static int
-_nc_read_tic_entry(char *const filename,
- const char *const dir, const char *ttn, TERMTYPE * const tp)
+_nc_read_tic_entry(char *filename,
+ unsigned limit,
+ const char *const path,
+ const char *name,
+ TERMTYPE *const tp)
{
-/* maximum safe length of terminfo root directory name */
-#define MAX_TPATH (PATH_MAX - MAX_ALIAS - 6)
+ int result = TGETENT_NO;
- if (strlen(dir) > MAX_TPATH)
- return 0;
- (void) snprintf(filename, MAX_TPATH + 1, "%s/%s", dir, ttn);
- return _nc_read_file_entry(filename, tp);
-}
+ /*
+ * If we are looking in a directory, assume the entry is a file under that,
+ * according to the normal rules.
+ *
+ * FIXME - add caseless-filename fixup.
+ */
+ unsigned need = 4 + strlen(path) + strlen(name);
+ if (need <= limit) {
+ (void) snprintf(filename, limit, "%s/" LEAF_FMT "/%s", path, *name, name);
+ if (_nc_is_dir_path(path))
+ result = _nc_read_file_entry(filename, tp);
+ }
-/*
- * Process the list of :-separated directories, looking for the terminal type.
- * We don't use strtok because it does not show us empty tokens.
- */
-static int
-_nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
- ttn, TERMTYPE * const tp)
-{
- char *list, *a;
- const char *b;
- int code = 0;
-
- /* we'll modify the argument, so we must copy */
- if ((b = a = list = strdup(dirs)) == NULL)
- return (0);
-
- for (;;) {
- int c = *a;
- if (c == 0 || c == NCURSES_PATHSEP) {
- *a = 0;
- if ((b + 1) >= a)
- b = TERMINFO;
- if (_nc_read_tic_entry(filename, b, ttn, tp) == 1) {
- code = 1;
- break;
+#if USE_HASHED_DB
+ else {
+ static const char suffix[] = DBM_SUFFIX;
+ DB *capdbp;
+ unsigned lens = sizeof(suffix) - 1;
+ unsigned size = strlen(path);
+ unsigned need = lens + size;
+
+ if (need <= limit) {
+ if (size >= lens
+ && !strcmp(path + size - lens, suffix))
+ (void) strlcpy(filename, path, limit);
+ else
+ (void) snprintf(filename, limit, "%s%s", path, suffix);
+
+ /*
+ * It would be nice to optimize the dbopen/close activity, as
+ * done in the cgetent implementation for tc= clauses. However,
+ * since we support multiple database locations, we cannot do
+ * that.
+ */
+ if ((capdbp = _nc_db_open(filename, FALSE)) != 0) {
+ DBT key, data;
+ int reccnt = 0;
+ char *save = strdup(name);
+
+ memset(&key, 0, sizeof(key));
+ key.data = save;
+ key.size = strlen(save);
+
+ /*
+ * This lookup could return termcap data, which we do not want.
+ * We are looking for compiled (binary) terminfo data.
+ *
+ * cgetent uses a two-level lookup. On the first it uses the
+ * given name to return a record containing only the aliases
+ * for an entry. On the second (using that list of aliases as
+ * a key), it returns the content of the terminal description.
+ * We expect second lookup to return data beginning with the
+ * same set of aliases.
+ *
+ * For compiled terminfo, the list of aliases in the second
+ * case will be null-terminated. A termcap entry will not be,
+ * and will run on into the description. So we can easily
+ * distinguish between the two (source/binary) by checking the
+ * lengths.
+ */
+ while (_nc_db_get(capdbp, &key, &data) == 0) {
+ int used = data.size - 1;
+ char *have = (char *) data.data;
+
+ if (*have++ == 0) {
+ if (data.size > key.size
+ && IS_TIC_MAGIC(have)) {
+ result = _nc_read_termtype(tp, have, used);
+ if (result == TGETENT_NO) {
+ _nc_free_termtype(tp);
+ }
+ }
+ break;
+ }
+
+ /*
+ * Just in case we have a corrupt database, do not waste
+ * time with it.
+ */
+ if (++reccnt >= 3)
+ break;
+
+ /*
+ * Prepare for the second level.
+ */
+ key.data = have;
+ key.size = used;
+ }
+
+ _nc_db_close(capdbp);
+ free(save);
}
- b = a + 1;
- if (c == 0)
- break;
}
- a++;
}
-
- free(list);
- return (code);
+#endif
+ return result;
}
+#endif /* USE_DATABASE */
/*
- * _nc_read_entry(char *tn, char *filename, TERMTYPE *tp)
+ * _nc_read_entry(char *name, char *filename, TERMTYPE *tp)
*
* Find and read the compiled entry for a given terminal type,
* if it exists. We take pains here to make sure no combination
@@ -467,52 +517,43 @@ _nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
*/
NCURSES_EXPORT(int)
-_nc_read_entry
-(const char *const tn, char *const filename, TERMTYPE * const tp)
+_nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp)
{
- char *envp;
- char ttn[MAX_ALIAS + 3];
+ int code = TGETENT_NO;
#ifdef __OpenBSD__
/* First check the BSD terminfo.db file */
- if (_nc_read_bsd_terminfo_entry(tn, filename, tp) == 1)
+ if (_nc_read_bsd_terminfo_entry(name, filename, tp) == 1)
return (1);
#endif /* __OpenBSD__ */
- /* truncate the terminal name to prevent dangerous buffer airline */
- (void) snprintf(ttn, sizeof(ttn), "%c/%.*s", *tn, MAX_ALIAS, tn);
-
- /* This is System V behavior, in conjunction with our requirements for
- * writing terminfo entries.
- */
- if (have_tic_directory
- && _nc_read_tic_entry(filename, _nc_tic_dir(0), ttn, tp) == 1)
- return 1;
-
- if (use_terminfo_vars()) {
- if ((envp = getenv("TERMINFO")) != 0
- && _nc_read_tic_entry(filename, _nc_tic_dir(envp), ttn, tp) == 1)
- return 1;
-
- /* this is an ncurses extension */
- if ((envp = _nc_home_terminfo()) != 0) {
- if (_nc_read_tic_entry(filename, envp, ttn, tp) == 1) {
- return (1);
+ snprintf(filename, PATH_MAX, "%s", name);
+ if (strlen(name) == 0
+ || strcmp(name, ".") == 0
+ || strcmp(name, "..") == 0
+ || _nc_pathlast(name) != 0
+ || strchr(name, NCURSES_PATHSEP) != 0) {
+ T(("illegal or missing entry name '%s'", name));
+ } else {
+#if USE_DATABASE
+ DBDIRS state = dbdTIC;
+ int offset = 0;
+ const char *path;
+
+ while ((path = _nc_next_db(&state, &offset)) != 0) {
+ code = _nc_read_tic_entry(filename, PATH_MAX, path, name, tp);
+ if (code == TGETENT_YES) {
+ _nc_last_db();
+ break;
}
}
-
- /* this is an ncurses extension */
- if ((envp = getenv("TERMINFO_DIRS")) != 0)
- return _nc_read_terminfo_dirs(envp, filename, ttn, tp);
- }
-
- /* Try the system directory. Note that the TERMINFO_DIRS value, if
- * defined by the configure script, begins with a ":", which will be
- * interpreted as TERMINFO.
- */
-#ifdef TERMINFO_DIRS
- return _nc_read_terminfo_dirs(TERMINFO_DIRS, filename, ttn, tp);
-#else
- return _nc_read_tic_entry(filename, TERMINFO, ttn, tp);
#endif
+#if USE_TERMCAP
+ if (code != TGETENT_YES) {
+ code = _nc_read_termcap_entry(name, tp);
+ snprintf(filename, PATH_MAX, "%s", _nc_get_source());
+ }
+#endif
+ }
+ return code;
}
diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c
index 65dc97fd04a..9968879f235 100644
--- a/lib/libcurses/tinfo/read_termcap.c
+++ b/lib/libcurses/tinfo/read_termcap.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: read_termcap.c,v 1.22 2010/01/12 23:22:06 nicm Exp $ */
+
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -52,25 +55,31 @@
#include <curses.priv.h>
#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <tic.h>
#include <term_entry.h>
-MODULE_ID("$From: read_termcap.c,v 1.55 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.22 2010/01/12 23:22:06 nicm Exp $")
#if !PURE_TERMINFO
-#ifdef __EMX__
-#define is_pathname(s) ((((s) != 0) && ((s)[0] == '/')) \
- || (((s)[0] != 0) && ((s)[1] == ':')))
-#else
-#define is_pathname(s) ((s) != 0 && (s)[0] == '/')
-#endif
-
#define TC_SUCCESS 0
-#define TC_UNRESOLVED -1
-#define TC_NOT_FOUND -2
-#define TC_SYS_ERR -3
-#define TC_REF_LOOP -4
+#define TC_NOT_FOUND -1
+#define TC_SYS_ERR -2
+#define TC_REF_LOOP -3
+#define TC_UNRESOLVED -4 /* this is not returned by BSD cgetent */
+
+static NCURSES_CONST char *
+get_termpath(void)
+{
+ NCURSES_CONST char *result;
+
+ if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
+ result = TERMPATH;
+ T(("TERMPATH is %s", result));
+ return result;
+}
#if USE_GETCAP
@@ -119,13 +128,7 @@ static int _nc_nfcmp(const char *, char *);
#define BFRAG 1024
#define BSIZE 1024
-#define ESC ('[' & 037) /* ASCII ESC */
#define MAX_RECURSION 32 /* maximum getent recursion */
-#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */
-
-#define RECOK (char)0
-#define TCERR (char)1
-#define SHADOW (char)2
static size_t topreclen; /* toprec length */
static char *toprec; /* Additional record specified by cgetset() */
@@ -218,10 +221,10 @@ _nc_cgetcap(char *buf, const char *cap, int type)
* Returns:
*
* positive # on success (i.e., the index in db_array)
- * TC_UNRESOLVED if we had too many recurrences to resolve
* TC_NOT_FOUND if the requested record couldn't be found
* TC_SYS_ERR if a system error was encountered (e.g.,couldn't open a file)
* TC_REF_LOOP if a potential reference loop is detected
+ * TC_UNRESOLVED if we had too many recurrences to resolve
*/
static int
_nc_cgetent(char **buf, int *oline, char **db_array, const char *name)
@@ -284,7 +287,7 @@ _nc_getent(
errno = ENOMEM;
return (TC_SYS_ERR);
}
- (void) strlcpy(record, toprec, topreclen + BFRAG);
+ (void) strlcpy(record, toprec, topreclen + BFRAG);
rp = record + topreclen + 1;
r_end = rp + BFRAG;
current = in_array;
@@ -659,7 +662,11 @@ _nc_nfcmp(const char *nf, char *rec)
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgment:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -701,7 +708,7 @@ get_tc_token(char **srcp, int *endp)
if (*s == '\0') {
break;
} else if (*s++ == '\n') {
- while (isspace(*s))
+ while (isspace(UChar(*s)))
s++;
} else {
found = TRUE;
@@ -715,7 +722,7 @@ get_tc_token(char **srcp, int *endp)
break;
}
base = s;
- } else if (isgraph(ch)) {
+ } else if (isgraph(UChar(ch))) {
found = TRUE;
}
}
@@ -735,7 +742,7 @@ copy_tc_token(char *dst, const char *src, size_t len)
while ((ch = *src++) != '\0') {
if (ch == '\\' && *src == '\n') {
- while (isspace(*src))
+ while (isspace(UChar(*src)))
src++;
continue;
}
@@ -755,7 +762,6 @@ static int
_nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
{
static char *the_source;
-
register char *p;
register char *cp;
char *dummy = NULL;
@@ -765,7 +771,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
char pathbuf[PBUFSIZ]; /* holds raw path of filenames */
char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
char **pvec; /* holds usable tail of path vector */
- char *termpath;
+ NCURSES_CONST char *termpath;
string_desc desc;
fname = pathvec;
@@ -785,23 +791,23 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
*/
_nc_str_init(&desc, pathbuf, sizeof(pathbuf));
if (cp == NULL) {
- _nc_safe_strcpy(&desc, "/usr/share/misc/termcap /etc/termcap");
- } else if (!is_pathname(cp)) { /* TERMCAP holds an entry */
- if ((termpath = getenv("TERMPATH")) != 0) {
+ _nc_safe_strcpy(&desc, get_termpath());
+ } else if (!_nc_is_abs_path(cp)) { /* TERMCAP holds an entry */
+ if ((termpath = get_termpath()) != 0) {
_nc_safe_strcat(&desc, termpath);
} else {
char temp[PBUFSIZ];
- size_t len;
temp[0] = 0;
if ((home = getenv("HOME")) != 0 && *home != '\0'
- && strchr(home, ' ') == 0) { /* setup path */
- len = snprintf(temp, sizeof(temp), "%s/.termcap", home);
- if (len < sizeof(temp)) {
- _nc_safe_strcat(&desc, temp);
- }
+ && strchr(home, ' ') == 0
+ && strlen(home) < sizeof(temp) - 10) { /* setup path */
+ snprintf(temp, sizeof(temp), "%s/", home); /* $HOME first */
}
- _nc_safe_strcat(&desc, " /usr/share/misc/termcap");
- _nc_safe_strcat(&desc, " /etc/termcap");
+ /* if no $HOME look in current directory */
+ strlcat(temp, ".termcap", sizeof temp);
+ _nc_safe_strcat(&desc, temp);
+ _nc_safe_strcat(&desc, " ");
+ _nc_safe_strcat(&desc, get_termpath());
}
} else { /* user-defined name in TERMCAP */
_nc_safe_strcat(&desc, cp); /* still can be tokenized */
@@ -824,7 +830,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
}
}
*fname = 0; /* mark end of vector */
- if (is_pathname(cp)) {
+ if (_nc_is_abs_path(cp)) {
if (_nc_cgetset(cp) < 0) {
return (TC_SYS_ERR);
}
@@ -877,8 +883,21 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
* cgetent, then it is the actual filename).
*/
if (i >= 0) {
+#if HAVE_BSD_CGETENT
+ char temp[PATH_MAX];
+
+ _nc_str_init(&desc, temp, sizeof(temp));
+ _nc_safe_strcpy(&desc, pathvec[i]);
+ _nc_safe_strcat(&desc, ".db");
+ if (_nc_access(temp, R_OK) == 0) {
+ _nc_safe_strcpy(&desc, pathvec[i]);
+ }
+ if ((the_source = strdup(temp)) != 0)
+ *sourcename = the_source;
+#else
if ((the_source = strdup(pathvec[i])) != 0)
*sourcename = the_source;
+#endif
}
return (i);
@@ -896,20 +915,26 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
static int
add_tc(char *termpaths[], char *path, int count)
{
+ char *save = strchr(path, NCURSES_PATHSEP);
+ if (save != 0)
+ *save = '\0';
if (count < MAXPATHS
- && _nc_access(path, R_OK) == 0)
+ && _nc_access(path, R_OK) == 0) {
termpaths[count++] = path;
+ T(("Adding termpath %s", path));
+ }
termpaths[count] = 0;
+ if (save != 0)
+ *save = NCURSES_PATHSEP;
return count;
}
#define ADD_TC(path, count) filecount = add_tc(termpaths, path, count)
#endif /* !USE_GETCAP */
NCURSES_EXPORT(int)
-_nc_read_termcap_entry
-(const char *const tn, TERMTYPE * const tp)
+_nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
{
- int found = FALSE;
+ int found = TGETENT_NO;
ENTRY *ep;
#if USE_GETCAP_CACHE
char cwd_buf[PATH_MAX];
@@ -920,20 +945,31 @@ _nc_read_termcap_entry
static char *source;
static int lineno;
+ T(("read termcap entry for %s", tn));
+
+ if (strlen(tn) == 0
+ || strcmp(tn, ".") == 0
+ || strcmp(tn, "..") == 0
+ || _nc_pathlast(tn) != 0) {
+ T(("illegal or missing entry name '%s'", tn));
+ return TGETENT_NO;
+ }
+
if (use_terminfo_vars() && (p = getenv("TERMCAP")) != 0
- && !is_pathname(p) && _nc_name_match(p, tn, "|:")) {
+ && !_nc_is_abs_path(p) && _nc_name_match(p, tn, "|:")) {
/* TERMCAP holds a termcap entry */
- strlcpy(tc, p, sizeof(tc));
+ strncpy(tc, p, sizeof(tc) - 1);
+ tc[sizeof(tc) - 1] = '\0';
_nc_set_source("TERMCAP");
} else {
/* we're using getcap(3) */
if ((status = _nc_tgetent(tc, &source, &lineno, tn)) < 0)
- return (status == -1 ? 0 : -1);
+ return (status == TC_NOT_FOUND ? TGETENT_NO : TGETENT_ERR);
_nc_curr_line = lineno;
_nc_set_source(source);
}
- _nc_read_entry_source((FILE *) 0, tc, FALSE, TRUE, NULLHOOK);
+ _nc_read_entry_source((FILE *) 0, tc, FALSE, FALSE, NULLHOOK);
#else
/*
* Here is what the 4.4BSD termcap(3) page prescribes:
@@ -964,65 +1000,98 @@ _nc_read_termcap_entry
FILE *fp;
char *tc, *termpaths[MAXPATHS];
int filecount = 0;
+ int j, k;
bool use_buffer = FALSE;
+ bool normal = TRUE;
char tc_buf[1024];
char pathbuf[PATH_MAX];
+ char *copied = 0;
+ char *cp;
+ struct stat test_stat[MAXPATHS];
termpaths[filecount] = 0;
if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != 0) {
- if (is_pathname(tc)) { /* interpret as a filename */
+ if (_nc_is_abs_path(tc)) { /* interpret as a filename */
ADD_TC(tc, 0);
+ normal = FALSE;
} else if (_nc_name_match(tc, tn, "|:")) { /* treat as a capability file */
use_buffer = TRUE;
- (void) snprintf(tc_buf, sizeof(tc_buf), "%.*s\n",
- (int) sizeof(tc_buf) - 2, tc);
- } else if ((tc = getenv("TERMPATH")) != 0) {
- char *cp;
-
- for (cp = tc; *cp; cp++) {
- if (*cp == NCURSES_PATHSEP)
- *cp = '\0';
- else if (cp == tc || cp[-1] == '\0') {
- ADD_TC(cp, filecount);
- }
- }
+ (void) snprintf(tc_buf, sizeof(tc_buf), "%.*s\n", (int) sizeof(tc_buf) - 2, tc);
+ normal = FALSE;
}
- } else { /* normal case */
- char envhome[PATH_MAX], *h;
+ }
- filecount = 0;
+ if (normal) { /* normal case */
+ char envhome[PATH_MAX], *h;
- /*
- * Probably /etc/termcap is a symlink to /usr/share/misc/termcap.
- * Avoid reading the same file twice.
- */
- if (_nc_access("/etc/termcap", F_OK) == 0)
- ADD_TC("/etc/termcap", filecount);
- else
- ADD_TC("/usr/share/misc/termcap", filecount);
+ copied = strdup(get_termpath());
+ for (cp = copied; *cp; cp++) {
+ if (*cp == NCURSES_PATHSEP)
+ *cp = '\0';
+ else if (cp == copied || cp[-1] == '\0') {
+ ADD_TC(cp, filecount);
+ }
+ }
#define PRIVATE_CAP "%s/.termcap"
if (use_terminfo_vars() && (h = getenv("HOME")) != NULL && *h != '\0'
&& (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) {
/* user's .termcap, if any, should override it */
- (void) strlcpy(envhome, h, sizeof(envhome));
+ (void) strlcpy(envhome, h, sizeof(envhome);
(void) snprintf(pathbuf, sizeof(pathbuf), PRIVATE_CAP, envhome);
ADD_TC(pathbuf, filecount);
}
}
+ /*
+ * Probably /etc/termcap is a symlink to /usr/share/misc/termcap.
+ * Avoid reading the same file twice.
+ */
+#if HAVE_LINK
+ for (j = 0; j < filecount; j++) {
+ bool omit = FALSE;
+ if (stat(termpaths[j], &test_stat[j]) != 0
+ || (test_stat[j].st_mode & S_IFMT) != S_IFREG) {
+ omit = TRUE;
+ } else {
+ for (k = 0; k < j; k++) {
+ if (test_stat[k].st_dev == test_stat[j].st_dev
+ && test_stat[k].st_ino == test_stat[j].st_ino) {
+ omit = TRUE;
+ break;
+ }
+ }
+ }
+ if (omit) {
+ T(("Path %s is a duplicate", termpaths[j]));
+ for (k = j + 1; k < filecount; k++) {
+ termpaths[k - 1] = termpaths[k];
+ test_stat[k - 1] = test_stat[k];
+ }
+ --filecount;
+ --j;
+ }
+ }
+#endif
+
/* parse the sources */
if (use_buffer) {
_nc_set_source("TERMCAP");
- _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, TRUE, NULLHOOK);
+
+ /*
+ * We don't suppress warning messages here. The presumption is
+ * that since it's just a single entry, they won't be a pain.
+ */
+ _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, FALSE, NULLHOOK);
} else {
int i;
for (i = 0; i < filecount; i++) {
T(("Looking for %s in %s", tn, termpaths[i]));
- if ((fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
+ if (_nc_access(termpaths[i], R_OK) == 0
+ && (fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
_nc_set_source(termpaths[i]);
/*
@@ -1036,13 +1105,15 @@ _nc_read_termcap_entry
}
}
}
+ if (copied != 0)
+ free(copied);
#endif /* USE_GETCAP */
if (_nc_head == 0)
- return (ERR);
+ return (TGETENT_ERR);
/* resolve all use references */
- _nc_resolve_uses(TRUE);
+ _nc_resolve_uses2(TRUE, FALSE);
/* find a terminal matching tn, if we can */
#if USE_GETCAP_CACHE
@@ -1052,13 +1123,12 @@ _nc_read_termcap_entry
for_entry_list(ep) {
if (_nc_name_match(ep->tterm.term_names, tn, "|:")) {
/*
- * Make a local copy of the terminal capabilities. Free all
- * entry storage except the string table for the loaded type
- * (which we disconnected from the list by NULLing out
- * ep->tterm.str_table above).
+ * Make a local copy of the terminal capabilities, delinked
+ * from the list.
*/
*tp = ep->tterm;
- ep->tterm.str_table = (char *) 0;
+ _nc_delink_entry(_nc_head, &(ep->tterm));
+ free(ep);
/*
* OK, now try to write the type to user's terminfo directory.
@@ -1075,7 +1145,7 @@ _nc_read_termcap_entry
#if USE_GETCAP_CACHE
(void) _nc_write_entry(tp);
#endif
- found = TRUE;
+ found = TGETENT_YES;
break;
}
}
@@ -1084,7 +1154,6 @@ _nc_read_termcap_entry
}
#endif
- _nc_free_entries(_nc_head);
return (found);
}
#else
diff --git a/lib/libcurses/tinfo/setbuf.c b/lib/libcurses/tinfo/setbuf.c
index cfe3771b036..a569f45cc52 100644
--- a/lib/libcurses/tinfo/setbuf.c
+++ b/lib/libcurses/tinfo/setbuf.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: setbuf.c,v 1.4 2001/01/22 18:01:57 millert Exp $ */
+/* $OpenBSD: setbuf.c,v 1.5 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: setbuf.c,v 1.7 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: setbuf.c,v 1.5 2010/01/12 23:22:06 nicm Exp $")
/*
* If the output file descriptor is connected to a tty (the typical case) it
@@ -100,47 +100,53 @@ MODULE_ID("$From: setbuf.c,v 1.7 2000/12/10 02:55:08 tom Exp $")
* buffer. So we disable this by default (there may yet be a workaround).
*/
NCURSES_EXPORT(void)
-_nc_set_buffer(FILE * ofp, bool buffered)
+_nc_set_buffer(FILE *ofp, bool buffered)
{
/* optional optimization hack -- do before any output to ofp */
#if HAVE_SETVBUF || HAVE_SETBUFFER
- unsigned buf_len;
- char *buf_ptr;
+ if (SP->_buffered != buffered) {
+ unsigned buf_len;
+ char *buf_ptr;
- if (getenv("NCURSES_NO_SETBUF") != 0)
- return;
+ if (getenv("NCURSES_NO_SETBUF") != 0)
+ return;
- fflush(ofp);
- if ((SP->_buffered = buffered) != 0) {
- buf_len = min(LINES * (COLS + 6), 2800);
- if ((buf_ptr = SP->_setbuf) == 0) {
- if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
- return;
- SP->_setbuf = buf_ptr;
- /* Don't try to free this! */
- }
+ fflush(ofp);
+#ifdef __DJGPP__
+ setmode(ofp, O_BINARY);
+#endif
+ if (buffered != 0) {
+ buf_len = min(LINES * (COLS + 6), 2800);
+ if ((buf_ptr = SP->_setbuf) == 0) {
+ if ((buf_ptr = typeMalloc(char, buf_len)) == NULL)
+ return;
+ SP->_setbuf = buf_ptr;
+ /* Don't try to free this! */
+ }
#if !USE_SETBUF_0
- else
- return;
+ else
+ return;
#endif
- } else {
+ } else {
#if !USE_SETBUF_0
- return;
+ return;
#else
- buf_len = 0;
- buf_ptr = 0;
+ buf_len = 0;
+ buf_ptr = 0;
#endif
- }
+ }
#if HAVE_SETVBUF
#ifdef SETVBUF_REVERSED /* pre-svr3? */
- (void) setvbuf(ofp, buf_ptr, buf_len, buf_len ? _IOFBF : _IOLBF);
+ (void) setvbuf(ofp, buf_ptr, buf_len, buf_len ? _IOFBF : _IOLBF);
#else
- (void) setvbuf(ofp, buf_ptr, buf_len ? _IOFBF : _IOLBF, buf_len);
+ (void) setvbuf(ofp, buf_ptr, buf_len ? _IOFBF : _IOLBF, buf_len);
#endif
#elif HAVE_SETBUFFER
- (void) setbuffer(ofp, buf_ptr, (int) buf_len);
+ (void) setbuffer(ofp, buf_ptr, (int) buf_len);
#endif
+ SP->_buffered = buffered;
+ }
#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
}
diff --git a/lib/libcurses/tinfo/strings.c b/lib/libcurses/tinfo/strings.c
index fd5d7f314b8..b0f06598466 100644
--- a/lib/libcurses/tinfo/strings.c
+++ b/lib/libcurses/tinfo/strings.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: strings.c,v 1.3 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: strings.c,v 1.4 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2000-2003,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,7 +38,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: strings.c,v 1.3 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.4 2010/01/12 23:22:06 nicm Exp $")
/****************************************************************************
* Useful string functions (especially for mvcur)
@@ -46,8 +46,7 @@ MODULE_ID("$From: strings.c,v 1.3 2000/12/10 02:55:08 tom Exp $")
#if !HAVE_STRSTR
NCURSES_EXPORT(char *)
-_nc_strstr
-(const char *haystack, const char *needle)
+_nc_strstr(const char *haystack, const char *needle)
{
size_t len1 = strlen(haystack);
size_t len2 = strlen(needle);
@@ -55,7 +54,7 @@ _nc_strstr
while ((len1 != 0) && (len1-- >= len2)) {
if (!strncmp(haystack, needle, len2)) {
- result = haystack;
+ result = (char *) haystack;
break;
}
haystack++;
@@ -65,16 +64,18 @@ _nc_strstr
#endif
/*
- * Initialize the descriptor so we can append to it.
+ * Initialize the descriptor so we can append to it. Note that 'src' may
+ * be a null pointer (see _nc_str_null), so the corresponding strcat and
+ * strcpy calls have to allow for this.
*/
NCURSES_EXPORT(string_desc *)
-_nc_str_init
-(string_desc * dst, char *src, size_t len)
+_nc_str_init(string_desc * dst, char *src, size_t len)
{
if (dst != 0) {
dst->s_head = src;
dst->s_tail = src;
dst->s_size = len - 1;
+ dst->s_init = dst->s_size;
if (src != 0)
*src = 0;
}
@@ -85,8 +86,7 @@ _nc_str_init
* Initialize the descriptor for only tracking the amount of memory used.
*/
NCURSES_EXPORT(string_desc *)
-_nc_str_null
-(string_desc * dst, size_t len)
+_nc_str_null(string_desc * dst, size_t len)
{
return _nc_str_init(dst, 0, len);
}
@@ -95,8 +95,7 @@ _nc_str_null
* Copy a descriptor
*/
NCURSES_EXPORT(string_desc *)
-_nc_str_copy
-(string_desc * dst, string_desc * src)
+_nc_str_copy(string_desc * dst, string_desc * src)
{
*dst = *src;
return dst;
@@ -137,7 +136,7 @@ _nc_safe_strcpy(string_desc * dst, const char *src)
strlcpy(dst->s_head, src, dst->s_size);
dst->s_tail = dst->s_head + len;
}
- dst->s_size -= len;
+ dst->s_size = dst->s_init - len;
return TRUE;
}
}
diff --git a/lib/libcurses/tinfo/trim_sgr0.c b/lib/libcurses/tinfo/trim_sgr0.c
new file mode 100644
index 00000000000..017d715bd01
--- /dev/null
+++ b/lib/libcurses/tinfo/trim_sgr0.c
@@ -0,0 +1,328 @@
+/* $OpenBSD: trim_sgr0.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2005-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+
+#include <tic.h>
+#include <term_entry.h>
+
+MODULE_ID("$Id: trim_sgr0.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+#undef CUR
+#define CUR tp->
+
+#define CSI 233
+#define ESC 033 /* ^[ */
+#define L_BRACK '['
+
+static char *
+set_attribute_9(TERMTYPE *tp, int flag)
+{
+ const char *result;
+
+ if ((result = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag)) == 0)
+ result = "";
+ return strdup(result);
+}
+
+static int
+is_csi(const char *s)
+{
+ if (UChar(s[0]) == CSI)
+ return 1;
+ else if (s[0] == ESC && s[1] == L_BRACK)
+ return 2;
+ return 0;
+}
+
+static char *
+skip_zero(char *s)
+{
+ if (s[0] == '0') {
+ if (s[1] == ';')
+ s += 2;
+ else if (isalpha(UChar(s[1])))
+ s += 1;
+ }
+ return s;
+}
+
+static const char *
+skip_delay(const char *s)
+{
+ if (s[0] == '$' && s[1] == '<') {
+ s += 2;
+ while (isdigit(UChar(*s)) || *s == '/')
+ ++s;
+ if (*s == '>')
+ ++s;
+ }
+ return s;
+}
+
+/*
+ * Improve similar_sgr a little by moving the attr-string from the beginning
+ * to the end of the s-string.
+ */
+static bool
+rewrite_sgr(char *s, char *attr)
+{
+ if (PRESENT(s)) {
+ if (PRESENT(attr)) {
+ unsigned len_s = strlen(s);
+ unsigned len_a = strlen(attr);
+
+ if (len_s > len_a && !strncmp(attr, s, len_a)) {
+ unsigned n;
+ TR(TRACE_DATABASE, ("rewrite:\n\t%s", s));
+ for (n = 0; n < len_s - len_a; ++n) {
+ s[n] = s[n + len_a];
+ }
+ strlcpy(s + n, attr, len_s - n);
+ TR(TRACE_DATABASE, ("to:\n\t%s", s));
+ }
+ }
+ return TRUE;
+ }
+ return FALSE; /* oops */
+}
+
+static bool
+similar_sgr(char *a, char *b)
+{
+ bool result = FALSE;
+ int csi_a = is_csi(a);
+ int csi_b = is_csi(b);
+ unsigned len_a;
+ unsigned len_b;
+
+ TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s",
+ _nc_visbuf2(1, a),
+ _nc_visbuf2(2, b)));
+ if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) {
+ a += csi_a;
+ b += csi_b;
+ if (*a != *b) {
+ a = skip_zero(a);
+ b = skip_zero(b);
+ }
+ }
+ len_a = strlen(a);
+ len_b = strlen(b);
+ if (len_a && len_b) {
+ if (len_a > len_b)
+ result = (strncmp(a, b, len_b) == 0);
+ else
+ result = (strncmp(a, b, len_a) == 0);
+ }
+ TR(TRACE_DATABASE, ("...similar_sgr: %d\n\t%s\n\t%s", result,
+ _nc_visbuf2(1, a),
+ _nc_visbuf2(2, b)));
+ return result;
+}
+
+static unsigned
+chop_out(char *string, unsigned i, unsigned j)
+{
+ TR(TRACE_DATABASE, ("chop_out %d..%d from %s", i, j, _nc_visbuf(string)));
+ while (string[j] != '\0') {
+ string[i++] = string[j++];
+ }
+ string[i] = '\0';
+ return i;
+}
+
+/*
+ * Compare, ignoring delays. Some of the delay values are inconsistent, and
+ * we do not want to be stopped by that.
+ *
+ * Returns the number of chars from 'full' that we matched. If any mismatch
+ * occurs, return zero.
+ */
+static int
+compare_part(const char *part, const char *full)
+{
+ const char *next_part;
+ const char *next_full;
+ int used_full = 0;
+ int used_delay = 0;
+
+ while (*part != 0) {
+ if (*part != *full) {
+ used_full = 0;
+ break;
+ }
+
+ /*
+ * Adjust the return-value to allow the rare case of
+ * string<delay>string
+ * to remove the whole piece. The most common case is a delay at the
+ * end of the string. The adjusted string will retain the delay, which
+ * is conservative.
+ */
+ if (used_delay != 0) {
+ used_full += used_delay;
+ used_delay = 0;
+ }
+ if (*part == '$' && *full == '$') {
+ next_part = skip_delay(part);
+ next_full = skip_delay(full);
+ if (next_part != part && next_full != full) {
+ used_delay += (next_full - full);
+ full = next_full;
+ part = next_part;
+ continue;
+ }
+ }
+ ++used_full;
+ ++part;
+ ++full;
+ }
+ return used_full;
+}
+
+/*
+ * While 'sgr0' is the "same" as termcap 'me', there is a compatibility issue.
+ * The sgr/sgr0 capabilities include setting/clearing alternate character set
+ * mode. A termcap application cannot use sgr, so sgr0 strings that reset
+ * alternate character set mode will be misinterpreted. Here, we remove those
+ * from the more common ISO/ANSI/VT100 entries, which have sgr0 agreeing with
+ * sgr.
+ *
+ * This function returns the modified sgr0 if it can be modified, a null if
+ * an error occurs, or the original sgr0 if no change is needed.
+ */
+NCURSES_EXPORT(char *)
+_nc_trim_sgr0(TERMTYPE *tp)
+{
+ char *result = exit_attribute_mode;
+
+ T((T_CALLED("_nc_trim_sgr0()")));
+
+ if (PRESENT(exit_attribute_mode)
+ && PRESENT(set_attributes)) {
+ bool found = FALSE;
+ char *on = set_attribute_9(tp, 1);
+ char *off = set_attribute_9(tp, 0);
+ char *end = strdup(exit_attribute_mode);
+ char *tmp;
+ size_t i, j, k;
+
+ TR(TRACE_DATABASE, ("checking if we can trim sgr0 based on sgr"));
+ TR(TRACE_DATABASE, ("sgr0 %s", _nc_visbuf(end)));
+ TR(TRACE_DATABASE, ("sgr(9:off) %s", _nc_visbuf(off)));
+ TR(TRACE_DATABASE, ("sgr(9:on) %s", _nc_visbuf(on)));
+
+ if (!rewrite_sgr(on, enter_alt_charset_mode)
+ || !rewrite_sgr(off, exit_alt_charset_mode)
+ || !rewrite_sgr(end, exit_alt_charset_mode)) {
+ FreeIfNeeded(off);
+ } else if (similar_sgr(off, end)
+ && !similar_sgr(off, on)) {
+ TR(TRACE_DATABASE, ("adjusting sgr(9:off) : %s", _nc_visbuf(off)));
+ result = off;
+ /*
+ * If rmacs is a substring of sgr(0), remove that chunk.
+ */
+ if (exit_alt_charset_mode != 0) {
+ TR(TRACE_DATABASE, ("scan for rmacs %s", _nc_visbuf(exit_alt_charset_mode)));
+ j = strlen(off);
+ k = strlen(exit_alt_charset_mode);
+ if (j > k) {
+ for (i = 0; i <= (j - k); ++i) {
+ int k2 = compare_part(exit_alt_charset_mode, off + i);
+ if (k2 != 0) {
+ found = TRUE;
+ chop_out(off, i, i + k2);
+ break;
+ }
+ }
+ }
+ }
+ /*
+ * SGR 10 would reset to normal font.
+ */
+ if (!found) {
+ if ((i = is_csi(off)) != 0
+ && off[strlen(off) - 1] == 'm') {
+ TR(TRACE_DATABASE, ("looking for SGR 10 in %s",
+ _nc_visbuf(off)));
+ tmp = skip_zero(off + i);
+ if (tmp[0] == '1'
+ && skip_zero(tmp + 1) != tmp + 1) {
+ i = tmp - off;
+ if (off[i - 1] == ';')
+ i--;
+ j = skip_zero(tmp + 1) - off;
+ i = chop_out(off, i, j);
+ found = TRUE;
+ }
+ }
+ }
+ if (!found
+ && (tmp = strstr(end, off)) != 0
+ && strcmp(end, off) != 0) {
+ i = tmp - end;
+ j = strlen(off);
+ tmp = strdup(end);
+ chop_out(tmp, i, j);
+ free(off);
+ result = tmp;
+ }
+ TR(TRACE_DATABASE, ("...adjusted sgr0 : %s", _nc_visbuf(result)));
+ if (!strcmp(result, exit_attribute_mode)) {
+ TR(TRACE_DATABASE, ("...same result, discard"));
+ free(result);
+ result = exit_attribute_mode;
+ }
+ } else {
+ /*
+ * Either the sgr does not reference alternate character set,
+ * or it is incorrect. That's too hard to decide right now.
+ */
+ free(off);
+ }
+ FreeIfNeeded(end);
+ FreeIfNeeded(on);
+ } else {
+ /*
+ * Possibly some applications are confused if sgr0 contains rmacs,
+ * but that would be a different bug report -TD
+ */
+ }
+
+ returnPtr(result);
+}
diff --git a/lib/libcurses/tinfo/use_screen.c b/lib/libcurses/tinfo/use_screen.c
new file mode 100644
index 00000000000..2d79e734601
--- /dev/null
+++ b/lib/libcurses/tinfo/use_screen.c
@@ -0,0 +1,60 @@
+/* $OpenBSD: use_screen.c,v 1.1 2010/01/12 23:22:06 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2007,2008 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2007 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: use_screen.c,v 1.1 2010/01/12 23:22:06 nicm Exp $")
+
+NCURSES_EXPORT(int)
+use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data)
+{
+ SCREEN *save_SP;
+ int code = OK;
+
+ T((T_CALLED("use_screen(%p,%p,%p)"), screen, func, data));
+
+ /*
+ * FIXME - add a flag so a given thread can check if _it_ has already
+ * recurred through this point, return an error if so.
+ */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ set_term(screen);
+
+ code = func(screen, data);
+
+ set_term(save_SP);
+ _nc_unlock_global(curses);
+ returnCode(code);
+}
diff --git a/lib/libcurses/tinfo/write_entry.c b/lib/libcurses/tinfo/write_entry.c
index 9aff48b5ef0..4f28313b905 100644
--- a/lib/libcurses/tinfo/write_entry.c
+++ b/lib/libcurses/tinfo/write_entry.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: write_entry.c,v 1.12 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: write_entry.c,v 1.13 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -38,6 +39,7 @@
*/
#include <curses.priv.h>
+#include <hashed_db.h>
#include <sys/stat.h>
@@ -48,21 +50,27 @@
#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR)
#endif
-#if 0
+#if 1
#define TRACE_OUT(p) DEBUG(2, p)
#else
#define TRACE_OUT(p) /*nothing */
#endif
-MODULE_ID("$From: write_entry.c,v 1.56 2000/12/10 02:55:08 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.13 2010/01/12 23:22:06 nicm Exp $")
static int total_written;
-static int write_object(FILE *, TERMTYPE *);
+static int make_db_root(const char *);
+static int write_object(TERMTYPE *, char *, unsigned *, unsigned);
+#if !USE_HASHED_DB
static void
-write_file(char *filename, TERMTYPE * tp)
+write_file(char *filename, TERMTYPE *tp)
{
+ char buffer[MAX_ENTRY_SIZE];
+ unsigned limit = sizeof(buffer);
+ unsigned offset = 0;
+
FILE *fp = (_nc_access(filename, W_OK) == 0) ? fopen(filename, "wb") : 0;
if (fp == 0) {
perror(filename);
@@ -70,49 +78,117 @@ write_file(char *filename, TERMTYPE * tp)
}
DEBUG(1, ("Created %s", filename));
- if (write_object(fp, tp) == ERR) {
+ if (write_object(tp, buffer, &offset, limit) == ERR
+ || fwrite(buffer, sizeof(char), offset, fp) != offset) {
_nc_syserr_abort("error writing %s/%s", _nc_tic_dir(0), filename);
}
+
fclose(fp);
}
/*
- * make_directory(char *path)
+ * Check for access rights to destination directories
+ * Create any directories which don't exist.
*
- * Make a directory if it doesn't exist.
+ * Note: there's no reason to return the result of make_db_root(), since
+ * this function is called only in instances where that has to succeed.
*/
+static void
+check_writeable(int code)
+{
+ static const char dirnames[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ static bool verified[sizeof(dirnames)];
+
+ char dir[sizeof(LEAF_FMT)];
+ char *s = 0;
+
+ if (code == 0 || (s = strchr(dirnames, code)) == 0)
+ _nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", code);
+
+ if (verified[s - dirnames])
+ return;
+
+ snprintf(dir, sizeof(dir), LEAF_FMT, code);
+ if (make_db_root(dir) < 0) {
+ _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
+ }
+
+ verified[s - dirnames] = TRUE;
+}
+#endif /* !USE_HASHED_DB */
+
static int
-make_directory(const char *path)
+make_db_path(char *dst, const char *src, unsigned limit)
{
- int rc;
- struct stat statbuf;
- char fullpath[PATH_MAX];
- const char *destination = _nc_tic_dir(0);
+ int rc = -1;
+ const char *top = _nc_tic_dir(0);
- if (path == destination || *path == '/') {
- if (strlcpy(fullpath, path, sizeof(fullpath)) >= sizeof(fullpath))
- return (-1);
+ if (src == top || _nc_is_abs_path(src)) {
+ if (strlen(src) + 1 <= limit) {
+ (void) strlcpy(dst, src, limit);
+ rc = 0;
+ }
} else {
- if (strlen(destination) + strlen(path) + 2 > sizeof(fullpath))
- return (-1);
- (void) snprintf(fullpath, sizeof(fullpath), "%s/%s", destination, path);
+ if (strlen(top) + strlen(src) + 2 <= limit) {
+ (void) snprintf(dst, limit, "%s/%s", top, src);
+ rc = 0;
+ }
+ }
+#if USE_HASHED_DB
+ if (rc == 0) {
+ if (_nc_is_dir_path(dst)) {
+ rc = -1;
+ } else {
+ unsigned have = strlen(dst);
+ if (have > 3 && strcmp(dst + have - 3, DBM_SUFFIX)) {
+ if (have + 3 <= limit)
+ strlcat(dst, DBM_SUFFIX, limit);
+ else
+ rc = -1;
+ }
+ }
}
+#endif
+ return rc;
+}
- if ((rc = stat(path, &statbuf)) < 0) {
- rc = mkdir(path, 0777);
- } else {
- if (_nc_access(path, R_OK | W_OK | X_OK) < 0) {
+/*
+ * Make a database-root if it doesn't exist.
+ */
+static int
+make_db_root(const char *path)
+{
+ int rc;
+ char fullpath[PATH_MAX];
+
+ if ((rc = make_db_path(fullpath, path, sizeof(fullpath))) == 0) {
+#if USE_HASHED_DB
+ DB *capdbp;
+
+ if ((capdbp = _nc_db_open(fullpath, TRUE)) == NULL)
+ rc = -1;
+ else if (_nc_db_close(capdbp) < 0)
+ rc = -1;
+#else
+ struct stat statbuf;
+
+ if ((rc = stat(path, &statbuf)) < 0) {
+ rc = mkdir(path, 0777);
+ } else if (_nc_access(path, R_OK | W_OK | X_OK) < 0) {
rc = -1; /* permission denied */
} else if (!(S_ISDIR(statbuf.st_mode))) {
rc = -1; /* not a directory */
}
+#endif
}
return rc;
}
+/*
+ * Set the write directory for compiled entries.
+ */
NCURSES_EXPORT(void)
_nc_set_writedir(char *dir)
-/* set the write directory for compiled entries */
{
const char *destination;
char actual[PATH_MAX];
@@ -125,12 +201,12 @@ _nc_set_writedir(char *dir)
(void) _nc_tic_dir(dir);
destination = _nc_tic_dir(0);
- if (make_directory(destination) < 0) {
+ if (make_db_root(destination) < 0) {
char *home = _nc_home_terminfo();
if (home != 0) {
destination = home;
- if (make_directory(destination) < 0)
+ if (make_db_root(destination) < 0)
_nc_err_abort("%s: permission denied (errno %d)",
destination, errno);
}
@@ -140,51 +216,17 @@ _nc_set_writedir(char *dir)
* Note: because of this code, this logic should be exercised
* *once only* per run.
*/
+#if USE_HASHED_DB
+ make_db_path(actual, destination, sizeof(actual));
+#else
if (chdir(_nc_tic_dir(destination)) < 0
|| getcwd(actual, sizeof(actual)) == 0)
_nc_err_abort("%s: not a directory", destination);
+#endif
_nc_keep_tic_dir(strdup(actual));
}
/*
- * check_writeable(char code)
- *
- * Miscellaneous initialisations
- *
- * Check for access rights to destination directories
- * Create any directories which don't exist.
- * Note: there's no reason to return the result of make_directory(), since
- * this function is called only in instances where that has to succeed.
- *
- */
-
-static void
-check_writeable(int code)
-{
- static const char dirnames[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- static bool verified[sizeof(dirnames)];
-
- char dir[2];
- char *s = 0;
-
- if (code == 0 || (s = strchr(dirnames, code)) == 0)
- _nc_err_abort("Illegal terminfo subdirectory \"%c\"", code);
-
- if (verified[s - dirnames])
- return;
-
- dir[0] = code;
- dir[1] = '\0';
- if (make_directory(dir) < 0) {
- _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(0), dir);
- }
-
- verified[s - dirnames] = TRUE;
-}
-
-/*
- * _nc_write_entry()
- *
* Save the compiled version of a description in the filesystem.
*
* make a copy of the name-list
@@ -204,24 +246,39 @@ check_writeable(int code)
* _nc_curr_line is properly set before the write_entry() call.
*/
-void
-_nc_write_entry(TERMTYPE * const tp)
+NCURSES_EXPORT(void)
+_nc_write_entry(TERMTYPE *const tp)
{
+#if USE_HASHED_DB
+
+ char buffer[MAX_ENTRY_SIZE + 1];
+ unsigned limit = sizeof(buffer);
+ unsigned offset = 0;
+
+#else /* !USE_HASHED_DB */
+
struct stat statbuf;
- char name_list[MAX_TERMINFO_LENGTH];
- char *first_name, *other_names;
- char *ptr;
char filename[PATH_MAX];
char linkname[PATH_MAX];
#if USE_SYMLINKS
char symlinkname[PATH_MAX];
+#if !HAVE_LINK
+#undef HAVE_LINK
+#define HAVE_LINK 1
+#endif
#endif /* USE_SYMLINKS */
+
static int call_count;
static time_t start_time; /* time at start of writes */
- if (call_count++ == 0) {
- start_time = 0;
- }
+#endif /* USE_HASHED_DB */
+
+ char name_list[MAX_TERMINFO_LENGTH];
+ char *first_name, *other_names;
+ char *ptr;
+
+ assert(strlen(tp->term_names) != 0);
+ assert(strlen(tp->term_names) < sizeof(name_list));
(void) strlcpy(name_list, tp->term_names, sizeof(name_list));
DEBUG(7, ("Name list = '%s'", name_list));
@@ -253,10 +310,59 @@ _nc_write_entry(TERMTYPE * const tp)
_nc_set_type(first_name);
- if (strlen(first_name) > sizeof(filename) - 3)
+#if USE_HASHED_DB
+ if (write_object(tp, buffer + 1, &offset, limit - 1) != ERR) {
+ DB *capdb = _nc_db_open(_nc_tic_dir(0), TRUE);
+ DBT key, data;
+
+ if (capdb != 0) {
+ buffer[0] = 0;
+
+ memset(&key, 0, sizeof(key));
+ key.data = tp->term_names;
+ key.size = strlen(tp->term_names);
+
+ memset(&data, 0, sizeof(data));
+ data.data = buffer;
+ data.size = offset + 1;
+
+ _nc_db_put(capdb, &key, &data);
+
+ buffer[0] = 2;
+
+ key.data = name_list;
+ key.size = strlen(name_list);
+
+ strlcpy(buffer + 1, tp->term_names, sizeof(buffer) - 1);
+ data.size = strlen(tp->term_names) + 1;
+
+ _nc_db_put(capdb, &key, &data);
+
+ while (*other_names != '\0') {
+ ptr = other_names++;
+ while (*other_names != '|' && *other_names != '\0')
+ other_names++;
+
+ if (*other_names != '\0')
+ *(other_names++) = '\0';
+
+ key.data = ptr;
+ key.size = strlen(ptr);
+
+ _nc_db_put(capdb, &key, &data);
+ }
+ _nc_db_close(capdb);
+ }
+ }
+#else /* !USE_HASHED_DB */
+ if (call_count++ == 0) {
+ start_time = 0;
+ }
+
+ if (strlen(first_name) >= sizeof(filename) - 3)
_nc_warning("terminal name too long.");
- snprintf(filename, sizeof(filename), "%c/%s", first_name[0], first_name);
+ snprintf(filename, sizeof(filename), LEAF_FMT "/%s", first_name[0], first_name);
/*
* Has this primary name been written since the first call to
@@ -281,6 +387,7 @@ _nc_write_entry(TERMTYPE * const tp)
}
while (*other_names != '\0') {
ptr = other_names++;
+ assert(ptr < buffer + sizeof(buffer) - 1);
while (*other_names != '|' && *other_names != '\0')
other_names++;
@@ -297,7 +404,7 @@ _nc_write_entry(TERMTYPE * const tp)
}
check_writeable(ptr[0]);
- snprintf(linkname, sizeof(linkname), "%c/%s", ptr[0], ptr);
+ snprintf(linkname, sizeof(linkname), LEAF_FMT "/%s", ptr[0], ptr);
if (strcmp(filename, linkname) == 0) {
_nc_warning("self-synonym ignored");
@@ -309,8 +416,8 @@ _nc_write_entry(TERMTYPE * const tp)
{
int code;
#if USE_SYMLINKS
- strlcpy(symlinkname, "../", sizeof(symlinkname));
- strlcat(symlinkname, filename, sizeof(symlinkname));
+ strlcpy(symlinkname, "../", sizeof(symlinkname));
+ strlcat(symlinkname, filename, sizeof(symlinkname));
#endif /* USE_SYMLINKS */
#if HAVE_REMOVE
code = remove(linkname);
@@ -351,20 +458,45 @@ _nc_write_entry(TERMTYPE * const tp)
write_file(linkname, tp);
#endif /* HAVE_LINK */
}
+#endif /* USE_HASHED_DB */
}
+static unsigned
+fake_write(char *dst,
+ unsigned *offset,
+ unsigned limit,
+ char *src,
+ unsigned want,
+ unsigned size)
+{
+ int have = (limit - *offset);
+
+ want *= size;
+ if (have > 0) {
+ if ((int) want > have)
+ want = have;
+ memcpy(dst + *offset, src, want);
+ *offset += want;
+ } else {
+ want = 0;
+ }
+ return (int) (want / size);
+}
+
+#define Write(buf, size, count) fake_write(buffer, offset, limit, (char *) buf, count, size)
+
#undef LITTLE_ENDIAN /* BSD/OS defines this as a feature macro */
#define HI(x) ((x) / 256)
#define LO(x) ((x) % 256)
#define LITTLE_ENDIAN(p, x) (p)[0] = LO(x), (p)[1] = HI(x)
-#define WRITE_STRING(str) (fwrite(str, sizeof(char), strlen(str) + 1, fp) == strlen(str) + 1)
+#define WRITE_STRING(str) (Write(str, sizeof(char), strlen(str) + 1) == strlen(str) + 1)
static int
-compute_offsets(char **Strings, int strmax, short *offsets)
+compute_offsets(char **Strings, unsigned strmax, short *offsets)
{
size_t nextfree = 0;
- int i;
+ unsigned i;
for (i = 0; i < strmax; i++) {
if (Strings[i] == ABSENT_STRING) {
@@ -374,16 +506,17 @@ compute_offsets(char **Strings, int strmax, short *offsets)
} else {
offsets[i] = nextfree;
nextfree += strlen(Strings[i]) + 1;
- TRACE_OUT(("put Strings[%d]=%s(%d)", i, _nc_visbuf(Strings[i]), nextfree));
+ TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i,
+ _nc_visbuf(Strings[i]), (int) nextfree));
}
}
return nextfree;
}
static void
-convert_shorts(unsigned char *buf, short *Numbers, int count)
+convert_shorts(unsigned char *buf, short *Numbers, unsigned count)
{
- int i;
+ unsigned i;
for (i = 0; i < count; i++) {
if (Numbers[i] == ABSENT_NUMERIC) { /* HI/LO won't work */
buf[2 * i] = buf[2 * i + 1] = 0377;
@@ -398,10 +531,68 @@ convert_shorts(unsigned char *buf, short *Numbers, int count)
}
#define even_boundary(value) \
- ((value) % 2 != 0 && fwrite(&zero, sizeof(char), 1, fp) != 1)
+ ((value) % 2 != 0 && Write(&zero, sizeof(char), 1) != 1)
+
+#if NCURSES_XNAMES
+static unsigned
+extended_Booleans(TERMTYPE *tp)
+{
+ unsigned short result = 0;
+ unsigned short i;
+
+ for (i = 0; i < tp->ext_Booleans; ++i) {
+ if (tp->Booleans[BOOLCOUNT + i] == TRUE)
+ result = (i + 1);
+ }
+ return result;
+}
+
+static unsigned
+extended_Numbers(TERMTYPE *tp)
+{
+ unsigned short result = 0;
+ unsigned short i;
+
+ for (i = 0; i < tp->ext_Numbers; ++i) {
+ if (tp->Numbers[NUMCOUNT + i] != ABSENT_NUMERIC)
+ result = (i + 1);
+ }
+ return result;
+}
+
+static unsigned
+extended_Strings(TERMTYPE *tp)
+{
+ unsigned short result = 0;
+ unsigned short i;
+
+ for (i = 0; i < tp->ext_Strings; ++i) {
+ if (tp->Strings[STRCOUNT + i] != ABSENT_STRING)
+ result = (i + 1);
+ }
+ return result;
+}
+
+/*
+ * _nc_align_termtype() will extend entries that are referenced in a use=
+ * clause - discard the unneeded data.
+ */
+static bool
+extended_object(TERMTYPE *tp)
+{
+ bool result = FALSE;
+
+ if (_nc_user_definable) {
+ result = ((extended_Booleans(tp)
+ + extended_Numbers(tp)
+ + extended_Strings(tp)) != 0);
+ }
+ return result;
+}
+#endif
static int
-write_object(FILE * fp, TERMTYPE * tp)
+write_object(TERMTYPE *tp, char *buffer, unsigned *offset, unsigned limit)
{
char *namelist;
size_t namelen, boolmax, nummax, strmax;
@@ -460,9 +651,9 @@ write_object(FILE * fp, TERMTYPE * tp)
LITTLE_ENDIAN(buf + 10, nextfree);
/* write out the header */
- TRACE_OUT(("Header of %s @%ld", namelist, ftell(fp)));
- if (fwrite(buf, 12, 1, fp) != 1
- || fwrite(namelist, sizeof(char), namelen, fp) != namelen)
+ TRACE_OUT(("Header of %s @%d", namelist, *offset));
+ if (Write(buf, 12, 1) != 1
+ || Write(namelist, sizeof(char), namelen) != namelen)
return (ERR);
for (i = 0; i < boolmax; i++)
@@ -470,27 +661,27 @@ write_object(FILE * fp, TERMTYPE * tp)
buf[i] = TRUE;
else
buf[i] = FALSE;
- if (fwrite(buf, sizeof(char), boolmax, fp) != boolmax)
+ if (Write(buf, sizeof(char), boolmax) != boolmax)
return (ERR);
if (even_boundary(namelen + boolmax))
return (ERR);
- TRACE_OUT(("Numerics begin at %04lx", ftell(fp)));
+ TRACE_OUT(("Numerics begin at %04x", *offset));
/* the numerics */
convert_shorts(buf, tp->Numbers, nummax);
- if (fwrite(buf, 2, nummax, fp) != nummax)
+ if (Write(buf, 2, nummax) != nummax)
return (ERR);
- TRACE_OUT(("String offsets begin at %04lx", ftell(fp)));
+ TRACE_OUT(("String offsets begin at %04x", *offset));
/* the string offsets */
convert_shorts(buf, offsets, strmax);
- if (fwrite(buf, 2, strmax, fp) != strmax)
+ if (Write(buf, 2, strmax) != strmax)
return (ERR);
- TRACE_OUT(("String table begins at %04lx", ftell(fp)));
+ TRACE_OUT(("String table begins at %04x", *offset));
/* the strings */
for (i = 0; i < strmax; i++)
@@ -499,15 +690,23 @@ write_object(FILE * fp, TERMTYPE * tp)
return (ERR);
#if NCURSES_XNAMES
- if (NUM_EXT_NAMES(tp)) {
+ if (extended_object(tp)) {
unsigned extcnt = NUM_EXT_NAMES(tp);
if (even_boundary(nextfree))
return (ERR);
- nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets);
+ nextfree = compute_offsets(tp->Strings + STRCOUNT,
+ tp->ext_Strings,
+ offsets);
TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
- nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings);
+
+ if (tp->ext_Strings >= SIZEOF(offsets))
+ return (ERR);
+
+ nextfree += compute_offsets(tp->ext_Names,
+ extcnt,
+ offsets + tp->ext_Strings);
TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
strmax = tp->ext_Strings + extcnt;
@@ -519,23 +718,23 @@ write_object(FILE * fp, TERMTYPE * tp)
LITTLE_ENDIAN(buf + 4, tp->ext_Strings);
LITTLE_ENDIAN(buf + 6, strmax);
LITTLE_ENDIAN(buf + 8, nextfree);
- TRACE_OUT(("WRITE extended-header @%ld", ftell(fp)));
- if (fwrite(buf, 10, 1, fp) != 1)
+ TRACE_OUT(("WRITE extended-header @%d", *offset));
+ if (Write(buf, 10, 1) != 1)
return (ERR);
- TRACE_OUT(("WRITE %d booleans @%ld", tp->ext_Booleans, ftell(fp)));
+ TRACE_OUT(("WRITE %d booleans @%d", tp->ext_Booleans, *offset));
if (tp->ext_Booleans
- && fwrite(tp->Booleans + BOOLCOUNT, sizeof(char),
- tp->ext_Booleans, fp) != tp->ext_Booleans)
+ && Write(tp->Booleans + BOOLCOUNT, sizeof(char),
+ tp->ext_Booleans) != tp->ext_Booleans)
return (ERR);
if (even_boundary(tp->ext_Booleans))
return (ERR);
- TRACE_OUT(("WRITE %d numbers @%ld", tp->ext_Numbers, ftell(fp)));
+ TRACE_OUT(("WRITE %d numbers @%d", tp->ext_Numbers, *offset));
if (tp->ext_Numbers) {
convert_shorts(buf, tp->Numbers + NUMCOUNT, tp->ext_Numbers);
- if (fwrite(buf, 2, tp->ext_Numbers, fp) != tp->ext_Numbers)
+ if (Write(buf, 2, tp->ext_Numbers) != tp->ext_Numbers)
return (ERR);
}
@@ -544,8 +743,8 @@ write_object(FILE * fp, TERMTYPE * tp)
* in that order.
*/
convert_shorts(buf, offsets, strmax);
- TRACE_OUT(("WRITE offsets @%ld", ftell(fp)));
- if (fwrite(buf, 2, strmax, fp) != strmax)
+ TRACE_OUT(("WRITE offsets @%d", *offset));
+ if (Write(buf, 2, strmax) != strmax)
return (ERR);
/*
@@ -554,7 +753,7 @@ write_object(FILE * fp, TERMTYPE * tp)
*/
for (i = 0; i < tp->ext_Strings; i++) {
if (VALID_STRING(tp->Strings[i + STRCOUNT])) {
- TRACE_OUT(("WRITE ext_Strings[%d]=%s", i,
+ TRACE_OUT(("WRITE ext_Strings[%d]=%s", (int) i,
_nc_visbuf(tp->Strings[i + STRCOUNT])));
if (!WRITE_STRING(tp->Strings[i + STRCOUNT]))
return (ERR);
@@ -565,7 +764,7 @@ write_object(FILE * fp, TERMTYPE * tp)
* Write the extended names
*/
for (i = 0; i < extcnt; i++) {
- TRACE_OUT(("WRITE ext_Names[%d]=%s", i, tp->ext_Names[i]));
+ TRACE_OUT(("WRITE ext_Names[%d]=%s", (int) i, tp->ext_Names[i]));
if (!WRITE_STRING(tp->ext_Names[i]))
return (ERR);
}
diff --git a/lib/libcurses/trace/lib_trace.c b/lib/libcurses/trace/lib_trace.c
index 2089f0e4977..ed8d45dd9e7 100644
--- a/lib/libcurses/trace/lib_trace.c
+++ b/lib/libcurses/trace/lib_trace.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_trace.c,v 1.7 2003/03/17 19:16:59 millert Exp $ */
+/* $OpenBSD: lib_trace.c,v 1.8 2010/01/12 23:22:06 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,10 +31,16 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
* lib_trace.c - Tracing/Debugging routines
+ *
+ * The _tracef() function is originally from pcurses (by Pavel Curtis) in 1982.
+ * pcurses allowed one to enable/disable tracing using traceon() and traceoff()
+ * functions. ncurses provides a trace() function which allows one to
+ * selectively enable or disable several tracing features.
*/
#include <curses.priv.h>
@@ -42,32 +48,73 @@
#include <ctype.h>
-MODULE_ID("$From: lib_trace.c,v 1.38 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.8 2010/01/12 23:22:06 nicm Exp $")
-NCURSES_EXPORT_VAR(unsigned)
-_nc_tracing = 0; /* always define this */
+NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
#ifdef TRACE
-NCURSES_EXPORT_VAR(const char *)
-_nc_tputs_trace = "";
-NCURSES_EXPORT_VAR(long)
-_nc_outchars = 0;
- static FILE *tracefp; /* default to writing to stderr */
+#if USE_REENTRANT
+NCURSES_EXPORT(const char *)
+NCURSES_PUBLIC_VAR(_nc_tputs_trace) (void)
+{
+ return SP ? SP->_tputs_trace : _nc_prescreen._tputs_trace;
+}
+NCURSES_EXPORT(long)
+NCURSES_PUBLIC_VAR(_nc_outchars) (void)
+{
+ return SP ? SP->_outchars : _nc_prescreen._outchars;
+}
+NCURSES_EXPORT(void)
+_nc_set_tputs_trace(const char *s)
+{
+ if (SP)
+ SP->_tputs_trace = s;
+ else
+ _nc_prescreen._tputs_trace = s;
+}
+NCURSES_EXPORT(void)
+_nc_count_outchars(long increment)
+{
+ if (SP)
+ SP->_outchars += increment;
+ else
+ _nc_prescreen._outchars += increment;
+}
+#else
+NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace = "";
+NCURSES_EXPORT_VAR(long) _nc_outchars = 0;
+#endif
+
+#define TraceFP _nc_globals.trace_fp
+#define TracePath _nc_globals.trace_fname
+#define TraceLevel _nc_globals.trace_level
NCURSES_EXPORT(void)
-trace(const unsigned int tracelevel GCC_UNUSED)
+trace(const unsigned int tracelevel)
{
- static bool been_here = FALSE;
- static char my_name[] = "trace";
+ if ((TraceFP == 0) && tracelevel) {
+ const char *mode = _nc_globals.init_trace ? "ab" : "wb";
- _nc_tracing = tracelevel;
- if (!been_here && tracelevel) {
- been_here = TRUE;
+ if (TracePath[0] == '\0') {
+ int size = sizeof(TracePath) - 12;
+ if (getcwd(TracePath, size) == 0) {
+ perror("curses: Can't get working directory");
+ exit(EXIT_FAILURE);
+ }
+ TracePath[size] = '\0';
+ assert(strlen(TracePath) <= size);
+ strlcat(TracePath, "/trace", sizeof(TracePath));
+ if (_nc_is_dir_path(TracePath)) {
+ strlcat(TracePath, ".log", sizeof(TracePath));
+ }
+ }
- if (_nc_access(my_name, W_OK) < 0
- || (tracefp = fopen(my_name, "wb")) == 0) {
- perror("curses: Can't open 'trace' file: ");
+ _nc_globals.init_trace = TRUE;
+ _nc_tracing = tracelevel;
+ if (_nc_access(TracePath, W_OK) < 0
+ || (TraceFP = fopen(TracePath, mode)) == 0) {
+ perror("curses: Can't open 'trace' file");
exit(EXIT_FAILURE);
}
/* Try to set line-buffered mode, or (failing that) unbuffered,
@@ -75,100 +122,46 @@ trace(const unsigned int tracelevel GCC_UNUSED)
* end of each line. This is useful in case the program dies.
*/
#if HAVE_SETVBUF /* ANSI */
- (void) setvbuf(tracefp, (char *) 0, _IOLBF, 0);
+ (void) setvbuf(TraceFP, (char *) 0, _IOLBF, 0);
#elif HAVE_SETBUF /* POSIX */
- (void) setbuffer(tracefp, (char *) 0);
-#endif
- _tracef("TRACING NCURSES version %s", curses_version());
- }
-}
-#endif
-
-NCURSES_EXPORT(const char *)
-_nc_visbuf2(int bufnum, const char *buf)
-/* visibilize a given string */
-{
- size_t vbsize;
- char *vbuf;
- char *tp;
- int c;
-
- if (buf == 0)
- return ("(null)");
- if (buf == CANCELLED_STRING)
- return ("(cancelled)");
-
- vbsize = (strlen(buf) * 4) + 5;
-#ifdef TRACE
- tp = vbuf = _nc_trace_buf(bufnum, vbsize);
-#else
- {
- static char *mybuf[2];
- mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], vbsize);
- tp = vbuf = mybuf[bufnum];
- }
+ (void) setbuffer(TraceFP, (char *) 0);
#endif
- *tp++ = '"';
- while ((c = *buf++) != '\0') {
- if (c == '"') {
- *tp++ = '\\';
- *tp++ = '"';
- } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
- *tp++ = c;
- } else if (c == '\n') {
- *tp++ = '\\';
- *tp++ = 'n';
- } else if (c == '\r') {
- *tp++ = '\\';
- *tp++ = 'r';
- } else if (c == '\b') {
- *tp++ = '\\';
- *tp++ = 'b';
- } else if (c == '\033') {
- *tp++ = '\\';
- *tp++ = 'e';
- } else if (is7bits(c) && iscntrl(c)) {
- *tp++ = '\\';
- *tp++ = '^';
- *tp++ = '@' + c;
- } else {
- snprintf(tp, vbsize - (tp - vbuf), "\\%03o", CharOf(c));
- tp += strlen(tp);
+ _tracef("TRACING NCURSES version %s.%d (tracelevel=%#x)",
+ NCURSES_VERSION,
+ NCURSES_VERSION_PATCH,
+ tracelevel);
+ } else if (tracelevel == 0) {
+ if (TraceFP != 0) {
+ fclose(TraceFP);
+ TraceFP = 0;
}
+ _nc_tracing = tracelevel;
+ } else if (_nc_tracing != tracelevel) {
+ _nc_tracing = tracelevel;
+ _tracef("tracelevel=%#x", tracelevel);
}
- *tp++ = '"';
- *tp++ = '\0';
- return (vbuf);
-}
-
-NCURSES_EXPORT(const char *)
-_nc_visbuf(const char *buf)
-{
- return _nc_visbuf2(0, buf);
}
-#ifdef TRACE
-NCURSES_EXPORT(void)
-_tracef(const char *fmt,...)
+static void
+_nc_va_tracef(const char *fmt, va_list ap)
{
static const char Called[] = T_CALLED("");
static const char Return[] = T_RETURN("");
- static int level;
- va_list ap;
+
bool before = FALSE;
bool after = FALSE;
- int doit = _nc_tracing;
+ unsigned doit = _nc_tracing;
int save_err = errno;
if (strlen(fmt) >= sizeof(Called) - 1) {
if (!strncmp(fmt, Called, sizeof(Called) - 1)) {
before = TRUE;
- level++;
+ TraceLevel++;
} else if (!strncmp(fmt, Return, sizeof(Return) - 1)) {
after = TRUE;
}
if (before || after) {
- if ((level <= 1)
+ if ((TraceLevel <= 1)
|| (doit & TRACE_ICALLS) != 0)
doit &= (TRACE_CALLS | TRACE_CCALLS);
else
@@ -177,25 +170,57 @@ _tracef(const char *fmt,...)
}
if (doit != 0) {
- if (tracefp == 0)
- tracefp = stderr;
+ if (TraceFP == 0)
+ TraceFP = stderr;
+#ifdef USE_PTHREADS
+ /*
+ * TRACE_ICALLS is "really" needed to show normal use with threaded
+ * applications, since anything can be running during a napms(),
+ * making it appear in the hierarchical trace as it other functions
+ * are being called.
+ *
+ * Rather than add the complication of a per-thread stack, just
+ * show the thread-id in each line of the trace.
+ */
+# if USE_WEAK_SYMBOLS
+ if ((pthread_self))
+# endif
+ fprintf(TraceFP, "%#lx:", (long) (void *) pthread_self());
+#endif
if (before || after) {
int n;
- for (n = 1; n < level; n++)
- fputs("+ ", tracefp);
+ for (n = 1; n < TraceLevel; n++)
+ fputs("+ ", TraceFP);
}
- va_start(ap, fmt);
- vfprintf(tracefp, fmt, ap);
- fputc('\n', tracefp);
- va_end(ap);
- fflush(tracefp);
+ vfprintf(TraceFP, fmt, ap);
+ fputc('\n', TraceFP);
+ fflush(TraceFP);
}
- if (after && level)
- level--;
+ if (after && TraceLevel)
+ TraceLevel--;
+
errno = save_err;
}
+NCURSES_EXPORT(void)
+_tracef(const char *fmt,...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ _nc_va_tracef(fmt, ap);
+ va_end(ap);
+}
+
+/* Trace 'bool' return-values */
+NCURSES_EXPORT(NCURSES_BOOL)
+_nc_retrace_bool(NCURSES_BOOL code)
+{
+ T((T_RETURN("%s"), code ? "TRUE" : "FALSE"));
+ return code;
+}
+
/* Trace 'int' return-values */
NCURSES_EXPORT(int)
_nc_retrace_int(int code)
@@ -204,6 +229,14 @@ _nc_retrace_int(int code)
return code;
}
+/* Trace 'unsigned' return-values */
+NCURSES_EXPORT(unsigned)
+_nc_retrace_unsigned(unsigned code)
+{
+ T((T_RETURN("%#x"), code));
+ return code;
+}
+
/* Trace 'char*' return-values */
NCURSES_EXPORT(char *)
_nc_retrace_ptr(char *code)
@@ -212,6 +245,38 @@ _nc_retrace_ptr(char *code)
return code;
}
+/* Trace 'const char*' return-values */
+NCURSES_EXPORT(const char *)
+_nc_retrace_cptr(const char *code)
+{
+ T((T_RETURN("%s"), _nc_visbuf(code)));
+ return code;
+}
+
+/* Trace 'NCURSES_CONST void*' return-values */
+NCURSES_EXPORT(NCURSES_CONST void *)
+_nc_retrace_cvoid_ptr(NCURSES_CONST void *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
+/* Trace 'void*' return-values */
+NCURSES_EXPORT(void *)
+_nc_retrace_void_ptr(void *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
+/* Trace 'SCREEN *' return-values */
+NCURSES_EXPORT(SCREEN *)
+_nc_retrace_sp(SCREEN *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
/* Trace 'WINDOW *' return-values */
NCURSES_EXPORT(WINDOW *)
_nc_retrace_win(WINDOW *code)
@@ -219,4 +284,53 @@ _nc_retrace_win(WINDOW *code)
T((T_RETURN("%p"), code));
return code;
}
+
+#if USE_REENTRANT
+/*
+ * Check if the given trace-mask is enabled.
+ *
+ * This function may be called from within one of the functions that fills
+ * in parameters for _tracef(), but in that case we do not want to lock the
+ * mutex, since it is already locked.
+ */
+NCURSES_EXPORT(int)
+_nc_use_tracef(unsigned mask)
+{
+ bool result = FALSE;
+
+ _nc_lock_global(tst_tracef);
+ if (!_nc_globals.nested_tracef++) {
+ if ((result = (_nc_tracing & (mask))) != 0
+ && _nc_try_global(tracef) == 0) {
+ /* we will call _nc_locked_tracef(), no nesting so far */
+ } else {
+ /* we will not call _nc_locked_tracef() */
+ _nc_globals.nested_tracef = 0;
+ }
+ } else {
+ /* we may call _nc_locked_tracef(), but with nested_tracef > 0 */
+ result = (_nc_tracing & (mask));
+ }
+ _nc_unlock_global(tst_tracef);
+ return result;
+}
+
+/*
+ * We call this if _nc_use_tracef() returns true, which means we must unlock
+ * the tracef mutex.
+ */
+NCURSES_EXPORT(void)
+_nc_locked_tracef(const char *fmt,...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ _nc_va_tracef(fmt, ap);
+ va_end(ap);
+
+ if (--(_nc_globals.nested_tracef) == 0)
+ _nc_unlock_global(tracef);
+}
+#endif /* USE_REENTRANT */
+
#endif /* TRACE */
diff --git a/lib/libcurses/trace/lib_traceatr.c b/lib/libcurses/trace/lib_traceatr.c
index e1b813bc3d9..34b65f3d7eb 100644
--- a/lib/libcurses/trace/lib_traceatr.c
+++ b/lib/libcurses/trace/lib_traceatr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_traceatr.c,v 1.5 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_traceatr.c,v 1.6 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * Author: Thomas Dickey 1996-on *
+ * and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -40,16 +41,42 @@
#include <curses.priv.h>
#include <term.h> /* acs_chars */
-MODULE_ID("$From: lib_traceatr.c,v 1.32 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
-#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
+#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
#ifdef TRACE
+
+static const char l_brace[] = StringOf(L_BRACE);
+static const char r_brace[] = StringOf(R_BRACE);
+
+#ifndef USE_TERMLIB
+
+#define my_buffer _nc_globals.traceatr_color_buf
+#define my_select _nc_globals.traceatr_color_sel
+#define my_cached _nc_globals.traceatr_color_last
+
+static char *
+color_of(int c)
+{
+ if (c != my_cached) {
+ my_cached = c;
+ my_select = !my_select;
+ if (c == COLOR_DEFAULT)
+ strlcpy(my_buffer[my_select], "default", _nc_globals_traceatr_color_buf_size);
+ else
+ snprintf(my_buffer[my_select], _nc_globals_traceatr_color_buf_size, "color%d", c);
+ }
+ return my_buffer[my_select];
+}
+
+#undef my_buffer
+#undef my_select
+#endif /* !USE_TERMLIB */
+
NCURSES_EXPORT(char *)
-_traceattr2(int bufnum, attr_t newmode)
+_traceattr2(int bufnum, chtype newmode)
{
- char *buf = _nc_trace_buf(bufnum, BUFSIZ);
- char *tmp = buf;
static const struct {
unsigned int val;
const char *name;
@@ -70,7 +97,9 @@ _traceattr2(int bufnum, attr_t newmode)
{ A_COLOR, "A_COLOR" },
/* *INDENT-ON* */
- },
+ }
+#ifndef USE_TERMLIB
+ ,
colors[] =
{
/* *INDENT-OFF* */
@@ -84,46 +113,58 @@ _traceattr2(int bufnum, attr_t newmode)
{ COLOR_WHITE, "COLOR_WHITE" },
/* *INDENT-ON* */
- };
+ }
+#endif /* !USE_TERMLIB */
+ ;
size_t n;
- unsigned save_nc_tracing = _nc_tracing;
- _nc_tracing = 0;
-
- *tmp++ = '{';
- *tmp = '\0';
-
- for (n = 0; n < SIZEOF(names); n++) {
- if ((newmode & names[n].val) != 0) {
- if (buf[1] != '\0')
- strlcat(tmp, "|", BUFSIZ - (tmp - buf));
- strlcat(tmp, names[n].name, BUFSIZ - (tmp - buf));
- tmp += strlen(tmp);
-
- if (names[n].val == A_COLOR) {
- short pairnum = PAIR_NUMBER(newmode);
- short fg, bg;
-
- if (pair_content(pairnum, &fg, &bg) == OK)
- (void) snprintf(tmp, BUFSIZ - (tmp - buf),
- "{%d = {%s, %s}}",
- pairnum,
- COLOR_OF(fg),
- COLOR_OF(bg)
- );
- else
- (void) snprintf(tmp, BUFSIZ - (tmp - buf), "{%d}", pairnum);
+ char temp[80];
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
+
+ if (result != 0) {
+ unsigned save_nc_tracing = _nc_tracing;
+
+ _nc_tracing = 0;
+
+ strlcpy(result, l_brace, BUFSIZ);
+
+ for (n = 0; n < SIZEOF(names); n++) {
+ if ((newmode & names[n].val) != 0) {
+ if (result[1] != '\0')
+ result = _nc_trace_bufcat(bufnum, "|");
+ result = _nc_trace_bufcat(bufnum, names[n].name);
+
+ if (names[n].val == A_COLOR) {
+ short pairnum = PAIR_NUMBER(newmode);
+#ifdef USE_TERMLIB
+ /* pair_content lives in libncurses */
+ (void) snprintf(temp, sizeof(temp), "{%d}", pairnum);
+#else
+ short fg, bg;
+
+ if (pair_content(pairnum, &fg, &bg) == OK) {
+ (void) snprintf(temp, sizeof(temp),
+ "{%d = {%s, %s}}",
+ pairnum,
+ COLOR_OF(fg),
+ COLOR_OF(bg));
+ } else {
+ (void) snprintf(temp, sizeof(temp), "{%d}", pairnum);
+ }
+#endif
+ result = _nc_trace_bufcat(bufnum, temp);
+ }
}
}
- }
- if (AttrOf(newmode) == A_NORMAL) {
- if (buf[1] != '\0')
- strlcat(tmp, "|", BUFSIZ - (tmp - buf));
- strlcat(tmp, "A_NORMAL", BUFSIZ - (tmp - buf));
- }
+ if (ChAttrOf(newmode) == A_NORMAL) {
+ if (result != 0 && result[1] != '\0')
+ (void) _nc_trace_bufcat(bufnum, "|");
+ (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
+ }
- _nc_tracing = save_nc_tracing;
- strlcat(buf, "}", BUFSIZ);
- return (buf);
+ _nc_tracing = save_nc_tracing;
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ }
+ return result;
}
NCURSES_EXPORT(char *)
@@ -140,105 +181,180 @@ _nc_retrace_attr_t(attr_t code)
return code;
}
-NCURSES_EXPORT(char *)
-_tracechtype2(int bufnum, chtype ch)
+const char *
+_nc_altcharset_name(attr_t attr, chtype ch)
{
- char *buf = _nc_trace_buf(bufnum, BUFSIZ);
- char *found = 0;
+ typedef struct {
+ unsigned int val;
+ const char *name;
+ } ALT_NAMES;
+ static const ALT_NAMES names[] =
+ {
+ {'l', "ACS_ULCORNER"}, /* upper left corner */
+ {'m', "ACS_LLCORNER"}, /* lower left corner */
+ {'k', "ACS_URCORNER"}, /* upper right corner */
+ {'j', "ACS_LRCORNER"}, /* lower right corner */
+ {'t', "ACS_LTEE"}, /* tee pointing right */
+ {'u', "ACS_RTEE"}, /* tee pointing left */
+ {'v', "ACS_BTEE"}, /* tee pointing up */
+ {'w', "ACS_TTEE"}, /* tee pointing down */
+ {'q', "ACS_HLINE"}, /* horizontal line */
+ {'x', "ACS_VLINE"}, /* vertical line */
+ {'n', "ACS_PLUS"}, /* large plus or crossover */
+ {'o', "ACS_S1"}, /* scan line 1 */
+ {'s', "ACS_S9"}, /* scan line 9 */
+ {'`', "ACS_DIAMOND"}, /* diamond */
+ {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
+ {'f', "ACS_DEGREE"}, /* degree symbol */
+ {'g', "ACS_PLMINUS"}, /* plus/minus */
+ {'~', "ACS_BULLET"}, /* bullet */
+ {',', "ACS_LARROW"}, /* arrow pointing left */
+ {'+', "ACS_RARROW"}, /* arrow pointing right */
+ {'.', "ACS_DARROW"}, /* arrow pointing down */
+ {'-', "ACS_UARROW"}, /* arrow pointing up */
+ {'h', "ACS_BOARD"}, /* board of squares */
+ {'i', "ACS_LANTERN"}, /* lantern symbol */
+ {'0', "ACS_BLOCK"}, /* solid square block */
+ {'p', "ACS_S3"}, /* scan line 3 */
+ {'r', "ACS_S7"}, /* scan line 7 */
+ {'y', "ACS_LEQUAL"}, /* less/equal */
+ {'z', "ACS_GEQUAL"}, /* greater/equal */
+ {'{', "ACS_PI"}, /* Pi */
+ {'|', "ACS_NEQUAL"}, /* not equal */
+ {'}', "ACS_STERLING"}, /* UK pound sign */
+ {'\0', (char *) 0}
+ };
- buf[0] = '{';
- buf[1] = '\0';
- if (ch & A_ALTCHARSET) {
+ const char *result = 0;
+
+ if ((attr & A_ALTCHARSET) && (acs_chars != 0)) {
char *cp;
- static const struct {
- unsigned int val;
- const char *name;
- } names[] =
- {
- /* *INDENT-OFF* */
- { 'l', "ACS_ULCORNER" }, /* upper left corner */
- { 'm', "ACS_LLCORNER" }, /* lower left corner */
- { 'k', "ACS_URCORNER" }, /* upper right corner */
- { 'j', "ACS_LRCORNER" }, /* lower right corner */
- { 't', "ACS_LTEE" }, /* tee pointing right */
- { 'u', "ACS_RTEE" }, /* tee pointing left */
- { 'v', "ACS_BTEE" }, /* tee pointing up */
- { 'w', "ACS_TTEE" }, /* tee pointing down */
- { 'q', "ACS_HLINE" }, /* horizontal line */
- { 'x', "ACS_VLINE" }, /* vertical line */
- { 'n', "ACS_PLUS" }, /* large plus or crossover */
- { 'o', "ACS_S1" }, /* scan line 1 */
- { 's', "ACS_S9" }, /* scan line 9 */
- { '`', "ACS_DIAMOND" }, /* diamond */
- { 'a', "ACS_CKBOARD" }, /* checker board (stipple) */
- { 'f', "ACS_DEGREE" }, /* degree symbol */
- { 'g', "ACS_PLMINUS" }, /* plus/minus */
- { '~', "ACS_BULLET" }, /* bullet */
- { ',', "ACS_LARROW" }, /* arrow pointing left */
- { '+', "ACS_RARROW" }, /* arrow pointing right */
- { '.', "ACS_DARROW" }, /* arrow pointing down */
- { '-', "ACS_UARROW" }, /* arrow pointing up */
- { 'h', "ACS_BOARD" }, /* board of squares */
- { 'i', "ACS_LANTERN" }, /* lantern symbol */
- { '0', "ACS_BLOCK" }, /* solid square block */
- { 'p', "ACS_S3" }, /* scan line 3 */
- { 'r', "ACS_S7" }, /* scan line 7 */
- { 'y', "ACS_LEQUAL" }, /* less/equal */
- { 'z', "ACS_GEQUAL" }, /* greater/equal */
- { '{', "ACS_PI" }, /* Pi */
- { '|', "ACS_NEQUAL" }, /* not equal */
- { '}', "ACS_STERLING" }, /* UK pound sign */
- { '\0', (char *) 0 }
- /* *INDENT-OFF* */
- },
- *sp;
+ char *found = 0;
+ const ALT_NAMES *sp;
for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
- if (TextOf(cp[1]) == TextOf(ch)) {
+ if (ChCharOf(cp[1]) == ChCharOf(ch)) {
found = cp;
/* don't exit from loop - there may be redefinitions */
}
}
if (found != 0) {
- ch = TextOf(*found);
+ ch = ChCharOf(*found);
for (sp = names; sp->val; sp++)
if (sp->val == ch) {
- (void) strlcat(buf, sp->name, BUFSIZ);
- ch &= ~A_ALTCHARSET;
+ result = sp->name;
break;
}
}
}
+ return result;
+}
+
+NCURSES_EXPORT(char *)
+_tracechtype2(int bufnum, chtype ch)
+{
+ const char *found;
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
- if (found == 0)
- (void) strlcat(buf, _tracechar(TextOf(ch)), BUFSIZ);
+ if (result != 0) {
+ strlcpy(result, l_brace, BUFSIZ);
+ if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
+ (void) _nc_trace_bufcat(bufnum, found);
+ } else
+ (void) _nc_trace_bufcat(bufnum, _nc_tracechar(SP, (int) ChCharOf(ch)));
- if (AttrOf(ch) != A_NORMAL)
- (void) snprintf(buf + strlen(buf), BUFSIZ - strlen(buf), " | %s",
- _traceattr2(bufnum + 20, AttrOf(ch)));
+ if (ChAttrOf(ch) != A_NORMAL) {
+ (void) _nc_trace_bufcat(bufnum, " | ");
+ (void) _nc_trace_bufcat(bufnum,
+ _traceattr2(bufnum + 20, ChAttrOf(ch)));
+ }
- strlcat(buf, "}", BUFSIZ);
- return (buf);
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ }
+ return result;
}
NCURSES_EXPORT(char *)
-_tracechtype (chtype ch)
+_tracechtype(chtype ch)
{
return _tracechtype2(0, ch);
}
/* Trace 'chtype' return-values */
-NCURSES_EXPORT(attr_t)
-_nc_retrace_chtype (attr_t code)
+NCURSES_EXPORT(chtype)
+_nc_retrace_chtype(chtype code)
{
T((T_RETURN("%s"), _tracechtype(code)));
return code;
}
-#else
-extern NCURSES_EXPORT(void) _nc_lib_traceatr (void);
-NCURSES_EXPORT(void) _nc_lib_traceatr (void)
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(char *)
+_tracecchar_t2(int bufnum, const cchar_t *ch)
{
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
+ attr_t attr;
+ const char *found;
+
+ if (result != 0) {
+ strlcpy(result, l_brace, BUFSIZ);
+ if (ch != 0) {
+ attr = AttrOfD(ch);
+ if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
+ (void) _nc_trace_bufcat(bufnum, found);
+ attr &= ~A_ALTCHARSET;
+ } else if (isWidecExt(CHDEREF(ch))) {
+ (void) _nc_trace_bufcat(bufnum, "{NAC}");
+ attr &= ~A_CHARTEXT;
+ } else {
+ PUTC_DATA;
+ int n;
+
+ PUTC_INIT;
+ (void) _nc_trace_bufcat(bufnum, "{ ");
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ PUTC_ch = ch->chars[PUTC_i];
+ if (PUTC_ch == L'\0')
+ break;
+ PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
+ if (PUTC_n <= 0) {
+ if (PUTC_ch != L'\0') {
+ /* it could not be a multibyte sequence */
+ (void) _nc_trace_bufcat(bufnum,
+ _nc_tracechar(SP,
+ UChar(ch->chars[PUTC_i])));
+ }
+ break;
+ }
+ for (n = 0; n < PUTC_n; n++) {
+ if (n)
+ (void) _nc_trace_bufcat(bufnum, ", ");
+ (void) _nc_trace_bufcat(bufnum,
+ _nc_tracechar(SP,
+ UChar(PUTC_buf[n])));
+ }
+ }
+ (void) _nc_trace_bufcat(bufnum, " }");
+ }
+ if (attr != A_NORMAL) {
+ (void) _nc_trace_bufcat(bufnum, " | ");
+ (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
+ }
+ }
+
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ }
+ return result;
}
+
+NCURSES_EXPORT(char *)
+_tracecchar_t(const cchar_t *ch)
+{
+ return _tracecchar_t2(0, ch);
+}
+#endif
+
+#else
+EMPTY_MODULE(_nc_lib_traceatr)
#endif /* TRACE */
diff --git a/lib/libcurses/trace/lib_tracebits.c b/lib/libcurses/trace/lib_tracebits.c
index b1ad17da12c..4905807f11f 100644
--- a/lib/libcurses/trace/lib_tracebits.c
+++ b/lib/libcurses/trace/lib_tracebits.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tracebits.c,v 1.9 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_tracebits.c,v 1.10 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,12 +31,13 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$From: lib_tracebits.c,v 1.9 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.10 2010/01/12 23:22:07 nicm Exp $")
#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
@@ -54,10 +55,27 @@ MODULE_ID("$From: lib_tracebits.c,v 1.9 2000/12/10 03:02:45 tom Exp $")
#ifndef TOSTOP
#define TOSTOP 0
#endif
+
#ifndef IEXTEN
#define IEXTEN 0
#endif
+#ifndef ONLCR
+#define ONLCR 0
+#endif
+
+#ifndef OCRNL
+#define OCRNL 0
+#endif
+
+#ifndef ONOCR
+#define ONOCR 0
+#endif
+
+#ifndef ONLRET
+#define ONLRET 0
+#endif
+
#ifdef TRACE
typedef struct {
@@ -84,7 +102,7 @@ lookup_bits(char *buf, size_t bufsize, const BITNAMES * table, const char *label
}
NCURSES_EXPORT(char *)
-_nc_tracebits(void)
+_nc_trace_ttymode(TTY * tty)
/* describe the state of the terminal control bits exactly */
{
char *buf;
@@ -109,8 +127,13 @@ _nc_tracebits(void)
}, oflags[] =
{
{OPOST, "OPOST"},
+ {OFLAGS_TABS, "XTABS"},
+ {ONLCR, "ONLCR"},
+ {OCRNL, "OCRNL"},
+ {ONOCR, "ONOCR"},
+ {ONLRET, "ONLRET"},
{0, NULL}
-#define ALLOUT (OPOST)
+#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET)
}, cflags[] =
{
{CLOCAL, "CLOCAL"},
@@ -140,60 +163,55 @@ _nc_tracebits(void)
};
bufsize = 8 + sizeof(iflags) + 8 + sizeof(oflags) + 8 + sizeof(cflags) +
- 8 + sizeof(lflags) + 8;
+ 8 + sizeof(lflags) + 8;
buf = _nc_trace_buf(0, bufsize);
- if (cur_term->Nttyb.c_iflag & ALLIN)
- lookup_bits(buf, bufsize, iflags, "iflags", cur_term->Nttyb.c_iflag);
+ if (buf != 0) {
+
+ if (tty->c_iflag & ALLIN)
+ lookup_bits(buf, bufsize, iflags, "iflags", tty->c_iflag);
- if (cur_term->Nttyb.c_oflag & ALLOUT)
- lookup_bits(buf, bufsize, oflags, "oflags", cur_term->Nttyb.c_oflag);
+ if (tty->c_oflag & ALLOUT)
+ lookup_bits(buf, bufsize, oflags, "oflags", tty->c_oflag);
- if (cur_term->Nttyb.c_cflag & ALLCTRL)
- lookup_bits(buf, bufsize, cflags, "cflags", cur_term->Nttyb.c_cflag);
+ if (tty->c_cflag & ALLCTRL)
+ lookup_bits(buf, bufsize, cflags, "cflags", tty->c_cflag);
#if defined(CS5) && defined(CS8)
- {
- static struct {
- char *name;
- int value;
- } csizes[] = {
- {
- "CS5 ", CS5
- },
+ {
+ static struct {
+ int value;
+ const char *name;
+ } csizes[] = {
+#define CS_DATA(name) { name, #name " " }
+ CS_DATA(CS5),
#ifdef CS6
- {
- "CS6 ", CS6
- },
+ CS_DATA(CS6),
#endif
#ifdef CS7
- {
- "CS7 ", CS7
- },
-#endif
- {
- "CS8 ", CS8
- },
- };
- char *result = "CSIZE? ";
- int value = (cur_term->Nttyb.c_cflag & CSIZE);
- unsigned n;
-
- if (value != 0) {
- for (n = 0; n < SIZEOF(csizes); n++) {
- if (csizes[n].value == value) {
- result = csizes[n].name;
- break;
+ CS_DATA(CS7),
+#endif
+ CS_DATA(CS8),
+ };
+ const char *result = "CSIZE? ";
+ int value = (tty->c_cflag & CSIZE);
+ unsigned n;
+
+ if (value != 0) {
+ for (n = 0; n < SIZEOF(csizes); n++) {
+ if (csizes[n].value == value) {
+ result = csizes[n].name;
+ break;
+ }
}
}
+ strlcat(buf, result, bufsize);
}
- strlcat(buf, result, bufsize);
- }
#endif
- if (cur_term->Nttyb.c_lflag & ALLLOCAL)
- lookup_bits(buf, bufsize, lflags, "lflags", cur_term->Nttyb.c_lflag);
-
+ if (tty->c_lflag & ALLLOCAL)
+ lookup_bits(buf, bufsize, lflags, "lflags", tty->c_lflag);
+ }
#else
/* reference: ttcompat(4M) on SunOS 4.1 */
#ifndef EVENP
@@ -230,18 +248,24 @@ _nc_tracebits(void)
buf = _nc_trace_buf(0,
8 + sizeof(cflags));
-
- if (cur_term->Nttyb.sg_flags & ALLCTRL) {
- lookup_bits(buf, bufsize, cflags, "cflags", cur_term->Nttyb.sg_flags);
+ if (buf != 0) {
+ if (tty->sg_flags & ALLCTRL) {
+ lookup_bits(buf, cflags, "cflags", tty->sg_flags);
+ }
}
#endif
return (buf);
}
+
+NCURSES_EXPORT(char *)
+_nc_tracebits(void)
+{
+ return _nc_trace_ttymode(&(cur_term->Nttyb));
+}
#else
NCURSES_EXPORT(char *)
_nc_tracebits(void)
{
- static char tmp[] = "";
- return tmp;
+ return NULL;
}
#endif /* TRACE */
diff --git a/lib/libcurses/trace/lib_tracechr.c b/lib/libcurses/trace/lib_tracechr.c
index f69a9c59a1f..e909ab79262 100644
--- a/lib/libcurses/trace/lib_tracechr.c
+++ b/lib/libcurses/trace/lib_tracechr.c
@@ -1,5 +1,7 @@
+/* $OpenBSD: lib_tracechr.c,v 1.5 2010/01/12 23:22:07 nicm Exp $ */
+
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -36,23 +39,49 @@
*/
#include <curses.priv.h>
-MODULE_ID("$From: lib_tracechr.c,v 1.4 2000/12/10 03:02:45 tom Exp $")
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_tracechr.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
#ifdef TRACE
+
NCURSES_EXPORT(char *)
-_tracechar(const unsigned char ch)
+_nc_tracechar(SCREEN *sp, int ch)
{
- static char crep[20];
- (void) snprintf(crep, sizeof(crep), "'%s' = 0x%02x", unctrl(ch),
- (unsigned) ch);
- return (crep);
+ NCURSES_CONST char *name;
+ char *MyBuffer = ((sp != 0)
+ ? sp->tracechr_buf
+ : _nc_globals.tracechr_buf);
+ size_t len = ((sp != 0)
+ ? _nc_screen_tracechr_buf_size
+ : _nc_globals_traceatr_color_buf_size);
+
+ if (ch > KEY_MIN || ch < 0) {
+ name = _nc_keyname(sp, ch);
+ if (name == 0 || *name == '\0')
+ name = "NULL";
+ (void) snprintf(MyBuffer, len, "'%.30s' = %#03o", name, ch);
+ } else if (!is8bits(ch) || !isprint(UChar(ch))) {
+ /*
+ * workaround for glibc bug:
+ * sprintf changes the result from unctrl() to an empty string if it
+ * does not correspond to a valid multibyte sequence.
+ */
+ (void) snprintf(MyBuffer, len, "%#03o", ch);
+ } else {
+ name = _nc_unctrl(sp, (chtype) ch);
+ if (name == 0 || *name == 0)
+ name = "null"; /* shouldn't happen */
+ (void) snprintf(MyBuffer, len, "'%.30s' = %#03o", name, ch);
+ }
+ return (MyBuffer);
}
-#else
-extern
-NCURSES_EXPORT(void)
-_nc_lib_tracechr(void);
-NCURSES_EXPORT(void)
-_nc_lib_tracechr(void)
+
+NCURSES_EXPORT(char *)
+_tracechar(int ch)
{
+ return _nc_tracechar(SP, ch);
}
+#else
+EMPTY_MODULE(_nc_lib_tracechr)
#endif
diff --git a/lib/libcurses/trace/lib_tracedmp.c b/lib/libcurses/trace/lib_tracedmp.c
index 4e557d65974..71759dc21db 100644
--- a/lib/libcurses/trace/lib_tracedmp.c
+++ b/lib/libcurses/trace/lib_tracedmp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tracedmp.c,v 1.3 2003/03/17 19:16:59 millert Exp $ */
+/* $OpenBSD: lib_tracedmp.c,v 1.4 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,8 @@
****************************************************************************/
/****************************************************************************
- * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * Author: Thomas E. Dickey 1996-on *
+ * and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
@@ -38,94 +39,148 @@
*/
#include <curses.priv.h>
+#include <ctype.h>
-MODULE_ID("$From: lib_tracedmp.c,v 1.16 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.4 2010/01/12 23:22:07 nicm Exp $")
#ifdef TRACE
+
+#define my_buffer _nc_globals.tracedmp_buf
+#define my_length _nc_globals.tracedmp_used
+
NCURSES_EXPORT(void)
_tracedump(const char *name, WINDOW *win)
{
int i, j, n, width;
/* compute narrowest possible display width */
- for (width = i = 0; i <= win->_maxy; i++) {
+ for (width = i = 0; i <= win->_maxy; ++i) {
n = 0;
- for (j = 0; j <= win->_maxx; j++)
- if (win->_line[i].text[j] != ' ')
+ for (j = 0; j <= win->_maxx; ++j) {
+ if (CharOf(win->_line[i].text[j]) != L(' ')
+ || AttrOf(win->_line[i].text[j]) != A_NORMAL
+ || GetPair(win->_line[i].text[j]) != 0) {
n = j;
+ }
+ }
if (n > width)
width = n;
}
if (width < win->_maxx)
++width;
+ if (++width + 1 > (int) my_length) {
+ my_length = 2 * (width + 1);
+ my_buffer = typeRealloc(char, my_length, my_buffer);
+ }
- for (n = 0; n <= win->_maxy; n++) {
- char buf[BUFSIZ], *ep;
+ for (n = 0; n <= win->_maxy; ++n) {
+ char *ep = my_buffer;
bool haveattrs, havecolors;
- /* dump A_CHARTEXT part */
- (void) snprintf(buf, sizeof(buf), "%s[%2d] %3d%3d ='",
- name, n,
- win->_line[n].firstchar,
- win->_line[n].lastchar);
- ep = buf + strlen(buf);
- for (j = 0; j <= width; j++) {
- ep[j] = TextOf(win->_line[n].text[j]);
- if (ep[j] == 0)
- ep[j] = '.';
+ /*
+ * Dump A_CHARTEXT part. It is more important to make the grid line up
+ * in the trace file than to represent control- and wide-characters, so
+ * we map those to '.' and '?' respectively.
+ */
+ for (j = 0; j < width; ++j) {
+ chtype test = CharOf(win->_line[n].text[j]);
+ ep[j] = (char) ((UChar(test) == test
+#if USE_WIDEC_SUPPORT
+ && (win->_line[n].text[j].chars[1] == 0)
+#endif
+ )
+ ? (iscntrl(UChar(test))
+ ? '.'
+ : UChar(test))
+ : '?');
}
- ep[j] = '\'';
- ep[j + 1] = '\0';
- _tracef("%s", buf);
+ ep[j] = '\0';
+ _tracef("%s[%2d] %3ld%3ld ='%s'",
+ name, n,
+ (long) win->_line[n].firstchar,
+ (long) win->_line[n].lastchar,
+ ep);
+
+ /* if there are multi-column characters on the line, print them now */
+ if_WIDEC({
+ bool multicolumn = FALSE;
+ for (j = 0; j < width; ++j)
+ if (WidecExt(win->_line[n].text[j]) != 0) {
+ multicolumn = TRUE;
+ break;
+ }
+ if (multicolumn) {
+ ep = my_buffer;
+ for (j = 0; j < width; ++j) {
+ int test = WidecExt(win->_line[n].text[j]);
+ if (test) {
+ ep[j] = (char) (test + '0');
+ } else {
+ ep[j] = ' ';
+ }
+ }
+ ep[j] = '\0';
+ _tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
+ "widec", n, 8, " ", my_buffer);
+ }
+ });
/* dump A_COLOR part, will screw up if there are more than 96 */
havecolors = FALSE;
- for (j = 0; j <= width; j++)
- if (win->_line[n].text[j] & A_COLOR) {
+ for (j = 0; j < width; ++j)
+ if (GetPair(win->_line[n].text[j]) != 0) {
havecolors = TRUE;
break;
}
if (havecolors) {
- (void) snprintf(buf, sizeof(buf), "%*s[%2d]%*s='",
- (int) strlen(name), "colors", n, 8, " ");
- ep = buf + strlen(buf);
- for (j = 0; j <= width; j++)
- ep[j] = CharOf(win->_line[n].text[j] >> 8) + ' ';
- ep[j] = '\'';
- ep[j + 1] = '\0';
- _tracef("%s", buf);
+ ep = my_buffer;
+ for (j = 0; j < width; ++j) {
+ int pair = GetPair(win->_line[n].text[j]);
+ if (pair >= 52)
+ ep[j] = '?';
+ else if (pair >= 36)
+ ep[j] = (char) (pair + 'A');
+ else if (pair >= 10)
+ ep[j] = (char) (pair + 'a');
+ else if (pair >= 1)
+ ep[j] = (char) (pair + '0');
+ else
+ ep[j] = ' ';
+ }
+ ep[j] = '\0';
+ _tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
+ "colors", n, 8, " ", my_buffer);
}
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 4; ++i) {
const char *hex = " 123456789ABCDEF";
- chtype mask = (0xf << ((i + 4) * 4));
+ attr_t mask = (0xf << ((i + 4) * 4));
haveattrs = FALSE;
- for (j = 0; j <= width; j++)
- if (win->_line[n].text[j] & mask) {
+ for (j = 0; j < width; ++j)
+ if (AttrOf(win->_line[n].text[j]) & mask) {
haveattrs = TRUE;
break;
}
if (haveattrs) {
- (void) snprintf(buf, sizeof(buf), "%*s%d[%2d]%*s='",
- (int) strlen(name) - 1, "attrs", i, n, 8, " ");
- ep = buf + strlen(buf);
- for (j = 0; j <= width; j++)
- ep[j] = hex[(win->_line[n].text[j] & mask) >> ((i + 4) * 4)];
- ep[j] = '\'';
- ep[j + 1] = '\0';
- _tracef("%s", buf);
+ ep = my_buffer;
+ for (j = 0; j < width; ++j)
+ ep[j] = hex[(AttrOf(win->_line[n].text[j]) & mask) >>
+ ((i + 4) * 4)];
+ ep[j] = '\0';
+ _tracef("%*s%d[%2d]%*s='%s'", (int) strlen(name) -
+ 1, "attrs", i, n, 8, " ", my_buffer);
}
}
}
+#if NO_LEAKS
+ free(my_buffer);
+ my_buffer = 0;
+ my_length = 0;
+#endif
}
+
#else
-extern
-NCURSES_EXPORT(void)
-_nc_lib_tracedmp(void);
-NCURSES_EXPORT(void)
-_nc_lib_tracedmp(void)
-{
-}
+EMPTY_MODULE(_nc_lib_tracedmp)
#endif /* TRACE */
diff --git a/lib/libcurses/trace/lib_tracemse.c b/lib/libcurses/trace/lib_tracemse.c
index 3346d87e224..798aae9f563 100644
--- a/lib/libcurses/trace/lib_tracemse.c
+++ b/lib/libcurses/trace/lib_tracemse.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tracemse.c,v 1.4 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: lib_tracemse.c,v 1.5 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -39,62 +40,92 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_tracemse.c,v 1.8 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
#ifdef TRACE
+#define my_buffer sp->tracemse_buf
+
NCURSES_EXPORT(char *)
-_tracemouse(MEVENT const *ep)
+_nc_tracemouse(SCREEN *sp, MEVENT const *ep)
{
- static char buf[80];
-
- (void) snprintf(buf, sizeof(buf), "id %2d at (%2d, %2d, %2d) state %4lx = {",
- ep->id, ep->x, ep->y, ep->z, ep->bstate);
-
-#define SHOW(m, s) if ((ep->bstate & m)==m) {strlcat(buf,s,sizeof(buf)); strlcat(buf, ", ",sizeof(buf));}
- SHOW(BUTTON1_RELEASED, "release-1")
- SHOW(BUTTON1_PRESSED, "press-1")
- SHOW(BUTTON1_CLICKED, "click-1")
- SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1")
- SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1")
- SHOW(BUTTON1_RESERVED_EVENT, "reserved-1")
- SHOW(BUTTON2_RELEASED, "release-2")
- SHOW(BUTTON2_PRESSED, "press-2")
- SHOW(BUTTON2_CLICKED, "click-2")
- SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2")
- SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2")
- SHOW(BUTTON2_RESERVED_EVENT, "reserved-2")
- SHOW(BUTTON3_RELEASED, "release-3")
- SHOW(BUTTON3_PRESSED, "press-3")
- SHOW(BUTTON3_CLICKED, "click-3")
- SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3")
- SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3")
- SHOW(BUTTON3_RESERVED_EVENT, "reserved-3")
- SHOW(BUTTON4_RELEASED, "release-4")
- SHOW(BUTTON4_PRESSED, "press-4")
- SHOW(BUTTON4_CLICKED, "click-4")
- SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4")
- SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4")
- SHOW(BUTTON4_RESERVED_EVENT, "reserved-4")
- SHOW(BUTTON_CTRL, "ctrl")
- SHOW(BUTTON_SHIFT, "shift")
- SHOW(BUTTON_ALT, "alt")
- SHOW(ALL_MOUSE_EVENTS, "all-events")
- SHOW(REPORT_MOUSE_POSITION, "position")
+ (void) snprintf(my_buffer, TRACEMSE_MAX, TRACEMSE_FMT,
+ ep->id,
+ ep->x,
+ ep->y,
+ ep->z,
+ (unsigned long) ep->bstate);
+
+#define SHOW(m, s) \
+ if ((ep->bstate & m) == m) { \
+ strlcat(my_buffer, s, TRACEMSE_MAX); \
+ strlcat(my_buffer, ", ", TRACEMSE_MAX); \
+}
+
+ SHOW(BUTTON1_RELEASED, "release-1");
+ SHOW(BUTTON1_PRESSED, "press-1");
+ SHOW(BUTTON1_CLICKED, "click-1");
+ SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
+ SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
+#if NCURSES_MOUSE_VERSION == 1
+ SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
+#endif
+
+ SHOW(BUTTON2_RELEASED, "release-2");
+ SHOW(BUTTON2_PRESSED, "press-2");
+ SHOW(BUTTON2_CLICKED, "click-2");
+ SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
+ SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
+#if NCURSES_MOUSE_VERSION == 1
+ SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
+#endif
+
+ SHOW(BUTTON3_RELEASED, "release-3");
+ SHOW(BUTTON3_PRESSED, "press-3");
+ SHOW(BUTTON3_CLICKED, "click-3");
+ SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
+ SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
+#if NCURSES_MOUSE_VERSION == 1
+ SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
+#endif
+
+ SHOW(BUTTON4_RELEASED, "release-4");
+ SHOW(BUTTON4_PRESSED, "press-4");
+ SHOW(BUTTON4_CLICKED, "click-4");
+ SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
+ SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
+#if NCURSES_MOUSE_VERSION == 1
+ SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
+#endif
+
+#if NCURSES_MOUSE_VERSION == 2
+ SHOW(BUTTON5_RELEASED, "release-5");
+ SHOW(BUTTON5_PRESSED, "press-5");
+ SHOW(BUTTON5_CLICKED, "click-5");
+ SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
+ SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
+#endif
+
+ SHOW(BUTTON_CTRL, "ctrl");
+ SHOW(BUTTON_SHIFT, "shift");
+ SHOW(BUTTON_ALT, "alt");
+ SHOW(ALL_MOUSE_EVENTS, "all-events");
+ SHOW(REPORT_MOUSE_POSITION, "position");
+
#undef SHOW
- if (buf[strlen(buf) - 1] == ' ')
- buf[strlen(buf) - 2] = '\0';
- (void) strlcat(buf, "}", sizeof(buf));
- return (buf);
+ if (my_buffer[strlen(my_buffer) - 1] == ' ')
+ my_buffer[strlen(my_buffer) - 2] = '\0';
+ (void) strlcat(my_buffer, "}", TRACEMSE_MAX);
+ return (my_buffer);
}
-#else /* !TRACE */
-/* don't make empty module */
-NCURSES_EXPORT(void)
-_nc_lib_tracemouse(void);
-NCURSES_EXPORT(void)
-_nc_lib_tracemouse(void)
+NCURSES_EXPORT(char *)
+_tracemouse(MEVENT const *ep)
{
+ return _nc_tracemouse(SP, ep);
}
+
+#else /* !TRACE */
+EMPTY_MODULE(_nc_lib_tracemouse)
#endif
diff --git a/lib/libcurses/trace/trace_buf.c b/lib/libcurses/trace/trace_buf.c
index 060ef5e686d..2b57ef77a3f 100644
--- a/lib/libcurses/trace/trace_buf.c
+++ b/lib/libcurses/trace/trace_buf.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: trace_buf.c,v 1.3 2001/01/22 18:01:58 millert Exp $ */
+/* $OpenBSD: trace_buf.c,v 1.4 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
* trace_buf.c - Tracing/Debugging buffers (attributes)
@@ -37,47 +37,85 @@
#include <curses.priv.h>
-MODULE_ID("$From: trace_buf.c,v 1.9 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.4 2010/01/12 23:22:07 nicm Exp $")
-typedef struct {
- char *text;
- size_t size;
-} LIST;
+#define MyList _nc_globals.tracebuf_ptr
+#define MySize _nc_globals.tracebuf_used
-NCURSES_EXPORT(char *)
-_nc_trace_buf(int bufnum, size_t want)
+static char *
+_nc_trace_alloc(int bufnum, size_t want)
{
- static LIST *list;
- static size_t have;
+#ifdef TRACE
+ char *result = 0;
+
+ if (bufnum >= 0) {
+ if ((size_t) (bufnum + 1) > MySize) {
+ size_t need = (bufnum + 1) * 2;
+ if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) {
+ while (need > MySize)
+ MyList[MySize++].text = 0;
+ }
+ }
+ if (MyList != 0) {
+ if (MyList[bufnum].text == 0
+ || want > MyList[bufnum].size) {
+ MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text);
+ if (MyList[bufnum].text != 0)
+ MyList[bufnum].size = want;
+ }
+ result = MyList[bufnum].text;
+ }
+ }
#if NO_LEAKS
- if (bufnum < 0) {
- if (have) {
- while (have--) {
- free(list[have].text);
+ else {
+ if (MySize) {
+ if (MyList) {
+ while (MySize--) {
+ if (MyList[MySize].text != 0) {
+ free(MyList[MySize].text);
+ }
+ }
+ free(MyList);
+ MyList = 0;
}
- free(list);
+ MySize = 0;
}
- return 0;
}
#endif
+ return result;
+#else
+ return NULL;
+#endif
+}
- if ((size_t) (bufnum + 1) > have) {
- size_t need = (bufnum + 1) * 2;
- if ((list = typeRealloc(LIST, need, list)) == 0)
- return (0);
- while (need > have)
- list[have++].text = 0;
- }
+/*
+ * (re)Allocate a buffer big enough for the caller's wants.
+ */
+NCURSES_EXPORT(char *)
+_nc_trace_buf(int bufnum, size_t want)
+{
+ char *result = _nc_trace_alloc(bufnum, want);
+ if (result != 0)
+ *result = '\0';
+ return result;
+}
- if (list[bufnum].text == 0
- || want > list[bufnum].size) {
- if ((list[bufnum].text = typeRealloc(char, want, list[bufnum].text))
- != 0)
- list[bufnum].size = want;
- }
+/*
+ * Append a new string to an existing buffer.
+ */
+NCURSES_EXPORT(char *)
+_nc_trace_bufcat(int bufnum, const char *value)
+{
+ char *buffer = _nc_trace_alloc(bufnum, 0);
+ if (buffer != 0) {
+ size_t have = strlen(buffer), length;
+
+ length = 1 + have + strlen(value);
+ buffer = _nc_trace_alloc(bufnum, length);
+ if (buffer != 0)
+ (void) strlcpy(buffer + have, value, length);
- if (list[bufnum].text != 0)
- *(list[bufnum].text) = '\0';
- return list[bufnum].text;
+ }
+ return buffer;
}
diff --git a/lib/libcurses/trace/trace_tries.c b/lib/libcurses/trace/trace_tries.c
index d0dd538d9be..0a138b48cab 100644
--- a/lib/libcurses/trace/trace_tries.c
+++ b/lib/libcurses/trace/trace_tries.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: trace_tries.c,v 1.4 2001/01/22 18:01:59 millert Exp $ */
+/* $OpenBSD: trace_tries.c,v 1.5 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1999-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,25 +37,27 @@
#include <curses.priv.h>
-MODULE_ID("$From: trace_tries.c,v 1.8 2000/12/10 03:03:51 tom Exp $")
+MODULE_ID("$Id: trace_tries.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
#ifdef TRACE
-static unsigned char *buffer;
-static unsigned len;
+#define my_buffer _nc_globals.tracetry_buf
+#define my_length _nc_globals.tracetry_used
static void
-recur_tries(struct tries *tree, unsigned level)
+recur_tries(TRIES * tree, unsigned level)
{
- if (level > len)
- buffer = (unsigned char *) realloc(buffer, len = (level + 1) * 4);
+ if (level > my_length) {
+ my_length = (level + 1) * 4;
+ my_buffer = (unsigned char *) realloc(my_buffer, my_length);
+ }
while (tree != 0) {
- if ((buffer[level] = tree->ch) == 0)
- buffer[level] = 128;
- buffer[level + 1] = 0;
+ if ((my_buffer[level] = tree->ch) == 0)
+ my_buffer[level] = 128;
+ my_buffer[level + 1] = 0;
if (tree->value != 0) {
_tracef("%5d: %s (%s)", tree->value,
- _nc_visbuf((char *) buffer), keyname(tree->value));
+ _nc_visbuf((char *) my_buffer), keyname(tree->value));
}
if (tree->child)
recur_tries(tree->child, level + 1);
@@ -64,18 +66,18 @@ recur_tries(struct tries *tree, unsigned level)
}
NCURSES_EXPORT(void)
-_nc_trace_tries(struct tries *tree)
+_nc_trace_tries(TRIES * tree)
{
- buffer = typeMalloc(unsigned char, len = 80);
+ my_buffer = typeMalloc(unsigned char, my_length = 80);
_tracef("BEGIN tries %p", tree);
recur_tries(tree, 0);
_tracef(". . . tries %p", tree);
- free(buffer);
+ free(my_buffer);
}
#else
NCURSES_EXPORT(void)
-_nc_trace_tries(struct tries *tree GCC_UNUSED)
+_nc_trace_tries(TRIES * tree)
{
}
#endif
diff --git a/lib/libcurses/trace/trace_xnames.c b/lib/libcurses/trace/trace_xnames.c
index 22dc761419f..2c5b0ff74dd 100644
--- a/lib/libcurses/trace/trace_xnames.c
+++ b/lib/libcurses/trace/trace_xnames.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trace_xnames.c,v 1.3 2001/01/22 18:01:59 millert Exp $ */
+/* $OpenBSD: trace_xnames.c,v 1.4 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1999,2000 Free Software Foundation, Inc. *
@@ -38,7 +38,7 @@
#include <curses.priv.h>
#include <term_entry.h>
-MODULE_ID("$From: trace_xnames.c,v 1.5 2000/12/10 03:02:45 tom Exp $")
+MODULE_ID("$Id: trace_xnames.c,v 1.4 2010/01/12 23:22:07 nicm Exp $")
NCURSES_EXPORT(void)
_nc_trace_xnames(TERMTYPE * tp GCC_UNUSED)
diff --git a/lib/libcurses/trace/varargs.c b/lib/libcurses/trace/varargs.c
new file mode 100644
index 00000000000..0a1d5cfa161
--- /dev/null
+++ b/lib/libcurses/trace/varargs.c
@@ -0,0 +1,186 @@
+/* $OpenBSD: varargs.c,v 1.1 2010/01/12 23:22:07 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2001-2007,2008 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2001 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+
+MODULE_ID("$Id: varargs.c,v 1.1 2010/01/12 23:22:07 nicm Exp $")
+
+#ifdef TRACE
+
+#define MAX_PARMS 10
+
+typedef enum {
+ atUnknown = 0, atInteger, atFloat, atPoint, atString
+} ARGTYPE;
+
+#define VA_INT(type) ival = va_arg(ap, type)
+#define VA_FLT(type) fval = va_arg(ap, type)
+#define VA_PTR(type) pval = (char *)va_arg(ap, type)
+#define VA_STR(type) sval = va_arg(ap, type)
+
+#define MyBuffer _nc_globals.tracearg_buf
+#define MyLength _nc_globals.tracearg_used
+
+/*
+ * Returns a string that represents the parameter list of a printf-style call.
+ */
+NCURSES_EXPORT(char *)
+_nc_varargs(const char *fmt, va_list ap)
+{
+ static char dummy[] = "";
+
+ char buffer[BUFSIZ];
+ const char *param;
+ int n;
+
+ if (fmt == 0 || *fmt == '\0')
+ return dummy;
+ if (MyLength == 0)
+ MyBuffer = typeMalloc(char, MyLength = BUFSIZ);
+ if (MyBuffer == 0)
+ return dummy;
+ *MyBuffer = '\0';
+
+ while (*fmt != '\0') {
+ if (*fmt == '%') {
+ char *pval = 0; /* avoid const-cast */
+ const char *sval = "";
+ double fval = 0.0;
+ int done = FALSE;
+ int ival = 0;
+ int type = 0;
+ ARGTYPE parm[MAX_PARMS];
+ int parms = 0;
+ ARGTYPE used = atUnknown;
+
+ while (*++fmt != '\0' && !done) {
+
+ if (*fmt == '*') {
+ VA_INT(int);
+ if (parms < MAX_PARMS)
+ parm[parms++] = atInteger;
+ } else if (isalpha(UChar(*fmt))) {
+ done = TRUE;
+ switch (*fmt) {
+ case 'Z': /* FALLTHRU */
+ case 'h': /* FALLTHRU */
+ case 'l': /* FALLTHRU */
+ done = FALSE;
+ type = *fmt;
+ break;
+ case 'i': /* FALLTHRU */
+ case 'd': /* FALLTHRU */
+ case 'u': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ if (type == 'l')
+ VA_INT(long);
+ else if (type == 'Z')
+ VA_INT(size_t);
+ else
+ VA_INT(int);
+ used = atInteger;
+ break;
+ case 'f': /* FALLTHRU */
+ case 'e': /* FALLTHRU */
+ case 'E': /* FALLTHRU */
+ case 'g': /* FALLTHRU */
+ case 'G': /* FALLTHRU */
+ VA_FLT(double);
+ used = atFloat;
+ break;
+ case 'c':
+ VA_INT(int);
+ used = atInteger;
+ break;
+ case 's':
+ VA_STR(const char *);
+ used = atString;
+ break;
+ case 'p':
+ VA_PTR(void *);
+ used = atPoint;
+ break;
+ case 'n':
+ VA_PTR(int *);
+ used = atPoint;
+ break;
+ default:
+ break;
+ }
+ } else if (*fmt == '%') {
+ done = TRUE;
+ }
+ if (used != atUnknown && parms < MAX_PARMS) {
+ parm[parms++] = used;
+ for (n = 0; n < parms; ++n) {
+ used = parm[n];
+ param = buffer;
+ switch (used) {
+ case atInteger:
+ snprintf(buffer, sizeof(buffer), "%d", ival);
+ break;
+ case atFloat:
+ snprintf(buffer, sizeof(buffer), "%f", fval);
+ break;
+ case atPoint:
+ snprintf(buffer, sizeof(buffer), "%p", pval);
+ break;
+ case atString:
+ param = _nc_visbuf2(1, sval);
+ break;
+ case atUnknown:
+ default:
+ strlcpy(buffer, "?", sizeof(buffer));
+ break;
+ }
+ MyLength += strlen(param) + 2;
+ MyBuffer = typeRealloc(char, MyLength, MyBuffer);
+ snprintf(MyBuffer + strlen(MyBuffer), MyLength - strlen(MyBuffer), ", %s", param);
+ }
+ }
+ used = atUnknown;
+ }
+ } else {
+ fmt++;
+ }
+ }
+
+ return (MyBuffer);
+}
+#else
+EMPTY_MODULE(_nc_varargs)
+#endif
diff --git a/lib/libcurses/trace/visbuf.c b/lib/libcurses/trace/visbuf.c
new file mode 100644
index 00000000000..47efca5e22c
--- /dev/null
+++ b/lib/libcurses/trace/visbuf.c
@@ -0,0 +1,333 @@
+/* $OpenBSD: visbuf.c,v 1.1 2010/01/12 23:22:07 nicm Exp $ */
+
+/****************************************************************************
+ * Copyright (c) 2001-2007,2008 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 1996-on *
+ * and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * visbuf.c - Tracing/Debugging support routines
+ */
+
+#define NEED_NCURSES_CH_T
+#include <curses.priv.h>
+
+#include <tic.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: visbuf.c,v 1.1 2010/01/12 23:22:07 nicm Exp $")
+
+#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4)
+#define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * MB_CUR_MAX)
+
+#ifdef TRACE
+static const char d_quote[] = StringOf(D_QUOTE);
+static const char l_brace[] = StringOf(L_BRACE);
+static const char r_brace[] = StringOf(R_BRACE);
+#endif
+
+static char *
+_nc_vischar(char *tp, size_t tl, unsigned c)
+{
+ if (c == '"' || c == '\\') {
+ *tp++ = '\\';
+ *tp++ = (char) c;
+ } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
+ *tp++ = (char) c;
+ } else if (c == '\n') {
+ *tp++ = '\\';
+ *tp++ = 'n';
+ } else if (c == '\r') {
+ *tp++ = '\\';
+ *tp++ = 'r';
+ } else if (c == '\b') {
+ *tp++ = '\\';
+ *tp++ = 'b';
+ } else if (c == '\033') {
+ *tp++ = '\\';
+ *tp++ = 'e';
+ } else if (UChar(c) == 0x7f) {
+ *tp++ = '\\';
+ *tp++ = '^';
+ *tp++ = '?';
+ } else if (is7bits(c) && iscntrl(UChar(c))) {
+ *tp++ = '\\';
+ *tp++ = '^';
+ *tp++ = (char) ('@' + c);
+ } else {
+ snprintf(tp, tl, "\\%03lo", (unsigned long) ChCharOf(c));
+ tp += strlen(tp);
+ }
+ *tp = 0;
+ return tp;
+}
+
+static const char *
+_nc_visbuf2n(int bufnum, const char *buf, int len)
+{
+ const char *vbuf;
+ char *tp;
+ int c;
+
+ if (buf == 0)
+ return ("(null)");
+ if (buf == CANCELLED_STRING)
+ return ("(cancelled)");
+
+ if (len < 0)
+ len = (int) strlen(buf);
+
+#ifdef TRACE
+ vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len));
+#else
+ {
+ static char *mybuf[4];
+ mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]);
+ vbuf = tp = mybuf[bufnum];
+ }
+#endif
+ if (tp != 0) {
+ *tp++ = D_QUOTE;
+ while ((--len >= 0) && (c = *buf++) != '\0') {
+ tp = _nc_vischar(tp, NormalLen(len) - (tp - vbuf), UChar(c));
+ }
+ *tp++ = D_QUOTE;
+ *tp++ = '\0';
+ } else {
+ vbuf = ("(_nc_visbuf2n failed)");
+ }
+ return (vbuf);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_visbuf2(int bufnum, const char *buf)
+{
+ return _nc_visbuf2n(bufnum, buf, -1);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_visbuf(const char *buf)
+{
+ return _nc_visbuf2(0, buf);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_visbufn(const char *buf, int len)
+{
+ return _nc_visbuf2n(0, buf, len);
+}
+
+#ifdef TRACE
+#if USE_WIDEC_SUPPORT
+
+#if defined(USE_TERMLIB)
+#define _nc_wchstrlen _my_wchstrlen
+static int
+_nc_wchstrlen(const cchar_t *s)
+{
+ int result = 0;
+ while (CharOf(s[result]) != L'\0') {
+ result++;
+ }
+ return result;
+}
+#endif
+
+static const char *
+_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
+{
+ const char *vbuf;
+ char *tp;
+ wchar_t c;
+
+ if (buf == 0)
+ return ("(null)");
+
+ if (len < 0)
+ len = (int) wcslen(buf);
+
+#ifdef TRACE
+ vbuf = tp = _nc_trace_buf(bufnum, WideLen(len));
+#else
+ {
+ static char *mybuf[2];
+ mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]);
+ vbuf = tp = mybuf[bufnum];
+ }
+#endif
+ if (tp != 0) {
+ *tp++ = D_QUOTE;
+ while ((--len >= 0) && (c = *buf++) != '\0') {
+ char temp[CCHARW_MAX + 80];
+ int j = wctomb(temp, c), k;
+ if (j <= 0) {
+ snprintf(temp, sizeof temp, "\\u%08X", (unsigned) c);
+ j = (int) strlen(temp);
+ }
+ for (k = 0; k < j; ++k) {
+ tp = _nc_vischar(tp, WideLen(len) - (tp - vbuf), UChar(temp[k]));
+ }
+ }
+ *tp++ = D_QUOTE;
+ *tp++ = '\0';
+ } else {
+ vbuf = ("(_nc_viswbuf2n failed)");
+ }
+ return (vbuf);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_viswbuf2(int bufnum, const wchar_t *buf)
+{
+ return _nc_viswbuf2n(bufnum, buf, -1);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_viswbuf(const wchar_t *buf)
+{
+ return _nc_viswbuf2(0, buf);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_viswbufn(const wchar_t *buf, int len)
+{
+ return _nc_viswbuf2n(0, buf, len);
+}
+
+/* this special case is used for wget_wstr() */
+NCURSES_EXPORT(const char *)
+_nc_viswibuf(const wint_t *buf)
+{
+ static wchar_t *mybuf;
+ static unsigned mylen;
+ unsigned n;
+
+ for (n = 0; buf[n] != 0; ++n) ;
+ if (mylen < ++n) {
+ mylen = n + 80;
+ if (mybuf != 0)
+ mybuf = typeRealloc(wchar_t, mylen, mybuf);
+ else
+ mybuf = typeMalloc(wchar_t, mylen);
+ }
+ for (n = 0; buf[n] != 0; ++n)
+ mybuf[n] = (wchar_t) buf[n];
+
+ return _nc_viswbuf2(0, mybuf);
+}
+#endif /* USE_WIDEC_SUPPORT */
+
+/* use these functions for displaying parts of a line within a window */
+NCURSES_EXPORT(const char *)
+_nc_viscbuf2(int bufnum, const NCURSES_CH_T * buf, int len)
+{
+ char *result = _nc_trace_buf(bufnum, BUFSIZ);
+ int first;
+ const char *found;
+
+ if (result != 0) {
+#if USE_WIDEC_SUPPORT
+ if (len < 0)
+ len = _nc_wchstrlen(buf);
+#endif /* USE_WIDEC_SUPPORT */
+
+ /*
+ * Display one or more strings followed by attributes.
+ */
+ first = 0;
+ while (first < len) {
+ attr_t attr = AttrOf(buf[first]);
+ int last = len - 1;
+ int j;
+
+ for (j = first + 1; j < len; ++j) {
+ if (!SameAttrOf(buf[j], buf[first])) {
+ last = j - 1;
+ break;
+ }
+ }
+
+ result = _nc_trace_bufcat(bufnum, l_brace);
+ result = _nc_trace_bufcat(bufnum, d_quote);
+ for (j = first; j <= last; ++j) {
+ found = _nc_altcharset_name(attr, (chtype) CharOf(buf[j]));
+ if (found != 0) {
+ result = _nc_trace_bufcat(bufnum, found);
+ attr &= ~A_ALTCHARSET;
+ } else
+#if USE_WIDEC_SUPPORT
+ if (!isWidecExt(buf[j])) {
+ PUTC_DATA;
+
+ PUTC_INIT;
+ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
+ int k;
+
+ PUTC_ch = buf[j].chars[PUTC_i];
+ if (PUTC_ch == L'\0')
+ break;
+ PUTC_n = (int) wcrtomb(PUTC_buf, buf[j].chars[PUTC_i], &PUT_st);
+ if (PUTC_n <= 0)
+ break;
+ for (k = 0; k < PUTC_n; k++) {
+ char temp[80];
+ _nc_vischar(temp, sizeof(temp), UChar(PUTC_buf[k]));
+ result = _nc_trace_bufcat(bufnum, temp);
+ }
+ }
+ }
+#else
+ {
+ char temp[80];
+ _nc_vischar(temp, sizeof(temp), UChar(buf[j]));
+ result = _nc_trace_bufcat(bufnum, temp);
+ }
+#endif /* USE_WIDEC_SUPPORT */
+ }
+ result = _nc_trace_bufcat(bufnum, d_quote);
+ if (attr != A_NORMAL) {
+ result = _nc_trace_bufcat(bufnum, " | ");
+ result = _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
+ }
+ result = _nc_trace_bufcat(bufnum, r_brace);
+ first = last + 1;
+ }
+ }
+ return result;
+}
+
+NCURSES_EXPORT(const char *)
+_nc_viscbuf(const NCURSES_CH_T * buf, int len)
+{
+ return _nc_viscbuf2(0, buf, len);
+}
+#endif /* TRACE */
diff --git a/lib/libcurses/tty/MKexpanded.sh b/lib/libcurses/tty/MKexpanded.sh
index c9de5292ec3..bc6902b5bb7 100644
--- a/lib/libcurses/tty/MKexpanded.sh
+++ b/lib/libcurses/tty/MKexpanded.sh
@@ -1,6 +1,7 @@
#! /bin/sh
+# $OpenBSD: MKexpanded.sh,v 1.4 2010/01/12 23:22:07 nicm Exp $
##############################################################################
-# Copyright (c) 1998,2000 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -29,8 +30,7 @@
#
# Author: Thomas E. Dickey <dickey@clark.net> 1997
#
-# $OpenBSD: MKexpanded.sh,v 1.3 2001/01/22 18:01:59 millert Exp $
-# $From: MKexpanded.sh,v 1.10 2000/12/10 00:24:33 tom Exp $
+# $Id: MKexpanded.sh,v 1.4 2010/01/12 23:22:07 nicm Exp $
#
# Script to generate 'expanded.c', a dummy source that contains functions
# corresponding to complex macros used in this library. By making functions,
@@ -85,7 +85,7 @@ NCURSES_EXPORT(int) _nc_InsCharCost (int count)
{
return InsCharCost(count);
}
-NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype c)
+NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T c)
{
UpdateAttrs(c);
}
diff --git a/lib/libcurses/tty/hardscroll.c b/lib/libcurses/tty/hardscroll.c
index 2633ce851e9..35cb745db31 100644
--- a/lib/libcurses/tty/hardscroll.c
+++ b/lib/libcurses/tty/hardscroll.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: hardscroll.c,v 1.6 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: hardscroll.c,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
+ * and: Alexander V Lukyanov 1997-1998 *
****************************************************************************/
/******************************************************************************
@@ -147,7 +149,7 @@ AUTHOR
#include <curses.priv.h>
-MODULE_ID("$From: hardscroll.c,v 1.36 2001/01/14 00:17:28 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
#if defined(SCROLLDEBUG) || defined(HASHDEBUG)
@@ -160,22 +162,25 @@ oldnums[MAXLINES];
# undef TR
# define TR(n, a) if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+
#else /* no debug */
/* OLDNUM(n) indicates which line will be shifted to the position n.
if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from
somewhere. */
NCURSES_EXPORT_VAR(int *)
-_nc_oldnums = 0;
+_nc_oldnums = 0; /* obsolete: keep for ABI compat */
# if USE_HASHMAP
- static int oldnums_allocated = 0;
-# define oldnums _nc_oldnums
+# define oldnums SP->_oldnum_list
# define OLDNUM(n) oldnums[n]
# else /* !USE_HASHMAP */
# define OLDNUM(n) newscr->_line[n].oldindex
# endif /* !USE_HASHMAP */
+#define OLDNUM_SIZE SP->_oldnum_size
+
#endif /* defined(SCROLLDEBUG) || defined(HASHDEBUG) */
NCURSES_EXPORT(void)
@@ -185,17 +190,17 @@ _nc_scroll_optimize(void)
int i;
int start, end, shift;
- TR(TRACE_ICALLS, ("_nc_scroll_optimize() begins"));
+ TR(TRACE_ICALLS, (T_CALLED("_nc_scroll_optimize")));
#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
#if USE_HASHMAP
/* get enough storage */
- if (oldnums_allocated < screen_lines) {
+ if (OLDNUM_SIZE < screen_lines) {
int *new_oldnums = typeRealloc(int, screen_lines, oldnums);
if (!new_oldnums)
return;
oldnums = new_oldnums;
- oldnums_allocated = screen_lines;
+ OLDNUM_SIZE = screen_lines;
}
/* calculate the indices */
_nc_hash_map();
@@ -203,8 +208,10 @@ _nc_scroll_optimize(void)
#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
#ifdef TRACE
- if (_nc_tracing & (TRACE_UPDATE | TRACE_MOVE))
+ if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
_nc_linedump();
+ _nc_unlock_global(tracef);
+ }
#endif /* TRACE */
/* pass 1 - from top to bottom scrolling up */
@@ -255,6 +262,7 @@ _nc_scroll_optimize(void)
}
#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
}
+ TR(TRACE_ICALLS, (T_RETURN("")));
}
#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
@@ -262,24 +270,18 @@ NCURSES_EXPORT(void)
_nc_linedump(void)
/* dump the state of the real and virtual oldnum fields */
{
- static size_t have;
- static char *buf;
-
int n;
+ char *buf = 0;
size_t want = (screen_lines + 1) * 4;
- if (have < want)
- buf = typeMalloc(char, have = want);
-
- (void) strlcpy(buf, "virt", have);
- for (n = 0; n < screen_lines; n++)
- (void) snprintf(buf + strlen(buf), have - strlen(buf), " %02d",
- OLDNUM(n));
- TR(TRACE_UPDATE | TRACE_MOVE, (buf));
-#if NO_LEAKS
- free(buf);
- have = 0;
-#endif
+ if ((buf = typeMalloc(char, want)) != 0) {
+
+ (void) strlcpy(buf, "virt", want);
+ for (n = 0; n < screen_lines; n++)
+ (void) snprintf(buf + strlen(buf), want - strlen(buf), " %02d", OLDNUM(n));
+ TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+ free(buf);
+ }
}
#endif /* defined(TRACE) || defined(SCROLLDEBUG) */
diff --git a/lib/libcurses/tty/hashmap.c b/lib/libcurses/tty/hashmap.c
index bf57cefdbe2..14739fa35a3 100644
--- a/lib/libcurses/tty/hashmap.c
+++ b/lib/libcurses/tty/hashmap.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: hashmap.c,v 1.7 2002/06/22 18:13:05 deraadt Exp $ */
+/* $OpenBSD: hashmap.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -72,7 +72,7 @@ AUTHOR
#include <curses.priv.h>
#include <term.h> /* for back_color_erase */
-MODULE_ID("$From: hashmap.c,v 1.36 2000/12/10 03:04:30 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
#ifdef HASHDEBUG
@@ -83,7 +83,8 @@ MODULE_ID("$From: hashmap.c,v 1.36 2000/12/10 03:04:30 tom Exp $")
# define screen_lines MAXLINES
# define TEXTWIDTH 1
int oldnums[MAXLINES], reallines[MAXLINES];
-static chtype oldtext[MAXLINES][TEXTWIDTH], newtext[MAXLINES][TEXTWIDTH];
+static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH];
+static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH];
# define OLDNUM(n) oldnums[n]
# define OLDTEXT(n) oldtext[n]
# define NEWTEXT(m) newtext[m]
@@ -91,7 +92,7 @@ static chtype oldtext[MAXLINES][TEXTWIDTH], newtext[MAXLINES][TEXTWIDTH];
#else /* !HASHDEBUG */
-# define OLDNUM(n) _nc_oldnums[n]
+# define OLDNUM(n) SP->_oldnum_list[n]
# define OLDTEXT(n) curscr->_line[n].text
# define NEWTEXT(m) newscr->_line[m].text
# define TEXTWIDTH (curscr->_maxx+1)
@@ -99,47 +100,58 @@ static chtype oldtext[MAXLINES][TEXTWIDTH], newtext[MAXLINES][TEXTWIDTH];
#endif /* !HASHDEBUG */
-#define oldhash (SP->oldhash)
-#define newhash (SP->newhash)
+#define oldhash (SP->oldhash)
+#define newhash (SP->newhash)
+#define hashtab (SP->hashtab)
+#define lines_alloc (SP->hashtab_len)
-static inline unsigned long
-hash(chtype * text)
+#if USE_WIDEC_SUPPORT
+#define HASH_VAL(ch) (ch.chars[0])
+#else
+#define HASH_VAL(ch) (ch)
+#endif
+
+static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
+
+static NCURSES_INLINE unsigned long
+hash(NCURSES_CH_T * text)
{
int i;
- chtype ch;
+ NCURSES_CH_T ch;
unsigned long result = 0;
for (i = TEXTWIDTH; i > 0; i--) {
ch = *text++;
- result += (result << 5) + ch;
+ result += (result << 5) + HASH_VAL(ch);
}
return result;
}
/* approximate update cost */
static int
-update_cost(chtype * from, chtype * to)
+update_cost(NCURSES_CH_T * from, NCURSES_CH_T * to)
{
int cost = 0;
int i;
- for (i = TEXTWIDTH; i > 0; i--)
- if (*from++ != *to++)
+ for (i = TEXTWIDTH; i > 0; i--, from++, to++)
+ if (!(CharEq(*from, *to)))
cost++;
return cost;
}
+
static int
-update_cost_from_blank(chtype * to)
+update_cost_from_blank(NCURSES_CH_T * to)
{
int cost = 0;
int i;
- chtype blank = BLANK;
+ NCURSES_CH_T blank = blankchar;
if (back_color_erase)
- blank |= (stdscr->_bkgd & A_COLOR);
+ SetPair(blank, GetPair(stdscr->_nc_bkgd));
- for (i = TEXTWIDTH; i > 0; i--)
- if (blank != *to++)
+ for (i = TEXTWIDTH; i > 0; i--, to++)
+ if (!(CharEq(blank, *to)))
cost++;
return cost;
@@ -149,7 +161,7 @@ update_cost_from_blank(chtype * to)
* Returns true when moving line 'from' to line 'to' seems to be cost
* effective. 'blank' indicates whether the line 'to' would become blank.
*/
-static inline bool
+static NCURSES_INLINE bool
cost_effective(const int from, const int to, const bool blank)
{
int new_from;
@@ -173,15 +185,6 @@ cost_effective(const int from, const int to, const bool blank)
+ update_cost(OLDTEXT(from), NEWTEXT(to)))) ? TRUE : FALSE;
}
-typedef struct {
- unsigned long hashval;
- int oldcount, newcount;
- int oldindex, newindex;
-} sym;
-
-static sym *hashtab = 0;
-static int lines_alloc = 0;
-
static void
grow_hunks(void)
{
@@ -269,14 +272,14 @@ grow_hunks(void)
NCURSES_EXPORT(void)
_nc_hash_map(void)
{
- sym *sp;
+ HASHMAP *sp;
register int i;
int start, shift, size;
if (screen_lines > lines_alloc) {
if (hashtab)
free(hashtab);
- hashtab = typeMalloc(sym, (screen_lines + 1) * 2);
+ hashtab = typeMalloc(HASHMAP, (screen_lines + 1) * 2);
if (!hashtab) {
if (oldhash) {
FreeAndNull(oldhash);
@@ -296,9 +299,9 @@ _nc_hash_map(void)
} else {
/* re-hash all */
if (oldhash == 0)
- oldhash = typeCalloc(unsigned long, screen_lines);
+ oldhash = typeCalloc(unsigned long, (unsigned) screen_lines);
if (newhash == 0)
- newhash = typeCalloc(unsigned long, screen_lines);
+ newhash = typeCalloc(unsigned long, (unsigned) screen_lines);
if (!oldhash || !newhash)
return; /* malloc failure */
for (i = 0; i < screen_lines; i++) {
@@ -389,11 +392,6 @@ _nc_hash_map(void)
/* After clearing invalid hunks, try grow the rest. */
grow_hunks();
-
-#if NO_LEAKS
- FreeAndNull(hashtab);
- lines_alloc = 0;
-#endif
}
NCURSES_EXPORT(void)
@@ -406,7 +404,7 @@ _nc_make_oldhash(int i)
NCURSES_EXPORT(void)
_nc_scroll_oldhash(int n, int top, int bot)
{
- int size;
+ size_t size;
int i;
if (!oldhash)
@@ -451,11 +449,14 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
char line[BUFSIZ], *st, *last;
int n;
- SP = typeCalloc(SCREEN, 1);
+ if (setupterm(NULL, fileno(stdout), (int *) 0) == ERR)
+ return EXIT_FAILURE;
+ (void) _nc_alloc_screen();
+
for (n = 0; n < screen_lines; n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
- oldtext[n][0] = newtext[n][0] = '.';
+ CharOf(oldtext[n][0]) = CharOf(newtext[n][0]) = '.';
}
if (isatty(fileno(stdin)))
@@ -467,7 +468,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
for (;;) {
/* grab a test command */
if (fgets(line, sizeof(line), stdin) == (char *) NULL)
- exit(EXIT_SUCCESS);
+ break;
switch (line[0]) {
case '#': /* comment */
@@ -489,22 +490,22 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
case 'n': /* use following letters as text of new lines */
for (n = 0; n < screen_lines; n++)
- newtext[n][0] = '.';
+ CharOf(newtext[n][0]) = '.';
for (n = 0; n < screen_lines; n++)
if (line[n + 1] == '\n')
break;
else
- newtext[n][0] = line[n + 1];
+ CharOf(newtext[n][0]) = line[n + 1];
break;
case 'o': /* use following letters as text of old lines */
for (n = 0; n < screen_lines; n++)
- oldtext[n][0] = '.';
+ CharOf(oldtext[n][0]) = '.';
for (n = 0; n < screen_lines; n++)
if (line[n + 1] == '\n')
break;
else
- oldtext[n][0] = line[n + 1];
+ CharOf(oldtext[n][0]) = line[n + 1];
break;
case 'd': /* dump state of test arrays */
@@ -513,12 +514,12 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
#endif
(void) fputs("Old lines: [", stdout);
for (n = 0; n < screen_lines; n++)
- putchar(oldtext[n][0]);
+ putchar(CharOf(oldtext[n][0]));
putchar(']');
putchar('\n');
(void) fputs("New lines: [", stdout);
for (n = 0; n < screen_lines; n++)
- putchar(newtext[n][0]);
+ putchar(CharOf(newtext[n][0]));
putchar(']');
putchar('\n');
break;
@@ -532,12 +533,17 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
_nc_scroll_optimize();
(void) fputs("Done.\n", stderr);
break;
+ default:
case '?':
usage();
break;
}
}
+#if NO_LEAKS
+ _nc_free_and_exit(EXIT_SUCCESS);
+#else
return EXIT_SUCCESS;
+#endif
}
#endif /* HASHDEBUG */
diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c
index df0a3080ade..bd0b4334345 100644
--- a/lib/libcurses/tty/lib_mvcur.c
+++ b/lib/libcurses/tty/lib_mvcur.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_mvcur.c,v 1.12 2007/05/17 04:34:50 ray Exp $ */
+/* $OpenBSD: lib_mvcur.c,v 1.13 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -110,7 +111,9 @@
* LONG_DIST and (b) further inward from the right or left edge than LONG_DIST,
* we'll consider nonlocal.
*/
-#define NOT_LOCAL(fy, fx, ty, tx) ((tx > LONG_DIST) && (tx < screen_lines - 1 - LONG_DIST) && (abs(ty-fy) + abs(tx-fx) > LONG_DIST))
+#define NOT_LOCAL(fy, fx, ty, tx) ((tx > LONG_DIST) \
+ && (tx < screen_columns - 1 - LONG_DIST) \
+ && (abs(ty-fy) + abs(tx-fx) > LONG_DIST))
/****************************************************************************
*
@@ -154,12 +157,8 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$From: lib_mvcur.c,v 1.77 2000/12/10 03:04:30 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.13 2010/01/12 23:22:07 nicm Exp $")
-#define CURRENT_ROW SP->_cursrow /* phys cursor row */
-#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
-#define CURRENT_ATTR SP->_current_attr /* current phys attribute */
-#define REAL_ATTR SP->_current_attr /* phys current attribute */
#define WANT_CHAR(y, x) SP->_newscr->_line[y].text[x] /* desired state */
#define BAUDRATE cur_term->_baudrate /* bits per second */
@@ -209,8 +208,7 @@ trace_normalized_cost(const char *capname, const char *cap, int affcnt)
#endif
NCURSES_EXPORT(int)
-_nc_msec_cost
-(const char *const cap, int affcnt)
+_nc_msec_cost(const char *const cap, int affcnt)
/* compute the cost of a given operation */
{
if (cap == 0)
@@ -225,16 +223,16 @@ _nc_msec_cost
float number = 0.0;
for (cp += 2; *cp != '>'; cp++) {
- if (isdigit(CharOf(*cp)))
+ if (isdigit(UChar(*cp)))
number = number * 10 + (*cp - '0');
else if (*cp == '*')
number *= affcnt;
- else if (*cp == '.' && (*++cp != '>') && isdigit(CharOf(*cp)))
+ else if (*cp == '.' && (*++cp != '>') && isdigit(UChar(*cp)))
number += (*cp - '0') / 10.0;
}
#if NCURSES_NO_PADDING
- if (!(SP->_no_padding))
+ if (!GetNoPadding(SP))
#endif
cum_cost += number * 10;
} else
@@ -261,7 +259,7 @@ reset_scroll_region(void)
{
if (change_scroll_region) {
TPUTS_TRACE("change_scroll_region");
- putp(tparm(change_scroll_region, 0, screen_lines - 1));
+ putp(TPARM_2(change_scroll_region, 0, screen_lines - 1));
}
}
@@ -299,10 +297,11 @@ NCURSES_EXPORT(void)
_nc_mvcur_init(void)
/* initialize the cost structure */
{
- /*
- * 9 = 7 bits + 1 parity + 1 stop.
- */
- SP->_char_padding = (9 * 1000 * 10) / (BAUDRATE > 0 ? BAUDRATE : 9600);
+ if (isatty(fileno(SP->_ofp)))
+ SP->_char_padding = ((BAUDBYTE * 1000 * 10)
+ / (BAUDRATE > 0 ? BAUDRATE : 9600));
+ else
+ SP->_char_padding = 1; /* must be nonzero */
if (SP->_char_padding <= 0)
SP->_char_padding = 1; /* must be nonzero */
TR(TRACE_CHARPUT | TRACE_MOVE, ("char_padding %d msecs", SP->_char_padding));
@@ -312,8 +311,13 @@ _nc_mvcur_init(void)
SP->_home_cost = CostOf(cursor_home, 0);
SP->_ll_cost = CostOf(cursor_to_ll, 0);
#if USE_HARD_TABS
- SP->_ht_cost = CostOf(tab, 0);
- SP->_cbt_cost = CostOf(back_tab, 0);
+ if (getenv("NCURSES_NO_HARD_TABS") == 0) {
+ SP->_ht_cost = CostOf(tab, 0);
+ SP->_cbt_cost = CostOf(back_tab, 0);
+ } else {
+ SP->_ht_cost = INFINITY;
+ SP->_cbt_cost = INFINITY;
+ }
#endif /* USE_HARD_TABS */
SP->_cub1_cost = CostOf(cursor_left, 0);
SP->_cuf1_cost = CostOf(cursor_right, 0);
@@ -359,13 +363,13 @@ _nc_mvcur_init(void)
* All these averages depend on the assumption that all parameter values
* are equally probable.
*/
- SP->_cup_cost = CostOf(tparm(SP->_address_cursor, 23, 23), 1);
- SP->_cub_cost = CostOf(tparm(parm_left_cursor, 23), 1);
- SP->_cuf_cost = CostOf(tparm(parm_right_cursor, 23), 1);
- SP->_cud_cost = CostOf(tparm(parm_down_cursor, 23), 1);
- SP->_cuu_cost = CostOf(tparm(parm_up_cursor, 23), 1);
- SP->_hpa_cost = CostOf(tparm(column_address, 23), 1);
- SP->_vpa_cost = CostOf(tparm(row_address, 23), 1);
+ SP->_cup_cost = CostOf(TPARM_2(SP->_address_cursor, 23, 23), 1);
+ SP->_cub_cost = CostOf(TPARM_1(parm_left_cursor, 23), 1);
+ SP->_cuf_cost = CostOf(TPARM_1(parm_right_cursor, 23), 1);
+ SP->_cud_cost = CostOf(TPARM_1(parm_down_cursor, 23), 1);
+ SP->_cuu_cost = CostOf(TPARM_1(parm_up_cursor, 23), 1);
+ SP->_hpa_cost = CostOf(TPARM_1(column_address, 23), 1);
+ SP->_vpa_cost = CostOf(TPARM_1(row_address, 23), 1);
/* non-parameterized screen-update strings */
SP->_ed_cost = NormalizedCost(clr_eos, 1);
@@ -374,15 +378,22 @@ _nc_mvcur_init(void)
SP->_dch1_cost = NormalizedCost(delete_character, 1);
SP->_ich1_cost = NormalizedCost(insert_character, 1);
+ /*
+ * If this is a bce-terminal, we want to bias the choice so we use clr_eol
+ * rather than spaces at the end of a line.
+ */
+ if (back_color_erase)
+ SP->_el_cost = 0;
+
/* parameterized screen-update strings */
- SP->_dch_cost = NormalizedCost(tparm(parm_dch, 23), 1);
- SP->_ich_cost = NormalizedCost(tparm(parm_ich, 23), 1);
- SP->_ech_cost = NormalizedCost(tparm(erase_chars, 23), 1);
- SP->_rep_cost = NormalizedCost(tparm(repeat_char, ' ', 23), 1);
-
- SP->_cup_ch_cost = NormalizedCost(tparm(SP->_address_cursor, 23, 23), 1);
- SP->_hpa_ch_cost = NormalizedCost(tparm(column_address, 23), 1);
- SP->_cuf_ch_cost = NormalizedCost(tparm(parm_right_cursor, 23), 1);
+ SP->_dch_cost = NormalizedCost(TPARM_1(parm_dch, 23), 1);
+ SP->_ich_cost = NormalizedCost(TPARM_1(parm_ich, 23), 1);
+ SP->_ech_cost = NormalizedCost(TPARM_1(erase_chars, 23), 1);
+ SP->_rep_cost = NormalizedCost(TPARM_2(repeat_char, ' ', 23), 1);
+
+ SP->_cup_ch_cost = NormalizedCost(TPARM_2(SP->_address_cursor, 23, 23), 1);
+ SP->_hpa_ch_cost = NormalizedCost(TPARM_1(column_address, 23), 1);
+ SP->_cuf_ch_cost = NormalizedCost(TPARM_1(parm_right_cursor, 23), 1);
SP->_inline_cost = min(SP->_cup_ch_cost,
min(SP->_hpa_ch_cost,
SP->_cuf_ch_cost));
@@ -417,8 +428,11 @@ _nc_mvcur_wrap(void)
mvcur(-1, -1, screen_lines - 1, 0);
/* set cursor to normal mode */
- if (SP->_cursor != -1)
+ if (SP->_cursor != -1) {
+ int cursor = SP->_cursor;
curs_set(1);
+ SP->_cursor = cursor;
+ }
if (exit_ca_mode) {
TPUTS_TRACE("exit_ca_mode");
@@ -444,7 +458,7 @@ _nc_mvcur_wrap(void)
/*
* Perform repeated-append, returning cost
*/
-static inline int
+static NCURSES_INLINE int
repeated_append(string_desc * target, int total, int num, int repeat, const char *src)
{
size_t need = repeat * strlen(src);
@@ -487,7 +501,7 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
vcost = INFINITY;
if (row_address != 0
- && _nc_safe_strcat(target, tparm(row_address, to_y))) {
+ && _nc_safe_strcat(target, TPARM_1(row_address, to_y))) {
vcost = SP->_vpa_cost;
}
@@ -497,11 +511,13 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
if (parm_down_cursor
&& SP->_cud_cost < vcost
&& _nc_safe_strcat(_nc_str_copy(target, &save),
- tparm(parm_down_cursor, n))) {
+ TPARM_1(parm_down_cursor, n))) {
vcost = SP->_cud_cost;
}
- if (cursor_down && (n * SP->_cud1_cost < vcost)) {
+ if (cursor_down
+ && (*cursor_down != '\n' || SP->_nl)
+ && (n * SP->_cud1_cost < vcost)) {
vcost = repeated_append(_nc_str_copy(target, &save), 0,
SP->_cud1_cost, n, cursor_down);
}
@@ -509,10 +525,10 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
n = (from_y - to_y);
if (parm_up_cursor
- && SP->_cup_cost < vcost
+ && SP->_cuu_cost < vcost
&& _nc_safe_strcat(_nc_str_copy(target, &save),
- tparm(parm_up_cursor, n))) {
- vcost = SP->_cup_cost;
+ TPARM_1(parm_up_cursor, n))) {
+ vcost = SP->_cuu_cost;
}
if (cursor_up && (n * SP->_cuu1_cost < vcost)) {
@@ -535,7 +551,7 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
if (column_address
&& _nc_safe_strcat(_nc_str_copy(target, &save),
- tparm(column_address, to_x))) {
+ TPARM_1(column_address, to_x))) {
hcost = SP->_hpa_cost;
}
@@ -545,7 +561,7 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
if (parm_right_cursor
&& SP->_cuf_cost < hcost
&& _nc_safe_strcat(_nc_str_copy(target, &save),
- tparm(parm_right_cursor, n))) {
+ TPARM_1(parm_right_cursor, n))) {
hcost = SP->_cuf_cost;
}
@@ -571,7 +587,6 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
}
#endif /* USE_HARD_TABS */
-#if defined(REAL_ATTR) && defined(WANT_CHAR)
if (n <= 0 || n >= (int) check.s_size)
ovw = FALSE;
#if BSD_TPUTS
@@ -585,9 +600,11 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
&& n > 0
&& n < (int) check.s_size
&& vcost == 0
- && str[0] == '\0'
- && isdigit(TextOf(WANT_CHAR(to_y, from_x))))
- ovw = FALSE;
+ && str[0] == '\0') {
+ int wanted = CharOf(WANT_CHAR(to_y, from_x));
+ if (is8bits(wanted) && isdigit(wanted))
+ ovw = FALSE;
+ }
#endif
/*
* If we have no attribute changes, overwrite is cheaper.
@@ -600,23 +617,28 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
if (ovw) {
int i;
- for (i = 0; i < n; i++)
- if ((WANT_CHAR(to_y, from_x + i) & A_ATTRIBUTES) != CURRENT_ATTR) {
+ for (i = 0; i < n; i++) {
+ NCURSES_CH_T ch = WANT_CHAR(to_y, from_x + i);
+ if (!SameAttrOf(ch, SCREEN_ATTRS(SP))
+#if USE_WIDEC_SUPPORT
+ || !Charable(ch)
+#endif
+ ) {
ovw = FALSE;
break;
}
+ }
}
if (ovw) {
int i;
for (i = 0; i < n; i++)
- *check.s_tail++ = WANT_CHAR(to_y, from_x + i);
+ *check.s_tail++ = (char) CharOf(WANT_CHAR(to_y,
+ from_x + i));
*check.s_tail = '\0';
check.s_size -= n;
lhcost += n * SP->_char_padding;
- } else
-#endif /* defined(REAL_ATTR) && defined(WANT_CHAR) */
- {
+ } else {
lhcost = repeated_append(&check, lhcost, SP->_cuf1_cost,
n, cursor_right);
}
@@ -632,7 +654,7 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
if (parm_left_cursor
&& SP->_cub_cost < hcost
&& _nc_safe_strcat(_nc_str_copy(target, &save),
- tparm(parm_left_cursor, n))) {
+ TPARM_1(parm_left_cursor, n))) {
hcost = SP->_cub_cost;
}
@@ -684,7 +706,7 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
* the simpler method below.
*/
-static inline int
+static NCURSES_INLINE int
onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
/* onscreen move from (yold, xold) to (ynew, xnew) */
{
@@ -703,7 +725,7 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
#define InitResult _nc_str_init(&result, buffer, sizeof(buffer))
/* tactic #0: use direct cursor addressing */
- if (_nc_safe_strcpy(InitResult, tparm(SP->_address_cursor, ynew, xnew))) {
+ if (_nc_safe_strcpy(InitResult, TPARM_2(SP->_address_cursor, ynew, xnew))) {
tactic = 0;
usecost = SP->_cup_cost;
@@ -812,78 +834,122 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
}
#endif /* !NO_OPTIMIZE */
+ nonlocal:
#if defined(MAIN) || defined(NCURSES_TEST)
gettimeofday(&after, NULL);
diff = after.tv_usec - before.tv_usec
+ (after.tv_sec - before.tv_sec) * 1000000;
if (!profiling)
(void) fprintf(stderr,
- "onscreen: %d msec, %f 28.8Kbps char-equivalents\n",
+ "onscreen: %d microsec, %f 28.8Kbps char-equivalents\n",
(int) diff, diff / 288);
#endif /* MAIN */
- nonlocal:
if (usecost != INFINITY) {
TPUTS_TRACE("mvcur");
tputs(buffer, 1, _nc_outch);
+ SP->_cursrow = ynew;
+ SP->_curscol = xnew;
return (OK);
} else
return (ERR);
}
NCURSES_EXPORT(int)
-mvcur
-(int yold, int xold, int ynew, int xnew)
+mvcur(int yold, int xold, int ynew, int xnew)
/* optimized cursor move from (yold, xold) to (ynew, xnew) */
{
- TR(TRACE_MOVE, ("mvcur(%d,%d,%d,%d) called", yold, xold, ynew, xnew));
+ NCURSES_CH_T oldattr;
+ int code;
- if (yold == ynew && xold == xnew)
- return (OK);
+ TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
+ yold, xold, ynew, xnew));
- /*
- * Most work here is rounding for terminal boundaries getting the
- * column position implied by wraparound or the lack thereof and
- * rolling up the screen to get ynew on the screen.
- */
+ if (SP == 0) {
+ code = ERR;
+ } else if (yold == ynew && xold == xnew) {
+ code = OK;
+ } else {
- if (xnew >= screen_columns) {
- ynew += xnew / screen_columns;
- xnew %= screen_columns;
- }
- if (xold >= screen_columns) {
- int l;
-
- l = (xold + 1) / screen_columns;
- yold += l;
- if (yold >= screen_lines)
- l -= (yold - screen_lines - 1);
-
- while (l > 0) {
- if (newline) {
- TPUTS_TRACE("newline");
- tputs(newline, 0, _nc_outch);
- } else
- putchar('\n');
- l--;
- if (xold > 0) {
- if (carriage_return) {
- TPUTS_TRACE("carriage_return");
- tputs(carriage_return, 0, _nc_outch);
- } else
- putchar('\r');
- xold = 0;
+ /*
+ * Most work here is rounding for terminal boundaries getting the
+ * column position implied by wraparound or the lack thereof and
+ * rolling up the screen to get ynew on the screen.
+ */
+ if (xnew >= screen_columns) {
+ ynew += xnew / screen_columns;
+ xnew %= screen_columns;
+ }
+
+ /*
+ * Force restore even if msgr is on when we're in an alternate
+ * character set -- these have a strong tendency to screw up the CR &
+ * LF used for local character motions!
+ */
+ oldattr = SCREEN_ATTRS(SP);
+ if ((AttrOf(oldattr) & A_ALTCHARSET)
+ || (AttrOf(oldattr) && !move_standout_mode)) {
+ TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
+ (unsigned long) AttrOf(oldattr),
+ _traceattr(AttrOf(oldattr))));
+ (void) VIDATTR(A_NORMAL, 0);
+ }
+
+ if (xold >= screen_columns) {
+ int l;
+
+ if (SP->_nl) {
+ l = (xold + 1) / screen_columns;
+ yold += l;
+ if (yold >= screen_lines)
+ l -= (yold - screen_lines - 1);
+
+ if (l > 0) {
+ if (carriage_return) {
+ TPUTS_TRACE("carriage_return");
+ putp(carriage_return);
+ } else
+ _nc_outch('\r');
+ xold = 0;
+
+ while (l > 0) {
+ if (newline) {
+ TPUTS_TRACE("newline");
+ putp(newline);
+ } else
+ _nc_outch('\n');
+ l--;
+ }
+ }
+ } else {
+ /*
+ * If caller set nonl(), we cannot really use newlines to
+ * position to the next row.
+ */
+ xold = -1;
+ yold = -1;
}
}
- }
- if (yold > screen_lines - 1)
- yold = screen_lines - 1;
- if (ynew > screen_lines - 1)
- ynew = screen_lines - 1;
+ if (yold > screen_lines - 1)
+ yold = screen_lines - 1;
+ if (ynew > screen_lines - 1)
+ ynew = screen_lines - 1;
- /* destination location is on screen now */
- return (onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
+ /* destination location is on screen now */
+ code = onscreen_mvcur(yold, xold, ynew, xnew, TRUE);
+
+ /*
+ * Restore attributes if we disabled them before moving.
+ */
+ if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP))) {
+ TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move",
+ (unsigned long) AttrOf(oldattr),
+ _traceattr(AttrOf(oldattr))));
+ (void) VIDATTR(AttrOf(oldattr), GetPair(oldattr));
+ }
+ }
+ returnCode(code);
}
#if defined(TRACE) || defined(NCURSES_TEST)
@@ -899,16 +965,15 @@ NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL;
#include <tic.h>
#include <dump_entry.h>
+#include <time.h>
-NCURSES_EXPORT_VAR(const char *)
-_nc_progname = "mvcur";
+NCURSES_EXPORT_VAR(const char *) _nc_progname = "mvcur";
- static unsigned long xmits;
+static unsigned long xmits;
/* these override lib_tputs.c */
NCURSES_EXPORT(int)
-tputs
-(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
+tputs(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
/* stub tputs() that dumps sequences in a visible form */
{
if (profiling)
@@ -931,18 +996,13 @@ _nc_outch(int ch)
return OK;
}
-NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
-NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
-NCURSES_EXPORT_VAR(int)
-_nc_nulls_sent = 0; /* used by 'tack' program */
-
NCURSES_EXPORT(int)
delay_output(int ms GCC_UNUSED)
{
return OK;
}
-static char tname[MAX_ALIAS];
+static char tname[PATH_MAX];
static void
load_term(void)
@@ -964,9 +1024,9 @@ roll(int n)
int
main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
{
- (void) strlcpy(tname, termname(), sizeof(tname));
+ strlcpy(tname, sizeof(tname), getenv("TERM"));
load_term();
- _nc_setupscreen(lines, columns, stdout);
+ _nc_setupscreen(lines, columns, stdout, FALSE, 0);
baudrate();
_nc_mvcur_init();
@@ -983,9 +1043,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
(void) fputs("> ", stdout);
if (fgets(buf, sizeof(buf), stdin) == NULL) {
- if (ferror(stdin))
- fputs("ferror on stdin", stderr);
- break;
+ if (ferror(stdin))
+ fputs("ferror on stdin", stderr);
+ break;
}
if (buf[0] == '?') {
@@ -1033,13 +1093,13 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
before.tv_sec)
* 1000000));
} else if (buf[0] == 'r') {
- (void) strlcpy(tname, termname(), sizeof(tname));
+ (void) strlcpy(tname, sizeof(tname), termname());
load_term();
} else if (sscanf(buf, "l %s", tname) == 1) {
load_term();
} else if (sscanf(buf, "d %s", capname) == 1) {
struct name_table_entry const *np = _nc_find_entry(capname,
- _nc_info_hash_table);
+ _nc_get_hash_table(FALSE));
if (np == NULL)
(void) printf("No such capability as \"%s\"\n", capname);
@@ -1067,7 +1127,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
}
} else if (buf[0] == 'i') {
dump_init((char *) NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
- dump_entry(&cur_term->type, FALSE, TRUE, 0);
+ dump_entry(&cur_term->type, FALSE, TRUE, 0, 0);
putchar('\n');
} else if (buf[0] == 'o') {
if (_nc_optimize_enable & OPTIMIZE_MVCUR) {
diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c
index 0e862bbcde5..a6126846461 100644
--- a/lib/libcurses/tty/lib_tstp.c
+++ b/lib/libcurses/tty/lib_tstp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tstp.c,v 1.9 2001/12/06 04:26:00 deraadt Exp $ */
+/* $OpenBSD: lib_tstp.c,v 1.10 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1995-on *
****************************************************************************/
/*
@@ -39,17 +40,15 @@
** The routine _nc_signal_handler().
**
*/
-
#include <curses.priv.h>
-#include <signal.h>
#include <SigAction.h>
#if SVR4_ACTION && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
-MODULE_ID("$From: lib_tstp.c,v 1.24 2000/12/10 03:04:30 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.10 2010/01/12 23:22:07 nicm Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -57,6 +56,41 @@ MODULE_ID("$From: lib_tstp.c,v 1.24 2000/12/10 03:04:30 tom Exp $")
#define USE_SIGTSTP 0
#endif
+#ifdef TRACE
+static const char *
+signal_name(int sig)
+{
+ switch (sig) {
+ case SIGALRM:
+ return "SIGALRM";
+#ifdef SIGCONT
+ case SIGCONT:
+ return "SIGCONT";
+#endif
+ case SIGINT:
+ return "SIGINT";
+ case SIGQUIT:
+ return "SIGQUIT";
+ case SIGTERM:
+ return "SIGTERM";
+#ifdef SIGTSTP
+ case SIGTSTP:
+ return "SIGTSTP";
+#endif
+#ifdef SIGTTOU
+ case SIGTTOU:
+ return "SIGTTOU";
+#endif
+#ifdef SIGWINCH
+ case SIGWINCH:
+ return "SIGWINCH";
+#endif
+ default:
+ return "unknown signal";
+ }
+}
+#endif
+
/*
* Note: This code is fragile! Its problem is that different OSs
* handle restart of system calls interrupted by signals differently.
@@ -202,16 +236,14 @@ tstp(int dummy GCC_UNUSED)
static void
cleanup(int sig)
{
- static int nested;
-
/*
- * XXX signal race. The kind of comment is completely ingenius!
+ * XXX signal race. This kind of comment is completely ingenious!
*
* Actually, doing any sort of I/O from within an signal handler is
* "unsafe". But we'll _try_ to clean up the screen and terminal
* settings on the way out.
*/
- if (!nested++
+ if (!_nc_globals.cleanup_nested++
&& (sig == SIGINT
|| sig == SIGQUIT)) {
#if HAVE_SIGACTION || HAVE_SIGVEC
@@ -219,24 +251,22 @@ cleanup(int sig)
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = SIG_IGN;
- if (sigaction(sig, &act, (sigaction_t *) 0) == 0)
+ if (sigaction(sig, &act, NULL) == 0)
#else
if (signal(sig, SIG_IGN) != SIG_ERR)
#endif
{
- SCREEN *scan = _nc_screen_chain;
- while (scan) {
- if (SP != 0
- && SP->_ofp != 0
- && isatty(fileno(SP->_ofp))) {
- SP->_cleanup = TRUE;
- SP->_outch = _nc_outch;
+ SCREEN *scan;
+ for (each_screen(scan)) {
+ if (scan->_ofp != 0
+ && isatty(fileno(scan->_ofp))) {
+ scan->_cleanup = TRUE;
+ scan->_outch = _nc_outch;
}
set_term(scan);
endwin();
if (SP)
SP->_endwin = FALSE; /* in case we have an atexit! */
- scan = scan->_next_screen;
}
}
}
@@ -247,11 +277,7 @@ cleanup(int sig)
static void
sigwinch(int sig GCC_UNUSED)
{
- SCREEN *scan = _nc_screen_chain;
- while (scan) {
- scan->_sig_winch = TRUE;
- scan = scan->_next_screen;
- }
+ _nc_globals.have_sigwinch = 1;
}
#endif /* USE_SIGWINCH */
@@ -259,43 +285,57 @@ sigwinch(int sig GCC_UNUSED)
* If the given signal is still in its default state, set it to the given
* handler.
*/
-#if HAVE_SIGACTION || HAVE_SIGVEC
static int
-CatchIfDefault(int sig, sigaction_t * act)
+CatchIfDefault(int sig, RETSIGTYPE (*handler) (int))
{
+ int result;
+#if HAVE_SIGACTION || HAVE_SIGVEC
sigaction_t old_act;
+ sigaction_t new_act;
+
+ memset(&new_act, 0, sizeof(new_act));
+ sigemptyset(&new_act.sa_mask);
+#ifdef SA_RESTART
+#ifdef SIGWINCH
+ if (sig != SIGWINCH)
+#endif
+ new_act.sa_flags |= SA_RESTART;
+#endif /* SA_RESTART */
+ new_act.sa_handler = handler;
- if (sigaction(sig, (sigaction_t *) 0, &old_act) == 0
+ if (sigaction(sig, NULL, &old_act) == 0
&& (old_act.sa_handler == SIG_DFL
+ || old_act.sa_handler == handler
#if USE_SIGWINCH
|| (sig == SIGWINCH && old_act.sa_handler == SIG_IGN)
#endif
)) {
- (void) sigaction(sig, act, (sigaction_t *) 0);
- return TRUE;
+ (void) sigaction(sig, &new_act, NULL);
+ result = TRUE;
+ } else {
+ result = FALSE;
}
- return FALSE;
-}
-#else
-static int
-CatchIfDefault(int sig, RETSIGTYPE(*handler) (int))
-{
- void (*ohandler) (int);
+#else /* !HAVE_SIGACTION */
+ RETSIGTYPE (*ohandler) (int);
ohandler = signal(sig, SIG_IGN);
if (ohandler == SIG_DFL
+ || ohandler == handler
#if USE_SIGWINCH
|| (sig == SIGWINCH && ohandler == SIG_IGN)
#endif
) {
signal(sig, handler);
- return TRUE;
+ result = TRUE;
} else {
signal(sig, ohandler);
- return FALSE;
+ result = FALSE;
}
-}
#endif
+ T(("CatchIfDefault - will %scatch %s",
+ result ? "" : "not ", signal_name(sig)));
+ return result;
+}
/*
* This is invoked once at the beginning (e.g., from 'initscr()'), to
@@ -311,60 +351,43 @@ CatchIfDefault(int sig, RETSIGTYPE(*handler) (int))
NCURSES_EXPORT(void)
_nc_signal_handler(bool enable)
{
+ T((T_CALLED("_nc_signal_handler(%d)"), enable));
#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */
- static sigaction_t act, oact;
- static int ignore;
-
- if (!ignore) {
- if (!enable) {
- act.sa_handler = SIG_IGN;
- sigaction(SIGTSTP, &act, &oact);
- } else if (act.sa_handler) {
- sigaction(SIGTSTP, &oact, NULL);
- } else { /*initialize */
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
-#if USE_SIGWINCH
- act.sa_handler = sigwinch;
- CatchIfDefault(SIGWINCH, &act);
-#endif
-
+ {
+ static bool ignore_tstp = FALSE;
+
+ if (!ignore_tstp) {
+ static sigaction_t new_sigaction, old_sigaction;
+
+ if (!enable) {
+ new_sigaction.sa_handler = SIG_IGN;
+ sigaction(SIGTSTP, &new_sigaction, &old_sigaction);
+ } else if (new_sigaction.sa_handler != SIG_DFL) {
+ sigaction(SIGTSTP, &old_sigaction, NULL);
+ } else if (sigaction(SIGTSTP, NULL, &old_sigaction) == 0
+ && (old_sigaction.sa_handler == SIG_DFL)) {
+ sigemptyset(&new_sigaction.sa_mask);
#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
+ new_sigaction.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
- act.sa_handler = cleanup;
- CatchIfDefault(SIGINT, &act);
- CatchIfDefault(SIGTERM, &act);
-
- act.sa_handler = tstp;
- if (!CatchIfDefault(SIGTSTP, &act))
- ignore = TRUE;
+ new_sigaction.sa_handler = tstp;
+ (void) sigaction(SIGTSTP, &new_sigaction, NULL);
+ } else {
+ ignore_tstp = TRUE;
+ }
}
}
-#else /* !USE_SIGTSTP */
- if (enable) {
-#if HAVE_SIGACTION || HAVE_SIGVEC
- static sigaction_t act;
- sigemptyset(&act.sa_mask);
-#if USE_SIGWINCH
- act.sa_handler = sigwinch;
- CatchIfDefault(SIGWINCH, &act);
-#endif
-#ifdef SA_RESTART
- act.sa_flags |= SA_RESTART;
-#endif /* SA_RESTART */
- act.sa_handler = cleanup;
- CatchIfDefault(SIGINT, &act);
- CatchIfDefault(SIGTERM, &act);
-
-#else /* !(HAVE_SIGACTION || HAVE_SIGVEC) */
+#endif /* !USE_SIGTSTP */
- CatchIfDefault(SIGINT, cleanup);
- CatchIfDefault(SIGTERM, cleanup);
+ if (!_nc_globals.init_signals) {
+ if (enable) {
+ CatchIfDefault(SIGINT, cleanup);
+ CatchIfDefault(SIGTERM, cleanup);
#if USE_SIGWINCH
- CatchIfDefault(SIGWINCH, sigwinch);
+ CatchIfDefault(SIGWINCH, sigwinch);
#endif
-#endif /* !(HAVE_SIGACTION || HAVE_SIGVEC) */
+ _nc_globals.init_signals = TRUE;
+ }
}
-#endif /* !USE_SIGTSTP */
+ returnVoid;
}
diff --git a/lib/libcurses/tty/lib_twait.c b/lib/libcurses/tty/lib_twait.c
index 0b7c4d2949b..fcbc3cfdf47 100644
--- a/lib/libcurses/tty/lib_twait.c
+++ b/lib/libcurses/tty/lib_twait.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_twait.c,v 1.8 2001/01/22 18:02:00 millert Exp $ */
+/* $OpenBSD: lib_twait.c,v 1.9 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@@ -42,12 +43,18 @@
** comments, none of the original code remains - T.Dickey).
*/
+#include <curses.priv.h>
+
+#if defined __HAIKU__ && defined __BEOS__
+#undef __BEOS__
+#endif
+
#ifdef __BEOS__
+#undef false
+#undef true
#include <OS.h>
#endif
-#include <curses.priv.h>
-
#if USE_FUNC_POLL
# if HAVE_SYS_TIME_H
# include <sys/time.h>
@@ -61,36 +68,64 @@
# endif
#endif
-MODULE_ID("$From: lib_twait.c,v 1.41 2000/12/10 03:04:30 tom Exp $")
+#undef CUR
+
+MODULE_ID("$Id: lib_twait.c,v 1.9 2010/01/12 23:22:07 nicm Exp $")
static long
-_nc_gettime(bool first)
+_nc_gettime(TimeType * t0, bool first)
{
long res;
-#if HAVE_GETTIMEOFDAY
-# define PRECISE_GETTIME 1
- static struct timeval t0;
- struct timeval t1;
+#if PRECISE_GETTIME
+ TimeType t1;
gettimeofday(&t1, (struct timezone *) 0);
if (first) {
- t0 = t1;
+ *t0 = t1;
+ res = 0;
+ } else {
+ /* .tv_sec and .tv_usec are unsigned, be careful when subtracting */
+ if (t0->tv_usec > t1.tv_usec) {
+ t1.tv_usec += 1000000; /* Convert 1s in 1e6 microsecs */
+ t1.tv_sec--;
+ }
+ res = (t1.tv_sec - t0->tv_sec) * 1000
+ + (t1.tv_usec - t0->tv_usec) / 1000;
}
- res = (t1.tv_sec - t0.tv_sec) * 1000
- + (t1.tv_usec - t0.tv_usec) / 1000;
#else
-# define PRECISE_GETTIME 0
- static time_t t0;
time_t t1 = time((time_t *) 0);
if (first) {
- t0 = t1;
+ *t0 = t1;
}
- res = (t1 - t0) * 1000;
+ res = (t1 - *t0) * 1000;
#endif
- T(("%s time: %ld msec", first ? "get" : "elapsed", res));
+ TR(TRACE_IEVENT, ("%s time: %ld msec", first ? "get" : "elapsed", res));
return res;
}
+#ifdef NCURSES_WGETCH_EVENTS
+NCURSES_EXPORT(int)
+_nc_eventlist_timeout(_nc_eventlist * evl)
+{
+ int event_delay = -1;
+ int n;
+
+ if (evl != 0) {
+
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_TIMEOUT_MSEC) {
+ event_delay = ev->data.timeout_msec;
+ if (event_delay < 0)
+ event_delay = INT_MAX; /* FIXME Is this defined? */
+ }
+ }
+ }
+ return event_delay;
+}
+#endif /* NCURSES_WGETCH_EVENTS */
+
/*
* Wait a specified number of milliseconds, returning nonzero if the timer
* didn't expire before there is activity on the specified file descriptors.
@@ -99,55 +134,137 @@ _nc_gettime(bool first)
* 1 - ncurses' normal input-descriptor
* 2 - mouse descriptor, if any
* 3 - either input or mouse.
+ *
+ * Experimental: if NCURSES_WGETCH_EVENTS is defined, (mode & 4) determines
+ * whether to pay attention to evl argument. If set, the smallest of
+ * millisecond and of timeout of evl is taken.
+ *
* We return a mask that corresponds to the mode (e.g., 2 for mouse activity).
*
* If the milliseconds given are -1, the wait blocks until activity on the
* descriptors.
*/
NCURSES_EXPORT(int)
-_nc_timed_wait
-(int mode, int milliseconds, int *timeleft)
+_nc_timed_wait(SCREEN *sp,
+ int mode,
+ int milliseconds,
+ int *timeleft
+ EVENTLIST_2nd(_nc_eventlist * evl))
{
int fd;
int count;
+ int result = 0;
+ TimeType t0;
- int result;
+#ifdef NCURSES_WGETCH_EVENTS
+ int timeout_is_event = 0;
+ int n;
+#endif
#if USE_FUNC_POLL
- struct pollfd fds[2];
+#define MIN_FDS 2
+ struct pollfd fd_list[MIN_FDS];
+ struct pollfd *fds = fd_list;
#elif defined(__BEOS__)
#elif HAVE_SELECT
- static fd_set *set;
- static size_t setsize;
- size_t nsetsize;
- int readfd;
+ fd_set set;
#endif
long starttime, returntime;
- T(("start twait: %d milliseconds, mode: %d", milliseconds, mode));
+ TR(TRACE_IEVENT, ("start twait: %d milliseconds, mode: %d",
+ milliseconds, mode));
-#if PRECISE_GETTIME
+#ifdef NCURSES_WGETCH_EVENTS
+ if (mode & 4) {
+ int event_delay = _nc_eventlist_timeout(evl);
+
+ if (event_delay >= 0
+ && (milliseconds >= event_delay || milliseconds < 0)) {
+ milliseconds = event_delay;
+ timeout_is_event = 1;
+ }
+ }
+#endif
+
+#if PRECISE_GETTIME && HAVE_NANOSLEEP
retry:
#endif
- starttime = _nc_gettime(TRUE);
+ starttime = _nc_gettime(&t0, TRUE);
count = 0;
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl)
+ evl->result_flags = 0;
+#endif
+
#if USE_FUNC_POLL
- memset(fds, 0, sizeof(fds));
+ memset(fd_list, 0, sizeof(fd_list));
+
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl)
+ fds = typeMalloc(struct pollfd, MIN_FDS + evl->count);
+#endif
+
if (mode & 1) {
- fds[count].fd = SP->_ifd;
+ fds[count].fd = sp->_ifd;
fds[count].events = POLLIN;
count++;
}
if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0) {
+ && (fd = sp->_mouse_fd) >= 0) {
fds[count].fd = fd;
fds[count].events = POLLIN;
count++;
}
- result = poll(fds, count, milliseconds);
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl) {
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_FILE
+ && (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+ fds[count].fd = ev->data.fev.fd;
+ fds[count].events = POLLIN;
+ count++;
+ }
+ }
+ }
+#endif
+
+ result = poll(fds, (unsigned) count, milliseconds);
+
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl) {
+ int c;
+
+ if (!result)
+ count = 0;
+
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_FILE
+ && (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+ ev->data.fev.result = 0;
+ for (c = 0; c < count; c++)
+ if (fds[c].fd == ev->data.fev.fd
+ && fds[c].revents & POLLIN) {
+ ev->data.fev.result |= _NC_EVENT_FILE_READABLE;
+ evl->result_flags |= _NC_EVENT_FILE_READABLE;
+ }
+ } else if (ev->type == _NC_EVENT_TIMEOUT_MSEC
+ && !result && timeout_is_event) {
+ evl->result_flags |= _NC_EVENT_TIMEOUT_MSEC;
+ }
+ }
+ }
+
+ if (fds != fd_list)
+ free((char *) fds);
+
+#endif
#elif defined(__BEOS__)
/*
@@ -158,73 +275,124 @@ _nc_timed_wait
*
* FIXME: the return values from the ioctl aren't very clear if we get
* interrupted.
+ *
+ * FIXME: this assumes mode&1 if milliseconds < 0 (see lib_getch.c).
*/
result = 0;
if (mode & 1) {
+ int step = (milliseconds < 0) ? 0 : 5000;
bigtime_t d;
bigtime_t useconds = milliseconds * 1000;
int n, howmany;
- if (useconds == 0) /* we're here to go _through_ the loop */
+ if (useconds <= 0) /* we're here to go _through_ the loop */
useconds = 1;
- for (d = 0; d < useconds; d += 5000) {
+ for (d = 0; d < useconds; d += step) {
n = 0;
howmany = ioctl(0, 'ichr', &n);
if (howmany >= 0 && n > 0) {
result = 1;
break;
}
- if (useconds > 1)
- snooze(5000);
- milliseconds -= 5;
+ if (useconds > 1 && step > 0) {
+ snooze(step);
+ milliseconds -= (step / 1000);
+ if (milliseconds <= 0) {
+ milliseconds = 0;
+ break;
+ }
+ }
}
} else if (milliseconds > 0) {
snooze(milliseconds * 1000);
milliseconds = 0;
}
#elif HAVE_SELECT
+ /*
+ * select() modifies the fd_set arguments; do this in the
+ * loop.
+ */
+ FD_ZERO(&set);
+
if (mode & 1) {
- count = SP->_ifd;
- readfd = SP->_ifd;
+ FD_SET(sp->_ifd, &set);
+ count = sp->_ifd + 1;
}
- if ((mode & 2) && (fd = SP->_mouse_fd) >= 0) {
- count = max(fd, count);
- readfd = fd;
+ if ((mode & 2)
+ && (fd = sp->_mouse_fd) >= 0) {
+ FD_SET(fd, &set);
+ count = max(fd, count) + 1;
}
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl) {
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
- /*
- * grow set as needed.
- */
- nsetsize = howmany(count, NFDBITS) * sizeof(fd_mask);
- if (setsize == 0 || setsize < nsetsize) {
- setsize = nsetsize;
- set = _nc_doalloc(set, setsize);
+ if (ev->type == _NC_EVENT_FILE
+ && (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+ FD_SET(ev->data.fev.fd, &set);
+ count = max(ev->data.fev.fd + 1, count);
+ }
+ }
}
-
- /*
- * select() modifies the fd_set arguments; do this in the
- * loop.
- */
- memset(set, 0, setsize);
- FD_SET(readfd, set);
+#endif
if (milliseconds >= 0) {
struct timeval ntimeout;
ntimeout.tv_sec = milliseconds / 1000;
ntimeout.tv_usec = (milliseconds % 1000) * 1000;
- result = select(count + 1, set, NULL, NULL, &ntimeout);
+ result = select(count, &set, NULL, NULL, &ntimeout);
} else {
- result = select(count + 1, set, NULL, NULL, NULL);
+ result = select(count, &set, NULL, NULL, NULL);
+ }
+
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl) {
+ evl->result_flags = 0;
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_FILE
+ && (ev->data.fev.flags & _NC_EVENT_FILE_READABLE)) {
+ ev->data.fev.result = 0;
+ if (FD_ISSET(ev->data.fev.fd, &set)) {
+ ev->data.fev.result |= _NC_EVENT_FILE_READABLE;
+ evl->result_flags |= _NC_EVENT_FILE_READABLE;
+ }
+ } else if (ev->type == _NC_EVENT_TIMEOUT_MSEC
+ && !result && timeout_is_event)
+ evl->result_flags |= _NC_EVENT_TIMEOUT_MSEC;
+ }
}
#endif
- returntime = _nc_gettime(FALSE);
+#endif /* USE_FUNC_POLL, etc */
+
+ returntime = _nc_gettime(&t0, FALSE);
if (milliseconds >= 0)
milliseconds -= (returntime - starttime);
-#if PRECISE_GETTIME
+#ifdef NCURSES_WGETCH_EVENTS
+ if (evl) {
+ evl->result_flags = 0;
+ for (n = 0; n < evl->count; ++n) {
+ _nc_event *ev = evl->events[n];
+
+ if (ev->type == _NC_EVENT_TIMEOUT_MSEC) {
+ long diff = (returntime - starttime);
+ if (ev->data.timeout_msec <= diff)
+ ev->data.timeout_msec = 0;
+ else
+ ev->data.timeout_msec -= diff;
+ }
+
+ }
+ }
+#endif
+
+#if PRECISE_GETTIME && HAVE_NANOSLEEP
/*
* If the timeout hasn't expired, and we've gotten no data,
* this is probably a system where 'select()' needs to be left
@@ -232,7 +400,7 @@ _nc_timed_wait
* then come back for more.
*/
if (result == 0 && milliseconds > 100) {
- napms(100);
+ napms(100); /* FIXME: this won't be right if I recur! */
milliseconds -= 100;
goto retry;
}
@@ -242,8 +410,8 @@ _nc_timed_wait
if (timeleft)
*timeleft = milliseconds;
- T(("end twait: returned %d (%d), remaining time %d msec",
- result, errno, milliseconds));
+ TR(TRACE_IEVENT, ("end twait: returned %d (%d), remaining time %d msec",
+ result, errno, milliseconds));
/*
* Both 'poll()' and 'select()' return the number of file descriptors
@@ -255,7 +423,7 @@ _nc_timed_wait
if (result > 0) {
result = 0;
#if USE_FUNC_POLL
- for (count = 0; count < 2; count++) {
+ for (count = 0; count < MIN_FDS; count++) {
if ((mode & (1 << count))
&& (fds[count].revents & POLLIN)) {
result |= (1 << count);
@@ -265,16 +433,20 @@ _nc_timed_wait
result = 1; /* redundant, but simple */
#elif HAVE_SELECT
if ((mode & 2)
- && (fd = SP->_mouse_fd) >= 0
- && FD_ISSET(fd, set))
+ && (fd = sp->_mouse_fd) >= 0
+ && FD_ISSET(fd, &set))
result |= 2;
if ((mode & 1)
- && FD_ISSET(SP->_ifd, set))
+ && FD_ISSET(sp->_ifd, &set))
result |= 1;
#endif
} else
result = 0;
}
+#ifdef NCURSES_WGETCH_EVENTS
+ if ((mode & 4) && evl && evl->result_flags)
+ result |= 4;
+#endif
return (result);
}
diff --git a/lib/libcurses/tty/lib_vidattr.c b/lib/libcurses/tty/lib_vidattr.c
index 4a5c9354b72..5553a348ead 100644
--- a/lib/libcurses/tty/lib_vidattr.c
+++ b/lib/libcurses/tty/lib_vidattr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_vidattr.c,v 1.8 2001/01/22 18:02:00 millert Exp $ */
+/* $OpenBSD: lib_vidattr.c,v 1.9 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
/*
@@ -66,7 +67,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_vidattr.c,v 1.36 2000/12/10 03:05:48 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.9 2010/01/12 23:22:07 nicm Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -88,15 +89,14 @@ MODULE_ID("$From: lib_vidattr.c,v 1.36 2000/12/10 03:05:48 tom Exp $")
} \
}
+#define PreviousAttr _nc_prescreen.previous_attr
+
NCURSES_EXPORT(int)
-vidputs
-(attr_t newmode, int (*outc) (int))
+vidputs(chtype newmode, int (*outc) (int))
{
- static attr_t previous_attr = A_NORMAL;
attr_t turn_on, turn_off;
int pair;
bool reverse = FALSE;
- bool used_ncv = FALSE;
bool can_color = (SP == 0 || SP->_coloron);
#if NCURSES_EXT_FUNCS
bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
@@ -104,19 +104,56 @@ vidputs
#define fix_pair0 FALSE
#endif
+ newmode &= A_ATTRIBUTES;
T((T_CALLED("vidputs(%s)"), _traceattr(newmode)));
/* this allows us to go on whether or not newterm() has been called */
if (SP)
- previous_attr = SP->_current_attr;
+ PreviousAttr = AttrOf(SCREEN_ATTRS(SP));
- TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(previous_attr)));
+ TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(PreviousAttr)));
-#if !USE_XMC_SUPPORT
if ((SP != 0)
- && (magic_cookie_glitch > 0))
+ && (magic_cookie_glitch > 0)) {
+#if USE_XMC_SUPPORT
+ static const chtype table[] =
+ {
+ A_STANDOUT,
+ A_UNDERLINE,
+ A_REVERSE,
+ A_BLINK,
+ A_DIM,
+ A_BOLD,
+ A_INVIS,
+ A_PROTECT,
+ };
+ unsigned n;
+ int used = 0;
+ int limit = (max_attributes <= 0) ? 1 : max_attributes;
+ chtype retain = 0;
+
+ /*
+ * Limit the number of attribute bits set in the newmode according to
+ * the terminfo max_attributes value.
+ */
+ for (n = 0; n < SIZEOF(table); ++n) {
+ if ((table[n] & SP->_ok_attributes) == 0) {
+ newmode &= ~table[n];
+ } else if ((table[n] & newmode) != 0) {
+ if (used++ >= limit) {
+ newmode &= ~table[n];
+ if (newmode == retain)
+ break;
+ } else {
+ retain = newmode;
+ }
+ }
+ }
+#else
newmode &= ~(SP->_xmc_suppress);
#endif
+ TR(TRACE_ATTRS, ("suppressed attribute is %s", _traceattr(newmode)));
+ }
/*
* If we have a terminal that cannot combine color with video
@@ -150,7 +187,7 @@ vidputs
newmode &= ~mask;
}
- if (newmode == previous_attr)
+ if (newmode == PreviousAttr)
returnCode(OK);
pair = PAIR_NUMBER(newmode);
@@ -159,17 +196,17 @@ vidputs
newmode &= ~A_REVERSE;
}
- turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
- turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR;
+ turn_off = (~newmode & PreviousAttr) & ALL_BUT_COLOR;
+ turn_on = (newmode & ~PreviousAttr) & ALL_BUT_COLOR;
- SetColorsIf(((pair == 0) && !fix_pair0), previous_attr);
+ SetColorsIf(((pair == 0) && !fix_pair0), PreviousAttr);
if (newmode == A_NORMAL) {
- if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
+ if ((PreviousAttr & A_ALTCHARSET) && exit_alt_charset_mode) {
doPut(exit_alt_charset_mode);
- previous_attr &= ~A_ALTCHARSET;
+ PreviousAttr &= ~A_ALTCHARSET;
}
- if (previous_attr) {
+ if (PreviousAttr) {
if (exit_attribute_mode) {
doPut(exit_attribute_mode);
} else {
@@ -180,11 +217,11 @@ vidputs
TurnOff(A_STANDOUT, exit_standout_mode);
}
}
- previous_attr &= ~A_COLOR;
+ PreviousAttr &= ALL_BUT_COLOR;
}
- SetColorsIf((pair != 0) || fix_pair0, previous_attr);
- } else if (set_attributes && !used_ncv) {
+ SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
+ } else if (set_attributes) {
if (turn_on || turn_off) {
TPUTS_TRACE("set_attributes");
tputs(tparm(set_attributes,
@@ -197,9 +234,9 @@ vidputs
(newmode & A_INVIS) != 0,
(newmode & A_PROTECT) != 0,
(newmode & A_ALTCHARSET) != 0), 1, outc);
- previous_attr &= ~A_COLOR;
+ PreviousAttr &= ALL_BUT_COLOR;
}
- SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+ SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
} else {
TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
@@ -216,10 +253,10 @@ vidputs
if (turn_off && exit_attribute_mode) {
doPut(exit_attribute_mode);
- turn_on |= (newmode & (chtype) (~A_COLOR));
- previous_attr &= ~A_COLOR;
+ turn_on |= (newmode & ALL_BUT_COLOR);
+ PreviousAttr &= ALL_BUT_COLOR;
}
- SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+ SetColorsIf((pair != 0) || fix_pair0, PreviousAttr);
TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
/* *INDENT-OFF* */
@@ -232,12 +269,14 @@ vidputs
TurnOn(A_PROTECT, enter_protected_mode);
TurnOn(A_INVIS, enter_secure_mode);
TurnOn(A_UNDERLINE, enter_underline_mode);
+#if USE_WIDEC_SUPPORT
TurnOn(A_HORIZONTAL, enter_horizontal_hl_mode);
TurnOn(A_LEFT, enter_left_hl_mode);
TurnOn(A_LOW, enter_low_hl_mode);
TurnOn(A_RIGHT, enter_right_hl_mode);
TurnOn(A_TOP, enter_top_hl_mode);
TurnOn(A_VERTICAL, enter_vertical_hl_mode);
+#endif
/* *INDENT-ON* */
}
@@ -246,15 +285,15 @@ vidputs
newmode |= A_REVERSE;
if (SP)
- SP->_current_attr = newmode;
+ SetAttr(SCREEN_ATTRS(SP), newmode);
else
- previous_attr = newmode;
+ PreviousAttr = newmode;
returnCode(OK);
}
NCURSES_EXPORT(int)
-vidattr(attr_t newmode)
+vidattr(chtype newmode)
{
T((T_CALLED("vidattr(%s)"), _traceattr(newmode)));
diff --git a/lib/libcurses/tty/tty_display.h b/lib/libcurses/tty/tty_display.h
index f1e0f47e1d1..f62abe2891a 100644
--- a/lib/libcurses/tty/tty_display.h
+++ b/lib/libcurses/tty/tty_display.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: tty_display.h,v 1.3 2001/01/22 18:02:00 millert Exp $ */
+/* $OpenBSD: tty_display.h,v 1.4 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,9 @@
#ifndef TTY_DISPLAY_H
#define TTY_DISPLAY_H 1
+/*
+ * $Id: tty_display.h,v 1.4 2010/01/12 23:22:07 nicm Exp $
+ */
extern NCURSES_EXPORT(bool) _nc_tty_beep (void);
extern NCURSES_EXPORT(bool) _nc_tty_check_resize (void);
extern NCURSES_EXPORT(bool) _nc_tty_cursor (int);
@@ -113,11 +116,11 @@ struct tty_display_data {
: ((enter_insert_mode && exit_insert_mode) \
? D->_smir_cost + D->_rmir_cost + (D->_ip_cost * count) \
: ((insert_character != 0) \
- ? (D->_ich1_cost * count) \
+ ? ((D->_ich1_cost + D->_ip_cost) * count) \
: INFINITY)))
#if USE_XMC_SUPPORT
-#define UpdateAttrs(c) if (D->_current_attr != AttrOf(c)) { \
+#define UpdateAttrs(c) if (!SameAttrOf(D->_current_attr, AttrOf(c))) { \
attr_t chg = D->_current_attr; \
vidattr(AttrOf(c)); \
if (magic_cookie_glitch > 0 \
@@ -130,7 +133,7 @@ struct tty_display_data {
} \
}
#else
-#define UpdateAttrs(c) if (D->_current_attr != AttrOf(c)) \
+#define UpdateAttrs(c) if (!SameAttrOf(D->_current_attr, AttrOf(c))) \
vidattr(AttrOf(c));
#endif
diff --git a/lib/libcurses/tty/tty_input.h b/lib/libcurses/tty/tty_input.h
index 21f551a49a2..cff0bb54e4b 100644
--- a/lib/libcurses/tty/tty_input.h
+++ b/lib/libcurses/tty/tty_input.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_input.h,v 1.2 2001/01/22 18:02:00 millert Exp $ */
+/* $OpenBSD: tty_input.h,v 1.3 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -29,7 +29,7 @@
****************************************************************************/
/*
- * $From: tty_input.h,v 1.2 2000/12/10 02:26:51 tom Exp $
+ * $Id: tty_input.h,v 1.3 2010/01/12 23:22:07 nicm Exp $
*/
#ifndef TTY_INPUT_H
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index 28b6b99927e..bd2f088adf6 100644
--- a/lib/libcurses/tty/tty_update.c
+++ b/lib/libcurses/tty/tty_update.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tty_update.c,v 1.15 2001/02/22 04:16:35 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.16 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,24 +31,31 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*-----------------------------------------------------------------
*
* lib_doupdate.c
*
- * The routine doupdate() and its dependents. Also _nc_outstr(),
- * so all physical output is concentrated here (except _nc_outch()
- * in lib_tputs.c).
+ * The routine doupdate() and its dependents.
+ * All physical output is concentrated here (except _nc_outch()
+ * in lib_tputs.c).
*
*-----------------------------------------------------------------*/
+#include <curses.priv.h>
+
+#if defined __HAIKU__ && defined __BEOS__
+#undef __BEOS__
+#endif
+
#ifdef __BEOS__
+#undef false
+#undef true
#include <OS.h>
#endif
-#include <curses.priv.h>
-
#if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES
#define USE_TRACE_TIMES 1
#else
@@ -70,9 +77,10 @@
#endif
#endif
+#include <ctype.h>
#include <term.h>
-MODULE_ID("$From: tty_update.c,v 1.151 2001/02/03 23:41:55 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.16 2010/01/12 23:22:07 nicm Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -87,6 +95,9 @@ MODULE_ID("$From: tty_update.c,v 1.151 2001/02/03 23:41:55 tom Exp $")
#define FILL_BCE() (SP->_coloron && !SP->_default_color && !back_color_erase)
+static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
+static NCURSES_CH_T normal = NewChar(BLANK_TEXT);
+
/*
* Enable checking to see if doupdate and friends are tracking the true
* cursor position correctly. NOTE: this is a debugging hack which will
@@ -94,12 +105,12 @@ MODULE_ID("$From: tty_update.c,v 1.151 2001/02/03 23:41:55 tom Exp $")
*/
/* #define POSITION_DEBUG */
-static inline chtype ClrBlank(WINDOW *win);
+static NCURSES_INLINE NCURSES_CH_T ClrBlank(WINDOW *win);
static int ClrBottom(int total);
-static void ClearScreen(chtype blank);
+static void ClearScreen(NCURSES_CH_T blank);
static void ClrUpdate(void);
static void DelChar(int count);
-static void InsStr(chtype * line, int count);
+static void InsStr(NCURSES_CH_T * line, int count);
static void TransformLine(int const lineno);
#ifdef POSITION_DEBUG
@@ -162,56 +173,131 @@ position_check(int expected_y, int expected_x, char *legend)
*
****************************************************************************/
-static inline void
+static NCURSES_INLINE void
GoTo(int const row, int const col)
{
- chtype oldattr = SP->_current_attr;
-
TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
row, col, SP->_cursrow, SP->_curscol));
position_check(SP->_cursrow, SP->_curscol, "GoTo");
- /*
- * Force restore even if msgr is on when we're in an alternate
- * character set -- these have a strong tendency to screw up the
- * CR & LF used for local character motions!
- */
- if ((oldattr & A_ALTCHARSET)
- || (oldattr && !move_standout_mode)) {
- TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
- oldattr, _traceattr(oldattr)));
- vidattr(A_NORMAL);
- }
-
mvcur(SP->_cursrow, SP->_curscol, row, col);
- SP->_cursrow = row;
- SP->_curscol = col;
position_check(SP->_cursrow, SP->_curscol, "GoTo2");
}
-static inline void
-PutAttrChar(chtype ch)
+static NCURSES_INLINE void
+PutAttrChar(CARG_CH_T ch)
{
- int data;
-
- if (tilde_glitch && (TextOf(ch) == '~'))
- ch = ('`' | AttrOf(ch));
+ int chlen = 1;
+ NCURSES_CH_T my_ch;
+ PUTC_DATA;
+ NCURSES_CH_T tilde;
+ NCURSES_CH_T attr = CHDEREF(ch);
TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
- _tracechtype(ch),
+ _tracech_t(ch),
SP->_cursrow, SP->_curscol));
- UpdateAttrs(ch);
- data = TextOf(ch);
+#if USE_WIDEC_SUPPORT
+ /*
+ * If this is not a valid character, there is nothing more to do.
+ */
+ if (isWidecExt(CHDEREF(ch))) {
+ TR(TRACE_CHARPUT, ("...skip"));
+ return;
+ }
+ /*
+ * Determine the number of character cells which the 'ch' value will use
+ * on the screen. It should be at least one.
+ */
+ if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
+ static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+
+ /*
+ * If the character falls into any of these special cases, do
+ * not force the result to a blank:
+ *
+ * a) it is printable (this works around a bug in wcwidth()).
+ * b) use_legacy_coding() has been called to modify the treatment
+ * of codes 128-255.
+ * c) the acs_map[] has been initialized to allow codes 0-31
+ * to be rendered. This supports Linux console's "PC"
+ * characters. Codes 128-255 are allowed though this is
+ * not checked.
+ */
+ if (is8bits(CharOf(CHDEREF(ch)))
+ && (isprint(CharOf(CHDEREF(ch)))
+ || (SP->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
+ || (SP->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
+ || (AttrOf(attr) & A_ALTCHARSET
+ && ((CharOfD(ch) < ACS_LEN
+ && SP->_acs_map != 0
+ && SP->_acs_map[CharOfD(ch)] != 0)
+ || (CharOfD(ch) >= 128))))) {
+ ;
+ } else {
+ ch = CHREF(blank);
+ TR(TRACE_CHARPUT, ("forced to blank"));
+ }
+ chlen = 1;
+ }
+#endif
+
+ if ((AttrOf(attr) & A_ALTCHARSET)
+ && SP->_acs_map != 0
+ && CharOfD(ch) < ACS_LEN) {
+ my_ch = CHDEREF(ch); /* work around const param */
+#if USE_WIDEC_SUPPORT
+ /*
+ * This is crude & ugly, but works most of the time. It checks if the
+ * acs_chars string specified that we have a mapping for this
+ * character, and uses the wide-character mapping when we expect the
+ * normal one to be broken (by mis-design ;-).
+ */
+ if (SP->_screen_acs_fix
+ && SP->_screen_acs_map[CharOf(my_ch)]) {
+ RemAttr(attr, A_ALTCHARSET);
+ my_ch = _nc_wacs[CharOf(my_ch)];
+ }
+#endif
+ /*
+ * If we (still) have alternate character set, it is the normal 8bit
+ * flavor. The _screen_acs_map[] array tells if the character was
+ * really in acs_chars, needed because of the way wide/normal line
+ * drawing flavors are integrated.
+ */
+ if (AttrOf(attr) & A_ALTCHARSET) {
+ int j = CharOfD(ch);
+ chtype temp = UChar(SP->_acs_map[j]);
+
+ if (!(SP->_screen_acs_map[j])) {
+ RemAttr(attr, A_ALTCHARSET);
+ if (temp == 0)
+ temp = ' ';
+ }
+ if (temp != 0)
+ SetChar(my_ch, temp, AttrOf(attr));
+ }
+ ch = CHREF(my_ch);
+ }
+ if (tilde_glitch && (CharOfD(ch) == L('~'))) {
+ SetChar(tilde, L('`'), AttrOf(attr));
+ ch = CHREF(tilde);
+ }
+
+ UpdateAttrs(attr);
+#if !USE_WIDEC_SUPPORT
+ /* FIXME - we do this special case for signal handling, should see how to
+ * make it work for wide characters.
+ */
if (SP->_outch != 0) {
- SP->_outch(data);
- } else {
- putc(data, SP->_ofp); /* macro's fastest... */
-#ifdef TRACE
- _nc_outchars++;
-#endif /* TRACE */
+ SP->_outch(UChar(ch));
+ } else
+#endif
+ {
+ PUTC(CHDEREF(ch), SP->_ofp); /* macro's fastest... */
+ COUNT_OUTCHARS(1);
}
- SP->_curscol++;
+ SP->_curscol += chlen;
if (char_padding) {
TPUTS_TRACE("char_padding");
putp(char_padding);
@@ -256,19 +342,16 @@ check_pending(void)
have_pending = TRUE;
}
#elif HAVE_SELECT
- fd_set *fdset;
+ fd_set fdset;
struct timeval ktimeout;
ktimeout.tv_sec =
ktimeout.tv_usec = 0;
- fdset = calloc(howmany(SP->_checkfd + 1, NFDBITS), sizeof(fd_mask));
- if (fdset != NULL) {
- FD_SET(SP->_checkfd, fdset);
- if (select(SP->_checkfd + 1, fdset, NULL, NULL, &ktimeout) != 0) {
- have_pending = TRUE;
- }
- free(fdset);
+ FD_ZERO(&fdset);
+ FD_SET(SP->_checkfd, &fdset);
+ if (select(SP->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
+ have_pending = TRUE;
}
#endif
}
@@ -281,7 +364,7 @@ check_pending(void)
/* put char at lower right corner */
static void
-PutCharLR(chtype const ch)
+PutCharLR(const ARG_CH_T ch)
{
if (!auto_right_margin) {
/* we can put the char directly */
@@ -306,39 +389,49 @@ PutCharLR(chtype const ch)
}
}
+/*
+ * Wrap the cursor position, i.e., advance to the beginning of the next line.
+ */
static void
wrap_cursor(void)
{
if (eat_newline_glitch) {
/*
- * xenl can manifest two different ways. The vt100
- * way is that, when you'd expect the cursor to wrap,
- * it stays hung at the right margin (on top of the
- * character just emitted) and doesn't wrap until the
- * *next* graphic char is emitted. The c100 way is
- * to ignore LF received just after an am wrap.
+ * xenl can manifest two different ways. The vt100 way is that, when
+ * you'd expect the cursor to wrap, it stays hung at the right margin
+ * (on top of the character just emitted) and doesn't wrap until the
+ * *next* graphic char is emitted. The c100 way is to ignore LF
+ * received just after an am wrap.
*
- * An aggressive way to handle this would be to
- * emit CR/LF after the char and then assume the wrap
- * is done, you're on the first position of the next
- * line, and the terminal out of its weird state.
- * Here it's safe to just tell the code that the
- * cursor is in hyperspace and let the next mvcur()
- * call straighten things out.
+ * An aggressive way to handle this would be to emit CR/LF after the
+ * char and then assume the wrap is done, you're on the first position
+ * of the next line, and the terminal out of its weird state. Here
+ * it's safe to just tell the code that the cursor is in hyperspace and
+ * let the next mvcur() call straighten things out.
*/
SP->_curscol = -1;
SP->_cursrow = -1;
} else if (auto_right_margin) {
SP->_curscol = 0;
SP->_cursrow++;
+ /*
+ * We've actually moved - but may have to work around problems with
+ * video attributes not working.
+ */
+ if (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP))) {
+ TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping",
+ (unsigned long) AttrOf(SCREEN_ATTRS(SP)),
+ _traceattr(AttrOf(SCREEN_ATTRS(SP)))));
+ (void) VIDATTR(A_NORMAL, 0);
+ }
} else {
SP->_curscol--;
}
position_check(SP->_cursrow, SP->_curscol, "wrap_cursor");
}
-static inline void
-PutChar(chtype const ch)
+static NCURSES_INLINE void
+PutChar(const ARG_CH_T ch)
/* insert character, handling automargin stuff */
{
if (SP->_cursrow == screen_lines - 1 && SP->_curscol == screen_columns - 1)
@@ -358,20 +451,30 @@ PutChar(chtype const ch)
* as A_REVERSE. All attribute flags which don't affect appearance of a space
* or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
*/
-static inline bool
-can_clear_with(chtype ch)
+static NCURSES_INLINE bool
+can_clear_with(ARG_CH_T ch)
{
if (!back_color_erase && SP->_coloron) {
- if (ch & A_COLOR)
- return FALSE;
#if NCURSES_EXT_FUNCS
+ int pair;
+
if (!SP->_default_color)
return FALSE;
if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
return FALSE;
+ if ((pair = GetPair(CHDEREF(ch))) != 0) {
+ short fg, bg;
+ pair_content(pair, &fg, &bg);
+ if (fg != C_MASK || bg != C_MASK)
+ return FALSE;
+ }
+#else
+ if (AttrOfD(ch) & A_COLOR)
+ return FALSE;
#endif
}
- return ((ch & ~(NONBLANK_ATTR | A_COLOR)) == BLANK);
+ return (ISBLANK(CHDEREF(ch)) &&
+ (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR);
}
/*
@@ -387,28 +490,30 @@ can_clear_with(chtype ch)
* This code is optimized using ech and rep.
*/
static int
-EmitRange(const chtype * ntext, int num)
+EmitRange(const NCURSES_CH_T * ntext, int num)
{
int i;
+ TR(TRACE_CHARPUT, ("EmitRange %d:%s", num, _nc_viscbuf(ntext, num)));
+
if (erase_chars || repeat_char) {
while (num > 0) {
int runcount;
- chtype ntext0;
+ NCURSES_CH_T ntext0;
- while (num > 1 && ntext[0] != ntext[1]) {
- PutChar(ntext[0]);
+ while (num > 1 && !CharEq(ntext[0], ntext[1])) {
+ PutChar(CHREF(ntext[0]));
ntext++;
num--;
}
ntext0 = ntext[0];
if (num == 1) {
- PutChar(ntext0);
+ PutChar(CHREF(ntext0));
return 0;
}
runcount = 2;
- while (runcount < num && ntext[runcount] == ntext0)
+ while (runcount < num && CharEq(ntext[runcount], ntext0))
runcount++;
/*
@@ -421,9 +526,9 @@ EmitRange(const chtype * ntext, int num)
*/
if (erase_chars
&& runcount > SP->_ech_cost + SP->_cup_ch_cost
- && can_clear_with(ntext0)) {
+ && can_clear_with(CHREF(ntext0))) {
UpdateAttrs(ntext0);
- putp(tparm(erase_chars, runcount));
+ putp(TPARM_1(erase_chars, runcount));
/*
* If this is the last part of the given interval,
@@ -443,14 +548,15 @@ EmitRange(const chtype * ntext, int num)
rep_count--;
UpdateAttrs(ntext0);
- putp(tparm(repeat_char, TextOf(ntext0), rep_count));
+ tputs(TPARM_2(repeat_char, CharOf(ntext0), rep_count),
+ rep_count, _nc_outch);
SP->_curscol += rep_count;
if (wrap_possible)
- PutChar(ntext0);
+ PutChar(CHREF(ntext0));
} else {
for (i = 0; i < runcount; i++)
- PutChar(ntext[i]);
+ PutChar(CHREF(ntext[i]));
}
ntext += runcount;
num -= runcount;
@@ -459,7 +565,7 @@ EmitRange(const chtype * ntext, int num)
}
for (i = 0; i < num; i++)
- PutChar(ntext[i]);
+ PutChar(CHREF(ntext[i]));
return 0;
}
@@ -472,31 +578,37 @@ EmitRange(const chtype * ntext, int num)
* Returns: same as EmitRange
*/
static int
-PutRange(
- const chtype * otext,
- const chtype * ntext,
- int row,
- int first, int last)
+PutRange(const NCURSES_CH_T * otext,
+ const NCURSES_CH_T * ntext,
+ int row,
+ int first, int last)
{
- int j, run;
+ int i, j, same;
TR(TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
otext, ntext, row, first, last));
if (otext != ntext
&& (last - first + 1) > SP->_inline_cost) {
- for (j = first, run = 0; j <= last; j++) {
- if (otext[j] == ntext[j]) {
- run++;
+ for (j = first, same = 0; j <= last; j++) {
+ if (!same && isWidecExt(otext[j]))
+ continue;
+ if (CharEq(otext[j], ntext[j])) {
+ same++;
} else {
- if (run > SP->_inline_cost) {
- int before_run = (j - run);
- EmitRange(ntext + first, before_run - first);
+ if (same > SP->_inline_cost) {
+ EmitRange(ntext + first, j - same - first);
GoTo(row, first = j);
}
- run = 0;
+ same = 0;
}
}
+ i = EmitRange(ntext + first, j - same - first);
+ /*
+ * Always return 1 for the next GoTo() after a PutRange() if we found
+ * identical characters at end of interval
+ */
+ return (same == 0 ? i : 1);
}
return EmitRange(ntext + first, last - first + 1);
}
@@ -518,13 +630,18 @@ doupdate(void)
T((T_CALLED("doupdate()")));
+ if (curscr == 0
+ || newscr == 0)
+ returnCode(ERR);
+
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE) {
+ if (USE_TRACEF(TRACE_UPDATE)) {
if (curscr->_clear)
_tracef("curscr is clear");
else
_tracedump("curscr", curscr);
_tracedump("newscr", newscr);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
@@ -534,7 +651,7 @@ doupdate(void)
SP->_fifohold--;
#if USE_SIZECHANGE
- if (SP->_endwin || SP->_sig_winch) {
+ if (SP->_endwin || _nc_handle_sigwinch(SP)) {
/*
* This is a transparent extension: XSI does not address it,
* and applications need not know that ncurses can do it.
@@ -543,7 +660,7 @@ doupdate(void)
* (this can happen in an xterm, for example), and resize the
* ncurses data structures accordingly.
*/
- _nc_update_screensize();
+ _nc_update_screensize(SP);
}
#endif
@@ -560,22 +677,20 @@ doupdate(void)
}
#if USE_TRACE_TIMES
/* zero the metering machinery */
- _nc_outchars = 0;
+ RESET_OUTCHARS();
(void) times(&before);
#endif /* USE_TRACE_TIMES */
/*
- * This is the support for magic-cookie terminals. The
- * theory: we scan the virtual screen looking for attribute
- * turnons. Where we find one, check to make sure it's
- * realizable by seeing if the required number of
- * un-attributed blanks are present before and after the
- * attributed range; try to shift the range boundaries over
- * blanks (not changing the screen display) so this becomes
- * true. If it is, shift the beginning attribute change
- * appropriately (the end one, if we've gotten this far, is
- * guaranteed room for its cookie). If not, nuke the added
- * attributes out of the span.
+ * This is the support for magic-cookie terminals. The theory: we scan
+ * the virtual screen looking for attribute turnons. Where we find one,
+ * check to make sure it's realizable by seeing if the required number of
+ * un-attributed blanks are present before and after the attributed range;
+ * try to shift the range boundaries over blanks (not changing the screen
+ * display) so this becomes true. If it is, shift the beginning attribute
+ * change appropriately (the end one, if we've gotten this far, is
+ * guaranteed room for its cookie). If not, nuke the added attributes out
+ * of the span.
*/
#if USE_XMC_SUPPORT
if (magic_cookie_glitch > 0) {
@@ -585,11 +700,13 @@ doupdate(void)
for (i = 0; i < screen_lines; i++) {
for (j = 0; j < screen_columns; j++) {
bool failed = FALSE;
- chtype turnon = AttrOf(newscr->_line[i].text[j]) & ~rattr;
+ NCURSES_CH_T *thisline = newscr->_line[i].text;
+ attr_t thisattr = AttrOf(thisline[j]) & SP->_xmc_triggers;
+ attr_t turnon = thisattr & ~rattr;
/* is an attribute turned on here? */
if (turnon == 0) {
- rattr = AttrOf(newscr->_line[i].text[j]);
+ rattr = thisattr;
continue;
}
@@ -597,23 +714,33 @@ doupdate(void)
TR(TRACE_ATTRS, ("...to %s", _traceattr(turnon)));
/*
- * If the attribute change location is a blank with a
- * "safe" attribute, undo the attribute turnon. This may
- * ensure there's enough room to set the attribute before
- * the first non-blank in the run.
+ * If the attribute change location is a blank with a "safe"
+ * attribute, undo the attribute turnon. This may ensure
+ * there's enough room to set the attribute before the first
+ * non-blank in the run.
*/
-#define SAFE(a) (!((a) & (chtype)~NONBLANK_ATTR))
- if (TextOf(newscr->_line[i].text[j]) == ' ' && SAFE(turnon)) {
- newscr->_line[i].text[j] &= ~turnon;
+#define SAFE(a) (!((a) & SP->_xmc_triggers))
+ if (ISBLANK(thisline[j]) && SAFE(turnon)) {
+ RemAttr(thisline[j], turnon);
continue;
}
/* check that there's enough room at start of span */
for (k = 1; k <= magic_cookie_glitch; k++) {
if (j - k < 0
- || TextOf(newscr->_line[i].text[j - k]) != ' '
- || !SAFE(AttrOf(newscr->_line[i].text[j - k])))
+ || !ISBLANK(thisline[j - k])
+ || !SAFE(AttrOf(thisline[j - k]))) {
failed = TRUE;
+ TR(TRACE_ATTRS, ("No room at start in %d,%d%s%s",
+ i, j - k,
+ (ISBLANK(thisline[j - k])
+ ? ""
+ : ":nonblank"),
+ (SAFE(AttrOf(thisline[j - k]))
+ ? ""
+ : ":unsafe")));
+ break;
+ }
}
if (!failed) {
bool end_onscreen = FALSE;
@@ -622,7 +749,8 @@ doupdate(void)
/* find end of span, if it's onscreen */
for (m = i; m < screen_lines; m++) {
for (; n < screen_columns; n++) {
- if (AttrOf(newscr->_line[m].text[n]) == rattr) {
+ attr_t testattr = AttrOf(newscr->_line[m].text[n]);
+ if ((testattr & SP->_xmc_triggers) == rattr) {
end_onscreen = TRUE;
TR(TRACE_ATTRS,
("Range attributed with %s ends at (%d, %d)",
@@ -638,25 +766,37 @@ doupdate(void)
foundit:;
if (end_onscreen) {
- chtype *lastline = newscr->_line[m].text;
+ NCURSES_CH_T *lastline = newscr->_line[m].text;
/*
- * If there are safely-attributed blanks at the
- * end of the range, shorten the range. This will
- * help ensure that there is enough room at end
- * of span.
+ * If there are safely-attributed blanks at the end of
+ * the range, shorten the range. This will help ensure
+ * that there is enough room at end of span.
*/
while (n >= 0
- && TextOf(lastline[n]) == ' '
- && SAFE(AttrOf(lastline[n])))
- lastline[n--] &= ~turnon;
+ && ISBLANK(lastline[n])
+ && SAFE(AttrOf(lastline[n]))) {
+ RemAttr(lastline[n--], turnon);
+ }
/* check that there's enough room at end of span */
- for (k = 1; k <= magic_cookie_glitch; k++)
+ for (k = 1; k <= magic_cookie_glitch; k++) {
if (n + k >= screen_columns
- || TextOf(lastline[n + k]) != ' '
- || !SAFE(AttrOf(lastline[n + k])))
+ || !ISBLANK(lastline[n + k])
+ || !SAFE(AttrOf(lastline[n + k]))) {
failed = TRUE;
+ TR(TRACE_ATTRS,
+ ("No room at end in %d,%d%s%s",
+ i, j - k,
+ (ISBLANK(lastline[n + k])
+ ? ""
+ : ":nonblank"),
+ (SAFE(AttrOf(lastline[n + k]))
+ ? ""
+ : ":unsafe")));
+ break;
+ }
+ }
}
}
@@ -670,9 +810,10 @@ doupdate(void)
/* turn off new attributes over span */
for (p = i; p < screen_lines; p++) {
for (; q < screen_columns; q++) {
- if (AttrOf(newscr->_line[p].text[q]) == rattr)
+ attr_t testattr = AttrOf(newscr->_line[p].text[q]);
+ if ((testattr & SP->_xmc_triggers) == rattr)
goto foundend;
- newscr->_line[p].text[q] &= ~turnon;
+ RemAttr(newscr->_line[p].text[q], turnon);
}
q = 0;
}
@@ -683,22 +824,23 @@ doupdate(void)
_traceattr(turnon), i, j));
/*
- * back up the start of range so there's room
- * for cookies before the first nonblank character
+ * Back up the start of range so there's room for cookies
+ * before the first nonblank character.
*/
for (k = 1; k <= magic_cookie_glitch; k++)
- newscr->_line[i].text[j - k] |= turnon;
+ AddAttr(thisline[j - k], turnon);
}
- rattr = AttrOf(newscr->_line[i].text[j]);
+ rattr = thisattr;
}
}
#ifdef TRACE
/* show altered highlights after magic-cookie check */
- if (_nc_tracing & TRACE_UPDATE) {
+ if (USE_TRACEF(TRACE_UPDATE)) {
_tracef("After magic-cookie check...");
_tracedump("newscr", newscr);
+ _nc_unlock_global(tracef);
}
#endif /* TRACE */
}
@@ -706,7 +848,6 @@ doupdate(void)
nonempty = 0;
if (curscr->_clear || newscr->_clear) { /* force refresh ? */
- TR(TRACE_UPDATE, ("clearing and updating from scratch"));
ClrUpdate();
curscr->_clear = FALSE; /* reset flag */
newscr->_clear = FALSE; /* reset flag */
@@ -774,21 +915,26 @@ doupdate(void)
cleanup:
/*
- * Keep the physical screen in normal mode in case we get other
- * processes writing to the screen.
+ * We would like to keep the physical screen in normal mode in case we get
+ * other processes writing to the screen. This goal cannot be met for
+ * magic cookies since it interferes with attributes that may propagate
+ * past the current position.
*/
- UpdateAttrs(A_NORMAL);
+#if USE_XMC_SUPPORT
+ if (magic_cookie_glitch != 0)
+#endif
+ UpdateAttrs(normal);
_nc_flush();
- curscr->_attrs = newscr->_attrs;
+ WINDOW_ATTRS(curscr) = WINDOW_ATTRS(newscr);
#if USE_TRACE_TIMES
(void) times(&after);
TR(TRACE_TIMES,
("Update cost: %ld chars, %ld clocks system time, %ld clocks user time",
_nc_outchars,
- after.tms_stime - before.tms_stime,
- after.tms_utime - before.tms_utime));
+ (long) (after.tms_stime - before.tms_stime),
+ (long) (after.tms_utime - before.tms_utime)));
#endif /* USE_TRACE_TIMES */
_nc_signal_handler(TRUE);
@@ -807,14 +953,14 @@ doupdate(void)
* in the wbkgd() call. Assume 'stdscr' for this case.
*/
#define BCE_ATTRS (A_NORMAL|A_COLOR)
-#define BCE_BKGD(win) (((win) == curscr ? stdscr : (win))->_bkgd)
+#define BCE_BKGD(win) (((win) == curscr ? stdscr : (win))->_nc_bkgd)
-static inline chtype
+static NCURSES_INLINE NCURSES_CH_T
ClrBlank(WINDOW *win)
{
- chtype blank = BLANK;
+ NCURSES_CH_T blank = blankchar;
if (back_color_erase)
- blank |= (BCE_BKGD(win) & BCE_ATTRS);
+ AddAttr(blank, (AttrOf(BCE_BKGD(win)) & BCE_ATTRS));
return blank;
}
@@ -829,10 +975,10 @@ static void
ClrUpdate(void)
{
int i;
- chtype blank = ClrBlank(stdscr);
+ NCURSES_CH_T blank = ClrBlank(stdscr);
int nonempty = min(screen_lines, newscr->_maxy + 1);
- TR(TRACE_UPDATE, ("ClrUpdate() called"));
+ TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
ClearScreen(blank);
@@ -842,6 +988,8 @@ ClrUpdate(void)
for (i = 0; i < nonempty; i++)
TransformLine(i);
+
+ TR(TRACE_UPDATE, (T_RETURN("")));
}
/*
@@ -851,7 +999,7 @@ ClrUpdate(void)
*/
static void
-ClrToEOL(chtype blank, bool needclear)
+ClrToEOL(NCURSES_CH_T blank, bool needclear)
{
int j;
@@ -859,9 +1007,9 @@ ClrToEOL(chtype blank, bool needclear)
&& SP->_cursrow >= 0) {
for (j = SP->_curscol; j < screen_columns; j++) {
if (j >= 0) {
- chtype *cp = &(curscr->_line[SP->_cursrow].text[j]);
+ NCURSES_CH_T *cp = &(curscr->_line[SP->_cursrow].text[j]);
- if (*cp != blank) {
+ if (!CharEq(*cp, blank)) {
*cp = blank;
needclear = TRUE;
}
@@ -874,12 +1022,12 @@ ClrToEOL(chtype blank, bool needclear)
if (needclear) {
UpdateAttrs(blank);
TPUTS_TRACE("clr_eol");
- if (SP->_el_cost > (screen_columns - SP->_curscol)) {
+ if (clr_eol && SP->_el_cost <= (screen_columns - SP->_curscol)) {
+ putp(clr_eol);
+ } else {
int count = (screen_columns - SP->_curscol);
while (count-- > 0)
- PutChar(blank);
- } else {
- putp(clr_eol);
+ PutChar(CHREF(blank));
}
}
}
@@ -891,7 +1039,7 @@ ClrToEOL(chtype blank, bool needclear)
*/
static void
-ClrToEOS(chtype blank)
+ClrToEOS(NCURSES_CH_T blank)
{
int row, col;
@@ -925,39 +1073,51 @@ ClrBottom(int total)
int col;
int top = total;
int last = min(screen_columns, newscr->_maxx + 1);
- chtype blank = ClrBlank(stdscr);
+ NCURSES_CH_T blank = newscr->_line[total - 1].text[last - 1];
bool ok;
- if (clr_eos && can_clear_with(blank)) {
+ if (clr_eos && can_clear_with(CHREF(blank))) {
for (row = total - 1; row >= 0; row--) {
for (col = 0, ok = TRUE; ok && col < last; col++) {
- ok = (newscr->_line[row].text[col] == blank);
+ ok = (CharEq(newscr->_line[row].text[col], blank));
}
if (!ok)
break;
for (col = 0; ok && col < last; col++) {
- ok = (curscr->_line[row].text[col] == blank);
+ ok = (CharEq(curscr->_line[row].text[col], blank));
}
if (!ok)
top = row;
}
/* don't use clr_eos for just one line if clr_eol available */
- if (top < total - 1 || (top < total && !clr_eol && !clr_bol)) {
+ if (top < total) {
GoTo(top, 0);
ClrToEOS(blank);
- total = top;
if (SP->oldhash && SP->newhash) {
for (row = top; row < screen_lines; row++)
SP->oldhash[row] = SP->newhash[row];
}
}
}
- return total;
+ return top;
}
+#if USE_XMC_SUPPORT
+#if USE_WIDEC_SUPPORT
+#define check_xmc_transition(a, b) \
+ ((((a)->attr ^ (b)->attr) & ~((a)->attr) & SP->_xmc_triggers) != 0)
+#define xmc_turn_on(a,b) check_xmc_transition(&(a), &(b))
+#else
+#define xmc_turn_on(a,b) ((((a)^(b)) & ~(a) & SP->_xmc_triggers) != 0)
+#endif
+
+#define xmc_new(r,c) newscr->_line[r].text[c]
+#define xmc_turn_off(a,b) xmc_turn_on(b,a)
+#endif /* USE_XMC_SUPPORT */
+
/*
** TransformLine(lineno)
**
@@ -980,19 +1140,17 @@ static void
TransformLine(int const lineno)
{
int firstChar, oLastChar, nLastChar;
- chtype *newLine = newscr->_line[lineno].text;
- chtype *oldLine = curscr->_line[lineno].text;
+ NCURSES_CH_T *newLine = newscr->_line[lineno].text;
+ NCURSES_CH_T *oldLine = curscr->_line[lineno].text;
int n;
bool attrchanged = FALSE;
- TR(TRACE_UPDATE, ("TransformLine(%d) called", lineno));
+ TR(TRACE_UPDATE, (T_CALLED("TransformLine(%d)"), lineno));
/* copy new hash value to old one */
if (SP->oldhash && SP->newhash)
SP->oldhash[lineno] = SP->newhash[lineno];
-#define ColorOf(n) ((n) & A_COLOR)
-#define unColor(n) ((n) & ALL_BUT_COLOR)
/*
* If we have colors, there is the possibility of having two color pairs
* that display as the same colors. For instance, Lynx does this. Check
@@ -1000,24 +1158,19 @@ TransformLine(int const lineno)
* they are equivalent.
*/
if (SP->_coloron) {
- chtype oldColor;
- chtype newColor;
int oldPair;
int newPair;
for (n = 0; n < screen_columns; n++) {
- if (newLine[n] != oldLine[n]) {
- oldColor = ColorOf(oldLine[n]);
- newColor = ColorOf(newLine[n]);
- if (oldColor != newColor
+ if (!CharEq(newLine[n], oldLine[n])) {
+ oldPair = GetPair(oldLine[n]);
+ newPair = GetPair(newLine[n]);
+ if (oldPair != newPair
&& unColor(oldLine[n]) == unColor(newLine[n])) {
- oldPair = PAIR_NUMBER(oldColor);
- newPair = PAIR_NUMBER(newColor);
if (oldPair < COLOR_PAIRS
&& newPair < COLOR_PAIRS
&& SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) {
- oldLine[n] &= ~A_COLOR;
- oldLine[n] |= ColorOf(newLine[n]);
+ SetPair(oldLine[n], GetPair(newLine[n]));
}
}
}
@@ -1027,8 +1180,10 @@ TransformLine(int const lineno)
if (ceol_standout_glitch && clr_eol) {
firstChar = 0;
while (firstChar < screen_columns) {
- if (AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar]))
+ if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
attrchanged = TRUE;
+ break;
+ }
firstChar++;
}
}
@@ -1041,10 +1196,6 @@ TransformLine(int const lineno)
PutRange(oldLine, newLine, lineno, 0, (screen_columns - 1));
#if USE_XMC_SUPPORT
-#define NEW(r,c) newscr->_line[r].text[c]
-#define xmc_turn_on(a,b) ((((a)^(b)) & ~(a) & SP->_xmc_triggers) != 0)
-#define xmc_turn_off(a,b) xmc_turn_on(b,a)
-
/*
* This is a very simple loop to paint characters which may have the
* magic cookie glitch embedded. It doesn't know much about video
@@ -1065,86 +1216,96 @@ TransformLine(int const lineno)
* If we are writing an attributed blank, where the
* previous cell is not attributed.
*/
- if (TextOf(newLine[n]) == ' '
+ if (ISBLANK(newLine[n])
&& ((n > 0
&& xmc_turn_on(newLine[n - 1], newLine[n]))
|| (n == 0
&& lineno > 0
- && xmc_turn_on(NEW(lineno - 1, screen_columns - 1),
+ && xmc_turn_on(xmc_new(lineno - 1, screen_columns - 1),
newLine[n])))) {
n = m;
}
- PutChar(newLine[n]);
+ PutChar(CHREF(newLine[n]));
/* check for turn-off:
* If we are writing an attributed non-blank, where the
* next cell is blank, and not attributed.
*/
- if (TextOf(newLine[n]) != ' '
+ if (!ISBLANK(newLine[n])
&& ((n + 1 < screen_columns
&& xmc_turn_off(newLine[n], newLine[n + 1]))
|| (n + 1 >= screen_columns
&& lineno + 1 < screen_lines
- && xmc_turn_off(newLine[n], NEW(lineno + 1, 0))))) {
+ && xmc_turn_off(newLine[n], xmc_new(lineno + 1, 0))))) {
n = m;
}
}
-#undef NEW
#endif
} else {
- chtype blank;
-
- /* find the first differing character */
- while (firstChar < screen_columns &&
- newLine[firstChar] == oldLine[firstChar])
- firstChar++;
-
- /* if there wasn't one, we're done */
- if (firstChar >= screen_columns)
- return;
+ NCURSES_CH_T blank;
/* it may be cheap to clear leading whitespace with clr_bol */
- if (clr_bol && can_clear_with(blank = newLine[0])) {
+ blank = newLine[0];
+ if (clr_bol && can_clear_with(CHREF(blank))) {
int oFirstChar, nFirstChar;
for (oFirstChar = 0; oFirstChar < screen_columns; oFirstChar++)
- if (oldLine[oFirstChar] != blank)
+ if (!CharEq(oldLine[oFirstChar], blank))
break;
for (nFirstChar = 0; nFirstChar < screen_columns; nFirstChar++)
- if (newLine[nFirstChar] != blank)
+ if (!CharEq(newLine[nFirstChar], blank))
break;
- if (nFirstChar > oFirstChar + SP->_el1_cost) {
- if (nFirstChar >= screen_columns && SP->_el_cost <= SP->_el1_cost) {
- GoTo(lineno, 0);
- UpdateAttrs(blank);
- TPUTS_TRACE("clr_eol");
- putp(clr_eol);
- } else {
- GoTo(lineno, nFirstChar - 1);
- UpdateAttrs(blank);
- TPUTS_TRACE("clr_bol");
- putp(clr_bol);
- }
-
- while (firstChar < nFirstChar)
- oldLine[firstChar++] = blank;
+ if (nFirstChar == oFirstChar) {
+ firstChar = nFirstChar;
+ /* find the first differing character */
+ while (firstChar < screen_columns
+ && CharEq(newLine[firstChar], oldLine[firstChar]))
+ firstChar++;
+ } else if (oFirstChar > nFirstChar) {
+ firstChar = nFirstChar;
+ } else { /* oFirstChar < nFirstChar */
+ firstChar = oFirstChar;
+ if (SP->_el1_cost < nFirstChar - oFirstChar) {
+ if (nFirstChar >= screen_columns
+ && SP->_el_cost <= SP->_el1_cost) {
+ GoTo(lineno, 0);
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clr_eol");
+ putp(clr_eol);
+ } else {
+ GoTo(lineno, nFirstChar - 1);
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clr_bol");
+ putp(clr_bol);
+ }
- if (firstChar >= screen_columns)
- return;
+ while (firstChar < nFirstChar)
+ oldLine[firstChar++] = blank;
+ }
}
+ } else {
+ /* find the first differing character */
+ while (firstChar < screen_columns
+ && CharEq(newLine[firstChar], oldLine[firstChar]))
+ firstChar++;
+ }
+ /* if there wasn't one, we're done */
+ if (firstChar >= screen_columns) {
+ TR(TRACE_UPDATE, (T_RETURN("")));
+ return;
}
blank = newLine[screen_columns - 1];
- if (!can_clear_with(blank)) {
+ if (!can_clear_with(CHREF(blank))) {
/* find the last differing character */
nLastChar = screen_columns - 1;
while (nLastChar > firstChar
- && newLine[nLastChar] == oldLine[nLastChar])
+ && CharEq(newLine[nLastChar], oldLine[nLastChar]))
nLastChar--;
if (nLastChar >= firstChar) {
@@ -1152,29 +1313,30 @@ TransformLine(int const lineno)
PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
memcpy(oldLine + firstChar,
newLine + firstChar,
- (nLastChar - firstChar + 1) * sizeof(chtype));
+ (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
}
+ TR(TRACE_UPDATE, (T_RETURN("")));
return;
}
/* find last non-blank character on old line */
oLastChar = screen_columns - 1;
- while (oLastChar > firstChar && oldLine[oLastChar] == blank)
+ while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
oLastChar--;
/* find last non-blank character on new line */
nLastChar = screen_columns - 1;
- while (nLastChar > firstChar && newLine[nLastChar] == blank)
+ while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
nLastChar--;
if ((nLastChar == firstChar)
&& (SP->_el_cost < (oLastChar - nLastChar))) {
GoTo(lineno, firstChar);
- if (newLine[firstChar] != blank)
- PutChar(newLine[firstChar]);
+ if (!CharEq(newLine[firstChar], blank))
+ PutChar(CHREF(newLine[firstChar]));
ClrToEOL(blank, FALSE);
} else if ((nLastChar != oLastChar)
- && (newLine[nLastChar] != oldLine[oLastChar]
+ && (!CharEq(newLine[nLastChar], oldLine[oLastChar])
|| !(_nc_idcok && has_ic()))) {
GoTo(lineno, firstChar);
if ((oLastChar - nLastChar) > SP->_el_cost) {
@@ -1190,14 +1352,16 @@ TransformLine(int const lineno)
int oLastNonblank = oLastChar;
/* find the last characters that really differ */
- while (newLine[nLastChar] == oldLine[oLastChar]) {
- if (nLastChar != 0
- && oLastChar != 0) {
- nLastChar--;
- oLastChar--;
- } else {
+ /* can be -1 if no characters differ */
+ while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
+ /* don't split a wide char */
+ if (isWidecExt(newLine[nLastChar]) &&
+ !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
+ break;
+ nLastChar--;
+ oLastChar--;
+ if (nLastChar == -1 || oLastChar == -1)
break;
- }
}
n = min(oLastChar, nLastChar);
@@ -1208,9 +1372,15 @@ TransformLine(int const lineno)
if (oLastChar < nLastChar) {
int m = max(nLastNonblank, oLastNonblank);
+#if USE_WIDEC_SUPPORT
+ while (isWidecExt(newLine[n + 1]) && n) {
+ --n;
+ --oLastChar;
+ }
+#endif
GoTo(lineno, n + 1);
- if (InsCharCost(nLastChar - oLastChar)
- > (m - n)) {
+ if ((nLastChar < nLastNonblank)
+ || InsCharCost(nLastChar - oLastChar) > (m - n)) {
PutRange(oldLine, newLine, lineno, n + 1, m);
} else {
InsStr(&newLine[n + 1], nLastChar - oLastChar);
@@ -1243,7 +1413,9 @@ TransformLine(int const lineno)
if (screen_columns > firstChar)
memcpy(oldLine + firstChar,
newLine + firstChar,
- (screen_columns - firstChar) * sizeof(chtype));
+ (screen_columns - firstChar) * sizeof(NCURSES_CH_T));
+ TR(TRACE_UPDATE, (T_RETURN("")));
+ return;
}
/*
@@ -1254,7 +1426,7 @@ TransformLine(int const lineno)
*/
static void
-ClearScreen(chtype blank)
+ClearScreen(NCURSES_CH_T blank)
{
int i, j;
bool fast_clear = (clear_screen || clr_eos || clr_eol);
@@ -1264,7 +1436,7 @@ ClearScreen(chtype blank)
#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
- _nc_do_color((int) COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
+ _nc_do_color(GET_SCREEN_PAIR(SP), 0, FALSE, _nc_outch);
if (!back_color_erase) {
fast_clear = FALSE;
}
@@ -1284,7 +1456,7 @@ ClearScreen(chtype blank)
UpdateAttrs(blank);
TPUTS_TRACE("clr_eos");
- putp(clr_eos);
+ tputs(clr_eos, screen_lines, _nc_outch);
} else if (clr_eol) {
SP->_cursrow = SP->_curscol = -1;
@@ -1301,7 +1473,7 @@ ClearScreen(chtype blank)
for (i = 0; i < screen_lines; i++) {
GoTo(i, 0);
for (j = 0; j < screen_columns; j++)
- PutChar(blank);
+ PutChar(CHREF(blank));
}
GoTo(0, 0);
}
@@ -1322,7 +1494,7 @@ ClearScreen(chtype blank)
*/
static void
-InsStr(chtype * line, int count)
+InsStr(NCURSES_CH_T * line, int count)
{
TR(TRACE_UPDATE, ("InsStr(%p,%d) called", line, count));
@@ -1331,9 +1503,9 @@ InsStr(chtype * line, int count)
/* The order must match that of InsCharCost. */
if (parm_ich) {
TPUTS_TRACE("parm_ich");
- tputs(tparm(parm_ich, count), count, _nc_outch);
+ tputs(TPARM_1(parm_ich, count), count, _nc_outch);
while (count) {
- PutAttrChar(*line);
+ PutAttrChar(CHREF(*line));
line++;
count--;
}
@@ -1341,7 +1513,7 @@ InsStr(chtype * line, int count)
TPUTS_TRACE("enter_insert_mode");
putp(enter_insert_mode);
while (count) {
- PutAttrChar(*line);
+ PutAttrChar(CHREF(*line));
if (insert_padding) {
TPUTS_TRACE("insert_padding");
putp(insert_padding);
@@ -1355,7 +1527,7 @@ InsStr(chtype * line, int count)
while (count) {
TPUTS_TRACE("insert_character");
putp(insert_character);
- PutAttrChar(*line);
+ PutAttrChar(CHREF(*line));
if (insert_padding) {
TPUTS_TRACE("insert_padding");
putp(insert_padding);
@@ -1379,12 +1551,14 @@ DelChar(int count)
{
int n;
- TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%d,%d)", count,
- newscr->_cury, newscr->_curx));
+ TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%ld,%ld)",
+ count,
+ (long) newscr->_cury,
+ (long) newscr->_curx));
if (parm_dch) {
TPUTS_TRACE("parm_dch");
- tputs(tparm(parm_dch, count), count, _nc_outch);
+ tputs(TPARM_1(parm_dch, count), count, _nc_outch);
} else {
for (n = 0; n < count; n++) {
TPUTS_TRACE("delete_character");
@@ -1394,19 +1568,6 @@ DelChar(int count)
}
/*
-** _nc_outstr(char *str)
-**
-** Emit a string without waiting for update.
-*/
-
-NCURSES_EXPORT(void)
-_nc_outstr(const char *str)
-{
- (void) putp(str);
- _nc_flush();
-}
-
-/*
* Physical-scrolling support
*
* This code was adapted from Keith Bostic's hardware scrolling
@@ -1440,53 +1601,54 @@ _nc_outstr(const char *str)
/* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
static int
-scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank)
+scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T blank)
{
- int i, j;
+ int i;
if (n == 1 && scroll_forward && top == miny && bot == maxy) {
GoTo(bot, 0);
UpdateAttrs(blank);
TPUTS_TRACE("scroll_forward");
- tputs(scroll_forward, 0, _nc_outch);
+ putp(scroll_forward);
} else if (n == 1 && delete_line && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
TPUTS_TRACE("delete_line");
- tputs(delete_line, 0, _nc_outch);
+ putp(delete_line);
} else if (parm_index && top == miny && bot == maxy) {
GoTo(bot, 0);
UpdateAttrs(blank);
TPUTS_TRACE("parm_index");
- tputs(tparm(parm_index, n, 0), n, _nc_outch);
+ tputs(TPARM_2(parm_index, n, 0), n, _nc_outch);
} else if (parm_delete_line && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
TPUTS_TRACE("parm_delete_line");
- tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
+ tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
} else if (scroll_forward && top == miny && bot == maxy) {
GoTo(bot, 0);
UpdateAttrs(blank);
for (i = 0; i < n; i++) {
TPUTS_TRACE("scroll_forward");
- tputs(scroll_forward, 0, _nc_outch);
+ putp(scroll_forward);
}
} else if (delete_line && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
for (i = 0; i < n; i++) {
TPUTS_TRACE("delete_line");
- tputs(delete_line, 0, _nc_outch);
+ putp(delete_line);
}
} else
return ERR;
#if NCURSES_EXT_FUNCS
if (FILL_BCE()) {
+ int j;
for (i = 0; i < n; i++) {
GoTo(bot - i, 0);
for (j = 0; j < screen_columns; j++)
- PutChar(blank);
+ PutChar(CHREF(blank));
}
}
#endif
@@ -1496,53 +1658,55 @@ scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank)
/* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
/* n > 0 */
static int
-scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank)
+scroll_csr_backward(int n, int top, int bot, int miny, int maxy,
+ NCURSES_CH_T blank)
{
- int i, j;
+ int i;
if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
TPUTS_TRACE("scroll_reverse");
- tputs(scroll_reverse, 0, _nc_outch);
+ putp(scroll_reverse);
} else if (n == 1 && insert_line && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
TPUTS_TRACE("insert_line");
- tputs(insert_line, 0, _nc_outch);
+ putp(insert_line);
} else if (parm_rindex && top == miny && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
TPUTS_TRACE("parm_rindex");
- tputs(tparm(parm_rindex, n, 0), n, _nc_outch);
+ tputs(TPARM_2(parm_rindex, n, 0), n, _nc_outch);
} else if (parm_insert_line && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
TPUTS_TRACE("parm_insert_line");
- tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
+ tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
} else if (scroll_reverse && top == miny && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
for (i = 0; i < n; i++) {
TPUTS_TRACE("scroll_reverse");
- tputs(scroll_reverse, 0, _nc_outch);
+ putp(scroll_reverse);
}
} else if (insert_line && bot == maxy) {
GoTo(top, 0);
UpdateAttrs(blank);
for (i = 0; i < n; i++) {
TPUTS_TRACE("insert_line");
- tputs(insert_line, 0, _nc_outch);
+ putp(insert_line);
}
} else
return ERR;
#if NCURSES_EXT_FUNCS
if (FILL_BCE()) {
+ int j;
for (i = 0; i < n; i++) {
GoTo(top + i, 0);
for (j = 0; j < screen_columns; j++)
- PutChar(blank);
+ PutChar(CHREF(blank));
}
}
#endif
@@ -1552,7 +1716,7 @@ scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank)
/* scroll by using delete_line at del and insert_line at ins */
/* n > 0 */
static int
-scroll_idl(int n, int del, int ins, chtype blank)
+scroll_idl(int n, int del, int ins, NCURSES_CH_T blank)
{
int i;
@@ -1563,14 +1727,14 @@ scroll_idl(int n, int del, int ins, chtype blank)
UpdateAttrs(blank);
if (n == 1 && delete_line) {
TPUTS_TRACE("delete_line");
- tputs(delete_line, 0, _nc_outch);
+ putp(delete_line);
} else if (parm_delete_line) {
TPUTS_TRACE("parm_delete_line");
- tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
+ tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
} else { /* if (delete_line) */
for (i = 0; i < n; i++) {
TPUTS_TRACE("delete_line");
- tputs(delete_line, 0, _nc_outch);
+ putp(delete_line);
}
}
@@ -1578,26 +1742,33 @@ scroll_idl(int n, int del, int ins, chtype blank)
UpdateAttrs(blank);
if (n == 1 && insert_line) {
TPUTS_TRACE("insert_line");
- tputs(insert_line, 0, _nc_outch);
+ putp(insert_line);
} else if (parm_insert_line) {
TPUTS_TRACE("parm_insert_line");
- tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
+ tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
} else { /* if (insert_line) */
for (i = 0; i < n; i++) {
TPUTS_TRACE("insert_line");
- tputs(insert_line, 0, _nc_outch);
+ putp(insert_line);
}
}
return OK;
}
+/*
+ * Note: some terminals require the cursor to be within the scrolling margins
+ * before setting them. Generally, the cursor must be at the appropriate end
+ * of the scrolling margins when issuing an indexing operation (it is not
+ * apparent whether it must also be at the left margin; we do this just to be
+ * safe). To make the related cursor movement a little faster, we use the
+ * save/restore cursor capabilities if the terminal has them.
+ */
NCURSES_EXPORT(int)
-_nc_scrolln
-(int n, int top, int bot, int maxy)
+_nc_scrolln(int n, int top, int bot, int maxy)
/* scroll region from top to bot by n lines */
{
- chtype blank = ClrBlank(stdscr);
+ NCURSES_CH_T blank = ClrBlank(stdscr);
int i;
bool cursor_saved = FALSE;
int res;
@@ -1626,13 +1797,13 @@ _nc_scrolln
&& save_cursor && restore_cursor) {
cursor_saved = TRUE;
TPUTS_TRACE("save_cursor");
- tputs(save_cursor, 0, _nc_outch);
+ putp(save_cursor);
}
TPUTS_TRACE("change_scroll_region");
- tputs(tparm(change_scroll_region, top, bot), 0, _nc_outch);
+ putp(TPARM_2(change_scroll_region, top, bot));
if (cursor_saved) {
TPUTS_TRACE("restore_cursor");
- tputs(restore_cursor, 0, _nc_outch);
+ putp(restore_cursor);
} else {
SP->_cursrow = SP->_curscol = -1;
}
@@ -1640,7 +1811,7 @@ _nc_scrolln
res = scroll_csr_forward(n, top, bot, top, bot, blank);
TPUTS_TRACE("change_scroll_region");
- tputs(tparm(change_scroll_region, 0, maxy), 0, _nc_outch);
+ putp(TPARM_2(change_scroll_region, 0, maxy));
SP->_cursrow = SP->_curscol = -1;
}
@@ -1652,13 +1823,14 @@ _nc_scrolln
*/
if (res != ERR
&& (non_dest_scroll_region || (memory_below && bot == maxy))) {
+ static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
if (bot == maxy && clr_eos) {
- GoTo(bot - n, 0);
- ClrToEOS(BLANK);
+ GoTo(bot - n + 1, 0);
+ ClrToEOS(blank2);
} else {
for (i = 0; i < n; i++) {
GoTo(bot - i, 0);
- ClrToEOL(BLANK, FALSE);
+ ClrToEOL(blank2, FALSE);
}
}
}
@@ -1671,13 +1843,13 @@ _nc_scrolln
&& save_cursor && restore_cursor) {
cursor_saved = TRUE;
TPUTS_TRACE("save_cursor");
- tputs(save_cursor, 0, _nc_outch);
+ putp(save_cursor);
}
TPUTS_TRACE("change_scroll_region");
- tputs(tparm(change_scroll_region, top, bot), 0, _nc_outch);
+ putp(TPARM_2(change_scroll_region, top, bot));
if (cursor_saved) {
TPUTS_TRACE("restore_cursor");
- tputs(restore_cursor, 0, _nc_outch);
+ putp(restore_cursor);
} else {
SP->_cursrow = SP->_curscol = -1;
}
@@ -1685,7 +1857,7 @@ _nc_scrolln
res = scroll_csr_backward(-n, top, bot, top, bot, blank);
TPUTS_TRACE("change_scroll_region");
- tputs(tparm(change_scroll_region, 0, maxy), 0, _nc_outch);
+ putp(TPARM_2(change_scroll_region, 0, maxy));
SP->_cursrow = SP->_curscol = -1;
}
@@ -1697,9 +1869,10 @@ _nc_scrolln
*/
if (res != ERR
&& (non_dest_scroll_region || (memory_above && top == 0))) {
+ static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
for (i = 0; i < -n; i++) {
GoTo(i + top, 0);
- ClrToEOL(BLANK, FALSE);
+ ClrToEOL(blank2, FALSE);
}
}
}
@@ -1719,11 +1892,27 @@ NCURSES_EXPORT(void)
_nc_screen_resume(void)
{
/* make sure terminal is in a sane known state */
- SP->_current_attr = A_NORMAL;
+ SetAttr(SCREEN_ATTRS(SP), A_NORMAL);
newscr->_clear = TRUE;
- if (SP->_coloron == TRUE && orig_pair)
- putp(orig_pair);
+ /* reset color pairs and definitions */
+ if (SP->_coloron || SP->_color_defs)
+ _nc_reset_colors();
+
+ /* restore user-defined colors, if any */
+ if (SP->_color_defs < 0) {
+ int n;
+ SP->_color_defs = -(SP->_color_defs);
+ for (n = 0; n < SP->_color_defs; ++n) {
+ if (SP->_color_table[n].init) {
+ init_color(n,
+ SP->_color_table[n].r,
+ SP->_color_table[n].g,
+ SP->_color_table[n].b);
+ }
+ }
+ }
+
if (exit_attribute_mode)
putp(exit_attribute_mode);
else {
@@ -1751,28 +1940,30 @@ _nc_screen_init(void)
NCURSES_EXPORT(void)
_nc_screen_wrap(void)
{
- UpdateAttrs(A_NORMAL);
+ UpdateAttrs(normal);
#if NCURSES_EXT_FUNCS
if (SP->_coloron
&& !SP->_default_color) {
+ static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
SP->_default_color = TRUE;
_nc_do_color(-1, 0, FALSE, _nc_outch);
SP->_default_color = FALSE;
mvcur(SP->_cursrow, SP->_curscol, screen_lines - 1, 0);
- SP->_cursrow = screen_lines - 1;
- SP->_curscol = 0;
- ClrToEOL(BLANK, TRUE);
+ ClrToEOL(blank, TRUE);
}
#endif
+ if (SP->_color_defs) {
+ _nc_reset_colors();
+ }
}
#if USE_XMC_SUPPORT
NCURSES_EXPORT(void)
_nc_do_xmc_glitch(attr_t previous)
{
- attr_t chg = XMC_CHANGES(previous ^ SP->_current_attr);
+ attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP)));
while (chg != 0) {
if (chg & 1) {
diff --git a/lib/libcurses/unctrl.h b/lib/libcurses/unctrl.h
index 211540418b9..eb9f9ce16a0 100644
--- a/lib/libcurses/unctrl.h
+++ b/lib/libcurses/unctrl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: unctrl.h,v 1.8 2001/01/22 18:01:35 millert Exp $ */
+/* $OpenBSD: unctrl.h,v 1.9 2010/01/12 23:21:59 nicm Exp $ */
/****************************************************************************
* Copyright (c) 1998,2000 Free Software Foundation, Inc. *
@@ -41,13 +41,13 @@
* as ^?. Printable characters are displayed as is.
*/
-/* $From: unctrl.h.in,v 1.9 2000/12/10 02:02:15 tom Exp $ */
+/* $Id: unctrl.h,v 1.9 2010/01/12 23:21:59 nicm Exp $ */
-#ifndef _UNCTRL_H
-#define _UNCTRL_H 1
+#ifndef NCURSES_UNCTRL_H_incl
+#define NCURSES_UNCTRL_H_incl 1
#undef NCURSES_VERSION
-#define NCURSES_VERSION "5.2"
+#define NCURSES_VERSION "5.7"
#ifdef __cplusplus
extern "C" {
@@ -62,4 +62,4 @@ NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
}
#endif
-#endif /* _UNCTRL_H */
+#endif /* NCURSES_UNCTRL_H_incl */
diff --git a/lib/libcurses/wresize.3 b/lib/libcurses/wresize.3
index 5d718031ee7..8e6b09eefb9 100644
--- a/lib/libcurses/wresize.3
+++ b/lib/libcurses/wresize.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: wresize.3,v 1.6 1998/09/13 19:16:31 millert Exp $
+.\" $OpenBSD: wresize.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,40 +28,34 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" Author: Thomas E. Dickey <dickey@clark.net> 1996
+.\" Author: Thomas E. Dickey 1996
.\"
-.\" $From: wresize.3x,v 1.5 1998/03/14 23:42:44 tom Exp $
+.\" $Id: wresize.3,v 1.7 2010/01/12 23:21:59 nicm Exp $
.TH wresize 3 ""
.SH NAME
\fBwresize\fR - resize a curses window
-..
.SH SYNOPSIS
\fB#include <curses.h>\fR
-
+.sp
\fBint wresize(WINDOW *win, int lines, int columns);\fR
-..
.SH DESCRIPTION
-The \fBwresize\fR function reallocates storage for a \fBcurses\fR
+The \fBwresize\fR function reallocates storage for an \fBncurses\fR
window to adjust its dimensions to the specified values.
If either dimension is larger than the current values, the
window's data is filled with blanks that have the current background rendition
(as set by \fBwbkgndset\fR) merged into them.
-..
.SH RETURN VALUE
The function returns the integer \fBERR\fR upon failure and \fBOK\fR on success.
It will fail if either of the dimensions less than or equal to zero,
or if an error occurs while (re)allocating memory for the window.
-..
.SH NOTES
The only restriction placed on the dimensions is that they be greater than zero.
The dimensions are not compared to \fBcurses\fR screen dimensions to
simplify the logic of \fBresizeterm\fR.
The caller must ensure that the window's dimensions fit within the
actual screen dimensions.
-..
.SH SEE ALSO
\fBresizeterm\fR(3).
-..
.SH AUTHOR
Thomas Dickey (from an equivalent function written in 1988 for BSD curses).
.\"#
diff --git a/lib/libform/Makefile b/lib/libform/Makefile
index 802d1a72693..8ce3ad75cfa 100644
--- a/lib/libform/Makefile
+++ b/lib/libform/Makefile
@@ -3,12 +3,13 @@ WANTLINT=
SRCS= fld_arg.c fld_attr.c fld_current.c fld_def.c fld_dup.c fld_ftchoice.c \
fld_ftlink.c fld_info.c fld_just.c fld_link.c fld_max.c fld_move.c \
fld_newftyp.c fld_opts.c fld_pad.c fld_page.c fld_stat.c fld_type.c \
- fld_user.c frm_adabind.c frm_cursor.c frm_data.c frm_def.c \
+ fld_user.c frm_cursor.c frm_data.c frm_def.c \
frm_driver.c frm_hook.c frm_opts.c frm_page.c frm_post.c \
frm_req_name.c frm_scale.c frm_sub.c frm_user.c frm_win.c fty_alnum.c \
- fty_alpha.c fty_enum.c fty_int.c fty_ipv4.c fty_num.c fty_regex.c
+ fty_alpha.c fty_enum.c fty_int.c fty_ipv4.c fty_num.c fty_regex.c \
+ f_trace.c
HDRS= form.h
-CFLAGS+=-I${.CURDIR}/../libmenu -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H
+CFLAGS+=-I${.CURDIR}/../libmenu -I${.CURDIR}/../libcurses
MAN= form.3tbl form_cursor.3 form_data.3 form_driver.3 form_field.3 \
form_field_attributes.3 form_field_buffer.3 form_field_info.3 \
form_field_just.3 form_field_new.3 form_field_opts.3 \
diff --git a/lib/libform/READ.ME b/lib/libform/READ.ME
index 12a540ea615..a2d2bb1bb26 100644
--- a/lib/libform/READ.ME
+++ b/lib/libform/READ.ME
@@ -1,3 +1,33 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. --
+-- --
+-- Permission is hereby granted, free of charge, to any person obtaining a --
+-- copy of this software and associated documentation files (the --
+-- "Software"), to deal in the Software without restriction, including --
+-- without limitation the rights to use, copy, modify, merge, publish, --
+-- distribute, distribute with modifications, sublicense, and/or sell copies --
+-- of the Software, and to permit persons to whom the Software is furnished --
+-- to do so, subject to the following conditions: --
+-- --
+-- The above copyright notice and this permission notice shall be included --
+-- in all copies or substantial portions of the Software. --
+-- --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN --
+-- NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE --
+-- USE OR OTHER DEALINGS IN THE SOFTWARE. --
+-- --
+-- Except as contained in this notice, the name(s) of the above copyright --
+-- holders shall not be used in advertising or otherwise to promote the --
+-- sale, use or other dealings in this Software without prior written --
+-- authorization. --
+-------------------------------------------------------------------------------
+-- $Id: READ.ME,v 1.3 2010/01/12 23:22:07 nicm Exp $
+-------------------------------------------------------------------------------
+
This is a clone of the form library that is available with typical
System V curses implementations (ETI).
@@ -10,6 +40,3 @@ For things that still need doing, see the TO-DO file in the top-level
directory.
Juergen Pfeifer
-
-eMail: Juergen.Pfeifer@T-Online.de
-
diff --git a/lib/libform/frm_adabind.c b/lib/libform/f_trace.c
index 5250e5767b9..97506441ba6 100644
--- a/lib/libform/frm_adabind.c
+++ b/lib/libform/f_trace.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_adabind.c,v 1.2 1998/07/24 02:37:24 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,55 +27,44 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1995,1997 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
-/***************************************************************************
-* Module frm_adabind.c *
-* Helper routines to ease the implementation of an Ada95 binding to *
-* ncurses. For details and copyright of the binding see the ../Ada95 *
-* subdirectory. *
-***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_adabind.c,v 1.5 1998/02/11 12:13:43 tom Exp $")
-
-/* Prototypes for the functions in this module */
-void _nc_ada_normalize_field_opts (int *opt);
-void _nc_ada_normalize_form_opts (int *opt);
-void* _nc_ada_getvarg(va_list *);
-FIELD* _nc_get_field(const FORM*, int);
-
+MODULE_ID("$Id: f_trace.c,v 1.1 2010/01/12 23:22:07 nicm Exp $")
-void _nc_ada_normalize_field_opts (int *opt)
+NCURSES_EXPORT(FIELD **)
+_nc_retrace_field_ptr(FIELD **code)
{
- *opt = ALL_FIELD_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
-void _nc_ada_normalize_form_opts (int *opt)
+NCURSES_EXPORT(FIELD *)
+_nc_retrace_field(FIELD *code)
{
- *opt = ALL_FORM_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_retrace_field_type(FIELDTYPE *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
-/* This tiny stub helps us to get a void pointer from an argument list.
-// The mechanism for libform to handle arguments to field types uses
-// unfortunately functions with variable argument lists. In the Ada95
-// binding we replace this by a mechanism that only uses one argument
-// that is a pointer to a record describing all the specifics of an
-// user defined field type. So we need only this simple generic
-// procedure to get the pointer from the arglist.
-*/
-void *_nc_ada_getvarg(va_list *ap)
+NCURSES_EXPORT(FORM *)
+_nc_retrace_form(FORM *code)
{
- return va_arg(*ap,void*);
+ T((T_RETURN("%p"), code));
+ return code;
}
-FIELD* _nc_get_field(const FORM* frm, int idx) {
- if (frm && frm->field && idx>=0 && (idx<frm->maxfield))
- {
- return frm->field[idx];
- }
- else
- return (FIELD*)0;
+NCURSES_EXPORT(Form_Hook)
+_nc_retrace_form_hook(Form_Hook code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
}
diff --git a/lib/libform/fld_arg.c b/lib/libform/fld_arg.c
index 5087cd986fc..7b690ac95ab 100644
--- a/lib/libform/fld_arg.c
+++ b/lib/libform/fld_arg.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_arg.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,21 +27,21 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_arg.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: fld_arg.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_fieldtype_arg(
| FIELDTYPE *typ,
| void * (* const make_arg)(va_list *),
| void * (* const copy_arg)(const void *),
| void (* const free_arg)(void *) )
-|
+|
| Description : Connects to the type additional arguments necessary
| for a set_field_type call. The various function pointer
| arguments are:
@@ -63,34 +61,38 @@ MODULE_ID("$From: fld_arg.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_fieldtype_arg
- (FIELDTYPE * typ,
- void * (* const make_arg)(va_list *),
- void * (* const copy_arg)(const void *),
- void (* const free_arg)(void *))
+set_fieldtype_arg(FIELDTYPE *typ,
+ void *(*const make_arg)(va_list *),
+ void *(*const copy_arg)(const void *),
+ void (*const free_arg) (void *))
{
- if ( !typ || !make_arg )
- RETURN(E_BAD_ARGUMENT);
+ T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"),
+ typ, make_arg, copy_arg, free_arg));
- typ->status |= _HAS_ARGS;
- typ->makearg = make_arg;
- typ->copyarg = copy_arg;
- typ->freearg = free_arg;
- RETURN(E_OK);
+ if (typ != 0 && make_arg != (void *)0)
+ {
+ typ->status |= _HAS_ARGS;
+ typ->makearg = make_arg;
+ typ->copyarg = copy_arg;
+ typ->freearg = free_arg;
+ RETURN(E_OK);
+ }
+ RETURN(E_BAD_ARGUMENT);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : void *field_arg(const FIELD *field)
-|
+|
| Description : Retrieve pointer to the fields argument structure.
|
| Return Values : Pointer to structure or NULL if none is defined.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-field_arg (const FIELD * field)
+field_arg(const FIELD *field)
{
- return Normalize_Field(field)->arg;
+ T((T_CALLED("field_arg(%p)"), field));
+ returnVoidPtr(Normalize_Field(field)->arg);
}
/* fld_arg.c ends here */
diff --git a/lib/libform/fld_attr.c b/lib/libform/fld_attr.c
index 01f71c99008..fa8709fcc29 100644
--- a/lib/libform/fld_attr.c
+++ b/lib/libform/fld_attr.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_attr.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_attr.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_attr.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*----------------------------------------------------------------------------
Field-Attribute manipulation routines
@@ -43,16 +42,22 @@ MODULE_ID("$From: fld_attr.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
{\
int res = E_BAD_ARGUMENT;\
+ T((T_CALLED("set_field_" #name "(%p,%s)"), field, _traceattr(attr)));\
if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
{\
Normalize_Field( field );\
- if ((field -> name) != attr)\
- {\
- field -> name = attr;\
- res = _nc_Synchronize_Attributes( field );\
- }\
- else\
- res = E_OK;\
+ if (field != 0) \
+ { \
+ if ((field -> name) != attr)\
+ {\
+ field -> name = attr;\
+ res = _nc_Synchronize_Attributes( field );\
+ }\
+ else\
+ {\
+ res = E_OK;\
+ }\
+ }\
}\
RETURN(res);\
}
@@ -61,13 +66,14 @@ NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
#define GEN_FIELD_ATTR_GET_FCT( name ) \
NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
{\
- return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
+ T((T_CALLED("field_" #name "(%p)"), field));\
+ returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_fore(FIELD *field, chtype attr)
-|
+|
| Description : Sets the foreground of the field used to display the
| field contents.
|
@@ -75,22 +81,22 @@ NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
| E_BAD_ARGUMENT - invalid attributes
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( fore )
+GEN_FIELD_ATTR_SET_FCT(fore)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : chtype field_fore(const FIELD *)
-|
+|
| Description : Retrieve fields foreground attribute
|
| Return Values : The foreground attribute
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( fore )
+GEN_FIELD_ATTR_GET_FCT(fore)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_back(FIELD *field, chtype attr)
-|
+|
| Description : Sets the background of the field used to display the
| fields extend.
|
@@ -98,16 +104,16 @@ GEN_FIELD_ATTR_GET_FCT( fore )
| E_BAD_ARGUMENT - invalid attributes
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( back )
+GEN_FIELD_ATTR_SET_FCT(back)
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : chtype field_back(const
-|
+| Function : chtype field_back(const
+|
| Description : Retrieve fields background attribute
|
| Return Values : The background attribute
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( back )
+GEN_FIELD_ATTR_GET_FCT(back)
/* fld_attr.c ends here */
diff --git a/lib/libform/fld_current.c b/lib/libform/fld_current.c
index 530dfbd69c5..b5c3a0fd2d8 100644
--- a/lib/libform/fld_current.c
+++ b/lib/libform/fld_current.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_current.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,16 +27,17 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_current.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_current.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_current_field(FORM * form,FIELD * field)
-|
+|
| Description : Set the current field of the form to the specified one.
|
| Return Values : E_OK - success
@@ -49,46 +48,53 @@ MODULE_ID("$From: fld_current.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_current_field (FORM * form, FIELD * field)
+set_current_field(FORM *form, FIELD *field)
{
int err = E_OK;
- if ( !form || !field )
- RETURN(E_BAD_ARGUMENT);
-
- if ( (form != field->form) || Field_Is_Not_Selectable(field) )
- RETURN(E_REQUEST_DENIED);
-
- if (!(form->status & _POSTED))
+ T((T_CALLED("set_current_field(%p,%p)"), form, field));
+ if (form == 0 || field == 0)
+ {
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else if ((form != field->form) || Field_Is_Not_Selectable(field))
+ {
+ RETURN(E_REQUEST_DENIED);
+ }
+ else if ((form->status & _POSTED) == 0)
{
form->current = field;
form->curpage = field->page;
- }
+ }
else
{
- if (form->status & _IN_DRIVER)
- err = E_BAD_STATE;
+ if ((form->status & _IN_DRIVER) != 0)
+ {
+ err = E_BAD_STATE;
+ }
else
{
if (form->current != field)
{
- if (!_nc_Internal_Validation(form))
- err = E_INVALID_FIELD;
+ if (!_nc_Internal_Validation(form))
+ {
+ err = E_INVALID_FIELD;
+ }
else
{
- Call_Hook(form,fieldterm);
+ Call_Hook(form, fieldterm);
if (field->page != form->curpage)
{
- Call_Hook(form,formterm);
- err = _nc_Set_Form_Page(form,field->page,field);
- Call_Hook(form,forminit);
- }
- else
+ Call_Hook(form, formterm);
+ err = _nc_Set_Form_Page(form, (int)field->page, field);
+ Call_Hook(form, forminit);
+ }
+ else
{
- err = _nc_Set_Current_Field(form,field);
+ err = _nc_Set_Current_Field(form, field);
}
- Call_Hook(form,fieldinit);
- _nc_Refresh_Current_Field(form);
+ Call_Hook(form, fieldinit);
+ (void)_nc_Refresh_Current_Field(form);
}
}
}
@@ -97,23 +103,24 @@ set_current_field (FORM * form, FIELD * field)
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : FIELD *current_field(const FORM * form)
-|
+|
| Description : Return the current field.
|
| Return Values : Pointer to the current field.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
-current_field (const FORM * form)
+current_field(const FORM *form)
{
- return Normalize_Form(form)->current;
+ T((T_CALLED("current_field(%p)"), form));
+ returnField(Normalize_Form(form)->current);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int field_index(const FIELD * field)
-|
+|
| Description : Return the index of the field in the field-array of
| the form.
|
@@ -121,9 +128,10 @@ current_field (const FORM * form)
| -1 : fieldpointer invalid or field not connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_index (const FIELD * field)
+field_index(const FIELD *field)
{
- return ( (field && field->form) ? field->index : -1 );
+ T((T_CALLED("field_index(%p)"), field));
+ returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
}
/* fld_current.c ends here */
diff --git a/lib/libform/fld_def.c b/lib/libform/fld_def.c
index d4402dcc282..46806b1104f 100644
--- a/lib/libform/fld_def.c
+++ b/lib/libform/fld_def.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_def.c,v 1.7 2003/11/08 19:17:27 jmc Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,296 +27,325 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_def.c,v 1.13 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_def.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/* this can't be readonly */
-static FIELD default_field = {
- 0, /* status */
- 0, /* rows */
- 0, /* cols */
- 0, /* frow */
- 0, /* fcol */
- 0, /* drows */
- 0, /* dcols */
- 0, /* maxgrow*/
- 0, /* nrow */
- 0, /* nbuf */
- NO_JUSTIFICATION, /* just */
- 0, /* page */
- 0, /* index */
- (int)' ', /* pad */
- A_NORMAL, /* fore */
- A_NORMAL, /* back */
- ALL_FIELD_OPTS, /* opts */
- (FIELD *)0, /* snext */
- (FIELD *)0, /* sprev */
- (FIELD *)0, /* link */
- (FORM *)0, /* form */
- (FIELDTYPE *)0, /* type */
- (char *)0, /* arg */
- (char *)0, /* buf */
- (char *)0 /* usrptr */
+static FIELD default_field =
+{
+ 0, /* status */
+ 0, /* rows */
+ 0, /* cols */
+ 0, /* frow */
+ 0, /* fcol */
+ 0, /* drows */
+ 0, /* dcols */
+ 0, /* maxgrow */
+ 0, /* nrow */
+ 0, /* nbuf */
+ NO_JUSTIFICATION, /* just */
+ 0, /* page */
+ 0, /* index */
+ (int)' ', /* pad */
+ A_NORMAL, /* fore */
+ A_NORMAL, /* back */
+ ALL_FIELD_OPTS, /* opts */
+ (FIELD *)0, /* snext */
+ (FIELD *)0, /* sprev */
+ (FIELD *)0, /* link */
+ (FORM *)0, /* form */
+ (FIELDTYPE *)0, /* type */
+ (char *)0, /* arg */
+ (FIELD_CELL *)0, /* buf */
+ (char *)0 /* usrptr */
+ NCURSES_FIELD_EXTENSION
};
-NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field = &default_field;
-
+NCURSES_EXPORT_VAR(FIELD *)
+_nc_Default_Field = &default_field;
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : TypeArgument *_nc_Make_Argument(
| const FIELDTYPE *typ,
| va_list *ap,
| int *err )
-|
+|
| Description : Create an argument structure for the specified type.
| Use the type-dependent argument list to construct
| it.
|
| Return Values : Pointer to argument structure. Maybe NULL.
-| In case of an error in *err an errorcounter is increased.
+| In case of an error in *err an error counter is increased.
+--------------------------------------------------------------------------*/
-NCURSES_EXPORT(TypeArgument*)
-_nc_Make_Argument
-(const FIELDTYPE *typ, va_list *ap, int *err)
+NCURSES_EXPORT(TypeArgument *)
+_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
{
- TypeArgument *res = (TypeArgument *)0;
+ TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
- if (typ && (typ->status & _HAS_ARGS))
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
- assert(err && ap);
- if (typ->status & _LINKED_TYPE)
+ assert(err != 0 && ap != (va_list *)0);
+ if ((typ->status & _LINKED_TYPE) != 0)
{
- p = (TypeArgument *)malloc(sizeof(TypeArgument));
- if (p)
+ p = typeMalloc(TypeArgument, 1);
+
+ if (p != 0)
{
- p->left = _nc_Make_Argument(typ->left ,ap,err);
- p->right = _nc_Make_Argument(typ->right,ap,err);
+ p->left = _nc_Make_Argument(typ->left, ap, err);
+ p->right = _nc_Make_Argument(typ->right, ap, err);
return p;
}
else
- *err += 1;
- } else
+ {
+ *err += 1;
+ }
+ }
+ else
{
- assert(typ->makearg);
- if ( !(res=(TypeArgument *)typ->makearg(ap)) )
- *err += 1;
+ assert(typ->makearg != (void *)0);
+ if (!(res = (TypeArgument *)typ->makearg(ap)))
+ {
+ *err += 1;
+ }
}
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ,
| const TypeArgument *argp,
| int *err )
-|
-| Description : Create a copy of an argument structure for the specified
+|
+| Description : Create a copy of an argument structure for the specified
| type.
|
| Return Values : Pointer to argument structure. Maybe NULL.
-| In case of an error in *err an errorcounter is increased.
+| In case of an error in *err an error counter is increased.
+--------------------------------------------------------------------------*/
-NCURSES_EXPORT(TypeArgument*)
-_nc_Copy_Argument
- (const FIELDTYPE *typ,
- const TypeArgument *argp, int *err)
+NCURSES_EXPORT(TypeArgument *)
+_nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
{
TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
- if ( typ && (typ->status & _HAS_ARGS) )
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
- assert(err && argp);
- if (typ->status & _LINKED_TYPE)
+ assert(err != 0 && argp != 0);
+ if ((typ->status & _LINKED_TYPE) != 0)
{
- p = (TypeArgument *)malloc(sizeof(TypeArgument));
- if (p)
+ p = typeMalloc(TypeArgument, 1);
+
+ if (p != 0)
{
- p->left = _nc_Copy_Argument(typ,argp->left ,err);
- p->right = _nc_Copy_Argument(typ,argp->right,err);
+ p->left = _nc_Copy_Argument(typ, argp->left, err);
+ p->right = _nc_Copy_Argument(typ, argp->right, err);
return p;
}
*err += 1;
- }
- else
+ }
+ else
{
- if (typ->copyarg)
+ if (typ->copyarg != (void *)0)
{
- if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
- *err += 1;
+ if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
+ {
+ *err += 1;
+ }
}
else
- res = (TypeArgument *)argp;
+ {
+ res = (TypeArgument *)argp;
+ }
}
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : void _nc_Free_Argument(const FIELDTYPE *typ,
| TypeArgument * argp )
-|
+|
| Description : Release memory associated with the argument structure
| for the given fieldtype.
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Free_Argument
-(const FIELDTYPE * typ, TypeArgument * argp)
+_nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *argp)
{
- if (!typ || !(typ->status & _HAS_ARGS))
- return;
-
- if (typ->status & _LINKED_TYPE)
- {
- assert(argp);
- _nc_Free_Argument(typ->left ,argp->left );
- _nc_Free_Argument(typ->right,argp->right);
- free(argp);
- }
- else
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
- if (typ->freearg)
- typ->freearg((void *)argp);
+ if ((typ->status & _LINKED_TYPE) != 0)
+ {
+ assert(argp != 0);
+ _nc_Free_Argument(typ->left, argp->left);
+ _nc_Free_Argument(typ->right, argp->right);
+ free(argp);
+ }
+ else
+ {
+ if (typ->freearg != (void *)0)
+ {
+ typ->freearg((void *)argp);
+ }
+ }
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : bool _nc_Copy_Type( FIELD *dst, FIELD const *src )
-|
+|
| Description : Copy argument structure of field src to field dst
|
| Return Values : TRUE - copy worked
-| FALSE - error occured
+| FALSE - error occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-_nc_Copy_Type
-(FIELD *dst, FIELD const *src)
+_nc_Copy_Type(FIELD *dst, FIELD const *src)
{
int err = 0;
- assert(dst && src);
+ assert(dst != 0 && src != 0);
dst->type = src->type;
- dst->arg = (void *)_nc_Copy_Argument(src->type,(TypeArgument *)(src->arg),&err);
+ dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err);
- if (err)
+ if (err != 0)
{
- _nc_Free_Argument(dst->type,(TypeArgument *)(dst->arg));
+ _nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg));
dst->type = (FIELDTYPE *)0;
- dst->arg = (void *)0;
+ dst->arg = (void *)0;
return FALSE;
}
else
{
- if (dst->type)
- dst->type->ref++;
+ if (dst->type != 0)
+ {
+ dst->type->ref++;
+ }
return TRUE;
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : void _nc_Free_Type( FIELD *field )
-|
+|
| Description : Release Argument structure for this field
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Free_Type (FIELD *field)
+_nc_Free_Type(FIELD *field)
{
- assert(field);
- if (field->type)
- field->type->ref--;
- _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
+ assert(field != 0);
+ if (field->type != 0)
+ {
+ field->type->ref--;
+ }
+ _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : FIELD *new_field( int rows, int cols,
+| Facility : libnform
+| Function : FIELD *new_field( int rows, int cols,
| int frow, int fcol,
| int nrow, int nbuf )
-|
+|
| Description : Create a new field with this many 'rows' and 'cols',
| starting at 'frow/fcol' in the subwindow of the form.
| Allocate 'nrow' off-screen rows and 'nbuf' additional
| buffers. If an error occurs, errno is set to
-|
+|
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
|
| Return Values : Pointer to the new field or NULL if failure.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
-new_field
-(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
+new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
{
+ static const FIELD_CELL blank = BLANK;
+ static const FIELD_CELL zeros = ZEROS;
+
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
- if (rows>0 &&
- cols>0 &&
- frow>=0 &&
- fcol>=0 &&
- nrow>=0 &&
- nbuf>=0 &&
- ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
- (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
+ T((T_CALLED("new_field(%d,%d,%d,%d,%d,%d)"), rows, cols, frow, fcol, nrow, nbuf));
+ if (rows > 0 &&
+ cols > 0 &&
+ frow >= 0 &&
+ fcol >= 0 &&
+ nrow >= 0 &&
+ nbuf >= 0 &&
+ ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
+ (New_Field = typeMalloc(FIELD, 1)) != 0)
{
- *New_Field = default_field;
- New_Field->rows = rows;
- New_Field->cols = cols;
+ T((T_CREATE("field %p"), New_Field));
+ *New_Field = default_field;
+ New_Field->rows = rows;
+ New_Field->cols = cols;
New_Field->drows = rows + nrow;
New_Field->dcols = cols;
- New_Field->frow = frow;
- New_Field->fcol = fcol;
- New_Field->nrow = nrow;
- New_Field->nbuf = nbuf;
- New_Field->link = New_Field;
+ New_Field->frow = frow;
+ New_Field->fcol = fcol;
+ New_Field->nrow = nrow;
+ New_Field->nbuf = nbuf;
+ New_Field->link = New_Field;
+
+#if USE_WIDEC_SUPPORT
+ New_Field->working = newpad(1, Buffer_Length(New_Field) + 1);
+ New_Field->expanded = typeCalloc(char *, 1 + (unsigned)nbuf);
+#endif
- if (_nc_Copy_Type(New_Field,&default_field))
+ if (_nc_Copy_Type(New_Field, &default_field))
{
size_t len;
len = Total_Buffer_Size(New_Field);
- if ((New_Field->buf = (char *)malloc(len)))
+ if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
{
/* Prefill buffers with blanks and insert terminating zeroes
- between buffers */
- int i;
+ between buffers */
+ int i, j;
+ int cells = Buffer_Length(New_Field);
- memset(New_Field->buf,' ',len);
- for(i=0;i<=New_Field->nbuf;i++)
+ for (i = 0; i <= New_Field->nbuf; i++)
{
- New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
- = '\0';
+ FIELD_CELL *buffer = &(New_Field->buf[(cells + 1) * i]);
+
+ for (j = 0; j < cells; ++j)
+ {
+ buffer[j] = blank;
+ }
+ buffer[j] = zeros;
}
- return New_Field;
+ returnField(New_Field);
}
}
}
- if (New_Field)
+ if (New_Field)
free_field(New_Field);
-
- SET_ERROR( err );
- return (FIELD *)0;
+
+ SET_ERROR(err);
+ returnField((FIELD *)0);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int free_field( FIELD *field )
-|
+|
| Description : Frees the storage allocated for the field.
|
| Return Values : E_OK - success
@@ -326,28 +353,45 @@ new_field
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_field (FIELD * field)
+free_field(FIELD *field)
{
- if (!field)
- RETURN(E_BAD_ARGUMENT);
-
- if (field->form)
- RETURN(E_CONNECTED);
-
- if (field == field->link)
+ T((T_CALLED("free_field(%p)"), field));
+ if (!field)
+ {
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else if (field->form != 0)
{
- if (field->buf)
+ RETURN(E_CONNECTED);
+ }
+ else if (field == field->link)
+ {
+ if (field->buf != 0)
free(field->buf);
}
- else
+ else
{
FIELD *f;
- for(f=field;f->link != field;f = f->link)
- {}
+ for (f = field; f->link != field; f = f->link)
+ {
+ }
f->link = field->link;
}
_nc_Free_Type(field);
+#if USE_WIDEC_SUPPORT
+ if (field->expanded != 0)
+ {
+ int n;
+
+ for (n = 0; n <= field->nbuf; ++n)
+ {
+ FreeIfNeeded(field->expanded[n]);
+ }
+ free(field->expanded);
+ (void)delwin(field->working);
+ }
+#endif
free(field);
RETURN(E_OK);
}
diff --git a/lib/libform/fld_dup.c b/lib/libform/fld_dup.c
index 3671141705a..7a10ca5929b 100644
--- a/lib/libform/fld_dup.c
+++ b/lib/libform/fld_dup.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_dup.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,72 +27,75 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_dup.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_dup.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : FIELD *dup_field(FIELD *field, int frow, int fcol)
-|
+|
| Description : Duplicates the field at the specified position. All
| field attributes and the buffers are copied.
| If an error occurs, errno is set to
-|
+|
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
|
| Return Values : Pointer to the new field or NULL if failure
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
-dup_field (FIELD * field, int frow, int fcol)
+dup_field(FIELD *field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
- if (field && (frow>=0) && (fcol>=0) &&
- ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
- (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
+ T((T_CALLED("dup_field(%p,%d,%d)"), field, frow, fcol));
+ if (field && (frow >= 0) && (fcol >= 0) &&
+ ((err = E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
+ (New_Field = typeMalloc(FIELD, 1)))
{
- *New_Field = *_nc_Default_Field;
- New_Field->frow = frow;
- New_Field->fcol = fcol;
- New_Field->link = New_Field;
- New_Field->rows = field->rows;
- New_Field->cols = field->cols;
- New_Field->nrow = field->nrow;
- New_Field->drows = field->drows;
- New_Field->dcols = field->dcols;
+ T((T_CREATE("field %p"), New_Field));
+ *New_Field = *_nc_Default_Field;
+ New_Field->frow = frow;
+ New_Field->fcol = fcol;
+ New_Field->link = New_Field;
+ New_Field->rows = field->rows;
+ New_Field->cols = field->cols;
+ New_Field->nrow = field->nrow;
+ New_Field->drows = field->drows;
+ New_Field->dcols = field->dcols;
New_Field->maxgrow = field->maxgrow;
- New_Field->nbuf = field->nbuf;
- New_Field->just = field->just;
- New_Field->fore = field->fore;
- New_Field->back = field->back;
- New_Field->pad = field->pad;
- New_Field->opts = field->opts;
- New_Field->usrptr = field->usrptr;
+ New_Field->nbuf = field->nbuf;
+ New_Field->just = field->just;
+ New_Field->fore = field->fore;
+ New_Field->back = field->back;
+ New_Field->pad = field->pad;
+ New_Field->opts = field->opts;
+ New_Field->usrptr = field->usrptr;
- if (_nc_Copy_Type(New_Field,field))
+ if (_nc_Copy_Type(New_Field, field))
{
- size_t len;
+ size_t i, len;
len = Total_Buffer_Size(New_Field);
- if ( (New_Field->buf=(char *)malloc(len)) )
+ if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
{
- memcpy(New_Field->buf,field->buf,len);
- return New_Field;
+ for (i = 0; i < len; ++i)
+ New_Field->buf[i] = field->buf[i];
+ returnField(New_Field);
}
}
}
- if (New_Field)
+ if (New_Field)
free_field(New_Field);
SET_ERROR(err);
- return (FIELD *)0;
+ returnField((FIELD *)0);
}
/* fld_dup.c ends here */
diff --git a/lib/libform/fld_ftchoice.c b/lib/libform/fld_ftchoice.c
index bf102348924..af4a2469959 100644
--- a/lib/libform/fld_ftchoice.c
+++ b/lib/libform/fld_ftchoice.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_ftchoice.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_ftchoice.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_ftchoice.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,12 +47,13 @@ MODULE_ID("$From: fld_ftchoice.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_BAD_ARGUMENT - invalid arguments
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_fieldtype_choice
- (FIELDTYPE * typ,
- bool (* const next_choice) (FIELD *,const void *),
- bool (* const prev_choice) (FIELD *,const void *))
+set_fieldtype_choice(FIELDTYPE *typ,
+ bool (*const next_choice) (FIELD *, const void *),
+ bool (*const prev_choice) (FIELD *, const void *))
{
- if ( !typ || !next_choice || !prev_choice )
+ T((T_CALLED("set_fieldtype_choice(%p,%p,%p)"), typ, next_choice, prev_choice));
+
+ if (!typ || !next_choice || !prev_choice)
RETURN(E_BAD_ARGUMENT);
typ->status |= _HAS_CHOICE;
diff --git a/lib/libform/fld_ftlink.c b/lib/libform/fld_ftlink.c
index 07557e59234..93072aa24b9 100644
--- a/lib/libform/fld_ftlink.c
+++ b/lib/libform/fld_ftlink.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_ftlink.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_ftlink.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_ftlink.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -48,40 +46,42 @@ MODULE_ID("$From: fld_ftlink.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_BAD_ARGUMENT - invalid arguments
| E_SYSTEM_ERROR - system error (no memory)
|
-| Return Values : Fieldtype pointer or NULL if error occured.
+| Return Values : Fieldtype pointer or NULL if error occurred.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
-link_fieldtype
-(FIELDTYPE * type1, FIELDTYPE * type2)
+link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
- if ( type1 && type2 )
+ T((T_CALLED("link_fieldtype(%p,%p)"), type1, type2));
+ if (type1 && type2)
{
- nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
+ nftyp = typeMalloc(FIELDTYPE, 1);
+
if (nftyp)
{
+ T((T_CREATE("fieldtype %p"), nftyp));
*nftyp = *_nc_Default_FieldType;
nftyp->status |= _LINKED_TYPE;
- if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) )
+ if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS))
nftyp->status |= _HAS_ARGS;
- if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) )
+ if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE))
nftyp->status |= _HAS_CHOICE;
- nftyp->left = type1;
- nftyp->right = type2;
+ nftyp->left = type1;
+ nftyp->right = type2;
type1->ref++;
type2->ref++;
}
else
{
- SET_ERROR( E_SYSTEM_ERROR );
+ SET_ERROR(E_SYSTEM_ERROR);
}
}
else
{
- SET_ERROR( E_BAD_ARGUMENT );
+ SET_ERROR(E_BAD_ARGUMENT);
}
- return nftyp;
+ returnFieldType(nftyp);
}
/* fld_ftlink.c ends here */
diff --git a/lib/libform/fld_info.c b/lib/libform/fld_info.c
index da868e6c1d4..216a8d24500 100644
--- a/lib/libform/fld_info.c
+++ b/lib/libform/fld_info.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_info.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_info.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_info.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,24 +47,35 @@ MODULE_ID("$From: fld_info.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_BAD_ARGUMENT - invalid field pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_info
- (const FIELD *field,
- int *rows, int *cols,
- int *frow, int *fcol,
- int *nrow, int *nbuf)
+field_info(const FIELD *field,
+ int *rows, int *cols,
+ int *frow, int *fcol,
+ int *nrow, int *nbuf)
{
- if (!field)
+ T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
+ field,
+ rows, cols,
+ frow, fcol,
+ nrow, nbuf));
+
+ if (!field)
RETURN(E_BAD_ARGUMENT);
- if (rows) *rows = field->rows;
- if (cols) *cols = field->cols;
- if (frow) *frow = field->frow;
- if (fcol) *fcol = field->fcol;
- if (nrow) *nrow = field->nrow;
- if (nbuf) *nbuf = field->nbuf;
+ if (rows)
+ *rows = field->rows;
+ if (cols)
+ *cols = field->cols;
+ if (frow)
+ *frow = field->frow;
+ if (fcol)
+ *fcol = field->fcol;
+ if (nrow)
+ *nrow = field->nrow;
+ if (nbuf)
+ *nbuf = field->nbuf;
RETURN(E_OK);
}
-
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int dynamic_field_info(const FIELD *field,
@@ -80,15 +89,19 @@ field_info
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-dynamic_field_info
-(const FIELD *field, int *drows, int *dcols, int *maxgrow)
+dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
{
+ T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"), field, drows, dcols, maxgrow));
+
if (!field)
RETURN(E_BAD_ARGUMENT);
- if (drows) *drows = field->drows;
- if (dcols) *dcols = field->dcols;
- if (maxgrow) *maxgrow = field->maxgrow;
+ if (drows)
+ *drows = field->drows;
+ if (dcols)
+ *dcols = field->dcols;
+ if (maxgrow)
+ *maxgrow = field->maxgrow;
RETURN(E_OK);
}
diff --git a/lib/libform/fld_just.c b/lib/libform/fld_just.c
index 61db459b6e7..0c1b7515af8 100644
--- a/lib/libform/fld_just.c
+++ b/lib/libform/fld_just.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_just.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_just.c,v 1.6 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_just.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,20 +45,22 @@ MODULE_ID("$From: fld_just.c,v 1.6 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_just (FIELD * field, int just)
+set_field_just(FIELD *field, int just)
{
int res = E_BAD_ARGUMENT;
- if ((just==NO_JUSTIFICATION) ||
- (just==JUSTIFY_LEFT) ||
- (just==JUSTIFY_CENTER) ||
- (just==JUSTIFY_RIGHT) )
+ T((T_CALLED("set_field_just(%p,%d)"), field, just));
+
+ if ((just == NO_JUSTIFICATION) ||
+ (just == JUSTIFY_LEFT) ||
+ (just == JUSTIFY_CENTER) ||
+ (just == JUSTIFY_RIGHT))
{
- Normalize_Field( field );
+ Normalize_Field(field);
if (field->just != just)
{
field->just = just;
- res = _nc_Synchronize_Attributes( field );
+ res = _nc_Synchronize_Attributes(field);
}
else
res = E_OK;
@@ -77,9 +77,10 @@ set_field_just (FIELD * field, int just)
| Return Values : The justification type.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_just (const FIELD * field)
+field_just(const FIELD *field)
{
- return Normalize_Field( field )->just;
+ T((T_CALLED("field_just(%p)"), field));
+ returnCode(Normalize_Field(field)->just);
}
/* fld_just.c ends here */
diff --git a/lib/libform/fld_link.c b/lib/libform/fld_link.c
index 8ee22de0067..544336845ac 100644
--- a/lib/libform/fld_link.c
+++ b/lib/libform/fld_link.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_link.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_link.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_link.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -51,43 +49,48 @@ MODULE_ID("$From: fld_link.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| Return Values : Pointer to the new field or NULL if failure
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
-link_field (FIELD * field, int frow, int fcol)
+link_field(FIELD *field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
- if (field && (frow>=0) && (fcol>=0) &&
- ((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
- (New_Field = (FIELD *)malloc(sizeof(FIELD))) )
+ T((T_CALLED("link_field(%p,%d,%d)"), field, frow, fcol));
+ if (field && (frow >= 0) && (fcol >= 0) &&
+ ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
+ (New_Field = typeMalloc(FIELD, 1)))
{
- *New_Field = *_nc_Default_Field;
- New_Field->frow = frow;
- New_Field->fcol = fcol;
- New_Field->link = field->link;
- field->link = New_Field;
- New_Field->buf = field->buf;
- New_Field->rows = field->rows;
- New_Field->cols = field->cols;
- New_Field->nrow = field->nrow;
- New_Field->nbuf = field->nbuf;
- New_Field->drows = field->drows;
- New_Field->dcols = field->dcols;
- New_Field->maxgrow= field->maxgrow;
- New_Field->just = field->just;
- New_Field->fore = field->fore;
- New_Field->back = field->back;
- New_Field->pad = field->pad;
- New_Field->opts = field->opts;
+ T((T_CREATE("field %p"), New_Field));
+ *New_Field = *_nc_Default_Field;
+ New_Field->frow = frow;
+ New_Field->fcol = fcol;
+
+ New_Field->link = field->link;
+ field->link = New_Field;
+
+ New_Field->buf = field->buf;
+ New_Field->rows = field->rows;
+ New_Field->cols = field->cols;
+ New_Field->nrow = field->nrow;
+ New_Field->nbuf = field->nbuf;
+ New_Field->drows = field->drows;
+ New_Field->dcols = field->dcols;
+ New_Field->maxgrow = field->maxgrow;
+ New_Field->just = field->just;
+ New_Field->fore = field->fore;
+ New_Field->back = field->back;
+ New_Field->pad = field->pad;
+ New_Field->opts = field->opts;
New_Field->usrptr = field->usrptr;
- if (_nc_Copy_Type(New_Field,field))
- return New_Field;
+
+ if (_nc_Copy_Type(New_Field, field))
+ returnField(New_Field);
}
- if (New_Field)
+ if (New_Field)
free_field(New_Field);
- SET_ERROR( err );
- return (FIELD *)0;
+ SET_ERROR(err);
+ returnField((FIELD *)0);
}
/* fld_link.c ends here */
diff --git a/lib/libform/fld_max.c b/lib/libform/fld_max.c
index 64ca77bfde4..0d6c66f9cce 100644
--- a/lib/libform/fld_max.c
+++ b/lib/libform/fld_max.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_max.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_max.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_max.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,17 +45,19 @@ MODULE_ID("$From: fld_max.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_max_field (FIELD *field, int maxgrow)
+set_max_field(FIELD *field, int maxgrow)
{
- if (!field || (maxgrow<0))
+ T((T_CALLED("set_max_field(%p,%d)"), field, maxgrow));
+
+ if (!field || (maxgrow < 0))
RETURN(E_BAD_ARGUMENT);
else
{
bool single_line_field = Single_Line_Field(field);
- if (maxgrow>0)
+ if (maxgrow > 0)
{
- if (( single_line_field && (maxgrow < field->dcols)) ||
+ if ((single_line_field && (maxgrow < field->dcols)) ||
(!single_line_field && (maxgrow < field->drows)))
RETURN(E_BAD_ARGUMENT);
}
@@ -65,13 +65,13 @@ set_max_field (FIELD *field, int maxgrow)
field->status &= ~_MAY_GROW;
if (!(field->opts & O_STATIC))
{
- if ((maxgrow==0) ||
- ( single_line_field && (field->dcols < maxgrow)) ||
+ if ((maxgrow == 0) ||
+ (single_line_field && (field->dcols < maxgrow)) ||
(!single_line_field && (field->drows < maxgrow)))
field->status |= _MAY_GROW;
}
}
RETURN(E_OK);
}
-
+
/* fld_max.c ends here */
diff --git a/lib/libform/fld_move.c b/lib/libform/fld_move.c
index 3fe67e621f2..864b024c8da 100644
--- a/lib/libform/fld_move.c
+++ b/lib/libform/fld_move.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_move.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_move.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_move.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -48,12 +46,14 @@ MODULE_ID("$From: fld_move.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-move_field (FIELD *field, int frow, int fcol)
+move_field(FIELD *field, int frow, int fcol)
{
- if ( !field || (frow<0) || (fcol<0) )
+ T((T_CALLED("move_field(%p,%d,%d)"), field, frow, fcol));
+
+ if (!field || (frow < 0) || (fcol < 0))
RETURN(E_BAD_ARGUMENT);
- if (field->form)
+ if (field->form)
RETURN(E_CONNECTED);
field->frow = frow;
@@ -62,4 +62,3 @@ move_field (FIELD *field, int frow, int fcol)
}
/* fld_move.c ends here */
-
diff --git a/lib/libform/fld_newftyp.c b/lib/libform/fld_newftyp.c
index 4abd3d5f16d..7d2e7ffb801 100644
--- a/lib/libform/fld_newftyp.c
+++ b/lib/libform/fld_newftyp.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_newftyp.c,v 1.5 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,76 +27,80 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_newftyp.c,v 1.6 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_newftyp.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
-static FIELDTYPE const default_fieldtype = {
- 0, /* status */
- 0L, /* reference count */
- (FIELDTYPE *)0, /* pointer to left operand */
- (FIELDTYPE *)0, /* pointer to right operand */
- NULL, /* makearg function */
- NULL, /* copyarg function */
- NULL, /* freearg function */
- NULL, /* field validation function */
- NULL, /* Character check function */
- NULL, /* enumerate next function */
- NULL /* enumerate previous function */
+static FIELDTYPE const default_fieldtype =
+{
+ 0, /* status */
+ 0L, /* reference count */
+ (FIELDTYPE *)0, /* pointer to left operand */
+ (FIELDTYPE *)0, /* pointer to right operand */
+ NULL, /* makearg function */
+ NULL, /* copyarg function */
+ NULL, /* freearg function */
+ NULL, /* field validation function */
+ NULL, /* Character check function */
+ NULL, /* enumerate next function */
+ NULL /* enumerate previous function */
};
-NCURSES_EXPORT_VAR(const FIELDTYPE*) _nc_Default_FieldType = &default_fieldtype;
-
+NCURSES_EXPORT_VAR(const FIELDTYPE *)
+_nc_Default_FieldType = &default_fieldtype;
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : FIELDTYPE *new_fieldtype(
| bool (* const field_check)(FIELD *,const void *),
-| bool (* const char_check) (int, const void *) )
-|
+| bool (* const char_check) (int, const void *) )
+|
| Description : Create a new fieldtype. The application programmer must
| write a field_check and a char_check function and give
| them as input to this call.
-| If an error occurs, errno is set to
+| If an error occurs, errno is set to
| E_BAD_ARGUMENT - invalid arguments
| E_SYSTEM_ERROR - system error (no memory)
|
-| Return Values : Fieldtype pointer or NULL if error occured
+| Return Values : Fieldtype pointer or NULL if error occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
-new_fieldtype (
- bool (* const field_check)(FIELD *,const void *),
- bool (* const char_check) (int,const void *) )
+new_fieldtype(bool (*const field_check) (FIELD *, const void *),
+ bool (*const char_check) (int, const void *))
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
-
- if ( (field_check) || (char_check) )
+
+ T((T_CALLED("new_fieldtype(%p,%p)"), field_check, char_check));
+ if ((field_check) || (char_check))
{
- nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
+ nftyp = typeMalloc(FIELDTYPE, 1);
+
if (nftyp)
{
+ T((T_CREATE("fieldtype %p"), nftyp));
*nftyp = default_fieldtype;
nftyp->fcheck = field_check;
nftyp->ccheck = char_check;
}
else
{
- SET_ERROR( E_SYSTEM_ERROR );
+ SET_ERROR(E_SYSTEM_ERROR);
}
}
else
{
- SET_ERROR( E_BAD_ARGUMENT );
+ SET_ERROR(E_BAD_ARGUMENT);
}
- return nftyp;
+ returnFieldType(nftyp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int free_fieldtype(FIELDTYPE *typ)
-|
+|
| Description : Release the memory associated with this fieldtype.
|
| Return Values : E_OK - success
@@ -106,12 +108,14 @@ new_fieldtype (
| E_BAD_ARGUMENT - invalid fieldtype pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_fieldtype (FIELDTYPE *typ)
+free_fieldtype(FIELDTYPE *typ)
{
+ T((T_CALLED("free_fieldtype(%p)"), typ));
+
if (!typ)
RETURN(E_BAD_ARGUMENT);
- if (typ->ref!=0)
+ if (typ->ref != 0)
RETURN(E_CONNECTED);
if (typ->status & _RESIDENT)
@@ -119,8 +123,10 @@ free_fieldtype (FIELDTYPE *typ)
if (typ->status & _LINKED_TYPE)
{
- if (typ->left ) typ->left->ref--;
- if (typ->right) typ->right->ref--;
+ if (typ->left)
+ typ->left->ref--;
+ if (typ->right)
+ typ->right->ref--;
}
free(typ);
RETURN(E_OK);
diff --git a/lib/libform/fld_opts.c b/lib/libform/fld_opts.c
index 2a2bbea6f39..fb38ac125d8 100644
--- a/lib/libform/fld_opts.c
+++ b/lib/libform/fld_opts.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_opts.c,v 1.5 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_opts.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
/*----------------------------------------------------------------------------
Field-Options manipulation routines
@@ -52,12 +51,15 @@ MODULE_ID("$From: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_opts (FIELD * field, Field_Options opts)
+set_field_opts(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("set_field_opts(%p,%d)"), field, opts));
+
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
- res = _nc_Synchronize_Options( Normalize_Field(field), opts );
+ res = _nc_Synchronize_Options(Normalize_Field(field), opts);
RETURN(res);
}
@@ -70,9 +72,11 @@ set_field_opts (FIELD * field, Field_Options opts)
| Return Values : The options.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Field_Options)
-field_opts (const FIELD * field)
+field_opts(const FIELD *field)
{
- return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
+ T((T_CALLED("field_opts(%p)"), field));
+
+ returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
}
/*---------------------------------------------------------------------------
@@ -88,15 +92,17 @@ field_opts (const FIELD * field)
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_opts_on (FIELD * field, Field_Options opts)
+field_opts_on(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
+ T((T_CALLED("field_opts_on(%p,%d)"), field, opts));
+
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
{
- Normalize_Field( field );
- res = _nc_Synchronize_Options( field, field->opts | opts );
+ Normalize_Field(field);
+ res = _nc_Synchronize_Options(field, field->opts | opts);
}
RETURN(res);
}
@@ -114,17 +120,19 @@ field_opts_on (FIELD * field, Field_Options opts)
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_opts_off (FIELD * field, Field_Options opts)
+field_opts_off(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
+ T((T_CALLED("field_opts_off(%p,%d)"), field, opts));
+
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
{
- Normalize_Field( field );
- res = _nc_Synchronize_Options( field, field->opts & ~opts );
+ Normalize_Field(field);
+ res = _nc_Synchronize_Options(field, field->opts & ~opts);
}
RETURN(res);
-}
+}
/* fld_opts.c ends here */
diff --git a/lib/libform/fld_pad.c b/lib/libform/fld_pad.c
index 5d2e4dfdceb..9197b731bef 100644
--- a/lib/libform/fld_pad.c
+++ b/lib/libform/fld_pad.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_pad.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_pad.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_pad.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,17 +46,19 @@ MODULE_ID("$From: fld_pad.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_pad (FIELD * field, int ch)
+set_field_pad(FIELD *field, int ch)
{
int res = E_BAD_ARGUMENT;
- Normalize_Field( field );
- if (isprint((unsigned char)ch))
+ T((T_CALLED("set_field_pad(%p,%d)"), field, ch));
+
+ Normalize_Field(field);
+ if (isprint(UChar(ch)))
{
if (field->pad != ch)
{
field->pad = ch;
- res = _nc_Synchronize_Attributes( field );
+ res = _nc_Synchronize_Attributes(field);
}
else
res = E_OK;
@@ -74,9 +75,11 @@ set_field_pad (FIELD * field, int ch)
| Return Values : The pad character.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_pad (const FIELD * field)
+field_pad(const FIELD *field)
{
- return Normalize_Field( field )->pad;
+ T((T_CALLED("field_pad(%p)"), field));
+
+ returnCode(Normalize_Field(field)->pad);
}
/* fld_pad.c ends here */
diff --git a/lib/libform/fld_page.c b/lib/libform/fld_page.c
index 3e37d022917..dbe94e0f926 100644
--- a/lib/libform/fld_page.c
+++ b/lib/libform/fld_page.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_page.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_page.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_page.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,13 +45,15 @@ MODULE_ID("$From: fld_page.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_new_page (FIELD * field, bool new_page_flag)
+set_new_page(FIELD *field, bool new_page_flag)
{
+ T((T_CALLED("set_new_page(%p,%d)"), field, new_page_flag));
+
Normalize_Field(field);
- if (field->form)
+ if (field->form)
RETURN(E_CONNECTED);
- if (new_page_flag)
+ if (new_page_flag)
field->status |= _NEWPAGE;
else
field->status &= ~_NEWPAGE;
@@ -72,9 +72,11 @@ set_new_page (FIELD * field, bool new_page_flag)
| FALSE - field doesn't start a new page
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-new_page (const FIELD * field)
+new_page(const FIELD *field)
{
- return (Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE;
+ T((T_CALLED("new_page(%p)"), field));
+
+ returnBool((Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE);
}
/* fld_page.c ends here */
diff --git a/lib/libform/fld_stat.c b/lib/libform/fld_stat.c
index 297f09022c1..ceb9168fac3 100644
--- a/lib/libform/fld_stat.c
+++ b/lib/libform/fld_stat.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_stat.c,v 1.6 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_stat.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_stat.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,16 +44,18 @@ MODULE_ID("$From: fld_stat.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_status (FIELD * field, bool status)
+set_field_status(FIELD *field, bool status)
{
- Normalize_Field( field );
+ T((T_CALLED("set_field_status(%p,%d)"), field, status));
+
+ Normalize_Field(field);
if (status)
field->status |= _CHANGED;
else
field->status &= ~_CHANGED;
- return(E_OK);
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -69,9 +69,11 @@ set_field_status (FIELD * field, bool status)
| FALSE - buffer has not been changed
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-field_status (const FIELD * field)
+field_status(const FIELD *field)
{
- return ((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
+ T((T_CALLED("field_status(%p)"), field));
+
+ returnBool((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
}
/* fld_stat.c ends here */
diff --git a/lib/libform/fld_type.c b/lib/libform/fld_type.c
index dd3754c5c27..e530a449626 100644
--- a/lib/libform/fld_type.c
+++ b/lib/libform/fld_type.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_type.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_type.c,v 1.10 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_type.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -48,30 +46,32 @@ MODULE_ID("$From: fld_type.c,v 1.10 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_type (FIELD *field,FIELDTYPE *type, ...)
+set_field_type(FIELD *field, FIELDTYPE *type,...)
{
va_list ap;
int res = E_SYSTEM_ERROR;
int err = 0;
- va_start(ap,type);
+ T((T_CALLED("set_field_type(%p,%p)"), field, type));
+
+ va_start(ap, type);
Normalize_Field(field);
_nc_Free_Type(field);
field->type = type;
- field->arg = (void *)_nc_Make_Argument(field->type,&ap,&err);
+ field->arg = (void *)_nc_Make_Argument(field->type, &ap, &err);
if (err)
{
- _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
+ _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
field->type = (FIELDTYPE *)0;
- field->arg = (void *)0;
+ field->arg = (void *)0;
}
else
{
res = E_OK;
- if (field->type)
+ if (field->type)
field->type->ref++;
}
@@ -88,9 +88,10 @@ set_field_type (FIELD *field,FIELDTYPE *type, ...)
| Return Values : Pointer to fieldtype of NULL if none is defined.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
-field_type (const FIELD * field)
+field_type(const FIELD *field)
{
- return Normalize_Field(field)->type;
+ T((T_CALLED("field_type(%p)"), field));
+ returnFieldType(Normalize_Field(field)->type);
}
/* fld_type.c ends here */
diff --git a/lib/libform/fld_user.c b/lib/libform/fld_user.c
index 2e08d902fbc..5d40c158586 100644
--- a/lib/libform/fld_user.c
+++ b/lib/libform/fld_user.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_user.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_user.c,v 1.9 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_user.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,9 +44,11 @@ MODULE_ID("$From: fld_user.c,v 1.9 2000/12/10 02:09:38 tom Exp $")
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_userptr (FIELD * field, void *usrptr)
+set_field_userptr(FIELD *field, void *usrptr)
{
- Normalize_Field( field )->usrptr = usrptr;
+ T((T_CALLED("set_field_userptr(%p,%p)"), field, usrptr));
+
+ Normalize_Field(field)->usrptr = usrptr;
RETURN(E_OK);
}
@@ -63,9 +63,10 @@ set_field_userptr (FIELD * field, void *usrptr)
| NULL is returned
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-field_userptr (const FIELD *field)
+field_userptr(const FIELD *field)
{
- return Normalize_Field( field )->usrptr;
+ T((T_CALLED("field_userptr(%p)"), field));
+ returnVoidPtr(Normalize_Field(field)->usrptr);
}
/* fld_user.c ends here */
diff --git a/lib/libform/form.3tbl b/lib/libform/form.3tbl
index bc11d367eca..9e2c7ae7fc0 100644
--- a/lib/libform/form.3tbl
+++ b/lib/libform/form.3tbl
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form.3tbl,v 1.5 1999/07/11 14:14:03 millert Exp $
+.\" $OpenBSD: form.3tbl,v 1.6 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form.3x,v 1.13 1999/07/10 21:53:03 tom Exp $
+.\" $Id: form.3tbl,v 1.6 2010/01/12 23:22:07 nicm Exp $
.TH form 3 ""
.SH NAME
\fBform\fR - curses extension for programming forms
@@ -42,26 +42,34 @@ form screens on character-cell terminals. The library includes: field
routines, which create and modify form fields; and form routines, which group
fields into forms, display forms on the screen, and handle interaction with the
user.
-
-The \fBform\fR library uses the \fBcurses\fR libraries, and a curses
-initialization routine such as \fBinitscr\fR must be called before using any of
-these functions. To use the \fBform\fR library, link with the options
+.PP
+The \fBform\fR library uses the \fBcurses\fR libraries.
+To use the \fBform\fR library, link with the options
\fB-lform -lcurses\fR.
-
+.PP
+Your program should set up the locale, e.g.,
+.sp
+ \fBsetlocale(LC_ALL, "");\fP
+.sp
+so that input/output processing will work.
+.PP
+A curses initialization routine such as \fBinitscr\fR must be called
+before using any of these functions.
+.
.SS Current Default Values for Field Attributes
-
+.
The \fBform\fR library maintains a default value for field attributes. You
can get or set this default by calling the appropriate \fBset_\fR
or retrieval
routine with a \fBNULL\fR field pointer. Changing this default with a
\fBset_\fR function affects future field creations, but does not change the
rendering of fields already created.
-
+.
.SS Routine Name Index
-
+.
The following table lists each \fBform\fR routine and the name of
the manual page on which it is described.
-
+.
.TS
l l
l l .
@@ -71,7 +79,7 @@ current_field \fBform_page\fR(3)
data_ahead \fBform_data\fR(3)
data_behind \fBform_data\fR(3)
dup_field \fBform_field_new\fR(3)
-dynamic_fieldinfo \fBform_field_info\fR(3)
+dynamic_field_info \fBform_field_info\fR(3)
field_arg \fBform_field_validation\fR(3)
field_back \fBform_field_attributes\fR(3)
field_buffer \fBform_field_buffer\fR(3)
@@ -103,11 +111,13 @@ form_term \fBform_hook\fR(3)
form_userptr \fBform_userptr\fR(3)
form_win \fBform_win\fR(3)
free_field \fBform_field_new\fR(3)
+free_fieldtype \fBform_fieldtype\fR(3)
free_form \fBform_new\fR(3)
link_field \fBform_field_new\fR(3)
link_fieldtype \fBform_fieldtype\fR(3)
move_field \fBform_field\fR(3)
new_field \fBform_field_new\fR(3)
+new_fieldtype \fBform_fieldtype\fR(3)
new_form \fBform_new\fR(3)
new_page \fBform_new_page\fR(3)
pos_form_cursor \fBform_cursor\fR(3)
@@ -140,60 +150,66 @@ set_new_page \fBform_new_page\fR(3)
unpost_form \fBform_post\fR(3)
.TE
.SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error. Routines that return
+Routines that return pointers return \fBNULL\fR on error,
+and set errno to the corresponding error-code returned by functions
+returning an integer.
+Routines that return
an integer return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_CONNECTED\fR
-The field is already connected to a form.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
-The form is already posted.
-.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
-Form is too large for its window.
-.TP 5
-\fBE_NOT_POSTED\fR
-The form has not been posted.
-.TP 5
-\fBE_UNKNOWN_COMMAND\fR
-The form driver code saw an unknown request code.
+.B E_CONNECTED
+The field is already connected to a form.
.TP 5
-\fBE_INVALID_FIELD\fR
+.B E_INVALID_FIELD
Contents of a field are not valid.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No fields are connected to the form.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_NOT_POSTED
+The form has not been posted.
+.TP 5
+.B E_NO_ROOM
+Form is too large for its window.
+.TP 5
+.B E_POSTED
+The form is already posted.
+.TP 5
+.B E_REQUEST_DENIED
The form driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.TP 5
+.B E_UNKNOWN_COMMAND
+The form driver code saw an unknown request code.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header files
\fB<curses.h>\fR and \fB<eti.h>\fR.
-
-In your library list, libform.a should be before libcurses.a; that is,
-you want to say `-lform -lcurses', not the other way around (which would
-give you a link error using GNU \fBld\fR(1) and many other linkers).
+.PP
+In your library list, libform.a should be before libncurses.a; that is,
+you want to say `-lform -lncurses', not the other way around (which would
+give you a link error using most linkers).
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for ncurses by Eric
S. Raymond.
+.SH SEE ALSO
+This describes \fBncurses\fR
+version 5.7.
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libform/form.h b/lib/libform/form.h
index f0ce4260a2b..d83bf69f058 100644
--- a/lib/libform/form.h
+++ b/lib/libform/form.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: form.h,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,9 +27,11 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: form.h,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
+
#ifndef FORM_H
#define FORM_H
@@ -42,6 +42,14 @@
extern "C" {
#endif
+#ifndef FORM_PRIV_H
+typedef void *FIELD_CELL;
+#endif
+
+#ifndef NCURSES_FIELD_INTERNALS
+#define NCURSES_FIELD_INTERNALS /* nothing */
+#endif
+
typedef int Form_Options;
typedef int Field_Options;
@@ -50,10 +58,10 @@ typedef int Field_Options;
**********/
typedef struct {
- short pmin; /* index of first field on page */
- short pmax; /* index of last field on page */
- short smin; /* index of top leftmost field on page */
- short smax; /* index of bottom rightmost field on page */
+ short pmin; /* index of first field on page */
+ short pmax; /* index of last field on page */
+ short smin; /* index of top leftmost field on page */
+ short smax; /* index of bottom rightmost field on page */
} _PAGE;
/**********
@@ -61,31 +69,40 @@ typedef struct {
**********/
typedef struct fieldnode {
- unsigned short status; /* flags */
- short rows; /* size in rows */
- short cols; /* size in cols */
- short frow; /* first row */
- short fcol; /* first col */
- int drows; /* dynamic rows */
- int dcols; /* dynamic cols */
- int maxgrow; /* maximum field growth */
- int nrow; /* offscreen rows */
- short nbuf; /* additional buffers */
- short just; /* justification */
- short page; /* page on form */
- short index; /* into form -> field */
- int pad; /* pad character */
- chtype fore; /* foreground attribute */
- chtype back; /* background attribute */
- Field_Options opts; /* options */
- struct fieldnode * snext; /* sorted order pointer */
- struct fieldnode * sprev; /* sorted order pointer */
- struct fieldnode * link; /* linked field chain */
- struct formnode * form; /* containing form */
- struct typenode * type; /* field type */
- void * arg; /* argument for type */
- char * buf; /* field buffers */
- void * usrptr; /* user pointer */
+ unsigned short status; /* flags */
+ short rows; /* size in rows */
+ short cols; /* size in cols */
+ short frow; /* first row */
+ short fcol; /* first col */
+ int drows; /* dynamic rows */
+ int dcols; /* dynamic cols */
+ int maxgrow; /* maximum field growth */
+ int nrow; /* off-screen rows */
+ short nbuf; /* additional buffers */
+ short just; /* justification */
+ short page; /* page on form */
+ short index; /* into form -> field */
+ int pad; /* pad character */
+ chtype fore; /* foreground attribute */
+ chtype back; /* background attribute */
+ Field_Options opts; /* options */
+ struct fieldnode * snext; /* sorted order pointer */
+ struct fieldnode * sprev; /* sorted order pointer */
+ struct fieldnode * link; /* linked field chain */
+ struct formnode * form; /* containing form */
+ struct typenode * type; /* field type */
+ void * arg; /* argument for type */
+ FIELD_CELL * buf; /* field buffers */
+ void * usrptr; /* user pointer */
+ /*
+ * The wide-character configuration requires extra information. Because
+ * there are existing applications that manipulate the members of FIELD
+ * directly, we cannot make the struct opaque. Offsets of members up to
+ * this point are the same in the narrow- and wide-character configuration.
+ * But note that the type of buf depends on the configuration, and is made
+ * opaque for that reason.
+ */
+ NCURSES_FIELD_INTERNALS
} FIELD;
/**************
@@ -93,20 +110,20 @@ typedef struct fieldnode {
**************/
typedef struct typenode {
- unsigned short status; /* flags */
- long ref; /* reference count */
- struct typenode * left; /* ptr to operand for | */
- struct typenode * right; /* ptr to operand for | */
+ unsigned short status; /* flags */
+ long ref; /* reference count */
+ struct typenode * left; /* ptr to operand for | */
+ struct typenode * right; /* ptr to operand for | */
- void* (*makearg)(va_list *); /* make fieldtype arg */
- void* (*copyarg)(const void *); /* copy fieldtype arg */
- void (*freearg)(void *); /* free fieldtype arg */
+ void* (*makearg)(va_list *); /* make fieldtype arg */
+ void* (*copyarg)(const void *); /* copy fieldtype arg */
+ void (*freearg)(void *); /* free fieldtype arg */
- bool (*fcheck)(FIELD *,const void *); /* field validation */
- bool (*ccheck)(int,const void *); /* character validation */
+ bool (*fcheck)(FIELD *,const void *); /* field validation */
+ bool (*ccheck)(int,const void *); /* character validation */
- bool (*next)(FIELD *,const void *); /* enumerate next value */
- bool (*prev)(FIELD *,const void *); /* enumerate prev value */
+ bool (*next)(FIELD *,const void *); /* enumerate next value */
+ bool (*prev)(FIELD *,const void *); /* enumerate prev value */
} FIELDTYPE;
@@ -115,29 +132,29 @@ typedef struct typenode {
*********/
typedef struct formnode {
- unsigned short status; /* flags */
- short rows; /* size in rows */
- short cols; /* size in cols */
- int currow; /* current row in field window*/
- int curcol; /* current col in field window*/
- int toprow; /* in scrollable field window */
- int begincol; /* in horiz. scrollable field */
- short maxfield; /* number of fields */
- short maxpage; /* number of pages */
- short curpage; /* index into page */
- Form_Options opts; /* options */
- WINDOW * win; /* window */
- WINDOW * sub; /* subwindow */
- WINDOW * w; /* window for current field */
- FIELD ** field; /* field [maxfield] */
- FIELD * current; /* current field */
- _PAGE * page; /* page [maxpage] */
- void * usrptr; /* user pointer */
-
- void (*forminit)(struct formnode *);
- void (*formterm)(struct formnode *);
- void (*fieldinit)(struct formnode *);
- void (*fieldterm)(struct formnode *);
+ unsigned short status; /* flags */
+ short rows; /* size in rows */
+ short cols; /* size in cols */
+ int currow; /* current row in field window */
+ int curcol; /* current col in field window */
+ int toprow; /* in scrollable field window */
+ int begincol; /* in horiz. scrollable field */
+ short maxfield; /* number of fields */
+ short maxpage; /* number of pages */
+ short curpage; /* index into page */
+ Form_Options opts; /* options */
+ WINDOW * win; /* window */
+ WINDOW * sub; /* subwindow */
+ WINDOW * w; /* window for current field */
+ FIELD ** field; /* field [maxfield] */
+ FIELD * current; /* current field */
+ _PAGE * page; /* page [maxpage] */
+ void * usrptr; /* user pointer */
+
+ void (*forminit)(struct formnode *);
+ void (*formterm)(struct formnode *);
+ void (*fieldinit)(struct formnode *);
+ void (*fieldterm)(struct formnode *);
} FORM;
@@ -154,20 +171,20 @@ typedef void (*Form_Hook)(FORM *);
#define JUSTIFY_RIGHT (3)
/* field options */
-#define O_VISIBLE (0x0001)
-#define O_ACTIVE (0x0002)
-#define O_PUBLIC (0x0004)
-#define O_EDIT (0x0008)
-#define O_WRAP (0x0010)
-#define O_BLANK (0x0020)
-#define O_AUTOSKIP (0x0040)
-#define O_NULLOK (0x0080)
-#define O_PASSOK (0x0100)
-#define O_STATIC (0x0200)
+#define O_VISIBLE (0x0001U)
+#define O_ACTIVE (0x0002U)
+#define O_PUBLIC (0x0004U)
+#define O_EDIT (0x0008U)
+#define O_WRAP (0x0010U)
+#define O_BLANK (0x0020U)
+#define O_AUTOSKIP (0x0040U)
+#define O_NULLOK (0x0080U)
+#define O_PASSOK (0x0100U)
+#define O_STATIC (0x0200U)
/* form options */
-#define O_NL_OVERLOAD (0x0001)
-#define O_BS_OVERLOAD (0x0002)
+#define O_NL_OVERLOAD (0x0001U)
+#define O_BS_OVERLOAD (0x0002U)
/* form driver commands */
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
@@ -209,7 +226,7 @@ typedef void (*Form_Hook)(FORM *);
#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
-#define REQ_DEL_WORD (KEY_MAX + 37) /* delete line at cursor */
+#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
@@ -219,14 +236,14 @@ typedef void (*Form_Hook)(FORM *);
#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
-#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
-#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
-#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
-#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
-#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
-#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
-#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
-#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
+#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
+#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
+#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
+#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
+#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
+#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
+#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
+#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
@@ -255,15 +272,15 @@ extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
- /************************************
+ /************************************
* built-in additional field types *
- * They are not defined in SVr4 *
+ * They are not defined in SVr4 *
************************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
- /***********************
- * Default objects *
- ***********************/
+ /***********************
+ * Default objects *
+ ***********************/
extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form;
extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
@@ -273,8 +290,9 @@ extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
***********************/
extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
bool (* const field_check)(FIELD *,const void *),
- bool (* const char_check)(int,const void *)),
- *link_fieldtype(FIELDTYPE *,FIELDTYPE *);
+ bool (* const char_check)(int,const void *));
+extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
+ FIELDTYPE *, FIELDTYPE *);
extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *);
extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
@@ -326,7 +344,7 @@ extern NCURSES_EXPORT(FIELDTYPE *) field_type (const FIELD *);
extern NCURSES_EXPORT(char *) field_buffer (const FIELD *,int);
-extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
+extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
/******************
* FORM routines *
@@ -334,7 +352,7 @@ extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
extern NCURSES_EXPORT(FORM *) new_form (FIELD **);
-extern NCURSES_EXPORT(FIELD **)form_fields (const FORM *);
+extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *);
extern NCURSES_EXPORT(FIELD *) current_field (const FORM *);
extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *);
diff --git a/lib/libform/form.priv.h b/lib/libform/form.priv.h
index f2770a65642..f9f9c175869 100644
--- a/lib/libform/form.priv.h
+++ b/lib/libform/form.priv.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: form.priv.h,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,38 +27,69 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: form.priv.h,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
+
+#ifndef FORM_PRIV_H
+#define FORM_PRIV_H 1
+
+#include "curses.priv.h"
#include "mf_common.h"
+
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
+#define FIELD_CELL NCURSES_CH_T
+
+#define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
+#define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0
+
+#else
+
+#define FIELD_CELL char
+
+#define NCURSES_FIELD_EXTENSION /* nothing */
+
+#endif
+
#include "form.h"
/* form status values */
-#define _OVLMODE (0x04) /* Form is in overlay mode */
-#define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
-#define _FCHECK_REQUIRED (0x20) /* Current field needs validation */
+#define _OVLMODE (0x04U) /* Form is in overlay mode */
+#define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
+#define _FCHECK_REQUIRED (0x20U) /* Current field needs validation */
/* field status values */
-#define _CHANGED (0x01) /* Field has been changed */
-#define _NEWTOP (0x02) /* Vertical scrolling occured */
-#define _NEWPAGE (0x04) /* field begins new page of form */
-#define _MAY_GROW (0x08) /* dynamic field may still grow */
+#define _CHANGED (0x01U) /* Field has been changed */
+#define _NEWTOP (0x02U) /* Vertical scrolling occurred */
+#define _NEWPAGE (0x04U) /* field begins new page of form */
+#define _MAY_GROW (0x08U) /* dynamic field may still grow */
/* fieldtype status values */
-#define _LINKED_TYPE (0x01) /* Type is a linked type */
-#define _HAS_ARGS (0x02) /* Type has arguments */
-#define _HAS_CHOICE (0x04) /* Type has choice methods */
-#define _RESIDENT (0x08) /* Type is builtin */
+#define _LINKED_TYPE (0x01U) /* Type is a linked type */
+#define _HAS_ARGS (0x02U) /* Type has arguments */
+#define _HAS_CHOICE (0x04U) /* Type has choice methods */
+#define _RESIDENT (0x08U) /* Type is built-in */
/* This are the field options required to be a selectable field in field
navigation requests */
#define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
/* If form is NULL replace form argument by default-form */
-#define Normalize_Form(form) ((form)=(form)?(form):_nc_Default_Form)
+#define Normalize_Form(form) \
+ ((form) = (form != 0) ? (form) : _nc_Default_Form)
/* If field is NULL replace field argument by default-field */
-#define Normalize_Field(field) ((field)=(field)?(field):_nc_Default_Field)
+#define Normalize_Field(field) \
+ ((field) = (field != 0) ? (field) : _nc_Default_Field)
/* Retrieve forms window */
#define Get_Form_Window(form) \
@@ -71,20 +100,22 @@
/* Calculate the total size of all buffers for this field */
#define Total_Buffer_Size(field) \
- ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
+ ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
/* Logic to determine whether or not a field is single lined */
#define Single_Line_Field(field) \
(((field)->rows + (field)->nrow) == 1)
/* Logic to determine whether or not a field is selectable */
-#define Field_Is_Selectable(f) (((f)->opts & O_SELECTABLE)==O_SELECTABLE)
-#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE)
+#define Field_Is_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
+#define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
-typedef struct typearg {
- struct typearg *left;
- struct typearg *right;
-} TypeArgument;
+typedef struct typearg
+ {
+ struct typearg *left;
+ struct typearg *right;
+ }
+TypeArgument;
/* This is a dummy request code (normally invalid) to be used internally
with the form_driver() routine to position to the first active field
@@ -96,7 +127,7 @@ typedef struct typearg {
O_NL_OVERLOAD |\
O_BS_OVERLOAD )
-#define ALL_FIELD_OPTS ( \
+#define ALL_FIELD_OPTS (Field_Options)( \
O_VISIBLE |\
O_ACTIVE |\
O_PUBLIC |\
@@ -108,23 +139,112 @@ typedef struct typearg {
O_PASSOK |\
O_STATIC )
-
#define C_BLANK ' '
#define is_blank(c) ((c)==C_BLANK)
+#define C_ZEROS '\0'
+
extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
-extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*,va_list*,int*);
-extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*,const TypeArgument*, int*);
-extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*,TypeArgument*);
+extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
+extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
+extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
-extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*,Field_Options);
-extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*,int,FIELD*);
+extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options);
+extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*);
extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
-extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*,FIELD*);
+extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
+
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
+#endif
+
+#ifdef TRACE
+
+#define returnField(code) TRACE_RETURN(code,field)
+#define returnFieldPtr(code) TRACE_RETURN(code,field_ptr)
+#define returnForm(code) TRACE_RETURN(code,form)
+#define returnFieldType(code) TRACE_RETURN(code,field_type)
+#define returnFormHook(code) TRACE_RETURN(code,form_hook)
+
+extern NCURSES_EXPORT(FIELD **) _nc_retrace_field_ptr (FIELD **);
+extern NCURSES_EXPORT(FIELD *) _nc_retrace_field (FIELD *);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_retrace_field_type (FIELDTYPE *);
+extern NCURSES_EXPORT(FORM *) _nc_retrace_form (FORM *);
+extern NCURSES_EXPORT(Form_Hook) _nc_retrace_form_hook (Form_Hook);
+
+#else /* !TRACE */
+
+#define returnFieldPtr(code) return code
+#define returnFieldType(code) return code
+#define returnField(code) return code
+#define returnForm(code) return code
+#define returnFormHook(code) return code
+
+#endif /* TRACE/!TRACE */
+
+/*
+ * Use Check_CTYPE_Field() to simplify FIELDTYPE's that use only the ccheck()
+ * function.
+ */
+#if USE_WIDEC_SUPPORT
+#define Check_CTYPE_Field(result, buffer, width, ccheck) \
+ while (*buffer && *buffer == ' ') \
+ buffer++; \
+ if (*buffer) \
+ { \
+ bool blank = FALSE; \
+ int len; \
+ int n; \
+ wchar_t *list = _nc_Widen_String((char *)buffer, &len); \
+ if (list != 0) \
+ { \
+ result = TRUE; \
+ for (n = 0; n < len; ++n) \
+ { \
+ if (blank) \
+ { \
+ if (list[n] != ' ') \
+ { \
+ result = FALSE; \
+ break; \
+ } \
+ } \
+ else if (list[n] == ' ') \
+ { \
+ blank = TRUE; \
+ result = (n + 1 >= width); \
+ } \
+ else if (!ccheck(list[n], NULL)) \
+ { \
+ result = FALSE; \
+ break; \
+ } \
+ } \
+ free(list); \
+ } \
+ }
+#else
+#define Check_CTYPE_Field(result, buffer, width, ccheck) \
+ while (*buffer && *buffer == ' ') \
+ buffer++; \
+ if (*buffer) \
+ { \
+ unsigned char *s = buffer; \
+ int l = -1; \
+ while (*buffer && ccheck(*buffer, NULL)) \
+ buffer++; \
+ l = (int)(buffer - s); \
+ while (*buffer && *buffer == ' ') \
+ buffer++; \
+ result = ((*buffer || (l < width)) ? FALSE : TRUE); \
+ }
+#endif
+
+#endif /* FORM_PRIV_H */
diff --git a/lib/libform/form_cursor.3 b/lib/libform/form_cursor.3
index b8eed87ef3a..e6b9825c8a0 100644
--- a/lib/libform/form_cursor.3
+++ b/lib/libform/form_cursor.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_cursor.3,v 1.6 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_cursor.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_cursor.3x,v 1.4 1998/11/29 01:05:43 Rick.Ohnemus Exp $
+.\" $Id: form_cursor.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.TH form_cursor 3 ""
.SH NAME
\fBform_cursor\fR - position a form window cursor
@@ -46,17 +46,18 @@ form operation.
.SH RETURN VALUE
This routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The form has not been posted.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_data.3 b/lib/libform/form_data.3
index 88cb4dd0b23..e7fca9792cd 100644
--- a/lib/libform/form_data.3
+++ b/lib/libform/form_data.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_data.3,v 1.10 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_data.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_data.3x,v 1.7 1998/11/29 01:13:22 Rick.Ohnemus Exp $
+.\" $Id: form_data.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.TH form_data 3 ""
.SH NAME
\fBform_data\fR - test for off-screen data in given forms
@@ -43,7 +43,7 @@ bool data_behind(const FORM *form);
.SH DESCRIPTION
The function \fBdata_ahead\fR tests whether there is off-screen data
ahead in the given form. It returns TRUE (1) or FALSE (0).
-
+.PP
The function \fBdata_behind\fR tests whether there is off-screen data
behind in the given form. It returns TRUE (1) or FALSE (0).
.SH SEE ALSO
diff --git a/lib/libform/form_driver.3 b/lib/libform/form_driver.3
index 5f8e753fd05..48d371abe8d 100644
--- a/lib/libform/form_driver.3
+++ b/lib/libform/form_driver.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: form_driver.3,v 1.7 1999/07/11 14:14:03 millert Exp $
+.\" $OpenBSD: form_driver.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: form_driver.3x,v 1.7 1999/07/10 23:13:18 tom Exp $
+.\" $Id: form_driver.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_driver 3 ""
.SH NAME
\fBform_driver\fR - command-processing loop of the form system
@@ -39,8 +39,21 @@ int form_driver(FORM *form, int c);
.br
.SH DESCRIPTION
Once a form has been posted (displayed), you should funnel input events to it
-through \fBform_driver\fR. This routine has two major input cases; either
-the input is a form navigation request or it's a printable ASCII character.
+through \fBform_driver\fR. This routine has three major input cases:
+.TP 3
+-
+The input is a form navigation request.
+Navigation request codes are constants defined in \fB<form.h>\fP,
+which are distinct from the key- and character codes returned by \fBwgetch\fP.
+.TP 3
+-
+The input is a printable character.
+Printable characters (which must be positive, less than 256) are
+checked according to the program's locale settings.
+.TP 3
+-
+The input is the KEY_MOUSE special key associated with an mouse event.
+.PP
The form driver requests are as follows:
.TP 5
REQ_NEXT_PAGE
@@ -54,7 +67,7 @@ Move to the first page.
.TP 5
REQ_LAST_PAGE
Move to the last field.
-
+.sp
.TP 5
REQ_NEXT_FIELD
Move to the next field.
@@ -91,7 +104,7 @@ Move up to a field.
.TP 5
REQ_DOWN_FIELD
Move down to a field.
-
+.sp
.TP 5
REQ_NEXT_CHAR
Move to the next char.
@@ -134,7 +147,7 @@ Move up in the field.
.TP 5
REQ_DOWN_CHAR
Move down in the field.
-
+.sp
.TP 5
REQ_NEW_LINE
Insert or overlay a new line.
@@ -171,7 +184,7 @@ Enter overlay mode.
.TP 5
REQ_INS_MODE
Enter insert mode.
-
+.sp
.TP 5
REQ_SCR_FLINE
Scroll the field forward a line.
@@ -190,7 +203,7 @@ Scroll the field forward half a page.
.TP 5
REQ_SCR_BHPAGE
Scroll the field backward half a page.
-
+.sp
.TP 5
REQ_SCR_FCHAR
Scroll the field forward a character.
@@ -209,7 +222,7 @@ Horizontal scroll the field forward half a line.
.TP 5
REQ_SCR_HBHALF
Horizontal scroll the field backward half a line.
-
+.sp
.TP
REQ_VALIDATION
Validate field.
@@ -220,43 +233,97 @@ Display next field choice.
REQ_PREV_CHOICE
Display previous field choice.
.PP
-If the second argument is a printable ASCII character, the driver places it
+If the second argument is a printable character, the driver places it
in the current position in the current field. If it is one of the forms
requests listed above, that request is executed.
+.SS MOUSE HANDLING
+.PP
+If the second argument is the KEY_MOUSE special key, the associated
+mouse event is translated into one of the above pre-defined requests.
+Currently only clicks in the user window (e.g. inside the form display
+area or the decoration window) are handled.
+.PP
+If you click above the display region of the form:
+.RS
+.TP
+a REQ_PREV_FIELD is generated for a single click,
+.TP
+a REQ_PREV_PAGE is generated for a double-click and
+.TP
+a REQ_FIRST_FIELD is generated for a triple-click.
+.RE
+.PP
+If you click below the display region of the form:
+.RS
+.TP
+a REQ_NEXT_FIELD is generated for a single click,
+.TP
+a REQ_NEXT_PAGE is generated for a double-click and
+.TP
+a REQ_LAST_FIELD is generated for a triple-click.
+.RE
.PP
-If the second argument is neither printable ASCII nor one of the above
+If you click at an field inside the display area of the form:
+.RS
+.TP 3
+-
+the form cursor is positioned to that field.
+.TP 3
+-
+If you double-click a field,
+the form cursor is positioned to that field
+and \fBE_UNKNOWN_COMMAND\fR is returned.
+This return value makes sense,
+because a double click usually means that an field-specific action should
+be returned.
+It is exactly the purpose of this return value to signal that an
+application specific command should be executed.
+.TP 3
+-
+If a translation
+into a request was done, \fBform_driver\fR returns the result of this request.
+.RE
+.PP
+If you clicked outside the user window or the mouse event could not be translated
+into a form request an \fBE_REQUEST_DENIED\fR is returned.
+.SS APPLICATION-DEFINED COMMANDS
+.PP
+If the second argument is neither printable nor one of the above
pre-defined form requests, the driver assumes it is an application-specific
command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands
should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
pre-defined requests.
.SH RETURN VALUE
-\fBform_driver\fR return one of the following error codes:
+\fBform_driver\fR returns one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The form has not been posted.
.TP 5
-\fBE_UNKNOWN_COMMAND\fR
-The form driver code saw an unknown request code.
-.TP 5
-\fBE_INVALID_FIELD\fR
+.B E_INVALID_FIELD
Contents of field is invalid.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The form driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.TP 5
+.B E_UNKNOWN_COMMAND
+The form driver code saw an unknown request code.
+.
.SH SEE ALSO
-\fBcurses\fR(3), \fBform\fR(3).
+\fBcurses\fR(3),
+\fBform\fR(3),
+\fBwgetch\fR(3).
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header files
\fB<curses.h>\fR.
diff --git a/lib/libform/form_field.3 b/lib/libform/form_field.3
index 85c235cfcbb..c5a464763e4 100644
--- a/lib/libform/form_field.3
+++ b/lib/libform/form_field.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field.3,v 1.8 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field.3x,v 1.5 1998/11/29 01:05:52 Rick.Ohnemus Exp $
+.\" $Id: form_field.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field 3 ""
.SH NAME
\fBform_field\fR - make and break connections between fields and forms
@@ -47,36 +47,37 @@ int move_field(FIELD *field, int frow, int fcol);
.SH DESCRIPTION
The function \fBset_form_fields\fR changes the field pointer array of
the given \fIform\fR. The array must be terminated by a \fBNULL\fR.
-
+.PP
The function \fBform_fields\fR returns the field array of the given form.
-
+.PP
The function \fBfield_count\fR returns the count of fields in \fIform\fR.
-
+.PP
The function \fBmove_field\fR moves the given field (which must be disconnected)
to a specified location on the screen.
.SH RETURN VALUES
-The function \fBform_fields\fR returns \fBNULL\fR on error.
-
-The function \fBfield_count\fR returns \fBERR\fR (the general
-\fBcurses\fR error return value) on error.
-
+The function \fBform_fields\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBfield_count\fR returns \fBERR\fR if the \fIform\fP parameter
+is \fBNULL\fP.
+.PP
The functions \fBset_form_fields\fR and \fBmove_field\fR return one of
the following codes on error:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_CONNECTED
+The field is already connected to a form.
+.TP 5
+.B E_POSTED
The form is already posted.
.TP 5
-\fBE_CONNECTED\fR
-The field is already connected to a form.
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -85,7 +86,7 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
+.PP
The SVr4 forms library documentation specifies the \fBfield_count\fR error value
as -1 (which is the value of \fBERR\fR).
.SH AUTHORS
diff --git a/lib/libform/form_field_attributes.3 b/lib/libform/form_field_attributes.3
index 4074137a3bc..ed9ac222042 100644
--- a/lib/libform/form_field_attributes.3
+++ b/lib/libform/form_field_attributes.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_attributes.3,v 1.7 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_field_attributes.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_attributes.3x,v 1.5 1998/11/29 01:06:02 Rick.Ohnemus Exp $
+.\" $Id: form_field_attributes.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_field_attributes 3 ""
.SH NAME
\fBform_field_attributes\fR - color and attribute control for form fields
@@ -46,35 +46,36 @@ chtype field_back(const FIELD *field);
.br
int set_field_pad(FIELD *field, int pad);
.br
-chtype field_pad(const FIELD *field);
+int field_pad(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_field_fore\fR sets the foreground attribute of
\fIfield\fR. This is the highlight used to display the field contents. The
function \fBfield_fore\fR returns the foreground attribute. The default is
\fBA_STANDOUT\fR.
-
+.PP
The function \fBset_field_back\fR sets the background attribute of
\fIform\fR. This is the highlight used to display the extent fields in the
form. The function \fBfield_back\fR returns the background attribute. The
default is \fBA_NORMAL\fR.
-
+.PP
The function \fBset_field_pad\fR sets the character used to fill the field.
The function \fBfield_pad\fR returns the given form's pad character. The
default is a blank.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_field_buffer.3 b/lib/libform/form_field_buffer.3
index d3577eaac54..d9de3880c37 100644
--- a/lib/libform/form_field_buffer.3
+++ b/lib/libform/form_field_buffer.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_buffer.3,v 1.11 2000/04/12 21:48:03 aaron Exp $
+.\" $OpenBSD: form_field_buffer.3,v 1.12 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: From: form_field_buffer.3x,v 1.8 1999/06/16 00:37:09 juergen Exp $
+.\" $Id: form_field_buffer.3,v 1.12 2010/01/12 23:22:07 nicm Exp $
.TH form_field_buffer 3 ""
.SH NAME
\fBform_field_buffer\fR - field buffer control
@@ -48,44 +48,87 @@ int set_max_field(FIELD *field, int max);
.br
.SH DESCRIPTION
The function \fBset_field_buffer\fR sets the numbered buffer of the given field
-to contain a given string. Buffer 0 is the displayed value of the field; other
-numbered buffers may be allocated by applications through the \fBnbuf\fR
-argument of (see \fBform_field_new\fR(3)) but are not manipulated by the forms
-library. The function \fBfield_buffer\fR returns the address of the buffer.
-Please note that this buffer has always the length of the buffer, that means
-that it may typically contain trailing spaces. If you entered leading spaces
-the buffer may also contain them. If you want the raw data, you must write your
+to contain a given string:
+.RS 3
+.TP 3
+-
+Buffer 0 is the displayed value of the field.
+.TP 3
+-
+Other numbered buffers may be allocated by applications through the \fBnbuf\fR
+argument of (see \fBform_field_new\fR(3))
+but are not manipulated by the forms library.
+.RE
+.PP
+The function \fBfield_buffer\fR returns a pointer to
+the contents of the given numbered buffer:
+.RS 3
+.TP 3
+-
+The buffer contents always have the same length,
+and are padded with trailing spaces
+as needed to ensure this length is the same.
+.TP 3
+-
+The buffer may contain leading spaces, depending on how it was set.
+.TP 3
+-
+The buffer contents are set with \fBset_field_buffer\fP,
+or as a side effect of any editing operations on the corresponding field.
+.TP 3
+-
+Editing operations are based on the \fIwindow\fP which displays the field,
+rather than a \fIstring\fP.
+The window contains only printable characters, and is filled with blanks.
+If you want the raw data, you must write your
own routine that copies the value out of the buffer and removes the leading
-and trailing spaces. Please note also, that subsequent operations on the form
-will probably change the content of the buffer. So don't use it for long term
-storage of the entered form data.
-
+and trailing spaces.
+.TP 3
+-
+Because editing operations change the content of the buffer to
+correspond to the window, you should not rely on using buffers
+for long-term storage of form data.
+.RE
+.PP
The function \fBset_field_status\fR sets the associated status flag of
\fIfield\fR; \fBfield_status\fR gets the current value. The status flag
is set to a nonzero value whenever the field changes.
-
+.PP
The function \fBset_max_field\fR sets the maximum size for a dynamic field.
An argument of 0 turns off any maximum size threshold for that field.
.SH RETURN VALUE
The \fBfield_buffer\fR function returns NULL on error.
-
+It sets errno according to their success:
+.TP 5
+.B E_OK
+The routine succeeded.
+.TP 5
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.PP
The \fBfield_status\fR function returns \fBTRUE\fR or \fBFALSE\fR.
-
+.PP
The remaining routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
+.PP
+When configured for wide-characters, \fBfield_buffer\fP returns a pointer
+to temporary storage (allocated and freed by the library).
+The application should not attempt to modify the data.
+It will be freed on the next call to \fBfield_buffer\fP to return the
+same buffer.
\fB<curses.h>\fR.
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
diff --git a/lib/libform/form_field_info.3 b/lib/libform/form_field_info.3
index da148a01c1f..23aad7cdafd 100644
--- a/lib/libform/form_field_info.3
+++ b/lib/libform/form_field_info.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_info.3,v 1.8 2000/06/19 03:53:56 millert Exp $
+.\" $OpenBSD: form_field_info.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_info.3x,v 1.6 2000/04/15 22:21:31 tom Exp $
+.\" $Id: form_field_info.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field_info 3 ""
.SH NAME
\fBform_field_info\fR - retrieve field characteristics
@@ -39,31 +39,32 @@
int field_info(const FIELD *field, int *rows, int *cols,
int *frow, int *fcol, int *nrow, int *nbuf);
.br
-int dynamic_field_info(const FIELD *field, int *rows, int *cols, *max);
+int dynamic_field_info(const FIELD *field, int *rows, int *cols, int *max);
.br
.SH DESCRIPTION
The function \fBfield_info\fR returns the sizes and other attributes passed in
to the field at its creation time. The attributes are: height, width, row of
upper-left corner, column of upper-left corner, number off-screen rows, and
number of working buffers.
-
+.PP
The function \fBdynamic_field_info\fR returns the actual size of the field, and
its maximum possible size. If the field has no size limit, the location
-addressed by the third argument will be set to 0. (A field can be made dynamic
-by turning off the \fBO_STATIC\fR).
+addressed by the third argument will be set to 0.
+A field can be made dynamic
+by turning off the \fBO_STATIC\fR option with \fBfield_opts_off\fR.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_field_just.3 b/lib/libform/form_field_just.3
index 502297418a7..c3246c2217b 100644
--- a/lib/libform/form_field_just.3
+++ b/lib/libform/form_field_just.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_just.3,v 1.8 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_just.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_just.3x,v 1.5 1998/11/29 01:06:32 Rick.Ohnemus Exp $
+.\" $Id: form_field_just.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field_just 3 ""
.SH NAME
\fBform_field_just\fR - retrieve field characteristics
@@ -45,23 +45,23 @@ The function \fBset_field_just\fR sets the justification attribute of
a field; \fBfield_just\fR returns a field's justification attribute.
The attribute may be one of NO_JUSTIFICATION, JUSTIFY_RIGHT,
JUSTIFY_LEFT, or JUSTIFY_CENTER.
-
+.
.SH RETURN VALUE
The function \fBfield_just\fR returns one of: NO_JUSTIFICATION,
JUSTIFY_RIGHT, JUSTIFY_LEFT, or JUSTIFY_CENTER.
-
+.PP
The function \fBset_field_just\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_field_new.3 b/lib/libform/form_field_new.3
index 232803a9dd4..3528bb91907 100644
--- a/lib/libform/form_field_new.3
+++ b/lib/libform/form_field_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_new.3,v 1.9 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_new.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: form_field_new.3x,v 1.9 1998/11/29 01:06:44 Rick.Ohnemus Exp $
+.\" $Id: form_field_new.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.TH form_field_new 3 ""
.SH NAME
\fBform_field_new\fR - create and destroy form fields
@@ -50,31 +50,41 @@ int free_field(FIELD *field);
The function \fBnew_field\fR allocates a new field and initializes it from the
parameters given: height, width, row of upper-left corner, column of upper-left
corner, number off-screen rows, and number of additional working buffers.
-
+.PP
The function \fBdup_field\fR duplicates a field at a new location. Most
attributes (including current contents, size, validation type, buffer count,
growth threshold, justification, foreground, background, pad character,
options, and user pointer) are copied. Field status and the field page bit are
not copied.
-
+.PP
The function \fBlink_field\fR acts like \fBdup_field\fR, but the new field
shares buffers with its parent. Attribute data is separate.
-
+.PP
The function \fBfree_field\fR de-allocates storage associated with a field.
.SH RETURN VALUE
The function, \fBnew_field\fR, \fBdup_field\fR, \fBlink_field\fR return
\fBNULL\fR on error.
-
-The function \fBfree_field\fR returns one of the following:
+They set errno according to their success:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
+The function \fBfree_field\fR returns one of the following:
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_OK
+The routine succeeded.
+.TP 5
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_CONNECTED
+field is connected.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -83,10 +93,10 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
+.PP
It may be unwise to count on the set of attributes copied by
-\fBdup_field\fR(3) being portable; the System V forms library documents are
-not very explicit about what gets copied and what doesn't.
+\fBdup_field\fR being portable; the System V forms library documents are
+not very explicit about what gets copied and what does not.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libform/form_field_opts.3 b/lib/libform/form_field_opts.3
index 5b1af60c97c..17bc7a1c6a7 100644
--- a/lib/libform/form_field_opts.3
+++ b/lib/libform/form_field_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_opts.3,v 1.9 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_opts.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,33 +29,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_opts.3x,v 1.7 1998/11/29 01:06:54 Rick.Ohnemus Exp $
+.\" $Id: form_field_opts.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.TH form_field_opts 3 ""
.SH NAME
\fBform_field_opts\fR - set and get field options
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_field_opts(FIELD *field, OPTIONS opts);
+int set_field_opts(FIELD *field, Field_Options opts);
.br
-int field_opts_on(FIELD *field, OPTIONS opts);
+int field_opts_on(FIELD *field, Field_Options opts);
.br
-int field_opts_off(FIELD *field, OPTIONS opts);
+int field_opts_off(FIELD *field, Field_Options opts);
.br
-OPTIONS field_opts(const FIELD *field);
+Field_Options field_opts(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_field_opts\fR sets all the given field's option bits (field
option bits may be logically OR'ed together).
-
+.PP
The function \fBfield_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBfield_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBfield_opts\fR returns the field's current option bits.
-
+.PP
The following options are defined (all are on by default):
.TP 5
O_VISIBLE
@@ -74,7 +74,7 @@ O_EDIT
The field can be edited.
.TP 5
O_WRAP
-Words that don't fit on a line are wrapped to the next line. Words are
+Words that do not fit on a line are wrapped to the next line. Words are
blank-separated.
.TP 5
O_BLANK
@@ -88,20 +88,24 @@ Allow a blank field.
.TP 5
O_STATIC
Field buffers are fixed to field's original size.
+Turn this option off to create a dynamic field.
.TP 5
O_PASSOK
Validate field only if modified by user.
.SH RETURN VALUE
Except for \fBfield_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_CURRENT\fR
+.B E_CURRENT
The field is the current field.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.TP 5
diff --git a/lib/libform/form_field_userptr.3 b/lib/libform/form_field_userptr.3
index ce97c279689..f92f35a2019 100644
--- a/lib/libform/form_field_userptr.3
+++ b/lib/libform/form_field_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_userptr.3,v 1.7 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_field_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_userptr.3x,v 1.6 1998/11/29 01:07:05 Rick.Ohnemus Exp $
+.\" $Id: form_field_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_field_userptr 3 ""
.SH NAME
\fBform_field_userptr\fR - associate application data with a form field
@@ -45,14 +45,10 @@ Every form field has a field that can be used to hold application-specific data
(that is, the form-driver code leaves it alone). These functions get and set
that field.
.SH RETURN VALUE
-The function \fBfield_userptr\fR returns \fBNULL\fR on error. The function
-\fBset_field_userptr\fR returns one of the following:
-.TP 5
-\fBE_OK\fR
-The routine succeeded.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+The function \fBfield_userptr\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBset_field_userptr\fR returns \fBE_OK\fP (success).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -61,9 +57,9 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
-The user pointer should be a void pointer. We leave it as a char pointer for
-SVr4 compatibility.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libform/form_field_validation.3 b/lib/libform/form_field_validation.3
index 267a59847e0..660d46e35cd 100644
--- a/lib/libform/form_field_validation.3
+++ b/lib/libform/form_field_validation.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: form_field_validation.3,v 1.8 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_validation.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: form_field_validation.3x,v 1.10 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: form_field_validation.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field_validation 3 ""
.SH NAME
\fBform_field_validation\fR - data type validation for fields
@@ -40,10 +40,25 @@ int set_field_type(FIELD *field, FIELDTYPE *type, ...);
FIELDTYPE *field_type(const FIELD *field);
.br
void *field_arg(const FIELD *field);
+.sp
+FIELDTYPE *TYPE_ALNUM;
+.br
+FIELDTYPE *TYPE_ALPHA;
+.br
+FIELDTYPE *TYPE_ENUM;
+.br
+FIELDTYPE *TYPE_INTEGER;
+.br
+FIELDTYPE *TYPE_NUMERIC;
+.br
+FIELDTYPE *TYPE_REGEXP;
+.br
+FIELDTYPE *TYPE_IPV4;
.br
.SH DESCRIPTION
The function \fBset_field_type\fR declares a data type for a given form field.
-This is the type checked by validation functions. The types are as follows:
+This is the type checked by validation functions.
+The predefined types are as follows:
.TP 5
TYPE_ALNUM
Alphanumeric data. Requires a third \fBint\fR argument, a minimum field width.
@@ -86,7 +101,7 @@ For details of the precision handling see \fBprintf's\fR man-page.
TYPE_REGEXP
Regular expression data. Requires a regular expression \fB(char *)\fR third argument;
the data is valid if the regular expression matches it. Regular expressions
-are in the format of \fBregcomp\fR(3) and \fBregexec\fR(3). Please notice
+are in the format of \fBregcomp\fR and \fBregexec\fR. Please notice
that the regular expression must match the whole field. If you have for
example an eight character wide field, a regular expression "^[0-9]*$" always
means that you have to fill all eight positions with digits. If you want to
@@ -100,17 +115,17 @@ is checked whether or not the buffer has the form a.b.c.d, where a,b,c and d are
numbers between 0 and 255. Trailing blanks in the buffer are ignored. The address
itself is not validated. Please note that this is an ncurses extension. This
field type may not be available in other curses implementations.
-
+.PP
It is possible to set up new programmer-defined field types. See the
\fBform_fieldtype\fR(3) manual page.
.SH RETURN VALUE
The functions \fBfield_type\fR and \fBfield_arg\fR return \fBNULL\fR on
error. The function \fBset_field_type\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_fieldtype.3 b/lib/libform/form_fieldtype.3
index 965e3899b00..a8444862b9d 100644
--- a/lib/libform/form_fieldtype.3
+++ b/lib/libform/form_fieldtype.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_fieldtype.3,v 1.10 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_fieldtype.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_fieldtype.3x,v 1.8 2000/07/15 22:02:03 tom Exp $
+.\" $Id: form_fieldtype.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.TH form_fieldtype 3 ""
.SH NAME
\fBform_fieldtype\fR - define validation-field types
@@ -49,7 +49,7 @@ int set_fieldtype_arg(
void (* const free_arg)(void *));
.br
int set_fieldtype_choice(
- FIELDTYPE *fieldtype
+ FIELDTYPE *fieldtype,
bool (* const next_choice)(FIELD *, const void *),
bool (* const prev_choice)(FIELD *, const void *));
.br
@@ -63,54 +63,76 @@ validity of an entered data string whenever the user attempts to leave a field.
The (FIELD *) argument is passed in so the validation predicate can see the
field's buffer, sizes and other attributes; the second argument is an
argument-block structure, about which more below.
-
+.PP
You also supply \fBnew_fieldtype\fR with \fIchar_check\fR,
a function to validate input characters as they are entered; it will be passed
the character to be checked and a pointer to an argument-block structure.
-
+.PP
The function \fBfree_fieldtype\fR frees the space allocated for a given
validation type.
-
-The function \fBset_fieldtype\fR associates three storage-management functions
-with a field type. The \fImak_arg\fR function is automatically applied to the
+.PP
+The function \fBset_fieldtype_arg\fR associates three storage-management functions
+with a field type.
+The \fImake_arg\fR function is automatically applied to the
list of arguments you give \fBset_field_type\fR when attaching validation
to a field; its job is to bundle these into an allocated argument-block
-object which can later be passed to validation predicated. The other two
-hook arguments should copy and free argument-block structures. They will
-be used by the forms-driver code. You must supply the \fImak_arg\fR function,
-the other two are optional, you may supply NULL for them. In this case it
-is assumed that \fImak_arg\fR doesn't allocate memory but simply loads the
+object which can later be passed to validation predicated.
+The other two hook arguments should copy and free argument-block structures.
+They will be used by the forms-driver code.
+You must supply the \fImake_arg\fR function,
+the other two are optional, you may supply NULL for them.
+In this case it is assumed
+that \fImake_arg\fR does not allocate memory but simply loads the
argument into a single scalar value.
-
+.PP
+The function \fBlink_fieldtype\fR creates
+a new field type from the two given types.
+They are connected by an logical 'OR'.
+.PP
The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume
that the possible values of a field form an ordered set, and provide the forms
-user with a way to move through the set. The \fBset_fieldtype_choice\fR
+user with a way to move through the set.
+The \fBset_fieldtype_choice\fR
function allows forms programmers to define successor and predecessor functions
-for the field type. These functions take the field pointer and an
+for the field type.
+These functions take the field pointer and an
argument-block structure as arguments.
.SH RETURN VALUE
The pointer-valued routines return NULL on error.
-
+They set errno according to their success:
+.TP 5
+.B E_OK
+The routine succeeded.
+.TP 5
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
The integer-valued routines return one of the following codes on
error:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_CONNECTED\fR
+.B E_CONNECTED
The field is already connected to a form.
+.TP 5
+.B E_CURRENT
+The field is the current field.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
\fB<curses.h>\fR.
-
+.PP
All of the \fB(char *)\fR arguments of these functions should actually be
\fB(void *)\fR. The type has been left uncorrected for strict compatibility
with System V.
diff --git a/lib/libform/form_hook.3 b/lib/libform/form_hook.3
index 6a7d3227918..4d53f0351f2 100644
--- a/lib/libform/form_hook.3
+++ b/lib/libform/form_hook.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_hook.3,v 1.9 1999/03/28 18:01:03 millert Exp $
+.\" $OpenBSD: form_hook.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,47 +29,47 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_hook.3x,v 1.6 1999/03/20 22:37:15 Todd.Miller Exp $
+.\" $Id: form_hook.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.TH form_hook 3 ""
.SH NAME
\fBform_hook\fR - set hooks for automatic invocation by applications
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_field_init(FORM *form, void (*func)(FORM *));
+int set_field_init(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) field_init(const FORM *form);
+Form_Hook field_init(const FORM *form);
.br
-int set_field_term(FORM *form, void (*func)(FORM *));
+int set_field_term(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) field_term(const FORM *form);
+Form_Hook field_term(const FORM *form);
.br
-int set_form_init(FORM *form, void (*func)(FORM *));
+int set_form_init(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) form_init(const FORM *form);
+Form_Hook form_init(const FORM *form);
.br
-int set_form_term(FORM *form, void (*func)(FORM *));
+int set_form_term(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) form_term(const FORM *form);
+Form_Hook form_term(const FORM *form);
.br
.SH DESCRIPTION
These functions make it possible to set hook functions to be called at various
points in the automatic processing of input event codes by \fBform_driver\fR.
-
+.PP
The function \fBset_field_init\fR sets a hook to be called at form-post time
and each time the selected field changes (after the change). \fBfield_init\fR
returns the current field init hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_field_term\fR sets a hook to be called at form-unpost time
and each time the selected field changes (before the change). \fBfield_term\fR
returns the current field term hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_form_init\fR sets a hook to be called at form-post time and
just after a page change once it is posted. \fBform_init\fR returns the
current form init hook, if any (\fBNULL\fR if there is no such hook).
-
+.PP
The function \fBset_form_term\fR sets a hook to be called at form-unpost time
and just before a page change once it is posted. \fBform_init\fR
returns the current form term hook, if any (\fBNULL\fR if there is no such
@@ -78,10 +78,10 @@ hook).
Routines that return pointers return \fBNULL\fR on error. Other routines
return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_new.3 b/lib/libform/form_new.3
index bd038576b9b..abe1a678197 100644
--- a/lib/libform/form_new.3
+++ b/lib/libform/form_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_new.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_new.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_new.3x,v 1.5 1998/11/29 01:07:37 Rick.Ohnemus Exp $
+.\" $Id: form_new.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_new 3 ""
.SH NAME
\fBform_new\fR - create and destroy forms
@@ -43,24 +43,34 @@ int free_form(FORM *form);
.SH DESCRIPTION
The function \fBnew_form\fR creates a new form connected to a specified field
pointer array (which must be \fBNULL\fR-terminated).
-
+.PP
The function \fBfree_form\fR disconnects \fIform\fR from its field array
and frees the storage allocated for the form.
.SH RETURN VALUE
The function \fBnew_form\fR returns \fBNULL\fR on error.
-
-The function \fBfree_form\fR returns one of the following:
+It sets errno according to the function's success:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_CONNECTED
+The field is already connected to a form.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
+The function \fBfree_form\fR returns one of the following:
+.TP 5
+.B E_OK
+The routine succeeded.
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The form has already been posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_new_page.3 b/lib/libform/form_new_page.3
index dea27f18e29..918fdf4d1db 100644
--- a/lib/libform/form_new_page.3
+++ b/lib/libform/form_new_page.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_new_page.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_new_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_new_page.3x,v 1.5 1998/11/29 01:07:45 Rick.Ohnemus Exp $
+.\" $Id: form_new_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_new_page 3 ""
.SH NAME
\fBform_new_page\fR - form pagination functions
@@ -43,24 +43,24 @@ bool new_page(const FIELD *field);
.SH DESCRIPTION
The function \fBset_new_page\fR sets or resets a flag marking the given field
as the beginning of a new page on its form.
-
+.PP
The function \fBnew_page\fR is a predicate which tests if a given field marks
a page beginning on its form.
.SH RETURN VALUE
The function \fBnew_page\fR returns \fBTRUE\fR or \fBFALSE\fR.
-
+.PP
The function \fBset_new_page\fR return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_CONNECTED\fR
+.B E_CONNECTED
The given field is already connected to a form.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_opts.3 b/lib/libform/form_opts.3
index 36906fe181d..429910b71b4 100644
--- a/lib/libform/form_opts.3
+++ b/lib/libform/form_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_opts.3,v 1.8 1999/05/12 13:26:49 aaron Exp $
+.\" $OpenBSD: form_opts.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,33 +29,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_opts.3x,v 1.6 1998/11/29 01:07:53 Rick.Ohnemus Exp $
+.\" $Id: form_opts.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_opts 3 ""
.SH NAME
\fBform_opts\fR - set and get form options
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_form_opts(FORM *form, OPTIONS opts);
+int set_form_opts(FORM *form, Field_Options opts);
.br
-int form_opts_on(FORM *form, OPTIONS opts);
+int form_opts_on(FORM *form, Field_Options opts);
.br
-int form_opts_off(FORM *form, OPTIONS opts);
+int form_opts_off(FORM *form, Field_Options opts);
.br
-OPTIONS form_opts(const FORM *form);
+Field_Options form_opts(const FORM *form);
.br
.SH DESCRIPTION
The function \fBset_form_opts\fR sets all the given form's option bits (form
option bits may be logically OR'ed together).
-
+.PP
The function \fBform_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBform_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBform_opts\fR returns the form's current option bits.
-
+.PP
The following options are defined (all are on by default):
.TP 5
O_NL_OVERLOAD
@@ -68,10 +68,10 @@ beginning of a field goes to the previous field.
.SH RETURN VALUE
Except for \fBform_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_page.3 b/lib/libform/form_page.3
index 94bebc7d5cc..845cfc7852f 100644
--- a/lib/libform/form_page.3
+++ b/lib/libform/form_page.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_page.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_page.3x,v 1.8 1998/11/29 01:08:02 Rick.Ohnemus Exp $
+.\" $Id: form_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_page 3 ""
.SH NAME
\fBform_page\fR - set and get form page number
@@ -61,23 +61,24 @@ the argument is the null pointer or the field is not connected.
.SH RETURN VALUE
Except for \fBform_page\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_INVALID_FIELD\fR
+.B E_INVALID_FIELD
Contents of a field are not valid.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The form driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_post.3 b/lib/libform/form_post.3
index e5278e07dfc..1cc25cdae00 100644
--- a/lib/libform/form_post.3
+++ b/lib/libform/form_post.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_post.3,v 1.6 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_post.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_post.3x,v 1.4 1998/11/29 01:08:10 Rick.Ohnemus Exp $
+.\" $Id: form_post.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.TH form_post 3 ""
.SH NAME
\fBform_post\fR - write or erase forms from associated subwindows
@@ -45,34 +45,35 @@ The function \fBpost_form\fR displays a form to its associated subwindow. To
trigger physical display of the subwindow, use \fBrefresh\fR or some equivalent
\fBcurses\fR routine (the implicit \fBdoupdate\fR triggered by an \fBcurses\fR
input request will do).
-
+.PP
The function \fBunpost_form\fR erases form from its associated subwindow.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
-The form has already been posted.
-.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
-Form is too large for its window.
-.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The form has not been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the form.
+.TP 5
+.B E_NO_ROOM
+Form is too large for its window.
+.TP 5
+.B E_POSTED
+The form has already been posted.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_requestname.3 b/lib/libform/form_requestname.3
index 51a819faa4f..6812d20e5d9 100644
--- a/lib/libform/form_requestname.3
+++ b/lib/libform/form_requestname.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_requestname.3,v 1.6 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_requestname.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_requestname.3x,v 1.6 1998/11/29 01:08:18 Rick.Ohnemus Exp $
+.\" $Id: form_requestname.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.TH form_requestname 3 ""
.SH NAME
\fBform_requestname\fR - handle printable form request names
@@ -51,6 +51,7 @@ with the given name and returns its request code. Otherwise E_NO_MATCH is return
to \fBE_BAD_ARGUMENT\fR.
.br
\fBform_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+It does not set errno.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_userptr.3 b/lib/libform/form_userptr.3
index 0cd1226ed92..9ea1daf3cd2 100644
--- a/lib/libform/form_userptr.3
+++ b/lib/libform/form_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_userptr.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_userptr.3x,v 1.9 1998/11/29 01:08:39 Rick.Ohnemus Exp $
+.\" $Id: form_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_userptr 3 ""
.SH NAME
\fBform_userptr\fR - associate application data with a form item
@@ -45,14 +45,10 @@ Every form and every form item has a field that can be used to hold
application-specific data (that is, the form-driver code leaves it alone).
These functions get and set the form user pointer field.
.SH RETURN VALUE
-The function \fBform_userptr\fR returns \fBNULL\fR on error.
-The function \fBset_form_userptr\fR returns one of the following:
-.TP 5
-\fBE_OK\fR
-The routine succeeded.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+The function \fBform_userptr\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBset_form_userptr\fR returns \fBE_OK\fP (success).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -61,9 +57,9 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
-The user pointer should be a void pointer. We leave it as a char pointer for
-SVr4 compatibility.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libform/form_win.3 b/lib/libform/form_win.3
index da9faf1de8a..fb42bcb0bd5 100644
--- a/lib/libform/form_win.3
+++ b/lib/libform/form_win.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_win.3,v 1.8 1999/05/08 20:29:03 millert Exp $
+.\" $OpenBSD: form_win.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_win.3x,v 1.8 1999/04/10 23:36:08 tom Exp $
+.\" $Id: form_win.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_win 3 ""
.SH NAME
\fBform_win\fR - make and break form window and subwindow associations
@@ -50,33 +50,33 @@ int scale_form(const FORM *form, int *rows, int *columns);
Every form has an associated pair of \fBcurses\fR windows. The form window
displays any title and border associated with the window; the form subwindow
displays the items of the form that are currently available for selection.
-
+.PP
The first four functions get and set those windows. It is not necessary to set
either window; by default, the driver code uses \fBstdscr\fR for both.
-
+.PP
In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as though
it were \fBstsdcr\fR. A form argument of \fBNULL\fR is treated as a request
to change the system default form window or subwindow.
-
+.PP
The function \fBscale_form\fR returns the minimum size required for the
subwindow of \fIform\fR.
.SH RETURN VALUE
Routines that return pointers return \fBNULL\fR on error. Routines that return
an integer return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The form has already been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the form.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/frm_cursor.c b/lib/libform/frm_cursor.c
index 8eec04c5b46..e1533fd3fd3 100644
--- a/lib/libform/frm_cursor.c
+++ b/lib/libform/frm_cursor.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_cursor.c,v 1.4 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: frm_cursor.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_cursor.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -50,16 +49,18 @@ MODULE_ID("$From: frm_cursor.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_NOT_POSTED - Form is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-pos_form_cursor (FORM * form)
+pos_form_cursor(FORM *form)
{
int res;
+ T((T_CALLED("pos_form_cursor(%p)"), form));
+
if (!form)
- res = E_BAD_ARGUMENT;
+ res = E_BAD_ARGUMENT;
else
{
if (!(form->status & _POSTED))
- res = E_NOT_POSTED;
+ res = E_NOT_POSTED;
else
res = _nc_Position_Form_Cursor(form);
}
diff --git a/lib/libform/frm_data.c b/lib/libform/frm_data.c
index 7f6dde0fd07..1b6ef2b8a86 100644
--- a/lib/libform/frm_data.c
+++ b/lib/libform/frm_data.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_data.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,28 +27,30 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_data.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_data.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_behind(const FORM *form)
|
| Description : Check for off-screen data behind. This is nearly trivial
-| becose the begin of a field is fixed.
+| because the beginning of a field is fixed.
|
| Return Values : TRUE - there are off-screen data behind
| FALSE - there are no off-screen data behind
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-data_behind (const FORM *form)
+data_behind(const FORM *form)
{
bool result = FALSE;
+ T((T_CALLED("data_behind(%p)"), form));
+
if (form && (form->status & _POSTED) && form->current)
{
FIELD *field;
@@ -58,42 +58,69 @@ data_behind (const FORM *form)
field = form->current;
if (!Single_Line_Field(field))
{
- result = (form->toprow==0) ? FALSE : TRUE;
+ result = (form->toprow == 0) ? FALSE : TRUE;
}
else
{
- result = (form->begincol==0) ? FALSE : TRUE;
+ result = (form->begincol == 0) ? FALSE : TRUE;
}
}
- return(result);
+ returnBool(result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static char * After_Last_Non_Pad_Position(
-| char *buffer,
+| Function : static char * Only_Padding(
+| WINDOW *w,
| int len,
| int pad)
|
-| Description : Find the last position in the buffer that doesn't
+| Description : Test if 'length' cells starting at the current position
| contain a padding character.
|
-| Return Values : The pointer to this position
+| Return Values : true if only padding cells are found
+--------------------------------------------------------------------------*/
-INLINE
-static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
+NCURSES_INLINE static bool
+Only_Padding(WINDOW *w, int len, int pad)
{
- char *end = buffer + len;
-
- assert(buffer && len>=0);
- while ( (buffer < end) && (*(end-1)==pad) )
- end--;
+ bool result = TRUE;
+ int y, x, j;
+ FIELD_CELL cell;
- return end;
+ getyx(w, y, x);
+ for (j = 0; j < len; ++j)
+ {
+ if (wmove(w, y, x + j) != ERR)
+ {
+#if USE_WIDEC_SUPPORT
+ if (win_wch(w, &cell) != ERR)
+ {
+ if ((chtype)CharOf(cell) != ChCharOf(pad)
+ || cell.chars[1] != 0)
+ {
+ result = FALSE;
+ break;
+ }
+ }
+#else
+ cell = winch(w);
+ if (ChCharOf(cell) != ChCharOf(pad))
+ {
+ result = FALSE;
+ break;
+ }
+#endif
+ }
+ else
+ {
+ /* if an error, return true: no non-padding text found */
+ break;
+ }
+ }
+ /* no need to reset the cursor position; caller does this */
+ return result;
}
-#define SMALL_BUFFER_SIZE (80)
-
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_ahead(const FORM *form)
@@ -105,31 +132,21 @@ static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
| FALSE - there are no off-screen data ahead
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-data_ahead (const FORM *form)
+data_ahead(const FORM *form)
{
bool result = FALSE;
+ T((T_CALLED("data_ahead(%p)"), form));
+
if (form && (form->status & _POSTED) && form->current)
{
- static char buffer[SMALL_BUFFER_SIZE + 1];
FIELD *field;
- bool large_buffer;
bool cursor_moved = FALSE;
- char *bp;
- char *found_content;
int pos;
field = form->current;
assert(form->w);
- large_buffer = (field->cols > SMALL_BUFFER_SIZE);
- if (large_buffer)
- bp = (char *)malloc((size_t)(field->cols) + 1);
- else
- bp = buffer;
-
- assert(bp);
-
if (Single_Line_Field(field))
{
int check_len;
@@ -138,15 +155,12 @@ data_ahead (const FORM *form)
while (pos < field->dcols)
{
check_len = field->dcols - pos;
- if ( check_len >= field->cols )
+ if (check_len >= field->cols)
check_len = field->cols;
cursor_moved = TRUE;
- wmove(form->w,0,pos);
- winnstr(form->w,bp,check_len);
- found_content =
- After_Last_Non_Pad_Position(bp,check_len,field->pad);
- if (found_content==bp)
- pos += field->cols;
+ wmove(form->w, 0, pos);
+ if (Only_Padding(form->w, check_len, field->pad))
+ pos += field->cols;
else
{
result = TRUE;
@@ -160,12 +174,9 @@ data_ahead (const FORM *form)
while (pos < field->drows)
{
cursor_moved = TRUE;
- wmove(form->w,pos,0);
+ wmove(form->w, pos, 0);
pos++;
- winnstr(form->w,bp,field->cols);
- found_content =
- After_Last_Non_Pad_Position(bp,field->cols,field->pad);
- if (found_content!=bp)
+ if (!Only_Padding(form->w, field->cols, field->pad))
{
result = TRUE;
break;
@@ -173,13 +184,10 @@ data_ahead (const FORM *form)
}
}
- if (large_buffer)
- free(bp);
-
if (cursor_moved)
- wmove(form->w,form->currow,form->curcol);
+ wmove(form->w, form->currow, form->curcol);
}
- return(result);
+ returnBool(result);
}
/* frm_data.c ends here */
diff --git a/lib/libform/frm_def.c b/lib/libform/frm_def.c
index ac123147d4a..63079bf5f3d 100644
--- a/lib/libform/frm_def.c
+++ b/lib/libform/frm_def.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_def.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,37 +27,38 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_def.c,v 1.10 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/* this can't be readonly */
-static FORM default_form = {
- 0, /* status */
- 0, /* rows */
- 0, /* cols */
- 0, /* currow */
- 0, /* curcol */
- 0, /* toprow */
- 0, /* begincol */
- -1, /* maxfield */
- -1, /* maxpage */
- -1, /* curpage */
- ALL_FORM_OPTS, /* opts */
- (WINDOW *)0, /* win */
- (WINDOW *)0, /* sub */
- (WINDOW *)0, /* w */
- (FIELD **)0, /* field */
- (FIELD *)0, /* current */
- (_PAGE *)0, /* page */
- (char *)0, /* usrptr */
- NULL, /* forminit */
- NULL, /* formterm */
- NULL, /* fieldinit */
- NULL /* fieldterm */
+static FORM default_form =
+{
+ 0, /* status */
+ 0, /* rows */
+ 0, /* cols */
+ 0, /* currow */
+ 0, /* curcol */
+ 0, /* toprow */
+ 0, /* begincol */
+ -1, /* maxfield */
+ -1, /* maxpage */
+ -1, /* curpage */
+ ALL_FORM_OPTS, /* opts */
+ (WINDOW *)0, /* win */
+ (WINDOW *)0, /* sub */
+ (WINDOW *)0, /* w */
+ (FIELD **)0, /* field */
+ (FIELD *)0, /* current */
+ (_PAGE *) 0, /* page */
+ (char *)0, /* usrptr */
+ NULL, /* forminit */
+ NULL, /* formterm */
+ NULL, /* fieldinit */
+ NULL /* fieldterm */
};
NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
@@ -76,39 +75,40 @@ NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
|
| Return Values : New head of sorted fieldlist
+--------------------------------------------------------------------------*/
-static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
+static FIELD *
+Insert_Field_By_Position(FIELD *newfield, FIELD *head)
{
FIELD *current, *newhead;
-
+
assert(newfield);
if (!head)
- { /* empty list is trivial */
+ { /* empty list is trivial */
newhead = newfield->snext = newfield->sprev = newfield;
}
else
{
newhead = current = head;
- while((current->frow < newfield->frow) ||
- ((current->frow==newfield->frow) &&
- (current->fcol < newfield->fcol)) )
+ while ((current->frow < newfield->frow) ||
+ ((current->frow == newfield->frow) &&
+ (current->fcol < newfield->fcol)))
{
current = current->snext;
- if (current==head)
- { /* We cycled through. Reset head to indicate that */
+ if (current == head)
+ { /* We cycled through. Reset head to indicate that */
head = (FIELD *)0;
break;
}
}
- /* we leave the loop with current pointing to the field after newfield*/
- newfield->snext = current;
- newfield->sprev = current->sprev;
+ /* we leave the loop with current pointing to the field after newfield */
+ newfield->snext = current;
+ newfield->sprev = current->sprev;
newfield->snext->sprev = newfield;
newfield->sprev->snext = newfield;
- if (current==head)
+ if (current == head)
newhead = newfield;
}
- return(newhead);
+ return (newhead);
}
/*---------------------------------------------------------------------------
@@ -119,25 +119,26 @@ static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Disconnect_Fields( FORM * form )
+static void
+Disconnect_Fields(FORM *form)
{
if (form->field)
{
FIELD **fields;
- for(fields=form->field;*fields;fields++)
+ for (fields = form->field; *fields; fields++)
{
- if (form == (*fields)->form)
+ if (form == (*fields)->form)
(*fields)->form = (FORM *)0;
}
-
+
form->rows = form->cols = 0;
form->maxfield = form->maxpage = -1;
form->field = (FIELD **)0;
- if (form->page)
+ if (form->page)
free(form->page);
- form->page = (_PAGE *)0;
- }
+ form->page = (_PAGE *) 0;
+ }
}
/*---------------------------------------------------------------------------
@@ -151,85 +152,98 @@ static void Disconnect_Fields( FORM * form )
| E_BAD_ARGUMENT - Invalid form pointer or field array
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
-static int Connect_Fields(FORM * form, FIELD ** fields)
+static int
+Connect_Fields(FORM *form, FIELD **fields)
{
int field_cnt, j;
int page_nr;
int maximum_row_in_field, maximum_col_in_field;
_PAGE *pg;
-
+
+ T((T_CALLED("Connect_Fields(%p,%p)"), form, fields));
+
assert(form);
- form->field = fields;
+ form->field = fields;
form->maxfield = 0;
- form->maxpage = 0;
+ form->maxpage = 0;
if (!fields)
RETURN(E_OK);
-
+
page_nr = 0;
/* store formpointer in fields and count pages */
- for(field_cnt=0;fields[field_cnt];field_cnt++)
+ for (field_cnt = 0; fields[field_cnt]; field_cnt++)
{
- if (fields[field_cnt]->form)
+ if (fields[field_cnt]->form)
RETURN(E_CONNECTED);
- if ( field_cnt==0 ||
- (fields[field_cnt]->status & _NEWPAGE))
+ if (field_cnt == 0 ||
+ (fields[field_cnt]->status & _NEWPAGE))
page_nr++;
fields[field_cnt]->form = form;
- }
- if (field_cnt==0)
+ }
+ if (field_cnt == 0 || (short)field_cnt < 0)
RETURN(E_BAD_ARGUMENT);
-
+
/* allocate page structures */
- if ( (pg = (_PAGE *)malloc(page_nr * sizeof(_PAGE))) != (_PAGE *)0 )
+ if ((pg = typeMalloc(_PAGE, page_nr)) != (_PAGE *) 0)
{
+ T((T_CREATE("_PAGE %p"), pg));
form->page = pg;
}
else
RETURN(E_SYSTEM_ERROR);
-
+
/* Cycle through fields and calculate page boundaries as well as
size of the form */
- for(j=0;j<field_cnt;j++)
+ for (j = 0; j < field_cnt; j++)
{
- if (j==0)
+ if (j == 0)
pg->pmin = j;
else
{
if (fields[j]->status & _NEWPAGE)
{
- pg->pmax = j-1;
+ pg->pmax = j - 1;
pg++;
pg->pmin = j;
}
}
-
+
maximum_row_in_field = fields[j]->frow + fields[j]->rows;
maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
-
- if (form->rows < maximum_row_in_field)
+
+ if (form->rows < maximum_row_in_field)
form->rows = maximum_row_in_field;
- if (form->cols < maximum_col_in_field)
+ if (form->cols < maximum_col_in_field)
form->cols = maximum_col_in_field;
}
-
- pg->pmax = field_cnt-1;
+
+ pg->pmax = field_cnt - 1;
form->maxfield = field_cnt;
- form->maxpage = page_nr;
-
+ form->maxpage = page_nr;
+
/* Sort fields on form pages */
- for(page_nr = 0;page_nr < form->maxpage; page_nr++)
+ for (page_nr = 0; page_nr < form->maxpage; page_nr++)
{
FIELD *fld = (FIELD *)0;
- for(j = form->page[page_nr].pmin;j <= form->page[page_nr].pmax;j++)
+
+ for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
{
fields[j]->index = j;
- fields[j]->page = page_nr;
- fld = Insert_Field_By_Position(fields[j],fld);
+ fields[j]->page = page_nr;
+ fld = Insert_Field_By_Position(fields[j], fld);
+ }
+ if (fld)
+ {
+ form->page[page_nr].smin = fld->index;
+ form->page[page_nr].smax = fld->sprev->index;
+ }
+ else
+ {
+ form->page[page_nr].smin = 0;
+ form->page[page_nr].smax = 0;
}
- form->page[page_nr].smin = fld->index;
- form->page[page_nr].smax = fld->sprev->index;
}
RETURN(E_OK);
}
@@ -242,46 +256,57 @@ static int Connect_Fields(FORM * form, FIELD ** fields)
| If there are fields, position to first active field.
|
| Return Values : E_OK - success
-| any other - error occured
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
-INLINE static int Associate_Fields(FORM *form, FIELD **fields)
+NCURSES_INLINE static int
+Associate_Fields(FORM *form, FIELD **fields)
{
- int res = Connect_Fields(form,fields);
+ int res = Connect_Fields(form, fields);
+
if (res == E_OK)
{
- if (form->maxpage>0)
+ if (form->maxpage > 0)
{
form->curpage = 0;
- form_driver(form,FIRST_ACTIVE_MAGIC);
+ form_driver(form, FIRST_ACTIVE_MAGIC);
}
else
{
form->curpage = -1;
form->current = (FIELD *)0;
- }
+ }
}
- return(res);
+ return (res);
}
-
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FORM *new_form( FIELD **fields )
|
| Description : Create new form with given array of fields.
|
-| Return Values : Pointer to form. NULL if error occured.
+| Return Values : Pointer to form. NULL if error occurred.
+! Set errno:
+| E_OK - success
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FORM *)
-new_form (FIELD ** fields)
-{
+new_form(FIELD **fields)
+{
int err = E_SYSTEM_ERROR;
- FORM *form = (FORM *)malloc(sizeof(FORM));
-
+ FORM *form = typeMalloc(FORM, 1);
+
+ T((T_CALLED("new_form(%p)"), fields));
if (form)
{
+ T((T_CREATE("form %p"), form));
*form = *_nc_Default_Form;
- if ((err=Associate_Fields(form,fields))!=E_OK)
+ if ((err = Associate_Fields(form, fields)) != E_OK)
{
free_form(form);
form = (FORM *)0;
@@ -290,8 +315,8 @@ new_form (FIELD ** fields)
if (!form)
SET_ERROR(err);
-
- return(form);
+
+ returnForm(form);
}
/*---------------------------------------------------------------------------
@@ -305,19 +330,21 @@ new_form (FIELD ** fields)
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_form (FORM * form)
+free_form(FORM *form)
{
- if ( !form )
+ T((T_CALLED("free_form(%p)"), form));
+
+ if (!form)
RETURN(E_BAD_ARGUMENT);
- if ( form->status & _POSTED)
+ if (form->status & _POSTED)
RETURN(E_POSTED);
-
- Disconnect_Fields( form );
- if (form->page)
+
+ Disconnect_Fields(form);
+ if (form->page)
free(form->page);
free(form);
-
+
RETURN(E_OK);
}
@@ -327,31 +354,35 @@ free_form (FORM * form)
|
| Description : Set a new association of an array of fields to a form
|
-| Return Values : E_OK - no error
-| E_BAD_ARGUMENT - invalid form pointer
-| E_POSTED - form is posted
+| Return Values : E_OK - no error
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_POSTED - form is posted
+| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_fields (FORM * form, FIELD ** fields)
+set_form_fields(FORM *form, FIELD **fields)
{
FIELD **old;
int res;
-
- if ( !form )
+
+ T((T_CALLED("set_form_fields(%p,%p)"), form, fields));
+
+ if (!form)
RETURN(E_BAD_ARGUMENT);
- if ( form->status & _POSTED )
+ if (form->status & _POSTED)
RETURN(E_POSTED);
-
+
old = form->field;
- Disconnect_Fields( form );
-
- if( (res = Associate_Fields( form, fields )) != E_OK )
- Connect_Fields( form, old );
-
+ Disconnect_Fields(form);
+
+ if ((res = Associate_Fields(form, fields)) != E_OK)
+ Connect_Fields(form, old);
+
RETURN(res);
}
-
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELD **form_fields( const FORM *form )
@@ -361,9 +392,10 @@ set_form_fields (FORM * form, FIELD ** fields)
| Return Values : Pointer to field array
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD **)
-form_fields (const FORM * form)
+form_fields(const FORM *form)
{
- return (Normalize_Form( form )->field);
+ T((T_CALLED("form_field(%p)"), form));
+ returnFieldPtr(Normalize_Form(form)->field);
}
/*---------------------------------------------------------------------------
@@ -375,9 +407,11 @@ form_fields (const FORM * form)
| Return Values : Number of fields, -1 if none are defined
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_count (const FORM * form)
+field_count(const FORM *form)
{
- return (Normalize_Form( form )->maxfield);
+ T((T_CALLED("field_count(%p)"), form));
+
+ returnCode(Normalize_Form(form)->maxfield);
}
/* frm_def.c ends here */
diff --git a/lib/libform/frm_driver.c b/lib/libform/frm_driver.c
index 5db838901a1..ea428fd113c 100644
--- a/lib/libform/frm_driver.c
+++ b/lib/libform/frm_driver.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_driver.c,v 1.8 2003/01/05 22:41:37 deraadt Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,21 +27,22 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: frm_driver.c,v 1.37 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.9 2010/01/12 23:22:07 nicm Exp $")
/*----------------------------------------------------------------------------
This is the core module of the form library. It contains the majority
- of the driver routines as well as the form_driver function.
+ of the driver routines as well as the form_driver function.
Essentially this module is nearly the whole library. This is because
all the functions in this module depends on some others in the module,
so it makes no sense to split them into separate files because they
will always be linked together. The only acceptable concern is turnaround
- time for this module, but now we have all Pentiums or Riscs, so what!
+ time for this module, but now we have all Pentiums or RISCs, so what!
The driver routines are grouped into nine generic categories:
@@ -54,12 +53,12 @@ MODULE_ID("$From: frm_driver.c,v 1.37 2000/12/10 02:09:38 tom Exp $")
The current field of the form is left and some new field is
entered.
c) Intra-Field Navigation ( all functions prefixed by IFN_ )
- The current position in the current field is changed.
+ The current position in the current field is changed.
d) Vertical Scrolling ( all functions prefixed by VSC_ )
- Esseantially this is a specialization of Intra-Field navigation.
+ Essentially this is a specialization of Intra-Field navigation.
It has to check for a multi-line field.
e) Horizontal Scrolling ( all functions prefixed by HSC_ )
- Esseantially this is a specialization of Intra-Field navigation.
+ Essentially this is a specialization of Intra-Field navigation.
It has to check for a single-line field.
f) Field Editing ( all functions prefixed by FE_ )
The content of the current field is changed
@@ -80,34 +79,46 @@ MODULE_ID("$From: frm_driver.c,v 1.37 2000/12/10 02:09:38 tom Exp $")
/*
Some options that may effect compatibility in behavior to SVr4 forms,
-but they are here to allow a more intuitive and user friendly behaviour of
+but they are here to allow a more intuitive and user friendly behavior of
our form implementation. This doesn't affect the API, so we feel it is
uncritical.
-The initial implementation tries to stay very close with the behaviour
+The initial implementation tries to stay very close with the behavior
of the original SVr4 implementation, although in some areas it is quite
clear that this isn't the most appropriate way. As far as possible this
sources will allow you to build a forms lib that behaves quite similar
-to SVr4, but now and in the future we will give you better options.
+to SVr4, but now and in the future we will give you better options.
Perhaps at some time we will make this configurable at runtime.
*/
-/* Implement a more user-friendly previous/next word behaviour */
+/* Implement a more user-friendly previous/next word behavior */
#define FRIENDLY_PREV_NEXT_WORD (1)
-/* Fix the wrong behaviour for forms with all fields inactive */
+/* Fix the wrong behavior for forms with all fields inactive */
#define FIX_FORM_INACTIVE_BUG (1)
/* Allow dynamic field growth also when navigating past the end */
#define GROW_IF_NAVIGATE (1)
+#if USE_WIDEC_SUPPORT
+#define myADDNSTR(w, s, n) wadd_wchnstr(w, s, n)
+#define myINSNSTR(w, s, n) wins_wchnstr(w, s, n)
+#define myINNSTR(w, s, n) fix_wchnstr(w, s, n)
+#define myWCWIDTH(w, y, x) cell_width(w, y, x)
+#else
+#define myADDNSTR(w, s, n) waddnstr(w, s, n)
+#define myINSNSTR(w, s, n) winsnstr(w, s, n)
+#define myINNSTR(w, s, n) winnstr(w, s, n)
+#define myWCWIDTH(w, y, x) 1
+#endif
+
/*----------------------------------------------------------------------------
Forward references to some internally used static functions
--------------------------------------------------------------------------*/
-static int Inter_Field_Navigation ( int (* const fct) (FORM *), FORM * form );
-static int FN_Next_Field (FORM * form);
-static int FN_Previous_Field (FORM * form);
+static int Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form);
+static int FN_Next_Field(FORM *form);
+static int FN_Previous_Field(FORM *form);
static int FE_New_Line(FORM *);
static int FE_Delete_Previous(FORM *);
-
+
/*----------------------------------------------------------------------------
Macro Definitions.
@@ -151,7 +162,7 @@ static int FE_Delete_Previous(FORM *);
#define Address_Of_Current_Position_In_Buffer(form) \
Address_Of_Current_Position_In_Nth_Buffer(form,0)
-/* Logic to decide wether or not a field is actually a field with
+/* Logic to decide whether or not a field is actually a field with
vertical or horizontal scrolling */
#define Is_Scroll_Field(field) \
(((field)->drows > (field)->rows) || \
@@ -191,168 +202,320 @@ static int FE_Delete_Previous(FORM *);
#define First_Position_In_Current_Field(form) \
(((form)->currow==0) && ((form)->curcol==0))
-
#define Minimum(a,b) (((a)<=(b)) ? (a) : (b))
#define Maximum(a,b) (((a)>=(b)) ? (a) : (b))
-
+
+/*----------------------------------------------------------------------------
+ Useful constants
+ --------------------------------------------------------------------------*/
+static FIELD_CELL myBLANK = BLANK;
+static FIELD_CELL myZEROS;
+
+#ifdef TRACE
+static void
+check_pos(FORM *form, int lineno)
+{
+ int y, x;
+
+ if (form && form->w)
+ {
+ getyx(form->w, y, x);
+ if (y != form->currow || x != form->curcol)
+ {
+ T(("CHECKPOS %s@%d have position %d,%d vs want %d,%d",
+ __FILE__, lineno,
+ y, x,
+ form->currow, form->curcol));
+ }
+ }
+}
+#define CHECKPOS(form) check_pos(form, __LINE__)
+#else
+#define CHECKPOS(form) /* nothing */
+#endif
+
+/*----------------------------------------------------------------------------
+ Wide-character special functions
+ --------------------------------------------------------------------------*/
+#if USE_WIDEC_SUPPORT
+/* like winsnstr */
+static int
+wins_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+ int code = ERR;
+ int y, x;
+
+ while (n-- > 0)
+ {
+ getyx(w, y, x);
+ if ((code = wins_wch(w, s++)) != OK)
+ break;
+ if ((code = wmove(w, y, x + 1)) != OK)
+ break;
+ }
+ return code;
+}
+
+/* win_wchnstr is inconsistent with winnstr, since it returns OK rather than
+ * the number of items transferred.
+ */
+static int
+fix_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+ int x;
+
+ win_wchnstr(w, s, n);
+ /*
+ * This function is used to extract the text only from the window.
+ * Strip attributes and color from the string so they will not be added
+ * back when copying the string to the window.
+ */
+ for (x = 0; x < n; ++x)
+ {
+ RemAttr(s[x], A_ATTRIBUTES);
+ SetPair(s[x], 0);
+ }
+ return n;
+}
+
+/*
+ * Returns the column of the base of the given cell.
+ */
+static int
+cell_base(WINDOW *win, int y, int x)
+{
+ int result = x;
+
+ while (LEGALYX(win, y, x))
+ {
+ cchar_t *data = &(win->_line[y].text[x]);
+
+ if (isWidecBase(CHDEREF(data)) || !isWidecExt(CHDEREF(data)))
+ {
+ result = x;
+ break;
+ }
+ --x;
+ }
+ return result;
+}
+
+/*
+ * Returns the number of columns needed for the given cell in a window.
+ */
+static int
+cell_width(WINDOW *win, int y, int x)
+{
+ int result = 1;
+
+ if (LEGALYX(win, y, x))
+ {
+ cchar_t *data = &(win->_line[y].text[x]);
+
+ if (isWidecExt(CHDEREF(data)))
+ {
+ /* recur, providing the number of columns to the next character */
+ result = cell_width(win, y, x - 1);
+ }
+ else
+ {
+ result = wcwidth(CharOf(CHDEREF(data)));
+ }
+ }
+ return result;
+}
+
+/*
+ * There is no wide-character function such as wdel_wch(), so we must find
+ * all of the cells that comprise a multi-column character and delete them
+ * one-by-one.
+ */
+static void
+delete_char(FORM *form)
+{
+ int cells = cell_width(form->w, form->currow, form->curcol);
+
+ form->curcol = cell_base(form->w, form->currow, form->curcol);
+ wmove(form->w, form->currow, form->curcol);
+ while (cells-- > 0)
+ {
+ wdelch(form->w);
+ }
+}
+#define DeleteChar(form) delete_char(form)
+#else
+#define DeleteChar(form) \
+ wmove((form)->w, (form)->currow, (form)->curcol), \
+ wdelch((form)->w)
+#endif
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *Get_Start_Of_Data(char * buf, int blen)
-|
+|
| Description : Return pointer to first non-blank position in buffer.
| If buffer is empty return pointer to buffer itself.
|
| Return Values : Pointer to first non-blank position in buffer
+--------------------------------------------------------------------------*/
-INLINE static char *Get_Start_Of_Data(char * buf, int blen)
+NCURSES_INLINE static FIELD_CELL *
+Get_Start_Of_Data(FIELD_CELL *buf, int blen)
{
- char *p = buf;
- char *end = &buf[blen];
+ FIELD_CELL *p = buf;
+ FIELD_CELL *end = &buf[blen];
- assert(buf && blen>=0);
- while( (p < end) && is_blank(*p) )
+ assert(buf && blen >= 0);
+ while ((p < end) && ISBLANK(*p))
p++;
- return( (p==end) ? buf : p );
+ return ((p == end) ? buf : p);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *After_End_Of_Data(char * buf, int blen)
-|
+|
| Description : Return pointer after last non-blank position in buffer.
| If buffer is empty, return pointer to buffer itself.
|
-| Return Values : Pointer to position after last non-blank position in
+| Return Values : Pointer to position after last non-blank position in
| buffer.
+--------------------------------------------------------------------------*/
-INLINE static char *After_End_Of_Data(char * buf,int blen)
+NCURSES_INLINE static FIELD_CELL *
+After_End_Of_Data(FIELD_CELL *buf, int blen)
{
- char *p = &buf[blen];
-
- assert(buf && blen>=0);
- while( (p>buf) && is_blank(p[-1]) )
+ FIELD_CELL *p = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p > buf) && ISBLANK(p[-1]))
p--;
- return( p );
+ return (p);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *Get_First_Whitespace_Character(
| char * buf, int blen)
-|
+|
| Description : Position to the first whitespace character.
|
| Return Values : Pointer to first whitespace character in buffer.
+--------------------------------------------------------------------------*/
-INLINE static char *Get_First_Whitespace_Character(char * buf, int blen)
+NCURSES_INLINE static FIELD_CELL *
+Get_First_Whitespace_Character(FIELD_CELL *buf, int blen)
{
- char *p = buf;
- char *end = &p[blen];
-
- assert(buf && blen>=0);
- while( (p < end) && !is_blank(*p))
+ FIELD_CELL *p = buf;
+ FIELD_CELL *end = &p[blen];
+
+ assert(buf && blen >= 0);
+ while ((p < end) && !ISBLANK(*p))
p++;
- return( (p==end) ? buf : p );
+ return ((p == end) ? buf : p);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *After_Last_Whitespace_Character(
| char * buf, int blen)
-|
+|
| Description : Get the position after the last whitespace character.
|
-| Return Values : Pointer to position after last whitespace character in
+| Return Values : Pointer to position after last whitespace character in
| buffer.
+--------------------------------------------------------------------------*/
-INLINE static char *After_Last_Whitespace_Character(char * buf, int blen)
+NCURSES_INLINE static FIELD_CELL *
+After_Last_Whitespace_Character(FIELD_CELL *buf, int blen)
{
- char *p = &buf[blen];
-
- assert(buf && blen>=0);
- while( (p>buf) && !is_blank(p[-1]) )
+ FIELD_CELL *p = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p > buf) && !ISBLANK(p[-1]))
p--;
- return( p );
+ return (p);
}
/* Set this to 1 to use the div_t version. This is a good idea if your
compiler has an intrinsic div() support. Unfortunately GNU-C has it
- not yet.
+ not yet.
N.B.: This only works if form->curcol follows immediately form->currow
- and both are of type int.
+ and both are of type int.
*/
#define USE_DIV_T (0)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Adjust_Cursor_Position(
| FORM * form, const char * pos)
-|
-| Description : Set current row and column of the form to values
+|
+| Description : Set current row and column of the form to values
| corresponding to the buffer position.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void Adjust_Cursor_Position(FORM * form, const char * pos)
+NCURSES_INLINE static void
+Adjust_Cursor_Position(FORM *form, const FIELD_CELL *pos)
{
FIELD *field;
int idx;
field = form->current;
- assert( pos >= field->buf && field->dcols > 0);
- idx = (int)( pos - field->buf );
+ assert(pos >= field->buf && field->dcols > 0);
+ idx = (int)(pos - field->buf);
#if USE_DIV_T
- *((div_t *)&(form->currow)) = div(idx,field->dcols);
+ *((div_t *) & (form->currow)) = div(idx, field->dcols);
#else
form->currow = idx / field->dcols;
form->curcol = idx - field->cols * form->currow;
-#endif
- if ( field->drows < form->currow )
+#endif
+ if (field->drows < form->currow)
form->currow = 0;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Buffer_To_Window(
| const FIELD * field,
| WINDOW * win)
-|
-| Description : Copy the buffer to the window. If its a multiline
+|
+| Description : Copy the buffer to the window. If it is a multi-line
| field, the buffer is split to the lines of the
| window without any editing.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Buffer_To_Window(const FIELD * field, WINDOW * win)
+static void
+Buffer_To_Window(const FIELD *field, WINDOW *win)
{
int width, height;
+ int y, x;
int len;
int row;
- char *pBuffer;
+ FIELD_CELL *pBuffer;
assert(win && field);
- width = getmaxx(win);
+ getyx(win, y, x);
+ width = getmaxx(win);
height = getmaxy(win);
- for(row=0, pBuffer=field->buf;
- row < height;
- row++, pBuffer += width )
+ for (row = 0, pBuffer = field->buf;
+ row < height;
+ row++, pBuffer += width)
{
- if ((len = (int)( After_End_Of_Data( pBuffer, width ) - pBuffer )) > 0)
+ if ((len = (int)(After_End_Of_Data(pBuffer, width) - pBuffer)) > 0)
{
- wmove( win, row, 0 );
- waddnstr( win, pBuffer, len );
+ wmove(win, row, 0);
+ myADDNSTR(win, pBuffer, len);
}
- }
+ }
+ wmove(win, y, x);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Window_To_Buffer(
| WINDOW * win,
| FIELD * field)
-|
+|
| Description : Copy the content of the window into the buffer.
| The multiple lines of a window are simply
| concatenated into the buffer. Pad characters in
@@ -360,42 +523,48 @@ static void Buffer_To_Window(const FIELD * field, WINDOW * win)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Window_To_Buffer(WINDOW * win, FIELD * field)
+static void
+Window_To_Buffer(WINDOW *win, FIELD *field)
{
int pad;
int len = 0;
- char *p;
+ FIELD_CELL *p;
int row, height;
-
- assert(win && field && field->buf );
+
+ assert(win && field && field->buf);
pad = field->pad;
p = field->buf;
height = getmaxy(win);
- for(row=0; (row < height) && (row < field->drows); row++ )
+ for (row = 0; (row < height) && (row < field->drows); row++)
{
- wmove( win, row, 0 );
- len += winnstr( win, p+len, field->dcols );
+ wmove(win, row, 0);
+ len += myINNSTR(win, p + len, field->dcols);
}
- p[len] = '\0';
+ p[len] = myZEROS;
/* replace visual padding character by blanks in buffer */
if (pad != C_BLANK)
{
int i;
- for(i=0; i<len; i++, p++)
+
+ for (i = 0; i < len; i++, p++)
{
- if (*p==pad)
- *p = C_BLANK;
+ if ((unsigned long)CharOf(*p) == ChCharOf(pad)
+#if USE_WIDEC_SUPPORT
+ && p->chars[1] == 0
+#endif
+ )
+ *p = myBLANK;
}
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Synchronize_Buffer(FORM * form)
-|
+|
| Description : If there was a change, copy the content of the
| window into the buffer, so the buffer is synchronized
| with the windows content. We have to indicate that the
@@ -403,21 +572,22 @@ static void Window_To_Buffer(WINDOW * win, FIELD * field)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void Synchronize_Buffer(FORM * form)
+NCURSES_INLINE static void
+Synchronize_Buffer(FORM *form)
{
if (form->status & _WINDOW_MODIFIED)
{
form->status &= ~_WINDOW_MODIFIED;
- form->status |= _FCHECK_REQUIRED;
- Window_To_Buffer(form->w,form->current);
- wmove(form->w,form->currow,form->curcol);
+ form->status |= _FCHECK_REQUIRED;
+ Window_To_Buffer(form->w, form->current);
+ wmove(form->w, form->currow, form->curcol);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Field_Grown( FIELD *field, int amount)
-|
+|
| Description : This function is called for growable dynamic fields
| only. It has to increase the buffers and to allocate
| a new window for this field.
@@ -428,7 +598,8 @@ INLINE static void Synchronize_Buffer(FORM * form)
| Return Values : TRUE - field successfully increased
| FALSE - there was some error
+--------------------------------------------------------------------------*/
-static bool Field_Grown(FIELD * field, int amount)
+static bool
+Field_Grown(FIELD *field, int amount)
{
bool result = FALSE;
@@ -439,23 +610,23 @@ static bool Field_Grown(FIELD * field, int amount)
int new_buflen;
int old_dcols = field->dcols;
int old_drows = field->drows;
- char *oldbuf = field->buf;
- char *newbuf;
+ FIELD_CELL *oldbuf = field->buf;
+ FIELD_CELL *newbuf;
int growth;
FORM *form = field->form;
- bool need_visual_update = ((form != (FORM *)0) &&
+ bool need_visual_update = ((form != (FORM *)0) &&
(form->status & _POSTED) &&
- (form->current==field));
-
+ (form->current == field));
+
if (need_visual_update)
Synchronize_Buffer(form);
-
+
if (single_line_field)
{
growth = field->cols * amount;
if (field->maxgrow)
- growth = Minimum(field->maxgrow - field->dcols,growth);
+ growth = Minimum(field->maxgrow - field->dcols, growth);
field->dcols += growth;
if (field->dcols == field->maxgrow)
field->status &= ~_MAY_GROW;
@@ -464,95 +635,142 @@ static bool Field_Grown(FIELD * field, int amount)
{
growth = (field->rows + field->nrow) * amount;
if (field->maxgrow)
- growth = Minimum(field->maxgrow - field->drows,growth);
+ growth = Minimum(field->maxgrow - field->drows, growth);
field->drows += growth;
if (field->drows == field->maxgrow)
field->status &= ~_MAY_GROW;
}
/* drows, dcols changed, so we get really the new buffer length */
new_buflen = Buffer_Length(field);
- newbuf=(char *)malloc((size_t)Total_Buffer_Size(field));
+ newbuf = (FIELD_CELL *)malloc(Total_Buffer_Size(field));
if (!newbuf)
- { /* restore to previous state */
+ {
+ /* restore to previous state */
field->dcols = old_dcols;
field->drows = old_drows;
- if (( single_line_field && (field->dcols!=field->maxgrow)) ||
- (!single_line_field && (field->drows!=field->maxgrow)))
+ if ((single_line_field && (field->dcols != field->maxgrow)) ||
+ (!single_line_field && (field->drows != field->maxgrow)))
field->status |= _MAY_GROW;
- return FALSE;
}
else
- { /* Copy all the buffers. This is the reason why we can't
- just use realloc().
- */
- int i;
- char *old_bp;
- char *new_bp;
-
+ {
+ /* Copy all the buffers. This is the reason why we can't just use
+ * realloc().
+ */
+ int i, j;
+ FIELD_CELL *old_bp;
+ FIELD_CELL *new_bp;
+
+ result = TRUE; /* allow sharing of recovery on failure */
+
+ T((T_CREATE("fieldcell %p"), newbuf));
field->buf = newbuf;
- for(i=0;i<=field->nbuf;i++)
+ for (i = 0; i <= field->nbuf; i++)
{
- new_bp = Address_Of_Nth_Buffer(field,i);
- old_bp = oldbuf + i*(1+old_buflen);
- memcpy(new_bp,old_bp,(size_t)old_buflen);
- if (new_buflen > old_buflen)
- memset(new_bp + old_buflen,C_BLANK,
- (size_t)(new_buflen - old_buflen));
- *(new_bp + new_buflen) = '\0';
+ new_bp = Address_Of_Nth_Buffer(field, i);
+ old_bp = oldbuf + i * (1 + old_buflen);
+ for (j = 0; j < old_buflen; ++j)
+ new_bp[j] = old_bp[j];
+ while (j < new_buflen)
+ new_bp[j++] = myBLANK;
+ new_bp[new_buflen] = myZEROS;
}
- if (need_visual_update)
- {
- WINDOW *new_window = newpad(field->drows,field->dcols);
- if (!new_window)
- { /* restore old state */
- field->dcols = old_dcols;
- field->drows = old_drows;
- field->buf = oldbuf;
- if (( single_line_field &&
- (field->dcols!=field->maxgrow)) ||
- (!single_line_field &&
- (field->drows!=field->maxgrow)))
- field->status |= _MAY_GROW;
- free( newbuf );
- return FALSE;
+#if USE_WIDEC_SUPPORT && NCURSES_EXT_FUNCS
+ if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
+ result = FALSE;
+#endif
+
+ if (need_visual_update && result)
+ {
+ WINDOW *new_window = newpad(field->drows, field->dcols);
+
+ if (new_window != 0)
+ {
+ assert(form != (FORM *)0);
+ if (form->w)
+ delwin(form->w);
+ form->w = new_window;
+ Set_Field_Window_Attributes(field, form->w);
+ werase(form->w);
+ Buffer_To_Window(field, form->w);
+ untouchwin(form->w);
+ wmove(form->w, form->currow, form->curcol);
}
- assert(form!=(FORM *)0);
- delwin(form->w);
- form->w = new_window;
- Set_Field_Window_Attributes(field,form->w);
- werase(form->w);
- Buffer_To_Window(field,form->w);
- untouchwin(form->w);
- wmove(form->w,form->currow,form->curcol);
+ else
+ result = FALSE;
}
- free(oldbuf);
- /* reflect changes in linked fields */
- if (field != field->link)
+ if (result)
{
- FIELD *linked_field;
- for(linked_field = field->link;
- linked_field!= field;
- linked_field = linked_field->link)
+ free(oldbuf);
+ /* reflect changes in linked fields */
+ if (field != field->link)
{
- linked_field->buf = field->buf;
- linked_field->drows = field->drows;
- linked_field->dcols = field->dcols;
+ FIELD *linked_field;
+
+ for (linked_field = field->link;
+ linked_field != field;
+ linked_field = linked_field->link)
+ {
+ linked_field->buf = field->buf;
+ linked_field->drows = field->drows;
+ linked_field->dcols = field->dcols;
+ }
}
}
- result = TRUE;
- }
+ else
+ {
+ /* restore old state */
+ field->dcols = old_dcols;
+ field->drows = old_drows;
+ field->buf = oldbuf;
+ if ((single_line_field &&
+ (field->dcols != field->maxgrow)) ||
+ (!single_line_field &&
+ (field->drows != field->maxgrow)))
+ field->status |= _MAY_GROW;
+ free(newbuf);
+ }
+ }
}
- return(result);
+ return (result);
}
+#ifdef NCURSES_MOUSE_VERSION
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
+| Function : int Field_encloses(FIELD *field, int ry, int rx)
+|
+| Description : Check if the given coordinates lie within the given field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_SYSTEM_ERROR - form has no current field or
+| field-window
++--------------------------------------------------------------------------*/
+static int
+Field_encloses(FIELD *field, int ry, int rx)
+{
+ T((T_CALLED("Field_encloses(%p)"), field));
+ if (field != 0
+ && field->frow <= ry
+ && (field->frow + field->rows) > ry
+ && field->fcol <= rx
+ && (field->fcol + field->cols) > rx)
+ {
+ RETURN(E_OK);
+ }
+ RETURN(E_INVALID_FIELD);
+}
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
| Function : int _nc_Position_Form_Cursor(FORM * form)
-|
+|
| Description : Position the cursor in the window for the current
-| field to be in sync. with the currow and curcol
+| field to be in sync. with the currow and curcol
| values.
|
| Return Values : E_OK - success
@@ -561,39 +779,39 @@ static bool Field_Grown(FIELD * field, int amount)
| field-window
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Position_Form_Cursor (FORM * form)
+_nc_Position_Form_Cursor(FORM *form)
{
- FIELD *field;
+ FIELD *field;
WINDOW *formwin;
-
+
if (!form)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
- if (!form->w || !form->current)
- return(E_SYSTEM_ERROR);
+ if (!form->w || !form->current)
+ return (E_SYSTEM_ERROR);
- field = form->current;
- formwin = Get_Form_Window(form);
+ field = form->current;
+ formwin = Get_Form_Window(form);
- wmove( form->w, form->currow, form->curcol );
- if ( Has_Invisible_Parts(field) )
+ wmove(form->w, form->currow, form->curcol);
+ if (Has_Invisible_Parts(field))
{
/* in this case fieldwin isn't derived from formwin, so we have
- to move the cursor in formwin by hand... */
+ to move the cursor in formwin by hand... */
wmove(formwin,
field->frow + form->currow - form->toprow,
field->fcol + form->curcol - form->begincol);
wcursyncup(formwin);
}
- else
+ else
wcursyncup(form->w);
- return(E_OK);
+ return (E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Refresh_Current_Field(FORM * form)
-|
+|
| Description : Propagate the changes in the fields window to the
| window of the form.
|
@@ -602,19 +820,21 @@ _nc_Position_Form_Cursor (FORM * form)
| E_SYSTEM_ERROR - general error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Refresh_Current_Field (FORM * form)
+_nc_Refresh_Current_Field(FORM *form)
{
WINDOW *formwin;
- FIELD *field;
+ FIELD *field;
+
+ T((T_CALLED("_nc_Refresh_Current_Field(%p)"), form));
if (!form)
RETURN(E_BAD_ARGUMENT);
- if (!form->w || !form->current)
+ if (!form->w || !form->current)
RETURN(E_SYSTEM_ERROR);
- field = form->current;
- formwin = Get_Form_Window(form);
+ field = form->current;
+ formwin = Get_Form_Window(form);
if (field->opts & O_PUBLIC)
{
@@ -623,13 +843,14 @@ _nc_Refresh_Current_Field (FORM * form)
/* Again, in this case the fieldwin isn't derived from formwin,
so we have to perform a copy operation. */
if (Single_Line_Field(field))
- { /* horizontal scrolling */
+ {
+ /* horizontal scrolling */
if (form->curcol < form->begincol)
- form->begincol = form->curcol;
+ form->begincol = form->curcol;
else
{
if (form->curcol >= (form->begincol + field->cols))
- form->begincol = form->curcol - field->cols + 1;
+ form->begincol = form->curcol - field->cols + 1;
}
copywin(form->w,
formwin,
@@ -642,8 +863,9 @@ _nc_Refresh_Current_Field (FORM * form)
0);
}
else
- { /* A multiline, i.e. vertical scrolling field */
- int row_after_bottom,first_modified_row,first_unmodified_row;
+ {
+ /* A multi-line, i.e. vertical scrolling field */
+ int row_after_bottom, first_modified_row, first_unmodified_row;
if (field->drows > field->rows)
{
@@ -659,25 +881,27 @@ _nc_Refresh_Current_Field (FORM * form)
field->status |= _NEWTOP;
}
if (field->status & _NEWTOP)
- { /* means we have to copy whole range */
+ {
+ /* means we have to copy whole range */
first_modified_row = form->toprow;
first_unmodified_row = first_modified_row + field->rows;
field->status &= ~_NEWTOP;
}
- else
- { /* we try to optimize : finding the range of touched
- lines */
+ else
+ {
+ /* we try to optimize : finding the range of touched
+ lines */
first_modified_row = form->toprow;
- while(first_modified_row < row_after_bottom)
+ while (first_modified_row < row_after_bottom)
{
- if (is_linetouched(form->w,first_modified_row))
+ if (is_linetouched(form->w, first_modified_row))
break;
first_modified_row++;
}
first_unmodified_row = first_modified_row;
- while(first_unmodified_row < row_after_bottom)
+ while (first_unmodified_row < row_after_bottom)
{
- if (!is_linetouched(form->w,first_unmodified_row))
+ if (!is_linetouched(form->w, first_unmodified_row))
break;
first_unmodified_row++;
}
@@ -685,7 +909,7 @@ _nc_Refresh_Current_Field (FORM * form)
}
else
{
- first_modified_row = form->toprow;
+ first_modified_row = form->toprow;
first_unmodified_row = first_modified_row + field->rows;
}
if (first_unmodified_row != first_modified_row)
@@ -702,45 +926,47 @@ _nc_Refresh_Current_Field (FORM * form)
wsyncup(formwin);
}
else
- { /* if the field-window is simply a derived window, i.e. contains
- no invisible parts, the whole thing is trivial
- */
+ {
+ /* if the field-window is simply a derived window, i.e. contains no
+ * invisible parts, the whole thing is trivial
+ */
wsyncup(form->w);
}
}
untouchwin(form->w);
- return _nc_Position_Form_Cursor(form);
+ returnCode(_nc_Position_Form_Cursor(form));
}
-
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Perform_Justification(
| FIELD * field,
| WINDOW * win)
-|
-| Description : Output field with requested justification
+|
+| Description : Output field with requested justification
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Perform_Justification(FIELD * field, WINDOW * win)
+static void
+Perform_Justification(FIELD *field, WINDOW *win)
{
- char *bp;
+ FIELD_CELL *bp;
int len;
- int col = 0;
+ int col = 0;
- bp = Get_Start_Of_Data(field->buf,Buffer_Length(field));
- len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field)) - bp);
+ bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+ len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
- if (len>0)
+ if (len > 0)
{
assert(win && (field->drows == 1) && (field->dcols == field->cols));
- switch(field->just)
+ switch (field->just)
{
case JUSTIFY_LEFT:
break;
case JUSTIFY_CENTER:
- col = (field->cols - len)/2;
+ col = (field->cols - len) / 2;
break;
case JUSTIFY_RIGHT:
col = field->cols - len;
@@ -749,77 +975,79 @@ static void Perform_Justification(FIELD * field, WINDOW * win)
break;
}
- wmove(win,0,col);
- waddnstr(win,bp,len);
+ wmove(win, 0, col);
+ myADDNSTR(win, bp, len);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Undo_Justification(
| FIELD * field,
| WINDOW * win)
-|
+|
| Description : Display field without any justification, i.e.
| left justified
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Undo_Justification(FIELD * field, WINDOW * win)
+static void
+Undo_Justification(FIELD *field, WINDOW *win)
{
- char *bp;
+ FIELD_CELL *bp;
int len;
- bp = Get_Start_Of_Data(field->buf,Buffer_Length(field));
- len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field))-bp);
+ bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+ len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
- if (len>0)
+ if (len > 0)
{
assert(win);
- wmove(win,0,0);
- waddnstr(win,bp,len);
+ wmove(win, 0, 0);
+ myADDNSTR(win, bp, len);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Check_Char(
| FIELDTYPE * typ,
| int ch,
| TypeArgument *argp)
-|
+|
| Description : Perform a single character check for character ch
-| according to the fieldtype instance.
+| according to the fieldtype instance.
|
| Return Values : TRUE - Character is valid
| FALSE - Character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp)
+static bool
+Check_Char(FIELDTYPE *typ, int ch, TypeArgument *argp)
{
- if (typ)
+ if (typ)
{
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Check_Char(typ->left ,ch,argp->left ) ||
- Check_Char(typ->right,ch,argp->right) );
- }
- else
+ return (
+ Check_Char(typ->left, ch, argp->left) ||
+ Check_Char(typ->right, ch, argp->right));
+ }
+ else
{
if (typ->ccheck)
- return typ->ccheck(ch,(void *)argp);
+ return typ->ccheck(ch, (void *)argp);
}
}
- return (isprint((unsigned char)ch) ? TRUE : FALSE);
+ return (!iscntrl(UChar(ch)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Display_Or_Erase_Field(
| FIELD * field,
| bool bEraseFlag)
-|
+|
| Description : Create a subwindow for the field and display the
| buffer contents (apply justification if required)
| or simply erase the field.
@@ -827,7 +1055,8 @@ static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp)
| Return Values : E_OK - on success
| E_SYSTEM_ERROR - some error (typical no memory)
+--------------------------------------------------------------------------*/
-static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
+static int
+Display_Or_Erase_Field(FIELD *field, bool bEraseFlag)
{
WINDOW *win;
WINDOW *fwin;
@@ -836,17 +1065,17 @@ static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
return E_SYSTEM_ERROR;
fwin = Get_Form_Window(field->form);
- win = derwin(fwin,
- field->rows,field->cols,field->frow,field->fcol);
+ win = derwin(fwin,
+ field->rows, field->cols, field->frow, field->fcol);
- if (!win)
+ if (!win)
return E_SYSTEM_ERROR;
else
{
if (field->opts & O_VISIBLE)
- Set_Field_Window_Attributes(field,win);
+ Set_Field_Window_Attributes(field, win);
else
- wattrset(win,getattrs(fwin));
+ wattrset(win, WINDOW_ATTRS(fwin));
werase(win);
}
@@ -855,9 +1084,9 @@ static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
if (field->opts & O_PUBLIC)
{
if (Justification_Allowed(field))
- Perform_Justification(field,win);
+ Perform_Justification(field, win);
else
- Buffer_To_Window(field,win);
+ Buffer_To_Window(field, win);
}
field->status &= ~_NEWTOP;
}
@@ -871,176 +1100,186 @@ static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
#define Erase_Field(field) Display_Or_Erase_Field(field,TRUE)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Synchronize_Field(FIELD * field)
-|
+|
| Description : Synchronize the windows content with the value in
| the buffer.
|
| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
+| E_BAD_ARGUMENT - invalid field pointer
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
-static int Synchronize_Field(FIELD * field)
+static int
+Synchronize_Field(FIELD *field)
{
FORM *form;
int res = E_OK;
if (!field)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
- if (((form=field->form) != (FORM *)0)
+ if (((form = field->form) != (FORM *)0)
&& Field_Really_Appears(field))
{
if (field == form->current)
- {
- form->currow = form->curcol = form->toprow = form->begincol = 0;
+ {
+ form->currow = form->curcol = form->toprow = form->begincol = 0;
werase(form->w);
-
- if ( (field->opts & O_PUBLIC) && Justification_Allowed(field) )
- Undo_Justification( field, form->w );
+
+ if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
+ Undo_Justification(field, form->w);
else
- Buffer_To_Window( field, form->w );
-
+ Buffer_To_Window(field, form->w);
+
field->status |= _NEWTOP;
- res = _nc_Refresh_Current_Field( form );
+ res = _nc_Refresh_Current_Field(form);
}
else
- res = Display_Field( field );
+ res = Display_Field(field);
}
field->status |= _CHANGED;
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Synchronize_Linked_Fields(FIELD * field)
-|
+|
| Description : Propagate the Synchronize_Field function to all linked
| fields. The first error that occurs in the sequence
-| of updates is the returnvalue.
+| of updates is the return value.
|
| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
+| E_BAD_ARGUMENT - invalid field pointer
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
-static int Synchronize_Linked_Fields(FIELD * field)
+static int
+Synchronize_Linked_Fields(FIELD *field)
{
FIELD *linked_field;
int res = E_OK;
int syncres;
if (!field)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
if (!field->link)
- return(E_SYSTEM_ERROR);
+ return (E_SYSTEM_ERROR);
- for(linked_field = field->link;
- linked_field!= field;
- linked_field = linked_field->link )
+ for (linked_field = field->link;
+ linked_field != field;
+ linked_field = linked_field->link)
{
- if (((syncres=Synchronize_Field(linked_field)) != E_OK) &&
- (res==E_OK))
+ if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
+ (res == E_OK))
res = syncres;
}
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Synchronize_Attributes(FIELD * field)
-|
+|
| Description : If a fields visual attributes have changed, this
| routine is called to propagate those changes to the
-| screen.
+| screen.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid field pointer
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Synchronize_Attributes (FIELD * field)
+_nc_Synchronize_Attributes(FIELD *field)
{
FORM *form;
int res = E_OK;
WINDOW *formwin;
+ T((T_CALLED("_nc_Synchronize_Attributes(%p)"), field));
+
if (!field)
- return(E_BAD_ARGUMENT);
+ returnCode(E_BAD_ARGUMENT);
- if (((form=field->form) != (FORM *)0)
+ CHECKPOS(field->form);
+ if (((form = field->form) != (FORM *)0)
&& Field_Really_Appears(field))
- {
- if (form->current==field)
+ {
+ if (form->current == field)
{
Synchronize_Buffer(form);
- Set_Field_Window_Attributes(field,form->w);
+ Set_Field_Window_Attributes(field, form->w);
werase(form->w);
+ wmove(form->w, form->currow, form->curcol);
+
if (field->opts & O_PUBLIC)
{
if (Justification_Allowed(field))
- Undo_Justification(field,form->w);
- else
- Buffer_To_Window(field,form->w);
+ Undo_Justification(field, form->w);
+ else
+ Buffer_To_Window(field, form->w);
}
- else
+ else
{
- formwin = Get_Form_Window(form);
- copywin(form->w,formwin,
- 0,0,
- field->frow,field->fcol,
- field->rows-1,field->cols-1,0);
+ formwin = Get_Form_Window(form);
+ copywin(form->w, formwin,
+ 0, 0,
+ field->frow, field->fcol,
+ field->rows - 1, field->cols - 1, 0);
wsyncup(formwin);
- Buffer_To_Window(field,form->w);
- field->status |= _NEWTOP; /* fake refresh to paint all */
+ Buffer_To_Window(field, form->w);
+ field->status |= _NEWTOP; /* fake refresh to paint all */
_nc_Refresh_Current_Field(form);
}
}
- else
+ else
{
res = Display_Field(field);
}
}
- return(res);
+ CHECKPOS(form);
+ returnCode(res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Synchronize_Options(FIELD * field,
| Field_Options newopts)
-|
+|
| Description : If a fields options have changed, this routine is
| called to propagate these changes to the screen and
-| to really change the behaviour of the field.
+| to really change the behavior of the field.
|
| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
+| E_BAD_ARGUMENT - invalid field pointer
+| E_CURRENT - field is the current one
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Synchronize_Options
-(FIELD *field, Field_Options newopts)
+_nc_Synchronize_Options(FIELD *field, Field_Options newopts)
{
Field_Options oldopts;
Field_Options changed_opts;
FORM *form;
int res = E_OK;
+ T((T_CALLED("_nc_Synchronize_Options(%p,%#x)"), field, newopts));
+
if (!field)
- return(E_BAD_ARGUMENT);
+ returnCode(E_BAD_ARGUMENT);
- oldopts = field->opts;
+ oldopts = field->opts;
changed_opts = oldopts ^ newopts;
- field->opts = newopts;
- form = field->form;
+ field->opts = newopts;
+ form = field->form;
if (form)
{
if (form->current == field)
{
field->opts = oldopts;
- return(E_CURRENT);
+ returnCode(E_CURRENT);
}
if (form->status & _POSTED)
@@ -1070,12 +1309,13 @@ _nc_Synchronize_Options
int res2 = E_OK;
if (newopts & O_STATIC)
- { /* the field becomes now static */
+ {
+ /* the field becomes now static */
field->status &= ~_MAY_GROW;
/* if actually we have no hidden columns, justification may
occur again */
- if (single_line_field &&
- (field->cols == field->dcols) &&
+ if (single_line_field &&
+ (field->cols == field->dcols) &&
(field->just != NO_JUSTIFICATION) &&
Field_Really_Appears(field))
{
@@ -1083,62 +1323,65 @@ _nc_Synchronize_Options
}
}
else
- { /* field is no longer static */
- if ((field->maxgrow==0) ||
- ( single_line_field && (field->dcols < field->maxgrow)) ||
+ {
+ /* field is no longer static */
+ if ((field->maxgrow == 0) ||
+ (single_line_field && (field->dcols < field->maxgrow)) ||
(!single_line_field && (field->drows < field->maxgrow)))
{
field->status |= _MAY_GROW;
- /* a field with justification now changes its behaviour,
- so we must redisplay it */
- if (single_line_field &&
+ /* a field with justification now changes its behavior,
+ so we must redisplay it */
+ if (single_line_field &&
(field->just != NO_JUSTIFICATION) &&
Field_Really_Appears(field))
{
res2 = Display_Field(field);
- }
- }
+ }
+ }
}
if (res2 != E_OK)
res = res2;
}
- return(res);
+ returnCode(res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Set_Current_Field(FORM * form,
| FIELD * newfield)
-|
+|
| Description : Make the newfield the new current field.
|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid form or field pointer
-| E_SYSTEM_ERROR - some severe basic error
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form or field pointer
+| E_SYSTEM_ERROR - some severe basic error
+| E_NOT_CONNECTED - no fields are connected to the form
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Set_Current_Field
-(FORM *form, FIELD *newfield)
+_nc_Set_Current_Field(FORM *form, FIELD *newfield)
{
- FIELD *field;
+ FIELD *field;
WINDOW *new_window;
- if (!form || !newfield || !form->current || (newfield->form!=form))
- return(E_BAD_ARGUMENT);
+ T((T_CALLED("_nc_Set_Current_Field(%p,%p)"), form, newfield));
+
+ if (!form || !newfield || !form->current || (newfield->form != form))
+ returnCode(E_BAD_ARGUMENT);
- if ( (form->status & _IN_DRIVER) )
- return(E_BAD_STATE);
+ if ((form->status & _IN_DRIVER))
+ returnCode(E_BAD_STATE);
if (!(form->field))
- return(E_NOT_CONNECTED);
+ returnCode(E_NOT_CONNECTED);
field = form->current;
-
- if ((field!=newfield) ||
+
+ if ((field != newfield) ||
!(form->status & _POSTED))
{
- if ((form->w) &&
+ if ((form->w) &&
(field->opts & O_VISIBLE) &&
(field->form->curpage == field->page))
{
@@ -1147,52 +1390,57 @@ _nc_Set_Current_Field
{
if (field->drows > field->rows)
{
- if (form->toprow==0)
+ if (form->toprow == 0)
field->status &= ~_NEWTOP;
- else
+ else
field->status |= _NEWTOP;
- }
- else
+ }
+ else
{
if (Justification_Allowed(field))
{
- Window_To_Buffer(form->w,field);
+ Window_To_Buffer(form->w, field);
werase(form->w);
- Perform_Justification(field,form->w);
+ Perform_Justification(field, form->w);
wsyncup(form->w);
}
}
}
delwin(form->w);
+ form->w = (WINDOW *)0;
}
-
+
field = newfield;
if (Has_Invisible_Parts(field))
- new_window = newpad(field->drows,field->dcols);
- else
+ new_window = newpad(field->drows, field->dcols);
+ else
new_window = derwin(Get_Form_Window(form),
- field->rows,field->cols,field->frow,field->fcol);
+ field->rows, field->cols, field->frow, field->fcol);
- if (!new_window)
- return(E_SYSTEM_ERROR);
+ if (!new_window)
+ returnCode(E_SYSTEM_ERROR);
form->current = field;
- form->w = new_window;
+
+ if (form->w)
+ delwin(form->w);
+ form->w = new_window;
+
form->status &= ~_WINDOW_MODIFIED;
- Set_Field_Window_Attributes(field,form->w);
+ Set_Field_Window_Attributes(field, form->w);
if (Has_Invisible_Parts(field))
{
werase(form->w);
- Buffer_To_Window(field,form->w);
- }
- else
+ Buffer_To_Window(field, form->w);
+ }
+ else
{
if (Justification_Allowed(field))
{
werase(form->w);
- Undo_Justification(field,form->w);
+ Undo_Justification(field, form->w);
wsyncup(form->w);
}
}
@@ -1201,417 +1449,461 @@ _nc_Set_Current_Field
}
form->currow = form->curcol = form->toprow = form->begincol = 0;
- return(E_OK);
+ returnCode(E_OK);
}
-
+
/*----------------------------------------------------------------------------
Intra-Field Navigation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Next_Character(FORM * form)
-|
-| Description : Move to the next character in the field. In a multiline
+|
+| Description : Move to the next character in the field. In a multi-line
| field this wraps at the end of the line.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the rightmost position
+--------------------------------------------------------------------------*/
-static int IFN_Next_Character(FORM * form)
+static int
+IFN_Next_Character(FORM *form)
{
FIELD *field = form->current;
-
- if ((++(form->curcol))==field->dcols)
+ int step = myWCWIDTH(form->w, form->currow, form->curcol);
+
+ T((T_CALLED("IFN_Next_Character(%p)"), form));
+ if ((form->curcol += step) == field->dcols)
{
- if ((++(form->currow))==field->drows)
+ if ((++(form->currow)) == field->drows)
{
#if GROW_IF_NAVIGATE
- if (!Single_Line_Field(field) && Field_Grown(field,1)) {
- form->curcol = 0;
- return(E_OK);
- }
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ {
+ form->curcol = 0;
+ returnCode(E_OK);
+ }
#endif
form->currow--;
#if GROW_IF_NAVIGATE
- if (Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+ if (Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
- form->curcol--;
- return(E_REQUEST_DENIED);
+ form->curcol -= step;
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = 0;
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Previous_Character(FORM * form)
-|
-| Description : Move to the previous character in the field. In a
-| multiline field this wraps and the beginning of the
+|
+| Description : Move to the previous character in the field. In a
+| multi-line field this wraps and the beginning of the
| line.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the leftmost position
+--------------------------------------------------------------------------*/
-static int IFN_Previous_Character(FORM * form)
+static int
+IFN_Previous_Character(FORM *form)
{
- if ((--(form->curcol))<0)
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Previous_Character(%p)"), form));
+ if ((form->curcol -= amount) < 0)
{
- if ((--(form->currow))<0)
+ if ((--(form->currow)) < 0)
{
form->currow++;
- form->curcol++;
- return(E_REQUEST_DENIED);
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = form->current->dcols - 1;
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Next_Line(FORM * form)
-|
+|
| Description : Move to the beginning of the next line in the field
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the last line
+--------------------------------------------------------------------------*/
-static int IFN_Next_Line(FORM * form)
+static int
+IFN_Next_Line(FORM *form)
{
FIELD *field = form->current;
- if ((++(form->currow))==field->drows)
+ T((T_CALLED("IFN_Next_Line(%p)"), form));
+ if ((++(form->currow)) == field->drows)
{
#if GROW_IF_NAVIGATE
- if (!Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
form->currow--;
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = 0;
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Previous_Line(FORM * form)
-|
+|
| Description : Move to the beginning of the previous line in the field
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the first line
+--------------------------------------------------------------------------*/
-static int IFN_Previous_Line(FORM * form)
+static int
+IFN_Previous_Line(FORM *form)
{
- if ( (--(form->currow)) < 0 )
+ T((T_CALLED("IFN_Previous_Line(%p)"), form));
+ if ((--(form->currow)) < 0)
{
form->currow++;
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = 0;
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Next_Word(FORM * form)
-|
+|
| Description : Move to the beginning of the next word in the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - there is no next word
+--------------------------------------------------------------------------*/
-static int IFN_Next_Word(FORM * form)
+static int
+IFN_Next_Word(FORM *form)
{
FIELD *field = form->current;
- char *bp = Address_Of_Current_Position_In_Buffer(form);
- char *s;
- char *t;
+ FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+ FIELD_CELL *s;
+ FIELD_CELL *t;
+
+ T((T_CALLED("IFN_Next_Word(%p)"), form));
/* We really need access to the data, so we have to synchronize */
Synchronize_Buffer(form);
/* Go to the first whitespace after the current position (including
- current position). This is then the startpoint to look for the
- next non-blank data */
- s = Get_First_Whitespace_Character(bp,Buffer_Length(field) -
+ current position). This is then the starting point to look for the
+ next non-blank data */
+ s = Get_First_Whitespace_Character(bp, Buffer_Length(field) -
(int)(bp - field->buf));
/* Find the start of the next word */
- t = Get_Start_Of_Data(s,Buffer_Length(field) -
+ t = Get_Start_Of_Data(s, Buffer_Length(field) -
(int)(s - field->buf));
#if !FRIENDLY_PREV_NEXT_WORD
- if (s==t)
- return(E_REQUEST_DENIED);
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
else
#endif
{
- Adjust_Cursor_Position(form,t);
- return(E_OK);
+ Adjust_Cursor_Position(form, t);
+ returnCode(E_OK);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Previous_Word(FORM * form)
-|
+|
| Description : Move to the beginning of the previous word in the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - there is no previous word
+--------------------------------------------------------------------------*/
-static int IFN_Previous_Word(FORM * form)
+static int
+IFN_Previous_Word(FORM *form)
{
FIELD *field = form->current;
- char *bp = Address_Of_Current_Position_In_Buffer(form);
- char *s;
- char *t;
- bool again = FALSE;
+ FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+ FIELD_CELL *s;
+ FIELD_CELL *t;
+ bool again = FALSE;
+
+ T((T_CALLED("IFN_Previous_Word(%p)"), form));
/* We really need access to the data, so we have to synchronize */
Synchronize_Buffer(form);
- s = After_End_Of_Data(field->buf,(int)(bp-field->buf));
+ s = After_End_Of_Data(field->buf, (int)(bp - field->buf));
/* s points now right after the last non-blank in the buffer before bp.
If bp was in a word, s equals bp. In this case we must find the last
whitespace in the buffer before bp and repeat the game to really find
the previous word! */
- if (s==bp)
+ if (s == bp)
again = TRUE;
-
+
/* And next call now goes backward to look for the last whitespace
before that, pointing right after this, so it points to the begin
- of the previous word.
- */
- t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
+ of the previous word.
+ */
+ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
#if !FRIENDLY_PREV_NEXT_WORD
- if (s==t)
- return(E_REQUEST_DENIED);
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
#endif
if (again)
- { /* and do it again, replacing bp by t */
- s = After_End_Of_Data(field->buf,(int)(t - field->buf));
- t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
+ {
+ /* and do it again, replacing bp by t */
+ s = After_End_Of_Data(field->buf, (int)(t - field->buf));
+ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
#if !FRIENDLY_PREV_NEXT_WORD
- if (s==t)
- return(E_REQUEST_DENIED);
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
#endif
}
- Adjust_Cursor_Position(form,t);
- return(E_OK);
+ Adjust_Cursor_Position(form, t);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Beginning_Of_Field(FORM * form)
-|
+|
| Description : Place the cursor at the first non-pad character in
-| the field.
+| the field.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_Beginning_Of_Field(FORM * form)
+static int
+IFN_Beginning_Of_Field(FORM *form)
{
FIELD *field = form->current;
+ T((T_CALLED("IFN_Beginning_Of_Field(%p)"), form));
Synchronize_Buffer(form);
Adjust_Cursor_Position(form,
- Get_Start_Of_Data(field->buf,Buffer_Length(field)));
- return(E_OK);
+ Get_Start_Of_Data(field->buf, Buffer_Length(field)));
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_End_Of_Field(FORM * form)
-|
+|
| Description : Place the cursor after the last non-pad character in
| the field. If the field occupies the last position in
-| the buffer, the cursos is positioned on the last
+| the buffer, the cursor is positioned on the last
| character.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_End_Of_Field(FORM * form)
+static int
+IFN_End_Of_Field(FORM *form)
{
FIELD *field = form->current;
- char *pos;
+ FIELD_CELL *pos;
+ T((T_CALLED("IFN_End_Of_Field(%p)"), form));
Synchronize_Buffer(form);
- pos = After_End_Of_Data(field->buf,Buffer_Length(field));
- if (pos==(field->buf + Buffer_Length(field)))
+ pos = After_End_Of_Data(field->buf, Buffer_Length(field));
+ if (pos == (field->buf + Buffer_Length(field)))
pos--;
- Adjust_Cursor_Position(form,pos);
- return(E_OK);
+ Adjust_Cursor_Position(form, pos);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Beginning_Of_Line(FORM * form)
-|
+|
| Description : Place the cursor on the first non-pad character in
| the current line of the field.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_Beginning_Of_Line(FORM * form)
+static int
+IFN_Beginning_Of_Line(FORM *form)
{
FIELD *field = form->current;
+ T((T_CALLED("IFN_Beginning_Of_Line(%p)"), form));
Synchronize_Buffer(form);
Adjust_Cursor_Position(form,
- Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
- field->dcols));
- return(E_OK);
+ Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
+ field->dcols));
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_End_Of_Line(FORM * form)
-|
+|
| Description : Place the cursor after the last non-pad character in the
-| current line of the field. If the field occupies the
+| current line of the field. If the field occupies the
| last column in the line, the cursor is positioned on the
| last character of the line.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_End_Of_Line(FORM * form)
+static int
+IFN_End_Of_Line(FORM *form)
{
FIELD *field = form->current;
- char *pos;
- char *bp;
+ FIELD_CELL *pos;
+ FIELD_CELL *bp;
+ T((T_CALLED("IFN_End_Of_Line(%p)"), form));
Synchronize_Buffer(form);
- bp = Address_Of_Current_Row_In_Buffer(form);
- pos = After_End_Of_Data(bp,field->dcols);
+ bp = Address_Of_Current_Row_In_Buffer(form);
+ pos = After_End_Of_Data(bp, field->dcols);
if (pos == (bp + field->dcols))
pos--;
- Adjust_Cursor_Position(form,pos);
- return(E_OK);
+ Adjust_Cursor_Position(form, pos);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Left_Character(FORM * form)
-|
+|
| Description : Move one character to the left in the current line.
-| This doesn't cycle.
+| This doesn't cycle.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in first column
+--------------------------------------------------------------------------*/
-static int IFN_Left_Character(FORM * form)
+static int
+IFN_Left_Character(FORM *form)
{
- if ( (--(form->curcol)) < 0 )
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Left_Character(%p)"), form));
+ if ((form->curcol -= amount) < 0)
{
- form->curcol++;
- return(E_REQUEST_DENIED);
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Right_Character(FORM * form)
-|
+|
| Description : Move one character to the right in the current line.
| This doesn't cycle.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in last column
+--------------------------------------------------------------------------*/
-static int IFN_Right_Character(FORM * form)
+static int
+IFN_Right_Character(FORM *form)
{
- if ( (++(form->curcol)) == form->current->dcols )
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Right_Character(%p)"), form));
+ if ((form->curcol += amount) >= form->current->dcols)
{
#if GROW_IF_NAVIGATE
FIELD *field = form->current;
- if (Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+
+ if (Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
- --(form->curcol);
- return(E_REQUEST_DENIED);
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Up_Character(FORM * form)
-|
+|
| Description : Move one line up. This doesn't cycle through the lines
| of the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in last column
+--------------------------------------------------------------------------*/
-static int IFN_Up_Character(FORM * form)
+static int
+IFN_Up_Character(FORM *form)
{
- if ( (--(form->currow)) < 0 )
+ T((T_CALLED("IFN_Up_Character(%p)"), form));
+ if ((--(form->currow)) < 0)
{
form->currow++;
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Down_Character(FORM * form)
-|
+|
| Description : Move one line down. This doesn't cycle through the
| lines of the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in last column
+--------------------------------------------------------------------------*/
-static int IFN_Down_Character(FORM * form)
+static int
+IFN_Down_Character(FORM *form)
{
FIELD *field = form->current;
- if ( (++(form->currow)) == field->drows )
+ T((T_CALLED("IFN_Down_Character(%p)"), form));
+ if ((++(form->currow)) == field->drows)
{
#if GROW_IF_NAVIGATE
- if (!Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
--(form->currow);
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*----------------------------------------------------------------------------
- END of Intra-Field Navigation routines
+ END of Intra-Field Navigation routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Vertical scrolling helper routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static int VSC_Generic(FORM *form, int lines)
+| Facility : libnform
+| Function : static int VSC_Generic(FORM *form, int nlines)
|
-| Description : Scroll multi-line field forward (lines>0) or
-| backward (lines<0) this many lines.
+| Description : Scroll multi-line field forward (nlines>0) or
+| backward (nlines<0) this many lines.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
| E_REQUEST_DENIED - can't scroll
+--------------------------------------------------------------------------*/
-static int VSC_Generic(FORM *form, int lines)
+static int
+VSC_Generic(FORM *form, int nlines)
{
FIELD *field = form->current;
int res = E_REQUEST_DENIED;
- int rows_to_go = (lines > 0 ? lines : -lines);
+ int rows_to_go = (nlines > 0 ? nlines : -nlines);
- if (lines > 0)
+ if (nlines > 0)
{
- if ( (rows_to_go + form->toprow) > (field->drows - field->rows) )
+ if ((rows_to_go + form->toprow) > (field->drows - field->rows))
rows_to_go = (field->drows - field->rows - form->toprow);
if (rows_to_go > 0)
@@ -1625,7 +1917,7 @@ static int VSC_Generic(FORM *form, int lines)
{
if (rows_to_go > form->toprow)
rows_to_go = form->toprow;
-
+
if (rows_to_go > 0)
{
form->currow -= rows_to_go;
@@ -1633,29 +1925,30 @@ static int VSC_Generic(FORM *form, int lines)
res = E_OK;
}
}
- return(res);
+ return (res);
}
/*----------------------------------------------------------------------------
End of Vertical scrolling helper routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Vertical scrolling routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Vertical_Scrolling(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Performs the generic vertical scrolling routines.
+|
+| Description : Performs the generic vertical scrolling routines.
| This has to check for a multi-line field and to set
-| the _NEWTOP flag if scrolling really occured.
+| the _NEWTOP flag if scrolling really occurred.
|
| Return Values : Propagated error code from low-level driver calls
+--------------------------------------------------------------------------*/
-static int Vertical_Scrolling(int (* const fct) (FORM *), FORM * form)
+static int
+Vertical_Scrolling(int (*const fct) (FORM *), FORM *form)
{
int res = E_REQUEST_DENIED;
@@ -1665,299 +1958,327 @@ static int Vertical_Scrolling(int (* const fct) (FORM *), FORM * form)
if (res == E_OK)
form->current->status |= _NEWTOP;
}
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Line_Forward(FORM * form)
-|
+|
| Description : Scroll multi-line field forward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Line_Forward(FORM * form)
+static int
+VSC_Scroll_Line_Forward(FORM *form)
{
- return VSC_Generic(form,1);
+ T((T_CALLED("VSC_Scroll_Line_Forward(%p)"), form));
+ returnCode(VSC_Generic(form, 1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Line_Backward(FORM * form)
-|
+|
| Description : Scroll multi-line field backward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Line_Backward(FORM * form)
+static int
+VSC_Scroll_Line_Backward(FORM *form)
{
- return VSC_Generic(form,-1);
+ T((T_CALLED("VSC_Scroll_Line_Backward(%p)"), form));
+ returnCode(VSC_Generic(form, -1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Page_Forward(FORM * form)
-|
+|
| Description : Scroll a multi-line field forward a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Page_Forward(FORM * form)
+static int
+VSC_Scroll_Page_Forward(FORM *form)
{
- return VSC_Generic(form,form->current->rows);
+ T((T_CALLED("VSC_Scroll_Page_Forward(%p)"), form));
+ returnCode(VSC_Generic(form, form->current->rows));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Half_Page_Forward(FORM * form)
-|
+|
| Description : Scroll a multi-line field forward half a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Half_Page_Forward(FORM * form)
+static int
+VSC_Scroll_Half_Page_Forward(FORM *form)
{
- return VSC_Generic(form,(form->current->rows + 1)/2);
+ T((T_CALLED("VSC_Scroll_Half_Page_Forward(%p)"), form));
+ returnCode(VSC_Generic(form, (form->current->rows + 1) / 2));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Page_Backward(FORM * form)
-|
+|
| Description : Scroll a multi-line field backward a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Page_Backward(FORM * form)
+static int
+VSC_Scroll_Page_Backward(FORM *form)
{
- return VSC_Generic(form, -(form->current->rows));
+ T((T_CALLED("VSC_Scroll_Page_Backward(%p)"), form));
+ returnCode(VSC_Generic(form, -(form->current->rows)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Half_Page_Backward(FORM * form)
-|
+|
| Description : Scroll a multi-line field backward half a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Half_Page_Backward(FORM * form)
+static int
+VSC_Scroll_Half_Page_Backward(FORM *form)
{
- return VSC_Generic(form, -((form->current->rows + 1)/2));
+ T((T_CALLED("VSC_Scroll_Half_Page_Backward(%p)"), form));
+ returnCode(VSC_Generic(form, -((form->current->rows + 1) / 2)));
}
/*----------------------------------------------------------------------------
End of Vertical scrolling routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Horizontal scrolling helper routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static int HSC_Generic(FORM *form, int columns)
+| Facility : libnform
+| Function : static int HSC_Generic(FORM *form, int ncolumns)
|
-| Description : Scroll single-line field forward (columns>0) or
-| backward (columns<0) this many columns.
+| Description : Scroll single-line field forward (ncolumns>0) or
+| backward (ncolumns<0) this many columns.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
| E_REQUEST_DENIED - can't scroll
+--------------------------------------------------------------------------*/
-static int HSC_Generic(FORM *form, int columns)
+static int
+HSC_Generic(FORM *form, int ncolumns)
{
FIELD *field = form->current;
int res = E_REQUEST_DENIED;
- int cols_to_go = (columns > 0 ? columns : -columns);
+ int cols_to_go = (ncolumns > 0 ? ncolumns : -ncolumns);
- if (columns > 0)
+ if (ncolumns > 0)
{
if ((cols_to_go + form->begincol) > (field->dcols - field->cols))
cols_to_go = field->dcols - field->cols - form->begincol;
-
+
if (cols_to_go > 0)
{
- form->curcol += cols_to_go;
+ form->curcol += cols_to_go;
form->begincol += cols_to_go;
res = E_OK;
}
}
else
{
- if ( cols_to_go > form->begincol )
+ if (cols_to_go > form->begincol)
cols_to_go = form->begincol;
if (cols_to_go > 0)
{
- form->curcol -= cols_to_go;
+ form->curcol -= cols_to_go;
form->begincol -= cols_to_go;
res = E_OK;
}
}
- return(res);
+ return (res);
}
/*----------------------------------------------------------------------------
End of Horizontal scrolling helper routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Horizontal scrolling routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Horizontal_Scrolling(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Performs the generic horizontal scrolling routines.
+|
+| Description : Performs the generic horizontal scrolling routines.
| This has to check for a single-line field.
|
| Return Values : Propagated error code from low-level driver calls
+--------------------------------------------------------------------------*/
-static int Horizontal_Scrolling(int (* const fct) (FORM *), FORM * form)
+static int
+Horizontal_Scrolling(int (*const fct) (FORM *), FORM *form)
{
if (Single_Line_Field(form->current))
return fct(form);
else
- return(E_REQUEST_DENIED);
+ return (E_REQUEST_DENIED);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Scroll_Char_Forward(FORM * form)
-|
+|
| Description : Scroll single-line field forward a character
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int HSC_Scroll_Char_Forward(FORM *form)
+static int
+HSC_Scroll_Char_Forward(FORM *form)
{
- return HSC_Generic(form,1);
+ T((T_CALLED("HSC_Scroll_Char_Forward(%p)"), form));
+ returnCode(HSC_Generic(form, 1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Scroll_Char_Backward(FORM * form)
-|
+|
| Description : Scroll single-line field backward a character
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int HSC_Scroll_Char_Backward(FORM *form)
+static int
+HSC_Scroll_Char_Backward(FORM *form)
{
- return HSC_Generic(form,-1);
+ T((T_CALLED("HSC_Scroll_Char_Backward(%p)"), form));
+ returnCode(HSC_Generic(form, -1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Line_Forward(FORM* form)
-|
+|
| Description : Scroll single-line field forward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Line_Forward(FORM * form)
+static int
+HSC_Horizontal_Line_Forward(FORM *form)
{
- return HSC_Generic(form,form->current->cols);
+ T((T_CALLED("HSC_Horizontal_Line_Forward(%p)"), form));
+ returnCode(HSC_Generic(form, form->current->cols));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Half_Line_Forward(FORM* form)
-|
+|
| Description : Scroll single-line field forward half a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Half_Line_Forward(FORM * form)
+static int
+HSC_Horizontal_Half_Line_Forward(FORM *form)
{
- return HSC_Generic(form,(form->current->cols + 1)/2);
+ T((T_CALLED("HSC_Horizontal_Half_Line_Forward(%p)"), form));
+ returnCode(HSC_Generic(form, (form->current->cols + 1) / 2));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Line_Backward(FORM* form)
-|
+|
| Description : Scroll single-line field backward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Line_Backward(FORM * form)
+static int
+HSC_Horizontal_Line_Backward(FORM *form)
{
- return HSC_Generic(form,-(form->current->cols));
+ T((T_CALLED("HSC_Horizontal_Line_Backward(%p)"), form));
+ returnCode(HSC_Generic(form, -(form->current->cols)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Half_Line_Backward(FORM* form)
-|
+|
| Description : Scroll single-line field backward half a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Half_Line_Backward(FORM * form)
+static int
+HSC_Horizontal_Half_Line_Backward(FORM *form)
{
- return HSC_Generic(form,-((form->current->cols + 1)/2));
+ T((T_CALLED("HSC_Horizontal_Half_Line_Backward(%p)"), form));
+ returnCode(HSC_Generic(form, -((form->current->cols + 1) / 2)));
}
/*----------------------------------------------------------------------------
End of Horizontal scrolling routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Field Editing
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Is_There_Room_For_A_Line(FORM * form)
-|
+|
| Description : Check whether or not there is enough room in the
| buffer to enter a whole line.
|
| Return Values : TRUE - there is enough space
| FALSE - there is not enough space
+--------------------------------------------------------------------------*/
-INLINE static bool Is_There_Room_For_A_Line(FORM * form)
+NCURSES_INLINE static bool
+Is_There_Room_For_A_Line(FORM *form)
{
FIELD *field = form->current;
- char *begin_of_last_line, *s;
-
+ FIELD_CELL *begin_of_last_line, *s;
+
Synchronize_Buffer(form);
- begin_of_last_line = Address_Of_Row_In_Buffer(field,(field->drows-1));
- s = After_End_Of_Data(begin_of_last_line,field->dcols);
- return ((s==begin_of_last_line) ? TRUE : FALSE);
+ begin_of_last_line = Address_Of_Row_In_Buffer(field, (field->drows - 1));
+ s = After_End_Of_Data(begin_of_last_line, field->dcols);
+ return ((s == begin_of_last_line) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
-|
+|
| Description : Checks whether or not there is room for a new character
| in the current line.
|
| Return Values : TRUE - there is room
| FALSE - there is not enough room (line full)
+--------------------------------------------------------------------------*/
-INLINE static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
+NCURSES_INLINE static bool
+Is_There_Room_For_A_Char_In_Line(FORM *form)
{
int last_char_in_line;
- wmove(form->w,form->currow,form->current->dcols-1);
- last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
- wmove(form->w,form->currow,form->curcol);
+ wmove(form->w, form->currow, form->current->dcols - 1);
+ last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
+ wmove(form->w, form->currow, form->curcol);
return (((last_char_in_line == form->current->pad) ||
is_blank(last_char_in_line)) ? TRUE : FALSE);
}
@@ -1966,85 +2287,90 @@ INLINE static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
!Is_There_Room_For_A_Char_In_Line(f)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Insert_String(
| FORM * form,
| int row,
| char *txt,
| int len )
-|
+|
| Description : Insert the 'len' characters beginning at pointer 'txt'
| into the 'row' of the 'form'. The insertion occurs
| on the beginning of the row, all other characters are
-| moved to the right. After the text a pad character will
+| moved to the right. After the text a pad character will
| be inserted to separate the text from the rest. If
| necessary the insertion moves characters on the next
| line to make place for the requested insertion string.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
| E_REQUEST_DENIED -
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-static int Insert_String(FORM *form, int row, char *txt, int len)
-{
- FIELD *field = form->current;
- char *bp = Address_Of_Row_In_Buffer(field,row);
- int datalen = (int)(After_End_Of_Data(bp,field->dcols) - bp);
- int freelen = field->dcols - datalen;
- int requiredlen = len+1;
- char *split;
+static int
+Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Row_In_Buffer(field, row);
+ int datalen = (int)(After_End_Of_Data(bp, field->dcols) - bp);
+ int freelen = field->dcols - datalen;
+ int requiredlen = len + 1;
+ FIELD_CELL *split;
int result = E_REQUEST_DENIED;
- const char *Space = " ";
if (freelen >= requiredlen)
{
- wmove(form->w,row,0);
- winsnstr(form->w,txt,len);
- wmove(form->w,row,len);
- winsnstr(form->w,Space,1);
+ wmove(form->w, row, 0);
+ myINSNSTR(form->w, txt, len);
+ wmove(form->w, row, len);
+ myINSNSTR(form->w, &myBLANK, 1);
return E_OK;
}
else
- { /* we have to move characters on the next line. If we are on the
- last line this may work, if the field is growable */
+ {
+ /* we have to move characters on the next line. If we are on the
+ last line this may work, if the field is growable */
if ((row == (field->drows - 1)) && Growable(field))
{
- if (!Field_Grown(field,1))
- return(E_SYSTEM_ERROR);
+ if (!Field_Grown(field, 1))
+ return (E_SYSTEM_ERROR);
/* !!!Side-Effect : might be changed due to growth!!! */
- bp = Address_Of_Row_In_Buffer(field,row);
+ bp = Address_Of_Row_In_Buffer(field, row);
}
- if (row < (field->drows - 1))
- {
- split = After_Last_Whitespace_Character(bp,
- (int)(Get_Start_Of_Data(bp + field->dcols - requiredlen ,
- requiredlen) - bp));
+ if (row < (field->drows - 1))
+ {
+ split =
+ After_Last_Whitespace_Character(bp,
+ (int)(Get_Start_Of_Data(bp
+ + field->dcols
+ - requiredlen,
+ requiredlen)
+ - bp));
/* split points now to the first character of the portion of the
line that must be moved to the next line */
- datalen = (int)(split-bp); /* + freelen has to stay on this line */
- freelen = field->dcols - (datalen + freelen); /* for the next line */
+ datalen = (int)(split - bp); /* + freelen has to stay on this line */
+ freelen = field->dcols - (datalen + freelen); /* for the next line */
- if ((result=Insert_String(form,row+1,split,freelen))==E_OK)
+ if ((result = Insert_String(form, row + 1, split, freelen)) == E_OK)
{
- wmove(form->w,row,datalen);
+ wmove(form->w, row, datalen);
wclrtoeol(form->w);
- wmove(form->w,row,0);
- winsnstr(form->w,txt,len);
- wmove(form->w,row,len);
- winsnstr(form->w,Space,1);
+ wmove(form->w, row, 0);
+ myINSNSTR(form->w, txt, len);
+ wmove(form->w, row, len);
+ myINSNSTR(form->w, &myBLANK, 1);
return E_OK;
}
}
- return(result);
+ return (result);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Wrapping_Not_Necessary_Or_Wrapping_Ok(
| FORM * form)
-|
+|
| Description : If a character has been entered into a field, it may
| be that wrapping has to occur. This routine checks
| whether or not wrapping is required and if so, performs
@@ -2055,40 +2381,43 @@ static int Insert_String(FORM *form, int row, char *txt, int len)
| E_REQUEST_DENIED -
| E_SYSTEM_ERROR - some system error
+--------------------------------------------------------------------------*/
-static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
+static int
+Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM *form)
{
- FIELD *field = form->current;
+ FIELD *field = form->current;
int result = E_REQUEST_DENIED;
bool Last_Row = ((field->drows - 1) == form->currow);
- if ( (field->opts & O_WRAP) && /* wrapping wanted */
- (!Single_Line_Field(field)) && /* must be multi-line */
- (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */
- (!Last_Row || Growable(field)) ) /* there are more lines*/
+ if ((field->opts & O_WRAP) && /* wrapping wanted */
+ (!Single_Line_Field(field)) && /* must be multi-line */
+ (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */
+ (!Last_Row || Growable(field))) /* there are more lines */
{
- char *bp;
- char *split;
+ FIELD_CELL *bp;
+ FIELD_CELL *split;
int chars_to_be_wrapped;
int chars_to_remain_on_line;
+
if (Last_Row)
- { /* the above logic already ensures, that in this case the field
+ {
+ /* the above logic already ensures, that in this case the field
is growable */
- if (!Field_Grown(field,1))
+ if (!Field_Grown(field, 1))
return E_SYSTEM_ERROR;
}
bp = Address_Of_Current_Row_In_Buffer(form);
- Window_To_Buffer(form->w,field);
- split = After_Last_Whitespace_Character(bp,field->dcols);
+ Window_To_Buffer(form->w, field);
+ split = After_Last_Whitespace_Character(bp, field->dcols);
/* split points to the first character of the sequence to be brought
on the next line */
chars_to_remain_on_line = (int)(split - bp);
- chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
+ chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
if (chars_to_remain_on_line > 0)
{
- if ((result=Insert_String(form,form->currow+1,split,
- chars_to_be_wrapped)) == E_OK)
+ if ((result = Insert_String(form, form->currow + 1, split,
+ chars_to_be_wrapped)) == E_OK)
{
- wmove(form->w,form->currow,chars_to_remain_on_line);
+ wmove(form->w, form->currow, chars_to_remain_on_line);
wclrtoeol(form->w);
if (form->curcol >= chars_to_remain_on_line)
{
@@ -2100,61 +2429,61 @@ static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
}
else
return E_OK;
- if (result!=E_OK)
+ if (result != E_OK)
{
- wmove(form->w,form->currow,form->curcol);
- wdelch(form->w);
- Window_To_Buffer(form->w,field);
+ DeleteChar(form);
+ Window_To_Buffer(form->w, field);
result = E_REQUEST_DENIED;
}
}
else
- result = E_OK; /* wrapping was not necessary */
- return(result);
+ result = E_OK; /* wrapping was not necessary */
+ return (result);
}
-
+
/*----------------------------------------------------------------------------
Field Editing routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Field_Editing(
| int (* const fct) (FORM *),
| FORM * form)
-|
+|
| Description : Generic routine for field editing requests. The driver
| routines are only called for editable fields, the
-| _WINDOW_MODIFIED flag is set if editing occured.
+| _WINDOW_MODIFIED flag is set if editing occurred.
| This is somewhat special due to the overload semantics
| of the NEW_LINE and DEL_PREV requests.
|
| Return Values : Error code from low level drivers.
+--------------------------------------------------------------------------*/
-static int Field_Editing(int (* const fct) (FORM *), FORM * form)
+static int
+Field_Editing(int (*const fct) (FORM *), FORM *form)
{
int res = E_REQUEST_DENIED;
- /* We have to deal here with the specific case of the overloaded
- behaviour of New_Line and Delete_Previous requests.
+ /* We have to deal here with the specific case of the overloaded
+ behavior of New_Line and Delete_Previous requests.
They may end up in navigational requests if we are on the first
character in a field. But navigation is also allowed on non-
editable fields.
- */
- if ((fct==FE_Delete_Previous) &&
- (form->opts & O_BS_OVERLOAD) &&
- First_Position_In_Current_Field(form) )
+ */
+ if ((fct == FE_Delete_Previous) &&
+ (form->opts & O_BS_OVERLOAD) &&
+ First_Position_In_Current_Field(form))
{
- res = Inter_Field_Navigation(FN_Previous_Field,form);
+ res = Inter_Field_Navigation(FN_Previous_Field, form);
}
else
{
- if (fct==FE_New_Line)
+ if (fct == FE_New_Line)
{
- if ((form->opts & O_NL_OVERLOAD) &&
+ if ((form->opts & O_NL_OVERLOAD) &&
First_Position_In_Current_Field(form))
{
- res = Inter_Field_Navigation(FN_Next_Field,form);
+ res = Inter_Field_Navigation(FN_Next_Field, form);
}
else
/* FE_New_Line deals itself with the _WINDOW_MODIFIED flag */
@@ -2166,7 +2495,7 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
if (form->current->opts & O_EDIT)
{
res = fct(form);
- if (res==E_OK)
+ if (res == E_OK)
form->status |= _WINDOW_MODIFIED;
}
}
@@ -2175,11 +2504,11 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_New_Line(FORM * form)
-|
+|
| Description : Perform a new line request. This is rather complex
-| compared to other routines in this code due to the
+| compared to other routines in this code due to the
| rather difficult to understand description in the
| manuals.
|
@@ -2187,130 +2516,141 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
| E_REQUEST_DENIED - new line not allowed
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-static int FE_New_Line(FORM * form)
+static int
+FE_New_Line(FORM *form)
{
- FIELD *field = form->current;
- char *bp, *t;
- bool Last_Row = ((field->drows - 1)==form->currow);
-
- if (form->status & _OVLMODE)
+ FIELD *field = form->current;
+ FIELD_CELL *bp, *t;
+ bool Last_Row = ((field->drows - 1) == form->currow);
+
+ T((T_CALLED("FE_New_Line(%p)"), form));
+ if (form->status & _OVLMODE)
{
- if (Last_Row &&
+ if (Last_Row &&
(!(Growable(field) && !Single_Line_Field(field))))
{
if (!(form->opts & O_NL_OVERLOAD))
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
/* we have to set this here, although it is also
handled in the generic routine. The reason is,
that FN_Next_Field may fail, but the form is
definitively changed */
form->status |= _WINDOW_MODIFIED;
- return Inter_Field_Navigation(FN_Next_Field,form);
+ returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
- else
+ else
{
- if (Last_Row && !Field_Grown(field,1))
- { /* N.B.: due to the logic in the 'if', LastRow==TRUE
- means here that the field is growable and not
- a single-line field */
- return(E_SYSTEM_ERROR);
+ if (Last_Row && !Field_Grown(field, 1))
+ {
+ /* N.B.: due to the logic in the 'if', LastRow==TRUE
+ means here that the field is growable and not
+ a single-line field */
+ returnCode(E_SYSTEM_ERROR);
}
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
form->currow++;
form->curcol = 0;
form->status |= _WINDOW_MODIFIED;
- return(E_OK);
+ returnCode(E_OK);
}
}
- else
- { /* Insert Mode */
+ else
+ {
+ /* Insert Mode */
if (Last_Row &&
!(Growable(field) && !Single_Line_Field(field)))
{
if (!(form->opts & O_NL_OVERLOAD))
- return(E_REQUEST_DENIED);
- return Inter_Field_Navigation(FN_Next_Field,form);
+ returnCode(E_REQUEST_DENIED);
+ returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
- else
+ else
{
bool May_Do_It = !Last_Row && Is_There_Room_For_A_Line(form);
-
+
if (!(May_Do_It || Growable(field)))
- return(E_REQUEST_DENIED);
- if (!May_Do_It && !Field_Grown(field,1))
- return(E_SYSTEM_ERROR);
-
- bp= Address_Of_Current_Position_In_Buffer(form);
- t = After_End_Of_Data(bp,field->dcols - form->curcol);
+ returnCode(E_REQUEST_DENIED);
+ if (!May_Do_It && !Field_Grown(field, 1))
+ returnCode(E_SYSTEM_ERROR);
+
+ bp = Address_Of_Current_Position_In_Buffer(form);
+ t = After_End_Of_Data(bp, field->dcols - form->curcol);
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
form->currow++;
- form->curcol=0;
- wmove(form->w,form->currow,form->curcol);
+ form->curcol = 0;
+ wmove(form->w, form->currow, form->curcol);
winsertln(form->w);
- waddnstr(form->w,bp,(int)(t-bp));
+ myADDNSTR(form->w, bp, (int)(t - bp));
form->status |= _WINDOW_MODIFIED;
- return E_OK;
+ returnCode(E_OK);
}
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Insert_Character(FORM * form)
-|
+|
| Description : Insert blank character at the cursor position
|
| Return Values : E_OK
| E_REQUEST_DENIED
+--------------------------------------------------------------------------*/
-static int FE_Insert_Character(FORM * form)
+static int
+FE_Insert_Character(FORM *form)
{
FIELD *field = form->current;
int result = E_REQUEST_DENIED;
- if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
+ T((T_CALLED("FE_Insert_Character(%p)"), form));
+ if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
{
bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
if (There_Is_Room ||
((Single_Line_Field(field) && Growable(field))))
{
- if (!There_Is_Room && !Field_Grown(field,1))
- result = E_SYSTEM_ERROR;
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ result = E_SYSTEM_ERROR;
else
{
- winsch(form->w,(chtype)C_BLANK);
+ winsch(form->w, (chtype)C_BLANK);
result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form);
}
}
}
- return result;
+ returnCode(result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Insert_Line(FORM * form)
-|
+|
| Description : Insert a blank line at the cursor position
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - line can not be inserted
+--------------------------------------------------------------------------*/
-static int FE_Insert_Line(FORM * form)
+static int
+FE_Insert_Line(FORM *form)
{
FIELD *field = form->current;
int result = E_REQUEST_DENIED;
- if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
+ T((T_CALLED("FE_Insert_Line(%p)"), form));
+ if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
{
- bool Maybe_Done = (form->currow!=(field->drows-1)) &&
- Is_There_Room_For_A_Line(form);
+ bool Maybe_Done = (form->currow != (field->drows - 1)) &&
+ Is_There_Room_For_A_Line(form);
if (!Single_Line_Field(field) &&
(Maybe_Done || Growable(field)))
{
- if (!Maybe_Done && !Field_Grown(field,1))
+ if (!Maybe_Done && !Field_Grown(field, 1))
result = E_SYSTEM_ERROR;
else
{
@@ -2320,27 +2660,29 @@ static int FE_Insert_Line(FORM * form)
}
}
}
- return result;
+ returnCode(result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Character(FORM * form)
-|
+|
| Description : Delete character at the cursor position
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Delete_Character(FORM * form)
+static int
+FE_Delete_Character(FORM *form)
{
- wdelch(form->w);
- return E_OK;
+ T((T_CALLED("FE_Delete_Character(%p)"), form));
+ DeleteChar(form);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Previous(FORM * form)
-|
+|
| Description : Delete character before cursor. Again this is a rather
| difficult piece compared to others due to the overloading
| semantics of backspace.
@@ -2350,301 +2692,353 @@ static int FE_Delete_Character(FORM * form)
| Return Values : E_OK - success
| E_REQUEST_DENIED - Character can't be deleted
+--------------------------------------------------------------------------*/
-static int FE_Delete_Previous(FORM * form)
+static int
+FE_Delete_Previous(FORM *form)
{
- FIELD *field = form->current;
-
+ FIELD *field = form->current;
+
+ T((T_CALLED("FE_Delete_Previous(%p)"), form));
if (First_Position_In_Current_Field(form))
- return E_REQUEST_DENIED;
+ returnCode(E_REQUEST_DENIED);
- if ( (--(form->curcol))<0 )
+ if ((--(form->curcol)) < 0)
{
- char *this_line, *prev_line, *prev_end, *this_end;
-
+ FIELD_CELL *this_line, *prev_line, *prev_end, *this_end;
+ int this_row = form->currow;
+
form->curcol++;
- if (form->status & _OVLMODE)
- return E_REQUEST_DENIED;
-
- prev_line = Address_Of_Row_In_Buffer(field,(form->currow-1));
- this_line = Address_Of_Row_In_Buffer(field,(form->currow));
+ if (form->status & _OVLMODE)
+ returnCode(E_REQUEST_DENIED);
+
+ prev_line = Address_Of_Row_In_Buffer(field, (form->currow - 1));
+ this_line = Address_Of_Row_In_Buffer(field, (form->currow));
Synchronize_Buffer(form);
- prev_end = After_End_Of_Data(prev_line,field->dcols);
- this_end = After_End_Of_Data(this_line,field->dcols);
- if ((int)(this_end-this_line) >
- (field->cols-(int)(prev_end-prev_line)))
- return E_REQUEST_DENIED;
+ prev_end = After_End_Of_Data(prev_line, field->dcols);
+ this_end = After_End_Of_Data(this_line, field->dcols);
+ if ((int)(this_end - this_line) >
+ (field->cols - (int)(prev_end - prev_line)))
+ returnCode(E_REQUEST_DENIED);
+ wmove(form->w, form->currow, form->curcol);
wdeleteln(form->w);
- Adjust_Cursor_Position(form,prev_end);
- wmove(form->w,form->currow,form->curcol);
- waddnstr(form->w,this_line,(int)(this_end-this_line));
- }
- else
+ Adjust_Cursor_Position(form, prev_end);
+ /*
+ * If we did not really move to the previous line, help the user a
+ * little. It is however a little inconsistent. Normally, when
+ * backspacing around the point where text wraps to a new line in a
+ * multi-line form, we absorb one keystroke for the wrapping point. That
+ * is consistent with SVr4 forms. However, SVr4 does not allow typing
+ * into the last column of the field, and requires the user to enter a
+ * newline to move to the next line. Therefore it can consistently eat
+ * that keystroke. Since ncurses allows the last column, it wraps
+ * automatically (given the proper options). But we cannot eat the
+ * keystroke to back over the wrapping point, since that would put the
+ * cursor past the end of the form field. In this case, just delete the
+ * character at the end of the field.
+ */
+ if (form->currow == this_row && this_row > 0)
+ {
+ form->currow -= 1;
+ form->curcol = field->dcols - 1;
+ DeleteChar(form);
+ }
+ else
+ {
+ wmove(form->w, form->currow, form->curcol);
+ myADDNSTR(form->w, this_line, (int)(this_end - this_line));
+ }
+ }
+ else
{
- wmove(form->w,form->currow,form->curcol);
- wdelch(form->w);
+ DeleteChar(form);
}
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Line(FORM * form)
-|
+|
| Description : Delete line at cursor position.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Delete_Line(FORM * form)
+static int
+FE_Delete_Line(FORM *form)
{
+ T((T_CALLED("FE_Delete_Line(%p)"), form));
form->curcol = 0;
wdeleteln(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Word(FORM * form)
-|
+|
| Description : Delete word at cursor position
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - failure
+--------------------------------------------------------------------------*/
-static int FE_Delete_Word(FORM * form)
+static int
+FE_Delete_Word(FORM *form)
{
- FIELD *field = form->current;
- char *bp = Address_Of_Current_Row_In_Buffer(form);
- char *ep = bp + field->dcols;
- char *cp = bp + form->curcol;
- char *s;
-
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Current_Row_In_Buffer(form);
+ FIELD_CELL *ep = bp + field->dcols;
+ FIELD_CELL *cp = bp + form->curcol;
+ FIELD_CELL *s;
+
+ T((T_CALLED("FE_Delete_Word(%p)"), form));
Synchronize_Buffer(form);
- if (is_blank(*cp))
- return E_REQUEST_DENIED; /* not in word */
+ if (ISBLANK(*cp))
+ returnCode(E_REQUEST_DENIED); /* not in word */
/* move cursor to begin of word and erase to end of screen-line */
Adjust_Cursor_Position(form,
- After_Last_Whitespace_Character(bp,form->curcol));
- wmove(form->w,form->currow,form->curcol);
+ After_Last_Whitespace_Character(bp, form->curcol));
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
/* skip over word in buffer */
- s = Get_First_Whitespace_Character(cp,(int)(ep-cp));
+ s = Get_First_Whitespace_Character(cp, (int)(ep - cp));
/* to begin of next word */
- s = Get_Start_Of_Data(s,(int)(ep - s));
- if ( (s!=cp) && !is_blank(*s))
+ s = Get_Start_Of_Data(s, (int)(ep - s));
+ if ((s != cp) && !ISBLANK(*s))
{
/* copy remaining line to window */
- waddnstr(form->w,s,(int)(s - After_End_Of_Data(s,(int)(ep - s))));
+ myADDNSTR(form->w, s, (int)(s - After_End_Of_Data(s, (int)(ep - s))));
}
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Clear_To_End_Of_Line(FORM * form)
-|
+|
| Description : Clear to end of current line.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Clear_To_End_Of_Line(FORM * form)
+static int
+FE_Clear_To_End_Of_Line(FORM *form)
{
+ T((T_CALLED("FE_Clear_To_End_Of_Line(%p)"), form));
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static int FE_Clear_To_End_Of_Form(FORM * form)
-|
-| Description : Clear to end of form.
+| Facility : libnform
+| Function : static int FE_Clear_To_End_Of_Field(FORM * form)
+|
+| Description : Clear to end of field.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Clear_To_End_Of_Form(FORM * form)
+static int
+FE_Clear_To_End_Of_Field(FORM *form)
{
+ T((T_CALLED("FE_Clear_To_End_Of_Field(%p)"), form));
+ wmove(form->w, form->currow, form->curcol);
wclrtobot(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Clear_Field(FORM * form)
-|
+|
| Description : Clear entire field.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Clear_Field(FORM * form)
+static int
+FE_Clear_Field(FORM *form)
{
+ T((T_CALLED("FE_Clear_Field(%p)"), form));
form->currow = form->curcol = 0;
werase(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*----------------------------------------------------------------------------
- END of Field Editing routines
+ END of Field Editing routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Edit Mode routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int EM_Overlay_Mode(FORM * form)
-|
+|
| Description : Switch to overlay mode.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int EM_Overlay_Mode(FORM * form)
+static int
+EM_Overlay_Mode(FORM *form)
{
+ T((T_CALLED("EM_Overlay_Mode(%p)"), form));
form->status |= _OVLMODE;
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int EM_Insert_Mode(FORM * form)
-|
+|
| Description : Switch to insert mode
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int EM_Insert_Mode(FORM * form)
+static int
+EM_Insert_Mode(FORM *form)
{
+ T((T_CALLED("EM_Insert_Mode(%p)"), form));
form->status &= ~_OVLMODE;
- return E_OK;
+ returnCode(E_OK);
}
/*----------------------------------------------------------------------------
- END of Edit Mode routines
+ END of Edit Mode routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Choice Requests
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Next_Choice(
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument *argp)
-|
+|
| Description : Get the next field choice. For linked types this is
| done recursively.
|
| Return Values : TRUE - next choice successfully retrieved
| FALSE - couldn't retrieve next choice
+--------------------------------------------------------------------------*/
-static bool Next_Choice(FIELDTYPE * typ, FIELD *field, TypeArgument *argp)
+static bool
+Next_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
- if (!typ || !(typ->status & _HAS_CHOICE))
+ if (!typ || !(typ->status & _HAS_CHOICE))
return FALSE;
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Next_Choice(typ->left ,field,argp->left) ||
- Next_Choice(typ->right,field,argp->right) );
- }
+ return (
+ Next_Choice(typ->left, field, argp->left) ||
+ Next_Choice(typ->right, field, argp->right));
+ }
else
{
assert(typ->next);
- return typ->next(field,(void *)argp);
+ return typ->next(field, (void *)argp);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Previous_Choice(
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument *argp)
-|
+|
| Description : Get the previous field choice. For linked types this
| is done recursively.
|
| Return Values : TRUE - previous choice successfully retrieved
| FALSE - couldn't retrieve previous choice
+--------------------------------------------------------------------------*/
-static bool Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+static bool
+Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
- if (!typ || !(typ->status & _HAS_CHOICE))
+ if (!typ || !(typ->status & _HAS_CHOICE))
return FALSE;
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Previous_Choice(typ->left ,field,argp->left) ||
- Previous_Choice(typ->right,field,argp->right));
- }
- else
+ return (
+ Previous_Choice(typ->left, field, argp->left) ||
+ Previous_Choice(typ->right, field, argp->right));
+ }
+ else
{
assert(typ->prev);
- return typ->prev(field,(void *)argp);
+ return typ->prev(field, (void *)argp);
}
}
/*----------------------------------------------------------------------------
End of Helper routines for Choice Requests
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Routines for Choice Requests
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int CR_Next_Choice(FORM * form)
-|
+|
| Description : Get the next field choice.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - next choice couldn't be retrieved
+--------------------------------------------------------------------------*/
-static int CR_Next_Choice(FORM * form)
+static int
+CR_Next_Choice(FORM *form)
{
FIELD *field = form->current;
+
+ T((T_CALLED("CR_Next_Choice(%p)"), form));
Synchronize_Buffer(form);
- return ((Next_Choice(field->type,field,(TypeArgument *)(field->arg))) ?
- E_OK : E_REQUEST_DENIED);
+ returnCode((Next_Choice(field->type, field, (TypeArgument *)(field->arg)))
+ ? E_OK
+ : E_REQUEST_DENIED);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int CR_Previous_Choice(FORM * form)
-|
+|
| Description : Get the previous field choice.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - prev. choice couldn't be retrieved
+--------------------------------------------------------------------------*/
-static int CR_Previous_Choice(FORM * form)
+static int
+CR_Previous_Choice(FORM *form)
{
FIELD *field = form->current;
+
+ T((T_CALLED("CR_Previous_Choice(%p)"), form));
Synchronize_Buffer(form);
- return ((Previous_Choice(field->type,field,(TypeArgument *)(field->arg))) ?
- E_OK : E_REQUEST_DENIED);
+ returnCode((Previous_Choice(field->type, field, (TypeArgument *)(field->arg)))
+ ? E_OK
+ : E_REQUEST_DENIED);
}
/*----------------------------------------------------------------------------
End of Routines for Choice Requests
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Field Validations.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Check_Field(
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument * argp)
-|
+|
| Description : Check the field according to its fieldtype and its
| actual arguments. For linked fieldtypes this is done
| recursively.
@@ -2652,59 +3046,63 @@ static int CR_Previous_Choice(FORM * form)
| Return Values : TRUE - field is valid
| FALSE - field is invalid.
+--------------------------------------------------------------------------*/
-static bool Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+static bool
+Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
if (typ)
{
if (field->opts & O_NULLOK)
{
- char *bp = field->buf;
+ FIELD_CELL *bp = field->buf;
+
assert(bp);
- while(is_blank(*bp))
- { bp++; }
- if (*bp == '\0')
+ while (ISBLANK(*bp))
+ {
+ bp++;
+ }
+ if (CharOf(*bp) == 0)
return TRUE;
}
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Check_Field(typ->left ,field,argp->left ) ||
- Check_Field(typ->right,field,argp->right) );
+ return (
+ Check_Field(typ->left, field, argp->left) ||
+ Check_Field(typ->right, field, argp->right));
}
- else
+ else
{
if (typ->fcheck)
- return typ->fcheck(field,(void *)argp);
+ return typ->fcheck(field, (void *)argp);
}
}
return TRUE;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : bool _nc_Internal_Validation(FORM * form )
-|
-| Description : Validate the current field of the form.
+|
+| Description : Validate the current field of the form.
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-_nc_Internal_Validation (FORM *form)
+_nc_Internal_Validation(FORM *form)
{
FIELD *field;
- field = form->current;
-
+ field = form->current;
+
Synchronize_Buffer(form);
if ((form->status & _FCHECK_REQUIRED) ||
(!(field->opts & O_PASSOK)))
{
- if (!Check_Field(field->type,field,(TypeArgument *)(field->arg)))
+ if (!Check_Field(field->type, field, (TypeArgument *)(field->arg)))
return FALSE;
- form->status &= ~_FCHECK_REQUIRED;
+ form->status &= ~_FCHECK_REQUIRED;
field->status |= _CHANGED;
Synchronize_Linked_Fields(field);
}
@@ -2713,67 +3111,71 @@ _nc_Internal_Validation (FORM *form)
/*----------------------------------------------------------------------------
End of Helper routines for Field Validations.
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Routines for Field Validation.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FV_Validation(FORM * form)
-|
+|
| Description : Validate the current field of the form.
|
| Return Values : E_OK - field valid
| E_INVALID_FIELD - field not valid
+--------------------------------------------------------------------------*/
-static int FV_Validation(FORM * form)
+static int
+FV_Validation(FORM *form)
{
+ T((T_CALLED("FV_Validation(%p)"), form));
if (_nc_Internal_Validation(form))
- return E_OK;
+ returnCode(E_OK);
else
- return E_INVALID_FIELD;
+ returnCode(E_INVALID_FIELD);
}
/*----------------------------------------------------------------------------
End of routines for Field Validation.
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Inter-Field Navigation
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Next_Field_On_Page(FIELD * field)
-|
-| Description : Get the next field after the given field on the current
+|
+| Description : Get the next field after the given field on the current
| page. The order of fields is the one defined by the
| fields array. Only visible and active fields are
| counted.
|
| Return Values : Pointer to the next field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Next_Field_On_Page(FIELD * field)
+NCURSES_INLINE static FIELD *
+Next_Field_On_Page(FIELD *field)
{
- FORM *form = field->form;
+ FORM *form = field->form;
FIELD **field_on_page = &form->field[field->index];
FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
- FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
do
{
- field_on_page =
- (field_on_page==last_on_page) ? first_on_page : field_on_page + 1;
+ field_on_page =
+ (field_on_page == last_on_page) ? first_on_page : field_on_page + 1;
if (Field_Is_Selectable(*field_on_page))
break;
- } while(field!=(*field_on_page));
- return(*field_on_page);
+ }
+ while (field != (*field_on_page));
+ return (*field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : FIELD* _nc_First_Active_Field(FORM * form)
-|
+|
| Description : Get the first active field on the current page,
| if there are such. If there are none, get the first
| visible field on the page. If there are also none,
@@ -2781,17 +3183,18 @@ INLINE static FIELD *Next_Field_On_Page(FIELD * field)
|
| Return Values : Pointer to calculated field.
+--------------------------------------------------------------------------*/
-NCURSES_EXPORT(FIELD*)
-_nc_First_Active_Field (FORM * form)
+NCURSES_EXPORT(FIELD *)
+_nc_First_Active_Field(FORM *form)
{
FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
FIELD *proposed = Next_Field_On_Page(*last_on_page);
if (proposed == *last_on_page)
- { /* there might be the special situation, where there is no
- active and visible field on the current page. We then select
- the first visible field on this readonly page
- */
+ {
+ /* there might be the special situation, where there is no
+ active and visible field on the current page. We then select
+ the first visible field on this readonly page
+ */
if (Field_Is_Not_Selectable(proposed))
{
FIELD **field = &form->field[proposed->index];
@@ -2799,66 +3202,71 @@ _nc_First_Active_Field (FORM * form)
do
{
- field = (field==last_on_page) ? first : field + 1;
+ field = (field == last_on_page) ? first : field + 1;
if (((*field)->opts & O_VISIBLE))
break;
- } while(proposed!=(*field));
-
+ }
+ while (proposed != (*field));
+
proposed = *field;
- if ((proposed == *last_on_page) && !(proposed->opts&O_VISIBLE))
- { /* This means, there is also no visible field on the page.
- So we propose the first one and hope the very best...
- Some very clever user has designed a readonly and invisible
- page on this form.
+ if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
+ {
+ /* This means, there is also no visible field on the page.
+ So we propose the first one and hope the very best...
+ Some very clever user has designed a readonly and invisible
+ page on this form.
*/
proposed = *first;
}
}
}
- return(proposed);
+ return (proposed);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Previous_Field_On_Page(FIELD * field)
-|
-| Description : Get the previous field before the given field on the
-| current page. The order of fields is the one defined by
+|
+| Description : Get the previous field before the given field on the
+| current page. The order of fields is the one defined by
| the fields array. Only visible and active fields are
| counted.
|
| Return Values : Pointer to the previous field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Previous_Field_On_Page(FIELD * field)
+NCURSES_INLINE static FIELD *
+Previous_Field_On_Page(FIELD *field)
{
- FORM *form = field->form;
+ FORM *form = field->form;
FIELD **field_on_page = &form->field[field->index];
FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
- FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
-
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+
do
{
- field_on_page =
- (field_on_page==first_on_page) ? last_on_page : field_on_page - 1;
+ field_on_page =
+ (field_on_page == first_on_page) ? last_on_page : field_on_page - 1;
if (Field_Is_Selectable(*field_on_page))
break;
- } while(field!=(*field_on_page));
-
+ }
+ while (field != (*field_on_page));
+
return (*field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Sorted_Next_Field(FIELD * field)
-|
-| Description : Get the next field after the given field on the current
+|
+| Description : Get the next field after the given field on the current
| page. The order of fields is the one defined by the
| (row,column) geometry, rows are major.
|
| Return Values : Pointer to the next field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Sorted_Next_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Sorted_Next_Field(FIELD *field)
{
FIELD *field_on_page = field;
@@ -2867,22 +3275,24 @@ INLINE static FIELD *Sorted_Next_Field(FIELD * field)
field_on_page = field_on_page->snext;
if (Field_Is_Selectable(field_on_page))
break;
- } while(field_on_page!=field);
-
+ }
+ while (field_on_page != field);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Sorted_Previous_Field(FIELD * field)
-|
-| Description : Get the previous field before the given field on the
-| current page. The order of fields is the one defined
+|
+| Description : Get the previous field before the given field on the
+| current page. The order of fields is the one defined
| by the (row,column) geometry, rows are major.
|
| Return Values : Pointer to the previous field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Sorted_Previous_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Sorted_Previous_Field(FIELD *field)
{
FIELD *field_on_page = field;
@@ -2891,73 +3301,79 @@ INLINE static FIELD *Sorted_Previous_Field(FIELD * field)
field_on_page = field_on_page->sprev;
if (Field_Is_Selectable(field_on_page))
break;
- } while(field_on_page!=field);
-
+ }
+ while (field_on_page != field);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Left_Neighbour_Field(FIELD * field)
-|
-| Description : Get the left neighbour of the field on the same line
+| Facility : libnform
+| Function : static FIELD *Left_Neighbor_Field(FIELD * field)
+|
+| Description : Get the left neighbor of the field on the same line
| and the same page. Cycles through the line.
|
-| Return Values : Pointer to left neighbour field.
+| Return Values : Pointer to left neighbor field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Left_Neighbour_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Left_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
- /* For a field that has really a left neighbour, the while clause
+ /* For a field that has really a left neighbor, the while clause
immediately fails and the loop is left, positioned at the right
- neighbour. Otherwise we cycle backwards through the sorted fieldlist
+ neighbor. Otherwise we cycle backwards through the sorted field list
until we enter the same line (from the right end).
- */
+ */
do
{
field_on_page = Sorted_Previous_Field(field_on_page);
- } while(field_on_page->frow != field->frow);
-
+ }
+ while (field_on_page->frow != field->frow);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Right_Neighbour_Field(FIELD * field)
-|
-| Description : Get the right neighbour of the field on the same line
+| Facility : libnform
+| Function : static FIELD *Right_Neighbor_Field(FIELD * field)
+|
+| Description : Get the right neighbor of the field on the same line
| and the same page.
|
-| Return Values : Pointer to right neighbour field.
+| Return Values : Pointer to right neighbor field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Right_Neighbour_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Right_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
- /* See the comments on Left_Neighbour_Field to understand how it works */
+ /* See the comments on Left_Neighbor_Field to understand how it works */
do
{
field_on_page = Sorted_Next_Field(field_on_page);
- } while(field_on_page->frow != field->frow);
-
+ }
+ while (field_on_page->frow != field->frow);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Upper_Neighbour_Field(FIELD * field)
-|
+| Facility : libnform
+| Function : static FIELD *Upper_Neighbor_Field(FIELD * field)
+|
| Description : Because of the row-major nature of sorting the fields,
-| its more difficult to define whats the upper neighbour
+| it is more difficult to define whats the upper neighbor
| field really means. We define that it must be on a
| 'previous' line (cyclic order!) and is the rightmost
| field laying on the left side of the given field. If
| this set is empty, we take the first field on the line.
|
-| Return Values : Pointer to the upper neighbour field.
+| Return Values : Pointer to the upper neighbor field.
+--------------------------------------------------------------------------*/
-static FIELD *Upper_Neighbour_Field(FIELD * field)
+static FIELD *
+Upper_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
int frow = field->frow;
@@ -2966,45 +3382,48 @@ static FIELD *Upper_Neighbour_Field(FIELD * field)
/* Walk back to the 'previous' line. The second term in the while clause
just guarantees that we stop if we cycled through the line because
there might be no 'previous' line if the page has just one line.
- */
+ */
do
{
field_on_page = Sorted_Previous_Field(field_on_page);
- } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
-
- if (field_on_page->frow!=frow)
- { /* We really found a 'previous' line. We are positioned at the
+ }
+ while (field_on_page->frow == frow && field_on_page->fcol != fcol);
+
+ if (field_on_page->frow != frow)
+ {
+ /* We really found a 'previous' line. We are positioned at the
rightmost field on this line */
- frow = field_on_page->frow;
+ frow = field_on_page->frow;
- /* We walk to the left as long as we are really right of the
- field. */
- while(field_on_page->frow==frow && field_on_page->fcol>fcol)
+ /* We walk to the left as long as we are really right of the
+ field. */
+ while (field_on_page->frow == frow && field_on_page->fcol > fcol)
field_on_page = Sorted_Previous_Field(field_on_page);
- /* If we wrapped, just go to the right which is the first field on
- the row */
- if (field_on_page->frow!=frow)
+ /* If we wrapped, just go to the right which is the first field on
+ the row */
+ if (field_on_page->frow != frow)
field_on_page = Sorted_Next_Field(field_on_page);
}
-
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Down_Neighbour_Field(FIELD * field)
-|
+| Facility : libnform
+| Function : static FIELD *Down_Neighbor_Field(FIELD * field)
+|
| Description : Because of the row-major nature of sorting the fields,
-| its more difficult to define whats the down neighbour
+| its more difficult to define whats the down neighbor
| field really means. We define that it must be on a
| 'next' line (cyclic order!) and is the leftmost
| field laying on the right side of the given field. If
| this set is empty, we take the last field on the line.
|
-| Return Values : Pointer to the upper neighbour field.
+| Return Values : Pointer to the upper neighbor field.
+--------------------------------------------------------------------------*/
-static FIELD *Down_Neighbour_Field(FIELD * field)
+static FIELD *
+Down_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
int frow = field->frow;
@@ -3013,42 +3432,44 @@ static FIELD *Down_Neighbour_Field(FIELD * field)
/* Walk forward to the 'next' line. The second term in the while clause
just guarantees that we stop if we cycled through the line because
there might be no 'next' line if the page has just one line.
- */
+ */
do
{
field_on_page = Sorted_Next_Field(field_on_page);
- } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
+ }
+ while (field_on_page->frow == frow && field_on_page->fcol != fcol);
- if (field_on_page->frow!=frow)
- { /* We really found a 'next' line. We are positioned at the rightmost
+ if (field_on_page->frow != frow)
+ {
+ /* We really found a 'next' line. We are positioned at the rightmost
field on this line */
frow = field_on_page->frow;
- /* We walk to the right as long as we are really left of the
- field. */
- while(field_on_page->frow==frow && field_on_page->fcol<fcol)
+ /* We walk to the right as long as we are really left of the
+ field. */
+ while (field_on_page->frow == frow && field_on_page->fcol < fcol)
field_on_page = Sorted_Next_Field(field_on_page);
- /* If we wrapped, just go to the left which is the last field on
- the row */
- if (field_on_page->frow!=frow)
+ /* If we wrapped, just go to the left which is the last field on
+ the row */
+ if (field_on_page->frow != frow)
field_on_page = Sorted_Previous_Field(field_on_page);
}
-
- return(field_on_page);
+
+ return (field_on_page);
}
-
+
/*----------------------------------------------------------------------------
Inter-Field Navigation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Inter_Field_Navigation(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Generic behaviour for changing the current field, the
+|
+| Description : Generic behavior for changing the current field, the
| field is left and a new field is entered. So the field
| must be validated and the field init/term hooks must
| be called.
@@ -3057,229 +3478,254 @@ static FIELD *Down_Neighbour_Field(FIELD * field)
| E_INVALID_FIELD - field is invalid
| some other - error from subordinate call
+--------------------------------------------------------------------------*/
-static int Inter_Field_Navigation(int (* const fct) (FORM *),FORM *form)
+static int
+Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form)
{
int res;
- if (!_nc_Internal_Validation(form))
+ if (!_nc_Internal_Validation(form))
res = E_INVALID_FIELD;
else
{
- Call_Hook(form,fieldterm);
+ Call_Hook(form, fieldterm);
res = fct(form);
- Call_Hook(form,fieldinit);
+ Call_Hook(form, fieldinit);
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Next_Field(FORM * form)
-|
+|
| Description : Move to the next field on the current page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Next_Field(FORM * form)
+static int
+FN_Next_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Next_Field_On_Page(form->current));
+ T((T_CALLED("FN_Next_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Next_Field_On_Page(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Previous_Field(FORM * form)
-|
-| Description : Move to the previous field on the current page of the
+|
+| Description : Move to the previous field on the current page of the
| form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Previous_Field(FORM * form)
+static int
+FN_Previous_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Previous_Field_On_Page(form->current));
+ T((T_CALLED("FN_Previous_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Previous_Field_On_Page(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_First_Field(FORM * form)
-|
+|
| Description : Move to the first field on the current page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_First_Field(FORM * form)
+static int
+FN_First_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Next_Field_On_Page(form->field[form->page[form->curpage].pmax]));
+ T((T_CALLED("FN_First_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Next_Field_On_Page(form->field[form->page[form->curpage].pmax])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Last_Field(FORM * form)
-|
+|
| Description : Move to the last field on the current page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Last_Field(FORM * form)
+static int
+FN_Last_Field(FORM *form)
{
- return
- _nc_Set_Current_Field(form,
- Previous_Field_On_Page(form->field[form->page[form->curpage].pmin]));
+ T((T_CALLED("FN_Last_Field(%p)"), form));
+ returnCode(
+ _nc_Set_Current_Field(form,
+ Previous_Field_On_Page(form->field[form->page[form->curpage].pmin])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_Next_Field(FORM * form)
-|
+|
| Description : Move to the sorted next field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_Next_Field(FORM * form)
+static int
+FN_Sorted_Next_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Next_Field(form->current));
+ T((T_CALLED("FN_Sorted_Next_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Next_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_Previous_Field(FORM * form)
-|
+|
| Description : Move to the sorted previous field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_Previous_Field(FORM * form)
+static int
+FN_Sorted_Previous_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Previous_Field(form->current));
+ T((T_CALLED("FN_Sorted_Previous_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Previous_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_First_Field(FORM * form)
-|
+|
| Description : Move to the sorted first field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_First_Field(FORM * form)
+static int
+FN_Sorted_First_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Next_Field(form->field[form->page[form->curpage].smax]));
+ T((T_CALLED("FN_Sorted_First_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Next_Field(form->field[form->page[form->curpage].smax])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_Last_Field(FORM * form)
-|
+|
| Description : Move to the sorted last field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_Last_Field(FORM * form)
+static int
+FN_Sorted_Last_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Previous_Field(form->field[form->page[form->curpage].smin]));
+ T((T_CALLED("FN_Sorted_Last_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Previous_Field(form->field[form->page[form->curpage].smin])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Left_Field(FORM * form)
-|
+|
| Description : Get the field on the left of the current field on the
| same line and the same page. Cycles through the line.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Left_Field(FORM * form)
+static int
+FN_Left_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Left_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Left_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Left_Neighbor_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Right_Field(FORM * form)
-|
+|
| Description : Get the field on the right of the current field on the
| same line and the same page. Cycles through the line.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Right_Field(FORM * form)
+static int
+FN_Right_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Right_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Right_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Right_Neighbor_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Up_Field(FORM * form)
-|
-| Description : Get the upper neighbour of the current field. This
+|
+| Description : Get the upper neighbor of the current field. This
| cycles through the page. See the comments of the
-| Upper_Neighbour_Field function to understand how
-| 'upper' is defined.
+| Upper_Neighbor_Field function to understand how
+| 'upper' is defined.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Up_Field(FORM * form)
+static int
+FN_Up_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Upper_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Up_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Upper_Neighbor_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Down_Field(FORM * form)
-|
-| Description : Get the down neighbour of the current field. This
+|
+| Description : Get the down neighbor of the current field. This
| cycles through the page. See the comments of the
-| Down_Neighbour_Field function to understand how
-| 'down' is defined.
+| Down_Neighbor_Field function to understand how
+| 'down' is defined.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Down_Field(FORM * form)
+static int
+FN_Down_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Down_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Down_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Down_Neighbor_Field(form->current)));
}
/*----------------------------------------------------------------------------
- END of Field Navigation routines
+ END of Field Navigation routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Page Navigation
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Set_Form_Page(FORM * form,
| int page,
| FIELD * field)
-|
-| Description : Make the given page nr. the current page and make
+|
+| Description : Make the given page number the current page and make
| the given field the current field on the page. If
| for the field NULL is given, make the first field on
| the page the current field. The routine acts only
@@ -3287,14 +3733,15 @@ static int FN_Down_Field(FORM * form)
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+| E_BAD_ARGUMENT - invalid field pointer
+| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Set_Form_Page
-(FORM * form, int page, FIELD * field)
+_nc_Set_Form_Page(FORM *form, int page, FIELD *field)
{
int res = E_OK;
- if ((form->curpage!=page))
+ if ((form->curpage != page))
{
FIELD *last_field, *field_on_page;
@@ -3304,64 +3751,67 @@ _nc_Set_Form_Page
do
{
if (field_on_page->opts & O_VISIBLE)
- if ((res=Display_Field(field_on_page))!=E_OK)
- return(res);
+ if ((res = Display_Field(field_on_page)) != E_OK)
+ return (res);
field_on_page = field_on_page->snext;
- } while(field_on_page != last_field);
+ }
+ while (field_on_page != last_field);
if (field)
- res = _nc_Set_Current_Field(form,field);
+ res = _nc_Set_Current_Field(form, field);
else
/* N.B.: we don't encapsulate this by Inter_Field_Navigation(),
because this is already executed in a page navigation
- context that contains field navigation
+ context that contains field navigation
*/
res = FN_First_Field(form);
}
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Next_Page_Number(const FORM * form)
-|
+|
| Description : Calculate the page number following the current page
| number. This cycles if the highest page number is
-| reached.
+| reached.
|
| Return Values : The next page number
+--------------------------------------------------------------------------*/
-INLINE static int Next_Page_Number(const FORM * form)
+NCURSES_INLINE static int
+Next_Page_Number(const FORM *form)
{
return (form->curpage + 1) % form->maxpage;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Previous_Page_Number(const FORM * form)
-|
+|
| Description : Calculate the page number before the current page
| number. This cycles if the first page number is
-| reached.
+| reached.
|
| Return Values : The previous page number
+--------------------------------------------------------------------------*/
-INLINE static int Previous_Page_Number(const FORM * form)
+NCURSES_INLINE static int
+Previous_Page_Number(const FORM *form)
{
- return (form->curpage!=0 ? form->curpage - 1 : form->maxpage - 1);
+ return (form->curpage != 0 ? form->curpage - 1 : form->maxpage - 1);
}
-
+
/*----------------------------------------------------------------------------
- Page Navigation routines
+ Page Navigation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Page_Navigation(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Generic behaviour for changing a page. This means
+|
+| Description : Generic behavior for changing a page. This means
| that the field is left and a new field is entered.
| So the field must be validated and the field init/term
| hooks must be called. Because also the page is changed,
@@ -3371,192 +3821,220 @@ INLINE static int Previous_Page_Number(const FORM * form)
| E_INVALID_FIELD - field is invalid
| some other - error from subordinate call
+--------------------------------------------------------------------------*/
-static int Page_Navigation(int (* const fct) (FORM *), FORM * form)
+static int
+Page_Navigation(int (*const fct) (FORM *), FORM *form)
{
int res;
- if (!_nc_Internal_Validation(form))
+ if (!_nc_Internal_Validation(form))
res = E_INVALID_FIELD;
else
{
- Call_Hook(form,fieldterm);
- Call_Hook(form,formterm);
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
res = fct(form);
- Call_Hook(form,forminit);
- Call_Hook(form,fieldinit);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_Next_Page(FORM * form)
-|
+|
| Description : Move to the next page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_Next_Page(FORM * form)
-{
- return _nc_Set_Form_Page(form,Next_Page_Number(form),(FIELD *)0);
+static int
+PN_Next_Page(FORM *form)
+{
+ T((T_CALLED("PN_Next_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, Next_Page_Number(form), (FIELD *)0));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_Previous_Page(FORM * form)
-|
+|
| Description : Move to the previous page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_Previous_Page(FORM * form)
+static int
+PN_Previous_Page(FORM *form)
{
- return _nc_Set_Form_Page(form,Previous_Page_Number(form),(FIELD *)0);
+ T((T_CALLED("PN_Previous_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, Previous_Page_Number(form), (FIELD *)0));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_First_Page(FORM * form)
-|
+|
| Description : Move to the first page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_First_Page(FORM * form)
+static int
+PN_First_Page(FORM *form)
{
- return _nc_Set_Form_Page(form,0,(FIELD *)0);
+ T((T_CALLED("PN_First_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, 0, (FIELD *)0));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_Last_Page(FORM * form)
-|
+|
| Description : Move to the last page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_Last_Page(FORM * form)
+static int
+PN_Last_Page(FORM *form)
{
- return _nc_Set_Form_Page(form,form->maxpage-1,(FIELD *)0);
+ T((T_CALLED("PN_Last_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, form->maxpage - 1, (FIELD *)0));
}
+
/*----------------------------------------------------------------------------
- END of Field Navigation routines
+ END of Field Navigation routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for the core form driver.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Data_Entry(FORM * form,int c)
-|
+|
| Description : Enter character c into at the current position of the
| current field of the form.
|
-| Return Values : E_OK -
-| E_REQUEST_DENIED -
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - driver could not process the request
| E_SYSTEM_ERROR -
+--------------------------------------------------------------------------*/
-static int Data_Entry(FORM * form, int c)
+static int
+Data_Entry(FORM *form, int c)
{
- FIELD *field = form->current;
+ FIELD *field = form->current;
int result = E_REQUEST_DENIED;
- if ( (field->opts & O_EDIT)
+ T((T_CALLED("Data_Entry(%p,%s)"), form, _tracechtype((chtype)c)));
+ if ((field->opts & O_EDIT)
#if FIX_FORM_INACTIVE_BUG
- && (field->opts & O_ACTIVE)
+ && (field->opts & O_ACTIVE)
#endif
- )
+ )
{
- if ( (field->opts & O_BLANK) &&
- First_Position_In_Current_Field(form) &&
- !(form->status & _FCHECK_REQUIRED) &&
- !(form->status & _WINDOW_MODIFIED) )
+ if ((field->opts & O_BLANK) &&
+ First_Position_In_Current_Field(form) &&
+ !(form->status & _FCHECK_REQUIRED) &&
+ !(form->status & _WINDOW_MODIFIED))
werase(form->w);
if (form->status & _OVLMODE)
{
- waddch(form->w,(chtype)c);
- }
- else /* no _OVLMODE */
+ waddch(form->w, (chtype)c);
+ }
+ else
+ /* no _OVLMODE */
{
bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
if (!(There_Is_Room ||
((Single_Line_Field(field) && Growable(field)))))
- return E_REQUEST_DENIED;
+ RETURN(E_REQUEST_DENIED);
- if (!There_Is_Room && !Field_Grown(field,1))
- return E_SYSTEM_ERROR;
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ RETURN(E_SYSTEM_ERROR);
- winsch(form->w,(chtype)c);
+ winsch(form->w, (chtype)c);
}
- if ((result=Wrapping_Not_Necessary_Or_Wrapping_Ok(form))==E_OK)
+ if ((result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form)) == E_OK)
{
- bool End_Of_Field= (((field->drows-1)==form->currow) &&
- ((field->dcols-1)==form->curcol));
+ bool End_Of_Field = (((field->drows - 1) == form->currow) &&
+ ((field->dcols - 1) == form->curcol));
+
form->status |= _WINDOW_MODIFIED;
if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP))
- result = Inter_Field_Navigation(FN_Next_Field,form);
+ result = Inter_Field_Navigation(FN_Next_Field, form);
else
{
- if (End_Of_Field && Growable(field) && !Field_Grown(field,1))
+ if (End_Of_Field && Growable(field) && !Field_Grown(field, 1))
result = E_SYSTEM_ERROR;
else
{
+#if USE_WIDEC_SUPPORT
+ /*
+ * We have just added a byte to the form field. It may have
+ * been part of a multibyte character. If it was, the
+ * addch_used field is nonzero and we should not try to move
+ * to a new column.
+ */
+ if (WINDOW_EXT(form->w, addch_used) == 0)
+ IFN_Next_Character(form);
+#else
IFN_Next_Character(form);
+#endif
result = E_OK;
}
}
}
}
- return result;
+ RETURN(result);
}
-
+
/* Structure to describe the binding of a request code to a function.
The member keycode codes the request value as well as the generic
routine to use for the request. The code for the generic routine
is coded in the upper 16 Bits while the request code is coded in
- the lower 16 bits.
+ the lower 16 bits.
In terms of C++ you might think of a request as a class with a
virtual method "perform". The different types of request are
derived from this base class and overload (or not) the base class
implementation of perform.
*/
-typedef struct {
- int keycode; /* must be at least 32 bit: hi:mode, lo: key */
- int (*cmd)(FORM *); /* low level driver routine for this key */
-} Binding_Info;
+typedef struct
+{
+ int keycode; /* must be at least 32 bit: hi:mode, lo: key */
+ int (*cmd) (FORM *); /* low level driver routine for this key */
+}
+Binding_Info;
/* You may see this is the class-id of the request type class */
-#define ID_PN (0x00000000) /* Page navigation */
-#define ID_FN (0x00010000) /* Inter-Field navigation */
-#define ID_IFN (0x00020000) /* Intra-Field navigation */
-#define ID_VSC (0x00030000) /* Vertical Scrolling */
-#define ID_HSC (0x00040000) /* Horizontal Scrolling */
-#define ID_FE (0x00050000) /* Field Editing */
-#define ID_EM (0x00060000) /* Edit Mode */
-#define ID_FV (0x00070000) /* Field Validation */
-#define ID_CH (0x00080000) /* Choice */
+#define ID_PN (0x00000000) /* Page navigation */
+#define ID_FN (0x00010000) /* Inter-Field navigation */
+#define ID_IFN (0x00020000) /* Intra-Field navigation */
+#define ID_VSC (0x00030000) /* Vertical Scrolling */
+#define ID_HSC (0x00040000) /* Horizontal Scrolling */
+#define ID_FE (0x00050000) /* Field Editing */
+#define ID_EM (0x00060000) /* Edit Mode */
+#define ID_FV (0x00070000) /* Field Validation */
+#define ID_CH (0x00080000) /* Choice */
#define ID_Mask (0xffff0000)
#define Key_Mask (0x0000ffff)
#define ID_Shft (16)
/* This array holds all the Binding Infos */
-static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+/* *INDENT-OFF* */
+static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{
{ REQ_NEXT_PAGE |ID_PN ,PN_Next_Page},
{ REQ_PREV_PAGE |ID_PN ,PN_Previous_Page},
{ REQ_FIRST_PAGE |ID_PN ,PN_First_Page},
{ REQ_LAST_PAGE |ID_PN ,PN_Last_Page},
-
+
{ REQ_NEXT_FIELD |ID_FN ,FN_Next_Field},
{ REQ_PREV_FIELD |ID_FN ,FN_Previous_Field},
{ REQ_FIRST_FIELD |ID_FN ,FN_First_Field},
@@ -3569,7 +4047,7 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{ REQ_RIGHT_FIELD |ID_FN ,FN_Right_Field},
{ REQ_UP_FIELD |ID_FN ,FN_Up_Field},
{ REQ_DOWN_FIELD |ID_FN ,FN_Down_Field},
-
+
{ REQ_NEXT_CHAR |ID_IFN ,IFN_Next_Character},
{ REQ_PREV_CHAR |ID_IFN ,IFN_Previous_Character},
{ REQ_NEXT_LINE |ID_IFN ,IFN_Next_Line},
@@ -3584,7 +4062,7 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{ REQ_RIGHT_CHAR |ID_IFN ,IFN_Right_Character},
{ REQ_UP_CHAR |ID_IFN ,IFN_Up_Character},
{ REQ_DOWN_CHAR |ID_IFN ,IFN_Down_Character},
-
+
{ REQ_NEW_LINE |ID_FE ,FE_New_Line},
{ REQ_INS_CHAR |ID_FE ,FE_Insert_Character},
{ REQ_INS_LINE |ID_FE ,FE_Insert_Line},
@@ -3593,36 +4071,37 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{ REQ_DEL_LINE |ID_FE ,FE_Delete_Line},
{ REQ_DEL_WORD |ID_FE ,FE_Delete_Word},
{ REQ_CLR_EOL |ID_FE ,FE_Clear_To_End_Of_Line},
- { REQ_CLR_EOF |ID_FE ,FE_Clear_To_End_Of_Form},
+ { REQ_CLR_EOF |ID_FE ,FE_Clear_To_End_Of_Field},
{ REQ_CLR_FIELD |ID_FE ,FE_Clear_Field},
-
+
{ REQ_OVL_MODE |ID_EM ,EM_Overlay_Mode},
{ REQ_INS_MODE |ID_EM ,EM_Insert_Mode},
-
+
{ REQ_SCR_FLINE |ID_VSC ,VSC_Scroll_Line_Forward},
{ REQ_SCR_BLINE |ID_VSC ,VSC_Scroll_Line_Backward},
{ REQ_SCR_FPAGE |ID_VSC ,VSC_Scroll_Page_Forward},
{ REQ_SCR_BPAGE |ID_VSC ,VSC_Scroll_Page_Backward},
{ REQ_SCR_FHPAGE |ID_VSC ,VSC_Scroll_Half_Page_Forward},
{ REQ_SCR_BHPAGE |ID_VSC ,VSC_Scroll_Half_Page_Backward},
-
+
{ REQ_SCR_FCHAR |ID_HSC ,HSC_Scroll_Char_Forward},
{ REQ_SCR_BCHAR |ID_HSC ,HSC_Scroll_Char_Backward},
{ REQ_SCR_HFLINE |ID_HSC ,HSC_Horizontal_Line_Forward},
{ REQ_SCR_HBLINE |ID_HSC ,HSC_Horizontal_Line_Backward},
{ REQ_SCR_HFHALF |ID_HSC ,HSC_Horizontal_Half_Line_Forward},
{ REQ_SCR_HBHALF |ID_HSC ,HSC_Horizontal_Half_Line_Backward},
-
+
{ REQ_VALIDATION |ID_FV ,FV_Validation},
{ REQ_NEXT_CHOICE |ID_CH ,CR_Next_Choice},
{ REQ_PREV_CHOICE |ID_CH ,CR_Previous_Choice}
};
+/* *INDENT-ON* */
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int form_driver(FORM * form,int c)
-|
+|
| Description : This is the workhorse of the forms system. It checks
| to determine whether the character c is a request or
| data. If it is a request, the form driver executes
@@ -3641,213 +4120,457 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
| E_INVALID_FIELD - field contents are invalid
| E_BAD_STATE - called from inside a hook routine
| E_REQUEST_DENIED - request failed
+| E_NOT_CONNECTED - no fields are connected to the form
| E_UNKNOWN_COMMAND - command not known
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_driver (FORM * form, int c)
+form_driver(FORM *form, int c)
{
- const Binding_Info* BI = (Binding_Info *)0;
+ const Binding_Info *BI = (Binding_Info *) 0;
int res = E_UNKNOWN_COMMAND;
+ T((T_CALLED("form_driver(%p,%d)"), form, c));
+
if (!form)
RETURN(E_BAD_ARGUMENT);
if (!(form->field))
RETURN(E_NOT_CONNECTED);
-
+
assert(form->page);
-
- if (c==FIRST_ACTIVE_MAGIC)
+
+ if (c == FIRST_ACTIVE_MAGIC)
{
form->current = _nc_First_Active_Field(form);
- return E_OK;
+ RETURN(E_OK);
}
-
- assert(form->current &&
- form->current->buf &&
+
+ assert(form->current &&
+ form->current->buf &&
(form->current->form == form)
- );
-
- if ( form->status & _IN_DRIVER )
+ );
+
+ if (form->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( !( form->status & _POSTED ) )
+ if (!(form->status & _POSTED))
RETURN(E_NOT_POSTED);
-
- if ((c>=MIN_FORM_COMMAND && c<=MAX_FORM_COMMAND) &&
- ((bindings[c-MIN_FORM_COMMAND].keycode & Key_Mask) == c))
- BI = &(bindings[c-MIN_FORM_COMMAND]);
-
+
+ if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
+ ((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
+ BI = &(bindings[c - MIN_FORM_COMMAND]);
+
if (BI)
{
- typedef int (*Generic_Method)(int (* const)(FORM *),FORM *);
- static const Generic_Method Generic_Methods[] =
- {
- Page_Navigation, /* overloaded to call field&form hooks */
- Inter_Field_Navigation, /* overloaded to call field hooks */
- NULL, /* Intra-Field is generic */
- Vertical_Scrolling, /* Overloaded to check multi-line */
- Horizontal_Scrolling, /* Overloaded to check single-line */
- Field_Editing, /* Overloaded to mark modification */
- NULL, /* Edit Mode is generic */
- NULL, /* Field Validation is generic */
- NULL /* Choice Request is generic */
- };
- size_t nMethods = (sizeof(Generic_Methods)/sizeof(Generic_Methods[0]));
- size_t method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff;
-
- if ( (method >= nMethods) || !(BI->cmd) )
+ typedef int (*Generic_Method) (int (*const) (FORM *), FORM *);
+ static const Generic_Method Generic_Methods[] =
+ {
+ Page_Navigation, /* overloaded to call field&form hooks */
+ Inter_Field_Navigation, /* overloaded to call field hooks */
+ NULL, /* Intra-Field is generic */
+ Vertical_Scrolling, /* Overloaded to check multi-line */
+ Horizontal_Scrolling, /* Overloaded to check single-line */
+ Field_Editing, /* Overloaded to mark modification */
+ NULL, /* Edit Mode is generic */
+ NULL, /* Field Validation is generic */
+ NULL /* Choice Request is generic */
+ };
+ size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
+ size_t method = (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */
+
+ if ((method >= nMethods) || !(BI->cmd))
res = E_SYSTEM_ERROR;
else
{
Generic_Method fct = Generic_Methods[method];
+
if (fct)
- res = fct(BI->cmd,form);
+ res = fct(BI->cmd, form);
else
- res = (BI->cmd)(form);
+ res = (BI->cmd) (form);
+ }
+ }
+#ifdef NCURSES_MOUSE_VERSION
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *win = form->win ? form->win : stdscr;
+ WINDOW *sub = form->sub ? form->sub : win;
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(win, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the form display area or at the decoration window.
+ */
+ int ry = event.y, rx = event.x; /* screen coordinates */
+
+ res = E_REQUEST_DENIED;
+ if (mouse_trafo(&ry, &rx, FALSE))
+ { /* rx, ry are now "curses" coordinates */
+ if (ry < sub->_begy)
+ { /* we clicked above the display region; this is
+ * interpreted as "scroll up" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ res = form_driver(form, REQ_PREV_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_PREV_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_FIRST_FIELD);
+ }
+ else if (ry > sub->_begy + sub->_maxy)
+ { /* we clicked below the display region; this is
+ * interpreted as "scroll down" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ res = form_driver(form, REQ_NEXT_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_NEXT_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_LAST_FIELD);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ int min_field = form->page[form->curpage].pmin;
+ int max_field = form->page[form->curpage].pmax;
+
+ for (i = min_field; i <= max_field; ++i)
+ {
+ FIELD *field = form->field[i];
+
+ if (Field_Is_Selectable(field)
+ && Field_encloses(field, ry, rx) == E_OK)
+ {
+ res = _nc_Set_Current_Field(form, field);
+ if (res == E_OK)
+ res = _nc_Position_Form_Cursor(form);
+ if (res == E_OK
+ && (event.bstate & BUTTON1_DOUBLE_CLICKED))
+ res = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ }
+ }
+ }
}
- }
- else
+ else
+ res = E_REQUEST_DENIED;
+ }
+#endif /* NCURSES_MOUSE_VERSION */
+ else if (!(c & (~(int)MAX_REGULAR_CHARACTER)))
{
- if (!(c & (~(int)MAX_REGULAR_CHARACTER)) &&
- isprint((unsigned char)c) &&
- Check_Char(form->current->type,c,
+ /*
+ * If we're using 8-bit characters, iscntrl+isprint cover the whole set.
+ * But with multibyte characters, there is a third possibility, i.e.,
+ * parts of characters that build up into printable characters which are
+ * not considered printable.
+ *
+ * FIXME: the wide-character branch should also use Check_Char().
+ */
+#if USE_WIDEC_SUPPORT
+ if (!iscntrl(UChar(c)))
+#else
+ if (isprint(UChar(c)) &&
+ Check_Char(form->current->type, c,
(TypeArgument *)(form->current->arg)))
- res = Data_Entry(form,c);
+#endif
+ res = Data_Entry(form, c);
}
_nc_Refresh_Current_Field(form);
RETURN(res);
}
-
+
/*----------------------------------------------------------------------------
Field-Buffer manipulation routines.
- The effects of setting a buffer is tightly coupled to the core of the form
+ The effects of setting a buffer are tightly coupled to the core of the form
driver logic. This is especially true in the case of growable fields.
- So I don't separate this into an own module.
+ So I don't separate this into a separate module.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_buffer(FIELD *field,
| int buffer, char *value)
-|
+|
| Description : Set the given buffer of the field to the given value.
| Buffer 0 stores the displayed content of the field.
| For dynamic fields this may grow the fieldbuffers if
| the length of the value exceeds the current buffer
| length. For buffer 0 only printable values are allowed.
| For static fields, the value needs not to be zero ter-
-| minated. It is copied up to the length of the buffer.
+| minated. It is copied up to the length of the buffer.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_buffer
-(FIELD * field, int buffer, const char * value)
+set_field_buffer(FIELD *field, int buffer, const char *value)
{
- char *s, *p;
+ FIELD_CELL *p;
int res = E_OK;
+ unsigned int i;
unsigned int len;
- if ( !field || !value || ((buffer < 0)||(buffer > field->nbuf)) )
- RETURN(E_BAD_ARGUMENT);
+#if USE_WIDEC_SUPPORT
+ FIELD_CELL *widevalue = 0;
+#endif
- len = Buffer_Length(field);
+ T((T_CALLED("set_field_buffer(%p,%d,%s)"), field, buffer, _nc_visbuf(value)));
- if (buffer==0)
- {
- const char *v;
- unsigned int i = 0;
+ if (!field || !value || ((buffer < 0) || (buffer > field->nbuf)))
+ RETURN(E_BAD_ARGUMENT);
- for(v=value; *v && (i<len); v++,i++)
- {
- if (!isprint((unsigned char)*v))
- RETURN(E_BAD_ARGUMENT);
- }
- }
+ len = Buffer_Length(field);
if (Growable(field))
{
/* for a growable field we must assume zero terminated strings, because
- somehow we have to detect the length of what should be copied.
- */
+ somehow we have to detect the length of what should be copied.
+ */
unsigned int vlen = strlen(value);
+
if (vlen > len)
{
if (!Field_Grown(field,
- (int)(1 + (vlen-len)/((field->rows+field->nrow)*field->cols))))
+ (int)(1 + (vlen - len) / ((field->rows + field->nrow)
+ * field->cols))))
RETURN(E_SYSTEM_ERROR);
- /* in this case we also have to check, wether or not the remaining
- characters in value are also printable for buffer 0. */
- if (buffer==0)
- {
- unsigned int i;
-
- for(i=len; i<vlen; i++)
- if (!isprint((unsigned char)value[i]))
- RETURN(E_BAD_ARGUMENT);
- }
len = vlen;
}
}
-
- p = Address_Of_Nth_Buffer(field,buffer);
-#if HAVE_MEMCCPY
- s = memccpy(p,value,0,len);
-#else
- for(s=(char *)value; *s && (s < (value+len)); s++)
- p[s-value] = *s;
- if (s < (value+len))
+ p = Address_Of_Nth_Buffer(field, buffer);
+
+#if USE_WIDEC_SUPPORT
+ /*
+ * Use addstr's logic for converting a string to an array of cchar_t's.
+ * There should be a better way, but this handles nonspacing characters
+ * and other special cases that we really do not want to handle here.
+ */
+#if NCURSES_EXT_FUNCS
+ if (wresize(field->working, field->drows, field->dcols) == ERR)
+#endif
{
- p[s-value] = *s++;
- s = p + (s-value);
+ delwin(field->working);
+ field->working = newpad(field->drows, field->dcols);
}
- else
- s=(char *)0;
-#endif
+ wclear(field->working);
+ mvwaddstr(field->working, 0, 0, value);
- if (s)
- { /* this means, value was null terminated and not greater than the
- buffer. We have to pad with blanks. Please note that due to memccpy
- logic s points after the terminating null. */
- s--; /* now we point to the terminator. */
- assert(len >= (unsigned int)(s-p));
- if (len > (unsigned int)(s-p))
- memset(s,C_BLANK,len-(unsigned int)(s-p));
+ if ((widevalue = typeCalloc(FIELD_CELL, len + 1)) == 0)
+ {
+ RETURN(E_SYSTEM_ERROR);
+ }
+ else
+ {
+ for (i = 0; i < (unsigned)field->drows; ++i)
+ {
+ mvwin_wchnstr(field->working, i, 0,
+ widevalue + (i * field->dcols),
+ field->dcols);
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (CharEq(myZEROS, widevalue[i]))
+ {
+ while (i < len)
+ p[i++] = myBLANK;
+ break;
+ }
+ p[i] = widevalue[i];
+ }
+ free(widevalue);
}
+#else
+ for (i = 0; i < len; ++i)
+ {
+ if (value[i] == '\0')
+ {
+ while (i < len)
+ p[i++] = myBLANK;
+ break;
+ }
+ p[i] = value[i];
+ }
+#endif
- if (buffer==0)
+ if (buffer == 0)
{
int syncres;
- if (((syncres=Synchronize_Field( field ))!=E_OK) &&
- (res==E_OK))
+
+ if (((syncres = Synchronize_Field(field)) != E_OK) &&
+ (res == E_OK))
res = syncres;
- if (((syncres=Synchronize_Linked_Fields(field ))!=E_OK) &&
- (res==E_OK))
+ if (((syncres = Synchronize_Linked_Fields(field)) != E_OK) &&
+ (res == E_OK))
res = syncres;
}
RETURN(res);
-}
+}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : char *field_buffer(const FIELD *field,int buffer)
-|
+|
| Description : Return the address of the buffer for the field.
|
| Return Values : Pointer to buffer or NULL if arguments were invalid.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(char *)
-field_buffer (const FIELD * field, int buffer)
+field_buffer(const FIELD *field, int buffer)
{
+ char *result = 0;
+
+ T((T_CALLED("field_buffer(%p,%d)"), field, buffer));
+
if (field && (buffer >= 0) && (buffer <= field->nbuf))
- return Address_Of_Nth_Buffer(field,buffer);
- else
- return (char *)0;
+ {
+#if USE_WIDEC_SUPPORT
+ FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
+ unsigned need = 0;
+ int size = Buffer_Length(field);
+ int n;
+
+ /* determine the number of bytes needed to store the expanded string */
+ for (n = 0; n < size; ++n)
+ {
+ if (!isWidecExt(data[n]))
+ {
+ mbstate_t state;
+ size_t next;
+
+ init_mb(state);
+ next = _nc_wcrtomb(0, data[n].chars[0], &state);
+ if (!isEILSEQ(next))
+ need += next;
+ }
+ }
+
+ /* allocate a place to store the expanded string */
+ if (field->expanded[buffer] != 0)
+ free(field->expanded[buffer]);
+ field->expanded[buffer] = typeMalloc(char, need + 1);
+
+ /* expand the multibyte data */
+ if ((result = field->expanded[buffer]) != 0)
+ {
+ wclear(field->working);
+ mvwadd_wchnstr(field->working, 0, 0, data, size);
+ mvwinnstr(field->working, 0, 0, result, (int)need);
+ }
+#else
+ result = Address_Of_Nth_Buffer(field, buffer);
+#endif
+ }
+ returnPtr(result);
+}
+
+#if USE_WIDEC_SUPPORT
+
+/* FIXME: see lib_get_wch.c */
+#if HAVE_MBTOWC && HAVE_MBLEN
+#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
+#define count_mbytes(buffer,length,state) mblen(buffer,length)
+#define trans_mbytes(wch,buffer,length,state) \
+ (int) mbtowc(&wch, buffer, length)
+#elif HAVE_MBRTOWC && HAVE_MBRLEN
+#define NEED_STATE
+#define reset_mbytes(state) init_mb(state)
+#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+#define trans_mbytes(wch,buffer,length,state) \
+ (int) mbrtowc(&wch, buffer, length, &state)
+#else
+make an error
+#endif
+
+/*---------------------------------------------------------------------------
+| Convert a multibyte string to a wide-character string. The result must be
+| freed by the caller.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(wchar_t *)
+_nc_Widen_String(char *source, int *lengthp)
+{
+ wchar_t *result = 0;
+ wchar_t wch;
+ size_t given = strlen(source);
+ size_t tries;
+ int pass;
+ int status;
+
+#ifdef NEED_STATE
+ mbstate_t state;
+#endif
+
+ for (pass = 0; pass < 2; ++pass)
+ {
+ unsigned need = 0;
+ size_t passed = 0;
+
+ while (passed < given)
+ {
+ bool found = FALSE;
+
+ for (tries = 1, status = 0; tries <= (given - passed); ++tries)
+ {
+ int save = source[passed + tries];
+
+ source[passed + tries] = 0;
+ reset_mbytes(state);
+ status = trans_mbytes(wch, source + passed, tries, state);
+ source[passed + tries] = save;
+
+ if (status > 0)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
+ {
+ if (pass)
+ {
+ result[need] = wch;
+ }
+ passed += status;
+ ++need;
+ }
+ else
+ {
+ if (pass)
+ {
+ result[need] = source[passed];
+ }
+ ++need;
+ ++passed;
+ }
+ }
+
+ if (!pass)
+ {
+ if (!need)
+ break;
+ result = typeCalloc(wchar_t, need);
+
+ *lengthp = need;
+ if (result == 0)
+ break;
+ }
+ }
+
+ return result;
}
+#endif
/* frm_driver.c ends here */
diff --git a/lib/libform/frm_hook.c b/lib/libform/frm_hook.c
index 8b4c3dfc8e5..540aab8ff74 100644
--- a/lib/libform/frm_hook.c
+++ b/lib/libform/frm_hook.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_hook.c,v 1.6 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,17 +27,18 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_hook.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_hook.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/* "Template" macro to generate function to set application specific hook */
#define GEN_HOOK_SET_FUNCTION( typ, name ) \
NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
{\
+ T((T_CALLED("set_" #typ"_"#name"(%p,%p)"), form, func));\
(Normalize_Form( form ) -> typ ## name) = func ;\
RETURN(E_OK);\
}
@@ -48,95 +47,96 @@ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook f
#define GEN_HOOK_GET_FUNCTION( typ, name ) \
NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
{\
- return ( Normalize_Form( form ) -> typ ## name );\
+ T((T_CALLED(#typ "_" #name "(%p)"), form));\
+ returnFormHook( Normalize_Form( form ) -> typ ## name );\
}
-
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_init(FORM *form, Form_Hook f)
-|
+|
| Description : Assigns an application defined initialization function
| to be called when the form is posted and just after
| the current field changes.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(field,init)
+GEN_HOOK_SET_FUNCTION(field, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : Form_Hook field_init(const FORM *form)
-|
+|
| Description : Retrieve field initialization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(field,init)
+GEN_HOOK_GET_FUNCTION(field, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_term(FORM *form, Form_Hook f)
-|
+|
| Description : Assigns an application defined finalization function
| to be called when the form is unposted and just before
| the current field changes.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(field,term)
+GEN_HOOK_SET_FUNCTION(field, term)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : Form_Hook field_term(const FORM *form)
-|
+|
| Description : Retrieve field finalization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(field,term)
+GEN_HOOK_GET_FUNCTION(field, term)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_form_init(FORM *form, Form_Hook f)
-|
+|
| Description : Assigns an application defined initialization function
| to be called when the form is posted and just after
| a page change.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(form,init)
+GEN_HOOK_SET_FUNCTION(form, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : Form_Hook form_init(const FORM *form)
-|
+|
| Description : Retrieve form initialization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(form,init)
+GEN_HOOK_GET_FUNCTION(form, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_form_term(FORM *form, Form_Hook f)
-|
+|
| Description : Assigns an application defined finalization function
| to be called when the form is unposted and just before
| a page change.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(form,term)
+GEN_HOOK_SET_FUNCTION(form, term)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : Form_Hook form_term(const FORM *form)
-|
+|
| Description : Retrieve form finalization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(form,term)
+GEN_HOOK_GET_FUNCTION(form, term)
/* frm_hook.c ends here */
diff --git a/lib/libform/frm_opts.c b/lib/libform/frm_opts.c
index 300493d518e..0c00cb3c23d 100644
--- a/lib/libform/frm_opts.c
+++ b/lib/libform/frm_opts.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_opts.c,v 1.7 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_opts.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_opts.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,14 +45,16 @@ MODULE_ID("$From: frm_opts.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_opts (FORM * form, Form_Options opts)
+set_form_opts(FORM *form, Form_Options opts)
{
+ T((T_CALLED("set_form_opts(%p,%d)"), form, opts));
+
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
- Normalize_Form( form )->opts = opts;
+ Normalize_Form(form)->opts = opts;
RETURN(E_OK);
}
}
@@ -68,9 +68,10 @@ set_form_opts (FORM * form, Form_Options opts)
| Return Values : The option flags.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Form_Options)
-form_opts (const FORM * form)
+form_opts(const FORM *form)
{
- return (Normalize_Form(form)->opts & ALL_FORM_OPTS);
+ T((T_CALLED("form_opts(%p)"), form));
+ returnCode((int)(Normalize_Form(form)->opts & ALL_FORM_OPTS));
}
/*---------------------------------------------------------------------------
@@ -84,14 +85,16 @@ form_opts (const FORM * form)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_opts_on (FORM * form, Form_Options opts)
+form_opts_on(FORM *form, Form_Options opts)
{
+ T((T_CALLED("form_opts_on(%p,%d)"), form, opts));
+
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
- Normalize_Form( form )->opts |= opts;
+ Normalize_Form(form)->opts |= opts;
RETURN(E_OK);
}
}
@@ -107,8 +110,10 @@ form_opts_on (FORM * form, Form_Options opts)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_opts_off (FORM * form, Form_Options opts)
+form_opts_off(FORM *form, Form_Options opts)
{
+ T((T_CALLED("form_opts_off(%p,%d)"), form, opts));
+
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
diff --git a/lib/libform/frm_page.c b/lib/libform/frm_page.c
index fbad21e25cf..5aa3892729b 100644
--- a/lib/libform/frm_page.c
+++ b/lib/libform/frm_page.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_page.c,v 1.4 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_page.c,v 1.6 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_page.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,35 +47,37 @@ MODULE_ID("$From: frm_page.c,v 1.6 2000/12/10 02:09:37 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_page (FORM * form, int page)
+set_form_page(FORM *form, int page)
{
int err = E_OK;
- if ( !form || (page<0) || (page>=form->maxpage) )
+ T((T_CALLED("set_form_page(%p,%d)"), form, page));
+
+ if (!form || (page < 0) || (page >= form->maxpage))
RETURN(E_BAD_ARGUMENT);
if (!(form->status & _POSTED))
{
form->curpage = page;
form->current = _nc_First_Active_Field(form);
- }
+ }
else
{
- if (form->status & _IN_DRIVER)
+ if (form->status & _IN_DRIVER)
err = E_BAD_STATE;
else
{
if (form->curpage != page)
{
- if (!_nc_Internal_Validation(form))
+ if (!_nc_Internal_Validation(form))
err = E_INVALID_FIELD;
else
{
- Call_Hook(form,fieldterm);
- Call_Hook(form,formterm);
- err = _nc_Set_Form_Page(form,page,(FIELD *)0);
- Call_Hook(form,forminit);
- Call_Hook(form,fieldinit);
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
+ err = _nc_Set_Form_Page(form, page, (FIELD *)0);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
_nc_Refresh_Current_Field(form);
}
}
@@ -96,9 +96,11 @@ set_form_page (FORM * form, int page)
| -1 : invalid form pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_page (const FORM * form)
+form_page(const FORM *form)
{
- return Normalize_Form(form)->curpage;
+ T((T_CALLED("form_page(%p)"), form));
+
+ returnCode(Normalize_Form(form)->curpage);
}
/* frm_page.c ends here */
diff --git a/lib/libform/frm_post.c b/lib/libform/frm_post.c
index 4027c5f29f8..b3bfc913d5c 100644
--- a/lib/libform/frm_post.c
+++ b/lib/libform/frm_post.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_post.c,v 1.4 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: frm_post.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_post.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,37 +48,39 @@ MODULE_ID("$From: frm_post.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-post_form (FORM * form)
+post_form(FORM *form)
{
WINDOW *formwin;
int err;
int page;
+ T((T_CALLED("post_form(%p)"), form));
+
if (!form)
RETURN(E_BAD_ARGUMENT);
- if (form->status & _POSTED)
+ if (form->status & _POSTED)
RETURN(E_POSTED);
if (!(form->field))
RETURN(E_NOT_CONNECTED);
-
+
formwin = Get_Form_Window(form);
- if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
+ if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
RETURN(E_NO_ROOM);
/* reset form->curpage to an invald value. This forces Set_Form_Page
to do the page initialization which is required by post_form.
- */
+ */
page = form->curpage;
form->curpage = -1;
- if ((err = _nc_Set_Form_Page(form,page,form->current))!=E_OK)
+ if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK)
RETURN(err);
form->status |= _POSTED;
- Call_Hook(form,forminit);
- Call_Hook(form,fieldinit);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
_nc_Refresh_Current_Field(form);
RETURN(E_OK);
@@ -97,19 +98,21 @@ post_form (FORM * form)
| E_BAD_STATE - called from a hook routine
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-unpost_form (FORM * form)
+unpost_form(FORM *form)
{
+ T((T_CALLED("unpost_form(%p)"), form));
+
if (!form)
RETURN(E_BAD_ARGUMENT);
- if (!(form->status & _POSTED))
+ if (!(form->status & _POSTED))
RETURN(E_NOT_POSTED);
- if (form->status & _IN_DRIVER)
+ if (form->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- Call_Hook(form,fieldterm);
- Call_Hook(form,formterm);
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
werase(Get_Form_Window(form));
delwin(form->w);
diff --git a/lib/libform/frm_req_name.c b/lib/libform/frm_req_name.c
index 069fe6df1d6..898283ed65d 100644
--- a/lib/libform/frm_req_name.c
+++ b/lib/libform/frm_req_name.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_req_name.c,v 1.5 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,71 +37,73 @@
#include "form.priv.h"
-MODULE_ID("$From: frm_req_name.c,v 1.8 2000/12/10 02:09:37 tom Exp $")
-
-static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
- "NEXT_PAGE" ,
- "PREV_PAGE" ,
- "FIRST_PAGE" ,
- "LAST_PAGE" ,
-
- "NEXT_FIELD" ,
- "PREV_FIELD" ,
- "FIRST_FIELD" ,
- "LAST_FIELD" ,
- "SNEXT_FIELD" ,
- "SPREV_FIELD" ,
- "SFIRST_FIELD" ,
- "SLAST_FIELD" ,
- "LEFT_FIELD" ,
- "RIGHT_FIELD" ,
- "UP_FIELD" ,
- "DOWN_FIELD" ,
-
- "NEXT_CHAR" ,
- "PREV_CHAR" ,
- "NEXT_LINE" ,
- "PREV_LINE" ,
- "NEXT_WORD" ,
- "PREV_WORD" ,
- "BEG_FIELD" ,
- "END_FIELD" ,
- "BEG_LINE" ,
- "END_LINE" ,
- "LEFT_CHAR" ,
- "RIGHT_CHAR" ,
- "UP_CHAR" ,
- "DOWN_CHAR" ,
-
- "NEW_LINE" ,
- "INS_CHAR" ,
- "INS_LINE" ,
- "DEL_CHAR" ,
- "DEL_PREV" ,
- "DEL_LINE" ,
- "DEL_WORD" ,
- "CLR_EOL" ,
- "CLR_EOF" ,
- "CLR_FIELD" ,
- "OVL_MODE" ,
- "INS_MODE" ,
- "SCR_FLINE" ,
- "SCR_BLINE" ,
- "SCR_FPAGE" ,
- "SCR_BPAGE" ,
- "SCR_FHPAGE" ,
- "SCR_BHPAGE" ,
- "SCR_FCHAR" ,
- "SCR_BCHAR" ,
- "SCR_HFLINE" ,
- "SCR_HBLINE" ,
- "SCR_HFHALF" ,
- "SCR_HBHALF" ,
-
- "VALIDATION" ,
- "NEXT_CHOICE" ,
- "PREV_CHOICE"
+MODULE_ID("$Id: frm_req_name.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
+
+static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+{
+ "NEXT_PAGE",
+ "PREV_PAGE",
+ "FIRST_PAGE",
+ "LAST_PAGE",
+
+ "NEXT_FIELD",
+ "PREV_FIELD",
+ "FIRST_FIELD",
+ "LAST_FIELD",
+ "SNEXT_FIELD",
+ "SPREV_FIELD",
+ "SFIRST_FIELD",
+ "SLAST_FIELD",
+ "LEFT_FIELD",
+ "RIGHT_FIELD",
+ "UP_FIELD",
+ "DOWN_FIELD",
+
+ "NEXT_CHAR",
+ "PREV_CHAR",
+ "NEXT_LINE",
+ "PREV_LINE",
+ "NEXT_WORD",
+ "PREV_WORD",
+ "BEG_FIELD",
+ "END_FIELD",
+ "BEG_LINE",
+ "END_LINE",
+ "LEFT_CHAR",
+ "RIGHT_CHAR",
+ "UP_CHAR",
+ "DOWN_CHAR",
+
+ "NEW_LINE",
+ "INS_CHAR",
+ "INS_LINE",
+ "DEL_CHAR",
+ "DEL_PREV",
+ "DEL_LINE",
+ "DEL_WORD",
+ "CLR_EOL",
+ "CLR_EOF",
+ "CLR_FIELD",
+ "OVL_MODE",
+ "INS_MODE",
+ "SCR_FLINE",
+ "SCR_BLINE",
+ "SCR_FPAGE",
+ "SCR_BPAGE",
+ "SCR_FHPAGE",
+ "SCR_BHPAGE",
+ "SCR_FCHAR",
+ "SCR_BCHAR",
+ "SCR_HFLINE",
+ "SCR_HBLINE",
+ "SCR_HFHALF",
+ "SCR_HBHALF",
+
+ "VALIDATION",
+ "NEXT_CHOICE",
+ "PREV_CHOICE"
};
+
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
/*---------------------------------------------------------------------------
@@ -116,18 +116,19 @@ static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-form_request_name ( int request )
+form_request_name(int request)
{
- if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
+ T((T_CALLED("form_request_name(%d)"), request));
+
+ if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
{
- SET_ERROR (E_BAD_ARGUMENT);
- return (const char *)0;
+ SET_ERROR(E_BAD_ARGUMENT);
+ returnCPtr((const char *)0);
}
else
- return request_names[ request - MIN_FORM_COMMAND ];
+ returnCPtr(request_names[request - MIN_FORM_COMMAND]);
}
-
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int form_request_by_name (const char *str);
@@ -138,28 +139,30 @@ form_request_name ( int request )
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_request_by_name ( const char *str )
-{
+form_request_by_name(const char *str)
+{
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
- */
+ */
unsigned int i = 0;
char buf[16];
-
+
+ T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
+
if (str)
{
- strncpy(buf,str,sizeof(buf));
- while( (i<sizeof(buf)) && (buf[i] != '\0') )
+ strncpy(buf, str, sizeof(buf));
+ while ((i < sizeof(buf)) && (buf[i] != '\0'))
{
- buf[i] = toupper(buf[i]);
+ buf[i] = toupper(UChar(buf[i]));
i++;
}
-
- for (i=0; i < A_SIZE; i++)
+
+ for (i = 0; i < A_SIZE; i++)
{
- if (strncmp(request_names[i],buf,sizeof(buf))==0)
- return MIN_FORM_COMMAND + i;
- }
+ if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ returnCode(MIN_FORM_COMMAND + (int) i);
+ }
}
RETURN(E_NO_MATCH);
}
diff --git a/lib/libform/frm_scale.c b/lib/libform/frm_scale.c
index 45ef3c1c8a3..cd76e6ac7e4 100644
--- a/lib/libform/frm_scale.c
+++ b/lib/libform/frm_scale.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_scale.c,v 1.4 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_scale.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_scale.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,19 +45,21 @@ MODULE_ID("$From: frm_scale.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_NOT_CONNECTED - no fields connected to form
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-scale_form (const FORM * form, int * rows, int * cols)
+scale_form(const FORM *form, int *rows, int *cols)
{
- if ( !form )
+ T((T_CALLED("scale_form(%p,%p,%p)"), form, rows, cols));
+
+ if (!form)
RETURN(E_BAD_ARGUMENT);
- if ( !(form->field) )
+ if (!(form->field))
RETURN(E_NOT_CONNECTED);
-
- if (rows)
+
+ if (rows)
*rows = form->rows;
- if (cols)
+ if (cols)
*cols = form->cols;
-
+
RETURN(E_OK);
}
diff --git a/lib/libform/frm_sub.c b/lib/libform/frm_sub.c
index 6a6f50278b5..0a1f9336cc1 100644
--- a/lib/libform/frm_sub.c
+++ b/lib/libform/frm_sub.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_sub.c,v 1.4 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_sub.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_sub.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,14 +44,16 @@ MODULE_ID("$From: frm_sub.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_sub (FORM * form, WINDOW * win)
+set_form_sub(FORM *form, WINDOW *win)
{
- if (form && (form->status & _POSTED))
+ T((T_CALLED("set_form_sub(%p,%p)"), form, win));
+
+ if (form && (form->status & _POSTED))
RETURN(E_POSTED);
- Normalize_Form( form )->sub = win;
+ Normalize_Form(form)->sub = win;
RETURN(E_OK);
-}
+}
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -64,10 +64,14 @@ set_form_sub (FORM * form, WINDOW * win)
| Return Values : The pointer to the Subwindow.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-form_sub (const FORM * form)
+form_sub(const FORM *form)
{
- const FORM* f = Normalize_Form( form );
- return Get_Form_Window(f);
+ const FORM *f;
+
+ T((T_CALLED("form_sub(%p)"), form));
+
+ f = Normalize_Form(form);
+ returnWin(Get_Form_Window(f));
}
/* frm_sub.c ends here */
diff --git a/lib/libform/frm_user.c b/lib/libform/frm_user.c
index 96bfab481ab..75b27457d87 100644
--- a/lib/libform/frm_user.c
+++ b/lib/libform/frm_user.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_user.c,v 1.6 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_user.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_user.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,8 +44,10 @@ MODULE_ID("$From: frm_user.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_userptr (FORM * form, void *usrptr)
+set_form_userptr(FORM *form, void *usrptr)
{
+ T((T_CALLED("set_form_userptr(%p,%p)"), form, usrptr));
+
Normalize_Form(form)->usrptr = usrptr;
RETURN(E_OK);
}
@@ -63,9 +63,10 @@ set_form_userptr (FORM * form, void *usrptr)
| NULL is returned
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-form_userptr (const FORM * form)
+form_userptr(const FORM *form)
{
- return Normalize_Form(form)->usrptr;
+ T((T_CALLED("form_userptr(%p)"), form));
+ returnVoidPtr(Normalize_Form(form)->usrptr);
}
/* frm_user.c ends here */
diff --git a/lib/libform/frm_win.c b/lib/libform/frm_win.c
index d428b6d274c..eb1d64a755c 100644
--- a/lib/libform/frm_win.c
+++ b/lib/libform/frm_win.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_win.c,v 1.6 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_win.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_win.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,14 +44,16 @@ MODULE_ID("$From: frm_win.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_win (FORM * form, WINDOW * win)
+set_form_win(FORM *form, WINDOW *win)
{
- if (form && (form->status & _POSTED))
+ T((T_CALLED("set_form_win(%p,%p)"), form, win));
+
+ if (form && (form->status & _POSTED))
RETURN(E_POSTED);
- Normalize_Form( form )->win = win;
+ Normalize_Form(form)->win = win;
RETURN(E_OK);
-}
+}
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -64,11 +64,14 @@ set_form_win (FORM * form, WINDOW * win)
| Return Values : The pointer to the Window or stdscr if there is none.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-form_win (const FORM * form)
+form_win(const FORM *form)
{
- const FORM* f = Normalize_Form( form );
- return (f->win ? f->win : stdscr);
+ const FORM *f;
+
+ T((T_CALLED("form_win(%p)"), form));
+
+ f = Normalize_Form(form);
+ returnWin(f->win ? f->win : stdscr);
}
/* frm_win.c ends here */
-
diff --git a/lib/libform/fty_alnum.c b/lib/libform/fty_alnum.c
index 61a4fb7ab78..f25b094edc7 100644
--- a/lib/libform/fty_alnum.c
+++ b/lib/libform/fty_alnum.c
@@ -1,139 +1,167 @@
-/* $OpenBSD: fty_alnum.c,v 1.7 2007/03/20 03:40:05 tedu Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_alnum.c,v 1.10 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_alnum.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+
+#define thisARG alnumARG
-typedef struct {
- int width;
-} alnumARG;
+typedef struct
+ {
+ int width;
+ }
+thisARG;
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Make_AlphaNumeric_Type(va_list *ap)
-|
+| Facility : libnform
+| Function : static void *Make_This_Type(va_list *ap)
+|
| Description : Allocate structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_AlphaNumeric_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- alnumARG *argp = (alnumARG *)malloc(sizeof(alnumARG));
+ thisARG *argp = typeMalloc(thisARG, 1);
if (argp)
- argp->width = va_arg(*ap,int);
+ {
+ T((T_CREATE("thisARG %p"), argp));
+ argp->width = va_arg(*ap, int);
+ }
return ((void *)argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Copy_AlphaNumericType(const void *argp)
-|
-| Description : Copy structure for alphanumeric type argument.
+| Facility : libnform
+| Function : static void *Copy_ThisType(const void *argp)
+|
+| Description : Copy structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_AlphaNumeric_Type(const void *argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const alnumARG *ap = (const alnumARG *)argp;
- alnumARG *result = (alnumARG *)malloc(sizeof(alnumARG));
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = typeMalloc(thisARG, 1);
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("thisARG %p"), result));
+ *result = *ap;
+ }
return ((void *)result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void Free_AlphaNumeric_Type(void *argp)
-|
+| Facility : libnform
+| Function : static void Free_This_Type(void *argp)
+|
| Description : Free structure for alphanumeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_AlphaNumeric_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_AlphaNumeric_Field(
-| FIELD *field,
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
| const void *argp)
-|
-| Description : Validate buffer content to be a valid alphanumeric value
|
-| Return Values : TRUE - field is valid
-| FALSE - field is invalid
+| Description : Check a character for the alphanumeric type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
{
- int width = ((const alnumARG *)argp)->width;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- int l = -1;
- unsigned char *s;
-
- while(*bp==' ')
- bp++;
- if (*bp)
- {
- s = bp;
- while(isalnum(*bp))
- bp++;
- l = (int)(bp-s);
- while(*bp==' ')
- bp++;
- }
- return ((*bp || (l < width)) ? FALSE : TRUE);
+#if USE_WIDEC_SUPPORT
+ if (iswalnum((wint_t) c))
+ return TRUE;
+#endif
+ return (isalnum(UChar(c)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_AlphaNumeric_Character(
-| int c,
-| const void *argp )
-|
-| Description : Check a character for the alphanumeric type.
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD *field,
+| const void *argp)
|
-| Return Values : TRUE - character is valid
-| FALSE - character is invalid
+| Description : Validate buffer content to be a valid alphanumeric value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- return (isalnum(c) ? TRUE : FALSE);
+ int width = ((const thisARG *)argp)->width;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ bool result = (width < 0);
+
+ Check_CTYPE_Field(result, bp, width, Check_This_Character);
+ return (result);
}
-static FIELDTYPE typeALNUM = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_AlphaNumeric_Type,
- Copy_AlphaNumeric_Type,
- Free_AlphaNumeric_Type,
- Check_AlphaNumeric_Field,
- Check_AlphaNumeric_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeALNUM;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeTHIS;
/* fty_alnum.c ends here */
diff --git a/lib/libform/fty_alpha.c b/lib/libform/fty_alpha.c
index 34b2a4b4fe8..3587e911138 100644
--- a/lib/libform/fty_alpha.c
+++ b/lib/libform/fty_alpha.c
@@ -1,140 +1,167 @@
-/* $OpenBSD: fty_alpha.c,v 1.7 2007/03/20 03:40:05 tedu Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_alpha.c,v 1.10 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_alpha.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+
+#define thisARG alphaARG
-typedef struct {
- int width;
-} alphaARG;
+typedef struct
+ {
+ int width;
+ }
+thisARG;
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Make_Alpha_Type(va_list *ap)
-|
+| Facility : libnform
+| Function : static void *Make_This_Type(va_list *ap)
+|
| Description : Allocate structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_Alpha_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- alphaARG *argp = (alphaARG *)malloc(sizeof(alphaARG));
+ thisARG *argp = typeMalloc(thisARG, 1);
+
if (argp)
{
- argp->width = va_arg(*ap,int);
+ T((T_CREATE("thisARG %p"), argp));
+ argp->width = va_arg(*ap, int);
}
+
return ((void *)argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Copy_Alpha_Type(const void * argp)
-|
-| Description : Copy structure for alpha type argument.
+| Facility : libnform
+| Function : static void *Copy_This_Type(const void * argp)
+|
+| Description : Copy structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_Alpha_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const alphaARG *ap = (const alphaARG *)argp;
- alphaARG *result = (alphaARG *)malloc(sizeof(alphaARG));
-
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = typeMalloc(thisARG, 1);
+
if (result)
{
+ T((T_CREATE("thisARG %p"), result));
*result = *ap;
}
+
return ((void *)result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void Free_Alpha_Type( void * argp )
-|
+| Facility : libnform
+| Function : static void Free_This_Type(void *argp)
+|
| Description : Free structure for alpha type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Alpha_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Alpha_Field(
-| FIELD * field,
-| const void * argp)
-|
-| Description : Validate buffer content to be a valid alpha value
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
+| const void *argp)
|
-| Return Values : TRUE - field is valid
-| FALSE - field is invalid
+| Description : Check a character for the alpha type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Alpha_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
{
- int width = ((const alphaARG *)argp)->width;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- int l = -1;
- unsigned char *s;
-
- while(*bp==' ')
- bp++;
- if (*bp)
- {
- s = bp;
- while(isalpha(*bp))
- bp++;
- l = (int)(bp-s);
- while(*bp==' ')
- bp++;
- }
- return ((*bp || (l < width)) ? FALSE : TRUE);
+#if USE_WIDEC_SUPPORT
+ if (iswalpha((wint_t) c))
+ return TRUE;
+#endif
+ return (isalpha(UChar(c)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Alpha_Character(
-| int c,
-| const void * argp)
-|
-| Description : Check a character for the alpha type.
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD *field,
+| const void *argp)
|
-| Return Values : TRUE - character is valid
-| FALSE - character is invalid
+| Description : Validate buffer content to be a valid alpha value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Alpha_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- return (isalpha(c) ? TRUE : FALSE);
+ int width = ((const thisARG *)argp)->width;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ bool result = (width < 0);
+
+ Check_CTYPE_Field(result, bp, width, Check_This_Character);
+ return (result);
}
-static FIELDTYPE typeALPHA = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_Alpha_Type,
- Copy_Alpha_Type,
- Free_Alpha_Type,
- Check_Alpha_Field,
- Check_Alpha_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeALPHA;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
/* fty_alpha.c ends here */
diff --git a/lib/libform/fty_enum.c b/lib/libform/fty_enum.c
index adf61a7c384..4c9201b4cf0 100644
--- a/lib/libform/fty_enum.c
+++ b/lib/libform/fty_enum.c
@@ -1,28 +1,49 @@
-/* $OpenBSD: fty_enum.c,v 1.9 2001/01/22 18:02:17 millert Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_enum.c,v 1.15 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_enum.c,v 1.10 2010/01/12 23:22:07 nicm Exp $")
-typedef struct {
- char **kwds;
- int count;
- bool checkcase;
- bool checkunique;
-} enumARG;
+typedef struct
+ {
+ char **kwds;
+ int count;
+ bool checkcase;
+ bool checkunique;
+ }
+enumARG;
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -32,9 +53,10 @@ typedef struct {
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_Enum_Type(va_list * ap)
+static void *
+Make_Enum_Type(va_list *ap)
{
- enumARG *argp = (enumARG *)malloc(sizeof(enumARG));
+ enumARG *argp = typeMalloc(enumARG, 1);
if (argp)
{
@@ -42,14 +64,17 @@ static void *Make_Enum_Type(va_list * ap)
char **kp = (char **)0;
int ccase, cunique;
- argp->kwds = va_arg(*ap,char **);
- ccase = va_arg(*ap,int);
- cunique = va_arg(*ap,int);
- argp->checkcase = ccase ? TRUE : FALSE;
+ T((T_CREATE("enumARG %p"), argp));
+ argp->kwds = va_arg(*ap, char **);
+ ccase = va_arg(*ap, int);
+ cunique = va_arg(*ap, int);
+
+ argp->checkcase = ccase ? TRUE : FALSE;
argp->checkunique = cunique ? TRUE : FALSE;
kp = argp->kwds;
- while( kp && (*kp++) ) cnt++;
+ while (kp && (*kp++))
+ cnt++;
argp->count = cnt;
}
return (void *)argp;
@@ -63,7 +88,8 @@ static void *Make_Enum_Type(va_list * ap)
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_Enum_Type(const void * argp)
+static void *
+Copy_Enum_Type(const void *argp)
{
enumARG *result = (enumARG *)0;
@@ -71,9 +97,13 @@ static void *Copy_Enum_Type(const void * argp)
{
const enumARG *ap = (const enumARG *)argp;
- result = (enumARG *)malloc(sizeof(enumARG));
+ result = typeMalloc(enumARG, 1);
+
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("enumARG %p"), result));
+ *result = *ap;
+ }
}
return (void *)result;
}
@@ -86,9 +116,10 @@ static void *Copy_Enum_Type(const void * argp)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Enum_Type(void * argp)
+static void
+Free_Enum_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
@@ -103,37 +134,40 @@ static void Free_Enum_Type(void * argp)
| const unsigned char * buf,
| bool ccase )
|
-| Description : Check wether or not the text in 'buf' matches the
+| Description : Check whether or not the text in 'buf' matches the
| text in 's', at least partial.
|
| Return Values : NOMATCH - buffer doesn't match
| PARTIAL - buffer matches partially
| EXACT - buffer matches exactly
+--------------------------------------------------------------------------*/
-static int Compare(const unsigned char *s, const unsigned char *buf,
- bool ccase)
+static int
+Compare(const unsigned char *s, const unsigned char *buf,
+ bool ccase)
{
- SKIP_SPACE(buf); /* Skip leading spaces in both texts */
+ SKIP_SPACE(buf); /* Skip leading spaces in both texts */
SKIP_SPACE(s);
- if (*buf=='\0')
+ if (*buf == '\0')
{
- return (((*s)!='\0') ? NOMATCH : EXACT);
- }
- else
+ return (((*s) != '\0') ? NOMATCH : EXACT);
+ }
+ else
{
if (ccase)
{
- while(*s++ == *buf)
+ while (*s++ == *buf)
{
- if (*buf++=='\0') return EXACT;
- }
- }
- else
+ if (*buf++ == '\0')
+ return EXACT;
+ }
+ }
+ else
{
- while(toupper(*s++)==toupper(*buf))
+ while (toupper(*s++) == toupper(*buf))
{
- if (*buf++=='\0') return EXACT;
+ if (*buf++ == '\0')
+ return EXACT;
}
}
}
@@ -141,12 +175,12 @@ static int Compare(const unsigned char *s, const unsigned char *buf,
matches with s. So if only blanks are following, we have a partial
match otherwise there is no match */
SKIP_SPACE(buf);
- if (*buf)
+ if (*buf)
return NOMATCH;
/* If it happens that the reference buffer is at its end, the partial
match is actually an exact match. */
- return ((s[-1]!='\0') ? PARTIAL : EXACT);
+ return ((s[-1] != '\0') ? PARTIAL : EXACT);
}
/*---------------------------------------------------------------------------
@@ -160,27 +194,28 @@ static int Compare(const unsigned char *s, const unsigned char *buf,
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Enum_Field(FIELD * field, const void * argp)
+static bool
+Check_Enum_Field(FIELD *field, const void *argp)
{
- char **kwds = ((const enumARG *)argp)->kwds;
- bool ccase = ((const enumARG *)argp)->checkcase;
- bool unique = ((const enumARG *)argp)->checkunique;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
+ char **kwds = ((const enumARG *)argp)->kwds;
+ bool ccase = ((const enumARG *)argp)->checkcase;
+ bool unique = ((const enumARG *)argp)->checkunique;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
char *s, *t, *p;
int res;
-
- while( kwds && (s=(*kwds++)) )
+
+ while (kwds && (s = (*kwds++)))
{
- if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH)
+ if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH)
{
- p=t=s; /* t is at least a partial match */
- if ((unique && res!=EXACT))
+ p = t = s; /* t is at least a partial match */
+ if ((unique && res != EXACT))
{
- while( kwds && (p = *kwds++) )
+ while (kwds && (p = *kwds++))
{
- if ((res=Compare((unsigned char *)p,bp,ccase))!=NOMATCH)
+ if ((res = Compare((unsigned char *)p, bp, ccase)) != NOMATCH)
{
- if (res==EXACT)
+ if (res == EXACT)
{
t = p;
break;
@@ -189,10 +224,10 @@ static bool Check_Enum_Field(FIELD * field, const void * argp)
t = (char *)0;
}
}
- }
+ }
if (t)
{
- set_field_buffer(field,0,t);
+ set_field_buffer(field, 0, t);
return TRUE;
}
if (!p)
@@ -202,7 +237,8 @@ static bool Check_Enum_Field(FIELD * field, const void * argp)
return FALSE;
}
-static const char *dummy[] = { (char *)0 };
+static const char *dummy[] =
+{(char *)0};
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -214,28 +250,30 @@ static const char *dummy[] = { (char *)0 };
| Return Values : TRUE - next value found and loaded
| FALSE - no next value loaded
+--------------------------------------------------------------------------*/
-static bool Next_Enum(FIELD * field, const void * argp)
+static bool
+Next_Enum(FIELD *field, const void *argp)
{
const enumARG *args = (const enumARG *)argp;
- char **kwds = args->kwds;
- bool ccase = args->checkcase;
- int cnt = args->count;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
+ char **kwds = args->kwds;
+ bool ccase = args->checkcase;
+ int cnt = args->count;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
- if (kwds) {
- while(cnt--)
- {
- if (Compare((unsigned char *)(*kwds++),bp,ccase)==EXACT)
- break;
- }
- if (cnt<=0)
- kwds = args->kwds;
- if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
- {
- set_field_buffer(field,0,*kwds);
- return TRUE;
- }
- }
+ if (kwds)
+ {
+ while (cnt--)
+ {
+ if (Compare((unsigned char *)(*kwds++), bp, ccase) == EXACT)
+ break;
+ }
+ if (cnt <= 0)
+ kwds = args->kwds;
+ if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
+ {
+ set_field_buffer(field, 0, *kwds);
+ return TRUE;
+ }
+ }
return FALSE;
}
@@ -250,37 +288,39 @@ static bool Next_Enum(FIELD * field, const void * argp)
| Return Values : TRUE - previous value found and loaded
| FALSE - no previous value loaded
+--------------------------------------------------------------------------*/
-static bool Previous_Enum(FIELD * field, const void * argp)
+static bool
+Previous_Enum(FIELD *field, const void *argp)
{
const enumARG *args = (const enumARG *)argp;
- int cnt = args->count;
- char **kwds = &args->kwds[cnt-1];
- bool ccase = args->checkcase;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
+ int cnt = args->count;
+ char **kwds = &args->kwds[cnt - 1];
+ bool ccase = args->checkcase;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
- if (kwds) {
- while(cnt--)
- {
- if (Compare((unsigned char *)(*kwds--),bp,ccase)==EXACT)
- break;
- }
-
- if (cnt<=0)
- kwds = &args->kwds[args->count-1];
-
- if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
- {
- set_field_buffer(field,0,*kwds);
- return TRUE;
- }
- }
+ if (kwds)
+ {
+ while (cnt--)
+ {
+ if (Compare((unsigned char *)(*kwds--), bp, ccase) == EXACT)
+ break;
+ }
+
+ if (cnt <= 0)
+ kwds = &args->kwds[args->count - 1];
+
+ if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
+ {
+ set_field_buffer(field, 0, *kwds);
+ return TRUE;
+ }
+ }
return FALSE;
}
-
-static FIELDTYPE typeENUM = {
+static FIELDTYPE typeENUM =
+{
_HAS_ARGS | _HAS_CHOICE | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_Enum_Type,
@@ -292,6 +332,7 @@ static FIELDTYPE typeENUM = {
Previous_Enum
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ENUM = &typeENUM;
+NCURSES_EXPORT_VAR(FIELDTYPE *)
+TYPE_ENUM = &typeENUM;
/* fty_enum.c ends here */
diff --git a/lib/libform/fty_int.c b/lib/libform/fty_int.c
index 5cc185e5e5c..7b7848608df 100644
--- a/lib/libform/fty_int.c
+++ b/lib/libform/fty_int.c
@@ -1,135 +1,217 @@
-/* $OpenBSD: fty_int.c,v 1.7 2003/04/05 13:41:43 espie Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_int.c,v 1.11 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_int.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
-typedef struct {
- int precision;
- long low;
- long high;
-} integerARG;
+#define thisARG integerARG
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+thisARG;
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void *Make_Integer_Type( va_list * ap )
+| Function : static void *Make_This_Type( va_list * ap )
|
| Description : Allocate structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_Integer_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- integerARG *argp = (integerARG *)malloc(sizeof(integerARG));
+ thisARG *argp = typeMalloc(thisARG, 1);
if (argp)
{
- argp->precision = va_arg(*ap,int);
- argp->low = va_arg(*ap,long);
- argp->high = va_arg(*ap,long);
+ T((T_CREATE("thisARG %p"), argp));
+ argp->precision = va_arg(*ap, int);
+ argp->low = va_arg(*ap, long);
+ argp->high = va_arg(*ap, long);
}
return (void *)argp;
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void *Copy_Integer_Type(const void * argp)
+| Function : static void *Copy_This_Type(const void * argp)
|
| Description : Copy structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_Integer_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const integerARG *ap = (const integerARG *)argp;
- integerARG *result = (integerARG *)0;
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = (thisARG *) 0;
if (argp)
{
- result = (integerARG *)malloc(sizeof(integerARG));
+ result = typeMalloc(thisARG, 1);
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("thisARG %p"), result));
+ *result = *ap;
+ }
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void Free_Integer_Type(void * argp)
+| Function : static void Free_This_Type(void * argp)
|
| Description : Free structure for integer type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Integer_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Check_Integer_Field(
-| FIELD * field,
-| const void * argp)
+| Function : static bool Check_This_Field(
+| FIELD * field,
+| const void * argp)
|
| Description : Validate buffer content to be a valid integer value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Integer_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- const integerARG *argi = (const integerARG *)argp;
- long low = argi->low;
- long high = argi->high;
- int prec = argi->precision;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- char *s = (char *)bp;
+ const thisARG *argi = (const thisARG *)argp;
+ long low = argi->low;
+ long high = argi->high;
+ int prec = argi->precision;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ char *s = (char *)bp;
long val;
char buf[100];
+ bool result = FALSE;
- while( *bp && *bp==' ') bp++;
+ while (*bp && *bp == ' ')
+ bp++;
if (*bp)
{
- if (*bp=='-') bp++;
+ if (*bp == '-')
+ bp++;
+#if USE_WIDEC_SUPPORT
+ if (*bp)
+ {
+ bool blank = FALSE;
+ int len;
+ int n;
+ wchar_t *list = _nc_Widen_String((char *)bp, &len);
+
+ if (list != 0)
+ {
+ result = TRUE;
+ for (n = 0; n < len; ++n)
+ {
+ if (blank)
+ {
+ if (list[n] != ' ')
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ else if (list[n] == ' ')
+ {
+ blank = TRUE;
+ }
+ else if (!isDigit(list[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ free(list);
+ }
+ }
+#else
while (*bp)
{
- if (!isdigit(*bp)) break;
+ if (!isdigit(UChar(*bp)))
+ break;
bp++;
}
- while(*bp && *bp==' ') bp++;
- if (*bp=='\0')
+ while (*bp && *bp == ' ')
+ bp++;
+ result = (*bp == '\0');
+#endif
+ if (result)
{
val = atol(s);
- if (low<high)
+ if (low < high)
{
- if (val<low || val>high) return FALSE;
+ if (val < low || val > high)
+ result = FALSE;
+ }
+ if (result)
+ {
+ snprintf(buf, sizeof(buf), "%.*ld", (prec > 0 ? prec : 0), val);
+ set_field_buffer(field, 0, buf);
}
- snprintf(buf, sizeof(buf), "%.*ld",(prec>0?prec:0),val);
- set_field_buffer(field,0,buf);
- return TRUE;
}
}
- return FALSE;
+ return (result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Check_Integer_Character(
+| Function : static bool Check_This_Character(
| int c,
| const void * argp)
|
@@ -138,25 +220,27 @@ static bool Check_Integer_Field(FIELD * field, const void * argp)
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Integer_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
{
- return ((isdigit(c) || (c=='-')) ? TRUE : FALSE);
+ return ((isDigit(UChar(c)) || (c == '-')) ? TRUE : FALSE);
}
-static FIELDTYPE typeINTEGER = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_Integer_Type,
- Copy_Integer_Type,
- Free_Integer_Type,
- Check_Integer_Field,
- Check_Integer_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeINTEGER;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS;
/* fty_int.c ends here */
diff --git a/lib/libform/fty_ipv4.c b/lib/libform/fty_ipv4.c
index 0cd429fdefa..d47655ef7cb 100644
--- a/lib/libform/fty_ipv4.c
+++ b/lib/libform/fty_ipv4.c
@@ -1,12 +1,31 @@
-/* $OpenBSD: fty_ipv4.c,v 1.5 2007/03/20 03:40:05 tedu Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
* Author : Per Foreby, perf@efd.lth.se *
@@ -15,7 +34,7 @@
#include "form.priv.h"
-MODULE_ID("$From: fty_ipv4.c,v 1.4 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_ipv4.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -28,24 +47,25 @@ MODULE_ID("$From: fty_ipv4.c,v 1.4 2000/12/09 23:46:12 tom Exp $")
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
+static bool
+Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
{
- char *bp = field_buffer(field,0);
+ char *bp = field_buffer(field, 0);
int num = 0, len;
unsigned int d1, d2, d3, d4;
- if(isdigit((unsigned char)*bp)) /* Must start with digit */
+ if (isdigit(UChar(*bp))) /* Must start with digit */
{
num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
if (num == 4)
- {
- bp += len; /* Make bp point to what sscanf() left */
- while (isspace((unsigned char)*bp))
- bp++; /* Allow trailing whitespace */
- }
+ {
+ bp += len; /* Make bp point to what sscanf() left */
+ while (isspace(UChar(*bp)))
+ bp++; /* Allow trailing whitespace */
+ }
}
return ((num != 4 || *bp || d1 > 255 || d2 > 255
- || d3 > 255 || d4 > 255) ? FALSE : TRUE);
+ || d3 > 255 || d4 > 255) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
@@ -59,14 +79,16 @@ static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_IPV4_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_IPV4_Character(int c, const void *argp GCC_UNUSED)
{
- return ((isdigit(c) || (c=='.')) ? TRUE : FALSE);
+ return ((isdigit(UChar(c)) || (c == '.')) ? TRUE : FALSE);
}
-static FIELDTYPE typeIPV4 = {
+static FIELDTYPE typeIPV4 =
+{
_RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
NULL,
diff --git a/lib/libform/fty_num.c b/lib/libform/fty_num.c
index c3bf889dc29..cafd6a504ce 100644
--- a/lib/libform/fty_num.c
+++ b/lib/libform/fty_num.c
@@ -1,197 +1,290 @@
-/* $OpenBSD: fty_num.c,v 1.7 2003/04/05 13:41:43 espie Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_num.c,v 1.14 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_num.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
#if HAVE_LOCALE_H
#include <locale.h>
#endif
-typedef struct {
- int precision;
- double low;
- double high;
- struct lconv* L;
-} numericARG;
+#if HAVE_LOCALE_H
+#define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.'))
+#else
+#define isDecimalPoint(c) ((c) == '.')
+#endif
+
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
+
+#define thisARG numericARG
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ struct lconv *L;
+ }
+thisARG;
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Make_Numeric_Type(va_list * ap)
-|
+| Facility : libnform
+| Function : static void *Make_This_Type(va_list * ap)
+|
| Description : Allocate structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_Numeric_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- numericARG *argn = (numericARG *)malloc(sizeof(numericARG));
+ thisARG *argn = typeMalloc(thisARG, 1);
if (argn)
{
- argn->precision = va_arg(*ap,int);
- argn->low = va_arg(*ap,double);
- argn->high = va_arg(*ap,double);
+ T((T_CREATE("thisARG %p"), argn));
+ argn->precision = va_arg(*ap, int);
+ argn->low = va_arg(*ap, double);
+ argn->high = va_arg(*ap, double);
+
#if HAVE_LOCALE_H
- argn->L = localeconv();
+ argn->L = localeconv();
#else
- argn->L = NULL;
+ argn->L = NULL;
#endif
}
return (void *)argn;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Copy_Numeric_Type(const void * argp)
-|
-| Description : Copy structure for numeric type argument.
+| Facility : libnform
+| Function : static void *Copy_This_Type(const void * argp)
+|
+| Description : Copy structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_Numeric_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const numericARG *ap = (const numericARG *)argp;
- numericARG *result = (numericARG *)0;
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = (thisARG *) 0;
if (argp)
{
- result = (numericARG *)malloc(sizeof(numericARG));
+ result = typeMalloc(thisARG, 1);
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("thisARG %p"), result));
+ *result = *ap;
+ }
}
return (void *)result;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void Free_Numeric_Type(void * argp)
-|
+| Facility : libnform
+| Function : static void Free_This_Type(void * argp)
+|
| Description : Free structure for numeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Numeric_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Numeric_Field(FIELD * field,
-| const void * argp)
-|
+| Facility : libnform
+| Function : static bool Check_This_Field(FIELD * field,
+| const void * argp)
+|
| Description : Validate buffer content to be a valid numeric value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Numeric_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- const numericARG *argn = (const numericARG *)argp;
- double low = argn->low;
- double high = argn->high;
- int prec = argn->precision;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- char *s = (char *)bp;
- double val = 0.0;
- struct lconv* L = argn->L;
+ const thisARG *argn = (const thisARG *)argp;
+ double low = argn->low;
+ double high = argn->high;
+ int prec = argn->precision;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ char *s = (char *)bp;
+ double val = 0.0;
+ struct lconv *L = argn->L;
char buf[64];
+ bool result = FALSE;
- while(*bp && *bp==' ') bp++;
+ while (*bp && *bp == ' ')
+ bp++;
if (*bp)
{
- if (*bp=='-' || *bp=='+')
+ if (*bp == '-' || *bp == '+')
bp++;
- while(*bp)
+#if USE_WIDEC_SUPPORT
+ if (*bp)
{
- if (!isdigit(*bp)) break;
+ bool blank = FALSE;
+ int state = 0;
+ int len;
+ int n;
+ wchar_t *list = _nc_Widen_String((char *)bp, &len);
+
+ if (list != 0)
+ {
+ result = TRUE;
+ for (n = 0; n < len; ++n)
+ {
+ if (blank)
+ {
+ if (list[n] != ' ')
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ else if (list[n] == ' ')
+ {
+ blank = TRUE;
+ }
+ else if (isDecimalPoint(list[n]))
+ {
+ if (++state > 1)
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ else if (!isDigit(list[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ free(list);
+ }
+ }
+#else
+ while (*bp)
+ {
+ if (!isdigit(UChar(*bp)))
+ break;
bp++;
}
- if (*bp==(
-#if HAVE_LOCALE_H
- (L && L->decimal_point) ? *(L->decimal_point) :
-#endif
- '.'))
+ if (isDecimalPoint(*bp))
{
bp++;
- while(*bp)
+ while (*bp)
{
- if (!isdigit(*bp)) break;
+ if (!isdigit(UChar(*bp)))
+ break;
bp++;
}
}
- while(*bp && *bp==' ') bp++;
- if (*bp=='\0')
+ while (*bp && *bp == ' ')
+ bp++;
+ result = (*bp == '\0');
+#endif
+ if (result)
{
val = atof(s);
- if (low<high)
+ if (low < high)
+ {
+ if (val < low || val > high)
+ result = FALSE;
+ }
+ if (result)
{
- if (val<low || val>high) return FALSE;
+ snprintf(buf, sizeof(buf), "%.*f", (prec > 0 ? prec : 0), val);
+ set_field_buffer(field, 0, buf);
}
- snprintf(buf, sizeof(buf), "%.*f",(prec>0?prec:0),val);
- set_field_buffer(field,0,buf);
- return TRUE;
}
}
- return FALSE;
+ return (result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Numeric_Character(
+| Facility : libnform
+| Function : static bool Check_This_Character(
| int c,
| const void * argp)
-|
+|
| Description : Check a character for the numeric type.
|
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Numeric_Character(int c, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp)
{
- const numericARG *argn = (const numericARG *)argp;
- struct lconv* L = argn->L;
+ const thisARG *argn = (const thisARG *)argp;
+ struct lconv *L = argn->L;
- return (isdigit(c) ||
- c == '+' ||
- c == '-' ||
- c == (
-#if HAVE_LOCALE_H
- (L && L->decimal_point) ? *(L->decimal_point) :
-#endif
- '.')
- ) ? TRUE : FALSE;
+ return ((isDigit(c) ||
+ c == '+' ||
+ c == '-' ||
+ isDecimalPoint(c))
+ ? TRUE
+ : FALSE);
}
-static FIELDTYPE typeNUMERIC = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_Numeric_Type,
- Copy_Numeric_Type,
- Free_Numeric_Type,
- Check_Numeric_Field,
- Check_Numeric_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeNUMERIC;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS;
/* fty_num.c ends here */
diff --git a/lib/libform/fty_regex.c b/lib/libform/fty_regex.c
index 8910777da19..28b94e42731 100644
--- a/lib/libform/fty_regex.c
+++ b/lib/libform/fty_regex.c
@@ -1,45 +1,67 @@
-/* $OpenBSD: fty_regex.c,v 1.7 2001/01/22 18:02:17 millert Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_regex.c,v 1.15 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_regex.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
-#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
+#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
#include <regex.h>
typedef struct
-{
- regex_t *pRegExp;
- unsigned long *refCount;
-} RegExp_Arg;
+ {
+ regex_t *pRegExp;
+ unsigned long *refCount;
+ }
+RegExp_Arg;
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
#undef RETURN
static int reg_errno;
-static char *RegEx_Init(char *instring)
+static char *
+RegEx_Init(char *instring)
{
- reg_errno = 0;
- return instring;
+ reg_errno = 0;
+ return instring;
}
-static char *RegEx_Error(int code)
+static char *
+RegEx_Error(int code)
{
- reg_errno = code;
- return 0;
+ reg_errno = code;
+ return 0;
}
#define INIT register char *sp = RegEx_Init(instring);
@@ -59,7 +81,8 @@ typedef struct
{
char *compiled_expression;
unsigned long *refCount;
-} RegExp_Arg;
+}
+RegExp_Arg;
/* Maximum Length we allow for a compiled regular expression */
#define MAX_RX_LEN (2048)
@@ -75,20 +98,25 @@ typedef struct
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_RegularExpression_Type(va_list * ap)
+static void *
+Make_RegularExpression_Type(va_list *ap)
{
#if HAVE_REGEX_H_FUNCS
- char *rx = va_arg(*ap,char *);
+ char *rx = va_arg(*ap, char *);
RegExp_Arg *preg;
- preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
+ preg = typeMalloc(RegExp_Arg, 1);
+
if (preg)
{
- if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
- && !regcomp(preg->pRegExp,rx,
- (REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
+ T((T_CREATE("RegExp_Arg %p"), preg));
+ if (((preg->pRegExp = typeMalloc(regex_t, 1)) != 0)
+ && !regcomp(preg->pRegExp, rx,
+ (REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
{
- preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+ T((T_CREATE("regex_t %p"), preg->pRegExp));
+ preg->refCount = typeMalloc(unsigned long, 1);
+
*(preg->refCount) = 1;
}
else
@@ -96,51 +124,58 @@ static void *Make_RegularExpression_Type(va_list * ap)
if (preg->pRegExp)
free(preg->pRegExp);
free(preg);
- preg = (RegExp_Arg*)0;
+ preg = (RegExp_Arg *)0;
}
}
- return((void *)preg);
+ return ((void *)preg);
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
- char *rx = va_arg(*ap,char *);
+ char *rx = va_arg(*ap, char *);
RegExp_Arg *pArg;
- pArg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
+ pArg = typeMalloc(RegExp_Arg, 1);
if (pArg)
{
int blen = RX_INCREMENT;
+
+ T((T_CREATE("RegExp_Arg %p"), pArg));
pArg->compiled_expression = NULL;
- pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+ pArg->refCount = typeMalloc(unsigned long, 1);
+
*(pArg->refCount) = 1;
- do {
- char *buf = (char *)malloc(blen);
- if (buf)
- {
+ do
+ {
+ char *buf = typeMalloc(char, blen);
+
+ if (buf)
+ {
#if HAVE_REGEXP_H_FUNCS
- char *last_pos = compile (rx, buf, &buf[blen], '\0');
+ char *last_pos = compile(rx, buf, &buf[blen], '\0');
+
#else /* HAVE_REGEXPR_H_FUNCS */
- char *last_pos = compile (rx, buf, &buf[blen]);
+ char *last_pos = compile(rx, buf, &buf[blen]);
#endif
- if (reg_errno)
- {
- free(buf);
- if (reg_errno==50)
- blen += RX_INCREMENT;
- else
- {
- free(pArg);
- pArg = NULL;
- break;
- }
- }
- else
- {
- pArg->compiled_expression = buf;
- break;
- }
- }
- } while( blen <= MAX_RX_LEN );
+ if (reg_errno)
+ {
+ free(buf);
+ if (reg_errno == 50)
+ blen += RX_INCREMENT;
+ else
+ {
+ free(pArg);
+ pArg = NULL;
+ break;
+ }
+ }
+ else
+ {
+ pArg->compiled_expression = buf;
+ break;
+ }
+ }
+ }
+ while (blen <= MAX_RX_LEN);
}
if (pArg && !pArg->compiled_expression)
{
@@ -162,7 +197,8 @@ static void *Make_RegularExpression_Type(va_list * ap)
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_RegularExpression_Type(const void * argp)
+static void *
+Copy_RegularExpression_Type(const void *argp)
{
#if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS)
const RegExp_Arg *ap = (const RegExp_Arg *)argp;
@@ -187,10 +223,12 @@ static void *Copy_RegularExpression_Type(const void * argp)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_RegularExpression_Type(void * argp)
+static void
+Free_RegularExpression_Type(void *argp)
{
#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
RegExp_Arg *ap = (RegExp_Arg *)argp;
+
if (ap)
{
if (--(*(ap->refCount)) == 0)
@@ -225,24 +263,33 @@ static void Free_RegularExpression_Type(void * argp)
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_RegularExpression_Field(FIELD * field, const void * argp)
+static bool
+Check_RegularExpression_Field(FIELD *field, const void *argp)
{
bool match = FALSE;
+
#if HAVE_REGEX_H_FUNCS
- const RegExp_Arg *ap = (const RegExp_Arg*)argp;
+ const RegExp_Arg *ap = (const RegExp_Arg *)argp;
+
if (ap && ap->pRegExp)
- match = (regexec(ap->pRegExp,field_buffer(field,0),0,NULL,0) ? FALSE:TRUE);
+ match = (regexec(ap->pRegExp, field_buffer(field, 0), 0, NULL, 0)
+ ? FALSE
+ : TRUE);
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
RegExp_Arg *ap = (RegExp_Arg *)argp;
+
if (ap && ap->compiled_expression)
- match = (step(field_buffer(field,0),ap->compiled_expression) ? TRUE:FALSE);
+ match = (step(field_buffer(field, 0), ap->compiled_expression)
+ ? TRUE
+ : FALSE);
#endif
return match;
}
-static FIELDTYPE typeREGEXP = {
+static FIELDTYPE typeREGEXP =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_RegularExpression_Type,
diff --git a/lib/libform/shlib_version b/lib/libform/shlib_version
index 012c14171d3..d9961ea9fef 100644
--- a/lib/libform/shlib_version
+++ b/lib/libform/shlib_version
@@ -1,2 +1,2 @@
-major=3
+major=4
minor=0
diff --git a/lib/libmenu/Makefile b/lib/libmenu/Makefile
index ede206b1067..fbf5facbe93 100644
--- a/lib/libmenu/Makefile
+++ b/lib/libmenu/Makefile
@@ -1,10 +1,10 @@
LIB= menu
WANTLINT=
-SRCS= m_adabind.c m_attribs.c m_cursor.c m_driver.c m_format.c \
+SRCS= m_attribs.c m_cursor.c m_driver.c m_format.c \
m_global.c m_hook.c m_item_cur.c m_item_nam.c m_item_new.c \
m_item_opt.c m_item_top.c m_item_use.c m_item_val.c m_item_vis.c \
m_items.c m_new.c m_opts.c m_pad.c m_pattern.c m_post.c \
- m_req_name.c m_scale.c m_spacing.c m_sub.c m_userptr.c m_win.c
+ m_req_name.c m_scale.c m_spacing.c m_sub.c m_trace.c m_userptr.c m_win.c
HDRS= menu.h eti.h
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H
MAN= menu.3tbl menu_attributes.3 menu_cursor.3 menu_driver.3 menu_format.3 \
diff --git a/lib/libmenu/READ.ME b/lib/libmenu/READ.ME
new file mode 100644
index 00000000000..56f1715cc04
--- /dev/null
+++ b/lib/libmenu/READ.ME
@@ -0,0 +1,42 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. --
+-- --
+-- Permission is hereby granted, free of charge, to any person obtaining a --
+-- copy of this software and associated documentation files (the --
+-- "Software"), to deal in the Software without restriction, including --
+-- without limitation the rights to use, copy, modify, merge, publish, --
+-- distribute, distribute with modifications, sublicense, and/or sell copies --
+-- of the Software, and to permit persons to whom the Software is furnished --
+-- to do so, subject to the following conditions: --
+-- --
+-- The above copyright notice and this permission notice shall be included --
+-- in all copies or substantial portions of the Software. --
+-- --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN --
+-- NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE --
+-- USE OR OTHER DEALINGS IN THE SOFTWARE. --
+-- --
+-- Except as contained in this notice, the name(s) of the above copyright --
+-- holders shall not be used in advertising or otherwise to promote the --
+-- sale, use or other dealings in this Software without prior written --
+-- authorization. --
+-------------------------------------------------------------------------------
+-- $Id: READ.ME,v 1.4 2010/01/12 23:22:07 nicm Exp $
+-------------------------------------------------------------------------------
+
+This is a clone of the menu library that is available with typical
+System V curses implementations (ETI).
+
+It is modelled after the documentation that comes for this library with
+a 386 based SVR4 implementation (ESIX).
+
+The development environment was and is an ELF based Linux system.
+
+For things that still need doing, see the TO-DO file in the top-level
+directory.
+
+Juergen Pfeifer
diff --git a/lib/libmenu/eti.h b/lib/libmenu/eti.h
index bf037d83143..d0df2de14be 100644
--- a/lib/libmenu/eti.h
+++ b/lib/libmenu/eti.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: eti.h,v 1.5 1999/05/17 03:04:18 millert Exp $ */
+/* $OpenBSD: eti.h,v 1.6 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +29,13 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
-#ifndef _ETI_ERRNO_H_
-#define _ETI_ERRNO_H_
+/* $Id: eti.h,v 1.6 2010/01/12 23:22:07 nicm Exp $ */
+
+#ifndef NCURSES_ETI_H_incl
+#define NCURSES_ETI_H_incl 1
#define E_OK (0)
#define E_SYSTEM_ERROR (-1)
diff --git a/lib/libmenu/m_attribs.c b/lib/libmenu/m_attribs.c
index 2008b8ec113..6b7f56f038f 100644
--- a/lib/libmenu/m_attribs.c
+++ b/lib/libmenu/m_attribs.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_attribs.c,v 1.6 2001/01/22 18:02:02 millert Exp $ */
+/* $OpenBSD: m_attribs.c,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_attribs.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_attribs.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/* Macro to redraw menu if it is posted and changed */
#define Refresh_Menu(menu) \
@@ -53,6 +53,7 @@ MODULE_ID("$From: m_attribs.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
#define GEN_MENU_ATTR_SET_FCT( name ) \
NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\
{\
+ T((T_CALLED("set_menu_" #name "(%p,%s)"), menu, _traceattr(attr)));\
if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
RETURN(E_BAD_ARGUMENT);\
if (menu && ( menu -> name != attr))\
@@ -64,11 +65,12 @@ NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\
RETURN(E_OK);\
}
-/* "Template" macro to generate a function to get a menus attribute */
+/* "Template" macro to generate a function to get a menu's attribute */
#define GEN_MENU_ATTR_GET_FCT( name ) \
NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
{\
- return (Normalize_Menu( menu ) -> name);\
+ T((T_CALLED("menu_" #name "(%p)"), menu));\
+ returnAttr(Normalize_Menu( menu ) -> name);\
}
/*---------------------------------------------------------------------------
@@ -76,14 +78,14 @@ NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
| Function : int set_menu_fore(MENU *menu, chtype attr)
|
| Description : Set the attribute for selectable items. In single-
-| valued menus thiis is used to highlight the current
+| valued menus this is used to highlight the current
| item ((i.e. where the cursor is), in multi-valued
| menus this is used to highlight the selected items.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( fore )
+GEN_MENU_ATTR_SET_FCT(fore)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -95,7 +97,7 @@ GEN_MENU_ATTR_SET_FCT( fore )
|
| Return Values : Attribute value
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( fore )
+GEN_MENU_ATTR_GET_FCT(fore)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -107,7 +109,7 @@ GEN_MENU_ATTR_GET_FCT( fore )
| Return Values : E_OK - success
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( back )
+GEN_MENU_ATTR_SET_FCT(back)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -118,7 +120,7 @@ GEN_MENU_ATTR_SET_FCT( back )
|
| Return Values : Attribute value
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( back )
+GEN_MENU_ATTR_GET_FCT(back)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -129,7 +131,7 @@ GEN_MENU_ATTR_GET_FCT( back )
| Return Values : E_OK - success
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( grey )
+GEN_MENU_ATTR_SET_FCT(grey)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -139,5 +141,5 @@ GEN_MENU_ATTR_SET_FCT( grey )
|
| Return Values : Attribute value
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( grey )
+GEN_MENU_ATTR_GET_FCT(grey)
/* m_attribs.c ends here */
diff --git a/lib/libmenu/m_cursor.c b/lib/libmenu/m_cursor.c
index 4562a46efec..a9bf98c5172 100644
--- a/lib/libmenu/m_cursor.c
+++ b/lib/libmenu/m_cursor.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_cursor.c,v 1.7 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_cursor.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,17 +29,17 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
* Module m_cursor *
-* Correctly position a menus cursor *
+* Correctly position a menu's cursor *
***************************************************************************/
#include "menu.priv.h"
-MODULE_ID("$From: m_cursor.c,v 1.14 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_cursor.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -52,24 +52,23 @@ MODULE_ID("$From: m_cursor.c,v 1.14 2000/12/10 02:16:48 tom Exp $")
| E_NOT_POSTED - Menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_menu_cursor_pos
-(const MENU* menu, const ITEM* item, int* pY, int* pX)
+_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
{
if (!menu || !pX || !pY)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
else
{
- if ((ITEM*)0 == item)
+ if ((ITEM *) 0 == item)
item = menu->curitem;
- assert(item!=(ITEM*)0);
+ assert(item != (ITEM *) 0);
- if ( !( menu->status & _POSTED ) )
- return(E_NOT_POSTED);
+ if (!(menu->status & _POSTED))
+ return (E_NOT_POSTED);
*pX = item->x * (menu->spc_cols + menu->itemlen);
*pY = (item->y - menu->toprow) * menu->spc_rows;
}
- return(E_OK);
+ return (E_OK);
}
/*---------------------------------------------------------------------------
@@ -83,24 +82,26 @@ _nc_menu_cursor_pos
| E_NOT_POSTED - Menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-pos_menu_cursor (const MENU * menu)
+pos_menu_cursor(const MENU * menu)
{
WINDOW *win, *sub;
- int x, y;
- int err = _nc_menu_cursor_pos(menu,(ITEM*)0,&y,&x);
+ int x = 0, y = 0;
+ int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);
- if (E_OK==err)
+ T((T_CALLED("pos_menu_cursor(%p)"), menu));
+
+ if (E_OK == err)
{
win = menu->userwin ? menu->userwin : stdscr;
sub = menu->usersub ? menu->usersub : win;
assert(win && sub);
if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
- x += ( menu->pindex + menu->marklen - 1);
+ x += (menu->pindex + menu->marklen - 1);
- wmove(sub,y,x);
+ wmove(sub, y, x);
- if ( win != sub )
+ if (win != sub)
{
wcursyncup(sub);
wsyncup(sub);
diff --git a/lib/libmenu/m_driver.c b/lib/libmenu/m_driver.c
index ccf9a82c9c8..6e08249575b 100644
--- a/lib/libmenu/m_driver.c
+++ b/lib/libmenu/m_driver.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_driver.c,v 1.7 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_driver.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_driver.c,v 1.18 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_driver.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/* Macros */
@@ -64,28 +64,31 @@ MODULE_ID("$From: m_driver.c,v 1.18 2000/12/10 02:16:48 tom Exp $")
| Return Values : TRUE - if it is a substring
| FALSE - if it is not a substring
+--------------------------------------------------------------------------*/
-static bool Is_Sub_String(
- bool IgnoreCaseFlag,
- const char *part,
- const char *string
- )
+static bool
+Is_Sub_String(
+ bool IgnoreCaseFlag,
+ const char *part,
+ const char *string
+)
{
- assert( part && string );
- if ( IgnoreCaseFlag )
+ assert(part && string);
+ if (IgnoreCaseFlag)
{
- while(*string && *part)
+ while (*string && *part)
{
- if (toupper(*string++)!=toupper(*part)) break;
+ if (toupper(UChar(*string++)) != toupper(UChar(*part)))
+ break;
part++;
}
}
else
{
- while( *string && *part )
- if (*part != *string++) break;
+ while (*string && *part)
+ if (*part != *string++)
+ break;
part++;
}
- return ( (*part) ? FALSE : TRUE );
+ return ((*part) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
@@ -115,73 +118,77 @@ static bool Is_Sub_String(
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
_nc_Match_Next_Character_In_Item_Name
-(MENU *menu, int ch, ITEM **item)
+(MENU * menu, int ch, ITEM ** item)
{
bool found = FALSE, passed = FALSE;
- int idx, last;
+ int idx, last;
+
+ T((T_CALLED("_nc_Match_Next_Character(%p,%d,%p)"), menu, ch, item));
- assert( menu && item && *item);
+ assert(menu && item && *item);
idx = (*item)->index;
- if (ch && ch!=BS)
+ if (ch && ch != BS)
{
/* if we become to long, we need no further checking : there can't be
- a match ! */
- if ((menu->pindex+1) > menu->namelen)
+ a match ! */
+ if ((menu->pindex + 1) > menu->namelen)
RETURN(E_NO_MATCH);
- Add_Character_To_Pattern(menu,ch);
+ Add_Character_To_Pattern(menu, ch);
/* we artificially position one item back, because in the do...while
- loop we start with the next item. This means, that with a new
- pattern search we always start the scan with the actual item. If
- we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
- one after or before the actual item. */
+ loop we start with the next item. This means, that with a new
+ pattern search we always start the scan with the actual item. If
+ we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
+ one after or before the actual item. */
if (--idx < 0)
- idx = menu->nitems-1;
+ idx = menu->nitems - 1;
}
last = idx; /* this closes the cycle */
- do{
- if (ch==BS)
- { /* we have to go backward */
- if (--idx < 0)
- idx = menu->nitems-1;
- }
- else
- { /* otherwise we always go forward */
- if (++idx >= menu->nitems)
- idx = 0;
- }
- if (Is_Sub_String((menu->opt & O_IGNORECASE) != 0,
- menu->pattern,
- menu->items[idx]->name.str)
+ do
+ {
+ if (ch == BS)
+ { /* we have to go backward */
+ if (--idx < 0)
+ idx = menu->nitems - 1;
+ }
+ else
+ { /* otherwise we always go forward */
+ if (++idx >= menu->nitems)
+ idx = 0;
+ }
+ if (Is_Sub_String((bool)((menu->opt & O_IGNORECASE) != 0),
+ menu->pattern,
+ menu->items[idx]->name.str)
)
- found = TRUE;
- else
- passed = TRUE;
- } while (!found && (idx != last));
+ found = TRUE;
+ else
+ passed = TRUE;
+ }
+ while (!found && (idx != last));
if (found)
{
- if (!((idx==(*item)->index) && passed))
+ if (!((idx == (*item)->index) && passed))
{
*item = menu->items[idx];
RETURN(E_OK);
}
/* This point is reached, if we fully cycled through the item list
- and the only match we found is the starting item. With a NEXT_PATTERN
- or PREV_PATTERN scan this means, that there was no additional match.
- If we searched with an expanded new pattern, we should never reach
- this point, because if the expanded pattern matches also the actual
- item we will find it in the first attempt (passed==FALSE) and we
- will never cycle through the whole item array.
- */
- assert( ch==0 || ch==BS );
+ and the only match we found is the starting item. With a NEXT_PATTERN
+ or PREV_PATTERN scan this means, that there was no additional match.
+ If we searched with an expanded new pattern, we should never reach
+ this point, because if the expanded pattern matches also the actual
+ item we will find it in the first attempt (passed==FALSE) and we
+ will never cycle through the whole item array.
+ */
+ assert(ch == 0 || ch == BS);
}
else
{
- if (ch && ch!=BS && menu->pindex>0)
+ if (ch && ch != BS && menu->pindex > 0)
{
/* if we had no match with a new pattern, we have to restore it */
Remove_Character_From_Pattern(menu);
@@ -203,7 +210,7 @@ _nc_Match_Next_Character_In_Item_Name
| E_NOT_POSTED - menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_driver (MENU * menu, int c)
+menu_driver(MENU * menu, int c)
{
#define NAVIGATE(dir) \
if (!item->dir)\
@@ -215,327 +222,332 @@ menu_driver (MENU * menu, int c)
ITEM *item;
int my_top_row, rdiff;
+ T((T_CALLED("menu_driver(%p,%d)"), menu, c));
+
if (!menu)
RETURN(E_BAD_ARGUMENT);
- if ( menu->status & _IN_DRIVER )
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( !( menu->status & _POSTED ) )
+ if (!(menu->status & _POSTED))
RETURN(E_NOT_POSTED);
item = menu->curitem;
- my_top_row = menu->toprow;
- assert(item);
-
- if ((c > KEY_MAX) && (c<=MAX_MENU_COMMAND))
- {
- if (!((c==REQ_BACK_PATTERN)
- || (c==REQ_NEXT_MATCH) || (c==REQ_PREV_MATCH)))
- {
- assert( menu->pattern );
- Reset_Pattern(menu);
- }
-
- switch(c)
- {
- case REQ_LEFT_ITEM:
+ my_top_row = menu->toprow;
+ assert(item);
+
+ if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND))
+ {
+ if (!((c == REQ_BACK_PATTERN)
+ || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH)))
+ {
+ assert(menu->pattern);
+ Reset_Pattern(menu);
+ }
+
+ switch (c)
+ {
+ case REQ_LEFT_ITEM:
/*=================*/
- NAVIGATE(left);
- break;
+ NAVIGATE(left);
+ break;
- case REQ_RIGHT_ITEM:
+ case REQ_RIGHT_ITEM:
/*==================*/
- NAVIGATE(right);
- break;
+ NAVIGATE(right);
+ break;
- case REQ_UP_ITEM:
+ case REQ_UP_ITEM:
/*===============*/
- NAVIGATE(up);
- break;
+ NAVIGATE(up);
+ break;
- case REQ_DOWN_ITEM:
+ case REQ_DOWN_ITEM:
/*=================*/
- NAVIGATE(down);
- break;
+ NAVIGATE(down);
+ break;
- case REQ_SCR_ULINE:
+ case REQ_SCR_ULINE:
/*=================*/
if (my_top_row == 0 || !(item->up))
- result = E_REQUEST_DENIED;
- else
- {
- --my_top_row;
- item = item->up;
- }
- break;
-
- case REQ_SCR_DLINE:
+ result = E_REQUEST_DENIED;
+ else
+ {
+ --my_top_row;
+ item = item->up;
+ }
+ break;
+
+ case REQ_SCR_DLINE:
/*=================*/
if ((my_top_row + menu->arows >= menu->rows) || !(item->down))
- {
- /* only if the menu has less items than rows, we can deny the
- request. Otherwise the epilogue of this routine adjusts the
- top row if necessary */
- result = E_REQUEST_DENIED;
- }
- else {
- my_top_row++;
+ {
+ /* only if the menu has less items than rows, we can deny the
+ request. Otherwise the epilogue of this routine adjusts the
+ top row if necessary */
+ result = E_REQUEST_DENIED;
+ }
+ else
+ {
+ my_top_row++;
item = item->down;
- }
- break;
+ }
+ break;
- case REQ_SCR_DPAGE:
+ case REQ_SCR_DPAGE:
/*=================*/
rdiff = menu->rows - (menu->arows + my_top_row);
- if (rdiff > menu->arows)
- rdiff = menu->arows;
- if (rdiff<=0)
- result = E_REQUEST_DENIED;
- else
- {
- my_top_row += rdiff;
- while(rdiff-- > 0 && item!=(ITEM*)0)
- item = item->down;
- }
- break;
-
- case REQ_SCR_UPAGE:
+ if (rdiff > menu->arows)
+ rdiff = menu->arows;
+ if (rdiff <= 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row += rdiff;
+ while (rdiff-- > 0 && item != 0 && item->down != 0)
+ item = item->down;
+ }
+ break;
+
+ case REQ_SCR_UPAGE:
/*=================*/
rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row;
- if (rdiff<=0)
- result = E_REQUEST_DENIED;
- else
- {
- my_top_row -= rdiff;
- while(rdiff-- && item!=(ITEM*)0)
- item = item->up;
- }
- break;
+ if (rdiff <= 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row -= rdiff;
+ while (rdiff-- > 0 && item != 0 && item->up != 0)
+ item = item->up;
+ }
+ break;
- case REQ_FIRST_ITEM:
+ case REQ_FIRST_ITEM:
/*==================*/
- item = menu->items[0];
- break;
+ item = menu->items[0];
+ break;
- case REQ_LAST_ITEM:
+ case REQ_LAST_ITEM:
/*=================*/
- item = menu->items[menu->nitems-1];
- break;
+ item = menu->items[menu->nitems - 1];
+ break;
- case REQ_NEXT_ITEM:
+ case REQ_NEXT_ITEM:
/*=================*/
- if ((item->index+1)>=menu->nitems)
- {
- if (menu->opt & O_NONCYCLIC)
- result = E_REQUEST_DENIED;
- else
- item = menu->items[0];
- }
- else
- item = menu->items[item->index + 1];
- break;
-
- case REQ_PREV_ITEM:
+ if ((item->index + 1) >= menu->nitems)
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[0];
+ }
+ else
+ item = menu->items[item->index + 1];
+ break;
+
+ case REQ_PREV_ITEM:
/*=================*/
- if (item->index<=0)
- {
- if (menu->opt & O_NONCYCLIC)
- result = E_REQUEST_DENIED;
- else
- item = menu->items[menu->nitems-1];
- }
- else
- item = menu->items[item->index - 1];
- break;
-
- case REQ_TOGGLE_ITEM:
- /*===================*/
- if (menu->opt & O_ONEVALUE)
- {
+ if (item->index <= 0)
+ {
+ if (menu->opt & O_NONCYCLIC)
result = E_REQUEST_DENIED;
- }
- else
- {
- if (menu->curitem->opt & O_SELECTABLE)
- {
- menu->curitem->value = !menu->curitem->value;
- Move_And_Post_Item(menu,menu->curitem);
- _nc_Show_Menu(menu);
- }
- else
- result = E_NOT_SELECTABLE;
- }
- break;
-
- case REQ_CLEAR_PATTERN:
+ else
+ item = menu->items[menu->nitems - 1];
+ }
+ else
+ item = menu->items[item->index - 1];
+ break;
+
+ case REQ_TOGGLE_ITEM:
+ /*===================*/
+ if (menu->opt & O_ONEVALUE)
+ {
+ result = E_REQUEST_DENIED;
+ }
+ else
+ {
+ if (menu->curitem->opt & O_SELECTABLE)
+ {
+ menu->curitem->value = !menu->curitem->value;
+ Move_And_Post_Item(menu, menu->curitem);
+ _nc_Show_Menu(menu);
+ }
+ else
+ result = E_NOT_SELECTABLE;
+ }
+ break;
+
+ case REQ_CLEAR_PATTERN:
/*=====================*/
- /* already cleared in prologue */
- break;
+ /* already cleared in prologue */
+ break;
- case REQ_BACK_PATTERN:
+ case REQ_BACK_PATTERN:
/*====================*/
- if (menu->pindex>0)
- {
- assert(menu->pattern);
- Remove_Character_From_Pattern(menu);
- pos_menu_cursor( menu );
- }
- else
- result = E_REQUEST_DENIED;
- break;
-
- case REQ_NEXT_MATCH:
+ if (menu->pindex > 0)
+ {
+ assert(menu->pattern);
+ Remove_Character_From_Pattern(menu);
+ pos_menu_cursor(menu);
+ }
+ else
+ result = E_REQUEST_DENIED;
+ break;
+
+ case REQ_NEXT_MATCH:
/*==================*/
- assert(menu->pattern);
- if (menu->pattern[0])
- result = _nc_Match_Next_Character_In_Item_Name(menu,0,&item);
- else
- {
- if ((item->index+1)<menu->nitems)
- item=menu->items[item->index+1];
- else
- {
- if (menu->opt & O_NONCYCLIC)
- result = E_REQUEST_DENIED;
- else
- item = menu->items[0];
- }
- }
- break;
-
- case REQ_PREV_MATCH:
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = _nc_Match_Next_Character_In_Item_Name(menu, 0, &item);
+ else
+ {
+ if ((item->index + 1) < menu->nitems)
+ item = menu->items[item->index + 1];
+ else
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[0];
+ }
+ }
+ break;
+
+ case REQ_PREV_MATCH:
/*==================*/
- assert(menu->pattern);
- if (menu->pattern[0])
- result = _nc_Match_Next_Character_In_Item_Name(menu,BS,&item);
- else
- {
- if (item->index)
- item = menu->items[item->index-1];
- else
- {
- if (menu->opt & O_NONCYCLIC)
- result = E_REQUEST_DENIED;
- else
- item = menu->items[menu->nitems-1];
- }
- }
- break;
-
- default:
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = _nc_Match_Next_Character_In_Item_Name(menu, BS, &item);
+ else
+ {
+ if (item->index)
+ item = menu->items[item->index - 1];
+ else
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[menu->nitems - 1];
+ }
+ }
+ break;
+
+ default:
/*======*/
- result = E_UNKNOWN_COMMAND;
- break;
- }
- }
- else
- { /* not a command */
- if ( !(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(c) )
- result = _nc_Match_Next_Character_In_Item_Name( menu, c, &item );
+ result = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ else
+ { /* not a command */
+ if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c)))
+ result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item);
#ifdef NCURSES_MOUSE_VERSION
- else if (KEY_MOUSE == c)
- {
- MEVENT event;
- WINDOW* uwin = Get_Menu_UserWin(menu);
-
- getmouse(&event);
- if ((event.bstate & (BUTTON1_CLICKED |
- BUTTON1_DOUBLE_CLICKED |
- BUTTON1_TRIPLE_CLICKED ))
- && wenclose(uwin,event.y, event.x))
- { /* we react only if the click was in the userwin, that means
- * inside the menu display area or at the decoration window.
- */
- WINDOW* sub = Get_Menu_Window(menu);
- int ry = event.y, rx = event.x; /* screen coordinates */
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *uwin = Get_Menu_UserWin(menu);
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(uwin, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the menu display area or at the decoration window.
+ */
+ WINDOW *sub = Get_Menu_Window(menu);
+ int ry = event.y, rx = event.x; /* screen coordinates */
- result = E_REQUEST_DENIED;
- if (mouse_trafo(&ry,&rx,FALSE))
- { /* rx, ry are now "curses" coordinates */
- if (ry < sub->_begy)
- { /* we clicked above the display region; this is
- * interpreted as "scroll up" request
- */
- if (event.bstate & BUTTON1_CLICKED)
- result = menu_driver(menu,REQ_SCR_ULINE);
- else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
- result = menu_driver(menu,REQ_SCR_UPAGE);
- else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
- result = menu_driver(menu,REQ_FIRST_ITEM);
- RETURN(result);
- }
- else if (ry >= sub->_begy + sub->_maxy)
- { /* we clicked below the display region; this is
- * interpreted as "scroll down" request
- */
- if (event.bstate & BUTTON1_CLICKED)
- result = menu_driver(menu,REQ_SCR_DLINE);
- else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
- result = menu_driver(menu,REQ_SCR_DPAGE);
- else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
- result = menu_driver(menu,REQ_LAST_ITEM);
- RETURN(result);
- }
- else if (wenclose(sub,event.y,event.x))
- { /* Inside the area we try to find the hit item */
- int i,x,y,err;
- ry = event.y; rx = event.x;
- if (wmouse_trafo(sub,&ry,&rx,FALSE))
- {
- for(i=0;i<menu->nitems;i++)
- {
- err = _nc_menu_cursor_pos(menu,menu->items[i],
- &y, &x);
- if (E_OK==err)
- {
- if ((ry==y) &&
- (rx>=x) &&
- (rx < x + menu->itemlen))
- {
- item = menu->items[i];
- result = E_OK;
- break;
- }
- }
- }
- if (E_OK==result)
- { /* We found an item, now we can handle the click.
+ result = E_REQUEST_DENIED;
+ if (mouse_trafo(&ry, &rx, FALSE))
+ { /* rx, ry are now "curses" coordinates */
+ if (ry < sub->_begy)
+ { /* we clicked above the display region; this is
+ * interpreted as "scroll up" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ result = menu_driver(menu, REQ_SCR_ULINE);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ result = menu_driver(menu, REQ_SCR_UPAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ result = menu_driver(menu, REQ_FIRST_ITEM);
+ RETURN(result);
+ }
+ else if (ry > sub->_begy + sub->_maxy)
+ { /* we clicked below the display region; this is
+ * interpreted as "scroll down" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ result = menu_driver(menu, REQ_SCR_DLINE);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ result = menu_driver(menu, REQ_SCR_DPAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ result = menu_driver(menu, REQ_LAST_ITEM);
+ RETURN(result);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i, x, y, err;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ for (i = 0; i < menu->nitems; i++)
+ {
+ err = _nc_menu_cursor_pos(menu, menu->items[i],
+ &y, &x);
+ if (E_OK == err)
+ {
+ if ((ry == y) &&
+ (rx >= x) &&
+ (rx < x + menu->itemlen))
+ {
+ item = menu->items[i];
+ result = E_OK;
+ break;
+ }
+ }
+ }
+ if (E_OK == result)
+ { /* We found an item, now we can handle the click.
* A single click just positions the menu cursor
* to the clicked item. A double click toggles
* the item.
*/
- if (event.bstate & BUTTON1_DOUBLE_CLICKED)
- {
- _nc_New_TopRow_and_CurrentItem(menu,
- my_top_row,
- item);
- menu_driver(menu,REQ_TOGGLE_ITEM);
- result = E_UNKNOWN_COMMAND;
- }
- }
- }
- }
- }
- }
- else
- result = E_REQUEST_DENIED;
- }
+ if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ {
+ _nc_New_TopRow_and_CurrentItem(menu,
+ my_top_row,
+ item);
+ menu_driver(menu, REQ_TOGGLE_ITEM);
+ result = E_UNKNOWN_COMMAND;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ result = E_REQUEST_DENIED;
+ }
#endif /* NCURSES_MOUSE_VERSION */
- else
- result = E_UNKNOWN_COMMAND;
- }
+ else
+ result = E_UNKNOWN_COMMAND;
+ }
- if (E_OK==result)
+ if (E_OK == result)
{
- /* Adjust the top row if it turns out that the current item unfortunately
- doesn't appear in the menu window */
- if ( item->y < my_top_row )
- my_top_row = item->y;
- else if ( item->y >= (my_top_row + menu->arows) )
- my_top_row = item->y - menu->arows + 1;
-
- _nc_New_TopRow_and_CurrentItem( menu, my_top_row, item );
+ /* Adjust the top row if it turns out that the current item unfortunately
+ doesn't appear in the menu window */
+ if (item->y < my_top_row)
+ my_top_row = item->y;
+ else if (item->y >= (my_top_row + menu->arows))
+ my_top_row = item->y - menu->arows + 1;
+
+ _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item);
}
diff --git a/lib/libmenu/m_format.c b/lib/libmenu/m_format.c
index 8a16f001b9a..3a5fd3ab6dd 100644
--- a/lib/libmenu/m_format.c
+++ b/lib/libmenu/m_format.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_format.c,v 1.6 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_format.c,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,14 +39,14 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_format.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_format.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
#define minimum(a,b) ((a)<(b) ? (a): (b))
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : int set_menu_format(MENU *menu, int rows, int cols)
-|
+|
| Description : Sets the maximum number of rows and columns of items
| that may be displayed at one time on a menu. If the
| menu contains more items than can be displayed at
@@ -58,42 +58,44 @@ MODULE_ID("$From: m_format.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - the menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_format (MENU *menu, int rows, int cols)
+set_menu_format(MENU * menu, int rows, int cols)
{
int total_rows, total_cols;
-
- if (rows<0 || cols<0)
+
+ T((T_CALLED("set_menu_format(%p,%d,%d)"), menu, rows, cols));
+
+ if (rows < 0 || cols < 0)
RETURN(E_BAD_ARGUMENT);
-
+
if (menu)
{
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
+
if (!(menu->items))
RETURN(E_NOT_CONNECTED);
-
- if (rows==0)
+
+ if (rows == 0)
rows = menu->frows;
- if (cols==0)
+ if (cols == 0)
cols = menu->fcols;
-
+
if (menu->pattern)
Reset_Pattern(menu);
-
+
menu->frows = rows;
menu->fcols = cols;
-
- assert(rows>0 && cols>0);
- total_rows = (menu->nitems - 1)/cols + 1;
- total_cols = (menu->status & O_ROWMAJOR) ?
- minimum(menu->nitems,cols) :
- (menu->nitems-1)/total_rows + 1;
-
- menu->rows = total_rows;
- menu->cols = total_cols;
- menu->arows = minimum(total_rows,rows);
- menu->toprow = 0;
+
+ assert(rows > 0 && cols > 0);
+ total_rows = (menu->nitems - 1) / cols + 1;
+ total_cols = (menu->opt & O_ROWMAJOR) ?
+ minimum(menu->nitems, cols) :
+ (menu->nitems - 1) / total_rows + 1;
+
+ menu->rows = total_rows;
+ menu->cols = total_cols;
+ menu->arows = minimum(total_rows, rows);
+ menu->toprow = 0;
menu->curitem = *(menu->items);
assert(menu->curitem);
menu->status |= _LINK_NEEDED;
@@ -101,24 +103,26 @@ set_menu_format (MENU *menu, int rows, int cols)
}
else
{
- if (rows>0) _nc_Default_Menu.frows = rows;
- if (cols>0) _nc_Default_Menu.fcols = cols;
+ if (rows > 0)
+ _nc_Default_Menu.frows = rows;
+ if (cols > 0)
+ _nc_Default_Menu.fcols = cols;
}
-
+
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : void menu_format(const MENU *menu, int *rows, int *cols)
-|
+|
| Description : Returns the maximum number of rows and columns that may
| be displayed at one time on menu.
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-menu_format (const MENU *menu, int *rows, int *cols)
+menu_format(const MENU * menu, int *rows, int *cols)
{
if (rows)
*rows = Normalize_Menu(menu)->frows;
diff --git a/lib/libmenu/m_global.c b/lib/libmenu/m_global.c
index 762261bb017..af6fa156924 100644
--- a/lib/libmenu/m_global.c
+++ b/lib/libmenu/m_global.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_global.c,v 1.7 2003/01/05 22:41:37 deraadt Exp $ */
+/* $OpenBSD: m_global.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,8 +39,10 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_global.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_global.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+static char mark[] = "-";
+/* *INDENT-OFF* */
NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
16, /* Nr. of chars high */
1, /* Nr. of chars wide */
@@ -75,7 +77,7 @@ NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
(Menu_Hook)0, /* Item init */
(Menu_Hook)0, /* Item term */
(void *)0, /* userptr */
- "-", /* mark */
+ mark, /* mark */
ALL_MENU_OPTS, /* options */
0 /* status */
};
@@ -95,6 +97,7 @@ NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = {
(ITEM *)0, /* up */
(ITEM *)0 /* down */
};
+/* *INDENT-ON* */
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -105,24 +108,29 @@ NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = {
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
+NCURSES_INLINE static void
+ComputeMaximum_NameDesc_Lengths(MENU * menu)
{
- unsigned MaximumNameLength = 0;
+ unsigned MaximumNameLength = 0;
unsigned MaximumDescriptionLength = 0;
ITEM **items;
-
+ unsigned check;
+
assert(menu && menu->items);
- for( items = menu->items; *items ; items++ )
+ for (items = menu->items; *items; items++)
{
- if (items[0]->name.length > MaximumNameLength )
- MaximumNameLength = items[0]->name.length;
-
- if (items[0]->description.length > MaximumDescriptionLength)
- MaximumDescriptionLength = items[0]->description.length;
+ check = _nc_Calculate_Text_Width(&((*items)->name));
+ if (check > MaximumNameLength)
+ MaximumNameLength = check;
+
+ check = _nc_Calculate_Text_Width(&((*items)->description));
+ if (check > MaximumDescriptionLength)
+ MaximumDescriptionLength = check;
}
-
+
menu->namelen = MaximumNameLength;
menu->desclen = MaximumDescriptionLength;
+ T(("ComputeMaximum_NameDesc_Lengths %d,%d", menu->namelen, menu->desclen));
}
/*---------------------------------------------------------------------------
@@ -134,22 +142,23 @@ INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
+NCURSES_INLINE static void
+ResetConnectionInfo(MENU * menu, ITEM ** items)
{
ITEM **item;
-
+
assert(menu && items);
- for(item=items; *item; item++)
+ for (item = items; *item; item++)
{
(*item)->index = 0;
- (*item)->imenu = (MENU *)0;
+ (*item)->imenu = (MENU *) 0;
}
if (menu->pattern)
free(menu->pattern);
menu->pattern = (char *)0;
- menu->pindex = 0;
- menu->items = (ITEM **)0;
- menu->nitems = 0;
+ menu->pindex = 0;
+ menu->items = (ITEM **) 0;
+ menu->nitems = 0;
}
/*---------------------------------------------------------------------------
@@ -164,25 +173,25 @@ INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
| FALSE - connection failed
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-_nc_Connect_Items (MENU *menu, ITEM **items)
+_nc_Connect_Items(MENU * menu, ITEM ** items)
{
ITEM **item;
unsigned int ItemCount = 0;
-
- if ( menu && items )
- {
- for(item=items; *item ; item++)
+
+ if (menu && items)
+ {
+ for (item = items; *item; item++)
{
- if ( (*item)->imenu )
+ if ((*item)->imenu)
{
/* if a item is already connected, reject connection */
break;
}
}
- if (! (*item) )
+ if (!(*item))
/* we reached the end, so there was no connected item */
{
- for(item=items; *item ; item++)
+ for (item = items; *item; item++)
{
if (menu->opt & O_ONEVALUE)
{
@@ -190,31 +199,31 @@ _nc_Connect_Items (MENU *menu, ITEM **items)
}
(*item)->index = ItemCount++;
(*item)->imenu = menu;
- }
+ }
}
}
else
- return(FALSE);
-
+ return (FALSE);
+
if (ItemCount != 0)
{
- menu->items = items;
+ menu->items = items;
menu->nitems = ItemCount;
ComputeMaximum_NameDesc_Lengths(menu);
- if ( (menu->pattern = (char *)malloc( (unsigned)(1 + menu->namelen))) )
+ if ((menu->pattern = typeMalloc(char, (unsigned)(1 + menu->namelen))))
{
- Reset_Pattern(menu);
- set_menu_format(menu,menu->frows,menu->fcols);
+ Reset_Pattern(menu);
+ set_menu_format(menu, menu->frows, menu->fcols);
menu->curitem = *items;
menu->toprow = 0;
- return(TRUE);
+ return (TRUE);
}
}
-
+
/* If we fall through to this point, we have to reset all items connection
and inform about a reject connection */
- ResetConnectionInfo( menu, items );
- return(FALSE);
+ ResetConnectionInfo(menu, items);
+ return (FALSE);
}
/*---------------------------------------------------------------------------
@@ -226,14 +235,102 @@ _nc_Connect_Items (MENU *menu, ITEM **items)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Disconnect_Items (MENU * menu)
+_nc_Disconnect_Items(MENU * menu)
{
if (menu && menu->items)
- ResetConnectionInfo( menu, menu->items );
+ ResetConnectionInfo(menu, menu->items);
}
/*---------------------------------------------------------------------------
| Facility : libnmenu
+| Function : int _nc_Calculate_Text_Width(const TEXT * item)
+|
+| Description : Calculate the number of columns for a TEXT.
+|
+| Return Values : the width
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ )
+{
+#if USE_WIDEC_SUPPORT
+ int result = item->length;
+
+ T((T_CALLED("_nc_menu_text_width(%p)"), item));
+ if (result != 0 && item->str != 0)
+ {
+ int count = mbstowcs(0, item->str, 0);
+ wchar_t *temp = 0;
+
+ if (count > 0
+ && (temp = typeMalloc(wchar_t, 2 + count)) != 0)
+ {
+ int n;
+
+ result = 0;
+ mbstowcs(temp, item->str, (unsigned)count);
+ for (n = 0; n < count; ++n)
+ {
+ int test = wcwidth(temp[n]);
+
+ if (test <= 0)
+ test = 1;
+ result += test;
+ }
+ free(temp);
+ }
+ }
+ returnCode(result);
+#else
+ return item->length;
+#endif
+}
+
+/*
+ * Calculate the actual width of a menu entry for wide-characters.
+ */
+#if USE_WIDEC_SUPPORT
+static int
+calculate_actual_width(MENU * menu, bool name)
+{
+ int width = 0;
+ int check = 0;
+ ITEM **items;
+
+ assert(menu && menu->items);
+
+ if (menu->items != 0)
+ {
+ for (items = menu->items; *items; items++)
+ {
+ if (name)
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->name));
+ }
+ else
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->description));
+ }
+ if (check > width)
+ width = check;
+ }
+ }
+ else
+ {
+ width = (name ? menu->namelen : menu->desclen);
+ }
+
+ T(("calculate_actual_width %s = %d/%d",
+ name ? "name" : "desc",
+ width,
+ name ? menu->namelen : menu->desclen));
+ return width;
+}
+#else
+#define calculate_actual_width(menu, name) (name ? menu->namelen : menu->desclen)
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
| Function : void _nc_Calculate_Item_Length_and_Width(MENU *menu)
|
| Description : Calculate the length of an item and the width of the
@@ -242,93 +339,103 @@ _nc_Disconnect_Items (MENU * menu)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Calculate_Item_Length_and_Width (MENU * menu)
+_nc_Calculate_Item_Length_and_Width(MENU * menu)
{
int l;
-
+
assert(menu);
- menu->height = 1 + menu->spc_rows * (menu->arows - 1);
+ menu->height = 1 + menu->spc_rows * (menu->arows - 1);
+
+ l = calculate_actual_width(menu, TRUE);
+ l += menu->marklen;
+
+ if ((menu->opt & O_SHOWDESC) && (menu->desclen > 0))
+ {
+ l += calculate_actual_width(menu, FALSE);
+ l += menu->spc_desc;
+ }
- l = menu->namelen + menu->marklen;
- if ( (menu->opt & O_SHOWDESC) && (menu->desclen > 0) )
- l += (menu->desclen + menu->spc_desc);
-
menu->itemlen = l;
l *= menu->cols;
- l += (menu->cols-1)*menu->spc_cols; /* for the padding between the columns */
+ l += (menu->cols - 1) * menu->spc_cols; /* for the padding between the columns */
menu->width = l;
-}
+
+ T(("_nc_CalculateItem_Length_and_Width columns %d, item %d, width %d",
+ menu->cols,
+ menu->itemlen,
+ menu->width));
+}
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : void _nc_Link_Item(MENU *menu)
|
-| Description : Statically calculate for every item its four neighbours.
+| Description : Statically calculate for every item its four neighbors.
| This depends on the orientation of the menu. This
-| static aproach simplifies navigation in the menu a lot.
+| static approach simplifies navigation in the menu a lot.
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Link_Items (MENU * menu)
+_nc_Link_Items(MENU * menu)
{
if (menu && menu->items && *(menu->items))
{
- int i,j;
+ int i, j;
ITEM *item;
int Number_Of_Items = menu->nitems;
int col = 0, row = 0;
int Last_in_Row;
int Last_in_Column;
bool cycle = (menu->opt & O_NONCYCLIC) ? FALSE : TRUE;
-
+
menu->status &= ~_LINK_NEEDED;
-
+
if (menu->opt & O_ROWMAJOR)
{
int Number_Of_Columns = menu->cols;
-
- for(i=0; i < Number_Of_Items; i++)
+
+ for (i = 0; i < Number_Of_Items; i++)
{
item = menu->items[i];
-
- Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns-1);
-
- item->left = (col) ?
- /* if we are not in the leftmost column, we can use the
- predecessor in the items array */
- menu->items[i-1] :
- (cycle ? menu->items[(Last_in_Row>=Number_Of_Items) ?
- Number_Of_Items-1:
- Last_in_Row] :
- (ITEM *)0 );
-
- item->right = ( (col < (Number_Of_Columns-1)) &&
- ((i+1) < Number_Of_Items)
- ) ?
- menu->items[i+1] :
- ( cycle ? menu->items[row * Number_Of_Columns] :
- (ITEM *)0
- );
-
- Last_in_Column = (menu->rows-1) * Number_Of_Columns + col;
-
- item->up = (row) ? menu->items[i-Number_Of_Columns] :
- (cycle ? menu->items[(Last_in_Column>=Number_Of_Items) ?
- Number_Of_Items-1 :
- Last_in_Column] :
- (ITEM *)0);
-
- item->down = ( (i+Number_Of_Columns) < Number_Of_Items )
- ?
- menu->items[i + Number_Of_Columns] :
- (cycle ? menu->items[(row+1)<menu->rows ?
- Number_Of_Items-1:col] :
- (ITEM *)0);
+
+ Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns - 1);
+
+ item->left = (col) ?
+ /* if we are not in the leftmost column, we can use the
+ predecessor in the items array */
+ menu->items[i - 1] :
+ (cycle ? menu->items[(Last_in_Row >= Number_Of_Items) ?
+ Number_Of_Items - 1 :
+ Last_in_Row] :
+ (ITEM *) 0);
+
+ item->right = ((col < (Number_Of_Columns - 1)) &&
+ ((i + 1) < Number_Of_Items)
+ )?
+ menu->items[i + 1] :
+ (cycle ? menu->items[row * Number_Of_Columns] :
+ (ITEM *) 0
+ );
+
+ Last_in_Column = (menu->rows - 1) * Number_Of_Columns + col;
+
+ item->up = (row) ? menu->items[i - Number_Of_Columns] :
+ (cycle ? menu->items[(Last_in_Column >= Number_Of_Items) ?
+ Number_Of_Items - 1 :
+ Last_in_Column] :
+ (ITEM *) 0);
+
+ item->down = ((i + Number_Of_Columns) < Number_Of_Items)
+ ?
+ menu->items[i + Number_Of_Columns] :
+ (cycle ? menu->items[(row + 1) < menu->rows ?
+ Number_Of_Items - 1 : col] :
+ (ITEM *) 0);
item->x = col;
item->y = row;
- if ( ++col == Number_Of_Columns )
+ if (++col == Number_Of_Columns)
{
row++;
col = 0;
@@ -338,48 +445,48 @@ _nc_Link_Items (MENU * menu)
else
{
int Number_Of_Rows = menu->rows;
-
- for(j=0; j<Number_Of_Items; j++)
+
+ for (j = 0; j < Number_Of_Items; j++)
{
- item = menu->items[i=(col * Number_Of_Rows + row)];
-
- Last_in_Column = (menu->cols-1) * Number_Of_Rows + row;
-
- item->left = (col) ?
+ item = menu->items[i = (col * Number_Of_Rows + row)];
+
+ Last_in_Column = (menu->cols - 1) * Number_Of_Rows + row;
+
+ item->left = (col) ?
menu->items[i - Number_Of_Rows] :
- (cycle ? (Last_in_Column >= Number_Of_Items ) ?
- menu->items[Last_in_Column-Number_Of_Rows] :
- menu->items[Last_in_Column] :
- (ITEM *)0 );
-
- item->right = ((i + Number_Of_Rows) <Number_Of_Items)
- ?
- menu->items[i + Number_Of_Rows] :
- (cycle ? menu->items[row] : (ITEM *)0);
-
+ (cycle ? (Last_in_Column >= Number_Of_Items) ?
+ menu->items[Last_in_Column - Number_Of_Rows] :
+ menu->items[Last_in_Column] :
+ (ITEM *) 0);
+
+ item->right = ((i + Number_Of_Rows) < Number_Of_Items)
+ ?
+ menu->items[i + Number_Of_Rows] :
+ (cycle ? menu->items[row] : (ITEM *) 0);
+
Last_in_Row = col * Number_Of_Rows + (Number_Of_Rows - 1);
-
- item->up = (row) ?
- menu->items[i-1] :
- (cycle ?
- menu->items[(Last_in_Row>=Number_Of_Items) ?
- Number_Of_Items-1:
- Last_in_Row] :
- (ITEM *)0);
-
- item->down = (row < (Number_Of_Rows-1))
- ?
- (menu->items[((i+1)<Number_Of_Items) ?
- i+1 :
- (col-1)*Number_Of_Rows + row + 1]) :
- (cycle ?
- menu->items[col * Number_Of_Rows] :
- (ITEM *)0
- );
-
+
+ item->up = (row) ?
+ menu->items[i - 1] :
+ (cycle ?
+ menu->items[(Last_in_Row >= Number_Of_Items) ?
+ Number_Of_Items - 1 :
+ Last_in_Row] :
+ (ITEM *) 0);
+
+ item->down = (row < (Number_Of_Rows - 1))
+ ?
+ (menu->items[((i + 1) < Number_Of_Items) ?
+ i + 1 :
+ (col - 1) * Number_Of_Rows + row + 1]) :
+ (cycle ?
+ menu->items[col * Number_Of_Rows] :
+ (ITEM *) 0
+ );
+
item->x = col;
item->y = row;
- if ( (++row) == Number_Of_Rows )
+ if ((++row) == Number_Of_Rows)
{
col++;
row = 0;
@@ -398,31 +505,31 @@ _nc_Link_Items (MENU * menu)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Show_Menu (const MENU *menu)
+_nc_Show_Menu(const MENU * menu)
{
WINDOW *win;
int maxy, maxx;
-
+
assert(menu);
- if ( (menu->status & _POSTED) && !(menu->status & _IN_DRIVER) )
+ if ((menu->status & _POSTED) && !(menu->status & _IN_DRIVER))
{
/* adjust the internal subwindow to start on the current top */
assert(menu->sub);
- mvderwin(menu->sub,menu->spc_rows * menu->toprow,0);
+ mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0);
win = Get_Menu_Window(menu);
-
+
maxy = getmaxy(win);
- maxx = getmaxx(win);
-
- if (menu->height < maxy)
+ maxx = getmaxx(win);
+
+ if (menu->height < maxy)
maxy = menu->height;
- if (menu->width < maxx)
+ if (menu->width < maxx)
maxx = menu->width;
-
- copywin(menu->sub,win,0,0,0,0,maxy-1,maxx-1,0);
+
+ copywin(menu->sub, win, 0, 0, 0, 0, maxy - 1, maxx - 1, 0);
pos_menu_cursor(menu);
- }
-}
+ }
+}
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -438,41 +545,41 @@ _nc_Show_Menu (const MENU *menu)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_New_TopRow_and_CurrentItem
-(MENU *menu, int new_toprow, ITEM *new_current_item)
+ _nc_New_TopRow_and_CurrentItem
+ (MENU * menu, int new_toprow, ITEM * new_current_item)
{
ITEM *cur_item;
bool mterm_called = FALSE;
bool iterm_called = FALSE;
-
+
assert(menu);
if (menu->status & _POSTED)
{
if (new_current_item != menu->curitem)
{
- Call_Hook(menu,itemterm);
+ Call_Hook(menu, itemterm);
iterm_called = TRUE;
}
if (new_toprow != menu->toprow)
{
- Call_Hook(menu,menuterm);
+ Call_Hook(menu, menuterm);
mterm_called = TRUE;
- }
-
- cur_item = menu->curitem;
+ }
+
+ cur_item = menu->curitem;
assert(cur_item);
- menu->toprow = new_toprow;
- menu->curitem = new_current_item;
-
+ menu->toprow = new_toprow;
+ menu->curitem = new_current_item;
+
if (mterm_called)
{
- Call_Hook(menu,menuinit);
+ Call_Hook(menu, menuinit);
}
if (iterm_called)
{
/* this means, move from the old current_item to the new one... */
- Move_To_Current_Item( menu, cur_item );
- Call_Hook(menu,iteminit);
+ Move_To_Current_Item(menu, cur_item);
+ Call_Hook(menu, iteminit);
}
if (mterm_called || iterm_called)
{
@@ -482,8 +589,8 @@ _nc_New_TopRow_and_CurrentItem
pos_menu_cursor(menu);
}
else
- { /* if we are not posted, this is quite simple */
- menu->toprow = new_toprow;
+ { /* if we are not posted, this is quite simple */
+ menu->toprow = new_toprow;
menu->curitem = new_current_item;
}
}
diff --git a/lib/libmenu/m_hook.c b/lib/libmenu/m_hook.c
index 11b62354d13..cab55c10ba8 100644
--- a/lib/libmenu/m_hook.c
+++ b/lib/libmenu/m_hook.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_hook.c,v 1.6 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_hook.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,12 +39,13 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_hook.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_hook.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/* "Template" macro to generate function to set application specific hook */
#define GEN_HOOK_SET_FUNCTION( typ, name ) \
NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
{\
+ T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), menu, func));\
(Normalize_Menu(menu) -> typ ## name = func );\
RETURN(E_OK);\
}
@@ -53,7 +54,8 @@ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook f
#define GEN_HOOK_GET_FUNCTION( typ, name ) \
NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
{\
- return (Normalize_Menu(menu) -> typ ## name);\
+ T((T_CALLED(#typ "_" #name "(%p)"), menu));\
+ returnMenuHook(Normalize_Menu(menu) -> typ ## name);\
}
/*---------------------------------------------------------------------------
@@ -65,7 +67,7 @@ NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( menu, init )
+GEN_HOOK_SET_FUNCTION(menu, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -77,7 +79,7 @@ GEN_HOOK_SET_FUNCTION( menu, init )
|
| Return Values : Menu init function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( menu, init )
+GEN_HOOK_GET_FUNCTION(menu, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -88,7 +90,7 @@ GEN_HOOK_GET_FUNCTION( menu, init )
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( menu, term )
+GEN_HOOK_SET_FUNCTION(menu, term)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -100,7 +102,7 @@ GEN_HOOK_SET_FUNCTION( menu, term )
|
| Return Values : Menu finalization function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( menu, term )
+GEN_HOOK_GET_FUNCTION(menu, term)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -111,7 +113,7 @@ GEN_HOOK_GET_FUNCTION( menu, term )
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( item, init )
+GEN_HOOK_SET_FUNCTION(item, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -123,7 +125,7 @@ GEN_HOOK_SET_FUNCTION( item, init )
|
| Return Values : Item init function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( item, init )
+GEN_HOOK_GET_FUNCTION(item, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -134,7 +136,7 @@ GEN_HOOK_GET_FUNCTION( item, init )
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( item, term )
+GEN_HOOK_SET_FUNCTION(item, term)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -146,6 +148,6 @@ GEN_HOOK_SET_FUNCTION( item, term )
|
| Return Values : Item finalization function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( item, term )
+GEN_HOOK_GET_FUNCTION(item, term)
/* m_hook.c ends here */
diff --git a/lib/libmenu/m_item_cur.c b/lib/libmenu/m_item_cur.c
index 25be32ff9f0..af3e26d1cdc 100644
--- a/lib/libmenu/m_item_cur.c
+++ b/lib/libmenu/m_item_cur.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_cur.c,v 1.6 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_item_cur.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_cur.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_cur.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -50,14 +50,16 @@ MODULE_ID("$From: m_item_cur.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_current_item (MENU * menu, ITEM * item)
+set_current_item(MENU * menu, ITEM * item)
{
- if (menu && item && (item->imenu==menu))
+ T((T_CALLED("set_current_item(%p,%p)"), menu, item));
+
+ if (menu && item && (item->imenu == menu))
{
- if ( menu->status & _IN_DRIVER )
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
-
- assert( menu->curitem );
+
+ assert(menu->curitem);
if (item != menu->curitem)
{
if (menu->status & _LINK_NEEDED)
@@ -71,12 +73,12 @@ set_current_item (MENU * menu, ITEM * item)
assert(menu->pattern);
Reset_Pattern(menu);
/* adjust the window to make item visible and update the menu */
- Adjust_Current_Item(menu,menu->toprow,item);
+ Adjust_Current_Item(menu, menu->toprow, item);
}
}
else
RETURN(E_BAD_ARGUMENT);
-
+
RETURN(E_OK);
}
@@ -89,9 +91,10 @@ set_current_item (MENU * menu, ITEM * item)
| Return Values : Item pointer or NULL if failure
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(ITEM *)
-current_item (const MENU * menu)
+current_item(const MENU * menu)
{
- return (menu && menu->items) ? menu->curitem : (ITEM *)0;
+ T((T_CALLED("current_item(%p)"), menu));
+ returnItem((menu && menu->items) ? menu->curitem : (ITEM *) 0);
}
/*---------------------------------------------------------------------------
@@ -103,9 +106,10 @@ current_item (const MENU * menu)
| Return Values : The index or ERR if this is an invalid item pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_index (const ITEM *item)
+item_index(const ITEM * item)
{
- return (item && item->imenu) ? item->index : ERR;
+ T((T_CALLED("item_index(%p)"), item));
+ returnCode((item && item->imenu) ? item->index : ERR);
}
/* m_item_cur.c ends here */
diff --git a/lib/libmenu/m_item_nam.c b/lib/libmenu/m_item_nam.c
index 2a882146737..9d1bebfb2ee 100644
--- a/lib/libmenu/m_item_nam.c
+++ b/lib/libmenu/m_item_nam.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_nam.c,v 1.6 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_nam.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_nam.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_nam.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -50,11 +50,12 @@ MODULE_ID("$From: m_item_nam.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
| Return Values : See above; returns NULL if item is invalid
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-item_name (const ITEM * item)
+item_name(const ITEM * item)
{
- return ((item) ? item->name.str : (char *)0);
+ T((T_CALLED("item_name(%p)"), item));
+ returnCPtr((item) ? item->name.str : (char *)0);
}
-
+
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : char *item_description(const ITEM *item)
@@ -64,9 +65,10 @@ item_name (const ITEM * item)
| Return Values : See above; Returns NULL if item is invalid
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-item_description (const ITEM * item)
+item_description(const ITEM * item)
{
- return ((item) ? item->description.str : (char *)0);
+ T((T_CALLED("item_description(%p)"), item));
+ returnCPtr((item) ? item->description.str : (char *)0);
}
/* m_item_nam.c ends here */
diff --git a/lib/libmenu/m_item_new.c b/lib/libmenu/m_item_new.c
index d5b9e8206b5..85bb38b7187 100644
--- a/lib/libmenu/m_item_new.c
+++ b/lib/libmenu/m_item_new.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_new.c,v 1.8 2003/04/04 23:04:36 tdeval Exp $ */
+/* $OpenBSD: m_item_new.c,v 1.9 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -40,7 +40,13 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_new.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#endif
+
+MODULE_ID("$Id: m_item_new.c,v 1.9 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -52,16 +58,44 @@ MODULE_ID("$From: m_item_new.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
| Return Values : TRUE - if string is printable
| FALSE - if string contains non-printable characters
+--------------------------------------------------------------------------*/
-static bool Is_Printable_String(const char *s)
+static bool
+Is_Printable_String(const char *s)
{
+ int result = TRUE;
+
+#if USE_WIDEC_SUPPORT
+ int count = mbstowcs(0, s, 0);
+ wchar_t *temp = 0;
+
+ assert(s);
+
+ if (count > 0
+ && (temp = typeCalloc(wchar_t, (2 + (unsigned)count))) != 0)
+ {
+ int n;
+
+ mbstowcs(temp, s, (unsigned)count);
+ for (n = 0; n < count; ++n)
+ if (!iswprint((wint_t) temp[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ free(temp);
+ }
+#else
assert(s);
- while(*s)
+ while (*s)
{
- if (!isprint((unsigned char)*s))
- return FALSE;
+ if (!isprint(UChar(*s)))
+ {
+ result = FALSE;
+ break;
+ }
s++;
}
- return TRUE;
+#endif
+ return result;
}
/*---------------------------------------------------------------------------
@@ -75,41 +109,45 @@ static bool Is_Printable_String(const char *s)
| Return Values : The item pointer or NULL if creation failed.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(ITEM *)
-new_item (const char *name, const char *description)
+new_item(const char *name, const char *description)
{
ITEM *item;
-
- if ( !name || (*name == '\0') || !Is_Printable_String(name) )
+
+ T((T_CALLED("new_item(\"%s\", \"%s\")"),
+ name ? name : "",
+ description ? description : ""));
+
+ if (!name || (*name == '\0') || !Is_Printable_String(name))
{
- item = (ITEM *)0;
- SET_ERROR( E_BAD_ARGUMENT );
+ item = (ITEM *) 0;
+ SET_ERROR(E_BAD_ARGUMENT);
}
else
{
- item = (ITEM *)calloc(1,sizeof(ITEM));
+ item = (ITEM *) calloc(1, sizeof(ITEM));
if (item)
{
- *item = _nc_Default_Item; /* hope we have struct assignment */
-
- item->name.length = strlen(name);
- item->name.str = name;
+ *item = _nc_Default_Item; /* hope we have struct assignment */
+
+ item->name.length = strlen(name);
+ item->name.str = name;
- if (description && (*description != '\0') &&
+ if (description && (*description != '\0') &&
Is_Printable_String(description))
{
- item->description.length = strlen(description);
- item->description.str = description;
+ item->description.length = strlen(description);
+ item->description.str = description;
}
else
{
item->description.length = 0;
- item->description.str = (char *)0;
+ item->description.str = (char *)0;
}
}
else
- SET_ERROR( E_SYSTEM_ERROR );
- }
- return(item);
+ SET_ERROR(E_SYSTEM_ERROR);
+ }
+ returnItem(item);
}
/*---------------------------------------------------------------------------
@@ -124,17 +162,19 @@ new_item (const char *name, const char *description)
| E_CONNECTED - item is still connected to a menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_item (ITEM * item)
+free_item(ITEM * item)
{
+ T((T_CALLED("free_item(%p)"), item));
+
if (!item)
- RETURN( E_BAD_ARGUMENT );
+ RETURN(E_BAD_ARGUMENT);
if (item->imenu)
- RETURN( E_CONNECTED );
-
+ RETURN(E_CONNECTED);
+
free(item);
- RETURN( E_OK );
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -155,16 +195,18 @@ free_item (ITEM * item)
| E_SYSTEM_ERROR - no memory to store mark
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_mark (MENU * menu, const char * mark)
+set_menu_mark(MENU * menu, const char *mark)
{
- int l;
+ unsigned l;
+
+ T((T_CALLED("set_menu_mark(%p,%s)"), menu, _nc_visbuf(mark)));
- if ( mark && (*mark != '\0') && Is_Printable_String(mark) )
+ if (mark && (*mark != '\0') && Is_Printable_String(mark))
l = strlen(mark);
else
l = 0;
- if ( menu )
+ if (menu)
{
char *old_mark = menu->mark;
unsigned short old_status = menu->status;
@@ -173,13 +215,13 @@ set_menu_mark (MENU * menu, const char * mark)
{
/* If the menu is already posted, the geometry is fixed. Then
we can only accept a mark with exactly the same length */
- if (menu->marklen != l)
+ if (menu->marklen != (int)l)
RETURN(E_BAD_ARGUMENT);
- }
+ }
menu->marklen = l;
if (l)
{
- menu->mark = (char *)malloc(l+1);
+ menu->mark = (char *)malloc(l + 1);
if (menu->mark)
{
strlcpy(menu->mark, mark, l+1);
@@ -194,24 +236,24 @@ set_menu_mark (MENU * menu, const char * mark)
}
else
menu->mark = (char *)0;
-
+
if ((old_status & _MARK_ALLOCATED) && old_mark)
free(old_mark);
if (menu->status & _POSTED)
{
- _nc_Draw_Menu( menu );
- _nc_Show_Menu( menu );
+ _nc_Draw_Menu(menu);
+ _nc_Show_Menu(menu);
}
else
{
/* Recalculate the geometry */
- _nc_Calculate_Item_Length_and_Width( menu );
+ _nc_Calculate_Item_Length_and_Width(menu);
}
}
else
{
- return set_menu_mark(&_nc_Default_Menu, mark);
+ returnCode(set_menu_mark(&_nc_Default_Menu, mark));
}
RETURN(E_OK);
}
@@ -225,9 +267,10 @@ set_menu_mark (MENU * menu, const char * mark)
| Return Values : The marker string pointer or NULL if no marker defined
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-menu_mark (const MENU * menu)
+menu_mark(const MENU * menu)
{
- return Normalize_Menu( menu )->mark;
+ T((T_CALLED("menu_mark(%p)"), menu));
+ returnPtr(Normalize_Menu(menu)->mark);
}
/* m_item_new.c */
diff --git a/lib/libmenu/m_item_opt.c b/lib/libmenu/m_item_opt.c
index 1ee8f030f18..8dc31abbff0 100644
--- a/lib/libmenu/m_item_opt.c
+++ b/lib/libmenu/m_item_opt.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_opt.c,v 1.8 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_opt.c,v 1.9 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_opt.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_opt.c,v 1.9 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,34 +53,36 @@ MODULE_ID("$From: m_item_opt.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| E_BAD_ARGUMENT - invalid item options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_item_opts (ITEM *item, Item_Options opts)
-{
+set_item_opts(ITEM * item, Item_Options opts)
+{
+ T((T_CALLED("set_menu_opts(%p,%d)"), item, opts));
+
opts &= ALL_ITEM_OPTS;
if (opts & ~ALL_ITEM_OPTS)
RETURN(E_BAD_ARGUMENT);
-
+
if (item)
{
if (item->opt != opts)
- {
+ {
MENU *menu = item->imenu;
-
+
item->opt = opts;
-
+
if ((!(opts & O_SELECTABLE)) && item->value)
item->value = FALSE;
-
+
if (menu && (menu->status & _POSTED))
{
- Move_And_Post_Item( menu, item );
+ Move_And_Post_Item(menu, item);
_nc_Show_Menu(menu);
}
}
}
else
_nc_Default_Item.opt = opts;
-
+
RETURN(E_OK);
}
@@ -94,18 +96,21 @@ set_item_opts (ITEM *item, Item_Options opts)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_opts_off (ITEM *item, Item_Options opts)
-{
- ITEM *citem = item; /* use a copy because set_item_opts must detect
- NULL item itself to adjust its behaviour */
+item_opts_off(ITEM * item, Item_Options opts)
+{
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+
+ NULL item itself to adjust its behavior */
+
+ T((T_CALLED("item_opts_off(%p,%d)"), item, opts));
if (opts & ~ALL_ITEM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
- Normalize_Item(citem);
+ Normalize_Item(citem);
opts = citem->opt & ~(opts & ALL_ITEM_OPTS);
- return set_item_opts( item, opts );
+ returnCode(set_item_opts(item, opts));
}
}
@@ -119,11 +124,14 @@ item_opts_off (ITEM *item, Item_Options opts)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_opts_on (ITEM *item, Item_Options opts)
+item_opts_on(ITEM * item, Item_Options opts)
{
- ITEM *citem = item; /* use a copy because set_item_opts must detect
- NULL item itself to adjust its behaviour */
-
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+
+ NULL item itself to adjust its behavior */
+
+ T((T_CALLED("item_opts_on(%p,%d)"), item, opts));
+
opts &= ALL_ITEM_OPTS;
if (opts & ~ALL_ITEM_OPTS)
RETURN(E_BAD_ARGUMENT);
@@ -131,7 +139,7 @@ item_opts_on (ITEM *item, Item_Options opts)
{
Normalize_Item(citem);
opts = citem->opt | opts;
- return set_item_opts( item, opts );
+ returnCode(set_item_opts(item, opts));
}
}
@@ -144,9 +152,10 @@ item_opts_on (ITEM *item, Item_Options opts)
| Return Values : Items options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Item_Options)
-item_opts (const ITEM * item)
+item_opts(const ITEM * item)
{
- return (ALL_ITEM_OPTS & Normalize_Item(item)->opt);
+ T((T_CALLED("item_opts(%p)"), item));
+ returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt);
}
/* m_item_opt.c ends here */
diff --git a/lib/libmenu/m_item_top.c b/lib/libmenu/m_item_top.c
index 2a492ad986c..d17c1d48744 100644
--- a/lib/libmenu/m_item_top.c
+++ b/lib/libmenu/m_item_top.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_top.c,v 1.4 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_top.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,48 +39,50 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_top.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_top.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int set_top_row(MENU *menu, int row)
|
-| Description : Makes the speified row the top row in the menu
+| Description : Makes the specified row the top row in the menu
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - not a menu pointer or invalid row
| E_NOT_CONNECTED - there are no items for the menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_top_row (MENU * menu, int row)
+set_top_row(MENU * menu, int row)
{
ITEM *item;
-
+
+ T((T_CALLED("set_top_row(%p,%d)"), menu, row));
+
if (menu)
{
- if ( menu->status & _IN_DRIVER )
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if (menu->items == (ITEM **)0)
+ if (menu->items == (ITEM **) 0)
RETURN(E_NOT_CONNECTED);
-
- if ((row<0) || (row > (menu->rows - menu->arows)))
+
+ if ((row < 0) || (row > (menu->rows - menu->arows)))
RETURN(E_BAD_ARGUMENT);
}
else
RETURN(E_BAD_ARGUMENT);
-
+
if (row != menu->toprow)
{
- if (menu->status & _LINK_NEEDED)
+ if (menu->status & _LINK_NEEDED)
_nc_Link_Items(menu);
-
- item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ];
+
+ item = menu->items[(menu->opt & O_ROWMAJOR) ? (row * menu->cols) : row];
assert(menu->pattern);
Reset_Pattern(menu);
_nc_New_TopRow_and_CurrentItem(menu, row, item);
}
-
- RETURN(E_OK);
+
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -92,15 +94,16 @@ set_top_row (MENU * menu, int row)
| Return Values : The row number or ERR if there is no row
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-top_row (const MENU * menu)
+top_row(const MENU * menu)
{
+ T((T_CALLED("top_row(%p)"), menu));
if (menu && menu->items && *(menu->items))
{
- assert( (menu->toprow>=0) && (menu->toprow < menu->rows) );
- return menu->toprow;
+ assert((menu->toprow >= 0) && (menu->toprow < menu->rows));
+ returnCode(menu->toprow);
}
else
- return(ERR);
+ returnCode(ERR);
}
/* m_item_top.c ends here */
diff --git a/lib/libmenu/m_item_use.c b/lib/libmenu/m_item_use.c
index b7fcd8633b0..68313046aa4 100644
--- a/lib/libmenu/m_item_use.c
+++ b/lib/libmenu/m_item_use.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_use.c,v 1.6 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_use.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_use.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_use.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,10 +51,11 @@ MODULE_ID("$From: m_item_use.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_item_userptr (ITEM * item, void * userptr)
+set_item_userptr(ITEM * item, void *userptr)
{
+ T((T_CALLED("set_item_userptr(%p,%p)"), item, userptr));
Normalize_Item(item)->userptr = userptr;
- RETURN( E_OK );
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -68,9 +69,10 @@ set_item_userptr (ITEM * item, void * userptr)
| NULL is returned.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-item_userptr (const ITEM * item)
+item_userptr(const ITEM * item)
{
- return Normalize_Item(item)->userptr;
+ T((T_CALLED("item_userptr(%p)"), item));
+ returnVoidPtr(Normalize_Item(item)->userptr);
}
/* m_item_use.c */
diff --git a/lib/libmenu/m_item_val.c b/lib/libmenu/m_item_val.c
index 939ebd76fb5..9d4b69c79ce 100644
--- a/lib/libmenu/m_item_val.c
+++ b/lib/libmenu/m_item_val.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_val.c,v 1.6 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_val.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,13 +39,13 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_val.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_val.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int set_item_value(ITEM *item, int value)
|
-| Description : Programmatically set the items selection value. This is
+| Description : Programmatically set the item's selection value. This is
| only allowed if the item is selectable at all and if
| it is not connected to a single-valued menu.
| If the item is connected to a posted menu, the menu
@@ -55,18 +55,19 @@ MODULE_ID("$From: m_item_val.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
| E_REQUEST_DENIED - not selectable or single valued menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_item_value (ITEM *item, bool value)
+set_item_value(ITEM * item, bool value)
{
MENU *menu;
-
+
+ T((T_CALLED("set_item_value(%p,%d)"), item, value));
if (item)
{
menu = item->imenu;
-
+
if ((!(item->opt & O_SELECTABLE)) ||
- (menu && (menu->opt & O_ONEVALUE)))
+ (menu && (menu->opt & O_ONEVALUE)))
RETURN(E_REQUEST_DENIED);
-
+
if (item->value ^ value)
{
item->value = value ? TRUE : FALSE;
@@ -74,7 +75,7 @@ set_item_value (ITEM *item, bool value)
{
if (menu->status & _POSTED)
{
- Move_And_Post_Item(menu,item);
+ Move_And_Post_Item(menu, item);
_nc_Show_Menu(menu);
}
}
@@ -82,7 +83,7 @@ set_item_value (ITEM *item, bool value)
}
else
_nc_Default_Item.value = value;
-
+
RETURN(E_OK);
}
@@ -96,9 +97,10 @@ set_item_value (ITEM *item, bool value)
| FALSE - if item is not selected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-item_value (const ITEM *item)
+item_value(const ITEM * item)
{
- return ((Normalize_Item(item)->value) ? TRUE : FALSE);
+ T((T_CALLED("item_value(%p)"), item));
+ returnBool((Normalize_Item(item)->value) ? TRUE : FALSE);
}
/* m_item_val.c ends here */
diff --git a/lib/libmenu/m_item_vis.c b/lib/libmenu/m_item_vis.c
index 9fbe0fcc874..9297c6c46f2 100644
--- a/lib/libmenu/m_item_vis.c
+++ b/lib/libmenu/m_item_vis.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_vis.c,v 1.6 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_item_vis.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_vis.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_vis.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -52,18 +52,19 @@ MODULE_ID("$From: m_item_vis.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| FALSE if invisible
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-item_visible (const ITEM * item)
+item_visible(const ITEM * item)
{
MENU *menu;
-
- if ( item &&
- (menu=item->imenu) &&
- (menu->status & _POSTED) &&
- ( (menu->toprow + menu->arows) > (item->y) ) &&
- ( item->y >= menu->toprow) )
- return TRUE;
+
+ T((T_CALLED("item_visible(%p)"), item));
+ if (item &&
+ (menu = item->imenu) &&
+ (menu->status & _POSTED) &&
+ ((menu->toprow + menu->arows) > (item->y)) &&
+ (item->y >= menu->toprow))
+ returnBool(TRUE);
else
- return FALSE;
+ returnBool(FALSE);
}
/* m_item_vis.c ends here */
diff --git a/lib/libmenu/m_items.c b/lib/libmenu/m_items.c
index 133b1534003..991d0229838 100644
--- a/lib/libmenu/m_items.c
+++ b/lib/libmenu/m_items.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_items.c,v 1.6 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_items.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_items.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_items.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -55,39 +55,42 @@ MODULE_ID("$From: m_items.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
| passed to the function
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_items (MENU * menu, ITEM ** items)
+set_menu_items(MENU * menu, ITEM ** items)
{
+ T((T_CALLED("set_menu_items(%p,%p)"), menu, items));
+
if (!menu || (items && !(*items)))
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _POSTED )
+
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
+
if (menu->items)
_nc_Disconnect_Items(menu);
-
+
if (items)
{
- if(!_nc_Connect_Items( menu, items ))
+ if (!_nc_Connect_Items(menu, items))
RETURN(E_CONNECTED);
}
-
+
menu->items = items;
RETURN(E_OK);
-}
+}
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : ITEM **menu_items(const MENU *menu)
|
-| Description : Returns a pointer to the item pointer arry of the menu
+| Description : Returns a pointer to the item pointer array of the menu
|
| Return Values : NULL on error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(ITEM **)
-menu_items (const MENU *menu)
+menu_items(const MENU * menu)
{
- return(menu ? menu->items : (ITEM **)0);
+ T((T_CALLED("menu_items(%p)"), menu));
+ returnItemPtr(menu ? menu->items : (ITEM **) 0);
}
/*---------------------------------------------------------------------------
@@ -100,9 +103,10 @@ menu_items (const MENU *menu)
| Return Values : Number of items or -1 to indicate error.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_count (const MENU *menu)
+item_count(const MENU * menu)
{
- return(menu ? menu->nitems : -1);
+ T((T_CALLED("item_count(%p)"), menu));
+ returnCode(menu ? menu->nitems : -1);
}
/* m_items.c ends here */
diff --git a/lib/libmenu/m_new.c b/lib/libmenu/m_new.c
index c237cb976fa..ce9ece3d4e9 100644
--- a/lib/libmenu/m_new.c
+++ b/lib/libmenu/m_new.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_new.c,v 1.7 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_new.c,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_new.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_new.c,v 1.8 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,10 +53,12 @@ MODULE_ID("$From: m_new.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| Return Values : NULL on error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(MENU *)
-new_menu (ITEM ** items)
+new_menu(ITEM ** items)
{
- MENU *menu = (MENU *)calloc(1,sizeof(MENU));
-
+ int err = E_SYSTEM_ERROR;
+ MENU *menu = (MENU *) calloc(1, sizeof(MENU));
+
+ T((T_CALLED("new_menu(%p)"), items));
if (menu)
{
*menu = _nc_Default_Menu;
@@ -65,18 +67,19 @@ new_menu (ITEM ** items)
menu->cols = menu->fcols;
if (items && *items)
{
- if (!_nc_Connect_Items(menu,items))
+ if (!_nc_Connect_Items(menu, items))
{
+ err = E_NOT_CONNECTED;
free(menu);
- menu = (MENU *)0;
+ menu = (MENU *) 0;
}
}
}
if (!menu)
- SET_ERROR(E_SYSTEM_ERROR);
+ SET_ERROR(err);
- return(menu);
+ returnMenu(menu);
}
/*---------------------------------------------------------------------------
@@ -91,17 +94,18 @@ new_menu (ITEM ** items)
| E_POSTED - Menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_menu (MENU * menu)
+free_menu(MENU * menu)
{
+ T((T_CALLED("free_menu(%p)"), menu));
if (!menu)
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _POSTED )
+
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
- if (menu->items)
+
+ if (menu->items)
_nc_Disconnect_Items(menu);
-
+
if ((menu->status & _MARK_ALLOCATED) && menu->mark)
free(menu->mark);
diff --git a/lib/libmenu/m_opts.c b/lib/libmenu/m_opts.c
index 9ca1078e27b..ce7600244b1 100644
--- a/lib/libmenu/m_opts.c
+++ b/lib/libmenu/m_opts.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_opts.c,v 1.7 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_opts.c,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_opts.c,v 1.13 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_opts.c,v 1.8 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -55,8 +55,10 @@ MODULE_ID("$From: m_opts.c,v 1.13 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_opts (MENU * menu, Menu_Options opts)
+set_menu_opts(MENU * menu, Menu_Options opts)
{
+ T((T_CALLED("set_menu_opts(%p,%d)"), menu, opts));
+
opts &= ALL_MENU_OPTS;
if (opts & ~ALL_MENU_OPTS)
@@ -64,18 +66,18 @@ set_menu_opts (MENU * menu, Menu_Options opts)
if (menu)
{
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
- if ( (opts&O_ROWMAJOR) != (menu->opt&O_ROWMAJOR))
+ if ((opts & O_ROWMAJOR) != (menu->opt & O_ROWMAJOR))
{
/* we need this only if the layout really changed ... */
if (menu->items && menu->items[0])
{
- menu->toprow = 0;
+ menu->toprow = 0;
menu->curitem = menu->items[0];
assert(menu->curitem);
- set_menu_format( menu, menu->frows, menu->fcols );
+ set_menu_format(menu, menu->frows, menu->fcols);
}
}
@@ -85,13 +87,13 @@ set_menu_opts (MENU * menu, Menu_Options opts)
{
ITEM **item;
- if ( ((item=menu->items) != (ITEM**)0) )
- for(;*item;item++)
+ if (((item = menu->items) != (ITEM **) 0))
+ for (; *item; item++)
(*item)->value = FALSE;
}
if (opts & O_SHOWDESC) /* this also changes the geometry */
- _nc_Calculate_Item_Length_and_Width( menu );
+ _nc_Calculate_Item_Length_and_Width(menu);
}
else
_nc_Default_Menu.opt = opts;
@@ -113,10 +115,13 @@ set_menu_opts (MENU * menu, Menu_Options opts)
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_opts_off (MENU *menu, Menu_Options opts)
+menu_opts_off(MENU * menu, Menu_Options opts)
{
- MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
- NULL menu itself to adjust its behaviour */
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+
+ NULL menu itself to adjust its behavior */
+
+ T((T_CALLED("menu_opts_off(%p,%d)"), menu, opts));
opts &= ALL_MENU_OPTS;
if (opts & ~ALL_MENU_OPTS)
@@ -125,7 +130,7 @@ menu_opts_off (MENU *menu, Menu_Options opts)
{
Normalize_Menu(cmenu);
opts = cmenu->opt & ~opts;
- return set_menu_opts( menu, opts );
+ returnCode(set_menu_opts(menu, opts));
}
}
@@ -143,10 +148,13 @@ menu_opts_off (MENU *menu, Menu_Options opts)
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_opts_on (MENU * menu, Menu_Options opts)
+menu_opts_on(MENU * menu, Menu_Options opts)
{
- MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
- NULL menu itself to adjust its behaviour */
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+
+ NULL menu itself to adjust its behavior */
+
+ T((T_CALLED("menu_opts_on(%p,%d)"), menu, opts));
opts &= ALL_MENU_OPTS;
if (opts & ~ALL_MENU_OPTS)
@@ -155,7 +163,7 @@ menu_opts_on (MENU * menu, Menu_Options opts)
{
Normalize_Menu(cmenu);
opts = cmenu->opt | opts;
- return set_menu_opts(menu, opts);
+ returnCode(set_menu_opts(menu, opts));
}
}
@@ -168,9 +176,10 @@ menu_opts_on (MENU * menu, Menu_Options opts)
| Return Values : Menu options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Menu_Options)
-menu_opts (const MENU *menu)
+menu_opts(const MENU * menu)
{
- return (ALL_MENU_OPTS & Normalize_Menu( menu )->opt);
+ T((T_CALLED("menu_opts(%p)"), menu));
+ returnMenuOpts(ALL_MENU_OPTS & Normalize_Menu(menu)->opt);
}
/* m_opts.c ends here */
diff --git a/lib/libmenu/m_pad.c b/lib/libmenu/m_pad.c
index 78122817642..4ea8d09fdf8 100644
--- a/lib/libmenu/m_pad.c
+++ b/lib/libmenu/m_pad.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_pad.c,v 1.4 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_pad.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_pad.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_pad.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/* Macro to redraw menu if it is posted and changed */
#define Refresh_Menu(menu) \
@@ -61,18 +61,20 @@ MODULE_ID("$From: m_pad.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_pad (MENU *menu, int pad)
+set_menu_pad(MENU * menu, int pad)
{
- bool do_refresh = (menu != (MENU*)0);
+ bool do_refresh = (menu != (MENU *) 0);
- if (!isprint((unsigned char)pad))
+ T((T_CALLED("set_menu_pad(%p,%d)"), menu, pad));
+
+ if (!isprint(UChar(pad)))
RETURN(E_BAD_ARGUMENT);
-
- Normalize_Menu( menu );
+
+ Normalize_Menu(menu);
menu->pad = pad;
-
+
if (do_refresh)
- Refresh_Menu( menu );
+ Refresh_Menu(menu);
RETURN(E_OK);
}
@@ -86,9 +88,10 @@ set_menu_pad (MENU *menu, int pad)
| Return Values : The pad character
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_pad (const MENU * menu)
+menu_pad(const MENU * menu)
{
- return (Normalize_Menu( menu ) -> pad);
+ T((T_CALLED("menu_pad(%p)"), menu));
+ returnCode(Normalize_Menu(menu)->pad);
}
/* m_pad.c ends here */
diff --git a/lib/libmenu/m_pattern.c b/lib/libmenu/m_pattern.c
index f750c02aae3..88ae225339b 100644
--- a/lib/libmenu/m_pattern.c
+++ b/lib/libmenu/m_pattern.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_pattern.c,v 1.4 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_pattern.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_pattern.c,v 1.6 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_pattern.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,9 +53,12 @@ MODULE_ID("$From: m_pattern.c,v 1.6 2000/12/10 02:16:48 tom Exp $")
| PatternString - as expected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(char *)
-menu_pattern (const MENU * menu)
+menu_pattern(const MENU * menu)
{
- return (menu ? (menu->pattern ? menu->pattern : "") : (char *)0);
+ static char empty[] = "";
+
+ T((T_CALLED("menu_pattern(%p)"), menu));
+ returnPtr(menu ? (menu->pattern ? menu->pattern : empty) : 0);
}
/*---------------------------------------------------------------------------
@@ -67,54 +70,56 @@ menu_pattern (const MENU * menu)
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid menu or pattern pointer
-| E_NOT_CONNECTED - no items connected to menu
| E_BAD_STATE - menu in user hook routine
+| E_NOT_CONNECTED - no items connected to menu
| E_NO_MATCH - no item matches pattern
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_pattern (MENU *menu, const char *p)
+set_menu_pattern(MENU * menu, const char *p)
{
ITEM *matchitem;
- int matchpos;
-
- if (!menu || !p)
+ int matchpos;
+
+ T((T_CALLED("set_menu_pattern(%p,%s)"), menu, _nc_visbuf(p)));
+
+ if (!menu || !p)
RETURN(E_BAD_ARGUMENT);
-
+
if (!(menu->items))
RETURN(E_NOT_CONNECTED);
-
- if ( menu->status & _IN_DRIVER )
+
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
-
+
Reset_Pattern(menu);
-
+
if (!(*p))
{
pos_menu_cursor(menu);
RETURN(E_OK);
}
-
- if (menu->status & _LINK_NEEDED)
+
+ if (menu->status & _LINK_NEEDED)
_nc_Link_Items(menu);
-
- matchpos = menu->toprow;
+
+ matchpos = menu->toprow;
matchitem = menu->curitem;
assert(matchitem);
-
- while(*p)
+
+ while (*p)
{
- if ( !isprint((unsigned char)(*p)) ||
- (_nc_Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) )
+ if (!isprint(UChar(*p)) ||
+ (_nc_Match_Next_Character_In_Item_Name(menu, *p, &matchitem) != E_OK))
{
Reset_Pattern(menu);
pos_menu_cursor(menu);
RETURN(E_NO_MATCH);
}
p++;
- }
-
+ }
+
/* This is reached if there was a match. So we position to the new item */
- Adjust_Current_Item(menu,matchpos,matchitem);
+ Adjust_Current_Item(menu, matchpos, matchitem);
RETURN(E_OK);
}
diff --git a/lib/libmenu/m_post.c b/lib/libmenu/m_post.c
index 828177fe568..504174189ad 100644
--- a/lib/libmenu/m_post.c
+++ b/lib/libmenu/m_post.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_post.c,v 1.6 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_post.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,113 +39,117 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_post.c,v 1.17 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_post.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnmenu
-| Function : void _nc_Post_Item(MENU *menu, ITEM *item)
-|
+| Facility : libnmenu
+| Function : void _nc_Post_Item(MENU *menu, ITEM *item)
+|
| Description : Draw the item in the menus window at the current
-| window position
+| window position
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Post_Item (const MENU * menu, const ITEM * item)
+_nc_Post_Item(const MENU * menu, const ITEM * item)
{
int i;
chtype ch;
int item_x, item_y;
int count = 0;
- bool isfore = FALSE, isback=FALSE, isgrey = FALSE;
-
+ bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
+ int name_len;
+ int desc_len;
+
assert(menu->win);
-
- getyx(menu->win,item_y,item_x);
-
+
+ getyx(menu->win, item_y, item_x);
+
/* We need a marker iff
- it is a onevalued menu and it is the current item
- or it has a selection value
- */
- wattron(menu->win,menu->back);
- if (item->value || (item==menu->curitem))
+ */
+ wattron(menu->win, menu->back);
+ if (item->value || (item == menu->curitem))
{
- if (menu->marklen)
+ if (menu->marklen)
{
/* In a multi selection menu we use the fore attribute
for a selected marker that is not the current one.
This improves visualization of the menu, because now
always the 'normal' marker denotes the current
item. */
- if (!(menu->opt & O_ONEVALUE) && item->value && item!=menu->curitem)
+ if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem)
{
- wattron(menu->win,menu->fore);
+ wattron(menu->win, menu->fore);
isfore = TRUE;
}
- waddstr(menu->win,menu->mark);
+ waddstr(menu->win, menu->mark);
if (isfore)
{
- wattron(menu->win,menu->fore);
+ wattron(menu->win, menu->fore);
isfore = FALSE;
}
}
}
- else /* otherwise we have to wipe out the marker area */
- for(ch=' ',i=menu->marklen;i>0;i--)
- waddch(menu->win,ch);
- wattroff(menu->win,menu->back);
+ else /* otherwise we have to wipe out the marker area */
+ for (ch = ' ', i = menu->marklen; i > 0; i--)
+ waddch(menu->win, ch);
+ wattroff(menu->win, menu->back);
count += menu->marklen;
/* First we have to calculate the attribute depending on selectability
and selection status
- */
+ */
if (!(item->opt & O_SELECTABLE))
{
- wattron(menu->win,menu->grey);
+ wattron(menu->win, menu->grey);
isgrey = TRUE;
}
else
{
- if (item->value || item==menu->curitem)
+ if (item->value || item == menu->curitem)
{
- wattron(menu->win,menu->fore);
+ wattron(menu->win, menu->fore);
isfore = TRUE;
}
else
{
- wattron(menu->win,menu->back);
+ wattron(menu->win, menu->back);
isback = TRUE;
}
}
- waddnstr(menu->win,item->name.str,item->name.length);
- for(ch=' ',i=menu->namelen-item->name.length;i>0;i--)
+ waddnstr(menu->win, item->name.str, item->name.length);
+ name_len = _nc_Calculate_Text_Width(&(item->name));
+ for (ch = ' ', i = menu->namelen - name_len; i > 0; i--)
{
- waddch(menu->win,ch);
+ waddch(menu->win, ch);
}
count += menu->namelen;
/* Show description if required and available */
- if ( (menu->opt & O_SHOWDESC) && menu->desclen>0 )
+ if ((menu->opt & O_SHOWDESC) && menu->desclen > 0)
{
- int m = menu->spc_desc/2;
+ int m = menu->spc_desc / 2;
int cy = -1, cx = -1;
- for(ch=' ',i=0; i < menu->spc_desc; i++)
+ for (ch = ' ', i = 0; i < menu->spc_desc; i++)
{
- if (i==m)
+ if (i == m)
{
- waddch(menu->win,menu->pad);
- getyx(menu->win,cy,cx);
+ waddch(menu->win, menu->pad);
+ getyx(menu->win, cy, cx);
}
else
- waddch(menu->win,ch);
+ waddch(menu->win, ch);
}
if (item->description.length)
- waddnstr(menu->win,item->description.str,item->description.length);
- for(ch=' ',i=menu->desclen-item->description.length; i>0; i--)
+ waddnstr(menu->win, item->description.str, item->description.length);
+ desc_len = _nc_Calculate_Text_Width(&(item->description));
+ for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--)
{
- waddch(menu->win,ch);
+ waddch(menu->win, ch);
}
count += menu->desclen + menu->spc_desc;
@@ -153,47 +157,49 @@ _nc_Post_Item (const MENU * menu, const ITEM * item)
{
int j, k, ncy, ncx;
- assert(cx>=0 && cy>=0);
- getyx(menu->win,ncy,ncx);
- if (isgrey) wattroff(menu->win,menu->grey);
- else if (isfore) wattroff(menu->win,menu->fore);
- wattron(menu->win,menu->back);
- for(j=1; j < menu->spc_rows;j++)
+ assert(cx >= 0 && cy >= 0);
+ getyx(menu->win, ncy, ncx);
+ if (isgrey)
+ wattroff(menu->win, menu->grey);
+ else if (isfore)
+ wattroff(menu->win, menu->fore);
+ wattron(menu->win, menu->back);
+ for (j = 1; j < menu->spc_rows; j++)
{
- if ((item_y+j) < getmaxy(menu->win))
+ if ((item_y + j) < getmaxy(menu->win))
{
- wmove (menu->win,item_y+j,item_x);
- for(k=0;k<count;k++)
- waddch(menu->win,' ');
+ wmove(menu->win, item_y + j, item_x);
+ for (k = 0; k < count; k++)
+ waddch(menu->win, ' ');
}
- if ((cy+j) < getmaxy(menu->win))
- mvwaddch(menu->win,cy+j,cx-1,menu->pad);
+ if ((cy + j) < getmaxy(menu->win))
+ mvwaddch(menu->win, cy + j, cx - 1, menu->pad);
}
- wmove(menu->win,ncy,ncx);
+ wmove(menu->win, ncy, ncx);
if (!isback)
- wattroff(menu->win,menu->back);
+ wattroff(menu->win, menu->back);
}
}
-
+
/* Remove attributes */
if (isfore)
- wattroff(menu->win,menu->fore);
+ wattroff(menu->win, menu->fore);
if (isback)
- wattroff(menu->win,menu->back);
+ wattroff(menu->win, menu->back);
if (isgrey)
- wattroff(menu->win,menu->grey);
-}
+ wattroff(menu->win, menu->grey);
+}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : void _nc_Draw_Menu(const MENU *)
-|
+|
| Description : Display the menu in its windows
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Draw_Menu (const MENU * menu)
+_nc_Draw_Menu(const MENU * menu)
{
ITEM *item = menu->items[0];
ITEM *lasthor, *lastvert;
@@ -204,75 +210,78 @@ _nc_Draw_Menu (const MENU * menu)
assert(item && menu->win);
s_bkgd = getbkgd(menu->win);
- wbkgdset(menu->win,menu->back);
+ wbkgdset(menu->win, menu->back);
werase(menu->win);
- wbkgdset(menu->win,s_bkgd);
+ wbkgdset(menu->win, s_bkgd);
- lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;
+ lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;
do
- {
- wmove(menu->win,y,0);
+ {
+ wmove(menu->win, y, 0);
+
+ hitem = item;
+ lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;
- hitem = item;
- lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
-
do
{
- _nc_Post_Item( menu, hitem);
+ _nc_Post_Item(menu, hitem);
- wattron(menu->win,menu->back);
- if ( ((hitem = hitem->right) != lasthor) && hitem )
+ wattron(menu->win, menu->back);
+ if (((hitem = hitem->right) != lasthor) && hitem)
{
- int i,j, cy, cx;
+ int i, j, cy, cx;
chtype ch = ' ';
- getyx(menu->win,cy,cx);
- for(j=0;j<menu->spc_rows;j++)
+ getyx(menu->win, cy, cx);
+ for (j = 0; j < menu->spc_rows; j++)
{
- wmove(menu->win,cy+j,cx);
- for(i=0; i < menu->spc_cols; i++)
+ wmove(menu->win, cy + j, cx);
+ for (i = 0; i < menu->spc_cols; i++)
{
- waddch( menu->win,ch);
+ waddch(menu->win, ch);
}
}
- wmove(menu->win,cy,cx+menu->spc_cols);
+ wmove(menu->win, cy, cx + menu->spc_cols);
}
- } while (hitem && (hitem != lasthor));
- wattroff(menu->win,menu->back);
-
+ }
+ while (hitem && (hitem != lasthor));
+ wattroff(menu->win, menu->back);
+
item = item->down;
y += menu->spc_rows;
-
- } while( item && (item != lastvert) );
+
+ }
+ while (item && (item != lastvert));
}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : int post_menu(MENU *)
-|
+|
| Description : Post a menu to the screen. This makes it visible.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - not a valid menu pointer
| E_SYSTEM_ERROR - error in lower layers
-| E_NO_ROOM - Menu to large for screen
| E_NOT_CONNECTED - No items connected to menu
| E_BAD_STATE - Menu in userexit routine
| E_POSTED - Menu already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-post_menu (MENU * menu)
+post_menu(MENU * menu)
{
+ T((T_CALLED("post_menu(%p)"), menu));
+
if (!menu)
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _IN_DRIVER )
+
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
+
if (menu->items && *(menu->items))
{
int y;
@@ -280,54 +289,50 @@ post_menu (MENU * menu)
WINDOW *win = Get_Menu_Window(menu);
int maxy = getmaxy(win);
- int maxx = getmaxx(win);
-
- if (maxx < menu->width || maxy < menu->height)
- RETURN(E_NO_ROOM);
- if ( (menu->win = newpad(h,menu->width)) )
+ if ((menu->win = newpad(h, menu->width)))
{
y = (maxy >= h) ? h : maxy;
- if (y>=menu->height)
+ if (y >= menu->height)
y = menu->height;
- if(!(menu->sub = subpad(menu->win,y,menu->width,0,0)))
+ if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0)))
RETURN(E_SYSTEM_ERROR);
}
- else
- RETURN(E_SYSTEM_ERROR);
-
- if (menu->status & _LINK_NEEDED)
+ else
+ RETURN(E_SYSTEM_ERROR);
+
+ if (menu->status & _LINK_NEEDED)
_nc_Link_Items(menu);
}
else
RETURN(E_NOT_CONNECTED);
-
+
menu->status |= _POSTED;
- if (!(menu->opt&O_ONEVALUE))
+ if (!(menu->opt & O_ONEVALUE))
{
ITEM **items;
-
- for(items=menu->items;*items;items++)
+
+ for (items = menu->items; *items; items++)
{
(*items)->value = FALSE;
}
}
-
+
_nc_Draw_Menu(menu);
-
- Call_Hook(menu,menuinit);
- Call_Hook(menu,iteminit);
-
+
+ Call_Hook(menu, menuinit);
+ Call_Hook(menu, iteminit);
+
_nc_Show_Menu(menu);
-
+
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : int unpost_menu(MENU *)
-|
+|
| Description : Detach menu from screen
|
| Return Values : E_OK - success
@@ -336,36 +341,38 @@ post_menu (MENU * menu)
| E_NOT_POSTED - menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-unpost_menu (MENU * menu)
+unpost_menu(MENU * menu)
{
WINDOW *win;
-
+
+ T((T_CALLED("unpost_menu(%p)"), menu));
+
if (!menu)
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _IN_DRIVER )
+
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( !( menu->status & _POSTED ) )
+ if (!(menu->status & _POSTED))
RETURN(E_NOT_POSTED);
-
- Call_Hook(menu,itemterm);
- Call_Hook(menu,menuterm);
-
+
+ Call_Hook(menu, itemterm);
+ Call_Hook(menu, menuterm);
+
win = Get_Menu_Window(menu);
werase(win);
wsyncup(win);
-
+
assert(menu->sub);
delwin(menu->sub);
menu->sub = (WINDOW *)0;
-
+
assert(menu->win);
delwin(menu->win);
menu->win = (WINDOW *)0;
-
+
menu->status &= ~_POSTED;
-
+
RETURN(E_OK);
}
diff --git a/lib/libmenu/m_req_name.c b/lib/libmenu/m_req_name.c
index 23951eb9c3c..14eda0f1fa4 100644
--- a/lib/libmenu/m_req_name.c
+++ b/lib/libmenu/m_req_name.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_req_name.c,v 1.5 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_req_name.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,27 +39,29 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_req_name.c,v 1.13 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_req_name.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
-static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = {
- "LEFT_ITEM" ,
- "RIGHT_ITEM" ,
- "UP_ITEM" ,
- "DOWN_ITEM" ,
- "SCR_ULINE" ,
- "SCR_DLINE" ,
- "SCR_DPAGE" ,
- "SCR_UPAGE" ,
- "FIRST_ITEM" ,
- "LAST_ITEM" ,
- "NEXT_ITEM" ,
- "PREV_ITEM" ,
- "TOGGLE_ITEM" ,
+static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] =
+{
+ "LEFT_ITEM",
+ "RIGHT_ITEM",
+ "UP_ITEM",
+ "DOWN_ITEM",
+ "SCR_ULINE",
+ "SCR_DLINE",
+ "SCR_DPAGE",
+ "SCR_UPAGE",
+ "FIRST_ITEM",
+ "LAST_ITEM",
+ "NEXT_ITEM",
+ "PREV_ITEM",
+ "TOGGLE_ITEM",
"CLEAR_PATTERN",
- "BACK_PATTERN" ,
- "NEXT_MATCH" ,
- "PREV_MATCH"
+ "BACK_PATTERN",
+ "NEXT_MATCH",
+ "PREV_MATCH"
};
+
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
/*---------------------------------------------------------------------------
@@ -72,18 +74,18 @@ static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = {
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-menu_request_name ( int request )
+menu_request_name(int request)
{
- if ( (request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND) )
+ T((T_CALLED("menu_request_name(%d)"), request));
+ if ((request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND))
{
SET_ERROR(E_BAD_ARGUMENT);
- return (const char *)0;
+ returnCPtr((const char *)0);
}
else
- return request_names[ request - MIN_MENU_COMMAND ];
+ returnCPtr(request_names[request - MIN_MENU_COMMAND]);
}
-
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int menu_request_by_name (const char *str);
@@ -94,28 +96,30 @@ menu_request_name ( int request )
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_request_by_name ( const char *str )
-{
+menu_request_by_name(const char *str)
+{
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
- */
+ */
unsigned int i = 0;
char buf[16];
-
+
+ T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
+
if (str)
{
- strncpy(buf,str,sizeof(buf));
- while( (i<sizeof(buf)) && (buf[i] != '\0') )
+ strncpy(buf, str, sizeof(buf));
+ while ((i < sizeof(buf)) && (buf[i] != '\0'))
{
- buf[i] = toupper(buf[i]);
+ buf[i] = toupper(UChar(buf[i]));
i++;
}
-
- for (i=0; i < A_SIZE; i++)
+
+ for (i = 0; i < A_SIZE; i++)
{
- if (strncmp(request_names[i],buf,sizeof(buf))==0)
- return MIN_MENU_COMMAND + i;
- }
+ if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ returnCode(MIN_MENU_COMMAND + (int)i);
+ }
}
RETURN(E_NO_MATCH);
}
diff --git a/lib/libmenu/m_scale.c b/lib/libmenu/m_scale.c
index ebd8801e9ec..002605cc94b 100644
--- a/lib/libmenu/m_scale.c
+++ b/lib/libmenu/m_scale.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_scale.c,v 1.4 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_scale.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_scale.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_scale.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,11 +53,13 @@ MODULE_ID("$From: m_scale.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
| E_NOT_CONNECTED - no items are connected to menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-scale_menu (const MENU *menu, int *rows, int *cols)
+scale_menu(const MENU * menu, int *rows, int *cols)
{
- if (!menu)
- RETURN( E_BAD_ARGUMENT );
-
+ T((T_CALLED("scale_menu(%p,%p,%p)"), menu, rows, cols));
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
if (menu->items && *(menu->items))
{
if (rows)
@@ -67,8 +69,7 @@ scale_menu (const MENU *menu, int *rows, int *cols)
RETURN(E_OK);
}
else
- RETURN( E_NOT_CONNECTED );
+ RETURN(E_NOT_CONNECTED);
}
/* m_scale.c ends here */
-
diff --git a/lib/libmenu/m_spacing.c b/lib/libmenu/m_spacing.c
index f31f928d3ae..d1ba795ddbe 100644
--- a/lib/libmenu/m_spacing.c
+++ b/lib/libmenu/m_spacing.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_spacing.c,v 1.5 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_spacing.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_spacing.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_spacing.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
#define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
#define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
@@ -49,15 +49,17 @@ MODULE_ID("$From: m_spacing.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
| Facility : libnmenu
| Function : int set_menu_spacing(MENU *menu,int desc, int r, int c);
|
-| Description : Set the spacing between entried
+| Description : Set the spacing between entries
|
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_spacing
-(MENU *menu, int s_desc, int s_row, int s_col )
+set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col)
{
- MENU *m; /* split for ATAC workaround */
+ MENU *m; /* split for ATAC workaround */
+
+ T((T_CALLED("set_menu_spacing(%p,%d,%d,%d)"), menu, s_desc, s_row, s_col));
+
m = Normalize_Menu(menu);
assert(m);
@@ -65,19 +67,18 @@ set_menu_spacing
RETURN(E_POSTED);
if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
- ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
- ((s_col < 0) || (s_col > MAX_SPC_COLS)))
+ ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
+ ((s_col < 0) || (s_col > MAX_SPC_COLS)))
RETURN(E_BAD_ARGUMENT);
m->spc_desc = s_desc ? s_desc : 1;
- m->spc_rows = s_row ? s_row : 1;
- m->spc_cols = s_col ? s_col : 1;
+ m->spc_rows = s_row ? s_row : 1;
+ m->spc_cols = s_col ? s_col : 1;
_nc_Calculate_Item_Length_and_Width(m);
RETURN(E_OK);
}
-
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int menu_spacing (const MENU *,int *,int *,int *);
@@ -87,15 +88,21 @@ set_menu_spacing
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_spacing ( const MENU *menu, int* s_desc, int* s_row, int* s_col)
+menu_spacing(const MENU * menu, int *s_desc, int *s_row, int *s_col)
{
- const MENU *m; /* split for ATAC workaround */
+ const MENU *m; /* split for ATAC workaround */
+
+ T((T_CALLED("menu_spacing(%p,%p,%p,%p)"), menu, s_desc, s_row, s_col));
+
m = Normalize_Menu(menu);
assert(m);
- if (s_desc) *s_desc = m->spc_desc;
- if (s_row) *s_row = m->spc_rows;
- if (s_col) *s_col = m->spc_cols;
+ if (s_desc)
+ *s_desc = m->spc_desc;
+ if (s_row)
+ *s_row = m->spc_rows;
+ if (s_col)
+ *s_col = m->spc_cols;
RETURN(E_OK);
}
diff --git a/lib/libmenu/m_sub.c b/lib/libmenu/m_sub.c
index d91658f057d..7204ba47e4b 100644
--- a/lib/libmenu/m_sub.c
+++ b/lib/libmenu/m_sub.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_sub.c,v 1.4 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_sub.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_sub.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_sub.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,18 +51,20 @@ MODULE_ID("$From: m_sub.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_sub (MENU *menu, WINDOW *win)
+set_menu_sub(MENU * menu, WINDOW *win)
{
+ T((T_CALLED("set_menu_sub(%p,%p)"), menu, win));
+
if (menu)
{
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
menu->usersub = win;
_nc_Calculate_Item_Length_and_Width(menu);
}
else
_nc_Default_Menu.usersub = win;
-
+
RETURN(E_OK);
}
@@ -75,10 +77,12 @@ set_menu_sub (MENU *menu, WINDOW *win)
| Return Values : NULL on error, otherwise a pointer to the window
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-menu_sub (const MENU * menu)
+menu_sub(const MENU * menu)
{
- const MENU* m = Normalize_Menu(menu);
- return Get_Menu_Window(m);
+ const MENU *m = Normalize_Menu(menu);
+
+ T((T_CALLED("menu_sub(%p)"), menu));
+ returnWin(Get_Menu_Window(m));
}
/* m_sub.c ends here */
diff --git a/lib/libmenu/m_adabind.c b/lib/libmenu/m_trace.c
index c9b134866e9..2adca5df7b2 100644
--- a/lib/libmenu/m_adabind.c
+++ b/lib/libmenu/m_trace.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: m_adabind.c,v 1.1 1998/07/24 16:38:52 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,39 +27,51 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1995,1997 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
-/***************************************************************************
-* Module m_adabind.c *
-* Helper routines to ease the implementation of an Ada95 binding to *
-* ncurses. For details and copyright of the binding see the ../Ada95 *
-* subdirectory. *
-***************************************************************************/
#include "menu.priv.h"
-MODULE_ID("$From: m_adabind.c,v 1.6 1998/02/11 12:13:50 tom Exp $")
+MODULE_ID("$Id: m_trace.c,v 1.1 2010/01/12 23:22:08 nicm Exp $")
+
+NCURSES_EXPORT(ITEM *)
+_nc_retrace_item(ITEM * code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
+NCURSES_EXPORT(ITEM **)
+_nc_retrace_item_ptr(ITEM ** code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
-/* Prototypes for the functions in this module */
-void _nc_ada_normalize_menu_opts (int *opt);
-void _nc_ada_normalize_item_opts (int *opt);
-ITEM* _nc_get_item(const MENU*, int);
+NCURSES_EXPORT(Item_Options)
+_nc_retrace_item_opts(Item_Options code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
+}
-void _nc_ada_normalize_menu_opts (int *opt)
+NCURSES_EXPORT(MENU *)
+_nc_retrace_menu(MENU * code)
{
- *opt = ALL_MENU_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
-void _nc_ada_normalize_item_opts (int *opt)
+NCURSES_EXPORT(Menu_Hook)
+_nc_retrace_menu_hook(Menu_Hook code)
{
- *opt = ALL_ITEM_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
-ITEM* _nc_get_item(const MENU* menu, int idx) {
- if (menu && menu->items && idx>=0 && (idx<menu->nitems))
- {
- return menu->items[idx];
- }
- else
- return (ITEM*)0;
+NCURSES_EXPORT(Menu_Options)
+_nc_retrace_menu_opts(Menu_Options code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
}
diff --git a/lib/libmenu/m_userptr.c b/lib/libmenu/m_userptr.c
index 1e8894e0ca8..a97a5d857a1 100644
--- a/lib/libmenu/m_userptr.c
+++ b/lib/libmenu/m_userptr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_userptr.c,v 1.6 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_userptr.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_userptr.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_userptr.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,10 +51,11 @@ MODULE_ID("$From: m_userptr.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_userptr (MENU * menu, void * userptr)
+set_menu_userptr(MENU * menu, void *userptr)
{
+ T((T_CALLED("set_menu_userptr(%p,%p)"), menu, userptr));
Normalize_Menu(menu)->userptr = userptr;
- RETURN( E_OK );
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -68,9 +69,10 @@ set_menu_userptr (MENU * menu, void * userptr)
| NULL is returned
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-menu_userptr (const MENU * menu)
+menu_userptr(const MENU * menu)
{
- return( Normalize_Menu(menu)->userptr);
+ T((T_CALLED("menu_userptr(%p)"), menu));
+ returnVoidPtr(Normalize_Menu(menu)->userptr);
}
/* m_userptr.c ends here */
diff --git a/lib/libmenu/m_win.c b/lib/libmenu/m_win.c
index 988e9695f18..369a922214f 100644
--- a/lib/libmenu/m_win.c
+++ b/lib/libmenu/m_win.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_win.c,v 1.6 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_win.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_win.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_win.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,18 +51,20 @@ MODULE_ID("$From: m_win.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_win (MENU *menu, WINDOW *win)
+set_menu_win(MENU * menu, WINDOW *win)
{
+ T((T_CALLED("set_menu_win(%p,%p)"), menu, win));
+
if (menu)
{
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
menu->userwin = win;
_nc_Calculate_Item_Length_and_Width(menu);
}
else
_nc_Default_Menu.userwin = win;
-
+
RETURN(E_OK);
}
@@ -75,10 +77,12 @@ set_menu_win (MENU *menu, WINDOW *win)
| Return Values : NULL on error, otherwise pointer to window
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-menu_win (const MENU *menu)
+menu_win(const MENU * menu)
{
- const MENU* m = Normalize_Menu(menu);
- return (m->userwin ? m->userwin : stdscr);
+ const MENU *m = Normalize_Menu(menu);
+
+ T((T_CALLED("menu_win(%p)"), menu));
+ returnWin(m->userwin ? m->userwin : stdscr);
}
/* m_win.c ends here */
diff --git a/lib/libmenu/menu.3tbl b/lib/libmenu/menu.3tbl
index cf7e1e6d5cd..828ba82080f 100644
--- a/lib/libmenu/menu.3tbl
+++ b/lib/libmenu/menu.3tbl
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu.3tbl,v 1.5 2000/07/24 04:06:12 millert Exp $
+.\" $OpenBSD: menu.3tbl,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu.3x,v 1.14 2000/07/15 22:55:59 tom Exp $
+.\" $Id: menu.3tbl,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu 3 ""
.SH NAME
\fBmenu\fR - curses extension for programming menus
@@ -41,25 +41,25 @@ The \fBmenu\fR library provides terminal-independent facilities for composing
menu systems on character-cell terminals. The library includes: item routines,
which create and modify menu items; and menu routines, which group items into
menus, display menus on the screen, and handle interaction with the user.
-
+.PP
The \fBmenu\fR library uses the \fBcurses\fR libraries, and a curses
initialization routine such as \fBinitscr\fR must be called before using any of
these functions. To use the \fBmenu\fR library, link with the options
\fB-lmenu -lcurses\fR.
-
+.
.SS Current Default Values for Item Attributes
-
+.
The \fBmenu\fR library maintains a default value for item attributes. You can
get or set this default by calling the appropriate \fBget_\fR or \fBset_\fR
routine with a \fBNULL\fR item pointer. Changing this default with a
\fBset_\fR function affects future item creations, but does not change the
rendering of items already created.
-
+.
.SS Routine Name Index
-
+.
The following table lists each \fBmenu\fR routine and the name of
the manual page on which it is described.
-
+.
.TS
l l .
\fBcurses\fR Routine Name Manual Page Name
@@ -133,57 +133,60 @@ unpost_menu \fBmenu_post\fR(3)
Routines that return pointers return \fBNULL\fR on error. Routines that return
an integer return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
-The menu is already posted.
-.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
-Menu is too large for its window.
+.B E_NO_MATCH
+Character failed to match.
.TP 5
-\fBE_NOT_POSTED\fR
-The menu has not been posted.
+.B E_NO_ROOM
+Menu is too large for its window.
.TP 5
-\fBE_UNKNOWN_COMMAND\fR
-The menu driver code saw an unknown request code.
+.B E_NOT_CONNECTED
+No items are connected to the menu.
.TP 5
-\fBE_NO_MATCH\fR
-Character failed to match.
+.B E_NOT_POSTED
+The menu has not been posted.
.TP 5
-\fBE_NOT_SELECTABLE\fR
+.B E_NOT_SELECTABLE
The designated item cannot be selected.
.TP 5
-\fBE_NOT_CONNECTED\fR
-No items are connected to the menu.
+.B E_POSTED
+The menu is already posted.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The menu driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.TP 5
+.B E_UNKNOWN_COMMAND
+The menu driver code saw an unknown request code.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin "menu_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "menu_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<menu.h>\fR automatically includes the header files
\fB<curses.h>\fR and \fB<eti.h>\fR.
-
-In your library list, libmenu.a should be before libcurses.a; that is,
-you want to say `-lmenu -lcurses', not the other way around (which would
-give you a link error using GNU \fBld\fR(1) and many other linkers).
+.PP
+In your library list, libmenu.a should be before libncurses.a; that is,
+you want to say `-lmenu -lncurses', not the other way around (which would
+usually give a link-error).
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for ncurses by Eric
S. Raymond.
+.SH SEE ALSO
+This describes \fBncurses\fR
+version 5.7.
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libmenu/menu.h b/lib/libmenu/menu.h
index 19d0ab5fe51..a5f3a5e2bf7 100644
--- a/lib/libmenu/menu.h
+++ b/lib/libmenu/menu.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: menu.h,v 1.7 2001/01/22 18:02:07 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,9 +27,11 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: menu.h,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
+
#ifndef ETI_MENU
#define ETI_MENU
@@ -78,7 +78,7 @@ typedef struct tagITEM
short x;
bool value; /* Selection value */
- struct tagITEM *left; /* neighbour items */
+ struct tagITEM *left; /* neighbor items */
struct tagITEM *right;
struct tagITEM *up;
struct tagITEM *down;
@@ -217,23 +217,23 @@ extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *);
extern NCURSES_EXPORT(int) post_menu (MENU *);
extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *);
extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item);
-extern NCURSES_EXPORT(int) set_item_init (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options);
-extern NCURSES_EXPORT(int) set_item_term (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *);
extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool);
extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int);
extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype);
-extern NCURSES_EXPORT(int) set_menu_init (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **);
extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *);
extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options);
extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int);
extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *);
extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *);
-extern NCURSES_EXPORT(int) set_menu_term (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *);
extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *);
extern NCURSES_EXPORT(int) set_top_row (MENU *,int);
diff --git a/lib/libmenu/menu.priv.h b/lib/libmenu/menu.priv.h
index 3d7527c6b07..913e0d1c795 100644
--- a/lib/libmenu/menu.priv.h
+++ b/lib/libmenu/menu.priv.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: menu.priv.h,v 1.7 2001/01/22 18:02:07 millert Exp $ */
+/* $OpenBSD: menu.priv.h,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,14 +29,20 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: menu.priv.h,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
+
/***************************************************************************
* Module menu.priv.h *
* Top level private header file for all libnmenu modules *
***************************************************************************/
+#ifndef MENU_PRIV_H_incl
+#define MENU_PRIV_H_incl 1
+
+#include "curses.priv.h"
#include "mf_common.h"
#include "menu.h"
@@ -102,10 +108,13 @@ extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu;
{ (menu)->pindex = 0; \
(menu)->pattern[0] = '\0'; }
+#define UChar(c) ((unsigned char)(c))
+
/* Internal functions. */
extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
+extern NCURSES_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *);
extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
@@ -114,3 +123,32 @@ extern NCURSES_EXPORT(void) _nc_Link_Items (MENU *);
extern NCURSES_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**);
extern NCURSES_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
int* pY, int* pX);
+
+#ifdef TRACE
+
+#define returnItem(code) TRACE_RETURN(code,item)
+#define returnItemPtr(code) TRACE_RETURN(code,item_ptr)
+#define returnItemOpts(code) TRACE_RETURN(code,item_opts)
+#define returnMenu(code) TRACE_RETURN(code,menu)
+#define returnMenuHook(code) TRACE_RETURN(code,menu_hook)
+#define returnMenuOpts(code) TRACE_RETURN(code,menu_opts)
+
+extern NCURSES_EXPORT(ITEM *) _nc_retrace_item (ITEM *);
+extern NCURSES_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **);
+extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options);
+extern NCURSES_EXPORT(MENU *) _nc_retrace_menu (MENU *);
+extern NCURSES_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook);
+extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options);
+
+#else /* !TRACE */
+
+#define returnItem(code) return code
+#define returnItemPtr(code) return code
+#define returnItemOpts(code) return code
+#define returnMenu(code) return code
+#define returnMenuHook(code) return code
+#define returnMenuOpts(code) return code
+
+#endif /* TRACE/!TRACE */
+
+#endif /* MENU_PRIV_H_incl */
diff --git a/lib/libmenu/menu_attributes.3 b/lib/libmenu/menu_attributes.3
index e400d63fe20..60990ba50b8 100644
--- a/lib/libmenu/menu_attributes.3
+++ b/lib/libmenu/menu_attributes.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_attributes.3,v 1.1 2000/07/24 04:06:12 millert Exp $
+.\" $OpenBSD: menu_attributes.3,v 1.2 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_attributes.3x,v 1.6 1998/11/29 01:09:20 Rick.Ohnemus Exp $
+.\" $Id: menu_attributes.3,v 1.2 2010/01/12 23:22:08 nicm Exp $
.TH menu_attributes 3 ""
.SH NAME
\fBmenu_attributes\fR - color and attribute control for menus
@@ -56,34 +56,34 @@ int menu_pad(const MENU *menu);
The function \fBset_menu_fore\fR sets the foreground attribute of
\fImenu\fR. This is the highlight used for selected menu items.
\fBmenu_fore\fR returns the foreground attribute. The default
-is \fBA_STANDOUT\fR.
-
+is \fBA_REVERSE\fR.
+.PP
The function \fBset_menu_back\fR sets the background attribute of
\fImenu\fR. This is the highlight used for selectable (but not currently
selected) menu items. The function \fBmenu_back\fR returns the background
attribute. The default is \fBA_NORMAL\fR.
-
+.PP
The function \fBset_menu_grey\fR sets the grey attribute of \fImenu\fR. This is
the highlight used for un-selectable menu items in menus that permit more than
one selection. The function \fBmenu_grey\fR returns the grey attribute.
The default is \fBA_UNDERLINE\fR.
-
+.PP
The function \fBset_menu_pad\fR sets the character used to fill the space
between the name and description parts of a menu item. \fBmenu_pad\fR returns
the given menu's pad character. The default is a blank.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "menu_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "menu_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<menu.h>\fR automatically includes the header file
diff --git a/lib/libmenu/menu_cursor.3 b/lib/libmenu/menu_cursor.3
index ce4599d2fbc..3f657861eae 100644
--- a/lib/libmenu/menu_cursor.3
+++ b/lib/libmenu/menu_cursor.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_cursor.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_cursor.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_cursor.3x,v 1.5 1998/11/29 01:09:30 Rick.Ohnemus Exp $
+.\" $Id: menu_cursor.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_cursor 3 ""
.SH NAME
\fBmenu_cursor\fR - position a menu's cursor
@@ -45,16 +45,16 @@ routines have been called to do screen-painting in response to a menu select.
.SH RETURN VALUE
This routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The menu has not been posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_driver.3 b/lib/libmenu/menu_driver.3
index fb6cd06759a..5b9bb140fb1 100644
--- a/lib/libmenu/menu_driver.3
+++ b/lib/libmenu/menu_driver.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: menu_driver.3,v 1.6 2000/03/14 21:31:46 aaron Exp $
+.\" $OpenBSD: menu_driver.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: menu_driver.3x,v 1.8 1999/01/09 22:55:18 tom Exp $
+.\" $Id: menu_driver.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_driver 3 ""
.SH NAME
\fBmenu_driver\fR - command-processing loop of the menu system
@@ -39,9 +39,21 @@ int menu_driver(MENU *menu, int c);
.br
.SH DESCRIPTION
Once a menu has been posted (displayed), you should funnel input events to it
-through \fBmenu_driver\fR. This routine has three major input cases; either
-the input is a menu navigation request, it's a printable ASCII character or it
-is the KEY_MOUSE special key associated with an mouse event.
+through \fBmenu_driver\fR. This routine has three major input cases:
+.TP 3
+-
+The input is a form navigation request.
+Navigation request codes are constants defined in \fB<form.h>\fP,
+which are distinct from the key- and character codes returned by \fBwgetch\fP.
+.TP 3
+-
+The input is a printable character.
+Printable characters (which must be positive, less than 256) are
+checked according to the program's locale settings.
+.TP 3
+-
+The input is the KEY_MOUSE special key associated with an mouse event.
+.PP
The menu driver requests are as follows:
.TP 5
REQ_LEFT_ITEM
@@ -95,34 +107,65 @@ Move to the next item matching the pattern match.
REQ_PREV_MATCH
Move to the previous item matching the pattern match.
.PP
-If the second argument is a printable ASCII character, the code appends
+If the second argument is a printable character, the code appends
it to the pattern buffer and attempts to move to the next item matching
the new pattern. If there is no such match, \fBmenu_driver\fR returns
\fBE_NO_MATCH\fR and deletes the appended character from the buffer.
.PP
If the second argument is one of the above pre-defined requests, the
corresponding action is performed.
+.SS MOUSE HANDLING
.PP
If the second argument is the KEY_MOUSE special key, the associated
mouse event is translated into one of the above pre-defined requests.
Currently only clicks in the user window (e.g., inside the menu display
-area or the decoration window) are handled. If you click above the
-display region of the menu, a REQ_SCR_ULINE is generated, if you
-doubleclick a REQ_SCR_UPAGE is generated and if you tripleclick a
-REQ_FIRST_ITEM is generated. If you click below the display region of
-the menu, a REQ_SCR_DLINE is generated, if you doubleclick a REQ_SCR_DPAGE
-is generated and if you tripleclick a REQ_LAST_ITEM is generated. If you
-click at an item inside the display area of the menu, the menu cursor
-is positioned to that item. If you double-click at an item a REQ_TOGGLE_ITEM
-is generated and \fBE_UNKNOWN_COMMAND\fR is returned. This return value makes
-sense, because a double click usually means that an item-specific action should
-be returned. It's exactly the purpose of this return value to signal that an
-application specific command should be executed. If a translation
+area or the decoration window) are handled.
+.PP
+If you click above the display region of the menu:
+.RS
+.TP
+a REQ_SCR_ULINE is generated for a single click,
+.TP
+a REQ_SCR_UPAGE is generated for a double-click and
+.TP
+a REQ_FIRST_ITEM is generated for a triple-click.
+.RE
+.PP
+If you click below the display region of the menu:
+.RS
+.TP
+a REQ_SCR_DLINE is generated for a single click,
+.TP
+a REQ_SCR_DPAGE is generated for a double-click and
+.TP
+a REQ_LAST_ITEM is generated for a triple-click.
+.RE
+.PP
+If you click at an item inside the display area of the menu:
+.RS
+.TP 3
+-
+the menu cursor is positioned to that item.
+.TP 3
+-
+If you double-click an item a REQ_TOGGLE_ITEM
+is generated and \fBE_UNKNOWN_COMMAND\fR is returned.
+This return value makes sense,
+because a double click usually means that an item-specific action should
+be returned.
+It is exactly the purpose of this return value to signal that an
+application specific command should be executed.
+.TP 3
+-
+If a translation
into a request was done, \fBmenu_driver\fR returns the result of this request.
-If you clicked outside the user window or the mouse event couldn't be translated
+.RE
+.PP
+If you clicked outside the user window or the mouse event could not be translated
into a menu request an \fBE_REQUEST_DENIED\fR is returned.
+.SS APPLICATION-DEFINED COMMANDS
.PP
-If the second argument is neither printable ASCII nor one of the above
+If the second argument is neither printable nor one of the above
pre-defined menu requests or KEY_MOUSE, the drive assumes it is an application-specific
command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands
should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
@@ -130,31 +173,33 @@ pre-defined requests.
.SH RETURN VALUE
\fBmenu_driver\fR return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The menu has not been posted.
.TP 5
-\fBE_UNKNOWN_COMMAND\fR
+.B E_UNKNOWN_COMMAND
The menu driver code saw an unknown request code.
.TP 5
-\fBE_NO_MATCH\fR
+.B E_NO_MATCH
Character failed to match.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The menu driver could not process the request.
.SH SEE ALSO
-\fBcurses\fR(3), \fBmenu\fR(3).
+\fBcurses\fR(3),
+\fBmenu\fR(3),
+\fBwgetch\fR(3).
.SH NOTES
The header file \fB<menu.h>\fR automatically includes the header files
\fB<curses.h>\fR.
diff --git a/lib/libmenu/menu_format.3 b/lib/libmenu/menu_format.3
index 2ea075b1585..2f827be8fa7 100644
--- a/lib/libmenu/menu_format.3
+++ b/lib/libmenu/menu_format.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_format.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_format.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_format.3x,v 1.7 1998/11/29 01:09:39 Rick.Ohnemus Exp $
+.\" $Id: menu_format.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_format 3 ""
.SH NAME
\fBmenu_format\fR - set and get menu sizes
@@ -38,35 +38,38 @@
.br
int set_menu_format(MENU *menu, int rows, int cols);
.br
-int menu_format(const MENU *menu, int *rows, int *cols);
+void menu_format(const MENU *menu, int *rows, int *cols);
.br
.SH DESCRIPTION
The function \fBset_menu_format\fR sets the maximum display size of the given
menu. If this size is too small to display all menu items, the menu will be
made scrollable. If this size is larger than the menus subwindow and the
subwindow is too small to display all menu items, \fBpost_menu()\fR will fail.
-
+.PP
The default format is 16 rows, 1 column. Calling \fBset_menu_format\fR with a
null menu pointer will change this default. A zero row or column argument to
\fBset_menu_format\fR is interpreted as a request not to change the current
value.
-
+.PP
The function \fBmenu_format\fR returns the maximum-size constraints for the
given menu into the storage addressed by \fBrows\fR and \fBcols\fR.
.SH RETURN VALUE
These routines returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu is already posted.
+.TP 5
+.B E_NOT_CONNECTED
+No items are connected to the menu.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_hook.3 b/lib/libmenu/menu_hook.3
index 88066b67a4f..dc8bdfd10be 100644
--- a/lib/libmenu/menu_hook.3
+++ b/lib/libmenu/menu_hook.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_hook.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_hook.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,48 +29,48 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_hook.3x,v 1.6 1998/11/29 01:09:47 Rick.Ohnemus Exp $
+.\" $Id: menu_hook.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_hook 3 ""
.SH NAME
\fBmenu_hook\fR - set hooks for automatic invocation by applications
.SH SYNOPSIS
\fB#include <menu.h>\fR
.br
-int set_item_init(MENU *menu, void (*func)(MENU *));
+int set_item_init(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) item_init(const MENU *menu);
+Menu_Hook item_init(const MENU *menu);
.br
-int set_item_term(MENU *menu, void (*func)(MENU *));
+int set_item_term(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) item_term(const MENU *menu);
+Menu_Hook item_term(const MENU *menu);
.br
-int set_menu_init(MENU *menu, void (*func)(MENU *));
+int set_menu_init(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) menu_init(const MENU *menu);
+Menu_Hook menu_init(const MENU *menu);
.br
-int set_menu_term(MENU *menu, void (*func)(MENU *));
+int set_menu_term(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) menu_term(const MENU *menu);
+Menu_Hook menu_term(const MENU *menu);
.br
.SH DESCRIPTION
These functions make it possible to set hook functions to be called at various
points in the automatic processing of input event codes by \fBmenu_driver\fR.
-
+.PP
The function \fBset_item_init\fR sets a hook to be called at menu-post time and
each time the selected item changes (after the change). \fBitem_init\fR
returns the current item init hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_item_term\fR sets a hook to be called at menu-unpost time
and each time the selected item changes (before the change). \fBitem_term\fR
returns the current item term hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_menu_init\fR sets a hook to be called at menu-post time and
just after the top row on the menu changes once it is posted. \fBmenu_init\fR
returns the current menu init hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_menu_term\fR sets a hook to be called at menu-unpost time
and just before the top row on the menu changes once it is posted.
\fBmenu_term\fR returns the current menu term hook, if any (\fBNULL\fR if there
@@ -79,10 +79,10 @@ is no such hook).
Routines that return pointers return \fBNULL\fR on error. Other routines
return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_items.3 b/lib/libmenu/menu_items.3
index 9adac1f204d..fc75b26c85e 100644
--- a/lib/libmenu/menu_items.3
+++ b/lib/libmenu/menu_items.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_items.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_items.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_items.3x,v 1.5 1998/11/29 01:09:56 Rick.Ohnemus Exp $
+.\" $Id: menu_items.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_items 3 ""
.SH NAME
\fBmenu_items\fR - make and break connections between items and menus
@@ -45,32 +45,34 @@ int item_count(const MENU *menu);
.SH DESCRIPTION
The function \fBset_menu_items\fR changes the item pointer array of the given
\fImenu\fR. The array must be terminated by a \fBNULL\fR.
-
+.PP
The function \fBmenu_items\fR returns the item array of the given menu.
-
+.PP
The function \fBitem_count\fR returns the count of items in \fImenu\fR.
.SH RETURN VALUES
-The function \fBmenu_items\fR returns \fBNULL\fR on error.
-
+The function \fBmenu_items\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
The function \fBitem_count\fR returns \fBERR\fR (the general \fBcurses\fR error
-return value) on error.
-
+return value) if its \fImenu\fP parameter is \fBNULL\fP.
+.PP
The function \fBset_menu_items\fR returns one of the following codes on error:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_NOT_CONNECTED
+No items are connected to the menu.
+.TP 5
+.B E_POSTED
The menu is already posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
-No items are connected to the menu.
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -79,7 +81,7 @@ The header file \fB<menu.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
-
+.PP
The SVr4 menu library documentation specifies the \fBitem_count\fR error value
as -1 (which is the value of \fBERR\fR).
.SH AUTHORS
diff --git a/lib/libmenu/menu_mark.3 b/lib/libmenu/menu_mark.3
index 3ff7a47c64c..b7b8ea2f706 100644
--- a/lib/libmenu/menu_mark.3
+++ b/lib/libmenu/menu_mark.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_mark.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_mark.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_mark.3x,v 1.6 1998/11/29 01:10:03 Rick.Ohnemus Exp $
+.\" $Id: menu_mark.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_mark 3 ""
.SH NAME
\fBmenu_mark\fR - get and set the menu mark string
@@ -44,29 +44,31 @@ const char *menu_mark(const MENU *menu);
In order to make menu selections visible on older terminals without
highlighting or color capability, the menu library marks selected items
in a menu with a prefix string.
-
+.PP
The function \fBset_menu_mark\fR sets the mark string for the given menu.
Calling \fBset_menu_mark\fR with a null menu item will abolish the mark string.
Note that changing the length of the mark string for a menu while the
menu is posted is likely to produce unhelpful behavior.
-
+.PP
The default string is "-" (a dash). Calling \fBset_menu_mark\fR with
-a \fBNULL\fR menu argument will change this default.
-
+a non-\fBNULL\fR menu argument will change this default.
+.PP
The function \fBmenu_mark\fR returns the menu's mark string (or \fBNULL\fR if
there is none).
.SH RETURN VALUE
-The function \fBmenu_mark\fR returns \fBNULL\fR on error. The function
-\fBset_menu_mark\fR may return the following error codes:
+The function \fBmenu_mark\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBset_menu_mark\fR may return the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_new.3 b/lib/libmenu/menu_new.3
index 8a18206c584..3056aab25e7 100644
--- a/lib/libmenu/menu_new.3
+++ b/lib/libmenu/menu_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_new.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_new.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_new.3x,v 1.7 1998/11/29 01:10:13 Rick.Ohnemus Exp $
+.\" $Id: menu_new.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_new 3 ""
.SH NAME
\fBmenu_new\fR - create and destroy menus
@@ -43,24 +43,31 @@ int free_menu(MENU *menu);
.SH DESCRIPTION
The function \fBnew_menu\fR creates a new menu connected to a specified item
pointer array (which must be \fBNULL\fR-terminated).
-
+.PP
The function \fBfree_menu\fR disconnects \fImenu\fR from its item array
and frees the storage allocated for the menu.
.SH RETURN VALUE
The function \fBnew_menu\fR returns \fBNULL\fR on error.
-
+It sets errno according to the function's failure:
+.TP 5
+.B E_NOT_CONNECTED
+No items are connected to the menu.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
The function \fBfree_menu\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu has already been posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_opts.3 b/lib/libmenu/menu_opts.3
index c9eecc8f1be..dfa3e2a7959 100644
--- a/lib/libmenu/menu_opts.3
+++ b/lib/libmenu/menu_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_opts.3,v 1.7 1999/05/12 13:26:49 aaron Exp $
+.\" $OpenBSD: menu_opts.3,v 1.8 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,33 +29,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_opts.3x,v 1.7 1998/11/29 01:10:21 Rick.Ohnemus Exp $
+.\" $Id: menu_opts.3,v 1.8 2010/01/12 23:22:08 nicm Exp $
.TH menu_opts 3 ""
.SH NAME
\fBmenu_opts\fR - set and get menu options
.SH SYNOPSIS
\fB#include <menu.h>\fR
.br
-int set_menu_opts(MENU *menu, OPTIONS opts);
+int set_menu_opts(MENU *menu, Menu_Options opts);
.br
-int menu_opts_on(MENU *menu, OPTIONS opts);
+int menu_opts_on(MENU *menu, Menu_Options opts);
.br
-int menu_opts_off(MENU *menu, OPTIONS opts);
+int menu_opts_off(MENU *menu, Menu_Options opts);
.br
-OPTIONS menu_opts(const MENU *menu);
+Menu_Options menu_opts(const MENU *menu);
.br
.SH DESCRIPTION
The function \fBset_menu_opts\fR sets all the given menu's option bits (menu
option bits may be logically OR'ed together).
-
+.PP
The function \fBmenu_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBmenu_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBmenu_opts\fR returns the menu's current option bits.
-
+.PP
The following options are defined (all are on by default):
.TP 5
O_ONEVALUE
@@ -79,13 +79,13 @@ requests to the other end of the menu.
.SH RETURN VALUE
Except for \fBmenu_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu is already posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_pattern.3 b/lib/libmenu/menu_pattern.3
index 63240fc886a..8c6251e3b26 100644
--- a/lib/libmenu/menu_pattern.3
+++ b/lib/libmenu/menu_pattern.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: menu_pattern.3,v 1.5 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_pattern.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: menu_pattern.3x,v 1.5 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: menu_pattern.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu_pattern 3 ""
.SH NAME
\fBmenu_pattern\fR - get and set a menu's pattern buffer
@@ -41,30 +41,39 @@ char *menu_pattern(const MENU *menu);
.br
.SH DESCRIPTION
Every menu has an associated pattern match buffer. As input events that are
-printable ASCII characters come in, they are appended to this match buffer
+printable characters come in, they are appended to this match buffer
and tested for a match, as described in \fBmenu_driver\fR(3).
-
+.PP
The function \fBset_menu_pattern\fR sets the pattern buffer for the given menu
and tries to find the first matching item. If it succeeds, that item becomes
-current; if not, the current item does not change.
-
+current; if not, the current item does not change.
+.PP
The function \fBmenu_pattern\fR returns the pattern buffer of the given
\fImenu\fR.
.SH RETURN VALUE
-The function \fBmenu_pattern\fR returns \fBNULL\fR on error. The function
-\fBset_menu_pattern\fR may return the following error codes:
+The function \fBmenu_pattern\fR returns a pointer, which is \fBNULL\fR if the \fImenu\fP parameter is \fBNULL\fP.
+Otherwise, it is a pointer to a string which is empty if no pattern has been set.
+It does not set errno.
+.PP
+The function \fBset_menu_pattern\fR may return the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_NO_MATCH\fR
+.B E_BAD_STATE
+Routine was called from an initialization or termination function.
+.TP 5
+.B E_NOT_CONNECTED
+No items are connected to menu.
+.TP 5
+.B E_NO_MATCH
Character failed to match.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_post.3 b/lib/libmenu/menu_post.3
index 24d2ee641bc..ce77165f75c 100644
--- a/lib/libmenu/menu_post.3
+++ b/lib/libmenu/menu_post.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_post.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_post.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_post.3x,v 1.7 1998/11/29 01:10:33 Rick.Ohnemus Exp $
+.\" $Id: menu_post.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_post 3 ""
.SH NAME
\fBmenu_post\fR - write or erase menus from associated subwindows
@@ -45,34 +45,34 @@ The function \fBpost_menu\fR displays a menu to its associated subwindow. To
trigger physical display of the subwindow, use \fBrefresh\fR or some equivalent
\fBcurses\fR routine (the implicit \fBdoupdate\fR triggered by an \fBcurses\fR
input request will do). \fBpost_menu\fR resets the selection status of all items.
-
+.PP
The function \fBunpost_menu\fR erases menu from its associated subwindow.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu has already been posted.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
+.B E_NO_ROOM
Menu is too large for its window. You should consider to use
\fBset_menu_format()\fR to solve the problem.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The menu has not been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the menu.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_requestname.3 b/lib/libmenu/menu_requestname.3
index 58d815c3bfb..a09c5b5d7fb 100644
--- a/lib/libmenu/menu_requestname.3
+++ b/lib/libmenu/menu_requestname.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_requestname.3,v 1.5 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_requestname.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_requestname.3x,v 1.6 1998/11/29 01:10:40 Rick.Ohnemus Exp $
+.\" $Id: menu_requestname.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu_requestname 3 ""
.SH NAME
\fBmenu_requestname\fR - handle printable menu request names
@@ -45,12 +45,14 @@ The function \fBmenu_request_name\fR returns the printable name of a menu
request code.
.br
The function \fBmenu_request_by_name\fR searches in the name-table for a request
-with the given name and returns its request code. Otherwise E_NO_MATCH is returned.
+with the given name and returns its request code.
+Otherwise E_NO_MATCH is returned.
.SH RETURN VALUE
-\fBmenu_request_name\fR returns \fBNULL\fR on error and sets errno
-to \fBE_BAD_ARGUMENT\fR.
+\fBmenu_request_name\fR returns \fBNULL\fR on error
+and sets errno to \fBE_BAD_ARGUMENT\fR.
.br
\fBmenu_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+It does not set errno.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_spacing.3 b/lib/libmenu/menu_spacing.3
index e000a3c13fc..ac6e8e50345 100644
--- a/lib/libmenu/menu_spacing.3
+++ b/lib/libmenu/menu_spacing.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_spacing.3,v 1.5 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_spacing.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2001,2004 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_spacing.3x,v 1.5 1998/11/29 01:10:51 Rick.Ohnemus Exp $
+.\" $Id: menu_spacing.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu_spacing 3 ""
.SH NAME
\fBmenu_spacing\fR - Control spacing between menu items.
@@ -37,12 +37,12 @@
\fB#include <menu.h>\fR
.br
int set_menu_spacing(MENU *menu,
- int spc_description
+ int spc_description,
int spc_rows,
int spc_columns);
.br
int menu_spacing(const MENU *menu,
- int* spc_description
+ int* spc_description,
int* spc_rows,
int* spc_columns);
.br
@@ -53,7 +53,7 @@ description. It must not be larger than \fBTABSIZE\fR. The menu system puts in t
middle of this spacing area the pad character. The remaining parts are filled with
spaces.
\fBspc_rows\fR controls the number of rows that are used for an item. It must not be
-larger than 3. The menu system inserts then blank lines between item rows, these lines
+larger than 3. The menu system inserts the blank lines between item rows, these lines
will contain the pad character in the appropriate positions.
\fBspc_columns\fR controls the number of blanks between columns of items. It must not
be larger than TABSIZE.
diff --git a/lib/libmenu/menu_userptr.3 b/lib/libmenu/menu_userptr.3
index 38e33fa9e44..ff00ba445ae 100644
--- a/lib/libmenu/menu_userptr.3
+++ b/lib/libmenu/menu_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_userptr.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_userptr.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_userptr.3x,v 1.6 1998/11/29 01:11:02 Rick.Ohnemus Exp $
+.\" $Id: menu_userptr.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_userptr 3 ""
.SH NAME
\fBmenu_userptr\fR - associate application data with a menu item
@@ -45,14 +45,10 @@ Every menu and every menu item has a field that can be used to hold
application-specific data (that is, the menu-driver code leaves it alone).
These functions get and set the menu user pointer field.
.SH RETURN VALUE
-Except for \fBmenu_userptr\fR (which returns \fBNULL\fR on error), each
-function returns one of the following:
-.TP 5
-\fBE_OK\fR
-The routine succeeded.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+\fBmenu_userptr\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+\fBset_menu_userptr\fP returns \fBE_OK\fP (success).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -61,9 +57,9 @@ The header file \fB<menu.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
-
-The user pointer should be a void pointer. We leave it as a char pointer for
-SVr4 compatibility.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libmenu/menu_win.3 b/lib/libmenu/menu_win.3
index b21d77e18ab..29b5e4f2670 100644
--- a/lib/libmenu/menu_win.3
+++ b/lib/libmenu/menu_win.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_win.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_win.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_win.3x,v 1.6 1998/11/29 01:11:11 Rick.Ohnemus Exp $
+.\" $Id: menu_win.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_win 3 ""
.SH NAME
\fBmenu_win\fR - make and break menu window and subwindow associations
@@ -50,33 +50,33 @@ int scale_menu(const MENU *menu, int *rows, int *columns);
Every menu has an associated pair of \fBcurses\fR windows. The menu window
displays any title and border associated with the window; the menu subwindow
displays the items of the menu that are currently available for selection.
-
+.PP
The first four functions get and set those windows. It is not necessary to set
either window; by default, the driver code uses \fBstdscr\fR for both.
-
+.PP
In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as though
it were \fBstsdcr\fR. A menu argument of \fBNULL\fR is treated as a request
to change the system default menu window or subwindow.
-
+.PP
The function \fBscale_menu\fR returns the minimum size required for the
subwindow of \fImenu\fR.
.SH RETURN VALUE
Routines that return pointers return \fBNULL\fR on error. Routines that return
an integer return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu has already been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the menu.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/mf_common.h b/lib/libmenu/mf_common.h
index b88aa91ac5b..c1a4e32dba4 100644
--- a/lib/libmenu/mf_common.h
+++ b/lib/libmenu/mf_common.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: mf_common.h,v 1.6 2000/10/08 22:47:07 millert Exp $ */
+/* $OpenBSD: mf_common.h,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,14 +29,18 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: mf_common.h,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
+
/* Common internal header for menu and form library */
-#if HAVE_CONFIG_H
-# include <ncurses_cfg.h>
-#endif
+#ifndef MF_COMMON_H_incl
+#define MF_COMMON_H_incl 1
+
+#include <ncurses_cfg.h>
+#include <curses.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -69,27 +73,25 @@ extern int errno;
#define MAX_REGULAR_CHARACTER (0xff)
#define SET_ERROR(code) (errno=(code))
-#define GET_ERROR() (errno)
-#define RETURN(code) return( SET_ERROR(code) )
+#define GET_ERROR() (errno)
+
+#ifdef TRACE
+#define RETURN(code) returnCode( SET_ERROR(code) )
+#else
+#define RETURN(code) return( SET_ERROR(code) )
+#endif
/* The few common values in the status fields for menus and forms */
-#define _POSTED (0x01) /* menu or form is posted */
-#define _IN_DRIVER (0x02) /* menu or form is processing hook routine */
+#define _POSTED (0x01U) /* menu or form is posted */
+#define _IN_DRIVER (0x02U) /* menu or form is processing hook routine */
/* Call object hook */
#define Call_Hook( object, handler ) \
- if ( (object) && ((object)->handler) )\
+ if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
{\
(object)->status |= _IN_DRIVER;\
(object)->handler(object);\
(object)->status &= ~_IN_DRIVER;\
}
-#define INLINE
-
-#ifndef TRACE
-# if CC_HAS_INLINE_FUNCS
-# undef INLINE
-# define INLINE inline
-# endif
-#endif
+#endif /* MF_COMMON_H_incl */
diff --git a/lib/libmenu/mitem_current.3 b/lib/libmenu/mitem_current.3
index 811c04a65d4..58e9b1d64a2 100644
--- a/lib/libmenu/mitem_current.3
+++ b/lib/libmenu/mitem_current.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_current.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_current.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_current.3x,v 1.9 1998/12/26 19:52:34 tom Exp $
+.\" $Id: mitem_current.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_current 3 ""
.SH NAME
\fBmitem_current\fR - set and get current_menu_item
@@ -50,37 +50,38 @@ int item_index(const ITEM *item);
The function \fBset_current_item\fR sets the current item (the item on which
the menu cursor is positioned). \fBcurrent_item\fR returns a pointer to the
current item in the given menu.
-
+.PP
The function \fBset_top_row\fR sets the top row of the menu to show the given
row (the top row is initially 0, and is reset to this value whenever the
\fBO_ROWMAJOR\fR option is toggled). The item leftmost on the given row
becomes current. The function \fBtop_row\fR returns the number of the top menu
row being displayed.
-
+.PP
The function \fBitem_index\fR returns the (zero-origin) index of \fIitem\fR in
the menu's item pointer list.
.SH RETURN VALUE
-\fBcurrent_item\fR returns \fBNULL\fR on error.
-
+\fBcurrent_item\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
\fBtop_row\fR and \fBitem_index\fR return \fBERR\fR (the general \fBcurses\fR
-error value) on error.
-
+error value) if their \fImenu\fP parameter is \fBNULL\fP.
+.PP
\fBset_current_item\fR and \fBset_top_row\fR return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the menu.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -89,7 +90,7 @@ The header file \fB<menu.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
-
+.PP
The SVr4 menu library documentation specifies the \fBtop_row\fR and
\fBindex_item\fR error value as -1 (which is the value of \fBERR\fR).
.SH AUTHORS
diff --git a/lib/libmenu/mitem_name.3 b/lib/libmenu/mitem_name.3
index 80af3095b49..11a5f442cf4 100644
--- a/lib/libmenu/mitem_name.3
+++ b/lib/libmenu/mitem_name.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_name.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_name.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_name.3x,v 1.5 1998/11/29 01:11:29 Rick.Ohnemus Exp $
+.\" $Id: mitem_name.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_name 3 ""
.SH NAME
\fBmitem_name\fR - get menu item name and description fields
@@ -46,15 +46,16 @@ The function \fBitem_name\fR returns the name part of the given item.
The function \fBitem_description\fR returns the description part of the given
item.
.SH RETURN VALUE
-These routines returns \fBNULL\fR on error.
+These routines return a pointer (which may be \fBNULL\fR).
+They do not set errno.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
The header file \fB<menu.h>\fR automatically includes the header file
\fB<curses.h>\fR.
.SH PORTABILITY
-These routines emulate the System V menu library. They were not supported on
-Version 7 or BSD versions.
+These routines emulate the System V menu library.
+They were not supported on Version 7 or BSD versions.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libmenu/mitem_new.3 b/lib/libmenu/mitem_new.3
index d722a995836..71f0a41e9ee 100644
--- a/lib/libmenu/mitem_new.3
+++ b/lib/libmenu/mitem_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_new.3,v 1.5 2003/10/22 08:07:09 jmc Exp $
+.\" $OpenBSD: mitem_new.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_new.3x,v 1.7 1998/11/29 01:11:38 Rick.Ohnemus Exp $
+.\" $Id: mitem_new.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH mitem_new 3 ""
.SH NAME
\fBmitem_new\fR - create and destroy menu items
@@ -52,20 +52,27 @@ is the responsibility of the application to release the memory for the
name or the description of the item.
.SH RETURN VALUE
The function \fBnew_item\fR returns \fBNULL\fR on error.
-
+It sets errno according to the function's failure:
+.TP 5
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
The function \fBfree_item\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_CONNECTED\fR
+.B E_CONNECTED
Item is connected to a menu.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/mitem_opts.3 b/lib/libmenu/mitem_opts.3
index 714937a0ea7..0dfc691d84d 100644
--- a/lib/libmenu/mitem_opts.3
+++ b/lib/libmenu/mitem_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_opts.3,v 1.5 1999/05/12 13:26:49 aaron Exp $
+.\" $OpenBSD: mitem_opts.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,43 +29,43 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_opts.3x,v 1.6 1998/11/29 01:12:37 Rick.Ohnemus Exp $
+.\" $Id: mitem_opts.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH mitem_opts 3 ""
.SH NAME
\fBmitem_opts\fR - set and get menu item options
.SH SYNOPSIS
\fB#include <menu.h>\fR
.br
-int set_item_opts(ITEM *item, OPTIONS opts);
+int set_item_opts(ITEM *item, Item_Options opts);
.br
-int item_opts_on(ITEM *item, OPTIONS opts);
+int item_opts_on(ITEM *item, Item_Options opts);
.br
-int item_opts_off(ITEM *item, OPTIONS opts);
+int item_opts_off(ITEM *item, Item_Options opts);
.br
-OPTIONS item_opts(const ITEM *item);
+Item_Options item_opts(const ITEM *item);
.br
.SH DESCRIPTION
The function \fBset_item_opts\fR sets all the given item's option bits (menu
option bits may be logically OR'ed together).
-
+.PP
The function \fBitem_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBitem_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBitem_opts\fR returns the item's current option bits.
-
+.PP
There is only one defined option bit mask, \fBO_SELECTABLE\fR. When this is
on, the item may be selected during menu processing. This option defaults
to on.
.SH RETURN VALUE
Except for \fBitem_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/mitem_userptr.3 b/lib/libmenu/mitem_userptr.3
index db4c0dd67b7..48db807db2b 100644
--- a/lib/libmenu/mitem_userptr.3
+++ b/lib/libmenu/mitem_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_userptr.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_userptr.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_userptr.3x,v 1.6 1998/11/29 01:12:47 Rick.Ohnemus Exp $
+.\" $Id: mitem_userptr.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_userptr 3 ""
.SH NAME
\fBmitem_userptr\fR - associate application data with a menu item
@@ -45,13 +45,11 @@ Every menu item has a field that can be used to hold application-specific data
(that is, the menu-driver code leaves it alone). These functions get and set
that field.
.SH RETURN VALUE
-Except for \fBitem_userptr\fR (which returns \fBNULL\fR on error), each function returns one of the following:
-.TP 5
-\fBE_OK\fR
-The routine succeeded.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+The function \fBitem_userptr\fR returns a pointer (possibly \fBNULL\fR).
+It does not set errno.
+.PP
+The \fBset_item_userptr\fP always returns \fBE_OK\fP (success).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -60,9 +58,9 @@ The header file \fB<menu.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
-
-The user pointer should be a void pointer. We leave it as a char pointer for
-SVr4 compatibility.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libmenu/mitem_value.3 b/lib/libmenu/mitem_value.3
index 2a55770c59d..bf5631551b3 100644
--- a/lib/libmenu/mitem_value.3
+++ b/lib/libmenu/mitem_value.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: mitem_value.3,v 1.2 1998/07/24 16:39:49 millert Exp $
+.\" $OpenBSD: mitem_value.3,v 1.3 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: mitem_value.3x,v 1.4 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: mitem_value.3,v 1.3 2010/01/12 23:22:08 nicm Exp $
.TH mitem_value 3 ""
.SH NAME
\fBmitem_value\fR - set and get menu item values
@@ -44,20 +44,20 @@ If you turn off the menu option \fBO_ONEVALUE\fR (e.g., with
\fBset_menu_opts\fR or \fBmenu_opts_off\fR; see \fBmenu_opts\fR(3)), the menu
becomes multi-valued; that is, more than one item may simultaneously be
selected.
-
+.PP
In a multi_valued menu, you can used \fBset_item_value\fR to select the
given menu item (second argument \fBTRUE\fR) or deselect it (second argument
\fBFALSE\fR).
.SH RETURN VALUE
The function \fBset_item_value\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The menu driver could not process the request.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/mitem_visible.3 b/lib/libmenu/mitem_visible.3
index 55531f4d726..a157019a9b9 100644
--- a/lib/libmenu/mitem_visible.3
+++ b/lib/libmenu/mitem_visible.3
@@ -1,5 +1,5 @@
'\" t
-.\" $OpenBSD: mitem_visible.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_visible.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
.\" Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_visible.3x,v 1.5 1998/11/29 01:12:55 Rick.Ohnemus Exp $
+.\" $Id: mitem_visible.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_visible 3 ""
.SH NAME
\fBmitem_visible\fR - check visibility of a menu item
diff --git a/lib/libmenu/shlib_version b/lib/libmenu/shlib_version
index 012c14171d3..d9961ea9fef 100644
--- a/lib/libmenu/shlib_version
+++ b/lib/libmenu/shlib_version
@@ -1,2 +1,2 @@
-major=3
+major=4
minor=0
diff --git a/lib/libpanel/Makefile b/lib/libpanel/Makefile
index d9d81a542e1..9e68ab42b9f 100644
--- a/lib/libpanel/Makefile
+++ b/lib/libpanel/Makefile
@@ -1,3 +1,5 @@
+# $OpenBSD: Makefile,v 1.8 2010/01/12 23:22:08 nicm Exp $
+
LIB= panel
WANTLINT=
SRCS= p_above.c p_below.c p_bottom.c p_delete.c p_hidden.c p_hide.c p_move.c \
@@ -10,7 +12,7 @@ MLINKS= panel.3 new_panel.3 panel.3 bottom_panel.3 panel.3 top_panel.3 \
panel.3 move_panel.3 panel.3 panel_hidden.3 panel.3 \
panel_above.3 panel.3 panel_below.3 panel.3 set_panel_userptr.3 \
panel.3 panel_userptr.3 panel.3 del_panel.3
-CFLAGS+= -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H
+CFLAGS+= -I${.CURDIR}/../libcurses
includes:
@cd ${.CURDIR}; for i in ${HDRS}; do \
diff --git a/lib/libpanel/p_above.c b/lib/libpanel/p_above.c
index 697422428d2..b979d464e39 100644
--- a/lib/libpanel/p_above.c
+++ b/lib/libpanel/p_above.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_above.c,v 1.4 2001/01/22 18:02:07 millert Exp $ */
+/* $OpenBSD: p_above.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,17 +37,18 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_above.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_above.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(PANEL *)
-panel_above (const PANEL *pan)
+panel_above(const PANEL * pan)
{
- if(!pan)
+ T((T_CALLED("panel_above(%p)"), pan));
+ if (!pan)
{
/* if top and bottom are equal, we have no or only the pseudo panel;
- if not, we return the panel above the pseudo panel */
- return(EMPTY_STACK() ? (PANEL*)0 : _nc_bottom_panel->above);
+ if not, we return the panel above the pseudo panel */
+ returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_bottom_panel->above);
}
else
- return(pan->above);
+ returnPanel(pan->above);
}
diff --git a/lib/libpanel/p_below.c b/lib/libpanel/p_below.c
index 122cad4f95c..c684bc9f5fb 100644
--- a/lib/libpanel/p_below.c
+++ b/lib/libpanel/p_below.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_below.c,v 1.4 2001/01/22 18:02:09 millert Exp $ */
+/* $OpenBSD: p_below.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -37,19 +37,20 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_below.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_below.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
-NCURSES_EXPORT(PANEL*)
-panel_below (const PANEL *pan)
+NCURSES_EXPORT(PANEL *)
+panel_below(const PANEL * pan)
{
- if(!pan)
+ T((T_CALLED("panel_below(%p)"), pan));
+ if (!pan)
{
/* if top and bottom are equal, we have no or only the pseudo panel */
- return(EMPTY_STACK() ? (PANEL*)0 : _nc_top_panel);
+ returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel);
}
else
{
/* we must not return the pseudo panel */
- return(Is_Pseudo(pan->below) ? (PANEL*) 0 : pan->below);
+ returnPanel(Is_Pseudo(pan->below) ? (PANEL *) 0 : pan->below);
}
}
diff --git a/lib/libpanel/p_bottom.c b/lib/libpanel/p_bottom.c
index 5d4a2b4da48..767de9865eb 100644
--- a/lib/libpanel/p_bottom.c
+++ b/lib/libpanel/p_bottom.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_bottom.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_bottom.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,35 +38,37 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_bottom.c,v 1.9 2001/02/24 23:46:33 tom Exp $")
+MODULE_ID("$Id: p_bottom.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-bottom_panel (PANEL *pan)
+bottom_panel(PANEL * pan)
{
int err = OK;
- if (pan) {
+ T((T_CALLED("bottom_panel(%p)"), pan));
+ if (pan)
+ {
+ if (!Is_Bottom(pan))
+ {
- if(!Is_Bottom(pan)) {
-
- dBug(("--> bottom_panel %s", USER_PTR(pan->user)));
-
- HIDE_PANEL(pan,err,OK);
- assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
-
- dStack("<lb%d>",1,pan);
-
- pan->below = _nc_bottom_panel;
- pan->above = _nc_bottom_panel->above;
- if (pan->above)
- pan->above->below = pan;
- _nc_bottom_panel->above = pan;
-
- dStack("<lb%d>",9,pan);
+ dBug(("--> bottom_panel %s", USER_PTR(pan->user)));
+
+ HIDE_PANEL(pan, err, OK);
+ assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
+
+ dStack("<lb%d>", 1, pan);
+
+ pan->below = _nc_bottom_panel;
+ pan->above = _nc_bottom_panel->above;
+ if (pan->above)
+ pan->above->below = pan;
+ _nc_bottom_panel->above = pan;
+
+ dStack("<lb%d>", 9, pan);
+ }
}
- }
else
err = ERR;
-
- return(err);
+
+ returnCode(err);
}
diff --git a/lib/libpanel/p_delete.c b/lib/libpanel/p_delete.c
index 66444579b94..cc234d70633 100644
--- a/lib/libpanel/p_delete.c
+++ b/lib/libpanel/p_delete.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_delete.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_delete.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,19 +38,22 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_delete.c,v 1.6 2001/02/24 23:46:41 tom Exp $")
+MODULE_ID("$Id: p_delete.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-del_panel (PANEL *pan)
+del_panel(PANEL * pan)
{
int err = OK;
- if(pan)
+
+ T((T_CALLED("del_panel(%p)"), pan));
+ if (pan)
{
dBug(("--> del_panel %s", USER_PTR(pan->user)));
- HIDE_PANEL(pan,err,OK);
+ HIDE_PANEL(pan, err, OK);
free((void *)pan);
}
else
err = ERR;
- return(err);
+
+ returnCode(err);
}
diff --git a/lib/libpanel/p_hidden.c b/lib/libpanel/p_hidden.c
index 11abe542b96..14db8e9f52f 100644
--- a/lib/libpanel/p_hidden.c
+++ b/lib/libpanel/p_hidden.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_hidden.c,v 1.4 2001/01/22 18:02:09 millert Exp $ */
+/* $OpenBSD: p_hidden.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,12 +38,13 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_hidden.c,v 1.5 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_hidden.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-panel_hidden (const PANEL *pan)
+panel_hidden(const PANEL * pan)
{
- if(!pan)
- return(ERR);
- return(IS_LINKED(pan) ? FALSE : TRUE);
-}
+ T((T_CALLED("panel_hidden(%p)"), pan));
+ if (!pan)
+ returnCode(ERR);
+ returnCode(IS_LINKED(pan) ? FALSE : TRUE);
+}
diff --git a/lib/libpanel/p_hide.c b/lib/libpanel/p_hide.c
index 18fde25f856..c6795095e7c 100644
--- a/lib/libpanel/p_hide.c
+++ b/lib/libpanel/p_hide.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_hide.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_hide.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,22 +38,23 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_hide.c,v 1.7 2001/02/24 23:46:45 tom Exp $")
+MODULE_ID("$Id: p_hide.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-hide_panel (register PANEL *pan)
+hide_panel(register PANEL * pan)
{
int err = OK;
- if(!pan)
- return(ERR);
+ T((T_CALLED("hide_panel(%p)"), pan));
+ if (!pan)
+ returnCode(ERR);
dBug(("--> hide_panel %s", USER_PTR(pan->user)));
- dStack("<u%d>",1,pan);
+ dStack("<u%d>", 1, pan);
- HIDE_PANEL(pan,err,ERR);
+ HIDE_PANEL(pan, err, ERR);
- dStack("<u%d>",9,pan);
+ dStack("<u%d>", 9, pan);
- return(err);
+ returnCode(err);
}
diff --git a/lib/libpanel/p_move.c b/lib/libpanel/p_move.c
index 1e7f49452c1..353bd310744 100644
--- a/lib/libpanel/p_move.c
+++ b/lib/libpanel/p_move.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_move.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_move.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,21 +38,21 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_move.c,v 1.7 2001/02/24 23:41:35 tom Exp $")
+MODULE_ID("$Id: p_move.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-move_panel (PANEL *pan, int starty, int startx)
+move_panel(PANEL * pan, int starty, int startx)
{
- if(!pan)
- return(ERR);
+ T((T_CALLED("move_panel(%p,%d,%d)"), pan, starty, startx));
- if (IS_LINKED(pan)) {
- Touchpan(pan);
- PANEL_UPDATE(pan,(PANEL*)0);
- }
+ if (!pan)
+ returnCode(ERR);
- if (mvwin(pan->win,starty,startx))
- return(ERR);
+ if (IS_LINKED(pan))
+ {
+ Touchpan(pan);
+ PANEL_UPDATE(pan, (PANEL *) 0);
+ }
- return(OK);
+ returnCode(mvwin(pan->win, starty, startx));
}
diff --git a/lib/libpanel/p_new.c b/lib/libpanel/p_new.c
index c9aefacf5c3..f1f5018e6bf 100644
--- a/lib/libpanel/p_new.c
+++ b/lib/libpanel/p_new.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_new.c,v 1.4 2001/01/22 18:02:09 millert Exp $ */
+/* $OpenBSD: p_new.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -31,6 +31,8 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Juergen Pfeifer 1997-1999 *
+ * and: Thomas E. Dickey 2000-on *
****************************************************************************/
/* p_new.c
@@ -38,61 +40,68 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_new.c,v 1.6 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_new.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
#ifdef TRACE
-static char* stdscr_id;
-static char* new_id;
+static char *stdscr_id;
+static char *new_id;
#endif
/*+-------------------------------------------------------------------------
Get root (i.e. stdscr's) panel.
Establish the pseudo panel for stdscr if necessary.
--------------------------------------------------------------------------*/
-static PANEL*
+static PANEL *
root_panel(void)
{
- if(_nc_stdscr_pseudo_panel == (PANEL*)0)
+ if (_nc_stdscr_pseudo_panel == (PANEL *) 0)
{
-
+
assert(stdscr && !_nc_bottom_panel && !_nc_top_panel);
- _nc_stdscr_pseudo_panel = (PANEL*)malloc(sizeof(PANEL));
- if (_nc_stdscr_pseudo_panel != 0) {
- PANEL* pan = _nc_stdscr_pseudo_panel;
- WINDOW* win = stdscr;
- pan->win = win;
- pan->below = (PANEL*)0;
- pan->above = (PANEL*)0;
+#if NO_LEAKS
+ _nc_panelhook()->destroy = del_panel;
+#endif
+ _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL));
+ if (_nc_stdscr_pseudo_panel != 0)
+ {
+ PANEL *pan = _nc_stdscr_pseudo_panel;
+ WINDOW *win = stdscr;
+
+ pan->win = win;
+ pan->below = (PANEL *) 0;
+ pan->above = (PANEL *) 0;
#ifdef TRACE
- if (!stdscr_id)
- stdscr_id = strdup("stdscr");
- pan->user = stdscr_id;
+ if (!stdscr_id)
+ stdscr_id = strdup("stdscr");
+ pan->user = stdscr_id;
#else
- pan->user = (void*)0;
+ pan->user = (void *)0;
#endif
- _nc_bottom_panel = _nc_top_panel = pan;
- }
+ _nc_bottom_panel = _nc_top_panel = pan;
+ }
}
return _nc_stdscr_pseudo_panel;
}
NCURSES_EXPORT(PANEL *)
-new_panel (WINDOW *win)
+new_panel(WINDOW *win)
{
- PANEL *pan = (PANEL*)0;
+ PANEL *pan = (PANEL *) 0;
+
+ T((T_CALLED("new_panel(%p)"), win));
if (!win)
- return(pan);
+ returnPanel(pan);
if (!_nc_stdscr_pseudo_panel)
(void)root_panel();
assert(_nc_stdscr_pseudo_panel);
- if (!(win->_flags & _ISPAD) && (pan = (PANEL*)malloc(sizeof(PANEL))))
+ if (!(win->_flags & _ISPAD) && (pan = (PANEL *) malloc(sizeof(PANEL))))
{
pan->win = win;
- pan->above = (PANEL *)0;
- pan->below = (PANEL *)0;
+ pan->above = (PANEL *) 0;
+ pan->below = (PANEL *) 0;
#ifdef TRACE
if (!new_id)
new_id = strdup("new");
@@ -102,5 +111,5 @@ new_panel (WINDOW *win)
#endif
(void)show_panel(pan);
}
- return(pan);
+ returnPanel(pan);
}
diff --git a/lib/libpanel/p_replace.c b/lib/libpanel/p_replace.c
index 09dd010b4c6..c0bb532cc1a 100644
--- a/lib/libpanel/p_replace.c
+++ b/lib/libpanel/p_replace.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_replace.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_replace.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,20 +38,23 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_replace.c,v 1.7 2001/02/24 23:41:38 tom Exp $")
+MODULE_ID("$Id: p_replace.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-replace_panel (PANEL *pan, WINDOW *win)
+replace_panel(PANEL * pan, WINDOW *win)
{
- if(!pan)
- return(ERR);
-
- if (IS_LINKED(pan)) {
- Touchpan(pan);
- PANEL_UPDATE(pan,(PANEL*)0);
- }
-
+ T((T_CALLED("replace_panel(%p,%p)"), pan, win));
+
+ if (!pan)
+ returnCode(ERR);
+
+ if (IS_LINKED(pan))
+ {
+ Touchpan(pan);
+ PANEL_UPDATE(pan, (PANEL *) 0);
+ }
+
pan->win = win;
- return(OK);
+ returnCode(OK);
}
diff --git a/lib/libpanel/p_show.c b/lib/libpanel/p_show.c
index b4a24b4ce65..d841b6cbddf 100644
--- a/lib/libpanel/p_show.c
+++ b/lib/libpanel/p_show.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_show.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_show.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,32 +38,34 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_show.c,v 1.9 2001/02/24 23:46:50 tom Exp $")
+MODULE_ID("$Id: p_show.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-show_panel (PANEL *pan)
-{
+show_panel(PANEL * pan)
+{
int err = OK;
- if(!pan)
- return(ERR);
+ T((T_CALLED("show_panel(%p)"), pan));
+
+ if (!pan)
+ returnCode(ERR);
if (Is_Top(pan))
- return(OK);
+ returnCode(OK);
dBug(("--> show_panel %s", USER_PTR(pan->user)));
- HIDE_PANEL(pan,err,OK);
+ HIDE_PANEL(pan, err, OK);
- dStack("<lt%d>",1,pan);
+ dStack("<lt%d>", 1, pan);
assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
_nc_top_panel->above = pan;
- pan->below = _nc_top_panel;
- pan->above = (PANEL *)0;
+ pan->below = _nc_top_panel;
+ pan->above = (PANEL *) 0;
_nc_top_panel = pan;
-
- dStack("<lt%d>",9,pan);
- return(OK);
+ dStack("<lt%d>", 9, pan);
+
+ returnCode(OK);
}
diff --git a/lib/libpanel/p_top.c b/lib/libpanel/p_top.c
index 8a2215e8fd6..f20a91b021b 100644
--- a/lib/libpanel/p_top.c
+++ b/lib/libpanel/p_top.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_top.c,v 1.3 2001/01/22 18:02:10 millert Exp $ */
+/* $OpenBSD: p_top.c,v 1.4 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,10 +38,11 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_top.c,v 1.3 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_top.c,v 1.4 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-top_panel (PANEL *pan)
+top_panel(PANEL * pan)
{
- return(show_panel(pan));
+ T((T_CALLED("top_panel(%p)"), pan));
+ returnCode(show_panel(pan));
}
diff --git a/lib/libpanel/p_update.c b/lib/libpanel/p_update.c
index 1913edbafa0..63b99459dcf 100644
--- a/lib/libpanel/p_update.c
+++ b/lib/libpanel/p_update.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_update.c,v 1.5 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: p_update.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,18 +38,19 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_update.c,v 1.7 2001/02/24 23:41:42 tom Exp $")
+MODULE_ID("$Id: p_update.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(void)
-update_panels (void)
+update_panels(void)
{
PANEL *pan;
+ T((T_CALLED("update_panels()")));
dBug(("--> update_panels"));
pan = _nc_bottom_panel;
- while(pan && pan->above)
+ while (pan && pan->above)
{
- PANEL_UPDATE(pan,pan->above);
+ PANEL_UPDATE(pan, pan->above);
pan = pan->above;
}
@@ -59,4 +60,6 @@ update_panels (void)
Wnoutrefresh(pan);
pan = pan->above;
}
+
+ returnVoid;
}
diff --git a/lib/libpanel/p_user.c b/lib/libpanel/p_user.c
index bb4e692c455..357a8252d6e 100644
--- a/lib/libpanel/p_user.c
+++ b/lib/libpanel/p_user.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_user.c,v 1.3 2001/01/22 18:02:10 millert Exp $ */
+/* $OpenBSD: p_user.c,v 1.4 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,21 +38,21 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_user.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_user.c,v 1.4 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(int)
-set_panel_userptr
-(PANEL *pan, NCURSES_CONST void *uptr)
+set_panel_userptr(PANEL * pan, NCURSES_CONST void *uptr)
{
- if(!pan)
- return(ERR);
+ T((T_CALLED("set_panel_userptr(%p,%p)"), pan, uptr));
+ if (!pan)
+ returnCode(ERR);
pan->user = uptr;
- return(OK);
+ returnCode(OK);
}
-NCURSES_EXPORT(NCURSES_CONST void*)
-panel_userptr (const PANEL *pan)
+NCURSES_EXPORT(NCURSES_CONST void *)
+panel_userptr(const PANEL * pan)
{
- return(pan ? pan->user : (NCURSES_CONST void *)0);
+ T((T_CALLED("panel_userptr(%p)"), pan));
+ returnCVoidPtr(pan ? pan->user : (NCURSES_CONST void *)0);
}
-
diff --git a/lib/libpanel/p_win.c b/lib/libpanel/p_win.c
index b986be31234..7559b4311b5 100644
--- a/lib/libpanel/p_win.c
+++ b/lib/libpanel/p_win.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: p_win.c,v 1.3 2001/01/22 18:02:10 millert Exp $ */
+/* $OpenBSD: p_win.c,v 1.4 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -38,14 +38,11 @@
*/
#include "panel.priv.h"
-MODULE_ID("$From: p_win.c,v 1.3 2000/12/10 02:20:43 tom Exp $")
+MODULE_ID("$Id: p_win.c,v 1.4 2010/01/12 23:22:08 nicm Exp $")
NCURSES_EXPORT(WINDOW *)
-panel_window (const PANEL *pan)
+panel_window(const PANEL * pan)
{
- return(pan ? pan->win : (WINDOW *)0);
+ T((T_CALLED("panel_window(%p)"), pan));
+ returnWin(pan ? pan->win : (WINDOW *)0);
}
-
-
-
-
diff --git a/lib/libpanel/panel.3 b/lib/libpanel/panel.3
index 1cf451e6e9c..a72fe1be016 100644
--- a/lib/libpanel/panel.3
+++ b/lib/libpanel/panel.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: panel.3,v 1.8 2003/05/24 18:30:32 jmc Exp $
+.\" $OpenBSD: panel.3,v 1.9 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,16 +28,16 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: panel.3x,v 1.10 2000/08/13 01:56:47 tom Exp $
+.\" $Id: panel.3,v 1.9 2010/01/12 23:22:08 nicm Exp $
.TH panel 3 ""
.ds n 5
-.ds d /usr/share/terminfo
+.ds d /usr/share/misc/terminfo
.SH NAME
panel - panel stack extension for curses
.SH SYNOPSIS
\fB#include <panel.h>\fR
.P
-\fBcc [flags] sourcefiles -lpanel -lcurses\fR
+\fBcc [flags] sourcefiles -lpanel -lncurses\fR
.P
\fBPANEL *new_panel(WINDOW *win)\fR
.br
@@ -86,13 +86,13 @@ Panel routines are a functional layer added to \fBcurses\fR(3), make only
high-level curses calls, and work anywhere terminfo curses does.
.SH FUNCTIONS
.TP
-\fBnew_panel(win)\fR
+.B new_panel(win)
allocates a \fBPANEL\fR structure, associates it with
\fBwin\fR, places the panel on the top of the stack (causes it
to be displayed above any other panel) and returns a
pointer to the new panel.
.TP
-\fBvoid update_panels()\fR
+.B update_panels()
refreshes the virtual screen to reflect the relations between the
panels in the stack, but does not call doupdate() to refresh the
physical screen. Use this function and not wrefresh or wnoutrefresh.
@@ -100,52 +100,57 @@ update_panels() may be called more than once before a call to
doupdate(), but doupdate() is the function responsible for updating
the physical screen.
.TP
-\fBdel_panel(pan)\fR
+.B del_panel(pan)
removes the given panel from the stack and deallocates the
\fBPANEL\fR structure (but not its associated window).
.TP
-\fBhide_panel(pan)\fR
+.B hide_panel(pan)
removes the given panel from the panel stack and thus hides it from
view. The \fBPANEL\fR structure is not lost, merely removed from the stack.
.TP
-\fBshow_panel(pan)\fR
+.B panel_hidden(pan)
+returns TRUE if the panel is in the panel stack,
+FALSE if it is not.
+If the panel is a null pointer, return ERR.
+.TP
+.B show_panel(pan)
makes a hidden panel visible by placing it on top of the panels in the
panel stack. See COMPATIBILITY below.
.TP
-\fBtop_panel(pan)\fR
+.B top_panel(pan)
puts the given visible panel on top of all panels in the stack. See
COMPATIBILITY below.
.TP
-\fBbottom_panel(pan)\fR
+.B bottom_panel(pan)
puts panel at the bottom of all panels.
.TP
-\fBmove_panel(pan,starty,startx)\fR
+.B move_panel(pan,starty,startx)
moves the given panel window so that its upper-left corner is at
\fBstarty\fR, \fBstartx\fR. It does not change the position of the
panel in the stack. Be sure to use this function, not \fBmvwin()\fR,
to move a panel window.
.TP
-\fBreplace_panel(pan,window)\fR
+.B replace_panel(pan,window)
replaces the current window of panel with \fBwindow\fR (useful, for
example if you want to resize a panel; if you're using \fBncurses\fR,
you can call \fBreplace_panel\fR on the output of \fBwresize\fR(3)).
It does not change the position of the panel in the stack.
.TP
-\fBpanel_above(pan)\fR
+.B panel_above(pan)
returns a pointer to the panel above pan. If the panel argument is
\fB(PANEL *)0\fR, it returns a pointer to the bottom panel in the stack.
.TP
-\fBpanel_below(pan)\fR
+.B panel_below(pan)
returns a pointer to the panel just below pan. If the panel argument
is \fB(PANEL *)0\fR, it returns a pointer to the top panel in the stack.
.TP
-\fBset_panel_userptr(pan,ptr)\fR
+.B set_panel_userptr(pan,ptr)
sets the panel's user pointer.
.TP
-\fBpanel_userptr(pan)\fR
+.B panel_userptr(pan)
returns the user pointer for a given panel.
.TP
-\fBpanel_window(pan)\fR
+.B panel_window(pan)
returns a pointer to the window of the given panel.
.SH DIAGNOSTICS
Each routine that returns a pointer returns \fBNULL\fR if an error
@@ -166,9 +171,9 @@ and \fBtop_panel()\fR is intended for making an already-visible panel
move to the top of the stack. You are cautioned to use the correct
function to ensure compatibility with native panel libraries.
.SH NOTE
-In your library list, libpanel.a should be before libcurses.a; that is,
-you want to say `-lpanel -lcurses', not the other way around (which would
-give you a link error using GNU \fBld\fR(1) and some other linkers).
+In your library list, libpanel.a should be before libncurses.a; that is,
+you want to say `-lpanel -lncurses', not the other way around (which would
+usually give a link-error).
.SH FILES
.P
panel.h
@@ -178,6 +183,9 @@ libpanel.a
the panels library itself
.SH SEE ALSO
\fBcurses\fR(3)
+.PP
+This describes \fBncurses\fR
+version 5.7.
.SH AUTHOR
Originally written by Warren Tucker <wht@n4hgf.mt-park.ga.us>,
primarily to assist in porting u386mon to systems without a native
diff --git a/lib/libpanel/panel.c b/lib/libpanel/panel.c
index 56e33aa1d07..f484d72c3bb 100644
--- a/lib/libpanel/panel.c
+++ b/lib/libpanel/panel.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: panel.c,v 1.9 2001/02/28 22:58:53 millert Exp $ */
+/* $OpenBSD: panel.c,v 1.10 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -36,37 +36,51 @@
/* panel.c -- implementation of panels library, some core routines */
#include "panel.priv.h"
-MODULE_ID("$From: panel.c,v 1.20 2001/02/24 23:17:26 tom Exp $")
+MODULE_ID("$Id: panel.c,v 1.10 2010/01/12 23:22:08 nicm Exp $")
+/*+-------------------------------------------------------------------------
+ _nc_retrace_panel (pan)
+--------------------------------------------------------------------------*/
+#ifdef TRACE
+NCURSES_EXPORT(PANEL *)
+_nc_retrace_panel(PANEL * pan)
+{
+ T((T_RETURN("%p"), pan));
+ return pan;
+}
+#endif
+
+/*+-------------------------------------------------------------------------
+ _nc_my_visbuf(ptr)
+--------------------------------------------------------------------------*/
#ifdef TRACE
#ifndef TRACE_TXT
NCURSES_EXPORT(const char *)
-_nc_my_visbuf (const void *ptr)
+_nc_my_visbuf(const void *ptr)
{
- char temp[32];
- if (ptr != 0)
- snprintf(temp, sizeof(temp), "ptr:%p", ptr);
- else
- strcpy(temp, "<null>");
- return _nc_visbuf(temp);
+ char temp[32];
+
+ if (ptr != 0)
+ sprintf(temp, "ptr:%p", ptr);
+ else
+ strcpy(temp, "<null>");
+ return _nc_visbuf(temp);
}
#endif
#endif
-
/*+-------------------------------------------------------------------------
dPanel(text,pan)
--------------------------------------------------------------------------*/
#ifdef TRACE
NCURSES_EXPORT(void)
-_nc_dPanel
-(const char *text, const PANEL *pan)
+_nc_dPanel(const char *text, const PANEL * pan)
{
- _tracef("%s id=%s b=%s a=%s y=%d x=%d",
- text, USER_PTR(pan->user),
- (pan->below) ? USER_PTR(pan->below->user) : "--",
- (pan->above) ? USER_PTR(pan->above->user) : "--",
- PSTARTY(pan), PSTARTX(pan));
+ _tracef("%s id=%s b=%s a=%s y=%d x=%d",
+ text, USER_PTR(pan->user),
+ (pan->below) ? USER_PTR(pan->below->user) : "--",
+ (pan->above) ? USER_PTR(pan->above->user) : "--",
+ PSTARTY(pan), PSTARTX(pan));
}
#endif
@@ -75,21 +89,20 @@ _nc_dPanel
--------------------------------------------------------------------------*/
#ifdef TRACE
NCURSES_EXPORT(void)
-_nc_dStack
-(const char *fmt, int num, const PANEL *pan)
+_nc_dStack(const char *fmt, int num, const PANEL * pan)
{
char s80[80];
- snprintf(s80,sizeof(s80),fmt,num,pan);
- _tracef("%s b=%s t=%s",s80,
- (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user) : "--",
- (_nc_top_panel) ? USER_PTR(_nc_top_panel->user) : "--");
- if(pan)
+ sprintf(s80, fmt, num, pan);
+ _tracef("%s b=%s t=%s", s80,
+ (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user) : "--",
+ (_nc_top_panel) ? USER_PTR(_nc_top_panel->user) : "--");
+ if (pan)
_tracef("pan id=%s", USER_PTR(pan->user));
pan = _nc_bottom_panel;
- while(pan)
+ while (pan)
{
- dPanel("stk",pan);
+ dPanel("stk", pan);
pan = pan->above;
}
}
@@ -100,9 +113,9 @@ _nc_dStack
--------------------------------------------------------------------------*/
#ifdef TRACE
NCURSES_EXPORT(void)
-_nc_Wnoutrefresh (const PANEL *pan)
+_nc_Wnoutrefresh(const PANEL * pan)
{
- dPanel("wnoutrefresh",pan);
+ dPanel("wnoutrefresh", pan);
wnoutrefresh(pan->win);
}
#endif
@@ -112,9 +125,9 @@ _nc_Wnoutrefresh (const PANEL *pan)
--------------------------------------------------------------------------*/
#ifdef TRACE
NCURSES_EXPORT(void)
-_nc_Touchpan (const PANEL *pan)
+_nc_Touchpan(const PANEL * pan)
{
- dPanel("Touchpan",pan);
+ dPanel("Touchpan", pan);
touchwin(pan->win);
}
#endif
@@ -124,19 +137,23 @@ _nc_Touchpan (const PANEL *pan)
--------------------------------------------------------------------------*/
#ifdef TRACE
NCURSES_EXPORT(void)
-_nc_Touchline
-(const PANEL *pan, int start, int count)
+_nc_Touchline(const PANEL * pan, int start, int count)
{
char s80[80];
- snprintf(s80,sizeof(s80),"Touchline s=%d c=%d",start,count);
- dPanel(s80,pan);
- touchline(pan->win,start,count);
+
+ sprintf(s80, "Touchline s=%d c=%d", start, count);
+ dPanel(s80, pan);
+ touchline(pan->win, start, count);
}
#endif
#ifndef TRACE
# ifndef __GNUC__
/* Some C compilers need something defined in a source file */
- void _nc_dummy_panel(void) { }
+extern void _nc_dummy_panel(void);
+void
+_nc_dummy_panel(void)
+{
+}
# endif
#endif
diff --git a/lib/libpanel/panel.h b/lib/libpanel/panel.h
index b0c1f4a9c33..cf427452560 100644
--- a/lib/libpanel/panel.h
+++ b/lib/libpanel/panel.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: panel.h,v 1.6 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,10 +31,12 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
+/* $Id: panel.h,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
+
/* panel.h -- interface file for panels library */
-#ifndef _PANEL_H
-#define _PANEL_H
+#ifndef NCURSES_PANEL_H_incl
+#define NCURSES_PANEL_H_incl 1
#include <curses.h>
@@ -72,6 +72,6 @@ extern NCURSES_EXPORT(int) panel_hidden (const PANEL *);
}
#endif
-#endif /* _PANEL_H */
+#endif /* NCURSES_PANEL_H_incl */
/* end of panel.h */
diff --git a/lib/libpanel/panel.priv.h b/lib/libpanel/panel.priv.h
index 05d6a72779a..2af40dce62a 100644
--- a/lib/libpanel/panel.priv.h
+++ b/lib/libpanel/panel.priv.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: panel.priv.h,v 1.8 2001/02/28 22:58:53 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -28,10 +26,10 @@
* authorization. *
****************************************************************************/
-/* $From: panel.priv.h,v 1.17 2001/02/24 23:47:05 tom Exp $ */
+/* $Id: panel.priv.h,v 1.9 2010/01/12 23:22:08 nicm Exp $ */
-#ifndef _PANEL_PRIV_H
-#define _PANEL_PRIV_H
+#ifndef NCURSES_PANEL_PRIV_H
+#define NCURSES_PANEL_PRIV_H 1
#if HAVE_CONFIG_H
# include <ncurses_cfg.h>
@@ -41,23 +39,10 @@
#include <string.h>
#include <assert.h>
-#if HAVE_LIBDMALLOC
-# include <dmalloc.h> /* Gray Watson's library */
-#endif
-
-#if HAVE_LIBDBMALLOC
-# include <dbmalloc.h> /* Conor Cahill's library */
-#endif
-
+#include "curses.priv.h"
#include "panel.h"
#include <nc_panel.h>
-#if ( CC_HAS_INLINE_FUNCS && !defined(TRACE) )
-# define INLINE inline
-#else
-# define INLINE
-#endif
-
#if USE_RCS_IDS
# define MODULE_ID(id) static const char Ident[] = id;
#else
@@ -73,6 +58,9 @@
# define USER_PTR(ptr) _nc_my_visbuf((const char *)ptr)
# endif
+# define returnPanel(code) TRACE_RETURN(code,panel)
+
+ extern NCURSES_EXPORT(PANEL *) _nc_retrace_panel (PANEL *);
extern NCURSES_EXPORT(void) _nc_dPanel (const char*, const PANEL*);
extern NCURSES_EXPORT(void) _nc_dStack (const char*, int, const PANEL*);
extern NCURSES_EXPORT(void) _nc_Wnoutrefresh (const PANEL*);
@@ -86,6 +74,7 @@
# define Touchpan(pan) _nc_Touchpan(pan)
# define Touchline(pan,start,count) _nc_Touchline(pan,start,count)
#else /* !TRACE */
+# define returnPanel(code) return code
# define dBug(x)
# define dPanel(text,pan)
# define dStack(fmt,num,pan)
@@ -99,19 +88,10 @@
#define _nc_bottom_panel _nc_panelhook()->bottom_panel
#define EMPTY_STACK() (_nc_top_panel==_nc_bottom_panel)
-#define Is_Bottom(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p)))
+#define Is_Bottom(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p)))
#define Is_Top(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_top_panel==(p)))
#define Is_Pseudo(p) ((p) && ((p)==_nc_bottom_panel))
-/* borrowed from curses.priv.h */
-#define CHANGED_RANGE(line,start,end) \
- if (line->firstchar == _NOCHANGE \
- || line->firstchar > (start)) \
- line->firstchar = start; \
- if (line->lastchar == _NOCHANGE \
- || line->lastchar < (end)) \
- line->lastchar = end
-
/*+-------------------------------------------------------------------------
IS_LINKED(pan) - check to see if panel is in the stack
--------------------------------------------------------------------------*/
@@ -148,9 +128,9 @@
/*+-------------------------------------------------------------------------
Walk through the panel stack starting at the given location and
check for intersections; overlapping panels are "touched", so they
- are incrementally overwriting cells that should be hidden.
+ are incrementally overwriting cells that should be hidden.
If the "touch" flag is set, the panel gets touched before it is
- updated.
+ updated.
---------------------------------------------------------------------------*/
#define PANEL_UPDATE(pan,panstart)\
{ PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\
@@ -200,4 +180,4 @@
err = err_if_unlinked;\
}
-#endif /* _PANEL_PRIV_H */
+#endif /* NCURSES_PANEL_PRIV_H */
diff --git a/lib/libpanel/shlib_version b/lib/libpanel/shlib_version
index 012c14171d3..d9961ea9fef 100644
--- a/lib/libpanel/shlib_version
+++ b/lib/libpanel/shlib_version
@@ -1,2 +1,2 @@
-major=3
+major=4
minor=0