From 3f639c2335ade11e248ca15775690e53971fd38d Mon Sep 17 00:00:00 2001 From: Mehmet Samet Duman Date: Sat, 28 Feb 2026 17:19:16 +0300 Subject: init: Standalone musl-libc-based Linux port of FreeBSD `csh` for Project Tick BSD/Linux Distribution. Signed-off-by: Mehmet Samet Duman --- .gitignore | 25 + GNUmakefile | 449 ++ LICENSES/BSD-2-Clause.txt | 9 + LICENSES/BSD-3-Clause.txt | 11 + LICENSES/MIT.txt | 18 + Makefile | 167 + Makefile.depend | 19 + README.md | 39 + config.h | 276 + config_p.h | 111 + csh.cshrc | 2 + csh.login | 11 + csh.logout | 2 + dot.cshrc | 45 + dot.login | 11 + iconv_stub.c | 80 + iconv_stub.h | 44 + ncurses/include/Caps | 1035 +++ ncurses/include/Caps-ncurses | 481 ++ ncurses/include/Caps.aix4 | 1129 ++++ ncurses/include/Caps.hpux11 | 1042 +++ ncurses/include/Caps.keys | 1119 ++++ ncurses/include/Caps.osf1r5 | 1034 +++ ncurses/include/Caps.uwin | 840 +++ ncurses/include/MKhashsize.sh | 46 + ncurses/include/MKkey_defs.sh | 200 + ncurses/include/MKncurses_def.sh | 84 + ncurses/include/MKparametrized.sh | 78 + ncurses/include/MKterm.h.awk.in | 419 ++ ncurses/include/Makefile.in | 181 + ncurses/include/capdefaults.c | 90 + ncurses/include/curses.events | 55 + ncurses/include/curses.h.in | 1550 +++++ ncurses/include/curses.tail | 241 + ncurses/include/curses.wide | 315 + ncurses/include/edit_cfg.sh | 72 + ncurses/include/hashed_db.h | 75 + ncurses/include/headers | 55 + ncurses/include/nc_access.h | 83 + ncurses/include/nc_alloc.h | 151 + ncurses/include/nc_panel.h | 83 + ncurses/include/nc_string.h | 93 + ncurses/include/nc_termios.h | 88 + ncurses/include/nc_tparm.h | 97 + ncurses/include/nc_win32.h.in | 215 + ncurses/include/ncurses_cfg.hin | 77 + ncurses/include/ncurses_defs | 295 + ncurses/include/ncurses_dll.h.in | 106 + ncurses/include/term_entry.h | 224 + ncurses/include/termcap.h.in | 76 + ncurses/include/tic.h | 384 ++ ncurses/include/unctrl.h.in | 71 + ncurses/ncurses/Makefile.in | 403 ++ ncurses/ncurses/README | 54 + ncurses/ncurses/README.IZ | 99 + ncurses/ncurses/SigAction.h | 113 + ncurses/ncurses/base/MKkeyname.awk | 181 + ncurses/ncurses/base/MKlib_gen.sh | 593 ++ ncurses/ncurses/base/MKunctrl.awk | 180 + ncurses/ncurses/base/README | 39 + ncurses/ncurses/base/define_key.c | 89 + ncurses/ncurses/base/key_defined.c | 91 + ncurses/ncurses/base/keybound.c | 67 + ncurses/ncurses/base/keyok.c | 106 + ncurses/ncurses/base/legacy_coding.c | 61 + ncurses/ncurses/base/lib_addch.c | 605 ++ ncurses/ncurses/base/lib_addstr.c | 262 + ncurses/ncurses/base/lib_beep.c | 94 + ncurses/ncurses/base/lib_bkgd.c | 276 + ncurses/ncurses/base/lib_box.c | 143 + ncurses/ncurses/base/lib_chgat.c | 84 + ncurses/ncurses/base/lib_clear.c | 60 + ncurses/ncurses/base/lib_clearok.c | 59 + ncurses/ncurses/base/lib_clrbot.c | 80 + ncurses/ncurses/base/lib_clreol.c | 95 + ncurses/ncurses/base/lib_color.c | 1171 ++++ ncurses/ncurses/base/lib_colorset.c | 68 + ncurses/ncurses/base/lib_delch.c | 73 + ncurses/ncurses/base/lib_delwin.c | 106 + ncurses/ncurses/base/lib_dft_fgbg.c | 107 + ncurses/ncurses/base/lib_driver.c | 107 + ncurses/ncurses/base/lib_echo.c | 87 + ncurses/ncurses/base/lib_endwin.c | 87 + ncurses/ncurses/base/lib_erase.c | 100 + ncurses/ncurses/base/lib_flash.c | 91 + ncurses/ncurses/base/lib_freeall.c | 204 + ncurses/ncurses/base/lib_getch.c | 782 +++ ncurses/ncurses/base/lib_getstr.c | 224 + ncurses/ncurses/base/lib_hline.c | 92 + ncurses/ncurses/base/lib_immedok.c | 58 + ncurses/ncurses/base/lib_inchstr.c | 72 + ncurses/ncurses/base/lib_initscr.c | 115 + ncurses/ncurses/base/lib_insch.c | 168 + ncurses/ncurses/base/lib_insdel.c | 67 + ncurses/ncurses/base/lib_insnstr.c | 99 + ncurses/ncurses/base/lib_instr.c | 125 + ncurses/ncurses/base/lib_isendwin.c | 65 + ncurses/ncurses/base/lib_leaveok.c | 59 + ncurses/ncurses/base/lib_mouse.c | 2112 ++++++ ncurses/ncurses/base/lib_move.c | 64 + ncurses/ncurses/base/lib_mvwin.c | 124 + ncurses/ncurses/base/lib_newterm.c | 379 ++ ncurses/ncurses/base/lib_newwin.c | 405 ++ ncurses/ncurses/base/lib_nl.c | 95 + ncurses/ncurses/base/lib_overlay.c | 226 + ncurses/ncurses/base/lib_pad.c | 352 + ncurses/ncurses/base/lib_printw.c | 170 + ncurses/ncurses/base/lib_redrawln.c | 91 + ncurses/ncurses/base/lib_refresh.c | 310 + ncurses/ncurses/base/lib_restart.c | 118 + ncurses/ncurses/base/lib_scanw.c | 129 + ncurses/ncurses/base/lib_screen.c | 1089 ++++ ncurses/ncurses/base/lib_scroll.c | 156 + ncurses/ncurses/base/lib_scrollok.c | 59 + ncurses/ncurses/base/lib_scrreg.c | 64 + ncurses/ncurses/base/lib_set_term.c | 877 +++ ncurses/ncurses/base/lib_slk.c | 257 + ncurses/ncurses/base/lib_slkatr_set.c | 84 + ncurses/ncurses/base/lib_slkatrof.c | 70 + ncurses/ncurses/base/lib_slkatron.c | 70 + ncurses/ncurses/base/lib_slkatrset.c | 65 + ncurses/ncurses/base/lib_slkattr.c | 68 + ncurses/ncurses/base/lib_slkclear.c | 78 + ncurses/ncurses/base/lib_slkcolor.c | 94 + ncurses/ncurses/base/lib_slkinit.c | 92 + ncurses/ncurses/base/lib_slklab.c | 65 + ncurses/ncurses/base/lib_slkrefr.c | 191 + ncurses/ncurses/base/lib_slkset.c | 160 + ncurses/ncurses/base/lib_slktouch.c | 65 + ncurses/ncurses/base/lib_touch.c | 101 + ncurses/ncurses/base/lib_ungetch.c | 97 + ncurses/ncurses/base/lib_vline.c | 92 + ncurses/ncurses/base/lib_wattroff.c | 68 + ncurses/ncurses/base/lib_wattron.c | 70 + ncurses/ncurses/base/lib_winch.c | 58 + ncurses/ncurses/base/lib_window.c | 257 + ncurses/ncurses/base/nc_panel.c | 57 + ncurses/ncurses/base/new_pair.c | 396 ++ ncurses/ncurses/base/resizeterm.c | 544 ++ ncurses/ncurses/base/safe_sprintf.c | 302 + ncurses/ncurses/base/sigaction.c | 103 + ncurses/ncurses/base/tries.c | 150 + ncurses/ncurses/base/use_window.c | 57 + ncurses/ncurses/base/version.c | 46 + ncurses/ncurses/base/vsscanf.c | 357 + ncurses/ncurses/base/wresize.c | 282 + ncurses/ncurses/build.priv.h | 111 + ncurses/ncurses/curses.priv.h | 2757 ++++++++ ncurses/ncurses/fifo_defs.h | 89 + ncurses/ncurses/llib-lncurses | 4515 +++++++++++++ ncurses/ncurses/llib-lncursest | 4636 +++++++++++++ ncurses/ncurses/llib-lncursestw | 5637 ++++++++++++++++ ncurses/ncurses/llib-lncursesw | 5516 ++++++++++++++++ ncurses/ncurses/llib-ltic | 206 + ncurses/ncurses/llib-ltict | 206 + ncurses/ncurses/llib-ltictw | 206 + ncurses/ncurses/llib-lticw | 206 + ncurses/ncurses/llib-ltinfo | 1616 +++++ ncurses/ncurses/llib-ltinfot | 1728 +++++ ncurses/ncurses/llib-ltinfotw | 1790 +++++ ncurses/ncurses/llib-ltinfow | 1678 +++++ ncurses/ncurses/modules | 268 + ncurses/ncurses/new_pair.h | 142 + ncurses/ncurses/report_ctype.c | 107 + ncurses/ncurses/report_hashing.c | 76 + ncurses/ncurses/report_offsets.c | 280 + ncurses/ncurses/term.priv.h | 367 ++ ncurses/ncurses/tinfo/MKcaptab.awk | 98 + ncurses/ncurses/tinfo/MKcaptab.sh | 239 + ncurses/ncurses/tinfo/MKcodes.awk | 179 + ncurses/ncurses/tinfo/MKfallback.sh | 169 + ncurses/ncurses/tinfo/MKkeys_list.sh | 74 + ncurses/ncurses/tinfo/MKnames.awk | 206 + ncurses/ncurses/tinfo/MKuserdefs.sh | 149 + ncurses/ncurses/tinfo/README | 40 + ncurses/ncurses/tinfo/access.c | 449 ++ ncurses/ncurses/tinfo/add_tries.c | 127 + ncurses/ncurses/tinfo/alloc_entry.c | 426 ++ ncurses/ncurses/tinfo/alloc_ttype.c | 721 ++ ncurses/ncurses/tinfo/captoinfo.c | 1061 +++ ncurses/ncurses/tinfo/comp_error.c | 176 + ncurses/ncurses/tinfo/comp_expand.c | 230 + ncurses/ncurses/tinfo/comp_hash.c | 154 + ncurses/ncurses/tinfo/comp_parse.c | 802 +++ ncurses/ncurses/tinfo/comp_scan.c | 1068 +++ ncurses/ncurses/tinfo/db_iterator.c | 463 ++ ncurses/ncurses/tinfo/doalloc.c | 65 + ncurses/ncurses/tinfo/entries.c | 197 + ncurses/ncurses/tinfo/free_ttype.c | 108 + ncurses/ncurses/tinfo/getenv_num.c | 79 + ncurses/ncurses/tinfo/hashed_db.c | 350 + ncurses/ncurses/tinfo/home_terminfo.c | 70 + ncurses/ncurses/tinfo/init_keytry.c | 117 + ncurses/ncurses/tinfo/lib_acs.c | 329 + ncurses/ncurses/tinfo/lib_baudrate.c | 321 + ncurses/ncurses/tinfo/lib_cur_term.c | 203 + ncurses/ncurses/tinfo/lib_data.c | 408 ++ ncurses/ncurses/tinfo/lib_has_cap.c | 98 + ncurses/ncurses/tinfo/lib_kernel.c | 204 + ncurses/ncurses/tinfo/lib_longname.c | 107 + ncurses/ncurses/tinfo/lib_napms.c | 100 + ncurses/ncurses/tinfo/lib_options.c | 381 ++ ncurses/ncurses/tinfo/lib_print.c | 117 + ncurses/ncurses/tinfo/lib_raw.c | 433 ++ ncurses/ncurses/tinfo/lib_setup.c | 1214 ++++ ncurses/ncurses/tinfo/lib_termcap.c | 450 ++ ncurses/ncurses/tinfo/lib_termname.c | 62 + ncurses/ncurses/tinfo/lib_tgoto.c | 225 + ncurses/ncurses/tinfo/lib_ti.c | 193 + ncurses/ncurses/tinfo/lib_tparm.c | 1411 ++++ ncurses/ncurses/tinfo/lib_tputs.c | 463 ++ ncurses/ncurses/tinfo/lib_ttyflags.c | 333 + ncurses/ncurses/tinfo/lib_win32con.c | 1271 ++++ ncurses/ncurses/tinfo/lib_win32util.c | 136 + ncurses/ncurses/tinfo/make_hash.c | 453 ++ ncurses/ncurses/tinfo/make_keys.c | 173 + ncurses/ncurses/tinfo/name_match.c | 129 + ncurses/ncurses/tinfo/obsolete.c | 338 + ncurses/ncurses/tinfo/parse_entry.c | 1169 ++++ ncurses/ncurses/tinfo/read_entry.c | 936 +++ ncurses/ncurses/tinfo/read_termcap.c | 1205 ++++ ncurses/ncurses/tinfo/strings.c | 147 + ncurses/ncurses/tinfo/tinfo_driver.c | 1570 +++++ ncurses/ncurses/tinfo/trim_sgr0.c | 407 ++ ncurses/ncurses/tinfo/use_screen.c | 66 + ncurses/ncurses/tinfo/write_entry.c | 984 +++ ncurses/ncurses/trace/README | 37 + ncurses/ncurses/trace/lib_trace.c | 462 ++ ncurses/ncurses/trace/lib_traceatr.c | 426 ++ ncurses/ncurses/trace/lib_tracebits.c | 302 + ncurses/ncurses/trace/lib_tracechr.c | 93 + ncurses/ncurses/trace/lib_tracedmp.c | 190 + ncurses/ncurses/trace/lib_tracemse.c | 161 + ncurses/ncurses/trace/trace_buf.c | 128 + ncurses/ncurses/trace/trace_tries.c | 85 + ncurses/ncurses/trace/trace_xnames.c | 82 + ncurses/ncurses/trace/varargs.c | 193 + ncurses/ncurses/trace/visbuf.c | 383 ++ ncurses/ncurses/tty/MKexpanded.sh | 144 + ncurses/ncurses/tty/hardscroll.c | 389 ++ ncurses/ncurses/tty/hashmap.c | 598 ++ ncurses/ncurses/tty/lib_mvcur.c | 1438 ++++ ncurses/ncurses/tty/lib_tstp.c | 431 ++ ncurses/ncurses/tty/lib_twait.c | 526 ++ ncurses/ncurses/tty/lib_vidattr.c | 436 ++ ncurses/ncurses/tty/tty_update.c | 2303 +++++++ ncurses/ncurses/wcwidth.h | 1003 +++ ncurses/ncurses/widechar/charable.c | 87 + ncurses/ncurses/widechar/lib_add_wch.c | 453 ++ ncurses/ncurses/widechar/lib_box_set.c | 117 + ncurses/ncurses/widechar/lib_cchar.c | 161 + ncurses/ncurses/widechar/lib_erasewchar.c | 99 + ncurses/ncurses/widechar/lib_get_wch.c | 124 + ncurses/ncurses/widechar/lib_get_wstr.c | 230 + ncurses/ncurses/widechar/lib_hline_set.c | 81 + ncurses/ncurses/widechar/lib_in_wch.c | 68 + ncurses/ncurses/widechar/lib_in_wchnstr.c | 80 + ncurses/ncurses/widechar/lib_ins_wch.c | 173 + ncurses/ncurses/widechar/lib_inwstr.c | 100 + ncurses/ncurses/widechar/lib_key_name.c | 70 + ncurses/ncurses/widechar/lib_pecho_wchar.c | 61 + ncurses/ncurses/widechar/lib_slk_wset.c | 81 + ncurses/ncurses/widechar/lib_unget_wch.c | 118 + ncurses/ncurses/widechar/lib_vid_attr.c | 372 ++ ncurses/ncurses/widechar/lib_vline_set.c | 81 + ncurses/ncurses/widechar/lib_wacs.c | 151 + ncurses/ncurses/widechar/lib_wunctrl.c | 75 + ncurses/ncurses/widechar/widechars.c | 156 + ncurses/ncurses/win32con/gettimeofday.c | 55 + ncurses/ncurses/win32con/wcwidth.c | 55 + ncurses/ncurses/win32con/win32_driver.c | 1217 ++++ ncurses/ncurses_cfg.h | 270 + ncurses/pathnames.h | 36 + tcsh/FAQ | 243 + tcsh/FREEBSD-Xlist | 23 + tcsh/FREEBSD-upgrade | 11 + tcsh/Fixes | 2198 +++++++ tcsh/NewThings | 169 + tcsh/Ported | 1073 +++ tcsh/README.md | 29 + tcsh/WishList | 309 + tcsh/Y2K | 10 + tcsh/complete.tcsh | 1280 ++++ tcsh/config/bsd4.4 | 104 + tcsh/config_f.h | 205 + tcsh/csh-mode.el | 935 +++ tcsh/dot.login | 12 + tcsh/dot.tcshrc | 110 + tcsh/dotlock.c | 182 + tcsh/dotlock.h | 38 + tcsh/ed.chared.c | 3896 +++++++++++ tcsh/ed.decls.h | 285 + tcsh/ed.defns.c | 1974 ++++++ tcsh/ed.h | 261 + tcsh/ed.init.c | 707 ++ tcsh/ed.inputl.c | 958 +++ tcsh/ed.refresh.c | 1359 ++++ tcsh/ed.screen.c | 1652 +++++ tcsh/ed.term.c | 1141 ++++ tcsh/ed.term.h | 532 ++ tcsh/ed.xmap.c | 761 +++ tcsh/eight-bit.me | 142 + tcsh/gethost.c | 407 ++ tcsh/glob.3 | 485 ++ tcsh/glob.c | 804 +++ tcsh/glob.h | 96 + tcsh/host.defs | 1284 ++++ tcsh/ma.setp.c | 596 ++ tcsh/mi.termios.c | 391 ++ tcsh/mi.varargs.h | 14 + tcsh/mi.wait.h | 44 + tcsh/nls/C/charset | 3 + tcsh/nls/C/set1 | 139 + tcsh/nls/C/set10 | 7 + tcsh/nls/C/set11 | 30 + tcsh/nls/C/set12 | 3 + tcsh/nls/C/set13 | 12 + tcsh/nls/C/set14 | 5 + tcsh/nls/C/set15 | 6 + tcsh/nls/C/set16 | 12 + tcsh/nls/C/set17 | 16 + tcsh/nls/C/set18 | 3 + tcsh/nls/C/set19 | 22 + tcsh/nls/C/set2 | 110 + tcsh/nls/C/set20 | 40 + tcsh/nls/C/set21 | 4 + tcsh/nls/C/set22 | 16 + tcsh/nls/C/set23 | 33 + tcsh/nls/C/set24 | 3 + tcsh/nls/C/set25 | 5 + tcsh/nls/C/set26 | 14 + tcsh/nls/C/set27 | 7 + tcsh/nls/C/set29 | 3 + tcsh/nls/C/set3 | 125 + tcsh/nls/C/set30 | 15 + tcsh/nls/C/set31 | 6 + tcsh/nls/C/set4 | 44 + tcsh/nls/C/set5 | 3 + tcsh/nls/C/set6 | 10 + tcsh/nls/C/set7 | 29 + tcsh/nls/C/set8 | 4 + tcsh/nls/C/set9 | 11 + tcsh/nls/Makefile.in | 119 + tcsh/nls/catgen | 20 + tcsh/nls/et/charset | 3 + tcsh/nls/et/set1 | 139 + tcsh/nls/et/set10 | 7 + tcsh/nls/et/set11 | 9 + tcsh/nls/et/set12 | 3 + tcsh/nls/et/set13 | 12 + tcsh/nls/et/set14 | 5 + tcsh/nls/et/set15 | 6 + tcsh/nls/et/set16 | 12 + tcsh/nls/et/set17 | 16 + tcsh/nls/et/set18 | 3 + tcsh/nls/et/set19 | 22 + tcsh/nls/et/set2 | 110 + tcsh/nls/et/set20 | 40 + tcsh/nls/et/set21 | 4 + tcsh/nls/et/set22 | 16 + tcsh/nls/et/set23 | 33 + tcsh/nls/et/set24 | 3 + tcsh/nls/et/set25 | 5 + tcsh/nls/et/set26 | 14 + tcsh/nls/et/set27 | 7 + tcsh/nls/et/set29 | 3 + tcsh/nls/et/set3 | 123 + tcsh/nls/et/set30 | 15 + tcsh/nls/et/set31 | 6 + tcsh/nls/et/set4 | 44 + tcsh/nls/et/set5 | 3 + tcsh/nls/et/set6 | 10 + tcsh/nls/et/set7 | 29 + tcsh/nls/et/set8 | 4 + tcsh/nls/et/set9 | 11 + tcsh/nls/finnish/charset | 3 + tcsh/nls/finnish/set1 | 139 + tcsh/nls/finnish/set10 | 7 + tcsh/nls/finnish/set11 | 9 + tcsh/nls/finnish/set12 | 3 + tcsh/nls/finnish/set13 | 12 + tcsh/nls/finnish/set14 | 5 + tcsh/nls/finnish/set15 | 6 + tcsh/nls/finnish/set16 | 12 + tcsh/nls/finnish/set17 | 16 + tcsh/nls/finnish/set18 | 3 + tcsh/nls/finnish/set19 | 22 + tcsh/nls/finnish/set2 | 93 + tcsh/nls/finnish/set20 | 40 + tcsh/nls/finnish/set21 | 4 + tcsh/nls/finnish/set22 | 16 + tcsh/nls/finnish/set23 | 33 + tcsh/nls/finnish/set24 | 3 + tcsh/nls/finnish/set25 | 5 + tcsh/nls/finnish/set26 | 14 + tcsh/nls/finnish/set27 | 7 + tcsh/nls/finnish/set29 | 3 + tcsh/nls/finnish/set3 | 123 + tcsh/nls/finnish/set30 | 15 + tcsh/nls/finnish/set31 | 6 + tcsh/nls/finnish/set4 | 44 + tcsh/nls/finnish/set5 | 3 + tcsh/nls/finnish/set6 | 10 + tcsh/nls/finnish/set7 | 29 + tcsh/nls/finnish/set8 | 4 + tcsh/nls/finnish/set9 | 11 + tcsh/nls/french/charset | 3 + tcsh/nls/french/set1 | 139 + tcsh/nls/french/set10 | 7 + tcsh/nls/french/set11 | 9 + tcsh/nls/french/set12 | 3 + tcsh/nls/french/set13 | 12 + tcsh/nls/french/set14 | 5 + tcsh/nls/french/set15 | 6 + tcsh/nls/french/set16 | 12 + tcsh/nls/french/set17 | 16 + tcsh/nls/french/set18 | 3 + tcsh/nls/french/set19 | 22 + tcsh/nls/french/set2 | 93 + tcsh/nls/french/set20 | 40 + tcsh/nls/french/set21 | 4 + tcsh/nls/french/set22 | 16 + tcsh/nls/french/set23 | 33 + tcsh/nls/french/set24 | 3 + tcsh/nls/french/set25 | 5 + tcsh/nls/french/set26 | 14 + tcsh/nls/french/set27 | 7 + tcsh/nls/french/set29 | 3 + tcsh/nls/french/set3 | 123 + tcsh/nls/french/set30 | 15 + tcsh/nls/french/set31 | 6 + tcsh/nls/french/set4 | 44 + tcsh/nls/french/set5 | 3 + tcsh/nls/french/set6 | 10 + tcsh/nls/french/set7 | 29 + tcsh/nls/french/set8 | 4 + tcsh/nls/french/set9 | 11 + tcsh/nls/german/charset | 3 + tcsh/nls/german/set1 | 139 + tcsh/nls/german/set10 | 7 + tcsh/nls/german/set11 | 9 + tcsh/nls/german/set12 | 3 + tcsh/nls/german/set13 | 12 + tcsh/nls/german/set14 | 5 + tcsh/nls/german/set15 | 6 + tcsh/nls/german/set16 | 12 + tcsh/nls/german/set17 | 16 + tcsh/nls/german/set18 | 3 + tcsh/nls/german/set19 | 22 + tcsh/nls/german/set2 | 93 + tcsh/nls/german/set20 | 40 + tcsh/nls/german/set21 | 4 + tcsh/nls/german/set22 | 16 + tcsh/nls/german/set23 | 33 + tcsh/nls/german/set24 | 3 + tcsh/nls/german/set25 | 5 + tcsh/nls/german/set26 | 14 + tcsh/nls/german/set27 | 7 + tcsh/nls/german/set29 | 3 + tcsh/nls/german/set3 | 123 + tcsh/nls/german/set30 | 15 + tcsh/nls/german/set31 | 6 + tcsh/nls/german/set4 | 44 + tcsh/nls/german/set5 | 3 + tcsh/nls/german/set6 | 10 + tcsh/nls/german/set7 | 29 + tcsh/nls/german/set8 | 4 + tcsh/nls/german/set9 | 11 + tcsh/nls/greek/charset | 3 + tcsh/nls/greek/set1 | 139 + tcsh/nls/greek/set10 | 7 + tcsh/nls/greek/set11 | 9 + tcsh/nls/greek/set12 | 3 + tcsh/nls/greek/set13 | 12 + tcsh/nls/greek/set14 | 5 + tcsh/nls/greek/set15 | 6 + tcsh/nls/greek/set16 | 12 + tcsh/nls/greek/set17 | 16 + tcsh/nls/greek/set18 | 3 + tcsh/nls/greek/set19 | 22 + tcsh/nls/greek/set2 | 93 + tcsh/nls/greek/set20 | 40 + tcsh/nls/greek/set21 | 4 + tcsh/nls/greek/set22 | 17 + tcsh/nls/greek/set23 | 30 + tcsh/nls/greek/set24 | 3 + tcsh/nls/greek/set25 | 5 + tcsh/nls/greek/set26 | 14 + tcsh/nls/greek/set27 | 7 + tcsh/nls/greek/set29 | 3 + tcsh/nls/greek/set3 | 123 + tcsh/nls/greek/set30 | 15 + tcsh/nls/greek/set31 | 6 + tcsh/nls/greek/set4 | 44 + tcsh/nls/greek/set5 | 3 + tcsh/nls/greek/set6 | 10 + tcsh/nls/greek/set7 | 29 + tcsh/nls/greek/set8 | 4 + tcsh/nls/greek/set9 | 11 + tcsh/nls/italian/charset | 3 + tcsh/nls/italian/set1 | 139 + tcsh/nls/italian/set10 | 7 + tcsh/nls/italian/set11 | 9 + tcsh/nls/italian/set12 | 3 + tcsh/nls/italian/set13 | 12 + tcsh/nls/italian/set14 | 5 + tcsh/nls/italian/set15 | 6 + tcsh/nls/italian/set16 | 12 + tcsh/nls/italian/set17 | 16 + tcsh/nls/italian/set18 | 3 + tcsh/nls/italian/set19 | 22 + tcsh/nls/italian/set2 | 93 + tcsh/nls/italian/set20 | 40 + tcsh/nls/italian/set21 | 4 + tcsh/nls/italian/set22 | 16 + tcsh/nls/italian/set23 | 33 + tcsh/nls/italian/set24 | 3 + tcsh/nls/italian/set25 | 5 + tcsh/nls/italian/set26 | 14 + tcsh/nls/italian/set27 | 7 + tcsh/nls/italian/set29 | 3 + tcsh/nls/italian/set3 | 123 + tcsh/nls/italian/set30 | 15 + tcsh/nls/italian/set31 | 6 + tcsh/nls/italian/set4 | 44 + tcsh/nls/italian/set5 | 3 + tcsh/nls/italian/set6 | 10 + tcsh/nls/italian/set7 | 29 + tcsh/nls/italian/set8 | 4 + tcsh/nls/italian/set9 | 11 + tcsh/nls/ja/charset | 3 + tcsh/nls/ja/set1 | 139 + tcsh/nls/ja/set10 | 7 + tcsh/nls/ja/set11 | 9 + tcsh/nls/ja/set12 | 3 + tcsh/nls/ja/set13 | 11 + tcsh/nls/ja/set15 | 6 + tcsh/nls/ja/set16 | 12 + tcsh/nls/ja/set17 | 15 + tcsh/nls/ja/set18 | 3 + tcsh/nls/ja/set2 | 93 + tcsh/nls/ja/set21 | 4 + tcsh/nls/ja/set24 | 3 + tcsh/nls/ja/set29 | 3 + tcsh/nls/ja/set3 | 123 + tcsh/nls/ja/set30 | 15 + tcsh/nls/ja/set4 | 44 + tcsh/nls/ja/set5 | 3 + tcsh/nls/ja/set6 | 10 + tcsh/nls/ja/set7 | 29 + tcsh/nls/ja/set8 | 4 + tcsh/nls/russian/charset | 3 + tcsh/nls/russian/set1 | 139 + tcsh/nls/russian/set10 | 7 + tcsh/nls/russian/set11 | 9 + tcsh/nls/russian/set12 | 3 + tcsh/nls/russian/set13 | 12 + tcsh/nls/russian/set14 | 5 + tcsh/nls/russian/set15 | 6 + tcsh/nls/russian/set16 | 12 + tcsh/nls/russian/set17 | 16 + tcsh/nls/russian/set18 | 3 + tcsh/nls/russian/set19 | 22 + tcsh/nls/russian/set2 | 110 + tcsh/nls/russian/set20 | 40 + tcsh/nls/russian/set21 | 4 + tcsh/nls/russian/set22 | 16 + tcsh/nls/russian/set23 | 33 + tcsh/nls/russian/set24 | 3 + tcsh/nls/russian/set25 | 5 + tcsh/nls/russian/set26 | 14 + tcsh/nls/russian/set27 | 7 + tcsh/nls/russian/set29 | 3 + tcsh/nls/russian/set3 | 116 + tcsh/nls/russian/set30 | 15 + tcsh/nls/russian/set31 | 6 + tcsh/nls/russian/set4 | 44 + tcsh/nls/russian/set5 | 3 + tcsh/nls/russian/set6 | 10 + tcsh/nls/russian/set7 | 29 + tcsh/nls/russian/set8 | 4 + tcsh/nls/russian/set9 | 11 + tcsh/nls/spanish/charset | 3 + tcsh/nls/spanish/set1 | 139 + tcsh/nls/spanish/set10 | 7 + tcsh/nls/spanish/set11 | 9 + tcsh/nls/spanish/set12 | 3 + tcsh/nls/spanish/set13 | 12 + tcsh/nls/spanish/set14 | 5 + tcsh/nls/spanish/set15 | 6 + tcsh/nls/spanish/set16 | 12 + tcsh/nls/spanish/set17 | 16 + tcsh/nls/spanish/set18 | 3 + tcsh/nls/spanish/set19 | 22 + tcsh/nls/spanish/set2 | 91 + tcsh/nls/spanish/set20 | 40 + tcsh/nls/spanish/set21 | 4 + tcsh/nls/spanish/set22 | 16 + tcsh/nls/spanish/set23 | 33 + tcsh/nls/spanish/set24 | 3 + tcsh/nls/spanish/set25 | 5 + tcsh/nls/spanish/set26 | 14 + tcsh/nls/spanish/set27 | 7 + tcsh/nls/spanish/set29 | 3 + tcsh/nls/spanish/set3 | 123 + tcsh/nls/spanish/set30 | 15 + tcsh/nls/spanish/set31 | 6 + tcsh/nls/spanish/set4 | 44 + tcsh/nls/spanish/set5 | 3 + tcsh/nls/spanish/set6 | 10 + tcsh/nls/spanish/set7 | 29 + tcsh/nls/spanish/set8 | 4 + tcsh/nls/spanish/set9 | 11 + tcsh/nls/ukrainian/charset | 3 + tcsh/nls/ukrainian/set1 | 139 + tcsh/nls/ukrainian/set10 | 7 + tcsh/nls/ukrainian/set11 | 9 + tcsh/nls/ukrainian/set12 | 3 + tcsh/nls/ukrainian/set13 | 12 + tcsh/nls/ukrainian/set14 | 5 + tcsh/nls/ukrainian/set15 | 6 + tcsh/nls/ukrainian/set16 | 12 + tcsh/nls/ukrainian/set17 | 16 + tcsh/nls/ukrainian/set18 | 3 + tcsh/nls/ukrainian/set19 | 22 + tcsh/nls/ukrainian/set2 | 110 + tcsh/nls/ukrainian/set20 | 40 + tcsh/nls/ukrainian/set21 | 4 + tcsh/nls/ukrainian/set22 | 16 + tcsh/nls/ukrainian/set23 | 33 + tcsh/nls/ukrainian/set24 | 3 + tcsh/nls/ukrainian/set25 | 5 + tcsh/nls/ukrainian/set26 | 14 + tcsh/nls/ukrainian/set27 | 7 + tcsh/nls/ukrainian/set29 | 3 + tcsh/nls/ukrainian/set3 | 123 + tcsh/nls/ukrainian/set30 | 15 + tcsh/nls/ukrainian/set31 | 6 + tcsh/nls/ukrainian/set4 | 44 + tcsh/nls/ukrainian/set5 | 3 + tcsh/nls/ukrainian/set6 | 10 + tcsh/nls/ukrainian/set7 | 29 + tcsh/nls/ukrainian/set8 | 4 + tcsh/nls/ukrainian/set9 | 11 + tcsh/patchlevel.h | 13 + tcsh/pathnames.h | 171 + tcsh/sh.c | 2565 ++++++++ tcsh/sh.char.c | 1170 ++++ tcsh/sh.char.h | 315 + tcsh/sh.decls.h | 450 ++ tcsh/sh.dir.c | 1426 ++++ tcsh/sh.dir.h | 59 + tcsh/sh.dol.c | 1151 ++++ tcsh/sh.err.c | 659 ++ tcsh/sh.exec.c | 1203 ++++ tcsh/sh.exp.c | 1056 +++ tcsh/sh.file.c | 769 +++ tcsh/sh.func.c | 2749 ++++++++ tcsh/sh.glob.c | 1025 +++ tcsh/sh.h | 1302 ++++ tcsh/sh.hist.c | 1388 ++++ tcsh/sh.init.c | 1072 +++ tcsh/sh.lex.c | 1865 ++++++ tcsh/sh.misc.c | 726 +++ tcsh/sh.parse.c | 694 ++ tcsh/sh.print.c | 314 + tcsh/sh.proc.c | 2063 ++++++ tcsh/sh.proc.h | 131 + tcsh/sh.sem.c | 998 +++ tcsh/sh.set.c | 1355 ++++ tcsh/sh.time.c | 744 +++ tcsh/sh.types.h | 399 ++ tcsh/snames.h | 88 + tcsh/src.desc | 72 + tcsh/tc.alloc.c | 670 ++ tcsh/tc.bind.c | 541 ++ tcsh/tc.const.c | 525 ++ tcsh/tc.decls.h | 347 + tcsh/tc.disc.c | 199 + tcsh/tc.func.c | 2128 ++++++ tcsh/tc.h | 82 + tcsh/tc.nls.c | 162 + tcsh/tc.nls.h | 61 + tcsh/tc.os.c | 1602 +++++ tcsh/tc.os.h | 622 ++ tcsh/tc.printf.c | 480 ++ tcsh/tc.prompt.c | 671 ++ tcsh/tc.sched.c | 257 + tcsh/tc.sig.c | 149 + tcsh/tc.sig.h | 175 + tcsh/tc.str.c | 713 ++ tcsh/tc.vers.c | 174 + tcsh/tc.wait.h | 157 + tcsh/tc.who.c | 652 ++ tcsh/tcsh.man | 5537 ++++++++++++++++ tcsh/tcsh.man.new | 9748 ++++++++++++++++++++++++++++ tcsh/tcsh.man2html | 849 +++ tcsh/termcap.vms | 50 + tcsh/tw.color.c | 493 ++ tcsh/tw.comp.c | 646 ++ tcsh/tw.decls.h | 133 + tcsh/tw.h | 112 + tcsh/tw.help.c | 208 + tcsh/tw.init.c | 1029 +++ tcsh/tw.parse.c | 2378 +++++++ tcsh/tw.spell.c | 161 + tcsh/vms.termcap.c | 353 + tests/test.sh | 99 + 708 files changed, 195684 insertions(+) create mode 100644 .gitignore create mode 100644 GNUmakefile create mode 100644 LICENSES/BSD-2-Clause.txt create mode 100644 LICENSES/BSD-3-Clause.txt create mode 100644 LICENSES/MIT.txt create mode 100644 Makefile create mode 100644 Makefile.depend create mode 100644 README.md create mode 100644 config.h create mode 100644 config_p.h create mode 100644 csh.cshrc create mode 100644 csh.login create mode 100644 csh.logout create mode 100644 dot.cshrc create mode 100644 dot.login create mode 100644 iconv_stub.c create mode 100644 iconv_stub.h create mode 100644 ncurses/include/Caps create mode 100644 ncurses/include/Caps-ncurses create mode 100644 ncurses/include/Caps.aix4 create mode 100644 ncurses/include/Caps.hpux11 create mode 100644 ncurses/include/Caps.keys create mode 100644 ncurses/include/Caps.osf1r5 create mode 100644 ncurses/include/Caps.uwin create mode 100755 ncurses/include/MKhashsize.sh create mode 100755 ncurses/include/MKkey_defs.sh create mode 100755 ncurses/include/MKncurses_def.sh create mode 100755 ncurses/include/MKparametrized.sh create mode 100644 ncurses/include/MKterm.h.awk.in create mode 100644 ncurses/include/Makefile.in create mode 100644 ncurses/include/capdefaults.c create mode 100644 ncurses/include/curses.events create mode 100644 ncurses/include/curses.h.in create mode 100644 ncurses/include/curses.tail create mode 100644 ncurses/include/curses.wide create mode 100755 ncurses/include/edit_cfg.sh create mode 100644 ncurses/include/hashed_db.h create mode 100644 ncurses/include/headers create mode 100644 ncurses/include/nc_access.h create mode 100644 ncurses/include/nc_alloc.h create mode 100644 ncurses/include/nc_panel.h create mode 100644 ncurses/include/nc_string.h create mode 100644 ncurses/include/nc_termios.h create mode 100644 ncurses/include/nc_tparm.h create mode 100644 ncurses/include/nc_win32.h.in create mode 100644 ncurses/include/ncurses_cfg.hin create mode 100644 ncurses/include/ncurses_defs create mode 100644 ncurses/include/ncurses_dll.h.in create mode 100644 ncurses/include/term_entry.h create mode 100644 ncurses/include/termcap.h.in create mode 100644 ncurses/include/tic.h create mode 100644 ncurses/include/unctrl.h.in create mode 100644 ncurses/ncurses/Makefile.in create mode 100644 ncurses/ncurses/README create mode 100644 ncurses/ncurses/README.IZ create mode 100644 ncurses/ncurses/SigAction.h create mode 100644 ncurses/ncurses/base/MKkeyname.awk create mode 100755 ncurses/ncurses/base/MKlib_gen.sh create mode 100644 ncurses/ncurses/base/MKunctrl.awk create mode 100644 ncurses/ncurses/base/README create mode 100644 ncurses/ncurses/base/define_key.c create mode 100644 ncurses/ncurses/base/key_defined.c create mode 100644 ncurses/ncurses/base/keybound.c create mode 100644 ncurses/ncurses/base/keyok.c create mode 100644 ncurses/ncurses/base/legacy_coding.c create mode 100644 ncurses/ncurses/base/lib_addch.c create mode 100644 ncurses/ncurses/base/lib_addstr.c create mode 100644 ncurses/ncurses/base/lib_beep.c create mode 100644 ncurses/ncurses/base/lib_bkgd.c create mode 100644 ncurses/ncurses/base/lib_box.c create mode 100644 ncurses/ncurses/base/lib_chgat.c create mode 100644 ncurses/ncurses/base/lib_clear.c create mode 100644 ncurses/ncurses/base/lib_clearok.c create mode 100644 ncurses/ncurses/base/lib_clrbot.c create mode 100644 ncurses/ncurses/base/lib_clreol.c create mode 100644 ncurses/ncurses/base/lib_color.c create mode 100644 ncurses/ncurses/base/lib_colorset.c create mode 100644 ncurses/ncurses/base/lib_delch.c create mode 100644 ncurses/ncurses/base/lib_delwin.c create mode 100644 ncurses/ncurses/base/lib_dft_fgbg.c create mode 100644 ncurses/ncurses/base/lib_driver.c create mode 100644 ncurses/ncurses/base/lib_echo.c create mode 100644 ncurses/ncurses/base/lib_endwin.c create mode 100644 ncurses/ncurses/base/lib_erase.c create mode 100644 ncurses/ncurses/base/lib_flash.c create mode 100644 ncurses/ncurses/base/lib_freeall.c create mode 100644 ncurses/ncurses/base/lib_getch.c create mode 100644 ncurses/ncurses/base/lib_getstr.c create mode 100644 ncurses/ncurses/base/lib_hline.c create mode 100644 ncurses/ncurses/base/lib_immedok.c create mode 100644 ncurses/ncurses/base/lib_inchstr.c create mode 100644 ncurses/ncurses/base/lib_initscr.c create mode 100644 ncurses/ncurses/base/lib_insch.c create mode 100644 ncurses/ncurses/base/lib_insdel.c create mode 100644 ncurses/ncurses/base/lib_insnstr.c create mode 100644 ncurses/ncurses/base/lib_instr.c create mode 100644 ncurses/ncurses/base/lib_isendwin.c create mode 100644 ncurses/ncurses/base/lib_leaveok.c create mode 100644 ncurses/ncurses/base/lib_mouse.c create mode 100644 ncurses/ncurses/base/lib_move.c create mode 100644 ncurses/ncurses/base/lib_mvwin.c create mode 100644 ncurses/ncurses/base/lib_newterm.c create mode 100644 ncurses/ncurses/base/lib_newwin.c create mode 100644 ncurses/ncurses/base/lib_nl.c create mode 100644 ncurses/ncurses/base/lib_overlay.c create mode 100644 ncurses/ncurses/base/lib_pad.c create mode 100644 ncurses/ncurses/base/lib_printw.c create mode 100644 ncurses/ncurses/base/lib_redrawln.c create mode 100644 ncurses/ncurses/base/lib_refresh.c create mode 100644 ncurses/ncurses/base/lib_restart.c create mode 100644 ncurses/ncurses/base/lib_scanw.c create mode 100644 ncurses/ncurses/base/lib_screen.c create mode 100644 ncurses/ncurses/base/lib_scroll.c create mode 100644 ncurses/ncurses/base/lib_scrollok.c create mode 100644 ncurses/ncurses/base/lib_scrreg.c create mode 100644 ncurses/ncurses/base/lib_set_term.c create mode 100644 ncurses/ncurses/base/lib_slk.c create mode 100644 ncurses/ncurses/base/lib_slkatr_set.c create mode 100644 ncurses/ncurses/base/lib_slkatrof.c create mode 100644 ncurses/ncurses/base/lib_slkatron.c create mode 100644 ncurses/ncurses/base/lib_slkatrset.c create mode 100644 ncurses/ncurses/base/lib_slkattr.c create mode 100644 ncurses/ncurses/base/lib_slkclear.c create mode 100644 ncurses/ncurses/base/lib_slkcolor.c create mode 100644 ncurses/ncurses/base/lib_slkinit.c create mode 100644 ncurses/ncurses/base/lib_slklab.c create mode 100644 ncurses/ncurses/base/lib_slkrefr.c create mode 100644 ncurses/ncurses/base/lib_slkset.c create mode 100644 ncurses/ncurses/base/lib_slktouch.c create mode 100644 ncurses/ncurses/base/lib_touch.c create mode 100644 ncurses/ncurses/base/lib_ungetch.c create mode 100644 ncurses/ncurses/base/lib_vline.c create mode 100644 ncurses/ncurses/base/lib_wattroff.c create mode 100644 ncurses/ncurses/base/lib_wattron.c create mode 100644 ncurses/ncurses/base/lib_winch.c create mode 100644 ncurses/ncurses/base/lib_window.c create mode 100644 ncurses/ncurses/base/nc_panel.c create mode 100644 ncurses/ncurses/base/new_pair.c create mode 100644 ncurses/ncurses/base/resizeterm.c create mode 100644 ncurses/ncurses/base/safe_sprintf.c create mode 100644 ncurses/ncurses/base/sigaction.c create mode 100644 ncurses/ncurses/base/tries.c create mode 100644 ncurses/ncurses/base/use_window.c create mode 100644 ncurses/ncurses/base/version.c create mode 100644 ncurses/ncurses/base/vsscanf.c create mode 100644 ncurses/ncurses/base/wresize.c create mode 100644 ncurses/ncurses/build.priv.h create mode 100644 ncurses/ncurses/curses.priv.h create mode 100644 ncurses/ncurses/fifo_defs.h create mode 100644 ncurses/ncurses/llib-lncurses create mode 100644 ncurses/ncurses/llib-lncursest create mode 100644 ncurses/ncurses/llib-lncursestw create mode 100644 ncurses/ncurses/llib-lncursesw create mode 100644 ncurses/ncurses/llib-ltic create mode 100644 ncurses/ncurses/llib-ltict create mode 100644 ncurses/ncurses/llib-ltictw create mode 100644 ncurses/ncurses/llib-lticw create mode 100644 ncurses/ncurses/llib-ltinfo create mode 100644 ncurses/ncurses/llib-ltinfot create mode 100644 ncurses/ncurses/llib-ltinfotw create mode 100644 ncurses/ncurses/llib-ltinfow create mode 100644 ncurses/ncurses/modules create mode 100644 ncurses/ncurses/new_pair.h create mode 100644 ncurses/ncurses/report_ctype.c create mode 100644 ncurses/ncurses/report_hashing.c create mode 100644 ncurses/ncurses/report_offsets.c create mode 100644 ncurses/ncurses/term.priv.h create mode 100644 ncurses/ncurses/tinfo/MKcaptab.awk create mode 100755 ncurses/ncurses/tinfo/MKcaptab.sh create mode 100644 ncurses/ncurses/tinfo/MKcodes.awk create mode 100755 ncurses/ncurses/tinfo/MKfallback.sh create mode 100755 ncurses/ncurses/tinfo/MKkeys_list.sh create mode 100644 ncurses/ncurses/tinfo/MKnames.awk create mode 100755 ncurses/ncurses/tinfo/MKuserdefs.sh create mode 100644 ncurses/ncurses/tinfo/README create mode 100644 ncurses/ncurses/tinfo/access.c create mode 100644 ncurses/ncurses/tinfo/add_tries.c create mode 100644 ncurses/ncurses/tinfo/alloc_entry.c create mode 100644 ncurses/ncurses/tinfo/alloc_ttype.c create mode 100644 ncurses/ncurses/tinfo/captoinfo.c create mode 100644 ncurses/ncurses/tinfo/comp_error.c create mode 100644 ncurses/ncurses/tinfo/comp_expand.c create mode 100644 ncurses/ncurses/tinfo/comp_hash.c create mode 100644 ncurses/ncurses/tinfo/comp_parse.c create mode 100644 ncurses/ncurses/tinfo/comp_scan.c create mode 100644 ncurses/ncurses/tinfo/db_iterator.c create mode 100644 ncurses/ncurses/tinfo/doalloc.c create mode 100644 ncurses/ncurses/tinfo/entries.c create mode 100644 ncurses/ncurses/tinfo/free_ttype.c create mode 100644 ncurses/ncurses/tinfo/getenv_num.c create mode 100644 ncurses/ncurses/tinfo/hashed_db.c create mode 100644 ncurses/ncurses/tinfo/home_terminfo.c create mode 100644 ncurses/ncurses/tinfo/init_keytry.c create mode 100644 ncurses/ncurses/tinfo/lib_acs.c create mode 100644 ncurses/ncurses/tinfo/lib_baudrate.c create mode 100644 ncurses/ncurses/tinfo/lib_cur_term.c create mode 100644 ncurses/ncurses/tinfo/lib_data.c create mode 100644 ncurses/ncurses/tinfo/lib_has_cap.c create mode 100644 ncurses/ncurses/tinfo/lib_kernel.c create mode 100644 ncurses/ncurses/tinfo/lib_longname.c create mode 100644 ncurses/ncurses/tinfo/lib_napms.c create mode 100644 ncurses/ncurses/tinfo/lib_options.c create mode 100644 ncurses/ncurses/tinfo/lib_print.c create mode 100644 ncurses/ncurses/tinfo/lib_raw.c create mode 100644 ncurses/ncurses/tinfo/lib_setup.c create mode 100644 ncurses/ncurses/tinfo/lib_termcap.c create mode 100644 ncurses/ncurses/tinfo/lib_termname.c create mode 100644 ncurses/ncurses/tinfo/lib_tgoto.c create mode 100644 ncurses/ncurses/tinfo/lib_ti.c create mode 100644 ncurses/ncurses/tinfo/lib_tparm.c create mode 100644 ncurses/ncurses/tinfo/lib_tputs.c create mode 100644 ncurses/ncurses/tinfo/lib_ttyflags.c create mode 100644 ncurses/ncurses/tinfo/lib_win32con.c create mode 100644 ncurses/ncurses/tinfo/lib_win32util.c create mode 100644 ncurses/ncurses/tinfo/make_hash.c create mode 100644 ncurses/ncurses/tinfo/make_keys.c create mode 100644 ncurses/ncurses/tinfo/name_match.c create mode 100644 ncurses/ncurses/tinfo/obsolete.c create mode 100644 ncurses/ncurses/tinfo/parse_entry.c create mode 100644 ncurses/ncurses/tinfo/read_entry.c create mode 100644 ncurses/ncurses/tinfo/read_termcap.c create mode 100644 ncurses/ncurses/tinfo/strings.c create mode 100644 ncurses/ncurses/tinfo/tinfo_driver.c create mode 100644 ncurses/ncurses/tinfo/trim_sgr0.c create mode 100644 ncurses/ncurses/tinfo/use_screen.c create mode 100644 ncurses/ncurses/tinfo/write_entry.c create mode 100644 ncurses/ncurses/trace/README create mode 100644 ncurses/ncurses/trace/lib_trace.c create mode 100644 ncurses/ncurses/trace/lib_traceatr.c create mode 100644 ncurses/ncurses/trace/lib_tracebits.c create mode 100644 ncurses/ncurses/trace/lib_tracechr.c create mode 100644 ncurses/ncurses/trace/lib_tracedmp.c create mode 100644 ncurses/ncurses/trace/lib_tracemse.c create mode 100644 ncurses/ncurses/trace/trace_buf.c create mode 100644 ncurses/ncurses/trace/trace_tries.c create mode 100644 ncurses/ncurses/trace/trace_xnames.c create mode 100644 ncurses/ncurses/trace/varargs.c create mode 100644 ncurses/ncurses/trace/visbuf.c create mode 100755 ncurses/ncurses/tty/MKexpanded.sh create mode 100644 ncurses/ncurses/tty/hardscroll.c create mode 100644 ncurses/ncurses/tty/hashmap.c create mode 100644 ncurses/ncurses/tty/lib_mvcur.c create mode 100644 ncurses/ncurses/tty/lib_tstp.c create mode 100644 ncurses/ncurses/tty/lib_twait.c create mode 100644 ncurses/ncurses/tty/lib_vidattr.c create mode 100644 ncurses/ncurses/tty/tty_update.c create mode 100644 ncurses/ncurses/wcwidth.h create mode 100644 ncurses/ncurses/widechar/charable.c create mode 100644 ncurses/ncurses/widechar/lib_add_wch.c create mode 100644 ncurses/ncurses/widechar/lib_box_set.c create mode 100644 ncurses/ncurses/widechar/lib_cchar.c create mode 100644 ncurses/ncurses/widechar/lib_erasewchar.c create mode 100644 ncurses/ncurses/widechar/lib_get_wch.c create mode 100644 ncurses/ncurses/widechar/lib_get_wstr.c create mode 100644 ncurses/ncurses/widechar/lib_hline_set.c create mode 100644 ncurses/ncurses/widechar/lib_in_wch.c create mode 100644 ncurses/ncurses/widechar/lib_in_wchnstr.c create mode 100644 ncurses/ncurses/widechar/lib_ins_wch.c create mode 100644 ncurses/ncurses/widechar/lib_inwstr.c create mode 100644 ncurses/ncurses/widechar/lib_key_name.c create mode 100644 ncurses/ncurses/widechar/lib_pecho_wchar.c create mode 100644 ncurses/ncurses/widechar/lib_slk_wset.c create mode 100644 ncurses/ncurses/widechar/lib_unget_wch.c create mode 100644 ncurses/ncurses/widechar/lib_vid_attr.c create mode 100644 ncurses/ncurses/widechar/lib_vline_set.c create mode 100644 ncurses/ncurses/widechar/lib_wacs.c create mode 100644 ncurses/ncurses/widechar/lib_wunctrl.c create mode 100644 ncurses/ncurses/widechar/widechars.c create mode 100644 ncurses/ncurses/win32con/gettimeofday.c create mode 100644 ncurses/ncurses/win32con/wcwidth.c create mode 100644 ncurses/ncurses/win32con/win32_driver.c create mode 100644 ncurses/ncurses_cfg.h create mode 100644 ncurses/pathnames.h create mode 100644 tcsh/FAQ create mode 100644 tcsh/FREEBSD-Xlist create mode 100644 tcsh/FREEBSD-upgrade create mode 100644 tcsh/Fixes create mode 100644 tcsh/NewThings create mode 100644 tcsh/Ported create mode 100644 tcsh/README.md create mode 100644 tcsh/WishList create mode 100644 tcsh/Y2K create mode 100644 tcsh/complete.tcsh create mode 100644 tcsh/config/bsd4.4 create mode 100644 tcsh/config_f.h create mode 100644 tcsh/csh-mode.el create mode 100644 tcsh/dot.login create mode 100644 tcsh/dot.tcshrc create mode 100644 tcsh/dotlock.c create mode 100644 tcsh/dotlock.h create mode 100644 tcsh/ed.chared.c create mode 100644 tcsh/ed.decls.h create mode 100644 tcsh/ed.defns.c create mode 100644 tcsh/ed.h create mode 100644 tcsh/ed.init.c create mode 100644 tcsh/ed.inputl.c create mode 100644 tcsh/ed.refresh.c create mode 100644 tcsh/ed.screen.c create mode 100644 tcsh/ed.term.c create mode 100644 tcsh/ed.term.h create mode 100644 tcsh/ed.xmap.c create mode 100644 tcsh/eight-bit.me create mode 100644 tcsh/gethost.c create mode 100644 tcsh/glob.3 create mode 100644 tcsh/glob.c create mode 100644 tcsh/glob.h create mode 100644 tcsh/host.defs create mode 100644 tcsh/ma.setp.c create mode 100644 tcsh/mi.termios.c create mode 100644 tcsh/mi.varargs.h create mode 100644 tcsh/mi.wait.h create mode 100644 tcsh/nls/C/charset create mode 100644 tcsh/nls/C/set1 create mode 100644 tcsh/nls/C/set10 create mode 100644 tcsh/nls/C/set11 create mode 100644 tcsh/nls/C/set12 create mode 100644 tcsh/nls/C/set13 create mode 100644 tcsh/nls/C/set14 create mode 100644 tcsh/nls/C/set15 create mode 100644 tcsh/nls/C/set16 create mode 100644 tcsh/nls/C/set17 create mode 100644 tcsh/nls/C/set18 create mode 100644 tcsh/nls/C/set19 create mode 100644 tcsh/nls/C/set2 create mode 100644 tcsh/nls/C/set20 create mode 100644 tcsh/nls/C/set21 create mode 100644 tcsh/nls/C/set22 create mode 100644 tcsh/nls/C/set23 create mode 100644 tcsh/nls/C/set24 create mode 100644 tcsh/nls/C/set25 create mode 100644 tcsh/nls/C/set26 create mode 100644 tcsh/nls/C/set27 create mode 100644 tcsh/nls/C/set29 create mode 100644 tcsh/nls/C/set3 create mode 100644 tcsh/nls/C/set30 create mode 100644 tcsh/nls/C/set31 create mode 100644 tcsh/nls/C/set4 create mode 100644 tcsh/nls/C/set5 create mode 100644 tcsh/nls/C/set6 create mode 100644 tcsh/nls/C/set7 create mode 100644 tcsh/nls/C/set8 create mode 100644 tcsh/nls/C/set9 create mode 100644 tcsh/nls/Makefile.in create mode 100755 tcsh/nls/catgen create mode 100644 tcsh/nls/et/charset create mode 100644 tcsh/nls/et/set1 create mode 100644 tcsh/nls/et/set10 create mode 100644 tcsh/nls/et/set11 create mode 100644 tcsh/nls/et/set12 create mode 100644 tcsh/nls/et/set13 create mode 100644 tcsh/nls/et/set14 create mode 100644 tcsh/nls/et/set15 create mode 100644 tcsh/nls/et/set16 create mode 100644 tcsh/nls/et/set17 create mode 100644 tcsh/nls/et/set18 create mode 100644 tcsh/nls/et/set19 create mode 100644 tcsh/nls/et/set2 create mode 100644 tcsh/nls/et/set20 create mode 100644 tcsh/nls/et/set21 create mode 100644 tcsh/nls/et/set22 create mode 100644 tcsh/nls/et/set23 create mode 100644 tcsh/nls/et/set24 create mode 100644 tcsh/nls/et/set25 create mode 100644 tcsh/nls/et/set26 create mode 100644 tcsh/nls/et/set27 create mode 100644 tcsh/nls/et/set29 create mode 100644 tcsh/nls/et/set3 create mode 100644 tcsh/nls/et/set30 create mode 100644 tcsh/nls/et/set31 create mode 100644 tcsh/nls/et/set4 create mode 100644 tcsh/nls/et/set5 create mode 100644 tcsh/nls/et/set6 create mode 100644 tcsh/nls/et/set7 create mode 100644 tcsh/nls/et/set8 create mode 100644 tcsh/nls/et/set9 create mode 100644 tcsh/nls/finnish/charset create mode 100644 tcsh/nls/finnish/set1 create mode 100644 tcsh/nls/finnish/set10 create mode 100644 tcsh/nls/finnish/set11 create mode 100644 tcsh/nls/finnish/set12 create mode 100644 tcsh/nls/finnish/set13 create mode 100644 tcsh/nls/finnish/set14 create mode 100644 tcsh/nls/finnish/set15 create mode 100644 tcsh/nls/finnish/set16 create mode 100644 tcsh/nls/finnish/set17 create mode 100644 tcsh/nls/finnish/set18 create mode 100644 tcsh/nls/finnish/set19 create mode 100644 tcsh/nls/finnish/set2 create mode 100644 tcsh/nls/finnish/set20 create mode 100644 tcsh/nls/finnish/set21 create mode 100644 tcsh/nls/finnish/set22 create mode 100644 tcsh/nls/finnish/set23 create mode 100644 tcsh/nls/finnish/set24 create mode 100644 tcsh/nls/finnish/set25 create mode 100644 tcsh/nls/finnish/set26 create mode 100644 tcsh/nls/finnish/set27 create mode 100644 tcsh/nls/finnish/set29 create mode 100644 tcsh/nls/finnish/set3 create mode 100644 tcsh/nls/finnish/set30 create mode 100644 tcsh/nls/finnish/set31 create mode 100644 tcsh/nls/finnish/set4 create mode 100644 tcsh/nls/finnish/set5 create mode 100644 tcsh/nls/finnish/set6 create mode 100644 tcsh/nls/finnish/set7 create mode 100644 tcsh/nls/finnish/set8 create mode 100644 tcsh/nls/finnish/set9 create mode 100644 tcsh/nls/french/charset create mode 100644 tcsh/nls/french/set1 create mode 100644 tcsh/nls/french/set10 create mode 100644 tcsh/nls/french/set11 create mode 100644 tcsh/nls/french/set12 create mode 100644 tcsh/nls/french/set13 create mode 100644 tcsh/nls/french/set14 create mode 100644 tcsh/nls/french/set15 create mode 100644 tcsh/nls/french/set16 create mode 100644 tcsh/nls/french/set17 create mode 100644 tcsh/nls/french/set18 create mode 100644 tcsh/nls/french/set19 create mode 100644 tcsh/nls/french/set2 create mode 100644 tcsh/nls/french/set20 create mode 100644 tcsh/nls/french/set21 create mode 100644 tcsh/nls/french/set22 create mode 100644 tcsh/nls/french/set23 create mode 100644 tcsh/nls/french/set24 create mode 100644 tcsh/nls/french/set25 create mode 100644 tcsh/nls/french/set26 create mode 100644 tcsh/nls/french/set27 create mode 100644 tcsh/nls/french/set29 create mode 100644 tcsh/nls/french/set3 create mode 100644 tcsh/nls/french/set30 create mode 100644 tcsh/nls/french/set31 create mode 100644 tcsh/nls/french/set4 create mode 100644 tcsh/nls/french/set5 create mode 100644 tcsh/nls/french/set6 create mode 100644 tcsh/nls/french/set7 create mode 100644 tcsh/nls/french/set8 create mode 100644 tcsh/nls/french/set9 create mode 100644 tcsh/nls/german/charset create mode 100644 tcsh/nls/german/set1 create mode 100644 tcsh/nls/german/set10 create mode 100644 tcsh/nls/german/set11 create mode 100644 tcsh/nls/german/set12 create mode 100644 tcsh/nls/german/set13 create mode 100644 tcsh/nls/german/set14 create mode 100644 tcsh/nls/german/set15 create mode 100644 tcsh/nls/german/set16 create mode 100644 tcsh/nls/german/set17 create mode 100644 tcsh/nls/german/set18 create mode 100644 tcsh/nls/german/set19 create mode 100644 tcsh/nls/german/set2 create mode 100644 tcsh/nls/german/set20 create mode 100644 tcsh/nls/german/set21 create mode 100644 tcsh/nls/german/set22 create mode 100644 tcsh/nls/german/set23 create mode 100644 tcsh/nls/german/set24 create mode 100644 tcsh/nls/german/set25 create mode 100644 tcsh/nls/german/set26 create mode 100644 tcsh/nls/german/set27 create mode 100644 tcsh/nls/german/set29 create mode 100644 tcsh/nls/german/set3 create mode 100644 tcsh/nls/german/set30 create mode 100644 tcsh/nls/german/set31 create mode 100644 tcsh/nls/german/set4 create mode 100644 tcsh/nls/german/set5 create mode 100644 tcsh/nls/german/set6 create mode 100644 tcsh/nls/german/set7 create mode 100644 tcsh/nls/german/set8 create mode 100644 tcsh/nls/german/set9 create mode 100644 tcsh/nls/greek/charset create mode 100644 tcsh/nls/greek/set1 create mode 100644 tcsh/nls/greek/set10 create mode 100644 tcsh/nls/greek/set11 create mode 100644 tcsh/nls/greek/set12 create mode 100644 tcsh/nls/greek/set13 create mode 100644 tcsh/nls/greek/set14 create mode 100644 tcsh/nls/greek/set15 create mode 100644 tcsh/nls/greek/set16 create mode 100644 tcsh/nls/greek/set17 create mode 100644 tcsh/nls/greek/set18 create mode 100644 tcsh/nls/greek/set19 create mode 100644 tcsh/nls/greek/set2 create mode 100644 tcsh/nls/greek/set20 create mode 100644 tcsh/nls/greek/set21 create mode 100644 tcsh/nls/greek/set22 create mode 100644 tcsh/nls/greek/set23 create mode 100644 tcsh/nls/greek/set24 create mode 100644 tcsh/nls/greek/set25 create mode 100644 tcsh/nls/greek/set26 create mode 100644 tcsh/nls/greek/set27 create mode 100644 tcsh/nls/greek/set29 create mode 100644 tcsh/nls/greek/set3 create mode 100644 tcsh/nls/greek/set30 create mode 100644 tcsh/nls/greek/set31 create mode 100644 tcsh/nls/greek/set4 create mode 100644 tcsh/nls/greek/set5 create mode 100644 tcsh/nls/greek/set6 create mode 100644 tcsh/nls/greek/set7 create mode 100644 tcsh/nls/greek/set8 create mode 100644 tcsh/nls/greek/set9 create mode 100644 tcsh/nls/italian/charset create mode 100644 tcsh/nls/italian/set1 create mode 100644 tcsh/nls/italian/set10 create mode 100644 tcsh/nls/italian/set11 create mode 100644 tcsh/nls/italian/set12 create mode 100644 tcsh/nls/italian/set13 create mode 100644 tcsh/nls/italian/set14 create mode 100644 tcsh/nls/italian/set15 create mode 100644 tcsh/nls/italian/set16 create mode 100644 tcsh/nls/italian/set17 create mode 100644 tcsh/nls/italian/set18 create mode 100644 tcsh/nls/italian/set19 create mode 100644 tcsh/nls/italian/set2 create mode 100644 tcsh/nls/italian/set20 create mode 100644 tcsh/nls/italian/set21 create mode 100644 tcsh/nls/italian/set22 create mode 100644 tcsh/nls/italian/set23 create mode 100644 tcsh/nls/italian/set24 create mode 100644 tcsh/nls/italian/set25 create mode 100644 tcsh/nls/italian/set26 create mode 100644 tcsh/nls/italian/set27 create mode 100644 tcsh/nls/italian/set29 create mode 100644 tcsh/nls/italian/set3 create mode 100644 tcsh/nls/italian/set30 create mode 100644 tcsh/nls/italian/set31 create mode 100644 tcsh/nls/italian/set4 create mode 100644 tcsh/nls/italian/set5 create mode 100644 tcsh/nls/italian/set6 create mode 100644 tcsh/nls/italian/set7 create mode 100644 tcsh/nls/italian/set8 create mode 100644 tcsh/nls/italian/set9 create mode 100644 tcsh/nls/ja/charset create mode 100644 tcsh/nls/ja/set1 create mode 100644 tcsh/nls/ja/set10 create mode 100644 tcsh/nls/ja/set11 create mode 100644 tcsh/nls/ja/set12 create mode 100644 tcsh/nls/ja/set13 create mode 100644 tcsh/nls/ja/set15 create mode 100644 tcsh/nls/ja/set16 create mode 100644 tcsh/nls/ja/set17 create mode 100644 tcsh/nls/ja/set18 create mode 100644 tcsh/nls/ja/set2 create mode 100644 tcsh/nls/ja/set21 create mode 100644 tcsh/nls/ja/set24 create mode 100644 tcsh/nls/ja/set29 create mode 100644 tcsh/nls/ja/set3 create mode 100644 tcsh/nls/ja/set30 create mode 100644 tcsh/nls/ja/set4 create mode 100644 tcsh/nls/ja/set5 create mode 100644 tcsh/nls/ja/set6 create mode 100644 tcsh/nls/ja/set7 create mode 100644 tcsh/nls/ja/set8 create mode 100644 tcsh/nls/russian/charset create mode 100644 tcsh/nls/russian/set1 create mode 100644 tcsh/nls/russian/set10 create mode 100644 tcsh/nls/russian/set11 create mode 100644 tcsh/nls/russian/set12 create mode 100644 tcsh/nls/russian/set13 create mode 100644 tcsh/nls/russian/set14 create mode 100644 tcsh/nls/russian/set15 create mode 100644 tcsh/nls/russian/set16 create mode 100644 tcsh/nls/russian/set17 create mode 100644 tcsh/nls/russian/set18 create mode 100644 tcsh/nls/russian/set19 create mode 100644 tcsh/nls/russian/set2 create mode 100644 tcsh/nls/russian/set20 create mode 100644 tcsh/nls/russian/set21 create mode 100644 tcsh/nls/russian/set22 create mode 100644 tcsh/nls/russian/set23 create mode 100644 tcsh/nls/russian/set24 create mode 100644 tcsh/nls/russian/set25 create mode 100644 tcsh/nls/russian/set26 create mode 100644 tcsh/nls/russian/set27 create mode 100644 tcsh/nls/russian/set29 create mode 100644 tcsh/nls/russian/set3 create mode 100644 tcsh/nls/russian/set30 create mode 100644 tcsh/nls/russian/set31 create mode 100644 tcsh/nls/russian/set4 create mode 100644 tcsh/nls/russian/set5 create mode 100644 tcsh/nls/russian/set6 create mode 100644 tcsh/nls/russian/set7 create mode 100644 tcsh/nls/russian/set8 create mode 100644 tcsh/nls/russian/set9 create mode 100644 tcsh/nls/spanish/charset create mode 100644 tcsh/nls/spanish/set1 create mode 100644 tcsh/nls/spanish/set10 create mode 100644 tcsh/nls/spanish/set11 create mode 100644 tcsh/nls/spanish/set12 create mode 100644 tcsh/nls/spanish/set13 create mode 100644 tcsh/nls/spanish/set14 create mode 100644 tcsh/nls/spanish/set15 create mode 100644 tcsh/nls/spanish/set16 create mode 100644 tcsh/nls/spanish/set17 create mode 100644 tcsh/nls/spanish/set18 create mode 100644 tcsh/nls/spanish/set19 create mode 100644 tcsh/nls/spanish/set2 create mode 100644 tcsh/nls/spanish/set20 create mode 100644 tcsh/nls/spanish/set21 create mode 100644 tcsh/nls/spanish/set22 create mode 100644 tcsh/nls/spanish/set23 create mode 100644 tcsh/nls/spanish/set24 create mode 100644 tcsh/nls/spanish/set25 create mode 100644 tcsh/nls/spanish/set26 create mode 100644 tcsh/nls/spanish/set27 create mode 100644 tcsh/nls/spanish/set29 create mode 100644 tcsh/nls/spanish/set3 create mode 100644 tcsh/nls/spanish/set30 create mode 100644 tcsh/nls/spanish/set31 create mode 100644 tcsh/nls/spanish/set4 create mode 100644 tcsh/nls/spanish/set5 create mode 100644 tcsh/nls/spanish/set6 create mode 100644 tcsh/nls/spanish/set7 create mode 100644 tcsh/nls/spanish/set8 create mode 100644 tcsh/nls/spanish/set9 create mode 100644 tcsh/nls/ukrainian/charset create mode 100644 tcsh/nls/ukrainian/set1 create mode 100644 tcsh/nls/ukrainian/set10 create mode 100644 tcsh/nls/ukrainian/set11 create mode 100644 tcsh/nls/ukrainian/set12 create mode 100644 tcsh/nls/ukrainian/set13 create mode 100644 tcsh/nls/ukrainian/set14 create mode 100644 tcsh/nls/ukrainian/set15 create mode 100644 tcsh/nls/ukrainian/set16 create mode 100644 tcsh/nls/ukrainian/set17 create mode 100644 tcsh/nls/ukrainian/set18 create mode 100644 tcsh/nls/ukrainian/set19 create mode 100644 tcsh/nls/ukrainian/set2 create mode 100644 tcsh/nls/ukrainian/set20 create mode 100644 tcsh/nls/ukrainian/set21 create mode 100644 tcsh/nls/ukrainian/set22 create mode 100644 tcsh/nls/ukrainian/set23 create mode 100644 tcsh/nls/ukrainian/set24 create mode 100644 tcsh/nls/ukrainian/set25 create mode 100644 tcsh/nls/ukrainian/set26 create mode 100644 tcsh/nls/ukrainian/set27 create mode 100644 tcsh/nls/ukrainian/set29 create mode 100644 tcsh/nls/ukrainian/set3 create mode 100644 tcsh/nls/ukrainian/set30 create mode 100644 tcsh/nls/ukrainian/set31 create mode 100644 tcsh/nls/ukrainian/set4 create mode 100644 tcsh/nls/ukrainian/set5 create mode 100644 tcsh/nls/ukrainian/set6 create mode 100644 tcsh/nls/ukrainian/set7 create mode 100644 tcsh/nls/ukrainian/set8 create mode 100644 tcsh/nls/ukrainian/set9 create mode 100644 tcsh/patchlevel.h create mode 100644 tcsh/pathnames.h create mode 100644 tcsh/sh.c create mode 100644 tcsh/sh.char.c create mode 100644 tcsh/sh.char.h create mode 100644 tcsh/sh.decls.h create mode 100644 tcsh/sh.dir.c create mode 100644 tcsh/sh.dir.h create mode 100644 tcsh/sh.dol.c create mode 100644 tcsh/sh.err.c create mode 100644 tcsh/sh.exec.c create mode 100644 tcsh/sh.exp.c create mode 100644 tcsh/sh.file.c create mode 100644 tcsh/sh.func.c create mode 100644 tcsh/sh.glob.c create mode 100644 tcsh/sh.h create mode 100644 tcsh/sh.hist.c create mode 100644 tcsh/sh.init.c create mode 100644 tcsh/sh.lex.c create mode 100644 tcsh/sh.misc.c create mode 100644 tcsh/sh.parse.c create mode 100644 tcsh/sh.print.c create mode 100644 tcsh/sh.proc.c create mode 100644 tcsh/sh.proc.h create mode 100644 tcsh/sh.sem.c create mode 100644 tcsh/sh.set.c create mode 100644 tcsh/sh.time.c create mode 100644 tcsh/sh.types.h create mode 100644 tcsh/snames.h create mode 100644 tcsh/src.desc create mode 100644 tcsh/tc.alloc.c create mode 100644 tcsh/tc.bind.c create mode 100644 tcsh/tc.const.c create mode 100644 tcsh/tc.decls.h create mode 100644 tcsh/tc.disc.c create mode 100644 tcsh/tc.func.c create mode 100644 tcsh/tc.h create mode 100644 tcsh/tc.nls.c create mode 100644 tcsh/tc.nls.h create mode 100644 tcsh/tc.os.c create mode 100644 tcsh/tc.os.h create mode 100644 tcsh/tc.printf.c create mode 100644 tcsh/tc.prompt.c create mode 100644 tcsh/tc.sched.c create mode 100644 tcsh/tc.sig.c create mode 100644 tcsh/tc.sig.h create mode 100644 tcsh/tc.str.c create mode 100644 tcsh/tc.vers.c create mode 100644 tcsh/tc.wait.h create mode 100644 tcsh/tc.who.c create mode 100644 tcsh/tcsh.man create mode 100644 tcsh/tcsh.man.new create mode 100644 tcsh/tcsh.man2html create mode 100644 tcsh/termcap.vms create mode 100644 tcsh/tw.color.c create mode 100644 tcsh/tw.comp.c create mode 100644 tcsh/tw.decls.h create mode 100644 tcsh/tw.h create mode 100644 tcsh/tw.help.c create mode 100644 tcsh/tw.init.c create mode 100644 tcsh/tw.parse.c create mode 100644 tcsh/tw.spell.c create mode 100644 tcsh/vms.termcap.c create mode 100644 tests/test.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..a74d30b48c --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +*.a +*.core +*.lo +*.nossppico +*.o +*.orig +*.pico +*.pieo +*.po +*.rej +*.so +*.so.[0-9]* +*.sw[nop] +*~ +.*DS_Store +.cache +.clangd +.ccls-cache +.depend* +compile_commands.json +compile_commands.events.json +tags +build/ +out/ +.linux-obj/ diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000000..d97c85f928 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,449 @@ +.DEFAULT_GOAL := all + +ifeq ($(origin CC), default) +CC := /usr/bin/cc +endif +ifeq ($(origin CC), environment) +CC := /usr/bin/cc +endif + +AR ?= ar +AWK ?= awk +RANLIB ?= ranlib +SH ?= sh + +CPPFLAGS += -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_PATH_TCSHELL='"/bin/csh"' -UNLS_CATALOGS +CFLAGS ?= -O2 +CFLAGS += -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare +LDFLAGS ?= + +CC_MACHINE := $(strip $(shell $(CC) -dumpmachine 2>/dev/null)) +IS_MUSL := $(if $(findstring musl,$(CC) $(CC_MACHINE)),1,0) + +ifeq ($(IS_MUSL),1) +CRYPTO_LIBS ?= +else +CRYPTO_LIBS ?= -lcrypt +endif +LDLIBS ?= $(CRYPTO_LIBS) + +TCSHDIR := $(CURDIR)/tcsh +NCURSESDIR := $(CURDIR)/ncurses +NCINCDIR := $(NCURSESDIR)/include +NCSRCDIR := $(NCURSESDIR)/ncurses +TINFOBASEDIR := $(NCSRCDIR)/base +TINFODIR := $(NCSRCDIR)/tinfo +TINFOTTYDIR := $(NCSRCDIR)/tty +TINFOTRACEDIR := $(NCSRCDIR)/trace + +OBJDIR := $(CURDIR)/build/obj +TINFOOBJDIR := $(CURDIR)/build/obj-tinfo +GENDIR := $(CURDIR)/build/gen +TINFOGENDIR := $(CURDIR)/build/gen-tinfo +OUTDIR := $(CURDIR)/out +TARGET := $(OUTDIR)/csh +TINFO_LIB := $(OUTDIR)/libtinfow.a + +CONFIG_HEADERS := $(CURDIR)/config.h $(CURDIR)/config_p.h $(TCSHDIR)/config_f.h +GEN_HEADERS := $(GENDIR)/sh.err.h $(GENDIR)/ed.defns.h $(GENDIR)/tc.const.h +GEN_SOURCES := $(GENDIR)/tc.defs.c + +TINFO_CPPFLAGS := $(CPPFLAGS) -DTERMIOS -I"$(TINFOGENDIR)" -I"$(NCURSESDIR)" -I"$(NCSRCDIR)" -I"$(NCINCDIR)" +TINFO_CONFIG := $(NCURSESDIR)/ncurses_cfg.h $(NCURSESDIR)/pathnames.h + +NCURSES_MAJOR := 6 +NCURSES_MINOR := 6 +NCURSES_PATCH := 20251230 +NCURSES_CH_T := cchar_t +NCURSES_CONST := const +NCURSES_INLINE := inline +NCURSES_LIBUTF8 := 0 +NCURSES_MBSTATE_T := 0 +NCURSES_MOUSE_VERSION := 2 +NCURSES_OK_WCHAR_T := 1 +NCURSES_OPAQUE := 0 +NCURSES_OPAQUE_FORM := 0 +NCURSES_OPAQUE_MENU := 0 +NCURSES_OPAQUE_PANEL := 0 +NCURSES_OSPEED := short +NCURSES_RGB_COLORS := 0 +NCURSES_SBOOL := char +NCURSES_SIZE_T := short +NCURSES_TPARM_ARG := intptr_t +NCURSES_TPARM_VARARGS := 1 +NCURSES_WATTR_MACROS := 1 +NCURSES_WCHAR_T := 0 +NCURSES_WCWIDTH_GRAPHICS := 1 +NCURSES_WINT_T := 0 +NCURSES_EXT_COLORS := 1 +NCURSES_EXT_FUNCS := 1 +NCURSES_INTEROP_FUNCS := 1 +NCURSES_SP_FUNCS := 1 +NCURSES_XNAMES := 1 +BROKEN_LINKER := 0 +BUILTIN_BOOL := 1 +ENABLE_LP64 := 1 +ENABLE_OPAQUE := NCURSES_OPAQUE +ENABLE_REENTRANT := 0 +ENABLE_SIGWINCH := 1 +HAVE_STDBOOL_H := 1 +HAVE_STDINT_H := 1 +HAVE_STDNORETURN_H := 0 +HAVE_TCGETATTR := 1 +HAVE_TERMIOS_H := 1 +HAVE_TERMIO_H := 0 +HAVE_VSSCANF := 1 +NEED_WCHAR_H := 1 +ONEUL := 1U +TYPEOF_CHTYPE := uint32_t +TYPEOF_MMASK_T := uint32_t +TYPE_OF_BOOL := unsigned char +USE_BIG_STRINGS := 1 +USE_CXX_BOOL := defined(__cplusplus) + +SRCS := \ + $(TCSHDIR)/sh.c \ + $(TCSHDIR)/sh.dir.c \ + $(TCSHDIR)/sh.dol.c \ + $(TCSHDIR)/sh.err.c \ + $(TCSHDIR)/sh.exec.c \ + $(TCSHDIR)/sh.char.c \ + $(TCSHDIR)/sh.exp.c \ + $(TCSHDIR)/sh.file.c \ + $(TCSHDIR)/sh.func.c \ + $(TCSHDIR)/sh.glob.c \ + $(TCSHDIR)/sh.hist.c \ + $(TCSHDIR)/sh.init.c \ + $(TCSHDIR)/sh.lex.c \ + $(TCSHDIR)/sh.misc.c \ + $(TCSHDIR)/sh.parse.c \ + $(TCSHDIR)/sh.print.c \ + $(TCSHDIR)/sh.proc.c \ + $(TCSHDIR)/sh.sem.c \ + $(TCSHDIR)/sh.set.c \ + $(TCSHDIR)/sh.time.c \ + $(TCSHDIR)/glob.c \ + $(TCSHDIR)/tw.help.c \ + $(TCSHDIR)/tw.init.c \ + $(TCSHDIR)/tw.parse.c \ + $(TCSHDIR)/tw.spell.c \ + $(TCSHDIR)/tw.comp.c \ + $(TCSHDIR)/tw.color.c \ + $(TCSHDIR)/ed.chared.c \ + $(TCSHDIR)/ed.defns.c \ + $(TCSHDIR)/ed.init.c \ + $(TCSHDIR)/ed.inputl.c \ + $(TCSHDIR)/ed.refresh.c \ + $(TCSHDIR)/ed.screen.c \ + $(TCSHDIR)/ed.xmap.c \ + $(TCSHDIR)/ed.term.c \ + $(TCSHDIR)/tc.alloc.c \ + $(TCSHDIR)/tc.bind.c \ + $(TCSHDIR)/tc.const.c \ + $(TCSHDIR)/tc.disc.c \ + $(TCSHDIR)/tc.func.c \ + $(TCSHDIR)/tc.nls.c \ + $(TCSHDIR)/tc.os.c \ + $(TCSHDIR)/tc.printf.c \ + $(TCSHDIR)/tc.prompt.c \ + $(TCSHDIR)/tc.sched.c \ + $(TCSHDIR)/tc.sig.c \ + $(TCSHDIR)/tc.str.c \ + $(TCSHDIR)/tc.vers.c \ + $(TCSHDIR)/tc.who.c \ + $(TCSHDIR)/dotlock.c \ + $(GEN_SOURCES) + +TCSH_OBJS := $(addprefix $(OBJDIR)/,$(notdir $(SRCS:.c=.o))) + +TINFO_BASE_SRCS := define_key.c key_defined.c keybound.c keyok.c tries.c version.c +TINFO_CORE_SRCS := \ + access.c \ + add_tries.c \ + alloc_entry.c \ + alloc_ttype.c \ + captoinfo.c \ + comp_captab.c \ + comp_error.c \ + comp_expand.c \ + comp_hash.c \ + comp_parse.c \ + comp_scan.c \ + comp_userdefs.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_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 \ + obsolete.c \ + parse_entry.c \ + read_entry.c \ + read_termcap.c \ + strings.c \ + trim_sgr0.c \ + write_entry.c +TINFO_TTY_SRCS := lib_twait.c +TINFO_TRACE_SRCS := lib_trace.c visbuf.c +TINFO_GEN_SRCS := names.c codes.c lib_keyname.c unctrl.c fallback.c comp_captab.c comp_userdefs.c +TINFO_ALL_SRCS := $(TINFO_BASE_SRCS) $(TINFO_CORE_SRCS) $(TINFO_TTY_SRCS) $(TINFO_TRACE_SRCS) $(TINFO_GEN_SRCS) +TINFO_OBJS := $(addprefix $(TINFOOBJDIR)/,$(TINFO_ALL_SRCS:.c=.o)) + +TINFO_BASE_HEADERS := \ + $(TINFOGENDIR)/curses.h \ + $(TINFOGENDIR)/hashsize.h \ + $(TINFOGENDIR)/ncurses_def.h \ + $(TINFOGENDIR)/ncurses_dll.h \ + $(TINFOGENDIR)/parametrized.h \ + $(TINFOGENDIR)/term.h \ + $(TINFOGENDIR)/termcap.h \ + $(TINFOGENDIR)/unctrl.h + +TINFO_HEADERS := $(TINFO_BASE_HEADERS) $(TINFOGENDIR)/init_keytry.h $(TINFOGENDIR)/nomacros.h + +TINFO_INTERMEDIATES := \ + $(TINFOGENDIR)/MKterm.h.awk \ + $(TINFOGENDIR)/codes.c \ + $(TINFOGENDIR)/comp_captab.c \ + $(TINFOGENDIR)/comp_userdefs.c \ + $(TINFOGENDIR)/curses.head \ + $(TINFOGENDIR)/fallback.c \ + $(TINFOGENDIR)/keys.list \ + $(TINFOGENDIR)/lib_keyname.c \ + $(TINFOGENDIR)/names.c \ + $(TINFOGENDIR)/unctrl.c + +vpath %.c $(TCSHDIR) $(TINFOBASEDIR) $(TINFODIR) $(TINFOTTYDIR) $(TINFOTRACEDIR) $(GENDIR) $(TINFOGENDIR) + +.PHONY: all clean dirs status test + +all: $(TARGET) + +dirs: + @mkdir -p "$(OBJDIR)" "$(TINFOOBJDIR)" "$(GENDIR)" "$(TINFOGENDIR)" "$(OUTDIR)" + +$(TARGET): $(TCSH_OBJS) $(TINFO_LIB) | dirs + $(CC) $(LDFLAGS) -o "$@" $(TCSH_OBJS) $(TINFO_LIB) $(LDLIBS) + +$(TINFO_LIB): $(TINFO_OBJS) | dirs + $(AR) rcs "$@" $(TINFO_OBJS) + $(RANLIB) "$@" + +$(OBJDIR)/%.o: %.c $(GEN_HEADERS) $(CONFIG_HEADERS) | dirs + $(CC) $(CPPFLAGS) $(CFLAGS) -I"$(GENDIR)" -I"$(CURDIR)" -I"$(TCSHDIR)" -c "$<" -o "$@" + +$(TINFOOBJDIR)/%.o: %.c $(TINFO_HEADERS) $(TINFO_INTERMEDIATES) $(TINFO_CONFIG) | dirs + $(CC) $(TINFO_CPPFLAGS) $(CFLAGS) -c "$<" -o "$@" + +$(GENDIR)/gethost: $(TCSHDIR)/gethost.c $(GENDIR)/sh.err.h $(CONFIG_HEADERS) | dirs + $(CC) $(CPPFLAGS) $(CFLAGS) -D_h_tc_const -I"$(GENDIR)" -I"$(CURDIR)" -I"$(TCSHDIR)" "$<" -o "$@" + +$(GENDIR)/tc.defs.c: $(GENDIR)/gethost $(TCSHDIR)/host.defs | dirs + { \ + printf '/* Do not edit this file, make creates it */\n'; \ + "$(GENDIR)/gethost" "$(TCSHDIR)/host.defs"; \ + } > "$@" + +$(GENDIR)/ed.defns.h: $(TCSHDIR)/ed.defns.c | dirs + { \ + printf '/* Do not edit this file, make creates it. */\n'; \ + printf '#ifndef _h_ed_defns\n#define _h_ed_defns\n'; \ + LC_ALL=C grep '[FV]_' "$<" | LC_ALL=C grep '^#define'; \ + printf '#endif /* _h_ed_defns */\n'; \ + } > "$@" + +$(GENDIR)/sh.err.h: $(TCSHDIR)/sh.err.c | dirs + { \ + printf '/* Do not edit this file, make creates it. */\n'; \ + printf '#ifndef _h_sh_err\n#define _h_sh_err\n'; \ + LC_ALL=C grep 'ERR_' "$<" | LC_ALL=C grep '^#define'; \ + printf '#endif /* _h_sh_err */\n'; \ + } > "$@" + +$(GENDIR)/tc.const.h: $(TCSHDIR)/tc.const.c | dirs + { \ + printf '/* Do not edit this file, make creates it. */\n'; \ + printf '#ifndef _h_tc_const\n#define _h_tc_const\n'; \ + LC_ALL=C awk '/^Char STR/ { sub(/\[\].*/, "[];"); print "extern " $$0 }' "$<"; \ + printf '#endif /* _h_tc_const */\n'; \ + } > "$@" + +$(TINFOGENDIR)/ncurses_def.h: $(NCINCDIR)/ncurses_defs | dirs + AWK="$(AWK)" "$(SH)" "$(NCINCDIR)/MKncurses_def.sh" "$<" > "$@" + +$(TINFOGENDIR)/ncurses_dll.h: $(NCINCDIR)/ncurses_dll.h.in | dirs + sed < "$<" \ + -e 's%@NCURSES_WRAP_PREFIX@%_nc_%g' > "$@" + +$(TINFOGENDIR)/termcap.h: $(NCINCDIR)/termcap.h.in | dirs + sed < "$<" \ + -e '/@NCURSES_MAJOR@/s%%$(NCURSES_MAJOR)%' \ + -e '/@NCURSES_MINOR@/s%%$(NCURSES_MINOR)%' \ + -e '/@NCURSES_CONST@/s%%$(NCURSES_CONST)%' \ + -e '/@NCURSES_OSPEED@/s%%$(NCURSES_OSPEED)%' > "$@" + +$(TINFOGENDIR)/unctrl.h: $(NCINCDIR)/unctrl.h.in | dirs + sed < "$<" \ + -e 's%@NCURSES_SP_FUNCS@%$(NCURSES_SP_FUNCS)%g' \ + -e '/@NCURSES_MAJOR@/s%%$(NCURSES_MAJOR)%' \ + -e '/@NCURSES_MINOR@/s%%$(NCURSES_MINOR)%' > "$@" + +$(TINFOGENDIR)/hashsize.h: $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses | dirs + "$(SH)" "$(NCINCDIR)/MKhashsize.sh" "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" > "$@" + +$(TINFOGENDIR)/parametrized.h: $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses | dirs + AWK="$(AWK)" "$(SH)" "$(NCINCDIR)/MKparametrized.sh" "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" > "$@" + +$(TINFOGENDIR)/MKterm.h.awk: $(NCINCDIR)/MKterm.h.awk.in | dirs + sed < "$<" \ + -e '/@BROKEN_LINKER@/s%%$(BROKEN_LINKER)%' \ + -e 's%@NCURSES_USE_DATABASE@%1%g' \ + -e 's%@NCURSES_USE_TERMCAP@%1%g' \ + -e '/@NCURSES_MAJOR@/s%%$(NCURSES_MAJOR)%' \ + -e '/@NCURSES_MINOR@/s%%$(NCURSES_MINOR)%' \ + -e '/@NCURSES_CONST@/s%%$(NCURSES_CONST)%' \ + -e '/@NCURSES_TPARM_VARARGS@/s%%$(NCURSES_TPARM_VARARGS)%' \ + -e '/@NCURSES_SBOOL@/s%%$(NCURSES_SBOOL)%' \ + -e '/@NCURSES_XNAMES@/s%%$(NCURSES_XNAMES)%' \ + -e '/@NCURSES_EXT_COLORS@/s%%$(NCURSES_EXT_COLORS)%' \ + -e '/@HAVE_TERMIOS_H@/s%%$(HAVE_TERMIOS_H)%' \ + -e '/@HAVE_TERMIO_H@/s%%$(HAVE_TERMIO_H)%' \ + -e '/@HAVE_TCGETATTR@/s%%$(HAVE_TCGETATTR)%' \ + -e 's%@cf_cv_enable_reentrant@%$(ENABLE_REENTRANT)%g' \ + -e 's%@NCURSES_SP_FUNCS@%1%' \ + -e 's%@NCURSES_PATCH@%$(NCURSES_PATCH)%' > "$@" + +$(TINFOGENDIR)/term.h: $(TINFOGENDIR)/MKterm.h.awk $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses $(NCINCDIR)/edit_cfg.sh $(NCURSESDIR)/ncurses_cfg.h | dirs + "$(AWK)" -f "$(TINFOGENDIR)/MKterm.h.awk" "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" > "$@.tmp" + "$(SH)" "$(NCINCDIR)/edit_cfg.sh" "$(NCURSESDIR)/ncurses_cfg.h" "$@.tmp" + mv -f "$@.tmp" "$@" + +$(TINFOGENDIR)/curses.head: $(NCINCDIR)/curses.h.in | dirs + sed < "$<" \ + -e '/@BROKEN_LINKER@/s%%$(BROKEN_LINKER)%' \ + -e '/@HAVE_VSSCANF@/s%%$(HAVE_VSSCANF)%' \ + -e '/@HAVE_STDINT_H@/s%%$(HAVE_STDINT_H)%' \ + -e '/@HAVE_STDNORETURN_H@/s%%$(HAVE_STDNORETURN_H)%' \ + -e '/@NCURSES_CH_T@/s%%$(NCURSES_CH_T)%' \ + -e '/@NCURSES_CONST@/s%%$(NCURSES_CONST)%' \ + -e '/@NCURSES_EXT_COLORS@/s%%$(NCURSES_EXT_COLORS)%' \ + -e '/@NCURSES_EXT_FUNCS@/s%%$(NCURSES_EXT_FUNCS)%' \ + -e '/@NCURSES_INLINE@/s%%$(NCURSES_INLINE)%' \ + -e '/@NCURSES_LIBUTF8@/s%%$(NCURSES_LIBUTF8)%' \ + -e '/@NCURSES_MAJOR@/s%%$(NCURSES_MAJOR)%' \ + -e '/@NCURSES_MBSTATE_T@/s%%$(NCURSES_MBSTATE_T)%' \ + -e '/@NCURSES_MINOR@/s%%$(NCURSES_MINOR)%' \ + -e '/@NCURSES_MOUSE_VERSION@/s%%$(NCURSES_MOUSE_VERSION)%' \ + -e '/@NCURSES_XNAMES@/s%%$(NCURSES_XNAMES)%' \ + -e '/@NCURSES_OK_WCHAR_T@/s%%$(NCURSES_OK_WCHAR_T)%' \ + -e '/@NCURSES_OPAQUE@/s%%$(NCURSES_OPAQUE)%' \ + -e '/@NCURSES_OPAQUE_FORM@/s%%$(NCURSES_OPAQUE_FORM)%' \ + -e '/@NCURSES_OPAQUE_MENU@/s%%$(NCURSES_OPAQUE_MENU)%' \ + -e '/@NCURSES_OPAQUE_PANEL@/s%%$(NCURSES_OPAQUE_PANEL)%' \ + -e '/@NCURSES_PATCH@/s%%$(NCURSES_PATCH)%' \ + -e '/@NCURSES_RGB_COLORS@/s%%$(NCURSES_RGB_COLORS)%' \ + -e '/@NCURSES_SIZE_T@/s%%$(NCURSES_SIZE_T)%' \ + -e '/@NCURSES_TPARM_VARARGS@/s%%$(NCURSES_TPARM_VARARGS)%' \ + -e '/@NCURSES_WATTR_MACROS@/s%%$(NCURSES_WATTR_MACROS)%' \ + -e '/@NCURSES_WCHAR_T@/s%%$(NCURSES_WCHAR_T)%' \ + -e '/@NCURSES_WCWIDTH_GRAPHICS@/s%%$(NCURSES_WCWIDTH_GRAPHICS)%g' \ + -e '/@NCURSES_WINT_T@/s%%$(NCURSES_WINT_T)%' \ + -e '/@NCURSES_INTEROP_FUNCS@/s%%$(NCURSES_INTEROP_FUNCS)%g' \ + -e '/@NCURSES_TPARM_ARG@/s%%$(NCURSES_TPARM_ARG)%g' \ + -e '/@NCURSES_SP_FUNCS@/s%%$(NCURSES_SP_FUNCS)%g' \ + -e '/@NEED_WCHAR_H@/s%%$(NEED_WCHAR_H)%' \ + -e '/@USE_CXX_BOOL@/s%%$(USE_CXX_BOOL)%' \ + -e '/@USE_STDBOOL_H@/s%%$(HAVE_STDBOOL_H)%' \ + -e '/@GENERATED_EXT_FUNCS@/s%%generated%g' \ + -e 's%@NCURSES_CCHARW_MAX@%5%g' \ + -e 's%@cf_cv_1UL@%$(ONEUL)%g' \ + -e 's%@USE_BUILTIN_BOOL@%$(BUILTIN_BOOL)%g' \ + -e 's%@cf_cv_enable_lp64@%$(ENABLE_LP64)%g' \ + -e 's%@cf_cv_enable_opaque@%$(ENABLE_OPAQUE)%g' \ + -e 's%@cf_cv_enable_reentrant@%$(ENABLE_REENTRANT)%g' \ + -e 's%@cf_cv_enable_sigwinch@%$(ENABLE_SIGWINCH)%g' \ + -e 's%@cf_cv_type_of_bool@%$(TYPE_OF_BOOL)%g' \ + -e 's%@cf_cv_typeof_chtype@%$(TYPEOF_CHTYPE)%g' \ + -e 's%@cf_cv_typeof_mmask_t@%$(TYPEOF_MMASK_T)%g' \ + -e 's/ _WCHAR_T/ __wchar_t/g' \ + -e 's/ _WINT_T/ __wint_t/g' > "$@" + +$(TINFOGENDIR)/keys.list: $(TINFODIR)/MKkeys_list.sh $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses | dirs + AWK="$(AWK)" USE_SIGWINCH="$(ENABLE_SIGWINCH)" "$(SH)" "$(TINFODIR)/MKkeys_list.sh" \ + "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" | LC_ALL=C sort > "$@" + +$(TINFOGENDIR)/names.c: $(TINFODIR)/MKnames.awk $(NCINCDIR)/Caps | dirs + "$(AWK)" -f "$<" bigstrings="$(USE_BIG_STRINGS)" "$(NCINCDIR)/Caps" > "$@" + +$(TINFOGENDIR)/codes.c: $(TINFODIR)/MKcodes.awk $(NCINCDIR)/Caps | dirs + "$(AWK)" -f "$<" bigstrings="$(USE_BIG_STRINGS)" "$(NCINCDIR)/Caps" > "$@" + +$(TINFOGENDIR)/lib_keyname.c: $(TINFOGENDIR)/keys.list $(TINFOBASEDIR)/MKkeyname.awk | dirs + "$(AWK)" -f "$(TINFOBASEDIR)/MKkeyname.awk" use_sigwinch="$(ENABLE_SIGWINCH)" \ + bigstrings="$(USE_BIG_STRINGS)" "$(TINFOGENDIR)/keys.list" > "$@" + +$(TINFOGENDIR)/unctrl.c: $(TINFOBASEDIR)/MKunctrl.awk | dirs + printf '\n' | "$(AWK)" -f "$<" bigstrings="$(USE_BIG_STRINGS)" > "$@" + +$(TINFOGENDIR)/fallback.c: $(TINFODIR)/MKfallback.sh | dirs + "$(SH)" "$<" "" "" "" "" > "$@.tmp" + mv -f "$@.tmp" "$@" + +$(TINFOGENDIR)/make_hash: $(TINFODIR)/make_hash.c $(TINFOGENDIR)/hashsize.h $(TINFOGENDIR)/ncurses_def.h $(TINFO_BASE_HEADERS) | dirs + $(CC) $(TINFO_CPPFLAGS) $(CFLAGS) -DMAIN_PROGRAM "$<" -o "$@" + +$(TINFOGENDIR)/make_keys: $(TINFODIR)/make_keys.c $(TINFOGENDIR)/names.c $(TINFOGENDIR)/ncurses_def.h $(TINFO_BASE_HEADERS) | dirs + $(CC) $(TINFO_CPPFLAGS) $(CFLAGS) "$<" -o "$@" + +$(TINFOGENDIR)/comp_captab.c: $(TINFODIR)/MKcaptab.sh $(TINFODIR)/MKcaptab.awk $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses $(TINFOGENDIR)/make_hash | dirs + cd "$(TINFOGENDIR)" && env PATH="$(TINFOGENDIR):$$PATH" "$(SH)" "$(TINFODIR)/MKcaptab.sh" "$(AWK)" "$(USE_BIG_STRINGS)" \ + "$(TINFODIR)/MKcaptab.awk" "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" > "$@" + +$(TINFOGENDIR)/comp_userdefs.c: $(TINFODIR)/MKuserdefs.sh $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses $(TINFOGENDIR)/make_hash | dirs + cd "$(TINFOGENDIR)" && env PATH="$(TINFOGENDIR):$$PATH" "$(SH)" "$(TINFODIR)/MKuserdefs.sh" "$(AWK)" "$(USE_BIG_STRINGS)" \ + "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" > "$@" + +$(TINFOGENDIR)/init_keytry.h: $(TINFOGENDIR)/keys.list $(TINFOGENDIR)/make_keys | dirs + "$(TINFOGENDIR)/make_keys" "$(TINFOGENDIR)/keys.list" > "$@" + +$(TINFOGENDIR)/curses.h: $(TINFOGENDIR)/curses.head $(NCINCDIR)/Caps $(NCINCDIR)/Caps-ncurses $(NCINCDIR)/curses.wide $(NCINCDIR)/curses.tail $(NCINCDIR)/MKkey_defs.sh | dirs + cp "$(TINFOGENDIR)/curses.head" "$@.tmp" + AWK="$(AWK)" _POSIX2_VERSION=199209 "$(SH)" "$(NCINCDIR)/MKkey_defs.sh" \ + "$(NCINCDIR)/Caps" "$(NCINCDIR)/Caps-ncurses" >> "$@.tmp" + cat "$(NCINCDIR)/curses.wide" >> "$@.tmp" + cat "$(NCINCDIR)/curses.tail" >> "$@.tmp" + mv -f "$@.tmp" "$@" + +$(TINFOGENDIR)/nomacros.h: $(TINFOBASEDIR)/MKlib_gen.sh $(TINFOGENDIR)/curses.h | dirs + LC_ALL=C "$(SH)" "$(TINFOBASEDIR)/MKlib_gen.sh" "$(CC) -E $(CFLAGS) $(TINFO_CPPFLAGS)" \ + "$(AWK)" generated < "$(TINFOGENDIR)/curses.h" | grep -F undef > "$@" + +test: $(TARGET) + LC_ALL=C CSH_BIN="$(TARGET)" sh "$(CURDIR)/tests/test.sh" + +status: + @printf '%s\n' "$(TARGET)" + +clean: + @rm -rf "$(CURDIR)/build" "$(CURDIR)/out" diff --git a/LICENSES/BSD-2-Clause.txt b/LICENSES/BSD-2-Clause.txt new file mode 100644 index 0000000000..5f662b354c --- /dev/null +++ b/LICENSES/BSD-2-Clause.txt @@ -0,0 +1,9 @@ +Copyright (c) + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt new file mode 100644 index 0000000000..ea890afbc7 --- /dev/null +++ b/LICENSES/BSD-3-Clause.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +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 copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000000..d817195dad --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,18 @@ +MIT License + +Copyright (c) + +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, 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 AUTHORS OR 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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..c7f86eb089 --- /dev/null +++ b/Makefile @@ -0,0 +1,167 @@ +# C Shell with process control; VM/UNIX VAX Makefile +# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria +# +# To profile, put -DPROF in DEFS and -pg in CFLAGS, and recompile. + +.include + +PACKAGE= csh + +CONFGROUPS= ETC ROOT +ETCPACKAGE= csh +ROOTPACKAGE= csh +ETC= csh.cshrc csh.login csh.logout +ROOT= dot.cshrc dot.login +ROOTDIR= /root +ROOTDIR_MODE= 0750 +ROOTNAME_dot.cshrc= .cshrc +ROOTNAME_dot.login= .login +TCSHDIR= ${.CURDIR}/tcsh +.PATH: ${TCSHDIR} + +PROG= csh +.if defined(RESCUE) +DFLAGS= -D_PATH_TCSHELL='"/rescue/${PROG}"' +.else +DFLAGS= -D_PATH_TCSHELL='"/bin/${PROG}"' +.endif +CFLAGS+= -I. -I${.CURDIR} -I${TCSHDIR} ${DFLAGS} +WARNS?= 1 +SRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \ + sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \ + sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \ + sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h +SRCS+= sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h +SRCS+= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \ + tw.comp.c tw.color.c +SRCS+= ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \ + ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h +SRCS+= tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \ + tc.func.c tc.nls.c tc.os.c tc.os.h tc.printf.c tc.prompt.c \ + tc.sched.c tc.sig.c tc.sig.h tc.str.c sh.types.h tc.vers.c tc.wait.h \ + tc.who.c tc.h +SRCS+= dotlock.c dotlock.h +GENHDRS= ed.defns.h sh.err.h tc.const.h tc.defs.c +SRCS+= ${GENHDRS} + +MLINKS= csh.1 tcsh.1 +# MLINKS for Shell built in commands for which there are no userland +# utilities of the same name are handled with the associated manpage, +# builtin.1 in share/man/man1/. + +LIBADD= termcapw crypt + +LINKS= ${BINDIR}/csh ${BINDIR}/tcsh + +CLEANFILES= ${GENHDRS} gethost csh.1 + +.if ${MK_EXAMPLES} != "no" +FILESDIR= ${SHAREDIR}/examples/tcsh +FILES= complete.tcsh csh-mode.el +.endif + +CATALOGS= et:et_EE.UTF-8 \ + finnish:fi_FI.UTF-8 \ + french:fr_FR.UTF-8 \ + german:de_DE.UTF-8 \ + greek:el_GR.UTF-8 \ + italian:it_IT.UTF-8 \ + ja:ja_JP.UTF-8 \ + russian:ru_RU.UTF-8 \ + spanish:es_ES.UTF-8 \ + ukrainian:uk_UA.UTF-8 + +NLSLINKS_de_DE.UTF-8 = de_AT.UTF-8 de_CH.UTF-8 +NLSLINKS_fr_FR.UTF-8 = fr_BE.UTF-8 fr_CA.UTF-8 fr_CH.UTF-8 +NLSLINKS_it_IT.UTF-8 = it_CH.UTF-8 + +.if ${MK_NLS_CATALOGS} == "no" || defined(RESCUE) +CFLAGS+= -DNO_NLS_CATALOGS +.else +CFLAGS+= -DHAVE_ICONV +.if ${MK_ICONV} != "no" +NLSLINKS_de_DE.UTF-8 += de_AT.ISO8859-1 de_AT.ISO8859-15 de_CH.ISO8859-1 \ + de_CH.ISO8859-15 de_DE.ISO8859-1 de_DE.ISO8859-15 +NLSLINKS_el_GR.UTF-8 = el_GR.ISO8859-7 +NLSLINKS_es_ES.UTF-8 = es_ES.ISO8859-1 es_ES.ISO8859-15 +NLSLINKS_et_EE.UTF-8 = et_EE.ISO8859-15 +NLSLINKS_fi_FI.UTF-8 = fi_FI.ISO8859-1 fi_FI.ISO8859-15 +NLSLINKS_fr_FR.UTF-8 += fr_BE.ISO8859-1 fr_BE.ISO8859-15 \ + fr_CA.ISO8859-1 fr_CA.ISO8859-15 fr_CH.ISO8859-1 \ + fr_CH.ISO8859-15 fr_FR.ISO8859-1 fr_FR.ISO8859-15 +NLSLINKS_it_IT.UTF-8 += it_CH.ISO8859-1 it_CH.ISO8859-15 it_IT.ISO8859-1 \ + it_IT.ISO8859-15 +NLSLINKS_ja_JP.UTF-8 = ja_JP.SJIS ja_JP.eucJP +NLSLINKS_ru_RU.UTF-8 = ru_RU.CP1251 ru_RU.CP866 ru_RU.ISO8859-5 ru_RU.KOI8-R +NLSLINKS_uk_UA.UTF-8 = uk_UA.ISO8859-5 uk_UA.KOI8-U +.else +# Above links can be installed from ports/shells/tcsh_nls + +GENHDRS+= iconv.h +SRCS+= iconv_stub.c + +iconv.h: ${.CURDIR}/iconv_stub.h + ${CP} ${.CURDIR}/iconv_stub.h ${.TARGET} +.endif +.endif + +NLSNAME= tcsh + +.for catalog in ${CATALOGS} +NLS+= ${catalog:C/.*://} +NLSSRCDIR_${catalog:C/.*://}= ${TCSHDIR}/nls/${catalog:C/:.*//} +NLSSRCFILES_${catalog:C/.*://}!= cd ${NLSSRCDIR_${catalog:C/.*://}}; echo charset set[0-9]* +.endfor + +csh.1: tcsh.man + cat ${.ALLSRC} > ${.TARGET} + +.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no" +build-tools: gethost +tc.defs.c: gethost + +DEPENDOBJS+= gethost +gethost: gethost.c sh.err.h sh.h ${BUILD_TOOLS_META} + @rm -f ${.TARGET} + # Define _h_tc_const so that tc.h will skip including tc.const.h. + # gethost.c does not actually require any of the definitions in there, + # and building tc.const.h requires target headers which are not + # available when we need to build gethost. + ${HOST_CC:N${CCACHE_BIN}} -o gethost ${LDFLAGS} ${CFLAGS:C/-DHAVE_ICONV//} \ + -D_h_tc_const \ + ${TCSHDIR}/gethost.c +.endif + +tc.defs.c: ${TCSHDIR}/host.defs + @rm -f ${.TARGET} + @echo "/* Do not edit this file, make creates it */" > ${.TARGET} + ${BTOOLSPATH:U.}/gethost ${TCSHDIR}/host.defs >> ${.TARGET} + +ed.defns.h: ed.defns.c + @rm -f ${.TARGET} + @echo '/* Do not edit this file, make creates it. */' > ${.TARGET} + @echo '#ifndef _h_ed_defns' >> ${.TARGET} + @echo '#define _h_ed_defns' >> ${.TARGET} + grep '[FV]_' ${TCSHDIR}/ed.defns.c | grep '^#define' >> ${.TARGET} + @echo '#endif /* _h_ed_defns */' >> ${.TARGET} + +sh.err.h: sh.err.c + @rm -f ${.TARGET} + @echo '/* Do not edit this file, make creates it. */' > ${.TARGET} + @echo '#ifndef _h_sh_err' >> ${.TARGET} + @echo '#define _h_sh_err' >> ${.TARGET} + grep 'ERR_' ${.ALLSRC} | grep '^#define' >> ${.TARGET} + @echo '#endif /* _h_sh_err */' >> ${.TARGET} + +tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h ${BUILD_TOOLS_META} + @rm -f ${.TARGET} + @echo '/* Do not edit this file, make creates it. */' > ${.TARGET} + @echo '#ifndef _h_tc_const' >> ${.TARGET} + @echo '#define _h_tc_const' >> ${.TARGET} + ${CC:N${CCACHE_BIN}} -E ${CFLAGS:C/-DHAVE_ICONV//} ${.ALLSRC} -D_h_tc_const | \ + grep 'Char STR' | \ + sed -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \ + sort >> ${.TARGET} + @echo '#endif /* _h_tc_const */' >> ${.TARGET} + +.include diff --git a/Makefile.depend b/Makefile.depend new file mode 100644 index 0000000000..604ca4ffe0 --- /dev/null +++ b/Makefile.depend @@ -0,0 +1,19 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + bin/csh.host \ + include \ + include/arpa \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/libcrypt \ + lib/ncurses/tinfo \ + + +.include + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/README.md b/README.md new file mode 100644 index 0000000000..a2b79be92a --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# csh + +Standalone musl-libc-based Linux port of FreeBSD `csh` for Project Tick BSD/Linux Distribution. + +## Build + +```sh +gmake -f GNUmakefile +gmake -f GNUmakefile CC=musl-gcc +``` + +Binary output: + +```sh +out/csh +``` + +## Test + +```sh +gmake -f GNUmakefile test +gmake -f GNUmakefile test CC=musl-gcc +``` + +## Port Strategy + +- The source base stays close to FreeBSD's `tcsh`, but the Linux build is standalone and generates its own `tc.defs.c`, `sh.err.h`, `ed.defns.h`, and `tc.const.h`. +- The required upstream `tcsh` sources now live under `bin/csh/tcsh`, and the Linux terminfo/termcap stack is built from vendored ncurses sources under `bin/csh/ncurses`. +- No shared BSD compatibility shim is introduced. FreeBSD-specific assumptions are replaced with Linux-native interfaces in the affected source files. +- Child process accounting on Linux uses `wait4(2)` instead of BSD `wait3(2)`, which keeps job-control resource accounting working on musl. +- Login/watch state reads Linux utmp/utmpx data from `_PATH_UTMP` when available, otherwise `/run/utmp`, rather than FreeBSD's `utx.active`. +- Terminal capability lookup is satisfied by the vendored `libtinfow` build, so Linux and musl builds do not depend on host `ncursesw`/`tinfo`. +- NLS catalogs are disabled in the standalone port at source level; the build does not install or load translated message catalogs. + +## Supported / Unsupported Linux Semantics + +- Supported: non-interactive `-c` execution, shell scripts, globbing, history-less `-f` operation, vendored termcap/terminfo lookups, job control/resource accounting via `wait4(2)`, `setpriority(2)`, `getrlimit(2)`, and `setrlimit(2)`. +- Supported with explicit runtime dependency: login watch uses the host's utmp/utmpx database; if the database is absent, tcsh reports the missing file instead of silently pretending the feature works. +- Unsupported in this standalone port: NLS catalog loading is disabled, so translated message catalogs are not installed or loaded. diff --git a/config.h b/config.h new file mode 100644 index 0000000000..7d7eeaee88 --- /dev/null +++ b/config.h @@ -0,0 +1,276 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to the type of elements in the array set by `getgroups'. Usually + this is either `int' or `gid_t'. */ +#define GETGROUPS_T gid_t + +/* Define to 1 if the `getpgrp' function requires zero arguments. */ +#define GETPGRP_VOID 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_AUTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CRYPT_H */ + +/* Define to 1 if you have the declaration of `crypt', and to 0 if you don't. + */ +#define HAVE_DECL_CRYPT 1 + +/* Define to 1 if you have the declaration of `environ', and to 0 if you + don't. */ +#define HAVE_DECL_ENVIRON 0 + +/* Define to 1 if you have the declaration of `gethostname', and to 0 if you + don't. */ +#define HAVE_DECL_GETHOSTNAME 1 + +/* Define to 1 if you have the declaration of `getpgrp', and to 0 if you + don't. */ +#define HAVE_DECL_GETPGRP 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_FEATURES_H */ + +/* Define to 1 if you have the `getauthid' function. */ +/* #undef HAVE_GETAUTHID */ + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getutent' function. */ +/* #undef HAVE_GETUTENT */ + +/* Define to 1 if you have the `getutxent' function. */ +#define HAVE_GETUTXENT 1 + +/* Define if you have the iconv() function and it works. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `mallinfo' function. */ +/* #undef HAVE_MALLINFO */ + +/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `nl_langinfo' function. */ +#define HAVE_NL_LANGINFO 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PATHS_H 1 + +/* Define to 1 if you have the `sbrk' function. */ +/* #undef HAVE_SBRK 1 */ + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcoll' function and it is properly defined. + */ +#define HAVE_STRCOLL 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if `d_ino' is a member of `struct dirent'. */ +#define HAVE_STRUCT_DIRENT_D_INO 1 + +/* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 + +/* Define to 1 if `ut_host' is a member of `struct utmpx'. */ +#define HAVE_STRUCT_UTMPX_UT_HOST 1 + +/* Define to 1 if `ut_tv' is a member of `struct utmpx'. */ +#define HAVE_STRUCT_UTMPX_UT_TV 1 + +/* Define to 1 if `ut_user' is a member of `struct utmpx'. */ +#define HAVE_STRUCT_UTMPX_UT_USER 1 + +/* Define to 1 if `ut_xtime' is a member of `struct utmpx'. */ +/* #undef HAVE_STRUCT_UTMPX_UT_XTIME */ + +/* Define to 1 if `ut_host' is a member of `struct utmp'. */ +#define HAVE_STRUCT_UTMP_UT_HOST 1 + +/* Define to 1 if `ut_tv' is a member of `struct utmp'. */ +#define HAVE_STRUCT_UTMP_UT_TV 1 + +/* Define to 1 if `ut_user' is a member of `struct utmp'. */ +#define HAVE_STRUCT_UTMP_UT_USER 1 + +/* Define to 1 if `ut_xtime' is a member of `struct utmp'. */ +/* #undef HAVE_STRUCT_UTMP_UT_XTIME */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTMPX_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_UTMP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if you have the `wcwidth' function. */ +#define HAVE_WCWIDTH 1 + +/* Define as const if the declaration of iconv() needs const. */ +#define ICONV_CONST + +/* Support NLS. */ +#define NLS 1 + +/* Support NLS catalogs. */ +/* #undef NLS_CATALOGS */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "http://bugs.gw.com/" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "tcsh" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "tcsh 6.18.01" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "tcsh" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "6.18.01" + +/* Define to 1 if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* Define to 1 if the `S_IS*' macros in do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if neither nor define. */ +/* #undef socklen_t */ + +/* Define to `int' not defined in . */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to empty if the keyword `volatile' does not work. Warning: valid + code using `volatile' can become incorrect without. Disable with care. */ +/* #undef volatile */ + +#include "config_p.h" +#include "config_f.h" + +/* Work around a vendor issue where config_f.h is #undef'ing this setting */ +#define SYSMALLOC diff --git a/config_p.h b/config_p.h new file mode 100644 index 0000000000..8b7ecd20de --- /dev/null +++ b/config_p.h @@ -0,0 +1,111 @@ +/* + * config.h -- configure various defines for tcsh + * + * All source files should #include this FIRST. + * + * Edit this to match your system type. + */ + +#ifndef _h_config +#define _h_config +/****************** System dependent compilation flags ****************/ +/* + * POSIX This system supports IEEE Std 1003.1-1988 (POSIX). + */ +#define POSIX + +/* + * POSIXJOBS This system supports the optional IEEE Std 1003.1-1988 (POSIX) + * job control facilities. + */ +#define POSIXJOBS + +/* + * VFORK This machine has a vfork(). + * It used to be that for job control to work, this define + * was mandatory. This is not the case any more. + * If you think you still need it, but you don't have vfork, + * define this anyway and then do #define vfork fork. + * I do this anyway on a Sun because of yellow pages brain damage, + * [should not be needed under 4.1] + * and on the iris4d cause SGI's fork is sufficiently "virtual" + * that vfork isn't necessary. (Besides, SGI's vfork is weird). + * Note that some machines eg. rs6000 have a vfork, but not + * with the berkeley semantics, so we cannot use it there either. + */ +/* #define VFORK */ +#define vfork fork + +/* + * BSDJOBS You have BSD-style job control (both process groups and + * a tty that deals correctly + */ +#define BSDJOBS + +/* + * BSDTIMES You have BSD-style process time stuff (like rusage) + * This may or may not be true. For example, Apple Unix + * (OREO) has BSDJOBS but not BSDTIMES. + */ +#define BSDTIMES + +/* + * BSDLIMIT You have BSD-style resource limit stuff (getrlimit/setrlimit) + */ +#define BSDLIMIT + +/* + * TERMIO You have struct termio instead of struct sgttyb. + * This is usually the case for SYSV systems, where + * BSD uses sgttyb. POSIX systems should define this + * anyway, even though they use struct termios. + */ +#define TERMIO + +/* + * SYSVREL Your machine is SYSV based (HPUX, A/UX) + * NOTE: don't do this if you are on a Pyramid -- tcsh is + * built in a BSD universe. + * Set SYSVREL to 1, 2, 3, or 4, depending the version of System V + * you are running. Or set it to 0 if you are not SYSV based + */ +#define SYSVREL 0 + +/* + * YPBUGS Work around Sun YP bugs that cause expansion of ~username + * to send command output to /dev/null + */ +#undef YPBUGS + +/****************** local defines *********************/ + +#if defined(__FreeBSD__) +#define NLS_BUGS +#define BSD_STYLE_COLORLS +/* Use LC_MESSAGES locale category to open the message catalog */ +#define MCLoadBySet NL_CAT_LOCALE +#define BUFSIZE 8192 +#define UTMPX_FILE "/var/run/utx.active" +#endif + +#if defined(__bsdi__) +/* + * _PATH_TCSHELL if you've change the installation location (vix) + */ +#include +# ifdef _BSDI_VERSION >= 199701 +# define _PATH_TCSHELL "/bin/tcsh" +# undef SYSMALLOC +# define SYSMALLOC +# else +# define _PATH_TCSHELL "/usr/contrib/bin/tcsh" +# endif + +# undef NLS +# undef NLS_CATALOGS + +#elif defined(__APPLE__) +# define SYSMALLOC +#endif + +#endif /* _h_config */ diff --git a/csh.cshrc b/csh.cshrc new file mode 100644 index 0000000000..b08603404c --- /dev/null +++ b/csh.cshrc @@ -0,0 +1,2 @@ +# +# System-wide .cshrc file for csh(1). diff --git a/csh.login b/csh.login new file mode 100644 index 0000000000..ec1b704512 --- /dev/null +++ b/csh.login @@ -0,0 +1,11 @@ +# +# System-wide .login file for csh(1). +# +# For the setting of languages and character sets please see +# login.conf(5) and in particular the charset and lang options. +# For full locales list check /usr/share/locale/* +# +# Check system messages +# msgs -q +# Allow terminal messages +# mesg y diff --git a/csh.logout b/csh.logout new file mode 100644 index 0000000000..73103d8096 --- /dev/null +++ b/csh.logout @@ -0,0 +1,2 @@ +# +# System-wide .logout file for csh(1). diff --git a/dot.cshrc b/dot.cshrc new file mode 100644 index 0000000000..3d1ddb094c --- /dev/null +++ b/dot.cshrc @@ -0,0 +1,45 @@ +# +# .cshrc - csh resource script, read at beginning of execution by each shell +# +# see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ +# + +alias h history 25 +alias j jobs -l +alias la ls -aF +alias lf ls -FA +alias ll ls -lAF + +# read(2) of directories may not be desirable by default, as this will provoke +# EISDIR errors from each directory encountered. +# alias grep grep -d skip + +# A righteous umask +umask 22 + +set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin $HOME/bin) + +setenv EDITOR vi +setenv PAGER less + +if ($?prompt) then + # An interactive shell -- set some stuff up + set prompt = "%N@%m:%~ %# " + set promptchars = "%#" + + set filec + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash + set mail = (/var/mail/$USER) + if ( $?tcsh ) then + bindkey "^W" backward-delete-word + bindkey -k up history-search-backward + bindkey -k down history-search-forward + endif + +endif diff --git a/dot.login b/dot.login new file mode 100644 index 0000000000..a18fc8c780 --- /dev/null +++ b/dot.login @@ -0,0 +1,11 @@ +# +# .login - csh login script, read by login shell, after `.cshrc' at login. +# +# See also csh(1), environ(7). +# + +# Query terminal size; useful for serial lines. +if ( -x /usr/bin/resizewin ) /usr/bin/resizewin -z + +# Uncomment to display a random cookie on each login. +# if ( -x /usr/bin/fortune ) /usr/bin/fortune -s diff --git a/iconv_stub.c b/iconv_stub.c new file mode 100644 index 0000000000..22a0fe3a03 --- /dev/null +++ b/iconv_stub.c @@ -0,0 +1,80 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 Hajimu UMEMOTO + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +#include "iconv.h" + +#undef iconv_open +#undef iconv +#undef iconv_close + +#define ICONVLIB "libiconv.so" +#define ICONV_ENGINE "libiconv" +#define ICONV_OPEN "libiconv_open" +#define ICONV_CLOSE "libiconv_close" + +typedef iconv_t iconv_open_t(const char *, const char *); + +dl_iconv_t *dl_iconv; +dl_iconv_close_t *dl_iconv_close; + +static int initialized; +static void *iconvlib; +static iconv_open_t *iconv_open; + +iconv_t +dl_iconv_open(const char *tocode, const char *fromcode) +{ + if (initialized) { + if (iconvlib == NULL) + return (iconv_t)-1; + } else { + initialized = 1; + iconvlib = dlopen(ICONVLIB, RTLD_LAZY | RTLD_GLOBAL); + if (iconvlib == NULL) + return (iconv_t)-1; + iconv_open = (iconv_open_t *)dlfunc(iconvlib, ICONV_OPEN); + if (iconv_open == NULL) + goto dlfunc_err; + dl_iconv = (dl_iconv_t *)dlfunc(iconvlib, ICONV_ENGINE); + if (dl_iconv == NULL) + goto dlfunc_err; + dl_iconv_close = (dl_iconv_close_t *)dlfunc(iconvlib, + ICONV_CLOSE); + if (dl_iconv_close == NULL) + goto dlfunc_err; + } + return iconv_open(tocode, fromcode); + +dlfunc_err: + dlclose(iconvlib); + iconvlib = NULL; + return (iconv_t)-1; +} diff --git a/iconv_stub.h b/iconv_stub.h new file mode 100644 index 0000000000..ab9cf5a719 --- /dev/null +++ b/iconv_stub.h @@ -0,0 +1,44 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 Hajimu UMEMOTO + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _ICONV_H_ +#define _ICONV_H_ + +typedef void *iconv_t; +typedef size_t dl_iconv_t(iconv_t, char **, size_t *, char **, size_t *); +typedef int dl_iconv_close_t(iconv_t); + +extern iconv_t dl_iconv_open(const char *, const char *); +extern dl_iconv_t *dl_iconv; +extern dl_iconv_close_t *dl_iconv_close; + +#define iconv_open dl_iconv_open +#define iconv dl_iconv +#define iconv_close dl_iconv_close + +#endif /* !_ICONV_H_ */ diff --git a/ncurses/include/Caps b/ncurses/include/Caps new file mode 100644 index 0000000000..136abd42e5 --- /dev/null +++ b/ncurses/include/Caps @@ -0,0 +1,1035 @@ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 1998-2015,2016 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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: Zeyd M. Ben-Halim 1992,1995 +# and: Eric S. Raymond +# +# $Id: Caps,v 1.62 2025/11/12 01:06:36 Branden.Robinson Exp $ +# +# This is the master termcap/terminfo capability table. +# +# This table is used to generate initializers for tables that drive tic, +# infocmp, and the library compilation code used to support the termcap +# compatibility hack. It is also used to generate the tabular portion of the +# terminfo(5) man page; lines beginning with `#%' are passed through to become +# the terminfo table. +# +# This file has three major sections; a standard-capabilities table, two +# extension-capability tables, and a section of aliases declarations. +# The first two have the same format, as follows: +# +# FILE FORMAT +# +# Column 1: terminfo variable name +# Column 2: terminfo capability name +# Column 3: capability type (Boolean, numeric, or string) +# Column 4: termcap capability name +# 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 8: capability description +# +# 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 is there to help the terminfo maintainer avoid emitting +# termcap entry translations that are more than 1023 bytes long (and tank a +# lot of old termcap-using programs). The codes read as follows: +# B = mentioned in the BSD man page for 4.4BSD curses +# C = used by the 4.4BSD curses library +# G = mentioned in the documentation for GNU termcap +# E = used by GNU Emacs +# K = remove this terminfo capability when translating to standard format +# The important codes are C and E. A cap with C or E should be preserved in +# 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 +# an asterisk (*). +# +# The aliases section has the following format: +# +# Column 1: either `capalias' or `infoalias' +# Column 2: name to be aliased +# Column 3: what name it should translate to. The name IGNORE means it +# should be discarded with a warning message. +# Column 4: name of the extension set (used for compiler warning messages) +# Column 5: capability description (usually an associated terminfo variable) +# +# HANDLING TERMCAP AND TERMINFO EXTENSIONS +# +# There are basically five different ways to handle termcap and terminfo +# extensions: +# +# 1. Don't list the capname here, or list it but comment it out (the latter +# is preferable; someone might want to handle it in the future). If you do +# this, the capability will be treated as unknown and raise a warning from +# the compiler. +# +# 2. Alias it. This is appropriate if the capability has the same meaning +# as an already-supported one. The compiler will handle aliasing, emitting +# an appropriate informational message whenever an alias fires. +# +# 3. List it in the standard table. You almost certainly do *not* want +# to do this -- the capabilities in that one, and their order, have been +# carefully chosen to be SVr4-binary-compatible when they're written out +# as a terminfo object, and breaking this would be bad. It is up to the ncurses +# library what to do with the terminfo data after it is read in. +# +# 4. List it in the aliases table with an IGNORE target field. If you +# do this, the capability will be ignored on input (though the user will +# get a warning message about it). +# +# 5. List it in the extensions table. If you do this, the compiler will +# silently accept the capability, but the curses library proper will never +# see it (because it won't be written out as part of the terminfo object +# format). It is up to you what you have the compiler do with it. +# +# There are two opposite reasons to choose option 5. One is when you want +# to eat the capability silently and discard it when doing translations +# to terminfo with tic -I. Some very old obsolete BSD caps like :kn: are +# in this class. Nothing will ever use them again. +# +# More usually, you want the compiler to try to deduce something from the +# capability value that it can use to translate it into your output format. +# You'll need to write custom code, probably in postprocess_termcap() or +# postprocess_terminfo(), to handle the translation. +# +# CONTROLLING ENTRY LENGTH +# +# Notes on specific elisions made to fit translations within 1023 bytes: +# +# Machines with IBM PC-like keyboards want to be able to define the following +# keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap- +# only environments for End or Home-Down), key_dc, and key_ic. This is also +# the set of keys the `joe' editor will be upset if it can't see. So don't +# trim those out of the set to be translated to termcap, or various users of +# the termcap file will become irate. +# +# It might look tempting to leave those long init strings out of translations. +# We can't do it (yet); 4.4BSD tput and tset use them. +# +# We retain the sgr capability in translation in spite of the fact that neither +# 4.4BSD nor GNU Emacs uses it, because (a) some entry naming distinctions are +# hard to understand without it, and (b) the entries in which it is long tend +# to be older types that don't use up a lot of string space on function keys. +# The tic(1) translation code will complain and elide it if it makes a critical +# difference (there is special code in tic to recognize this situation). +# +# Yes, BSD tset(1) uses hpa. We elide hpa/vpa anyway because the motion +# optimizer in BSD curses didn't use them. This omission seems to be the +# single most effective one, it shortened the resolved length of all thirteen +# problem entries in the 9.9.0 version of the terminfo master below critical. +# +# It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap +# translations go back over critical if we do this. As 4.4BSD curses fades +# into history and GNU termcap's application base shrinks towards being GNU +# Emacs only, we'll probably elide out some BSD-only capabilities in order +# to buy space for non-essentials Emacs is still using. Capabilities high +# on that hit list: rc, sc, uc. +# +# FORMATTING THE TABLES +# +# We manually specify a (minimum) column width for the capability name +# and terminfo code columns in the tables to achieve a consistent +# arrangement; as used here, tbl(1) cannot know the width required by +# one table's data while formatting another's. +# +# The longest capability names (C variables) are +# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at +# 25n), and the longest terminfo code is "setcolor" (8n). +# +# The tables are a tight fit on traditional man(7) implementations that +# use a line length of 65n, and the "Description" column has little room +# within which the formatter can make breaking or adjustment decisions. +# (MKterminfo.sh causes such columns to be formatted in tbl(1) text +# blocks.) Words like "micro_..._address" and "parm_..._micro" don't +# break. Reducing the inter-column gaps to 2 ens gives them enough +# room. --GBR +# +############################################################################# +# +# STANDARD CAPABILITIES +# +#%Tables of capabilities +#%.I \%ncurses +#%recognizes in a +#%.I \%term\%info +#%terminal type description and available to +#%.IR \%term\%info -using +#%code follow. +#%.bP +#%The capability name identifies the symbol by which the programmer +#%using the +#%.I \%term\%info +#%API accesses the capability. +#%.bP +#%The TI +#%.RI ( \%term\%info ) +#%code is the short name used by a person composing or updating a +#%terminal type entry. +#%.IP +#%Whenever possible, +#%these codes are the same as or similar to those of the ANSI X3.64-1979 +#%standard +#%(now superseded by ECMA-48, +#%which uses identical or very similar names). +#%Semantics are also intended to match those of the specification. +#%.IP +#%.I \%term\%info +#%codes have no hard length limit, +#%but +#%.I \%ncurses +#%maintains an informal one of 5 characters to keep them short and to +#%allow the tabs in the source file +#%.I Caps +#%to line up nicely. +#%(Some standard codes exceed this limit regardless.) +#%.bP +#%The TC +#%.RI ( termcap ) +#%code is that used by the corresponding API of +#%.IR \%ncurses . +#%(Some capabilities are new, +#%and have names that BSD +#%.I termcap +#%did not originate.) +#%.bP +#%The description field attempts to convey the capability's semantics. +#%.PP +#%The description field employs a handful of notations. +#%.TP +#%.B (P) +#%indicates that padding may be specified. +#%.TP +#%.B (P*) +#%indicates that padding may vary in proportion to the number of output +#%lines affected. +#%.TP +#%.BI # i +#%indicates the +#%.IR i th +#%parameter of a string capability; +#%the programmer should pass the string to \fB\%tparm\fP(3X) with the +#%parameters listed. +#%.IP +#%If the description lists no parameters, +#%passing the string to \fB\%tparm\fP(3X) may produce unexpected +#%behavior, +#%for instance if the string contains percent signs. +#%. +#%.br +#%.if n .ne 4v +#%.if t .ne 3v +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Boolean Capability Name TI TC Description +#%_ +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 definable windows +# The following were introduced by SVr3.2's color support. +# https://github.com/ryanwoodsmall/oldsysv/blob/\ +# e68293af91e2dc39f5f29c20d7e429f9e0cabc75/\ +# sysvr3/32/usr/src/lib/libcurses/screen/caps#L64 +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 +#%.PP +#%. +#%The following numeric capabilities are present in the SVr4.0 term structure, +#%but are not yet documented in the man page. +#%They came in with SVr4's printer support. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 keypad transmit mode +keypad_xmit smkx str ks - - YBCGE enter keypad 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 (not in BSD \fItermcap\fP) +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 +# +# 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.PP +#%. +#%The following string capabilities are present in the SVr4.0 term structure, +#%but were originally not documented in the man page. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 rectangular 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 +#%.TE +#%.PP +#%. +#%The XSI Curses standard added these hardcopy capabilities. +#%They were used in some post-4.1 versions of System V curses, +#%e.g., Solaris 2.5 and IRIX 6.x. +#%Except for \fBYI\fP, the \fBncurses\fR termcap names for them are invented. +#%According to the XSI Curses standard, they have no termcap names. +#%If your compiled terminfo entries use these, +#%they may not be binary-compatible with System V terminfo +#%entries after SVr4.1; beware! +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 YI - - ----- Set page length to #1 hundredth of an inch (some implementations use sL for termcap). +#%.TE +# +# The magic token below tells the tic compiler-generator code that all the caps +# past it should be ignored (not written out) when dumping terminfo objects. It +# also tells the man page table generator not to pass through following lines +# This means we can have obsolete capabilities and pseudo-capabilities that are +# recognized for termcap or terminfo compilation, but not output. +# +# %%-STOP-HERE-%% +# +# Don't move this casually! In fact, don't move it at all unless you're +# either doing it to add System V or XPG4 extensions, or have decided you +# don't care about SVr4 binary compatibility. +# +############################################################################# +# +# TERMCAP EXTENSION CAPABILITIES +# +# The capabilities below are either obsolete or extensions on certain systems. +# They are not used by SVR4 terminfo. Some are used by captoinfo to translate +# termcap sources; the rest are listed for completeness, and in case somebody +# cares about them enough to hack in code that will translate them into +# terminfo capabilities. +# +# The first part of the list is from Ross Ridge's `mytinfo' package +# (comp.sources.unix, volume 26); the variable names and terminfo names (as +# well as the termcap codes) match his list. +# +# This group of codes is not marked obsolete in 4.4BSD, but have no direct +# terminfo equivalents. The rs capability is specially translated to terminfo +# r2, and vice versa, if an entry does not already have an r2. Similarly, +# i2 is translated to r3 if there is no r3 (because SV terminfo maps is to i2). +# 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 +# +# 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 +# +# 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 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 +# +# The following comments describe capnames so ancient that I believe no +# software uses them any longer. Some of these have to go because they +# clash with terminfo names in ways that cannot be resolved by type +# information. +# +# These mytinfo codes are not used in the 4.4BSD curses code. They are +# marked obsolete in the 4.4BSD manual pages. +# +# There is one conflict with terminfo; ma is in both. This conflict is +# resolved by type information. +# +# The `ko' capability is translated by special code. It should contain a +# comma-separated list of capabilities for which there are corresponding keys. +# The `kn' code is accepted but ignored. +# +# The `ma' capability was a 4.0BSD feature used by vi version 2. +# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh. +# Besides being obsolete, that interpretation conflicts with max_attributes. +# +# Here is a description of memory_lock_above and memory_unlock: +# "You can 'freeze' data on the screen by turning on Memory Lock in a line of +# text. All lines above the cursor's current line become locked in place on +# the screen. Then enter data normally. When the screen fills up, any +# further data entered forces the first line of unfrozen line text to scroll +# under the frozen data. Lines scrolled off the screen are inserted into +# memory immediately preceding the first frozen line." (from the HP 700/96 +# User's manual). VT100/ANSI memory lock set is \E[>2h, reset is \E[>2l. +# +# 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 motion-keys for vi version 2 +# 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 is 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 +# +# 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 +# +# 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 +# +# The mytinfo capabilities end here. +# +# XENIX extensions: +# +# Xenix defined its own set of forms-drawing capabilities: +# +# cap IBM ASCII description ACS ASCII +# --- ----------- -------------------- ------------- ------ +# G1 191 \277 M-? single upper right ACS_URCORNER +# G2 218 \332 M-Z single upper left ACS_ULCORNER +# G3 192 \300 M-@ single lower left ACS_LLCORNER +# G4 217 \331 M-Y single lower right ACS_LRCORNER +# G5 187 \273 M-; double upper right +# G6 201 \311 M-I double upper left +# G7 200 \310 M-H double lower left +# G8 188 \274 M-< double lower right +# GC 197 \305 M-E single intersection ACS_PLUS _ _ +# GD 194 \302 M-B single down-tick ACS_TTEE | +# GH 196 \304 M-D single horizontal line ACS_HLINE +# GL 180 \264 M-4 single left tick ACS_RTEE -| +# GR 195 \303 M-C single right tick ACS_LTEE |- +# GU 193 \301 M-A single up tick ACS_BTEE _|_ +# GV 179 \263 M-3 single vertical line ACS_VLINE +# Gc 206 \316 M-N double intersection +# Gd 203 \313 M-K double down tick +# Gh 205 \315 M-M double horizontal line +# Gl 204 \204 M-L double left tick +# Gr 185 \271 M-9 double right tick +# Gu 202 \312 M-J double up tick +# Gv 186 \272 M-: double vertical line +# +# The compiler will translate the single-line caps and discard the others +# (via IGNORE aliases further down). We don't want to do normal pad +# translation on these, they're often single-character printable ASCII +# strings that happen to be numerics. There's awk code in parametrized.sh +# 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 +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# (see Caps-ncurses for the complete set of comments) +# +memory_lock meml str ml - - ----K lock memory above cursor +memory_unlock memu str mu - - ----K unlock memory +box_chars_1 box1 str bx - - ----K box characters primary set +############################################################################# diff --git a/ncurses/include/Caps-ncurses b/ncurses/include/Caps-ncurses new file mode 100644 index 0000000000..6e0457f213 --- /dev/null +++ b/ncurses/include/Caps-ncurses @@ -0,0 +1,481 @@ +############################################################################## +# Copyright 2019-2022,2023 Thomas E. Dickey # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# $Id: Caps-ncurses,v 1.15 2023/10/28 21:55:47 tom Exp $ +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# This section is all comments (selected lines are copied/uncommented into +# specific "Caps" files). The section describes what capabilities need to be +# squeezed out to get down to the XSI Curses standard set. They are flagged +# with K. +# +# HP extensions +# +# These extensions follow ptr_non (replacing everything after it) in HP +# terminfo files. Except for memory_lock and memory_unlock, they are +# functionally identical to SVr4 extensions, but they make the binary format +# different. Grrr.... +# +#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 +# +# These extensions follow ptr_non (replacing everything after it) in IBM +# terminfo files. +# +# The places in the box[12] capabilities correspond to acsc characters, here is +# the mapping: +# +# box1[0] = ACS_ULCORNER +# box1[1] = ACS_HLINE +# box1[2] = ACS_URCORNER +# box1[3] = ACS_VLINE +# box1[4] = ACS_LRCORNER +# box1[5] = ACS_LLCORNER +# box1[6] = ACS_TTEE +# box1[7] = ACS_RTEE +# box1[8] = ACS_BTEE +# box1[9] = ACS_LTEE +# box1[10] = ACS_PLUS +# +# 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 +# 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 +# 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 +# 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 +# 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 +# +############################################################################# +# +# ALIAS DECLARATIONS +# +# Here we set up aliases for translating extensions into standard terminfo. +# +#---------------------------------- Termcap aliases ------------------------- +# +# BSD aliases: +# +# This is a common error in many termcap files. We'll get notified during +# translation when this (or any other alias) fires. +# +capalias sb sr BSD scroll text down +# +# AT&T extensions: +# +# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of +# nonstandard capabilities. Its signature is the KM capability, used to name +# some sort of keymap file. EE, BO, CI, CV, XS, DS, FL and FE are in this +# set. Comments in the original, and a little cross-checking with other AT&T +# documentation, seem to establish the following mappings: +# +capalias BO mr AT&T enter_reverse_mode +capalias CI vi AT&T cursor_invisible +capalias CV ve AT&T cursor_normal +capalias DS mh AT&T enter_dim_mode +#capalias EE me AT&T exit_attribute_mode +capalias FE LF AT&T label_on +capalias FL LO AT&T label_off +capalias XS mk AT&T enter_secure_mode +# +# We comment out EE because the conflicting XENIX EE is more common in +# old entries. +# +# XENIX extensions: +# +# These are the ones we know how to translate directly: +# +capalias EE mh XENIX exit_attribute_mode +capalias GE ae XENIX exit_alt_charset_mode +capalias GS as XENIX enter_alt_charset_mode +capalias CF vi XENIX cursor_invis +capalias CO ve XENIX cursor_normal +capalias EN @7 XENIX key_end +capalias HM kh XENIX key_home +capalias LD kL XENIX key_dl +capalias PD kN XENIX key_npage +capalias PN po XENIX prtr_off +capalias PS pf XENIX prtr_on +capalias PU kP XENIX key_ppage +capalias RT @8 XENIX kent +capalias UP ku XENIX kcuu1 +capalias G6 IGNORE XENIX double-ACS_ULCORNER +capalias G7 IGNORE XENIX double-ACS_LLCORNER +capalias G5 IGNORE XENIX double-ACS_URCORNER +capalias G8 IGNORE XENIX double-ACS_LRCORNER +capalias Gr IGNORE XENIX double-ACS_LTEE +capalias Gr IGNORE XENIX double-ACS_RTEE +capalias Gu IGNORE XENIX double-ACS_BTEE +capalias Gd IGNORE XENIX double ACS_TTEE +capalias Gh IGNORE XENIX double-ACS_HLINE +capalias Gv IGNORE XENIX double-ACS_VLINE +capalias Gc IGNORE XENIX double-ACS_PLUS +capalias GG IGNORE XENIX acs-glitch +# +# IBM extensions: +# +capalias kq %1 IBM key_help +# +# Iris extensions: +# +capalias HS mh IRIS enter_dim_mode +# +# Tektronix extensions: +# +capalias KA k; Tek key_f10 +capalias KB F1 Tek key_f11 +capalias KC F2 Tek key_f12 +capalias KD F3 Tek key_f13 +capalias KE F4 Tek key_f14 +capalias KF F5 Tek key_f15 +capalias BC Sb Tek set_background +capalias FC Sf Tek set_foreground +# +# There are also the following: +# +# XENIX XENIX variable name name clash with terminfo? +# ----- ------------------- ------------------------- +# CL key_char_left +# CR key_char_right +# CW key_change_window +# HP ?? +# LF key_linefeed label_off +# NU key_next_unlocked_cell +# PL ?? +# PR ?? +# RC key_recalc remove_clock +# RF key_toggle_ref req_for_input +# WL key_word_left +# WR key_word_right +# +# If you know what any of the question-marked ones mean, please tell us. +# +#--------------------------------- Terminfo aliases ------------------------ +# +# IBM extensions: +# +infoalias font0 s0ds IBM set0_des_seq +infoalias font1 s1ds IBM set1_des_seq +infoalias font2 s2ds IBM set2_des_seq +infoalias font3 s3ds IBM set3_des_seq +infoalias kbtab kcbt IBM key_backtab +infoalias ksel kslt IBM key_select +# +# Some others are identical to SVr4/XPG4 capabilities, in particular: +# kcmd, kend, khlp, and kf11...kf63. +# +############################################################################# +# This is a table of ncurses user-definable capabilities which applications +# developers may have used. ncurses may use the table to check consistency of +# types/parameters. Applications may have defined others (such as screen's +# LP and NF), but where a standard capability is available, those alternatives +# are not listed here. +# +used_by ncurses +userdef CO num n number of indexed colors overlaying RGB space +userdef E3 str - clears the terminal's scrollback buffer. +userdef NQ bool - terminal does not support query/response +userdef RGB bool - use direct colors with 1/3 of color-pair bits per color. +userdef RGB num n use direct colors with given number of bits per color. +userdef RGB str - use direct colors with given bit-layout. +userdef TS str - like "tsl", but uses no parameter. +userdef U8 num n terminal does/does not support VT100 SI/SO when processing UTF-8 encoding. +userdef XM str n initialize alternate xterm mouse mode +userdef grbom str - disable real bold (not intensity bright) mode. +userdef gsbom str - enable real bold (not intensity bright) mode. +userdef xm str - mouse response, no parameters +userdef xm str n mouse response, p1 = y-ordinate +userdef xm str nn mouse response, p2 = x-ordinate +userdef xm str nnn mouse response, p3 = button +userdef xm str nnns mouse response, p4 = state, e.g., pressed or released +userdef xm str nnnsn mouse response, p5 = y-ordinate starting region +userdef xm str nnnsnn mouse response, p6 = x-ordinate starting region +userdef xm str nnnsnnn mouse response, p7 = y-ordinate ending region +userdef xm str nnnsnnnn mouse response, p8 = x-ordinate ending region +# +used_by mintty +userdef Rmol str - remove overline-mode +userdef Smol str - set overline-mode +userdef blink2 str - turn on rapid blinking +userdef norm str - turn off bold and half-bright mode +userdef opaq str - turn off blank mode +userdef setal str n set underline-color +userdef smul2 str - begin double underline mode +# +used_by screen +userdef AN bool - turn on autonuke. +userdef AX bool - understands ANSI set default fg/bg color (\E[39m / \E[49m). +userdef C0 str - use the string as a conversion table for font '0', like acsc. +userdef C8 bool - terminal shows bold as high-intensity colors. +userdef CE str - switch cursor-keys back to normal mode. +userdef CS str - switch cursor-keys to application mode. +userdef E0 str - switch charset 'G0' back to standard charset. Default is '\E(B'. +userdef G0 bool - terminal can deal with ISO 2022 font selection sequences. +userdef KJ str s set the encoding of the terminal. +userdef OL num n set the screen program's output buffer limit. +userdef S0 str s switch charset 'G0' to the specified charset. Default is '\E(%.'. +userdef TF bool - add missing capabilities to screen's termcap/info entry. (Set by default). +userdef WS str nn resize display. This capability has the desired width and height as arguments. SunView(tm) example: '\E[8;%d;%dt'. +userdef XC str s describe a translation of characters to strings depending on the current font. +userdef XT bool - terminal understands special xterm sequences (OSC, mouse tracking). +userdef Z0 str - change width to 132 columns. +userdef Z1 str - change width to 80 columns. +# +used_by tmux +userdef Cr str - restore the default cursor color. +userdef Cs str s set the cursor color. +userdef Csr str n change the cursor style, overriding Ss. +userdef Ms str ss store the current buffer in the host terminal's selection (clipboard). +userdef Se str - reset the cursor style to the terminal initial state. +userdef Smulx str n modify the appearance of underlines in VTE. +userdef Ss str n change the cursor style. +userdef rmxx str - reset ECMA-48 strikeout/crossed-out attributes. +userdef smxx str - set ECMA-48 strikeout/crossed-out attributes. +# +used_by vim +userdef BD str - disables bracketed paste +userdef BE str - enables bracketed paste +userdef PE str - is sent after pasted text +userdef PS str - is sent before pasted text +userdef RV str - report terminal secondary device attributes +userdef XR str - report terminal version as a free-format string. +userdef XF bool - terminal supports xterm focus in/out +userdef fd str - disable xterm focus-events +userdef fe str - enable xterm focus-events +userdef rv str - response to RV, regular expression +userdef xr str - response to XR, regular expression +# +used_by xterm +userdef csl str - clear status line +userdef kDC3 str - alt delete-character +userdef kDC4 str - shift+alt delete-character +userdef kDC5 str - control delete-character +userdef kDC6 str - shift+control delete-character +userdef kDC7 str - alt+control delete-character +userdef kDN str - shift down-cursor +userdef kDN3 str - alt down-cursor +userdef kDN4 str - shift+alt down-cursor +userdef kDN5 str - control down-cursor +userdef kDN6 str - shift+control down-cursor +userdef kDN7 str - alt+control down-cursor +userdef kEND3 str - alt end +userdef kEND4 str - shift+alt end +userdef kEND5 str - control end +userdef kEND6 str - shift+control end +userdef kEND7 str - alt+control end +userdef kHOM3 str - alt home +userdef kHOM4 str - shift+alt home +userdef kHOM5 str - control home +userdef kHOM6 str - shift+control home +userdef kHOM7 str - alt+control home +userdef kIC3 str - alt insert-character +userdef kIC4 str - shift+alt insert-character +userdef kIC5 str - control insert-character +userdef kIC6 str - shift+control insert-character +userdef kIC7 str - alt+control insert-character +userdef kLFT3 str - alt left-cursor +userdef kLFT4 str - shift+alt left-cursor +userdef kLFT5 str - control left-cursor +userdef kLFT6 str - shift+control left-cursor +userdef kLFT7 str - alt+control left-cursor +userdef kNXT3 str - alt next +userdef kNXT4 str - shift+alt next +userdef kNXT5 str - control next +userdef kNXT6 str - shift+control next +userdef kNXT7 str - alt+control next +userdef kPRV3 str - alt previous +userdef kPRV4 str - shift+alt previous +userdef kPRV5 str - control previous +userdef kPRV6 str - shift+control previous +userdef kPRV7 str - alt+control previous +userdef kRIT3 str - alt right-cursor +userdef kRIT4 str - shift+alt right-cursor +userdef kRIT5 str - control right-cursor +userdef kRIT6 str - shift+control right-cursor +userdef kRIT7 str - alt+control right-cursor +userdef kUP str - shift up-cursor +userdef kUP3 str - alt up-cursor +userdef kUP4 str - shift+alt up-cursor +userdef kUP5 str - control up-cursor +userdef kUP6 str - shift+control up-cursor +userdef kUP7 str - alt+control up-cursor +userdef ka2 str - vt220-keypad extensions +userdef kb1 str - vt220-keypad extensions +userdef kb3 str - vt220-keypad extensions +userdef kc2 str - vt220-keypad extensions +userdef kxIN str - mouse response on focus-in +userdef kxOUT str - mouse response on focus-out +############################################################################# diff --git a/ncurses/include/Caps.aix4 b/ncurses/include/Caps.aix4 new file mode 100644 index 0000000000..059de989ac --- /dev/null +++ b/ncurses/include/Caps.aix4 @@ -0,0 +1,1129 @@ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2001-2015,2016 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# $Id: Caps.aix4,v 1.30 2025/11/12 01:27:41 tom Exp $ +# +# This is an adaptation of ncurses' termcap/terminfo capability table, which +# is designed to align with AIX 4.x's terminfo. +# +# This table is used to generate initializers for tables that drive tic, +# infocmp, and the library compilation code used to support the termcap +# compatibility hack. It is also used to generate the tabular portion of the +# terminfo(5) man page; lines beginning with `#%' are passed through to become +# the terminfo table. +# +# This file has three major sections; a standard-capabilities table, two +# extension-capability tables, and a section of aliases declarations. +# The first two have the same format, as follows: +# +# FILE FORMAT +# +# Column 1: terminfo variable name +# Column 2: terminfo capability name +# Column 3: capability type (Boolean, numeric, or string) +# Column 4: termcap capability name +# 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 8: capability description +# +# 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 is there to help the terminfo maintainer avoid emitting +# termcap entry translations that are more than 1023 bytes long (and tank a +# lot of old termcap-using programs). The codes read as follows: +# B = mentioned in the BSD man page for 4.4BSD curses +# C = used by the 4.4BSD curses library +# G = mentioned in the documentation for GNU termcap +# E = used by GNU Emacs +# K = remove this terminfo capability when translating to standard format +# The important codes are C and E. A cap with C or E should be preserved in +# 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 +# an asterisk (*). +# +# The aliases section has the following format: +# +# Column 1: either `capalias' or `infoalias' +# Column 2: name to be aliased +# Column 3: what name it should translate to. The name IGNORE means it +# should be discarded with a warning message. +# Column 4: name of the extension set (used for compiler warning messages) +# Column 5: capability description (usually an associated terminfo variable) +# +# HANDLING TERMCAP AND TERMINFO EXTENSIONS +# +# There are basically five different ways to handle termcap and terminfo +# extensions: +# +# 1. Don't list the capname here, or list it but comment it out (the latter +# is preferable; someone might want to handle it in the future). If you do +# this, the capability will be treated as unknown and raise a warning from +# the compiler. +# +# 2. Alias it. This is appropriate if the capability has the same meaning +# as an already-supported one. The compiler will handle aliasing, emitting +# an appropriate informational message whenever an alias fires. +# +# 3. List it in the standard table. You almost certainly do *not* want +# to do this -- the capabilities in that one, and their order, have been +# carefully chosen to be SVr4-binary-compatible when they're written out +# as a terminfo object, and breaking this would be bad. It is up to the ncurses +# library what to do with the terminfo data after it is read in. +# +# 4. List it in the aliases table with an IGNORE target field. If you +# do this, the capability will be ignored on input (though the user will +# get a warning message about it). +# +# 5. List it in the extensions table. If you do this, the compiler will +# silently accept the capability, but the curses library proper will never +# see it (because it won't be written out as part of the terminfo object +# format). It is up to you what you have the compiler do with it. +# +# There are two opposite reasons to choose option 5. One is when you want +# to eat the capability silently and discard it when doing translations +# to terminfo with tic -I. Some very old obsolete BSD caps like :kn: are +# in this class. Nothing will ever use them again. +# +# More usually, you want the compiler to try to deduce something from the +# capability value that it can use to translate it into your output format. +# You'll need to write custom code, probably in postprocess_termcap() or +# postprocess_terminfo(), to handle the translation. +# +# CONTROLLING ENTRY LENGTH +# +# Notes on specific elisions made to fit translations within 1023 bytes: +# +# Machines with IBM PC-like keyboards want to be able to define the following +# keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap- +# only environments for End or Home-Down), key_dc, and key_ic. This is also +# the set of keys the `joe' editor will be upset if it can't see. So don't +# trim those out of the set to be translated to termcap, or various users of +# the termcap file will become irate. +# +# It might look tempting to leave those long init strings out of translations. +# We can't do it (yet); 4.4BSD tput and tset use them. +# +# We retain the sgr capability in translation in spite of the fact that neither +# 4.4BSD nor GNU Emacs uses it, because (a) some entry naming distinctions are +# hard to understand without it, and (b) the entries in which it is long tend +# to be older types that don't use up a lot of string space on function keys. +# The tic(1) translation code will complain and elide it if it makes a critical +# difference (there is special code in tic to recognize this situation). +# +# Yes, BSD tset(1) uses hpa. We elide hpa/vpa anyway because the motion +# optimizer in BSD curses didn't use them. This omission seems to be the +# single most effective one, it shortened the resolved length of all thirteen +# problem entries in the 9.9.0 version of the terminfo master below critical. +# +# It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap +# translations go back over critical if we do this. As 4.4BSD curses fades +# into history and GNU termcap's application base shrinks towards being GNU +# Emacs only, we'll probably elide out some BSD-only capabilities in order +# to buy space for non-essentials Emacs is still using. Capabilities high +# on that hit list: rc, sc, uc. +# +# FORMATTING THE TABLES +# +# We manually specify a (minimum) column width for the capability name +# and terminfo code columns in the tables to achieve a consistent +# arrangement; as used here, tbl(1) cannot know the width required by +# one table's data while formatting another's. +# +# The longest capability names (C variables) are +# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at +# 25n), and the longest terminfo code is "setcolor" (8n). +# +# The tables are a tight fit on traditional man(7) implementations that +# use a line length of 65n, and the "Description" column has little room +# within which the formatter can make breaking or adjustment decisions. +# Words like "micro_..._address" and "parm_..._micro" don't break. +# Reducing the inter-column gaps to 2 ens gives them enough room. --GBR +# +############################################################################# +# +# STANDARD CAPABILITIES +# +#%Tables of capabilities +#%.I \%ncurses +#%recognizes in a +#%.I \%term\%info +#%terminal type description and available to +#%.IR \%term\%info -using +#%code follow. +#%.bP +#%The capability name identifies the symbol by which the programmer +#%using the +#%.I \%term\%info +#%API accesses the capability. +#%.bP +#%The TI +#%.RI ( \%term\%info ) +#%code is the short name used by a person composing or updating a +#%terminal type entry. +#%.IP +#%Whenever possible, +#%these codes are the same as or similar to those of the ANSI X3.64-1979 +#%standard +#%(now superseded by ECMA-48, +#%which uses identical or very similar names). +#%Semantics are also intended to match those of the specification. +#%.IP +#%.I \%term\%info +#%codes have no hard length limit, +#%but +#%.I \%ncurses +#%maintains an informal one of 5 characters to keep them short and to +#%allow the tabs in the source file +#%.I Caps +#%to line up nicely. +#%(Some standard codes exceed this limit regardless.) +#%.bP +#%The TC +#%.RI ( termcap ) +#%code is that used by the corresponding API of +#%.IR \%ncurses . +#%(Some capabilities are new, +#%and have names that BSD +#%.I termcap +#%did not originate.) +#%.bP +#%The description field attempts to convey the capability's semantics. +#%.PP +#%The description field employs a handful of notations. +#%.TP +#%.B (P) +#%indicates that padding may be specified. +#%.TP +#%.B (P*) +#%indicates that padding may vary in proportion to the number of output +#%lines affected. +#%.TP +#%.BI # i +#%indicates the +#%.IR i th +#%parameter of a string capability; +#%the programmer should pass the string to \fB\%tparm\fP(3X) with the +#%parameters listed. +#%.IP +#%If the description lists no parameters, +#%passing the string to \fB\%tparm\fP(3X) may produce unexpected +#%behavior, +#%for instance if the string contains percent signs. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Boolean Capability Name TI TC Description +#%_ +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 definable 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 cannot be used with colors +#%.TE +#%.PP +#%. +#%The following numeric capabilities are present in the SVr4.0 term structure, +#%but are not yet documented in the man page. +#%They came in with SVr4's printer support. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +# +# IBM extensions +# +# These extensions follow ptr_non (replacing everything after it) in IBM +# terminfo files. +# +# The places in the box[12] capabilities correspond to acsc characters, here is +# the mapping: +# +# box1[0] = ACS_ULCORNER +# box1[1] = ACS_HLINE +# box1[2] = ACS_URCORNER +# box1[3] = ACS_VLINE +# box1[4] = ACS_LRCORNER +# box1[5] = ACS_LLCORNER +# box1[6] = ACS_TTEE +# box1[7] = ACS_RTEE +# box1[8] = ACS_BTEE +# box1[9] = ACS_LTEE +# box1[10] = ACS_PLUS +# +# 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 - - ----K select font 0 +font_1 font1 str f1 - - ----K select font 1 +font_2 font2 str f2 - - ----K select font 2 +font_3 font3 str f3 - - ----K 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 kO - - ----K backtab key +key_do kdo str ki - - ----K do request key +key_command kcmd str @4 - - ----K command-request key +key_command_pane kcpn str kW - - ----K command-pane key +key_end kend str @7 KEY_END 0550 ----- end key +key_help khlp str %1 - - ----- help key +key_newline knl str kn - - ----K newline key +key_next_pane knpn str kv - - ----K next-pane key +key_prev_cmd kpcmd 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_aix 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 +key_smap_in6 kmpf6 str Kr - - ----K special mapped key 6 input +key_smap_out6 kmpt6 str KR - - ----K special mapped key 6 output +key_smap_in7 kmpf7 str Ks - - ----K special mapped key 7 input +key_smap_out7 kmpt7 str KS - - ----K special mapped key 7 output +key_smap_in8 kmpf8 str Kt - - ----K special mapped key 8 input +key_smap_out8 kmpt8 str KT - - ----K special mapped key 8 output +key_smap_in9 kmpf9 str Ku - - ----K special mapped key 9 input +key_smap_out9 kmpt9 str KU - - ----K special mapped key 9 output +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 S0 - - ----K special function key 10 +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +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 +# +# SVr4 capabilities resume here. Note that key_end is in the IBM-extensions. +# +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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) +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 (not in BSD \fItermcap\fP) +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 +# +# 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.PP +#%. +#%The following string capabilities are present in the SVr4.0 term structure, +#%but were originally not documented in the man page. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 rectangular 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 +#%.TE +#%.PP +#%. +#%The XSI Curses standard added these hardcopy capabilities. +#%They were used in some post-4.1 versions of System V curses, +#%e.g., Solaris 2.5 and IRIX 6.x. +#%Except for \fBYI\fP, the \fBncurses\fR termcap names for them are invented. +#%According to the XSI Curses standard, they have no termcap names. +#%If your compiled terminfo entries use these, +#%they may not be binary-compatible with System V terminfo +#%entries after SVr4.1; beware! +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +#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 YI - - ----- Set page length to #1 hundredth of an inch (some implementations use sL for termcap). +#%.TE +# +# The magic token below tells the tic compiler-generator code that all the caps +# past it should be ignored (not written out) when dumping terminfo objects. It +# also tells the man page table generator not to pass through following lines +# This means we can have obsolete capabilities and pseudo-capabilities that are +# recognized for termcap or terminfo compilation, but not output. +# +# %%-STOP-HERE-%% +# +# Don't move this casually! In fact, don't move it at all unless you're +# either doing it to add System V or XPG4 extensions, or have decided you +# don't care about SVr4 binary compatibility. +# +############################################################################# +# +# TERMCAP EXTENSION CAPABILITIES +# +# The capabilities below are either obsolete or extensions on certain systems. +# They are not used by SVR4 terminfo. Some are used by captoinfo to translate +# termcap sources; the rest are listed for completeness, and in case somebody +# cares about them enough to hack in code that will translate them into +# terminfo capabilities. +# +# The first part of the list is from Ross Ridge's `mytinfo' package +# (comp.sources.unix, volume 26); the variable names and terminfo names (as +# well as the termcap codes) match his list. +# +# This group of codes is not marked obsolete in 4.4BSD, but have no direct +# terminfo equivalents. The rs capability is specially translated to terminfo +# r2, and vice versa, if an entry does not already have an r2. Similarly, +# i2 is translated to r3 if there is no r3 (because SV terminfo maps is to i2). +# 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 +# +# 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 +# +# 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 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 +# +# The following comments describe capnames so ancient that I believe no +# software uses them any longer. Some of these have to go because they +# clash with terminfo names in ways that cannot be resolved by type +# information. +# +# These mytinfo codes are not used in the 4.4BSD curses code. They are +# marked obsolete in the 4.4BSD manual pages. +# +# There is one conflict with terminfo; ma is in both. This conflict is +# resolved by type information. +# +# The `ko' capability is translated by special code. It should contain a +# comma-separated list of capabilities for which there are corresponding keys. +# The `kn' code is accepted but ignored. +# +# The `ma' capability was a 4.0BSD feature used by vi version 2. +# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh. +# Besides being obsolete, that interpretation conflicts with max_attributes. +# +# Here is a description of memory_lock_above and memory_unlock: +# "You can 'freeze' data on the screen by turning on Memory Lock in a line of +# text. All lines above the cursor's current line become locked in place on +# the screen. Then enter data normally. When the screen fills up, any +# further data entered forces the first line of unfrozen line text to scroll +# under the frozen data. Lines scrolled off the screen are inserted into +# memory immediately preceding the first frozen line." (from the HP 700/96 +# User's manual). VT100/ANSI memory lock set is \E[>2h, reset is \E[>2l. +# +# 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 motion-keys for vi version 2 +# 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 is 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 +# +# 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 +# +# 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 +# +# The mytinfo capabilities end here. +# +# XENIX extensions: +# +# Xenix defined its own set of forms-drawing capabilities: +# +# cap IBM ASCII description ACS ASCII +# --- ----------- -------------------- ------------- ------ +# G1 191 \277 M-? single upper right ACS_URCORNER +# G2 218 \332 M-Z single upper left ACS_ULCORNER +# G3 192 \300 M-@ single lower left ACS_LLCORNER +# G4 217 \331 M-Y single lower right ACS_LRCORNER +# G5 187 \273 M-; double upper right +# G6 201 \311 M-I double upper left +# G7 200 \310 M-H double lower left +# G8 188 \274 M-< double lower right +# GC 197 \305 M-E single intersection ACS_PLUS _ _ +# GD 194 \302 M-B single down-tick ACS_TTEE | +# GH 196 \304 M-D single horizontal line ACS_HLINE +# GL 180 \264 M-4 single left tick ACS_RTEE -| +# GR 195 \303 M-C single right tick ACS_LTEE |- +# GU 193 \301 M-A single up tick ACS_BTEE _|_ +# GV 179 \263 M-3 single vertical line ACS_VLINE +# Gc 206 \316 M-N double intersection +# Gd 203 \313 M-K double down tick +# Gh 205 \315 M-M double horizontal line +# Gl 204 \204 M-L double left tick +# Gr 185 \271 M-9 double right tick +# Gu 202 \312 M-J double up tick +# Gv 186 \272 M-: double vertical line +# +# The compiler will translate the single-line caps and discard the others +# (via IGNORE aliases further down). We don't want to do normal pad +# translation on these, they're often single-character printable ASCII +# strings that happen to be numerics. There's awk code in parametrized.sh +# 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 +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# (see Caps-ncurses for the complete set of comments) +# +memory_lock meml str ml - - ----K lock memory above cursor +memory_unlock memu str mu - - ----K unlock memory +# +############################################################################# diff --git a/ncurses/include/Caps.hpux11 b/ncurses/include/Caps.hpux11 new file mode 100644 index 0000000000..8ba19c42b8 --- /dev/null +++ b/ncurses/include/Caps.hpux11 @@ -0,0 +1,1042 @@ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2002-2015,2016 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# $Id: Caps.hpux11,v 1.28 2025/11/12 01:27:41 tom Exp $ +# +# This is an adaptation of ncurses' termcap/terminfo capability table, which +# is designed to align with HPUX 11.x's terminfo. +# +# This table is used to generate initializers for tables that drive tic, +# infocmp, and the library compilation code used to support the termcap +# compatibility hack. It is also used to generate the tabular portion of the +# terminfo(5) man page; lines beginning with `#%' are passed through to become +# the terminfo table. +# +# This file has three major sections; a standard-capabilities table, two +# extension-capability tables, and a section of aliases declarations. +# The first two have the same format, as follows: +# +# FILE FORMAT +# +# Column 1: terminfo variable name +# Column 2: terminfo capability name +# Column 3: capability type (Boolean, numeric, or string) +# Column 4: termcap capability name +# 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 8: capability description +# +# 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 is there to help the terminfo maintainer avoid emitting +# termcap entry translations that are more than 1023 bytes long (and tank a +# lot of old termcap-using programs). The codes read as follows: +# B = mentioned in the BSD man page for 4.4BSD curses +# C = used by the 4.4BSD curses library +# G = mentioned in the documentation for GNU termcap +# E = used by GNU Emacs +# K = remove this terminfo capability when translating to standard format +# The important codes are C and E. A cap with C or E should be preserved in +# 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 +# an asterisk (*). +# +# The aliases section has the following format: +# +# Column 1: either `capalias' or `infoalias' +# Column 2: name to be aliased +# Column 3: what name it should translate to. The name IGNORE means it +# should be discarded with a warning message. +# Column 4: name of the extension set (used for compiler warning messages) +# Column 5: capability description (usually an associated terminfo variable) +# +# HANDLING TERMCAP AND TERMINFO EXTENSIONS +# +# There are basically five different ways to handle termcap and terminfo +# extensions: +# +# 1. Don't list the capname here, or list it but comment it out (the latter +# is preferable; someone might want to handle it in the future). If you do +# this, the capability will be treated as unknown and raise a warning from +# the compiler. +# +# 2. Alias it. This is appropriate if the capability has the same meaning +# as an already-supported one. The compiler will handle aliasing, emitting +# an appropriate informational message whenever an alias fires. +# +# 3. List it in the standard table. You almost certainly do *not* want +# to do this -- the capabilities in that one, and their order, have been +# carefully chosen to be SVr4-binary-compatible when they're written out +# as a terminfo object, and breaking this would be bad. It is up to the ncurses +# library what to do with the terminfo data after it is read in. +# +# 4. List it in the aliases table with an IGNORE target field. If you +# do this, the capability will be ignored on input (though the user will +# get a warning message about it). +# +# 5. List it in the extensions table. If you do this, the compiler will +# silently accept the capability, but the curses library proper will never +# see it (because it won't be written out as part of the terminfo object +# format). It is up to you what you have the compiler do with it. +# +# There are two opposite reasons to choose option 5. One is when you want +# to eat the capability silently and discard it when doing translations +# to terminfo with tic -I. Some very old obsolete BSD caps like :kn: are +# in this class. Nothing will ever use them again. +# +# More usually, you want the compiler to try to deduce something from the +# capability value that it can use to translate it into your output format. +# You'll need to write custom code, probably in postprocess_termcap() or +# postprocess_terminfo(), to handle the translation. +# +# CONTROLLING ENTRY LENGTH +# +# Notes on specific elisions made to fit translations within 1023 bytes: +# +# Machines with IBM PC-like keyboards want to be able to define the following +# keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap- +# only environments for End or Home-Down), key_dc, and key_ic. This is also +# the set of keys the `joe' editor will be upset if it can't see. So don't +# trim those out of the set to be translated to termcap, or various users of +# the termcap file will become irate. +# +# It might look tempting to leave those long init strings out of translations. +# We can't do it (yet); 4.4BSD tput and tset use them. +# +# We retain the sgr capability in translation in spite of the fact that neither +# 4.4BSD nor GNU Emacs uses it, because (a) some entry naming distinctions are +# hard to understand without it, and (b) the entries in which it is long tend +# to be older types that don't use up a lot of string space on function keys. +# The tic(1) translation code will complain and elide it if it makes a critical +# difference (there is special code in tic to recognize this situation). +# +# Yes, BSD tset(1) uses hpa. We elide hpa/vpa anyway because the motion +# optimizer in BSD curses didn't use them. This omission seems to be the +# single most effective one, it shortened the resolved length of all thirteen +# problem entries in the 9.9.0 version of the terminfo master below critical. +# +# It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap +# translations go back over critical if we do this. As 4.4BSD curses fades +# into history and GNU termcap's application base shrinks towards being GNU +# Emacs only, we'll probably elide out some BSD-only capabilities in order +# to buy space for non-essentials Emacs is still using. Capabilities high +# on that hit list: rc, sc, uc. +# +# FORMATTING THE TABLES +# +# We manually specify a (minimum) column width for the capability name +# and terminfo code columns in the tables to achieve a consistent +# arrangement; as used here, tbl(1) cannot know the width required by +# one table's data while formatting another's. +# +# The longest capability names (C variables) are +# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at +# 25n), and the longest terminfo code is "setcolor" (8n). +# +# The tables are a tight fit on traditional man(7) implementations that +# use a line length of 65n, and the "Description" column has little room +# within which the formatter can make breaking or adjustment decisions. +# Words like "micro_..._address" and "parm_..._micro" don't break. +# Reducing the inter-column gaps to 2 ens gives them enough room. --GBR +# +############################################################################# +# +# STANDARD CAPABILITIES +# +#%Tables of capabilities +#%.I \%ncurses +#%recognizes in a +#%.I \%term\%info +#%terminal type description and available to +#%.IR \%term\%info -using +#%code follow. +#%.bP +#%The capability name identifies the symbol by which the programmer +#%using the +#%.I \%term\%info +#%API accesses the capability. +#%.bP +#%The TI +#%.RI ( \%term\%info ) +#%code is the short name used by a person composing or updating a +#%terminal type entry. +#%.IP +#%Whenever possible, +#%these codes are the same as or similar to those of the ANSI X3.64-1979 +#%standard +#%(now superseded by ECMA-48, +#%which uses identical or very similar names). +#%Semantics are also intended to match those of the specification. +#%.IP +#%.I \%term\%info +#%codes have no hard length limit, +#%but +#%.I \%ncurses +#%maintains an informal one of 5 characters to keep them short and to +#%allow the tabs in the source file +#%.I Caps +#%to line up nicely. +#%(Some standard codes exceed this limit regardless.) +#%.bP +#%The TC +#%.RI ( termcap ) +#%code is that used by the corresponding API of +#%.IR \%ncurses . +#%(Some capabilities are new, +#%and have names that BSD +#%.I termcap +#%did not originate.) +#%.bP +#%The description field attempts to convey the capability's semantics. +#%.PP +#%The description field employs a handful of notations. +#%.TP +#%.B (P) +#%indicates that padding may be specified. +#%.TP +#%.B (P*) +#%indicates that padding may vary in proportion to the number of output +#%lines affected. +#%.TP +#%.BI # i +#%indicates the +#%.IR i th +#%parameter of a string capability; +#%the programmer should pass the string to \fB\%tparm\fP(3X) with the +#%parameters listed. +#%.IP +#%If the description lists no parameters, +#%passing the string to \fB\%tparm\fP(3X) may produce unexpected +#%behavior, +#%for instance if the string contains percent signs. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Boolean Capability Name TI TC Description +#%_ +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 +# end Booleans for HPUX 9, 10 (non-color curses) +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 +# end numbers for HPUX 9, 10 (non-color curses) +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 definable 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 cannot be used with colors +#%.TE +#%.PP +#%. +#%The following numeric capabilities are present in the SVr4.0 term structure, +#%but are not yet documented in the man page. +#%They came in with SVr4's printer support. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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_char_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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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. +# +# HPUX defines these if __HP_CURSES_COMPAT is defined: +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 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +# end of strings in HPUX 9 +char_padding rmp str rP - - ----- like ip but when in insert mode +acs_chars acsc str ac - - ----- graphics charset pairs, based on vt100 +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 +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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) +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 (not in BSD \fItermcap\fP) +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 +# +# 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.PP +#%. +#%The following string capabilities are present in the SVr4.0 term structure, +#%but were originally not documented in the man page. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 rectangular 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 +#%.TE +#%.PP +#%. +#%The XSI Curses standard added these hardcopy capabilities. +#%They were used in some post-4.1 versions of System V curses, +#%e.g., Solaris 2.5 and IRIX 6.x. +#%Except for \fBYI\fP, the \fBncurses\fR termcap names for them are invented. +#%According to the XSI Curses standard, they have no termcap names. +#%If your compiled terminfo entries use these, +#%they may not be binary-compatible with System V terminfo +#%entries after SVr4.1; beware! +#%. +#%AIX and Solaris do not provide termcap names for these; HPUX does. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +set_pglen_inch slength str YI - - ----- Set page length to #1 hundredth of an inch (some implementations use sL for termcap). +enter_horizontal_hl_mode ehhlm str Q1 - - ----- Enter horizontal highlight mode +enter_left_hl_mode elhlm str Q2 - - ----- Enter left highlight mode +enter_low_hl_mode elohlm str Q3 - - ----- Enter low highlight mode +enter_right_hl_mode erhlm str Q4 - - ----- Enter right highlight mode +enter_top_hl_mode ethlm str Q5 - - ----- Enter top highlight mode +enter_vertical_hl_mode evhlm str Q6 - - ----- Enter vertical highlight mode +set_a_attributes sgr1 str Q7 - - ----- Define second set of video attributes #1-#6 +exit_horizontal_hl_mode rmhhlm str Q8 - - ----K Exit horizontal highlight mode +exit_left_hl_mode rmlhlm str Q9 - - ----K Exit left highlight mode +exit_low_hl_mode rmlohlm str Qa - - ----K Exit low highlight mode +exit_right_hl_mode rmrhlm str Qb - - ----K Exit right highlight mode +exit_top_hl_mode rmthlm str Qc - - ----K Exit top highlight mode +exit_vertical_hl_mode rmvhlm str Qd - - ----K Exit vertical highlight mode +#%.TE +# +# The magic token below tells the tic compiler-generator code that all the caps +# past it should be ignored (not written out) when dumping terminfo objects. It +# also tells the man page table generator not to pass through following lines +# This means we can have obsolete capabilities and pseudo-capabilities that are +# recognized for termcap or terminfo compilation, but not output. +# +# %%-STOP-HERE-%% +# +# Don't move this casually! In fact, don't move it at all unless you're +# either doing it to add System V or XPG4 extensions, or have decided you +# don't care about SVr4 binary compatibility. +# +############################################################################# +# +# TERMCAP EXTENSION CAPABILITIES +# +# The capabilities below are either obsolete or extensions on certain systems. +# They are not used by SVR4 terminfo. Some are used by captoinfo to translate +# termcap sources; the rest are listed for completeness, and in case somebody +# cares about them enough to hack in code that will translate them into +# terminfo capabilities. +# +# The first part of the list is from Ross Ridge's `mytinfo' package +# (comp.sources.unix, volume 26); the variable names and terminfo names (as +# well as the termcap codes) match his list. +# +# This group of codes is not marked obsolete in 4.4BSD, but have no direct +# terminfo equivalents. The rs capability is specially translated to terminfo +# r2, and vice versa, if an entry does not already have an r2. Similarly, +# i2 is translated to r3 if there is no r3 (because SV terminfo maps is to i2). +# 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 +# +# 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 +# +# 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 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 +# +# The following comments describe capnames so ancient that I believe no +# software uses them any longer. Some of these have to go because they +# clash with terminfo names in ways that cannot be resolved by type +# information. +# +# These mytinfo codes are not used in the 4.4BSD curses code. They are +# marked obsolete in the 4.4BSD manual pages. +# +# There is one conflict with terminfo; ma is in both. This conflict is +# resolved by type information. +# +# The `ko' capability is translated by special code. It should contain a +# comma-separated list of capabilities for which there are corresponding keys. +# The `kn' code is accepted but ignored. +# +# The `ma' capability was a 4.0BSD feature used by vi version 2. +# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh. +# Besides being obsolete, that interpretation conflicts with max_attributes. +# +# Here is a description of memory_lock_above and memory_unlock: +# "You can 'freeze' data on the screen by turning on Memory Lock in a line of +# text. All lines above the cursor's current line become locked in place on +# the screen. Then enter data normally. When the screen fills up, any +# further data entered forces the first line of unfrozen line text to scroll +# under the frozen data. Lines scrolled off the screen are inserted into +# memory immediately preceding the first frozen line." (from the HP 700/96 +# User's manual). VT100/ANSI memory lock set is \E[>2h, reset is \E[>2l. +# +# 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 motion-keys for vi version 2 +# 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 is 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 +# +# 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 +# +# 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 +# +# The mytinfo capabilities end here. +# +# XENIX extensions: +# +# Xenix defined its own set of forms-drawing capabilities: +# +# cap IBM ASCII description ACS ASCII +# --- ----------- -------------------- ------------- ------ +# G1 191 \277 M-? single upper right ACS_URCORNER +# G2 218 \332 M-Z single upper left ACS_ULCORNER +# G3 192 \300 M-@ single lower left ACS_LLCORNER +# G4 217 \331 M-Y single lower right ACS_LRCORNER +# G5 187 \273 M-; double upper right +# G6 201 \311 M-I double upper left +# G7 200 \310 M-H double lower left +# G8 188 \274 M-< double lower right +# GC 197 \305 M-E single intersection ACS_PLUS _ _ +# GD 194 \302 M-B single down-tick ACS_TTEE | +# GH 196 \304 M-D single horizontal line ACS_HLINE +# GL 180 \264 M-4 single left tick ACS_RTEE -| +# GR 195 \303 M-C single right tick ACS_LTEE |- +# GU 193 \301 M-A single up tick ACS_BTEE _|_ +# GV 179 \263 M-3 single vertical line ACS_VLINE +# Gc 206 \316 M-N double intersection +# Gd 203 \313 M-K double down tick +# Gh 205 \315 M-M double horizontal line +# Gl 204 \204 M-L double left tick +# Gr 185 \271 M-9 double right tick +# Gu 202 \312 M-J double up tick +# Gv 186 \272 M-: double vertical line +# +# The compiler will translate the single-line caps and discard the others +# (via IGNORE aliases further down). We don't want to do normal pad +# translation on these, they're often single-character printable ASCII +# strings that happen to be numerics. There's awk code in parametrized.sh +# 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 +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# (see Caps-ncurses for the complete set of comments) +# +box_chars_1 box1 str bx - - ----K box characters primary set +# +############################################################################# diff --git a/ncurses/include/Caps.keys b/ncurses/include/Caps.keys new file mode 100644 index 0000000000..a6b0ced3d9 --- /dev/null +++ b/ncurses/include/Caps.keys @@ -0,0 +1,1119 @@ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2001-2015,2016 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# and: Ilya Zakharevich +# +# $Id: Caps.keys,v 1.27 2025/11/12 01:27:41 tom Exp $ +# +# This is an adaptation of ncurses' termcap/terminfo capability table, which +# is illustrates an experimental extension to describe alt-, shift- and +# control-modifiers applied to function and normal keys, as done on IBM pc's. +# +# This table is used to generate initializers for tables that drive tic, +# infocmp, and the library compilation code used to support the termcap +# compatibility hack. It is also used to generate the tabular portion of the +# terminfo(5) man page; lines beginning with `#%' are passed through to become +# the terminfo table. +# +# This file has three major sections; a standard-capabilities table, two +# extension-capability tables, and a section of aliases declarations. +# The first two have the same format, as follows: +# +# FILE FORMAT +# +# Column 1: terminfo variable name +# Column 2: terminfo capability name +# Column 3: capability type (Boolean, numeric, or string) +# Column 4: termcap capability name +# 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 8: capability description +# +# 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 is there to help the terminfo maintainer avoid emitting +# termcap entry translations that are more than 1023 bytes long (and tank a +# lot of old termcap-using programs). The codes read as follows: +# B = mentioned in the BSD man page for 4.4BSD curses +# C = used by the 4.4BSD curses library +# G = mentioned in the documentation for GNU termcap +# E = used by GNU Emacs +# K = remove this terminfo capability when translating to standard format +# The important codes are C and E. A cap with C or E should be preserved in +# 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 +# an asterisk (*). +# +# The aliases section has the following format: +# +# Column 1: either `capalias' or `infoalias' +# Column 2: name to be aliased +# Column 3: what name it should translate to. The name IGNORE means it +# should be discarded with a warning message. +# Column 4: name of the extension set (used for compiler warning messages) +# Column 5: capability description (usually an associated terminfo variable) +# +# HANDLING TERMCAP AND TERMINFO EXTENSIONS +# +# There are basically five different ways to handle termcap and terminfo +# extensions: +# +# 1. Don't list the capname here, or list it but comment it out (the latter +# is preferable; someone might want to handle it in the future). If you do +# this, the capability will be treated as unknown and raise a warning from +# the compiler. +# +# 2. Alias it. This is appropriate if the capability has the same meaning +# as an already-supported one. The compiler will handle aliasing, emitting +# an appropriate informational message whenever an alias fires. +# +# 3. List it in the standard table. You almost certainly do *not* want +# to do this -- the capabilities in that one, and their order, have been +# carefully chosen to be SVr4-binary-compatible when they're written out +# as a terminfo object, and breaking this would be bad. It is up to the ncurses +# library what to do with the terminfo data after it is read in. +# +# 4. List it in the aliases table with an IGNORE target field. If you +# do this, the capability will be ignored on input (though the user will +# get a warning message about it). +# +# 5. List it in the extensions table. If you do this, the compiler will +# silently accept the capability, but the curses library proper will never +# see it (because it won't be written out as part of the terminfo object +# format). It is up to you what you have the compiler do with it. +# +# There are two opposite reasons to choose option 5. One is when you want +# to eat the capability silently and discard it when doing translations +# to terminfo with tic -I. Some very old obsolete BSD caps like :kn: are +# in this class. Nothing will ever use them again. +# +# More usually, you want the compiler to try to deduce something from the +# capability value that it can use to translate it into your output format. +# You'll need to write custom code, probably in postprocess_termcap() or +# postprocess_terminfo(), to handle the translation. +# +# CONTROLLING ENTRY LENGTH +# +# Notes on specific elisions made to fit translations within 1023 bytes: +# +# Machines with IBM PC-like keyboards want to be able to define the following +# keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap- +# only environments for End or Home-Down), key_dc, and key_ic. This is also +# the set of keys the `joe' editor will be upset if it can't see. So don't +# trim those out of the set to be translated to termcap, or various users of +# the termcap file will become irate. +# +# It might look tempting to leave those long init strings out of translations. +# We can't do it (yet); 4.4BSD tput and tset use them. +# +# We retain the sgr capability in translation in spite of the fact that neither +# 4.4BSD nor GNU Emacs uses it, because (a) some entry naming distinctions are +# hard to understand without it, and (b) the entries in which it is long tend +# to be older types that don't use up a lot of string space on function keys. +# The tic(1) translation code will complain and elide it if it makes a critical +# difference (there is special code in tic to recognize this situation). +# +# Yes, BSD tset(1) uses hpa. We elide hpa/vpa anyway because the motion +# optimizer in BSD curses didn't use them. This omission seems to be the +# single most effective one, it shortened the resolved length of all thirteen +# problem entries in the 9.9.0 version of the terminfo master below critical. +# +# It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap +# translations go back over critical if we do this. As 4.4BSD curses fades +# into history and GNU termcap's application base shrinks towards being GNU +# Emacs only, we'll probably elide out some BSD-only capabilities in order +# to buy space for non-essentials Emacs is still using. Capabilities high +# on that hit list: rc, sc, uc. +# +# FORMATTING THE TABLES +# +# We manually specify a (minimum) column width for the capability name +# and terminfo code columns in the tables to achieve a consistent +# arrangement; as used here, tbl(1) cannot know the width required by +# one table's data while formatting another's. +# +# The longest capability names (C variables) are +# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at +# 25n), and the longest terminfo codes are "setcolor", "kcdelete", +# "kcinsert", "kadelete", and "kcinsert" (8n). +# +# The tables are a tight fit on traditional man(7) implementations that +# use a line length of 65n, and the "Description" column has little room +# within which the formatter can make breaking or adjustment decisions. +# Words like "micro_..._address" and "parm_..._micro" don't break. +# Reducing the inter-column gaps to 2 ens gives them enough room. --GBR +# +############################################################################# +# +# STANDARD CAPABILITIES +# +#%Tables of capabilities +#%.I \%ncurses +#%recognizes in a +#%.I \%term\%info +#%terminal type description and available to +#%.IR \%term\%info -using +#%code follow. +#%.bP +#%The capability name identifies the symbol by which the programmer +#%using the +#%.I \%term\%info +#%API accesses the capability. +#%.bP +#%The TI +#%.RI ( \%term\%info ) +#%code is the short name used by a person composing or updating a +#%terminal type entry. +#%.IP +#%Whenever possible, +#%these codes are the same as or similar to those of the ANSI X3.64-1979 +#%standard +#%(now superseded by ECMA-48, +#%which uses identical or very similar names). +#%Semantics are also intended to match those of the specification. +#%.IP +#%.I \%term\%info +#%codes have no hard length limit, +#%but +#%.I \%ncurses +#%maintains an informal one of 5 characters to keep them short and to +#%allow the tabs in the source file +#%.I Caps +#%to line up nicely. +#%(Some standard codes exceed this limit regardless.) +#%.bP +#%The TC +#%.RI ( termcap ) +#%code is that used by the corresponding API of +#%.IR \%ncurses . +#%(Some capabilities are new, +#%and have names that BSD +#%.I termcap +#%did not originate.) +#%.bP +#%The description field attempts to convey the capability's semantics. +#%.PP +#%The description field employs a handful of notations. +#%.TP +#%.B (P) +#%indicates that padding may be specified. +#%.TP +#%.B (P*) +#%indicates that padding may vary in proportion to the number of output +#%lines affected. +#%.TP +#%.BI # i +#%indicates the +#%.IR i th +#%parameter of a string capability; +#%the programmer should pass the string to \fB\%tparm\fP(3X) with the +#%parameters listed. +#%.IP +#%If the description lists no parameters, +#%passing the string to \fB\%tparm\fP(3X) may produce unexpected +#%behavior, +#%for instance if the string contains percent signs. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Boolean Capability Name TI TC Description +#%_ +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 definable 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 cannot be used with colors +#%.TE +#%.PP +#%. +#%The following numeric capabilities are present in the SVr4.0 term structure, +#%but are not yet documented in the man page. +#%They came in with SVr4's printer support. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 (not in BSD \fItermcap\fP) +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 +# +# NCurses extensions for keys accessible on most PC consoles +# +key_sup kUP str !5 KEY_SUP + ----- shifted up-arrow key +key_sdown kDOWN str !6 KEY_SDOWN + ----- shifted down-arrow key +key_sbackspace kBS str !7 KEY_SBACKSPACE + ----- shifted backspace key +key_c_delete kcdelete str !8 KEY_C_DELETE + ----- control- delete-character key +key_c_end kcend str !9 KEY_C_END + ----- control- end key +key_c_home kchom str !0 KEY_C_HOME + ----- control- home key +key_c_insert kcinsert str !_ KEY_C_INSERT + ----- control- insert-character key +key_c_left kclft str %k KEY_C_LEFT + ----- control- left-arrow key +key_c_next kcnxt str %l KEY_C_NEXT + ----- control- next key +key_c_previous kcprv str %m KEY_C_PREVIOUS + ----- control- previous key +key_c_print kcprt str %n KEY_C_PRINT + ----- control- print key +key_c_right kcrit str %o KEY_C_RIGHT + ----- control- right-arrow key +key_c_backspace kcbs str %p KEY_C_BACKSPACE + ----- control- backspace key +key_c_up kcup str %q KEY_C_UP + ----- control- up-arrow key +key_c_down kcdown str %r KEY_C_DOWN + ----- control- down-arrow key +key_a_delete kadelete str %s KEY_A_DELETE + ----- alt- delete-character key +key_a_end kaend str %t KEY_A_END + ----- alt- end key +key_a_home kahom str %u KEY_A_HOME + ----- alt- home key +key_a_insert kainsert str %v KEY_A_INSERT + ----- alt- insert-character key +key_a_left kalft str %w KEY_A_LEFT + ----- alt- left-arrow key +key_a_next kanxt str %x KEY_A_NEXT + ----- alt- next key +key_a_previous kaprv str %y KEY_A_PREVIOUS + ----- alt- previous key +key_a_print kaprt str %z KEY_A_PRINT + ----- alt- print key +key_a_right karit str %! KEY_A_RIGHT + ----- alt- right-arrow key +key_a_backspace kabs str %@ KEY_A_BACKSPACE + ----- alt- backspace key +key_a_up kaup str %# KEY_A_UP + ----- alt- up-arrow key +key_a_down kadown str %$ KEY_A_DOWN + ----- alt- down-arrow key +key_a_a kaa str $a KEY_A_A + ----- alt- a key +key_a_b kab str $b KEY_A_B + ----- alt- b key +key_a_c kac str $c KEY_A_C + ----- alt- c key +key_a_d kad str $d KEY_A_D + ----- alt- d key +key_a_e kae str $e KEY_A_E + ----- alt- e key +key_a_f kaf str $f KEY_A_F + ----- alt- f key +key_a_g kag str $g KEY_A_G + ----- alt- g key +key_a_h kah str $h KEY_A_H + ----- alt- h key +key_a_i kai str $i KEY_A_I + ----- alt- i key +key_a_j kaj str $j KEY_A_J + ----- alt- j key +key_a_k kak str $k KEY_A_K + ----- alt- k key +key_a_l kal str $l KEY_A_L + ----- alt- l key +key_a_m kam str $m KEY_A_M + ----- alt- m key +key_a_n kan str $n KEY_A_N + ----- alt- n key +key_a_o kao str $o KEY_A_O + ----- alt- o key +key_a_p kap str $p KEY_A_P + ----- alt- p key +key_a_q kaq str $q KEY_A_Q + ----- alt- q key +key_a_r kar str $r KEY_A_R + ----- alt- r key +key_a_s kas str $s KEY_A_S + ----- alt- s key +key_a_t kat str $t KEY_A_T + ----- alt- t key +key_a_u kau str $u KEY_A_U + ----- alt- u key +key_a_v kav str $v KEY_A_V + ----- alt- v key +key_a_w kaw str $w KEY_A_W + ----- alt- w key +key_a_x kax str $x KEY_A_X + ----- alt- x key +key_a_y kay str $y KEY_A_Y + ----- alt- y key +key_a_z kaz str $z KEY_A_Z + ----- alt- z key +key_a_0 ka_0 str $0 KEY_A_0 + ----- alt- 0 key +key_a_1 ka_1 str $1 KEY_A_1 + ----- alt- 1 key +key_a_2 ka_2 str $2 KEY_A_2 + ----- alt- 2 key +key_a_3 ka_3 str $3 KEY_A_3 + ----- alt- 3 key +key_a_4 ka_4 str $4 KEY_A_4 + ----- alt- 4 key +key_a_5 ka_5 str $5 KEY_A_5 + ----- alt- 5 key +key_a_6 ka_6 str $6 KEY_A_6 + ----- alt- 6 key +key_a_7 ka_7 str $7 KEY_A_7 + ----- alt- 7 key +key_a_8 ka_8 str $8 KEY_A_8 + ----- alt- 8 key +key_a_9 ka_9 str $9 KEY_A_9 + ----- alt- 9 key +key_a_backtick ka_bt str $` KEY_A_BACKTICK + ----- alt- ` key +key_a_under ka_und str $_ KEY_A_UNDER + ----- alt- _ key +key_a_equals ka_eq str $= KEY_A_EQUALS + ----- alt- = key +key_a_bar ka_bsl str $| KEY_A_BAR + ----- alt- | key +key_a_lbracker ka_lbr str $[ KEY_A_LBRACKER + ----- alt- [ key +key_a_rbracker ka_rbr str $] KEY_A_RBRACKER + ----- alt- ] key +key_a_semi ka_semi str $; KEY_A_SEMI + ----- alt- ; key +key_a_tick ka_tick str $' KEY_A_TICK + ----- alt- ' key +key_a_comma ka_com str $, KEY_A_COMMA + ----- alt- , key +key_a_dot ka_dot str $. KEY_A_DOT + ----- alt- . key +key_a_question ka_sla str $? KEY_A_QUESTION + ----- alt- ? key +key_a_divide ka_div str $/ KEY_A_DIVIDE + ----- alt- keypad / key +key_a_multiply ka_mul str $* KEY_A_MULTIPLY + ----- alt- keypad * key +key_a_add ka_add str $+ KEY_A_ADD + ----- alt- keypad + key +key_a_subtract ka_sub str $- KEY_A_SUBTRACT + ----- alt- keypad - key +key_a_kenter ka_kent str $< KEY_A_KENTER + ----- alt- keypad enter key +key_a_enter ka_ent str $> KEY_A_ENTER + ----- alt- enter key +key_c_at kcat str %% KEY_C_AT + ----- control- @ key +key_c_divide kcdiv str %/ KEY_C_DIVIDE + ----- control- keypad / key +key_c_multiply kcmul str %* KEY_C_MULTIPLY + ----- control- keypad * key +key_c_add kcadd str %+ KEY_C_ADD + ----- control- keypad + key +key_c_subtract kcsub str %- KEY_C_SUBTRACT + ----- control- keypad - key +# +# 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 +# +# 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.PP +#%. +#%The following string capabilities are present in the SVr4.0 term structure, +#%but were originally not documented in the man page. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 rectangular 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 +#%.TE +#%.PP +#%. +#%The XSI Curses standard added these hardcopy capabilities. +#%They were used in some post-4.1 versions of System V curses, +#%e.g., Solaris 2.5 and IRIX 6.x. +#%Except for \fBYI\fP, the \fBncurses\fR termcap names for them are invented. +#%According to the XSI Curses standard, they have no termcap names. +#%If your compiled terminfo entries use these, +#%they may not be binary-compatible with System V terminfo +#%entries after SVr4.1; beware! +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 YI - - ----- Set page length to #1 hundredth of an inch (some implementations use sL for termcap). +#%.TE +# +# The magic token below tells the tic compiler-generator code that all the caps +# past it should be ignored (not written out) when dumping terminfo objects. It +# also tells the man page table generator not to pass through following lines +# This means we can have obsolete capabilities and pseudo-capabilities that are +# recognized for termcap or terminfo compilation, but not output. +# +# %%-STOP-HERE-%% +# +# Don't move this casually! In fact, don't move it at all unless you're +# either doing it to add System V or XPG4 extensions, or have decided you +# don't care about SVr4 binary compatibility. +# +############################################################################# +# +# TERMCAP EXTENSION CAPABILITIES +# +# The capabilities below are either obsolete or extensions on certain systems. +# They are not used by SVR4 terminfo. Some are used by captoinfo to translate +# termcap sources; the rest are listed for completeness, and in case somebody +# cares about them enough to hack in code that will translate them into +# terminfo capabilities. +# +# The first part of the list is from Ross Ridge's `mytinfo' package +# (comp.sources.unix, volume 26); the variable names and terminfo names (as +# well as the termcap codes) match his list. +# +# This group of codes is not marked obsolete in 4.4BSD, but have no direct +# terminfo equivalents. The rs capability is specially translated to terminfo +# r2, and vice versa, if an entry does not already have an r2. Similarly, +# i2 is translated to r3 if there is no r3 (because SV terminfo maps is to i2). +# 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 +# +# 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 +# +# 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 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 +# +# The following comments describe capnames so ancient that I believe no +# software uses them any longer. Some of these have to go because they +# clash with terminfo names in ways that cannot be resolved by type +# information. +# +# These mytinfo codes are not used in the 4.4BSD curses code. They are +# marked obsolete in the 4.4BSD manual pages. +# +# There is one conflict with terminfo; ma is in both. This conflict is +# resolved by type information. +# +# The `ko' capability is translated by special code. It should contain a +# comma-separated list of capabilities for which there are corresponding keys. +# The `kn' code is accepted but ignored. +# +# The `ma' capability was a 4.0BSD feature used by vi version 2. +# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh. +# Besides being obsolete, that interpretation conflicts with max_attributes. +# +# Here is a description of memory_lock_above and memory_unlock: +# "You can 'freeze' data on the screen by turning on Memory Lock in a line of +# text. All lines above the cursor's current line become locked in place on +# the screen. Then enter data normally. When the screen fills up, any +# further data entered forces the first line of unfrozen line text to scroll +# under the frozen data. Lines scrolled off the screen are inserted into +# memory immediately preceding the first frozen line." (from the HP 700/96 +# User's manual). VT100/ANSI memory lock set is \E[>2h, reset is \E[>2l. +# +# 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 motion-keys for vi version 2 +# 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 is 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 +# +# 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 +# +# 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 +# +# The mytinfo capabilities end here. +# +# XENIX extensions: +# +# Xenix defined its own set of forms-drawing capabilities: +# +# cap IBM ASCII description ACS ASCII +# --- ----------- -------------------- ------------- ------ +# G1 191 \277 M-? single upper right ACS_URCORNER +# G2 218 \332 M-Z single upper left ACS_ULCORNER +# G3 192 \300 M-@ single lower left ACS_LLCORNER +# G4 217 \331 M-Y single lower right ACS_LRCORNER +# G5 187 \273 M-; double upper right +# G6 201 \311 M-I double upper left +# G7 200 \310 M-H double lower left +# G8 188 \274 M-< double lower right +# GC 197 \305 M-E single intersection ACS_PLUS _ _ +# GD 194 \302 M-B single down-tick ACS_TTEE | +# GH 196 \304 M-D single horizontal line ACS_HLINE +# GL 180 \264 M-4 single left tick ACS_RTEE -| +# GR 195 \303 M-C single right tick ACS_LTEE |- +# GU 193 \301 M-A single up tick ACS_BTEE _|_ +# GV 179 \263 M-3 single vertical line ACS_VLINE +# Gc 206 \316 M-N double intersection +# Gd 203 \313 M-K double down tick +# Gh 205 \315 M-M double horizontal line +# Gl 204 \204 M-L double left tick +# Gr 185 \271 M-9 double right tick +# Gu 202 \312 M-J double up tick +# Gv 186 \272 M-: double vertical line +# +# The compiler will translate the single-line caps and discard the others +# (via IGNORE aliases further down). We don't want to do normal pad +# translation on these, they're often single-character printable ASCII +# strings that happen to be numerics. There's awk code in parametrized.sh +# 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 +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# (see Caps-ncurses for the complete set of comments) +# +memory_lock meml str ml - - ----K lock memory above cursor +memory_unlock memu str mu - - ----K unlock memory +box_chars_1 box1 str bx - - ----K box characters primary set +# +############################################################################# diff --git a/ncurses/include/Caps.osf1r5 b/ncurses/include/Caps.osf1r5 new file mode 100644 index 0000000000..382ac85142 --- /dev/null +++ b/ncurses/include/Caps.osf1r5 @@ -0,0 +1,1034 @@ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2002-2015,2016 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# $Id: Caps.osf1r5,v 1.26 2025/11/12 01:27:41 tom Exp $ +# +# This is an adaptation of ncurses' termcap/terminfo capability table, which +# is designed to align with OSF/1 version 5 (Tru64) terminfo. +# +# This table is used to generate initializers for tables that drive tic, +# infocmp, and the library compilation code used to support the termcap +# compatibility hack. It is also used to generate the tabular portion of the +# terminfo(5) man page; lines beginning with `#%' are passed through to become +# the terminfo table. +# +# This file has three major sections; a standard-capabilities table, two +# extension-capability tables, and a section of aliases declarations. +# The first two have the same format, as follows: +# +# FILE FORMAT +# +# Column 1: terminfo variable name +# Column 2: terminfo capability name +# Column 3: capability type (Boolean, numeric, or string) +# Column 4: termcap capability name +# 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 8: capability description +# +# 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 is there to help the terminfo maintainer avoid emitting +# termcap entry translations that are more than 1023 bytes long (and tank a +# lot of old termcap-using programs). The codes read as follows: +# B = mentioned in the BSD man page for 4.4BSD curses +# C = used by the 4.4BSD curses library +# G = mentioned in the documentation for GNU termcap +# E = used by GNU Emacs +# K = remove this terminfo capability when translating to standard format +# The important codes are C and E. A cap with C or E should be preserved in +# 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 +# an asterisk (*). +# +# The aliases section has the following format: +# +# Column 1: either `capalias' or `infoalias' +# Column 2: name to be aliased +# Column 3: what name it should translate to. The name IGNORE means it +# should be discarded with a warning message. +# Column 4: name of the extension set (used for compiler warning messages) +# Column 5: capability description (usually an associated terminfo variable) +# +# HANDLING TERMCAP AND TERMINFO EXTENSIONS +# +# There are basically five different ways to handle termcap and terminfo +# extensions: +# +# 1. Don't list the capname here, or list it but comment it out (the latter +# is preferable; someone might want to handle it in the future). If you do +# this, the capability will be treated as unknown and raise a warning from +# the compiler. +# +# 2. Alias it. This is appropriate if the capability has the same meaning +# as an already-supported one. The compiler will handle aliasing, emitting +# an appropriate informational message whenever an alias fires. +# +# 3. List it in the standard table. You almost certainly do *not* want +# to do this -- the capabilities in that one, and their order, have been +# carefully chosen to be SVr4-binary-compatible when they're written out +# as a terminfo object, and breaking this would be bad. It is up to the ncurses +# library what to do with the terminfo data after it is read in. +# +# 4. List it in the aliases table with an IGNORE target field. If you +# do this, the capability will be ignored on input (though the user will +# get a warning message about it). +# +# 5. List it in the extensions table. If you do this, the compiler will +# silently accept the capability, but the curses library proper will never +# see it (because it won't be written out as part of the terminfo object +# format). It is up to you what you have the compiler do with it. +# +# There are two opposite reasons to choose option 5. One is when you want +# to eat the capability silently and discard it when doing translations +# to terminfo with tic -I. Some very old obsolete BSD caps like :kn: are +# in this class. Nothing will ever use them again. +# +# More usually, you want the compiler to try to deduce something from the +# capability value that it can use to translate it into your output format. +# You'll need to write custom code, probably in postprocess_termcap() or +# postprocess_terminfo(), to handle the translation. +# +# CONTROLLING ENTRY LENGTH +# +# Notes on specific elisions made to fit translations within 1023 bytes: +# +# Machines with IBM PC-like keyboards want to be able to define the following +# keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap- +# only environments for End or Home-Down), key_dc, and key_ic. This is also +# the set of keys the `joe' editor will be upset if it can't see. So don't +# trim those out of the set to be translated to termcap, or various users of +# the termcap file will become irate. +# +# It might look tempting to leave those long init strings out of translations. +# We can't do it (yet); 4.4BSD tput and tset use them. +# +# We retain the sgr capability in translation in spite of the fact that neither +# 4.4BSD nor GNU Emacs uses it, because (a) some entry naming distinctions are +# hard to understand without it, and (b) the entries in which it is long tend +# to be older types that don't use up a lot of string space on function keys. +# The tic(1) translation code will complain and elide it if it makes a critical +# difference (there is special code in tic to recognize this situation). +# +# Yes, BSD tset(1) uses hpa. We elide hpa/vpa anyway because the motion +# optimizer in BSD curses didn't use them. This omission seems to be the +# single most effective one, it shortened the resolved length of all thirteen +# problem entries in the 9.9.0 version of the terminfo master below critical. +# +# It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap +# translations go back over critical if we do this. As 4.4BSD curses fades +# into history and GNU termcap's application base shrinks towards being GNU +# Emacs only, we'll probably elide out some BSD-only capabilities in order +# to buy space for non-essentials Emacs is still using. Capabilities high +# on that hit list: rc, sc, uc. +# +# FORMATTING THE TABLES +# +# We manually specify a (minimum) column width for the capability name +# and terminfo code columns in the tables to achieve a consistent +# arrangement; as used here, tbl(1) cannot know the width required by +# one table's data while formatting another's. +# +# The longest capability names (C variables) are +# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at +# 25n), and the longest terminfo code is "setcolor" (8n). +# +# The tables are a tight fit on traditional man(7) implementations that +# use a line length of 65n, and the "Description" column has little room +# within which the formatter can make breaking or adjustment decisions. +# Words like "micro_..._address" and "parm_..._micro" don't break. +# Reducing the inter-column gaps to 2 ens gives them enough room. --GBR +# +############################################################################# +# +# STANDARD CAPABILITIES +# +#%Tables of capabilities +#%.I \%ncurses +#%recognizes in a +#%.I \%term\%info +#%terminal type description and available to +#%.IR \%term\%info -using +#%code follow. +#%.bP +#%The capability name identifies the symbol by which the programmer +#%using the +#%.I \%term\%info +#%API accesses the capability. +#%.bP +#%The TI +#%.RI ( \%term\%info ) +#%code is the short name used by a person composing or updating a +#%terminal type entry. +#%.IP +#%Whenever possible, +#%these codes are the same as or similar to those of the ANSI X3.64-1979 +#%standard +#%(now superseded by ECMA-48, +#%which uses identical or very similar names). +#%Semantics are also intended to match those of the specification. +#%.IP +#%.I \%term\%info +#%codes have no hard length limit, +#%but +#%.I \%ncurses +#%maintains an informal one of 5 characters to keep them short and to +#%allow the tabs in the source file +#%.I Caps +#%to line up nicely. +#%(Some standard codes exceed this limit regardless.) +#%.bP +#%The TC +#%.RI ( termcap ) +#%code is that used by the corresponding API of +#%.IR \%ncurses . +#%(Some capabilities are new, +#%and have names that BSD +#%.I termcap +#%did not originate.) +#%.bP +#%The description field attempts to convey the capability's semantics. +#%.PP +#%The description field employs a handful of notations. +#%.TP +#%.B (P) +#%indicates that padding may be specified. +#%.TP +#%.B (P*) +#%indicates that padding may vary in proportion to the number of output +#%lines affected. +#%.TP +#%.BI # i +#%indicates the +#%.IR i th +#%parameter of a string capability; +#%the programmer should pass the string to \fB\%tparm\fP(3X) with the +#%parameters listed. +#%.IP +#%If the description lists no parameters, +#%passing the string to \fB\%tparm\fP(3X) may produce unexpected +#%behavior, +#%for instance if the string contains percent signs. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Boolean Capability Name TI TC Description +#%_ +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 +back_color_erase bce bool ut - - ----- screen erased with background color +can_change ccc bool cc - - ----- terminal can re-define existing colors +col_addr_glitch xhpa bool YA - - ----- only positive motion for hpa/mhpa caps +cpi_changes_res cpix bool YF - - ----- changing character pitch changes resolution +cr_cancels_micro_mode crxm bool YB - - ----- using cr turns off micro mode +hard_cursor chts bool HC - - ----- cursor is hard to see +has_print_wheel daisy bool YC - - ----- printer needs operator to change character set +hue_lightness_saturation hls bool hl - - ----- terminal uses only HLS color notation (Tektronix) +lpi_changes_res lpix bool YG - - ----- changing line pitch changes resolution +needs_xon_xoff nxon bool nx - - ----- padding will not work, xon/xoff required +non_dest_scroll_region ndscr bool ND - - ----- scrolling region is non-destructive +non_rev_rmcup nrrmc bool NR - - ----- smcup does not reverse rmcup +no_pad_char npc bool NP - - ----- pad character does not exist +prtr_silent mc5i bool 5i - - ----- printer will not echo on screen +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 +#%.TE +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 +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 +buttons btns num BT - - ----- number of buttons on mouse +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 +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 +max_colors colors num Co - - ----- maximum number of colors on screen +max_micro_address maddr num Yd - - ----- maximum value in micro_..._address +max_micro_jump mjump num Ye - - ----- maximum value in parm_..._micro +max_pairs pairs num pa - - ----- maximum number of color-pairs on the screen +maximum_windows wnum num MW - - ----- maximum number of definable windows +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 +no_color_video ncv num NC - - ----- video attributes that can not be used with colors +number_of_pins npins num Yh - - ----- numbers of pins in print-head +num_labels nlab num Nl - - ----- number of labels on screen +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 +#%.TE +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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. +# +# OSF1 differences start here, based on IBM version: +# +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 kc KEY_COMMAND 0545 ----- command key +key_command_pane kcpn str kW - - ----K command-pane key +key_end kend str @7 KEY_END 0550 ----- end key +key_help khlp str %1 KEY_HELP 0553 ----- 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 kslt str *6 KEY_SELECT 0601 ----- 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 are described in +# the Tru64 manual pages. +key_smap_in6 kmpf6 str Kr - - ----K special mapped key 6 input +key_smap_out6 kmpt6 str KR - - ----K special mapped key 6 output +key_smap_in7 kmpf7 str Ks - - ----K special mapped key 7 input +key_smap_out7 kmpt7 str KS - - ----K special mapped key 7 output +key_smap_in8 kmpf8 str Kt - - ----K special mapped key 8 input +key_smap_out8 kmpt8 str KT - - ----K special mapped key 8 output +key_smap_in9 kmpf9 str Ku - - ----K special mapped key 9 input +key_smap_out9 kmpt9 str KU - - ----K special mapped key 9 output +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 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_action kact str kJ KEY_ACTION 0541 ----K sent by action key +acs_chars acsc str ac - - ----- graphics charset pairs, based on vt100 +alt_scancode_esc scesa str S8 - - ----- Alternate escape for scancode emulation +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 +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 +char_padding rmp str rP - - ----- like ip but when in insert mode +char_set_names csnm str Zy - - ----- Produce #1'th item from list of character set names +clear_margins mgc str MC - - ----- clear right and left soft margins +clr_bol el1 str cb - - ----- Clear to beginning of line +code_set_init csin str ci - - ----- Init sequence for multiple codesets +color_names colornm str Yw - - ----- Give name for color #1 +create_window cwin str CW - - ----- define a window #1 from #2,#3 to #4,#5 +define_bit_image_region defbi str Yx - - ----- Define rectangular bit image region +define_char defc str ZE - - ----- Define a character #1, #2 dots wide, descender #3 +device_type devt str dv - - ----- Indicate language/codeset support +dial_phone dial str DI - - ----- dial number #1 +display_clock dclk str DK - - ----- display clock +display_pc_char dispc str S1 - - ----- Display PC character #1 +ena_acs enacs str eA - - ----- enable alternate char set +end_bit_image_region endbi str Yy - - ----- End a bit-image region +enter_am_mode smam str SA - - ----- turn on automatic margins +enter_doublewide_mode swidm str ZF - - ----- Enter double-wide mode +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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_pc_charset_mode smpch str S2 - - ----- Enter PC character display mode +enter_scancode_mode smsc str S4 - - ----- Enter PC scancode 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 +enter_xon_mode smxon str SX - - ----- turn on xon/xoff handshaking +exit_am_mode rmam str RA - - ----- turn off automatic margins +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_pc_charset_mode rmpch str S3 - - ----- Exit PC character display mode +exit_scancode_mode rmsc str S5 - - ----- Exit PC scancode 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 +exit_xon_mode rmxon str RX - - ----- turn off xon/xoff handshaking +fixed_pause pause str PA - - ----- pause for 2-3 seconds +flash_hook hook str fh - - ----- flash switch hook +get_mouse getm str Gm - - ----- Curses should get button events, parameter #1 not documented. +goto_window wingo str WG - - ----- go to window #1 +hangup hup str HU - - ----- hang-up phone +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) +key_beg kbeg str @1 KEY_BEG 0542 ----- begin key +key_btab kcbt str kB KEY_BTAB 0632 ----- back-tab key +key_cancel kcan str @2 KEY_CANCEL 0543 ----- cancel key +key_close kclo str @3 KEY_CLOSE 0544 ----- close key +key_copy kcpy str @5 KEY_COPY 0546 ----- copy key +key_create kcrt str @6 KEY_CREATE 0547 ----- create key +key_enter kent str @8 KEY_ENTER 0527 ----- enter/send key +key_exit kext str @9 KEY_EXIT 0551 ----- exit 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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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 +key_find kfnd str @0 KEY_FIND 0552 ----- find key +key_mark kmrk str %2 KEY_MARK 0554 ----- mark key +key_message kmsg str %3 KEY_MESSAGE 0555 ----- message key +key_mouse kmous str Km KEY_MOUSE 0631 ----- Mouse event has occurred +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 +#%.TE +#%.TS +#%center; +#%Lbw(25n)2 Lbw(8n)2 Lb2 Lw(17n)x. +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_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 +key_suspend kspd str &7 KEY_SUSPEND 0627 ----- suspend key +key_undo kund str &8 KEY_UNDO 0630 ----- undo key +label_format fln str Lf - - ----- label format +label_off rmln str LF - - ----- turn off soft labels +label_on smln str LO - - ----- turn on soft labels +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 +mouse_info minfo str Mi - - ----- Mouse status information +order_of_pins porder str Ze - - ----- Match software bits to print-head pins +orig_colors oc str oc - - ----- Set all color pairs to the original ones +orig_pair op str op - - ----- Set default pair to its original value +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 +pc_term_options pctrm str S6 - - ----- PC terminal options +pkey_plab pfxl str xl - - ----- Program function key #1 to type string #2 and show string #3 +plab_norm pln str pn - - ----- program label #1 to show string #2 +pulse pulse str PU - - ----- select pulse dialing +quick_dial qdial str QD - - ----- dial number #1 without checking +req_for_input rfi str RF - - ----- send next input char (for ptys) +req_mouse_pos reqmp str RQ - - ----- Request mouse position +remove_clock rmclk str RC - - ----- remove clock +scancode_escape scesc str S7 - - ----- Escape for scancode emulation +select_char_set scs str Zj - - ----- Select character set, #1 +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_a_background setab str AB - - ----- Set background color to #1, using ANSI escape +set_a_foreground setaf str AF - - ----- Set foreground color to #1, using ANSI escape +set_background setb str Sb - - ----- Set background color #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_clock sclk str SC - - ----- set clock, #1 hrs #2 mins #3 secs +set_color_band setcolor str Yz - - ----- Change to ribbon color #1 +set_color_pair scp str sp - - ----- Set current color pair to #1 +set_foreground setf str Sf - - ----- Set foreground color #1 +set_left_margin smgl str ML - - ----- set left soft margin at current column (not in BSD \fItermcap\fP) +set_left_margin_parm smglp str Zm - - ----- Set left (right) margin at column #1 +set_lr_margin smglr str ML - - ----- Set both left and right margins to #1, #2. (ML is not in BSD termcap). +set_page_length slines str YZ - - ----- Set page length to #1 lines +set_right_margin smgr str MR - - ----- set right soft margin at current column +set_right_margin_parm smgrp str Zn - - ----- Set right margin at column #1 +set_tb_margin smgtb str MT - - ----- Sets both top and bottom margins to #1, #2 +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 +tone tone str TO - - ----- select touch tone dialing +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 +wait_tone wait str WA - - ----- wait for dial-tone +xoff_character xoffc str XF - - ----- XOFF character +xon_character xonc str XN - - ----- XON character +zero_motion zerom str Zx - - ----- No motion for subsequent character +set_pglen_inch slength str YI - - ----- Set page length to #1 hundredth of an inch (some implementations use sL for termcap). +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 +# +# +# +# %%-STOP-HERE-%% +# +# Don't move this casually! In fact, don't move it at all unless you're +# either doing it to add System V or XPG4 extensions, or have decided you +# don't care about SVr4 binary compatibility. +# +############################################################################# +# +# TERMCAP EXTENSION CAPABILITIES +# +# The capabilities below are either obsolete or extensions on certain systems. +# They are not used by SVR4 terminfo. Some are used by captoinfo to translate +# termcap sources; the rest are listed for completeness, and in case somebody +# cares about them enough to hack in code that will translate them into +# terminfo capabilities. +# +# The first part of the list is from Ross Ridge's `mytinfo' package +# (comp.sources.unix, volume 26); the variable names and terminfo names (as +# well as the termcap codes) match his list. +# +# This group of codes is not marked obsolete in 4.4BSD, but have no direct +# terminfo equivalents. The rs capability is specially translated to terminfo +# r2, and vice versa, if an entry does not already have an r2. Similarly, +# i2 is translated to r3 if there is no r3 (because SV terminfo maps is to i2). +# 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 +# +# 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 +# +# 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 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 +# +# The following comments describe capnames so ancient that I believe no +# software uses them any longer. Some of these have to go because they +# clash with terminfo names in ways that cannot be resolved by type +# information. +# +# These mytinfo codes are not used in the 4.4BSD curses code. They are +# marked obsolete in the 4.4BSD manual pages. +# +# There is one conflict with terminfo; ma is in both. This conflict is +# resolved by type information. +# +# The `ko' capability is translated by special code. It should contain a +# comma-separated list of capabilities for which there are corresponding keys. +# The `kn' code is accepted but ignored. +# +# The `ma' capability was a 4.0BSD feature used by vi version 2. +# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh. +# Besides being obsolete, that interpretation conflicts with max_attributes. +# +# Here is a description of memory_lock_above and memory_unlock: +# "You can 'freeze' data on the screen by turning on Memory Lock in a line of +# text. All lines above the cursor's current line become locked in place on +# the screen. Then enter data normally. When the screen fills up, any +# further data entered forces the first line of unfrozen line text to scroll +# under the frozen data. Lines scrolled off the screen are inserted into +# memory immediately preceding the first frozen line." (from the HP 700/96 +# User's manual). VT100/ANSI memory lock set is \E[>2h, reset is \E[>2l. +# +# 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 motion-keys for vi version 2 +# 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 is 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 +# +# 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 +# +# 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 +# +# The mytinfo capabilities end here. +# +# XENIX extensions: +# +# Xenix defined its own set of forms-drawing capabilities: +# +# cap IBM ASCII description ACS ASCII +# --- ----------- -------------------- ------------- ------ +# G1 191 \277 M-? single upper right ACS_URCORNER +# G2 218 \332 M-Z single upper left ACS_ULCORNER +# G3 192 \300 M-@ single lower left ACS_LLCORNER +# G4 217 \331 M-Y single lower right ACS_LRCORNER +# G5 187 \273 M-; double upper right +# G6 201 \311 M-I double upper left +# G7 200 \310 M-H double lower left +# G8 188 \274 M-< double lower right +# GC 197 \305 M-E single intersection ACS_PLUS _ _ +# GD 194 \302 M-B single down-tick ACS_TTEE | +# GH 196 \304 M-D single horizontal line ACS_HLINE +# GL 180 \264 M-4 single left tick ACS_RTEE -| +# GR 195 \303 M-C single right tick ACS_LTEE |- +# GU 193 \301 M-A single up tick ACS_BTEE _|_ +# GV 179 \263 M-3 single vertical line ACS_VLINE +# Gc 206 \316 M-N double intersection +# Gd 203 \313 M-K double down tick +# Gh 205 \315 M-M double horizontal line +# Gl 204 \204 M-L double left tick +# Gr 185 \271 M-9 double right tick +# Gu 202 \312 M-J double up tick +# Gv 186 \272 M-: double vertical line +# +# The compiler will translate the single-line caps and discard the others +# (via IGNORE aliases further down). We don't want to do normal pad +# translation on these, they're often single-character printable ASCII +# strings that happen to be numerics. There's awk code in parametrized.sh +# 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 +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# (see Caps-ncurses for the complete set of comments) +# +memory_lock meml str ml - - ----K lock memory above cursor +memory_unlock memu str mu - - ----K unlock memory +# +############################################################################# diff --git a/ncurses/include/Caps.uwin b/ncurses/include/Caps.uwin new file mode 100644 index 0000000000..e5732d48cc --- /dev/null +++ b/ncurses/include/Caps.uwin @@ -0,0 +1,840 @@ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2001-2015,2016 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# $Id: Caps.uwin,v 1.25 2025/11/12 01:06:36 Branden.Robinson Exp $ +# +# This is an adaptation of ncurses' termcap/terminfo capability table, which +# is designed to align with U/Win's terminfo. +# +# This table is used to generate initializers for tables that drive tic, +# infocmp, and the library compilation code used to support the termcap +# compatibility hack. It is also used to generate the tabular portion of the +# terminfo(5) man page; lines beginning with `#%' are passed through to become +# the terminfo table. +# +# This file has three major sections; a standard-capabilities table, two +# extension-capability tables, and a section of aliases declarations. +# The first two have the same format, as follows: +# +# FILE FORMAT +# +# Column 1: terminfo variable name +# Column 2: terminfo capability name +# Column 3: capability type (Boolean, numeric, or string) +# Column 4: termcap capability name +# 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 8: capability description +# +# 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 is there to help the terminfo maintainer avoid emitting +# termcap entry translations that are more than 1023 bytes long (and tank a +# lot of old termcap-using programs). The codes read as follows: +# B = mentioned in the BSD man page for 4.4BSD curses +# C = used by the 4.4BSD curses library +# G = mentioned in the documentation for GNU termcap +# E = used by GNU Emacs +# K = remove this terminfo capability when translating to standard format +# The important codes are C and E. A cap with C or E should be preserved in +# 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 +# an asterisk (*). +# +# The aliases section has the following format: +# +# Column 1: either `capalias' or `infoalias' +# Column 2: name to be aliased +# Column 3: what name it should translate to. The name IGNORE means it +# should be discarded with a warning message. +# Column 4: name of the extension set (used for compiler warning messages) +# Column 5: capability description (usually an associated terminfo variable) +# +# HANDLING TERMCAP AND TERMINFO EXTENSIONS +# +# There are basically five different ways to handle termcap and terminfo +# extensions: +# +# 1. Don't list the capname here, or list it but comment it out (the latter +# is preferable; someone might want to handle it in the future). If you do +# this, the capability will be treated as unknown and raise a warning from +# the compiler. +# +# 2. Alias it. This is appropriate if the capability has the same meaning +# as an already-supported one. The compiler will handle aliasing, emitting +# an appropriate informational message whenever an alias fires. +# +# 3. List it in the standard table. You almost certainly do *not* want +# to do this -- the capabilities in that one, and their order, have been +# carefully chosen to be SVr4-binary-compatible when they're written out +# as a terminfo object, and breaking this would be bad. It is up to the ncurses +# library what to do with the terminfo data after it is read in. +# +# 4. List it in the aliases table with an IGNORE target field. If you +# do this, the capability will be ignored on input (though the user will +# get a warning message about it). +# +# 5. List it in the extensions table. If you do this, the compiler will +# silently accept the capability, but the curses library proper will never +# see it (because it won't be written out as part of the terminfo object +# format). It is up to you what you have the compiler do with it. +# +# There are two opposite reasons to choose option 5. One is when you want +# to eat the capability silently and discard it when doing translations +# to terminfo with tic -I. Some very old obsolete BSD caps like :kn: are +# in this class. Nothing will ever use them again. +# +# More usually, you want the compiler to try to deduce something from the +# capability value that it can use to translate it into your output format. +# You'll need to write custom code, probably in postprocess_termcap() or +# postprocess_terminfo(), to handle the translation. +# +# CONTROLLING ENTRY LENGTH +# +# Notes on specific elisions made to fit translations within 1023 bytes: +# +# Machines with IBM PC-like keyboards want to be able to define the following +# keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap- +# only environments for End or Home-Down), key_dc, and key_ic. This is also +# the set of keys the `joe' editor will be upset if it can't see. So don't +# trim those out of the set to be translated to termcap, or various users of +# the termcap file will become irate. +# +# It might look tempting to leave those long init strings out of translations. +# We can't do it (yet); 4.4BSD tput and tset use them. +# +# We retain the sgr capability in translation in spite of the fact that neither +# 4.4BSD nor GNU Emacs uses it, because (a) some entry naming distinctions are +# hard to understand without it, and (b) the entries in which it is long tend +# to be older types that don't use up a lot of string space on function keys. +# The tic(1) translation code will complain and elide it if it makes a critical +# difference (there is special code in tic to recognize this situation). +# +# Yes, BSD tset(1) uses hpa. We elide hpa/vpa anyway because the motion +# optimizer in BSD curses didn't use them. This omission seems to be the +# single most effective one, it shortened the resolved length of all thirteen +# problem entries in the 9.9.0 version of the terminfo master below critical. +# +# It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap +# translations go back over critical if we do this. As 4.4BSD curses fades +# into history and GNU termcap's application base shrinks towards being GNU +# Emacs only, we'll probably elide out some BSD-only capabilities in order +# to buy space for non-essentials Emacs is still using. Capabilities high +# on that hit list: rc, sc, uc. +# +# FORMATTING THE TABLES +# +# We manually specify a (minimum) column width for the capability name +# and terminfo code columns in the tables to achieve a consistent +# arrangement; as used here, tbl(1) cannot know the width required by +# one table's data while formatting another's. +# +# The longest capability names (C variable) is +# "hue_lightness_saturation" (24n), and the longest terminfo code is +# "colornm" (7n). +# +# The tables are a tight fit on traditional man(7) implementations that +# use a line length of 65n, and the "Description" column has little room +# within which the formatter can make breaking or adjustment decisions. +# Words like "micro_..._address" and "parm_..._micro" don't break. +# Reducing the inter-column gaps to 2 ens gives them enough room. --GBR +# +############################################################################# +# +# STANDARD CAPABILITIES +# +#%Tables of capabilities +#%.I \%ncurses +#%recognizes in a +#%.I \%term\%info +#%terminal type description and available to +#%.IR \%term\%info -using +#%code follow. +#%.bP +#%The capability name identifies the symbol by which the programmer +#%using the +#%.I \%term\%info +#%API accesses the capability. +#%.bP +#%The TI +#%.RI ( \%term\%info ) +#%code is the short name used by a person composing or updating a +#%terminal type entry. +#%.IP +#%Whenever possible, +#%these codes are the same as or similar to those of the ANSI X3.64-1979 +#%standard +#%(now superseded by ECMA-48, +#%which uses identical or very similar names). +#%Semantics are also intended to match those of the specification. +#%.IP +#%.I \%term\%info +#%codes have no hard length limit, +#%but +#%.I \%ncurses +#%maintains an informal one of 5 characters to keep them short and to +#%allow the tabs in the source file +#%.I Caps +#%to line up nicely. +#%(Some standard codes exceed this limit regardless.) +#%.bP +#%The TC +#%.RI ( termcap ) +#%code is that used by the corresponding API of +#%.IR \%ncurses . +#%(Some capabilities are new, +#%and have names that BSD +#%.I termcap +#%did not originate.) +#%.bP +#%The description field attempts to convey the capability's semantics. +#%.PP +#%The description field employs a handful of notations. +#%.TP +#%.B (P) +#%indicates that padding may be specified. +#%.TP +#%.B (P*) +#%indicates that padding may vary in proportion to the number of output +#%lines affected. +#%.TP +#%.BI # i +#%indicates the +#%.IR i th +#%parameter of a string capability; +#%the programmer should pass the string to \fB\%tparm\fP(3X) with the +#%parameters listed. +#%.IP +#%If the description lists no parameters, +#%passing the string to \fB\%tparm\fP(3X) may produce unexpected +#%behavior, +#%for instance if the string contains percent signs. +#%. +#%.PP +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Boolean Capability Name TI TC Description +#%_ +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 +back_color_erase bce bool ut - - ----- screen erased with background color +can_change ccc bool cc - - ----- terminal can re-define existing colors +hue_lightness_saturation hls bool hl - - ----- terminal uses only HLS color notation (Tektronix) +#%.TE +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%Numeric Capability Name TI TC Description +#%_ +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 +buttons btns num BT - - ----- number of buttons on mouse +#max_attributes ma num ma - - YBC-- maximum combined attributes terminal can handle +#maximum_windows wnum num MW - - ----- maximum number of definable 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 cannot be used with colors +#%.TE +#%.PP +#%. +#%.TS +#%center; +#%Lb Cb S Lb +#%Lb Lb Lb Lb +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +#%\& Code \& +#%String Capability Name TI TC Description +#%_ +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 +#%.TE +#%.TS +#%center; +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +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 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 +#%.TE +#%.TS +#%center; +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +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 +#%.TE +#%.TS +#%center; +#%Lbw(24n)2 Lbw(7n)2 Lb2 Lw(17n)x. +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 (not in BSD \fItermcap\fP) +set_right_margin smgr str MR - - ----- set right soft margin at current column +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 +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. +release_mouse relm str Rm - - ----- Curses should release the mouse */ +color_names colornm str Yw - - ----- Give name for color #1 +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) +orig_colors oc str oc - - ----- Set all color pairs to the original ones +orig_pair op str op - - ----- Set default pair to its original value +set_a_background setab str AB - - ----- Set background color to #1, using ANSI escape +set_a_foreground setaf str AF - - ----- Set foreground color to #1, using ANSI escape +set_background setb str Sb - - ----- Set background color #1 +set_color_pair scp str sp - - ----- Set current color pair to #1 +set_foreground setf str Sf - - ----- Set foreground color #1 +#%.TE +#% +# The magic token below tells the tic compiler-generator code that all the caps +# past it should be ignored (not written out) when dumping terminfo objects. It +# also tells the man page table generator not to pass through following lines +# This means we can have obsolete capabilities and pseudo-capabilities that are +# recognized for termcap or terminfo compilation, but not output. +# +# %%-STOP-HERE-%% +# +# Don't move this casually! In fact, don't move it at all unless you're +# either doing it to add System V or XPG4 extensions, or have decided you +# don't care about SVr4 binary compatibility. +# +############################################################################# +# +# TERMCAP EXTENSION CAPABILITIES +# +# The capabilities below are either obsolete or extensions on certain systems. +# They are not used by SVR4 terminfo. Some are used by captoinfo to translate +# termcap sources; the rest are listed for completeness, and in case somebody +# cares about them enough to hack in code that will translate them into +# terminfo capabilities. +# +# The first part of the list is from Ross Ridge's `mytinfo' package +# (comp.sources.unix, volume 26); the variable names and terminfo names (as +# well as the termcap codes) match his list. +# +# This group of codes is not marked obsolete in 4.4BSD, but have no direct +# terminfo equivalents. The rs capability is specially translated to terminfo +# r2, and vice versa, if an entry does not already have an r2. Similarly, +# i2 is translated to r3 if there is no r3 (because SV terminfo maps is to i2). +# 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 +# +# 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 +# +# 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 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 +# +# The following comments describe capnames so ancient that I believe no +# software uses them any longer. Some of these have to go because they +# clash with terminfo names in ways that cannot be resolved by type +# information. +# +# These mytinfo codes are not used in the 4.4BSD curses code. They are +# marked obsolete in the 4.4BSD manual pages. +# +# There is one conflict with terminfo; ma is in both. This conflict is +# resolved by type information. +# +# The `ko' capability is translated by special code. It should contain a +# comma-separated list of capabilities for which there are corresponding keys. +# The `kn' code is accepted but ignored. +# +# The `ma' capability was a 4.0BSD feature used by vi version 2. +# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh. +# Besides being obsolete, that interpretation conflicts with max_attributes. +# +# Here is a description of memory_lock_above and memory_unlock: +# "You can 'freeze' data on the screen by turning on Memory Lock in a line of +# text. All lines above the cursor's current line become locked in place on +# the screen. Then enter data normally. When the screen fills up, any +# further data entered forces the first line of unfrozen line text to scroll +# under the frozen data. Lines scrolled off the screen are inserted into +# memory immediately preceding the first frozen line." (from the HP 700/96 +# User's manual). VT100/ANSI memory lock set is \E[>2h, reset is \E[>2l. +# +# 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 motion-keys for vi version 2 +# 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 is 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 +# +# 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 +# +# 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 +# +# The mytinfo capabilities end here. +# +# XENIX extensions: +# +# Xenix defined its own set of forms-drawing capabilities: +# +# cap IBM ASCII description ACS ASCII +# --- ----------- -------------------- ------------- ------ +# G1 191 \277 M-? single upper right ACS_URCORNER +# G2 218 \332 M-Z single upper left ACS_ULCORNER +# G3 192 \300 M-@ single lower left ACS_LLCORNER +# G4 217 \331 M-Y single lower right ACS_LRCORNER +# G5 187 \273 M-; double upper right +# G6 201 \311 M-I double upper left +# G7 200 \310 M-H double lower left +# G8 188 \274 M-< double lower right +# GC 197 \305 M-E single intersection ACS_PLUS _ _ +# GD 194 \302 M-B single down-tick ACS_TTEE | +# GH 196 \304 M-D single horizontal line ACS_HLINE +# GL 180 \264 M-4 single left tick ACS_RTEE -| +# GR 195 \303 M-C single right tick ACS_LTEE |- +# GU 193 \301 M-A single up tick ACS_BTEE _|_ +# GV 179 \263 M-3 single vertical line ACS_VLINE +# Gc 206 \316 M-N double intersection +# Gd 203 \313 M-K double down tick +# Gh 205 \315 M-M double horizontal line +# Gl 204 \204 M-L double left tick +# Gr 185 \271 M-9 double right tick +# Gu 202 \312 M-J double up tick +# Gv 186 \272 M-: double vertical line +# +# The compiler will translate the single-line caps and discard the others +# (via IGNORE aliases further down). We don't want to do normal pad +# translation on these, they're often single-character printable ASCII +# strings that happen to be numerics. There's awk code in parametrized.sh +# 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 +# +############################################################################# +# +# TERMINFO EXTENSION CAPABILITIES +# +# (see Caps-ncurses for the complete set of comments) +# +memory_lock meml str ml - - ----K lock memory above cursor +memory_unlock memu str mu - - ----K unlock memory +box_chars_1 box1 str bx - - ----K box characters primary set +# +############################################################################# diff --git a/ncurses/include/MKhashsize.sh b/ncurses/include/MKhashsize.sh new file mode 100755 index 0000000000..4eb48dd141 --- /dev/null +++ b/ncurses/include/MKhashsize.sh @@ -0,0 +1,46 @@ +#!/bin/sh +############################################################################## +# Copyright 2019,2020 Thomas E. Dickey # +# Copyright 1998,2006 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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: MKhashsize.sh,v 1.9 2020/02/02 23:34:34 tom Exp $ +# +# MKhashsize.sh --- generate size include for hash functions +# +echo "/*" +echo " * hashsize.h -- hash and token table constants" +echo " */" + +test $# = 0 && set Caps +TABSIZE=`cat "$@" | grep -v '^[ #]' | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | grep -v "^userdef" | grep -v "^used_by" | wc -l` + +echo "" +echo "#define CAPTABSIZE ${TABSIZE}" +echo "#define HASHTABSIZE (${TABSIZE} * 2)" diff --git a/ncurses/include/MKkey_defs.sh b/ncurses/include/MKkey_defs.sh new file mode 100755 index 0000000000..9a25b33410 --- /dev/null +++ b/ncurses/include/MKkey_defs.sh @@ -0,0 +1,200 @@ +#! /bin/sh +# $Id: MKkey_defs.sh,v 1.25 2025/06/14 14:44:56 tom Exp $ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2001-2013,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 function-key definitions for curses.h +# +# Author: Thomas E. Dickey 2001 +# +# Extract function-key definitions from the Caps file +# +: "${AWK-awk}" + +test $# = 0 && set Caps + +data=data$$ +pass1=pass1_$$ +pass2=pass2_$$ +pass3=pass3_$$ +pass4=pass4_$$ +trap 'rm -f $data pass[1234]_$$; exit 1' 1 2 3 15 +trap 'rm -f $data pass[1234]_$$' 0 + +# change repeated tabs (used for readability) to single tabs (needed to make +# awk see the right field alignment of the corresponding columns): +if sort -k 6 "$@" >$data 2>/dev/null +then + # POSIX + sed -e 's/[ ][ ]*/ /g' "$@" |sort -n -k 6 >$data +elif sort -n +5 "$@" >$data 2>/dev/null +then + # SunOS (and SVr4, marked as obsolete but still recognized) + sed -e 's/[ ][ ]*/ /g' "$@" |sort -n +5 >$data +else + echo "Your sort utility is broken. Please install one that works." >&2 + exit 1 +fi + +# add keys that we generate automatically: +cat >>$data <$output <$data ' +function print_cols(text,cols) { + printf "%s", text + len = length(text); + while (len < cols) { + printf " " + len += 8; + } +} +function decode(keycode) { + result = 0; + if (substr(keycode, 1, 2) == "0x") { + digits="0123456789abcdef"; + } else if (substr(keycode, 1, 1) == "0") { + digits="01234567"; + } else { + digits="0123456789"; + } + while (length(keycode) != 0) { + digit=substr(keycode, 1, 1); + keycode=substr(keycode, 2); + result = result * length(digits) + index(digits, digit) - 1; + } + return result; +} + +BEGIN { + maxkey='"$maxkey"'; + pass='"$pass"'; + key_max=1; + bits=1; + while (key_max < maxkey) { + bits = bits + 1; + key_max = (key_max * 2) + 1; + } + octal_fmt = sprintf ("%%0%do", (bits + 2) / 3 + 1); +} + +/^$/ {next;} +/^#/ {next;} +/^capalias/ {next;} +/^infoalias/ {next;} +/^used_by/ {next;} +/^userdef/ {next;} + +$5 != "-" && $6 != "-" { + if ($6 == "+") { + if (pass == 1 || pass == 2) + next; + thiskey=maxkey + 1; + } else { + if (pass == 3) + next; + thiskey=decode($6); + } + if (thiskey > maxkey) + maxkey = thiskey; + if (pass == 2 || pass == 3) { + showkey=sprintf(octal_fmt, thiskey); + ifdef = 0; + if (index($7,"NCURSES_") == 1) { + ifdef = 1; + printf "\n"; + printf "#if %s\n", $7; + } + if ($5 == "KEY_F(0)" ) { + printf "#define " + print_cols("KEY_F0", 16); + print_cols(showkey, 16); + print "/* Function keys. Space for 64 */"; + printf "#define " + print_cols("KEY_F(n)", 16); + print_cols("(KEY_F0+(n))", 16); + print "/* Value of function key n */" + } else { + printf "#define " + print_cols($5, 16); + print_cols(showkey, 16); + printf "/*" + for (i = 8; i <= NF; i++) + printf " %s", $i + print " */" + } + if (ifdef != 0) { + printf "#endif\n"; + } + } + } +END { + if (pass == 1) { + print maxkey; + } else if (pass == 4) { + print ""; + printf "#define "; + print_cols("KEY_MAX", 16); + result = sprintf (octal_fmt, key_max); + print_cols(result, 16); + printf "/* Maximum key value is "; + printf octal_fmt, maxkey; + print " */"; + } + } +' +if test $pass = 1 ; then + maxkey=`cat $pass1` +fi + +done + +cat $pass2 +cat $pass3 +cat $pass4 diff --git a/ncurses/include/MKncurses_def.sh b/ncurses/include/MKncurses_def.sh new file mode 100755 index 0000000000..4330c67db7 --- /dev/null +++ b/ncurses/include/MKncurses_def.sh @@ -0,0 +1,84 @@ +#! /bin/sh +# $Id: MKncurses_def.sh,v 1.5 2022/07/16 17:03:59 tom Exp $ +############################################################################## +# Copyright 2020,2022 Thomas E. Dickey # +# Copyright 2000,2003 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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. # +############################################################################## +# +# MKncurses_def.sh -- generate fallback definitions for ncurses_cfg.h +# +# Author: Thomas E. Dickey 2000 +# +# Given the choice between constructs such as +# +# #if defined(foo) && foo +# #if foo +# +# we chose the latter. It is guaranteed by the language standard, and there +# appear to be no broken compilers that do not honor that detail. But some +# people want to use gcc's -Wundef option (corresponding to one of the less +# useful features in Watcom's compiler) to check for misspellings. So we +# generate a set of fallback definitions to quiet the warnings without making +# the code ugly. +# +DEFS="${1-ncurses_defs}" +cat < 1992,1995 */" + print "/* and: Eric S. Raymond */" + print "/* and: Thomas E. Dickey 1995-on */" + print "/****************************************************************************/" + print "" + print "/* $Id: MKterm.h.awk.in,v 1.94 2025/12/26 23:33:14 tom Exp $ */" + print "" + print "/*" + print "** term.h -- Definition of struct term" + print "*/" + print "" + print "#ifndef NCURSES_TERM_H_incl" + print "#define NCURSES_TERM_H_incl 1" + print "" + print "#undef NCURSES_VERSION" + print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\"" + print "" + print "#include " + print "" + print "#ifdef __cplusplus" + printf "extern \"C\" %s\n", lcurl; + print "#endif" + print "" + print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H" + print " * definition (based on the system for which this was configured)." + print " */" + print "" + print "#ifndef __NCURSES_H" + print "" + print "typedef struct screen SCREEN;" + print "" + print "/* configured with --enable-sp-funcs? */" + print "#if @NCURSES_SP_FUNCS@" + print "#undef NCURSES_SP_FUNCS" + print "#define NCURSES_SP_FUNCS @NCURSES_PATCH@" + print "#undef NCURSES_SP_NAME" + print "#define NCURSES_SP_NAME(name) name##_sp" + print "" + print "/* Define the sp-funcs helper function */" + print "#undef NCURSES_SP_OUTC" + print "#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)" + print "typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);" + print "#endif" + print "" + print "#endif /* __NCURSES_H */" + print "" + print "#undef NCURSES_CONST" + print "#define NCURSES_CONST @NCURSES_CONST@" + print "" + print "#undef NCURSES_SBOOL" + print "#define NCURSES_SBOOL @NCURSES_SBOOL@" + print "" + print "#undef NCURSES_USE_DATABASE" + print "#define NCURSES_USE_DATABASE @NCURSES_USE_DATABASE@" + print "" + print "#undef NCURSES_USE_TERMCAP" + print "#define NCURSES_USE_TERMCAP @NCURSES_USE_TERMCAP@" + print "" + print "#undef NCURSES_XNAMES" + print "#define NCURSES_XNAMES @NCURSES_XNAMES@" + print "" + print "/* TTY, SET_TTY and GET_TTY are used internally */" + print "#ifdef NCURSES_INTERNALS" + print "" + print "/* We use these symbols to hide differences between" + print " * termios/termio/sgttyb interfaces." + print " */" + print "#undef TTY" + print "#undef SET_TTY" + print "#undef GET_TTY" + print "" + print "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@ /* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */" + print "" + print "#undef TERMIOS" + print "#define TERMIOS 1" + print "#include " + print "#define TTY struct termios" + print "" + print "#elif @HAVE_TERMIO_H@ /* HAVE_TERMIO_H */" + print "" + print "#undef TERMIOS" + print "#define TERMIOS 1" + print "#include " + print "#define TTY struct termio" + print "" + print "#elif (defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) || defined(__MINGW64__))" + print "" + print "#include " + print "#define TTY ConsoleMode" + print "" + print "#elif @HAVE_SGTTY_H@ /* HAVE_SGTTY_H */" + print "" + print "#undef TERMIOS" + print "#include " + print "#include " + print "#define TTY struct sgttyb" + print "" + print "#else" + print "" + print "#error no termio/termios/sgtty found" + print "" + print "#endif /* HAVE_TERMIOS_H */" + print "" + print "#ifdef TERMIOS" + print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)" + print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)" + print "/* configured with --enable-exp-win32? */" + print "#elif defined(_WIN32) || defined(_WIN64)" + print "#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf)" + print "#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf)" + print "#elif @HAVE_SGTTY_H@ /* HAVE_SGTTY_H */" + print "#define GET_TTY(fd, buf) gtty(fd, buf)" + print "#define SET_TTY(fd, buf) stty(fd, buf)" + print "#endif" + print "" + print "#endif /* NCURSES_INTERNALS */" + print "" + print "#ifndef GCC_NORETURN" + print "#define GCC_NORETURN /* nothing */" + print "#endif" + print "" + print "#define NAMESIZE 256" + print "" + print "/* The cast works because TERMTYPE is the first data in TERMINAL */" + print "#define CUR ((TERMTYPE *)(cur_term))->" + print "" +} + +$2 == "%%-STOP-HERE-%%" { + print "" + printf "#define BOOLWRITE %d\n", BoolCount + printf "#define NUMWRITE %d\n", NumberCount + printf "#define STRWRITE %d\n", StringCount + print "" + print "/* older synonyms for some capabilities */" + print "#define beehive_glitch no_esc_ctlc" + print "#define teleray_glitch dest_tabs_magic_smso" + print "" + print "/* HPUX-11 uses this name rather than the standard one */" + print "#ifndef micro_char_size" + print "#define micro_char_size micro_col_size" + print "#endif" + print "" + print "#ifdef __INTERNAL_CAPS_VISIBLE" +} + +/^#/ { next; } + +/^used_by/ { next ; } +/^userdef/ { next ; } + +$1 == "acs_chars" { + acsindex = StringCount; +} + +$3 == "bool" { + printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++ +} + +$3 == "num" { + printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++ +} + +$3 == "str" { + printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++ +} + +END { + print "#endif /* __INTERNAL_CAPS_VISIBLE */" + print "" + print "" + print "/*" + print " * Predefined terminfo array sizes" + print " */" + printf "#define BOOLCOUNT %d\n", BoolCount + printf "#define NUMCOUNT %d\n", NumberCount + printf "#define STRCOUNT %d\n", StringCount + print "" + print "/* used by code for comparing entries */" + print "#define acs_chars_index ", acsindex + print "" + declare_termtype("short",""); + print "" + print "/*" + print " * The only reason these structures are visible is for read-only use." + print " * Programs which modify the data are not, never were, portable across" + print " * curses implementations." + print " *" + print " * The first field in TERMINAL is used in macros." + print " * The remaining fields are private." + print " */" + print "#ifdef NCURSES_INTERNALS" + print "" + print "#undef TERMINAL" + print "#define TERMINAL struct term" + print "TERMINAL;" + print "" + if (@NCURSES_EXT_COLORS@) { + print "/* configured with --enable-ext-colors */" + declare_termtype("int","2"); + } else { + print "#undef TERMTYPE2" + print "#define TERMTYPE2 TERMTYPE" + } + print "#else" + print "" + print "typedef struct term { /* describe an actual terminal */" + print " TERMTYPE type; /* terminal type description */" + print "} TERMINAL;" + print "" + print "#endif /* NCURSES_INTERNALS */" + print "" + print "/* configured with --enable-broken_linker and reentrancy disabled */" + print "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@" + print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" + print "/* reentrancy enabled */" + print "#elif @cf_cv_enable_reentrant@" + print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);" + print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())" + print "#else" + print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" + print "#endif" + print "" + print "/* configured with --enable-broken_linker or reentrancy enabled */" + print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);" + print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);" + print "" + print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())" + print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())" + print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())" + print "#define numnames NCURSES_PUBLIC_VAR(numnames())" + print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())" + print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())" + print "#define strnames NCURSES_PUBLIC_VAR(strnames())" + print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())" + print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())" + print "" + print "#else" + print "" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];" + print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];" + print "" + print "#endif" + print "" + print "/*" + print " * These entrypoints are used only by the ncurses utilities such as tic." + print " */" + print "#ifdef NCURSES_INTERNALS" + print "" + print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);" + print "extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);" + print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);" + print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);" + print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);" + print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);" + print "extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);" + print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);" + print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);" + print "" + print "#endif /* NCURSES_INTERNALS */" + print "" + print "/*" + print " * Normal entry points" + print " */" + print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);" + print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);" + print "" + print "/* miscellaneous entry points */" + print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);" + print "extern NCURSES_EXPORT(int) setupterm (const char *,int,int *);" + print "" + print "/* terminfo entry points, also declared in curses.h */" + print "#if !defined(__NCURSES_H)" + print "extern NCURSES_EXPORT(char *) tigetstr (const char *);" + print "extern NCURSES_EXPORT_VAR(char) ttytype[];" + print "extern NCURSES_EXPORT(int) putp (const char *);" + print "extern NCURSES_EXPORT(int) tigetflag (const char *);" + print "extern NCURSES_EXPORT(int) tigetnum (const char *);" + print "" + print "/* configured without --disable-tparm-varargs? */" + print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */" + print "extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */" + print "#else" + print "extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */" + print "#endif" + print "" + print "extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */" + print "extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...); /* special */" + print "extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *); /* special */" + print "" + print "#endif /* __NCURSES_H */" + print "" + print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */" + print "#if !defined(NCURSES_TERMCAP_H_incl)" + print "extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);" + print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);" + print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);" + print "extern NCURSES_EXPORT(int) tgetflag (const char *);" + print "extern NCURSES_EXPORT(int) tgetnum (const char *);" + print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));" + print "#endif /* NCURSES_TERMCAP_H_incl */" + print "" + print "/*" + print " * Include curses.h before term.h to enable these extensions." + print " */" + print "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)" + print "" + print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *);" + print "" + print "/* configured without --disable-tparm-varargs? */" + print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */" + print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */" + print "#else" + print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */" + print "#endif" + print "" + print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */" + print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **);" + print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);" + print "" + print "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);" + print "" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);" + print "#endif /* NCURSES_SP_FUNCS */" + print "" + print "/*" + print " * Debugging features." + print " */" + print "extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int);" + print "" + print "#ifdef __cplusplus" + printf "%s\n", rcurl; + print "#endif" + print "" + print "#endif /* NCURSES_TERM_H_incl */" +} diff --git a/ncurses/include/Makefile.in b/ncurses/include/Makefile.in new file mode 100644 index 0000000000..f0baa7bd6f --- /dev/null +++ b/ncurses/include/Makefile.in @@ -0,0 +1,181 @@ +# $Id: Makefile.in,v 1.56 2025/10/18 13:33:46 tom Exp $ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 1998-2013,2015 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# Makefile for ncurses source code. +# +# This makes/installs ncurses include-files +# +# The variable 'srcdir' refers to the source-distribution, and can be set with +# the configure script by "--srcdir=DIR". + +# turn off _all_ suffix rules; we'll generate our own +.SUFFIXES: + +SHELL = @SHELL@ +VPATH = @srcdir@ +THIS = Makefile + +@SET_DESTDIR@ +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +includedir = @includedir@ +includesubdir = @includesubdir@ + +INCLUDEDIR = $(DESTDIR)$(includedir@MERGE_PREFIX@)$(includesubdir) + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +AWK = @AWK@ +LN_S = @LN_S@ + +CC = @CC@ +CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ +CPPFLAGS = -DHAVE_CONFIG_H -I. @CPPFLAGS@ + +CTAGS = @CTAGS@ +ETAGS = @ETAGS@ + +VERSION = @cf_cv_rel_version@ + +# The "Caps" file specifies the terminfo database format, as well as the list +# of function keys. +TERMINFO_CAPS = $(srcdir)/@TERMINFO_CAPS@ +CAPLIST = $(TERMINFO_CAPS) \ + $(srcdir)/Caps-ncurses + +# These files are generated by the configure script +CONFIG_SRC = \ + MKterm.h.awk \ + curses.head \ + nc_win32.h \ + ncurses_dll.h \ + termcap.h \ + unctrl.h + +# These files are generated by this makefile +AUTO_SRC = \ + curses.h \ + hashsize.h \ + ncurses_def.h \ + parametrized.h \ + config.h \ + term.h + +################################################################################ + +@MAKE_PHONY@.PHONY : all +@MAKE_PHONY@.PHONY : check +@MAKE_PHONY@.PHONY : clean +@MAKE_PHONY@.PHONY : depend +@MAKE_PHONY@.PHONY : distclean +@MAKE_PHONY@.PHONY : install +@MAKE_PHONY@.PHONY : install.libs +@MAKE_PHONY@.PHONY : libs +@MAKE_PHONY@.PHONY : mostlyclean +@MAKE_PHONY@.PHONY : realclean +@MAKE_PHONY@.PHONY : sources +@MAKE_PHONY@.PHONY : uninstall +@MAKE_PHONY@.PHONY : uninstall.libs + +all \ +libs \ +depend \ +sources \ +install :: $(AUTO_SRC) + +curses.h : $(CAPLIST) \ + curses.head \ + $(srcdir)/curses.tail \ + $(srcdir)/MKkey_defs.sh + cat curses.head >$@ + AWK=$(AWK) $(SHELL) $(srcdir)/MKkey_defs.sh $(CAPLIST) >>$@ + $(SHELL) -c 'if test "@NCURSES_WGETCH_EVENTS@" = "1" ; then cat $(srcdir)/curses.events >>$@ ; fi' + $(SHELL) -c 'if test "@NCURSES_CH_T@" = "cchar_t" ; then cat $(srcdir)/curses.wide >>$@ ; fi' + cat $(srcdir)/curses.tail >>$@ + +term.h: $(CAPLIST) \ + MKterm.h.awk + $(AWK) -f MKterm.h.awk $(CAPLIST) > $@ + $(SHELL) $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@ + +hashsize.h: $(CAPLIST) \ + $(srcdir)/MKhashsize.sh + $(SHELL) $(srcdir)/MKhashsize.sh $(CAPLIST) >$@ + +ncurses_def.h: $(srcdir)/ncurses_defs $(srcdir)/MKncurses_def.sh + AWK=$(AWK) $(SHELL) $(srcdir)/MKncurses_def.sh $(srcdir)/ncurses_defs >$@ + +parametrized.h: $(CAPLIST) \ + $(srcdir)/MKparametrized.sh + AWK=$(AWK) $(SHELL) $(srcdir)/MKparametrized.sh $(CAPLIST) >$@ + +# This is required by pthread.h on MinGW +config.h: + touch $@ + +tags: + $(CTAGS) *.[ch] + +@MAKE_UPPER_TAGS@TAGS: +@MAKE_UPPER_TAGS@ $(ETAGS) *.[ch] + +mostlyclean :: + -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace + +clean :: mostlyclean + -rm -f $(AUTO_SRC) + -rm -rf *.dSYM + +distclean :: clean + -rm -f Makefile $(CONFIG_SRC) config.h + +realclean :: distclean + +# Verify that each header-file can be compiled without including another. +check: + @$(SHELL) -c "for header in *.h;\ + do \ + echo \"** testing \$${header}\" ; \ + echo \"#include <\$${header}>\" >headers.c; \ + echo \"int main(void) { return 0; }\" >>headers.c; \ + $(CC) -c $(CFLAGS) $(CPPFLAGS) headers.c; \ + done" + -@rm -f headers.* + +############################################################################### +# The remainder of this file is automatically generated during configuration +############################################################################### diff --git a/ncurses/include/capdefaults.c b/ncurses/include/capdefaults.c new file mode 100644 index 0000000000..6ac89f6d3c --- /dev/null +++ b/ncurses/include/capdefaults.c @@ -0,0 +1,90 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 1998-2000,2008 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* $Id: capdefaults.c,v 1.17 2024/07/27 19:19:23 tom Exp $ */ + + /* + * Compute obsolete capabilities. The reason this is an include file is + * that the two places where it is needed require the macros to generate + * offsets to different structures. See the file Caps for explanations of + * these conversions. + * + * Note: This code is the functional inverse of the first part of + * postprocess_termcap(). + */ +{ + const char *strp; + short capval; + +#define EXTRACT_DELAY(str) \ + (short) (strp = strchr(str, '*'), strp ? atoi(strp+1) : 0) + + /* current (4.4BSD) capabilities marked obsolete */ + if (VALID_STRING(carriage_return) + && (capval = EXTRACT_DELAY(carriage_return))) + carriage_return_delay = capval; + if (VALID_STRING(newline) && (capval = EXTRACT_DELAY(newline))) + new_line_delay = capval; + + /* current (4.4BSD) capabilities not obsolete */ + if (!VALID_STRING(termcap_init2) && VALID_STRING(init_3string)) { + termcap_init2 = init_3string; + init_3string = ABSENT_STRING; + } + if (!VALID_STRING(termcap_reset) + && VALID_STRING(reset_2string) + && !VALID_STRING(reset_1string) + && !VALID_STRING(reset_3string)) { + termcap_reset = reset_2string; + reset_2string = ABSENT_STRING; + } + if (magic_cookie_glitch_ul == ABSENT_NUMERIC + && magic_cookie_glitch != ABSENT_NUMERIC + && VALID_STRING(enter_underline_mode)) + magic_cookie_glitch_ul = magic_cookie_glitch; + + /* totally obsolete capabilities */ + linefeed_is_newline = (char) (VALID_STRING(newline) + && (strcmp("\n", newline) == 0)); + if (VALID_STRING(cursor_left) + && (capval = EXTRACT_DELAY(cursor_left))) + backspace_delay = capval; + if (VALID_STRING(tab) && (capval = EXTRACT_DELAY(tab))) + horizontal_tab_delay = capval; +#undef EXTRACT_DELAY +} diff --git a/ncurses/include/curses.events b/ncurses/include/curses.events new file mode 100644 index 0000000000..2509b1bf70 --- /dev/null +++ b/ncurses/include/curses.events @@ -0,0 +1,55 @@ +/* $Id: curses.events,v 1.4 2024/01/19 09:24:17 tom Exp $ */ +/* + * vile:cmode: + * This file is part of ncurses, designed to be appended after curses.h.in + * (see that file for the relevant copyright). + */ + +/* + * This is an extension to support events... + */ +#ifdef NCURSES_WGETCH_EVENTS +#if !defined(__BEOS__) || defined(__HAIKU__) + /* Fix _nc_timed_wait() on BEOS... */ +# define NCURSES_EVENT_VERSION 1 +#endif /* !defined(__BEOS__) */ + +/* + * Bits to set in _nc_event.data.flags + */ +# 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 *) GCC_DEPRECATED(experimental option); /* experimental */ +extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *) GCC_DEPRECATED(experimental option); /* experimental */ + +#define KEY_EVENT 0634 /* We were interrupted by an event */ + +#endif /* NCURSES_WGETCH_EVENTS */ diff --git a/ncurses/include/curses.h.in b/ncurses/include/curses.h.in new file mode 100644 index 0000000000..bc5c679b16 --- /dev/null +++ b/ncurses/include/curses.h.in @@ -0,0 +1,1550 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* $Id: curses.h.in,v 1.299 2025/08/08 23:19:21 tom Exp $ */ + +#ifndef __NCURSES_H +#define __NCURSES_H + +/* + The symbols beginning NCURSES_ or USE_ are configuration choices. + A few of the former can be overridden by applications at compile-time. + Most of the others correspond to configure-script options (or checks + by the configure-script for features of the system on which it is built). + + These symbols can be overridden by applications at compile-time: + NCURSES_NOMACROS suppresses macro definitions in favor of functions + NCURSES_WATTR_MACROS suppresses wattr_* macro definitions + NCURSES_WIDECHAR is an alternative for declaring wide-character functions. + + These symbols are used only when building ncurses: + NCURSES_ATTR_T + NCURSES_FIELD_INTERNALS + NCURSES_INTERNALS + + These symbols are set by the configure script: + NCURSES_ENABLE_STDBOOL_H + NCURSES_EXPANDED + NCURSES_EXT_COLORS + NCURSES_EXT_FUNCS + NCURSES_EXT_PUTWIN + NCURSES_NO_PADDING + NCURSES_OSPEED_COMPAT + NCURSES_PATHSEP + NCURSES_REENTRANT + NCURSES_SIGWINCH + */ + +#define CURSES 1 +#define CURSES_H 1 + +/* These are defined only in curses.h, and are used for conditional compiles */ +#define NCURSES_VERSION_MAJOR @NCURSES_MAJOR@ +#define NCURSES_VERSION_MINOR @NCURSES_MINOR@ +#define NCURSES_VERSION_PATCH @NCURSES_PATCH@ + +/* This is defined in more than one ncurses header, for identification */ +#undef NCURSES_VERSION +#define NCURSES_VERSION "@NCURSES_MAJOR@.@NCURSES_MINOR@" + +/* + * Identify the mouse encoding version. + */ +#define NCURSES_MOUSE_VERSION @NCURSES_MOUSE_VERSION@ + +/* + * Definitions to facilitate DLL's. + */ +#include + +/* + * Extra headers. + */ +#if @HAVE_STDINT_H@ +#include +#endif + +#ifdef __cplusplus +#else +#if @HAVE_STDNORETURN_H@ +#include +#undef GCC_NORETURN +#define GCC_NORETURN _Noreturn +#endif +#endif + +/* + * User-definable tweak to disable the include of . + */ +#ifndef NCURSES_ENABLE_STDBOOL_H +#define NCURSES_ENABLE_STDBOOL_H @USE_STDBOOL_H@ +#endif + +/* + * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses + * configured using --disable-macros. + */ +#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 @NCURSES_CONST@ /* for old compilers */ + +#undef NCURSES_INLINE +#define NCURSES_INLINE @NCURSES_INLINE@ /* for old compilers */ + +/* + * The standard type used for color values, and for color-pairs. The latter + * allows the curses library to enumerate the combinations of foreground and + * background colors used by an application, and is normally the product of the + * total foreground and background colors. + * + * X/Open uses "short" for both of these types, ultimately because they are + * numbers from the SVr4 terminal database, which uses 16-bit signed values. + */ +#undef NCURSES_COLOR_T +#define NCURSES_COLOR_T short + +#undef NCURSES_PAIRS_T +#define NCURSES_PAIRS_T short + +/* + * Definitions used to make WINDOW and similar structs opaque. + */ +#ifndef NCURSES_INTERNALS +#define NCURSES_OPAQUE @NCURSES_OPAQUE@ +#define NCURSES_OPAQUE_FORM @NCURSES_OPAQUE_FORM@ +#define NCURSES_OPAQUE_MENU @NCURSES_OPAQUE_MENU@ +#define NCURSES_OPAQUE_PANEL @NCURSES_OPAQUE_PANEL@ +#endif + +/* + * Definition used to optionally suppress wattr* macros to help with the + * transition from ncurses5 to ncurses6 by allowing the header files to + * be shared across development packages for ncursesw in both ABIs. + */ +#ifndef NCURSES_WATTR_MACROS +#define NCURSES_WATTR_MACROS @NCURSES_WATTR_MACROS@ +#endif + +/* + * The reentrant code relies on the opaque setting, but adds features. + */ +#ifndef NCURSES_REENTRANT +#define NCURSES_REENTRANT @cf_cv_enable_reentrant@ +#endif + +/* + * KEY_RESIZE is an extended feature that relies upon the SIGWINCH handler + * in ncurses. + */ +#if @NCURSES_EXT_FUNCS@ /* NCURSES_EXT_FUNCS */ +#ifndef NCURSES_SIGWINCH +#define NCURSES_SIGWINCH @cf_cv_enable_sigwinch@ +#endif +#else +#undef NCURSES_SIGWINCH +#define NCURSES_SIGWINCH 0 +#endif /* NCURSES_EXT_FUNCS */ + +/* + * In certain environments, we must work around linker problems for data + */ +#undef NCURSES_BROKEN_LINKER +#if @BROKEN_LINKER@ +#define NCURSES_BROKEN_LINKER 1 +#endif + +/* + * Control whether bindings for interop support are added. + */ +#undef NCURSES_INTEROP_FUNCS +#define NCURSES_INTEROP_FUNCS @NCURSES_INTEROP_FUNCS@ + +/* + * The internal type used for window dimensions. + */ +#undef NCURSES_SIZE_T +#define NCURSES_SIZE_T @NCURSES_SIZE_T@ + +/* + * Control whether tparm() supports varargs or fixed-parameter list. + */ +#undef NCURSES_TPARM_VARARGS +#define NCURSES_TPARM_VARARGS @NCURSES_TPARM_VARARGS@ + +/* + * Control type used for tparm's arguments. While X/Open equates long and + * char* values, this is not always workable for 64-bit platforms. + */ +#undef NCURSES_TPARM_ARG +#define NCURSES_TPARM_ARG @NCURSES_TPARM_ARG@ + +/* + * Control whether ncurses uses wcwidth() for checking width of line-drawing + * characters. + */ +#undef NCURSES_WCWIDTH_GRAPHICS +#define NCURSES_WCWIDTH_GRAPHICS @NCURSES_WCWIDTH_GRAPHICS@ + +/* + * 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 @NCURSES_CH_T@ + +#if @cf_cv_enable_lp64@ /* cf_cv_enable_lp64 */ && defined(_LP64) +typedef unsigned chtype; +typedef unsigned mmask_t; +#else +typedef @cf_cv_typeof_chtype@ chtype; /* cf_cv_typeof_chtype */ +typedef @cf_cv_typeof_mmask_t@ mmask_t; /* cf_cv_typeof_mmask_t */ +#endif + +/* + * We need FILE, etc. Include this before checking any feature symbols. + */ +#include + +/* + * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or + * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is + * not already defined, e.g., if the platform relies upon nonstandard feature + * test macros, define it at this point if the standard feature test macros + * indicate that it should be defined. + */ +#ifndef NCURSES_WIDECHAR +#if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) +#define NCURSES_WIDECHAR 1 +#else +#define NCURSES_WIDECHAR 0 +#endif +#endif /* NCURSES_WIDECHAR */ + +#include /* we need va_list */ +#if NCURSES_WIDECHAR +#include /* we want wchar_t */ +#endif + +/* 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 may declare 'bool' to be a + * different type, such as an enum which is not necessarily compatible with + * C++. If we have , 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 +#define TRUE 1 + +#undef FALSE +#define FALSE 0 + +typedef @cf_cv_type_of_bool@ NCURSES_BOOL; + +#if @USE_CXX_BOOL@ /* __cplusplus, etc. */ + +/* use the C++ compiler's bool type */ +#define NCURSES_BOOL bool + +#else /* c89, c99, etc. */ + +#if NCURSES_ENABLE_STDBOOL_H +#include +/* use whatever the C compiler decides bool really is */ +#define NCURSES_BOOL bool +#elif !defined(__cplusplus) && !@USE_BUILTIN_BOOL@ /* USE_BUILTIN_BOOL */ +/* there is no predefined bool - use our own */ +#undef bool +#define bool NCURSES_BOOL +#endif + +#endif /* !__cplusplus, etc. */ + +#ifdef __cplusplus +extern "C" { +#define NCURSES_CAST(type,value) static_cast(value) +#else +#define NCURSES_CAST(type,value) (type)(value) +#endif + +#define NCURSES_OK_ADDR(p) (NULL != NCURSES_CAST(const void *, (p))) + +/* + * X/Open attributes. In the ncurses implementation, they are identical to the + * A_ attributes. + */ +#define WA_ATTRIBUTES A_ATTRIBUTES +#define WA_NORMAL A_NORMAL +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE +#define WA_REVERSE A_REVERSE +#define WA_BLINK A_BLINK +#define WA_DIM A_DIM +#define WA_BOLD A_BOLD +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_INVIS A_INVIS +#define WA_PROTECT A_PROTECT +#define WA_HORIZONTAL A_HORIZONTAL +#define WA_LEFT A_LEFT +#define WA_LOW A_LOW +#define WA_RIGHT A_RIGHT +#define WA_TOP A_TOP +#define WA_VERTICAL A_VERTICAL + +#if @NCURSES_EXT_FUNCS@ /* NCURSES_EXT_FUNCS */ +#define WA_ITALIC A_ITALIC /* ncurses extension */ +#endif + +/* colors */ +#define COLOR_BLACK 0 +#define COLOR_RED 1 +#define COLOR_GREEN 2 +#define COLOR_YELLOW 3 +#define COLOR_BLUE 4 +#define COLOR_MAGENTA 5 +#define COLOR_CYAN 6 +#define COLOR_WHITE 7 + +/* line graphics */ + +#if @BROKEN_LINKER@ /* BROKEN_LINKER */ || NCURSES_REENTRANT +NCURSES_WRAPPED_VAR(chtype*, acs_map); +#define acs_map NCURSES_PUBLIC_VAR(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 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 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 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 + * is the right, b is the bottom, and l is the left. t, r, b, and l might + * be B (blank), S (single), D (double), or T (thick). The subset defined + * here only uses B and S. + */ +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +#undef ERR +#define ERR (-1) + +#undef OK +#define OK (0) + +/* values for the _flags member */ +#define _SUBWIN 0x01 /* is this a sub-window? */ +#define _ENDLINE 0x02 /* is the window flush right? */ +#define _FULLWIN 0x04 /* is the window full-screen? */ +#define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ +#define _ISPAD 0x10 /* is this window a pad? */ +#define _HASMOVED 0x20 /* has cursor moved since last refresh? */ +#define _WRAPPED 0x40 /* cursor was just wrappped */ + +/* + * this value is used in the firstchar and lastchar fields to mark + * unchanged lines + */ +#define _NOCHANGE -1 + +/* + * this value is used in the oldindex field to mark lines created by insertions + * and scrolls. + */ +#define _NEWINDEX -1 + +#ifdef NCURSES_INTERNALS +#undef SCREEN +#define SCREEN struct screen +SCREEN; +#else +typedef struct screen SCREEN; +#endif + +typedef struct _win_st WINDOW; + +typedef chtype attr_t; /* ...must be at least as wide as chtype */ + +#if NCURSES_WIDECHAR + +#if @NCURSES_LIBUTF8@ /* NCURSES_LIBUTF8 */ +#ifdef mblen /* libutf8.h defines it w/o undefining first */ +#undef mblen +#endif +#include +#endif + +#if @NEED_WCHAR_H@ /* NEED_WCHAR_H */ +#include /* ...to get mbstate_t, etc. */ +#endif + +#if @NCURSES_WCHAR_T@ /* NCURSES_WCHAR_T */ +typedef unsigned short wchar_t@NCURSES_OK_WCHAR_T@; +#endif + +#if @NCURSES_WINT_T@ /* NCURSES_WINT_T */ +typedef unsigned int wint_t@NCURSES_OK_WCHAR_T@; +#endif + +/* + * cchar_t stores an array of CCHARW_MAX wide characters. The first is + * normally a spacing character. The others are non-spacing. If those + * (spacing and nonspacing) do not fill the array, a null L'\0' follows. + * Otherwise, a null is assumed to follow when extracting via getcchar(). + */ +#define CCHARW_MAX @NCURSES_CCHARW_MAX@ /* NCURSES_CCHARW_MAX */ +typedef struct +{ + attr_t attr; + wchar_t chars[CCHARW_MAX]; +#if @NCURSES_EXT_COLORS@ /* NCURSES_EXT_COLORS */ +#undef NCURSES_EXT_COLORS +#define NCURSES_EXT_COLORS @NCURSES_PATCH@ /* NCURSES_PATCH */ + int ext_color; /* color pair, must be more than 16-bits */ +#if @NCURSES_RGB_COLORS@ /* NCURSES_RGB_COLORS */ + int rgb_color; /* extra data for direct-color (rgb) */ +#endif +#endif /* NCURSES_EXT_COLORS */ +} +cchar_t; + +#endif /* NCURSES_WIDECHAR */ + +#if !NCURSES_OPAQUE +struct ldat; + +struct _win_st +{ + NCURSES_SIZE_T _cury, _curx; /* current cursor position */ + + /* window location and size */ + NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ + NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ + + short _flags; /* window state flags */ + + /* attribute tracking */ + attr_t _attrs; /* current attribute for non-space character */ + chtype _bkgd; /* current background char/attribute pair */ + + /* 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 _immed; /* window in immed mode? (not yet used) */ + bool _sync; /* window in sync mode? */ + bool _use_keypad; /* process function keys into KEY_ symbols? */ + int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ + + struct ldat *_line; /* the actual line data */ + + /* global screen state */ + NCURSES_SIZE_T _regtop; /* top line of scrolling region */ + NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ + + /* these are used only if this is a sub-window */ + int _parx; /* x coordinate of this window in parent */ + int _pary; /* y coordinate of this window in parent */ + WINDOW *_parent; /* pointer to parent if a sub-window */ + + /* these are used only if this is a pad */ + struct pdat + { + NCURSES_SIZE_T _pad_y, _pad_x; + NCURSES_SIZE_T _pad_top, _pad_left; + NCURSES_SIZE_T _pad_bottom, _pad_right; + } _pad; + + NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ + +#if NCURSES_WIDECHAR /* NCURSES_WIDECHAR */ + cchar_t _bkgrnd; /* current background char/attribute pair */ +#if @NCURSES_EXT_COLORS@ /* NCURSES_EXT_COLORS */ + int _color; /* current color-pair for non-space character */ +#endif +#endif +}; +#endif /* NCURSES_OPAQUE */ + +/* + * 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. + * Old versions of G++ do not accept it anyway, at least not consistently with + * GCC. + */ +#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) +#define __attribute__(p) /* nothing */ +#endif + +/* + * We cannot define these in ncurses_cfg.h, since they require parameters to be + * passed (that is non-portable). + */ +#ifndef GCC_PRINTFLIKE +#ifndef printf +#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) +#else +#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#endif +#endif + +#ifndef GCC_SCANFLIKE +#ifndef 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 */ +#endif + +#ifndef GCC_UNUSED +#define GCC_UNUSED /* nothing */ +#endif + +#undef GCC_DEPRECATED +#if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) +#define GCC_DEPRECATED(msg) __attribute__((deprecated)) +#else +#define GCC_DEPRECATED(msg) /* nothing */ +#endif + +/* + * Curses uses a helper function. Define our type for this to simplify + * extending it for the sp-funcs feature. + */ +typedef int (*NCURSES_OUTC)(int); + +/* + * 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. + */ + +extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ +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 */ +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 */ +extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ +extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ +extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ +extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ +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 */ +extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ +extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ +extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ +extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ +extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ +extern NCURSES_EXPORT(int) clear (void); /* generated */ +extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ +extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ +extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ +extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ +extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ +extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ +extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ +extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ +extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ +extern NCURSES_EXPORT(int) delch (void); /* generated */ +extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ +extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) deleteln (void); /* generated */ +extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ +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 */ +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 */ +extern NCURSES_EXPORT(int) getch (void); /* generated */ +extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ +extern NCURSES_EXPORT(int) getstr (char *); /* generated */ +extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ +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 */ +extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(chtype) inch (void); /* generated */ +extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ +extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ +extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ +extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ +extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ +extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ +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 */ +extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ +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 */ +extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(char) killchar (void); /* implemented */ +extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(char *) longname (void); /* implemented */ +extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) move (int, int); /* generated */ +extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ +extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ +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 */ +extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, 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 */ +extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ +extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ +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 */ +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 */ +extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ + GCC_PRINTFLIKE(3,4); +extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ + GCC_SCANFLIKE(3,4); +extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ +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 */ +extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, 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 */ +extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ +extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ +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 */ +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 */ +extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ + GCC_PRINTFLIKE(4,5); +extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ + GCC_SCANFLIKE(4,5); +extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ +extern NCURSES_EXPORT(int) napms (int); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ +extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ +extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ +extern NCURSES_EXPORT(int) nl (void); /* implemented */ +extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ +extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) noecho (void); /* implemented */ +extern NCURSES_EXPORT(int) nonl (void); /* implemented */ +extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ +extern NCURSES_EXPORT(int) noraw (void); /* implemented */ +extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ +extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ +extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ +extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ +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 (const char *,...) /* implemented */ + GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ +extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ +extern NCURSES_EXPORT(int) raw (void); /* implemented */ +extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ +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 (*)(WINDOW *, int)); /* implemented */ +extern NCURSES_EXPORT(int) savetty (void); /* implemented */ +extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ + GCC_SCANFLIKE(1,2); +extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ +extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ +extern NCURSES_EXPORT(int) scrl (int); /* generated */ +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 */ +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 */ +extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ +extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ +extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ +extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ +extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ +extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ +extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ +extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ +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 */ +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(int) syncok (WINDOW *, bool); /* implemented */ +extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ +extern NCURSES_EXPORT(char *) termname (void); /* 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(int) typeahead (int); /* implemented */ +extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ +extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ +extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ +extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ +extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ +extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ +extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ +extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_printw) /* implemented */ + GCC_PRINTFLIKE(2,0); +extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *, va_list) /* implemented */ + GCC_PRINTFLIKE(2,0); +extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_scanw) /* implemented */ + GCC_SCANFLIKE(2,0); +extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *, va_list) /* implemented */ + GCC_SCANFLIKE(2,0); +extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* 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 *,int); /* implemented */ +extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ +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 *, NCURSES_PAIRS_T *, void *); /* generated */ +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, NCURSES_PAIRS_T, void *); /* generated */ +extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ +extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ +extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ +extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ +extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ +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 */ +extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ +extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ +extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ +extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ +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 */ +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 */ +extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ +extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* 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 */ +extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ + GCC_SCANFLIKE(2,3); +extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ +extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ +extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ +extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ +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 */ +extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ + +/* + * These are also declared in : + */ +extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ +extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ +extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ +extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ + +#if NCURSES_TPARM_VARARGS +extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ +#else +extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ +#endif + +extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ +extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...); /* special */ +extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *); /* special */ + +/* + * 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. + */ +#if !NCURSES_WIDECHAR +#define vid_attr(a,pair,opts) vidattr(a) +#endif + +/* + * These functions are extensions - not in X/Open Curses. + */ +#if @NCURSES_EXT_FUNCS@ /* NCURSES_EXT_FUNCS */ +#undef NCURSES_EXT_FUNCS +#define NCURSES_EXT_FUNCS @NCURSES_PATCH@ /* NCURSES_PATCH */ +typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); +typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); +extern NCURSES_EXPORT(int) alloc_pair (int, int); +extern NCURSES_EXPORT(int) assume_default_colors (int, int); +extern NCURSES_EXPORT(const char *) curses_version (void); +extern NCURSES_EXPORT(int) define_key (const char *, int); +extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); +extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); +extern NCURSES_EXPORT(int) extended_slk_color(int); +extern NCURSES_EXPORT(int) find_pair (int, int); +extern NCURSES_EXPORT(int) free_pair (int); +extern NCURSES_EXPORT(int) get_escdelay (void); +extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); +extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); +extern NCURSES_EXPORT(int) is_cbreak(void); +extern NCURSES_EXPORT(int) is_echo(void); +extern NCURSES_EXPORT(int) is_nl(void); +extern NCURSES_EXPORT(int) is_raw(void); +extern NCURSES_EXPORT(bool) is_term_resized (int, int); +extern NCURSES_EXPORT(int) key_defined (const char *); +extern NCURSES_EXPORT(char *) keybound (int, int); +extern NCURSES_EXPORT(int) keyok (int, bool); +extern NCURSES_EXPORT(void) nofilter(void); +extern NCURSES_EXPORT(void) reset_color_pairs (void); +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_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); + +#if @NCURSES_XNAMES@ /* NCURSES_XNAMES */ +#undef NCURSES_XNAMES +#define NCURSES_XNAMES @NCURSES_XNAMES@ /* NCURSES_XNAMES */ +extern NCURSES_EXPORT(int) use_extended_names (bool); +#endif + +/* + * These extensions provide access to information stored in the WINDOW even + * when NCURSES_OPAQUE is set: + */ +extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* @GENERATED_EXT_FUNCS@ */ +extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* @GENERATED_EXT_FUNCS@ */ + +#else /* !NCURSES_EXT_FUNCS */ +#define curses_version() NCURSES_VERSION +#endif /* NCURSES_EXT_FUNCS */ + +/* + * Extra extension-functions, which pass a SCREEN pointer rather than using + * a global variable SP. + */ +#if @NCURSES_SP_FUNCS@ /* NCURSES_SP_FUNCS */ +#undef NCURSES_SP_FUNCS +#define NCURSES_SP_FUNCS @NCURSES_PATCH@ /* NCURSES_PATCH */ +#define NCURSES_SP_NAME(name) name##_sp + +/* Define the sp-funcs helper function */ +#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) +typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); + +extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ + +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ +#if @NCURSES_EXT_FUNCS@ /* NCURSES_EXT_FUNCS */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_cbreak) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_echo) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_nl) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_raw) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ +#endif /* NCURSES_EXT_FUNCS */ +#else /* !NCURSES_SP_FUNCS */ +#undef NCURSES_SP_FUNCS +#define NCURSES_SP_FUNCS 0 +#define NCURSES_SP_NAME(name) name +#define NCURSES_SP_OUTC NCURSES_OUTC +#endif /* NCURSES_SP_FUNCS */ + +/* attributes */ + +#define NCURSES_ATTR_SHIFT 8 +#define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) + +#define A_NORMAL (@cf_cv_1UL@ - @cf_cv_1UL@) +#define A_ATTRIBUTES NCURSES_BITS(~(@cf_cv_1UL@ - @cf_cv_1UL@),0) +#define A_CHARTEXT (NCURSES_BITS(@cf_cv_1UL@,0) - @cf_cv_1UL@) +#define A_COLOR NCURSES_BITS(((@cf_cv_1UL@) << 8) - @cf_cv_1UL@,0) +#define A_STANDOUT NCURSES_BITS(@cf_cv_1UL@,8) +#define A_UNDERLINE NCURSES_BITS(@cf_cv_1UL@,9) +#define A_REVERSE NCURSES_BITS(@cf_cv_1UL@,10) +#define A_BLINK NCURSES_BITS(@cf_cv_1UL@,11) +#define A_DIM NCURSES_BITS(@cf_cv_1UL@,12) +#define A_BOLD NCURSES_BITS(@cf_cv_1UL@,13) +#define A_ALTCHARSET NCURSES_BITS(@cf_cv_1UL@,14) + +/* SVr4 curses marks these as "subject to change" */ +#define A_INVIS NCURSES_BITS(@cf_cv_1UL@,15) +#define A_PROTECT NCURSES_BITS(@cf_cv_1UL@,16) + +/* X/Open features not found in SVr4 curses */ +#define A_HORIZONTAL NCURSES_BITS(@cf_cv_1UL@,17) +#define A_LEFT NCURSES_BITS(@cf_cv_1UL@,18) +#define A_LOW NCURSES_BITS(@cf_cv_1UL@,19) +#define A_RIGHT NCURSES_BITS(@cf_cv_1UL@,20) +#define A_TOP NCURSES_BITS(@cf_cv_1UL@,21) +#define A_VERTICAL NCURSES_BITS(@cf_cv_1UL@,22) + +#if @NCURSES_EXT_FUNCS@ /* NCURSES_EXT_FUNCS */ +#define A_ITALIC NCURSES_BITS(@cf_cv_1UL@,23) /* ncurses extension */ +#if @NCURSES_RGB_COLORS@ /* NCURSES_RGB_COLORS */ +#define A_FOREGROUND NCURSES_BITS(@cf_cv_1UL@,17) /* ncurses extension */ +#define A_BACKGROUND NCURSES_BITS(@cf_cv_1UL@,18) /* ncurses extension */ +#define A_DIRECT (A_FOREGROUND|A_BACKGROUND) +#endif /* NCURSES_RGB_COLORS */ +#endif /* NCURSES_EXT_FUNCS */ + +/* + * 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)) + +#define setterm(term) setupterm(term, 1, (int *)0) + +#define fixterm() reset_prog_mode() +#define resetterm() reset_shell_mode() +#define saveterm() def_prog_mode() +#define crmode() cbreak() +#define nocrmode() nocbreak() +#define gettmode() + +/* It seems older SYSV curses versions define these */ +#if !NCURSES_OPAQUE +#define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) +#define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) +#define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) +#define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) +#define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) +#define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) +#define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) +#define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) +#define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) +#endif /* NCURSES_OPAQUE */ + +#define wstandout(win) (wattrset(win,A_STANDOUT)) +#define wstandend(win) (wattrset(win,A_NORMAL)) + +#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 NCURSES_WATTR_MACROS +#if NCURSES_WIDECHAR && @NCURSES_EXT_COLORS@ /* NCURSES_EXT_COLORS */ +#define wattrset(win,at) \ + (NCURSES_OK_ADDR(win) \ + ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ + (win)->_attrs = NCURSES_CAST(attr_t, at), \ + OK) \ + : ERR) +#else +#define wattrset(win,at) \ + (NCURSES_OK_ADDR(win) \ + ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ + OK) \ + : ERR) +#endif +#endif /* NCURSES_WATTR_MACROS */ +#endif /* NCURSES_OPAQUE */ + +#define scroll(win) wscrl(win,1) + +#define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) +#define touchline(win, s, c) wtouchln((win), s, c, 1) +#define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) + +#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) +#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) +#define hline(ch, n) whline(stdscr, ch, (n)) +#define vline(ch, n) wvline(stdscr, ch, (n)) + +#define winstr(w, s) winnstr(w, s, -1) +#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, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -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) & A_COLOR) +#define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) + +/* + * pseudo functions for standard screen + */ + +#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 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 attroff(at) wattroff(stdscr,(at)) +#define attron(at) wattron(stdscr,(at)) +#define attrset(at) wattrset(stdscr,(at)) +#define bkgd(ch) wbkgd(stdscr,(ch)) +#define bkgdset(ch) wbkgdset(stdscr,(ch)) +#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 echochar(c) wechochar(stdscr,(c)) +#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 insdelln(n) winsdelln(stdscr,(n)) +#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 scrl(n) wscrl(stdscr,(n)) +#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) + +/* + * mv functions + */ + +#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 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 mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) +#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 ? 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 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 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 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 mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) +#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 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)) + +/* + * Some wide-character functions can be implemented without the extensions. + */ +#if !NCURSES_OPAQUE +#define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) +#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)) + +#if !NCURSES_OPAQUE +#if NCURSES_WATTR_MACROS +#if NCURSES_WIDECHAR && @NCURSES_EXT_COLORS@ /* NCURSES_EXT_COLORS */ +#define wattr_set(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ + (win)->_color = (opts) ? *(int *)(opts) : (p)), \ + OK) \ + : ERR) +#define wattr_get(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)(NCURSES_OK_ADDR(a) \ + ? (*(a) = (win)->_attrs) \ + : OK), \ + (void)(NCURSES_OK_ADDR(p) \ + ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ + : OK), \ + (void)(NCURSES_OK_ADDR(opts) \ + ? (*(int *)(opts) = (win)->_color) \ + : OK), \ + OK) \ + : ERR) +#else /* !(NCURSES_WIDECHAR && NCURSES_EXT_COLORS) */ +#define wattr_set(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ + (attr_t)COLOR_PAIR(p))), \ + OK) \ + : ERR) +#define wattr_get(win,a,p,opts) \ + (NCURSES_OK_ADDR(win) \ + ? ((void)(NCURSES_OK_ADDR(a) \ + ? (*(a) = (win)->_attrs) \ + : OK), \ + (void)(NCURSES_OK_ADDR(p) \ + ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ + : OK), \ + OK) \ + : ERR) +#endif /* (NCURSES_WIDECHAR && NCURSES_EXT_COLORS) */ +#endif /* NCURSES_WATTR_MACROS */ +#endif /* NCURSES_OPAQUE */ + +/* + * 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... + */ +/* define vw_printw vwprintw */ +/* define vw_scanw vwscanw */ + +/* + * Export fallback function for use in C++ binding. + */ +#if !@HAVE_VSSCANF@ /* HAVE_VSSCANF */ +#define vsscanf(a,b,c) _nc_vsscanf(a,b,c) +extern NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); +#endif + +/* + * These macros are extensions - not in X/Open Curses. + */ +#if @NCURSES_EXT_FUNCS@ /* NCURSES_EXT_FUNCS */ +#if !NCURSES_OPAQUE +#define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) +#define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) +#define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) +#define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) +#define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) +#define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) +#define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) +#define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) +#define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) +#define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) +#define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) +#define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) +#define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) +#define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) +#define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) +#endif +#endif /* NCURSES_EXT_FUNCS */ + +/* + * X/Open says this returns a bool; SVr4 also checked for out-of-range line. + * The macro provides compatibility: + */ +#define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) + +#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 NCURSES_REENTRANT + +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_SRESET 0530 /* Soft (partial) reset (unreliable) */ +#define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ diff --git a/ncurses/include/curses.tail b/ncurses/include/curses.tail new file mode 100644 index 0000000000..c1347a9dc0 --- /dev/null +++ b/ncurses/include/curses.tail @@ -0,0 +1,241 @@ +/* $Id: curses.tail,v 1.29 2025/07/26 15:32:01 tom 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 */ + +#if NCURSES_MOUSE_VERSION > 1 +#define NCURSES_MOUSE_MASK(b,m) ((mmask_t)(m) << (((b) - 1) * 5)) +#else +#define NCURSES_MOUSE_MASK(b,m) ((mmask_t)(m) << (((b) - 1) * 6)) +#endif + +#define NCURSES_BUTTON_RELEASED 001UL +#define NCURSES_BUTTON_PRESSED 002UL +#define NCURSES_BUTTON_CLICKED 004UL +#define NCURSES_DOUBLE_CLICKED 010UL +#define NCURSES_TRIPLE_CLICKED 020UL +#define NCURSES_RESERVED_EVENT 040UL + +/* event masks */ +#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) + +/* + * 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 + +#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) + +/* + * If mmask_T is 64-bits, we can define another 6 button stanzas, for a total + * of 11, which happens to be the maximum number supported in the X11 protocol. + */ +#if NCURSES_MOUSE_VERSION > 2 + +#define BUTTON6_RELEASED NCURSES_MOUSE_MASK(6, NCURSES_BUTTON_RELEASED) +#define BUTTON6_PRESSED NCURSES_MOUSE_MASK(6, NCURSES_BUTTON_PRESSED) +#define BUTTON6_CLICKED NCURSES_MOUSE_MASK(6, NCURSES_BUTTON_CLICKED) +#define BUTTON6_DOUBLE_CLICKED NCURSES_MOUSE_MASK(6, NCURSES_DOUBLE_CLICKED) +#define BUTTON6_TRIPLE_CLICKED NCURSES_MOUSE_MASK(6, NCURSES_TRIPLE_CLICKED) + +#define BUTTON7_RELEASED NCURSES_MOUSE_MASK(7, NCURSES_BUTTON_RELEASED) +#define BUTTON7_PRESSED NCURSES_MOUSE_MASK(7, NCURSES_BUTTON_PRESSED) +#define BUTTON7_CLICKED NCURSES_MOUSE_MASK(7, NCURSES_BUTTON_CLICKED) +#define BUTTON7_DOUBLE_CLICKED NCURSES_MOUSE_MASK(7, NCURSES_DOUBLE_CLICKED) +#define BUTTON7_TRIPLE_CLICKED NCURSES_MOUSE_MASK(7, NCURSES_TRIPLE_CLICKED) + +#define BUTTON8_RELEASED NCURSES_MOUSE_MASK(8, NCURSES_BUTTON_RELEASED) +#define BUTTON8_PRESSED NCURSES_MOUSE_MASK(8, NCURSES_BUTTON_PRESSED) +#define BUTTON8_CLICKED NCURSES_MOUSE_MASK(8, NCURSES_BUTTON_CLICKED) +#define BUTTON8_DOUBLE_CLICKED NCURSES_MOUSE_MASK(8, NCURSES_DOUBLE_CLICKED) +#define BUTTON8_TRIPLE_CLICKED NCURSES_MOUSE_MASK(8, NCURSES_TRIPLE_CLICKED) + +#define BUTTON9_RELEASED NCURSES_MOUSE_MASK(9, NCURSES_BUTTON_RELEASED) +#define BUTTON9_PRESSED NCURSES_MOUSE_MASK(9, NCURSES_BUTTON_PRESSED) +#define BUTTON9_CLICKED NCURSES_MOUSE_MASK(9, NCURSES_BUTTON_CLICKED) +#define BUTTON9_DOUBLE_CLICKED NCURSES_MOUSE_MASK(9, NCURSES_DOUBLE_CLICKED) +#define BUTTON9_TRIPLE_CLICKED NCURSES_MOUSE_MASK(9, NCURSES_TRIPLE_CLICKED) + +#define BUTTON10_RELEASED NCURSES_MOUSE_MASK(10, NCURSES_BUTTON_RELEASED) +#define BUTTON10_PRESSED NCURSES_MOUSE_MASK(10, NCURSES_BUTTON_PRESSED) +#define BUTTON10_CLICKED NCURSES_MOUSE_MASK(10, NCURSES_BUTTON_CLICKED) +#define BUTTON10_DOUBLE_CLICKED NCURSES_MOUSE_MASK(10, NCURSES_DOUBLE_CLICKED) +#define BUTTON10_TRIPLE_CLICKED NCURSES_MOUSE_MASK(10, NCURSES_TRIPLE_CLICKED) + +#define BUTTON11_RELEASED NCURSES_MOUSE_MASK(11, NCURSES_BUTTON_RELEASED) +#define BUTTON11_PRESSED NCURSES_MOUSE_MASK(11, NCURSES_BUTTON_PRESSED) +#define BUTTON11_CLICKED NCURSES_MOUSE_MASK(11, NCURSES_BUTTON_CLICKED) +#define BUTTON11_DOUBLE_CLICKED NCURSES_MOUSE_MASK(11, NCURSES_DOUBLE_CLICKED) +#define BUTTON11_TRIPLE_CLICKED NCURSES_MOUSE_MASK(11, NCURSES_TRIPLE_CLICKED) + +#endif + +#else /* NCURSES_MOUSE_VERSION == 1 */ + +#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 /* NCURSES_MOUSE_VERSION >= 1 */ + +#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 +{ + short id; /* ID to distinguish multiple devices */ + int x, y, z; /* event coordinates (character-cell) */ + mmask_t bstate; /* button state bits */ +} +MEVENT; + +extern NCURSES_EXPORT(bool) has_mouse(void); +extern NCURSES_EXPORT(int) getmouse (MEVENT *); +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*, int*, int*, bool); +extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); +extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); +#endif + +#ifndef NCURSES_NOMACROS +#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) +#endif + +/* other non-XSI functions */ + +extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ +extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ +#endif + +/* Debugging : use with libncurses_g.a */ + +extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT(char *) _traceattr (attr_t); +extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); +extern NCURSES_EXPORT(char *) _tracechar (int); +extern NCURSES_EXPORT(char *) _tracechtype (chtype); +extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); +#if NCURSES_WIDECHAR +#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(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); +extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); + +/* trace masks */ +#define TRACE_DISABLE 0x0000 /* turn off tracing */ +#define TRACE_TIMES 0x0001 /* trace user and system times of updates */ +#define TRACE_TPUTS 0x0002 /* trace tputs calls */ +#define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ +#define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ +#define TRACE_CHARPUT 0x0010 /* trace all character outputs */ +#define TRACE_ORDINARY 0x001F /* trace all update actions */ +#define TRACE_CALLS 0x0020 /* trace all curses calls */ +#define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ +#define TRACE_IEVENT 0x0080 /* trace low-level input processing */ +#define TRACE_BITS 0x0100 /* trace state of TTY control bits */ +#define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ +#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_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 */ +extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); +#define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ +#define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ +#define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ +#define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ +#endif + +extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); + +#include + +#ifdef __cplusplus + +#ifndef NCURSES_NOMACROS + +/* these names conflict with STL */ +#undef box +#undef clear +#undef erase +#undef move +#undef refresh + +#endif /* NCURSES_NOMACROS */ + +} +#endif + +#endif /* __NCURSES_H */ diff --git a/ncurses/include/curses.wide b/ncurses/include/curses.wide new file mode 100644 index 0000000000..1e0f197ec6 --- /dev/null +++ b/ncurses/include/curses.wide @@ -0,0 +1,315 @@ +/* $Id: curses.wide,v 1.53 2025/01/18 21:08:32 Branden.Robinson Exp $ */ +/* + * vile:cmode: + * This file is part of ncurses, designed to be appended after curses.h.in + * (see that file for the relevant copyright). + */ +#define _XOPEN_CURSES 1 + +#if NCURSES_WIDECHAR + +extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; + +#define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) + +#define WACS_BSSB NCURSES_WACS('l') +#define WACS_SSBB NCURSES_WACS('m') +#define WACS_BBSS NCURSES_WACS('k') +#define WACS_SBBS NCURSES_WACS('j') +#define WACS_SBSS NCURSES_WACS('u') +#define WACS_SSSB NCURSES_WACS('t') +#define WACS_SSBS NCURSES_WACS('v') +#define WACS_BSSS NCURSES_WACS('w') +#define WACS_BSBS NCURSES_WACS('q') +#define WACS_SBSB NCURSES_WACS('x') +#define WACS_SSSS NCURSES_WACS('n') + +#define WACS_ULCORNER WACS_BSSB +#define WACS_LLCORNER WACS_SSBB +#define WACS_URCORNER WACS_BBSS +#define WACS_LRCORNER WACS_SBBS +#define WACS_RTEE WACS_SBSS +#define WACS_LTEE WACS_SSSB +#define WACS_BTEE WACS_SSBS +#define WACS_TTEE WACS_BSSS +#define WACS_HLINE WACS_BSBS +#define WACS_VLINE WACS_SBSB +#define WACS_PLUS WACS_SSSS + +#define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ +#define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ +#define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ +#define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ +#define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ +#define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ +#define WACS_BULLET NCURSES_WACS('~') /* bullet */ + + /* Teletype 5410v1 symbols */ +#define WACS_LARROW NCURSES_WACS(',') /* arrow left */ +#define WACS_RARROW NCURSES_WACS('+') /* arrow right */ +#define WACS_DARROW NCURSES_WACS('.') /* arrow down */ +#define WACS_UARROW NCURSES_WACS('-') /* arrow up */ +#define WACS_BOARD NCURSES_WACS('h') /* board of squares */ +#define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ +#define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ + + /* ncurses extensions */ +#define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ +#define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ +#define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ +#define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ +#define WACS_PI NCURSES_WACS('{') /* Pi */ +#define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ +#define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ + + /* double lines */ +#define WACS_BDDB NCURSES_WACS('C') +#define WACS_DDBB NCURSES_WACS('D') +#define WACS_BBDD NCURSES_WACS('B') +#define WACS_DBBD NCURSES_WACS('A') +#define WACS_DBDD NCURSES_WACS('G') +#define WACS_DDDB NCURSES_WACS('F') +#define WACS_DDBD NCURSES_WACS('H') +#define WACS_BDDD NCURSES_WACS('I') +#define WACS_BDBD NCURSES_WACS('R') +#define WACS_DBDB NCURSES_WACS('Y') +#define WACS_DDDD NCURSES_WACS('E') + +#define WACS_D_ULCORNER WACS_BDDB +#define WACS_D_LLCORNER WACS_DDBB +#define WACS_D_URCORNER WACS_BBDD +#define WACS_D_LRCORNER WACS_DBBD +#define WACS_D_RTEE WACS_DBDD +#define WACS_D_LTEE WACS_DDDB +#define WACS_D_BTEE WACS_DDBD +#define WACS_D_TTEE WACS_BDDD +#define WACS_D_HLINE WACS_BDBD +#define WACS_D_VLINE WACS_DBDB +#define WACS_D_PLUS WACS_DDDD + + /* thick lines */ +#define WACS_BTTB NCURSES_WACS('L') +#define WACS_TTBB NCURSES_WACS('M') +#define WACS_BBTT NCURSES_WACS('K') +#define WACS_TBBT NCURSES_WACS('J') +#define WACS_TBTT NCURSES_WACS('U') +#define WACS_TTTB NCURSES_WACS('T') +#define WACS_TTBT NCURSES_WACS('V') +#define WACS_BTTT NCURSES_WACS('W') +#define WACS_BTBT NCURSES_WACS('Q') +#define WACS_TBTB NCURSES_WACS('X') +#define WACS_TTTT NCURSES_WACS('N') + +#define WACS_T_ULCORNER WACS_BTTB +#define WACS_T_LLCORNER WACS_TTBB +#define WACS_T_URCORNER WACS_BBTT +#define WACS_T_LRCORNER WACS_TBBT +#define WACS_T_RTEE WACS_TBTT +#define WACS_T_LTEE WACS_TTTB +#define WACS_T_BTEE WACS_TTBT +#define WACS_T_TTEE WACS_BTTT +#define WACS_T_HLINE WACS_BTBT +#define WACS_T_VLINE WACS_TBTB +#define WACS_T_PLUS WACS_TTTT + +/* + * Function prototypes for wide-character operations. + * + * "generated" comments should include ":WIDEC" to make the corresponding + * functions ifdef'd in lib_gen.c + * + * "implemented" comments do not need this marker. + */ + +extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ +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*); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ +extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ +extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ +extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ +extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ +extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ +extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ +extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ +extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ +extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ +extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ +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*); /* implemented */ +extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ +extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ +extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* generated:WIDEC */ +extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ +extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(erasewchar) (SCREEN*, wchar_t *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(killwchar) (SCREEN*, wchar_t *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ +extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ +#endif + +#ifndef NCURSES_NOMACROS + +/* + * XSI curses macros for XPG4 conformance. + */ +#define add_wch(c) wadd_wch(stdscr,(c)) +#define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) +#define add_wchstr(str) wadd_wchstr(stdscr,(str)) +#define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) +#define addwstr(wstr) waddwstr(stdscr,(wstr)) +#define bkgrnd(c) wbkgrnd(stdscr,(c)) +#define bkgrndset(c) wbkgrndset(stdscr,(c)) +#define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) +#define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),NULL,NULL,NULL,NULL) +#define echo_wchar(c) wecho_wchar(stdscr,(c)) +#define get_wch(c) wget_wch(stdscr,(c)) +#define get_wstr(t) wget_wstr(stdscr,(t)) +#define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) +#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_wchstr(stdscr,(c)) +#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_wstr(stdscr,(t)) +#define inwstr(c) winwstr(stdscr,(c)) +#define vline_set(c,n) wvline_set(stdscr,(c),(n)) +#define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) +#define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) +#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) + +#if !NCURSES_OPAQUE +#define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) +#endif + +#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) +#define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) +#define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) +#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) +#define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) +#define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) +#define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) +#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_wchstr(stdscr,(y),(x),(c)) +#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_wstr(stdscr,(y),(x),(t)) +#define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) +#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((win),(c))) +#define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) +#define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) +#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) +#define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) +#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 : wget_wstr((win),(t))) +#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((win),(c),(n))) +#define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) +#define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) +#define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) +#define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) +#define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) +#define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) +#define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) + +#endif /* NCURSES_NOMACROS */ + +#if defined(TRACE) || defined(NCURSES_TEST) +extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); +extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); +#endif + +#endif /* NCURSES_WIDECHAR */ diff --git a/ncurses/include/edit_cfg.sh b/ncurses/include/edit_cfg.sh new file mode 100755 index 0000000000..29accf0f5f --- /dev/null +++ b/ncurses/include/edit_cfg.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# $Id: edit_cfg.sh,v 1.16 2022/07/16 18:02:32 tom Exp $ +############################################################################## +# Copyright 2020,2022 Thomas E. Dickey # +# Copyright 1998-2001,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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,1997,2000 +# +# Edit the default value of the term.h file based on the autoconf-generated +# values: +# +# $1 = ncurses_cfg.h +# $2 = term.h +# +BAK=save$$ +TMP=edit$$ +trap "rm -f $BAK $TMP; exit 1" 1 2 3 15 +trap "rm -f $BAK $TMP" 0 +for name in \ + HAVE_TCGETATTR \ + HAVE_TERMIOS_H \ + HAVE_TERMIO_H \ + BROKEN_LINKER +do + mv "$2" "$BAK" + if ( grep "[ ]${name}[ ]" "$1" >$TMP 2>&1 ) + then + value=1 + else + value=0 + fi + echo '** edit: '$name $value + sed \ + -e "s@#define ${name}.*\$@#define $name $value@" \ + -e "s@#if $name\$@#if $value /* $name */@" \ + -e "s@#if !$name\$@#if $value /* !$name */@" \ + "$BAK" >"$2" + if (cmp -s "$2" "$BAK") + then + mv "$BAK" "$2" + else + rm -f "$BAK" + fi +done diff --git a/ncurses/include/hashed_db.h b/ncurses/include/hashed_db.h new file mode 100644 index 0000000000..60f4f539c7 --- /dev/null +++ b/ncurses/include/hashed_db.h @@ -0,0 +1,75 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 2006-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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.9 2020/02/02 23:34:34 tom Exp $ + */ + +#ifndef HASHED_DB_H +#define HASHED_DB_H 1 + +#include + +#include + +#if USE_HASHED_DB + +#define DB_DBM_HSEARCH 0 /* quiet gcc -Wundef with db6 */ + +#include + +#ifndef DBM_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/ncurses/include/headers b/ncurses/include/headers new file mode 100644 index 0000000000..3e20d1ccf6 --- /dev/null +++ b/ncurses/include/headers @@ -0,0 +1,55 @@ +# $Id: headers,v 1.22 2025/12/26 23:33:03 tom Exp $ +############################################################################## +# Copyright 2020-2023,2025 Thomas E. Dickey # +# Copyright 1998-2012,2013 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +curses.h +unctrl.h +ncurses_dll.h + +# Support for termcap (and tic, etc.), which can be a separate library +@ termlib +term.h +termcap.h + +# Header used by tack 1.08 +@ ticlib +$(srcdir)/term_entry.h + +# Porting +@ port_win32con +nc_win32.h +@ port_win32 +nc_win32.h + +# vile:makemode diff --git a/ncurses/include/nc_access.h b/ncurses/include/nc_access.h new file mode 100644 index 0000000000..23d4a1d674 --- /dev/null +++ b/ncurses/include/nc_access.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * Copyright 2021,2023 Thomas E. Dickey * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: nc_access.h,v 1.6 2023/05/06 10:54:55 tom Exp $ */ + +#ifndef NC_ACCESS_included +#define NC_ACCESS_included 1 +/* *INDENT-OFF* */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Turn off the 'use_terminfo_vars()' symbol to limit access to environment + * variables when running with privileges. + */ +#if defined(USE_ROOT_ENVIRON) && defined(USE_SETUID_ENVIRON) +#define use_terminfo_vars() 1 +#else +#define use_terminfo_vars() _nc_env_access() +#endif + +extern NCURSES_EXPORT(int) _nc_env_access (void); + +/* + * Turn off this symbol to limit access to files when running setuid. + */ +#ifdef USE_ROOT_ACCESS + +#define safe_fopen(name,mode) fopen(name,mode) +#define safe_open2(name,flags) open(name,flags) +#define safe_open3(name,flags,mode) open(name,flags,mode) + +#else + +#define safe_fopen(name,mode) _nc_safe_fopen(name,mode) +#define safe_open2(name,flags) _nc_safe_open3(name,flags,0) +#define safe_open3(name,flags,mode) _nc_safe_open3(name,flags,mode) +extern NCURSES_EXPORT(FILE *) _nc_safe_fopen (const char *, const char *); +extern NCURSES_EXPORT(int) _nc_safe_open3 (const char *, int, mode_t); + +#endif + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ + +#endif /* NC_ACCESS_included */ diff --git a/ncurses/include/nc_alloc.h b/ncurses/include/nc_alloc.h new file mode 100644 index 0000000000..f17a8ba0c7 --- /dev/null +++ b/ncurses/include/nc_alloc.h @@ -0,0 +1,151 @@ +/**************************************************************************** + * Copyright 2019-2021,2025 Thomas E. Dickey * + * Copyright 1998-2013,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ +/* $Id: nc_alloc.h,v 1.36 2025/03/01 15:02:06 tom Exp $ */ + +#ifndef NC_ALLOC_included +#define NC_ALLOC_included 1 +/* *INDENT-OFF* */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(HAVE_LIBDMALLOC) && HAVE_LIBDMALLOC +#include +#undef strndup /* workaround for #define in GLIBC 2.7 */ +#include /* Gray Watson's library */ +#else +#undef HAVE_LIBDMALLOC +#define HAVE_LIBDMALLOC 0 +#endif + +#if defined(HAVE_LIBDBMALLOC) && HAVE_LIBDBMALLOC +#include /* Conor Cahill's library */ +#else +#undef HAVE_LIBDBMALLOC +#define HAVE_LIBDBMALLOC 0 +#endif + +#if defined(HAVE_LIBMPATROL) && HAVE_LIBMPATROL +#include /* Memory-Patrol library */ +#else +#undef HAVE_LIBMPATROL +#define HAVE_LIBMPATROL 0 +#endif + +#ifndef NO_LEAKS +#define NO_LEAKS 0 +#endif + +#if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS +#define HAVE_NC_FREEALL 1 +struct termtype; +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_DEPRECATED("use exit_terminfo"); + +#ifdef NCURSES_INTERNALS +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_tic(int); +extern void _nc_leaks_dump_entry(void); +extern NCURSES_EXPORT(void) _nc_leaks_tic(void); + +#if NCURSES_SP_FUNCS +extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int); +#endif +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int); + +#else /* !NCURSES_INTERNALS */ +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses"); +#endif + +#define ExitProgram(code) exit_curses(code) + +#else +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses"); +#endif /* NO_LEAKS, etc */ + +#ifndef HAVE_NC_FREEALL +#define HAVE_NC_FREEALL 0 +#endif + +#ifndef ExitProgram +#define ExitProgram(code) exit(code) +#endif + +/* doalloc.c */ +extern NCURSES_EXPORT(void *) _nc_doalloc(void *, size_t); +#if !HAVE_STRDUP +#undef strdup +#define strdup _nc_strdup +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((size_t)(elts)*sizeof(type)) +#define typeCalloc(type,elts) (type *)calloc((size_t)(elts),sizeof(type)) +#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (size_t)(elts)*sizeof(type)) + +/* provide for using VLAs if supported, otherwise assume alloca() */ + +#ifndef __STDC_VERSION__ +#define __STDC_VERSION__ 0 +#endif + +#ifndef __STDC_NO_VLA__ +#define __STDC_NO_VLA__ 1 +#endif + +#if __STDC_VERSION__ >= 19901L && (__STDC_VERSION__ < 201000L || !__STDC_NO_VLA__) +#define MakeArray(name,type,count) type name[count] +#else +#if HAVE_ALLOCA_H +#include +#elif HAVE_MALLOC_H +#include +#endif +#define MakeArray(name,type,count) type *name = (type*) alloca(sizeof(type) * (size_t) (count)) +#endif + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ + +#endif /* NC_ALLOC_included */ diff --git a/ncurses/include/nc_panel.h b/ncurses/include/nc_panel.h new file mode 100644 index 0000000000..68d39a22b2 --- /dev/null +++ b/ncurses/include/nc_panel.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2009,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997 * + * and: Thomas E. Dickey * + ****************************************************************************/ + +/* + * $Id: nc_panel.h,v 1.10 2020/02/02 23:34:34 tom Exp $ + * + * nc_panel.h + * + * Headerfile to provide an interface for the panel layer into + * the SCREEN structure of the ncurses core. + */ + +#ifndef NC_PANEL_H +#define NC_PANEL_H 1 + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct panel; /* Forward Declaration */ + + struct panelhook + { + struct panel *top_panel; + struct panel *bottom_panel; + struct panel *stdscr_pseudo_panel; +#if NO_LEAKS + int (*destroy) (struct panel *); +#endif + }; + + struct screen; /* Forward declaration */ +/* Retrieve the panelhook of the specified screen */ + extern NCURSES_EXPORT(struct panelhook *) + _nc_panelhook (void); +#if NCURSES_SP_FUNCS + extern NCURSES_EXPORT(struct panelhook *) + NCURSES_SP_NAME(_nc_panelhook) (SCREEN *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NC_PANEL_H */ diff --git a/ncurses/include/nc_string.h b/ncurses/include/nc_string.h new file mode 100644 index 0000000000..0d107f285b --- /dev/null +++ b/ncurses/include/nc_string.h @@ -0,0 +1,93 @@ +/**************************************************************************** + * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 2012-2013,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012 * + ****************************************************************************/ + +#ifndef STRING_HACKS_H +#define STRING_HACKS_H 1 + +#include + +#if HAVE_BSD_STRING_H +#include +#endif + +/* + * $Id: nc_string.h,v 1.9 2021/04/25 00:10:43 tom Exp $ + * + * String-hacks. Use these macros to stifle warnings on (presumably) correct + * uses of strcat, strcpy and sprintf. + * + * By the way - + * A fundamental limitation of the interfaces (and frequent issue in bug + * reports using these functions) is that sizes are passed as unsigned values + * (with associated sign-extension problems), limiting their effectiveness + * when checking for buffer overflow. + */ + +#ifdef __cplusplus +#define NCURSES_VOID /* nothing */ +#else +#define NCURSES_VOID (void) +#endif + +#if USE_STRING_HACKS && HAVE_STRLCAT +#define _nc_STRCAT(d,s,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n)) +#define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m)) +#else +#define _nc_STRCAT(d,s,n) NCURSES_VOID strcat((d),(s)) +#define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strncat((d),(s),(n)) +#endif + +#if USE_STRING_HACKS && HAVE_STRLCPY +#define _nc_STRCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n)) +#define _nc_STRNCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n)) +#else +#define _nc_STRCPY(d,s,n) NCURSES_VOID strcpy((d),(s)) +#define _nc_STRNCPY(d,s,n) NCURSES_VOID strncpy((d),(s),(n)) +#endif + +#if USE_STRING_HACKS && HAVE_SNPRINTF +#ifdef __cplusplus +#define _nc_SPRINTF NCURSES_VOID snprintf +#else +#define _nc_SPRINTF NCURSES_VOID (snprintf) +#endif +#define _nc_SLIMIT(n) NCURSES_CAST(size_t,n), +#else +#define _nc_SPRINTF NCURSES_VOID sprintf +#define _nc_SLIMIT(n) /* nothing */ +#endif + +#endif /* STRING_HACKS_H */ diff --git a/ncurses/include/nc_termios.h b/ncurses/include/nc_termios.h new file mode 100644 index 0000000000..29df6c976c --- /dev/null +++ b/ncurses/include/nc_termios.h @@ -0,0 +1,88 @@ +/**************************************************************************** + * Copyright 2018-2020,2025 Thomas E. Dickey * + * Copyright 2011-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2011 * + ****************************************************************************/ + +/* $Id: nc_termios.h,v 1.10 2025/10/18 17:53:13 tom Exp $ */ + +#ifndef NC_TERMIOS_included +#define NC_TERMIOS_included 1 + +#include + +#if HAVE_TERMIOS_H && HAVE_TCGETATTR + +#else /* !HAVE_TERMIOS_H */ + +#if HAVE_TERMIO_H + +/* Add definitions to make termio look like termios. + * But ifdef it, since there are some implementations + * that try to do this for us in a fake . + */ +#ifndef TCSADRAIN +#define TCSADRAIN TCSETAW +#endif +#ifndef TCSAFLUSH +#define TCSAFLUSH TCSETAF +#endif +#ifndef tcsetattr +#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg) +#endif +#ifndef tcgetattr +#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg) +#endif +#ifndef cfgetospeed +#define cfgetospeed(t) ((t)->c_cflag & CBAUD) +#endif +#ifndef TCIFLUSH +#define TCIFLUSH 0 +#endif +#ifndef tcflush +#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg) +#endif + +#if defined(_WIN32) +#undef TERMIOS +#endif + +#else /* !HAVE_TERMIO_H */ + +#undef TERMIOS + +#endif /* HAVE_TERMIO_H */ + +#endif /* HAVE_TERMIOS_H */ + +#endif /* NC_TERMIOS_included */ diff --git a/ncurses/include/nc_tparm.h b/ncurses/include/nc_tparm.h new file mode 100644 index 0000000000..4f6646fb46 --- /dev/null +++ b/ncurses/include/nc_tparm.h @@ -0,0 +1,97 @@ +/**************************************************************************** + * Copyright 2018-2023,2025 Thomas E. Dickey * + * Copyright 2006-2012,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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.13 2025/01/04 23:42:30 tom Exp $ */ + +#ifndef NC_TPARM_included +#define NC_TPARM_included 1 + +#include +#include + +/* + * Cast parameters past the formatting-string for tparm() to match the + * assumption of the varargs code. + */ +#ifndef TPARM_ARG +#ifdef NCURSES_TPARM_ARG +#define TPARM_ARG NCURSES_TPARM_ARG +#else +#define TPARM_ARG long +#endif +#endif /* TPARAM_ARG */ + +#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_0(a) TPARM_1(a,0) +#endif + +#ifdef NCURSES_INTERNALS +#define TIPARM_0(s) _nc_tiparm(0,s) +#define TIPARM_1(s,a) _nc_tiparm(1,s,a) +#define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b) +#define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c) +#define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d) +#define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e) +#define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f) +#define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g) +#define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h) +#define TIPARM_9(s,a,b,c,d,e,f,g,h,i) _nc_tiparm(9,s,a,b,c,d,e,f,g,h,i) +#define TIPARM_N(N,s,a,b,c,d,e,f,g,h,i) _nc_tiparm(N,s,a,b,c,d,e,f,g,h,i) +#endif + +#endif /* NC_TPARM_included */ diff --git a/ncurses/include/nc_win32.h.in b/ncurses/include/nc_win32.h.in new file mode 100644 index 0000000000..68321f18b6 --- /dev/null +++ b/ncurses/include/nc_win32.h.in @@ -0,0 +1,215 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2008-2010,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 2008-on * + ****************************************************************************/ + +/* $Id: nc_win32.h.in,v 1.19 2025/12/26 23:32:43 tom Exp $ */ + +#ifndef NC_WIN32_H +#define NC_WIN32_H 1 + +#include + +#if defined(_WIN32) || defined(_WIN64) || defined(USE_WIN32CON_DRIVER) + +#if @USE_NAMED_PIPES@ /* USE_NAMED_PIPES */ + +#ifndef _NC_WINDOWS_NATIVE +#define _NC_WINDOWS_NATIVE +#endif + +#ifdef TERMIOS +#error TERMIOS must not be defined on Windows +#endif + +/* + Minimum requirement for named pipes is Windows Vista or Server2008, + aka Windows NT 6.0 +*/ +#ifdef WINVER +# if WINVER < 0x0600 +# error WINVER must at least be 0x0600 +# endif +#else +# define WINVER 0x0600 +#endif + +#undef _NC_CHECK_MINTTY +#if WINVER >= 0x0600 +#define _NC_CHECK_MINTTY +#endif + +#include + +#else /* !USE_NAMED_PIPES */ + +#ifdef WINVER +# if WINVER < 0x0501 +# error WINVER must at least be 0x0501 +# endif +#else +# define WINVER 0x0501 +#endif + +#include + +#undef sleep +#define sleep(n) Sleep((n) * 1000) + +#endif /* USE_NAMED_PIPES */ + +#if HAVE_SYS_TIME_H +#include /* for struct timeval */ +#endif + +#ifdef _MSC_VER +#include /* for struct timeval */ +#endif + +#include /* for uint32_t */ + +/* + * Allow for build-override, e.g., MinGW used "cygwin". + */ +#ifndef DEFAULT_TERM_ENV +#define DEFAULT_TERM_ENV "ms-terminal" +#endif + +#undef VALID_TERM_ENV +#define VALID_TERM_ENV(term_env, no_terminal) \ + (term_env = (NonEmpty(term_env) \ + ? term_env \ + : (_nc_console_vt_supported() \ + ? DEFAULT_TERM_ENV \ + : no_terminal)), \ + NonEmpty(term_env)) + + /* + * Various Console mode definitions + */ + + /* Flags to enable virtual Terminal processing */ +#define VT_FLAG_OUT ENABLE_VIRTUAL_TERMINAL_PROCESSING +#define VT_FLAG_IN ENABLE_VIRTUAL_TERMINAL_INPUT + + /* Default flags for input/output modes */ +#define CONMODE_IN_DEFAULT (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT) +#define CONMODE_OUT_DEFAULT (ENABLE_PROCESSED_OUTPUT | DISABLE_NEWLINE_AUTO_RETURN | ENABLE_LVB_GRID_WORLDWIDE) + + /* Flags to reset from RAW/CBREAK */ +#define CONMODE_NORAW (ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT) +#define CONMODE_NOCBREAK (ENABLE_LINE_INPUT) + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(CURSES_PRIV_H) || defined(TEST_PRIV_H) + +#if !HAVE_CLOCK_GETTIME && !HAVE_GETTIMEOFDAY +extern NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *); +#undef HAVE_GETTIMEOFDAY +#define HAVE_GETTIMEOFDAY 2 +#define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz) +#endif + +#endif /* defined(CURSES_PRIV_H) || defined(TEST_PRIV_H) */ + +#if !HAVE_WCWIDTH +#undef wcwidth +#define wcwidth(ucs) _nc_wcwidth((wchar_t)(ucs)) +extern NCURSES_EXPORT(int) _nc_wcwidth(uint32_t); +#endif + +typedef struct +{ + DWORD dwFlagIn; + DWORD dwFlagOut; +} ConsoleMode; + +#define CON_NUMPAIRS 64 +typedef struct { + BOOL initialized; + BOOL buffered; + BOOL window_only; + BOOL progMode; + BOOL isMinTTY; + BOOL isTermInfoConsole; + HANDLE out; + HANDLE inp; + HANDLE hdl; + HANDLE lastOut; + int numButtons; + LPDWORD ansi_map; + LPDWORD map; + LPDWORD rmap; + WORD pairs[CON_NUMPAIRS]; + COORD origin; + CHAR_INFO *save_screen; + COORD save_size; + SMALL_RECT save_region; + CONSOLE_SCREEN_BUFFER_INFO SBI; + CONSOLE_SCREEN_BUFFER_INFO save_SBI; + CONSOLE_CURSOR_INFO save_CI; + ConsoleMode originalMode; +} ConsoleInfo; + +extern NCURSES_EXPORT_VAR(ConsoleInfo) _nc_CONSOLE; +#define WINCONSOLE _nc_CONSOLE + +#ifdef __cplusplus +} +#endif + +#ifdef CURSES_PRIV_H /* test.priv.h just needs the preceding */ +#include +#endif + +#if USE_DOS_PATHS +NCURSES_EXPORT(const char *) _nc_to_dospath(const char *, char *); +#define FixupPathname(path) \ + char fixed_pathname[PATH_MAX]; \ + path = _nc_to_dospath(path, fixed_pathname) +#define FixupPathname2(path,buffer) \ + path = _nc_to_dospath(path, buffer) +#endif + +#undef ttyname +#define ttyname(fd) NULL + +#endif /* _WIN32 || _WIN64 */ + +#endif /* NC_WIN32_H */ diff --git a/ncurses/include/ncurses_cfg.hin b/ncurses/include/ncurses_cfg.hin new file mode 100644 index 0000000000..fe51855125 --- /dev/null +++ b/ncurses/include/ncurses_cfg.hin @@ -0,0 +1,77 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + ****************************************************************************/ +/* + * $Id: ncurses_cfg.hin,v 1.15 2024/06/08 14:04:14 tom Exp $ + * + * Both ncurses_cfg.h and ncurses_def.h are internal header-files used when + * building ncurses. + * + * This is a template-file used to generate the "ncurses_cfg.h" file. + * + * Rather than list every definition, the configuration script substitutes the + * definitions that it finds using 'sed'. You need a patch (original date + * 971222) to autoconf 2.12 or 2.13 to do this. + * + * See: + * https://invisible-island.net/autoconf/ + * https://invisible-island.net/archives/autoconf/ + */ +#ifndef NC_CONFIG_H +#define NC_CONFIG_H +@DEFS@ + +#include + + /* The C compiler may not treat these properly but C++ has to */ +#ifdef __cplusplus +#undef const +#undef inline +#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 + +/* + * vile:cmode + */ +#endif /* NC_CONFIG_H */ diff --git a/ncurses/include/ncurses_defs b/ncurses/include/ncurses_defs new file mode 100644 index 0000000000..d80b55e7b7 --- /dev/null +++ b/ncurses/include/ncurses_defs @@ -0,0 +1,295 @@ +# $Id: ncurses_defs,v 1.123 2025/12/27 12:45:14 tom Exp $ +############################################################################## +# Copyright 2018-2024,2025 Thomas E. Dickey # +# Copyright 2000-2016,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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. # +############################################################################## +# +# See "MKncurses_def.sh" for an explanation. +# +# (hint: don't try to define NDEBUG ;-) + +BROKEN_LINKER +BSD_TPUTS +CGETENT_CONST /* nothing */ +CPP_HAS_PARAM_INIT +CURSES_ACS_ARRAY acs_map +CURSES_WACS_ARRAY _nc_wacs +DECL_ERRNO +ETIP_NEEDS_MATH_H +GCC_NORETURN /* nothing */ +GCC_UNUSED /* nothing */ +HAVE_ALLOCA_H +HAVE_ALLOC_PAIR +HAVE_ASSUME_DEFAULT_COLORS +HAVE_BIG_CORE +HAVE_BSD_CGETENT +HAVE_BSD_SIGNAL_H +HAVE_BSD_STRING_H +HAVE_BTOWC +HAVE_BUILTIN_H +HAVE_CC_T +HAVE_CHGAT 1 +HAVE_CLOCK_GETTIME +HAVE_COLOR_CONTENT 1 +HAVE_COLOR_SET 1 +HAVE_CONSISTENT_GETENV +HAVE_CONSISTENT_MB_LEN_MAX +HAVE_COPYWIN 1 +HAVE_CURSCR 1 +HAVE_CURSES_DATA_TABSIZE 1 +HAVE_CURSES_DATA_TTYTYPE 1 +HAVE_CURSES_TRACE 1 +HAVE_DELSCREEN 1 +HAVE_DERWIN 1 +HAVE_DIRENT_H +HAVE_DUPWIN 1 +HAVE_ERRNO +HAVE_EXIT_CURSES 1 +HAVE_EXIT_TERMINFO 1 +HAVE_FCNTL_H +HAVE_FILTER 1 +HAVE_FORM_H +HAVE_FPATHCONF +HAVE_GETAUXVAL +HAVE_GETBEGX 1 +HAVE_GETCURX 1 +HAVE_GETCWD +HAVE_GETEGID +HAVE_GETEUID +HAVE_GETMAXX 1 +HAVE_GETNSTR +HAVE_GETOPT_H +HAVE_GETPARX 1 +HAVE_GETTIMEOFDAY +HAVE_GETTTYNAM +HAVE_GETUID +HAVE_GETWIN 1 +HAVE_GPM_H +HAVE_GPP_BUILTIN_H +HAVE_GXX_BUILTIN_H +HAVE_HALFDELAY 1 +HAVE_HAS_KEY +HAVE_INIT_EXTENDED_COLOR +HAVE_INTTYPES_H +HAVE_IOSTREAM +HAVE_ISASCII +HAVE_ISSETUGID +HAVE_LANGINFO_CODESET +HAVE_LIBC_H +HAVE_LIBDBMALLOC +HAVE_LIBDMALLOC +HAVE_LIBFORM +HAVE_LIBGPM +HAVE_LIBMENU +HAVE_LIBMPATROL +HAVE_LIBPANEL +HAVE_LIB_PCRE2 +HAVE_LIMITS_H +HAVE_LINK +HAVE_LOCALECONV +HAVE_LOCALE_H +HAVE_LONG_FILE_NAMES +HAVE_MALLOC_H +HAVE_MATH_FUNCS +HAVE_MATH_H +HAVE_MBLEN +HAVE_MBRLEN +HAVE_MBRTOWC +HAVE_MBSRTOWCS +HAVE_MBSTOWCS +HAVE_MBTOWC +HAVE_MENU_H +HAVE_MKSTEMP +HAVE_MVDERWIN 1 +HAVE_MVVLINE 1 +HAVE_MVWIN 1 +HAVE_MVWVLINE 1 +HAVE_NANOSLEEP +HAVE_NAPMS 1 +HAVE_NC_ALLOC_H +HAVE_NEWPAD 1 +HAVE_PANEL_H +HAVE_PATH_TTYS +HAVE_PCRE2POSIX_H +HAVE_PCREPOSIX_H +HAVE_POLL +HAVE_POLL_H +HAVE_PURIFY +HAVE_PUTENV +HAVE_PUTWC +HAVE_PUTWIN 1 +HAVE_REGEXPR_H_FUNCS +HAVE_REGEXP_H_FUNCS +HAVE_REGEX_H_FUNCS +HAVE_REMOVE +HAVE_RESET_COLOR_PAIRS +HAVE_RESIZETERM +HAVE_RESIZE_TERM +HAVE_RESTARTTERM 1 +HAVE_RIPOFFLINE 1 +HAVE_SCR_DUMP 1 +HAVE_SELECT +HAVE_SETBUF +HAVE_SETBUFFER +HAVE_SETENV +HAVE_SETFSUID +HAVE_SETUPTERM 1 +HAVE_SETVBUF +HAVE_SGTTY_H +HAVE_SIGACTION +HAVE_SIGSET_T +HAVE_SIGVEC +HAVE_SIZECHANGE +HAVE_SLK_COLOR +HAVE_SLK_INIT 1 +HAVE_SNPRINTF +HAVE_SPEED_T +HAVE_STDINT_H +HAVE_STRDUP +HAVE_STRLCAT +HAVE_STRLCPY +HAVE_STRSTR +HAVE_SYMLINK +HAVE_SYSCONF +HAVE_SYS_AUXV_H +HAVE_SYS_BSDTYPES_H +HAVE_SYS_FSUID_H +HAVE_SYS_IOCTL_H +HAVE_SYS_PARAM_H +HAVE_SYS_POLL_H +HAVE_SYS_SELECT_H +HAVE_SYS_TERMIO_H +HAVE_SYS_TIMES_H +HAVE_SYS_TIME_H +HAVE_SYS_TIME_SELECT +HAVE_TCFLAG_T +HAVE_TCGETATTR +HAVE_TCGETPGRP +HAVE_TELL +HAVE_TERMATTRS 1 +HAVE_TERMCAP_H 1 +HAVE_TERMIOS_H +HAVE_TERMIO_H +HAVE_TERMNAME 1 +HAVE_TERM_ENTRY_H 1 +HAVE_TERM_H 1 +HAVE_TGETENT 1 +HAVE_TIGETNUM 1 +HAVE_TIGETSTR 1 +HAVE_TIMES +HAVE_TIPARM 1 +HAVE_TIPARM_S 1 +HAVE_TISCAN_S 1 +HAVE_TPUTS_SP +HAVE_TSEARCH +HAVE_TYPEAHEAD 1 +HAVE_TYPEINFO +HAVE_TYPE_ATTR_T +HAVE_TYPE_SIGACTION +HAVE_UNCTRL_H 1 +HAVE_UNGET_WCH 1 +HAVE_UNISTD_H +HAVE_UNLINK +HAVE_USE_DEFAULT_COLORS +HAVE_USE_ENV 1 +HAVE_USE_EXTENDED_NAMES NCURSES_XNAMES +HAVE_USE_SCREEN +HAVE_USE_WINDOW +HAVE_VFSCANF +HAVE_VIDPUTS 1 +HAVE_VID_PUTS 1 +HAVE_VSNPRINTF +HAVE_VSSCANF +HAVE_VW_PRINTW 1 +HAVE_WCHGAT 1 +HAVE_WCSRTOMBS +HAVE_WCSTOMBS +HAVE_WCTOB +HAVE_WCTOMB +HAVE_WCTYPE_H +HAVE_WCWIDTH +HAVE_WINSDELLN 1 +HAVE_WINSSTR 1 +HAVE_WMEMCHR +HAVE_WORKING_POLL +HAVE_WRESIZE +HAVE_WSYNCDOWN 1 +HAVE__DOSCAN +HAVE__NC_TPARM_ANALYZE 1 +HAVE__TRACEF +MIXEDCASE_FILENAMES +NCURSES_CHAR_EQ +NCURSES_EXPANDED +NCURSES_EXT_COLORS +NCURSES_EXT_FUNCS +NCURSES_EXT_PUTWIN +NCURSES_NO_PADDING +NCURSES_OSPEED_COMPAT +NCURSES_PATHSEP ':' +NCURSES_RGB_COLORS +NCURSES_WIDECHAR +NEED_PTEM_H +NO_LEAKS +PURE_TERMINFO +STDC_HEADERS +SVR4_ACTION +SVR4_TERMIO +SYSTEM_NAME "unknown" +TERMINFO "none" +TERMPATH "none" +TIME_WITH_SYS_TIME +TYPEOF_CHTYPE +USE_COLORFGBG +USE_DOS_PATHS +USE_FOPEN_BIN_R +USE_GETCAP +USE_GETCAP_CACHE +USE_HARD_TABS +USE_HASHED_DB +USE_HASHMAP +USE_HOME_TERMINFO +USE_LINKS +USE_MY_MEMMOVE +USE_NAMED_PIPES +USE_OK_BCOPY +USE_PTHREADS_EINTR +USE_RCS_IDS +USE_REENTRANT +USE_SAFE_SPRINTF +USE_SCROLL_HINTS +USE_SIGWINCH +USE_STDBOOL_H +USE_STRING_HACKS +USE_SYMLINKS +USE_SYSMOUSE +USE_TERM_DRIVER +USE_WEAK_SYMBOLS +USE_WIDEC_SUPPORT +USE_XMC_SUPPORT diff --git a/ncurses/include/ncurses_dll.h.in b/ncurses/include/ncurses_dll.h.in new file mode 100644 index 0000000000..9cfb6fec6c --- /dev/null +++ b/ncurses/include/ncurses_dll.h.in @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright 2018-2020,2023 Thomas E. Dickey * + * Copyright 2009,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: ncurses_dll.h.in,v 1.18 2023/05/06 20:12:43 tom Exp $ */ + +#ifndef NCURSES_DLL_H_incl +#define NCURSES_DLL_H_incl 1 + +/* + * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64. + */ +#if defined(__MINGW64__) + +#ifndef _WIN64 +#define _WIN64 1 +#endif + +#elif defined(__MINGW32__) + +#ifndef _WIN32 +#define _WIN32 1 +#endif + +/* 2014-08-02 workaround for broken MinGW compiler. + * Oddly, only TRACE is mapped to trace - the other -D's are okay. + * suggest TDM as an alternative. + */ +#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) + +#ifdef trace +#undef trace +#define TRACE +#endif + +#endif /* broken compiler */ + +#endif /* MingW */ + +/* + * For reentrant code, we map the various global variables into SCREEN by + * using functions to access them. + */ +#define NCURSES_PUBLIC_VAR(name) @NCURSES_WRAP_PREFIX@##name + +#if defined(BUILDING_NCURSES) +# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT +#else +# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT +#endif + +#define NCURSES_WRAPPED_VAR(type,name) extern NCURSES_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) + +#define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API +#define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type + +/* + * These symbols hide dllimport/dllexport, for compilers which care about it. + */ +#if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64)) +# if defined(NCURSES_STATIC) /* "static" here only implies "not-a-DLL" */ +# define NCURSES_EXPORT_GENERAL_IMPORT +# define NCURSES_EXPORT_GENERAL_EXPORT +# else +# define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport) +# define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport) +# endif +# define NCURSES_API __cdecl +#else +# define NCURSES_EXPORT_GENERAL_IMPORT +# if (__GNUC__ >= 4) && !defined(__cplusplus) +# define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility ("default"))) +# else +# define NCURSES_EXPORT_GENERAL_EXPORT +# endif +# define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */ +#endif + +#endif /* NCURSES_DLL_H_incl */ diff --git a/ncurses/include/term_entry.h b/ncurses/include/term_entry.h new file mode 100644 index 0000000000..a0c097335e --- /dev/null +++ b/ncurses/include/term_entry.h @@ -0,0 +1,224 @@ +/**************************************************************************** + * Copyright 2018-2023,2025 Thomas E. Dickey * + * Copyright 1998-2015,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1998-on * + ****************************************************************************/ + +/* $Id: term_entry.h,v 1.65 2025/01/11 20:37:28 tom Exp $ */ + +/* + * term_entry.h -- interface to entry-manipulation code + */ + +#ifndef NCURSES_TERM_ENTRY_H_incl +#define NCURSES_TERM_ENTRY_H_incl 1 +/* *INDENT-OFF* */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * These macros may be used by programs that know about TERMTYPE: + */ +#if NCURSES_XNAMES +#define NUM_BOOLEANS(tp) (tp)->num_Booleans +#define NUM_NUMBERS(tp) (tp)->num_Numbers +#define NUM_STRINGS(tp) (tp)->num_Strings +#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i] +#else +#define NUM_BOOLEANS(tp) BOOLCOUNT +#define NUM_NUMBERS(tp) NUMCOUNT +#define NUM_STRINGS(tp) STRCOUNT +#define EXT_NAMES(tp,i,limit,index,table) table[i] +#endif + +#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings) + +#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++) +#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++) +#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++) + +#if NCURSES_XNAMES +#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++) +#define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++) +#define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++) +#endif + +#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names) +#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names) +#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names) + +/* + * The remaining type-definitions and macros are used only internally by the + * ncurses utilities. + */ +#ifdef NCURSES_INTERNALS + +/* + * see db_iterator.c - this enumeration lists the places searched for a + * terminal description and defines the order in which they are searched. + */ +typedef enum { + dbdTIC = 0, /* special, used by tic when writing entry */ +#if NCURSES_USE_DATABASE + dbdEnvOnce, /* the $TERMINFO environment variable */ + dbdHome, /* $HOME/.terminfo */ + dbdEnvList, /* the $TERMINFO_DIRS environment variable */ + dbdCfgList, /* the compiled-in TERMINFO_DIRS value */ + dbdCfgOnce, /* the compiled-in TERMINFO value */ +#endif +#if NCURSES_USE_TERMCAP + dbdEnvOnce2, /* the $TERMCAP environment variable */ + dbdEnvList2, /* the $TERMPATH environment variable */ + dbdCfgList2, /* the compiled-in TERMPATH */ +#endif + dbdLAST +} DBDIRS; + +#define WARN_MAX_USES 32 +#define HARD_MAX_USES 40 +#define MAX_CROSSLINKS 16 + +typedef struct entry ENTRY; + +typedef struct { + char *name; + ENTRY *link; + long line; +} ENTRY_USES; + +struct entry { + TERMTYPE2 tterm; + unsigned nuses; + ENTRY_USES uses[HARD_MAX_USES]; + int ncrosslinks; + ENTRY *crosslinks[MAX_CROSSLINKS]; + long cstart; + long cend; + long startline; + ENTRY *next; + ENTRY *last; +}; + +extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head; +extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail; +#define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next) +#define for_entry_list2(qp,q0) for (qp = q0; qp; qp = qp->next) + +#define MAX_LINE 132 + +#define NULLHOOK (bool(*)(ENTRY *))0 + +/* + * Note that WANTED and PRESENT are not simple inverses! If a capability + * has been explicitly cancelled, it is not considered WANTED. + */ +#define WANTED(s) ((s) == ABSENT_STRING) +#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) + +#define ANDMISSING(p,q) \ + { \ + if (PRESENT(p) && !PRESENT(q)) \ + _nc_warning(#p " but no " #q); \ + } + +#define PAIRED(p,q) \ + { \ + if (PRESENT(q) && !PRESENT(p)) \ + _nc_warning(#q " but no " #p); \ + if (PRESENT(p) && !PRESENT(q)) \ + _nc_warning(#p " but no " #q); \ + } + +/* + * These entrypoints are used only by the ncurses utilities such as tic. + */ + +/* alloc_entry.c: elementary allocation code */ +extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp); +extern NCURSES_EXPORT(char *) _nc_save_str (const char *const); +extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const); +extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const); +extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool); + +/* alloc_ttype.c: elementary allocation code */ +extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *); + +/* free_ttype.c: elementary allocation code */ +extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *); +extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *); +extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *); + +/* lib_termcap.c: trim sgr0 string for termcap users */ +extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *); + +/* parse_entry.c: entry-parsing code */ +#if NCURSES_XNAMES +extern NCURSES_EXPORT_VAR(bool) _nc_user_definable; +extern NCURSES_EXPORT_VAR(bool) _nc_disable_period; +#endif +extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool); +extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *); + +/* write_entry.c: writing an entry to the file system */ +extern NCURSES_EXPORT(void) _nc_set_writedir (const char *); +extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const); +extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned); + +/* 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); /* 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 *); /* obs 20040705 */ +extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool); + +/* trace_xnames.c */ +extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *); + +#endif /* NCURSES_INTERNALS */ + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ + +#endif /* NCURSES_TERM_ENTRY_H_incl */ diff --git a/ncurses/include/termcap.h.in b/ncurses/include/termcap.h.in new file mode 100644 index 0000000000..ec77e6aa0e --- /dev/null +++ b/ncurses/include/termcap.h.in @@ -0,0 +1,76 @@ +/**************************************************************************** + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 1998-2000,2001 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* $Id: termcap.h.in,v 1.20 2021/06/17 21:26:02 tom Exp $ */ + +#ifndef NCURSES_TERMCAP_H_incl +#define NCURSES_TERMCAP_H_incl 1 + +#undef NCURSES_VERSION +#define NCURSES_VERSION "@NCURSES_MAJOR@.@NCURSES_MINOR@" + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include + +#undef NCURSES_OSPEED +#define NCURSES_OSPEED @NCURSES_OSPEED@ + +extern NCURSES_EXPORT_VAR(char) PC; +extern NCURSES_EXPORT_VAR(char *) UP; +extern NCURSES_EXPORT_VAR(char *) BC; +extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; + +#if !defined(NCURSES_TERM_H_incl) +extern NCURSES_EXPORT(char *) tgetstr (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 (const char *); +extern NCURSES_EXPORT(int) tgetnum (const char *); +extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NCURSES_TERMCAP_H_incl */ diff --git a/ncurses/include/tic.h b/ncurses/include/tic.h new file mode 100644 index 0000000000..acfd2e1980 --- /dev/null +++ b/ncurses/include/tic.h @@ -0,0 +1,384 @@ +/**************************************************************************** + * Copyright 2018-2023,2025 Thomas E. Dickey * + * Copyright 1998-2012,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996 on * + ****************************************************************************/ + +/* + * $Id: tic.h,v 1.91 2025/12/25 21:23:29 tom Exp $ + * tic.h - Global variables and structures for the terminfo compiler. + */ + +#ifndef __TIC_H +#define __TIC_H +/* *INDENT-OFF* */ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include /* for the _tracef() prototype, ERR/OK, bool defs */ + +/* +** The format of SVr2 compiled terminfo files is as follows: +** +** Header (12 bytes), containing information given below +** Names Section, containing the names of the terminal +** Boolean Section, containing the values of all of the +** boolean capabilities +** A null byte may be inserted here to make +** sure that the Number Section begins on an +** even word boundary. +** Number Section, containing the values of all of the numeric +** capabilities, each as a short integer +** String Section, containing short integer offsets into the +** String Table, one per string capability +** String Table, containing the actual characters of the string +** capabilities. +** +** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes +** inconvenient. The numbers are signed, to provide for absent and canceled +** values. ncurses6.1 introduced an extension to this compiled format, by +** making the Number Section a list of signed 32-bit integers. +** +** NOTE that all short integers in the file are stored using VAX/PDP-style +** byte-order, i.e., least-significant byte first. +** +** There is no structure definition here because it would only confuse +** matters. Terminfo format is a raw byte layout, not a structure +** dump. If you happen to be on a little-endian machine with 16-bit +** shorts that requires no padding between short members in a struct, +** then there is a natural C structure that captures the header, but +** not very helpfully. +*/ + +#define MAGIC 0432 /* first two bytes of a compiled entry */ +#define MAGIC2 01036 /* first two bytes of a compiled 32-bit 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 || LOW_MSB(p) == MAGIC2) + +#define quick_prefix(s) (!strncmp((s), "b64:", (size_t)4) || !strncmp((s), "hex:", (size_t)4)) + +/* + * The "maximum" here is misleading; XSI guarantees minimum values, which a + * given implementation may exceed. + */ +#define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */ +#define MAX_ENTRY_SIZE1 4096 /* maximum legal entry size (SVr2) */ +#define MAX_ENTRY_SIZE2 32768 /* maximum legal entry size (ncurses6.1) */ + +#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR +#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2 +#else +#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1 +#endif + +/* + * 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 /* smaller than POSIX minimum for PATH_MAX */ +#else +#define MAX_ALIAS 14 /* SVr3 filename length */ +#endif + +/* location of user's personal info directory */ +#define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */ + +/* + * Some traces are designed to be used via tic's verbose option (and similar in + * infocmp and toe) rather than the 'trace()' function. So we use the bits + * above the normal trace() parameter as a debug-level. + */ + +#define MAX_DEBUG_LEVEL 15 +#define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT) + +#define set_trace_level(n) \ + _nc_tracing &= TRACE_MAXIMUM, \ + _nc_tracing |= DEBUG_LEVEL(n) + +#ifdef TRACE +#define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a +#else +#define DEBUG(n, a) /*nothing*/ +#endif + +/* + * These are the types of tokens returned by the scanner. The first + * three are also used in the hash table of capability names. The scanner + * returns one of these values after loading the specifics into the global + * structure curr_token. + */ + +#define BOOLEAN 0 /* Boolean capability */ +#define NUMBER 1 /* Numeric capability */ +#define STRING 2 /* String-valued capability */ +#define CANCEL 3 /* Capability to be cancelled in following tc's */ +#define NAMES 4 /* The names for a terminal type */ +#define UNDEF 5 /* Undefined */ + +#define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */ + +/* + * The global structure in which the specific parts of a + * scanned token are returned. + */ + +struct token +{ + char *tk_name; /* name of capability */ + int tk_valnumber; /* value of capability (if a number) */ + char *tk_valstring; /* value of capability (if a string) */ +}; + +/* + * Offsets to string capabilities, with the corresponding functionkey codes. + */ +struct tinfo_fkeys { + unsigned offset; + chtype code; + }; + +typedef short HashValue; + +/* + * The file comp_captab.c contains an array of these structures, one per + * possible capability. These are indexed by a hash table array of pointers to + * the same structures for use by the parser. + */ +struct name_table_entry +{ + const char *nte_name; /* name to hash on */ + int nte_type; /* BOOLEAN, NUMBER or STRING */ + HashValue nte_index; /* index of associated variable in its array */ + HashValue nte_link; /* index in table of next hash, or -1 */ +}; + +/* + * Use this structure to hide differences between terminfo and termcap tables. + */ +typedef struct { + unsigned table_size; + const HashValue *table_data; + HashValue (*hash_of)(const char *); + int (*compare_names)(const char *, const char *); +} HashData; + +struct alias +{ + const char *from; + const char *to; + const char *source; +}; + +#define NOTFOUND ((struct name_table_entry *) 0) + +/* + * The file comp_userdefs.c contains an array of these structures, one per + * possible capability. These are indexed by a hash table array of pointers to + * the same structures for use by the parser. + */ +struct user_table_entry +{ + const char *ute_name; /* name to hash on */ + int ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ + unsigned ute_argc; /* number of parameters */ + unsigned ute_args; /* bit-mask for string parameters */ + HashValue ute_index; /* index of associated variable in its array */ + HashValue ute_link; /* index in table of next hash, or -1 */ +}; + +/* + * The casts are required for correct sign-propagation with systems such as + * AIX, IRIX64, Solaris which default to unsigned characters. The C standard + * leaves this detail unspecified. + */ + +/* out-of-band values for representing absent capabilities */ +#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) /* 254 */ +#define CANCELLED_NUMERIC (-2) +#define CANCELLED_STRING (char *)(-1) + +#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) + +/* termcap entries longer than this may break old binaries */ +#define MAX_TERMCAP_LENGTH 1023 + +/* this is a documented limitation of terminfo */ +#define MAX_TERMINFO_LENGTH 4096 + +#ifndef TERMINFO +#define TERMINFO "/usr/share/terminfo" +#endif + +#ifdef NCURSES_TERM_ENTRY_H_incl + +/* + * These entrypoints are used only by the ncurses utilities such as tic. + */ +#ifdef NCURSES_INTERNALS +/* 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(bool) _nc_is_path_found (const char *, struct stat *); +extern NCURSES_EXPORT(char *) _nc_basename (char *); +extern NCURSES_EXPORT(char *) _nc_rootname (char *); + +/* comp_captab.c */ +extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool); +extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool); +extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool); + +/* comp_hash.c: name lookup */ +extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry + (const char *, int, bool); +extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry + (const char *); + +/* comp_scan.c: lexical analysis */ +extern NCURSES_EXPORT(int) _nc_get_token (bool); +extern NCURSES_EXPORT(void) _nc_panic_mode (char); +extern NCURSES_EXPORT(void) _nc_push_token (int); +extern NCURSES_EXPORT_VAR(int) _nc_curr_col; +extern NCURSES_EXPORT_VAR(int) _nc_curr_line; +extern NCURSES_EXPORT_VAR(int) _nc_syntax; +extern NCURSES_EXPORT_VAR(int) _nc_strict_bsd; +extern NCURSES_EXPORT_VAR(long) _nc_comment_end; +extern NCURSES_EXPORT_VAR(long) _nc_comment_start; +extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos; +extern NCURSES_EXPORT_VAR(long) _nc_start_line; +#define SYN_TERMINFO 0 +#define SYN_TERMCAP 1 + +/* comp_error.c: warning & abort messages */ +extern NCURSES_EXPORT(const char *) _nc_get_source (void); +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT(void) _nc_get_type (char *name); +extern NCURSES_EXPORT(void) _nc_set_source (const char *const); +extern NCURSES_EXPORT(void) _nc_set_type (const char *const); +extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2); +extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings; + +/* comp_scan.c */ +extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token; + +/* comp_userdefs.c */ +extern NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void); +extern NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void); + +/* 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); + +/* init_keytry.c */ +#if BROKEN_LINKER +#define _nc_tinfo_fkeys _nc_tinfo_fkeysf() +extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void); +#else +extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[]; +#endif + +/* lib_tparm.c */ +#define NUM_PARM 9 + +extern NCURSES_EXPORT_VAR(int) _nc_tparm_err; + +extern NCURSES_EXPORT(int) _nc_tparm_analyze(TERMINAL *, const char *, char **, int *); +extern NCURSES_EXPORT(void) _nc_reset_tparm(TERMINAL *); + +/* lib_trace.c */ +extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; +extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); +extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); + +/* lib_tputs.c */ +extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */ + +/* comp_expand.c: expand string into readable form */ +extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int); + +/* comp_hash.c: name lookup */ +extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry + (const char *, const HashValue *); +extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool); + +/* comp_main.c: compiler main */ +extern const char * _nc_progname; + +/* db_iterator.c */ +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); + +#endif /* NCURSES_INTERNALS */ + +#endif /* NCURSES_TERM_ENTRY_H_incl */ + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ +#endif /* __TIC_H */ diff --git a/ncurses/include/unctrl.h.in b/ncurses/include/unctrl.h.in new file mode 100644 index 0000000000..4901e1e6b9 --- /dev/null +++ b/ncurses/include/unctrl.h.in @@ -0,0 +1,71 @@ +/**************************************************************************** + * Copyright 2020,2025 Thomas E. Dickey * + * Copyright 1998-2001,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * unctrl.h + * + * Display a printable version of a control character. + * Control characters are displayed in caret notation (^x), DELETE is displayed + * as ^?. Printable characters are displayed as is. + */ + +/* $Id: unctrl.h.in,v 1.14 2025/08/08 23:19:21 tom Exp $ */ + +#ifndef NCURSES_UNCTRL_H_incl +#define NCURSES_UNCTRL_H_incl 1 + +#undef NCURSES_VERSION +#define NCURSES_VERSION "@NCURSES_MAJOR@.@NCURSES_MINOR@" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#undef unctrl +extern NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype); + +#if @NCURSES_SP_FUNCS@ /* NCURSES_SP_FUNCS */ +extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NCURSES_UNCTRL_H_incl */ diff --git a/ncurses/ncurses/Makefile.in b/ncurses/ncurses/Makefile.in new file mode 100644 index 0000000000..6eaa4e8ec9 --- /dev/null +++ b/ncurses/ncurses/Makefile.in @@ -0,0 +1,403 @@ +# $Id: Makefile.in,v 1.194 2025/10/25 17:29:43 tom Exp $ +############################################################################## +# Copyright 2018-2024,2025 Thomas E. Dickey # +# Copyright 1998-2017,2018 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# +# Makefile for ncurses source code. +# +# This makes the following: +# programs +# includes +# libraries (normal/debug/profile/shared) +# +# The variable 'srcdir' refers to the source-distribution, and can be set with +# the configure script by "--srcdir=DIR". +# +# The rules are organized to produce the libraries for the configured models, +# and the programs with the configured default model. + +# turn off _all_ suffix rules; we'll generate our own +.SUFFIXES: + +SHELL = @SHELL@ +VPATH = @srcdir@ +THIS = Makefile + +@SET_MAKE@ +@SET_DESTDIR@ +TOP_MFLAGS = DESTDIR="$(DESTDIR)" RPATH_LIST="$(RPATH_LIST)" + +x = @EXEEXT@ +o = .@OBJEXT@ + +MODEL = @DFT_LWR_MODEL@ +top_srcdir = @top_srcdir@ +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +includedir = @includedir@ +datarootdir = @datarootdir@ +datadir = @datadir@ +includesubdir = @includesubdir@ + +INCLUDEDIR = $(DESTDIR)$(includedir@MERGE_PREFIX@)$(includesubdir) +BINDIR = $(DESTDIR)$(bindir@MERGE_PREFIX@) +LIBDIR = $(DESTDIR)$(libdir@MERGE_PREFIX@) + +PACKAGE = @PACKAGE@ + +LIBTOOL = @LIBTOOL@ +LIBTOOL_OPTS = @LIBTOOL_OPTS@ @EXPORT_SYMS@ +LIBTOOL_CLEAN = @LIB_CLEAN@ +LIBTOOL_COMPILE = @LIB_COMPILE@ +LIBTOOL_LINK = @LIB_LINK@ +LIBTOOL_INSTALL = @LIB_INSTALL@ +LIBTOOL_UNINSTALL = @LIB_UNINSTALL@ +LT_UNDEF = @LT_UNDEF@ + +INSTALL = @INSTALL@ +INSTALL_LIB = @INSTALL@ @INSTALL_LIB@ +INSTALL_PROG = @INSTALL_PROGRAM@ @INSTALL_OPT_S@ +INSTALL_DATA = @INSTALL_DATA@ + +AR = @AR@ +ARFLAGS = @ARFLAGS@ +AWK = @AWK@ +LD = @LD@ +LN_S = @LN_S@ +NM = @NM@ + +CTAGS = @CTAGS@ +ETAGS = @ETAGS@ + +CC = @CC@ +CPP = @CPP@ +CFLAGS = @CFLAGS@ @EXTRA_CFLAGS@ +LIBS = @LIBS@ + +INCDIR = $(srcdir)/../include +CPPFLAGS = -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses @CPPFLAGS@ + +CCFLAGS = $(CPPFLAGS) $(CFLAGS) + +BUILD_CPPFLAGS = -DHAVE_CONFIG_H -DUSE_BUILD_CC -I../ncurses -I$(srcdir) -I../include -I$(INCDIR) @BUILD_CPPFLAGS@ +BUILD_CC = @BUILD_CC@ +BUILD_CCFLAGS = @BUILD_CFLAGS@ +BUILD_LDFLAGS = @BUILD_LDFLAGS@ +BUILD_LIBS = @BUILD_LIBS@ + +# The executables built in this directory are used for generating source that +# is compiled into the build, or are test-programs that are not installed. + +BUILD_EXEEXT = @BUILD_EXEEXT@ +x = @EXEEXT@ + +CFLAGS_LIBTOOL = $(CCFLAGS) +CFLAGS_NORMAL = $(CCFLAGS) -DNCURSES_STATIC +CFLAGS_DEBUG = $(CCFLAGS) -DNCURSES_STATIC @CC_G_OPT@ -DTRACE +CFLAGS_PROFILE = $(CCFLAGS) -DNCURSES_STATIC -pg +CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@ + +CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@) + +LINK = $(LIBTOOL) +LDFLAGS = @LDFLAGS@ @LD_MODEL@ + +SHLIB_DIRS = -L../lib +SHLIB_LIST = $(SHLIB_DIRS) @SHLIB_LIST@ @LIBS@ +TINFO_LIST = $(SHLIB_DIRS) @TINFO_LIST@ @LIBS@ +TICS_LIST = $(SHLIB_DIRS) @TICS_LIST@ @LIBS@ + +RPATH_LIST = @RPATH_LIST@ +RESULTING_SYMS = @RESULTING_SYMS@ +VERSIONED_SYMS = @VERSIONED_SYMS@ +MK_SHARED_LIB = @MK_SHARED_LIB@ + +NCURSES_MAJOR = @NCURSES_MAJOR@ +NCURSES_MINOR = @NCURSES_MINOR@ +REL_VERSION = @cf_cv_rel_version@ +ABI_VERSION = @cf_cv_abi_version@ + +RANLIB = @LIB_PREP@ + +LIBRARIES = @Libs_To_Make@ + +LINT = @LINT@ +LINT_OPTS = @LINT_OPTS@ +LINT_LIBS = -lncurses @LIBS@ + +FALLBACK_LIST = @FALLBACK_LIST@ + +USE_BIG_STRINGS = @USE_BIG_STRINGS@ +TERMINFO_CAPS = $(top_srcdir)/include/@TERMINFO_CAPS@ +CAPLIST = $(TERMINFO_CAPS) $(top_srcdir)/include/Caps-ncurses + +TERMINFO = @TERMINFO@ +TERMINFO_SRC = @TERMINFO_SRC@ +TIC_PATH = @TIC@ +INFOCMP_PATH = @INFOCMP@ + +AUTO_SRC = \ + ./codes.c \ + ./comp_captab.c \ + ./comp_userdefs.c \ + ./expanded.c \ + ./fallback.c \ + ./lib_gen.c \ + ./lib_keyname.c \ + ./link_test.c \ + ./names.c \ + ./unctrl.c \ + init_keytry.h \ + keys.list + +HEADER_DEPS = @INTERNALS_HDR@ \ + ../include/ncurses_cfg.h \ + ../include/ncurses_def.h \ + ../include/ncurses_dll.h \ + ../include/curses.h \ + ../include/term.h \ + ../include/unctrl.h \ + $(INCDIR)/nc_alloc.h \ + $(INCDIR)/nc_panel.h \ + $(INCDIR)/nc_string.h \ + $(INCDIR)/nc_termios.h \ + $(INCDIR)/nc_tparm.h \ + $(INCDIR)/term_entry.h \ + $(srcdir)/curses.priv.h \ + $(srcdir)/new_pair.h \ + $(srcdir)/term.priv.h + +TEST_DEPS = ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@ +TEST_ARGS = @LDFLAGS_STATIC@ @TEST_ARGS@ @LDFLAGS_SHARED@ +TEST_LDFLAGS = @LD_MODEL@ $(TEST_ARGS) @LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@ + +TEST_PROGS = \ + captoinfo$x \ + hardscroll$x \ + hashmap$x \ + lib_mvcur$x \ + link_test$x \ + report_ctype$x \ + report_hashing$x + +LOCAL_LIBDIR = @top_builddir@/lib + +base = $(srcdir)/base +serial = $(srcdir)/tty +tinfo = $(srcdir)/tinfo +trace = $(srcdir)/trace +wide = $(srcdir)/widechar +win32con = $(srcdir)/win32con + +################################################################################ + +@MAKE_PHONY@.PHONY : all +@MAKE_PHONY@.PHONY : check +@MAKE_PHONY@.PHONY : clean +@MAKE_PHONY@.PHONY : distclean +@MAKE_PHONY@.PHONY : libs +@MAKE_PHONY@.PHONY : mostlyclean +@MAKE_PHONY@.PHONY : realclean +@MAKE_PHONY@.PHONY : sources +@MAKE_PHONY@.PHONY : test_progs + +all libs :: $(AUTO_SRC) ../lib $(LIBRARIES) + +@CHECK_BUILD@all libs :: report_offsets$(BUILD_EXEEXT) + +sources: $(AUTO_SRC) + +$(BINDIR) \ +$(LIBDIR) : + mkdir -p $@ + +../lib : ; mkdir $@ + +./fallback.c : $(tinfo)/MKfallback.sh + $(SHELL) -e $(tinfo)/MKfallback.sh $(TERMINFO) $(TERMINFO_SRC) "$(TIC_PATH)" "$(INFOCMP_PATH)" $(FALLBACK_LIST) >$@ + +./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h + FGREP="@FGREP@" $(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" generated <../include/curses.h >$@ + +init_keytry.h : make_keys$(BUILD_EXEEXT) keys.list + ./make_keys$(BUILD_EXEEXT) keys.list > $@ + +keys.list : $(tinfo)/MKkeys_list.sh + AWK=$(AWK) USE_SIGWINCH=@cf_cv_enable_sigwinch@ $(SHELL) $(tinfo)/MKkeys_list.sh $(CAPLIST) | LC_ALL=C sort >$@ + +make_keys$(BUILD_EXEEXT) : \ + build.priv.h \ + $(tinfo)/make_keys.c \ + ./names.c + $(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_keys.c $(BUILD_LDFLAGS) $(BUILD_LIBS) + @./$@ "-?" + @echo "... made $@" + +make_hash$(BUILD_EXEEXT) : \ + build.priv.h \ + $(tinfo)/make_hash.c \ + ../include/hashsize.h + $(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS) + @./$@ "-?" + @echo "... made $@" + +report_offsets$(BUILD_EXEEXT) : \ + $(srcdir)/curses.priv.h \ + $(srcdir)/report_offsets.c + $(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(srcdir)/report_offsets.c $(BUILD_LDFLAGS) $(BUILD_LIBS) + @./$@ "-?" + @echo "... made $@" + ./report_offsets$(BUILD_EXEEXT) + +./expanded.c : $(srcdir)/curses.priv.h $(serial)/MKexpanded.sh + $(SHELL) -e $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@ + +./comp_captab.c: \ + make_hash$(BUILD_EXEEXT) \ + ../include/hashsize.h \ + $(tinfo)/MKcaptab.sh \ + $(tinfo)/MKcaptab.awk + $(SHELL) -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(CAPLIST) > $@ + +./comp_userdefs.c: \ + make_hash$(BUILD_EXEEXT) \ + ../include/hashsize.h \ + $(tinfo)/MKuserdefs.sh + $(SHELL) -e $(tinfo)/MKuserdefs.sh $(AWK) $(USE_BIG_STRINGS) $(CAPLIST) > $@ + +./lib_keyname.c: keys.list $(base)/MKkeyname.awk + $(AWK) -f $(base)/MKkeyname.awk use_sigwinch=@cf_cv_enable_sigwinch@ bigstrings=$(USE_BIG_STRINGS) keys.list > $@ + +./codes.c: $(tinfo)/MKcodes.awk + $(AWK) -f $(tinfo)/MKcodes.awk bigstrings=$(USE_BIG_STRINGS) $(CAPLIST) >$@ + +./names.c: $(tinfo)/MKnames.awk + $(AWK) -f $(tinfo)/MKnames.awk bigstrings=$(USE_BIG_STRINGS) $(CAPLIST) >$@ + +./unctrl.c: $(base)/MKunctrl.awk + echo | $(AWK) -f $(base)/MKunctrl.awk bigstrings=$(USE_BIG_STRINGS) >$@ + +tags: + $(CTAGS) *.[ch] */*.[ch] + +@MAKE_UPPER_TAGS@TAGS: +@MAKE_UPPER_TAGS@ $(ETAGS) *.[ch] */*.[ch] + +mostlyclean :: + -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac + -test -d trace || rm -f trace + -rm -f $(TEST_PROGS) + +clean :: mostlyclean + -rm -f $(AUTO_SRC) + -rm -f make_keys$(BUILD_EXEEXT) + -rm -f make_hash$(BUILD_EXEEXT) + -rm -f report_ctype$(BUILD_EXEEXT) + -rm -f report_offsets$(BUILD_EXEEXT) + -rm -rf .libs *.dSYM *.map + +distclean :: clean + -rm -f Makefile + +realclean :: distclean + +# These rules are used to allow "make -n" to work on a clean directory-tree +../include/curses.h \ +../include/hashsize.h \ +../include/ncurses_def.h \ +../include/parametrized.h \ +../include/term.h : + ( cd ../include && $(MAKE) $(TOP_MFLAGS) ) + +# These rules build test-programs for the modules that have test-drivers +@MAKE_PHONY@.PHONY : test_progs +test_progs : $(TEST_PROGS) + +./link_test.c : $(base)/MKlib_gen.sh ../include/curses.h + FGREP="@FGREP@" $(SHELL) -e $(base)/MKlib_gen.sh "$(CPP) $(CPPFLAGS)" "$(AWK)" implemented <../include/curses.h >$@ + +captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS) + @ECHO_LD@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS) + +hardscroll$x : $(serial)/hardscroll.c $(TEST_DEPS) + @ECHO_LD@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DSCROLLDEBUG $(serial)/hardscroll.c $(TEST_LDFLAGS) + +hashmap$x : $(serial)/hashmap.c $(serial)/hardscroll.c $(TEST_DEPS) + @ECHO_LD@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DHASHDEBUG $(serial)/hashmap.c $(serial)/hardscroll.c $(TEST_LDFLAGS) + +lib_mvcur$x : $(serial)/lib_mvcur.c $(TEST_DEPS) \ + ../@DFT_OBJ_SUBDIR@/dump_entry$o + @ECHO_LD@ $(LIBTOOL_LINK) -o $@ $(CFLAGS_DEFAULT) -DNCURSES_TEST -I$(serial)/../../progs $(serial)/lib_mvcur.c ../@DFT_OBJ_SUBDIR@/dump_entry$o $(TEST_LDFLAGS) + +link_test$x : ./link_test.c $(TEST_DEPS) \ + ../@DFT_OBJ_SUBDIR@/link_test$o + @ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) ../@DFT_OBJ_SUBDIR@/link_test$o $(TEST_LDFLAGS) + +../@DFT_OBJ_SUBDIR@/dump_entry$o: + ( cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry$o ) + +report_ctype$x : \ + $(srcdir)/curses.priv.h \ + $(srcdir)/report_ctype.c $(TEST_DEPS) + @ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) $(srcdir)/report_ctype.c $(TEST_LDFLAGS) + @echo "... made $@" + ./report_ctype$x + +report_hashing$x : \ + $(srcdir)/curses.priv.h \ + $(srcdir)/report_hashing.c $(TEST_DEPS) + @ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) $(srcdir)/report_hashing.c $(TEST_LDFLAGS) + +# Verify that each header-file can be compiled without including another. +@MAKE_PHONY@.PHONY : check_headers +check_headers: + @$(SHELL) -c "for header in *.h;\ + do \ + echo \"** testing \$${header}\" ; \ + echo \"#include <\$${header}>\" >headers.c; \ + echo \"int main(void) { return 0; }\" >>headers.c; \ + $(CC) -c $(CFLAGS) $(CPPFLAGS) headers.c; \ + done" + -@rm -f headers.* + +@MAKE_PHONY@.PHONY : check_objects +check_objects: test_progs + +check :: check_headers check_objects + +############################################################################### +# The remainder of this file is automatically generated during configuration +############################################################################### diff --git a/ncurses/ncurses/README b/ncurses/ncurses/README new file mode 100644 index 0000000000..bcfae0101d --- /dev/null +++ b/ncurses/ncurses/README @@ -0,0 +1,54 @@ +------------------------------------------------------------------------------- +-- Copyright 2020 Thomas E. Dickey -- +-- Copyright 1998-2006,2009 Free Software Foundation, Inc. -- +-- -- +-- Copyright (c) 2026 -- +-- Project Tick. All rights reserved. -- +-- -- +-- 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: README,v 1.11 2020/02/02 23:34:34 tom Exp $ +------------------------------------------------------------------------------- +For discussion of the package internals, see hackguide.html in the doc/html +directory. + +------------------------------------------------------------------------------- +The llib-lXXXX files could be used as lint-library sources (and were, at one +time). However, they are actually used as a documentation aid to keep track +of changes to the public/private interfaces in ncurses. Most of the text in +these files is generated using cproto; some manual cleanup and adjustment of +types (to reflect #define's in curses.h) is needed. The functions listed in +the llib-lXXXX files do not correspond to the default configure options; some +additional ones are added to include "all" of the entrypoints for each of the +major configurations (normal, wide-character, threaded): + + --disable-macros + --disable-root-environ + --enable-expanded + --enable-getcap + --enable-getcap-cache + --enable-sp-funcs + --enable-termcap + --with-develop diff --git a/ncurses/ncurses/README.IZ b/ncurses/ncurses/README.IZ new file mode 100644 index 0000000000..0c8c047341 --- /dev/null +++ b/ncurses/ncurses/README.IZ @@ -0,0 +1,99 @@ +------------------------------------------------------------------------------- +-- Copyright 2020,2021 Thomas E. Dickey -- +-- Copyright 2002,2006 Free Software Foundation, Inc. -- +-- -- +-- Copyright (c) 2026 -- +-- Project Tick. All rights reserved. -- +-- -- +-- 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: README.IZ,v 1.5 2021/06/17 21:20:30 tom Exp $ +--------------------------------------------------------------------- + +Here is the patch. I did no testing whatsoever with event watching +requests present (I need some applications which exercise this before +this, probably lynx ;-), but the code looks working "the normal way". + +I had no way to test that the poll() branch compiles/works... + +Here is the API: + +*) two new functions wgetch_events() wgetstrn_event() are introduced, + which allow an event-watch specification given as the last argument; + +*) if the last argument is NULL, they behave as wgetch() and + wgetstrn() (TESTED!); + +*) the event specification is a pointer to _nc_eventlist, which + contains bookkeeping elements (count and the summary of results), + and an array of pointers to _nc_event; + +*) each _nc_event is a typed union, with two types supported "as + shipped": _NC_EVENT_TIMEOUT_MSEC, _NC_EVENT_FILE. For + _NC_EVENT_FILE the fields are fd, flag, and the output field. + +*) The only supported flag "as shipped" is _NC_EVENT_FILE_READABLE. + If the file was found readable, the return field is set to this, + otherwise to 0; + +*) If these functions return KEY_EVENT, this means that the return + fields in both the _nc_eventlist and _nc_event structures make + sense. The field result_flags of _nc_eventlist may have a + combination of bits _NC_EVENT_TIMEOUT_MSEC and _NC_EVENT_FILE_READABLE + set; + +*) The timeout_msec field of _NC_EVENT_TIMEOUT_MSEC _nc_event's is + updated on return, even if the return is not KEY_EVENT. However, + the change in the value represents only the amount of time spent in + waiting for events, not the amount of time spent bookkeeping; + +*) the return KEY_EVENT of wgetstrn_event() means that the output + string includes the user input typed so far, but the user did not have + a chance to press ENTER (or whatever). This call should be + repeated (with "shifted" pointer to a buffer, of course) to + complete the input; + +*) The presence of this extension can be checked via inspecting + #ifdef NCURSES_EVENT_VERSION. This symbol is not defined on BeOS, + since there is no support for this on BeOS. + +Known issues: calls interrupted by KEY_EVENT reset the ESCDELAY +timer. This is not entirely new, since other synthetic events behave +the same (see "if (ch >= KEY_MIN)" branch of kgetch()). However, +KEY_EVENT may be generated in a continuous stream (say, when +downloading a file), thus this may be more important than with other +synthetic keys. An additional field in window structure which keeps +timestamp of the first raw key in the queue may be needed to +circumvent this. + +Another possible issue: KEY_EVENT has a preference over a user input, +so a stream of KEY_EVENT's can make input hard. Maybe use +result_flags as in input parameter too, which specifies whether the +user input should have higher precedence? + +Also: I took an opportunity to document kgetch() better. + +Enjoy, +Ilya diff --git a/ncurses/ncurses/SigAction.h b/ncurses/ncurses/SigAction.h new file mode 100644 index 0000000000..f52d9f7b4b --- /dev/null +++ b/ncurses/ncurses/SigAction.h @@ -0,0 +1,113 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2003,2005 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * $Id: SigAction.h,v 1.10 2020/02/02 23:34:34 tom Exp $ + * + * This file exists to handle non-POSIX systems which don't have , + * and usually no sigaction() nor + */ + +#ifndef _SIGACTION_H +#define _SIGACTION_H + +#ifndef HAVE_SIGACTION +#define HAVE_SIGACTION 0 +#endif + +#ifndef HAVE_SIGVEC +#define HAVE_SIGVEC 0 +#endif + +#if HAVE_SIGACTION + +#if !HAVE_TYPE_SIGACTION +typedef struct sigaction sigaction_t; +#endif + +#else /* !HAVE_SIGACTION */ + +#if HAVE_SIGVEC + +#undef SIG_BLOCK +#define SIG_BLOCK 00 + +#undef SIG_UNBLOCK +#define SIG_UNBLOCK 01 + +#undef SIG_SETMASK +#define SIG_SETMASK 02 + + /* + * is in the Linux 1.2.8 + gcc 2.7.0 configuration, + * and is useful for testing this header file. + */ +#if HAVE_BSD_SIGNAL_H +#include +#endif + +typedef struct sigvec sigaction_t; + +#define sigset_t _nc_sigset_t +typedef unsigned long sigset_t; + +#undef sa_mask +#define sa_mask sv_mask +#undef sa_handler +#define sa_handler sv_handler +#undef sa_flags +#define sa_flags sv_flags + +#undef sigaction +#define sigaction _nc_sigaction +#undef sigprocmask +#define sigprocmask _nc_sigprocmask +#undef sigemptyset +#define sigemptyset _nc_sigemptyset +#undef sigsuspend +#define sigsuspend _nc_sigsuspend +#undef sigdelset +#define sigdelset _nc_sigdelset +#undef sigaddset +#define sigaddset _nc_sigaddset + +/* tty/lib_tstp.c is the only user */ +#include + +#endif /* HAVE_SIGVEC */ +#endif /* HAVE_SIGACTION */ +#endif /* !defined(_SIGACTION_H) */ diff --git a/ncurses/ncurses/base/MKkeyname.awk b/ncurses/ncurses/base/MKkeyname.awk new file mode 100644 index 0000000000..36338e4795 --- /dev/null +++ b/ncurses/ncurses/base/MKkeyname.awk @@ -0,0 +1,181 @@ +# $Id: MKkeyname.awk,v 1.53 2024/12/07 21:09:39 tom Exp $ +############################################################################## +# Copyright 2020,2024 Thomas E. Dickey # +# Copyright 1998-2016,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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. # +############################################################################## +BEGIN { + print "/* generated by MKkeyname.awk */" + print "" + print "#include " + print "#include " + print "" + first = 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 { + 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 "#define MyInit _nc_globals.init_keyname" + print "" + print "NCURSES_EXPORT(NCURSES_CONST char *)" + print "safe_keyname (SCREEN *sp, int c)" + print "{" + print " char name[20];" + print " NCURSES_CONST char *result = NULL;" + print "" + print " if (c == -1) {" + print " result = \"-1\";" + print " } else {" + print " int i;" + 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 != NULL; 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 == NULL && (c >= 0 && c < SIZEOF_TABLE)) {" + print " if (MyTable == NULL)" + print " MyTable = typeCalloc(char *, SIZEOF_TABLE);" + print "" + print " if (MyTable != NULL) {" + print " int m_prefix = (sp == NULL || sp->_use_meta);" + print "" + print " /* if sense of meta() changed, discard cached data */" + print " if (MyInit != (m_prefix + 1)) {" + print " MyInit = m_prefix + 1;" + print " for (i = 0; i < SIZEOF_TABLE; ++i) {" + print " if (MyTable[i]) {" + print " FreeAndNull(MyTable[i]);" + print " }" + print " }" + print " }" + print "" + print " /* create and cache result as needed */" + print " if (MyTable[c] == NULL) {" + print " int cc = c;" + print " char *p = name;" + print "#define P_LIMIT (sizeof(name) - (size_t) (p - name))" + print " if (cc >= 128 && m_prefix) {" + print " _nc_STRCPY(p, \"M-\", P_LIMIT);" + print " p += 2;" + print " cc -= 128;" + print " }" + print " if (cc < 32)" + print " _nc_SPRINTF(p, _nc_SLIMIT(P_LIMIT) \"^%c\", cc + '@');" + print " else if (cc == 127)" + print " _nc_STRCPY(p, \"^?\", P_LIMIT);" + print " else" + print " _nc_SPRINTF(p, _nc_SLIMIT(P_LIMIT) \"%c\", cc);" + print " MyTable[c] = strdup(name);" + print " }" + print " result = MyTable[c];" + print " }" + print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES" + print " } else if (result == NULL && HasTerminal(sp)) {" + print " int j, k;" + print " char * bound;" + print " TERMTYPE2 *tp = &TerminalType(TerminalOf(sp));" + print " unsigned save_trace = _nc_tracing;" + print "" + print " _nc_tracing = 0; /* prevent recursion via keybound() */" + print " for (j = 0; (bound = NCURSES_SP_NAME(keybound)(NCURSES_SP_ARGx c, j)) != NULL; ++j) {" + print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {" + print " if (tp->Strings[k] != NULL && !strcmp(bound, tp->Strings[k])) {" + print " result = ExtStrname(tp, k, strnames);" + print " break;" + print " }" + print " }" + print " free(bound);" + print " if (result != NULL)" + print " break;" + print " }" + print " _nc_tracing = save_trace;" + print "#endif" + print " }" + print " }" + print " return result;" + print "}" + print "" + print "NCURSES_EXPORT(NCURSES_CONST char *)" + print "keyname (int c)" + print "{" + print " return safe_keyname (CURRENT_SCREEN, c);" + print "}" + print "" + print "#if NO_LEAKS" + print "void _nc_keyname_leaks(void)" + print "{" + print " if (MyTable != NULL) {" + print " int j;" + 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/ncurses/ncurses/base/MKlib_gen.sh b/ncurses/ncurses/base/MKlib_gen.sh new file mode 100755 index 0000000000..1b5c032afc --- /dev/null +++ b/ncurses/ncurses/base/MKlib_gen.sh @@ -0,0 +1,593 @@ +#!/bin/sh +# +# MKlib_gen.sh -- generate sources from curses.h macro definitions +# +# ($Id: MKlib_gen.sh,v 1.79 2025/02/23 01:55:06 tom Exp $) +# +############################################################################## +# Copyright 2018-2024,2025 Thomas E. Dickey # +# Copyright 1998-2016,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# by macros. Rather than hand-hack all that code, we actually +# generate functions from the macros. +# +# 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 +# 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 +# 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 +# 6. awk: strip the expansion junk off the front and add the new header +# 7. sed: squeeze spaces, strip off gen_ prefix. +# + +# 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_WATTR_MACROS -DNCURSES_INTERNALS -I../include" +AWK="$2" +USE="$3" + +# A patch discussed here: +# https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html +# +# introduces spurious #line markers into the preprocessor output. The result +# appears in gcc 5.0 and (with modification) in 5.1, making it necessary to +# determine if we are using gcc, and if so, what version because the proposed +# solution uses a nonstandard option. +# +# As illustrated in +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60723 +# +# gcc developers chose to ignore the problems with this, and summarized those +# as "intriguing problems" in +# https://gcc.gnu.org/gcc-5/porting_to.html + +PRG=`echo "$1" | "$AWK" '{ sub(/^[ ]*/,""); sub(/[ ].*$/, ""); print; }' || exit 0` +FSF=`("$PRG" --version 2>/dev/null || exit 0) | ${FGREP-grep -F} "Free Software Foundation" | head -n 1` +ALL=`"$PRG" -dumpversion 2>/dev/null || exit 0` +ONE=`echo "$ALL" | sed -e 's/[^0-9].*$//'` +if test -n "$FSF" && test -n "$ALL" && test -n "$ONE" ; then + if test "$ONE" -ge 5 ; then + echo ".. adding -P option to work around $PRG $ALL" >&2 + preprocessor="$preprocessor -P" + fi +fi + +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; exit 1" 1 2 3 15 +trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0 + +ALL=$USE +if test "$USE" = implemented ; then + cat >$ED1 <$ED1 <$ED2 <$ED3 <$ED4 <$ED4 <$AW1 <<\EOF1 +BEGIN { + skip=0; + } +/^P_POUNDCif/ { + print "\n" + print $0 + skip=0; +} +/^P_POUNDCendif/ { + print $0 + skip=1; +} +$0 !~ /^P_/ { + if (skip) + print "\n" + skip=1; + + first=$1 + for (i = 1; i <= NF; i++) { + if ( $i != "NCURSES_CONST" ) { + first = i; + break; + } + } + second = first + 1; + returnCast = ""; + if ( $first == "chtype" ) { + returnType = "Chtype"; + } 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 = "IntAttr"; + returnCast = "(attr_t)"; + } else if ( $first == "bool" || $first == "NCURSES_BOOL" ) { + returnType = "Bool"; + } else if ( $second == "*" ) { + returnType = ($1 == "NCURSES_CONST") ? "CPtr" : "Ptr"; + } else { + returnType = "Code"; + } + myfunc = second; + for (i = second; i <= NF; i++) { + if ($i != "*") { + myfunc = i; + break; + } + } + if (using == "implemented") { + printf "#undef %s\n", $myfunc; + } + print $0; + print "{"; + argcount = 1; + check = NF - 1; + if ($check == "void") + argcount = 0; + if (argcount != 0) { + for (i = 1; i <= NF; i++) + if ($i == ",") + argcount++; + } + + # suppress trace-code for functions that we cannot do properly here, + # since they return data. + dotrace = 1; + if ($myfunc ~ /innstr/) + dotrace = 0; + if ($myfunc ~ /innwstr/) + dotrace = 0; + + # workaround functions that we do not parse properly + if ($myfunc ~ /ripoffline/) { + dotrace = 0; + argcount = 2; + if ($myfunc ~ /NCURSES_SP_NAME/) { + argcount = 3; + } + } + if ($myfunc ~ /wunctrl/) { + dotrace = 0; + } + + do_getstr = 0; + if ($myfunc ~ /get[n]?str/) { + do_getstr = 1; + } + + call = "@@T((T_CALLED(\"" + args = "" + comma = "" + num = 0; + pointer = 0; + va_list = 0; + varargs = 0; + argtype = "" + for (i = myfunc; i <= NF; i++) { + ch = $i; + if ( ch == "*" ) { + pointer = 1; + } else if ( ch == "va_list" ) { + va_list = 1; + } else if ( ch == "..." ) { + varargs = 1; + } else if ( ch == "char" ) { + argtype = "char"; + } else if ( ch == "int" ) { + argtype = "int"; + } else if ( ch == "short" ) { + argtype = "short"; + } else if ( ch == "chtype" ) { + argtype = "chtype"; + } else if ( ch == "attr_t" || ch == "NCURSES_ATTR_T" ) { + argtype = "attr"; + } + + if ( ch == "," || ch == ")" ) { + argcast = ""; + if (va_list) { + call = call "%s" + } else if (varargs) { + call = call "%s" + } else if (pointer) { + if ( argtype == "char" ) { + if (do_getstr) { + call = call "%p" + } else { + call = call "%s" + } + comma = comma "_nc_visbuf2(" num "," + pointer = 0; + } else { + call = call "%p" + comma = comma "(const void *)" + } + } else if (argcount != 0) { + if ( argtype == "int" || argtype == "short" ) { + call = call "%d" + argtype = "" + } else if ( argtype != "" ) { + call = call "%s" + comma = comma "_trace" argtype "2(" num "," + if (argtype == "attr") { + argcast = "(chtype)"; + } + } else { + call = call "%#lx" + comma = comma "(long)" + } + } + if (ch == ",") { + args = args comma "a" ++num; + } else if ( argcount != 0 ) { + if ( va_list ) { + args = args comma "\"va_list\"" + } else if ( varargs ) { + args = args comma "\"...\"" + } else { + args = args comma argcast "z" + } + } + call = call ch + if (pointer == 0 && argcount != 0 && argtype != "" ) + args = args ")" + if (args != "") + comma = ", " + pointer = 0; + argtype = "" + } + if ( i == myfunc || ch == "(" ) + call = call ch + } + call = call "\")" + if (args != "") + call = call ", " args + call = call ")); " + + if (dotrace) + printf "%s\n\t@@", call + + if (match($0, "^void")) { + call = "" + } else if (dotrace) { + call = sprintf("return%s( ", returnType); + if (returnCast != "") { + call = call returnCast; + } + } else { + call = "@@return "; + } + + 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) { + call = call ")"; + } + print call ";" + + if (match($0, "^void")) + print "@@returnVoid;" + print "}"; +} +EOF1 + +cat >$AW2 <" + print "" + print "#if USE_STDBOOL_H" + print "#include " + print "#endif" + print "" + print "#undef NCURSES_NOMACROS /* _this_ file uses macros */" + print "#define NCURSES_NOMACROS 1" + print "" + print "#include " + print "" + } +/^DECLARATIONS/ {start = 1; next;} + { + if (start) { + if ( "$USE" == "generated" ) { + print \$0; + } else if ( \$0 ~ /^[{}]?\$/ ) { + print \$0; + } else if ( \$0 ~ /;/ ) { + print \$0; + } else { + calls[start] = \$0; + print \$0; + start++; + } + } + } +END { + if ( "$USE" != "generated" ) { + print "static int link_test(int code)" + print "{" + print " switch(code)" + print " {" + casenum = 1; + for (n = 1; n < start; ++n) { + value = calls[n]; + if ( value !~ /P_POUNDC/ ) { + gsub(/[ \t]+/," ",value); + sub(/^[0-9a-zA-Z_]+ /,"",value); + sub(/^[*][ \t]*/,"",value); + gsub("struct[ \t]*[0-9a-zA-Z_]+[ \t]*[*]","",value); + arg_l = index(value, "("); + arg_r = index(value, ")"); + if ( arg_l > 0 && arg_r > arg_l + 1 ) { + args = substr(value, arg_l + 1, arg_r - arg_l - 1); + gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*[0-9a-zA-Z_]+/,"NULL",args); + gsub(/ (bool|int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",args); + value = substr(value,0,arg_l) args substr(value,arg_r); + } + gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*/,"",value); + gsub(/ (const) /," ",value); + gsub(/ (bool|int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",value); + gsub(/ void /,"",value); + sub(/^/,"call_",value); + gsub(/ (a[0-9]|z) /, " 0 ", value); + gsub(/ int[ \t]*[(][^)]+[)][(][^)]+[)]/, "0", value); + if ( index(value, "call_NCURSES_SP_NAME") > 0 ) { + sub("0","NULL", value); + } + printf " case %d: %s; break;\n", casenum++, value; + } else { + if ( index(value, "call_NCURSES_SP_NAME") > 0 ) { + printf "/* FIXME %s */\n", value; + sub("0","NULL", value); + } + print value; + } + } + print " default: return 0; /* case did not exist */" + print " }" + print " return 1; /* case exists */" + print "}" + } + } +EOF1 + +cat >$TMP < +#undef NCURSES_NOMACROS +#include +#include +#include + +DECLARATIONS + +EOF + +sed -n -f $ED1 \ +| sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \ +| sed -f $ED2 \ +| "$AWK" -f $AW1 using="$USE" \ +| sed \ + -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;/' \ + -e 's/gen_//' \ + -e 's/^[ ]*#/#/' \ + -e '/#ident/d' \ + -e '/#line/d' \ +| sed -f $ED4 + +# a simple test-driver checks one or all of the linkages +if test "$USE" = "implemented" +then +cat <<"EOF" +int main(int argc, char *argv[]) +{ + int n; + int rc; + if (argc > 1) + { + rc = !link_test(atoi(argv[1])); + } + else + { + rc = 0; + for (n = 1; ; ++n) + { + printf("TEST %d\n", n); + fflush(stdout); + if (!link_test(n)) + { + rc = 1; + break; + } + } + } + return rc; +} +EOF +fi diff --git a/ncurses/ncurses/base/MKunctrl.awk b/ncurses/ncurses/base/MKunctrl.awk new file mode 100644 index 0000000000..9eb28e8e29 --- /dev/null +++ b/ncurses/ncurses/base/MKunctrl.awk @@ -0,0 +1,180 @@ +# $Id: MKunctrl.awk,v 1.31 2024/12/07 21:06:39 tom Exp $ +############################################################################## +# Copyright 2020,2024 Thomas E. Dickey # +# Copyright 1998-2012,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 (1997-on) +# + +BEGIN { + print "/* generated by MKunctrl.awk */" + print "" + print "#include " + print "#include " + print "" + print "#undef unctrl" + print "" + } +END { + print "NCURSES_EXPORT(NCURSES_CONST char *) safe_unctrl(SCREEN *sp, chtype ch)" + print "{" + 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 = "," + 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) { + part = sprintf ("^\\%03o", ch + 64); + offset = offset + 3; + } else if (ch == 127) { + part = "^?"; + offset = offset + 3; + } else if (ch >= 128 && ch < 160) { + 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 { + gap = gap " " + part = sprintf("\\%03o", ch); + offset = offset + 2; + } + if (ch == 255) + gap = "\n" + else if (((ch + 1) % 8) != 0) + gap = 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 "" + if (bigstrings) { + print "static const char unctrl_blob[] ="blob";" + print "" + stringname = "unctrl_blob + unctrl" + } else { + stringname = "unctrl" + } + print "\tint check = (int) ChCharOf(ch);" + print "\tconst char *result;" + print "" + print "\t(void) sp;" + print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {" + print "#if NCURSES_EXT_FUNCS" + print "\t\tif ((sp != NULL)" + 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 "\t\tif ((check >= 160)" + print "\t\t && (check < 256)" + print "\t\t && !_nc_unicode_locale()" + print "\t\t && ((sp != NULL)" + 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 /* NCURSES_EXT_FUNCS */" + printf "\t\t\tresult = %s_table[check];\n", stringname; + print "\t} else {" + print "\t\tresult = NULL;" + print "\t}" + print "\treturn (NCURSES_CONST char *)result;" + print "}" + print "" + print "NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype ch)" + print "{" + print "\treturn safe_unctrl(CURRENT_SCREEN, ch);" + print "}" + } diff --git a/ncurses/ncurses/base/README b/ncurses/ncurses/base/README new file mode 100644 index 0000000000..7d3a39ac18 --- /dev/null +++ b/ncurses/ncurses/base/README @@ -0,0 +1,39 @@ +------------------------------------------------------------------------------- +-- Copyright 2020 Thomas E. Dickey -- +-- Copyright 1998,2006 Free Software Foundation, Inc. -- +-- -- +-- Copyright (c) 2026 -- +-- Project Tick. All rights reserved. -- +-- -- +-- 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: README,v 1.3 2020/02/02 23:34:34 tom Exp $ +------------------------------------------------------------------------------- + +The functions in this directory are the generic (not device-specific) modules +of ncurses. + +As a rule, these modules should not depend directly on term.h references and +associated terminfo function and variables. diff --git a/ncurses/ncurses/base/define_key.c b/ncurses/ncurses/base/define_key.c new file mode 100644 index 0000000000..251c2b0f3c --- /dev/null +++ b/ncurses/ncurses/base/define_key.c @@ -0,0 +1,89 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2009,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: define_key.c,v 1.24 2025/12/27 12:41:23 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(define_key) (NCURSES_SP_DCLx const char *str, int keycode) +{ + int code = ERR; + + T((T_CALLED("define_key(%p, %s,%d)"), (void *) SP_PARM, _nc_visbuf(str), keycode)); + if (SP_PARM == NULL || !HasTInfoTerminal(SP_PARM)) { + code = ERR; + } else if (keycode > 0) { + unsigned ukey = (unsigned) keycode; + +#if USE_TERM_DRIVER +#define CallHasKey(keycode) CallDriver_1(SP_PARM, td_kyExist, keycode) +#else +#define CallHasKey(keycode) NCURSES_SP_NAME(has_key)(NCURSES_SP_ARGx keycode) +#endif + + if (str != NULL) { + NCURSES_SP_NAME(define_key) (NCURSES_SP_ARGx str, 0); + } else if (CallHasKey(keycode)) { + while (_nc_remove_key(&(SP_PARM->_keytry), ukey)) + code = OK; + } + if (str != NULL) { + if (NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx str) == 0) { + if (_nc_add_to_try(&(SP_PARM->_keytry), str, ukey) == OK) { + code = OK; + } else { + code = ERR; + } + } else { + code = ERR; + } + } + } else { + while (_nc_remove_string(&(SP_PARM->_keytry), str)) + code = OK; + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +define_key(const char *str, int keycode) +{ + return NCURSES_SP_NAME(define_key) (CURRENT_SCREEN, str, keycode); +} +#endif diff --git a/ncurses/ncurses/base/key_defined.c b/ncurses/ncurses/base/key_defined.c new file mode 100644 index 0000000000..d5e8b68151 --- /dev/null +++ b/ncurses/ncurses/base/key_defined.c @@ -0,0 +1,91 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 2003-2006,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +#include +#include + +MODULE_ID("$Id: key_defined.c,v 1.12 2024/12/07 21:24:18 tom Exp $") + +static int +find_definition(TRIES * tree, const char *str) +{ + TRIES *ptr; + int result = OK; + + if (VALID_STRING(str) && *str != '\0') { + for (ptr = tree; ptr != NULL; ptr = ptr->sibling) { + if (UChar(*str) == UChar(ptr->ch)) { + if (str[1] == '\0' && ptr->child != NULL) { + 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) +NCURSES_SP_NAME(key_defined) (NCURSES_SP_DCLx const char *str) +{ + int code = ERR; + + T((T_CALLED("key_defined(%p, %s)"), (void *) SP_PARM, _nc_visbuf(str))); + if (SP_PARM != NULL && str != NULL) { + code = find_definition(SP_PARM->_keytry, str); + } + + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +key_defined(const char *str) +{ + return NCURSES_SP_NAME(key_defined) (CURRENT_SCREEN, str); +} +#endif diff --git a/ncurses/ncurses/base/keybound.c b/ncurses/ncurses/base/keybound.c new file mode 100644 index 0000000000..814aee3a8d --- /dev/null +++ b/ncurses/ncurses/base/keybound.c @@ -0,0 +1,67 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1999-2009,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: keybound.c,v 1.13 2024/12/07 21:24:18 tom 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 *) +NCURSES_SP_NAME(keybound) (NCURSES_SP_DCLx int code, int count) +{ + char *result = NULL; + + T((T_CALLED("keybound(%p, %d,%d)"), (void *) SP_PARM, code, count)); + if (SP_PARM != NULL && code >= 0) { + result = _nc_expand_try(SP_PARM->_keytry, + (unsigned) code, + &count, + (size_t) 0); + } + returnPtr(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +keybound(int code, int count) +{ + return NCURSES_SP_NAME(keybound) (CURRENT_SCREEN, code, count); +} +#endif diff --git a/ncurses/ncurses/base/keyok.c b/ncurses/ncurses/base/keyok.c new file mode 100644 index 0000000000..255d34645b --- /dev/null +++ b/ncurses/ncurses/base/keyok.c @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2012,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: keyok.c,v 1.19 2025/12/27 12:41:23 tom Exp $") + +/* + * Enable (or disable) ncurses' interpretation of a keycode by adding (or + * removing) the corresponding 'tries' entry. + * + * Do this by storing a second tree of tries, which records the disabled keys. + * The simplest way to copy is to make a function that returns the string (with + * nulls set to 0200), then use that to reinsert the string into the + * corresponding tree. + */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag) +{ + int code = ERR; + + if (HasTerminal(SP_PARM)) { + T((T_CALLED("keyok(%p, %d,%d)"), (void *) SP_PARM, c, flag)); +#if USE_TERM_DRIVER + code = CallDriver_2(sp, td_kyOk, c, flag); +#else + if (c >= 0) { + int count = 0; + char *s; + unsigned ch = (unsigned) c; + + if (flag) { + while ((s = _nc_expand_try(SP_PARM->_key_ok, + ch, &count, (size_t) 0)) != NULL) { + if (_nc_remove_key(&(SP_PARM->_key_ok), ch)) { + code = _nc_add_to_try(&(SP_PARM->_keytry), s, ch); + free(s); + count = 0; + if (code != OK) + break; + } else { + free(s); + } + } + } else { + while ((s = _nc_expand_try(SP_PARM->_keytry, + ch, &count, (size_t) 0)) != NULL) { + if (_nc_remove_key(&(SP_PARM->_keytry), ch)) { + code = _nc_add_to_try(&(SP_PARM->_key_ok), s, ch); + free(s); + count = 0; + if (code != OK) + break; + } else { + free(s); + } + } + } + } +#endif + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +keyok(int c, bool flag) +{ + return NCURSES_SP_NAME(keyok) (CURRENT_SCREEN, c, flag); +} +#endif diff --git a/ncurses/ncurses/base/legacy_coding.c b/ncurses/ncurses/base/legacy_coding.c new file mode 100644 index 0000000000..dc788c157a --- /dev/null +++ b/ncurses/ncurses/base/legacy_coding.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2005,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2005 * + * Juergen Pfeifer 2009 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: legacy_coding.c,v 1.7 2024/12/07 20:00:48 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(use_legacy_coding) (NCURSES_SP_DCLx int level) +{ + int result = ERR; + + T((T_CALLED("use_legacy_coding(%p,%d)"), (void *) SP_PARM, level)); + if (level >= 0 && level <= 2 && SP_PARM != NULL) { + result = SP_PARM->_legacy_coding; + SP_PARM->_legacy_coding = level; + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +use_legacy_coding(int level) +{ + return NCURSES_SP_NAME(use_legacy_coding) (CURRENT_SCREEN, level); +} +#endif diff --git a/ncurses/ncurses/base/lib_addch.c b/ncurses/ncurses/base/lib_addch.c new file mode 100644 index 0000000000..95f2abe98c --- /dev/null +++ b/ncurses/ncurses/base/lib_addch.c @@ -0,0 +1,605 @@ +/**************************************************************************** + * Copyright 2019-2022,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* +** lib_addch.c +** +** The routine waddch(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_addch.c,v 1.144 2024/12/07 17:18:07 tom Exp $") + +static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT); + +/* + * Ugly microtweaking alert. Everything from here to end of module is + * likely to be speed-critical -- profiling data sure says it is! + * Most of the important screen-painting functions are shells around + * waddch(). So we make every effort to reduce function-call overhead + * by inlining stuff, even at the cost of making wrapped copies for + * export. Also we supply some internal versions that don't call the + * window sync hook, for use by string-put functions. + */ + +/* Return bit mask for clearing color pair number if given ch has color */ +#define COLOR_MASK(ch) (~(attr_t)(((ch) & A_COLOR) ? A_COLOR : 0)) + +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 */ +{ + 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 bkgrnd */ + a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a); + /* color in ch has precedence */ + if (pair == 0) { + if ((pair = GET_WINDOW_PAIR(win)) == 0) + pair = GetPair(win->_nc_bkgd); + } + AddAttr(ch, (a & COLOR_MASK(AttrOf(ch)))); + SetPair(ch, pair); + } + + 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(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); +} + +/* check if position is legal; if not, return error */ +#ifndef NDEBUG /* treat this like an assertion */ +#define CHECK_POSITION(win, x, y) \ + if (y > win->_maxy \ + || x > win->_maxx \ + || y < 0 \ + || x < 0) { \ + TR(TRACE_VIRTPUT, ("Alert! Win=%p _curx = %d, _cury = %d " \ + "(_maxx = %d, _maxy = %d)", win, x, y, \ + win->_maxx, win->_maxy)); \ + return(ERR); \ + } +#else +#define CHECK_POSITION(win, x, y) /* nothing */ +#endif + +static bool +newline_forces_scroll(const WINDOW *win, NCURSES_SIZE_T *ypos) +{ + bool result = FALSE; + + if (*ypos >= win->_regtop && *ypos <= win->_regbottom) { + if (*ypos == win->_regbottom) { + *ypos = win->_regbottom; + result = TRUE; + } else if (*ypos < win->_maxy) { + *ypos = (NCURSES_SIZE_T) (*ypos + 1); + } + } else if (*ypos < win->_maxy) { + *ypos = (NCURSES_SIZE_T) (*ypos + 1); + } + return result; +} + +/* + * 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); + 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 = (NCURSES_SIZE_T) save_x; + win->_cury = (NCURSES_SIZE_T) 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; + + /* + * If the background character is a wide-character, that may interfere with + * processing multibyte characters in this function. + */ + if (!is8bits(CharOf(CHDEREF(ch)))) { + if (WINDOW_EXT(win, addch_used) != 0) { + /* discard the incomplete multibyte character */ + WINDOW_EXT(win, addch_used) = 0; + TR(TRACE_VIRTPUT, + ("Alert discarded incomplete multibyte")); + } + return 1; + } + + 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 = (int) mbrtowc(&result, + buffer, + (size_t) 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); + + line = win->_line + y; + + CHANGED_CELL(line, x); + + /* + * Build up multibyte characters until we have a wide-character. + */ +#if NCURSES_SP_FUNCS +#define DeriveSP() SCREEN *sp = _nc_screen_of(win); +#else +#define DeriveSP() /*nothing */ +#endif + if_WIDEC({ + DeriveSP(); + if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) { + int len = _nc_build_wch(win, CHREF(ch)); + + if (len >= -1) { + attr_t attr = AttrOf(ch); + + /* handle EILSEQ (i.e., when len >= -1) */ + if (len == -1 && is8bits(CharOf(ch))) { + const char *s = NCURSES_SP_NAME(unctrl) + (NCURSES_SP_ARGx (chtype) CharOf(ch)); + + if (s[1] != '\0') { + int rc = OK; + while (*s != '\0') { + rc = waddch(win, UChar(*s) | attr); + if (rc != OK) + break; + ++s; + } + return rc; + } + } + if (len == -1) + return waddch(win, ' ' | attr); + } 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 = _nc_wacs_width(CharOf(ch)); + int i; + int j; + + if (len == 0) { /* non-spacing */ + if ((x > 0 && y >= 0) + || (win->_maxx >= 0 && win->_cury >= 1)) { + NCURSES_CH_T *dst; + wchar_t *chars; + if (x > 0 && y >= 0) { + for (j = x - 1; j >= 0; --j) { + if (!isWidecExt(win->_line[y].text[j])) { + win->_curx = (NCURSES_SIZE_T) j; + break; + } + } + dst = &(win->_line[y].text[j]); + } else { + dst = &(win->_line[y - 1].text[win->_maxx]); + } + chars = dst->chars; + for (i = 0; i < CCHARW_MAX; ++i) { + if (chars[i] == 0) { + TR(TRACE_VIRTPUT, + ("adding non-spacing %s (level %d)", + _tracech_t(CHREF(ch)), i)); + 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_POSITION(win, x, y); + line = win->_line + y; + } + /* + * 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 (%d, %d..%d) = %s", + win->_cury, win->_curx, x - 1, + _tracech_t(CHREF(line->text[win->_curx])))); + + if (x > win->_maxx) { + return wrap_to_next_line(win); + } + win->_curx = (NCURSES_SIZE_T) x; + return OK; +} + +static NCURSES_INLINE int +waddch_nosync(WINDOW *win, const NCURSES_CH_T ch) +/* the workhorse function -- add a character to the given window */ +{ + NCURSES_SIZE_T x, y; + chtype t = (chtype) CharOf(ch); +#if USE_WIDEC_SUPPORT || NCURSES_SP_FUNCS || USE_REENTRANT + SCREEN *sp = _nc_screen_of(win); +#endif + const char *s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx t); + int tabsize = 8; + + /* + * 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 (and not also a control character), + * treat it that way. + */ + if ((AttrOf(ch) & A_ALTCHARSET) + || ( +#if USE_WIDEC_SUPPORT + (sp != NULL && sp->_legacy_coding) && +#endif + s[1] == 0 + ) + || ( + (isprint(UChar(t)) && !iscntrl(UChar(t))) +#if USE_WIDEC_SUPPORT + || ((sp == NULL || !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; + CHECK_POSITION(win, x, y); + + switch (t) { + case '\t': +#if USE_REENTRANT + tabsize = *ptrTabsize(sp); +#else + tabsize = TABSIZE; +#endif + x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize))); + /* + * Space-fill the tab on the bottom line so that we'll get the + * "correct" cursor position. + */ + if ((!win->_scroll && (y == win->_regbottom)) + || (x <= win->_maxx)) { + NCURSES_CH_T blank = blankchar; + AddAttr(blank, AttrOf(ch)); + while (win->_curx < x) { + if (waddch_literal(win, blank) == ERR) + return (ERR); + } + break; + } else { + wclrtoeol(win); + win->_flags |= _WRAPPED; + if (newline_forces_scroll(win, &y)) { + x = win->_maxx; + if (win->_scroll) { + scroll(win); + x = 0; + } + } else { + x = 0; + } + } + break; + case '\n': + wclrtoeol(win); + if (newline_forces_scroll(win, &y)) { + if (win->_scroll) + scroll(win); + else + return (ERR); + } + /* FALLTHRU */ + case '\r': + x = 0; + win->_flags &= ~_WRAPPED; + break; + case '\b': + if (x == 0) + return (OK); + x--; + win->_flags &= ~_WRAPPED; + break; + default: + while (*s) { + NCURSES_CH_T sch; + SetChar(sch, UChar(*s++), AttrOf(ch)); + if_EXT_COLORS(SetPair(sch, GetPair(ch))); + if (waddch_literal(win, sch) == ERR) + return ERR; + } + return (OK); + } + + win->_curx = x; + win->_cury = y; + + return (OK); +} + +NCURSES_EXPORT(int) +_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_synchook(). We wanted to avoid this in the + * version exported for string puts; they'll call _nc_synchook once at end + * of run. + */ + +/* These are actual entry points */ + +NCURSES_EXPORT(int) +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)"), (void *) win, + _tracechtype(ch))); + + if (win && (waddch_nosync(win, wch) != ERR)) { + _nc_synchook(win); + code = OK; + } + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} + +NCURSES_EXPORT(int) +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)"), + (void *) win, + _tracechtype(ch))); + + if (win && (waddch_nosync(win, wch) != ERR)) { + bool save_immed = win->_immed; + win->_immed = TRUE; + _nc_synchook(win); + win->_immed = save_immed; + code = OK; + } + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/ncurses/ncurses/base/lib_addstr.c b/ncurses/ncurses/base/lib_addstr.c new file mode 100644 index 0000000000..fd840f92bf --- /dev/null +++ b/ncurses/ncurses/base/lib_addstr.c @@ -0,0 +1,262 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * * + * Rewritten 2001-2004 to support wide-characters by * + * Sven Verdoolaege * + * Thomas Dickey * + ****************************************************************************/ + +/* +** lib_addstr.c +* +** The routines waddnstr(), waddchnstr(). +** +*/ + +#include + +MODULE_ID("$Id: lib_addstr.c,v 1.65 2025/02/20 08:53:36 tom Exp $") + +NCURSES_EXPORT(int) +waddnstr(WINDOW *win, const char *astr, int n) +{ + const char *str = astr; + int code = ERR; + + T((T_CALLED("waddnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(astr, n), n)); + + if (win != NULL && str != NULL) { + bool explicit = (n >= 0); + + TR(TRACE_VIRTPUT | TRACE_ATTRS, + ("... current %s", _traceattr(WINDOW_ATTRS(win)))); + code = OK; + + TR(TRACE_VIRTPUT, ("str is not null, length = %d", + (explicit ? n : (int) strlen(str)))); + if (!explicit) + n = INT_MAX; + while ((n-- > 0) && (*str != '\0')) { + 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; + } + } + _nc_synchook(win); + } + TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); + returnCode(code); +} + +NCURSES_EXPORT(int) +waddchnstr(WINDOW *win, const chtype *astr, int n) +{ + NCURSES_SIZE_T y, x; + int code = OK; + int i; + struct ldat *line; + + T((T_CALLED("waddchnstr(%p,%p,%d)"), (void *) win, (const void *) astr, n)); + + if (!win || !astr) + returnCode(ERR); + + y = win->_cury; + x = win->_curx; + if (n < 0) { + const chtype *str; + n = 0; + for (str = (const chtype *) astr; *str != 0; str++) + n++; + } + if (n > win->_maxx - x + 1) + n = win->_maxx - x + 1; + if (n == 0) + returnCode(code); + + line = &(win->_line[y]); + for (i = 0; i < n && ChCharOf(astr[i]) != '\0'; ++i) { + SetChar2(line->text[i + x], astr[i]); + } + CHANGED_RANGE(line, x, (NCURSES_SIZE_T) (x + n - 1)); + + _nc_synchook(win); + returnCode(code); +} + +#if USE_WIDEC_SUPPORT + +NCURSES_EXPORT(int) +_nc_wchstrlen(const cchar_t *s) +{ + int result = 0; + if (s != NULL) { + 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)"), + (void *) win, + _nc_viscbuf(astr, n), + n)); + + if (!win || !astr) + 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 = _nc_wacs_width(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); + } + } else { + len = 1; + } + x = (NCURSES_SIZE_T) (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)"), (void *) win, _nc_viswbufn(str, n), n)); + + if (win != NULL && str != NULL) { + bool explicit = (n >= 0); + + TR(TRACE_VIRTPUT | TRACE_ATTRS, + ("... current %s", _traceattr(WINDOW_ATTRS(win)))); + code = OK; + + TR(TRACE_VIRTPUT, ("str is not null, length = %d", + (explicit ? n : (int) wcslen(str)))); + if (!explicit) + n = INT_MAX; + 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/ncurses/ncurses/base/lib_beep.c b/ncurses/ncurses/base/lib_beep.c new file mode 100644 index 0000000000..84aa85c15f --- /dev/null +++ b/ncurses/ncurses/base/lib_beep.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2013,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * beep.c + * + * The routine beep(). + * + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_beep.c,v 1.21 2025/12/27 12:41:23 tom Exp $") + +/* + * beep() + * + * Sound the current terminal's audible bell if it has one. If not, + * flash the screen if possible. + * + */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(beep) (NCURSES_SP_DCL0) +{ + int res = ERR; + + T((T_CALLED("beep(%p)"), (void *) SP_PARM)); + +#if USE_TERM_DRIVER + if (SP_PARM != NULL) + res = CallDriver_1(SP_PARM, td_doBeepOrFlash, TRUE); +#else + /* FIXME: should make sure that we are not in altchar mode */ + if (cur_term == NULL) { + res = ERR; + } else if (bell) { + res = NCURSES_PUTP2_FLUSH("bell", bell); + } else if (flash_screen) { + res = NCURSES_PUTP2_FLUSH("flash_screen", flash_screen); + _nc_flush(); + } +#endif + + returnCode(res); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +beep(void) +{ + return NCURSES_SP_NAME(beep) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_bkgd.c b/ncurses/ncurses/base/lib_bkgd.c new file mode 100644 index 0000000000..ca263dd893 --- /dev/null +++ b/ncurses/ncurses/base/lib_bkgd.c @@ -0,0 +1,276 @@ +/**************************************************************************** + * Copyright 2018-2021,2024 Thomas E. Dickey * + * Copyright 1998-2014,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Juergen Pfeifer 1997 * + * and: Sven Verdoolaege 2000 * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: lib_bkgd.c,v 1.64 2024/12/07 20:00:48 tom Exp $") + +static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); + +/* + * Set the window's background information. + */ +#if USE_WIDEC_SUPPORT +NCURSES_EXPORT(void) +#else +static NCURSES_INLINE void +#endif +wbkgrndset(WINDOW *win, const ARG_CH_T ch) +{ + T((T_CALLED("wbkgrndset(%p,%s)"), (void *) win, _tracech_t(ch))); + + if (win) { + 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); + +#if NCURSES_EXT_COLORS + { + int pair; + + if (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; + + memset(&wch, 0, sizeof(wch)); + (void) wgetbkgrnd(win, &wch); + tmp = _nc_to_char((wint_t) CharOf(wch)); + + win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp) + | (AttrOf(wch) & ALL_BUT_COLOR) + | (chtype) ColorPair(GET_WINDOW_PAIR(win))); + } +#endif + } + returnVoid; +} + +NCURSES_EXPORT(void) +wbkgdset(WINDOW *win, chtype ch) +{ + NCURSES_CH_T wch; + T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracechtype(ch))); + SetChar2(wch, ch); + wbkgrndset(win, CHREF(wch)); + returnVoid; +} + +/* + * Set the window's background information and apply it to each cell. + */ +static NCURSES_INLINE int +_nc_background(WINDOW *win, const ARG_CH_T ch, bool narrow) +{ +#undef SP_PARM +#define SP_PARM SP /* to use Charable() */ + int code = ERR; + +#if USE_WIDEC_SUPPORT + T((T_CALLED("%s(%p,%s)"), + narrow ? "wbkgd" : "wbkgrnd", + (void *) win, + _tracecchar_t(ch))); +#define TraceChar(c) _tracecchar_t2(1, &(c)) +#else + T((T_CALLED("%s(%p,%s)"), + "wbkgd", + (void *) win, + _tracech_t(ch))); + (void) narrow; +#define TraceChar(c) _tracechar(CharOf(c)) +#endif + + if (SP == NULL) { + ; + } else if (win) { + NCURSES_CH_T new_bkgd = CHDEREF(ch); + NCURSES_CH_T old_bkgd; + int y; + NCURSES_CH_T old_char; + attr_t old_attr; + int old_pair; + NCURSES_CH_T new_char; + attr_t new_attr; + int new_pair; + + /* SVr4 trims color info if non-color terminal */ + if (!SP->_pair_limit) { + RemAttr(new_bkgd, A_COLOR); + SetPair(new_bkgd, 0); + } + + /* avoid setting background-character to a null */ + if (CharOf(new_bkgd) == 0) { + NCURSES_CH_T tmp_bkgd = blank; + SetAttr(tmp_bkgd, AttrOf(new_bkgd)); + SetPair(tmp_bkgd, GetPair(new_bkgd)); + new_bkgd = tmp_bkgd; + } + + memset(&old_bkgd, 0, sizeof(old_bkgd)); + (void) wgetbkgrnd(win, &old_bkgd); + + if (!memcmp(&old_bkgd, &new_bkgd, sizeof(new_bkgd))) { + T(("...unchanged")); + returnCode(OK); + } + + old_char = old_bkgd; + RemAttr(old_char, ~A_CHARTEXT); + old_attr = AttrOf(old_bkgd); + old_pair = GetPair(old_bkgd); + + if (!(old_attr & A_COLOR)) { + old_pair = 0; + } + T(("... old background char %s, attr %s, pair %d", + TraceChar(old_char), _traceattr(old_attr), old_pair)); + + new_char = new_bkgd; + RemAttr(new_char, ~A_CHARTEXT); + new_attr = AttrOf(new_bkgd); + new_pair = GetPair(new_bkgd); + + /* SVr4 limits background character to printable 7-bits */ + if ( +#if USE_WIDEC_SUPPORT + narrow && +#endif + !Charable(new_bkgd)) { + new_char = old_char; + } + if (!(new_attr & A_COLOR)) { + new_pair = 0; + } + T(("... new background char %s, attr %s, pair %d", + TraceChar(new_char), _traceattr(new_attr), new_pair)); + + (void) wbkgrndset(win, CHREF(new_bkgd)); + + /* SVr4 updates color pair if old/new match, otherwise just attrs */ + if ((new_pair != 0) && (new_pair == old_pair)) { + WINDOW_ATTRS(win) = new_attr; + SET_WINDOW_PAIR(win, new_pair); + } else { + WINDOW_ATTRS(win) = new_attr; + } + + for (y = 0; y <= win->_maxy; y++) { + int x; + + for (x = 0; x <= win->_maxx; x++) { + NCURSES_CH_T *cp = &(win->_line[y].text[x]); + int tmp_pair = GetPair(*cp); + attr_t tmp_attr = AttrOf(*cp); + + if (CharEq(*cp, old_bkgd)) { +#if USE_WIDEC_SUPPORT + if (!narrow) { + if (Charable(new_bkgd)) { + SetChar2(*cp, CharOf(new_char)); + } else { + SetChar(*cp, L' ', AttrOf(new_char)); + } + memcpy(cp->chars, + new_char.chars, + CCHARW_MAX * sizeof(cp->chars[0])); + } else +#endif + SetChar2(*cp, CharOf(new_char)); + } + if (tmp_pair != 0) { + if (tmp_pair == old_pair) { + SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr); + SetPair(*cp, new_pair); + } else { + SetAttr(*cp, + (tmp_attr & (~old_attr | A_COLOR)) + | (new_attr & ALL_BUT_COLOR)); + } + } else { + SetAttr(*cp, (tmp_attr & ~old_attr) | new_attr); + SetPair(*cp, new_pair); + } + } + } + touchwin(win); + _nc_synchook(win); + code = OK; + } + returnCode(code); +} + +#if USE_WIDEC_SUPPORT +NCURSES_EXPORT(int) +wbkgrnd(WINDOW *win, const ARG_CH_T ch) +{ + return _nc_background(win, ch, FALSE); +} +#endif + +NCURSES_EXPORT(int) +wbkgd(WINDOW *win, chtype ch) +{ + NCURSES_CH_T wch; + SetChar2(wch, ch); + return _nc_background(win, CHREF(wch), TRUE); +} diff --git a/ncurses/ncurses/base/lib_box.c b/ncurses/ncurses/base/lib_box.c new file mode 100644 index 0000000000..95d57b8871 --- /dev/null +++ b/ncurses/ncurses/base/lib_box.c @@ -0,0 +1,143 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2010,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Sven Verdoolaege 2001 * + ****************************************************************************/ + +/* +** lib_box.c +** +** The routine wborder(). +** +*/ + +#include + +MODULE_ID("$Id: lib_box.c,v 1.26 2020/02/02 23:34:34 tom 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 ((attr_t) 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) +{ + 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)"), + (void *) win, + _tracechtype2(1, ls), + _tracechtype2(2, rs), + _tracechtype2(3, ts), + _tracechtype2(4, bs), + _tracechtype2(5, tl), + _tracechtype2(6, tr), + _tracechtype2(7, bl), + _tracechtype2(8, br))); + + if (!win) + returnCode(ERR); + + 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 %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++) { + 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++) { +#if USE_WIDEC_SUPPORT + if (endx > 0 && isWidecExt(win->_line[i].text[endx])) { + SetChar2(win->_line[i].text[endx - 1], ' '); + } +#endif + SetChar2(win->_line[i].text[0], wls); + SetChar2(win->_line[i].text[endx], wrs); + win->_line[i].firstchar = 0; + win->_line[i].lastchar = endx; +#if USE_WIDEC_SUPPORT + if (isWidecExt(win->_line[i].text[1])) { + SetChar2(win->_line[i].text[1], ' '); + } +#endif + } + 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/ncurses/ncurses/base/lib_chgat.c b/ncurses/ncurses/base/lib_chgat.c new file mode 100644 index 0000000000..2ae79d1c91 --- /dev/null +++ b/ncurses/ncurses/base/lib_chgat.c @@ -0,0 +1,84 @@ +/**************************************************************************** + * Copyright 2020-2015,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Sven Verdoolaege 2001 * + * and: Thomas E. Dickey 2005 * + ****************************************************************************/ + +/* +** lib_chgat.c +** +** The routine wchgat(). +** +*/ + +#include + +MODULE_ID("$Id: lib_chgat.c,v 1.15 2025/02/15 20:53:36 tom Exp $") + +NCURSES_EXPORT(int) +wchgat(WINDOW *win, + int n, + attr_t attr, + NCURSES_PAIRS_T pair_arg, + const void *opts GCC_UNUSED) +{ + int code = ERR; + int color_pair = pair_arg; + + T((T_CALLED("wchgat(%p,%d,%s,%d)"), + (void *) win, + n, + _traceattr(attr), + color_pair)); + + set_extended_pair(opts, color_pair); + if (win != NULL + && color_pair >= 0) { + struct ldat *line = &(win->_line[win->_cury]); + int i; + + toggle_attr_on(attr, ColorPair(color_pair)); + + for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) { + SetAttr(line->text[i], attr); + SetPair(line->text[i], color_pair); + CHANGED_CELL(line, i); + } + + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_clear.c b/ncurses/ncurses/base/lib_clear.c new file mode 100644 index 0000000000..ae36a3e2e1 --- /dev/null +++ b/ncurses/ncurses/base/lib_clear.c @@ -0,0 +1,60 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_clear.c +** +** The routine wclear(). +** +*/ + +#include + +MODULE_ID("$Id: lib_clear.c,v 1.9 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +wclear(WINDOW *win) +{ + int code = ERR; + + T((T_CALLED("wclear(%p)"), (void *) win)); + + if ((code = werase(win)) != ERR) + win->_clear = TRUE; + + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_clearok.c b/ncurses/ncurses/base/lib_clearok.c new file mode 100644 index 0000000000..276bf8423e --- /dev/null +++ b/ncurses/ncurses/base/lib_clearok.c @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_clearok.c +** +** The routine clearok. +** +*/ + +#include + +MODULE_ID("$Id: lib_clearok.c,v 1.6 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +clearok(WINDOW *win, bool flag) +{ + T((T_CALLED("clearok(%p,%d)"), (void *) win, flag)); + + if (win) { + win->_clear = flag; + returnCode(OK); + } else + returnCode(ERR); +} diff --git a/ncurses/ncurses/base/lib_clrbot.c b/ncurses/ncurses/base/lib_clrbot.c new file mode 100644 index 0000000000..3596f3876e --- /dev/null +++ b/ncurses/ncurses/base/lib_clrbot.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2006,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_clrbot.c +** +** The routine wclrtobot(). +** +*/ + +#include + +MODULE_ID("$Id: lib_clrbot.c,v 1.22 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +wclrtobot(WINDOW *win) +{ + int code = ERR; + + T((T_CALLED("wclrtobot(%p)"), (void *) win)); + + if (win) { + NCURSES_SIZE_T y; + NCURSES_SIZE_T startx = win->_curx; + NCURSES_CH_T blank = win->_nc_bkgd; + + 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]); + NCURSES_CH_T *ptr = &(line->text[startx]); + NCURSES_CH_T *end = &(line->text[win->_maxx]); + + CHANGED_TO_EOL(line, startx, win->_maxx); + + while (ptr <= end) + *ptr++ = blank; + + startx = 0; + } + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_clreol.c b/ncurses/ncurses/base/lib_clreol.c new file mode 100644 index 0000000000..97de42f452 --- /dev/null +++ b/ncurses/ncurses/base/lib_clreol.c @@ -0,0 +1,95 @@ +/**************************************************************************** + * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 1998-2001,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_clreol.c +** +** The routine wclrtoeol(). +** +*/ + +#include + +MODULE_ID("$Id: lib_clreol.c,v 1.24 2021/10/23 19:06:01 tom Exp $") + +NCURSES_EXPORT(int) +wclrtoeol(WINDOW *win) +{ + int code = ERR; + + T((T_CALLED("wclrtoeol(%p)"), (void *) win)); + + if (win) { + NCURSES_CH_T blank; + NCURSES_CH_T *ptr, *end; + struct ldat *line; + NCURSES_SIZE_T y = win->_cury; + NCURSES_SIZE_T x = win->_curx; + + /* + * If we have just wrapped the cursor, the clear applies to the + * new line, unless we are at the lower right corner. + */ + if (IS_WRAPPED(win) != 0 + && y < win->_maxy) { + win->_flags &= ~_WRAPPED; + } + + /* + * There's no point in clearing if we're not on a legal + * position, either. + */ + if (IS_WRAPPED(win) + || y > win->_maxy + || x > win->_maxx) + returnCode(ERR); + + blank = win->_nc_bkgd; + line = &win->_line[y]; + CHANGED_TO_EOL(line, x, win->_maxx); + + ptr = &(line->text[x]); + end = &(line->text[win->_maxx]); + + while (ptr <= end) + *ptr++ = blank; + + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_color.c b/ncurses/ncurses/base/lib_color.c new file mode 100644 index 0000000000..739da30cd8 --- /dev/null +++ b/ncurses/ncurses/base/lib_color.c @@ -0,0 +1,1171 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* lib_color.c + * + * Handles color emulation of SYS V curses + */ + +#define NEW_PAIR_INTERNAL 1 + +#include +#include +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_color.c,v 1.157 2025/12/27 12:31:03 tom Exp $") + +#if USE_TERM_DRIVER +#define CanChange InfoOf(SP_PARM).canchange +#define DefaultPalette InfoOf(SP_PARM).defaultPalette +#define HasColor InfoOf(SP_PARM).hascolor +#define InitColor InfoOf(SP_PARM).initcolor +#define MaxColors InfoOf(SP_PARM).maxcolors +#define MaxPairs InfoOf(SP_PARM).maxpairs +#define UseHlsPalette (DefaultPalette == _nc_hls_palette) +#else +#define CanChange can_change +#define DefaultPalette (hue_lightness_saturation ? hls_palette : cga_palette) +#define HasColor has_color +#define InitColor initialize_color +#define MaxColors max_colors +#define MaxPairs max_pairs +#define UseHlsPalette (hue_lightness_saturation) +#endif + +#if !USE_TERM_DRIVER +/* + * 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. + */ +#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 +#endif /* !USE_TERM_DRIVER */ + +#define DATA(r,g,b) {r,g,b, 0,0,0, 0} + +#define MAX_PALETTE 8 + +#define OkColorHi(n) (((n) < COLORS) && ((n) < maxcolors)) +#define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE) + +/* + * Given a RGB range of 0..1000, we'll normally set the individual values + * to about 2/3 of the maximum, leaving full-range for bold/bright colors. + */ +#define RGB_ON 680 +#define RGB_OFF 0 +/* *INDENT-OFF* */ +static const color_t cga_palette[] = +{ + /* R G B */ + 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 */ + 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 */ +}; + +#if USE_TERM_DRIVER +NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette = cga_palette; +NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette = hls_palette; +#endif + +/* *INDENT-ON* */ +#if NCURSES_EXT_FUNCS +/* + * 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(NCURSES_SP_DCL0) +{ + return (SP_PARM != NULL) ? SP_PARM->_default_fg : COLOR_WHITE; +} + +static int +default_bg(NCURSES_SP_DCL0) +{ + return SP_PARM != NULL ? SP_PARM->_default_bg : COLOR_BLACK; +} +#else +#define default_fg(sp) COLOR_WHITE +#define default_bg(sp) COLOR_BLACK +#endif + +#if !USE_TERM_DRIVER +/* + * SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly + * to maintain compatibility with a pre-ANSI scheme. The same scheme is + * also used in the FreeBSD syscons. + */ +static int +toggled_colors(int c) +{ + if (c < 16) { + static const int table[] = + {0, 4, 2, 6, 1, 5, 3, 7, + 8, 12, 10, 14, 9, 13, 11, 15}; + c = table[c]; + } + return c; +} +#endif + +static void +set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc) +{ +#if USE_TERM_DRIVER + CallDriver_3(SP_PARM, td_color, FALSE, bg, outc); +#else + if (set_a_background) { + TPUTS_TRACE("set_a_background"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_a_background, bg), + 1, outc); + } else { + TPUTS_TRACE("set_background"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_background, toggled_colors(bg)), + 1, outc); + } +#endif +} + +static void +set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc) +{ +#if USE_TERM_DRIVER + CallDriver_3(SP_PARM, td_color, TRUE, fg, outc); +#else + if (set_a_foreground) { + TPUTS_TRACE("set_a_foreground"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_a_foreground, fg), + 1, outc); + } else { + TPUTS_TRACE("set_foreground"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_foreground, toggled_colors(fg)), + 1, outc); + } +#endif +} + +static void +init_color_table(NCURSES_SP_DCL0) +{ + const color_t *tp = DefaultPalette; + int n; + + assert(tp != 0); + + for (n = 0; n < COLORS; n++) { + if (InPalette(n)) { + SP_PARM->_color_table[n] = tp[n]; + } else { + SP_PARM->_color_table[n] = tp[n % MAX_PALETTE]; + if (UseHlsPalette) { + SP_PARM->_color_table[n].green = 100; + } else { + if (SP_PARM->_color_table[n].red) + SP_PARM->_color_table[n].red = 1000; + if (SP_PARM->_color_table[n].green) + SP_PARM->_color_table[n].green = 1000; + if (SP_PARM->_color_table[n].blue) + SP_PARM->_color_table[n].blue = 1000; + } + } + } +} + +static bool +init_direct_colors(NCURSES_SP_DCL0) +{ + static NCURSES_CONST char name[] = UserCap(RGB); + + rgb_bits_t *result = &(SP_PARM->_direct_color); + + result->value = 0; + + if (COLORS >= 8) { + int n; + const char *s; + int width; + + /* find the number of bits needed for the maximum color value */ + for (width = 0; (1 << width) - 1 < (COLORS - 1); ++width) { + ; + } + + if (tigetflag(name) > 0) { + n = (width + 2) / 3; + result->bits.red = UChar(n); + result->bits.green = UChar(n); + result->bits.blue = UChar(width - (2 * n)); + } else if ((n = tigetnum(name)) > 0) { + result->bits.red = UChar(n); + result->bits.green = UChar(n); + result->bits.blue = UChar(n); + } else if ((s = tigetstr(name)) != NULL && VALID_STRING(s)) { + int red = n; + int green = n; + int blue = width - (2 * n); + + switch (sscanf(s, "%d/%d/%d", &red, &green, &blue)) { + default: + blue = width - (2 * n); + /* FALLTHRU */ + case 1: + green = n; + /* FALLTHRU */ + case 2: + red = n; + /* FALLTHRU */ + case 3: + /* okay */ + break; + } + result->bits.red = UChar(red); + result->bits.green = UChar(green); + result->bits.blue = UChar(blue); + } + } + return (result->value != 0); +} + +/* + * Reset the color pair, e.g., to whatever color pair 0 is. + */ +static bool +reset_color_pair(NCURSES_SP_DCL0) +{ +#if USE_TERM_DRIVER + return CallDriver(SP_PARM, td_rescol); +#else + bool result = FALSE; + + (void) SP_PARM; + if (orig_pair != NULL) { + (void) NCURSES_PUTP2("orig_pair", orig_pair); + result = TRUE; + } + return result; +#endif +} + +/* + * 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. + */ +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0) +{ + int result = FALSE; + + T((T_CALLED("_nc_reset_colors(%p)"), (void *) SP_PARM)); + if (SP_PARM->_color_defs > 0) + SP_PARM->_color_defs = -(SP_PARM->_color_defs); + if (reset_color_pair(NCURSES_SP_ARG)) + result = TRUE; + +#if USE_TERM_DRIVER + result = CallDriver(SP_PARM, td_rescolors); +#else + if (orig_colors != NULL) { + NCURSES_PUTP2("orig_colors", orig_colors); + result = TRUE; + } +#endif + returnBool(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +_nc_reset_colors(void) +{ + return NCURSES_SP_NAME(_nc_reset_colors) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0) +{ + int result = ERR; + + T((T_CALLED("start_color(%p)"), (void *) SP_PARM)); + + if (SP_PARM == NULL) { + result = ERR; + } else if (SP_PARM->_coloron) { + result = OK; + } else { + int maxpairs = MaxPairs; + int maxcolors = MaxColors; + if (reset_color_pair(NCURSES_SP_ARG) != TRUE) { + set_foreground_color(NCURSES_SP_ARGx + default_fg(NCURSES_SP_ARG), + NCURSES_SP_NAME(_nc_outch)); + set_background_color(NCURSES_SP_ARGx + default_bg(NCURSES_SP_ARG), + NCURSES_SP_NAME(_nc_outch)); + } +#if !NCURSES_EXT_COLORS + /* + * Without ext-colors, we cannot represent more than 256 color pairs. + */ + if (maxpairs > 256) + maxpairs = 256; +#endif + + if (maxpairs > 0 && maxcolors > 0) { + SP_PARM->_pair_limit = maxpairs; + +#if NCURSES_EXT_FUNCS + /* + * If using default colors, allocate extra space in table to + * allow for default-color as a component of a color-pair. + */ + if (maxcolors < maxpairs) { + SP_PARM->_pair_limit += (1 + (2 * maxcolors)); + } +#if !NCURSES_EXT_COLORS + SP_PARM->_pair_limit = limit_PAIRS(SP_PARM->_pair_limit); +#endif +#endif /* NCURSES_EXT_FUNCS */ + SP_PARM->_pair_count = maxpairs; + SP_PARM->_color_count = maxcolors; +#if !USE_REENTRANT + COLOR_PAIRS = maxpairs; + COLORS = maxcolors; +#endif + + ReservePairs(SP_PARM, 16); + if (SP_PARM->_color_pairs != NULL) { + if (init_direct_colors(NCURSES_SP_ARG)) { + result = OK; + } else { + TYPE_CALLOC(color_t, maxcolors, SP_PARM->_color_table); + if (SP_PARM->_color_table != NULL) { + MakeColorPair(SP_PARM->_color_pairs[0], + default_fg(NCURSES_SP_ARG), + default_bg(NCURSES_SP_ARG)); + init_color_table(NCURSES_SP_ARG); + + result = OK; + } + } + if (result == OK) { + T(("started color: COLORS = %d, COLOR_PAIRS = %d", + COLORS, COLOR_PAIRS)); + + SP_PARM->_coloron = 1; + } else if (SP_PARM->_color_pairs != NULL) { + FreeAndNull(SP_PARM->_color_pairs); + } + } + } else { + result = OK; + } + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +start_color(void) +{ + return NCURSES_SP_NAME(start_color) (CURRENT_SCREEN); +} +#endif + +/* This function was originally written by Daniel Weaver */ +static void +rgb2hls(int r, int g, int b, int *h, int *l, int *s) +/* convert RGB to HLS system */ +{ + int min, max, t; + + if ((min = g < r ? g : r) > b) + min = b; + if ((max = g > r ? g : r) < b) + max = b; + + /* calculate lightness */ + *l = ((min + max) / 20); + + if (min == max) { /* black, white and all shades of gray */ + *h = 0; + *s = 0; + return; + } + + /* calculate saturation */ + if (*l < 50) + *s = (((max - min) * 100) / (max + min)); + else + *s = (((max - min) * 100) / (2000 - max - min)); + + /* calculate hue */ + if (r == max) + t = (120 + ((g - b) * 60) / (max - min)); + else if (g == max) + t = (240 + ((b - r) * 60) / (max - min)); + else + t = (360 + ((r - g) * 60) / (max - min)); + + *h = (t % 360); +} + +/* + * Change all cells which use(d) a given color pair to force a repaint. + */ +NCURSES_EXPORT(void) +_nc_change_pair(SCREEN *sp, int pair) +{ + int y, x; + + if (CurScreen(sp)->_clear) + return; +#if NO_LEAKS + if (_nc_globals.leak_checking) + return; +#endif + + for (y = 0; y <= CurScreen(sp)->_maxy; y++) { + struct ldat *ptr = &(CurScreen(sp)->_line[y]); + bool changed = FALSE; + for (x = 0; x <= CurScreen(sp)->_maxx; x++) { + if (GetPair(ptr->text[x]) == pair) { + /* Set the old cell to zero to ensure it will be + updated on the next doupdate() */ + SetChar(ptr->text[x], 0, 0); + CHANGED_CELL(ptr, x); + changed = TRUE; + } + } + if (changed) + NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y); + } +} + +NCURSES_EXPORT(void) +_nc_reserve_pairs(SCREEN *sp, int want) +{ + int have = sp->_pair_alloc; + + if (have == 0) + have = 1; + while (have <= want) + have *= 2; + if (have > sp->_pair_limit) + have = sp->_pair_limit; + + if (sp->_color_pairs == NULL) { + TYPE_CALLOC(colorpair_t, have, sp->_color_pairs); + } else if (have > sp->_pair_alloc) { +#if NCURSES_EXT_COLORS && NCURSES_EXT_FUNCS + colorpair_t *next; + + if ((next = typeCalloc(colorpair_t, have)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); + memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next)); + _nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc); + free(sp->_color_pairs); + sp->_color_pairs = next; +#else + TYPE_REALLOC(colorpair_t, have, sp->_color_pairs); + if (sp->_color_pairs != NULL) { + memset(sp->_color_pairs + sp->_pair_alloc, 0, + sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc)); + } +#endif + } + if (sp->_color_pairs != NULL) { + sp->_pair_alloc = have; + } +} + +/* + * Extension (1997/1/18) - Allow negative f/b values to set default color + * values. + */ +NCURSES_EXPORT(int) +_nc_init_pair(SCREEN *sp, int pair, int f, int b) +{ + static colorpair_t null_pair; + colorpair_t result = null_pair; + colorpair_t previous; + int maxcolors; + + T((T_CALLED("init_pair(%p,%d,%d,%d)"), (void *) sp, pair, f, b)); + + if (!ValidPair(sp, pair)) + returnCode(ERR); + + maxcolors = MaxColors; + + ReservePairs(sp, pair); + previous = sp->_color_pairs[pair]; +#if NCURSES_EXT_FUNCS + if (sp->_default_color || sp->_assumed_color) { + bool isDefault = FALSE; + bool wasDefault = FALSE; + int default_pairs = sp->_default_pairs; + + /* + * Map caller's color number, e.g., -1, 0, 1, .., 7, etc., into + * internal unsigned values which we will store in the _color_pairs[] + * table. + */ + if (isDefaultColor(f)) { + f = COLOR_DEFAULT; + isDefault = TRUE; + } else if (!OkColorHi(f)) { + returnCode(ERR); + } + + if (isDefaultColor(b)) { + b = COLOR_DEFAULT; + isDefault = TRUE; + } else if (!OkColorHi(b)) { + returnCode(ERR); + } + + /* + * Check if the table entry that we are going to init/update used + * default colors. + */ + if (isDefaultColor(FORE_OF(previous)) + || isDefaultColor(BACK_OF(previous))) + wasDefault = TRUE; + + /* + * Keep track of the number of entries in the color pair table which + * used a default color. + */ + if (isDefault && !wasDefault) { + ++default_pairs; + } else if (wasDefault && !isDefault) { + --default_pairs; + } + + /* + * As an extension, ncurses allows the pair number to exceed the + * terminal's color_pairs value for pairs using a default color. + * + * Note that updating a pair which used a default color with one + * that does not will decrement the count - and possibly interfere + * with sequentially adding new pairs. + */ + if (pair > (sp->_pair_count + default_pairs)) { + returnCode(ERR); + } + sp->_default_pairs = default_pairs; + } else +#endif + { + if ((f < 0) || !OkColorHi(f) + || (b < 0) || !OkColorHi(b) + || (pair < 1)) { + returnCode(ERR); + } + } + + /* + * When a pair's content is changed, replace its colors (if pair was + * initialized before a screen update is performed replacing original + * pair colors with the new ones). + */ + MakeColorPair(result, f, b); + if ((FORE_OF(previous) != 0 + || BACK_OF(previous) != 0) + && !isSamePair(previous, result)) { + _nc_change_pair(sp, pair); + } + + _nc_reset_color_pair(sp, pair, &result); + sp->_color_pairs[pair] = result; + _nc_set_color_pair(sp, pair, cpINIT); + + if (GET_SCREEN_PAIR(sp) == pair) + SET_SCREEN_PAIR(sp, (int) (~0)); /* force attribute update */ + +#if USE_TERM_DRIVER + CallDriver_3(sp, td_initpair, pair, f, b); +#else + if (initialize_pair && InPalette(f) && InPalette(b)) { + const color_t *tp = DefaultPalette; + + TR(TRACE_ATTRS, + ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)", + (int) pair, + (int) tp[f].red, (int) tp[f].green, (int) tp[f].blue, + (int) tp[b].red, (int) tp[b].green, (int) tp[b].blue)); + + NCURSES_PUTP2("initialize_pair", + TIPARM_7(initialize_pair, + pair, + (int) tp[f].red, + (int) tp[f].green, + (int) tp[f].blue, + (int) tp[b].red, + (int) tp[b].green, + (int) tp[b].blue)); + } +#endif + + returnCode(OK); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx + NCURSES_PAIRS_T pair, + NCURSES_COLOR_T f, + NCURSES_COLOR_T b) +{ + return _nc_init_pair(SP_PARM, pair, f, b); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +init_pair(NCURSES_COLOR_T pair, NCURSES_COLOR_T f, NCURSES_COLOR_T b) +{ + return NCURSES_SP_NAME(init_pair) (CURRENT_SCREEN, pair, f, b); +} +#endif + +#define okRGB(n) ((n) >= 0 && (n) <= 1000) + +NCURSES_EXPORT(int) +_nc_init_color(SCREEN *sp, int color, int r, int g, int b) +{ + int result = ERR; + int maxcolors; + + T((T_CALLED("init_color(%p,%d,%d,%d,%d)"), + (void *) sp, + color, + r, g, b)); + + if (sp == NULL || sp->_direct_color.value) + returnCode(result); + + maxcolors = MaxColors; + + if (InitColor + && 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 (UseHlsPalette) { + 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 USE_TERM_DRIVER + CallDriver_4(sp, td_initcolor, color, r, g, b); +#else + NCURSES_PUTP2("initialize_color", + TIPARM_4(initialize_color, color, r, g, b)); +#endif + sp->_color_defs = Max(color + 1, sp->_color_defs); + + result = OK; + } + returnCode(result); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx + NCURSES_COLOR_T color, + NCURSES_COLOR_T r, + NCURSES_COLOR_T g, + NCURSES_COLOR_T b) +{ + return _nc_init_color(SP_PARM, color, r, g, b); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +init_color(NCURSES_COLOR_T color, + NCURSES_COLOR_T r, + NCURSES_COLOR_T g, + NCURSES_COLOR_T b) +{ + return NCURSES_SP_NAME(init_color) (CURRENT_SCREEN, color, r, g, b); +} +#endif + +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL) +{ + bool result = FALSE; + + T((T_CALLED("can_change_color(%p)"), (void *) SP_PARM)); + + if (HasTerminal(SP_PARM) && (CanChange != 0)) { + result = TRUE; + } + + returnBool(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +can_change_color(void) +{ + return NCURSES_SP_NAME(can_change_color) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(has_colors) (NCURSES_SP_DCL0) +{ + bool code = FALSE; + + (void) SP_PARM; + T((T_CALLED("has_colors(%p)"), (void *) SP_PARM)); + if (HasTerminal(SP_PARM)) { +#if USE_TERM_DRIVER + code = HasColor; +#else + code = ((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs) + && (((set_foreground != NULL) + && (set_background != NULL)) + || ((set_a_foreground != NULL) + && (set_a_background != NULL)) + || set_color_pair)) ? TRUE : FALSE); +#endif + } + returnBool(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +has_colors(void) +{ + return NCURSES_SP_NAME(has_colors) (CURRENT_SCREEN); +} +#endif + +static int +_nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b) +{ + int result = ERR; + + T((T_CALLED("color_content(%p,%d,%p,%p,%p)"), + (void *) sp, + color, + (void *) r, + (void *) g, + (void *) b)); + + if (sp != NULL) { + int maxcolors = MaxColors; + + if (color >= 0 && OkColorHi(color) && sp->_coloron) { + int c_r, c_g, c_b; + + if (sp->_direct_color.value) { + rgb_bits_t *work = &(sp->_direct_color); + +#define max_direct_color(name) ((1 << work->bits.name) - 1) +#define value_direct_color(max) (1000 * ((color >> bitoff) & max)) / max + + int max_r = max_direct_color(red); + int max_g = max_direct_color(green); + int max_b = max_direct_color(blue); + + int bitoff = 0; + + c_b = value_direct_color(max_b); + bitoff += work->bits.blue; + + c_g = value_direct_color(max_g); + bitoff += work->bits.green; + + c_r = value_direct_color(max_r); + + } else { + c_r = sp->_color_table[color].red; + c_g = sp->_color_table[color].green; + 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; + } + } + if (result != OK) { + if (r) + *r = 0; + if (g) + *g = 0; + if (b) + *b = 0; + } + returnCode(result); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx + NCURSES_COLOR_T color, + NCURSES_COLOR_T *r, + NCURSES_COLOR_T *g, + NCURSES_COLOR_T *b) +{ + int my_r, my_g, my_b; + int rc = _nc_color_content(SP_PARM, color, &my_r, &my_g, &my_b); + if (rc == OK) { + *r = limit_COLOR(my_r); + *g = limit_COLOR(my_g); + *b = limit_COLOR(my_b); + } + return rc; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +color_content(NCURSES_COLOR_T color, + NCURSES_COLOR_T *r, + NCURSES_COLOR_T *g, + NCURSES_COLOR_T *b) +{ + return NCURSES_SP_NAME(color_content) (CURRENT_SCREEN, color, r, g, b); +} +#endif + +NCURSES_EXPORT(int) +_nc_pair_content(SCREEN *sp, int pair, int *f, int *b) +{ + int result; + + T((T_CALLED("pair_content(%p,%d,%p,%p)"), + (void *) sp, + (int) pair, + (void *) f, + (void *) b)); + + if (!ValidPair(sp, pair)) { + result = ERR; + } else { + int fg; + int bg; + + ReservePairs(sp, pair); + fg = FORE_OF(sp->_color_pairs[pair]); + bg = BACK_OF(sp->_color_pairs[pair]); +#if NCURSES_EXT_FUNCS + if (isDefaultColor(fg)) + fg = -1; + if (isDefaultColor(bg)) + bg = -1; +#endif + + if (f) + *f = fg; + if (b) + *b = bg; + + TR(TRACE_ATTRS, ("...pair_content(%p,%d,%d,%d)", + (void *) sp, + (int) pair, + (int) fg, (int) bg)); + result = OK; + } + returnCode(result); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx + NCURSES_PAIRS_T pair, + NCURSES_COLOR_T *f, + NCURSES_COLOR_T *b) +{ + int my_f, my_b; + int rc = _nc_pair_content(SP_PARM, pair, &my_f, &my_b); + if (rc == OK) { + *f = limit_COLOR(my_f); + *b = limit_COLOR(my_b); + } + return rc; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +pair_content(NCURSES_COLOR_T pair, NCURSES_COLOR_T *f, NCURSES_COLOR_T *b) +{ + return NCURSES_SP_NAME(pair_content) (CURRENT_SCREEN, pair, f, b); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx + int old_pair, + int pair, + int reverse, + NCURSES_SP_OUTC outc) +{ +#if USE_TERM_DRIVER + CallDriver_4(SP_PARM, td_docolor, old_pair, pair, reverse, outc); +#else + int fg = COLOR_DEFAULT; + int bg = COLOR_DEFAULT; + int old_fg = -1; + int old_bg = -1; + + if (!ValidPair(SP_PARM, pair)) { + return; + } else if (pair != 0) { + if (set_color_pair) { + TPUTS_TRACE("set_color_pair"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_color_pair, pair), + 1, outc); + return; + } else if (SP_PARM != NULL) { + if (_nc_pair_content(SP_PARM, pair, &fg, &bg) == ERR) + return; + } + } + + if (old_pair >= 0 + && SP_PARM != NULL + && _nc_pair_content(SP_PARM, 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_PARM->_has_sgr_39_49 + && isDefaultColor(old_bg) + && !isDefaultColor(old_fg)) { + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc); + } else if (SP_PARM->_has_sgr_39_49 + && isDefaultColor(old_fg) + && !isDefaultColor(old_bg)) { + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc); + } else +#endif + reset_color_pair(NCURSES_SP_ARG); + } + } else { + reset_color_pair(NCURSES_SP_ARG); + if (old_pair < 0 && pair <= 0) + return; + } + +#if NCURSES_EXT_FUNCS + if (isDefaultColor(fg)) + fg = default_fg(NCURSES_SP_ARG); + if (isDefaultColor(bg)) + bg = default_bg(NCURSES_SP_ARG); +#endif + + if (reverse) { + int xx = fg; + fg = bg; + bg = xx; + } + + TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair, + fg, bg)); + + if (!isDefaultColor(fg)) { + set_foreground_color(NCURSES_SP_ARGx fg, outc); + } + if (!isDefaultColor(bg)) { + set_background_color(NCURSES_SP_ARGx bg, outc); + } +#endif +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_do_color(int old_pair, int pair, int reverse, NCURSES_OUTC outc) +{ + SetSafeOutcWrapper(outc); + NCURSES_SP_NAME(_nc_do_color) (CURRENT_SCREEN, + old_pair, + pair, + reverse, + _nc_outc_wrapper); +} +#endif + +#if NCURSES_EXT_COLORS && NCURSES_EXT_FUNCS +NCURSES_EXPORT(int) +NCURSES_SP_NAME(init_extended_pair) (NCURSES_SP_DCLx int pair, int f, int b) +{ + return _nc_init_pair(SP_PARM, pair, f, b); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(init_extended_color) (NCURSES_SP_DCLx + int color, + int r, int g, int b) +{ + return _nc_init_color(SP_PARM, color, r, g, b); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(extended_color_content) (NCURSES_SP_DCLx + int color, + int *r, int *g, int *b) +{ + return _nc_color_content(SP_PARM, color, r, g, b); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(extended_pair_content) (NCURSES_SP_DCLx + int pair, + int *f, int *b) +{ + return _nc_pair_content(SP_PARM, pair, f, b); +} + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(reset_color_pairs) (NCURSES_SP_DCL0) +{ + if (SP_PARM != NULL) { + if (SP_PARM->_color_pairs) { + _nc_free_ordered_pairs(SP_PARM); + free(SP_PARM->_color_pairs); + SP_PARM->_color_pairs = NULL; + SP_PARM->_pair_alloc = 0; + ReservePairs(SP_PARM, 16); + clearok(CurScreen(SP_PARM), TRUE); + touchwin(StdScreen(SP_PARM)); + } + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +init_extended_pair(int pair, int f, int b) +{ + return NCURSES_SP_NAME(init_extended_pair) (CURRENT_SCREEN, pair, f, b); +} + +NCURSES_EXPORT(int) +init_extended_color(int color, int r, int g, int b) +{ + return NCURSES_SP_NAME(init_extended_color) (CURRENT_SCREEN, + color, + r, g, b); +} + +NCURSES_EXPORT(int) +extended_color_content(int color, int *r, int *g, int *b) +{ + return NCURSES_SP_NAME(extended_color_content) (CURRENT_SCREEN, + color, + r, g, b); +} + +NCURSES_EXPORT(int) +extended_pair_content(int pair, int *f, int *b) +{ + return NCURSES_SP_NAME(extended_pair_content) (CURRENT_SCREEN, pair, f, b); +} + +NCURSES_EXPORT(void) +reset_color_pairs(void) +{ + NCURSES_SP_NAME(reset_color_pairs) (CURRENT_SCREEN); +} +#endif /* NCURSES_SP_FUNCS */ +#endif /* NCURSES_EXT_COLORS */ diff --git a/ncurses/ncurses/base/lib_colorset.c b/ncurses/ncurses/base/lib_colorset.c new file mode 100644 index 0000000000..d98e688bc7 --- /dev/null +++ b/ncurses/ncurses/base/lib_colorset.c @@ -0,0 +1,68 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1998 * + * and: Thomas E. Dickey, 2005-on * + ****************************************************************************/ + +/* +** lib_colorset.c +** +** The routine wcolor_set(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_colorset.c,v 1.17 2024/12/07 20:00:48 tom Exp $") + +NCURSES_EXPORT(int) +wcolor_set(WINDOW *win, NCURSES_PAIRS_T pair_arg, void *opts) +{ + int code = ERR; + int color_pair = pair_arg; + + T((T_CALLED("wcolor_set(%p,%d)"), (void *) win, color_pair)); + set_extended_pair(opts, color_pair); + if (win + && (SP != NULL) + && (color_pair >= 0) + && (color_pair < SP->_pair_limit)) { + TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win))); + SET_WINDOW_PAIR(win, color_pair); + if_EXT_COLORS(win->_color = color_pair); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_delch.c b/ncurses/ncurses/base/lib_delch.c new file mode 100644 index 0000000000..75e726e389 --- /dev/null +++ b/ncurses/ncurses/base/lib_delch.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2001,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_delch.c +** +** The routine wdelch(). +** +*/ + +#include + +MODULE_ID("$Id: lib_delch.c,v 1.16 2024/10/19 21:20:46 tom Exp $") + +NCURSES_EXPORT(int) +wdelch(WINDOW *win) +{ + int code = ERR; + + T((T_CALLED("wdelch(%p)"), (void *) win)); + + if (win) { + NCURSES_CH_T blank = win->_nc_bkgd; + struct ldat *line = &(win->_line[win->_cury]); + NCURSES_CH_T *end = &(line->text[win->_maxx]); + NCURSES_CH_T *temp1 = &(line->text[win->_curx]); + const NCURSES_CH_T *temp2 = temp1 + 1; + + CHANGED_TO_EOL(line, win->_curx, win->_maxx); + while (temp1 < end) + *temp1++ = *temp2++; + + *temp1 = blank; + + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_delwin.c b/ncurses/ncurses/base/lib_delwin.c new file mode 100644 index 0000000000..ae12d84092 --- /dev/null +++ b/ncurses/ncurses/base/lib_delwin.c @@ -0,0 +1,106 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2008,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2008 * + ****************************************************************************/ + +/* +** lib_delwin.c +** +** The routine delwin(). +** +*/ + +#include + +MODULE_ID("$Id: lib_delwin.c,v 1.29 2024/12/07 17:28:13 tom Exp $") + +static bool +cannot_delete(const WINDOW *win) +{ + bool result = TRUE; + bool found = FALSE; + SCREEN *scan; + WINDOWLIST *p; + + for (each_screen(scan)) { + for (each_window(scan, p)) { + if (&(p->win) == win) { + result = FALSE; + found = TRUE; + break; + } else if (IS_SUBWIN(&(p->win)) + && p->win._parent == win) { + result = TRUE; + found = TRUE; + break; + } + } + if (found) + break; + } + return result; +} + +NCURSES_EXPORT(int) +delwin(WINDOW *win) +{ + int result = ERR; + + T((T_CALLED("delwin(%p)"), (void *) win)); + + if (_nc_try_global(curses) == 0) { + if (win == NULL + || cannot_delete(win)) { + result = ERR; + } else if (IS_PAD(win)) { + win->_parent = NULL; + result = _nc_freewin(win); + } else { +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + if (IS_SUBWIN(win)) { + touchwin(win->_parent); + } else if (CurScreen(SP_PARM) != NULL) { + touchwin(CurScreen(SP_PARM)); + } + result = _nc_freewin(win); + } + _nc_unlock_global(curses); + } + returnCode(result); +} diff --git a/ncurses/ncurses/base/lib_dft_fgbg.c b/ncurses/ncurses/base/lib_dft_fgbg.c new file mode 100644 index 0000000000..2c1e06b495 --- /dev/null +++ b/ncurses/ncurses/base/lib_dft_fgbg.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1998-on * + * Juergen Pfeifer 2009 * + ****************************************************************************/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_dft_fgbg.c,v 1.34 2025/12/27 12:28:45 tom Exp $") + +/* + * Modify the behavior of color-pair 0 so that the library doesn't assume that + * it is white on black. This is an extension to XSI curses. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(use_default_colors) (NCURSES_SP_DCL0) +{ + T((T_CALLED("use_default_colors(%p)"), (void *) SP_PARM)); + returnCode(NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_ARGx -1, -1)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +use_default_colors(void) +{ + return NCURSES_SP_NAME(use_default_colors) (CURRENT_SCREEN); +} +#endif + +/* + * Modify the behavior of color-pair 0 so that the library assumes that it + * is something specific, possibly not white on black. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg) +{ + int code = ERR; + + T((T_CALLED("assume_default_colors(%p,%d,%d)"), (void *) SP_PARM, fg, bg)); + if (SP_PARM != NULL) { +#if USE_TERM_DRIVER + code = CallDriver_2(SP_PARM, td_defaultcolors, fg, bg); +#else + if ((orig_pair || orig_colors) && !initialize_pair) { + + SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg); + SP_PARM->_has_sgr_39_49 = (tigetflag(UserCap(AX)) == TRUE); + SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg; + SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg; + if (SP_PARM->_color_pairs != NULL) { + bool save = SP_PARM->_default_color; + SP_PARM->_assumed_color = TRUE; + SP_PARM->_default_color = TRUE; + NCURSES_SP_NAME(init_pair) (NCURSES_SP_ARGx 0, + (short)fg, + (short)bg); + SP_PARM->_default_color = save; + } + code = OK; + } +#endif + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +assume_default_colors(int fg, int bg) +{ + return NCURSES_SP_NAME(assume_default_colors) (CURRENT_SCREEN, fg, bg); +} +#endif diff --git a/ncurses/ncurses/base/lib_driver.c b/ncurses/ncurses/base/lib_driver.c new file mode 100644 index 0000000000..159b83c289 --- /dev/null +++ b/ncurses/ncurses/base/lib_driver.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2009-2012,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: lib_driver.c,v 1.12 2025/10/18 19:20:33 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(has_key) (SCREEN *sp, int keycode) +{ + T((T_CALLED("has_key(%p, %d)"), (void *) sp, keycode)); + returnCode(IsValidTIScreen(sp) ? CallDriver_1(sp, td_kyExist, keycode) : FALSE); +} + +NCURSES_EXPORT(int) +has_key(int keycode) +{ + return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_mcprint) (SCREEN *sp, char *data, int len) +{ + int code = ERR; + + if (NULL != TerminalOf(sp)) + code = CallDriver_2(sp, td_print, data, len); + return (code); +} + +NCURSES_EXPORT(int) +mcprint(char *data, int len) +{ + return NCURSES_SP_NAME(_nc_mcprint) (CURRENT_SCREEN, data, len); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(doupdate) (SCREEN *sp) +{ + int code = ERR; + + T((T_CALLED("doupdate(%p)"), (void *) sp)); + + if (IsValidScreen(sp)) + code = CallDriver(sp, td_update); + + returnCode(code); +} + +NCURSES_EXPORT(int) +doupdate(void) +{ + return NCURSES_SP_NAME(doupdate) (CURRENT_SCREEN); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(mvcur) (SCREEN *sp, int yold, int xold, int ynew, int xnew) +{ + int code = ERR; + TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%p,%d,%d,%d,%d)"), + (void *) sp, yold, xold, ynew, xnew)); + if (HasTerminal(sp)) { + code = CallDriver_4(sp, td_hwcur, yold, xold, ynew, xnew); + } + returnCode(code); +} + +NCURSES_EXPORT(int) +mvcur(int yold, int xold, int ynew, int xnew) +/* optimized cursor move from (yold, xold) to (ynew, xnew) */ +{ + return NCURSES_SP_NAME(mvcur) (CURRENT_SCREEN, yold, xold, ynew, xnew); +} diff --git a/ncurses/ncurses/base/lib_echo.c b/ncurses/ncurses/base/lib_echo.c new file mode 100644 index 0000000000..dedb53a6f9 --- /dev/null +++ b/ncurses/ncurses/base/lib_echo.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * echo.c + * + * Routines: + * echo() + * noecho() + * + */ + +#include + +MODULE_ID("$Id: lib_echo.c,v 1.11 2024/12/07 20:00:48 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0) +{ + T((T_CALLED("echo(%p)"), (void *) SP_PARM)); + if (NULL == SP_PARM) + returnCode(ERR); + IsEcho(SP_PARM) = TRUE; + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +echo(void) +{ + return NCURSES_SP_NAME(echo) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(noecho) (NCURSES_SP_DCL0) +{ + T((T_CALLED("noecho(%p)"), (void *) SP_PARM)); + if (NULL == SP_PARM) + returnCode(ERR); + IsEcho(SP_PARM) = FALSE; + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +noecho(void) +{ + return NCURSES_SP_NAME(noecho) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_endwin.c b/ncurses/ncurses/base/lib_endwin.c new file mode 100644 index 0000000000..8c193d02ee --- /dev/null +++ b/ncurses/ncurses/base/lib_endwin.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * Copyright 2020-2023,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_endwin.c +** +** The routine endwin(). +** +*/ + +#include + +MODULE_ID("$Id: lib_endwin.c,v 1.29 2025/12/27 12:41:23 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(endwin) (NCURSES_SP_DCL0) +{ + int code = ERR; + + T((T_CALLED("endwin(%p)"), (void *) SP_PARM)); + + if (SP_PARM != NULL) { + if (SP_PARM->_endwin != ewSuspend) { +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = TCBOf(SP_PARM); + + SP_PARM->_endwin = ewSuspend; + if (TCB && TCB->drv && TCB->drv->td_scexit) + TCB->drv->td_scexit(SP_PARM); +#else + SP_PARM->_endwin = ewSuspend; + SP_PARM->_mouse_wrap(SP_PARM); + _nc_screen_wrap(); + _nc_mvcur_wrap(); /* wrap up cursor addressing */ +#endif + code = OK; + } + if (NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_ARG) == ERR) + code = ERR; + } + + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +endwin(void) +{ + return NCURSES_SP_NAME(endwin) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_erase.c b/ncurses/ncurses/base/lib_erase.c new file mode 100644 index 0000000000..72ddefb250 --- /dev/null +++ b/ncurses/ncurses/base/lib_erase.c @@ -0,0 +1,100 @@ +/**************************************************************************** + * Copyright 2020-2022,2024 Thomas E. Dickey * + * Copyright 1998-2009,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_erase.c +** +** The routine werase(). +** +*/ + +#include + +MODULE_ID("$Id: lib_erase.c,v 1.21 2024/12/07 20:00:48 tom Exp $") + +NCURSES_EXPORT(int) +werase(WINDOW *win) +{ + int code = ERR; + NCURSES_CH_T *start; + + T((T_CALLED("werase(%p)"), (void *) win)); + + if (win) { + NCURSES_CH_T blank; + NCURSES_CH_T *sp; + int y; + + blank = win->_nc_bkgd; + for (y = 0; y <= win->_maxy; y++) { + NCURSES_CH_T *end; + + 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 != NULL) ? (win->_begx) : 0; + while (x-- > 0) { + if (isWidecBase(start[-1])) { + --start; + break; + } + --start; + } + } + }); + + for (sp = start; sp <= end; sp++) + *sp = blank; + + win->_line[y].firstchar = 0; + win->_line[y].lastchar = win->_maxx; + } + win->_curx = win->_cury = 0; + win->_flags &= ~_WRAPPED; + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_flash.c b/ncurses/ncurses/base/lib_flash.c new file mode 100644 index 0000000000..00e5b92b1f --- /dev/null +++ b/ncurses/ncurses/base/lib_flash.c @@ -0,0 +1,91 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2013,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * flash.c + * + * The routine flash(). + * + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_flash.c,v 1.17 2025/12/27 12:41:23 tom Exp $") + +/* + * flash() + * + * Flash the current terminal's screen if possible. If not, + * sound the audible bell if one exists. + * + */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(flash) (NCURSES_SP_DCL0) +{ + int res = ERR; + + T((T_CALLED("flash(%p)"), (void *) SP_PARM)); +#if USE_TERM_DRIVER + if (SP_PARM != NULL) + res = CallDriver_1(SP_PARM, td_doBeepOrFlash, FALSE); +#else + if (HasTerminal(SP_PARM)) { + /* FIXME: should make sure that we are not in altchar mode */ + if (flash_screen) { + res = NCURSES_PUTP2_FLUSH("flash_screen", flash_screen); + } else if (bell) { + res = NCURSES_PUTP2_FLUSH("bell", bell); + } + } +#endif + returnCode(res); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +flash(void) +{ + return NCURSES_SP_NAME(flash) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_freeall.c b/ncurses/ncurses/base/lib_freeall.c new file mode 100644 index 0000000000..476da3ad78 --- /dev/null +++ b/ncurses/ncurses/base/lib_freeall.c @@ -0,0 +1,204 @@ +/**************************************************************************** + * Copyright 2018-2021,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +#include +#include + +#if HAVE_NC_FREEALL + +#if HAVE_LIBDBMALLOC +extern int malloc_errfd; /* FIXME */ +#endif + +MODULE_ID("$Id: lib_freeall.c,v 1.78 2024/12/07 18:00:11 tom Exp $") + +/* + * Free all ncurses data. This is used for testing only (there's no practical + * use for it as an extension). + */ +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) +{ + static va_list empty_va; + + T((T_CALLED("_nc_freeall()"))); +#if NO_LEAKS + _nc_globals.leak_checking = TRUE; + if (SP_PARM != NULL) { + if (SP_PARM->_oldnum_list != NULL) { + FreeAndNull(SP_PARM->_oldnum_list); + } + if (SP_PARM->_panelHook.destroy != NULL) { + SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel); + } +#if NCURSES_EXT_COLORS + _nc_new_pair_leaks(SP_PARM); +#endif + } +#endif + if (SP_PARM != NULL) { + _nc_lock_global(curses); + + while (WindowList(SP_PARM) != NULL) { + WINDOWLIST *p, *q; + bool deleted = FALSE; + + /* Delete only windows that're not a parent */ + for (each_window(SP_PARM, p)) { + WINDOW *p_win = &(p->win); + bool found = FALSE; + + if (IS_PAD(p_win)) + continue; + +#ifndef USE_SP_WINDOWLIST + if (p->screen != SP_PARM) + continue; +#endif + + for (each_window(SP_PARM, q)) { + const WINDOW *q_win = &(q->win); + +#ifndef USE_SP_WINDOWLIST + if (q->screen != SP_PARM) + continue; +#endif + + if ((p != q) + && IS_SUBWIN(q_win) + && (p_win == q_win->_parent)) { + found = TRUE; + break; + } + } + + if (!found) { + if (delwin(p_win) != ERR) + deleted = TRUE; + break; + } + } + + /* + * Don't continue to loop if the list is trashed. + */ + if (!deleted) + break; + } + delscreen(SP_PARM); + _nc_unlock_global(curses); + } + + (void) _nc_printf_string(NULL, empty_va); +#ifdef TRACE + (void) _nc_trace_buf(-1, (size_t) 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; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_freeall(void) +{ + NCURSES_SP_NAME(_nc_freeall) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) +{ + T((T_CALLED("_nc_free_and_exit(%d)"), code)); + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_ARG); +#ifdef TRACE + curses_trace(0); /* close trace file, freeing its setbuf */ + { + static va_list fake; + free(_nc_varargs("?", fake)); + } +#endif + exit(code); +} + +#else /* !HAVE_NC_FREEALL */ +NCURSES_EXPORT(void) +_nc_freeall(void) +{ +} + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_free_and_exit) (NCURSES_SP_DCLx int code) +{ + if (SP_PARM) { + delscreen(SP_PARM); + } + exit(code); +} +#endif /* HAVE_NC_FREEALL */ + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_free_and_exit(int code) +{ + NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code); +} +#endif + +NCURSES_EXPORT(void) +exit_curses(int code) +{ +#if NO_LEAKS +#if NCURSES_SP_FUNCS + NCURSES_SP_NAME(_nc_free_and_exit) (CURRENT_SCREEN, code); +#else + _nc_free_and_exit(code); /* deprecated... */ +#endif +#endif + exit(code); +} diff --git a/ncurses/ncurses/base/lib_getch.c b/ncurses/ncurses/base/lib_getch.c new file mode 100644 index 0000000000..f0d51abf47 --- /dev/null +++ b/ncurses/ncurses/base/lib_getch.c @@ -0,0 +1,782 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2015,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_getch.c +** +** The routine getch(). +** +*/ + +#define NEED_KEY_EVENT +#include + +MODULE_ID("$Id: lib_getch.c,v 1.154 2025/12/27 12:28:45 tom Exp $") + +#include + +#if USE_REENTRANT +#define GetEscdelay(sp) *_nc_ptr_Escdelay(sp) +NCURSES_EXPORT(int) +NCURSES_PUBLIC_VAR(ESCDELAY) (void) +{ + return *(_nc_ptr_Escdelay(CURRENT_SCREEN)); +} + +NCURSES_EXPORT(int *) +_nc_ptr_Escdelay(SCREEN *sp) +{ + return ptrEscdelay(sp); +} +#else +#define GetEscdelay(sp) ESCDELAY +NCURSES_EXPORT_VAR(int) ESCDELAY = 1000; +#endif + +#if NCURSES_EXT_FUNCS +NCURSES_EXPORT(int) +NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_DCLx int value) +{ + int code = OK; + if (value < 0) { + code = ERR; + } else { +#if USE_REENTRANT + if (SP_PARM) { + SET_ESCDELAY(value); + } else { + code = ERR; + } +#else + (void) SP_PARM; + ESCDELAY = value; +#endif + } + return code; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +set_escdelay(int value) +{ + int code; + if (value < 0) { + code = ERR; + } else { +#if USE_REENTRANT + code = NCURSES_SP_NAME(set_escdelay) (CURRENT_SCREEN, value); +#else + ESCDELAY = value; + code = OK; +#endif + } + return code; +} +#endif +#endif /* NCURSES_EXT_FUNCS */ + +#if NCURSES_EXT_FUNCS +NCURSES_EXPORT(int) +NCURSES_SP_NAME(get_escdelay) (NCURSES_SP_DCL0) +{ +#if !USE_REENTRANT + (void) SP_PARM; +#endif + return GetEscdelay(SP_PARM); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +get_escdelay(void) +{ + return NCURSES_SP_NAME(get_escdelay) (CURRENT_SCREEN); +} +#endif +#endif /* NCURSES_EXT_FUNCS */ + +static int +_nc_use_meta(WINDOW *win) +{ + SCREEN *sp = _nc_screen_of(win); + return (sp ? sp->_use_meta : 0); +} + +/* + * 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_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp); + rc = TCBOf(sp)->drv->td_testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl)); +# if USE_NAMED_PIPES || defined(_NC_WINDOWS_NATIVE) + /* if we emulate terminfo on console, we have to use the console routine */ + if (IsTermInfoOnConsole(sp)) { + rc = _nc_console_testmouse(sp, + _nc_console_handle(sp->_ifd), + delay EVENTLIST_2nd(evl)); + } else +# endif + rc = TCB->drv->td_testmouse(TCB, delay EVENTLIST_2nd(evl)); +#else /* !USE_TERM_DRIVER */ +# if USE_SYSMOUSE + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail)) { + rc = TW_MOUSE; + } else +# endif + { +# if USE_NAMED_PIPES + rc = _nc_console_testmouse(sp, + _nc_console_handle(sp->_ifd), + delay + EVENTLIST_2nd(evl)); +# else + rc = _nc_timed_wait(sp, + TWAIT_MASK, + delay, + (int *) 0 + EVENTLIST_2nd(evl)); +# endif +# if USE_SYSMOUSE + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail) + && (rc == 0) + && (errno == EINTR)) { + rc |= TW_MOUSE; + } +# endif + } +#endif /* USE_TERM_DRIVER */ + return rc; +} + +static NCURSES_INLINE int +fifo_peek(SCREEN *sp) +{ + int ch = (peek >= 0) ? sp->_fifo[peek] : ERR; + TR(TRACE_IEVENT, ("peeking at %d", peek)); + + p_inc(); + return ch; +} + +static NCURSES_INLINE int +fifo_pull(SCREEN *sp) +{ + int ch = (head >= 0) ? sp->_fifo[head] : ERR; + + TR(TRACE_IEVENT, ("pulling %s from %d", _nc_tracechar(sp, ch), head)); + + if (peek == head) { + h_inc(); + peek = head; + } else { + h_inc(); + } + +#ifdef TRACE + if (USE_TRACEF(TRACE_IEVENT)) { + _nc_fifo_dump(sp); + _nc_unlock_global(tracef); + } +#endif + return ch; +} + +static NCURSES_INLINE int +fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl)) +{ + int n; + int ch = 0; + int mask = 0; + + (void) mask; + if (tail < 0) + return ERR; + +#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 & TW_EVENT) { + T(("fifo_push: ungetch KEY_EVENT")); + safe_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 & TW_MOUSE)) { + 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 +#if USE_TERM_DRIVER + if ((sp->_mouse_type == M_TERM_DRIVER) + && (sp->_drv_mouse_head < sp->_drv_mouse_tail)) { + sp->_mouse_event(sp); + ch = KEY_MOUSE; + n = 1; + } else +#endif +#if USE_KLIBC_KBD + if (NC_ISATTY(sp->_ifd) && IsCbreak(sp)) { + ch = _read_kbd(0, 1, !IsRaw(sp)); + n = (ch == -1) ? -1 : 1; + sp->_extended_key = (ch == 0); + } else +#endif + { /* Can block... */ +#if USE_TERM_DRIVER + int buf; +# if USE_NAMED_PIPES || defined(_NC_WINDOWS_NATIVE) + if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp)) { + _nc_set_read_thread(TRUE); + n = _nc_console_read(sp, + _nc_console_handle(sp->_ifd), + &buf); + _nc_set_read_thread(FALSE); + } else +# endif /* USE_NAMED_PIPES */ + n = CallDriver_1(sp, td_read, &buf); + ch = buf; +#else /* !USE_TERM_DRIVER */ +#if USE_NAMED_PIPES + int buf; +#endif + unsigned char c2 = 0; + + _nc_set_read_thread(TRUE); +#if USE_NAMED_PIPES + n = _nc_console_read(sp, + _nc_console_handle(sp->_ifd), + &buf); + c2 = buf; +#else + n = (int) read(sp->_ifd, &c2, (size_t) 1); +#endif + _nc_set_read_thread(FALSE); + ch = c2; +#endif /* USE_TERM_DRIVER */ + } + + if ((n == -1) || (n == 0)) { + 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; + if (head == -1) + head = peek = tail; + t_inc(); + TR(TRACE_IEVENT, ("pushed %s at %d", _nc_tracechar(sp, ch), tail)); +#ifdef TRACE + if (USE_TRACEF(TRACE_IEVENT)) { + _nc_fifo_dump(sp); + _nc_unlock_global(tracef); + } +#endif + return ch; +} + +static NCURSES_INLINE void +fifo_clear(SCREEN *sp) +{ + memset(sp->_fifo, 0, sizeof(sp->_fifo)); + head = -1; + tail = peek = 0; +} + +static int kgetch(SCREEN *, bool EVENTLIST_2nd(_nc_eventlist *)); + +static void +recur_wrefresh(WINDOW *win) +{ +#ifdef USE_PTHREADS + SCREEN *sp = _nc_screen_of(win); + bool same_sp; + + if (_nc_use_pthreads) { + _nc_lock_global(curses); + same_sp = (sp == CURRENT_SCREEN); + _nc_unlock_global(curses); + } else { + same_sp = (sp == CURRENT_SCREEN); + } + + if (_nc_use_pthreads && !same_sp) { + SCREEN *save_SP; + + /* temporarily switch to the window's screen to check/refresh */ + _nc_lock_global(curses); + save_SP = CURRENT_SCREEN; + _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)) + && !IS_PAD(win)) { + wrefresh(win); + } +} + +static int +recur_wgetnstr(WINDOW *win, char *buf) +{ + SCREEN *sp = _nc_screen_of(win); + int rc; + + if (sp != NULL) { +#ifdef USE_PTHREADS + if (_nc_use_pthreads && sp != CURRENT_SCREEN) { + SCREEN *save_SP; + + /* temporarily switch to the window's screen to get cooked input */ + _nc_lock_global(curses); + save_SP = CURRENT_SCREEN; + _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) +_nc_wgetch(WINDOW *win, + int *result, + int use_meta + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + SCREEN *sp; + int ch; + int rc = 0; +#ifdef NCURSES_WGETCH_EVENTS + int event_delay = -1; +#endif + + T((T_CALLED("_nc_wgetch(%p)"), (void *) win)); + + *result = 0; + + sp = _nc_screen_of(win); + if (win == NULL || sp == NULL) { + returnCode(ERR); + } + + if (cooked_key_in_fifo()) { + 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->_notty && + !IsRaw(sp) && + !IsCbreak(sp) && + !sp->_called_wgetch) { + char buf[MAXCOLUMNS], *bufp; + + TR(TRACE_IEVENT, ("filling queue in cooked mode")); + + /* ungetch in reverse order */ +#ifdef NCURSES_WGETCH_EVENTS + rc = recur_wgetnstr(win, buf); + if (rc != KEY_EVENT && rc != ERR) + safe_ungetch(sp, '\n'); +#else + if (recur_wgetnstr(win, buf) != ERR) + safe_ungetch(sp, '\n'); +#endif + for (bufp = buf + strlen(buf); bufp > buf; bufp--) + safe_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 (win->_use_keypad != sp->_keypad_on) + _nc_keypad(sp, win->_use_keypad); + + recur_wrefresh(win); + + if ((win->_delay >= 0) || (IsCbreak(sp) > 1)) { + if (head == -1) { /* fifo is empty */ + int delay; + + TR(TRACE_IEVENT, ("timed delay in wgetch()")); + if (IsCbreak(sp) > 1) + delay = (IsCbreak(sp) - 1) * 100; + else + delay = win->_delay; + +#ifdef NCURSES_WGETCH_EVENTS + if (event_delay >= 0 && delay > event_delay) + delay = event_delay; +#endif + + TR(TRACE_IEVENT, ("delay is %d milliseconds", delay)); + + rc = check_mouse_activity(sp, delay EVENTLIST_2nd(evl)); + +#ifdef NCURSES_WGETCH_EVENTS + if (rc & TW_EVENT) { + *result = KEY_EVENT; + returnCode(KEY_CODE_YES); + } +#endif + if (!rc) { + goto check_sigwinch; + } + } + /* else go on to read data available */ + } + + if (win->_use_keypad) { + /* + * This is tricky. We only want to get special-key + * events one at a time. But we want to accumulate + * mouse events until either (a) the mouse logic tells + * us it has picked up a complete gesture, or (b) + * there's a detectable time lapse after one. + * + * Note: if the mouse code starts failing to compose + * press/release events into clicks, you should probably + * increase the wait with mouseinterval(). + */ + int runcount = 0; + + do { + ch = kgetch(sp, win->_notimeout EVENTLIST_2nd(evl)); + if (ch == KEY_MOUSE) { + ++runcount; + if (sp->_mouse_inline(sp)) + break; + } + if (sp->_maxclick < 0) + break; + } while + (ch == KEY_MOUSE + && (((rc = check_mouse_activity(sp, sp->_maxclick + EVENTLIST_2nd(evl))) != 0 + && !(rc & TW_EVENT)) + || !sp->_mouse_parse(sp, runcount))); +#ifdef NCURSES_WGETCH_EVENTS + if ((rc & TW_EVENT) && !(ch == KEY_EVENT)) { + safe_ungetch(sp, ch); + ch = KEY_EVENT; + } +#endif + if (runcount > 0 && ch != KEY_MOUSE) { +#ifdef NCURSES_WGETCH_EVENTS + /* mouse event sequence ended by an event, report event */ + if (ch == KEY_EVENT) { + safe_ungetch(sp, KEY_MOUSE); /* FIXME This interrupts a gesture... */ + } else +#endif + { + /* mouse event sequence ended by keystroke, store keystroke */ + safe_ungetch(sp, ch); + ch = KEY_MOUSE; + } + } + } else { + if (head == -1) + fifo_push(sp EVENTLIST_2nd(evl)); + ch = fifo_pull(sp); + } + + if (ch == ERR) { + check_sigwinch: +#if USE_SIZECHANGE + if (_nc_handle_sigwinch(sp)) { + _nc_update_screensize(sp); + /* resizeterm can push KEY_RESIZE */ + if (cooked_key_in_fifo()) { + *result = fifo_pull(sp); + /* + * Get the ERR from queue -- it is from WINCH, + * so we should take it out, the "error" is handled. + */ + if (fifo_peek(sp) == -1) + fifo_pull(sp); + returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK); + } + } +#endif + returnCode(ERR); + } + + /* + * If echo() is in effect, display the printable version of the + * key on the screen. Carriage return and backspace are treated + * specially by Solaris curses: + * + * If carriage return is defined as a function key in the + * terminfo, e.g., kent, then Solaris may return either ^J (or ^M + * if nonl() is set) or KEY_ENTER depending on the echo() mode. + * We echo before translating carriage return based on nonl(), + * since the visual result simply moves the cursor to column 0. + * + * Backspace is a different matter. Solaris curses does not + * translate it to KEY_BACKSPACE if kbs=^H. This does not depend + * on the stty modes, but appears to be a hardcoded special case. + * This is a difference from ncurses, which uses the terminfo entry. + * However, we provide the same visual result as Solaris, moving the + * cursor to the left. + */ + if (IsEcho(sp) && !IS_PAD(win)) { + chtype backup = (chtype) ((ch == KEY_BACKSPACE) ? '\b' : ch); + if (backup < KEY_MIN) + wechochar(win, backup); + } + + /* + * Simulate ICRNL mode + */ + if ((ch == '\r') && IsNl(sp)) + ch = '\n'; + + /* Strip 8th-bit if so desired. We do this only for characters that + * are in the range 128-255, to provide compatibility with terminals + * that display only 7-bit characters. Note that 'ch' may be a + * function key at this point, so we mustn't strip _those_. + */ + if (!use_meta) + if ((ch < KEY_MIN) && (ch & 0x80)) + ch &= 0x7f; + + 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; + int value; + + T((T_CALLED("wgetch_events(%p,%p)"), (void *) win, (void *) 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; + int value; + + T((T_CALLED("wgetch(%p)"), (void *) win)); + code = _nc_wgetch(win, + &value, + _nc_use_meta(win) + EVENTLIST_2nd((_nc_eventlist *) 0)); + if (code != ERR) + code = value; + returnCode(code); +} + +/* +** int +** kgetch() +** +** Get an input character, but take care of keypad sequences, returning +** an appropriate code when one matches the input. After each character +** is received, set an alarm call based on ESCDELAY. If no more of the +** sequence is received by the time the alarm goes off, pass through +** the sequence gotten so far. +** +** This function must be called when there are no cooked keys in queue. +** (that is head==-1 || peek==head) +** +*/ + +static int +kgetch(SCREEN *sp, bool forever EVENTLIST_2nd(_nc_eventlist * evl)) +{ + TRIES *ptr; + int ch = 0; + int timeleft = forever ? 9999999 : GetEscdelay(sp); + + TR(TRACE_IEVENT, ("kgetch() called")); + + ptr = sp->_keytry; + + for (;;) { + 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(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", _nc_tracechar(sp, (unsigned char) ch))); + while ((ptr != NULL) && (ptr->ch != (unsigned char) ch)) + ptr = ptr->sibling; + + if (ptr == NULL) { + TR(TRACE_IEVENT, ("ptr is null")); + break; + } + TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d", + (void *) ptr, ptr->ch, ptr->value)); + + if (ptr->value != 0) { /* sequence terminated */ + TR(TRACE_IEVENT, ("end of sequence")); + if (peek == tail) { + fifo_clear(sp); + } else { + head = peek; + } + return (ptr->value); + } + + ptr = ptr->child; + + if (!raw_key_in_fifo()) { + int rc; + + TR(TRACE_IEVENT, ("waiting for rest of sequence")); + rc = check_mouse_activity(sp, timeleft EVENTLIST_2nd(evl)); +#ifdef NCURSES_WGETCH_EVENTS + if (rc & TW_EVENT) { + 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(sp); + peek = head; + return ch; +} diff --git a/ncurses/ncurses/base/lib_getstr.c b/ncurses/ncurses/base/lib_getstr.c new file mode 100644 index 0000000000..185cec166b --- /dev/null +++ b/ncurses/ncurses/base/lib_getstr.c @@ -0,0 +1,224 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2011,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_getstr.c +** +** The routine wgetstr(). +** +*/ + +#define NEED_KEY_EVENT +#include + +MODULE_ID("$Id: lib_getstr.c,v 1.42 2025/01/19 00:51:54 tom Exp $") + +/* + * This wipes out the last character, no matter whether it was a tab, control + * or other character, and handles reverse wraparound. + */ +static char * +WipeOut(WINDOW *win, int y, int x, const char *first, char *last, int echoed) +{ + if (last > first) { + *--last = '\0'; + if (echoed) { + int y1 = win->_cury; + int x1 = win->_curx; + + wmove(win, y, x); + waddstr(win, first); + getyx(win, y, x); + while (win->_cury < y1 + || (win->_cury == y1 && win->_curx < x1)) + waddch(win, (chtype) ' '); + + wmove(win, y, x); + } + } + return last; +} + +NCURSES_EXPORT(int) +wgetnstr_events(WINDOW *win, + char *str, + int maxlen, + EVENTLIST_1st(_nc_eventlist * evl)) +{ + SCREEN *sp = _nc_screen_of(win); + TTY buf; + TTY_FLAGS save_flags; + char erasec; + char killc; + const char *oldstr; + int ch; + int y, x; + + T((T_CALLED("wgetnstr_events(%p,%p,%d)"), (void *) win, (void *) str, maxlen)); + + if (!win || !str) + returnCode(ERR); + + maxlen = _nc_getstr_limit(maxlen); + + NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx &buf); + + save_flags = sp->_tty_flags; + NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); + if (!save_flags._raw) + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); + + erasec = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG); + killc = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG); + + oldstr = str; + getyx(win, y, x); + + if (is_wintouched(win) || (win->_flags & _HASMOVED)) + wrefresh(win); + + 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 is the + * user's choice whether to set kcud=\n for wgetch(); + * terminating *getstr() with \n should work either way. + */ + if (ch == '\n' + || ch == '\r' + || ch == KEY_DOWN + || ch == KEY_ENTER) { + if (save_flags._echo == TRUE + && win->_cury == win->_maxy + && win->_scroll) + 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, save_flags._echo); + } + } else if (ch == killc) { + while (str > oldstr) { + str = WipeOut(win, y, x, oldstr, str, save_flags._echo); + } + } else if (ch >= KEY_MIN + || (str - oldstr >= maxlen)) { + NCURSES_SP_NAME(beep) (NCURSES_SP_ARG); + } else { + *str++ = (char) ch; + if (save_flags._echo == TRUE) { + int oldy = win->_cury; + if (waddch(win, (chtype) ch) == ERR) { + /* + * We can't really use the lower-right + * corner for input, since it'll mess + * up bookkeeping for erases. + */ + win->_flags &= ~_WRAPPED; + waddch(win, (chtype) ' '); + str = WipeOut(win, y, x, oldstr, str, save_flags._echo); + continue; + } else if (IS_WRAPPED(win)) { + /* + * If the last waddch forced a wrap & + * scroll, adjust our reference point + * for erasures. + */ + if (win->_scroll + && oldy == win->_maxy + && win->_cury == win->_maxy) { + if (--y <= 0) { + y = 0; + } + } + win->_flags &= ~_WRAPPED; + } + wrefresh(win); + } + } + } + + win->_curx = 0; + win->_flags &= ~_WRAPPED; + if (win->_cury < win->_maxy) + win->_cury++; + wrefresh(win); + + /* Restore with a single I/O call, to fix minor asymmetry between + * raw/noraw, etc. + */ + sp->_tty_flags = save_flags; + NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + + *str = '\0'; + if (ch == ERR) + returnCode(ch); + + T(("wgetnstr_events 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/ncurses/ncurses/base/lib_hline.c b/ncurses/ncurses/base/lib_hline.c new file mode 100644 index 0000000000..a73e1c1878 --- /dev/null +++ b/ncurses/ncurses/base/lib_hline.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Sven Verdoolaege 2001 * + ****************************************************************************/ + +/* +** lib_hline.c +** +** The routine whline(). +** +*/ + +#include + +MODULE_ID("$Id: lib_hline.c,v 1.16 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +whline(WINDOW *win, chtype ch, int n) +{ + int code = ERR; + + T((T_CALLED("whline(%p,%s,%d)"), (void *) win, _tracechtype(ch), n)); + + if (win) { + struct ldat *line = &(win->_line[win->_cury]); + NCURSES_CH_T wch; + int start = win->_curx; + int end = start + n - 1; + + if (end > win->_maxx) + end = win->_maxx; + + CHANGED_RANGE(line, start, end); + + if (ch == 0) + SetChar2(wch, ACS_HLINE); + else + SetChar2(wch, ch); + wch = _nc_render(win, wch); + +#if USE_WIDEC_SUPPORT + if (start > 0 && isWidecExt(line->text[start])) { + SetChar2(line->text[start - 1], ' '); + } + if (end < win->_maxx && isWidecExt(line->text[end + 1])) { + SetChar2(line->text[end + 1], ' '); + } +#endif + while (end >= start) { + line->text[end] = wch; + end--; + } + + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_immedok.c b/ncurses/ncurses/base/lib_immedok.c new file mode 100644 index 0000000000..fb1a7169ca --- /dev/null +++ b/ncurses/ncurses/base/lib_immedok.c @@ -0,0 +1,58 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_immedok.c +** +** The routine immedok. +** +*/ + +#include + +MODULE_ID("$Id: lib_immedok.c,v 1.6 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(void) +immedok(WINDOW *win, bool flag) +{ + T((T_CALLED("immedok(%p,%d)"), (void *) win, flag)); + + if (win) + win->_immed = flag; + + returnVoid; +} diff --git a/ncurses/ncurses/base/lib_inchstr.c b/ncurses/ncurses/base/lib_inchstr.c new file mode 100644 index 0000000000..3796cb8549 --- /dev/null +++ b/ncurses/ncurses/base/lib_inchstr.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2010,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_inchstr.c +** +** The routine winchnstr(). +** +*/ + +#include + +MODULE_ID("$Id: lib_inchstr.c,v 1.17 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +winchnstr(WINDOW *win, chtype *str, int n) +{ + int i = 0; + + T((T_CALLED("winchnstr(%p,%p,%d)"), (void *) win, (void *) str, n)); + + if (!win || !str) { + i = ERR; + } else { + int row = win->_cury; + int col = win->_curx; + NCURSES_CH_T *text = win->_line[row].text; + + for (; (n < 0 || (i < n)) && (col + i <= win->_maxx); i++) { + str[i] = (((chtype) CharOf(text[col + i]) & A_CHARTEXT) | + AttrOf(text[col + i])); + } + str[i] = (chtype) 0; + } + + returnCode(i); +} diff --git a/ncurses/ncurses/base/lib_initscr.c b/ncurses/ncurses/base/lib_initscr.c new file mode 100644 index 0000000000..c772fd197c --- /dev/null +++ b/ncurses/ncurses/base/lib_initscr.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_initscr.c +** +** The routines initscr(), and termname(). +** +*/ + +#include + +#if HAVE_SYS_TERMIO_H +#include /* needed for ISC */ +#endif + +MODULE_ID("$Id: lib_initscr.c,v 1.52 2025/03/09 00:49:14 tom Exp $") + +NCURSES_EXPORT(WINDOW *) +initscr(void) +{ + WINDOW *result; + + START_TRACE(); + T((T_CALLED("initscr()"))); + + _nc_init_pthreads(); + _nc_lock_global(curses); + + /* Portable applications must not call initscr() more than once */ + if (!_nc_globals.init_screen) { + const char *env; + char *name; + + _nc_globals.init_screen = TRUE; + + env = getenv("TERM"); + (void) VALID_TERM_ENV(env, "unknown"); + + if ((name = strdup(env)) == NULL) { + fprintf(stderr, "ncurses: cannot allocate %d bytes of" + "memory for $TERM; exiting\n", (int) strlen(env)); + ExitProgram(EXIT_FAILURE); + } +#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 (NC_ISATTY(fileno(stdout))) { + FILE *fp = fopen("/dev/tty", "w"); + if (fp != 0 && NC_ISATTY(fileno(fp))) { + fclose(stdout); + dup2(fileno(fp), STDOUT_FILENO); + stdout = fdopen(STDOUT_FILENO, "w"); + } + } +#endif + if (newterm(name, stdout, stdin) == NULL) { + fprintf(stderr, "ncurses: cannot initialize terminal type" + " ($TERM=\"%s\"); exiting\n", name); + ExitProgram(EXIT_FAILURE); + } + + /* def_shell_mode - done in newterm/_nc_setupscreen */ +#if NCURSES_SP_FUNCS + NCURSES_SP_NAME(def_prog_mode) (CURRENT_SCREEN); +#else + def_prog_mode(); +#endif + free(name); + } + result = stdscr; + _nc_unlock_global(curses); + + returnWin(result); +} diff --git a/ncurses/ncurses/base/lib_insch.c b/ncurses/ncurses/base/lib_insch.c new file mode 100644 index 0000000000..b3a38e5ed3 --- /dev/null +++ b/ncurses/ncurses/base/lib_insch.c @@ -0,0 +1,168 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2013,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Sven Verdoolaege * + * and: Thomas E. Dickey * + ****************************************************************************/ + +/* +** lib_insch.c +** +** The routine winsch(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_insch.c,v 1.39 2024/12/07 17:40:33 tom Exp $") + +/* + * Insert the given character, updating the current location to simplify + * inserting a string. + */ +NCURSES_EXPORT(int) +_nc_insert_ch(SCREEN *sp, WINDOW *win, chtype ch) +{ + int code = OK; + int ch8 = (int) ChCharOf(ch); + NCURSES_CH_T wch; + int count; + int tabsize = ( +#if USE_REENTRANT + sp->_TABSIZE +#else + TABSIZE +#endif + ); + + switch (ch) { + case '\t': + for (count = (tabsize - (win->_curx % tabsize)); count > 0; count--) { + if ((code = _nc_insert_ch(sp, 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 + (isprint(ch8) || + (ChAttrOf(ch) & A_ALTCHARSET) || + (sp != NULL && sp->_legacy_coding && !iscntrl(ch8)))) { + 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]); + const 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 (iscntrl(ch8)) { + NCURSES_CONST char *s; + s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx (chtype) ch8); + while (*s != '\0') { + code = _nc_insert_ch(sp, 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 = _nc_insert_wch(win, &wch); + } else if (count == -1) { + NCURSES_CONST char *s; + /* handle EILSEQ */ + s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx (chtype) ch8); + if (strlen(s) > 1) { + while (*s != '\0') { + code = _nc_insert_ch(sp, 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) +{ + int code = ERR; + + T((T_CALLED("winsch(%p, %s)"), (void *) win, _tracechtype(c))); + + if (win != NULL) { + NCURSES_SIZE_T oy = win->_cury; + NCURSES_SIZE_T ox = win->_curx; + + code = _nc_insert_ch(_nc_screen_of(win), win, c); + + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_insdel.c b/ncurses/ncurses/base/lib_insdel.c new file mode 100644 index 0000000000..4c29526551 --- /dev/null +++ b/ncurses/ncurses/base/lib_insdel.c @@ -0,0 +1,67 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2003,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_insdel.c +** +** The routine winsdelln(win, n). +** positive n insert n lines above current line +** negative n delete n lines starting from current line +** +*/ + +#include + +MODULE_ID("$Id: lib_insdel.c,v 1.14 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +winsdelln(WINDOW *win, int n) +{ + int code = ERR; + + T((T_CALLED("winsdelln(%p,%d)"), (void *) win, n)); + + if (win) { + if (n != 0) { + _nc_scroll_window(win, -n, win->_cury, win->_maxy, + win->_nc_bkgd); + _nc_synchook(win); + } + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_insnstr.c b/ncurses/ncurses/base/lib_insnstr.c new file mode 100644 index 0000000000..564588d721 --- /dev/null +++ b/ncurses/ncurses/base/lib_insnstr.c @@ -0,0 +1,99 @@ +/**************************************************************************** + * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 2004-2009,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* +** lib_insnstr.c +** +** The routine winsnstr(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_insnstr.c,v 1.11 2024/12/07 20:00:48 tom Exp $") + +NCURSES_EXPORT(int) +winsnstr(WINDOW *win, const char *s, int n) +{ + int code = ERR; + const unsigned char *str = (const unsigned char *) s; + + T((T_CALLED("winsnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(s, n), n)); + + if (win != NULL && str != NULL && n != 0) { + SCREEN *sp = _nc_screen_of(win); +#if USE_WIDEC_SUPPORT + /* + * If the output contains "wide" (multibyte) characters, we will not + * really know the width of a character until we get the last byte + * of the character. Since the preceding byte(s) may use more columns + * on the screen than the final character, it is best to route the + * call to the wins_nwstr() function. + */ + if (sp->_screen_unicode) { + size_t nn = (n > 0) ? (size_t) n : strlen(s); + wchar_t *buffer = typeMalloc(wchar_t, nn + 1); + if (buffer != NULL) { + mbstate_t state; + size_t n3; + init_mb(state); + n3 = mbstowcs(buffer, s, nn); + if (n3 != (size_t) (-1)) { + buffer[n3] = '\0'; + code = wins_nwstr(win, buffer, (int) n3); + } + free(buffer); + } + } + if (code == ERR) +#endif + { + NCURSES_SIZE_T oy = win->_cury; + NCURSES_SIZE_T ox = win->_curx; + const unsigned char *cp; + + for (cp = str; (n < 0 || (cp - str) < n) && *cp; cp++) { + _nc_insert_ch(sp, win, (chtype) UChar(*cp)); + } + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + code = OK; + } + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_instr.c b/ncurses/ncurses/base/lib_instr.c new file mode 100644 index 0000000000..eaef06d8b7 --- /dev/null +++ b/ncurses/ncurses/base/lib_instr.c @@ -0,0 +1,125 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_instr.c +** +** The routine winnstr(). +** +*/ + +#include + +MODULE_ID("$Id: lib_instr.c,v 1.28 2024/12/07 17:53:39 tom Exp $") + +NCURSES_EXPORT(int) +winnstr(WINDOW *win, char *str, int n) +{ + int i = 0; + + T((T_CALLED("winnstr(%p,%p,%d)"), (void *) win, str, n)); + + if (!win || !str) { + i = ERR; + } else { + int row = win->_cury; + int col = win->_curx; + NCURSES_CH_T *text = win->_line[row].text; + + if (n < 0) + n = win->_maxx - col + 1; + + for (; i < n;) { +#if USE_WIDEC_SUPPORT + const cchar_t *cell = &(text[col]); + attr_t attrs; + NCURSES_PAIRS_T pair; + char *tmp; + + if (!isWidecExt(*cell)) { + wchar_t *wch; + int n2; + + n2 = getcchar(cell, NULL, NULL, NULL, NULL); + if (n2 > 0 + && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != NULL) { + bool done = FALSE; + + if (getcchar(cell, wch, &attrs, &pair, NULL) == OK) { + mbstate_t state; + size_t n3; + + init_mb(state); + n3 = wcstombs(NULL, wch, (size_t) 0); + if (!isEILSEQ(n3) && (n3 != 0) && (n3 <= MB_LEN_MAX)) { + size_t need = n3 + 10 + (size_t) i; + int have = (int) n3 + i; + + /* check for loop-done as well as overflow */ + if (have > n || (int) need <= 0) { + done = TRUE; + } else if ((tmp = typeCalloc(char, need)) == NULL) { + done = TRUE; + } else { + size_t i3; + + 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(text[col]); +#endif + if (++col > win->_maxx) { + break; + } + } + str[i] = '\0'; /* SVr4 does not seem to count the null */ + } + T(("winnstr returns %s", _nc_visbuf(str))); + returnCode(i); +} diff --git a/ncurses/ncurses/base/lib_isendwin.c b/ncurses/ncurses/base/lib_isendwin.c new file mode 100644 index 0000000000..fe10082659 --- /dev/null +++ b/ncurses/ncurses/base/lib_isendwin.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2009,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_endwin.c +** +** The routine endwin(). +** +*/ + +#include + +MODULE_ID("$Id: lib_isendwin.c,v 1.9 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(isendwin) (NCURSES_SP_DCL0) +{ + if (SP_PARM == NULL) + return FALSE; + return (SP_PARM->_endwin == ewSuspend); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +isendwin(void) +{ + return NCURSES_SP_NAME(isendwin) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_leaveok.c b/ncurses/ncurses/base/lib_leaveok.c new file mode 100644 index 0000000000..f299c16d7e --- /dev/null +++ b/ncurses/ncurses/base/lib_leaveok.c @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_leaveok.c +** +** The routine leaveok. +** +*/ + +#include + +MODULE_ID("$Id: lib_leaveok.c,v 1.7 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +leaveok(WINDOW *win, bool flag) +{ + T((T_CALLED("leaveok(%p,%d)"), (void *) win, flag)); + + if (win) { + win->_leaveok = flag; + returnCode(OK); + } else + returnCode(ERR); +} diff --git a/ncurses/ncurses/base/lib_mouse.c b/ncurses/ncurses/base/lib_mouse.c new file mode 100644 index 0000000000..5a965c9119 --- /dev/null +++ b/ncurses/ncurses/base/lib_mouse.c @@ -0,0 +1,2112 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2008 * + ****************************************************************************/ + +/* + * This module is intended to encapsulate ncurses's interface to pointing + * devices. + * + * 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 implementers of new mouse-interface methods: + * + * The code is logically split into a lower level that accepts event reports + * in a device-dependent format and an upper level that parses mouse gestures + * and filters events. The mediating data structure is a circular queue of + * MEVENT structures. + * + * Functionally, the lower level's job is to pick up primitive events and + * put them on the circular queue. This can happen in one of two ways: + * either (a) _nc_mouse_event() detects a series of incoming mouse reports + * and queues them, or (b) code in lib_getch.c detects the kmous prefix in + * the keyboard input stream and calls _nc_mouse_inline to queue up a series + * of adjacent mouse reports. + * + * In either case, _nc_mouse_parse() should be called after the series is + * accepted to parse the digested mouse reports (low-level MEVENTs) into + * a gesture (a high-level or composite MEVENT). + * + * Don't be too shy about adding new event types or modifiers, if you can find + * room for them in the 32-bit mask. The API is written so that users get + * feedback on which theoretical event types they won't see when they call + * mousemask. There's one bit per button (the RESERVED_EVENT bit) not being + * used yet, and a couple of bits open at the high end. + */ + +#ifdef __EMX__ +# define INCL_DOS +# define INCL_VIO +# define INCL_KBD +# define INCL_MOU +# define INCL_DOSPROCESS +# include /* Need to include before the others */ +#endif + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_mouse.c,v 1.219 2025/12/30 17:23:24 tom Exp $") + +#include + +#if USE_GPM_SUPPORT +#include /* defines KG_* macros */ + +#ifdef HAVE_LIBDL +/* use dynamic loader to avoid linkage dependency */ +#include + +#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 +#if defined(__DragonFly_version) || (defined(__FreeBSD__) && (__FreeBSD_version >= 400017)) +#include +#include +#else +#include +#endif +#endif /* use_SYSMOUSE */ + +#if USE_KLIBC_MOUSE +#include +#define pipe(handles) socketpair(AF_LOCAL, SOCK_STREAM, 0, handles) +#define DosWrite(hfile, pbuffer, cbwrite, pcbactual) \ + write(hfile, pbuffer, cbwrite) +#define DosExit(action, result ) /* do nothing */ +#define DosCreateThread(ptid, pfn, param, flag, cbStack) \ + (*(ptid) = _beginthread(pfn, NULL, cbStack, \ + (void *)param), (*(ptid) == -1)) +#endif + +#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT + +#define MASK_RELEASE(x) (mmask_t) NCURSES_MOUSE_MASK(x, 001) +#define MASK_PRESS(x) (mmask_t) NCURSES_MOUSE_MASK(x, 002) +#define MASK_CLICK(x) (mmask_t) NCURSES_MOUSE_MASK(x, 004) +#define MASK_DOUBLE_CLICK(x) (mmask_t) NCURSES_MOUSE_MASK(x, 010) +#define MASK_TRIPLE_CLICK(x) (mmask_t) NCURSES_MOUSE_MASK(x, 020) +#define MASK_RESERVED_EVENT(x) (mmask_t) 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) + +#if NCURSES_MOUSE_VERSION == 2 +#define MAX_BUTTONS 5 +#else +#define MAX_BUTTONS 11 +#endif + +#endif + +#define INVALID_EVENT -1 +#define NORMAL_EVENT 0 + +#define ValidEvent(ep) ((ep)->id != INVALID_EVENT) +#define Invalidate(ep) (ep)->id = INVALID_EVENT + +#if USE_GPM_SUPPORT + +#ifndef LIBGPM_SONAME +#define LIBGPM_SONAME "libgpm.so" +#endif + +#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(sp->_dlopen_gpm, #name)) + +#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 */ + +#define FirstEV(sp) ((sp)->_mouse_events) +#define LastEV(sp) ((sp)->_mouse_events + EV_MAX - 1) + +#undef NEXT +#define NEXT(ep) ((ep >= LastEV(SP_PARM)) \ + ? FirstEV(SP_PARM) \ + : ep + 1) + +#undef PREV +#define PREV(ep) ((ep <= FirstEV(SP_PARM)) \ + ? LastEV(SP_PARM) \ + : 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(SCREEN *sp, const char *tag) +{ + MEVENT *ep; + + _tracef("%s", tag); + + for (ep = FirstEV(sp); ep <= LastEV(sp); ep++) + _tracef("mouse event queue slot %ld = %s", + (long) IndexEV(sp, ep), + _nc_tracemouse(sp, ep)); +} +#endif + +#if USE_EMX_MOUSE + +# define TOP_ROW 0 +# define LEFT_COL 0 + +# define M_FD(sp) sp->_mouse_fd + +static void +write_event(SCREEN *sp, int down, int button, int x, int y) +{ + char buf[6]; + unsigned long ignore; + + _nc_STRCPY(buf, "\033[M", sizeof(buf)); /* should be the same as key_mouse */ + buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40); + buf[4] = ' ' + x - LEFT_COL + 1; + buf[5] = ' ' + y - TOP_ROW + 1; + DosWrite(sp->_emxmouse_wfd, buf, 6, &ignore); +} + +static void +#if USE_KLIBC_MOUSE +mouse_server(void *param) +#else +mouse_server(unsigned long param) +#endif +{ + SCREEN *sp = (SCREEN *) param; + unsigned short fWait = MOU_WAIT; + /* NOPTRRECT mourt = { 0,0,24,79 }; */ + MOUEVENTINFO mouev; + HMOU hmou; + unsigned short mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN; + int nbuttons = 3; + int oldstate = 0; + char err[80]; + unsigned long rc; + + /* open the handle for the mouse */ + if (MouOpen(NULL, &hmou) == 0) { + rc = MouSetEventMask(&mask, hmou); + if (rc) { /* retry with 2 buttons */ + mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN; + rc = MouSetEventMask(&mask, hmou); + nbuttons = 2; + } + if (rc == 0 && MouDrawPtr(hmou) == 0) { + for (;;) { + /* sit and wait on the event queue */ + rc = MouReadEventQue(&mouev, &fWait, hmou); + if (rc) { + _nc_SPRINTF(err, _nc_SLIMIT(sizeof(err)) + "Error reading mouse queue, rc=%lu.\r\n", rc); + break; + } + if (!sp->_emxmouse_activated) + goto finish; + + /* + * OS/2 numbers a 3-button mouse inconsistently from other + * platforms: + * 1 = left + * 2 = right + * 3 = middle. + */ + if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN) + 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(sp, mouev.fs & MOUSE_BN2_DOWN, + sp->_emxmouse_buttons[3], mouev.col, mouev.row); + if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN) + write_event(sp, mouev.fs & MOUSE_BN3_DOWN, + sp->_emxmouse_buttons[2], mouev.col, mouev.row); + + finish: + oldstate = mouev.fs; + } + } else { + _nc_SPRINTF(err, _nc_SLIMIT(sizeof(err)) + "Error setting event mask, buttons=%d, rc=%lu.\r\n", + nbuttons, rc); + } + + DosWrite(2, err, strlen(err), &rc); + MouClose(hmou); + } + DosExit(EXIT_THREAD, 0L); +} + +#endif /* USE_EMX_MOUSE */ + +#if USE_SYSMOUSE +static void +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(CURRENT_SCREEN); +} +#endif /* USE_SYSMOUSE */ + +#if !defined(_NC_WINDOWS_NATIVE) || USE_NAMED_PIPES +#define xterm_kmous "\033[M" + +static void +init_xterm_mouse(SCREEN *sp) +{ + sp->_mouse_type = M_XTERM; + sp->_mouse_format = MF_X10; + sp->_mouse_xtermcap = tigetstr(UserCap(XM)); + if (VALID_STRING(sp->_mouse_xtermcap)) { + char *code = strstr(sp->_mouse_xtermcap, "[?"); + if (code != NULL) { + code += 2; + while ((*code >= '0') && (*code <= '9')) { + char *next = code; + while ((*next >= '0') && (*next <= '9')) { + ++next; + } + if (!strncmp(code, "1006", (size_t) (next - code))) { + sp->_mouse_format = MF_SGR1006; + } +#ifdef EXP_XTERM_1005 + if (!strncmp(code, "1005", (size_t) (next - code))) { + sp->_mouse_format = MF_XTERM_1005; + } +#endif + if (*next == ';') { + while (*next == ';') { + ++next; + } + code = next; + } else { + break; + } + } + } + } else { + int code = tigetnum(UserCap(XM)); + switch (code) { +#ifdef EXP_XTERM_1005 + case 1005: + /* see "xterm+sm+1005" */ + sp->_mouse_xtermcap = "\033[?1005;1000%?%p1%{1}%=%th%el%;"; + sp->_mouse_format = MF_XTERM_1005; + break; +#endif + case 1006: + /* see "xterm+sm+1006" */ + sp->_mouse_xtermcap = "\033[?1006;1000%?%p1%{1}%=%th%el%;"; + sp->_mouse_format = MF_SGR1006; + break; + default: + sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;"; + break; + } + } +} +#endif + +static void +enable_xterm_mouse(SCREEN *sp, bool enable) +{ + TPUTS_TRACE(enable + ? "xterm mouse initialization" + : "xterm mouse deinitialization"); +#if USE_EMX_MOUSE + sp->_emxmouse_activated = enable; +#else + NCURSES_PUTP2("xterm-mouse", TIPARM_1(sp->_mouse_xtermcap, enable)); +#endif + sp->_mouse_active = enable; +} + +#if USE_TERM_DRIVER +static void +enable_win32_mouse(SCREEN *sp, bool enable) +{ +#if USE_NAMED_PIPES + enable_xterm_mouse(sp, enable); +#else + sp->_mouse_active = enable; +#endif +} +#endif + +#if USE_GPM_SUPPORT +static bool +allow_gpm_mouse(SCREEN *sp GCC_UNUSED) +{ + bool result = FALSE; + +#if USE_WEAK_SYMBOLS + /* Danger Robinson: do not use dlopen for libgpm if already loaded */ + if ((Gpm_Wgetch) != 0) { + if (!sp->_mouse_gpm_loaded) { + T(("GPM library was already dlopen'd, not by us")); + } + } else +#endif + /* GPM does printf's without checking if stdout is a terminal */ + if (NC_ISATTY(fileno(stdout))) { + const char *list = getenv("NCURSES_GPM_TERMS"); + const char *env = getenv("TERM"); + if (list != NULL) { + if (env != NULL) { + result = _nc_name_match(list, env, "|:") ? TRUE : FALSE; + } + } 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 != NULL && strstr(env, "linux") != NULL) { + result = TRUE; + } + } + } + return result; +} + +#ifdef HAVE_LIBDL +static void +unload_gpm_library(SCREEN *sp) +{ + if (sp->_dlopen_gpm != NULL) { + T(("unload GPM library")); + sp->_mouse_gpm_loaded = FALSE; + sp->_mouse_fd = -1; + } +} + +static void +load_gpm_library(SCREEN *sp) +{ + sp->_mouse_gpm_found = FALSE; + + /* + * If we already had a successful dlopen, reuse it. + */ + if (sp->_dlopen_gpm != NULL) { + sp->_mouse_gpm_found = TRUE; + sp->_mouse_gpm_loaded = TRUE; + } else if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != NULL) { +#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + if (GET_DLSYM(gpm_fd) == NULL || + GET_DLSYM(Gpm_Open) == NULL || + GET_DLSYM(Gpm_Close) == NULL || + GET_DLSYM(Gpm_GetEvent) == NULL) { +#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + T(("GPM initialization failed: %s", dlerror())); + unload_gpm_library(sp); + dlclose(sp->_dlopen_gpm); + sp->_dlopen_gpm = NULL; + } else { + sp->_mouse_gpm_found = TRUE; + sp->_mouse_gpm_loaded = TRUE; + } + } +} +#endif /* HAVE_LIBDL */ + +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) { + int code; + + /* 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. + */ + code = my_Gpm_Open(&sp->_mouse_gpm_connect, 0); + result = (code >= 0); + + /* + * GPM can return a -2 if it is trying to do something with xterm. + * Ignore that, since it conflicts with our use of stdin. + */ + if (code == -2) { + my_Gpm_Close(); + } + } 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 */ + +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 + if (allow_gpm_mouse(sp)) { + 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 */ +#if USE_EMX_MOUSE + if (!sp->_emxmouse_thread + && strstr(SP_TERMTYPE term_names, "xterm") == 0 + && NonEmpty(key_mouse)) { + int handles[2]; + + if (pipe(handles) < 0) { + perror("mouse pipe error"); + returnVoid; + } else { + int rc; + + if (!sp->_emxmouse_buttons[0]) { + const char *s = getenv("MOUSE_BUTTONS_123"); + + sp->_emxmouse_buttons[0] = 1; + if (s && strlen(s) >= 3) { + 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; + } + } + 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 *) &sp->_emxmouse_thread, + mouse_server, (long) sp, 0, 8192); + if (rc) { + printf("mouse thread error %d=%#x", rc, rc); + } else { + sp->_mouse_type = M_XTERM; + } + returnVoid; + } + } +#endif /* USE_EMX_MOUSE */ + +#if USE_SYSMOUSE + { + static char dev_tty[] = "/dev/tty"; + struct mouse_info the_mouse; + char *the_device = 0; + + if (NC_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 */ + +#if USE_TERM_DRIVER + CallDriver(sp, td_initmouse); +#endif +#if !defined(_NC_WINDOWS_NATIVE) || USE_NAMED_PIPES + /* we know how to recognize mouse events under "xterm" */ + if (NonEmpty(key_mouse)) { + init_xterm_mouse(sp); + } else if (SP_TERMTYPE term_names != NULL + && strstr(SP_TERMTYPE term_names, "xterm") != NULL) { + if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK) + init_xterm_mouse(sp); + } +#endif + + returnVoid; +} + +static bool +_nc_mouse_init(SCREEN *sp) +/* initialize the mouse */ +{ + bool result = FALSE; + + T((T_CALLED("_nc_mouse_init(%p)"), (void *) sp)); + + if (sp != NULL) { + if (!sp->_mouse_initialized) { + int i; + + sp->_mouse_initialized = TRUE; + + TR(MY_TRACE, ("set _mouse_initialized")); + + sp->_mouse_readp = sp->_mouse_writep = FirstEV(sp); + for (i = 0; i < EV_MAX; i++) + Invalidate(sp->_mouse_events + i); + + initialize_mousetype(sp); + + T(("set _mouse_type to %d", sp->_mouse_type)); + } + result = sp->_mouse_initialized; + } + returnBool(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) +{ + MEVENT *eventp = sp->_mouse_writep; + bool result = FALSE; + + (void) eventp; + + 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: + if (sp->_mouse_fd >= 0) { + /* query server for event, return TRUE if we find one */ + Gpm_Event ev; + + switch (my_Gpm_GetEvent(&ev)) { + case 0: + /* Connection closed, drop the mouse. */ + sp->_mouse_fd = -1; + break; + case 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: + eventp->bstate |= REPORT_MOUSE_POSITION; + break; + } + + eventp->x = ev.x - 1; + eventp->y = ev.y - 1; + eventp->z = 0; + + /* bump the next-free pointer into the circular list */ + sp->_mouse_writep = NEXT(eventp); + result = TRUE; + break; + } + } + break; +#endif + +#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_writep = eventp = NEXT(eventp); + result = TRUE; + } + break; +#endif /* USE_SYSMOUSE */ + +#if USE_TERM_DRIVER + case M_TERM_DRIVER: + while (sp->_drv_mouse_head < sp->_drv_mouse_tail) { + *eventp = sp->_drv_mouse_fifo[sp->_drv_mouse_head]; + + /* + * Point the fifo-head to the next possible location. If there + * are none, reset the indices. + */ + sp->_drv_mouse_head += 1; + if (sp->_drv_mouse_head == sp->_drv_mouse_tail) { + sp->_drv_mouse_tail = 0; + sp->_drv_mouse_head = 0; + } + + /* bump the next-free pointer into the circular list */ + sp->_mouse_writep = eventp = NEXT(eventp); + result = TRUE; + } + break; +#endif + + case M_NONE: + break; + } + + return result; /* true if we found an event */ +} + +#if USE_EMX_MOUSE +#define PRESS_POSITION(n) \ + do { \ + eventp->bstate = MASK_PRESS(n); \ + sp->_mouse_bstate |= MASK_PRESS(n); \ + if (button & 0x40) { \ + eventp->bstate = MASK_RELEASE(n); \ + sp->_mouse_bstate &= ~MASK_PRESS(n); \ + } \ + } while (0) +#else +#define PRESS_POSITION(n) \ + do { \ + eventp->bstate = (mmask_t) ((sp->_mouse_bstate & MASK_PRESS(n)) \ + ? REPORT_MOUSE_POSITION \ + : MASK_PRESS(n)); \ + sp->_mouse_bstate |= MASK_PRESS(n); \ + } while (0) +#endif + +static bool +handle_wheel(SCREEN *sp, MEVENT * eventp, int button, int wheel) +{ + bool result = TRUE; + + switch (button & 3) { + case 0: + if (wheel) { + eventp->bstate = MASK_PRESS(4); + /* Do not record in sp->_mouse_bstate; there will be no + * corresponding release event. + */ + } else { + PRESS_POSITION(1); + } + break; + case 1: + if (wheel) { +#if NCURSES_MOUSE_VERSION >= 2 + eventp->bstate = MASK_PRESS(5); + /* See comment above for button 4 */ +#else + /* Ignore this event as it is not a true press of the button */ + eventp->bstate = REPORT_MOUSE_POSITION; +#endif + } else { + PRESS_POSITION(2); + } + break; + case 2: + if (wheel) { + /* Ignore this event as it is not a true press of the button */ + eventp->bstate = REPORT_MOUSE_POSITION; + } else { + PRESS_POSITION(3); + } + break; + default: + /* + * case 3 is sent when the mouse buttons are released. + * + * If the terminal uses xterm mode 1003, a continuous series of + * button-release events is sent as the mouse moves around the screen, + * or as the wheel mouse is rotated. + * + * Return false in this case, so that when running in X10 mode, we will + * recalculate bstate. + */ + eventp->bstate = REPORT_MOUSE_POSITION; + result = FALSE; + break; + } + return result; +} + +static bool +decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro) +{ + bool result; + int button = 0; + int wheel = (intro & 96) == 96; + + eventp->bstate = 0; + + if (intro >= 96) { + if (intro >= 160) { + button = (int) (intro - 152); /* buttons 8-11 */ + } else { + button = (int) (intro - 92); /* buttons 4-7 */ + } + } else { + button = (intro & 3); + } + + if (button > MAX_BUTTONS) { + eventp->bstate = REPORT_MOUSE_POSITION; + } else if (!handle_wheel(sp, eventp, (int) intro, wheel)) { + + /* + * 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. + */ + if (sp->_mouse_bstate & BUTTON_PRESSED) { + int b; + + eventp->bstate = BUTTON_RELEASED; + for (b = 1; b <= MAX_BUTTONS; ++b) { + if (!(sp->_mouse_bstate & MASK_PRESS(b))) + eventp->bstate &= ~MASK_RELEASE(b); + } + sp->_mouse_bstate = 0; + } else { + /* + * xterm will return a stream of release-events to let the + * application know where the mouse is going, if private mode + * 1002 or 1003 is enabled. + */ + eventp->bstate = REPORT_MOUSE_POSITION; + } + } + + if (intro & 4) { + eventp->bstate |= BUTTON_SHIFT; + } + if (intro & 8) { + eventp->bstate |= BUTTON_ALT; + } + if (intro & 16) { + eventp->bstate |= BUTTON_CTRL; + } + result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE; + return result; +} + +/* This code requires that your xterm entry contain the kmous capability and + * that it be set to the \E[M documented in the Xterm Control Sequences + * reference. This is how we arrange for mouse events to be reported via a + * KEY_MOUSE return value from wgetch(). After this value is received, + * _nc_mouse_inline() gets called and is immediately responsible for parsing + * the mouse status information following the prefix. + * + * The following quotes from the ctlseqs.ms document in the XTerm distribution, + * describing the mouse tracking feature: + * + * Parameters for all mouse tracking escape sequences generated by xterm encode + * numeric parameters in a single character as value+040. For example, ! is + * 1. + * + * On button press or release, xterm sends ESC [ M CbCxCy. The low two bits of + * Cb encode button information: 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, + * 3=release. The upper bits encode what modifiers were down when the button + * was pressed and are added together. 4=Shift, 8=Meta, 16=Control. Cx and Cy + * are the x and y coordinates of the mouse event. The upper left corner is + * (1,1). + * + * (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. + * + * Wheel mice may return buttons 4 and 5 when the wheel is turned. We encode + * those as button presses. + */ +static bool +decode_xterm_X10(SCREEN *sp, MEVENT * eventp) +{ +#define MAX_KBUF 3 + unsigned char kbuf[MAX_KBUF + 1]; + size_t grabbed; + int res; + bool result; + + _nc_set_read_thread(TRUE); + for (grabbed = 0; grabbed < MAX_KBUF; grabbed += (size_t) res) { + + /* For VIO mouse we add extra bit 64 to disambiguate button-up. */ + res = (int) read( +#if USE_EMX_MOUSE + (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd, +#else + sp->_ifd, +#endif + kbuf + grabbed, (size_t) (MAX_KBUF - (int) grabbed)); + if (res < 0) + break; + } + _nc_set_read_thread(FALSE); + kbuf[MAX_KBUF] = '\0'; + + TR(TRACE_IEVENT, + ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf)); + + /* there's only one mouse... */ + eventp->id = NORMAL_EVENT; + + result = decode_X10_bstate(sp, eventp, kbuf[0]); + + eventp->x = (kbuf[1] - ' ') - 1; + eventp->y = (kbuf[2] - ' ') - 1; + + return result; +} + +#ifdef EXP_XTERM_1005 +/* + * This is identical to X10/X11 responses except that there are two UTF-8 + * characters storing the ordinates instead of two bytes. + */ +static bool +decode_xterm_1005(SCREEN *sp, MEVENT * eventp) +{ + char kbuf[80]; + size_t grabbed; + size_t limit = (sizeof(kbuf) - 1); + unsigned coords[2]; + bool result; + + coords[0] = 0; + coords[1] = 0; + + _nc_set_read_thread(TRUE); + for (grabbed = 0; grabbed < limit;) { + int res; + + res = (int) read( +#if USE_EMX_MOUSE + (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd, +#else + sp->_ifd, +#endif + (kbuf + grabbed), (size_t) 1); + if (res < 0) + break; + grabbed += (size_t) res; + if (grabbed > 1) { + size_t check = 1; + int n; + + for (n = 0; n < 2; ++n) { + int rc; + + if (check >= grabbed) + break; + rc = _nc_conv_to_utf32(&coords[n], kbuf + check, (unsigned) + (grabbed - check)); + if (!rc) + break; + check += (size_t) rc; + } + if (n >= 2) + break; + } + } + _nc_set_read_thread(FALSE); + + TR(TRACE_IEVENT, + ("_nc_mouse_inline sees the following xterm data: %s", + _nc_visbufn(kbuf, (int) grabbed))); + + /* there's only one mouse... */ + eventp->id = NORMAL_EVENT; + + result = decode_X10_bstate(sp, eventp, UChar(kbuf[0])); + + eventp->x = (int) (coords[0] - ' ') - 1; + eventp->y = (int) (coords[1] - ' ') - 1; + + return result; +} +#endif /* EXP_XTERM_1005 */ + +/* + * ECMA-48 section 5.4 + */ +#define isInter(c) ((c) >= 0x20 && (c) <= 0x2f) +#define isParam(c) ((c) >= 0x30 && (c) <= 0x3f) +#define isFinal(c) ((c) >= 0x40 && (c) <= 0x7e) + +#define MAX_PARAMS 9 + +typedef struct { + int nerror; /* nonzero if there are unexpected chars */ + int nparam; /* number of numeric parameters */ + int params[MAX_PARAMS]; + int final; /* the final-character */ +} SGR_DATA; + +static bool +read_SGR(const SCREEN *sp, SGR_DATA * result) +{ + char kbuf[80]; /* bigger than any possible mouse response */ + int grabbed = 0; + int ch = 0; + int now = -1; + int marker = 1; + + memset(result, 0, sizeof(*result)); + _nc_set_read_thread(TRUE); + + do { + int res; + + res = (int) read( +#if USE_EMX_MOUSE + (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd, +#else + sp->_ifd, +#endif + (kbuf + grabbed), (size_t) 1); + if (res < 0) + break; + if ((grabbed + MAX_KBUF) >= (int) sizeof(kbuf)) { + result->nerror++; + break; + } + ch = UChar(kbuf[grabbed]); + kbuf[grabbed + 1] = 0; + switch (ch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (marker) { + ++now; + result->nparam = (now + 1); + } + marker = 0; + result->params[now] = (result->params[now] * 10) + (ch - '0'); + break; + case ';': + if (marker) { + ++now; + result->nparam = (now + 1); + } + marker = 1; + break; + default: + if (ch < 32 || ch > 126) { + /* + * Technically other characters could be interspersed in the + * response. Ignore those for now. + */ + result->nerror++; + continue; + } else if (isFinal(ch)) { + if (marker) { + result->nparam++; + } + result->final = ch; + } else { + result->nerror++; + } + break; + } + ++grabbed; + } while (!isFinal(ch)); + _nc_set_read_thread(FALSE); + + kbuf[++grabbed] = 0; + TR(TRACE_IEVENT, + ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf)); + return (grabbed > 0) && (result->nerror == 0); +} + +static bool +decode_xterm_SGR1006(SCREEN *sp, MEVENT * eventp) +{ + SGR_DATA data; + bool result = FALSE; + if (read_SGR(sp, &data)) { + int b = data.params[0]; + int b3 = 1 + (b & 3); + int wheel = ((b & 64) == 64); + + if (b >= 132) { + b3 = MAX_BUTTONS + 1; + } else if (b >= 128) { + b3 = (b - 120); /* buttons 8-11 */ + } else if (b >= 64) { + b3 = (b - 60); /* buttons 6-7 */ + } + + eventp->id = NORMAL_EVENT; + if (data.final == 'M') { + (void) handle_wheel(sp, eventp, b, wheel); + } else if (b3 > MAX_BUTTONS) { + eventp->bstate = REPORT_MOUSE_POSITION; + } else { + mmask_t pressed = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_PRESSED); + mmask_t release = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_RELEASED); + if (sp->_mouse_bstate & pressed) { + eventp->bstate = release; + sp->_mouse_bstate &= ~pressed; + } else { + eventp->bstate = REPORT_MOUSE_POSITION; + } + } + if (b & 4) { + eventp->bstate |= BUTTON_SHIFT; + } + if (b & 8) { + eventp->bstate |= BUTTON_ALT; + } + if (b & 16) { + eventp->bstate |= BUTTON_CTRL; + } + result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE; + eventp->x = (data.params[1] ? (data.params[1] - 1) : 0); + eventp->y = (data.params[2] ? (data.params[2] - 1) : 0); + } + return result; +} + +static bool +_nc_mouse_inline(SCREEN *sp) +/* mouse report received in the keyboard stream -- parse its info */ +{ + bool result = FALSE; + MEVENT *eventp = sp->_mouse_writep; + + TR(MY_TRACE, (T_CALLED("_nc_mouse_inline(%p)"), (void *) sp)); + + if (sp->_mouse_type == M_XTERM) { + switch (sp->_mouse_format) { + case MF_X10: + result = decode_xterm_X10(sp, eventp); + break; + case MF_SGR1006: + result = decode_xterm_SGR1006(sp, eventp); + break; +#ifdef EXP_XTERM_1005 + case MF_XTERM_1005: + result = decode_xterm_1005(sp, eventp); + break; +#endif + } + + TR(MY_TRACE, + ("_nc_mouse_inline: primitive mouse-event %s has slot %ld", + _nc_tracemouse(sp, eventp), + (long) IndexEV(sp, eventp))); + + /* bump the next-free pointer into the circular list */ + sp->_mouse_writep = NEXT(eventp); + + if (!result) { + /* If this event is from a wheel-mouse, treat it like position + * reports and avoid waiting for the release-events which will + * never come. + */ + if (eventp->bstate & BUTTON_PRESSED) { + int b; + + for (b = 4; b <= MAX_BUTTONS; ++b) { + if ((eventp->bstate & MASK_PRESS(b))) { + result = TRUE; + break; + } + } + } + } + } + + returnCode(result); +} + +static void +mouse_activate(SCREEN *sp, bool on) +{ + T((T_CALLED("mouse_activate(%p,%s)"), + (void *) SP_PARM, on ? "on" : "off")); + + if (!on && !sp->_mouse_initialized) + returnVoid; + + if (!_nc_mouse_init(sp)) + returnVoid; + + if (on) { + sp->_mouse_bstate = 0; + switch (sp->_mouse_type) { + case M_XTERM: +#if NCURSES_EXT_FUNCS + NCURSES_SP_NAME(keyok) (NCURSES_SP_ARGx KEY_MOUSE, on); +#endif + enable_xterm_mouse(sp, TRUE); + break; +#if USE_GPM_SUPPORT + case M_GPM: + 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 +#if USE_TERM_DRIVER + case M_TERM_DRIVER: + enable_win32_mouse(sp, TRUE); + break; +#endif + case M_NONE: + returnVoid; + default: + T(("unexpected mouse mode")); + break; + } + /* Make runtime binding to cut down on object size of applications that + * do not use the mouse (e.g., 'clear'). + */ + /* *INDENT-EQLS* */ + 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 (sp->_mouse_type) { + case M_XTERM: + enable_xterm_mouse(sp, FALSE); + 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 +#if USE_TERM_DRIVER + case M_TERM_DRIVER: + enable_win32_mouse(sp, FALSE); + break; +#endif + case M_NONE: + returnVoid; + default: + T(("unexpected mouse mode")); + break; + } + } + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + returnVoid; +} + +/************************************************************************** + * + * Device-independent code + * + **************************************************************************/ + +static bool +_nc_mouse_parse(SCREEN *sp, int runcount) +/* parse a run of atomic mouse events into a gesture */ +{ + MEVENT *eventp = sp->_mouse_writep; + MEVENT *next, *ep; + MEVENT *first_valid = NULL; + MEVENT *first_invalid = NULL; + int n; + int b; + bool merge; + bool endLoop; + + TR(MY_TRACE, (T_CALLED("_nc_mouse_parse(%d)"), runcount)); + + if (!sp->_maxclick + && sp->_mouse_readp != NULL + && ValidEvent(sp->_mouse_readp) + && ((sp->_mouse_readp->bstate & sp->_mouse_mask) != 0)) { + returnCode(1); + } + + /* + * 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 collapse this run into a single higher-level event + * or gesture. + * + * We accomplish this in two passes. The first pass merges press/release + * pairs into click events. The second merges runs of click events into + * double or triple-click events. + * + * It's possible that the run may not resolve to a single event (for + * example, if the user quadruple-clicks). If so, leading events + * in the run are ignored if user does not call getmouse in a loop (getting + * them from newest to older). + * + * Note that this routine is independent of the format of the specific + * format of the pointing-device's reports. We can use it to parse + * gestures on anything that reports press/release events on a per- + * button basis, as long as the device-dependent mouse code puts stuff + * on the queue in MEVENT format. + */ + + /* + * Reset all events that were not set, in case the user sometimes calls + * getmouse only once and other times until there are no more events in + * queue. + * + * This also allows reaching the beginning of the run. + */ + ep = eventp; + for (n = runcount; n < EV_MAX; n++) { + Invalidate(ep); + ep = NEXT(ep); + } + +#ifdef TRACE + 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", + RunParams(sp, eventp, ep), + runcount); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + + /* first pass; merge press/release pairs */ + endLoop = FALSE; + while (!endLoop) { + next = NEXT(ep); + if (next == eventp) { + /* Will end the loop, but compact before */ + endLoop = TRUE; + } else { + +#define MASK_CHANGED(x) (!(ep->bstate & MASK_PRESS(x)) \ + == !(next->bstate & MASK_RELEASE(x))) + + if (ValidEvent(ep) && ValidEvent(next) + && ep->x == next->x && ep->y == next->y + && (ep->bstate & BUTTON_PRESSED) + && (!(next->bstate & BUTTON_PRESSED))) { + bool changed = TRUE; + + for (b = 1; b <= MAX_BUTTONS; ++b) { + if (!MASK_CHANGED(b)) { + changed = FALSE; + break; + } + } + + if (changed) { + merge = FALSE; + for (b = 1; b <= MAX_BUTTONS; ++b) { + if ((sp->_mouse_mask2 & MASK_CLICK(b)) + && (ep->bstate & MASK_PRESS(b))) { + next->bstate &= ~MASK_RELEASE(b); + next->bstate |= MASK_CLICK(b); + merge = TRUE; + } + } + if (merge) { + Invalidate(ep); + } + } + } + } + + /* Compact valid events */ + if (!ValidEvent(ep)) { + if ((first_valid != NULL) && (first_invalid == NULL)) { + first_invalid = ep; + } + } else { + if (first_valid == NULL) { + first_valid = ep; + } else if (first_invalid != NULL) { + *first_invalid = *ep; + Invalidate(ep); + first_invalid = NEXT(first_invalid); + } + } + + ep = next; + } + + if (first_invalid != NULL) { + eventp = first_invalid; + } +#ifdef TRACE + if (USE_TRACEF(TRACE_IEVENT)) { + _trace_slot(sp, "before mouse click merge:"); + if (first_valid == NULL) { + _tracef("_nc_mouse_parse: no valid event"); + } else { + _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d", + RunParams(sp, eventp, first_valid), + runcount); + _nc_unlock_global(tracef); + } + } +#endif /* TRACE */ + + /* + * Second pass; merge click runs. We merge click events forward in the + * queue. For example, double click can be changed to triple click. + * + * NOTE: There is a problem with this design! If the application + * allows enough click events to pile up in the circular queue so + * they wrap around, it will cheerfully merge the newest forward + * into the oldest, creating a bogus doubleclick and confusing + * the queue-traversal logic rather badly. Generally this won't + * happen, because calling getmouse() marks old events invalid and + * ineligible for merges. The true solution to this problem would + * be to timestamp each MEVENT and perform the obvious sanity check, + * but the timer element would have to have sub-second resolution, + * which would get us into portability trouble. + */ + first_invalid = NULL; + endLoop = (first_valid == NULL); + ep = first_valid; + while (!endLoop) { + next = NEXT(ep); + + if (next == eventp) { + /* Will end the loop, but check event type and compact before */ + endLoop = TRUE; + } else if (!ValidEvent(next)) { + continue; + } else { + /* merge click events forward */ + if ((ep->bstate & BUTTON_CLICKED) + && (next->bstate & BUTTON_CLICKED)) { + merge = FALSE; + for (b = 1; b <= MAX_BUTTONS; ++b) { + if ((sp->_mouse_mask2 & MASK_DOUBLE_CLICK(b)) + && (ep->bstate & MASK_CLICK(b)) + && (next->bstate & MASK_CLICK(b))) { + next->bstate &= ~MASK_CLICK(b); + next->bstate |= MASK_DOUBLE_CLICK(b); + merge = TRUE; + } + } + if (merge) { + Invalidate(ep); + } + } + + /* merge double-click events forward */ + if ((ep->bstate & BUTTON_DOUBLE_CLICKED) + && (next->bstate & BUTTON_CLICKED)) { + merge = FALSE; + for (b = 1; b <= MAX_BUTTONS; ++b) { + if ((sp->_mouse_mask2 & MASK_TRIPLE_CLICK(b)) + && (ep->bstate & MASK_DOUBLE_CLICK(b)) + && (next->bstate & MASK_CLICK(b))) { + next->bstate &= ~MASK_CLICK(b); + next->bstate |= MASK_TRIPLE_CLICK(b); + merge = TRUE; + } + } + if (merge) { + Invalidate(ep); + } + } + } + + /* Discard event if it does not match event mask */ + if (!(ep->bstate & sp->_mouse_mask2)) { + Invalidate(ep); + } + + /* Compact valid events */ + if (!ValidEvent(ep)) { + if (ep == first_valid) { + first_valid = next; + } else if (first_invalid == NULL) { + first_invalid = ep; + } + } else if (first_invalid != NULL) { + *first_invalid = *ep; + Invalidate(ep); + first_invalid = NEXT(first_invalid); + } + + ep = next; + } + + if (first_invalid == NULL) { + first_invalid = eventp; + } + sp->_mouse_writep = first_invalid; + +#ifdef TRACE + if (first_valid != NULL) { + 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", + RunParams(sp, first_invalid, first_valid), + runcount); + _nc_unlock_global(tracef); + } + for (ep = first_valid; ep != first_invalid; ep = NEXT(ep)) { + if (ValidEvent(ep)) + TR(MY_TRACE, + ("_nc_mouse_parse: returning composite mouse event %s at slot %ld", + _nc_tracemouse(sp, ep), + (long) IndexEV(sp, ep))); + } + } +#endif /* TRACE */ + + /* after all this, do we have a valid event? */ + ep = PREV(first_invalid); + returnCode(ValidEvent(ep) && ((ep->bstate & sp->_mouse_mask) != 0)); +} + +static void +_nc_mouse_wrap(SCREEN *sp) +/* release mouse -- called by endwin() before shellout/exit */ +{ + TR(MY_TRACE, ("_nc_mouse_wrap() called")); + + switch (sp->_mouse_type) { + case M_XTERM: + 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 +#if USE_TERM_DRIVER + case M_TERM_DRIVER: + mouse_activate(sp, FALSE); + break; +#endif + case M_NONE: + break; + } +} + +static void +_nc_mouse_resume(SCREEN *sp) +/* re-connect to mouse -- called by doupdate() after shellout */ +{ + TR(MY_TRACE, ("_nc_mouse_resume() called")); + + switch (sp->_mouse_type) { + case M_XTERM: + /* xterm: re-enable reporting */ + if (sp->_mouse_mask) + mouse_activate(sp, TRUE); + break; + +#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 + +#if USE_TERM_DRIVER + case M_TERM_DRIVER: + mouse_activate(sp, TRUE); + break; +#endif + + case M_NONE: + break; + } +} + +/************************************************************************** + * + * Mouse interface entry points for the API + * + **************************************************************************/ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(getmouse) (NCURSES_SP_DCLx MEVENT * aevent) +{ + int result = ERR; + MEVENT *readp; + + T((T_CALLED("getmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent)); + + if ((aevent != NULL) && + (SP_PARM != NULL) && + (SP_PARM->_mouse_type != M_NONE) && + (readp = SP_PARM->_mouse_readp) != NULL) { + /* + * Discard events not matching mask (there could be still some if + * _nc_mouse_parse was not called, e.g., when _nc_mouse_inline returns + * false). + */ + while (readp != SP_PARM->_mouse_writep && + (!ValidEvent(readp) || !(readp->bstate & SP_PARM->_mouse_mask2))) { + Invalidate(readp); + readp = NEXT(readp); + } + if (readp != SP_PARM->_mouse_writep && ValidEvent(readp)) { + /* copy the event we find there */ + *aevent = *readp; + + TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld", + _nc_tracemouse(SP_PARM, readp), + (long) IndexEV(SP_PARM, readp))); + + Invalidate(readp); /* so the queue slot becomes free */ + SP_PARM->_mouse_readp = NEXT(readp); + result = OK; + } else { + /* Reset the provided event */ + aevent->bstate = 0; + Invalidate(aevent); + aevent->x = 0; + aevent->y = 0; + aevent->z = 0; + } + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +/* grab a copy of the current mouse event */ +NCURSES_EXPORT(int) +getmouse(MEVENT * aevent) +{ + return NCURSES_SP_NAME(getmouse) (CURRENT_SCREEN, aevent); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(ungetmouse) (NCURSES_SP_DCLx MEVENT * aevent) +{ + int result = ERR; + MEVENT *eventp; + + T((T_CALLED("ungetmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent)); + + if (aevent != NULL && + SP_PARM != NULL && + (eventp = SP_PARM->_mouse_writep) != NULL) { + + /* stick the given event in the next-free slot */ + *eventp = *aevent; + + /* bump the next-free pointer into the circular list */ + SP_PARM->_mouse_writep = NEXT(eventp); + + /* push back the notification event on the keyboard queue */ + result = NCURSES_SP_NAME(ungetch) (NCURSES_SP_ARGx KEY_MOUSE); + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +/* enqueue a synthesized mouse event to be seen by the next wgetch() */ +NCURSES_EXPORT(int) +ungetmouse(MEVENT * aevent) +{ + return NCURSES_SP_NAME(ungetmouse) (CURRENT_SCREEN, aevent); +} +#endif + +NCURSES_EXPORT(mmask_t) +NCURSES_SP_NAME(mousemask) (NCURSES_SP_DCLx mmask_t newmask, mmask_t * oldmask) +/* set the mouse event mask */ +{ + mmask_t result = 0; + + T((T_CALLED("mousemask(%p,%#lx,%p)"), + (void *) SP_PARM, + (unsigned long) newmask, + (void *) oldmask)); + + if (SP_PARM != NULL) { + if (oldmask) + *oldmask = SP_PARM->_mouse_mask; + + if (newmask || SP_PARM->_mouse_initialized) { + _nc_mouse_init(SP_PARM); + + if (SP_PARM->_mouse_type != M_NONE) { + int b; + + 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_PARM, (bool) (result != 0)); + + SP_PARM->_mouse_mask = result; + SP_PARM->_mouse_mask2 = result; + + /* + * Make a mask corresponding to the states we will need to + * retain (temporarily) while building up the state that the + * user asked for. + */ + for (b = 1; b <= MAX_BUTTONS; ++b) { + if (SP_PARM->_mouse_mask2 & MASK_TRIPLE_CLICK(b)) + SP_PARM->_mouse_mask2 |= MASK_DOUBLE_CLICK(b); + if (SP_PARM->_mouse_mask2 & MASK_DOUBLE_CLICK(b)) + SP_PARM->_mouse_mask2 |= MASK_CLICK(b); + if (SP_PARM->_mouse_mask2 & MASK_CLICK(b)) + SP_PARM->_mouse_mask2 |= (MASK_PRESS(b) | + MASK_RELEASE(b)); + } + } + } + } + returnMMask(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(mmask_t) +mousemask(mmask_t newmask, mmask_t * oldmask) +{ + return NCURSES_SP_NAME(mousemask) (CURRENT_SCREEN, newmask, oldmask); +} +#endif + +NCURSES_EXPORT(bool) +wenclose(const WINDOW *win, int y, int x) +/* check to see if given window encloses given screen location */ +{ + bool result = FALSE; + + T((T_CALLED("wenclose(%p,%d,%d)"), (const void *) win, y, x)); + + if (win != NULL) { + y -= win->_yoffset; + if (IS_PAD(win)) { + if (win->_pad._pad_y >= 0 && + win->_pad._pad_x >= 0 && + win->_pad._pad_top >= 0 && + win->_pad._pad_left >= 0 && + win->_pad._pad_right >= 0 && + win->_pad._pad_bottom >= 0) { + result = ((win->_pad._pad_top <= y && + win->_pad._pad_left <= x && + win->_pad._pad_right >= x && + win->_pad._pad_bottom >= y) ? TRUE : FALSE); + } + } else { + result = ((win->_begy <= y && + win->_begx <= x && + (win->_begx + win->_maxx) >= x && + (win->_begy + win->_maxy) >= y) ? TRUE : FALSE); + } + } + returnBool(result); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(mouseinterval) (NCURSES_SP_DCLx int maxclick) +/* set the maximum mouse interval within which to recognize a click */ +{ + int oldval; + + T((T_CALLED("mouseinterval(%p,%d)"), (void *) SP_PARM, maxclick)); + + if (SP_PARM != NULL) { + oldval = SP_PARM->_maxclick; + if (maxclick >= 0) + SP_PARM->_maxclick = maxclick; + } else { + oldval = DEFAULT_MAXCLICK; + } + + returnCode(oldval); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +mouseinterval(int maxclick) +{ + return NCURSES_SP_NAME(mouseinterval) (CURRENT_SCREEN, maxclick); +} +#endif + +/* This may be used by other routines to ask for the existence of mouse + support */ +NCURSES_EXPORT(bool) +_nc_has_mouse(const SCREEN *sp) +{ + return (((NULL == sp) || (sp->_mouse_type == M_NONE)) ? FALSE : TRUE); +} + +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(has_mouse) (NCURSES_SP_DCL0) +{ + return _nc_has_mouse(SP_PARM); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +has_mouse(void) +{ + return _nc_has_mouse(CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(bool) +wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen) +{ + bool result = FALSE; + + T((T_CALLED("wmouse_trafo(%p,%p,%p,%d)"), + (const void *) win, + (void *) pY, + (void *) pX, + to_screen)); + + if (win && pY && pX) { + int y = *pY; + int x = *pX; + + T(("transform input %d,%d", y, x)); + if (to_screen) { + y += win->_begy + win->_yoffset; + x += win->_begx; + if (wenclose(win, y, x)) + result = TRUE; + } else { + if (wenclose(win, y, x)) { + y -= (win->_begy + win->_yoffset); + x -= win->_begx; + result = TRUE; + } + } + if (result) { + *pX = x; + *pY = y; + T(("output transform %d,%d", y, x)); + } + } + returnBool(result); +} diff --git a/ncurses/ncurses/base/lib_move.c b/ncurses/ncurses/base/lib_move.c new file mode 100644 index 0000000000..9e36dd1f3a --- /dev/null +++ b/ncurses/ncurses/base/lib_move.c @@ -0,0 +1,64 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2004,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_move.c +** +** The routine wmove(). +** +*/ + +#include + +MODULE_ID("$Id: lib_move.c,v 1.14 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +wmove(WINDOW *win, int y, int x) +{ + T((T_CALLED("wmove(%p,%d,%d)"), (void *) win, y, x)); + + if (LEGALYX(win, y, x)) { + win->_curx = (NCURSES_SIZE_T) x; + win->_cury = (NCURSES_SIZE_T) y; + + win->_flags &= ~_WRAPPED; + win->_flags |= _HASMOVED; + returnCode(OK); + } else + returnCode(ERR); +} diff --git a/ncurses/ncurses/base/lib_mvwin.c b/ncurses/ncurses/base/lib_mvwin.c new file mode 100644 index 0000000000..811d1923e8 --- /dev/null +++ b/ncurses/ncurses/base/lib_mvwin.c @@ -0,0 +1,124 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* +** lib_mvwin.c +** +** The routine mvwin(). +** +*/ + +#include + +MODULE_ID("$Id: lib_mvwin.c,v 1.21 2024/07/27 19:23:59 tom Exp $") + +NCURSES_EXPORT(int) +mvwin(WINDOW *win, int by, int bx) +{ +#if NCURSES_SP_FUNCS + const SCREEN *sp = _nc_screen_of(win); +#endif + + T((T_CALLED("mvwin(%p,%d,%d)"), (void *) win, by, bx)); + + if (!win || IS_PAD(win)) + 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 (IS_SUBWIN(win)) { + int err = ERR; + WINDOW *parent = win->_parent; + if (parent) { /* Now comes the complicated and costly part, you should really + * try to avoid to move subwindows. Because a subwindow shares + * the text buffers with its parent, one can't do a simple + * memmove of the text buffers. One has to create a copy, then + * to relocate the subwindow and then to do a copy. + */ + if ((by - parent->_begy == win->_pary) && + (bx - parent->_begx == win->_parx)) + err = OK; /* we don't actually move */ + else { + WINDOW *clone = dupwin(win); + if (clone) { + /* now we have the clone, so relocate win */ + + werase(win); /* Erase the original place */ + /* fill with parents background */ + wbkgrnd(win, CHREF(parent->_nc_bkgd)); + wsyncup(win); /* Tell the parent(s) */ + + err = mvderwin(win, + by - parent->_begy, + bx - parent->_begx); + if (err != ERR) { + err = copywin(clone, win, + 0, 0, 0, 0, win->_maxy, win->_maxx, 0); + if (ERR != err) + wsyncup(win); + } + if (ERR == delwin(clone)) + err = ERR; + } + } + } + returnCode(err); + } +#endif + + if (by + win->_maxy > screen_lines(SP_PARM) - 1 + || bx + win->_maxx > screen_columns(SP_PARM) - 1 + || by < 0 + || bx < 0) + returnCode(ERR); + + /* + * Whether or not the window is moved, touch the window's contents so + * that a following call to 'wrefresh()' will paint the window at the + * new location. This ensures that if the caller has refreshed another + * window at the same location, that this one will be displayed. + */ + win->_begy = (NCURSES_SIZE_T) by; + win->_begx = (NCURSES_SIZE_T) bx; + returnCode(touchwin(win)); +} diff --git a/ncurses/ncurses/base/lib_newterm.c b/ncurses/ncurses/base/lib_newterm.c new file mode 100644 index 0000000000..ca009fb802 --- /dev/null +++ b/ncurses/ncurses/base/lib_newterm.c @@ -0,0 +1,379 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_newterm.c +** +** The newterm() function. +** +*/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +#include + +MODULE_ID("$Id: lib_newterm.c,v 1.110 2025/12/27 12:28:45 tom Exp $") + +#if USE_TERM_DRIVER +#define NumLabels InfoOf(SP_PARM).numlabels +#else +#define NumLabels num_labels +#endif + +#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ +#define ONLCR 0 +#endif + +/* + * SVr4/XSI Curses specify that hardware echo is turned off in initscr, and not + * restored during the curses session. The library simulates echo in software. + * (The behavior is unspecified if the application enables hardware echo). + * + * The newterm function also initializes terminal settings, and since initscr + * is supposed to behave as if it calls newterm, we do it here. + */ +static NCURSES_INLINE int +_nc_initscr(NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *term = TerminalOf(SP_PARM); + + /* for extended XPG4 conformance requires cbreak() at this point */ + /* (SVr4 curses does this anyway) */ + T((T_CALLED("_nc_initscr(%p) ->term %p"), (void *) SP_PARM, (void *) term)); + if (NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG) == OK) { + TTY buf; + + buf = term->Nttyb; +#ifdef TERMIOS + buf.c_lflag &= (unsigned) ~(ECHO | ECHONL); + buf.c_iflag &= (unsigned) ~(ICRNL | INLCR | IGNCR); + buf.c_oflag &= (unsigned) ~(ONLCR); +#elif HAVE_SGTTY_H + buf.sg_flags &= ~(ECHO | CRMOD); +#elif USE_NAMED_PIPES + buf.dwFlagIn = CONMODE_IN_DEFAULT; + buf.dwFlagOut = CONMODE_OUT_DEFAULT | VT_FLAG_OUT; + if (WINCONSOLE.isTermInfoConsole) { + buf.dwFlagIn |= VT_FLAG_IN; + } +#else + memset(&buf, 0, sizeof(buf)); +#endif + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) + term->Nttyb = buf; + } + returnCode(result); +} + +/* + * filter() has to be called before either initscr() or newterm(), so there is + * apparently no way to make this flag apply to some terminals and not others, + * aside from possibly delaying a filter() call until some terminals have been + * initialized. + */ +NCURSES_EXPORT(void) +NCURSES_SP_NAME(filter) (NCURSES_SP_DCL0) +{ + START_TRACE(); + T((T_CALLED("filter(%p)"), (void *) SP_PARM)); +#if NCURSES_SP_FUNCS + if (IsPreScreen(SP_PARM)) { + SP_PARM->_filtered = TRUE; + } +#else + _nc_prescreen.filter_mode = TRUE; +#endif + returnVoid; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +filter(void) +{ + START_TRACE(); + T((T_CALLED("filter()"))); + _nc_prescreen.filter_mode = TRUE; + returnVoid; +} +#endif + +#if NCURSES_EXT_FUNCS +/* + * An extension, allowing the application to open a new screen without + * requiring it to also be filtered. + */ +NCURSES_EXPORT(void) +NCURSES_SP_NAME(nofilter) (NCURSES_SP_DCL0) +{ + START_TRACE(); + T((T_CALLED("nofilter(%p)"), (void *) SP_PARM)); +#if NCURSES_SP_FUNCS + if (IsPreScreen(SP_PARM)) { + SP_PARM->_filtered = FALSE; + } +#else + _nc_prescreen.filter_mode = FALSE; +#endif + returnVoid; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +nofilter(void) +{ + START_TRACE(); + T((T_CALLED("nofilter()"))); + _nc_prescreen.filter_mode = FALSE; + returnVoid; +} +#endif +#endif /* NCURSES_EXT_FUNCS */ + +NCURSES_EXPORT(SCREEN *) +NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx + const char *name, + FILE *ofp, + FILE *ifp) +{ + int errret; + SCREEN *result = NULL; + SCREEN *current; + TERMINAL *its_term; + FILE *_ofp = ofp ? ofp : stdout; + FILE *_ifp = ifp ? ifp : stdin; + TERMINAL *new_term = NULL; + + START_TRACE(); + T((T_CALLED("newterm(%p, \"%s\", %p,%p)"), + (void *) SP_PARM, + (name ? name : ""), + (void *) ofp, + (void *) ifp)); + +#if NCURSES_SP_FUNCS + assert(SP_PARM != NULL); + if (SP_PARM == NULL) + returnSP(SP_PARM); +#endif + + _nc_init_pthreads(); + _nc_lock_global(curses); + + current = CURRENT_SCREEN; + its_term = (current ? current->_term : NULL); + +#if USE_NAMED_PIPES + _setmode(fileno(_ifp), _O_BINARY); + _setmode(fileno(_ofp), _O_BINARY); +#endif + + INIT_TERM_DRIVER(); + /* this loads the capability entry, then sets LINES and COLS */ + if ( + TINFO_SETUP_TERM(&new_term, name, + fileno(_ofp), &errret, FALSE) != ERR) { + int slk_format; + bool filter_mode; + + _nc_set_screen(NULL); +#if USE_TERM_DRIVER + assert(new_term != NULL); +#endif + +#if NCURSES_SP_FUNCS + slk_format = SP_PARM->slk_format; + filter_mode = SP_PARM->_filtered; +#else + slk_format = _nc_globals.slk_format; + filter_mode = _nc_prescreen.filter_mode; +#endif + + /* + * This actually allocates the screen structure, and saves the original + * terminal settings. + */ + if (NCURSES_SP_NAME(_nc_setupscreen) ( +#if NCURSES_SP_FUNCS + &SP_PARM, +#endif + *(ptrLines(SP_PARM)), + *(ptrCols(SP_PARM)), + _ofp, + filter_mode, + slk_format) == ERR) { + _nc_set_screen(current); + result = NULL; + } else { + int value; + int cols; + +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB; +#elif !NCURSES_SP_FUNCS + _nc_set_screen(CURRENT_SCREEN); +#endif + assert(SP_PARM != NULL); + cols = *(ptrCols(SP_PARM)); +#if USE_TERM_DRIVER + _nc_set_screen(SP_PARM); + TCB = (TERMINAL_CONTROL_BLOCK *) new_term; + TCB->csp = SP_PARM; +#endif + /* + * In setupterm() we did a set_curterm(), but it was before we set + * CURRENT_SCREEN. So the "current" screen's terminal pointer was + * overwritten with a different terminal. Later, in + * _nc_setupscreen(), we set CURRENT_SCREEN 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 USE_TERM_DRIVER + SP_PARM->_term = new_term; +#else + new_term = SP_PARM->_term; +#endif + + /* allow user to set maximum escape delay from the environment */ + if ((value = _nc_getenv_num("ESCDELAY")) >= 0) { + value = Min(value, MAX_DELAY_MSECS); +#if NCURSES_EXT_FUNCS + NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_ARGx value); +#else + ESCDELAY = value; +#endif + } + + /* if the terminal type has real soft labels, set those up */ + if (slk_format && NumLabels > 0 && SLK_STDFMT(slk_format)) + _nc_slk_initialize(StdScreen(SP_PARM), cols); + + SP_PARM->_ifd = fileno(_ifp); + NCURSES_SP_NAME(typeahead) (NCURSES_SP_ARGx fileno(_ifp)); +#ifdef TERMIOS + SP_PARM->_use_meta = ((new_term->Ottyb.c_cflag & CSIZE) == CS8 && + !(new_term->Ottyb.c_iflag & ISTRIP)) || + USE_KLIBC_KBD; +#else + SP_PARM->_use_meta = FALSE; +#endif + SP_PARM->_endwin = ewInitial; +#if !USE_TERM_DRIVER + /* + * 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_PARM->_scrolling = ((scroll_forward && scroll_reverse) || + ((parm_rindex || + parm_insert_line || + insert_line) && + (parm_index || + parm_delete_line || + delete_line))); +#endif + + NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets a field in the screen structure */ + + SP_PARM->_keytry = NULL; + + /* compute movement costs so we can do better move optimization */ +#if USE_TERM_DRIVER + TCBOf(SP_PARM)->drv->td_scinit(SP_PARM); +#else /* ! USE_TERM_DRIVER */ + /* + * 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 != NULL) && (exit_attribute_mode == NULL || strcmp(mode, exit_attribute_mode)) + SP_PARM->_use_rmso = SGR0_TEST(exit_standout_mode); + SP_PARM->_use_rmul = SGR0_TEST(exit_underline_mode); +#if USE_ITALIC + SP_PARM->_use_ritm = SGR0_TEST(exit_italics_mode); +#endif + + /* compute movement costs so we can do better move optimization */ + _nc_mvcur_init(); + + /* initialize terminal to a sane state */ + _nc_screen_init(); +#endif /* USE_TERM_DRIVER */ + + /* Initialize the terminal line settings. */ + _nc_initscr(NCURSES_SP_ARG); + + _nc_signal_handler(TRUE); + result = SP_PARM; + } + } + _nc_unlock_global(curses); + returnSP(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(SCREEN *) +newterm(const char *name, FILE *ofp, FILE *ifp) +{ + SCREEN *rc; + + _nc_init_pthreads(); + _nc_lock_global(prescreen); + START_TRACE(); + rc = NCURSES_SP_NAME(newterm) (CURRENT_SCREEN_PRE, name, ofp, ifp); + _nc_forget_prescr(); + _nc_unlock_global(prescreen); + + return rc; +} +#endif diff --git a/ncurses/ncurses/base/lib_newwin.c b/ncurses/ncurses/base/lib_newwin.c new file mode 100644 index 0000000000..693147ab02 --- /dev/null +++ b/ncurses/ncurses/base/lib_newwin.c @@ -0,0 +1,405 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_newwin.c +** +** The routines newwin(), subwin() and their dependent +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_newwin.c,v 1.79 2024/12/14 23:50:18 tom Exp $") + +#define window_is(name) ((sp)->_##name == win) + +#if USE_REENTRANT +#define remove_window(name) \ + sp->_##name = NULL +#else +#define remove_window(name) \ + sp->_##name = NULL; \ + if (win == name) \ + name = NULL +#endif + +static void +remove_window_from_screen(WINDOW *win) +{ + SCREEN *sp; + +#ifdef USE_SP_WINDOWLIST + if ((sp = _nc_screen_of(win)) != NULL) { + if (window_is(curscr)) { + remove_window(curscr); + } else if (window_is(stdscr)) { + remove_window(stdscr); + } else if (window_is(newscr)) { + remove_window(newscr); + } + } +#else + 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; + } + } +#endif +} + +NCURSES_EXPORT(int) +_nc_freewin(WINDOW *win) +{ + int result = ERR; +#ifdef USE_SP_WINDOWLIST + SCREEN *sp = _nc_screen_of(win); /* pretend this is parameter */ +#endif + + T((T_CALLED("_nc_freewin(%p)"), (void *) win)); + + if (win != NULL) { + + if (_nc_nonsp_try_global(curses) == 0) { + WINDOWLIST *p, *q; + + q = NULL; + for (each_window(sp, p)) { + + if (&(p->win) == win) { + remove_window_from_screen(win); + if (q == NULL) + WindowList(sp) = p->next; + else + q->next = p->next; + + if (!IS_SUBWIN(win)) { + int i; + + for (i = 0; i <= win->_maxy; i++) + FreeIfNeeded(win->_line[i].text); + } + free(win->_line); + free(p); + + result = OK; + T(("...deleted win=%p", (void *) win)); + break; + } + q = p; + } + _nc_nonsp_unlock_global(curses); + } + } + returnCode(result); +} + +NCURSES_EXPORT(WINDOW *) +NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx + int num_lines, int num_columns, int begy, int begx) +{ + WINDOW *win; + NCURSES_CH_T *ptr; + int i; + + T((T_CALLED("newwin(%p, %d,%d,%d,%d)"), (void *) SP_PARM, num_lines, num_columns, + begy, begx)); + + if (begy < 0 + || begx < 0 + || num_lines < 0 + || num_columns < 0 + || SP_PARM == NULL) + returnWin(NULL); + + if (num_lines == 0) + num_lines = SP_PARM->_lines_avail - begy; + if (num_columns == 0) + num_columns = screen_columns(SP_PARM) - begx; + + win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx + num_lines, num_columns, begy, begx, 0); + if (win == NULL) + returnWin(NULL); + + for (i = 0; i < num_lines; i++) { + win->_line[i].text = typeCalloc(NCURSES_CH_T, (unsigned) num_columns); + if (win->_line[i].text == NULL) { + (void) _nc_freewin(win); + returnWin(NULL); + } + for (ptr = win->_line[i].text; + ptr < win->_line[i].text + num_columns; + ptr++) + SetChar(*ptr, BLANK_TEXT, BLANK_ATTR); + } + + returnWin(win); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(WINDOW *) +newwin(int num_lines, int num_columns, int begy, int begx) +{ + WINDOW *win; + _nc_sp_lock_global(curses); + win = NCURSES_SP_NAME(newwin) (CURRENT_SCREEN, + num_lines, num_columns, begy, begx); + _nc_sp_unlock_global(curses); + return (win); +} +#endif + +NCURSES_EXPORT(WINDOW *) +derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) +{ + WINDOW *win; + int i; + int flags = _SUBWIN; +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(orig); +#endif + + T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), (void *) orig, num_lines, num_columns, + begy, begx)); + + /* + * make sure window fits inside the original one + */ + if (begy < 0 + || begx < 0 + || orig == NULL + || num_lines < 0 + || num_columns < 0 + || begy + num_lines > orig->_maxy + 1 + || begx + num_columns > orig->_maxx + 1) + returnWin(NULL); + + if (num_lines == 0) + num_lines = orig->_maxy + 1 - begy; + + if (num_columns == 0) + num_columns = orig->_maxx + 1 - begx; + + if (IS_PAD(orig)) + flags |= _ISPAD; + + win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx num_lines, num_columns, + orig->_begy + begy, + orig->_begx + begx, flags); + if (win == NULL) + returnWin(NULL); + + win->_pary = begy; + win->_parx = begx; + 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; + + returnWin(win); +} + +NCURSES_EXPORT(WINDOW *) +subwin(WINDOW *w, int l, int c, int y, int x) +{ + WINDOW *result = NULL; + + T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), (void *) w, l, c, y, x)); + if (w != NULL) { + T(("parent has begy = %ld, begx = %ld", (long) w->_begy, (long) w->_begx)); + + result = derwin(w, l, c, y - w->_begy, x - w->_begx); + } + returnWin(result); +} + +NCURSES_EXPORT(WINDOW *) +NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx + int num_lines, + int num_columns, + int begy, + int begx, + int flags) +{ + int i; + WINDOWLIST *wp; + WINDOW *win; + bool is_padwin = (flags & _ISPAD); + + T((T_CALLED("_nc_makenew(%p,%d,%d,%d,%d)"), + (void *) SP_PARM, num_lines, num_columns, begy, begx)); + + if (SP_PARM == NULL) + returnWin(NULL); + + if (!OK_DIMENSION(num_lines) || !OK_DIMENSION(num_columns)) + returnWin(NULL); + + if ((wp = typeCalloc(WINDOWLIST, 1)) == NULL) + returnWin(NULL); + + win = &(wp->win); + + if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == NULL) { + free(wp); + returnWin(NULL); + } + + _nc_nonsp_lock_global(curses); + + win->_curx = 0; + win->_cury = 0; + win->_maxy = (NCURSES_SIZE_T) (num_lines - 1); + win->_maxx = (NCURSES_SIZE_T) (num_columns - 1); + win->_begy = (NCURSES_SIZE_T) begy; + win->_begx = (NCURSES_SIZE_T) begx; + win->_yoffset = SP_PARM->_topstolen; + + win->_flags = (short) flags; + WINDOW_ATTRS(win) = A_NORMAL; + SetChar(win->_nc_bkgd, BLANK_TEXT, BLANK_ATTR); + + win->_clear = (is_padwin + ? FALSE + : (num_lines == screen_lines(SP_PARM) + && num_columns == screen_columns(SP_PARM))); + win->_idlok = FALSE; + win->_idcok = TRUE; + win->_scroll = FALSE; + win->_leaveok = FALSE; + win->_use_keypad = FALSE; + win->_delay = -1; + win->_immed = FALSE; + win->_sync = 0; + win->_parx = -1; + win->_pary = -1; + win->_parent = NULL; + + win->_regtop = 0; + win->_regbottom = (NCURSES_SIZE_T) (num_lines - 1); + + win->_pad._pad_y = -1; + win->_pad._pad_x = -1; + win->_pad._pad_top = -1; + win->_pad._pad_bottom = -1; + win->_pad._pad_left = -1; + win->_pad._pad_right = -1; + + for (i = 0; i < num_lines; i++) { + /* + * This used to do + * + * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE; + * + * which marks the whole window unchanged. That's how + * SVr1 curses did it, but SVr4 curses marks the whole new + * window changed. + * + * With the old SVr1-like code, say you have stdscr full of + * characters, then create a new window with newwin(), + * then do a printw(win, "foo ");, the trailing spaces are + * completely ignored by the following refreshes. So, you + * get "foojunkjunk" on the screen instead of "foo " as + * you actually intended. + * + * SVr4 doesn't do this. Instead the spaces are actually written. + * So that's how we want ncurses to behave. + */ + win->_line[i].firstchar = 0; + win->_line[i].lastchar = (NCURSES_SIZE_T) (num_columns - 1); + + if_USE_SCROLL_HINTS(win->_line[i].oldindex = i); + } + + if (!is_padwin && (begx + num_columns == screen_columns(SP_PARM))) { + win->_flags |= _ENDLINE; + + if (begx == 0 && num_lines == screen_lines(SP_PARM) && begy == 0) + win->_flags |= _FULLWIN; + + if (begy + num_lines == screen_lines(SP_PARM)) + win->_flags |= _SCROLLWIN; + } + + wp->next = WindowList(SP_PARM); + wp->screen = SP_PARM; + WindowList(SP_PARM) = wp; + + T((T_CREATE("window %p"), (void *) win)); + + _nc_nonsp_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. + */ +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(WINDOW *) +_nc_curscr_of(SCREEN *sp) +{ + return (sp == NULL) ? NULL : CurScreen(sp); +} + +NCURSES_EXPORT(WINDOW *) +_nc_newscr_of(SCREEN *sp) +{ + return (sp == NULL) ? NULL : NewScreen(sp); +} + +NCURSES_EXPORT(WINDOW *) +_nc_stdscr_of(SCREEN *sp) +{ + return (sp == NULL) ? NULL : StdScreen(sp); +} +#endif diff --git a/ncurses/ncurses/base/lib_nl.c b/ncurses/ncurses/base/lib_nl.c new file mode 100644 index 0000000000..d62f80c27e --- /dev/null +++ b/ncurses/ncurses/base/lib_nl.c @@ -0,0 +1,95 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * nl.c + * + * Routines: + * nl() + * nonl() + * + */ + +#include + +MODULE_ID("$Id: lib_nl.c,v 1.16 2025/06/21 14:27:02 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(nl) (NCURSES_SP_DCL0) +{ + T((T_CALLED("nl(%p)"), (void *) SP_PARM)); + if (NULL == SP_PARM) + returnCode(ERR); + IsNl(SP_PARM) = TRUE; +#ifdef __EMX__ + _nc_flush(); + _fsetmode(NC_OUTPUT(SP_PARM), "t"); +#endif + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +nl(void) +{ + return NCURSES_SP_NAME(nl) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(nonl) (NCURSES_SP_DCL0) +{ + T((T_CALLED("nonl(%p)"), (void *) SP_PARM)); + if (NULL == SP_PARM) + returnCode(ERR); + IsNl(SP_PARM) = FALSE; +#ifdef __EMX__ + _nc_flush(); + _fsetmode(NC_OUTPUT(SP_PARM), "b"); +#endif + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +nonl(void) +{ + return NCURSES_SP_NAME(nonl) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_overlay.c b/ncurses/ncurses/base/lib_overlay.c new file mode 100644 index 0000000000..d71d28716a --- /dev/null +++ b/ncurses/ncurses/base/lib_overlay.c @@ -0,0 +1,226 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2013,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_overlay.c +** +** The routines overlay(), copywin(), and overwrite(). +** +*/ + +#include + +MODULE_ID("$Id: lib_overlay.c,v 1.35 2024/12/07 20:03:37 tom Exp $") + +static int +overlap(const WINDOW *const src, WINDOW *const dst, int const flag) +{ + int rc = ERR; + + T((T_CALLED("overlap(%p,%p,%d)"), (const void *) src, (void *) dst, flag)); + + if (src != NULL && dst != NULL) { + int sx1, sy1, sx2, sy2; + int dx1, dy1, dx2, dy2; + + _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) { + int sminrow = Max(sy1, dy1) - sy1; + int smincol = Max(sx1, dx1) - sx1; + int dminrow = Max(sy1, dy1) - dy1; + int dmincol = Max(sx1, dx1) - dx1; + int dmaxrow = Min(sy2, dy2) - dy1; + int dmaxcol = Min(sx2, dx2) - dx1; + + rc = copywin(src, dst, + sminrow, smincol, + dminrow, dmincol, + dmaxrow, dmaxcol, + flag); + } + _nc_unlock_global(curses); + } + returnCode(rc); +} + +/* +** +** overlay(win1, win2) +** +** +** overlay() writes the overlapping area of win1 behind win2 +** on win2 non-destructively. +** +**/ + +NCURSES_EXPORT(int) +overlay(const WINDOW *win1, WINDOW *win2) +{ + T((T_CALLED("overlay(%p,%p)"), (const void *) win1, (void *) win2)); + returnCode(overlap(win1, win2, TRUE)); +} + +/* +** +** overwrite(win1, win2) +** +** +** overwrite() writes the overlapping area of win1 behind win2 +** on win2 destructively. +** +**/ + +NCURSES_EXPORT(int) +overwrite(const WINDOW *win1, WINDOW *win2) +{ + T((T_CALLED("overwrite(%p,%p)"), (const void *) win1, (void *) win2)); + returnCode(overlap(win1, win2, FALSE)); +} + +NCURSES_EXPORT(int) +copywin(const WINDOW *src, WINDOW *dst, + int sminrow, int smincol, + int dminrow, int dmincol, + int dmaxrow, int dmaxcol, + int over) +{ + int rc = ERR; + + T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"), + (const void *) src, + (void *) dst, + sminrow, smincol, + dminrow, dmincol, + dmaxrow, dmaxcol, over)); + + if (src != NULL + && dst != NULL + && dmaxrow >= dminrow + && dmaxcol >= dmincol) { + attr_t bk; + attr_t mask; + + _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) { + int sx, sy, dx, dy; + bool copied = FALSE; + + T(("rectangle fits in destination")); + + for (dy = dminrow, sy = sminrow; + dy <= dmaxrow; + sy++, dy++) { + bool touched; + + if (dy < 0 || sy < 0) + continue; + + touched = FALSE; + for (dx = dmincol, sx = smincol; + dx <= dmaxcol; + sx++, dx++) { + + if (dx < 0 || sx < 0) + continue; + copied = TRUE; + + 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")); + if (copied) + rc = OK; + } + } + _nc_unlock_global(curses); + } + returnCode(rc); +} diff --git a/ncurses/ncurses/base/lib_pad.c b/ncurses/ncurses/base/lib_pad.c new file mode 100644 index 0000000000..1de5a8f01c --- /dev/null +++ b/ncurses/ncurses/base/lib_pad.c @@ -0,0 +1,352 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 1998-2010,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * lib_pad.c + * newpad -- create a new pad + * pnoutrefresh -- refresh a pad, no update + * pechochar -- add a char to a pad and refresh + */ + +#include + +MODULE_ID("$Id: lib_pad.c,v 1.52 2024/12/07 17:44:59 tom Exp $") + +NCURSES_EXPORT(WINDOW *) +NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c) +{ + WINDOW *win; + NCURSES_CH_T *ptr; + int i; + + T((T_CALLED("newpad(%p,%d, %d)"), (void *) SP_PARM, l, c)); + + if (l <= 0 || c <= 0) + returnWin(NULL); + + win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx l, c, 0, 0, _ISPAD); + if (win == NULL) + returnWin(NULL); + + for (i = 0; i < l; i++) { + if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX); + if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == NULL) { + (void) _nc_freewin(win); + returnWin(NULL); + } + for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ptr++) + SetChar(*ptr, BLANK_TEXT, BLANK_ATTR); + } + + returnWin(win); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(WINDOW *) +newpad(int l, int c) +{ + return NCURSES_SP_NAME(newpad) (CURRENT_SCREEN, l, c); +} +#endif + +NCURSES_EXPORT(WINDOW *) +subpad(WINDOW *orig, int l, int c, int begy, int begx) +{ + WINDOW *win = (WINDOW *) 0; + + T((T_CALLED("subpad(%d, %d)"), l, c)); + + if (orig) { + if (!IS_PAD(orig) + || ((win = derwin(orig, l, c, begy, begx)) == NULL)) + returnWin(NULL); + } + returnWin(win); +} + +NCURSES_EXPORT(int) +prefresh(WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) +{ +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + + T((T_CALLED("prefresh()"))); + if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, + smaxcol) != ERR + && NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG) != ERR) { + returnCode(OK); + } + returnCode(ERR); +} + +NCURSES_EXPORT(int) +pnoutrefresh(WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) +{ + int i, j; + int m, n; + int pmaxrow; + int pmaxcol; + SCREEN *sp; + +#if USE_SCROLL_HINTS + const int my_len = 2; /* parameterize the threshold for hardscroll */ + NCURSES_SIZE_T displaced; + bool wide; +#endif + + T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"), + (void *) win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol)); + + if (win == NULL) + returnCode(ERR); + + if (!IS_PAD(win)) + returnCode(ERR); + + sp = _nc_screen_of(win); + + /* negative values are interpreted as zero */ + if (pminrow < 0) + pminrow = 0; + if (pmincol < 0) + pmincol = 0; + if (sminrow < 0) + sminrow = 0; + if (smincol < 0) + smincol = 0; + + pmaxrow = pminrow + smaxrow - sminrow; + pmaxcol = pmincol + smaxcol - smincol; + + 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. + */ + if (pmaxrow > win->_maxy) { + smaxrow -= (pmaxrow - win->_maxy); + pmaxrow = pminrow + smaxrow - sminrow; + } + if (pmaxcol > win->_maxx) { + smaxcol -= (pmaxcol - win->_maxx); + pmaxcol = pmincol + smaxcol - smincol; + } + + if (smaxrow >= screen_lines(sp) + || smaxcol >= screen_columns(sp) + || sminrow > smaxrow + || smincol > smaxcol) + returnCode(ERR); + + T(("pad being refreshed")); + +#ifdef TRACE + if (USE_TRACEF(TRACE_UPDATE)) { + _tracedump("...pad", win); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ +#if USE_SCROLL_HINTS + if (win->_pad._pad_y >= 0) { + displaced = ((pminrow - win->_pad._pad_y) - + (sminrow - win->_pad._pad_top)); + T(("pad being shifted by %d line(s)", displaced)); + } else + displaced = 0; +#endif + + /* + * For pure efficiency, we'd want to transfer scrolling information + * from the pad to newscr whenever the window is wide enough that + * its update will dominate the cost of the update for the horizontal + * band of newscr that it occupies. Unfortunately, this threshold + * tends to be complex to estimate, and in any case scrolling the + * whole band and rewriting the parts outside win's image would look + * really ugly. So. What we do is consider the pad "wide" if it + * either (a) occupies the whole width of newscr, or (b) occupies + * all but at most one column on either vertical edge of the screen + * (this caters to fussy people who put boxes around full-screen + * windows). Note that changing this formula will not break any code, + * merely change the costs of various update cases. + */ +#if USE_SCROLL_HINTS + wide = (smincol < my_len && smaxcol > (NewScreen(sp)->_maxx - my_len)); +#endif + + for (i = pminrow, m = sminrow + win->_yoffset; + i <= pmaxrow && m <= NewScreen(sp)->_maxy; + i++, m++) { + register struct ldat *nline = &NewScreen(sp)->_line[m]; + register struct ldat *oline = &win->_line[i]; + for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) { + 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); + } + } + +#if USE_SCROLL_HINTS + if (wide) { + int nind = m + displaced; + if (oline->oldindex < 0 + || nind < sminrow + || nind > smaxrow) { + nind = _NEWINDEX; + } else if (displaced) { + register struct ldat *pline = &CurScreen(sp)->_line[nind]; + for (j = 0; j <= my_len; j++) { + int k = NewScreen(sp)->_maxx - j; + if (pline->text[j] != nline->text[j] + || pline->text[k] != nline->text[k]) { + nind = _NEWINDEX; + break; + } + } + } + + nline->oldindex = nind; + } +#endif /* USE_SCROLL_HINTS */ + oline->firstchar = oline->lastchar = _NOCHANGE; + if_USE_SCROLL_HINTS(oline->oldindex = i); + } + + /* + * Clean up debris from scrolling or resizing the pad, so we do not + * accidentally pick up the index value during the next call to this + * procedure. The only rows that should have an index value are those + * that are displayed during this cycle. + */ +#if USE_SCROLL_HINTS + for (i = pminrow - 1; (i >= 0) && (win->_line[i].oldindex >= 0); i--) + win->_line[i].oldindex = _NEWINDEX; + for (i = pmaxrow + 1; (i <= win->_maxy) + && (win->_line[i].oldindex >= 0); i++) + win->_line[i].oldindex = _NEWINDEX; +#endif + + win->_begx = (NCURSES_SIZE_T) smincol; + win->_begy = (NCURSES_SIZE_T) sminrow; + + if (win->_clear) { + win->_clear = FALSE; + NewScreen(sp)->_clear = TRUE; + } + + /* + * Use the pad's current position, if it will be visible. + * If not, don't do anything; it is not an error. + */ + if (win->_leaveok == FALSE + && win->_cury >= pminrow + && win->_curx >= pmincol + && win->_cury <= pmaxrow + && win->_curx <= pmaxcol) { + NewScreen(sp)->_cury = (NCURSES_SIZE_T) (win->_cury - pminrow + + win->_begy + win->_yoffset); + NewScreen(sp)->_curx = (NCURSES_SIZE_T) (win->_curx - pmincol + + win->_begx); + } + NewScreen(sp)->_leaveok = win->_leaveok; + win->_flags &= ~_HASMOVED; + + /* + * Update our cache of the line-numbers that we displayed from the pad. + * We will use this on subsequent calls to this function to derive + * values to stuff into 'oldindex[]' -- for scrolling optimization. + */ + win->_pad._pad_y = (NCURSES_SIZE_T) pminrow; + win->_pad._pad_x = (NCURSES_SIZE_T) pmincol; + win->_pad._pad_top = (NCURSES_SIZE_T) sminrow; + win->_pad._pad_left = (NCURSES_SIZE_T) smincol; + win->_pad._pad_bottom = (NCURSES_SIZE_T) smaxrow; + win->_pad._pad_right = (NCURSES_SIZE_T) smaxcol; + + returnCode(OK); +} + +NCURSES_EXPORT(int) +pechochar(WINDOW *pad, const chtype ch) +{ + T((T_CALLED("pechochar(%p, %s)"), (void *) pad, _tracechtype(ch))); + + if (pad == NULL) + returnCode(ERR); + + if (!IS_PAD(pad)) + returnCode(wechochar(pad, ch)); + + waddch(pad, ch); + prefresh(pad, pad->_pad._pad_y, + pad->_pad._pad_x, + pad->_pad._pad_top, + pad->_pad._pad_left, + pad->_pad._pad_bottom, + pad->_pad._pad_right); + + returnCode(OK); +} diff --git a/ncurses/ncurses/base/lib_printw.c b/ncurses/ncurses/base/lib_printw.c new file mode 100644 index 0000000000..57a7b60ce7 --- /dev/null +++ b/ncurses/ncurses/base/lib_printw.c @@ -0,0 +1,170 @@ +/**************************************************************************** + * Copyright 2018-2020,2024 Thomas E. Dickey * + * Copyright 1998-2012,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + ****************************************************************************/ + +/* +** lib_printw.c +** +** The routines printw(), wprintw() and friends. +** +*/ + +#include + +MODULE_ID("$Id: lib_printw.c,v 1.30 2024/12/07 17:44:59 tom Exp $") + +NCURSES_EXPORT(int) +printw(const char *fmt, ...) +{ + va_list argp; + int code; + +#ifdef TRACE + va_list argq; + va_start(argq, fmt); + T((T_CALLED("printw(%s%s)"), + _nc_visbuf(fmt), _nc_varargs(fmt, argq))); + va_end(argq); +#endif + + va_start(argp, fmt); + code = vw_printw(stdscr, fmt, argp); + va_end(argp); + + returnCode(code); +} + +NCURSES_EXPORT(int) +wprintw(WINDOW *win, const char *fmt, ...) +{ + va_list argp; + int code; + +#ifdef TRACE + va_list argq; + va_start(argq, fmt); + T((T_CALLED("wprintw(%p,%s%s)"), + (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); + va_end(argq); +#endif + + va_start(argp, fmt); + code = vw_printw(win, fmt, argp); + va_end(argp); + + returnCode(code); +} + +NCURSES_EXPORT(int) +mvprintw(int y, int x, const char *fmt, ...) +{ + int code; + +#ifdef TRACE + va_list argq; + va_start(argq, fmt); + T((T_CALLED("mvprintw(%d,%d,%s%s)"), + y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); + va_end(argq); +#endif + + if ((code = move(y, x)) != ERR) { + va_list argp; + + va_start(argp, fmt); + code = vw_printw(stdscr, fmt, argp); + va_end(argp); + } + returnCode(code); +} + +NCURSES_EXPORT(int) +mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...) +{ + int code; + +#ifdef TRACE + va_list argq; + va_start(argq, fmt); + T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"), + y, x, (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); + va_end(argq); +#endif + + if ((code = wmove(win, y, x)) != ERR) { + va_list argp; + + va_start(argp, fmt); + code = vw_printw(win, fmt, argp); + va_end(argp); + } + returnCode(code); +} + +NCURSES_EXPORT(int) +vwprintw(WINDOW *win, const char *fmt, va_list argp) +{ + const char *buf; + int code = ERR; +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + + T((T_CALLED("vwprintw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt))); + + buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp); + if (buf != NULL) { + code = waddstr(win, buf); + } + returnCode(code); +} + +NCURSES_EXPORT(int) +vw_printw(WINDOW *win, const char *fmt, va_list argp) +{ + const char *buf; + int code = ERR; +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + + T((T_CALLED("vw_printw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt))); + + buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp); + if (buf != NULL) { + code = waddstr(win, buf); + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_redrawln.c b/ncurses/ncurses/base/lib_redrawln.c new file mode 100644 index 0000000000..cb4634bde1 --- /dev/null +++ b/ncurses/ncurses/base/lib_redrawln.c @@ -0,0 +1,91 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997 * + ****************************************************************************/ + +/* + * lib_redrawln.c + * + * The routine wredrawln(). + * + */ + +#include + +MODULE_ID("$Id: lib_redrawln.c,v 1.19 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +wredrawln(WINDOW *win, int beg, int num) +{ + int i; + int end; + size_t len; + SCREEN *sp; + + T((T_CALLED("wredrawln(%p,%d,%d)"), (void *) win, beg, num)); + + if (win == NULL) + returnCode(ERR); + + sp = _nc_screen_of(win); + + if (beg < 0) + beg = 0; + + if (touchline(win, beg, num) == ERR) + returnCode(ERR); + + if (touchline(CurScreen(sp), beg + win->_begy, num) == ERR) + returnCode(ERR); + + end = beg + num; + if (end > CurScreen(sp)->_maxy + 1 - win->_begy) + end = CurScreen(sp)->_maxy + 1 - win->_begy; + if (end > win->_maxy + 1) + end = win->_maxy + 1; + + len = (size_t) (win->_maxx + 1); + if (len > (size_t) (CurScreen(sp)->_maxx + 1 - win->_begx)) + len = (size_t) (CurScreen(sp)->_maxx + 1 - win->_begx); + len *= sizeof(CurScreen(sp)->_line[0].text[0]); + + for (i = beg; i < end; i++) { + int crow = i + win->_begy; + + memset(CurScreen(sp)->_line[crow].text + win->_begx, 0, len); + NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx crow); + } + + returnCode(OK); +} diff --git a/ncurses/ncurses/base/lib_refresh.c b/ncurses/ncurses/base/lib_refresh.c new file mode 100644 index 0000000000..ec1428b7c3 --- /dev/null +++ b/ncurses/ncurses/base/lib_refresh.c @@ -0,0 +1,310 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2010,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* + * lib_refresh.c + * + * The routines wrefresh() and wnoutrefresh(). + * + */ + +#include + +MODULE_ID("$Id: lib_refresh.c,v 1.49 2024/09/22 20:17:40 tom Exp $") + +NCURSES_EXPORT(int) +wrefresh(WINDOW *win) +{ + int code; +#if NCURSES_SP_FUNCS + SCREEN *SP_PARM = _nc_screen_of(win); +#endif + + T((T_CALLED("wrefresh(%p)"), (void *) win)); + + if (SP_PARM == NULL || win == NULL) { + code = ERR; + } else if (win == CurScreen(SP_PARM)) { + CurScreen(SP_PARM)->_clear = TRUE; + code = NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG); + } else if ((code = wnoutrefresh(win)) == OK) { + if (win->_clear) + NewScreen(SP_PARM)->_clear = TRUE; + code = NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG); + /* + * Reset the clearok() flag in case it was set for the special + * case in hardscroll.c (if we don't reset it here, we'll get 2 + * refreshes because the flag is copied from stdscr to newscr). + * Resetting the flag shouldn't do any harm, anyway. + */ + win->_clear = FALSE; + } + returnCode(code); +} + +NCURSES_EXPORT(int) +wnoutrefresh(WINDOW *win) +{ + int limit_x; + int src_row, src_col; + int begx; + int begy; + int dst_row, dst_col; +#if USE_SCROLL_HINTS + bool wide; +#endif +#if NCURSES_SP_FUNCS + SCREEN *SP_PARM = _nc_screen_of(win); +#endif + + T((T_CALLED("wnoutrefresh(%p)"), (void *) win)); + + if (SP_PARM == NULL || win == NULL) + returnCode(ERR); + + /* + * Handle pads as a special case. + */ + if (IS_PAD(win)) { + returnCode(pnoutrefresh(win, + win->_pad._pad_y, + win->_pad._pad_x, + win->_pad._pad_top, + win->_pad._pad_left, + win->_pad._pad_bottom, + win->_pad._pad_right)); + } +#ifdef TRACE + if (USE_TRACEF(TRACE_UPDATE)) { + _tracedump("...win", win); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + + /* put them here so "win == 0" won't break our code */ + begx = win->_begx; + begy = win->_begy; + + NewScreen(SP_PARM)->_nc_bkgd = win->_nc_bkgd; + WINDOW_ATTRS(NewScreen(SP_PARM)) = WINDOW_ATTRS(win); + + /* merge in change information from all subwindows of this window */ + wsyncdown(win); + +#if USE_SCROLL_HINTS + /* + * For pure efficiency, we'd want to transfer scrolling information + * from the window to newscr whenever the window is wide enough that + * its update will dominate the cost of the update for the horizontal + * band of newscr that it occupies. Unfortunately, this threshold + * tends to be complex to estimate, and in any case scrolling the + * whole band and rewriting the parts outside win's image would look + * really ugly. So. What we do is consider the window "wide" if it + * either (a) occupies the whole width of newscr, or (b) occupies + * all but at most one column on either vertical edge of the screen + * (this caters to fussy people who put boxes around full-screen + * windows). Note that changing this formula will not break any code, + * merely change the costs of various update cases. + */ + wide = (begx <= 1 && win->_maxx >= (NewScreen(SP_PARM)->_maxx - 1)); +#endif + + win->_flags &= ~_HASMOVED; + + /* + * Microtweaking alert! This double loop is one of the genuine + * hot spots in the code. Even gcc doesn't seem to do enough + * common-subexpression chunking to make it really tense, + * so we'll force the issue. + */ + + /* limit(dst_col) */ + limit_x = win->_maxx; + /* limit(src_col) */ + if (limit_x > NewScreen(SP_PARM)->_maxx - begx) + limit_x = NewScreen(SP_PARM)->_maxx - begx; + + for (src_row = 0, dst_row = begy + win->_yoffset; + src_row <= win->_maxy && dst_row <= NewScreen(SP_PARM)->_maxy; + src_row++, dst_row++) { + struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]); + struct ldat *oline = &win->_line[src_row]; + + if (oline->firstchar != _NOCHANGE) { + 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({ + 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_WIDEC({ + int last_dst = begx + ((last_src < win->_maxx) + ? last_src + : win->_maxx); + int fix_left = dst_col; + int fix_right = last_dst; + int j; + + /* + * 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 <= NewScreen(SP_PARM)->_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) { + static cchar_t blank = BLANK; + 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); + } + } + + } +#if USE_SCROLL_HINTS + if (wide) { + int oind = oline->oldindex; + + nline->oldindex = ((oind == _NEWINDEX) + ? _NEWINDEX + : (begy + oind + win->_yoffset)); + } +#endif /* USE_SCROLL_HINTS */ + + oline->firstchar = oline->lastchar = _NOCHANGE; + if_USE_SCROLL_HINTS(oline->oldindex = src_row); + } + + if (win->_clear) { + win->_clear = FALSE; + NewScreen(SP_PARM)->_clear = TRUE; + } + + if (!win->_leaveok) { + NewScreen(SP_PARM)->_cury = (NCURSES_SIZE_T) (win->_cury + + win->_begy + win->_yoffset); + NewScreen(SP_PARM)->_curx = (NCURSES_SIZE_T) (win->_curx + win->_begx); + } + NewScreen(SP_PARM)->_leaveok = win->_leaveok; + +#ifdef TRACE + if (USE_TRACEF(TRACE_UPDATE)) { + _tracedump("newscr", NewScreen(SP_PARM)); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + returnCode(OK); +} diff --git a/ncurses/ncurses/base/lib_restart.c b/ncurses/ncurses/base/lib_restart.c new file mode 100644 index 0000000000..78f7a05fd7 --- /dev/null +++ b/ncurses/ncurses/base/lib_restart.c @@ -0,0 +1,118 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2012,2015 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2008 * + ****************************************************************************/ + +/* + * Terminfo-only terminal setup routines: + * + * int restartterm(const char *, int, int *) + */ + +#include + +MODULE_ID("$Id: lib_restart.c,v 1.21 2025/12/27 12:41:23 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx + NCURSES_CONST char *termp, + int filenum, + int *errret) +{ + int result; +#if USE_TERM_DRIVER + TERMINAL *new_term = NULL; +#endif + + START_TRACE(); + T((T_CALLED("restartterm(%p,%s,%d,%p)"), + (void *) SP_PARM, + termp, + filenum, + (void *) errret)); + + if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) { + result = ERR; + } else if (SP_PARM != NULL) { + TTY_FLAGS save_flags = SP_PARM->_tty_flags; + +#if USE_TERM_DRIVER + SP_PARM->_term = new_term; +#endif + if (save_flags._echo) { + NCURSES_SP_NAME(echo) (NCURSES_SP_ARG); + } else { + NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); + } + + if (save_flags._cbreak) { + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); + } else if (save_flags._raw) { + NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); + NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); + } else { + NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); + } + if (save_flags._nl) { + NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); + } else { + NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG); + } + + NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG); + +#if USE_SIZECHANGE + _nc_update_screensize(SP_PARM); +#endif + + result = OK; + } else { + result = ERR; + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +restartterm(NCURSES_CONST char *termp, int filenum, int *errret) +{ + START_TRACE(); + return NCURSES_SP_NAME(restartterm) (CURRENT_SCREEN, termp, filenum, errret); +} +#endif diff --git a/ncurses/ncurses/base/lib_scanw.c b/ncurses/ncurses/base/lib_scanw.c new file mode 100644 index 0000000000..49580753bb --- /dev/null +++ b/ncurses/ncurses/base/lib_scanw.c @@ -0,0 +1,129 @@ +/**************************************************************************** + * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 1998-2009,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_scanw.c +** +** The routines scanw(), wscanw() and friends. +** +*/ + +#include + +MODULE_ID("$Id: lib_scanw.c,v 1.19 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +vwscanw(WINDOW *win, const char *fmt, va_list argp) +{ + char buf[BUFSIZ]; + int code = ERR; + + if (wgetnstr(win, buf, (int) sizeof(buf) - 1) != ERR) { + if ((code = vsscanf(buf, fmt, argp)) == EOF) { + code = ERR; + } + } + + return code; +} + +NCURSES_EXPORT(int) +vw_scanw(WINDOW *win, const char *fmt, va_list argp) +{ + char buf[BUFSIZ]; + int code = ERR; + + if (wgetnstr(win, buf, (int) sizeof(buf) - 1) != ERR) { + if ((code = vsscanf(buf, fmt, argp)) == EOF) { + code = ERR; + } + } + + return code; +} + +NCURSES_EXPORT(int) +scanw(const char *fmt, ...) +{ + int code; + va_list ap; + + T(("scanw(\"%s\",...) called", fmt)); + + va_start(ap, fmt); + code = vw_scanw(stdscr, fmt, ap); + va_end(ap); + return (code); +} + +NCURSES_EXPORT(int) +wscanw(WINDOW *win, const char *fmt, ...) +{ + int code; + va_list ap; + + T(("wscanw(%p,\"%s\",...) called", (void *) win, fmt)); + + va_start(ap, fmt); + code = vw_scanw(win, fmt, ap); + va_end(ap); + return (code); +} + +NCURSES_EXPORT(int) +mvscanw(int y, int x, const char *fmt, ...) +{ + int code; + va_list ap; + + va_start(ap, fmt); + code = (move(y, x) == OK) ? vw_scanw(stdscr, fmt, ap) : ERR; + va_end(ap); + return (code); +} + +NCURSES_EXPORT(int) +mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...) +{ + int code; + va_list ap; + + va_start(ap, fmt); + code = (wmove(win, y, x) == OK) ? vw_scanw(win, fmt, ap) : ERR; + va_end(ap); + return (code); +} diff --git a/ncurses/ncurses/base/lib_screen.c b/ncurses/ncurses/base/lib_screen.c new file mode 100644 index 0000000000..e250e2e4e2 --- /dev/null +++ b/ncurses/ncurses/base/lib_screen.c @@ -0,0 +1,1089 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2017,2018 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996 on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +#include + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_screen.c,v 1.113 2025/12/27 12:28:45 tom Exp $") + +#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */ + +#define MARKER '\\' +#define APPEND '+' +#define GUTTER '|' +#define L_CURL '{' +#define R_CURL '}' + +#if USE_STRING_HACKS && HAVE_SNPRINTF +#define ARG_SLIMIT(name) size_t name, +#else +#define ARG_SLIMIT(name) /* nothing */ +#endif + +#define CUR_SLIMIT _nc_SLIMIT(limit - (size_t) (target + 1 - base)) +#define TOP_SLIMIT _nc_SLIMIT(sizeof(buffer)) + +/* + * Use 0x888888 as the magic number for new-format files, since it cannot be + * mistaken for the _cury/_curx pair of 16-bit numbers which start the old + * format. It happens to be unused in the file 5.22 database (2015/03/07). + */ +static const char my_magic[] = +{'\210', '\210', '\210', '\210', 0}; + +#if NCURSES_EXT_PUTWIN +typedef enum { + pINT /* int */ + ,pSHORT /* short */ + ,pBOOL /* bool */ + ,pATTR /* attr_t */ + ,pCHAR /* chtype */ + ,pSIZE /* NCURSES_SIZE_T */ +#if NCURSES_WIDECHAR + ,pCCHAR /* cchar_t */ +#endif +} PARAM_TYPE; + +typedef struct { + const char name[11]; + attr_t attr; +} SCR_ATTRS; + +typedef struct { + const char name[17]; + PARAM_TYPE type; + size_t offset; +} SCR_PARAMS; + +#define DATA(name) { { #name }, A_##name } +static const SCR_ATTRS scr_attrs[] = +{ + DATA(NORMAL), + DATA(STANDOUT), + DATA(UNDERLINE), + DATA(REVERSE), + DATA(BLINK), + DATA(DIM), + DATA(BOLD), + DATA(ALTCHARSET), + DATA(INVIS), + DATA(PROTECT), + DATA(HORIZONTAL), + DATA(LEFT), + DATA(LOW), + DATA(RIGHT), + DATA(TOP), + DATA(VERTICAL), + +#ifdef A_ITALIC + DATA(ITALIC), +#endif +}; +#undef DATA + +#define DATA(name, type) { { #name }, type, offsetof(WINDOW, name) } + +static const SCR_PARAMS scr_params[] = +{ + DATA(_cury, pSIZE), + DATA(_curx, pSIZE), + DATA(_maxy, pSIZE), + DATA(_maxx, pSIZE), + DATA(_begy, pSIZE), + DATA(_begx, pSIZE), + DATA(_flags, pSHORT), + DATA(_attrs, pATTR), + DATA(_bkgd, pCHAR), + DATA(_notimeout, pBOOL), + DATA(_clear, pBOOL), + DATA(_leaveok, pBOOL), + DATA(_scroll, pBOOL), + DATA(_idlok, pBOOL), + DATA(_idcok, pBOOL), + DATA(_immed, pBOOL), + DATA(_sync, pBOOL), + DATA(_use_keypad, pBOOL), + DATA(_delay, pINT), + DATA(_regtop, pSIZE), + DATA(_regbottom, pSIZE), + DATA(_pad._pad_y, pSIZE), + DATA(_pad._pad_x, pSIZE), + DATA(_pad._pad_top, pSIZE), + DATA(_pad._pad_left, pSIZE), + DATA(_pad._pad_bottom, pSIZE), + DATA(_pad._pad_right, pSIZE), + DATA(_yoffset, pSIZE), +#if NCURSES_WIDECHAR + DATA(_bkgrnd, pCCHAR), +#if NCURSES_EXT_COLORS + DATA(_color, pINT), +#endif +#endif +}; +#undef DATA + +static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); + +/* + * Allocate and read a line of text. Caller must free it. + */ +static char * +read_txt(FILE *fp) +{ + size_t limit = 1024; + char *result = malloc(limit); + char *buffer; + + if (result != NULL) { + int ch = 0; + size_t used = 0; + + clearerr(fp); + result[used] = '\0'; + do { + if (used + 2 >= limit) { + limit += 1024; + buffer = realloc(result, limit); + if (buffer == NULL) { + free(result); + result = NULL; + break; + } + result = buffer; + } + ch = fgetc(fp); + if (ch == EOF) + break; + result[used++] = (char) ch; + result[used] = '\0'; + } while (ch != '\n'); + + if (ch == '\n') { + result[--used] = '\0'; + TR(TRACE_IEVENT, ("READ:%s", result)); + } else if (used == 0) { + free(result); + result = NULL; + } + } + return result; +} + +static char * +decode_attr(char *source, attr_t *target, int *color) +{ + bool found = FALSE; + + TR(TRACE_IEVENT, ("decode_attr '%s'", source)); + + while (*source) { + if (source[0] == MARKER && source[1] == L_CURL) { + source += 2; + found = TRUE; + } else if (source[0] == R_CURL) { + source++; + found = FALSE; + } else if (found) { + char *next = source; + + if (source[0] == GUTTER) { + ++next; + } else if (*next == 'C') { + int value = 0; + unsigned pair; + next++; + while (isdigit(UChar(*next))) { + value = value * 10 + (*next++ - '0'); + } + *target &= ~A_COLOR; + pair = (unsigned) ((value > 256) + ? COLOR_PAIR(255) + : COLOR_PAIR(value)); + *target |= pair; + *color = value; + } else { + size_t n; + + while (isalnum(UChar(*next))) { + ++next; + } + for (n = 0; n < SIZEOF(scr_attrs); ++n) { + if ((size_t) (next - source) == strlen(scr_attrs[n].name)) { + if (scr_attrs[n].attr) { + *target |= scr_attrs[n].attr; + } else { + *target = A_NORMAL; + } + break; + } + } + } + source = next; + } else { + break; + } + } + return source; +} + +static char * +decode_char(char *source, int *target) +{ + int limit = 0; + int base = 16; + const char digits[] = "0123456789abcdef"; + + TR(TRACE_IEVENT, ("decode_char '%s'", source)); + *target = ' '; + switch (*source) { + case MARKER: + switch (*++source) { + case APPEND: + break; + case MARKER: + *target = MARKER; + ++source; + break; + case 's': + *target = ' '; + ++source; + break; + case '0': + case '1': + case '2': + case '3': + base = 8; + limit = 3; + break; + case 'u': + limit = 4; + ++source; + break; + case 'U': + limit = 8; + ++source; + break; + } + if (limit) { + *target = 0; + while (limit-- > 0) { + const char *find = strchr(digits, *source++); + int ch = (find != NULL) ? (int) (find - digits) : -1; + *target *= base; + if (ch >= 0 && ch < base) { + *target += ch; + } + } + } + break; + default: + *target = *source++; + break; + } + return source; +} + +static char * +decode_chtype(char *source, chtype fillin, chtype *target) +{ + attr_t attr = ChAttrOf(fillin); + int color = PAIR_NUMBER((int) attr); + int value; + + TR(TRACE_IEVENT, ("decode_chtype '%s'", source)); + source = decode_attr(source, &attr, &color); + source = decode_char(source, &value); + *target = (ChCharOf(value) | attr | (chtype) COLOR_PAIR(color)); + /* FIXME - ignore combining characters */ + return source; +} + +#if NCURSES_WIDECHAR +static char * +decode_cchar(char *source, const cchar_t *fillin, cchar_t *target) +{ + int color; + attr_t attr = fillin->attr; + wchar_t chars[CCHARW_MAX]; + int append = 0; + int value = 0; + + TR(TRACE_IEVENT, ("decode_cchar '%s'", source)); + *target = blank; +#if NCURSES_EXT_COLORS + color = fillin->ext_color; +#else + color = (int) PAIR_NUMBER(attr); +#endif + source = decode_attr(source, &attr, &color); + memset(chars, 0, sizeof(chars)); + source = decode_char(source, &value); + chars[0] = (wchar_t) value; + /* handle combining characters */ + while (source[0] == MARKER && source[1] == APPEND) { + source += 2; + source = decode_char(source, &value); + if (++append < CCHARW_MAX) { + chars[append] = (wchar_t) value; + } + } + setcchar(target, chars, attr, (short) color, &color); + return source; +} +#endif + +static int +read_win(WINDOW *win, FILE *fp) +{ + int code = ERR; + size_t n; + int color; +#if NCURSES_WIDECHAR + NCURSES_CH_T prior; +#endif + chtype prior2; + + memset(win, 0, sizeof(WINDOW)); + for (;;) { + const char *name; + char *value; + char *txt = read_txt(fp); + + if (txt == NULL) + break; + if (!strcmp(txt, "rows:")) { + free(txt); + code = OK; + break; + } + if ((value = strchr(txt, '=')) == NULL) { + free(txt); + continue; + } + *value++ = '\0'; + name = !strcmp(txt, "flag") ? value : txt; + for (n = 0; n < SIZEOF(scr_params); ++n) { + if (!strcmp(name, scr_params[n].name)) { + void *data = (void *) ((char *) win + scr_params[n].offset); + + switch (scr_params[n].type) { + case pATTR: + (void) decode_attr(value, data, &color); + break; + case pBOOL: + *(bool *) data = TRUE; + break; + case pCHAR: + prior2 = ' '; + decode_chtype(value, prior2, data); + break; + case pINT: + *(int *) data = atoi(value); + break; + case pSHORT: + *(short *) data = (short) atoi(value); + break; + case pSIZE: + *(NCURSES_SIZE_T *) data = (NCURSES_SIZE_T) atoi(value); + break; +#if NCURSES_WIDECHAR + case pCCHAR: + prior = blank; + decode_cchar(value, &prior, data); + break; +#endif + } + break; + } + } + free(txt); + } + return code; +} + +static int +read_row(char *source, NCURSES_CH_T *prior, NCURSES_CH_T *target, int length) +{ + while (*source != '\0' && length > 0) { +#if NCURSES_WIDECHAR + int len; + + source = decode_cchar(source, prior, target); + len = _nc_wacs_width(target->chars[0]); + if (len > 1) { + int n; + + SetWidecExt(CHDEREF(target), 0); + for (n = 1; n < len; ++n) { + target[n] = target[0]; + SetWidecExt(CHDEREF(target), n); + } + target += (len - 1); + length -= (len - 1); + } +#else + source = decode_chtype(source, *prior, target); +#endif + *prior = *target; + ++target; + --length; + } + while (length-- > 0) { + *target++ = blank; + } + /* FIXME - see what error conditions should apply if I need to return ERR */ + return 0; +} +#endif /* NCURSES_EXT_PUTWIN */ + +/* + * Originally, getwin/putwin used fread/fwrite, because they used binary data. + * The new format uses printable ASCII, which does not have as predictable + * sizes. Consequently, we use buffered I/O, e.g., fgetc/fprintf, which need + * special handling if we want to read screen dumps from an older library. + */ +static int +read_block(void *target, size_t length, FILE *fp) +{ + int result = 0; + char *buffer = target; + + clearerr(fp); + while (length-- != 0) { + int ch = fgetc(fp); + if (ch == EOF) { + result = -1; + break; + } + *buffer++ = (char) ch; + } + return result; +} + +NCURSES_EXPORT(WINDOW *) +NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep) +{ + WINDOW tmp, *nwin; + bool old_format = FALSE; + + T((T_CALLED("getwin(%p)"), (void *) filep)); + + if (filep == NULL) { + returnWin(NULL); + } + + /* + * Read the first 4 bytes to determine first if this is an old-format + * screen-dump, or new-format. + */ + if (read_block(&tmp, (size_t) 4, filep) < 0) { + returnWin(NULL); + } + /* + * If this is a new-format file, and we do not support it, give up. + */ + if (!memcmp(&tmp, my_magic, (size_t) 4)) { +#if NCURSES_EXT_PUTWIN + if (read_win(&tmp, filep) < 0) +#endif + returnWin(NULL); + } else if (read_block(((char *) &tmp) + 4, sizeof(WINDOW) - 4, filep) < 0) { + returnWin(NULL); + } else { + old_format = TRUE; + } + + /* + * Check the window-size: + */ + if (tmp._maxy == 0 || + tmp._maxy > MAX_SIZE || + tmp._maxx == 0 || + tmp._maxx > MAX_SIZE) { + returnWin(NULL); + } + + if (IS_PAD(&tmp)) { + nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx + tmp._maxy + 1, + tmp._maxx + 1); + } else { + nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx + 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. + */ + if (nwin != NULL) { + int n; + size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1); + + 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 (IS_PAD(&tmp)) + nwin->_pad = tmp._pad; + + if (old_format) { + T(("reading old-format screen dump")); + for (n = 0; n <= nwin->_maxy; n++) { + if (read_block(nwin->_line[n].text, linesize, filep) < 0) { + delwin(nwin); + returnWin(NULL); + } + } + } +#if NCURSES_EXT_PUTWIN + else { + char *txt = NULL; + bool success = TRUE; + NCURSES_CH_T prior = blank; + + T(("reading new-format screen dump")); + for (n = 0; n <= nwin->_maxy; n++) { + long row; + char *next; + + if ((txt = read_txt(filep)) == NULL) { + T(("...failed to read string for row %d", n + 1)); + success = FALSE; + break; + } + row = strtol(txt, &next, 10); + if (row != (n + 1) || *next != ':') { + T(("...failed to read row-number %d", n + 1)); + success = FALSE; + break; + } + + if (read_row(++next, &prior, nwin->_line[n].text, tmp._maxx + + 1) < 0) { + T(("...failed to read cells for row %d", n + 1)); + success = FALSE; + break; + } + free(txt); + txt = NULL; + } + + if (!success) { + free(txt); + delwin(nwin); + returnWin(NULL); + } + } +#endif + touchwin(nwin); + } + returnWin(nwin); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(WINDOW *) +getwin(FILE *filep) +{ + return NCURSES_SP_NAME(getwin) (CURRENT_SCREEN, filep); +} +#endif + +#if NCURSES_EXT_PUTWIN +static void +encode_attr(char *target, ARG_SLIMIT(limit) + attr_t source, + attr_t prior, + int source_color, + int prior_color) +{ +#if USE_STRING_HACKS && HAVE_SNPRINTF + char *base = target; +#endif + source &= ~A_CHARTEXT; + prior &= ~A_CHARTEXT; + + *target = '\0'; + if ((source != prior) || (source_color != prior_color)) { + size_t n; + bool first = TRUE; + + *target++ = MARKER; + *target++ = L_CURL; + + for (n = 0; n < SIZEOF(scr_attrs); ++n) { + if ((source & scr_attrs[n].attr) != 0 || + ((source & ALL_BUT_COLOR) == 0 && + (scr_attrs[n].attr == A_NORMAL))) { + if (first) { + first = FALSE; + } else { + *target++ = '|'; + } + _nc_STRCPY(target, scr_attrs[n].name, limit); + target += strlen(target); + } + } + if (source_color != prior_color) { + if (!first) + *target++ = '|'; + _nc_SPRINTF(target, CUR_SLIMIT "C%d", source_color); + target += strlen(target); + } + + *target++ = R_CURL; + *target = '\0'; + } +} + +static void +encode_cell(char *target, ARG_SLIMIT(limit) CARG_CH_T source, CARG_CH_T previous) +{ +#if USE_STRING_HACKS && HAVE_SNPRINTF + char *base = target; +#endif +#if NCURSES_WIDECHAR + size_t n; + int source_pair = GetPair(*source); + int previous_pair = GetPair(*previous); + + *target = '\0'; + if ((previous->attr != source->attr) || (previous_pair != source_pair)) { + encode_attr(target, CUR_SLIMIT + source->attr, + previous->attr, + source_pair, + previous_pair); + } + target += strlen(target); +#if NCURSES_EXT_COLORS + if (previous->ext_color != source->ext_color) { + _nc_SPRINTF(target, CUR_SLIMIT + "%c%cC%d%c", MARKER, L_CURL, source->ext_color, R_CURL); + } +#endif + for (n = 0; n < SIZEOF(source->chars); ++n) { + unsigned uch = (unsigned) source->chars[n]; + if (uch == 0) + continue; + if (n) { + *target++ = MARKER; + *target++ = APPEND; + } + *target++ = MARKER; + if (uch > 0xffff) { + _nc_SPRINTF(target, CUR_SLIMIT "U%08x", uch); + } else if (uch > 0xff) { + _nc_SPRINTF(target, CUR_SLIMIT "u%04x", uch); + } else if (uch < 32 || uch >= 127) { + _nc_SPRINTF(target, CUR_SLIMIT "%03o", uch & 0xff); + } else { + switch (uch) { + case ' ': + _nc_STRCPY(target, "s", limit); + break; + case MARKER: + *target++ = MARKER; + *target = '\0'; + break; + default: + --target; + _nc_SPRINTF(target, CUR_SLIMIT "%c", uch); + break; + } + } + target += strlen(target); + } +#else + chtype ch = CharOfD(source); + + *target = '\0'; + if (AttrOfD(previous) != AttrOfD(source)) { + encode_attr(target, CUR_SLIMIT + AttrOfD(source), + AttrOfD(previous), + GetPair(source), + GetPair(previous)); + } + target += strlen(target); + *target++ = MARKER; + if (ch < 32 || ch >= 127) { + _nc_SPRINTF(target, CUR_SLIMIT "%03o", UChar(ch)); + } else { + switch (ch) { + case ' ': + _nc_STRCPY(target, "s", limit); + break; + case MARKER: + *target++ = MARKER; + *target = '\0'; + break; + default: + --target; + _nc_SPRINTF(target, CUR_SLIMIT "%c", UChar(ch)); + break; + } + } +#endif +} +#endif + +NCURSES_EXPORT(int) +putwin(WINDOW *win, FILE *filep) +{ + int code = ERR; + + T((T_CALLED("putwin(%p,%p)"), (void *) win, (void *) filep)); + +#if NCURSES_EXT_PUTWIN + if (win != NULL) { + const char *version = curses_version(); + char buffer[1024]; + NCURSES_CH_T last_cell; + int y; + + memset(&last_cell, 0, sizeof(last_cell)); + + clearerr(filep); + + /* + * Our magic number is technically nonprinting, but aside from that, + * all of the file is printable ASCII. + */ +#define PUTS(s) if (fputs(s, filep) == EOF || ferror(filep)) returnCode(code) + PUTS(my_magic); + PUTS(version); + PUTS("\n"); + for (y = 0; y < (int) SIZEOF(scr_params); ++y) { + const char *name = scr_params[y].name; + const char *data = (char *) win + scr_params[y].offset; + const void *dp = (const void *) data; + attr_t attr; + + *buffer = '\0'; + if (!strncmp(name, "_pad.", (size_t) 5) && !IS_PAD(win)) { + continue; + } + switch (scr_params[y].type) { + case pATTR: + attr = (*(const attr_t *) dp) & ~A_CHARTEXT; + encode_attr(buffer, TOP_SLIMIT + (*(const attr_t *) dp) & ~A_CHARTEXT, + A_NORMAL, + COLOR_PAIR((int) attr), + 0); + break; + case pBOOL: + if (!(*(const bool *) data)) { + continue; + } + _nc_STRCPY(buffer, name, sizeof(buffer)); + name = "flag"; + break; + case pCHAR: + attr = (*(const attr_t *) dp); + encode_attr(buffer, TOP_SLIMIT + * (const attr_t *) dp, + A_NORMAL, + COLOR_PAIR((int) attr), + 0); + break; + case pINT: + if (!(*(const int *) dp)) + continue; + _nc_SPRINTF(buffer, TOP_SLIMIT + "%d", *(const int *) dp); + break; + case pSHORT: + if (!(*(const short *) dp)) + continue; + _nc_SPRINTF(buffer, TOP_SLIMIT + "%d", *(const short *) dp); + break; + case pSIZE: + if (!(*(const NCURSES_SIZE_T *) dp)) + continue; + _nc_SPRINTF(buffer, TOP_SLIMIT + "%d", *(const NCURSES_SIZE_T *) dp); + break; +#if NCURSES_WIDECHAR + case pCCHAR: + encode_cell(buffer, TOP_SLIMIT + (CARG_CH_T) dp, CHREF(last_cell)); + break; +#endif + } + /* + * Only write non-default data. + */ + if (*buffer != '\0') { + if (fprintf(filep, "%s=%s\n", name, buffer) <= 0 + || ferror(filep)) + returnCode(code); + } + } + /* Write row-data */ + fprintf(filep, "rows:\n"); + for (y = 0; y <= win->_maxy; y++) { + NCURSES_CH_T *data = win->_line[y].text; + int x; + if (fprintf(filep, "%d:", y + 1) <= 0 + || ferror(filep)) + returnCode(code); + for (x = 0; x <= win->_maxx; x++) { +#if NCURSES_WIDECHAR + int len = _nc_wacs_width(data[x].chars[0]); + encode_cell(buffer, TOP_SLIMIT CHREF(data[x]), CHREF(last_cell)); + last_cell = data[x]; + PUTS(buffer); + if (len > 1) + x += (len - 1); +#else + encode_cell(buffer, TOP_SLIMIT CHREF(data[x]), CHREF(last_cell)); + last_cell = data[x]; + PUTS(buffer); +#endif + } + PUTS("\n"); + } + code = OK; + } +#else + /* + * This is the original putwin(): + * A straight binary dump is simple, but its format can depend on whether + * ncurses is compiled with wide-character support, and also may depend + * on the version of ncurses, e.g., if the WINDOW structure is extended. + */ + if (win != NULL) { + size_t len = (size_t) (win->_maxx + 1); + int y; + + clearerr(filep); + if (fwrite(win, sizeof(WINDOW), (size_t) 1, filep) != 1 + || ferror(filep)) + returnCode(code); + + for (y = 0; y <= win->_maxy; y++) { + if (fwrite(win->_line[y].text, + sizeof(NCURSES_CH_T), len, filep) != len + || ferror(filep)) { + returnCode(code); + } + } + code = OK; + } +#endif + returnCode(code); +} + +/* + * Replace a window covering the whole screen, i.e., newscr or curscr. + */ +static WINDOW * +replace_window(const WINDOW *target, FILE *source) +{ + WINDOW *result = getwin(source); +#if NCURSES_EXT_FUNCS + if (result != NULL) { + if (getmaxx(result) != getmaxx(target) + || getmaxy(result) != getmaxy(target)) { + int code = wresize(result, + 1 + getmaxy(target), + 1 + getmaxx(target)); + if (code != OK) { + delwin(result); + result = NULL; + } + } + } +#endif + return result; +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file) +{ + FILE *fp = NULL; + int code = ERR; + + T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file))); + + if (SP_PARM != NULL + && _nc_access(file, R_OK) >= 0 + && (fp = safe_fopen(file, BIN_R)) != NULL) { + WINDOW *my_newscr = replace_window(NewScreen(SP_PARM), fp); + (void) fclose(fp); + if (my_newscr != NULL) { + delwin(NewScreen(SP_PARM)); + NewScreen(SP_PARM) = my_newscr; +#if !USE_REENTRANT + newscr = my_newscr; +#endif + code = OK; + } + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +scr_restore(const char *file) +{ + return NCURSES_SP_NAME(scr_restore) (CURRENT_SCREEN, file); +} +#endif + +NCURSES_EXPORT(int) +scr_dump(const char *file) +{ + int result; + FILE *fp = NULL; + + T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file))); + + if (_nc_access(file, W_OK) < 0 + || (fp = safe_fopen(file, BIN_W)) == NULL) { + result = ERR; + } else { + (void) putwin(newscr, fp); + (void) fclose(fp); + result = OK; + } + returnCode(result); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(scr_init) (NCURSES_SP_DCLx const char *file) +{ + int code = ERR; + + T((T_CALLED("scr_init(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file))); + + if (SP_PARM != NULL && +#if USE_TERM_DRIVER + InfoOf(SP_PARM).caninit +#else + !(exit_ca_mode && non_rev_rmcup) +#endif + ) { + FILE *fp = NULL; + + if (_nc_access(file, R_OK) >= 0 + && (fp = safe_fopen(file, BIN_R)) != NULL) { + WINDOW *my_curscr = replace_window(CurScreen(SP_PARM), fp); + (void) fclose(fp); + if (my_curscr != NULL) { + delwin(CurScreen(SP_PARM)); + CurScreen(SP_PARM) = my_curscr; +#if !USE_REENTRANT + curscr = my_curscr; +#endif + code = OK; + } + } + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +scr_init(const char *file) +{ + return NCURSES_SP_NAME(scr_init) (CURRENT_SCREEN, file); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file) +{ + int code = ERR; + + T((T_CALLED("scr_set(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file))); + + if (SP_PARM != NULL + && NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == OK) { + delwin(NewScreen(SP_PARM)); + NewScreen(SP_PARM) = dupwin(curscr); +#if !USE_REENTRANT + newscr = NewScreen(SP_PARM); +#endif + if (NewScreen(SP_PARM) != NULL) { + code = OK; + } + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +scr_set(const char *file) +{ + return NCURSES_SP_NAME(scr_set) (CURRENT_SCREEN, file); +} +#endif diff --git a/ncurses/ncurses/base/lib_scroll.c b/ncurses/ncurses/base/lib_scroll.c new file mode 100644 index 0000000000..428fe5a1dc --- /dev/null +++ b/ncurses/ncurses/base/lib_scroll.c @@ -0,0 +1,156 @@ +/**************************************************************************** + * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 1998-2010,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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-2003 * + * and: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_scroll.c +** +** The routine wscrl(win, n). +** positive n scroll the window up (ie. move lines down) +** negative n scroll the window down (ie. move lines up) +** +*/ + +#include + +MODULE_ID("$Id: lib_scroll.c,v 1.32 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(void) +_nc_scroll_window(WINDOW *win, + int const n, + int const top, + int const bottom, + NCURSES_CH_T blank) +{ + int limit; + int line; + int j; + size_t to_copy = (sizeof(NCURSES_CH_T) * (size_t) (win->_maxx + 1)); + + TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %ld, %ld)", + (void *) 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. + * That (a) doesn't work when the window is derived and doesn't have + * its own storage, (b) doesn't save you a lot on modern machines + * anyway. Your typical memcpy implementations are coded in + * assembler using a tight BLT loop; for the size of copies we're + * talking here, the total execution time is dominated by the one-time + * setup cost. So there is no point in trying to be excessively + * clever -- esr. + */ +#define BottomLimit(n) ((n) >= 0 && (n) >= top) +#define TopLimit(n) ((n) <= win->_maxy && (n) <= bottom) + + /* shift n lines downwards */ + if (n < 0) { + limit = top - n; + for (line = bottom; line >= limit && BottomLimit(line); 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); + } + for (line = top; line < limit && TopLimit(line); 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); + } + } + + /* shift n lines upwards */ + if (n > 0) { + limit = bottom - n; + for (line = top; line <= limit && TopLimit(line); 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 > limit && BottomLimit(line); 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) +wscrl(WINDOW *win, int n) +{ + T((T_CALLED("wscrl(%p,%d)"), (void *) win, n)); + + if (!win || !win->_scroll) { + TR(TRACE_MOVE, ("...scrollok is false")); + returnCode(ERR); + } + + if (n != 0) { + _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd); + _nc_synchook(win); + } + returnCode(OK); +} diff --git a/ncurses/ncurses/base/lib_scrollok.c b/ncurses/ncurses/base/lib_scrollok.c new file mode 100644 index 0000000000..a4a947600a --- /dev/null +++ b/ncurses/ncurses/base/lib_scrollok.c @@ -0,0 +1,59 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_scrollok.c +** +** The routine scrollok. +** +*/ + +#include + +MODULE_ID("$Id: lib_scrollok.c,v 1.6 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +scrollok(WINDOW *win, bool flag) +{ + T((T_CALLED("scrollok(%p,%d)"), (void *) win, flag)); + + if (win) { + win->_scroll = flag; + returnCode(OK); + } else + returnCode(ERR); +} diff --git a/ncurses/ncurses/base/lib_scrreg.c b/ncurses/ncurses/base/lib_scrreg.c new file mode 100644 index 0000000000..1a8680362d --- /dev/null +++ b/ncurses/ncurses/base/lib_scrreg.c @@ -0,0 +1,64 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_scrreg.c +** +** The routine wsetscrreg(). +** +*/ + +#include + +MODULE_ID("$Id: lib_scrreg.c,v 1.12 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +wsetscrreg(WINDOW *win, int top, int bottom) +{ + T((T_CALLED("wsetscrreg(%p,%d,%d)"), (void *) win, top, bottom)); + + if (win && + top >= 0 && top <= win->_maxy && + bottom >= 0 && bottom <= win->_maxy && + bottom > top) { + win->_regtop = (NCURSES_SIZE_T) top; + win->_regbottom = (NCURSES_SIZE_T) bottom; + + returnCode(OK); + } else + returnCode(ERR); +} diff --git a/ncurses/ncurses/base/lib_set_term.c b/ncurses/ncurses/base/lib_set_term.c new file mode 100644 index 0000000000..11cc16163d --- /dev/null +++ b/ncurses/ncurses/base/lib_set_term.c @@ -0,0 +1,877 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_set_term.c +** +** The routine set_term(). +** +*/ + +#define NEW_PAIR_INTERNAL 1 + +#include +#include +#include + +#if USE_GPM_SUPPORT +#ifdef HAVE_LIBDL +/* use dynamic loader to avoid linkage dependency */ +#include +#endif +#endif + +#undef CUR +#define CUR SP_TERMTYPE + +MODULE_ID("$Id: lib_set_term.c,v 1.199 2025/12/27 12:28:45 tom Exp $") + +#if USE_TERM_DRIVER +#define MaxColors InfoOf(sp).maxcolors +#define NumLabels InfoOf(sp).numlabels +#else +#define MaxColors max_colors +#define NumLabels num_labels +#endif + +NCURSES_EXPORT(SCREEN *) +set_term(SCREEN *screenp) +{ + SCREEN *oldSP; + SCREEN *newSP; + + T((T_CALLED("set_term(%p)"), (void *) screenp)); + + _nc_lock_global(curses); + + oldSP = CURRENT_SCREEN; + _nc_set_screen(screenp); + newSP = screenp; + + if (newSP != NULL) { + TINFO_SET_CURTERM(newSP, newSP->_term); +#if !USE_REENTRANT + curscr = CurScreen(newSP); + newscr = NewScreen(newSP); + stdscr = StdScreen(newSP); + COLORS = newSP->_color_count; + COLOR_PAIRS = newSP->_pair_count; +#endif + } else { + TINFO_SET_CURTERM(oldSP, NULL); +#if !USE_REENTRANT + curscr = NULL; + newscr = NULL; + stdscr = NULL; + COLORS = 0; + COLOR_PAIRS = 0; +#endif + } + + _nc_unlock_global(curses); + + T((T_RETURN("%p"), (void *) oldSP)); + return (oldSP); +} + +static void +_nc_free_keytry(TRIES * kt) +{ + if (kt != NULL) { + _nc_free_keytry(kt->child); + _nc_free_keytry(kt->sibling); + free(kt); + } +} + +static bool +delink_screen(SCREEN *sp) +{ + SCREEN *last = NULL; + SCREEN *temp; + bool result = FALSE; + + for (each_screen(temp)) { + if (temp == sp) { + if (last) + last->_next_screen = 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) +{ + + T((T_CALLED("delscreen(%p)"), (void *) sp)); + + _nc_lock_global(curses); + if (delink_screen(sp)) { + WINDOWLIST *wl; + bool is_current = (sp == CURRENT_SCREEN); + +#ifdef USE_SP_RIPOFF + if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) { + ripoff_t *rop; + for (rop = safe_ripoff_stack; + rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS; + rop++) { + if (rop->win) { + (void) delwin(rop->win); + rop->win = NULL; + } + } + } +#endif + + /* delete all of the windows in this screen */ + rescan: + for (each_window(sp, wl)) { + if (_nc_freewin(&(wl->win)) == OK) { + goto rescan; + } + } + + if (sp->_slk != NULL) { + + if (sp->_slk->ent != NULL) { + int i; + + 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 = NULL; + } + + _nc_free_keytry(sp->_keytry); + sp->_keytry = NULL; + + _nc_free_keytry(sp->_key_ok); + sp->_key_ok = NULL; + + FreeIfNeeded(sp->_current_attr); + + _nc_free_ordered_pairs(sp); + FreeIfNeeded(sp->_color_table); + FreeIfNeeded(sp->_color_pairs); + + FreeIfNeeded(sp->_oldnum_list); + FreeIfNeeded(sp->oldhash); + FreeIfNeeded(sp->newhash); + FreeIfNeeded(sp->hashtab); + + FreeIfNeeded(sp->_acs_map); + FreeIfNeeded(sp->_screen_acs_map); + + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term); + FreeIfNeeded(sp->out_buffer); + if (_nc_find_prescr() == sp) { + _nc_forget_prescr(); + } +#if USE_GPM_SUPPORT +#ifdef HAVE_LIBDL + if (sp->_dlopen_gpm != NULL) { + dlclose(sp->_dlopen_gpm); + sp->_dlopen_gpm = NULL; + } +#endif +#endif /* USE_GPM_SUPPORT */ + 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 (is_current) { +#if !USE_REENTRANT + curscr = NULL; + newscr = NULL; + stdscr = NULL; + COLORS = 0; + COLOR_PAIRS = 0; +#endif + _nc_set_screen(NULL); +#if USE_WIDEC_SUPPORT + if (SP == NULL) { + FreeIfNeeded(_nc_wacs); + _nc_wacs = NULL; + } +#endif + } else { + set_term(CURRENT_SCREEN); + } + } + _nc_unlock_global(curses); + + returnVoid; +} + +static bool +no_mouse_event(SCREEN *sp GCC_UNUSED) +{ + return FALSE; +} + +static bool +no_mouse_inline(SCREEN *sp GCC_UNUSED) +{ + return FALSE; +} + +static bool +no_mouse_parse(SCREEN *sp GCC_UNUSED, int code GCC_UNUSED) +{ + return TRUE; +} + +static void +no_mouse_resume(SCREEN *sp GCC_UNUSED) +{ +} + +static void +no_mouse_wrap(SCREEN *sp GCC_UNUSED) +{ +} + +#if NCURSES_EXT_FUNCS && USE_COLORFGBG +static const char * +extract_fgbg(const char *src, int *result) +{ + const char *dst = 0; + char *tmp = 0; + long value = strtol(src, &tmp, 0); + + if ((dst = tmp) == 0) { + dst = src; + } else if (value >= 0) { + *result = (int) value; + } + while (*dst != 0 && *dst != ';') + dst++; + if (*dst == ';') + dst++; + return dst; +} +#endif + +#define ReturnScreenError() do { _nc_set_screen(NULL); \ + returnCode(ERR); } while (0) + +/* OS-independent screen initializations */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_setupscreen) ( +#if NCURSES_SP_FUNCS + SCREEN **spp, +#endif + int slines, + int scolumns, + FILE *output, + bool filtered, + int slk_format) +{ +#if !USE_TERM_DRIVER + static const TTY null_TTY; /* all zeros iff uninitialized */ +#endif + char *env; + int bottom_stolen = 0; + SCREEN *sp; +#if !USE_TERM_DRIVER + bool support_cookies = USE_XMC_SUPPORT; +#endif + + T((T_CALLED("_nc_setupscreen(%d, %d, %p, %d, %d)"), + slines, scolumns, (void *) output, filtered, slk_format)); + + /* CURRENT_SCREEN is reset in newterm() */ + if (CURRENT_SCREEN) + returnCode(ERR); + +#if NCURSES_SP_FUNCS + if (spp == NULL) + returnCode(ERR); + sp = *spp; + + if (!sp) { + sp = _nc_alloc_screen_sp(); + T(("_nc_alloc_screen_sp %p", (void *) sp)); + *spp = sp; + } + if (sp == NULL) { + ReturnScreenError(); + } + if ((sp->_acs_map = typeCalloc(chtype, ACS_LEN)) == NULL) { + ReturnScreenError(); + } + if ((sp->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == NULL) { + free(sp->_acs_map); + ReturnScreenError(); + } + + T(("created SP %p", (void *) sp)); + sp->_next_screen = _nc_screen_chain; + _nc_screen_chain = sp; + + if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == NULL) { + ReturnScreenError(); + } +#else + if (!_nc_alloc_screen() + || ((SP->_acs_map = typeCalloc(chtype, ACS_LEN)) == NULL) + || ((SP->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == NULL)) { + returnCode(ERR); + } + + T(("created SP %p", (void *) SP)); + + sp = SP; /* fixup so SET_LINES and SET_COLS works */ + sp->_next_screen = _nc_screen_chain; + _nc_screen_chain = sp; + + if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == NULL) { + returnCode(ERR); + } +#endif + + /* + * We should always check the screensize, just in case. + */ + _nc_set_screen(sp); + sp->_term = cur_term; +#if USE_TERM_DRIVER + TCBOf(sp)->csp = sp; + _nc_get_screensize(sp, sp->_term, &slines, &scolumns); +#else + _nc_get_screensize(sp, &slines, &scolumns); +#endif + if (scolumns < 0) + scolumns = 0; + if (slines < 0) + slines = 0; + SET_LINES(slines); + SET_COLS(scolumns); + + T((T_CREATE("screen %s %dx%d"), + NCURSES_SP_NAME(termname) (NCURSES_SP_ARG), slines, scolumns)); + + sp->_filtered = filtered; + + /* implement filter mode */ + if (filtered) { + slines = 1; + SET_LINES(slines); +#if USE_TERM_DRIVER + CallDriver(sp, td_setfilter); +#else + /* *INDENT-EQLS* */ + clear_screen = ABSENT_STRING; + cursor_address = ABSENT_STRING; + cursor_down = ABSENT_STRING; + cursor_up = ABSENT_STRING; + parm_down_cursor = ABSENT_STRING; + parm_up_cursor = ABSENT_STRING; + row_address = ABSENT_STRING; + cursor_home = carriage_return; + + if (back_color_erase) + clr_eos = ABSENT_STRING; + +#endif + T(("filter screensize %dx%d", slines, scolumns)); + } +#if USE_NAMED_PIPES + T(("setting output mode to binary")); + fflush(output); + _setmode(fileno(output), _O_BINARY); +#endif + sp->_lines = (NCURSES_SIZE_T) slines; + sp->_lines_avail = (NCURSES_SIZE_T) slines; + sp->_columns = (NCURSES_SIZE_T) scolumns; + + fflush(output); + sp->_ofd = output ? fileno(output) : -1; + sp->_ofp = output; +#if USE_NAMED_PIPES + if (output) + _setmode(fileno(output), _O_BINARY); +#endif + sp->out_limit = (size_t) ((2 + slines) * (6 + scolumns)); + if ((sp->out_buffer = malloc(sp->out_limit)) == NULL) + sp->out_limit = 0; + sp->out_inuse = 0; + + SP_PRE_INIT(sp); + SetNoPadding(sp); + +#if NCURSES_EXT_FUNCS + sp->_default_color = FALSE; + sp->_has_sgr_39_49 = FALSE; + + /* + * Set our assumption of the terminal's default foreground and background + * colors. The curs_color man page states that we can assume that the + * background is black. The origin of this assumption appears to be + * terminals that displayed colored text, but no colored backgrounds, e.g., + * the first colored terminals around 1980. More recent ones with better + * technology can display not only colored backgrounds, but all + * combinations. So a terminal might be something other than "white" on + * black (green/black looks monochrome too), but black on white or even + * on ivory. + * + * White-on-black is the simplest thing to use for monochrome. Almost + * all applications that use color paint both text and background, so + * the distinction is moot. But a few do not - which is why we leave this + * configurable (a better solution is to use assume_default_colors() for + * the rare applications that do require that sort of appearance, since + * is appears that more users expect to be able to make a white-on-black + * or black-on-white display under control of the application than not). + */ +#ifdef USE_ASSUMED_COLOR + sp->_default_fg = COLOR_WHITE; + sp->_default_bg = COLOR_BLACK; +#else + sp->_default_fg = COLOR_DEFAULT; + sp->_default_bg = COLOR_DEFAULT; +#endif + + /* + * Allow those assumed/default color assumptions to be overridden at + * runtime: + */ + if ((env = getenv("NCURSES_ASSUMED_COLORS")) != NULL) { + 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 < MaxColors) ? fg : COLOR_DEFAULT); + if (count >= 3) { + sp->_default_bg = ((bg >= 0 && bg < MaxColors) ? bg : COLOR_DEFAULT); + } + 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 + * default colors. Note that rxvt (mis)uses bold colors, equating a bold + * color to that value plus 8. We'll only use the non-bold color for now - + * decide later if it is worth having default attributes as well. + */ + if (getenv("COLORFGBG") != 0) { + const 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 */ + 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 >= MaxColors) { + if (set_a_foreground != ABSENT_STRING + && !strcmp(set_a_foreground, "\033[3%p1%dm")) { + set_a_foreground = strdup("\033[3%?%p1%{8}%>%t9%e%p1%d%;m"); + } else { + sp->_default_fg %= MaxColors; + } + } + if (sp->_default_bg >= MaxColors) { + if (set_a_background != ABSENT_STRING + && !strcmp(set_a_background, "\033[4%p1%dm")) { + set_a_background = strdup("\033[4%?%p1%{8}%>%t9%e%p1%d%;m"); + } else { + sp->_default_bg %= MaxColors; + } + } + } +#endif +#endif /* NCURSES_EXT_FUNCS */ + + sp->_maxclick = DEFAULT_MAXCLICK; + sp->_mouse_event = no_mouse_event; + sp->_mouse_inline = no_mouse_inline; + sp->_mouse_parse = no_mouse_parse; + sp->_mouse_resume = no_mouse_resume; + sp->_mouse_wrap = no_mouse_wrap; + sp->_mouse_fd = -1; + + /* + * 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 = NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG); + if (NCURSES_SP_NAME(has_colors) (NCURSES_SP_ARG)) { + sp->_ok_attributes |= A_COLOR; + } +#if USE_TERM_DRIVER + _nc_cookie_init(sp); +#else +#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) { + if (getenv("NCURSES_NO_MAGIC_COOKIE") != NULL) { + 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 & XMC_CONFLICT; +#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 the cookie support simple, suppress all of the optimization + * hooks except for clear_screen and the cursor addressing. + */ + 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(sp->_term)) { + acs_chars = NULL; + ena_acs = NULL; + enter_alt_charset_mode = NULL; + exit_alt_charset_mode = NULL; + set_attributes = NULL; + } +#endif +#endif + + NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_ARG); +#if USE_WIDEC_SUPPORT + sp->_screen_unicode = _nc_unicode_locale(); + if (_nc_wacs == NULL) { + _nc_init_wacs(); + } + if (_nc_wacs == NULL) { + ReturnScreenError(); + } + + sp->_screen_acs_fix = (sp->_screen_unicode + && _nc_locale_breaks_acs(sp->_term)); +#endif + env = _nc_get_locale(); + sp->_legacy_coding = ((env == NULL) + || !strcmp(env, "C") + || !strcmp(env, "POSIX")); + T(("legacy-coding %d", sp->_legacy_coding)); + + sp->_nc_sp_idcok = TRUE; + sp->_nc_sp_idlok = FALSE; + + sp->oldhash = NULL; + sp->newhash = NULL; + + T(("creating newscr")); + NewScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx slines, scolumns, + 0, 0); + if (NewScreen(sp) == NULL) { + ReturnScreenError(); + } + T(("creating curscr")); + CurScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx slines, scolumns, + 0, 0); + if (CurScreen(sp) == NULL) { + ReturnScreenError(); + } +#if !USE_REENTRANT + newscr = NewScreen(sp); + curscr = CurScreen(sp); +#endif +#if USE_SIZECHANGE + sp->_resize = NCURSES_SP_NAME(resizeterm); + sp->_ungetch = safe_ungetch; +#endif + + NewScreen(sp)->_clear = TRUE; + CurScreen(sp)->_clear = FALSE; + + /* + * Get the current tty-modes. setupterm() may already have done this, + * unless we use the term-driver. + */ +#if !USE_TERM_DRIVER + if (cur_term != NULL && + !memcmp(&cur_term->Ottyb, &null_TTY, sizeof(TTY))) +#endif + { + NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG); + NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG); + } + + if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) { + ripoff_t *rop; + + for (rop = safe_ripoff_stack; + rop != safe_ripoff_sp && (rop - safe_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 (!TerminalOf(sp)) { + continue; + } + if (!(NumLabels <= 0 || !SLK_STDFMT(slk_format))) { + continue; + } + } + if (rop->hook) { + int count; + WINDOW *w; + + count = (rop->line < 0) ? -rop->line : rop->line; + T(("ripping off %i lines at %s", count, + ((rop->line < 0) + ? "bottom" + : "top"))); + + w = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx + count, scolumns, + ((rop->line < 0) + ? sp->_lines_avail - count + : 0), + 0); + if (w) { + rop->win = w; + rop->hook(w, scolumns); + } else { + ReturnScreenError(); + } + if (rop->line < 0) { + bottom_stolen += count; + } else { + sp->_topstolen = (NCURSES_SIZE_T) (sp->_topstolen + count); + } + sp->_lines_avail = (NCURSES_SIZE_T) (sp->_lines_avail - count); + } + } + /* reset the stack */ + safe_ripoff_sp = safe_ripoff_stack; + } + + T(("creating stdscr")); + (void) bottom_stolen; + assert((sp->_lines_avail + sp->_topstolen + bottom_stolen) == slines); + if ((StdScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx + sp->_lines_avail, + scolumns, 0, 0)) == NULL) { + ReturnScreenError(); + } + SET_LINES(sp->_lines_avail); +#if !USE_REENTRANT + stdscr = StdScreen(sp); +#endif + sp->_prescreen = FALSE; + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_setupscreen(int slines GCC_UNUSED, + int scolumns GCC_UNUSED, + FILE *output, + bool filtered, + int slk_format) +{ + SCREEN *sp = NULL; + int rc = NCURSES_SP_NAME(_nc_setupscreen) (&sp, + slines, + scolumns, + output, + filtered, + slk_format); + if (rc != OK) + _nc_set_screen(NULL); + return rc; +} +#endif + +/* + * The internal implementation interprets line as the number of lines to rip + * off from the top or bottom. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_DCLx + int line, + int (*init) (WINDOW *, int)) +{ + int code = ERR; + TR_FUNC_BFR(1); + + START_TRACE(); + T((T_CALLED("ripoffline(%p,%d,%s)"), + (void *) SP_PARM, line, + TR_FUNC_ARG(0, init))); + +#if NCURSES_SP_FUNCS + if (SP_PARM != NULL && SP_PARM->_prescreen) +#endif + { + if (line == 0) { + code = OK; + } else { + if (safe_ripoff_sp == NULL) { + safe_ripoff_sp = safe_ripoff_stack; + } + if (safe_ripoff_sp < safe_ripoff_stack + N_RIPS) { + safe_ripoff_sp->line = line; + safe_ripoff_sp->hook = init; + (safe_ripoff_sp)++; + T(("ripped-off %d:%d chunks", + (int) (safe_ripoff_sp - safe_ripoff_stack), N_RIPS)); + code = OK; + } + } + } + + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_ripoffline(int line, int (*init) (WINDOW *, int)) +{ + int rc; + + _nc_init_pthreads(); + _nc_lock_global(prescreen); + START_TRACE(); + rc = NCURSES_SP_NAME(_nc_ripoffline) (CURRENT_SCREEN_PRE, line, init); + _nc_unlock_global(prescreen); + + return rc; +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(ripoffline) (NCURSES_SP_DCLx + int line, + int (*init) (WINDOW *, int)) +{ + START_TRACE(); + return NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_ARGx + (line < 0) ? -1 : 1, + init); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +ripoffline(int line, int (*init) (WINDOW *, int)) +{ + int rc; + + _nc_init_pthreads(); + _nc_lock_global(prescreen); + START_TRACE(); + rc = NCURSES_SP_NAME(ripoffline) (CURRENT_SCREEN_PRE, line, init); + _nc_unlock_global(prescreen); + + return rc; +} +#endif diff --git a/ncurses/ncurses/base/lib_slk.c b/ncurses/ncurses/base/lib_slk.c new file mode 100644 index 0000000000..568db67338 --- /dev/null +++ b/ncurses/ncurses/base/lib_slk.c @@ -0,0 +1,257 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2010,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/**************************************************************************** + * Authors: * + * Gerhard Fuernkranz 1993 (original) * + * Zeyd M. Ben-Halim 1992,1995 (sic) * + * Eric S. Raymond * + * Juergen Pfeifer 1996-on * + * Thomas E. Dickey * + ****************************************************************************/ + +/* + * lib_slk.c + * Soft key routines. + */ + +#include +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_slk.c,v 1.52 2025/12/27 12:41:23 tom Exp $") + +#if USE_TERM_DRIVER +#define NumLabels InfoOf(SP_PARM).numlabels +#define NoColorVideo InfoOf(SP_PARM).nocolorvideo +#define LabelWidth InfoOf(SP_PARM).labelwidth +#define LabelHeight InfoOf(SP_PARM).labelheight +#else +#define NumLabels num_labels +#define NoColorVideo no_color_video +#define LabelWidth label_width +#define LabelHeight label_height +#endif + +/* + * Free any memory related to soft labels, return an error. + */ +static int +slk_failed(NCURSES_SP_DCL0) +{ + if ((NULL != SP_PARM) && SP_PARM->_slk) { + FreeIfNeeded(SP_PARM->_slk->ent); + free(SP_PARM->_slk); + SP_PARM->_slk = (SLK *) 0; + } + return ERR; +} + +NCURSES_EXPORT(int) +_nc_format_slks(NCURSES_SP_DCLx int cols) +{ + int gap, i, x; + int max_length; + + if (!SP_PARM || !SP_PARM->_slk) + return ERR; + + max_length = SP_PARM->_slk->maxlen; + if (SP_PARM->slk_format >= 3) { /* PC style */ + gap = (cols - 3 * (3 + 4 * max_length)) / 2; + + if (gap < 1) + gap = 1; + + for (i = x = 0; i < SP_PARM->_slk->maxlab; i++) { + SP_PARM->_slk->ent[i].ent_x = x; + x += max_length; + x += (i == 3 || i == 7) ? gap : 1; + } + } else { + if (SP_PARM->slk_format == 2) { /* 4-4 */ + gap = cols - (int) (SP_PARM->_slk->maxlab * max_length) - 6; + + if (gap < 1) + gap = 1; + for (i = x = 0; i < SP_PARM->_slk->maxlab; i++) { + SP_PARM->_slk->ent[i].ent_x = x; + x += max_length; + x += (i == 3) ? gap : 1; + } + } else { + if (SP_PARM->slk_format == 1) { /* 1 -> 3-2-3 */ + gap = (cols - (SP_PARM->_slk->maxlab * max_length) - 5) + / 2; + + if (gap < 1) + gap = 1; + for (i = x = 0; i < SP_PARM->_slk->maxlab; i++) { + SP_PARM->_slk->ent[i].ent_x = x; + x += max_length; + x += (i == 2 || i == 4) ? gap : 1; + } + } else { + return slk_failed(NCURSES_SP_ARG); + } + } + } + SP_PARM->_slk->dirty = TRUE; + + return OK; +} + +/* + * Initialize soft labels. + * Called from newterm() + */ +NCURSES_EXPORT(int) +_nc_slk_initialize(WINDOW *stwin, int cols) +{ + int i; + int res = OK; + size_t max_length; + SCREEN *sp; + int numlab; + + T((T_CALLED("_nc_slk_initialize()"))); + + assert(stwin); + + sp = _nc_screen_of(stwin); + if (NULL == sp) + returnCode(ERR); + + assert(TerminalOf(SP_PARM)); + + numlab = NumLabels; + + if (SP_PARM->_slk) { /* we did this already, so simply return */ + returnCode(OK); + } else if ((SP_PARM->_slk = typeCalloc(SLK, 1)) == NULL) + returnCode(ERR); + + if (!SP_PARM->slk_format) + SP_PARM->slk_format = _nc_globals.slk_format; + + /* + * 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 ((NoColorVideo & 1) == 0) + SetAttr(SP_PARM->_slk->attr, A_STANDOUT); + else + SetAttr(SP_PARM->_slk->attr, A_REVERSE); + + SP_PARM->_slk->maxlab = (short) ((numlab > 0) + ? numlab + : MAX_SKEY(SP_PARM->slk_format)); + SP_PARM->_slk->maxlen = (short) ((numlab > 0) + ? LabelWidth * LabelHeight + : MAX_SKEY_LEN(SP_PARM->slk_format)); + SP_PARM->_slk->labcnt = (short) ((SP_PARM->_slk->maxlab < MAX_SKEY(SP_PARM->slk_format)) + ? MAX_SKEY(SP_PARM->slk_format) + : SP_PARM->_slk->maxlab); + + if (SP_PARM->_slk->maxlen <= 0 + || SP_PARM->_slk->labcnt <= 0 + || (SP_PARM->_slk->ent = typeCalloc(slk_ent, + (size_t) SP_PARM->_slk->labcnt)) + == NULL) { + free(SP_PARM->_slk->ent); + returnCode(slk_failed(NCURSES_SP_ARG)); + } + + max_length = (size_t) SP_PARM->_slk->maxlen; + for (i = 0; i < SP_PARM->_slk->labcnt; i++) { + size_t used = max_length + 1; + + SP_PARM->_slk->ent[i].ent_text = (char *) _nc_doalloc(NULL, used); + if (SP_PARM->_slk->ent[i].ent_text == NULL) + returnCode(slk_failed(NCURSES_SP_ARG)); + memset(SP_PARM->_slk->ent[i].ent_text, 0, used); + + SP_PARM->_slk->ent[i].form_text = (char *) _nc_doalloc(NULL, used); + if (SP_PARM->_slk->ent[i].form_text == NULL) + returnCode(slk_failed(NCURSES_SP_ARG)); + + if (used > 1) { + memset(SP_PARM->_slk->ent[i].form_text, ' ', used - 1); + } + SP_PARM->_slk->ent[i].form_text[used - 1] = '\0'; + + SP_PARM->_slk->ent[i].visible = (char) (i < SP_PARM->_slk->maxlab); + } + + res = _nc_format_slks(NCURSES_SP_ARGx cols); + + if ((SP_PARM->_slk->win = stwin) == NULL) { + returnCode(slk_failed(NCURSES_SP_ARG)); + } + + /* 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) + */ + _nc_globals.slk_format = 0; + returnCode(res); +} + +/* + * Restore the soft labels on the screen. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_restore) (NCURSES_SP_DCL0) +{ + T((T_CALLED("slk_restore(%p)"), (void *) SP_PARM)); + + if (NULL == SP_PARM) + returnCode(ERR); + if (SP_PARM->_slk == NULL) + returnCode(ERR); + SP_PARM->_slk->hidden = FALSE; + SP_PARM->_slk->dirty = TRUE; + + returnCode(NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_ARG)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_restore(void) +{ + return NCURSES_SP_NAME(slk_restore) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkatr_set.c b/ncurses/ncurses/base/lib_slkatr_set.c new file mode 100644 index 0000000000..c3fc17c971 --- /dev/null +++ b/ncurses/ncurses/base/lib_slkatr_set.c @@ -0,0 +1,84 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1998 * + * and: Thomas E. Dickey 2005-on * + ****************************************************************************/ + +/* + * lib_slkatr_set.c + * Soft key routines. + * Set the label's attributes + */ +#include + +MODULE_ID("$Id: lib_slkatr_set.c,v 1.18 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx + const attr_t attr, + NCURSES_PAIRS_T pair_arg, + void *opts) +{ + int code = ERR; + int color_pair = pair_arg; + + T((T_CALLED("slk_attr_set(%p,%s,%d)"), + (void *) SP_PARM, + _traceattr(attr), + color_pair)); + + set_extended_pair(opts, color_pair); + if (SP_PARM != NULL + && SP_PARM->_slk != NULL + && color_pair >= 0 + && color_pair < SP_PARM->_pair_limit) { + TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); + SetAttr(SP_PARM->_slk->attr, attr); + if (color_pair > 0) { + SetPair(SP_PARM->_slk->attr, color_pair); + } + TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); + code = OK; + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_attr_set(const attr_t attr, NCURSES_COLOR_T pair_arg, void *opts) +{ + return NCURSES_SP_NAME(slk_attr_set) (CURRENT_SCREEN, attr, + pair_arg, opts); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkatrof.c b/ncurses/ncurses/base/lib_slkatrof.c new file mode 100644 index 0000000000..0fdc6c4f6f --- /dev/null +++ b/ncurses/ncurses/base/lib_slkatrof.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2005,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1997 * + * and: Thomas E. Dickey 2005 * + ****************************************************************************/ + +/* + * lib_slkatrof.c + * Soft key routines. + * Switch off labels attributes + */ +#include + +MODULE_ID("$Id: lib_slkatrof.c,v 1.13 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_attroff) (NCURSES_SP_DCLx const chtype attr) +{ + T((T_CALLED("slk_attroff(%p,%s)"), (void *) SP_PARM, _traceattr(attr))); + + if (SP_PARM != NULL && SP_PARM->_slk != NULL) { + TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); + RemAttr(SP_PARM->_slk->attr, attr); + if ((attr & A_COLOR) != 0) { + SetPair(SP_PARM->_slk->attr, 0); + } + TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); + returnCode(OK); + } else + returnCode(ERR); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_attroff(const chtype attr) +{ + return NCURSES_SP_NAME(slk_attroff) (CURRENT_SCREEN, attr); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkatron.c b/ncurses/ncurses/base/lib_slkatron.c new file mode 100644 index 0000000000..60c733e3b6 --- /dev/null +++ b/ncurses/ncurses/base/lib_slkatron.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1997 * + * and: Thomas E. Dickey 2005 * + ****************************************************************************/ + +/* + * lib_slkatron.c + * Soft key routines. + * Switch on labels attributes + */ +#include + +MODULE_ID("$Id: lib_slkatron.c,v 1.14 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_attron) (NCURSES_SP_DCLx const chtype attr) +{ + T((T_CALLED("slk_attron(%p,%s)"), (void *) SP_PARM, _traceattr(attr))); + + if (SP_PARM != NULL && SP_PARM->_slk != NULL) { + TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); + AddAttr(SP_PARM->_slk->attr, attr); + if ((attr & A_COLOR) != 0) { + SetPair(SP_PARM->_slk->attr, PairNumber(attr)); + } + TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); + returnCode(OK); + } else + returnCode(ERR); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_attron(const chtype attr) +{ + return NCURSES_SP_NAME(slk_attron) (CURRENT_SCREEN, attr); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkatrset.c b/ncurses/ncurses/base/lib_slkatrset.c new file mode 100644 index 0000000000..5de7ed0124 --- /dev/null +++ b/ncurses/ncurses/base/lib_slkatrset.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2005,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1997 * + * and: Thomas E. Dickey 2005 * + ****************************************************************************/ + +/* + * lib_slkatrset.c + * Soft key routines. + * Set the labels attributes + */ +#include + +MODULE_ID("$Id: lib_slkatrset.c,v 1.12 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_attrset) (NCURSES_SP_DCLx const chtype attr) +{ + T((T_CALLED("slk_attrset(%p,%s)"), (void *) SP_PARM, _traceattr(attr))); + + if (SP_PARM != NULL && SP_PARM->_slk != NULL) { + SetAttr(SP_PARM->_slk->attr, attr); + returnCode(OK); + } else + returnCode(ERR); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_attrset(const chtype attr) +{ + return NCURSES_SP_NAME(slk_attrset) (CURRENT_SCREEN, attr); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkattr.c b/ncurses/ncurses/base/lib_slkattr.c new file mode 100644 index 0000000000..a43894e5ba --- /dev/null +++ b/ncurses/ncurses/base/lib_slkattr.c @@ -0,0 +1,68 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1997 * + * and: Thomas E. Dickey 2005 * + ****************************************************************************/ + +/* + * lib_slkattr.c + * Soft key routines. + * Fetch the labels attributes + */ +#include + +MODULE_ID("$Id: lib_slkattr.c,v 1.13 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(attr_t) +NCURSES_SP_NAME(slk_attr) (NCURSES_SP_DCL0) +{ + T((T_CALLED("slk_attr(%p)"), (void *) SP_PARM)); + + if (SP_PARM != NULL && SP_PARM->_slk != NULL) { + attr_t result = AttrOf(SP_PARM->_slk->attr) & ALL_BUT_COLOR; + int pair = GetPair(SP_PARM->_slk->attr); + + result |= (attr_t) ColorPair(pair); + returnAttr(result); + } else + returnAttr(0); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(attr_t) +slk_attr(void) +{ + return NCURSES_SP_NAME(slk_attr) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkclear.c b/ncurses/ncurses/base/lib_slkclear.c new file mode 100644 index 0000000000..613013fded --- /dev/null +++ b/ncurses/ncurses/base/lib_slkclear.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2007,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Juergen Pfeifer 1996-1999 * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * lib_slkclear.c + * Soft key routines. + * Remove soft labels from the screen. + */ +#include + +MODULE_ID("$Id: lib_slkclear.c,v 1.16 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_clear) (NCURSES_SP_DCL0) +{ + int rc = ERR; + + T((T_CALLED("slk_clear(%p)"), (void *) SP_PARM)); + + if (SP_PARM != NULL && SP_PARM->_slk != NULL) { + SP_PARM->_slk->hidden = TRUE; + /* For simulated SLK's it looks much more natural to + inherit those attributes from the standard screen */ + SP_PARM->_slk->win->_nc_bkgd = StdScreen(SP_PARM)->_nc_bkgd; + WINDOW_ATTRS(SP_PARM->_slk->win) = WINDOW_ATTRS(StdScreen(SP_PARM)); + if (SP_PARM->_slk->win == StdScreen(SP_PARM)) { + rc = OK; + } else { + werase(SP_PARM->_slk->win); + rc = wrefresh(SP_PARM->_slk->win); + } + } + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_clear(void) +{ + return NCURSES_SP_NAME(slk_clear) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkcolor.c b/ncurses/ncurses/base/lib_slkcolor.c new file mode 100644 index 0000000000..7bc6a147f0 --- /dev/null +++ b/ncurses/ncurses/base/lib_slkcolor.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * Copyright 2018-2020,2024 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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, 1998,2009 * + * and: Thomas E. Dickey 2005-on * + ****************************************************************************/ + +/* + * lib_slkcolor.c + * Soft key routines. + * Set the label's color + */ +#include + +MODULE_ID("$Id: lib_slkcolor.c,v 1.21 2024/12/07 20:03:37 tom Exp $") + +static int +_nc_slk_color(SCREEN *sp, int pair_arg) +{ + int code = ERR; + + T((T_CALLED("slk_color(%p,%d)"), (void *) sp, pair_arg)); + + if (sp != NULL + && sp->_slk != NULL + && pair_arg >= 0 + && pair_arg < sp->_pair_limit) { + TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(sp->_slk->attr)))); + SetPair(sp->_slk->attr, pair_arg); + TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(sp->_slk->attr)))); + code = OK; + } + returnCode(code); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_color) (NCURSES_SP_DCLx NCURSES_PAIRS_T pair_arg) +{ + return _nc_slk_color(SP_PARM, pair_arg); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_color(NCURSES_PAIRS_T pair_arg) +{ + return NCURSES_SP_NAME(slk_color) (CURRENT_SCREEN, pair_arg); +} +#endif + +#if NCURSES_EXT_COLORS +NCURSES_EXPORT(int) +NCURSES_SP_NAME(extended_slk_color) (NCURSES_SP_DCLx int pair_arg) +{ + return _nc_slk_color(SP_PARM, pair_arg); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +extended_slk_color(int pair_arg) +{ + return NCURSES_SP_NAME(extended_slk_color) (CURRENT_SCREEN, pair_arg); +} +#endif +#endif diff --git a/ncurses/ncurses/base/lib_slkinit.c b/ncurses/ncurses/base/lib_slkinit.c new file mode 100644 index 0000000000..9f0650d705 --- /dev/null +++ b/ncurses/ncurses/base/lib_slkinit.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * Copyright 2020,2022 Thomas E. Dickey * + * Copyright 1998-2009,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * lib_slkinit.c + * Soft key routines. + * Initialize soft labels. Called by the user before initscr(). + */ +#include + +MODULE_ID("$Id: lib_slkinit.c,v 1.16 2022/07/09 18:58:58 tom Exp $") + +#ifdef USE_SP_RIPOFF +#define SoftkeyFormat SP_PARM->slk_format +#else +#define SoftkeyFormat _nc_globals.slk_format +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_init) (NCURSES_SP_DCLx int format) +{ + int code = ERR; + + START_TRACE(); + T((T_CALLED("slk_init(%p,%d)"), (void *) SP_PARM, format)); + + if (format >= 0 + && format <= 3 +#ifdef USE_SP_RIPOFF + && SP_PARM + && SP_PARM->_prescreen +#endif + && !SoftkeyFormat) { + SoftkeyFormat = 1 + format; + code = NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_ARGx + -SLK_LINES(SoftkeyFormat), + _nc_slk_initialize); + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_init(int format) +{ + int rc; + + _nc_init_pthreads(); + _nc_lock_global(prescreen); + START_TRACE(); + rc = NCURSES_SP_NAME(slk_init) (CURRENT_SCREEN_PRE, format); + _nc_unlock_global(prescreen); + + return rc; +} +#endif diff --git a/ncurses/ncurses/base/lib_slklab.c b/ncurses/ncurses/base/lib_slklab.c new file mode 100644 index 0000000000..50f06014b5 --- /dev/null +++ b/ncurses/ncurses/base/lib_slklab.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2003,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Juergen Pfeifer, 1998,2009 * + * and: Thomas E. Dickey 1998-on * + ****************************************************************************/ + +/* + * lib_slklab.c + * Soft key routines. + * Fetch the label text. + */ +#include + +MODULE_ID("$Id: lib_slklab.c,v 1.12 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(slk_label) (NCURSES_SP_DCLx int n) +{ + T((T_CALLED("slk_label(%p,%d)"), (void *) SP_PARM, n)); + + if (SP_PARM == NULL || SP_PARM->_slk == NULL || n < 1 || n > SP_PARM->_slk->labcnt) + returnPtr(NULL); + returnPtr(SP_PARM->_slk->ent[n - 1].ent_text); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +slk_label(int n) +{ + return NCURSES_SP_NAME(slk_label) (CURRENT_SCREEN, n); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkrefr.c b/ncurses/ncurses/base/lib_slkrefr.c new file mode 100644 index 0000000000..64e25529fb --- /dev/null +++ b/ncurses/ncurses/base/lib_slkrefr.c @@ -0,0 +1,191 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2013,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Juergen Pfeifer 1996-on * + * and: Thomas E. Dickey * + ****************************************************************************/ + +/* + * lib_slkrefr.c + * Write SLK window to the (virtual) screen. + */ +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_slkrefr.c,v 1.35 2025/12/27 12:41:23 tom Exp $") + +#if USE_TERM_DRIVER +#define NumLabels InfoOf(SP_PARM).numlabels +#else +#define NumLabels num_labels +#endif + +/* + * Paint the info line for the PC style SLK emulation. + */ +static void +slk_paint_info(WINDOW *win) +{ + const SCREEN *sp = _nc_screen_of(win); + + if (win && sp && (sp->slk_format == 4)) { + int i; + + (void) 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. + */ +static void +slk_intern_refresh(SCREEN *sp) +{ + int i; + int fmt; + SLK *slk; + int numlab; + + if (sp == NULL) + return; + + slk = sp->_slk; + fmt = sp->slk_format; + numlab = NumLabels; + + if (slk->hidden) + return; + + for (i = 0; i < slk->labcnt; i++) { + if (slk->dirty || slk->ent[i].dirty) { + if (slk->ent[i].visible) { + if (numlab > 0 && SLK_STDFMT(fmt)) { +#if USE_TERM_DRIVER + CallDriver_2(sp, td_hwlabel, i + 1, slk->ent[i].form_text); +#else + if (i < num_labels) { + NCURSES_PUTP2("plab_norm", + TPARM_2(plab_norm, + i + 1, + slk->ent[i].form_text)); + } +#endif + } else { + if (fmt == 4) + slk_paint_info(slk->win); + wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); + (void) wattrset(slk->win, (int) AttrOf(slk->attr)); + waddstr(slk->win, slk->ent[i].form_text); + /* if we simulate SLK's, it is looking much more + natural to use the current ATTRIBUTE also + for the label window */ + (void) wattrset(slk->win, (int) WINDOW_ATTRS(StdScreen(sp))); + } + } + slk->ent[i].dirty = FALSE; + } + } + slk->dirty = FALSE; + + if (numlab > 0) { +#if USE_TERM_DRIVER + CallDriver_1(sp, td_hwlabelOnOff, slk->hidden ? FALSE : TRUE); +#else + if (slk->hidden) { + NCURSES_PUTP2("label_off", label_off); + } else { + NCURSES_PUTP2("label_on", label_on); + } +#endif + } +} + +/* + * Refresh the soft labels. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_noutrefresh) (NCURSES_SP_DCL0) +{ + T((T_CALLED("slk_noutrefresh(%p)"), (void *) SP_PARM)); + + if (SP_PARM == NULL || SP_PARM->_slk == NULL) + returnCode(ERR); + if (SP_PARM->_slk->hidden) + returnCode(OK); + slk_intern_refresh(SP_PARM); + + returnCode(wnoutrefresh(SP_PARM->_slk->win)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_noutrefresh(void) +{ + return NCURSES_SP_NAME(slk_noutrefresh) (CURRENT_SCREEN); +} +#endif + +/* + * Refresh the soft labels. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_DCL0) +{ + T((T_CALLED("slk_refresh(%p)"), (void *) SP_PARM)); + + if (SP_PARM == NULL || SP_PARM->_slk == NULL) + returnCode(ERR); + if (SP_PARM->_slk->hidden) + returnCode(OK); + slk_intern_refresh(SP_PARM); + + returnCode(wrefresh(SP_PARM->_slk->win)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_refresh(void) +{ + return NCURSES_SP_NAME(slk_refresh) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_slkset.c b/ncurses/ncurses/base/lib_slkset.c new file mode 100644 index 0000000000..2d559cd067 --- /dev/null +++ b/ncurses/ncurses/base/lib_slkset.c @@ -0,0 +1,160 @@ +/**************************************************************************** + * Copyright 2019-2020,2024 Thomas E. Dickey * + * Copyright 1998-2011,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Thomas E. Dickey * + ****************************************************************************/ + +/* + * lib_slkset.c + * Set soft label text. + */ +#include +#include + +#if USE_WIDEC_SUPPORT +#if HAVE_WCTYPE_H +#include +#endif +#endif + +MODULE_ID("$Id: lib_slkset.c,v 1.27 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format) +{ + SLK *slk; + int offset = 0; + int numchrs; + int numcols; + int limit; + const char *str = astr; + const char *p; + + T((T_CALLED("slk_set(%p, %d, \"%s\", %d)"), (void *) SP_PARM, i, str, format)); + + if (SP_PARM == NULL + || (slk = SP_PARM->_slk) == NULL + || i < 1 + || i > slk->labcnt + || format < 0 + || format > 2) + returnCode(ERR); + if (str == NULL) + str = ""; + --i; /* Adjust numbering of labels */ + + limit = MAX_SKEY_LEN(SP_PARM->slk_format); + while (isspace(UChar(*str))) + str++; /* skip over leading spaces */ + p = str; + +#if USE_WIDEC_SUPPORT + numcols = 0; + while (*p != 0) { + mbstate_t state; + wchar_t wc; + size_t need; + + init_mb(state); + need = mbrtowc(NULL, p, strlen(p), &state); + if (need == (size_t) -1) + break; + mbrtowc(&wc, p, need, &state); + if (!iswprint((wint_t) wc)) + break; + if (_nc_wacs_width(wc) + numcols > limit) + break; + numcols += _nc_wacs_width(wc); + p += need; + } + numchrs = (int) (p - str); +#else + while (isprint(UChar(*p))) + p++; /* The first non-print stops */ + + numcols = (int) (p - str); + if (numcols > limit) + numcols = limit; + numchrs = numcols; +#endif + + FreeIfNeeded(slk->ent[i].ent_text); + if ((slk->ent[i].ent_text = strdup(str)) == NULL) + returnCode(ERR); + slk->ent[i].ent_text[numchrs] = '\0'; + + if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text, + (size_t) (limit + + numchrs + 1)) + ) == NULL) + returnCode(ERR); + + switch (format) { + case 0: /* left-justified */ + offset = 0; + break; + case 1: /* centered */ + offset = (limit - numcols) / 2; + break; + case 2: /* right-justified */ + offset = limit - numcols; + break; + } + if (offset <= 0) + offset = 0; + else + memset(slk->ent[i].form_text, ' ', (size_t) offset); + + memcpy(slk->ent[i].form_text + offset, + slk->ent[i].ent_text, + (size_t) numchrs); + + if (offset < limit) { + memset(slk->ent[i].form_text + offset + numchrs, + ' ', + (size_t) (limit - (offset + numcols))); + } + + slk->ent[i].form_text[numchrs - numcols + limit] = 0; + slk->ent[i].dirty = TRUE; + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_set(int i, const char *astr, int format) +{ + return NCURSES_SP_NAME(slk_set) (CURRENT_SCREEN, i, astr, format); +} +#endif diff --git a/ncurses/ncurses/base/lib_slktouch.c b/ncurses/ncurses/base/lib_slktouch.c new file mode 100644 index 0000000000..45e2cf940e --- /dev/null +++ b/ncurses/ncurses/base/lib_slktouch.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997,2009 * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * lib_slktouch.c + * Soft key routines. + * Force the code to believe that the soft keys have been changed. + */ +#include + +MODULE_ID("$Id: lib_slktouch.c,v 1.10 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(slk_touch) (NCURSES_SP_DCL0) +{ + T((T_CALLED("slk_touch(%p)"), (void *) SP_PARM)); + + if (SP_PARM == NULL || SP_PARM->_slk == NULL) + returnCode(ERR); + SP_PARM->_slk->dirty = TRUE; + + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_touch(void) +{ + return NCURSES_SP_NAME(slk_touch) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/lib_touch.c b/ncurses/ncurses/base/lib_touch.c new file mode 100644 index 0000000000..5bda52b37b --- /dev/null +++ b/ncurses/ncurses/base/lib_touch.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_touch.c +** +** The routines untouchwin(), +** wtouchln(), +** is_linetouched() +** is_wintouched(). +** +*/ + +#include + +MODULE_ID("$Id: lib_touch.c,v 1.17 2024/11/23 19:17:05 tom Exp $") + +#undef is_linetouched + +NCURSES_EXPORT(bool) +is_linetouched(WINDOW *win, int line) +{ + T((T_CALLED("is_linetouched(%p,%d)"), (void *) win, line)); + + /* XSI doesn't define any error, and gcc ultimately made it impossible */ + if (!win || (line > win->_maxy) || (line < 0)) { + returnBool(FALSE); + } + + returnBool(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE); +} + +NCURSES_EXPORT(bool) +is_wintouched(WINDOW *win) +{ + T((T_CALLED("is_wintouched(%p)"), (void *) win)); + + if (win) { + int i; + + for (i = 0; i <= win->_maxy; i++) + if (win->_line[i].firstchar != _NOCHANGE) + returnBool(TRUE); + } + returnBool(FALSE); +} + +NCURSES_EXPORT(int) +wtouchln(WINDOW *win, int y, int n, int changed) +{ + int i; + + T((T_CALLED("wtouchln(%p,%d,%d,%d)"), (void *) win, y, n, changed)); + + if (!win || (n < 0) || (y < 0) || (y > win->_maxy)) + returnCode(ERR); + + for (i = y; i < y + n; i++) { + if (i > win->_maxy) + break; + win->_line[i].firstchar = (NCURSES_SIZE_T) (changed ? 0 : _NOCHANGE); + win->_line[i].lastchar = (NCURSES_SIZE_T) (changed + ? win->_maxx + : _NOCHANGE); + } + returnCode(OK); +} diff --git a/ncurses/ncurses/base/lib_ungetch.c b/ncurses/ncurses/base/lib_ungetch.c new file mode 100644 index 0000000000..f59d329837 --- /dev/null +++ b/ncurses/ncurses/base/lib_ungetch.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2011,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_ungetch.c +** +** The routine ungetch(). +** +*/ + +#include + +MODULE_ID("$Id: lib_ungetch.c,v 1.18 2024/12/07 20:03:37 tom Exp $") + +#include + +#ifdef TRACE +NCURSES_EXPORT(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, _nc_tracechar(sp, sp->_fifo[i]))); +} +#endif /* TRACE */ + +NCURSES_EXPORT(int) +safe_ungetch(SCREEN *sp, int ch) +{ + int rc = ERR; + + T((T_CALLED("ungetch(%p,%s)"), (void *) sp, _nc_tracechar(sp, ch))); + + if (sp != NULL && tail >= 0) { + if (head < 0) { + head = 0; + t_inc(); + peek = tail; /* no raw keys */ + } else { + h_dec(); + } + + sp->_fifo[head] = ch; + T(("ungetch %s ok", _nc_tracechar(sp, ch))); +#ifdef TRACE + if (USE_TRACEF(TRACE_IEVENT)) { + _nc_fifo_dump(sp); + _nc_unlock_global(tracef); + } +#endif + rc = OK; + } + returnCode(rc); +} + +NCURSES_EXPORT(int) +ungetch(int ch) +{ + return safe_ungetch(CURRENT_SCREEN, ch); +} diff --git a/ncurses/ncurses/base/lib_vline.c b/ncurses/ncurses/base/lib_vline.c new file mode 100644 index 0000000000..fe067133e6 --- /dev/null +++ b/ncurses/ncurses/base/lib_vline.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Sven Verdoolaege 2001 * + ****************************************************************************/ + +/* +** lib_vline.c +** +** The routine wvline(). +** +*/ + +#include + +MODULE_ID("$Id: lib_vline.c,v 1.15 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +wvline(WINDOW *win, chtype ch, int n) +{ + int code = ERR; + + T((T_CALLED("wvline(%p,%s,%d)"), (void *) win, _tracechtype(ch), n)); + + if (win) { + NCURSES_CH_T wch; + int row = win->_cury; + int col = win->_curx; + int end = row + n - 1; + + if (end > win->_maxy) + end = win->_maxy; + + if (ch == 0) + SetChar2(wch, ACS_VLINE); + else + SetChar2(wch, ch); + wch = _nc_render(win, wch); + + while (end >= row) { + struct ldat *line = &(win->_line[end]); +#if USE_WIDEC_SUPPORT + if (col > 0 && isWidecExt(line->text[col])) { + SetChar2(line->text[col - 1], ' '); + } + if (col < win->_maxx && isWidecExt(line->text[col + 1])) { + SetChar2(line->text[col + 1], ' '); + } +#endif + line->text[col] = wch; + CHANGED_CELL(line, col); + end--; + } + + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/base/lib_wattroff.c b/ncurses/ncurses/base/lib_wattroff.c new file mode 100644 index 0000000000..e4746a1159 --- /dev/null +++ b/ncurses/ncurses/base/lib_wattroff.c @@ -0,0 +1,68 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2006,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_wattroff.c +** +** The routine wattr_off(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_wattroff.c,v 1.11 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +wattr_off(WINDOW *win, attr_t at, void *opts GCC_UNUSED) +{ + T((T_CALLED("wattr_off(%p,%s)"), (void *) win, _traceattr(at))); + if (win) { + 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/ncurses/ncurses/base/lib_wattron.c b/ncurses/ncurses/base/lib_wattron.c new file mode 100644 index 0000000000..ea7dc40c86 --- /dev/null +++ b/ncurses/ncurses/base/lib_wattron.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * Copyright 2020-2022,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_wattron.c +** +** The routines wattr_on(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_wattron.c,v 1.14 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(int) +wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED) +{ + T((T_CALLED("wattr_on(%p,%s)"), (void *) win, _traceattr(at))); + if (win != NULL) { + T(("... current %s (%d)", + _traceattr(WINDOW_ATTRS(win)), + GET_WINDOW_PAIR(win))); + + if_EXT_COLORS({ + if (at & A_COLOR) { + win->_color = PairNumber(at); + set_extended_pair(opts, win->_color); + } + }); + toggle_attr_on(WINDOW_ATTRS(win), at); + returnCode(OK); + } else + returnCode(ERR); +} diff --git a/ncurses/ncurses/base/lib_winch.c b/ncurses/ncurses/base/lib_winch.c new file mode 100644 index 0000000000..6d7fc4d92a --- /dev/null +++ b/ncurses/ncurses/base/lib_winch.c @@ -0,0 +1,58 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1998 * + ****************************************************************************/ + +/* +** lib_winch.c +** +** The routine winch(). +** +*/ + +#include + +MODULE_ID("$Id: lib_winch.c,v 1.10 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(chtype) +winch(WINDOW *win) +{ + T((T_CALLED("winch(%p)"), (void *) win)); + if (win != NULL) { + returnChtype((chtype) CharOf(win->_line[win->_cury].text[win->_curx]) + | AttrOf(win->_line[win->_cury].text[win->_curx])); + } else { + returnChtype(0); + } +} diff --git a/ncurses/ncurses/base/lib_window.c b/ncurses/ncurses/base/lib_window.c new file mode 100644 index 0000000000..5db67bd201 --- /dev/null +++ b/ncurses/ncurses/base/lib_window.c @@ -0,0 +1,257 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 1998-2010,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* +** lib_window.c +** +** +*/ + +#include + +MODULE_ID("$Id: lib_window.c,v 1.33 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(void) +_nc_synchook(WINDOW *win) +/* hook to be called after each window change */ +{ + if (win->_immed) + wrefresh(win); + if (win->_sync) + wsyncup(win); +} + +NCURSES_EXPORT(int) +mvderwin(WINDOW *win, int y, int x) +/* move a derived window */ +{ + WINDOW *orig; + int rc = ERR; + + T((T_CALLED("mvderwin(%p,%d,%d)"), (void *) win, y, x)); + + if (win != NULL + && (orig = win->_parent) != NULL + && (x >= 0 && y >= 0) + && (x + getmaxx(win) <= getmaxx(orig)) + && (y + getmaxy(win) <= getmaxy(orig))) { + int i; + + wsyncup(win); + win->_parx = x; + win->_pary = y; + for (i = 0; i < getmaxy(win); i++) + win->_line[i].text = &(orig->_line[y++].text[x]); + rc = OK; + } + returnCode(rc); +} + +NCURSES_EXPORT(int) +syncok(WINDOW *win, bool bf) +/* enable/disable automatic wsyncup() on each change to window */ +{ + T((T_CALLED("syncok(%p,%d)"), (void *) win, bf)); + + if (win) { + win->_sync = bf; + returnCode(OK); + } else + returnCode(ERR); +} + +NCURSES_EXPORT(void) +wsyncup(WINDOW *win) +/* mark changed every cell in win's ancestors that is changed in win */ +/* Rewritten by J. Pfeifer, 1-Apr-96 (don't even think that...) */ +{ + WINDOW *wp; + + T((T_CALLED("wsyncup(%p)"), (void *) win)); + if (win && win->_parent) { + for (wp = win; wp->_parent; wp = wp->_parent) { + int y; + WINDOW *pp = wp->_parent; + + assert((wp->_pary <= pp->_maxy) && + ((wp->_pary + wp->_maxy) <= pp->_maxy)); + + for (y = 0; y <= wp->_maxy; y++) { + int left = wp->_line[y].firstchar; + if (left >= 0) { /* line is touched */ + struct ldat *line = &(pp->_line[wp->_pary + y]); + /* left & right character in parent window coordinates */ + int right = wp->_line[y].lastchar + wp->_parx; + left += wp->_parx; + + CHANGED_RANGE(line, left, right); + } + } + } + } + returnVoid; +} + +NCURSES_EXPORT(void) +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)"), (void *) win)); + + if (win != NULL && win->_parent != NULL) { + WINDOW *pp = win->_parent; + int y; + + /* This recursion guarantees, that the changes are propagated down- + wards from the root to our direct parent. */ + wsyncdown(pp); + + /* and now we only have to propagate the changes from our direct + parent, if there are any. */ + assert((win->_pary <= pp->_maxy) && + ((win->_pary + win->_maxy) <= pp->_maxy)); + + for (y = 0; y <= win->_maxy; y++) { + if (pp->_line[win->_pary + y].firstchar >= 0) { /* parent changed */ + struct ldat *line = &(win->_line[y]); + /* 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 may be outside the child's range */ + if (left < 0) + left = 0; + if (right > win->_maxx) + right = win->_maxx; + CHANGED_RANGE(line, left, right); + } + } + } + returnVoid; +} + +NCURSES_EXPORT(void) +wcursyncup(WINDOW *win) +/* sync the cursor in all derived windows to its value in the base window */ +{ + WINDOW *wp; + + T((T_CALLED("wcursyncup(%p)"), (void *) 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 = NULL; + + T((T_CALLED("dupwin(%p)"), (void *) win)); + + if (win != NULL) { +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + _nc_lock_global(curses); + if (IS_PAD(win)) { + nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx + win->_maxy + 1, + win->_maxx + 1); + } else { + nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx + win->_maxy + 1, + win->_maxx + 1, + win->_begy, + win->_begx); + } + + if (nwin != NULL) { + int i; + size_t linesize; + + 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 (IS_PAD(win)) + nwin->_pad = win->_pad; + + linesize = (unsigned) (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/ncurses/ncurses/base/nc_panel.c b/ncurses/ncurses/base/nc_panel.c new file mode 100644 index 0000000000..02ccaa4f92 --- /dev/null +++ b/ncurses/ncurses/base/nc_panel.c @@ -0,0 +1,57 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2000,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: nc_panel.c,v 1.7 2024/12/07 20:03:37 tom Exp $") + +NCURSES_EXPORT(struct panelhook *) +NCURSES_SP_NAME(_nc_panelhook) (NCURSES_SP_DCL0) +{ + return (SP_PARM + ? &(SP_PARM->_panelHook) + : (CURRENT_SCREEN + ? &(CURRENT_SCREEN->_panelHook) + : NULL)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(struct panelhook *) +_nc_panelhook(void) +{ + return NCURSES_SP_NAME(_nc_panelhook) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/base/new_pair.c b/ncurses/ncurses/base/new_pair.c new file mode 100644 index 0000000000..46f25fa736 --- /dev/null +++ b/ncurses/ncurses/base/new_pair.c @@ -0,0 +1,396 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* new_pair.c + * + * New color-pair functions, alloc_pair and free_pair + */ + +#define NEW_PAIR_INTERNAL 1 +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +#if USE_TERM_DRIVER +#define MaxColors InfoOf(SP_PARM).maxcolors +#else +#define MaxColors max_colors +#endif + +#if NCURSES_EXT_COLORS + +/* fix redefinition versys tic.h */ +#undef entry +#define entry my_entry +#undef ENTRY +#define ENTRY my_ENTRY + +#include + +#endif + +MODULE_ID("$Id: new_pair.c,v 1.27 2025/12/27 12:41:23 tom Exp $") + +#if NCURSES_EXT_COLORS + +#ifdef NEW_PAIR_DEBUG + +static int +prev_len(SCREEN *sp, int pair) +{ + int result = 1; + int base = pair; + colorpair_t *list = sp->_color_pairs; + while (list[pair].prev != base) { + result++; + pair = list[pair].prev; + } + return result; +} + +static int +next_len(SCREEN *sp, int pair) +{ + int result = 1; + int base = pair; + colorpair_t *list = sp->_color_pairs; + while (list[pair].next != base) { + result++; + pair = list[pair].next; + } + return result; +} + +/* + * Trace the contents of LRU color-pairs. + */ +static void +dumpit(SCREEN *sp, int pair, const char *tag) +{ + colorpair_t *list = sp->_color_pairs; + char bigbuf[256 * 20]; + char *p = bigbuf; + int n; + size_t have = sizeof(bigbuf); + + _nc_STRCPY(p, tag, have); + for (n = 0; n < sp->_pair_alloc; ++n) { + if (list[n].mode != cpFREE) { + p += strlen(p); + if ((size_t) (p - bigbuf) + 50 > have) + break; + _nc_SPRINTF(p, _nc_SLIMIT(have - (p - bigbuf)) + " %d%c(%d,%d)", + n, n == pair ? '@' : ':', list[n].next, list[n].prev); + } + } + T(("(%d/%d) %ld - %s", + next_len(sp, 0), + prev_len(sp, 0), + strlen(bigbuf), bigbuf)); + + if (next_len(sp, 0) != prev_len(sp, 0)) { + endwin(); + ExitProgram(EXIT_FAILURE); + } +} +#else +#define dumpit(sp, pair, tag) /* nothing */ +#endif + +static int +compare_data(const void *a, const void *b) +{ + const colorpair_t *p = (const colorpair_t *) a; + const colorpair_t *q = (const colorpair_t *) b; + return ((p->fg == q->fg) + ? (p->bg - q->bg) + : (p->fg - q->fg)); +} + +static int +_nc_find_color_pair(SCREEN *sp, int fg, int bg) +{ + colorpair_t find; + int result = -1; + + find.fg = fg; + find.bg = bg; + if (sp != NULL) { + void *pp; + if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != NULL) { + const colorpair_t *temp = *(colorpair_t **) pp; + result = (int) (temp - sp->_color_pairs); + } + } + return result; +} + +static void +delink_color_pair(SCREEN *sp, int pair) +{ + colorpair_t *list = sp->_color_pairs; + int prev = list[pair].prev; + int next = list[pair].next; + + /* delink this from its current location */ + if (list[prev].next == pair && + list[next].prev == pair) { + list[prev].next = next; + list[next].prev = prev; + dumpit(sp, pair, "delinked"); + } +} + +/* + * Discard all nodes in the fast-index. + */ +NCURSES_EXPORT(void) +_nc_free_ordered_pairs(SCREEN *sp) +{ + if (sp && sp->_ordered_pairs && sp->_pair_alloc) { + int n; + for (n = 0; n < sp->_pair_alloc; ++n) { + tdelete(&sp->_color_pairs[n], &sp->_ordered_pairs, compare_data); + } + } +} + +/* + * Use this call to update the fast-index when modifying an entry in the color + * pair table. + */ +NCURSES_EXPORT(void) +_nc_reset_color_pair(SCREEN *sp, int pair, const colorpair_t * next) +{ + colorpair_t *last; + + if (ValidPair(sp, pair)) { + bool used; + + ReservePairs(sp, pair); + last = &(sp->_color_pairs[pair]); + delink_color_pair(sp, pair); + if (last->mode > cpFREE && + (last->fg != next->fg || last->bg != next->bg)) { + /* remove the old entry from fast index */ + tdelete(last, &sp->_ordered_pairs, compare_data); + used = FALSE; + } else { + used = (last->mode != cpFREE); + } + if (!used) { + /* create a new entry in fast index */ + *last = *next; + tsearch(last, &sp->_ordered_pairs, compare_data); + } + } +} + +/* + * Use this call to relink the newest pair to the front of the list, keeping + * "0" first. + */ +NCURSES_EXPORT(void) +_nc_set_color_pair(SCREEN *sp, int pair, int mode) +{ + if (ValidPair(sp, pair)) { + colorpair_t *list = sp->_color_pairs; + dumpit(sp, pair, "SET_PAIR"); + list[0].mode = cpKEEP; + if (list[pair].mode <= cpFREE) + sp->_pairs_used++; + list[pair].mode = mode; + if (list[0].next != pair) { + /* link it at the front of the list */ + list[pair].next = list[0].next; + list[list[pair].next].prev = pair; + list[pair].prev = 0; + list[0].next = pair; + } + dumpit(sp, pair, "...after"); + } +} + +/* + * If we reallocate the color-pair array, we have to adjust the fast-index. + */ +NCURSES_EXPORT(void) +_nc_copy_pairs(SCREEN *sp, colorpair_t * target, colorpair_t * source, int length) +{ + int n; + for (n = 0; n < length; ++n) { + const void *find = tfind(source + n, &sp->_ordered_pairs, compare_data); + if (find != NULL) { + tdelete(source + n, &sp->_ordered_pairs, compare_data); + tsearch(target + n, &sp->_ordered_pairs, compare_data); + } + } +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg) +{ + int pair; + + T((T_CALLED("alloc_pair(%d,%d)"), fg, bg)); + if (SP_PARM == NULL) { + pair = -1; + } else if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) { + /* + * Check if all of the slots have been used. If not, find one and + * use that. + */ + if (SP_PARM->_pairs_used + 1 < SP_PARM->_pair_limit) { + bool found = FALSE; + int hint = SP_PARM->_recent_pair; + + /* + * The linear search is done to allow mixing calls to init_pair() + * and alloc_pair(). The former can make gaps... + */ + for (pair = hint + 1; pair < SP_PARM->_pair_alloc; pair++) { + if (SP_PARM->_color_pairs[pair].mode == cpFREE) { + T(("found gap %d", pair)); + found = TRUE; + break; + } + } + if (!found && (SP_PARM->_pair_alloc < SP_PARM->_pair_limit)) { + pair = SP_PARM->_pair_alloc; + ReservePairs(SP_PARM, pair); + if (SP_PARM->_color_pairs == NULL) { + pair = -1; + } else { + found = TRUE; + } + } + if (!found && SP_PARM->_color_pairs != NULL) { + for (pair = 1; pair <= hint; pair++) { + if (SP_PARM->_color_pairs[pair].mode == cpFREE) { + T(("found gap %d", pair)); + found = TRUE; + break; + } + } + } + if (found) { + SP_PARM->_recent_pair = pair; + } else { + pair = ERR; + } + } else { + /* reuse the oldest one */ + pair = SP_PARM->_color_pairs[0].prev; + T(("reusing %d", pair)); + } + + if (_nc_init_pair(SP_PARM, pair, fg, bg) == ERR) + pair = ERR; + } + returnCode(pair); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(find_pair) (NCURSES_SP_DCLx int fg, int bg) +{ + int pair; + + T((T_CALLED("find_pair(%d,%d)"), fg, bg)); + pair = _nc_find_color_pair(SP_PARM, fg, bg); + returnCode(pair); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(free_pair) (NCURSES_SP_DCLx int pair) +{ + int result = ERR; + T((T_CALLED("free_pair(%d)"), pair)); + if (ValidPair(SP_PARM, pair) && pair < SP_PARM->_pair_alloc) { + colorpair_t *cp = &(SP_PARM->_color_pairs[pair]); + if (pair != 0) { + _nc_change_pair(SP_PARM, pair); + delink_color_pair(SP_PARM, pair); + tdelete(cp, &SP_PARM->_ordered_pairs, compare_data); + cp->mode = cpFREE; + result = OK; + SP_PARM->_pairs_used--; + } + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +alloc_pair(int f, int b) +{ + return NCURSES_SP_NAME(alloc_pair) (CURRENT_SCREEN, f, b); +} + +NCURSES_EXPORT(int) +find_pair(int f, int b) +{ + return NCURSES_SP_NAME(find_pair) (CURRENT_SCREEN, f, b); +} + +NCURSES_EXPORT(int) +free_pair(int pair) +{ + return NCURSES_SP_NAME(free_pair) (CURRENT_SCREEN, pair); +} +#endif + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_new_pair_leaks(SCREEN *sp) +{ + if (sp->_color_pairs) { + while (sp->_color_pairs[0].next) { + free_pair(sp->_color_pairs[0].next); + } + } +} +#endif + +#else +void _nc_new_pair(void); +void +_nc_new_pair(void) +{ +} +#endif /* NCURSES_EXT_COLORS */ diff --git a/ncurses/ncurses/base/resizeterm.c b/ncurses/ncurses/base/resizeterm.c new file mode 100644 index 0000000000..725ddb75bf --- /dev/null +++ b/ncurses/ncurses/base/resizeterm.c @@ -0,0 +1,544 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2015,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* + * This is an extension to the curses library. It provides callers with a hook + * into the NCURSES data to resize windows, primarily for use by programs + * running in an X Window terminal (e.g., xterm). I abstracted this module + * from my application library for NCURSES because it must be compiled with + * the private data structures -- T.Dickey 1995/7/4. + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: resizeterm.c,v 1.61 2025/12/27 12:28:45 tom Exp $") + +/* + * 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 + +#if NCURSES_SP_FUNCS && !defined(USE_SP_WINDOWLIST) +#define UNUSED_SP (void) sp +#else +#define UNUSED_SP /* nothing */ +#endif + +#ifdef TRACE +static void +show_window_sizes(const char *name) +{ + SCREEN *sp; + WINDOWLIST *wp; + + _nc_lock_global(curses); + for (each_screen(sp)) { + _tracef("%s resizing: %p: %2d x %2d (%2d x %2d)", name, (void *) sp, + *(ptrLines(sp)), + *(ptrCols(sp)), + screen_lines(sp), screen_columns(sp)); + for (each_window(sp, wp)) { + _tracef(" window %p is %2ld x %2ld at %2ld,%2ld", + (void *) &(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) +NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_DCLx int ToLines, int ToCols) +{ + T((T_CALLED("is_term_resized(%p, %d, %d)"), (void *) SP_PARM, ToLines, ToCols)); + returnBool(ToLines > 0 + && ToCols > 0 + && SP_PARM != NULL + && (ToLines != screen_lines(SP_PARM) + || ToCols != screen_columns(SP_PARM))); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +is_term_resized(int ToLines, int ToCols) +{ + return NCURSES_SP_NAME(is_term_resized) (CURRENT_SCREEN, ToLines, ToCols); +} +#endif + +/* + */ +static ripoff_t * +ripped_window(WINDOW *win) +{ + ripoff_t *result = NULL; + ripoff_t *rop; + + if (win != NULL) { +#ifdef USE_SP_RIPOFF + SCREEN *sp = _nc_screen_of(win); +#endif + 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; + + if (win != NULL) { + ripoff_t *rop; + +#ifdef USE_SP_RIPOFF + SCREEN *sp = _nc_screen_of(win); +#endif + 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 != NULL) { +#ifdef USE_SP_WINDOWLIST + SCREEN *sp = _nc_screen_of(cmp); +#endif + WINDOWLIST *wp; + + for (each_window(sp, 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 != NULL) { + WINDOW *tst; + while ((tst = cmp->_parent) != NULL) { + ++depth; + cmp = tst; + } + } + return depth; +} + +/* + * FIXME: must adjust position so it is within the parent! + */ +static int +adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS) +{ + int result; + int bottom = CurLines + _nc_screen_of(win)->_topstolen - stolen; + int myLines = win->_maxy + 1; + int myCols = win->_maxx + 1; + const ripoff_t *rop = ripped_window(win); + + T((T_CALLED("adjust_window(%p,%d,%d)%s depth %d/%d currently %ldx%ld at %ld,%ld"), + (void *) win, ToLines, ToCols, + (rop != NULL) ? " (rip)" : "", + parent_depth(win), + child_depth(win), + (long) getmaxy(win), (long) getmaxx(win), + (long) getbegy(win) + win->_yoffset, (long) getbegx(win))); + + if (rop != NULL && 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 = (NCURSES_SIZE_T) (ToLines - ripped_bottom(win) - 0 - win->_yoffset); + if (rop->hook == _nc_slk_initialize) + _nc_format_slks( +#if NCURSES_SP_FUNCS + _nc_screen_of(win), +#endif + ToCols); + } 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 = (NCURSES_SIZE_T) (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(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS) +{ + bool found; + int depth = 0; + WINDOWLIST *wp; + + T((T_CALLED("decrease_size(%p, %d, %d)"), (void *) SP_PARM, ToLines, ToCols)); + UNUSED_SP; + + do { + found = FALSE; + TR(TRACE_UPDATE, ("decreasing size of windows to %dx%d, depth=%d", + ToLines, ToCols, depth)); + for (each_window(SP_PARM, wp)) { + WINDOW *win = &(wp->win); + + if (!IS_PAD(win)) { + 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(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS) +{ + bool found; + int depth = 0; + WINDOWLIST *wp; + + T((T_CALLED("increase_size(%p, %d, %d)"), (void *) SP_PARM, ToLines, ToCols)); + UNUSED_SP; + + do { + found = FALSE; + TR(TRACE_UPDATE, ("increasing size of windows to %dx%d, depth=%d", + ToLines, ToCols, depth)); + for (each_window(SP_PARM, wp)) { + WINDOW *win = &(wp->win); + + if (!IS_PAD(win)) { + 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) +NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols) +{ + int result = OK EXTRA_ARGS; + int was_stolen; + + T((T_CALLED("resize_term(%p,%d,%d) old(%d,%d)"), + (void *) SP_PARM, ToLines, ToCols, + (SP_PARM == NULL) ? -1 : screen_lines(SP_PARM), + (SP_PARM == NULL) ? -1 : screen_columns(SP_PARM))); + + if (SP_PARM == NULL || ToLines <= 0 || ToCols <= 0) { + returnCode(ERR); + } + + _nc_nonsp_lock_global(curses); + + was_stolen = (screen_lines(SP_PARM) - SP_PARM->_lines_avail); + if (NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_ARGx ToLines, ToCols)) { + int myLines = CurLines = screen_lines(SP_PARM); + int myCols = CurCols = screen_columns(SP_PARM); + +#ifdef TRACE + if (USE_TRACEF(TRACE_UPDATE)) { + show_window_sizes("before"); + _nc_unlock_global(tracef); + } +#endif + if (ToLines > screen_lines(SP_PARM)) { + result = increase_size(NCURSES_SP_ARGx + myLines = ToLines, + myCols, + was_stolen EXTRA_ARGS); + CurLines = myLines; + CurCols = myCols; + } + + if ((result == OK) + && (ToCols > screen_columns(SP_PARM))) { + result = increase_size(NCURSES_SP_ARGx + myLines, + myCols = ToCols, + was_stolen EXTRA_ARGS); + CurLines = myLines; + CurCols = myCols; + } + + if ((result == OK) + && (ToLines < myLines || + ToCols < myCols)) { + result = decrease_size(NCURSES_SP_ARGx + ToLines, + ToCols, + was_stolen EXTRA_ARGS); + } + + if (result == OK) { + screen_lines(SP_PARM) = (NCURSES_SIZE_T) ToLines; + screen_columns(SP_PARM) = (NCURSES_SIZE_T) ToCols; + +#if USE_TERM_DRIVER + CallDriver_2(SP_PARM, td_setsize, ToLines, ToCols); +#else + lines = (NCURSES_INT2) ToLines; + columns = (NCURSES_INT2) ToCols; +#endif + + SP_PARM->_lines_avail = (NCURSES_SIZE_T) (ToLines - was_stolen); + + if (SP_PARM->oldhash) { + FreeAndNull(SP_PARM->oldhash); + } + if (SP_PARM->newhash) { + FreeAndNull(SP_PARM->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 + } + } + + if (result == OK) { + /* + * Always update LINES, to allow for call from lib_doupdate.c which + * needs to have the count adjusted by the stolen (ripped off) lines. + */ + SET_LINES(ToLines - was_stolen); + SET_COLS(ToCols); + } + + _nc_nonsp_unlock_global(curses); + + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +resize_term(int ToLines, int ToCols) +{ + int res; + _nc_sp_lock_global(curses); + res = NCURSES_SP_NAME(resize_term) (CURRENT_SCREEN, ToLines, ToCols); + _nc_sp_unlock_global(curses); + return (res); +} +#endif + +/* + * 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) +NCURSES_SP_NAME(resizeterm) (NCURSES_SP_DCLx int ToLines, int ToCols) +{ + int result = ERR; + + T((T_CALLED("resizeterm(%p, %d,%d) old(%d,%d)"), + (void *) SP_PARM, ToLines, ToCols, + (SP_PARM == NULL) ? -1 : screen_lines(SP_PARM), + (SP_PARM == NULL) ? -1 : screen_columns(SP_PARM))); + + if (SP_PARM != NULL && ToLines > 0 && ToCols > 0) { + result = OK; + SP_PARM->_sig_winch = FALSE; + + if (NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_ARGx ToLines, ToCols)) { +#if USE_SIGWINCH + ripoff_t *rop; + bool slk_visible = (SP_PARM != NULL + && SP_PARM->_slk != NULL + && !(SP_PARM->_slk->hidden)); + + if (slk_visible) { + slk_clear(); + } +#endif + result = NCURSES_SP_NAME(resize_term) (NCURSES_SP_ARGx ToLines, ToCols); + +#if USE_SIGWINCH + clearok(CurScreen(SP_PARM), 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 != StdScreen(SP_PARM) + && rop->win != NULL + && 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) { + NCURSES_SP_NAME(slk_restore) (NCURSES_SP_ARG); + NCURSES_SP_NAME(slk_touch) (NCURSES_SP_ARG); + NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_ARG); + } +#endif + } +#if USE_SIGWINCH + safe_ungetch(SP_PARM, KEY_RESIZE); /* so application can know this */ +#endif + } + + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +resizeterm(int ToLines, int ToCols) +{ + return NCURSES_SP_NAME(resizeterm) (CURRENT_SCREEN, ToLines, ToCols); +} +#endif diff --git a/ncurses/ncurses/base/safe_sprintf.c b/ncurses/ncurses/base/safe_sprintf.c new file mode 100644 index 0000000000..f2e663d63d --- /dev/null +++ b/ncurses/ncurses/base/safe_sprintf.c @@ -0,0 +1,302 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2012,2013 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + ****************************************************************************/ + +#include +#include + +MODULE_ID("$Id: safe_sprintf.c,v 1.39 2025/02/20 01:07:05 tom Exp $") + +#if USE_SAFE_SPRINTF + +typedef enum { + Flags, Width, Prec, Type, Format +} PRINTF; + +#define VA_INTGR(type) ival = (int) va_arg(ap, type) +#define VA_FLOAT(type) fval = va_arg(ap, type) +#define VA_POINT(type) pval = (void *)va_arg(ap, type) + +/* + * Scan a variable-argument list for printf to determine the number of + * characters that would be emitted. + */ +static int +_nc_printf_length(const char *fmt, va_list ap) +{ + size_t length = BUFSIZ; + char *buffer; + char *format; + int len = 0; + size_t fmt_len; + char fmt_arg[BUFSIZ]; + + if (fmt == NULL || *fmt == '\0') + return 0; + fmt_len = strlen(fmt) + 1; + if ((format = typeMalloc(char, fmt_len)) == NULL) + return -1; + if ((buffer = typeMalloc(char, length)) == NULL) { + free(format); + return -1; + } + + while (*fmt != '\0') { + if (*fmt == '%') { + static char dummy[] = ""; + PRINTF state = Flags; + char *pval = dummy; /* avoid const-cast */ + double fval = 0.0; + int done = FALSE; + int ival = 0; + int prec = -1; + int type = 0; + int used = 0; + int width = -1; + size_t f = 0; + + format[f++] = *fmt; + while (*++fmt != '\0' && len >= 0 && !done) { + format[f++] = *fmt; + + if (isdigit(UChar(*fmt))) { + int num = *fmt - '0'; + if (state == Flags && num != 0) + state = Width; + if (state == Width) { + if (width < 0) + width = 0; + width = (width * 10) + num; + } else if (state == Prec) { + if (prec < 0) + prec = 0; + prec = (prec * 10) + num; + } + } else if (*fmt == '*') { + VA_INTGR(int); + if (state == Flags) + state = Width; + if (state == Width) { + width = ival; + } else if (state == Prec) { + prec = ival; + } + _nc_SPRINTF(fmt_arg, + _nc_SLIMIT(sizeof(fmt_arg)) + "%d", ival); + fmt_len += strlen(fmt_arg); + if ((format = _nc_doalloc(format, fmt_len)) == NULL) { + free(buffer); + return -1; + } + --f; + _nc_STRCPY(&format[f], fmt_arg, fmt_len - f); + f = strlen(format); + } 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_INTGR(long); + else if (type == 'Z') + VA_INTGR(size_t); + else + VA_INTGR(int); + used = 'i'; + break; + case 'f': /* FALLTHRU */ + case 'e': /* FALLTHRU */ + case 'E': /* FALLTHRU */ + case 'g': /* FALLTHRU */ + case 'G': /* FALLTHRU */ + VA_FLOAT(double); + used = 'f'; + break; + case 'c': + VA_INTGR(int); + used = 'i'; + break; + case 's': + VA_POINT(char *); + if (prec < 0) + prec = (int) strlen(pval); + if (prec > (int) length) { + length = length + (size_t) prec; + buffer = typeRealloc(char, length, buffer); + if (buffer == NULL) { + free(format); + return -1; + } + } + used = 'p'; + break; + case 'p': + VA_POINT(void *); + used = 'p'; + break; + case 'n': + VA_POINT(int *); + used = 0; + break; + default: + break; + } + } else if (*fmt == '.') { + state = Prec; + } else if (*fmt == '%') { + done = TRUE; + used = 'p'; + } + } + format[f] = '\0'; + switch (used) { + case 'i': + _nc_SPRINTF(buffer, _nc_SLIMIT(length) format, ival); + break; + case 'f': + _nc_SPRINTF(buffer, _nc_SLIMIT(length) format, fval); + break; + default: + _nc_SPRINTF(buffer, _nc_SLIMIT(length) format, pval); + break; + } + len += (int) strlen(buffer); + } else { + fmt++; + len++; + } + } + + free(buffer); + free(format); + return len; +} +#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 *) +NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx + const char *fmt, + va_list ap) +{ + char *result = NULL; + + if (SP_PARM != NULL && fmt != NULL) { +#if USE_SAFE_SPRINTF + va_list ap2; + int len; + + begin_va_copy(ap2, ap); + len = _nc_printf_length(fmt, ap2); + end_va_copy(ap2); + + if ((int) my_length < len + 1) { + my_length = (size_t) (2 * (len + 1)); + my_buffer = typeRealloc(char, my_length, my_buffer); + } + if (my_buffer != NULL) { + *my_buffer = '\0'; + if (len >= 0) { + vsprintf(my_buffer, fmt, ap); + } + result = my_buffer; + } +#else +#define MyCols _nc_globals.safeprint_cols +#define MyRows _nc_globals.safeprint_rows + + if (screen_lines(SP_PARM) > MyRows || screen_columns(SP_PARM) > MyCols) { + if (screen_lines(SP_PARM) > MyRows) + MyRows = screen_lines(SP_PARM); + if (screen_columns(SP_PARM) > MyCols) + MyCols = screen_columns(SP_PARM); + my_length = (size_t) (MyRows * (MyCols + 1)) + 1; + if (my_length < 80) + my_length = 80; + my_buffer = typeRealloc(char, my_length, my_buffer); + } + + if (my_buffer != NULL) { +# if HAVE_VSNPRINTF + do { + /* SUSv2, 1997 */ + int used; + va_list ap2; + + begin_va_copy(ap2, ap); + used = vsnprintf(my_buffer, my_length, fmt, ap2); + end_va_copy(ap2); + if (used < (int) my_length) + break; + my_length = (size_t) ((3 * used) / 2); + my_buffer = typeRealloc(char, my_length, my_buffer); + } while (my_buffer != NULL); +# else + /* ISO/ANSI C, 1989 */ + vsprintf(my_buffer, fmt, ap); +# endif + result = my_buffer; + } +#endif + } else if (my_buffer != NULL) { /* see _nc_freeall() */ + free(my_buffer); + my_buffer = NULL; + my_length = 0; + } + return result; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +_nc_printf_string(const char *fmt, va_list ap) +{ + return NCURSES_SP_NAME(_nc_printf_string) (CURRENT_SCREEN, fmt, ap); +} +#endif diff --git a/ncurses/ncurses/base/sigaction.c b/ncurses/ncurses/base/sigaction.c new file mode 100644 index 0000000000..d8a8110e9c --- /dev/null +++ b/ncurses/ncurses/base/sigaction.c @@ -0,0 +1,103 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2002,2003 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-2003 * + ****************************************************************************/ + +/* This file provides sigaction() emulation using sigvec() */ +/* Use only if this is non POSIX system */ + +MODULE_ID("$Id: sigaction.c,v 1.15 2020/02/02 23:34:34 tom Exp $") + +static int +_nc_sigaction(int sig, sigaction_t * sigact, sigaction_t * osigact) +{ + return sigvec(sig, sigact, osigact); +} + +static int +_nc_sigemptyset(sigset_t * mask) +{ + *mask = 0; + return 0; +} + +static int +_nc_sigprocmask(int mode, sigset_t * mask, sigset_t * omask) +{ + sigset_t current = sigsetmask(0); + + if (omask) + *omask = current; + + if (mode == SIG_BLOCK) + current |= *mask; + else if (mode == SIG_UNBLOCK) + current &= ~*mask; + else if (mode == SIG_SETMASK) + current = *mask; + + sigsetmask(current); + return 0; +} + +static int +_nc_sigaddset(sigset_t * mask, int sig) +{ + *mask |= sigmask(sig); + return 0; +} + +/* not used in lib_tstp.c */ +#if 0 +static int +_nc_sigsuspend(sigset_t * mask) +{ + return sigpause(*mask); +} + +static int +_nc_sigdelset(sigset_t * mask, int sig) +{ + *mask &= ~sigmask(sig); + return 0; +} + +static int +_nc_sigismember(sigset_t * mask, int sig) +{ + return (*mask & sigmask(sig)) != 0; +} +#endif diff --git a/ncurses/ncurses/base/tries.c b/ncurses/ncurses/base/tries.c new file mode 100644 index 0000000000..930213024e --- /dev/null +++ b/ncurses/ncurses/base/tries.c @@ -0,0 +1,150 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997 * + ****************************************************************************/ + +/* +** tries.c +** +** Functions to manage the tree of partial-completions for keycodes. +** +*/ + +#include +#include + +MODULE_ID("$Id: tries.c,v 1.33 2024/12/07 21:24:18 tom 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(TRIES * tree, unsigned code, int *count, size_t len) +{ + TRIES *ptr = tree; + char *result = NULL; + + if (code != 0) { + while (ptr != NULL) { + if ((result = _nc_expand_try(ptr->child, code, count, len + 1)) + != NULL) { + break; + } + if (ptr->value == code) { + *count -= 1; + if (*count == -1) { + result = typeCalloc(char, len + 2); + break; + } + } + ptr = ptr->sibling; + } + } + if (result != NULL) { + if (ptr != NULL && (result[len] = (char) ptr->ch) == 0) + *((unsigned char *) (result + len)) = 128; +#ifdef TRACE + if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) { + _tracef("expand_key %s %s", + _nc_tracechar(CURRENT_SCREEN, (int) code), + _nc_visbuf(result)); + _nc_unlock_global(tracef); + } +#endif + } + return result; +} + +/* + * Remove a code from the specified tree, freeing the unused nodes. Returns + * true if the code was found/removed. + */ +NCURSES_EXPORT(int) +_nc_remove_key(TRIES ** tree, unsigned code) +{ + T((T_CALLED("_nc_remove_key(%p,%d)"), (void *) tree, code)); + + if (code == 0) + returnCode(FALSE); + + while (*tree != NULL) { + if (_nc_remove_key(&(*tree)->child, code)) { + returnCode(TRUE); + } + if ((*tree)->value == code) { + if ((*tree)->child) { + /* don't cut the whole sub-tree */ + (*tree)->value = 0; + } else { + TRIES *to_free = *tree; + *tree = (*tree)->sibling; + free(to_free); + } + returnCode(TRUE); + } + tree = &(*tree)->sibling; + } + returnCode(FALSE); +} + +/* + * Remove a string from the specified tree, freeing the unused nodes. Returns + * true if the string was found/removed. + */ +NCURSES_EXPORT(int) +_nc_remove_string(TRIES ** tree, const char *string) +{ + T((T_CALLED("_nc_remove_string(%p,%s)"), (void *) tree, _nc_visbuf(string))); + + if (!VALID_STRING(string) || *string == 0) + returnCode(FALSE); + + while (*tree != NULL) { + if (UChar((*tree)->ch) == UChar(*string)) { + if (string[1] != 0) + returnCode(_nc_remove_string(&(*tree)->child, string + 1)); + if ((*tree)->child == NULL) { + TRIES *to_free = *tree; + *tree = (*tree)->sibling; + free(to_free); + returnCode(TRUE); + } else { + returnCode(FALSE); + } + } + tree = &(*tree)->sibling; + } + returnCode(FALSE); +} diff --git a/ncurses/ncurses/base/use_window.c b/ncurses/ncurses/base/use_window.c new file mode 100644 index 0000000000..36a79e7f6f --- /dev/null +++ b/ncurses/ncurses/base/use_window.c @@ -0,0 +1,57 @@ +/**************************************************************************** + * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2007-2009,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +MODULE_ID("$Id: use_window.c,v 1.13 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data) +{ + int code = OK; + TR_FUNC_BFR(1); + + T((T_CALLED("use_window(%p,%s,%p)"), + (void *) win, + TR_FUNC_ARG(0, func), + data)); + + _nc_lock_global(curses); + code = func(win, data); + _nc_unlock_global(curses); + + returnCode(code); +} diff --git a/ncurses/ncurses/base/version.c b/ncurses/ncurses/base/version.c new file mode 100644 index 0000000000..12c0e9c0b5 --- /dev/null +++ b/ncurses/ncurses/base/version.c @@ -0,0 +1,46 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1999-2004,2005 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: version.c,v 1.7 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(const char *) +curses_version(void) +{ + T((T_CALLED("curses_version()"))); + returnCPtr("ncurses " NCURSES_VERSION_STRING); +} diff --git a/ncurses/ncurses/base/vsscanf.c b/ncurses/ncurses/base/vsscanf.c new file mode 100644 index 0000000000..0813e660ad --- /dev/null +++ b/ncurses/ncurses/base/vsscanf.c @@ -0,0 +1,357 @@ +/**************************************************************************** + * Copyright 2020-2023,2025 Thomas E. Dickey * + * Copyright 1998-2004,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +#if !HAVE_VSSCANF + +MODULE_ID("$Id: vsscanf.c,v 1.23 2025/02/20 01:08:11 tom Exp $") + +#if !(HAVE_VFSCANF || HAVE__DOSCAN) + +#include + +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 != NULL) { + /* + * 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 = NULL; + 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_BLOCK) { + 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_BLOCK) { + 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) { + _nc_STRCAT(my_fmt, "%n", len_fmt); + } + + switch (chunk) { + case cAssigned: + _nc_STRCAT(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/ncurses/ncurses/base/wresize.c b/ncurses/ncurses/base/wresize.c new file mode 100644 index 0000000000..f6135d9549 --- /dev/null +++ b/ncurses/ncurses/base/wresize.c @@ -0,0 +1,282 @@ +/**************************************************************************** + * Copyright 2019-2023,2024 Thomas E. Dickey * + * Copyright 1998-2010,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Juergen Pfeifer * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: wresize.c,v 1.45 2024/12/07 18:08:56 tom Exp $") + +static int +cleanup_lines(struct ldat *data, int length) +{ + while (--length >= 0) + FreeAndNull(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; +#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST) + SCREEN *sp = _nc_screen_of(cmp); +#endif + + _nc_lock_global(curses); + + for (each_window(SP_PARM, wp)) { + WINDOW *tst = &(wp->win); + + if (tst->_parent == cmp) { + +#define REPAIR1(field, limit) \ + if (tst->field > cmp->limit) \ + tst->field = cmp->limit + + REPAIR1(_pary, _maxy); + REPAIR1(_parx, _maxx); + +#define REPAIR2(field, limit) \ + if (tst->limit + tst->field > cmp->limit) \ + tst->limit = (NCURSES_SIZE_T) (cmp->limit - tst->field) + + REPAIR2(_pary, _maxy); + REPAIR2(_parx, _maxx); + +#define REPAIR3(field, limit) \ + if (tst->field > tst->limit) \ + tst->field = tst->limit + + REPAIR3(_cury, _maxy); + REPAIR3(_curx, _maxx); + + REPAIR3(_regtop, _maxy); + REPAIR3(_regbottom, _maxy); + + 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. + */ +NCURSES_EXPORT(int) +wresize(WINDOW *win, int ToLines, int ToCols) +{ + int col, row, size_x, size_y; + struct ldat *pline; + struct ldat *new_lines = NULL; + +#ifdef TRACE + T((T_CALLED("wresize(%p,%d,%d)"), (void *) win, ToLines, ToCols)); + if (win) { + 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 + + if (!win || !OK_DIMENSION(ToLines) || !OK_DIMENSION(ToCols)) + returnCode(ERR); + + ToLines--; + ToCols--; + size_x = win->_maxx; + size_y = win->_maxy; + + if (ToLines == size_y + && ToCols == size_x) + returnCode(OK); + + if (IS_SUBWIN(win)) { + /* + * Check if the new limits will fit into the parent window's size. If + * not, do not resize. We could adjust the location of the subwindow, + * but the application may not like that. + */ + if (win->_pary + ToLines > win->_parent->_maxy + || win->_parx + ToCols > win->_parent->_maxx) { + returnCode(ERR); + } + pline = win->_parent->_line; + } else { + pline = NULL; + } + + /* + * 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. + */ + new_lines = typeCalloc(struct ldat, (unsigned) (ToLines + 1)); + if (new_lines == NULL) + 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 (!IS_SUBWIN(win)) { + if (row <= size_y) { + if (ToCols != size_x) { + s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1); + if (s == NULL) + returnCode(cleanup_lines(new_lines, row)); + for (col = 0; col <= ToCols; ++col) { + bool valid = (col <= size_x); + if_WIDEC({ + if (col == ToCols + && col < size_x + && isWidecBase(win->_line[row].text[col])) { + valid = FALSE; + } + }); + s[col] = (valid + ? win->_line[row].text[col] + : win->_nc_bkgd); + } + } else { + s = win->_line[row].text; + } + } else { + s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1); + if (s == NULL) + returnCode(cleanup_lines(new_lines, row)); + for (col = 0; col <= ToCols; ++col) + s[col] = win->_nc_bkgd; + } + } else if (pline != NULL && pline[win->_pary + row].text != NULL) { + s = &pline[win->_pary + row].text[win->_parx]; + } else { + s = NULL; + } + + 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 = (NCURSES_SIZE_T) begin; + } else { /* shrinking */ + new_lines[row].firstchar = 0; + } + new_lines[row].lastchar = (NCURSES_SIZE_T) ToCols; + } + new_lines[row].text = s; + } + + /* + * Dispose of unwanted memory. + */ + if (!(win->_flags & _SUBWIN)) { + if (ToCols == size_x) { + for (row = ToLines + 1; row <= size_y; row++) { + FreeAndNull(win->_line[row].text); + } + } else { + for (row = 0; row <= size_y; row++) { + FreeAndNull(win->_line[row].text); + } + } + } + + FreeAndNull(win->_line); + win->_line = new_lines; + + /* + * Finally, adjust the parameters showing screen size and cursor + * position: + */ + win->_maxx = (NCURSES_SIZE_T) ToCols; + win->_maxy = (NCURSES_SIZE_T) ToLines; + + if (win->_regtop > win->_maxy) + win->_regtop = win->_maxy; + if (win->_regbottom > win->_maxy + || win->_regbottom == size_y) + win->_regbottom = win->_maxy; + + if (win->_curx > win->_maxx) + win->_curx = win->_maxx; + 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 (%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/ncurses/ncurses/build.priv.h b/ncurses/ncurses/build.priv.h new file mode 100644 index 0000000000..9f3f32414f --- /dev/null +++ b/ncurses/ncurses/build.priv.h @@ -0,0 +1,111 @@ +/**************************************************************************** + * Copyright 2019-2020,2024 Thomas E. Dickey * + * Copyright 2010,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2010 * + ****************************************************************************/ + +/* + * $Id: build.priv.h,v 1.13 2024/12/14 22:32:09 tom Exp $ + * + * build.priv.h + * + * This is a reduced version of curses.priv.h, for build-time utilities. + * Because it has fewer dependencies, this simplifies cross-compiling. + * + */ + +#ifndef CURSES_PRIV_H +#define CURSES_PRIV_H 1 + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if USE_RCS_IDS +#define MODULE_ID(id) static const char Ident[] = id; +#else +#define MODULE_ID(id) /*nothing */ +#endif + +#include +#include +#include + +#include +#include + +#include + +#include /* we'll use -Ipath directive to get the right one! */ + +/* usually in */ +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif + +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif + +#define FreeAndNull(p) do { free(p); p = NULL; } while (0) +#define UChar(c) ((unsigned char)(c)) +#define SIZEOF(v) (sizeof(v) / sizeof(v[0])) + +#include +#include + +/* declare these, to avoid needing term.h */ +#if BROKEN_LINKER || USE_REENTRANT +#define NCURSES_ARRAY(name) \ + NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, name) + + NCURSES_ARRAY(boolnames); + NCURSES_ARRAY(boolfnames); + NCURSES_ARRAY(numnames); + NCURSES_ARRAY(numfnames); + NCURSES_ARRAY(strnames); + NCURSES_ARRAY(strfnames); +#endif + +#if NO_LEAKS + NCURSES_EXPORT(void) _nc_names_leaks(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* CURSES_PRIV_H */ diff --git a/ncurses/ncurses/curses.priv.h b/ncurses/ncurses/curses.priv.h new file mode 100644 index 0000000000..b377d24ddb --- /dev/null +++ b/ncurses/ncurses/curses.priv.h @@ -0,0 +1,2757 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2017,2018 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* + * $Id: curses.priv.h,v 1.741 2025/12/27 21:46:04 tom Exp $ + * + * curses.priv.h + * + * Header file for curses library objects which are private to + * the library. + * + */ + +#ifndef CURSES_PRIV_H +#define CURSES_PRIV_H 1 +/* *INDENT-OFF* */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if USE_RCS_IDS +#define MODULE_ID(id) static const char Ident[] = id; +#else +#define MODULE_ID(id) /* nothing */ +#endif + +#include /* for offsetof */ +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif + +#include +#include + +#include + +#if defined __hpux +# ifndef EILSEQ +# define EILSEQ 47 +# endif +#endif + +#if DECL_ERRNO +extern int errno; +#endif + +/* Some Windows related defines */ + +#undef _NC_WINDOWS +#if (defined(_WIN32) || defined(_WIN64__) || defined(__MSYS__)) +#define _NC_WINDOWS +#endif + +#undef _NC_CYGWIN +#if (defined(__MSYS__) || defined(__CYGWIN__)) +#define _NC_CYGWIN +#endif + +#undef _NC_WINDOWS_NATIVE +#if (defined(_WIN32) || defined(_WIN64)) +#define _NC_WINDOWS_NATIVE +#endif + +#undef _NC_MINGW +#if (defined(__MINGW32__) || defined(__MINGW64__)) +#define _NC_MINGW +#endif + +#undef _NC_MSC +#ifdef _MSC_VER +#define _NC_MSC +#endif + +/* Some systems have a broken 'select()', but workable 'poll()'. Use that */ +#if HAVE_WORKING_POLL +#define USE_FUNC_POLL 1 +#if HAVE_POLL_H +#include +#else +#include +#endif +#else +#define USE_FUNC_POLL 0 +#endif + +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif + +#if (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0) && (defined(__GNUC__) && (__GNUC__ < 12)) +# undef PRIxPTR /* gcc bug fixed in 12.x */ +# define PRIxPTR "lX" +# define CASTxPTR(n) (unsigned long)(intptr_t)(void*)(n) +#else +# define CASTxPTR(n) (intptr_t)(n) +#endif + +#ifndef PRIxPTR +# define PRIxPTR "lx" +# undef CASTxPTR +# define CASTxPTR(n) (long)(void*)(n) +#endif + +/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */ +#include + +/* Alessandro Rubini's GPM (general-purpose mouse) */ +#if HAVE_LIBGPM && HAVE_GPM_H +#define USE_GPM_SUPPORT 1 +#else +#define USE_GPM_SUPPORT 0 +#endif + +/* QNX mouse support */ +#if defined(__QNX__) && !defined(__QNXNTO__) +#define USE_QNX_MOUSE 1 +#else +#define USE_QNX_MOUSE 0 +#endif + +/* EMX mouse support */ +#ifdef __EMX__ +#define USE_EMX_MOUSE 1 +#else +#define USE_EMX_MOUSE 0 +#endif + +/* kLIBC keyboard/mouse support */ +#if defined(__OS2__) && defined(__KLIBC__) +#define USE_KLIBC_KBD 1 +#define USE_KLIBC_MOUSE 1 +#else +#define USE_KLIBC_KBD 0 +#define USE_KLIBC_MOUSE 0 +#endif + +#define DEFAULT_MAXCLICK 166 +#define EV_MAX 8 /* size of mouse circular event queue */ + +/* + * If we don't have signals to support it, don't add a sigwinch handler. + * In any case, resizing is an extended feature. Use it if we've got it. + */ +#if !NCURSES_EXT_FUNCS +#undef HAVE_SIZECHANGE +#define HAVE_SIZECHANGE 0 +#endif + +#if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH) +#define USE_SIZECHANGE 1 +#else +#define USE_SIZECHANGE 0 +#undef USE_SIGWINCH +#define USE_SIGWINCH 0 +#endif + +/* + * When building in the MSYS2 environment, the automatic discovery of + * the path separator in configure doesn't work properly. So, if building + * for MinGW, we enforce the correct Windows PATH separator + */ +#if defined(_NC_WINDOWS_NATIVE) || defined(__DJGPP__) +# ifdef NCURSES_PATHSEP +# undef NCURSES_PATHSEP +# endif +# define NCURSES_PATHSEP ';' +#endif + +/* + * When the standard handles have been redirected (such as inside a text editor + * or the less utility), keystrokes must be read from the console rather than + * the redirected handle. The standard output handle suffers from a similar + * problem. Both handles are not closed once opened. The console shall be + * considered reachable throughout the process. + */ +#if defined(_NC_WINDOWS) +#define GetDirectHandle(fileName, shareMode) \ + CreateFile(TEXT(fileName), \ + GENERIC_READ | GENERIC_WRITE, \ + shareMode, \ + 0, \ + OPEN_EXISTING, \ + 0, \ + 0) +#endif + +/* + * The stricmp() function is in MSVCRT, and cannot be called or linked from + * Cygwin runtime-dependent binaries currently. Use the POSIX strcaseccmp() + * function instead which is pretty much the same. + */ +#if defined(_NC_CYGWIN) +#define stricmp(s1, s2) strcasecmp(s1, s2) +#endif + +/* + * Not all platforms have memmove; some have an equivalent bcopy. (Some may + * have neither). + */ +#if USE_OK_BCOPY +#define memmove(d,s,n) bcopy(s,d,n) +#elif USE_MY_MEMMOVE +#define memmove(d,s,n) _nc_memmove(d,s,n) +extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); +#endif + +/* + * If we have va_copy(), use it for assigning va_list's. + */ +#if defined(HAVE___VA_COPY) +#define begin_va_copy(dst,src) __va_copy(dst, src) +#define end_va_copy(dst) va_end(dst) +#elif defined(va_copy) || defined(HAVE_VA_COPY) +#define begin_va_copy(dst,src) va_copy(dst, src) +#define end_va_copy(dst) va_end(dst) +#else +#define begin_va_copy(dst,src) (dst) = (src) +#define end_va_copy(dst) /* nothing */ +#endif + +/* + * Either/both S_ISxxx and/or S_IFxxx are defined in sys/types.h; some systems + * lack one or the other. + */ +#ifndef S_ISDIR +#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISREG +#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG) +#endif + +/* + * POSIX ignores the "b", which c89 specified. Some very old systems do not + * accept it. + */ +#if USE_FOPEN_BIN_R +#define BIN_R "rb" +#define BIN_W "wb" +#else +#define BIN_R "r" +#define BIN_W "w" +#endif + +/* + * Scroll hints are useless when hashmap is used + */ +#if !USE_SCROLL_HINTS +#if !USE_HASHMAP +#define USE_SCROLL_HINTS 1 +#else +#define USE_SCROLL_HINTS 0 +#endif +#endif + +#if USE_SCROLL_HINTS +#define if_USE_SCROLL_HINTS(stmt) stmt +#else +#define if_USE_SCROLL_HINTS(stmt) /*nothing*/ +#endif + +#include + +/* + * Options for terminal drivers, etc... + */ +#if USE_TERM_DRIVER +#define NO_TERMINAL "unknown" +#define USE_SP_RIPOFF 1 +#define USE_SP_TERMTYPE 1 +#else +#define NO_TERMINAL 0 +#endif + +#define VALID_TERM_ENV(term_env, no_terminal) \ + (term_env = (NonEmpty(term_env) \ + ? term_env \ + : no_terminal), \ + NonEmpty(term_env)) + +/* + * Originally a terminal-driver option, the window-list is per-screen to allow + * freeing memory used for windows when a screen is deleted. + */ +#define USE_SP_WINDOWLIST 1 + +/* + * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only + * when we're throwing control codes at the screen at high volume. To see + * this, re-enable USE_HARD_TABS and run worm for a while. Other systems + * probably don't want to define this either due to uncertainties about tab + * delays and expansion in raw mode. + */ + +#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. */ +#undef TRIES +} TRIES; + +/* + * Common/troublesome character definitions + */ +#define StringOf(ch) {ch, 0} + +#define CSI_CHR 0x9b +#define ESC_CHR 0x1b + +#define L_BLOCK '[' +#define R_BLOCK ']' +#define L_BRACE '{' +#define R_BRACE '}' +#define S_QUOTE '\'' +#define D_QUOTE '"' + +#define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~" + +/* + * To make them easier to find, user-defined capabilities used within ncurses + * should be tagged with this macro: + */ +#define UserCap(name) #name + +/* + * Structure for palette tables + */ + +#define MAXCOLUMNS 135 +#define MAXLINES 66 +#define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */ + +#define ACS_LEN 128 + +#define WINDOWLIST struct _win_list + +#if USE_WIDEC_SUPPORT +#define _nc_bkgd _bkgrnd +#else +#undef _XOPEN_SOURCE_EXTENDED +#undef _XPG5 +#define _nc_bkgd _bkgd +#define wgetbkgrnd(win, wch) ((*wch = win->_bkgd) != 0 ? OK : ERR) +#define wbkgrnd wbkgd +#endif + +#undef NCURSES_OPAQUE +#define NCURSES_INTERNALS 1 +#define NCURSES_OPAQUE 0 + +#include /* we'll use -Ipath directive to get the right one! */ + +#if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT)) +#undef KEY_EVENT /* reduce compiler-warnings with Visual 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 +#define TWAIT_MASK (TW_ANY | TW_EVENT) +#else +#define EVENTLIST_0th(param) void +#define EVENTLIST_1st(param) /* nothing */ +#define EVENTLIST_2nd(param) /* nothing */ +#define TWAIT_MASK TW_ANY +#endif + +#include /* defines TERMIOS via term.h */ + +#if USE_TERM_DRIVER +#if defined(TERMIOS) +#undef USE_NAMED_PIPES +#define USE_NAMED_PIPES 0 +#undef USE_WIN32CON_DRIVER +#elif defined(_NC_WINDOWS) +#include +#endif /* TERMIOS */ +#endif /* USE_TERM_DRIVER */ + +#ifndef FixupPathname +#define FixupPathname(path) /* nothing */ +#define FixupPathname2(path,buffer) /* nothing */ +#endif + +typedef struct +{ + int red, green, blue; /* what color_content() returns */ + int r, g, b; /* params to init_color() */ + int init; /* true if we called init_color() */ +} +color_t; + +typedef union { + struct { + unsigned char red; + unsigned char green; + unsigned char blue; + } bits; /* bits per color-value in RGB */ + unsigned value; +} rgb_bits_t; + +/* + * If curses.h did not expose the SCREEN-functions, then we do not need the + * parameter in the corresponding unextended functions. + */ + +#define USE_SP_FUNC_SUPPORT NCURSES_SP_FUNCS +#define USE_EXT_SP_FUNC_SUPPORT (NCURSES_SP_FUNCS && NCURSES_EXT_FUNCS) + +#if NCURSES_SP_FUNCS +#define SP_PARM sp /* use parameter */ +#define NCURSES_SP_ARG SP_PARM +#define NCURSES_SP_DCL SCREEN *NCURSES_SP_ARG +#define NCURSES_SP_DCL0 NCURSES_SP_DCL +#define NCURSES_SP_ARGx NCURSES_SP_ARG, +#define NCURSES_SP_DCLx SCREEN *NCURSES_SP_ARGx +#else +#define SP_PARM SP /* use global variable */ +#define NCURSES_SP_ARG +#define NCURSES_SP_DCL +#define NCURSES_SP_DCL0 void +#define NCURSES_SP_ARGx +#define NCURSES_SP_DCLx +#endif + +#include + +#include + +#define IsPreScreen(sp) (((sp) != NULL) && sp->_prescreen) +#define HasTerminal(sp) (((sp) != NULL) && (NULL != ((sp)->_term))) +#define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp)) + +#if USE_REENTRANT +#define CurTerm _nc_prescreen._cur_term +#else +#define CurTerm cur_term +#endif + +#if NCURSES_SP_FUNCS +#define TerminalOf(sp) ((sp) ? ((sp)->_term ? (sp)->_term : CurTerm) : CurTerm) +#else +#define TerminalOf(sp) CurTerm +#endif + +/* + * The legacy layout for TERMTYPE uses "short" for all of the numbers. Moving + * past that, numeric capabilities can be "int" by using a TERMTYPE2 structure + * in TERMINAL, and doing most of the internal work using TERMTYPE2. There are + * a few places (mostly to expose the legacy layout) where the distinction + * needs attention. + */ +#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR +#define NCURSES_EXT_NUMBERS 1 +#define NCURSES_INT2 int +#define SIZEOF_INT2 4 +#define TerminalType(tp) (tp)->type2 +#else +#define NCURSES_EXT_NUMBERS 0 +#define NCURSES_INT2 short +#define SIZEOF_INT2 2 +#define TerminalType(tp) (tp)->type +#endif + +#define SIZEOF_SHORT 2 + +#ifdef CUR +#undef CUR +#define CUR TerminalType(cur_term). +#endif + +/* + * Reduce dependency on cur_term global by using terminfo data from SCREEN's + * pointer to this data. + */ +#ifdef USE_SP_TERMTYPE +#undef CUR +#endif + +#define SP_TERMTYPE TerminalType(TerminalOf(sp)). + +#include + +#include + +/* + * Simplify ifdef's for the "*_ATTR" macros in case italics are not configured. + */ +#if defined(A_ITALIC) && defined(exit_italics_mode) +#define USE_ITALIC 1 +#else +#define USE_ITALIC 0 +#undef A_ITALIC +#define A_ITALIC 0 +#endif + +/* + * Use these macros internally, to make tracing less verbose. But leave the + * option for compiling the tracing into the library. + */ +#if 1 +#define ColorPair(n) (NCURSES_BITS(n, 0) & A_COLOR) +#define PairNumber(a) (NCURSES_CAST(int,(((unsigned long)(a) & A_COLOR) >> NCURSES_ATTR_SHIFT))) +#else +#define ColorPair(pair) COLOR_PAIR(pair) +#define PairNumber(attr) PAIR_NUMBER(attr) +#endif + +#define unColor(n) unColor2(AttrOf(n)) +#define unColor2(a) ((a) & ALL_BUT_COLOR) + +/* + * Extended-colors stores the color pair in a separate struct-member than the + * attributes. But for compatibility, we handle most cases where a program + * written for non-extended colors stores the color in the attributes by + * checking for a color pair in both places. + */ +#if NCURSES_EXT_COLORS +#define if_EXT_COLORS(stmt) stmt +#define SetPair(value,p) SetPair2((value).ext_color, AttrOf(value), p) +#define SetPair2(c,a,p) c = (p), \ + a = (unColor2(a) | ColorPair(oldColor(c))) +#define GetPair(value) GetPair2((value).ext_color, AttrOf(value)) +#define GetPair2(c,a) ((c) ? (c) : PairNumber(a)) +#define oldColor(p) (((p) > 255) ? 255 : (p)) +#define GET_WINDOW_PAIR(w) GetPair2((w)->_color, (w)->_attrs) +#define SET_WINDOW_PAIR(w,p) (w)->_color = (p) +#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b)) + +#define VIDPUTS(sp,attr,pair) do { \ + int vid_pair = pair; \ + NCURSES_SP_NAME(vid_puts)( \ + NCURSES_SP_ARGx attr, \ + (NCURSES_PAIRS_T) pair, \ + &vid_pair, \ + NCURSES_OUTC_FUNC); \ + } while (0) + +#else /* !NCURSES_EXT_COLORS */ + +#define if_EXT_COLORS(stmt) /* nothing */ +#define SetPair(value,p) RemAttr(value, A_COLOR), \ + SetAttr(value, AttrOf(value) | ColorPair(p)) +#define GetPair(value) PairNumber(AttrOf(value)) +#define GET_WINDOW_PAIR(w) PairNumber(WINDOW_ATTRS(w)) +#define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \ + WINDOW_ATTRS(w) |= ColorPair(p) +#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b)) + +#define VIDPUTS(sp,attr,pair) NCURSES_SP_NAME(vidputs)(NCURSES_SP_ARGx attr, NCURSES_OUTC_FUNC) + +#endif /* NCURSES_EXT_COLORS */ + +#define NCURSES_OUTC_FUNC NCURSES_SP_NAME(_nc_outch) +#define NCURSES_PUTP2(name,value) NCURSES_SP_NAME(_nc_putp)(NCURSES_SP_ARGx name, value) +#define NCURSES_PUTP2_FLUSH(name,value) NCURSES_SP_NAME(_nc_putp_flush)(NCURSES_SP_ARGx name, value) + +#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_SP_FUNCS +extern NCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *); +extern NCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *); +extern NCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *); +extern NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); +#endif + +#if USE_REENTRANT + +#define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES)) +#define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS)) +#define ptrTabsize(sp) (sp ? &(sp->_TABSIZE) : &(_nc_prescreen._TABSIZE)) +#define ptrEscdelay(sp) (sp ? &(sp->_ESCDELAY) : &(_nc_prescreen._ESCDELAY)) + +#define SET_LINES(value) *_nc_ptr_Lines(SP_PARM) = value +#define SET_COLS(value) *_nc_ptr_Cols(SP_PARM) = value +#define SET_TABSIZE(value) *_nc_ptr_Tabsize(SP_PARM) = value +#define SET_ESCDELAY(value) *_nc_ptr_Escdelay(SP_PARM) = value + +#else + +#define ptrLines(sp) &LINES +#define ptrCols(sp) &COLS +#define ptrTabsize(sp) &TABSIZE +#define ptrEscdelay(sp) &ESCDELAY + +#define SET_LINES(value) LINES = value +#define SET_COLS(value) COLS = value +#define SET_TABSIZE(value) TABSIZE = value +#define SET_ESCDELAY(value) ESCDELAY = value + +#endif + +#define IS_SUBWIN(w) ((w)->_flags & _SUBWIN) +#define IS_PAD(w) ((w)->_flags & _ISPAD) +#define IS_WRAPPED(w) ((w)->_flags & _WRAPPED) + +#define HasHardTabs() (NonEmpty(clear_all_tabs) && NonEmpty(set_tab)) + +#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) + +#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)) +#else +# undef USE_WEAK_SYMBOLS +# define USE_WEAK_SYMBOLS 0 +#endif +#endif + +#ifdef USE_PTHREADS + +#if USE_REENTRANT +#include +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 + +#ifdef USE_PTHREADS +# if USE_WEAK_SYMBOLS +weak_symbol(pthread_sigmask); +weak_symbol(pthread_kill); +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(a, b, c) _nc_sigprocmask(a, b, c) +# define GetThreadID() (((pthread_self)) ? pthread_self() : (pthread_t) getpid()) +# else +# define GetThreadID() pthread_self() +# endif +#endif + +#if HAVE_NANOSLEEP +#undef HAVE_NANOSLEEP +#define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */ +#endif + +#else /* !USE_PTHREADS */ + +#if USE_PTHREADS_EINTR +# if USE_WEAK_SYMBOLS +#include +weak_symbol(pthread_sigmask); +weak_symbol(pthread_kill); +weak_symbol(pthread_self); +weak_symbol(pthread_equal); +extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); +# undef sigprocmask +# define sigprocmask(a, b, c) _nc_sigprocmask(a, b, c) +# endif +#endif /* USE_PTHREADS_EINTR */ + +#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 USE_PTHREADS_EINTR +extern NCURSES_EXPORT(void) _nc_set_read_thread(bool); +#else +#define _nc_set_read_thread(enable) /* nothing */ +#endif + +/* + * When using sp-funcs, locks are targeted to SCREEN-level granularity. + * So the locking is done in the non-sp-func (which calls the sp-func) rather + * than in the sp-func itself. + * + * Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()". + * Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS". + */ +#if NCURSES_SP_FUNCS + +#define _nc_nonsp_lock_global(name) /* nothing */ +#define _nc_nonsp_try_global(name) 0 +#define _nc_nonsp_unlock_global(name) /* nothing */ + +#define _nc_sp_lock_global(name) _nc_lock_global(name) +#define _nc_sp_try_global(name) _nc_try_global(name) +#define _nc_sp_unlock_global(name) _nc_unlock_global(name) + +#else + +#define _nc_nonsp_lock_global(name) _nc_lock_global(name) +#define _nc_nonsp_try_global(name) _nc_try_global(name) +#define _nc_nonsp_unlock_global(name) _nc_unlock_global(name) + +#define _nc_sp_lock_global(name) /* nothing */ +#define _nc_sp_try_global(name) 0 +#define _nc_sp_unlock_global(name) /* nothing */ + +#endif + +#if HAVE_CLOCK_GETTIME +# define PRECISE_GETTIME 1 +# define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t) +# define TimeType struct timespec +# define TimeScale 1000000000L /* 1e9 */ +# define sub_secs tv_nsec +#elif HAVE_GETTIMEOFDAY +# define PRECISE_GETTIME 1 +# define GetClockTime(t) gettimeofday(t, 0) +# define TimeType struct timeval +# define TimeScale 1000000L /* 1e6 */ +# define sub_secs tv_usec +#else +# define PRECISE_GETTIME 0 +# define TimeType time_t +#endif + +/* + * Definitions for color pairs + */ + +#define MAX_OF_TYPE(t) (int)(((unsigned t)(~0))>>1) + +#include + +#define isDefaultColor(c) ((c) < 0) +#define COLOR_DEFAULT -1 + +#if defined(USE_BUILD_CC) || (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 +#if USE_TERM_DRIVER + ,M_TERM_DRIVER /* Win32 console, etc */ +#endif +} MouseType; + +typedef enum { + MF_X10 = 0 /* conventional 3-byte format */ + , MF_SGR1006 /* xterm private mode 1006, SGR-style */ +#ifdef EXP_XTERM_1005 + , MF_XTERM_1005 /* xterm UTF-8 private mode 1005 */ +#endif +} MouseFormat; + +/* + * Structures for scrolling. + */ + +typedef struct { + unsigned long hashval; + int oldcount, newcount; + int oldindex, newindex; +} HASHMAP; + +/* + * Structures for soft labels. + */ + +struct _SLK; + +#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) + +typedef struct +{ + 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 _SLK { + bool dirty; /* all labels have changed */ + bool hidden; /* soft labels are hidden */ + WINDOW *win; + slk_ent *ent; + 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 */ + +#if USE_GPM_SUPPORT +#undef buttons /* term.h defines this, and gpm uses it! */ +#include +#if USE_WEAK_SYMBOLS +weak_symbol(Gpm_Wgetch); +#endif + +#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_PARM->_mouse_gpm_fd +#define my_Gpm_Open SP_PARM->_mouse_Gpm_Open +#define my_Gpm_Close SP_PARM->_mouse_Gpm_Close +#define my_Gpm_GetEvent SP_PARM->_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 */ + +/* + * Limit delay-times to 30 seconds, which is consistent with signed 16-bit + * numbers in legacy terminfo. + */ +#define MAX_DELAY_MSECS 30000 + +/* + * Limit screen dimensions read from environment variables. + */ +#define MAX_ENV_LINES 512 +#define MAX_ENV_COLUMNS 512 + +/* + * When converting from terminfo to termcap, check for cases where we can trim + * octal escapes down to 2-character form. It is useful for terminfo format + * also, but not as important. + */ +#define MAX_TC_FIXUPS 10 +#define MIN_TC_FIXUPS 4 + +#define isoctal(c) ((c) >= '0' && (c) <= '7') + +/* + * 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. + * + * The leading "./" is used in _nc_to_dospath() to decide whether to prefix + * the converted path with the MinGW32 base directory. + */ +#if MIXEDCASE_FILENAMES +#define LEAF_FMT "./%c" +#define LEAF_LEN 3 +#else +#define LEAF_FMT "./%02x" +#define LEAF_LEN 4 +#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 TRACECHR_BUF 40 +#define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15)) +#define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */ + +#if USE_TERM_DRIVER +struct DriverTCB; /* Terminal Control Block forward declaration */ +#define INIT_TERM_DRIVER() _nc_globals.term_driver = _nc_get_driver +#else +#define INIT_TERM_DRIVER() /* nothing */ +#endif + +extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; + +/* The limit reserves one byte for a terminating NUL */ +#define my_getstr_limit (_nc_globals.getstr_limit - 1) +#define _nc_getstr_limit(n) \ + (((n) < 0) \ + ? my_getstr_limit \ + : (((n) > my_getstr_limit) \ + ? my_getstr_limit \ + : (n))) + +/* + * Use screen-specific ripoff data (for softkeys) rather than global. + */ +#ifdef USE_SP_RIPOFF +#define safe_ripoff_sp (sp)->rsp +#define safe_ripoff_stack (sp)->rippedoff +#else +#define safe_ripoff_sp _nc_prescreen.rsp +#define safe_ripoff_stack _nc_prescreen.rippedoff +#endif + +extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen; + +typedef enum { + ewUnknown = 0, + ewInitial, + ewRunning, + ewSuspend +} ENDWIN; + +typedef struct { + 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 */ +} TTY_FLAGS; + +#define IsNl(sp) (sp)->_tty_flags._nl +#define IsRaw(sp) (sp)->_tty_flags._raw +#define IsCbreak(sp) (sp)->_tty_flags._cbreak +#define IsEcho(sp) (sp)->_tty_flags._echo + +/* + * The SCREEN structure. + */ +typedef struct screen { + int _ifd; /* input file descriptor for screen */ + int _ofd; /* output file descriptor for screen */ + FILE *_ofp; /* output file ptr for screen */ + char *out_buffer; /* output buffer */ + size_t out_limit; /* output buffer size */ + size_t out_inuse; /* output buffer current use */ + bool _filtered; /* filter() was called */ + bool _prescreen; /* is in prescreen phase */ + bool _use_env; /* LINES & COLS from environment? */ + 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 */ + +#define CurScreen(sp) (sp)->_curscr +#define NewScreen(sp) (sp)->_newscr +#define StdScreen(sp) (sp)->_stdscr + + 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 */ + TTY_FLAGS _tty_flags; + 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 */ + 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 _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) */ + /* used in lib_mvcur.c */ + char * _address_cursor; + /* used in tty_update.c */ + int _scrolling; /* 1 if terminal's smart enough to */ + + /* used in lib_color.c */ + rgb_bits_t _direct_color; /* RGB overrides color-table */ + 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; /* same as COLOR_PAIRS */ + int _pair_limit; /* actual limit of color-pairs */ + int _pair_alloc; /* current table-size of color-pairs */ + 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' */ + + /* + * These data correspond to the state of the idcok() and idlok() + * functions. A caveat is in order here: the XSI and SVr4 + * documentation specify that these functions apply to the window which + * 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; + + /* + * These are the data that support the mouse interface. + */ + 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; /* set via mousemask() */ + mmask_t _mouse_mask2; /* OR's in press/release bits */ + mmask_t _mouse_bstate; + MouseFormat _mouse_format; /* type of xterm mouse protocol */ + NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */ + MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */ + MEVENT *_mouse_readp; /* read pointer into event queue */ + MEVENT *_mouse_writep; /* write pointer into event queue */ + + /* + * These are data that support the proper handling of the panel stack on an + * per screen basis. + */ + struct panelhook _panelHook; + + 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; + + NCURSES_SP_OUTC _outch; /* output handler if not putc */ + NCURSES_OUTC jump; + + ripoff_t rippedoff[N_RIPS]; + ripoff_t *rsp; + + int _legacy_coding; /* see use_legacy_coding() */ + +#if NCURSES_NO_PADDING + bool _no_padding; /* flag to set if padding disabled */ +#endif + +#if USE_HARD_TABS + int _ht_cost; /* cost of (tab) */ + int _cbt_cost; /* cost of (backtab) */ +#endif /* USE_HARD_TABS */ + + /* used in lib_vidattr.c */ +#if USE_ITALIC + bool _use_ritm; /* true if we may use 'ritm' */ +#endif + + /* used in getch/twait */ +#if USE_KLIBC_KBD + bool _extended_key; /* true if an extended key */ +#endif + + /* used in lib_color.c */ +#if NCURSES_EXT_FUNCS + bool _assumed_color; /* use assumed colors */ + 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 */ + int _default_pairs; /* count pairs using default color */ +#endif + + /* system-dependent mouse data */ +#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 + +#if USE_TERM_DRIVER || USE_NAMED_PIPES + MEVENT _drv_mouse_fifo[FIFO_SIZE]; + int _drv_mouse_head; + int _drv_mouse_tail; + int _drv_mouse_old_buttons; + int _drv_mouse_new_buttons; +#endif + /* + * This supports automatic resizing + */ +#if USE_SIZECHANGE + int (*_resize)(NCURSES_SP_DCLx int y, int x); + int (*_ungetch)(SCREEN *, int); +#endif + +#ifdef USE_SP_WINDOWLIST + WINDOWLIST* _windowlist; +#define WindowList(sp) (sp)->_windowlist +#endif + +#if USE_REENTRANT + char _ttytype[NAMESIZE]; + int _ESCDELAY; + int _TABSIZE; + int _LINES; + int _COLS; +#endif + +#if NCURSES_SP_FUNCS + bool use_tioctl; +#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; + bool _screen_unicode; +#endif + +#if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS + void *_ordered_pairs; /* index used by alloc_pair() */ + int _pairs_used; /* actual number of color-pairs used */ + int _recent_pair; /* number for most recent free-pair */ +#endif + +#ifdef TRACE + char tracechr_buf[TRACECHR_BUF]; + char tracemse_buf[TRACEMSE_MAX]; +#if USE_REENTRANT + long _outchars; + const char *_tputs_trace; +#endif +#endif +#undef SCREEN +} SCREEN; + +extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; +extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; + + WINDOWLIST { + WINDOWLIST *next; + SCREEN *screen; /* screen containing the window */ + WINDOW win; /* WINDOW_EXT() needs to account for offset */ +#if NCURSES_WIDECHAR + 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 +}; + +#define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m) + +#ifdef USE_SP_WINDOWLIST +#define SP_INIT_WINDOWLIST(sp) WindowList(sp) = NULL +#else +#define SP_INIT_WINDOWLIST(sp) /* nothing */ +#endif + +#define SP_PRE_INIT(sp) \ + sp->_cursrow = -1; \ + sp->_curscol = -1; \ + IsNl(sp) = TRUE; \ + IsRaw(sp) = FALSE; \ + IsCbreak(sp) = 0; \ + IsEcho(sp) = TRUE; \ + sp->_fifohead = -1; \ + sp->_endwin = ewSuspend; \ + sp->_cursor = -1; \ + SP_INIT_WINDOWLIST(sp); \ + sp->_outch = NCURSES_OUTC_FUNC; \ + sp->jump = NULL \ + +/* usually in */ +#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 + +#ifndef Max +#define Max(a,b) ((a) < (b) ? (b) : (a)) +#endif + +/* usually in */ +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#ifndef STDERR_FILENO +#define STDERR_FILENO 2 +#endif + +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif + +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif + +#ifndef R_OK +#define R_OK 4 /* Test for read permission. */ +#endif +#ifndef W_OK +#define W_OK 2 /* Test for write permission. */ +#endif +#ifndef X_OK +#define X_OK 1 /* Test for execute permission. */ +#endif +#ifndef F_OK +#define F_OK 0 /* Test for existence. */ +#endif + +#if HAVE_FCNTL_H +#include /* may define O_BINARY */ +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +#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 UShort(c) ((unsigned short)(c)) +#define ChCharOf(c) ((chtype)(c) & (chtype)A_CHARTEXT) +#define ChAttrOf(c) ((chtype)(c) & (chtype)A_ATTRIBUTES) + +#define TR_PUTC(c) TR(TRACE_CHARPUT, ("PUTC %#x", UChar(c))) + +#if USE_WIDEC_SUPPORT /* { */ +/* true if the status/errno indicate an illegal multibyte sequence */ +#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 + +#if NCURSES_RGB_COLORS +#define NulDirect , 0 +#else +#define NulDirect /* nothing */ +#endif + +#if CCHARW_MAX > 6 +#define NulChar 0,0,0,0,0 +#elif CCHARW_MAX > 5 +#define NulChar 0,0,0,0 /* ncurses7 */ +#elif CCHARW_MAX > 4 +#define NulChar 0,0,0 /* ncurses6 */ +#elif CCHARW_MAX > 3 +#define NulChar 0,0 +#elif CCHARW_MAX > 2 +#define NulChar 0 +#else +#define NulChar /* nothing */ +#endif + +#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 NulDirect } +#define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch)) + +#if CCHARW_MAX > 1 +#define CharEq(a,b) (((a).attr == (b).attr) \ + && !memcmp((a).chars, \ + (b).chars, \ + CCHARW_MAX * sizeof((b).chars[0])) \ + 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] = (wchar_t) (c); \ + _cp->attr = (a); \ + if_EXT_COLORS(SetPair(ch, PairNumber(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) do { if(!isWidecExt(ch)) { \ + if (Charable(ch)) { \ + TR_PUTC(CharOf(ch)); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) CharOf(ch)); \ + COUNT_OUTCHARS(1); \ + } else { \ + for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \ + PUTC_ch = (ch).chars[PUTC_i]; \ + if (PUTC_ch == L'\0') \ + break; \ + PUTC_INIT; \ + PUTC_n = (int) wcrtomb(PUTC_buf, \ + (ch).chars[PUTC_i], &PUT_st); \ + if (PUTC_n <= 0) { \ + if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) { \ + TR_PUTC(CharOf(ch)); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) CharOf(ch)); \ + } \ + break; \ + } else if (PUTC_n > 1 || !is8bits(PUTC_ch)) { \ + int PUTC_j; \ + for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \ + TR_PUTC(PUTC_buf[PUTC_j]); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \ + } \ + } else { \ + PUTC_buf[0] = (char) PUTC_ch; \ + TR_PUTC(PUTC_buf[0]); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[0]); \ + } \ + } \ + 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) (int) (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) |= (attr_t) (ext + 1) + +#define if_WIDEC(code) code +#define Charable(ch) (((SP_PARM->_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 /* nothing */ +#define PUTC(ch) { \ + TR_PUTC(ch); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) ch); \ + } + +#define BLANK (' '|A_NORMAL) +#define ZEROS ('\0'|A_NORMAL) +#define ISBLANK(ch) (CharOf(ch) == ' ') + +#define isWidecExt(ch) (0) +#define if_WIDEC(code) /* nothing */ + +#define Charable(ch) (CharOf(ch) >= ' ' && CharOf(ch) <= '~') +#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) != NULL && \ + ((x) >= 0 && (x) <= (w)->_maxx && \ + (y) >= 0 && (y) <= (w)->_maxy)) + +#define OK_DIMENSION(n) ((NCURSES_SIZE_T)(n) == (n) && (n) > 0) + +#define CHANGED_CELL(line,col) \ + if (line->firstchar == _NOCHANGE) \ + line->firstchar = line->lastchar = (NCURSES_SIZE_T) (col); \ + else if ((col) < line->firstchar) \ + line->firstchar = (NCURSES_SIZE_T) (col); \ + else if ((col) > line->lastchar) \ + line->lastchar = (NCURSES_SIZE_T) (col) + +#define CHANGED_RANGE(line,start,end) \ + if (line->firstchar == _NOCHANGE \ + || line->firstchar > (start)) \ + line->firstchar = (NCURSES_SIZE_T) (start); \ + if (line->lastchar == _NOCHANGE \ + || line->lastchar < (end)) \ + line->lastchar = (NCURSES_SIZE_T) (end) + +#define CHANGED_TO_EOL(line,start,end) \ + if (line->firstchar == _NOCHANGE \ + || line->firstchar > (start)) \ + line->firstchar = (NCURSES_SIZE_T) (start); \ + line->lastchar = (NCURSES_SIZE_T) (end) + +#define SIZEOF(v) (sizeof(v)/sizeof(v[0])) + +#include +#include + +#define FreeIfNeeded(p) if ((p) != NULL) free(p) + +/* FreeAndNull() is not a comma-separated expression because some compilers + * do not accept a mixture of void with values. + */ +#define FreeAndNull(p) do { free(p); p = NULL; } while (0) + +#ifdef EXP_OOM_TESTING +extern NCURSES_EXPORT(void *) _nc_oom_malloc(size_t size); +extern NCURSES_EXPORT(void *) _nc_oom_calloc(size_t nmemb, size_t size); +extern NCURSES_EXPORT(void *) _nc_oom_realloc(void *ptr, size_t size); +extern NCURSES_EXPORT(void) _nc_oom_free(void *ptr); +extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr); +#define malloc(size) _nc_oom_malloc(size) +#define calloc(nmemb, size) _nc_oom_calloc(nmemb, size) +#define realloc(ptr, size) _nc_oom_realloc(ptr, size) +#define free(ptr) _nc_oom_free(ptr) +#define strdup(ptr) _nc_oom_strdup(ptr) +#endif + +/* + * Use these for tic/infocmp malloc failures. Generally the ncurses library + * tries to limp along after a failure. + */ +#define TYPE_MALLOC(type, size, name) \ + do { \ + name = typeMalloc(type, size); \ + if (name == NULL) \ + _nc_err_abort(MSG_NO_MEMORY); \ + } while (0) + +#define TYPE_CALLOC(type, size, name) \ + do { \ + name = typeCalloc(type, size); \ + if (name == NULL) \ + _nc_err_abort(MSG_NO_MEMORY); \ + } while (0) + +#define TYPE_REALLOC(type, size, name) \ + do { \ + name = typeRealloc(type, size, name); \ + if (name == NULL) \ + _nc_err_abort(MSG_NO_MEMORY); \ + } while (0) + +/* + * 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 + +#ifdef __TANDEM +#define ROOT_UID 65535 +#endif + +#ifndef ROOT_UID +#define ROOT_UID 0 +#endif + +/* + * Standardize/simplify common loops + */ +#define each_screen(p) p = _nc_screen_chain; p != NULL; p = (p)->_next_screen +#define each_window(sp,p) p = WindowList(sp); p != NULL; p = (p)->next +#define each_ripoff(p) p = safe_ripoff_stack; (p - safe_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 NonNull(s) ((s) != NULL ? s : "") +#define NonEmpty(s) ((s) != NULL && *(s) != '\0') + +#ifdef TRACE + +#if USE_REENTRANT +#define TPUTS_TRACE(s) _nc_set_tputs_trace(s); +#else +#define TPUTS_TRACE(s) _nc_tputs_trace = s; +#endif + +#ifdef HAVE_CONSISTENT_GETENV +#define START_TRACE() \ + if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \ + int t = _nc_getenv_num("NCURSES_TRACE"); \ + if (t >= 0) \ + curses_trace((unsigned) t); \ + } +#else +#define START_TRACE() /* nothing */ +#endif + +/* + * 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((type)(value)) +#define TRACE_RETURN1(value,dst) return _nc_retrace_##dst(value) +#define TRACE_RETURN2(value,dst,src) return _nc_retrace_##dst##_##src(value) +#define TRACE_RETURN_SP(value,type) return _nc_retrace_##type(SP_PARM, value) + +typedef void VoidFunc(void); + +#define TR_FUNC_LEN ((sizeof(void *) + sizeof(void (*)(void))) * 2 + 4) +#define TR_FUNC_BFR(max) char tr_func_data[max][TR_FUNC_LEN] +#define TR_FUNC_ARG(num,func) _nc_fmt_funcptr(&tr_func_data[num][0], (const char *)&(func), sizeof((func))) + +#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_RETURN1(code,cptr) +#define returnCVoidPtr(code) TRACE_RETURN1(code,cvoid_ptr) +#define returnChar(code) TRACE_RETURN(code,char) +#define returnChtype(code) TRACE_RETURN(code,chtype) +#define returnCode(code) TRACE_RETURN(code,int) +#define returnIntAttr(code) TRACE_RETURN2(code,int,attr_t) +#define returnMMask(code) TRACE_RETURN_SP(code,mmask_t) +#define returnPtr(code) TRACE_RETURN1(code,ptr) +#define returnSP(code) TRACE_RETURN1(code,sp) +#define returnVoid { T((T_RETURN(""))); return; } +#define returnVoidPtr(code) TRACE_RETURN1(code,void_ptr) +#define returnWin(code) TRACE_RETURN1(code,win) + +#define returnDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("code %d"), (rc))); return (rc); } while (0) +#define returnPtrDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0) +#define returnVoidDB do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0) + +extern NCURSES_EXPORT(bool) _nc_retrace_bool (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(const 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(char) _nc_retrace_char (int); +extern NCURSES_EXPORT(int) _nc_retrace_int (int); +extern NCURSES_EXPORT(int) _nc_retrace_int_attr_t (attr_t); +extern NCURSES_EXPORT(mmask_t) _nc_retrace_mmask_t (SCREEN *, mmask_t); +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 *); + +extern NCURSES_EXPORT(char *) _nc_fmt_funcptr(char *, const char *, size_t); + +#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; + +extern NCURSES_EXPORT(char *) _nc_tracebits (void); +extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *); +extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *); + +#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 TR_FUNC_BFR(max) + +#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 ((char) code) +#define returnChtype(code) return code +#define returnCode(code) return code +#define returnIntAttr(code) return code +#define returnMMask(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 + +#define returnDB(code) return code +#define returnPtrDB(rc) return rc +#define returnVoidDB return + +#endif /* TRACE/!TRACE */ + +/* + * Workaround for defective implementation of gcc attribute warn_unused_result + */ +#if defined(__GNUC__) && defined(_FORTIFY_SOURCE) +#define IGNORE_RC(func) errno = (int) func +#else +#define IGNORE_RC(func) (void) func +#endif /* gcc workarounds */ + +/* + * 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 EMPTY_MODULE(name) \ +extern NCURSES_EXPORT(void) name (void); \ + NCURSES_EXPORT(void) name (void) { } + +#define ALL_BUT_COLOR ((chtype)~(A_COLOR)) +#define NONBLANK_ATTR (A_BOLD | A_DIM | A_BLINK | A_ITALIC) +#define TPARM_ATTR (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_ALTCHARSET | A_INVIS | A_PROTECT) +#define XMC_CONFLICT (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_INVIS | A_PROTECT | A_ITALIC) +#define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress) + +#define toggle_attr_on(S,at) {\ + if (PairNumber(at) > 0) {\ + (S) = ((S) & ALL_BUT_COLOR) | (attr_t) (at);\ + } else {\ + (S) |= (attr_t) (at);\ + }\ + TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} + + +#define toggle_attr_off(S,at) {\ + if (PairNumber(at) > 0) {\ + (S) &= ~(at|A_COLOR);\ + } else {\ + (S) &= ~(at);\ + }\ + TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} + +#define DelCharCost(sp,count) \ + ((parm_dch != NULL) \ + ? sp->_dch_cost \ + : ((delete_character != NULL) \ + ? (sp->_dch1_cost * count) \ + : NC_INFINITY)) + +#define InsCharCost(sp,count) \ + ((parm_ich != NULL) \ + ? sp->_ich_cost \ + : ((enter_insert_mode && exit_insert_mode) \ + ? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \ + : ((insert_character != NULL) \ + ? ((sp->_ich1_cost + sp->_ip_cost) * count) \ + : NC_INFINITY))) + +#if USE_XMC_SUPPORT +#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ + attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \ + VIDPUTS(sp, AttrOf(c), GetPair(c)); \ + if (magic_cookie_glitch > 0 \ + && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(sp))))) { \ + T(("%s @%d before glitch %d,%d", \ + __FILE__, __LINE__, \ + sp->_cursrow, \ + sp->_curscol)); \ + NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \ + } \ + } +#else +#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ + VIDPUTS(sp, AttrOf(c), GetPair(c)); \ + } +#endif + +#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS + +#undef toggle_attr_on +#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at) +extern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t); + +#undef toggle_attr_off +#define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at) +extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t); + +#undef DelCharCost +#define DelCharCost(sp, count) NCURSES_SP_NAME(_nc_DelCharCost)(NCURSES_SP_ARGx count) + +#undef InsCharCost +#define InsCharCost(sp, count) NCURSES_SP_NAME(_nc_InsCharCost)(NCURSES_SP_ARGx count) + +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int _c); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int _c); + +#undef UpdateAttrs +#define UpdateAttrs(sp,c) NCURSES_SP_NAME(_nc_UpdateAttrs)(NCURSES_SP_ARGx CHREF(c)) + +#if USE_WIDEC_SUPPORT || defined(NEED_NCURSES_CH_T) +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T _c); +#else +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx chtype c); +#endif + +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(int) _nc_DelCharCost (int); +extern NCURSES_EXPORT(int) _nc_InsCharCost (int); +extern NCURSES_EXPORT(void) _nc_UpdateAttrs (CARG_CH_T); +#endif /* NCURSES_SP_FUNCS */ + +#else + +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 + +#define save_ttytype(termp) \ + if (TerminalType(termp).term_names != NULL) { \ + _nc_STRNCPY(ttytype, \ + TerminalType(termp).term_names, \ + NAMESIZE - 1); \ + ttytype[NAMESIZE - 1] = '\0'; \ + } + +#if !NCURSES_WCWIDTH_GRAPHICS +extern NCURSES_EXPORT(int) _nc_wacs_width(wchar_t); +#else +#define _nc_wacs_width(ch) wcwidth(ch) +#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; + +/* comp_userdefs.c */ +typedef struct { + short ute_name; /* offset of name to hash on */ + unsigned ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ + unsigned ute_argc; /* number of parameters */ + unsigned ute_args; /* bit-mask for string parameters */ + short ute_index; /* index of associated variable in its array */ + short ute_link; /* index in table of next hash, or -1 */ +} user_table_data; + +/* doupdate.c */ +#if USE_XMC_SUPPORT +extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t); +#endif + +/* hardscroll.c */ +#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) +extern NCURSES_EXPORT(void) _nc_linedump (void); +#endif + +/* lib_acs.c */ +extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */ +extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); + +/* lib_addch.c */ +#if USE_WIDEC_SUPPORT +extern NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch); +#endif + +/* lib_addstr.c */ +#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) +extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *); +#endif + +/* lib_color.c */ +extern NCURSES_EXPORT(int) _nc_init_color(SCREEN *, int, int, int, int); +extern NCURSES_EXPORT(int) _nc_init_pair(SCREEN *, int, int, int); +extern NCURSES_EXPORT(int) _nc_pair_content(SCREEN *, int, int *, int *); +extern NCURSES_EXPORT(bool) _nc_reset_colors(void); +extern NCURSES_EXPORT(void) _nc_reserve_pairs(SCREEN *, int); +extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int); + +#define ReservePairs(sp,want) \ + if ((sp->_color_pairs == NULL) || (want >= sp->_pair_alloc)) \ + _nc_reserve_pairs(sp, want) + +/* lib_getch.c */ +extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *)); + +/* lib_insch.c */ +extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype); + +/* lib_mouse.c */ +extern NCURSES_EXPORT(bool) _nc_has_mouse (const SCREEN *); + +/* lib_mvcur.c */ +#define NC_INFINITY 1000000 /* cost: too high to use */ +#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */ + +extern NCURSES_EXPORT(int) _nc_mvcur(int yold, int xold, int ynew, int xnew); + +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); + +/* lib_setup.c */ +extern NCURSES_EXPORT(char *) _nc_get_locale(void); +extern NCURSES_EXPORT(bool) _nc_unicode_locale(void); +extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); +extern NCURSES_EXPORT(int) _nc_setupterm(const char *, int, int *, int); +extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); + +#ifdef USE_PTHREADS +extern NCURSES_EXPORT(SCREEN *) _nc_find_prescr(void); +extern NCURSES_EXPORT(void) _nc_forget_prescr(void); +#else +#define _nc_find_prescr() _nc_prescreen.allocated +#define _nc_forget_prescr() _nc_prescreen.allocated = NULL +#endif + +/* lib_set_term.c */ +extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); + +/* lib_setup.c */ +#define ExitTerminfo(code) exit_terminfo(code) + +#define SETUP_FAIL ERR + +#define ret_error(rc, fmt, p, q) if (errret) {\ + *errret = rc;\ + q;\ + returnCode(SETUP_FAIL);\ + } else {\ + fprintf(stderr, fmt, p);\ + q;\ + ExitTerminfo(EXIT_FAILURE);\ + } + +#define ret_error1(rc, fmt, p, q) ret_error(rc, "'%s': " fmt, p, q) + +#define ret_error0(rc, msg) if (errret) {\ + *errret = rc;\ + returnCode(SETUP_FAIL);\ + } else {\ + fprintf(stderr, msg);\ + ExitTerminfo(EXIT_FAILURE);\ + } + +/* lib_tstp.c */ +#if USE_SIGWINCH +extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *); +#else +#define _nc_handle_sigwinch(a) /* nothing */ +#endif + +/* lib_wacs.c */ +#if USE_WIDEC_SUPPORT +extern NCURSES_EXPORT(void) _nc_init_wacs(void); +#endif + +typedef struct { + 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 *, 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 *, const 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 +extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *); +#endif + +/* safe_sprintf.c */ +extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list); + +/* tries.c */ +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(SCREEN *) _nc_screen_of (WINDOW *); +extern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void); +extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int); +extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t); +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(char *) _nc_trace_mmask_t (SCREEN *, mmask_t); +extern NCURSES_EXPORT(int) _nc_access (const char *, int); +extern NCURSES_EXPORT(int) _nc_baudrate (int); +extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *); +extern NCURSES_EXPORT(int) _nc_getenv_num (const char *); +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_putchar (int); +extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *); +extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *); +extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2 *const); +extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *); +extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int); +extern NCURSES_EXPORT(int) _nc_timed_wait (const SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); +extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *); +extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const); +extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC); +extern NCURSES_EXPORT(void) _nc_flush (void); +extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, const TERMTYPE2 *); +extern NCURSES_EXPORT(void) _nc_freeall (void); +extern NCURSES_EXPORT(void) _nc_hash_map (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_reset_input (FILE *, char *); +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_set_buffer (FILE *, int); +extern NCURSES_EXPORT(void) _nc_setenv_num (const char *, int); +extern NCURSES_EXPORT(void) _nc_signal_handler (int); +extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *); +extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *); + +#if NCURSES_EXT_NUMBERS +extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *); +#else +#define _nc_fallback2(tp) _nc_fallback(tp) +#endif + +extern NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *); + +#if NCURSES_EXT_NUMBERS +extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *); +extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *); +#else +#define _nc_copy_termtype2(dst,src) _nc_copy_termtype((dst),(src)) +#define _nc_export_termtype2(dst,src) /* nothing */ +#define _nc_free_termtype2(t) _nc_free_termtype(t) +/* also... */ +#define _nc_read_entry2 _nc_read_entry +#endif + +#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_error_leaks(void); +extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void); +extern NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void); +extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void); +extern NCURSES_EXPORT(void) _nc_keyname_leaks(void); +extern NCURSES_EXPORT(void) _nc_names_leaks(void); +extern NCURSES_EXPORT(void) _nc_tgetent_leak(const TERMINAL *); +extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void); +#endif + +#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) +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, int const, int const, NCURSES_CH_T); +#endif + +#if USE_WIDEC_SUPPORT +extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *); +#endif + +#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) +extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *); +#endif + +#if USE_SIZECHANGE +extern NCURSES_EXPORT(void) _nc_update_screensize (SCREEN *); +#endif + +#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 + +/* + * Wide-character macros to hide some platform-differences. + */ +#if USE_WIDEC_SUPPORT + +#if defined(_NC_WINDOWS_NATIVE) && !defined(_NC_MSC) && !USE_NAMED_PIPES +/* + * MinGW has wide-character functions, but they do not work correctly. + */ +extern int __MINGW_NOTHROW _nc_wctomb(char *, wchar_t); +#define wctomb(s,wc) _nc_wctomb(s,wc) +#define wcrtomb(s,wc,n) _nc_wctomb(s,wc) + +extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); +#define mbtowc(pwc,s,n) _nc_mbtowc(pwc,s,n) + +extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); +#define mblen(s,n) _nc_mblen(s, n) + +#endif /* _NC_WINDOWS_NATIVE && !_NC_MSC */ + +#if HAVE_MBTOWC && HAVE_MBLEN +#define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0)) +#define count_mbytes(buffer,length,state) mblen(buffer,length) +#define check_mbytes(wch,buffer,length,state) \ + (int) mbtowc(&(wch), buffer, length) +#define state_unused +#elif HAVE_MBRTOWC && HAVE_MBRLEN +#define reset_mbytes(state) init_mb(state) +#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&(state)) +#define check_mbytes(wch,buffer,length,state) \ + (int) mbrtowc(&(wch), buffer, length, &(state)) +#else +make an error +#endif + +#endif /* USE_WIDEC_SUPPORT */ + +/* + * 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 */ +extern NCURSES_EXPORT_VAR(int *) _nc_oldnums; + +#define USE_SETBUF_0 0 + +#define NC_OUTPUT(sp) ((sp != NULL && sp->_ofp != NULL) ? sp->_ofp : stdout) + +/* + * On systems with a broken linker, define 'SP' as a function to force the + * linker to pull in the data-only module with 'SP'. + */ +#define _nc_alloc_screen_sp() typeCalloc(SCREEN, 1) + +#if BROKEN_LINKER +#define SP _nc_screen() +extern NCURSES_EXPORT(SCREEN *) _nc_screen (void); +extern NCURSES_EXPORT(int) _nc_alloc_screen (void); +extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *); +#define CURRENT_SCREEN _nc_screen() +#else +/* current screen is private data; avoid possible linking conflicts too */ +extern NCURSES_EXPORT_VAR(SCREEN *) SP; +#define CURRENT_SCREEN SP +#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != NULL) +#define _nc_set_screen(sp) SP = sp +#endif + +#if NCURSES_SP_FUNCS +#define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr()) +#else +#define CURRENT_SCREEN_PRE CURRENT_SCREEN +#endif + +/* + * We don't want to use the lines or columns capabilities internally, because + * if the application is running multiple screens under X, it is quite possible + * they could all have type xterm but have different sizes! So... + */ +#define screen_lines(sp) (sp)->_lines +#define screen_columns(sp) (sp)->_columns + +extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int); +extern NCURSES_EXPORT(int) _nc_format_slks (NCURSES_SP_DCLx int _c); + +/* + * Some constants related to SLK's + */ +#define MAX_SKEY_OLD 8 /* count of soft keys */ +#define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */ +#define MAX_SKEY_PC 12 /* This is what most PC's have */ +#define MAX_SKEY_LEN_PC 5 + +/* Macro to check whether or not we use a standard format */ +#define SLK_STDFMT(fmt) (fmt < 3) +/* Macro to determine height of label window */ +#define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2)) + +#define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC) +#define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC) + +/* + * Common error messages + */ +#define MSG_NO_MEMORY "Out of memory" +#define MSG_NO_INPUTS "Premature EOF" + +extern NCURSES_EXPORT(int) _nc_set_tty_mode(TTY *); +extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); + +/* timed_wait flag definitions */ +#define TW_NONE 0 +#define TW_INPUT 1 +#define TW_MOUSE 2 +#define TW_ANY (TW_INPUT | TW_MOUSE) +#define TW_EVENT 4 + +#define SetSafeOutcWrapper(outc) \ + SCREEN* sp = CURRENT_SCREEN; \ + struct screen outc_wrapper; \ + if (sp == NULL) { \ + sp = &outc_wrapper; \ + memset(sp,0,sizeof(struct screen)); \ + sp->_outch = _nc_outc_wrapper; \ + }\ + sp->jump = outc + +#if USE_TERM_DRIVER + +typedef struct _termInfo +{ + bool caninit; + + bool hascolor; + bool initcolor; + bool canchange; + + int tabsize; + + int maxcolors; + int maxpairs; + int nocolorvideo; + + int numbuttons; + int numlabels; + int labelwidth; + int labelheight; + + const color_t* defaultPalette; +} TerminalInfo; + +typedef struct term_driver { + bool isTerminfo; + const char* (*td_name)(struct DriverTCB*); + bool (*td_CanHandle)(struct DriverTCB*, const char*, int*); + void (*td_init)(struct DriverTCB*); + void (*td_release)(struct DriverTCB*); + int (*td_size)(struct DriverTCB*, int* Line, int *Cols); + int (*td_sgmode)(struct DriverTCB*, int setFlag, TTY*); + chtype (*td_conattr)(struct DriverTCB*); + int (*td_hwcur)(struct DriverTCB*, int yold, int xold, int y, int x); + int (*td_mode)(struct DriverTCB*, int progFlag, int defFlag); + bool (*td_rescol)(struct DriverTCB*); + bool (*td_rescolors)(struct DriverTCB*); + void (*td_color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int)); + int (*td_doBeepOrFlash)(struct DriverTCB*, int); + void (*td_initpair)(struct DriverTCB*, int, int, int); + void (*td_initcolor)(struct DriverTCB*, int, int, int, int); + void (*td_docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int)); + void (*td_initmouse)(struct DriverTCB*); + int (*td_testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*)); + void (*td_setfilter)(struct DriverTCB*); + void (*td_hwlabel)(struct DriverTCB*, int, char*); + void (*td_hwlabelOnOff)(struct DriverTCB*, int); + int (*td_update)(struct DriverTCB*); + int (*td_defaultcolors)(struct DriverTCB*, int, int); + int (*td_print)(struct DriverTCB*, char*, int); + int (*td_getsize)(struct DriverTCB*, int*, int*); + int (*td_setsize)(struct DriverTCB*, int, int); + void (*td_initacs)(struct DriverTCB*, chtype*, chtype*); + void (*td_scinit)(SCREEN *); + void (*td_scexit)(SCREEN *); + int (*td_twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*)); + int (*td_read)(struct DriverTCB*, int*); + int (*td_nap)(struct DriverTCB*, int); + int (*td_kpad)(struct DriverTCB*, int); + int (*td_kyOk)(struct DriverTCB*, int, int); + bool (*td_kyExist)(struct DriverTCB*, int); + int (*td_cursorSet)(struct DriverTCB*, int); +} TERM_DRIVER; + +typedef struct DriverTCB +{ + TERMINAL term; /* needs to be the first Element !!! */ + TERM_DRIVER* drv; /* The driver for that Terminal */ + SCREEN* csp; /* The screen that owns that Terminal */ + TerminalInfo info; /* Driver independent core capabilities of the Terminal */ + void* prop; /* Driver dependent property storage to be used by the Driver */ + long magic; +} TERMINAL_CONTROL_BLOCK; + +#define NCDRV_MAGIC(id) (0x47110000 | (id&0xffff)) +#define NCDRV_TINFO 0x01 +#define NCDRV_WINCONSOLE 0x02 + +#define TCBOf(sp) ((TERMINAL_CONTROL_BLOCK*)(TerminalOf(sp))) +#define InfoOf(sp) TCBOf(sp)->info +#define CallDriver(sp,method) TCBOf(sp)->drv->method(TCBOf(sp)) +#define CallDriver_1(sp,method,arg1) TCBOf(sp)->drv->method(TCBOf(sp),arg1) +#define CallDriver_2(sp,method,arg1,arg2) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2) +#define CallDriver_3(sp,method,arg1,arg2,arg3) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3) +#define CallDriver_4(sp,method,arg1,arg2,arg3,arg4) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3,arg4) + +extern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette; +extern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette; + +extern NCURSES_EXPORT(int) _nc_get_driver(TERMINAL_CONTROL_BLOCK*, const char*, int*); +extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int *, int *); +#endif /* USE_TERM_DRIVER */ + +/* + * Entrypoints which are actually provided in the terminal driver, which would + * be an sp-name otherwise. + */ +#if USE_TERM_DRIVER +#define TINFO_HAS_KEY _nc_tinfo_has_key +#define TINFO_DOUPDATE _nc_tinfo_doupdate +#define TINFO_MVCUR _nc_tinfo_mvcur +extern NCURSES_EXPORT(int) TINFO_HAS_KEY(SCREEN*, int); +extern NCURSES_EXPORT(int) TINFO_DOUPDATE(SCREEN *); +extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int); +#else +#define TINFO_HAS_KEY NCURSES_SP_NAME(has_key) +#define TINFO_DOUPDATE NCURSES_SP_NAME(doupdate) +#define TINFO_MVCUR NCURSES_SP_NAME(_nc_mvcur) +#endif + +#ifdef _NC_WINDOWS +#if USE_WIDEC_SUPPORT +#include +#endif +#include +#include +#elif defined(_NC_WINDOWS_NATIVE) +#include +#include +#elif defined(__EMX__) +#include +#endif + +/* + * Entrypoints using an extra parameter with the terminal driver. + */ +#if USE_TERM_DRIVER +extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *); +extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, const char *, int , int *, int); +#define TINFO_GET_SIZE(sp, tp, lp, cp) \ + _nc_get_screensize(sp, tp, lp, cp) +#define TINFO_SET_CURTERM(sp, tp) \ + NCURSES_SP_NAME(set_curterm)(sp, tp) +#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ + _nc_setupterm_ex(tpp, name, fd, err, reuse) +#else /* !USE_TERM_DRIVER */ +extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); +#define TINFO_GET_SIZE(sp, tp, lp, cp) \ + _nc_get_screensize(sp, lp, cp) +#define TINFO_SET_CURTERM(sp, tp) \ + set_curterm(tp) +#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ + _nc_setupterm(name, fd, err, reuse) +#endif /* !USE_TERM_DRIVER */ + +#if USE_TERM_DRIVER +extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER; +extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; +#endif /* USE_TERM_DRIVER */ + +#ifdef TERMIOS +#define USE_WINCONMODE 0 +#elif defined(USE_WIN32CON_DRIVER) +#define USE_WINCONMODE 1 +extern NCURSES_EXPORT(int) _nc_console_setmode(void* handle, const ConsoleMode* arg); +extern NCURSES_EXPORT(int) _nc_console_getmode(void* handle, ConsoleMode* arg); +extern NCURSES_EXPORT(bool) _nc_console_checkinit(bool assumeTermInfo); +extern NCURSES_EXPORT(void*) _nc_console_fd2handle(int fd); +extern NCURSES_EXPORT(WORD) _nc_console_MapColor(bool fore, int color); +extern NCURSES_EXPORT(int) _nc_console_flush(void* handle); +extern NCURSES_EXPORT(bool) _nc_console_get_SBI(void); +extern NCURSES_EXPORT(HANDLE) _nc_console_handle(int fd); +extern NCURSES_EXPORT(int) _nc_console_isatty(int fd); +extern NCURSES_EXPORT(bool) _nc_console_keyExist(int keycode); +extern NCURSES_EXPORT(int) _nc_console_keyok(int keycode, int flag); +extern NCURSES_EXPORT(int) _nc_console_read(SCREEN *sp, HANDLE fd, int *buf); +extern NCURSES_EXPORT(bool) _nc_console_restore(void); +extern NCURSES_EXPORT(void) _nc_console_selectActiveHandle(void); +extern NCURSES_EXPORT(void) _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info); +extern NCURSES_EXPORT(void) _nc_console_size(int *Lines, int *Cols); +extern NCURSES_EXPORT(int) _nc_console_test(int fd); +extern NCURSES_EXPORT(int) _nc_console_testmouse(const SCREEN *sp, HANDLE fd, int delay EVENTLIST_2nd(_nc_eventlist*)); +extern NCURSES_EXPORT(int) _nc_console_twait(const SCREEN *sp, HANDLE hdl,int mode,int msec,int *left EVENTLIST_2nd(_nc_eventlist * evl)); +extern NCURSES_EXPORT(int) _nc_console_vt_supported(void); + +#ifdef _NC_CHECK_MINTTY +extern NCURSES_EXPORT(int) _nc_console_checkmintty(int fd, LPHANDLE pMinTTY); +#endif + +#else +#error unsupported driver configuration +#endif /* USE_WIN32CON_DRIVER */ + +#if USE_TERM_DRIVER && defined(USE_WIN32CON_DRIVER) +#define NC_ISATTY(fd) (0 != _nc_console_isatty(fd)) +#else +#define NC_ISATTY(fd) isatty(fd) +#endif + +/* + * Perhaps not "real" but possibly not "fake". + */ +#define IsRealTty(fd,value) \ + (NC_ISATTY(fd) \ + && (value = ttyname(fd)) != NULL \ + && strncmp(value, "/dev/pts/", 9)) + +#if USE_TERM_DRIVER +# define IsTermInfo(sp) ((TCBOf(sp) != NULL) && ((TCBOf(sp)->drv != NULL)) && ((TCBOf(sp)->drv->isTerminfo))) +# define HasTInfoTerminal(sp) ((NULL != TerminalOf(sp)) && IsTermInfo(sp)) +# if USE_NAMED_PIPES +# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes)) +# elif defined(USE_WIN32CON_DRIVER) +# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes)) +# else +# define IsTermInfoOnConsole(sp) FALSE +# endif +#else +# define IsTermInfo(sp) TRUE +# define HasTInfoTerminal(sp) (NULL != TerminalOf(sp)) +# if USE_NAMED_PIPES +# define IsTermInfoOnConsole(sp) _nc_console_test(TerminalOf(sp)->Filedes) +# else +# define IsTermInfoOnConsole(sp) FALSE +# endif +#endif + +#define IsValidTIScreen(sp) (HasTInfoTerminal(sp)) + +/* + * Exported entrypoints beyond the published API + */ +#if NCURSES_SP_FUNCS +extern NCURSES_EXPORT(WINDOW *) _nc_curscr_of(SCREEN*); +extern NCURSES_EXPORT(WINDOW *) _nc_newscr_of(SCREEN*); +extern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*); +extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int); + +#if USE_REENTRANT +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*); +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*); +#endif + +#if NCURSES_EXT_FUNCS +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int); +#endif + +/* + * We put the safe versions of various calls here as they are not published + * part of the API up to now + */ +extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_get_cur_term) (SCREEN *sp); +extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int); +extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*); +extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list); +extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(_nc_acs_char)(SCREEN*,int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_get_tty_mode)(SCREEN*,TTY*); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mvcur)(SCREEN*, int, int, int, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_outch)(SCREEN*, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putchar)(SCREEN*, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char*); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int)); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, bool, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_flush)(SCREEN*); +extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_freeall)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_hash_map)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_init_acs)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_make_oldhash)(SCREEN*, int i); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_init)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_resume)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_wrap)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_init)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_resume)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*); +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, int); + +extern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp); + +#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) +extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_linedump)(SCREEN*); +#endif + +#if USE_WIDEC_SUPPORT +extern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t *); +#endif + +#endif /* NCURSES_SP_FUNCS */ + +#if NCURSES_SP_FUNCS + +#define safe_keyname NCURSES_SP_NAME(keyname) +#define safe_unctrl NCURSES_SP_NAME(unctrl) +#define safe_ungetch NCURSES_SP_NAME(ungetch) + +#else + +#define safe_keyname _nc_keyname +#define safe_unctrl _nc_unctrl +#define safe_ungetch _nc_ungetch + +extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int); +extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int); +extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype); + +#endif + +#ifdef EXP_XTERM_1005 +extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned); +extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned); +#endif + +#ifdef _NC_WINDOWS +#if USE_WIDEC_SUPPORT +#define write_screen WriteConsoleOutputW +#define read_screen ReadConsoleOutputW +#define read_keycode ReadConsoleInputW +#define KeyEventChar KeyEvent.uChar.UnicodeChar +#define CharInfoChar Char.UnicodeChar +#else +#define write_screen WriteConsoleOutput +#define read_screen ReadConsoleOutput +#define read_keycode ReadConsoleInput +#define KeyEventChar KeyEvent.uChar.AsciiChar +#define CharInfoChar Char.AsciiChar +#endif +#endif /* _NC_WINDOWS */ + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ + +#endif /* CURSES_PRIV_H */ diff --git a/ncurses/ncurses/fifo_defs.h b/ncurses/ncurses/fifo_defs.h new file mode 100644 index 0000000000..befa5d1335 --- /dev/null +++ b/ncurses/ncurses/fifo_defs.h @@ -0,0 +1,89 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2012,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * Common macros for lib_getch.c, lib_ungetch.c + * + * $Id: fifo_defs.h,v 1.9 2020/02/02 23:34:34 tom Exp $ + */ + +#ifndef FIFO_DEFS_H +#define FIFO_DEFS_H 1 + +#define head sp->_fifohead +#define tail sp->_fifotail +/* peek points to next uninterpreted character */ +#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 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(sp); \ + } +#define p_inc() { \ + (peek >= FIFO_SIZE-1) \ + ? peek = 0 \ + : peek++; \ + } + +#define cooked_key_in_fifo() ((head >= 0) && (peek != head)) +#define raw_key_in_fifo() ((head >= 0) && (peek != tail)) + +#endif /* FIFO_DEFS_H */ diff --git a/ncurses/ncurses/llib-lncurses b/ncurses/ncurses/llib-lncurses new file mode 100644 index 0000000000..00b8602e3d --- /dev/null +++ b/ncurses/ncurses/llib-lncurses @@ -0,0 +1,4515 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tty/hardscroll.c */ + +#include + +#undef _nc_oldnums +int *_nc_oldnums; + +#undef _nc_scroll_optimize_sp +void _nc_scroll_optimize_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_scroll_optimize +void _nc_scroll_optimize(void) + { /* void */ } + +#undef _nc_linedump_sp +void _nc_linedump_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_linedump +void _nc_linedump(void) + { /* void */ } + +/* ./tty/hashmap.c */ + +#undef _nc_hash_map_sp +void _nc_hash_map_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_hash_map +void _nc_hash_map(void) + { /* void */ } + +#undef _nc_make_oldhash_sp +void _nc_make_oldhash_sp( + SCREEN *sp, + int i) + { /* void */ } + +#undef _nc_make_oldhash +void _nc_make_oldhash( + int i) + { /* void */ } + +#undef _nc_scroll_oldhash_sp +void _nc_scroll_oldhash_sp( + SCREEN *sp, + int n, + int top, + int bot) + { /* void */ } + +#undef _nc_scroll_oldhash +void _nc_scroll_oldhash( + int n, + int top, + int bot) + { /* void */ } + +/* ./base/lib_addch.c */ + +#undef _nc_render +chtype _nc_render( + WINDOW *win, + chtype ch) + { return(*(chtype *)0); } + +#undef _nc_waddch_nosync +int _nc_waddch_nosync( + WINDOW *win, + const chtype c) + { return(*(int *)0); } + +#undef waddch +int waddch( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +#undef wechochar +int wechochar( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_addstr.c */ + +#undef waddnstr +int waddnstr( + WINDOW *win, + const char *astr, + int n) + { return(*(int *)0); } + +#undef waddchnstr +int waddchnstr( + WINDOW *win, + const chtype *astr, + int n) + { return(*(int *)0); } + +/* ./base/lib_beep.c */ + +#undef beep_sp +int beep_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef beep +int beep(void) + { return(*(int *)0); } + +/* ./base/lib_bkgd.c */ + +#undef wbkgdset +void wbkgdset( + WINDOW *win, + chtype ch) + { /* void */ } + +#undef wbkgd +int wbkgd( + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +/* ./base/lib_box.c */ + +#undef wborder +int wborder( + WINDOW *win, + chtype ls, + chtype rs, + chtype ts, + chtype bs, + chtype tl, + chtype tr, + chtype bl, + chtype br) + { return(*(int *)0); } + +/* ./base/lib_chgat.c */ + +#undef wchgat +int wchgat( + WINDOW *win, + int n, + attr_t attr, + short pair_arg, + const void *opts) + { return(*(int *)0); } + +/* ./base/lib_clear.c */ + +#undef wclear +int wclear( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clearok.c */ + +#undef clearok +int clearok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_clrbot.c */ + +#undef wclrtobot +int wclrtobot( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clreol.c */ + +#undef wclrtoeol +int wclrtoeol( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_color.c */ + +#undef COLOR_PAIRS +int COLOR_PAIRS; +#undef COLORS +int COLORS; + +#undef _nc_reset_colors_sp +NCURSES_BOOL _nc_reset_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_reset_colors +NCURSES_BOOL _nc_reset_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef start_color_sp +int start_color_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef start_color +int start_color(void) + { return(*(int *)0); } + +#undef _nc_change_pair +void _nc_change_pair( + SCREEN *sp, + int pair) + { /* void */ } + +#undef _nc_reserve_pairs +void _nc_reserve_pairs( + SCREEN *sp, + int want) + { /* void */ } + +#undef _nc_init_pair +int _nc_init_pair( + SCREEN *sp, + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_pair_sp +int init_pair_sp( + SCREEN *sp, + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef init_pair +int init_pair( + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef _nc_init_color +int _nc_init_color( + SCREEN *sp, + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef init_color_sp +int init_color_sp( + SCREEN *sp, + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef init_color +int init_color( + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef can_change_color_sp +NCURSES_BOOL can_change_color_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef can_change_color +NCURSES_BOOL can_change_color(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors_sp +NCURSES_BOOL has_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors +NCURSES_BOOL has_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef color_content_sp +int color_content_sp( + SCREEN *sp, + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef color_content +int color_content( + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef _nc_pair_content +int _nc_pair_content( + SCREEN *sp, + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef pair_content_sp +int pair_content_sp( + SCREEN *sp, + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef pair_content +int pair_content( + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef _nc_do_color_sp +void _nc_do_color_sp( + SCREEN *sp, + int old_pair, + int pair, + int reverse, + NCURSES_OUTC_sp outc) + { /* void */ } + +#undef _nc_do_color +void _nc_do_color( + int old_pair, + int pair, + int reverse, + NCURSES_OUTC outc) + { /* void */ } + +/* ./base/lib_colorset.c */ + +#undef wcolor_set +int wcolor_set( + WINDOW *win, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_delch.c */ + +#undef wdelch +int wdelch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_delwin.c */ + +#undef delwin +int delwin( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_echo.c */ + +#undef echo_sp +int echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef echo +int echo(void) + { return(*(int *)0); } + +#undef noecho_sp +int noecho_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noecho +int noecho(void) + { return(*(int *)0); } + +/* ./base/lib_endwin.c */ + +#undef endwin_sp +int endwin_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef endwin +int endwin(void) + { return(*(int *)0); } + +/* ./base/lib_erase.c */ + +#undef werase +int werase( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_flash.c */ + +#undef flash_sp +int flash_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flash +int flash(void) + { return(*(int *)0); } + +/* ./lib_gen.c */ + +#undef addch +int addch( + const chtype z) + { return(*(int *)0); } + +#undef addchnstr +int addchnstr( + const chtype *a1, + int z) + { return(*(int *)0); } + +#undef addchstr +int addchstr( + const chtype *z) + { return(*(int *)0); } + +#undef addnstr +int addnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef addstr +int addstr( + const char *z) + { return(*(int *)0); } + +#undef attroff +int attroff( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attron +int attron( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attrset +int attrset( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attr_get +int attr_get( + attr_t *a1, + short *a2, + void *z) + { return(*(int *)0); } + +#undef attr_off +int attr_off( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_on +int attr_on( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_set +int attr_set( + attr_t a1, + short a2, + void *z) + { return(*(int *)0); } + +#undef bkgd +int bkgd( + chtype z) + { return(*(int *)0); } + +#undef bkgdset +void bkgdset( + chtype z) + { /* void */ } + +#undef border +int border( + chtype a1, + chtype a2, + chtype a3, + chtype a4, + chtype a5, + chtype a6, + chtype a7, + chtype z) + { return(*(int *)0); } + +#undef box +int box( + WINDOW *a1, + chtype a2, + chtype z) + { return(*(int *)0); } + +#undef chgat +int chgat( + int a1, + attr_t a2, + short a3, + const void *z) + { return(*(int *)0); } + +#undef clear +int clear(void) + { return(*(int *)0); } + +#undef clrtobot +int clrtobot(void) + { return(*(int *)0); } + +#undef clrtoeol +int clrtoeol(void) + { return(*(int *)0); } + +#undef color_set +int color_set( + short a1, + void *z) + { return(*(int *)0); } + +#undef COLOR_PAIR +int COLOR_PAIR( + int z) + { return(*(int *)0); } + +#undef delch +int delch(void) + { return(*(int *)0); } + +#undef deleteln +int deleteln(void) + { return(*(int *)0); } + +#undef echochar +int echochar( + const chtype z) + { return(*(int *)0); } + +#undef erase +int erase(void) + { return(*(int *)0); } + +#undef getbkgd +chtype getbkgd( + WINDOW *z) + { return(*(chtype *)0); } + +#undef getch +int getch(void) + { return(*(int *)0); } + +#undef getnstr +int getnstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef getstr +int getstr( + char *z) + { return(*(int *)0); } + +#undef hline +int hline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef inch +chtype inch(void) + { return(*(chtype *)0); } + +#undef inchnstr +int inchnstr( + chtype *a1, + int z) + { return(*(int *)0); } + +#undef inchstr +int inchstr( + chtype *z) + { return(*(int *)0); } + +#undef innstr +int innstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef insch +int insch( + chtype z) + { return(*(int *)0); } + +#undef insdelln +int insdelln( + int z) + { return(*(int *)0); } + +#undef insertln +int insertln(void) + { return(*(int *)0); } + +#undef insnstr +int insnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef insstr +int insstr( + const char *z) + { return(*(int *)0); } + +#undef instr +int instr( + char *z) + { return(*(int *)0); } + +#undef move +int move( + int a1, + int z) + { return(*(int *)0); } + +#undef mvaddch +int mvaddch( + int a1, + int a2, + const chtype z) + { return(*(int *)0); } + +#undef mvaddchnstr +int mvaddchnstr( + int a1, + int a2, + const chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvaddchstr +int mvaddchstr( + int a1, + int a2, + const chtype *z) + { return(*(int *)0); } + +#undef mvaddnstr +int mvaddnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvaddstr +int mvaddstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvchgat +int mvchgat( + int a1, + int a2, + int a3, + attr_t a4, + short a5, + const void *z) + { return(*(int *)0); } + +#undef mvdelch +int mvdelch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetch +int mvgetch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetnstr +int mvgetnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvgetstr +int mvgetstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvhline +int mvhline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvinch +chtype mvinch( + int a1, + int z) + { return(*(chtype *)0); } + +#undef mvinchnstr +int mvinchnstr( + int a1, + int a2, + chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvinchstr +int mvinchstr( + int a1, + int a2, + chtype *z) + { return(*(int *)0); } + +#undef mvinnstr +int mvinnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsch +int mvinsch( + int a1, + int a2, + chtype z) + { return(*(int *)0); } + +#undef mvinsnstr +int mvinsnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsstr +int mvinsstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvinstr +int mvinstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvvline +int mvvline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvwaddch +int mvwaddch( + WINDOW *a1, + int a2, + int a3, + const chtype z) + { return(*(int *)0); } + +#undef mvwaddchnstr +int mvwaddchnstr( + WINDOW *a1, + int a2, + int a3, + const chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddchstr +int mvwaddchstr( + WINDOW *a1, + int a2, + int a3, + const chtype *z) + { return(*(int *)0); } + +#undef mvwaddnstr +int mvwaddnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddstr +int mvwaddstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwchgat +int mvwchgat( + WINDOW *a1, + int a2, + int a3, + int a4, + attr_t a5, + short a6, + const void *z) + { return(*(int *)0); } + +#undef mvwdelch +int mvwdelch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetch +int mvwgetch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetnstr +int mvwgetnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwgetstr +int mvwgetstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwhline +int mvwhline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef mvwinch +chtype mvwinch( + WINDOW *a1, + int a2, + int z) + { return(*(chtype *)0); } + +#undef mvwinchnstr +int mvwinchnstr( + WINDOW *a1, + int a2, + int a3, + chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwinchstr +int mvwinchstr( + WINDOW *a1, + int a2, + int a3, + chtype *z) + { return(*(int *)0); } + +#undef mvwinnstr +int mvwinnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsch +int mvwinsch( + WINDOW *a1, + int a2, + int a3, + chtype z) + { return(*(int *)0); } + +#undef mvwinsnstr +int mvwinsnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsstr +int mvwinsstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwinstr +int mvwinstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwvline +int mvwvline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef PAIR_NUMBER +int PAIR_NUMBER( + int z) + { return(*(int *)0); } + +#undef redrawwin +int redrawwin( + WINDOW *z) + { return(*(int *)0); } + +#undef refresh +int refresh(void) + { return(*(int *)0); } + +#undef scrl +int scrl( + int z) + { return(*(int *)0); } + +#undef scroll +int scroll( + WINDOW *z) + { return(*(int *)0); } + +#undef setscrreg +int setscrreg( + int a1, + int z) + { return(*(int *)0); } + +#undef standout +int standout(void) + { return(*(int *)0); } + +#undef standend +int standend(void) + { return(*(int *)0); } + +#undef timeout +void timeout( + int z) + { /* void */ } + +#undef touchline +int touchline( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef touchwin +int touchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef untouchwin +int untouchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef vline +int vline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef waddchstr +int waddchstr( + WINDOW *a1, + const chtype *z) + { return(*(int *)0); } + +#undef waddstr +int waddstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef wattron +int wattron( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattroff +int wattroff( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattrset +int wattrset( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattr_get +int wattr_get( + WINDOW *a1, + attr_t *a2, + short *a3, + void *z) + { return(*(int *)0); } + +#undef wattr_set +int wattr_set( + WINDOW *a1, + attr_t a2, + short a3, + void *z) + { return(*(int *)0); } + +#undef wdeleteln +int wdeleteln( + WINDOW *z) + { return(*(int *)0); } + +#undef wgetstr +int wgetstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef winchstr +int winchstr( + WINDOW *a1, + chtype *z) + { return(*(int *)0); } + +#undef winsertln +int winsertln( + WINDOW *z) + { return(*(int *)0); } + +#undef winsstr +int winsstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef winstr +int winstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef wstandout +int wstandout( + WINDOW *z) + { return(*(int *)0); } + +#undef wstandend +int wstandend( + WINDOW *z) + { return(*(int *)0); } + +#undef getattrs +int getattrs( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcurx +int getcurx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcury +int getcury( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegx +int getbegx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegy +int getbegy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxx +int getmaxx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxy +int getmaxy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getparx +int getparx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getpary +int getpary( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetparent +WINDOW *wgetparent( + const WINDOW *z) + { return(*(WINDOW **)0); } + +#undef is_cleared +NCURSES_BOOL is_cleared( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idcok +NCURSES_BOOL is_idcok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idlok +NCURSES_BOOL is_idlok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_immedok +NCURSES_BOOL is_immedok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_keypad +NCURSES_BOOL is_keypad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_leaveok +NCURSES_BOOL is_leaveok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_nodelay +NCURSES_BOOL is_nodelay( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_notimeout +NCURSES_BOOL is_notimeout( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_pad +NCURSES_BOOL is_pad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_scrollok +NCURSES_BOOL is_scrollok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_subwin +NCURSES_BOOL is_subwin( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_syncok +NCURSES_BOOL is_syncok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef wgetdelay +int wgetdelay( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetscrreg +int wgetscrreg( + const WINDOW *a1, + int *a2, + int *z) + { return(*(int *)0); } + +#undef mouse_trafo +NCURSES_BOOL mouse_trafo( + int *a1, + int *a2, + NCURSES_BOOL z) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_getch.c */ + +#undef ESCDELAY +int ESCDELAY; + +#undef set_escdelay_sp +int set_escdelay_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_escdelay +int set_escdelay( + int value) + { return(*(int *)0); } + +#undef get_escdelay_sp +int get_escdelay_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef get_escdelay +int get_escdelay(void) + { return(*(int *)0); } + +#undef _nc_wgetch +int _nc_wgetch( + WINDOW *win, + int *result, + int use_meta) + { return(*(int *)0); } + +#undef wgetch +int wgetch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_getstr.c */ + +#undef wgetnstr +int wgetnstr( + WINDOW *win, + char *str, + int maxlen) + { return(*(int *)0); } + +/* ./base/lib_hline.c */ + +#undef whline +int whline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_immedok.c */ + +#undef immedok +void immedok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +/* ./base/lib_inchstr.c */ + +#undef winchnstr +int winchnstr( + WINDOW *win, + chtype *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_initscr.c */ + +#undef initscr +WINDOW *initscr(void) + { return(*(WINDOW **)0); } + +/* ./base/lib_insch.c */ + +#undef _nc_insert_ch +int _nc_insert_ch( + SCREEN *sp, + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +#undef winsch +int winsch( + WINDOW *win, + chtype c) + { return(*(int *)0); } + +/* ./base/lib_insdel.c */ + +#undef winsdelln +int winsdelln( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_insnstr.c */ + +#undef winsnstr +int winsnstr( + WINDOW *win, + const char *s, + int n) + { return(*(int *)0); } + +/* ./base/lib_instr.c */ + +#undef winnstr +int winnstr( + WINDOW *win, + char *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_isendwin.c */ + +#undef isendwin_sp +NCURSES_BOOL isendwin_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef isendwin +NCURSES_BOOL isendwin(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_leaveok.c */ + +#undef leaveok +int leaveok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_mouse.c */ + +#undef getmouse_sp +int getmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef getmouse +int getmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse_sp +int ungetmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse +int ungetmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef mousemask_sp +mmask_t mousemask_sp( + SCREEN *sp, + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef mousemask +mmask_t mousemask( + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef wenclose +NCURSES_BOOL wenclose( + const WINDOW *win, + int y, + int x) + { return(*(NCURSES_BOOL *)0); } + +#undef mouseinterval_sp +int mouseinterval_sp( + SCREEN *sp, + int maxclick) + { return(*(int *)0); } + +#undef mouseinterval +int mouseinterval( + int maxclick) + { return(*(int *)0); } + +#undef _nc_has_mouse +NCURSES_BOOL _nc_has_mouse( + const SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse_sp +NCURSES_BOOL has_mouse_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse +NCURSES_BOOL has_mouse(void) + { return(*(NCURSES_BOOL *)0); } + +#undef wmouse_trafo +NCURSES_BOOL wmouse_trafo( + const WINDOW *win, + int *pY, + int *pX, + NCURSES_BOOL to_screen) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_move.c */ + +#undef wmove +int wmove( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +/* ./tty/lib_mvcur.c */ + +#undef _nc_msec_cost_sp +int _nc_msec_cost_sp( + SCREEN *sp, + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_msec_cost +int _nc_msec_cost( + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_mvcur_resume_sp +void _nc_mvcur_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_resume +void _nc_mvcur_resume(void) + { /* void */ } + +#undef _nc_mvcur_init_sp +void _nc_mvcur_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_init +void _nc_mvcur_init(void) + { /* void */ } + +#undef _nc_mvcur_wrap_sp +void _nc_mvcur_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_wrap +void _nc_mvcur_wrap(void) + { /* void */ } + +#undef _nc_mvcur_sp +int _nc_mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_mvcur +int _nc_mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur_sp +int mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur +int mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_optimize_enable +int _nc_optimize_enable; + +/* ./base/lib_mvwin.c */ + +#undef mvwin +int mvwin( + WINDOW *win, + int by, + int bx) + { return(*(int *)0); } + +/* ./base/lib_newterm.c */ + +#undef filter_sp +void filter_sp( + SCREEN *sp) + { /* void */ } + +#undef filter +void filter(void) + { /* void */ } + +#undef nofilter_sp +void nofilter_sp( + SCREEN *sp) + { /* void */ } + +#undef nofilter +void nofilter(void) + { /* void */ } + +#undef newterm_sp +SCREEN *newterm_sp( + SCREEN *sp, + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +#undef newterm +SCREEN *newterm( + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +/* ./base/lib_newwin.c */ + +#undef _nc_freewin +int _nc_freewin( + WINDOW *win) + { return(*(int *)0); } + +#undef newwin_sp +WINDOW *newwin_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef newwin +WINDOW *newwin( + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef derwin +WINDOW *derwin( + WINDOW *orig, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef subwin +WINDOW *subwin( + WINDOW *w, + int l, + int c, + int y, + int x) + { return(*(WINDOW **)0); } + +#undef _nc_makenew_sp +WINDOW *_nc_makenew_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx, + int flags) + { return(*(WINDOW **)0); } + +#undef _nc_curscr_of +WINDOW *_nc_curscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_newscr_of +WINDOW *_nc_newscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_stdscr_of +WINDOW *_nc_stdscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +/* ./base/lib_nl.c */ + +#undef nl_sp +int nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nl +int nl(void) + { return(*(int *)0); } + +#undef nonl_sp +int nonl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nonl +int nonl(void) + { return(*(int *)0); } + +/* ./base/lib_overlay.c */ + +#undef overlay +int overlay( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef overwrite +int overwrite( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef copywin +int copywin( + const WINDOW *src, + WINDOW *dst, + int sminrow, + int smincol, + int dminrow, + int dmincol, + int dmaxrow, + int dmaxcol, + int over) + { return(*(int *)0); } + +/* ./base/lib_pad.c */ + +#undef newpad_sp +WINDOW *newpad_sp( + SCREEN *sp, + int l, + int c) + { return(*(WINDOW **)0); } + +#undef newpad +WINDOW *newpad( + int l, + int c) + { return(*(WINDOW **)0); } + +#undef subpad +WINDOW *subpad( + WINDOW *orig, + int l, + int c, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef prefresh +int prefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pnoutrefresh +int pnoutrefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pechochar +int pechochar( + WINDOW *pad, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_printw.c */ + +#undef printw +int printw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wprintw +int wprintw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvprintw +int mvprintw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwprintw +int mvwprintw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef vwprintw +int vwprintw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_printw +int vw_printw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +/* ./base/lib_redrawln.c */ + +#undef wredrawln +int wredrawln( + WINDOW *win, + int beg, + int num) + { return(*(int *)0); } + +/* ./base/lib_refresh.c */ + +#undef wrefresh +int wrefresh( + WINDOW *win) + { return(*(int *)0); } + +#undef wnoutrefresh +int wnoutrefresh( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_restart.c */ + +#undef restartterm_sp +int restartterm_sp( + SCREEN *sp, + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +#undef restartterm +int restartterm( + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +/* ./base/lib_scanw.c */ + +#undef vwscanw +int vwscanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_scanw +int vw_scanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef scanw +int scanw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wscanw +int wscanw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvscanw +int mvscanw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwscanw +int mvwscanw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +/* ./base/lib_screen.c */ + +#undef getwin_sp +WINDOW *getwin_sp( + SCREEN *sp, + FILE *filep) + { return(*(WINDOW **)0); } + +#undef getwin +WINDOW *getwin( + FILE *filep) + { return(*(WINDOW **)0); } + +#undef putwin +int putwin( + WINDOW *win, + FILE *filep) + { return(*(int *)0); } + +#undef scr_restore_sp +int scr_restore_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_restore +int scr_restore( + const char *file) + { return(*(int *)0); } + +#undef scr_dump +int scr_dump( + const char *file) + { return(*(int *)0); } + +#undef scr_init_sp +int scr_init_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_init +int scr_init( + const char *file) + { return(*(int *)0); } + +#undef scr_set_sp +int scr_set_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_set +int scr_set( + const char *file) + { return(*(int *)0); } + +/* ./base/lib_scroll.c */ + +#undef _nc_scroll_window +void _nc_scroll_window( + WINDOW *win, + int const n, + int const top, + int const bottom, + chtype blank) + { /* void */ } + +#undef wscrl +int wscrl( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_scrollok.c */ + +#undef scrollok +int scrollok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_scrreg.c */ + +#undef wsetscrreg +int wsetscrreg( + WINDOW *win, + int top, + int bottom) + { return(*(int *)0); } + +/* ./base/lib_set_term.c */ + +#undef set_term +SCREEN *set_term( + SCREEN *screenp) + { return(*(SCREEN **)0); } + +#undef delscreen +void delscreen( + SCREEN *sp) + { /* void */ } + +#undef _nc_setupscreen_sp +int _nc_setupscreen_sp( + SCREEN **spp, + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_setupscreen +int _nc_setupscreen( + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_ripoffline_sp +int _nc_ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef _nc_ripoffline +int _nc_ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline_sp +int ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline +int ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +/* ./base/lib_slk.c */ + +#undef _nc_format_slks +int _nc_format_slks( + SCREEN *sp, + int cols) + { return(*(int *)0); } + +#undef _nc_slk_initialize +int _nc_slk_initialize( + WINDOW *stwin, + int cols) + { return(*(int *)0); } + +#undef slk_restore_sp +int slk_restore_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_restore +int slk_restore(void) + { return(*(int *)0); } + +/* ./base/lib_slkatr_set.c */ + +#undef slk_attr_set_sp +int slk_attr_set_sp( + SCREEN *sp, + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef slk_attr_set +int slk_attr_set( + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_slkatrof.c */ + +#undef slk_attroff_sp +int slk_attroff_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attroff +int slk_attroff( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatron.c */ + +#undef slk_attron_sp +int slk_attron_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attron +int slk_attron( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatrset.c */ + +#undef slk_attrset_sp +int slk_attrset_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attrset +int slk_attrset( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkattr.c */ + +#undef slk_attr_sp +attr_t slk_attr_sp( + SCREEN *sp) + { return(*(attr_t *)0); } + +#undef slk_attr +attr_t slk_attr(void) + { return(*(attr_t *)0); } + +/* ./base/lib_slkclear.c */ + +#undef slk_clear_sp +int slk_clear_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_clear +int slk_clear(void) + { return(*(int *)0); } + +/* ./base/lib_slkcolor.c */ + +#undef slk_color_sp +int slk_color_sp( + SCREEN *sp, + short pair_arg) + { return(*(int *)0); } + +#undef slk_color +int slk_color( + short pair_arg) + { return(*(int *)0); } + +/* ./base/lib_slkinit.c */ + +#undef slk_init_sp +int slk_init_sp( + SCREEN *sp, + int format) + { return(*(int *)0); } + +#undef slk_init +int slk_init( + int format) + { return(*(int *)0); } + +/* ./base/lib_slklab.c */ + +#undef slk_label_sp +char *slk_label_sp( + SCREEN *sp, + int n) + { return(*(char **)0); } + +#undef slk_label +char *slk_label( + int n) + { return(*(char **)0); } + +/* ./base/lib_slkrefr.c */ + +#undef slk_noutrefresh_sp +int slk_noutrefresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_noutrefresh +int slk_noutrefresh(void) + { return(*(int *)0); } + +#undef slk_refresh_sp +int slk_refresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_refresh +int slk_refresh(void) + { return(*(int *)0); } + +/* ./base/lib_slkset.c */ + +#undef slk_set_sp +int slk_set_sp( + SCREEN *sp, + int i, + const char *astr, + int format) + { return(*(int *)0); } + +#undef slk_set +int slk_set( + int i, + const char *astr, + int format) + { return(*(int *)0); } + +/* ./base/lib_slktouch.c */ + +#undef slk_touch_sp +int slk_touch_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_touch +int slk_touch(void) + { return(*(int *)0); } + +/* ./base/lib_touch.c */ + +#undef is_linetouched +NCURSES_BOOL is_linetouched( + WINDOW *win, + int line) + { return(*(NCURSES_BOOL *)0); } + +#undef is_wintouched +NCURSES_BOOL is_wintouched( + WINDOW *win) + { return(*(NCURSES_BOOL *)0); } + +#undef wtouchln +int wtouchln( + WINDOW *win, + int y, + int n, + int changed) + { return(*(int *)0); } + +/* ./trace/lib_tracedmp.c */ + +#undef _tracedump +void _tracedump( + const char *name, + WINDOW *win) + { /* void */ } + +/* ./trace/lib_tracemse.c */ + +#undef _nc_trace_mmask_t +char *_nc_trace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(char **)0); } + +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + +#undef _nc_retrace_mmask_t +mmask_t _nc_retrace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(mmask_t *)0); } + +#undef _tracemouse +char *_tracemouse( + MEVENT const *ep) + { return(*(char **)0); } + +/* ./tty/lib_tstp.c */ + +#undef _nc_signal_handler +void _nc_signal_handler( + int enable) + { /* void */ } + +/* ./base/lib_ungetch.c */ + +#undef _nc_fifo_dump +void _nc_fifo_dump( + SCREEN *sp) + { /* void */ } + +#undef ungetch_sp +int ungetch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef ungetch +int ungetch( + int ch) + { return(*(int *)0); } + +/* ./tty/lib_vidattr.c */ + +#undef vidputs_sp +int vidputs_sp( + SCREEN *sp, + chtype newmode, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef vidputs +int vidputs( + chtype newmode, + NCURSES_OUTC outc) + { return(*(int *)0); } + +#undef vidattr_sp +int vidattr_sp( + SCREEN *sp, + chtype newmode) + { return(*(int *)0); } + +#undef vidattr +int vidattr( + chtype newmode) + { return(*(int *)0); } + +#undef termattrs_sp +chtype termattrs_sp( + SCREEN *sp) + { return(*(chtype *)0); } + +#undef termattrs +chtype termattrs(void) + { return(*(chtype *)0); } + +/* ./base/lib_vline.c */ + +#undef wvline +int wvline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_wattroff.c */ + +#undef wattr_off +int wattr_off( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_wattron.c */ + +#undef wattr_on +int wattr_on( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_winch.c */ + +#undef winch +chtype winch( + WINDOW *win) + { return(*(chtype *)0); } + +/* ./base/lib_window.c */ + +#undef _nc_synchook +void _nc_synchook( + WINDOW *win) + { /* void */ } + +#undef mvderwin +int mvderwin( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +#undef syncok +int syncok( + WINDOW *win, + NCURSES_BOOL bf) + { return(*(int *)0); } + +#undef wsyncup +void wsyncup( + WINDOW *win) + { /* void */ } + +#undef wsyncdown +void wsyncdown( + WINDOW *win) + { /* void */ } + +#undef wcursyncup +void wcursyncup( + WINDOW *win) + { /* void */ } + +#undef dupwin +WINDOW *dupwin( + WINDOW *win) + { return(*(WINDOW **)0); } + +/* ./base/nc_panel.c */ + +#undef _nc_panelhook_sp +struct panelhook *_nc_panelhook_sp( + SCREEN *sp) + { return(*(struct panelhook **)0); } + +#undef _nc_panelhook +struct panelhook *_nc_panelhook(void) + { return(*(struct panelhook **)0); } + +/* ./base/safe_sprintf.c */ + +#undef _nc_printf_string_sp +char *_nc_printf_string_sp( + SCREEN *sp, + const char *fmt, + va_list ap) + { return(*(char **)0); } + +#undef _nc_printf_string +char *_nc_printf_string( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./tty/tty_update.c */ + +#undef doupdate_sp +int doupdate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef doupdate +int doupdate(void) + { return(*(int *)0); } + +#undef _nc_scrolln_sp +int _nc_scrolln_sp( + SCREEN *sp, + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_scrolln +int _nc_scrolln( + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_screen_resume_sp +void _nc_screen_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_resume +void _nc_screen_resume(void) + { /* void */ } + +#undef _nc_screen_init_sp +void _nc_screen_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_init +void _nc_screen_init(void) + { /* void */ } + +#undef _nc_screen_wrap_sp +void _nc_screen_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_wrap +void _nc_screen_wrap(void) + { /* void */ } + +#undef _nc_do_xmc_glitch_sp +void _nc_do_xmc_glitch_sp( + SCREEN *sp, + attr_t previous) + { /* void */ } + +#undef _nc_do_xmc_glitch +void _nc_do_xmc_glitch( + attr_t previous) + { /* void */ } + +/* ./trace/varargs.c */ + +#undef _nc_varargs +char *_nc_varargs( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./base/vsscanf.c */ + +#undef _nc_vsscanf +void _nc_vsscanf(void) + { /* void */ } + +/* ./base/lib_freeall.c */ + +#undef _nc_freeall +void _nc_freeall(void) + { /* void */ } + +#undef _nc_free_and_exit_sp +void _nc_free_and_exit_sp( + SCREEN *sp, + int code) + { /* void */ } + +#undef _nc_free_and_exit +void _nc_free_and_exit( + int code) + { /* void */ } + +#undef exit_curses +void exit_curses( + int code) + { /* void */ } + +/* ./expanded.c */ + +#undef _nc_toggle_attr_on +void _nc_toggle_attr_on( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_toggle_attr_off +void _nc_toggle_attr_off( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_DelCharCost_sp +int _nc_DelCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost_sp +int _nc_InsCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs_sp +void _nc_UpdateAttrs_sp( + SCREEN *sp, + chtype c) + { /* void */ } + +#undef _nc_DelCharCost +int _nc_DelCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost +int _nc_InsCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs +void _nc_UpdateAttrs( + chtype c) + { /* void */ } + +/* ./base/legacy_coding.c */ + +#undef use_legacy_coding_sp +int use_legacy_coding_sp( + SCREEN *sp, + int level) + { return(*(int *)0); } + +#undef use_legacy_coding +int use_legacy_coding( + int level) + { return(*(int *)0); } + +/* ./base/lib_dft_fgbg.c */ + +#undef use_default_colors_sp +int use_default_colors_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_default_colors +int use_default_colors(void) + { return(*(int *)0); } + +#undef assume_default_colors_sp +int assume_default_colors_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef assume_default_colors +int assume_default_colors( + int fg, + int bg) + { return(*(int *)0); } + +/* ./tinfo/lib_print.c */ + +#undef mcprint_sp +int mcprint_sp( + SCREEN *sp, + char *data, + int len) + { return(*(int *)0); } + +#undef mcprint +int mcprint( + char *data, + int len) + { return(*(int *)0); } + +/* ./base/new_pair.c */ + +#undef _nc_new_pair +void _nc_new_pair(void) + { /* void */ } + +/* ./base/resizeterm.c */ + +#undef is_term_resized_sp +NCURSES_BOOL is_term_resized_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef is_term_resized +NCURSES_BOOL is_term_resized( + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef resize_term_sp +int resize_term_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resize_term +int resize_term( + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm_sp +int resizeterm_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm +int resizeterm( + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./trace/trace_xnames.c */ + +#undef _nc_trace_xnames +void _nc_trace_xnames( + TERMTYPE *tp) + { /* void */ } + +/* ./tinfo/use_screen.c */ + +#undef use_screen +int use_screen( + SCREEN *screen, + NCURSES_SCREEN_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/use_window.c */ + +#undef use_window +int use_window( + WINDOW *win, + NCURSES_WINDOW_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/wresize.c */ + +#undef wresize +int wresize( + WINDOW *win, + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./tinfo/access.c */ + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE *to, + TERMTYPE *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +/* ./codes.c */ + +#undef boolcodes +const char *const boolcodes[] = {0}; +#undef numcodes +const char *const numcodes[] = {0}; +#undef strcodes +const char *const strcodes[] = {0}; + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef acs_map +chtype acs_map[128]; + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef cur_term +TERMINAL *cur_term; + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef stdscr +WINDOW *stdscr; +#undef curscr +WINDOW *curscr; +#undef newscr +WINDOW *newscr; +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef ttytype +char ttytype[256]; +#undef LINES +int LINES; +#undef COLS +int COLS; +#undef TABSIZE +int TABSIZE; + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; +#undef _nc_tputs_trace +const char *_nc_tputs_trace = {0}; +#undef _nc_outchars +long _nc_outchars; + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef boolnames +const char *const boolnames[] = {0}; +#undef boolfnames +const char *const boolfnames[] = {0}; +#undef numnames +const char *const numnames[] = {0}; +#undef numfnames +const char *const numfnames[] = {0}; +#undef strnames +const char *const strnames[] = {0}; +#undef strfnames +const char *const strfnames[] = {0}; + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap_entry +int _nc_read_termcap_entry( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const chtype *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const chtype *buf, + int len) + { return(*(const char **)0); } + +/* ./tinfo/alloc_entry.c */ + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-lncursest b/ncurses/ncurses/llib-lncursest new file mode 100644 index 0000000000..fd6568b660 --- /dev/null +++ b/ncurses/ncurses/llib-lncursest @@ -0,0 +1,4636 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 2008-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2008-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tty/hardscroll.c */ + +#include + +#undef _nc_oldnums +int *_nc_oldnums; + +#undef _nc_scroll_optimize_sp +void _nc_scroll_optimize_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_scroll_optimize +void _nc_scroll_optimize(void) + { /* void */ } + +#undef _nc_linedump_sp +void _nc_linedump_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_linedump +void _nc_linedump(void) + { /* void */ } + +/* ./tty/hashmap.c */ + +#undef _nc_hash_map_sp +void _nc_hash_map_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_hash_map +void _nc_hash_map(void) + { /* void */ } + +#undef _nc_make_oldhash_sp +void _nc_make_oldhash_sp( + SCREEN *sp, + int i) + { /* void */ } + +#undef _nc_make_oldhash +void _nc_make_oldhash( + int i) + { /* void */ } + +#undef _nc_scroll_oldhash_sp +void _nc_scroll_oldhash_sp( + SCREEN *sp, + int n, + int top, + int bot) + { /* void */ } + +#undef _nc_scroll_oldhash +void _nc_scroll_oldhash( + int n, + int top, + int bot) + { /* void */ } + +/* ./base/lib_addch.c */ + +#undef _nc_render +chtype _nc_render( + WINDOW *win, + chtype ch) + { return(*(chtype *)0); } + +#undef _nc_waddch_nosync +int _nc_waddch_nosync( + WINDOW *win, + const chtype c) + { return(*(int *)0); } + +#undef waddch +int waddch( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +#undef wechochar +int wechochar( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_addstr.c */ + +#undef waddnstr +int waddnstr( + WINDOW *win, + const char *astr, + int n) + { return(*(int *)0); } + +#undef waddchnstr +int waddchnstr( + WINDOW *win, + const chtype *astr, + int n) + { return(*(int *)0); } + +/* ./base/lib_beep.c */ + +#undef beep_sp +int beep_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef beep +int beep(void) + { return(*(int *)0); } + +/* ./base/lib_bkgd.c */ + +#undef wbkgdset +void wbkgdset( + WINDOW *win, + chtype ch) + { /* void */ } + +#undef wbkgd +int wbkgd( + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +/* ./base/lib_box.c */ + +#undef wborder +int wborder( + WINDOW *win, + chtype ls, + chtype rs, + chtype ts, + chtype bs, + chtype tl, + chtype tr, + chtype bl, + chtype br) + { return(*(int *)0); } + +/* ./base/lib_chgat.c */ + +#undef wchgat +int wchgat( + WINDOW *win, + int n, + attr_t attr, + short pair_arg, + const void *opts) + { return(*(int *)0); } + +/* ./base/lib_clear.c */ + +#undef wclear +int wclear( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clearok.c */ + +#undef clearok +int clearok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_clrbot.c */ + +#undef wclrtobot +int wclrtobot( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clreol.c */ + +#undef wclrtoeol +int wclrtoeol( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_color.c */ + +#undef _nc_COLOR_PAIRS +int _nc_COLOR_PAIRS(void) + { return(*(int *)0); } + +#undef _nc_COLORS +int _nc_COLORS(void) + { return(*(int *)0); } + +#undef _nc_reset_colors_sp +NCURSES_BOOL _nc_reset_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_reset_colors +NCURSES_BOOL _nc_reset_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef start_color_sp +int start_color_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef start_color +int start_color(void) + { return(*(int *)0); } + +#undef _nc_change_pair +void _nc_change_pair( + SCREEN *sp, + int pair) + { /* void */ } + +#undef _nc_reserve_pairs +void _nc_reserve_pairs( + SCREEN *sp, + int want) + { /* void */ } + +#undef _nc_init_pair +int _nc_init_pair( + SCREEN *sp, + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_pair_sp +int init_pair_sp( + SCREEN *sp, + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef init_pair +int init_pair( + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef _nc_init_color +int _nc_init_color( + SCREEN *sp, + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef init_color_sp +int init_color_sp( + SCREEN *sp, + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef init_color +int init_color( + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef can_change_color_sp +NCURSES_BOOL can_change_color_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef can_change_color +NCURSES_BOOL can_change_color(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors_sp +NCURSES_BOOL has_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors +NCURSES_BOOL has_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef color_content_sp +int color_content_sp( + SCREEN *sp, + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef color_content +int color_content( + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef _nc_pair_content +int _nc_pair_content( + SCREEN *sp, + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef pair_content_sp +int pair_content_sp( + SCREEN *sp, + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef pair_content +int pair_content( + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef _nc_do_color_sp +void _nc_do_color_sp( + SCREEN *sp, + int old_pair, + int pair, + int reverse, + NCURSES_OUTC_sp outc) + { /* void */ } + +#undef _nc_do_color +void _nc_do_color( + int old_pair, + int pair, + int reverse, + NCURSES_OUTC outc) + { /* void */ } + +/* ./base/lib_colorset.c */ + +#undef wcolor_set +int wcolor_set( + WINDOW *win, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_delch.c */ + +#undef wdelch +int wdelch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_delwin.c */ + +#undef delwin +int delwin( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_echo.c */ + +#undef echo_sp +int echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef echo +int echo(void) + { return(*(int *)0); } + +#undef noecho_sp +int noecho_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noecho +int noecho(void) + { return(*(int *)0); } + +/* ./base/lib_endwin.c */ + +#undef endwin_sp +int endwin_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef endwin +int endwin(void) + { return(*(int *)0); } + +/* ./base/lib_erase.c */ + +#undef werase +int werase( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_flash.c */ + +#undef flash_sp +int flash_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flash +int flash(void) + { return(*(int *)0); } + +/* ./lib_gen.c */ + +#undef addch +int addch( + const chtype z) + { return(*(int *)0); } + +#undef addchnstr +int addchnstr( + const chtype *a1, + int z) + { return(*(int *)0); } + +#undef addchstr +int addchstr( + const chtype *z) + { return(*(int *)0); } + +#undef addnstr +int addnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef addstr +int addstr( + const char *z) + { return(*(int *)0); } + +#undef attroff +int attroff( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attron +int attron( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attrset +int attrset( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attr_get +int attr_get( + attr_t *a1, + short *a2, + void *z) + { return(*(int *)0); } + +#undef attr_off +int attr_off( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_on +int attr_on( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_set +int attr_set( + attr_t a1, + short a2, + void *z) + { return(*(int *)0); } + +#undef bkgd +int bkgd( + chtype z) + { return(*(int *)0); } + +#undef bkgdset +void bkgdset( + chtype z) + { /* void */ } + +#undef border +int border( + chtype a1, + chtype a2, + chtype a3, + chtype a4, + chtype a5, + chtype a6, + chtype a7, + chtype z) + { return(*(int *)0); } + +#undef box +int box( + WINDOW *a1, + chtype a2, + chtype z) + { return(*(int *)0); } + +#undef chgat +int chgat( + int a1, + attr_t a2, + short a3, + const void *z) + { return(*(int *)0); } + +#undef clear +int clear(void) + { return(*(int *)0); } + +#undef clrtobot +int clrtobot(void) + { return(*(int *)0); } + +#undef clrtoeol +int clrtoeol(void) + { return(*(int *)0); } + +#undef color_set +int color_set( + short a1, + void *z) + { return(*(int *)0); } + +#undef COLOR_PAIR +int COLOR_PAIR( + int z) + { return(*(int *)0); } + +#undef delch +int delch(void) + { return(*(int *)0); } + +#undef deleteln +int deleteln(void) + { return(*(int *)0); } + +#undef echochar +int echochar( + const chtype z) + { return(*(int *)0); } + +#undef erase +int erase(void) + { return(*(int *)0); } + +#undef getbkgd +chtype getbkgd( + WINDOW *z) + { return(*(chtype *)0); } + +#undef getch +int getch(void) + { return(*(int *)0); } + +#undef getnstr +int getnstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef getstr +int getstr( + char *z) + { return(*(int *)0); } + +#undef hline +int hline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef inch +chtype inch(void) + { return(*(chtype *)0); } + +#undef inchnstr +int inchnstr( + chtype *a1, + int z) + { return(*(int *)0); } + +#undef inchstr +int inchstr( + chtype *z) + { return(*(int *)0); } + +#undef innstr +int innstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef insch +int insch( + chtype z) + { return(*(int *)0); } + +#undef insdelln +int insdelln( + int z) + { return(*(int *)0); } + +#undef insertln +int insertln(void) + { return(*(int *)0); } + +#undef insnstr +int insnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef insstr +int insstr( + const char *z) + { return(*(int *)0); } + +#undef instr +int instr( + char *z) + { return(*(int *)0); } + +#undef move +int move( + int a1, + int z) + { return(*(int *)0); } + +#undef mvaddch +int mvaddch( + int a1, + int a2, + const chtype z) + { return(*(int *)0); } + +#undef mvaddchnstr +int mvaddchnstr( + int a1, + int a2, + const chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvaddchstr +int mvaddchstr( + int a1, + int a2, + const chtype *z) + { return(*(int *)0); } + +#undef mvaddnstr +int mvaddnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvaddstr +int mvaddstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvchgat +int mvchgat( + int a1, + int a2, + int a3, + attr_t a4, + short a5, + const void *z) + { return(*(int *)0); } + +#undef mvdelch +int mvdelch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetch +int mvgetch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetnstr +int mvgetnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvgetstr +int mvgetstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvhline +int mvhline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvinch +chtype mvinch( + int a1, + int z) + { return(*(chtype *)0); } + +#undef mvinchnstr +int mvinchnstr( + int a1, + int a2, + chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvinchstr +int mvinchstr( + int a1, + int a2, + chtype *z) + { return(*(int *)0); } + +#undef mvinnstr +int mvinnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsch +int mvinsch( + int a1, + int a2, + chtype z) + { return(*(int *)0); } + +#undef mvinsnstr +int mvinsnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsstr +int mvinsstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvinstr +int mvinstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvvline +int mvvline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvwaddch +int mvwaddch( + WINDOW *a1, + int a2, + int a3, + const chtype z) + { return(*(int *)0); } + +#undef mvwaddchnstr +int mvwaddchnstr( + WINDOW *a1, + int a2, + int a3, + const chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddchstr +int mvwaddchstr( + WINDOW *a1, + int a2, + int a3, + const chtype *z) + { return(*(int *)0); } + +#undef mvwaddnstr +int mvwaddnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddstr +int mvwaddstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwchgat +int mvwchgat( + WINDOW *a1, + int a2, + int a3, + int a4, + attr_t a5, + short a6, + const void *z) + { return(*(int *)0); } + +#undef mvwdelch +int mvwdelch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetch +int mvwgetch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetnstr +int mvwgetnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwgetstr +int mvwgetstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwhline +int mvwhline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef mvwinch +chtype mvwinch( + WINDOW *a1, + int a2, + int z) + { return(*(chtype *)0); } + +#undef mvwinchnstr +int mvwinchnstr( + WINDOW *a1, + int a2, + int a3, + chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwinchstr +int mvwinchstr( + WINDOW *a1, + int a2, + int a3, + chtype *z) + { return(*(int *)0); } + +#undef mvwinnstr +int mvwinnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsch +int mvwinsch( + WINDOW *a1, + int a2, + int a3, + chtype z) + { return(*(int *)0); } + +#undef mvwinsnstr +int mvwinsnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsstr +int mvwinsstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwinstr +int mvwinstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwvline +int mvwvline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef PAIR_NUMBER +int PAIR_NUMBER( + int z) + { return(*(int *)0); } + +#undef redrawwin +int redrawwin( + WINDOW *z) + { return(*(int *)0); } + +#undef refresh +int refresh(void) + { return(*(int *)0); } + +#undef scrl +int scrl( + int z) + { return(*(int *)0); } + +#undef scroll +int scroll( + WINDOW *z) + { return(*(int *)0); } + +#undef setscrreg +int setscrreg( + int a1, + int z) + { return(*(int *)0); } + +#undef standout +int standout(void) + { return(*(int *)0); } + +#undef standend +int standend(void) + { return(*(int *)0); } + +#undef timeout +void timeout( + int z) + { /* void */ } + +#undef touchline +int touchline( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef touchwin +int touchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef untouchwin +int untouchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef vline +int vline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef waddchstr +int waddchstr( + WINDOW *a1, + const chtype *z) + { return(*(int *)0); } + +#undef waddstr +int waddstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef wattron +int wattron( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattroff +int wattroff( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattrset +int wattrset( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattr_get +int wattr_get( + WINDOW *a1, + attr_t *a2, + short *a3, + void *z) + { return(*(int *)0); } + +#undef wattr_set +int wattr_set( + WINDOW *a1, + attr_t a2, + short a3, + void *z) + { return(*(int *)0); } + +#undef wdeleteln +int wdeleteln( + WINDOW *z) + { return(*(int *)0); } + +#undef wgetstr +int wgetstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef winchstr +int winchstr( + WINDOW *a1, + chtype *z) + { return(*(int *)0); } + +#undef winsertln +int winsertln( + WINDOW *z) + { return(*(int *)0); } + +#undef winsstr +int winsstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef winstr +int winstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef wstandout +int wstandout( + WINDOW *z) + { return(*(int *)0); } + +#undef wstandend +int wstandend( + WINDOW *z) + { return(*(int *)0); } + +#undef getattrs +int getattrs( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcurx +int getcurx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcury +int getcury( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegx +int getbegx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegy +int getbegy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxx +int getmaxx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxy +int getmaxy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getparx +int getparx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getpary +int getpary( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetparent +WINDOW *wgetparent( + const WINDOW *z) + { return(*(WINDOW **)0); } + +#undef is_cleared +NCURSES_BOOL is_cleared( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idcok +NCURSES_BOOL is_idcok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idlok +NCURSES_BOOL is_idlok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_immedok +NCURSES_BOOL is_immedok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_keypad +NCURSES_BOOL is_keypad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_leaveok +NCURSES_BOOL is_leaveok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_nodelay +NCURSES_BOOL is_nodelay( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_notimeout +NCURSES_BOOL is_notimeout( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_pad +NCURSES_BOOL is_pad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_scrollok +NCURSES_BOOL is_scrollok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_subwin +NCURSES_BOOL is_subwin( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_syncok +NCURSES_BOOL is_syncok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef wgetdelay +int wgetdelay( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetscrreg +int wgetscrreg( + const WINDOW *a1, + int *a2, + int *z) + { return(*(int *)0); } + +#undef mouse_trafo +NCURSES_BOOL mouse_trafo( + int *a1, + int *a2, + NCURSES_BOOL z) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_getch.c */ + +#undef _nc_ESCDELAY +int _nc_ESCDELAY(void) + { return(*(int *)0); } + +#undef _nc_ptr_Escdelay +int *_nc_ptr_Escdelay( + SCREEN *sp) + { return(*(int **)0); } + +#undef set_escdelay_sp +int set_escdelay_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_escdelay +int set_escdelay( + int value) + { return(*(int *)0); } + +#undef get_escdelay_sp +int get_escdelay_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef get_escdelay +int get_escdelay(void) + { return(*(int *)0); } + +#undef _nc_wgetch +int _nc_wgetch( + WINDOW *win, + int *result, + int use_meta) + { return(*(int *)0); } + +#undef wgetch +int wgetch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_getstr.c */ + +#undef wgetnstr +int wgetnstr( + WINDOW *win, + char *str, + int maxlen) + { return(*(int *)0); } + +/* ./base/lib_hline.c */ + +#undef whline +int whline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_immedok.c */ + +#undef immedok +void immedok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +/* ./base/lib_inchstr.c */ + +#undef winchnstr +int winchnstr( + WINDOW *win, + chtype *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_initscr.c */ + +#undef initscr +WINDOW *initscr(void) + { return(*(WINDOW **)0); } + +/* ./base/lib_insch.c */ + +#undef _nc_insert_ch +int _nc_insert_ch( + SCREEN *sp, + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +#undef winsch +int winsch( + WINDOW *win, + chtype c) + { return(*(int *)0); } + +/* ./base/lib_insdel.c */ + +#undef winsdelln +int winsdelln( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_insnstr.c */ + +#undef winsnstr +int winsnstr( + WINDOW *win, + const char *s, + int n) + { return(*(int *)0); } + +/* ./base/lib_instr.c */ + +#undef winnstr +int winnstr( + WINDOW *win, + char *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_isendwin.c */ + +#undef isendwin_sp +NCURSES_BOOL isendwin_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef isendwin +NCURSES_BOOL isendwin(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_leaveok.c */ + +#undef leaveok +int leaveok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_mouse.c */ + +#undef getmouse_sp +int getmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef getmouse +int getmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse_sp +int ungetmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse +int ungetmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef mousemask_sp +mmask_t mousemask_sp( + SCREEN *sp, + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef mousemask +mmask_t mousemask( + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef wenclose +NCURSES_BOOL wenclose( + const WINDOW *win, + int y, + int x) + { return(*(NCURSES_BOOL *)0); } + +#undef mouseinterval_sp +int mouseinterval_sp( + SCREEN *sp, + int maxclick) + { return(*(int *)0); } + +#undef mouseinterval +int mouseinterval( + int maxclick) + { return(*(int *)0); } + +#undef _nc_has_mouse +NCURSES_BOOL _nc_has_mouse( + const SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse_sp +NCURSES_BOOL has_mouse_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse +NCURSES_BOOL has_mouse(void) + { return(*(NCURSES_BOOL *)0); } + +#undef wmouse_trafo +NCURSES_BOOL wmouse_trafo( + const WINDOW *win, + int *pY, + int *pX, + NCURSES_BOOL to_screen) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_move.c */ + +#undef wmove +int wmove( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +/* ./tty/lib_mvcur.c */ + +#undef _nc_msec_cost_sp +int _nc_msec_cost_sp( + SCREEN *sp, + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_msec_cost +int _nc_msec_cost( + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_mvcur_resume_sp +void _nc_mvcur_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_resume +void _nc_mvcur_resume(void) + { /* void */ } + +#undef _nc_mvcur_init_sp +void _nc_mvcur_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_init +void _nc_mvcur_init(void) + { /* void */ } + +#undef _nc_mvcur_wrap_sp +void _nc_mvcur_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_wrap +void _nc_mvcur_wrap(void) + { /* void */ } + +#undef _nc_mvcur_sp +int _nc_mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_mvcur +int _nc_mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur_sp +int mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur +int mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_optimize_enable +int _nc_optimize_enable; + +/* ./base/lib_mvwin.c */ + +#undef mvwin +int mvwin( + WINDOW *win, + int by, + int bx) + { return(*(int *)0); } + +/* ./base/lib_newterm.c */ + +#undef filter_sp +void filter_sp( + SCREEN *sp) + { /* void */ } + +#undef filter +void filter(void) + { /* void */ } + +#undef nofilter_sp +void nofilter_sp( + SCREEN *sp) + { /* void */ } + +#undef nofilter +void nofilter(void) + { /* void */ } + +#undef newterm_sp +SCREEN *newterm_sp( + SCREEN *sp, + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +#undef newterm +SCREEN *newterm( + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +/* ./base/lib_newwin.c */ + +#undef _nc_freewin +int _nc_freewin( + WINDOW *win) + { return(*(int *)0); } + +#undef newwin_sp +WINDOW *newwin_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef newwin +WINDOW *newwin( + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef derwin +WINDOW *derwin( + WINDOW *orig, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef subwin +WINDOW *subwin( + WINDOW *w, + int l, + int c, + int y, + int x) + { return(*(WINDOW **)0); } + +#undef _nc_makenew_sp +WINDOW *_nc_makenew_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx, + int flags) + { return(*(WINDOW **)0); } + +#undef _nc_curscr_of +WINDOW *_nc_curscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_newscr_of +WINDOW *_nc_newscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_stdscr_of +WINDOW *_nc_stdscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +/* ./base/lib_nl.c */ + +#undef nl_sp +int nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nl +int nl(void) + { return(*(int *)0); } + +#undef nonl_sp +int nonl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nonl +int nonl(void) + { return(*(int *)0); } + +/* ./base/lib_overlay.c */ + +#undef overlay +int overlay( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef overwrite +int overwrite( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef copywin +int copywin( + const WINDOW *src, + WINDOW *dst, + int sminrow, + int smincol, + int dminrow, + int dmincol, + int dmaxrow, + int dmaxcol, + int over) + { return(*(int *)0); } + +/* ./base/lib_pad.c */ + +#undef newpad_sp +WINDOW *newpad_sp( + SCREEN *sp, + int l, + int c) + { return(*(WINDOW **)0); } + +#undef newpad +WINDOW *newpad( + int l, + int c) + { return(*(WINDOW **)0); } + +#undef subpad +WINDOW *subpad( + WINDOW *orig, + int l, + int c, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef prefresh +int prefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pnoutrefresh +int pnoutrefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pechochar +int pechochar( + WINDOW *pad, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_printw.c */ + +#undef printw +int printw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wprintw +int wprintw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvprintw +int mvprintw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwprintw +int mvwprintw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef vwprintw +int vwprintw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_printw +int vw_printw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +/* ./base/lib_redrawln.c */ + +#undef wredrawln +int wredrawln( + WINDOW *win, + int beg, + int num) + { return(*(int *)0); } + +/* ./base/lib_refresh.c */ + +#undef wrefresh +int wrefresh( + WINDOW *win) + { return(*(int *)0); } + +#undef wnoutrefresh +int wnoutrefresh( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_restart.c */ + +#undef restartterm_sp +int restartterm_sp( + SCREEN *sp, + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +#undef restartterm +int restartterm( + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +/* ./base/lib_scanw.c */ + +#undef vwscanw +int vwscanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_scanw +int vw_scanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef scanw +int scanw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wscanw +int wscanw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvscanw +int mvscanw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwscanw +int mvwscanw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +/* ./base/lib_screen.c */ + +#undef getwin_sp +WINDOW *getwin_sp( + SCREEN *sp, + FILE *filep) + { return(*(WINDOW **)0); } + +#undef getwin +WINDOW *getwin( + FILE *filep) + { return(*(WINDOW **)0); } + +#undef putwin +int putwin( + WINDOW *win, + FILE *filep) + { return(*(int *)0); } + +#undef scr_restore_sp +int scr_restore_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_restore +int scr_restore( + const char *file) + { return(*(int *)0); } + +#undef scr_dump +int scr_dump( + const char *file) + { return(*(int *)0); } + +#undef scr_init_sp +int scr_init_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_init +int scr_init( + const char *file) + { return(*(int *)0); } + +#undef scr_set_sp +int scr_set_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_set +int scr_set( + const char *file) + { return(*(int *)0); } + +/* ./base/lib_scroll.c */ + +#undef _nc_scroll_window +void _nc_scroll_window( + WINDOW *win, + int const n, + int const top, + int const bottom, + chtype blank) + { /* void */ } + +#undef wscrl +int wscrl( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_scrollok.c */ + +#undef scrollok +int scrollok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_scrreg.c */ + +#undef wsetscrreg +int wsetscrreg( + WINDOW *win, + int top, + int bottom) + { return(*(int *)0); } + +/* ./base/lib_set_term.c */ + +#undef set_term +SCREEN *set_term( + SCREEN *screenp) + { return(*(SCREEN **)0); } + +#undef delscreen +void delscreen( + SCREEN *sp) + { /* void */ } + +#undef _nc_setupscreen_sp +int _nc_setupscreen_sp( + SCREEN **spp, + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_setupscreen +int _nc_setupscreen( + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_ripoffline_sp +int _nc_ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef _nc_ripoffline +int _nc_ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline_sp +int ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline +int ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +/* ./base/lib_slk.c */ + +#undef _nc_format_slks +int _nc_format_slks( + SCREEN *sp, + int cols) + { return(*(int *)0); } + +#undef _nc_slk_initialize +int _nc_slk_initialize( + WINDOW *stwin, + int cols) + { return(*(int *)0); } + +#undef slk_restore_sp +int slk_restore_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_restore +int slk_restore(void) + { return(*(int *)0); } + +/* ./base/lib_slkatr_set.c */ + +#undef slk_attr_set_sp +int slk_attr_set_sp( + SCREEN *sp, + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef slk_attr_set +int slk_attr_set( + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_slkatrof.c */ + +#undef slk_attroff_sp +int slk_attroff_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attroff +int slk_attroff( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatron.c */ + +#undef slk_attron_sp +int slk_attron_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attron +int slk_attron( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatrset.c */ + +#undef slk_attrset_sp +int slk_attrset_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attrset +int slk_attrset( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkattr.c */ + +#undef slk_attr_sp +attr_t slk_attr_sp( + SCREEN *sp) + { return(*(attr_t *)0); } + +#undef slk_attr +attr_t slk_attr(void) + { return(*(attr_t *)0); } + +/* ./base/lib_slkclear.c */ + +#undef slk_clear_sp +int slk_clear_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_clear +int slk_clear(void) + { return(*(int *)0); } + +/* ./base/lib_slkcolor.c */ + +#undef slk_color_sp +int slk_color_sp( + SCREEN *sp, + short pair_arg) + { return(*(int *)0); } + +#undef slk_color +int slk_color( + short pair_arg) + { return(*(int *)0); } + +/* ./base/lib_slkinit.c */ + +#undef slk_init_sp +int slk_init_sp( + SCREEN *sp, + int format) + { return(*(int *)0); } + +#undef slk_init +int slk_init( + int format) + { return(*(int *)0); } + +/* ./base/lib_slklab.c */ + +#undef slk_label_sp +char *slk_label_sp( + SCREEN *sp, + int n) + { return(*(char **)0); } + +#undef slk_label +char *slk_label( + int n) + { return(*(char **)0); } + +/* ./base/lib_slkrefr.c */ + +#undef slk_noutrefresh_sp +int slk_noutrefresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_noutrefresh +int slk_noutrefresh(void) + { return(*(int *)0); } + +#undef slk_refresh_sp +int slk_refresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_refresh +int slk_refresh(void) + { return(*(int *)0); } + +/* ./base/lib_slkset.c */ + +#undef slk_set_sp +int slk_set_sp( + SCREEN *sp, + int i, + const char *astr, + int format) + { return(*(int *)0); } + +#undef slk_set +int slk_set( + int i, + const char *astr, + int format) + { return(*(int *)0); } + +/* ./base/lib_slktouch.c */ + +#undef slk_touch_sp +int slk_touch_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_touch +int slk_touch(void) + { return(*(int *)0); } + +/* ./base/lib_touch.c */ + +#undef is_linetouched +NCURSES_BOOL is_linetouched( + WINDOW *win, + int line) + { return(*(NCURSES_BOOL *)0); } + +#undef is_wintouched +NCURSES_BOOL is_wintouched( + WINDOW *win) + { return(*(NCURSES_BOOL *)0); } + +#undef wtouchln +int wtouchln( + WINDOW *win, + int y, + int n, + int changed) + { return(*(int *)0); } + +/* ./trace/lib_tracedmp.c */ + +#undef _tracedump +void _tracedump( + const char *name, + WINDOW *win) + { /* void */ } + +/* ./trace/lib_tracemse.c */ + +#undef _nc_trace_mmask_t +char *_nc_trace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(char **)0); } + +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + +#undef _nc_retrace_mmask_t +mmask_t _nc_retrace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(mmask_t *)0); } + +#undef _tracemouse +char *_tracemouse( + MEVENT const *ep) + { return(*(char **)0); } + +/* ./tty/lib_tstp.c */ + +#undef _nc_signal_handler +void _nc_signal_handler( + int enable) + { /* void */ } + +/* ./base/lib_ungetch.c */ + +#undef _nc_fifo_dump +void _nc_fifo_dump( + SCREEN *sp) + { /* void */ } + +#undef ungetch_sp +int ungetch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef ungetch +int ungetch( + int ch) + { return(*(int *)0); } + +/* ./tty/lib_vidattr.c */ + +#undef vidputs_sp +int vidputs_sp( + SCREEN *sp, + chtype newmode, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef vidputs +int vidputs( + chtype newmode, + NCURSES_OUTC outc) + { return(*(int *)0); } + +#undef vidattr_sp +int vidattr_sp( + SCREEN *sp, + chtype newmode) + { return(*(int *)0); } + +#undef vidattr +int vidattr( + chtype newmode) + { return(*(int *)0); } + +#undef termattrs_sp +chtype termattrs_sp( + SCREEN *sp) + { return(*(chtype *)0); } + +#undef termattrs +chtype termattrs(void) + { return(*(chtype *)0); } + +/* ./base/lib_vline.c */ + +#undef wvline +int wvline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_wattroff.c */ + +#undef wattr_off +int wattr_off( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_wattron.c */ + +#undef wattr_on +int wattr_on( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_winch.c */ + +#undef winch +chtype winch( + WINDOW *win) + { return(*(chtype *)0); } + +/* ./base/lib_window.c */ + +#undef _nc_synchook +void _nc_synchook( + WINDOW *win) + { /* void */ } + +#undef mvderwin +int mvderwin( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +#undef syncok +int syncok( + WINDOW *win, + NCURSES_BOOL bf) + { return(*(int *)0); } + +#undef wsyncup +void wsyncup( + WINDOW *win) + { /* void */ } + +#undef wsyncdown +void wsyncdown( + WINDOW *win) + { /* void */ } + +#undef wcursyncup +void wcursyncup( + WINDOW *win) + { /* void */ } + +#undef dupwin +WINDOW *dupwin( + WINDOW *win) + { return(*(WINDOW **)0); } + +/* ./base/nc_panel.c */ + +#undef _nc_panelhook_sp +struct panelhook *_nc_panelhook_sp( + SCREEN *sp) + { return(*(struct panelhook **)0); } + +#undef _nc_panelhook +struct panelhook *_nc_panelhook(void) + { return(*(struct panelhook **)0); } + +/* ./base/safe_sprintf.c */ + +#undef _nc_printf_string_sp +char *_nc_printf_string_sp( + SCREEN *sp, + const char *fmt, + va_list ap) + { return(*(char **)0); } + +#undef _nc_printf_string +char *_nc_printf_string( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./tty/tty_update.c */ + +#undef doupdate_sp +int doupdate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef doupdate +int doupdate(void) + { return(*(int *)0); } + +#undef _nc_scrolln_sp +int _nc_scrolln_sp( + SCREEN *sp, + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_scrolln +int _nc_scrolln( + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_screen_resume_sp +void _nc_screen_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_resume +void _nc_screen_resume(void) + { /* void */ } + +#undef _nc_screen_init_sp +void _nc_screen_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_init +void _nc_screen_init(void) + { /* void */ } + +#undef _nc_screen_wrap_sp +void _nc_screen_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_wrap +void _nc_screen_wrap(void) + { /* void */ } + +#undef _nc_do_xmc_glitch_sp +void _nc_do_xmc_glitch_sp( + SCREEN *sp, + attr_t previous) + { /* void */ } + +#undef _nc_do_xmc_glitch +void _nc_do_xmc_glitch( + attr_t previous) + { /* void */ } + +/* ./trace/varargs.c */ + +#undef _nc_varargs +char *_nc_varargs( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./base/vsscanf.c */ + +#undef _nc_vsscanf +void _nc_vsscanf(void) + { /* void */ } + +/* ./base/lib_freeall.c */ + +#undef _nc_freeall +void _nc_freeall(void) + { /* void */ } + +#undef _nc_free_and_exit_sp +void _nc_free_and_exit_sp( + SCREEN *sp, + int code) + { /* void */ } + +#undef _nc_free_and_exit +void _nc_free_and_exit( + int code) + { /* void */ } + +#undef exit_curses +void exit_curses( + int code) + { /* void */ } + +/* ./expanded.c */ + +#undef _nc_toggle_attr_on +void _nc_toggle_attr_on( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_toggle_attr_off +void _nc_toggle_attr_off( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_DelCharCost_sp +int _nc_DelCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost_sp +int _nc_InsCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs_sp +void _nc_UpdateAttrs_sp( + SCREEN *sp, + chtype c) + { /* void */ } + +#undef _nc_DelCharCost +int _nc_DelCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost +int _nc_InsCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs +void _nc_UpdateAttrs( + chtype c) + { /* void */ } + +/* ./base/legacy_coding.c */ + +#undef use_legacy_coding_sp +int use_legacy_coding_sp( + SCREEN *sp, + int level) + { return(*(int *)0); } + +#undef use_legacy_coding +int use_legacy_coding( + int level) + { return(*(int *)0); } + +/* ./base/lib_dft_fgbg.c */ + +#undef use_default_colors_sp +int use_default_colors_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_default_colors +int use_default_colors(void) + { return(*(int *)0); } + +#undef assume_default_colors_sp +int assume_default_colors_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef assume_default_colors +int assume_default_colors( + int fg, + int bg) + { return(*(int *)0); } + +/* ./tinfo/lib_print.c */ + +#undef mcprint_sp +int mcprint_sp( + SCREEN *sp, + char *data, + int len) + { return(*(int *)0); } + +#undef mcprint +int mcprint( + char *data, + int len) + { return(*(int *)0); } + +/* ./base/new_pair.c */ + +#undef _nc_new_pair +void _nc_new_pair(void) + { /* void */ } + +/* ./base/resizeterm.c */ + +#undef is_term_resized_sp +NCURSES_BOOL is_term_resized_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef is_term_resized +NCURSES_BOOL is_term_resized( + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef resize_term_sp +int resize_term_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resize_term +int resize_term( + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm_sp +int resizeterm_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm +int resizeterm( + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./trace/trace_xnames.c */ + +#undef _nc_trace_xnames +void _nc_trace_xnames( + TERMTYPE *tp) + { /* void */ } + +/* ./tinfo/use_screen.c */ + +#undef use_screen +int use_screen( + SCREEN *screen, + NCURSES_SCREEN_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/use_window.c */ + +#undef use_window +int use_window( + WINDOW *win, + NCURSES_WINDOW_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/wresize.c */ + +#undef wresize +int wresize( + WINDOW *win, + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./tinfo/access.c */ + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE *to, + TERMTYPE *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +/* ./codes.c */ + +#undef _nc_boolcodes +const char *const *_nc_boolcodes(void) + { return(*(const char **)0); } + +#undef _nc_numcodes +const char *const *_nc_numcodes(void) + { return(*(const char **)0); } + +#undef _nc_strcodes +const char *const *_nc_strcodes(void) + { return(*(const char **)0); } + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef _nc_acs_map +chtype *_nc_acs_map(void) + { return(*(chtype **)0); } + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef _nc_get_cur_term_sp +TERMINAL *_nc_get_cur_term_sp( + SCREEN *sp) + { return(*(TERMINAL **)0); } + +#undef _nc_get_cur_term +TERMINAL *_nc_get_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef _nc_cur_term +TERMINAL *_nc_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef _nc_stdscr +WINDOW *_nc_stdscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_curscr +WINDOW *_nc_curscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_newscr +WINDOW *_nc_newscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +#undef _nc_init_pthreads +void _nc_init_pthreads(void) + { /* void */ } + +#undef _nc_mutex_init +void _nc_mutex_init( + pthread_mutex_t *obj) + { /* void */ } + +#undef _nc_mutex_lock +int _nc_mutex_lock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_trylock +int _nc_mutex_trylock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_unlock +int _nc_mutex_unlock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef _nc_ttytype +char *_nc_ttytype(void) + { return(*(char **)0); } + +#undef _nc_ptr_Lines +int *_nc_ptr_Lines( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_LINES +int _nc_LINES(void) + { return(*(int *)0); } + +#undef _nc_ptr_Cols +int *_nc_ptr_Cols( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_COLS +int _nc_COLS(void) + { return(*(int *)0); } + +#undef _nc_ptr_Tabsize +int *_nc_ptr_Tabsize( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_TABSIZE +int _nc_TABSIZE(void) + { return(*(int *)0); } + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef _nc_find_prescr +SCREEN *_nc_find_prescr(void) + { return(*(SCREEN **)0); } + +#undef _nc_forget_prescr +void _nc_forget_prescr(void) + { /* void */ } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; + +#undef _nc__nc_tputs_trace +const char *_nc__nc_tputs_trace(void) + { return(*(const char **)0); } + +#undef _nc__nc_outchars +long _nc__nc_outchars(void) + { return(*(long *)0); } + +#undef _nc_set_tputs_trace +void _nc_set_tputs_trace( + const char *s) + { /* void */ } + +#undef _nc_count_outchars +void _nc_count_outchars( + long increment) + { /* void */ } + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +#undef _nc_use_tracef +int _nc_use_tracef( + unsigned mask) + { return(*(int *)0); } + +#undef _nc_locked_tracef +void _nc_locked_tracef( + const char *fmt, + ...) + { /* void */ } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef _nc_boolnames +const char *const *_nc_boolnames(void) + { return(*(const char **)0); } + +#undef _nc_boolfnames +const char *const *_nc_boolfnames(void) + { return(*(const char **)0); } + +#undef _nc_numnames +const char *const *_nc_numnames(void) + { return(*(const char **)0); } + +#undef _nc_numfnames +const char *const *_nc_numfnames(void) + { return(*(const char **)0); } + +#undef _nc_strnames +const char *const *_nc_strnames(void) + { return(*(const char **)0); } + +#undef _nc_strfnames +const char *const *_nc_strfnames(void) + { return(*(const char **)0); } + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap_entry +int _nc_read_termcap_entry( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const chtype *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const chtype *buf, + int len) + { return(*(const char **)0); } + +/* ./tinfo/alloc_entry.c */ + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-lncursestw b/ncurses/ncurses/llib-lncursestw new file mode 100644 index 0000000000..f9710ee685 --- /dev/null +++ b/ncurses/ncurses/llib-lncursestw @@ -0,0 +1,5637 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2009-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2009-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tty/hardscroll.c */ + +#include + +#undef _nc_oldnums +int *_nc_oldnums; + +#undef _nc_scroll_optimize_sp +void _nc_scroll_optimize_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_scroll_optimize +void _nc_scroll_optimize(void) + { /* void */ } + +#undef _nc_linedump_sp +void _nc_linedump_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_linedump +void _nc_linedump(void) + { /* void */ } + +/* ./tty/hashmap.c */ + +#undef _nc_hash_map_sp +void _nc_hash_map_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_hash_map +void _nc_hash_map(void) + { /* void */ } + +#undef _nc_make_oldhash_sp +void _nc_make_oldhash_sp( + SCREEN *sp, + int i) + { /* void */ } + +#undef _nc_make_oldhash +void _nc_make_oldhash( + int i) + { /* void */ } + +#undef _nc_scroll_oldhash_sp +void _nc_scroll_oldhash_sp( + SCREEN *sp, + int n, + int top, + int bot) + { /* void */ } + +#undef _nc_scroll_oldhash +void _nc_scroll_oldhash( + int n, + int top, + int bot) + { /* void */ } + +/* ./base/lib_addch.c */ + +#undef _nc_render +cchar_t _nc_render( + WINDOW *win, + cchar_t ch) + { return(*(cchar_t *)0); } + +#undef _nc_build_wch +int _nc_build_wch( + WINDOW *win, + cchar_t *ch) + { return(*(int *)0); } + +#undef _nc_waddch_nosync +int _nc_waddch_nosync( + WINDOW *win, + const cchar_t c) + { return(*(int *)0); } + +#undef waddch +int waddch( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +#undef wechochar +int wechochar( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_addstr.c */ + +#undef waddnstr +int waddnstr( + WINDOW *win, + const char *astr, + int n) + { return(*(int *)0); } + +#undef waddchnstr +int waddchnstr( + WINDOW *win, + const chtype *astr, + int n) + { return(*(int *)0); } + +#undef _nc_wchstrlen +int _nc_wchstrlen( + const cchar_t *s) + { return(*(int *)0); } + +#undef wadd_wchnstr +int wadd_wchnstr( + WINDOW *win, + const cchar_t *astr, + int n) + { return(*(int *)0); } + +#undef waddnwstr +int waddnwstr( + WINDOW *win, + const wchar_t *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_beep.c */ + +#undef beep_sp +int beep_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef beep +int beep(void) + { return(*(int *)0); } + +/* ./base/lib_bkgd.c */ + +#undef wbkgrndset +void wbkgrndset( + WINDOW *win, + const cchar_t *ch) + { /* void */ } + +#undef wbkgdset +void wbkgdset( + WINDOW *win, + chtype ch) + { /* void */ } + +#undef wbkgrnd +int wbkgrnd( + WINDOW *win, + const cchar_t *ch) + { return(*(int *)0); } + +#undef wbkgd +int wbkgd( + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +/* ./base/lib_box.c */ + +#undef wborder +int wborder( + WINDOW *win, + chtype ls, + chtype rs, + chtype ts, + chtype bs, + chtype tl, + chtype tr, + chtype bl, + chtype br) + { return(*(int *)0); } + +/* ./base/lib_chgat.c */ + +#undef wchgat +int wchgat( + WINDOW *win, + int n, + attr_t attr, + short pair_arg, + const void *opts) + { return(*(int *)0); } + +/* ./base/lib_clear.c */ + +#undef wclear +int wclear( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clearok.c */ + +#undef clearok +int clearok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_clrbot.c */ + +#undef wclrtobot +int wclrtobot( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clreol.c */ + +#undef wclrtoeol +int wclrtoeol( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_color.c */ + +#undef _nc_COLOR_PAIRS +int _nc_COLOR_PAIRS(void) + { return(*(int *)0); } + +#undef _nc_COLORS +int _nc_COLORS(void) + { return(*(int *)0); } + +#undef _nc_reset_colors_sp +NCURSES_BOOL _nc_reset_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_reset_colors +NCURSES_BOOL _nc_reset_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef start_color_sp +int start_color_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef start_color +int start_color(void) + { return(*(int *)0); } + +#undef _nc_change_pair +void _nc_change_pair( + SCREEN *sp, + int pair) + { /* void */ } + +#undef _nc_reserve_pairs +void _nc_reserve_pairs( + SCREEN *sp, + int want) + { /* void */ } + +#undef _nc_init_pair +int _nc_init_pair( + SCREEN *sp, + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_pair_sp +int init_pair_sp( + SCREEN *sp, + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef init_pair +int init_pair( + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef _nc_init_color +int _nc_init_color( + SCREEN *sp, + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef init_color_sp +int init_color_sp( + SCREEN *sp, + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef init_color +int init_color( + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef can_change_color_sp +NCURSES_BOOL can_change_color_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef can_change_color +NCURSES_BOOL can_change_color(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors_sp +NCURSES_BOOL has_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors +NCURSES_BOOL has_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef color_content_sp +int color_content_sp( + SCREEN *sp, + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef color_content +int color_content( + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef _nc_pair_content +int _nc_pair_content( + SCREEN *sp, + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef pair_content_sp +int pair_content_sp( + SCREEN *sp, + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef pair_content +int pair_content( + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef _nc_do_color_sp +void _nc_do_color_sp( + SCREEN *sp, + int old_pair, + int pair, + int reverse, + NCURSES_OUTC_sp outc) + { /* void */ } + +#undef _nc_do_color +void _nc_do_color( + int old_pair, + int pair, + int reverse, + NCURSES_OUTC outc) + { /* void */ } + +#undef init_extended_pair_sp +int init_extended_pair_sp( + SCREEN *sp, + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_extended_color_sp +int init_extended_color_sp( + SCREEN *sp, + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef extended_color_content_sp +int extended_color_content_sp( + SCREEN *sp, + int color, + int *r, + int *g, + int *b) + { return(*(int *)0); } + +#undef extended_pair_content_sp +int extended_pair_content_sp( + SCREEN *sp, + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef reset_color_pairs_sp +void reset_color_pairs_sp( + SCREEN *sp) + { /* void */ } + +#undef init_extended_pair +int init_extended_pair( + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_extended_color +int init_extended_color( + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef extended_color_content +int extended_color_content( + int color, + int *r, + int *g, + int *b) + { return(*(int *)0); } + +#undef extended_pair_content +int extended_pair_content( + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef reset_color_pairs +void reset_color_pairs(void) + { /* void */ } + +/* ./base/lib_colorset.c */ + +#undef wcolor_set +int wcolor_set( + WINDOW *win, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_delch.c */ + +#undef wdelch +int wdelch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_delwin.c */ + +#undef delwin +int delwin( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_echo.c */ + +#undef echo_sp +int echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef echo +int echo(void) + { return(*(int *)0); } + +#undef noecho_sp +int noecho_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noecho +int noecho(void) + { return(*(int *)0); } + +/* ./base/lib_endwin.c */ + +#undef endwin_sp +int endwin_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef endwin +int endwin(void) + { return(*(int *)0); } + +/* ./base/lib_erase.c */ + +#undef werase +int werase( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_flash.c */ + +#undef flash_sp +int flash_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flash +int flash(void) + { return(*(int *)0); } + +/* ./lib_gen.c */ + +#undef addch +int addch( + const chtype z) + { return(*(int *)0); } + +#undef addchnstr +int addchnstr( + const chtype *a1, + int z) + { return(*(int *)0); } + +#undef addchstr +int addchstr( + const chtype *z) + { return(*(int *)0); } + +#undef addnstr +int addnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef addstr +int addstr( + const char *z) + { return(*(int *)0); } + +#undef attroff +int attroff( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attron +int attron( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attrset +int attrset( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attr_get +int attr_get( + attr_t *a1, + short *a2, + void *z) + { return(*(int *)0); } + +#undef attr_off +int attr_off( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_on +int attr_on( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_set +int attr_set( + attr_t a1, + short a2, + void *z) + { return(*(int *)0); } + +#undef bkgd +int bkgd( + chtype z) + { return(*(int *)0); } + +#undef bkgdset +void bkgdset( + chtype z) + { /* void */ } + +#undef border +int border( + chtype a1, + chtype a2, + chtype a3, + chtype a4, + chtype a5, + chtype a6, + chtype a7, + chtype z) + { return(*(int *)0); } + +#undef box +int box( + WINDOW *a1, + chtype a2, + chtype z) + { return(*(int *)0); } + +#undef chgat +int chgat( + int a1, + attr_t a2, + short a3, + const void *z) + { return(*(int *)0); } + +#undef clear +int clear(void) + { return(*(int *)0); } + +#undef clrtobot +int clrtobot(void) + { return(*(int *)0); } + +#undef clrtoeol +int clrtoeol(void) + { return(*(int *)0); } + +#undef color_set +int color_set( + short a1, + void *z) + { return(*(int *)0); } + +#undef COLOR_PAIR +int COLOR_PAIR( + int z) + { return(*(int *)0); } + +#undef delch +int delch(void) + { return(*(int *)0); } + +#undef deleteln +int deleteln(void) + { return(*(int *)0); } + +#undef echochar +int echochar( + const chtype z) + { return(*(int *)0); } + +#undef erase +int erase(void) + { return(*(int *)0); } + +#undef getbkgd +chtype getbkgd( + WINDOW *z) + { return(*(chtype *)0); } + +#undef getch +int getch(void) + { return(*(int *)0); } + +#undef getnstr +int getnstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef getstr +int getstr( + char *z) + { return(*(int *)0); } + +#undef hline +int hline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef inch +chtype inch(void) + { return(*(chtype *)0); } + +#undef inchnstr +int inchnstr( + chtype *a1, + int z) + { return(*(int *)0); } + +#undef inchstr +int inchstr( + chtype *z) + { return(*(int *)0); } + +#undef innstr +int innstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef insch +int insch( + chtype z) + { return(*(int *)0); } + +#undef insdelln +int insdelln( + int z) + { return(*(int *)0); } + +#undef insertln +int insertln(void) + { return(*(int *)0); } + +#undef insnstr +int insnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef insstr +int insstr( + const char *z) + { return(*(int *)0); } + +#undef instr +int instr( + char *z) + { return(*(int *)0); } + +#undef move +int move( + int a1, + int z) + { return(*(int *)0); } + +#undef mvaddch +int mvaddch( + int a1, + int a2, + const chtype z) + { return(*(int *)0); } + +#undef mvaddchnstr +int mvaddchnstr( + int a1, + int a2, + const chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvaddchstr +int mvaddchstr( + int a1, + int a2, + const chtype *z) + { return(*(int *)0); } + +#undef mvaddnstr +int mvaddnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvaddstr +int mvaddstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvchgat +int mvchgat( + int a1, + int a2, + int a3, + attr_t a4, + short a5, + const void *z) + { return(*(int *)0); } + +#undef mvdelch +int mvdelch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetch +int mvgetch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetnstr +int mvgetnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvgetstr +int mvgetstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvhline +int mvhline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvinch +chtype mvinch( + int a1, + int z) + { return(*(chtype *)0); } + +#undef mvinchnstr +int mvinchnstr( + int a1, + int a2, + chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvinchstr +int mvinchstr( + int a1, + int a2, + chtype *z) + { return(*(int *)0); } + +#undef mvinnstr +int mvinnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsch +int mvinsch( + int a1, + int a2, + chtype z) + { return(*(int *)0); } + +#undef mvinsnstr +int mvinsnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsstr +int mvinsstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvinstr +int mvinstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvvline +int mvvline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvwaddch +int mvwaddch( + WINDOW *a1, + int a2, + int a3, + const chtype z) + { return(*(int *)0); } + +#undef mvwaddchnstr +int mvwaddchnstr( + WINDOW *a1, + int a2, + int a3, + const chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddchstr +int mvwaddchstr( + WINDOW *a1, + int a2, + int a3, + const chtype *z) + { return(*(int *)0); } + +#undef mvwaddnstr +int mvwaddnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddstr +int mvwaddstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwchgat +int mvwchgat( + WINDOW *a1, + int a2, + int a3, + int a4, + attr_t a5, + short a6, + const void *z) + { return(*(int *)0); } + +#undef mvwdelch +int mvwdelch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetch +int mvwgetch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetnstr +int mvwgetnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwgetstr +int mvwgetstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwhline +int mvwhline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef mvwinch +chtype mvwinch( + WINDOW *a1, + int a2, + int z) + { return(*(chtype *)0); } + +#undef mvwinchnstr +int mvwinchnstr( + WINDOW *a1, + int a2, + int a3, + chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwinchstr +int mvwinchstr( + WINDOW *a1, + int a2, + int a3, + chtype *z) + { return(*(int *)0); } + +#undef mvwinnstr +int mvwinnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsch +int mvwinsch( + WINDOW *a1, + int a2, + int a3, + chtype z) + { return(*(int *)0); } + +#undef mvwinsnstr +int mvwinsnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsstr +int mvwinsstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwinstr +int mvwinstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwvline +int mvwvline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef PAIR_NUMBER +int PAIR_NUMBER( + int z) + { return(*(int *)0); } + +#undef redrawwin +int redrawwin( + WINDOW *z) + { return(*(int *)0); } + +#undef refresh +int refresh(void) + { return(*(int *)0); } + +#undef scrl +int scrl( + int z) + { return(*(int *)0); } + +#undef scroll +int scroll( + WINDOW *z) + { return(*(int *)0); } + +#undef setscrreg +int setscrreg( + int a1, + int z) + { return(*(int *)0); } + +#undef slk_attr_off +int slk_attr_off( + const attr_t a1, + void *z) + { return(*(int *)0); } + +#undef slk_attr_on +int slk_attr_on( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef standout +int standout(void) + { return(*(int *)0); } + +#undef standend +int standend(void) + { return(*(int *)0); } + +#undef timeout +void timeout( + int z) + { /* void */ } + +#undef touchline +int touchline( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef touchwin +int touchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef untouchwin +int untouchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef vline +int vline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef waddchstr +int waddchstr( + WINDOW *a1, + const chtype *z) + { return(*(int *)0); } + +#undef waddstr +int waddstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef wattron +int wattron( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattroff +int wattroff( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattrset +int wattrset( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattr_get +int wattr_get( + WINDOW *a1, + attr_t *a2, + short *a3, + void *z) + { return(*(int *)0); } + +#undef wattr_set +int wattr_set( + WINDOW *a1, + attr_t a2, + short a3, + void *z) + { return(*(int *)0); } + +#undef wdeleteln +int wdeleteln( + WINDOW *z) + { return(*(int *)0); } + +#undef wgetstr +int wgetstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef winchstr +int winchstr( + WINDOW *a1, + chtype *z) + { return(*(int *)0); } + +#undef winsertln +int winsertln( + WINDOW *z) + { return(*(int *)0); } + +#undef winsstr +int winsstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef winstr +int winstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef wstandout +int wstandout( + WINDOW *z) + { return(*(int *)0); } + +#undef wstandend +int wstandend( + WINDOW *z) + { return(*(int *)0); } + +#undef getattrs +int getattrs( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcurx +int getcurx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcury +int getcury( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegx +int getbegx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegy +int getbegy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxx +int getmaxx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxy +int getmaxy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getparx +int getparx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getpary +int getpary( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetparent +WINDOW *wgetparent( + const WINDOW *z) + { return(*(WINDOW **)0); } + +#undef is_cleared +NCURSES_BOOL is_cleared( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idcok +NCURSES_BOOL is_idcok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idlok +NCURSES_BOOL is_idlok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_immedok +NCURSES_BOOL is_immedok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_keypad +NCURSES_BOOL is_keypad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_leaveok +NCURSES_BOOL is_leaveok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_nodelay +NCURSES_BOOL is_nodelay( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_notimeout +NCURSES_BOOL is_notimeout( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_pad +NCURSES_BOOL is_pad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_scrollok +NCURSES_BOOL is_scrollok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_subwin +NCURSES_BOOL is_subwin( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_syncok +NCURSES_BOOL is_syncok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef wgetdelay +int wgetdelay( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetscrreg +int wgetscrreg( + const WINDOW *a1, + int *a2, + int *z) + { return(*(int *)0); } + +#undef add_wch +int add_wch( + const cchar_t *z) + { return(*(int *)0); } + +#undef add_wchnstr +int add_wchnstr( + const cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef add_wchstr +int add_wchstr( + const cchar_t *z) + { return(*(int *)0); } + +#undef addnwstr +int addnwstr( + const wchar_t *a1, + int z) + { return(*(int *)0); } + +#undef addwstr +int addwstr( + const wchar_t *z) + { return(*(int *)0); } + +#undef bkgrnd +int bkgrnd( + const cchar_t *z) + { return(*(int *)0); } + +#undef bkgrndset +void bkgrndset( + const cchar_t *z) + { /* void */ } + +#undef border_set +int border_set( + const cchar_t *a1, + const cchar_t *a2, + const cchar_t *a3, + const cchar_t *a4, + const cchar_t *a5, + const cchar_t *a6, + const cchar_t *a7, + const cchar_t *z) + { return(*(int *)0); } + +#undef box_set +int box_set( + WINDOW *a1, + const cchar_t *a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef echo_wchar +int echo_wchar( + const cchar_t *z) + { return(*(int *)0); } + +#undef get_wch +int get_wch( + wint_t *z) + { return(*(int *)0); } + +#undef get_wstr +int get_wstr( + wint_t *z) + { return(*(int *)0); } + +#undef getbkgrnd +int getbkgrnd( + cchar_t *z) + { return(*(int *)0); } + +#undef getn_wstr +int getn_wstr( + wint_t *a1, + int z) + { return(*(int *)0); } + +#undef hline_set +int hline_set( + const cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef in_wch +int in_wch( + cchar_t *z) + { return(*(int *)0); } + +#undef in_wchnstr +int in_wchnstr( + cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef in_wchstr +int in_wchstr( + cchar_t *z) + { return(*(int *)0); } + +#undef innwstr +int innwstr( + wchar_t *a1, + int z) + { return(*(int *)0); } + +#undef ins_nwstr +int ins_nwstr( + const wchar_t *a1, + int z) + { return(*(int *)0); } + +#undef ins_wch +int ins_wch( + const cchar_t *z) + { return(*(int *)0); } + +#undef ins_wstr +int ins_wstr( + const wchar_t *z) + { return(*(int *)0); } + +#undef inwstr +int inwstr( + wchar_t *z) + { return(*(int *)0); } + +#undef mvadd_wch +int mvadd_wch( + int a1, + int a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvadd_wchnstr +int mvadd_wchnstr( + int a1, + int a2, + const cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvadd_wchstr +int mvadd_wchstr( + int a1, + int a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvaddnwstr +int mvaddnwstr( + int a1, + int a2, + const wchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvaddwstr +int mvaddwstr( + int a1, + int a2, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvget_wch +int mvget_wch( + int a1, + int a2, + wint_t *z) + { return(*(int *)0); } + +#undef mvget_wstr +int mvget_wstr( + int a1, + int a2, + wint_t *z) + { return(*(int *)0); } + +#undef mvgetn_wstr +int mvgetn_wstr( + int a1, + int a2, + wint_t *a3, + int z) + { return(*(int *)0); } + +#undef mvhline_set +int mvhline_set( + int a1, + int a2, + const cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvin_wch +int mvin_wch( + int a1, + int a2, + cchar_t *z) + { return(*(int *)0); } + +#undef mvin_wchnstr +int mvin_wchnstr( + int a1, + int a2, + cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvin_wchstr +int mvin_wchstr( + int a1, + int a2, + cchar_t *z) + { return(*(int *)0); } + +#undef mvinnwstr +int mvinnwstr( + int a1, + int a2, + wchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvins_nwstr +int mvins_nwstr( + int a1, + int a2, + const wchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvins_wch +int mvins_wch( + int a1, + int a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvins_wstr +int mvins_wstr( + int a1, + int a2, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvinwstr +int mvinwstr( + int a1, + int a2, + wchar_t *z) + { return(*(int *)0); } + +#undef mvvline_set +int mvvline_set( + int a1, + int a2, + const cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvwadd_wch +int mvwadd_wch( + WINDOW *a1, + int a2, + int a3, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvwadd_wchnstr +int mvwadd_wchnstr( + WINDOW *a1, + int a2, + int a3, + const cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwadd_wchstr +int mvwadd_wchstr( + WINDOW *a1, + int a2, + int a3, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvwaddnwstr +int mvwaddnwstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddwstr +int mvwaddwstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvwget_wch +int mvwget_wch( + WINDOW *a1, + int a2, + int a3, + wint_t *z) + { return(*(int *)0); } + +#undef mvwget_wstr +int mvwget_wstr( + WINDOW *a1, + int a2, + int a3, + wint_t *z) + { return(*(int *)0); } + +#undef mvwgetn_wstr +int mvwgetn_wstr( + WINDOW *a1, + int a2, + int a3, + wint_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwhline_set +int mvwhline_set( + WINDOW *a1, + int a2, + int a3, + const cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwin_wch +int mvwin_wch( + WINDOW *a1, + int a2, + int a3, + cchar_t *z) + { return(*(int *)0); } + +#undef mvwin_wchnstr +int mvwin_wchnstr( + WINDOW *a1, + int a2, + int a3, + cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwin_wchstr +int mvwin_wchstr( + WINDOW *a1, + int a2, + int a3, + cchar_t *z) + { return(*(int *)0); } + +#undef mvwinnwstr +int mvwinnwstr( + WINDOW *a1, + int a2, + int a3, + wchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwins_nwstr +int mvwins_nwstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwins_wch +int mvwins_wch( + WINDOW *a1, + int a2, + int a3, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvwins_wstr +int mvwins_wstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvwinwstr +int mvwinwstr( + WINDOW *a1, + int a2, + int a3, + wchar_t *z) + { return(*(int *)0); } + +#undef mvwvline_set +int mvwvline_set( + WINDOW *a1, + int a2, + int a3, + const cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef vline_set +int vline_set( + const cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef wadd_wchstr +int wadd_wchstr( + WINDOW *a1, + const cchar_t *z) + { return(*(int *)0); } + +#undef waddwstr +int waddwstr( + WINDOW *a1, + const wchar_t *z) + { return(*(int *)0); } + +#undef wget_wstr +int wget_wstr( + WINDOW *a1, + wint_t *z) + { return(*(int *)0); } + +#undef wgetbkgrnd +int wgetbkgrnd( + WINDOW *a1, + cchar_t *z) + { return(*(int *)0); } + +#undef win_wchstr +int win_wchstr( + WINDOW *a1, + cchar_t *z) + { return(*(int *)0); } + +#undef wins_wstr +int wins_wstr( + WINDOW *a1, + const wchar_t *z) + { return(*(int *)0); } + +#undef winwstr +int winwstr( + WINDOW *a1, + wchar_t *z) + { return(*(int *)0); } + +#undef mouse_trafo +NCURSES_BOOL mouse_trafo( + int *a1, + int *a2, + NCURSES_BOOL z) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_getch.c */ + +#undef _nc_ESCDELAY +int _nc_ESCDELAY(void) + { return(*(int *)0); } + +#undef _nc_ptr_Escdelay +int *_nc_ptr_Escdelay( + SCREEN *sp) + { return(*(int **)0); } + +#undef set_escdelay_sp +int set_escdelay_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_escdelay +int set_escdelay( + int value) + { return(*(int *)0); } + +#undef get_escdelay_sp +int get_escdelay_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef get_escdelay +int get_escdelay(void) + { return(*(int *)0); } + +#undef _nc_wgetch +int _nc_wgetch( + WINDOW *win, + int *result, + int use_meta) + { return(*(int *)0); } + +#undef wgetch +int wgetch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_getstr.c */ + +#undef wgetnstr +int wgetnstr( + WINDOW *win, + char *str, + int maxlen) + { return(*(int *)0); } + +/* ./base/lib_hline.c */ + +#undef whline +int whline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_immedok.c */ + +#undef immedok +void immedok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +/* ./base/lib_inchstr.c */ + +#undef winchnstr +int winchnstr( + WINDOW *win, + chtype *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_initscr.c */ + +#undef initscr +WINDOW *initscr(void) + { return(*(WINDOW **)0); } + +/* ./base/lib_insch.c */ + +#undef _nc_insert_ch +int _nc_insert_ch( + SCREEN *sp, + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +#undef winsch +int winsch( + WINDOW *win, + chtype c) + { return(*(int *)0); } + +/* ./base/lib_insdel.c */ + +#undef winsdelln +int winsdelln( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_insnstr.c */ + +#undef winsnstr +int winsnstr( + WINDOW *win, + const char *s, + int n) + { return(*(int *)0); } + +/* ./base/lib_instr.c */ + +#undef winnstr +int winnstr( + WINDOW *win, + char *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_isendwin.c */ + +#undef isendwin_sp +NCURSES_BOOL isendwin_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef isendwin +NCURSES_BOOL isendwin(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_leaveok.c */ + +#undef leaveok +int leaveok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_mouse.c */ + +#undef getmouse_sp +int getmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef getmouse +int getmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse_sp +int ungetmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse +int ungetmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef mousemask_sp +mmask_t mousemask_sp( + SCREEN *sp, + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef mousemask +mmask_t mousemask( + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef wenclose +NCURSES_BOOL wenclose( + const WINDOW *win, + int y, + int x) + { return(*(NCURSES_BOOL *)0); } + +#undef mouseinterval_sp +int mouseinterval_sp( + SCREEN *sp, + int maxclick) + { return(*(int *)0); } + +#undef mouseinterval +int mouseinterval( + int maxclick) + { return(*(int *)0); } + +#undef _nc_has_mouse +NCURSES_BOOL _nc_has_mouse( + const SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse_sp +NCURSES_BOOL has_mouse_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse +NCURSES_BOOL has_mouse(void) + { return(*(NCURSES_BOOL *)0); } + +#undef wmouse_trafo +NCURSES_BOOL wmouse_trafo( + const WINDOW *win, + int *pY, + int *pX, + NCURSES_BOOL to_screen) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_move.c */ + +#undef wmove +int wmove( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +/* ./tty/lib_mvcur.c */ + +#undef _nc_msec_cost_sp +int _nc_msec_cost_sp( + SCREEN *sp, + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_msec_cost +int _nc_msec_cost( + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_mvcur_resume_sp +void _nc_mvcur_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_resume +void _nc_mvcur_resume(void) + { /* void */ } + +#undef _nc_mvcur_init_sp +void _nc_mvcur_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_init +void _nc_mvcur_init(void) + { /* void */ } + +#undef _nc_mvcur_wrap_sp +void _nc_mvcur_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_wrap +void _nc_mvcur_wrap(void) + { /* void */ } + +#undef _nc_mvcur_sp +int _nc_mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_mvcur +int _nc_mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur_sp +int mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur +int mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_optimize_enable +int _nc_optimize_enable; + +/* ./base/lib_mvwin.c */ + +#undef mvwin +int mvwin( + WINDOW *win, + int by, + int bx) + { return(*(int *)0); } + +/* ./base/lib_newterm.c */ + +#undef filter_sp +void filter_sp( + SCREEN *sp) + { /* void */ } + +#undef filter +void filter(void) + { /* void */ } + +#undef nofilter_sp +void nofilter_sp( + SCREEN *sp) + { /* void */ } + +#undef nofilter +void nofilter(void) + { /* void */ } + +#undef newterm_sp +SCREEN *newterm_sp( + SCREEN *sp, + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +#undef newterm +SCREEN *newterm( + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +/* ./base/lib_newwin.c */ + +#undef _nc_freewin +int _nc_freewin( + WINDOW *win) + { return(*(int *)0); } + +#undef newwin_sp +WINDOW *newwin_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef newwin +WINDOW *newwin( + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef derwin +WINDOW *derwin( + WINDOW *orig, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef subwin +WINDOW *subwin( + WINDOW *w, + int l, + int c, + int y, + int x) + { return(*(WINDOW **)0); } + +#undef _nc_makenew_sp +WINDOW *_nc_makenew_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx, + int flags) + { return(*(WINDOW **)0); } + +#undef _nc_curscr_of +WINDOW *_nc_curscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_newscr_of +WINDOW *_nc_newscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_stdscr_of +WINDOW *_nc_stdscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +/* ./base/lib_nl.c */ + +#undef nl_sp +int nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nl +int nl(void) + { return(*(int *)0); } + +#undef nonl_sp +int nonl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nonl +int nonl(void) + { return(*(int *)0); } + +/* ./base/lib_overlay.c */ + +#undef overlay +int overlay( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef overwrite +int overwrite( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef copywin +int copywin( + const WINDOW *src, + WINDOW *dst, + int sminrow, + int smincol, + int dminrow, + int dmincol, + int dmaxrow, + int dmaxcol, + int over) + { return(*(int *)0); } + +/* ./base/lib_pad.c */ + +#undef newpad_sp +WINDOW *newpad_sp( + SCREEN *sp, + int l, + int c) + { return(*(WINDOW **)0); } + +#undef newpad +WINDOW *newpad( + int l, + int c) + { return(*(WINDOW **)0); } + +#undef subpad +WINDOW *subpad( + WINDOW *orig, + int l, + int c, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef prefresh +int prefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pnoutrefresh +int pnoutrefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pechochar +int pechochar( + WINDOW *pad, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_printw.c */ + +#undef printw +int printw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wprintw +int wprintw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvprintw +int mvprintw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwprintw +int mvwprintw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef vwprintw +int vwprintw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_printw +int vw_printw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +/* ./base/lib_redrawln.c */ + +#undef wredrawln +int wredrawln( + WINDOW *win, + int beg, + int num) + { return(*(int *)0); } + +/* ./base/lib_refresh.c */ + +#undef wrefresh +int wrefresh( + WINDOW *win) + { return(*(int *)0); } + +#undef wnoutrefresh +int wnoutrefresh( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_restart.c */ + +#undef restartterm_sp +int restartterm_sp( + SCREEN *sp, + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +#undef restartterm +int restartterm( + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +/* ./base/lib_scanw.c */ + +#undef vwscanw +int vwscanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_scanw +int vw_scanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef scanw +int scanw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wscanw +int wscanw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvscanw +int mvscanw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwscanw +int mvwscanw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +/* ./base/lib_screen.c */ + +#undef getwin_sp +WINDOW *getwin_sp( + SCREEN *sp, + FILE *filep) + { return(*(WINDOW **)0); } + +#undef getwin +WINDOW *getwin( + FILE *filep) + { return(*(WINDOW **)0); } + +#undef putwin +int putwin( + WINDOW *win, + FILE *filep) + { return(*(int *)0); } + +#undef scr_restore_sp +int scr_restore_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_restore +int scr_restore( + const char *file) + { return(*(int *)0); } + +#undef scr_dump +int scr_dump( + const char *file) + { return(*(int *)0); } + +#undef scr_init_sp +int scr_init_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_init +int scr_init( + const char *file) + { return(*(int *)0); } + +#undef scr_set_sp +int scr_set_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_set +int scr_set( + const char *file) + { return(*(int *)0); } + +/* ./base/lib_scroll.c */ + +#undef _nc_scroll_window +void _nc_scroll_window( + WINDOW *win, + int const n, + int const top, + int const bottom, + cchar_t blank) + { /* void */ } + +#undef wscrl +int wscrl( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_scrollok.c */ + +#undef scrollok +int scrollok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_scrreg.c */ + +#undef wsetscrreg +int wsetscrreg( + WINDOW *win, + int top, + int bottom) + { return(*(int *)0); } + +/* ./base/lib_set_term.c */ + +#undef set_term +SCREEN *set_term( + SCREEN *screenp) + { return(*(SCREEN **)0); } + +#undef delscreen +void delscreen( + SCREEN *sp) + { /* void */ } + +#undef _nc_setupscreen_sp +int _nc_setupscreen_sp( + SCREEN **spp, + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_setupscreen +int _nc_setupscreen( + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_ripoffline_sp +int _nc_ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef _nc_ripoffline +int _nc_ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline_sp +int ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline +int ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +/* ./base/lib_slk.c */ + +#undef _nc_format_slks +int _nc_format_slks( + SCREEN *sp, + int cols) + { return(*(int *)0); } + +#undef _nc_slk_initialize +int _nc_slk_initialize( + WINDOW *stwin, + int cols) + { return(*(int *)0); } + +#undef slk_restore_sp +int slk_restore_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_restore +int slk_restore(void) + { return(*(int *)0); } + +/* ./base/lib_slkatr_set.c */ + +#undef slk_attr_set_sp +int slk_attr_set_sp( + SCREEN *sp, + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef slk_attr_set +int slk_attr_set( + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_slkatrof.c */ + +#undef slk_attroff_sp +int slk_attroff_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attroff +int slk_attroff( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatron.c */ + +#undef slk_attron_sp +int slk_attron_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attron +int slk_attron( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatrset.c */ + +#undef slk_attrset_sp +int slk_attrset_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attrset +int slk_attrset( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkattr.c */ + +#undef slk_attr_sp +attr_t slk_attr_sp( + SCREEN *sp) + { return(*(attr_t *)0); } + +#undef slk_attr +attr_t slk_attr(void) + { return(*(attr_t *)0); } + +/* ./base/lib_slkclear.c */ + +#undef slk_clear_sp +int slk_clear_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_clear +int slk_clear(void) + { return(*(int *)0); } + +/* ./base/lib_slkcolor.c */ + +#undef slk_color_sp +int slk_color_sp( + SCREEN *sp, + short pair_arg) + { return(*(int *)0); } + +#undef slk_color +int slk_color( + short pair_arg) + { return(*(int *)0); } + +#undef extended_slk_color_sp +int extended_slk_color_sp( + SCREEN *sp, + int pair_arg) + { return(*(int *)0); } + +#undef extended_slk_color +int extended_slk_color( + int pair_arg) + { return(*(int *)0); } + +/* ./base/lib_slkinit.c */ + +#undef slk_init_sp +int slk_init_sp( + SCREEN *sp, + int format) + { return(*(int *)0); } + +#undef slk_init +int slk_init( + int format) + { return(*(int *)0); } + +/* ./base/lib_slklab.c */ + +#undef slk_label_sp +char *slk_label_sp( + SCREEN *sp, + int n) + { return(*(char **)0); } + +#undef slk_label +char *slk_label( + int n) + { return(*(char **)0); } + +/* ./base/lib_slkrefr.c */ + +#undef slk_noutrefresh_sp +int slk_noutrefresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_noutrefresh +int slk_noutrefresh(void) + { return(*(int *)0); } + +#undef slk_refresh_sp +int slk_refresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_refresh +int slk_refresh(void) + { return(*(int *)0); } + +/* ./base/lib_slkset.c */ + +#undef slk_set_sp +int slk_set_sp( + SCREEN *sp, + int i, + const char *astr, + int format) + { return(*(int *)0); } + +#undef slk_set +int slk_set( + int i, + const char *astr, + int format) + { return(*(int *)0); } + +/* ./base/lib_slktouch.c */ + +#undef slk_touch_sp +int slk_touch_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_touch +int slk_touch(void) + { return(*(int *)0); } + +/* ./base/lib_touch.c */ + +#undef is_linetouched +NCURSES_BOOL is_linetouched( + WINDOW *win, + int line) + { return(*(NCURSES_BOOL *)0); } + +#undef is_wintouched +NCURSES_BOOL is_wintouched( + WINDOW *win) + { return(*(NCURSES_BOOL *)0); } + +#undef wtouchln +int wtouchln( + WINDOW *win, + int y, + int n, + int changed) + { return(*(int *)0); } + +/* ./trace/lib_tracedmp.c */ + +#undef _tracedump +void _tracedump( + const char *name, + WINDOW *win) + { /* void */ } + +/* ./trace/lib_tracemse.c */ + +#undef _nc_trace_mmask_t +char *_nc_trace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(char **)0); } + +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + +#undef _nc_retrace_mmask_t +mmask_t _nc_retrace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(mmask_t *)0); } + +#undef _tracemouse +char *_tracemouse( + MEVENT const *ep) + { return(*(char **)0); } + +/* ./tty/lib_tstp.c */ + +#undef _nc_signal_handler +void _nc_signal_handler( + int enable) + { /* void */ } + +/* ./base/lib_ungetch.c */ + +#undef _nc_fifo_dump +void _nc_fifo_dump( + SCREEN *sp) + { /* void */ } + +#undef ungetch_sp +int ungetch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef ungetch +int ungetch( + int ch) + { return(*(int *)0); } + +/* ./tty/lib_vidattr.c */ + +#undef vidputs_sp +int vidputs_sp( + SCREEN *sp, + chtype newmode, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef vidputs +int vidputs( + chtype newmode, + NCURSES_OUTC outc) + { return(*(int *)0); } + +#undef vidattr_sp +int vidattr_sp( + SCREEN *sp, + chtype newmode) + { return(*(int *)0); } + +#undef vidattr +int vidattr( + chtype newmode) + { return(*(int *)0); } + +#undef termattrs_sp +chtype termattrs_sp( + SCREEN *sp) + { return(*(chtype *)0); } + +#undef termattrs +chtype termattrs(void) + { return(*(chtype *)0); } + +/* ./base/lib_vline.c */ + +#undef wvline +int wvline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_wattroff.c */ + +#undef wattr_off +int wattr_off( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_wattron.c */ + +#undef wattr_on +int wattr_on( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_winch.c */ + +#undef winch +chtype winch( + WINDOW *win) + { return(*(chtype *)0); } + +/* ./base/lib_window.c */ + +#undef _nc_synchook +void _nc_synchook( + WINDOW *win) + { /* void */ } + +#undef mvderwin +int mvderwin( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +#undef syncok +int syncok( + WINDOW *win, + NCURSES_BOOL bf) + { return(*(int *)0); } + +#undef wsyncup +void wsyncup( + WINDOW *win) + { /* void */ } + +#undef wsyncdown +void wsyncdown( + WINDOW *win) + { /* void */ } + +#undef wcursyncup +void wcursyncup( + WINDOW *win) + { /* void */ } + +#undef dupwin +WINDOW *dupwin( + WINDOW *win) + { return(*(WINDOW **)0); } + +/* ./base/nc_panel.c */ + +#undef _nc_panelhook_sp +struct panelhook *_nc_panelhook_sp( + SCREEN *sp) + { return(*(struct panelhook **)0); } + +#undef _nc_panelhook +struct panelhook *_nc_panelhook(void) + { return(*(struct panelhook **)0); } + +/* ./base/safe_sprintf.c */ + +#undef _nc_printf_string_sp +char *_nc_printf_string_sp( + SCREEN *sp, + const char *fmt, + va_list ap) + { return(*(char **)0); } + +#undef _nc_printf_string +char *_nc_printf_string( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./tty/tty_update.c */ + +#undef doupdate_sp +int doupdate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef doupdate +int doupdate(void) + { return(*(int *)0); } + +#undef _nc_scrolln_sp +int _nc_scrolln_sp( + SCREEN *sp, + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_scrolln +int _nc_scrolln( + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_screen_resume_sp +void _nc_screen_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_resume +void _nc_screen_resume(void) + { /* void */ } + +#undef _nc_screen_init_sp +void _nc_screen_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_init +void _nc_screen_init(void) + { /* void */ } + +#undef _nc_screen_wrap_sp +void _nc_screen_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_wrap +void _nc_screen_wrap(void) + { /* void */ } + +#undef _nc_do_xmc_glitch_sp +void _nc_do_xmc_glitch_sp( + SCREEN *sp, + attr_t previous) + { /* void */ } + +#undef _nc_do_xmc_glitch +void _nc_do_xmc_glitch( + attr_t previous) + { /* void */ } + +/* ./trace/varargs.c */ + +#undef _nc_varargs +char *_nc_varargs( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./base/vsscanf.c */ + +#undef _nc_vsscanf +void _nc_vsscanf(void) + { /* void */ } + +/* ./base/lib_freeall.c */ + +#undef _nc_freeall +void _nc_freeall(void) + { /* void */ } + +#undef _nc_free_and_exit_sp +void _nc_free_and_exit_sp( + SCREEN *sp, + int code) + { /* void */ } + +#undef _nc_free_and_exit +void _nc_free_and_exit( + int code) + { /* void */ } + +#undef exit_curses +void exit_curses( + int code) + { /* void */ } + +/* ./widechar/charable.c */ + +#undef _nc_is_charable +NCURSES_BOOL _nc_is_charable( + wchar_t ch) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_to_char +int _nc_to_char( + wint_t ch) + { return(*(int *)0); } + +#undef _nc_to_widechar +wint_t _nc_to_widechar( + int ch) + { return(*(wint_t *)0); } + +/* ./widechar/lib_add_wch.c */ + +#undef wadd_wch +int wadd_wch( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +#undef wecho_wchar +int wecho_wchar( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +/* ./widechar/lib_box_set.c */ + +#undef wborder_set +int wborder_set( + WINDOW *win, + const cchar_t *ls, + const cchar_t *rs, + const cchar_t *ts, + const cchar_t *bs, + const cchar_t *tl, + const cchar_t *tr, + const cchar_t *bl, + const cchar_t *br) + { return(*(int *)0); } + +/* ./widechar/lib_cchar.c */ + +#undef setcchar +int setcchar( + cchar_t *wcval, + const wchar_t *wch, + const attr_t attrs, + short pair_arg, + const void *opts) + { return(*(int *)0); } + +#undef getcchar +int getcchar( + const cchar_t *wcval, + wchar_t *wch, + attr_t *attrs, + short *pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./widechar/lib_erasewchar.c */ + +#undef erasewchar_sp +int erasewchar_sp( + SCREEN *sp, + wchar_t *wch) + { return(*(int *)0); } + +#undef erasewchar +int erasewchar( + wchar_t *wch) + { return(*(int *)0); } + +#undef killwchar_sp +int killwchar_sp( + SCREEN *sp, + wchar_t *wch) + { return(*(int *)0); } + +#undef killwchar +int killwchar( + wchar_t *wch) + { return(*(int *)0); } + +/* ./widechar/lib_get_wch.c */ + +#undef wget_wch +int wget_wch( + WINDOW *win, + wint_t *result) + { return(*(int *)0); } + +/* ./widechar/lib_get_wstr.c */ + +#undef wgetn_wstr +int wgetn_wstr( + WINDOW *win, + wint_t *str, + int maxlen) + { return(*(int *)0); } + +/* ./widechar/lib_hline_set.c */ + +#undef whline_set +int whline_set( + WINDOW *win, + const cchar_t *ch, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_in_wch.c */ + +#undef win_wch +int win_wch( + WINDOW *win, + cchar_t *wcval) + { return(*(int *)0); } + +/* ./widechar/lib_in_wchnstr.c */ + +#undef win_wchnstr +int win_wchnstr( + WINDOW *win, + cchar_t *wchstr, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_ins_wch.c */ + +#undef _nc_insert_wch +int _nc_insert_wch( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +#undef wins_wch +int wins_wch( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +#undef wins_nwstr +int wins_nwstr( + WINDOW *win, + const wchar_t *wstr, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_inwstr.c */ + +#undef winnwstr +int winnwstr( + WINDOW *win, + wchar_t *wstr, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_key_name.c */ + +#undef key_name +const char *key_name( + wchar_t c) + { return(*(const char **)0); } + +/* ./widechar/lib_pecho_wchar.c */ + +#undef pecho_wchar +int pecho_wchar( + WINDOW *pad, + const cchar_t *wch) + { return(*(int *)0); } + +/* ./widechar/lib_slk_wset.c */ + +#undef slk_wset +int slk_wset( + int i, + const wchar_t *astr, + int format) + { return(*(int *)0); } + +/* ./widechar/lib_unget_wch.c */ + +#undef _nc_wcrtomb +size_t _nc_wcrtomb( + char *target, + wchar_t source, + mbstate_t *state) + { return(*(size_t *)0); } + +#undef unget_wch_sp +int unget_wch_sp( + SCREEN *sp, + const wchar_t wch) + { return(*(int *)0); } + +#undef unget_wch +int unget_wch( + const wchar_t wch) + { return(*(int *)0); } + +/* ./widechar/lib_vid_attr.c */ + +#undef vid_puts_sp +int vid_puts_sp( + SCREEN *sp, + attr_t newmode, + short pair_arg, + void *opts, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef vid_puts +int vid_puts( + attr_t newmode, + short pair_arg, + void *opts, + NCURSES_OUTC outc) + { return(*(int *)0); } + +#undef vid_attr_sp +int vid_attr_sp( + SCREEN *sp, + attr_t newmode, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef vid_attr +int vid_attr( + attr_t newmode, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef term_attrs_sp +attr_t term_attrs_sp( + SCREEN *sp) + { return(*(attr_t *)0); } + +#undef term_attrs +attr_t term_attrs(void) + { return(*(attr_t *)0); } + +/* ./widechar/lib_vline_set.c */ + +#undef wvline_set +int wvline_set( + WINDOW *win, + const cchar_t *ch, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_wacs.c */ + +#undef _nc_wacs +cchar_t *_nc_wacs; + +#undef _nc_init_wacs +void _nc_init_wacs(void) + { /* void */ } + +/* ./widechar/lib_wunctrl.c */ + +#undef wunctrl_sp +wchar_t *wunctrl_sp( + SCREEN *sp, + cchar_t *wc) + { return(*(wchar_t **)0); } + +#undef wunctrl +wchar_t *wunctrl( + cchar_t *wc) + { return(*(wchar_t **)0); } + +/* ./expanded.c */ + +#undef _nc_toggle_attr_on +void _nc_toggle_attr_on( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_toggle_attr_off +void _nc_toggle_attr_off( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_DelCharCost_sp +int _nc_DelCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost_sp +int _nc_InsCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs_sp +void _nc_UpdateAttrs_sp( + SCREEN *sp, + const cchar_t *c) + { /* void */ } + +#undef _nc_DelCharCost +int _nc_DelCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost +int _nc_InsCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs +void _nc_UpdateAttrs( + const cchar_t *c) + { /* void */ } + +/* ./base/legacy_coding.c */ + +#undef use_legacy_coding_sp +int use_legacy_coding_sp( + SCREEN *sp, + int level) + { return(*(int *)0); } + +#undef use_legacy_coding +int use_legacy_coding( + int level) + { return(*(int *)0); } + +/* ./base/lib_dft_fgbg.c */ + +#undef use_default_colors_sp +int use_default_colors_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_default_colors +int use_default_colors(void) + { return(*(int *)0); } + +#undef assume_default_colors_sp +int assume_default_colors_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef assume_default_colors +int assume_default_colors( + int fg, + int bg) + { return(*(int *)0); } + +/* ./tinfo/lib_print.c */ + +#undef mcprint_sp +int mcprint_sp( + SCREEN *sp, + char *data, + int len) + { return(*(int *)0); } + +#undef mcprint +int mcprint( + char *data, + int len) + { return(*(int *)0); } + +/* ./base/new_pair.c */ + +#undef _nc_free_ordered_pairs +void _nc_free_ordered_pairs( + SCREEN *sp) + { /* void */ } + +#undef _nc_reset_color_pair +void _nc_reset_color_pair( + SCREEN *sp, + int pair, + const colorpair_t *next) + { /* void */ } + +#undef _nc_set_color_pair +void _nc_set_color_pair( + SCREEN *sp, + int pair, + int mode) + { /* void */ } + +#undef _nc_copy_pairs +void _nc_copy_pairs( + SCREEN *sp, + colorpair_t *target, + colorpair_t *source, + int length) + { /* void */ } + +#undef alloc_pair_sp +int alloc_pair_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef find_pair_sp +int find_pair_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef free_pair_sp +int free_pair_sp( + SCREEN *sp, + int pair) + { return(*(int *)0); } + +#undef alloc_pair +int alloc_pair( + int f, + int b) + { return(*(int *)0); } + +#undef find_pair +int find_pair( + int f, + int b) + { return(*(int *)0); } + +#undef free_pair +int free_pair( + int pair) + { return(*(int *)0); } + +/* ./base/resizeterm.c */ + +#undef is_term_resized_sp +NCURSES_BOOL is_term_resized_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef is_term_resized +NCURSES_BOOL is_term_resized( + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef resize_term_sp +int resize_term_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resize_term +int resize_term( + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm_sp +int resizeterm_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm +int resizeterm( + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./trace/trace_xnames.c */ + +#undef _nc_trace_xnames +void _nc_trace_xnames( + TERMTYPE *tp) + { /* void */ } + +/* ./tinfo/use_screen.c */ + +#undef use_screen +int use_screen( + SCREEN *screen, + NCURSES_SCREEN_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/use_window.c */ + +#undef use_window +int use_window( + WINDOW *win, + NCURSES_WINDOW_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/wresize.c */ + +#undef wresize +int wresize( + WINDOW *win, + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./tinfo/access.c */ + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE2 *to, + TERMTYPE2 *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +#undef _nc_copy_termtype2 +void _nc_copy_termtype2( + TERMTYPE2 *dst, + const TERMTYPE2 *src) + { /* void */ } + +#undef _nc_export_termtype2 +void _nc_export_termtype2( + TERMTYPE *dst, + const TERMTYPE2 *src) + { /* void */ } + +/* ./codes.c */ + +#undef _nc_boolcodes +const char *const *_nc_boolcodes(void) + { return(*(const char **)0); } + +#undef _nc_numcodes +const char *const *_nc_numcodes(void) + { return(*(const char **)0); } + +#undef _nc_strcodes +const char *const *_nc_strcodes(void) + { return(*(const char **)0); } + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE2 *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback2 +const TERMTYPE2 *_nc_fallback2( + const char *name) + { return(*(const TERMTYPE2 **)0); } + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype2 +void _nc_free_termtype2( + TERMTYPE2 *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef _nc_acs_map +chtype *_nc_acs_map(void) + { return(*(chtype **)0); } + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef _nc_get_cur_term_sp +TERMINAL *_nc_get_cur_term_sp( + SCREEN *sp) + { return(*(TERMINAL **)0); } + +#undef _nc_get_cur_term +TERMINAL *_nc_get_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef _nc_cur_term +TERMINAL *_nc_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef _nc_stdscr +WINDOW *_nc_stdscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_curscr +WINDOW *_nc_curscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_newscr +WINDOW *_nc_newscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +#undef _nc_init_pthreads +void _nc_init_pthreads(void) + { /* void */ } + +#undef _nc_mutex_init +void _nc_mutex_init( + pthread_mutex_t *obj) + { /* void */ } + +#undef _nc_mutex_lock +int _nc_mutex_lock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_trylock +int _nc_mutex_trylock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_unlock +int _nc_mutex_unlock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef _nc_ttytype +char *_nc_ttytype(void) + { return(*(char **)0); } + +#undef _nc_ptr_Lines +int *_nc_ptr_Lines( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_LINES +int _nc_LINES(void) + { return(*(int *)0); } + +#undef _nc_ptr_Cols +int *_nc_ptr_Cols( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_COLS +int _nc_COLS(void) + { return(*(int *)0); } + +#undef _nc_ptr_Tabsize +int *_nc_ptr_Tabsize( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_TABSIZE +int _nc_TABSIZE(void) + { return(*(int *)0); } + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef _nc_find_prescr +SCREEN *_nc_find_prescr(void) + { return(*(SCREEN **)0); } + +#undef _nc_forget_prescr +void _nc_forget_prescr(void) + { /* void */ } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; + +#undef _nc__nc_tputs_trace +const char *_nc__nc_tputs_trace(void) + { return(*(const char **)0); } + +#undef _nc__nc_outchars +long _nc__nc_outchars(void) + { return(*(long *)0); } + +#undef _nc_set_tputs_trace +void _nc_set_tputs_trace( + const char *s) + { /* void */ } + +#undef _nc_count_outchars +void _nc_count_outchars( + long increment) + { /* void */ } + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +#undef _nc_use_tracef +int _nc_use_tracef( + unsigned mask) + { return(*(int *)0); } + +#undef _nc_locked_tracef +void _nc_locked_tracef( + const char *fmt, + ...) + { /* void */ } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +#undef _tracecchar_t2 +char *_tracecchar_t2( + int bufnum, + const cchar_t *ch) + { return(*(char **)0); } + +#undef _tracecchar_t +char *_tracecchar_t( + const cchar_t *ch) + { return(*(char **)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef _nc_boolnames +const char *const *_nc_boolnames(void) + { return(*(const char **)0); } + +#undef _nc_boolfnames +const char *const *_nc_boolfnames(void) + { return(*(const char **)0); } + +#undef _nc_numnames +const char *const *_nc_numnames(void) + { return(*(const char **)0); } + +#undef _nc_numfnames +const char *const *_nc_numfnames(void) + { return(*(const char **)0); } + +#undef _nc_strnames +const char *const *_nc_strnames(void) + { return(*(const char **)0); } + +#undef _nc_strfnames +const char *const *_nc_strfnames(void) + { return(*(const char **)0); } + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE2 *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE2 *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry2 +int _nc_read_entry2( + const char *const name, + char *const filename, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap_entry +int _nc_read_termcap_entry( + const char *const tn, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE2 *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswbuf2 +const char *_nc_viswbuf2( + int bufnum, + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbuf +const char *_nc_viswbuf( + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbufn +const char *_nc_viswbufn( + const wchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswibuf +const char *_nc_viswibuf( + const wint_t *buf) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +/* ./tinfo/alloc_entry.c */ + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE2 *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE2 *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-lncursesw b/ncurses/ncurses/llib-lncursesw new file mode 100644 index 0000000000..91dea8b43d --- /dev/null +++ b/ncurses/ncurses/llib-lncursesw @@ -0,0 +1,5516 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2001-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tty/hardscroll.c */ + +#include + +#undef _nc_oldnums +int *_nc_oldnums; + +#undef _nc_scroll_optimize_sp +void _nc_scroll_optimize_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_scroll_optimize +void _nc_scroll_optimize(void) + { /* void */ } + +#undef _nc_linedump_sp +void _nc_linedump_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_linedump +void _nc_linedump(void) + { /* void */ } + +/* ./tty/hashmap.c */ + +#undef _nc_hash_map_sp +void _nc_hash_map_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_hash_map +void _nc_hash_map(void) + { /* void */ } + +#undef _nc_make_oldhash_sp +void _nc_make_oldhash_sp( + SCREEN *sp, + int i) + { /* void */ } + +#undef _nc_make_oldhash +void _nc_make_oldhash( + int i) + { /* void */ } + +#undef _nc_scroll_oldhash_sp +void _nc_scroll_oldhash_sp( + SCREEN *sp, + int n, + int top, + int bot) + { /* void */ } + +#undef _nc_scroll_oldhash +void _nc_scroll_oldhash( + int n, + int top, + int bot) + { /* void */ } + +/* ./base/lib_addch.c */ + +#undef _nc_render +cchar_t _nc_render( + WINDOW *win, + cchar_t ch) + { return(*(cchar_t *)0); } + +#undef _nc_build_wch +int _nc_build_wch( + WINDOW *win, + cchar_t *ch) + { return(*(int *)0); } + +#undef _nc_waddch_nosync +int _nc_waddch_nosync( + WINDOW *win, + const cchar_t c) + { return(*(int *)0); } + +#undef waddch +int waddch( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +#undef wechochar +int wechochar( + WINDOW *win, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_addstr.c */ + +#undef waddnstr +int waddnstr( + WINDOW *win, + const char *astr, + int n) + { return(*(int *)0); } + +#undef waddchnstr +int waddchnstr( + WINDOW *win, + const chtype *astr, + int n) + { return(*(int *)0); } + +#undef _nc_wchstrlen +int _nc_wchstrlen( + const cchar_t *s) + { return(*(int *)0); } + +#undef wadd_wchnstr +int wadd_wchnstr( + WINDOW *win, + const cchar_t *astr, + int n) + { return(*(int *)0); } + +#undef waddnwstr +int waddnwstr( + WINDOW *win, + const wchar_t *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_beep.c */ + +#undef beep_sp +int beep_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef beep +int beep(void) + { return(*(int *)0); } + +/* ./base/lib_bkgd.c */ + +#undef wbkgrndset +void wbkgrndset( + WINDOW *win, + const cchar_t *ch) + { /* void */ } + +#undef wbkgdset +void wbkgdset( + WINDOW *win, + chtype ch) + { /* void */ } + +#undef wbkgrnd +int wbkgrnd( + WINDOW *win, + const cchar_t *ch) + { return(*(int *)0); } + +#undef wbkgd +int wbkgd( + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +/* ./base/lib_box.c */ + +#undef wborder +int wborder( + WINDOW *win, + chtype ls, + chtype rs, + chtype ts, + chtype bs, + chtype tl, + chtype tr, + chtype bl, + chtype br) + { return(*(int *)0); } + +/* ./base/lib_chgat.c */ + +#undef wchgat +int wchgat( + WINDOW *win, + int n, + attr_t attr, + short pair_arg, + const void *opts) + { return(*(int *)0); } + +/* ./base/lib_clear.c */ + +#undef wclear +int wclear( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clearok.c */ + +#undef clearok +int clearok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_clrbot.c */ + +#undef wclrtobot +int wclrtobot( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_clreol.c */ + +#undef wclrtoeol +int wclrtoeol( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_color.c */ + +#undef COLOR_PAIRS +int COLOR_PAIRS; +#undef COLORS +int COLORS; + +#undef _nc_reset_colors_sp +NCURSES_BOOL _nc_reset_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_reset_colors +NCURSES_BOOL _nc_reset_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef start_color_sp +int start_color_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef start_color +int start_color(void) + { return(*(int *)0); } + +#undef _nc_change_pair +void _nc_change_pair( + SCREEN *sp, + int pair) + { /* void */ } + +#undef _nc_reserve_pairs +void _nc_reserve_pairs( + SCREEN *sp, + int want) + { /* void */ } + +#undef _nc_init_pair +int _nc_init_pair( + SCREEN *sp, + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_pair_sp +int init_pair_sp( + SCREEN *sp, + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef init_pair +int init_pair( + short pair, + short f, + short b) + { return(*(int *)0); } + +#undef _nc_init_color +int _nc_init_color( + SCREEN *sp, + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef init_color_sp +int init_color_sp( + SCREEN *sp, + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef init_color +int init_color( + short color, + short r, + short g, + short b) + { return(*(int *)0); } + +#undef can_change_color_sp +NCURSES_BOOL can_change_color_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef can_change_color +NCURSES_BOOL can_change_color(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors_sp +NCURSES_BOOL has_colors_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_colors +NCURSES_BOOL has_colors(void) + { return(*(NCURSES_BOOL *)0); } + +#undef color_content_sp +int color_content_sp( + SCREEN *sp, + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef color_content +int color_content( + short color, + short *r, + short *g, + short *b) + { return(*(int *)0); } + +#undef _nc_pair_content +int _nc_pair_content( + SCREEN *sp, + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef pair_content_sp +int pair_content_sp( + SCREEN *sp, + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef pair_content +int pair_content( + short pair, + short *f, + short *b) + { return(*(int *)0); } + +#undef _nc_do_color_sp +void _nc_do_color_sp( + SCREEN *sp, + int old_pair, + int pair, + int reverse, + NCURSES_OUTC_sp outc) + { /* void */ } + +#undef _nc_do_color +void _nc_do_color( + int old_pair, + int pair, + int reverse, + NCURSES_OUTC outc) + { /* void */ } + +#undef init_extended_pair_sp +int init_extended_pair_sp( + SCREEN *sp, + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_extended_color_sp +int init_extended_color_sp( + SCREEN *sp, + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef extended_color_content_sp +int extended_color_content_sp( + SCREEN *sp, + int color, + int *r, + int *g, + int *b) + { return(*(int *)0); } + +#undef extended_pair_content_sp +int extended_pair_content_sp( + SCREEN *sp, + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef reset_color_pairs_sp +void reset_color_pairs_sp( + SCREEN *sp) + { /* void */ } + +#undef init_extended_pair +int init_extended_pair( + int pair, + int f, + int b) + { return(*(int *)0); } + +#undef init_extended_color +int init_extended_color( + int color, + int r, + int g, + int b) + { return(*(int *)0); } + +#undef extended_color_content +int extended_color_content( + int color, + int *r, + int *g, + int *b) + { return(*(int *)0); } + +#undef extended_pair_content +int extended_pair_content( + int pair, + int *f, + int *b) + { return(*(int *)0); } + +#undef reset_color_pairs +void reset_color_pairs(void) + { /* void */ } + +/* ./base/lib_colorset.c */ + +#undef wcolor_set +int wcolor_set( + WINDOW *win, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_delch.c */ + +#undef wdelch +int wdelch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_delwin.c */ + +#undef delwin +int delwin( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_echo.c */ + +#undef echo_sp +int echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef echo +int echo(void) + { return(*(int *)0); } + +#undef noecho_sp +int noecho_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noecho +int noecho(void) + { return(*(int *)0); } + +/* ./base/lib_endwin.c */ + +#undef endwin_sp +int endwin_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef endwin +int endwin(void) + { return(*(int *)0); } + +/* ./base/lib_erase.c */ + +#undef werase +int werase( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_flash.c */ + +#undef flash_sp +int flash_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flash +int flash(void) + { return(*(int *)0); } + +/* ./lib_gen.c */ + +#undef addch +int addch( + const chtype z) + { return(*(int *)0); } + +#undef addchnstr +int addchnstr( + const chtype *a1, + int z) + { return(*(int *)0); } + +#undef addchstr +int addchstr( + const chtype *z) + { return(*(int *)0); } + +#undef addnstr +int addnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef addstr +int addstr( + const char *z) + { return(*(int *)0); } + +#undef attroff +int attroff( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attron +int attron( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attrset +int attrset( + NCURSES_ATTR_T z) + { return(*(int *)0); } + +#undef attr_get +int attr_get( + attr_t *a1, + short *a2, + void *z) + { return(*(int *)0); } + +#undef attr_off +int attr_off( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_on +int attr_on( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef attr_set +int attr_set( + attr_t a1, + short a2, + void *z) + { return(*(int *)0); } + +#undef bkgd +int bkgd( + chtype z) + { return(*(int *)0); } + +#undef bkgdset +void bkgdset( + chtype z) + { /* void */ } + +#undef border +int border( + chtype a1, + chtype a2, + chtype a3, + chtype a4, + chtype a5, + chtype a6, + chtype a7, + chtype z) + { return(*(int *)0); } + +#undef box +int box( + WINDOW *a1, + chtype a2, + chtype z) + { return(*(int *)0); } + +#undef chgat +int chgat( + int a1, + attr_t a2, + short a3, + const void *z) + { return(*(int *)0); } + +#undef clear +int clear(void) + { return(*(int *)0); } + +#undef clrtobot +int clrtobot(void) + { return(*(int *)0); } + +#undef clrtoeol +int clrtoeol(void) + { return(*(int *)0); } + +#undef color_set +int color_set( + short a1, + void *z) + { return(*(int *)0); } + +#undef COLOR_PAIR +int COLOR_PAIR( + int z) + { return(*(int *)0); } + +#undef delch +int delch(void) + { return(*(int *)0); } + +#undef deleteln +int deleteln(void) + { return(*(int *)0); } + +#undef echochar +int echochar( + const chtype z) + { return(*(int *)0); } + +#undef erase +int erase(void) + { return(*(int *)0); } + +#undef getbkgd +chtype getbkgd( + WINDOW *z) + { return(*(chtype *)0); } + +#undef getch +int getch(void) + { return(*(int *)0); } + +#undef getnstr +int getnstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef getstr +int getstr( + char *z) + { return(*(int *)0); } + +#undef hline +int hline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef inch +chtype inch(void) + { return(*(chtype *)0); } + +#undef inchnstr +int inchnstr( + chtype *a1, + int z) + { return(*(int *)0); } + +#undef inchstr +int inchstr( + chtype *z) + { return(*(int *)0); } + +#undef innstr +int innstr( + char *a1, + int z) + { return(*(int *)0); } + +#undef insch +int insch( + chtype z) + { return(*(int *)0); } + +#undef insdelln +int insdelln( + int z) + { return(*(int *)0); } + +#undef insertln +int insertln(void) + { return(*(int *)0); } + +#undef insnstr +int insnstr( + const char *a1, + int z) + { return(*(int *)0); } + +#undef insstr +int insstr( + const char *z) + { return(*(int *)0); } + +#undef instr +int instr( + char *z) + { return(*(int *)0); } + +#undef move +int move( + int a1, + int z) + { return(*(int *)0); } + +#undef mvaddch +int mvaddch( + int a1, + int a2, + const chtype z) + { return(*(int *)0); } + +#undef mvaddchnstr +int mvaddchnstr( + int a1, + int a2, + const chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvaddchstr +int mvaddchstr( + int a1, + int a2, + const chtype *z) + { return(*(int *)0); } + +#undef mvaddnstr +int mvaddnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvaddstr +int mvaddstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvchgat +int mvchgat( + int a1, + int a2, + int a3, + attr_t a4, + short a5, + const void *z) + { return(*(int *)0); } + +#undef mvdelch +int mvdelch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetch +int mvgetch( + int a1, + int z) + { return(*(int *)0); } + +#undef mvgetnstr +int mvgetnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvgetstr +int mvgetstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvhline +int mvhline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvinch +chtype mvinch( + int a1, + int z) + { return(*(chtype *)0); } + +#undef mvinchnstr +int mvinchnstr( + int a1, + int a2, + chtype *a3, + int z) + { return(*(int *)0); } + +#undef mvinchstr +int mvinchstr( + int a1, + int a2, + chtype *z) + { return(*(int *)0); } + +#undef mvinnstr +int mvinnstr( + int a1, + int a2, + char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsch +int mvinsch( + int a1, + int a2, + chtype z) + { return(*(int *)0); } + +#undef mvinsnstr +int mvinsnstr( + int a1, + int a2, + const char *a3, + int z) + { return(*(int *)0); } + +#undef mvinsstr +int mvinsstr( + int a1, + int a2, + const char *z) + { return(*(int *)0); } + +#undef mvinstr +int mvinstr( + int a1, + int a2, + char *z) + { return(*(int *)0); } + +#undef mvvline +int mvvline( + int a1, + int a2, + chtype a3, + int z) + { return(*(int *)0); } + +#undef mvwaddch +int mvwaddch( + WINDOW *a1, + int a2, + int a3, + const chtype z) + { return(*(int *)0); } + +#undef mvwaddchnstr +int mvwaddchnstr( + WINDOW *a1, + int a2, + int a3, + const chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddchstr +int mvwaddchstr( + WINDOW *a1, + int a2, + int a3, + const chtype *z) + { return(*(int *)0); } + +#undef mvwaddnstr +int mvwaddnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddstr +int mvwaddstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwchgat +int mvwchgat( + WINDOW *a1, + int a2, + int a3, + int a4, + attr_t a5, + short a6, + const void *z) + { return(*(int *)0); } + +#undef mvwdelch +int mvwdelch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetch +int mvwgetch( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef mvwgetnstr +int mvwgetnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwgetstr +int mvwgetstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwhline +int mvwhline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef mvwinch +chtype mvwinch( + WINDOW *a1, + int a2, + int z) + { return(*(chtype *)0); } + +#undef mvwinchnstr +int mvwinchnstr( + WINDOW *a1, + int a2, + int a3, + chtype *a4, + int z) + { return(*(int *)0); } + +#undef mvwinchstr +int mvwinchstr( + WINDOW *a1, + int a2, + int a3, + chtype *z) + { return(*(int *)0); } + +#undef mvwinnstr +int mvwinnstr( + WINDOW *a1, + int a2, + int a3, + char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsch +int mvwinsch( + WINDOW *a1, + int a2, + int a3, + chtype z) + { return(*(int *)0); } + +#undef mvwinsnstr +int mvwinsnstr( + WINDOW *a1, + int a2, + int a3, + const char *a4, + int z) + { return(*(int *)0); } + +#undef mvwinsstr +int mvwinsstr( + WINDOW *a1, + int a2, + int a3, + const char *z) + { return(*(int *)0); } + +#undef mvwinstr +int mvwinstr( + WINDOW *a1, + int a2, + int a3, + char *z) + { return(*(int *)0); } + +#undef mvwvline +int mvwvline( + WINDOW *a1, + int a2, + int a3, + chtype a4, + int z) + { return(*(int *)0); } + +#undef PAIR_NUMBER +int PAIR_NUMBER( + int z) + { return(*(int *)0); } + +#undef redrawwin +int redrawwin( + WINDOW *z) + { return(*(int *)0); } + +#undef refresh +int refresh(void) + { return(*(int *)0); } + +#undef scrl +int scrl( + int z) + { return(*(int *)0); } + +#undef scroll +int scroll( + WINDOW *z) + { return(*(int *)0); } + +#undef setscrreg +int setscrreg( + int a1, + int z) + { return(*(int *)0); } + +#undef slk_attr_off +int slk_attr_off( + const attr_t a1, + void *z) + { return(*(int *)0); } + +#undef slk_attr_on +int slk_attr_on( + attr_t a1, + void *z) + { return(*(int *)0); } + +#undef standout +int standout(void) + { return(*(int *)0); } + +#undef standend +int standend(void) + { return(*(int *)0); } + +#undef timeout +void timeout( + int z) + { /* void */ } + +#undef touchline +int touchline( + WINDOW *a1, + int a2, + int z) + { return(*(int *)0); } + +#undef touchwin +int touchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef untouchwin +int untouchwin( + WINDOW *z) + { return(*(int *)0); } + +#undef vline +int vline( + chtype a1, + int z) + { return(*(int *)0); } + +#undef waddchstr +int waddchstr( + WINDOW *a1, + const chtype *z) + { return(*(int *)0); } + +#undef waddstr +int waddstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef wattron +int wattron( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattroff +int wattroff( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattrset +int wattrset( + WINDOW *a1, + int z) + { return(*(int *)0); } + +#undef wattr_get +int wattr_get( + WINDOW *a1, + attr_t *a2, + short *a3, + void *z) + { return(*(int *)0); } + +#undef wattr_set +int wattr_set( + WINDOW *a1, + attr_t a2, + short a3, + void *z) + { return(*(int *)0); } + +#undef wdeleteln +int wdeleteln( + WINDOW *z) + { return(*(int *)0); } + +#undef wgetstr +int wgetstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef winchstr +int winchstr( + WINDOW *a1, + chtype *z) + { return(*(int *)0); } + +#undef winsertln +int winsertln( + WINDOW *z) + { return(*(int *)0); } + +#undef winsstr +int winsstr( + WINDOW *a1, + const char *z) + { return(*(int *)0); } + +#undef winstr +int winstr( + WINDOW *a1, + char *z) + { return(*(int *)0); } + +#undef wstandout +int wstandout( + WINDOW *z) + { return(*(int *)0); } + +#undef wstandend +int wstandend( + WINDOW *z) + { return(*(int *)0); } + +#undef getattrs +int getattrs( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcurx +int getcurx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getcury +int getcury( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegx +int getbegx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getbegy +int getbegy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxx +int getmaxx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getmaxy +int getmaxy( + const WINDOW *z) + { return(*(int *)0); } + +#undef getparx +int getparx( + const WINDOW *z) + { return(*(int *)0); } + +#undef getpary +int getpary( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetparent +WINDOW *wgetparent( + const WINDOW *z) + { return(*(WINDOW **)0); } + +#undef is_cleared +NCURSES_BOOL is_cleared( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idcok +NCURSES_BOOL is_idcok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_idlok +NCURSES_BOOL is_idlok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_immedok +NCURSES_BOOL is_immedok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_keypad +NCURSES_BOOL is_keypad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_leaveok +NCURSES_BOOL is_leaveok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_nodelay +NCURSES_BOOL is_nodelay( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_notimeout +NCURSES_BOOL is_notimeout( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_pad +NCURSES_BOOL is_pad( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_scrollok +NCURSES_BOOL is_scrollok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_subwin +NCURSES_BOOL is_subwin( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef is_syncok +NCURSES_BOOL is_syncok( + const WINDOW *z) + { return(*(NCURSES_BOOL *)0); } + +#undef wgetdelay +int wgetdelay( + const WINDOW *z) + { return(*(int *)0); } + +#undef wgetscrreg +int wgetscrreg( + const WINDOW *a1, + int *a2, + int *z) + { return(*(int *)0); } + +#undef add_wch +int add_wch( + const cchar_t *z) + { return(*(int *)0); } + +#undef add_wchnstr +int add_wchnstr( + const cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef add_wchstr +int add_wchstr( + const cchar_t *z) + { return(*(int *)0); } + +#undef addnwstr +int addnwstr( + const wchar_t *a1, + int z) + { return(*(int *)0); } + +#undef addwstr +int addwstr( + const wchar_t *z) + { return(*(int *)0); } + +#undef bkgrnd +int bkgrnd( + const cchar_t *z) + { return(*(int *)0); } + +#undef bkgrndset +void bkgrndset( + const cchar_t *z) + { /* void */ } + +#undef border_set +int border_set( + const cchar_t *a1, + const cchar_t *a2, + const cchar_t *a3, + const cchar_t *a4, + const cchar_t *a5, + const cchar_t *a6, + const cchar_t *a7, + const cchar_t *z) + { return(*(int *)0); } + +#undef box_set +int box_set( + WINDOW *a1, + const cchar_t *a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef echo_wchar +int echo_wchar( + const cchar_t *z) + { return(*(int *)0); } + +#undef get_wch +int get_wch( + wint_t *z) + { return(*(int *)0); } + +#undef get_wstr +int get_wstr( + wint_t *z) + { return(*(int *)0); } + +#undef getbkgrnd +int getbkgrnd( + cchar_t *z) + { return(*(int *)0); } + +#undef getn_wstr +int getn_wstr( + wint_t *a1, + int z) + { return(*(int *)0); } + +#undef hline_set +int hline_set( + const cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef in_wch +int in_wch( + cchar_t *z) + { return(*(int *)0); } + +#undef in_wchnstr +int in_wchnstr( + cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef in_wchstr +int in_wchstr( + cchar_t *z) + { return(*(int *)0); } + +#undef innwstr +int innwstr( + wchar_t *a1, + int z) + { return(*(int *)0); } + +#undef ins_nwstr +int ins_nwstr( + const wchar_t *a1, + int z) + { return(*(int *)0); } + +#undef ins_wch +int ins_wch( + const cchar_t *z) + { return(*(int *)0); } + +#undef ins_wstr +int ins_wstr( + const wchar_t *z) + { return(*(int *)0); } + +#undef inwstr +int inwstr( + wchar_t *z) + { return(*(int *)0); } + +#undef mvadd_wch +int mvadd_wch( + int a1, + int a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvadd_wchnstr +int mvadd_wchnstr( + int a1, + int a2, + const cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvadd_wchstr +int mvadd_wchstr( + int a1, + int a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvaddnwstr +int mvaddnwstr( + int a1, + int a2, + const wchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvaddwstr +int mvaddwstr( + int a1, + int a2, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvget_wch +int mvget_wch( + int a1, + int a2, + wint_t *z) + { return(*(int *)0); } + +#undef mvget_wstr +int mvget_wstr( + int a1, + int a2, + wint_t *z) + { return(*(int *)0); } + +#undef mvgetn_wstr +int mvgetn_wstr( + int a1, + int a2, + wint_t *a3, + int z) + { return(*(int *)0); } + +#undef mvhline_set +int mvhline_set( + int a1, + int a2, + const cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvin_wch +int mvin_wch( + int a1, + int a2, + cchar_t *z) + { return(*(int *)0); } + +#undef mvin_wchnstr +int mvin_wchnstr( + int a1, + int a2, + cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvin_wchstr +int mvin_wchstr( + int a1, + int a2, + cchar_t *z) + { return(*(int *)0); } + +#undef mvinnwstr +int mvinnwstr( + int a1, + int a2, + wchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvins_nwstr +int mvins_nwstr( + int a1, + int a2, + const wchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvins_wch +int mvins_wch( + int a1, + int a2, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvins_wstr +int mvins_wstr( + int a1, + int a2, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvinwstr +int mvinwstr( + int a1, + int a2, + wchar_t *z) + { return(*(int *)0); } + +#undef mvvline_set +int mvvline_set( + int a1, + int a2, + const cchar_t *a3, + int z) + { return(*(int *)0); } + +#undef mvwadd_wch +int mvwadd_wch( + WINDOW *a1, + int a2, + int a3, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvwadd_wchnstr +int mvwadd_wchnstr( + WINDOW *a1, + int a2, + int a3, + const cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwadd_wchstr +int mvwadd_wchstr( + WINDOW *a1, + int a2, + int a3, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvwaddnwstr +int mvwaddnwstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwaddwstr +int mvwaddwstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvwget_wch +int mvwget_wch( + WINDOW *a1, + int a2, + int a3, + wint_t *z) + { return(*(int *)0); } + +#undef mvwget_wstr +int mvwget_wstr( + WINDOW *a1, + int a2, + int a3, + wint_t *z) + { return(*(int *)0); } + +#undef mvwgetn_wstr +int mvwgetn_wstr( + WINDOW *a1, + int a2, + int a3, + wint_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwhline_set +int mvwhline_set( + WINDOW *a1, + int a2, + int a3, + const cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwin_wch +int mvwin_wch( + WINDOW *a1, + int a2, + int a3, + cchar_t *z) + { return(*(int *)0); } + +#undef mvwin_wchnstr +int mvwin_wchnstr( + WINDOW *a1, + int a2, + int a3, + cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwin_wchstr +int mvwin_wchstr( + WINDOW *a1, + int a2, + int a3, + cchar_t *z) + { return(*(int *)0); } + +#undef mvwinnwstr +int mvwinnwstr( + WINDOW *a1, + int a2, + int a3, + wchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwins_nwstr +int mvwins_nwstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *a4, + int z) + { return(*(int *)0); } + +#undef mvwins_wch +int mvwins_wch( + WINDOW *a1, + int a2, + int a3, + const cchar_t *z) + { return(*(int *)0); } + +#undef mvwins_wstr +int mvwins_wstr( + WINDOW *a1, + int a2, + int a3, + const wchar_t *z) + { return(*(int *)0); } + +#undef mvwinwstr +int mvwinwstr( + WINDOW *a1, + int a2, + int a3, + wchar_t *z) + { return(*(int *)0); } + +#undef mvwvline_set +int mvwvline_set( + WINDOW *a1, + int a2, + int a3, + const cchar_t *a4, + int z) + { return(*(int *)0); } + +#undef vline_set +int vline_set( + const cchar_t *a1, + int z) + { return(*(int *)0); } + +#undef wadd_wchstr +int wadd_wchstr( + WINDOW *a1, + const cchar_t *z) + { return(*(int *)0); } + +#undef waddwstr +int waddwstr( + WINDOW *a1, + const wchar_t *z) + { return(*(int *)0); } + +#undef wget_wstr +int wget_wstr( + WINDOW *a1, + wint_t *z) + { return(*(int *)0); } + +#undef wgetbkgrnd +int wgetbkgrnd( + WINDOW *a1, + cchar_t *z) + { return(*(int *)0); } + +#undef win_wchstr +int win_wchstr( + WINDOW *a1, + cchar_t *z) + { return(*(int *)0); } + +#undef wins_wstr +int wins_wstr( + WINDOW *a1, + const wchar_t *z) + { return(*(int *)0); } + +#undef winwstr +int winwstr( + WINDOW *a1, + wchar_t *z) + { return(*(int *)0); } + +#undef mouse_trafo +NCURSES_BOOL mouse_trafo( + int *a1, + int *a2, + NCURSES_BOOL z) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_getch.c */ + +#undef ESCDELAY +int ESCDELAY; + +#undef set_escdelay_sp +int set_escdelay_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_escdelay +int set_escdelay( + int value) + { return(*(int *)0); } + +#undef get_escdelay_sp +int get_escdelay_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef get_escdelay +int get_escdelay(void) + { return(*(int *)0); } + +#undef _nc_wgetch +int _nc_wgetch( + WINDOW *win, + int *result, + int use_meta) + { return(*(int *)0); } + +#undef wgetch +int wgetch( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_getstr.c */ + +#undef wgetnstr +int wgetnstr( + WINDOW *win, + char *str, + int maxlen) + { return(*(int *)0); } + +/* ./base/lib_hline.c */ + +#undef whline +int whline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_immedok.c */ + +#undef immedok +void immedok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +/* ./base/lib_inchstr.c */ + +#undef winchnstr +int winchnstr( + WINDOW *win, + chtype *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_initscr.c */ + +#undef initscr +WINDOW *initscr(void) + { return(*(WINDOW **)0); } + +/* ./base/lib_insch.c */ + +#undef _nc_insert_ch +int _nc_insert_ch( + SCREEN *sp, + WINDOW *win, + chtype ch) + { return(*(int *)0); } + +#undef winsch +int winsch( + WINDOW *win, + chtype c) + { return(*(int *)0); } + +/* ./base/lib_insdel.c */ + +#undef winsdelln +int winsdelln( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_insnstr.c */ + +#undef winsnstr +int winsnstr( + WINDOW *win, + const char *s, + int n) + { return(*(int *)0); } + +/* ./base/lib_instr.c */ + +#undef winnstr +int winnstr( + WINDOW *win, + char *str, + int n) + { return(*(int *)0); } + +/* ./base/lib_isendwin.c */ + +#undef isendwin_sp +NCURSES_BOOL isendwin_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef isendwin +NCURSES_BOOL isendwin(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_leaveok.c */ + +#undef leaveok +int leaveok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_mouse.c */ + +#undef getmouse_sp +int getmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef getmouse +int getmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse_sp +int ungetmouse_sp( + SCREEN *sp, + MEVENT *aevent) + { return(*(int *)0); } + +#undef ungetmouse +int ungetmouse( + MEVENT *aevent) + { return(*(int *)0); } + +#undef mousemask_sp +mmask_t mousemask_sp( + SCREEN *sp, + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef mousemask +mmask_t mousemask( + mmask_t newmask, + mmask_t *oldmask) + { return(*(mmask_t *)0); } + +#undef wenclose +NCURSES_BOOL wenclose( + const WINDOW *win, + int y, + int x) + { return(*(NCURSES_BOOL *)0); } + +#undef mouseinterval_sp +int mouseinterval_sp( + SCREEN *sp, + int maxclick) + { return(*(int *)0); } + +#undef mouseinterval +int mouseinterval( + int maxclick) + { return(*(int *)0); } + +#undef _nc_has_mouse +NCURSES_BOOL _nc_has_mouse( + const SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse_sp +NCURSES_BOOL has_mouse_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_mouse +NCURSES_BOOL has_mouse(void) + { return(*(NCURSES_BOOL *)0); } + +#undef wmouse_trafo +NCURSES_BOOL wmouse_trafo( + const WINDOW *win, + int *pY, + int *pX, + NCURSES_BOOL to_screen) + { return(*(NCURSES_BOOL *)0); } + +/* ./base/lib_move.c */ + +#undef wmove +int wmove( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +/* ./tty/lib_mvcur.c */ + +#undef _nc_msec_cost_sp +int _nc_msec_cost_sp( + SCREEN *sp, + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_msec_cost +int _nc_msec_cost( + const char *const cap, + int affcnt) + { return(*(int *)0); } + +#undef _nc_mvcur_resume_sp +void _nc_mvcur_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_resume +void _nc_mvcur_resume(void) + { /* void */ } + +#undef _nc_mvcur_init_sp +void _nc_mvcur_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_init +void _nc_mvcur_init(void) + { /* void */ } + +#undef _nc_mvcur_wrap_sp +void _nc_mvcur_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_mvcur_wrap +void _nc_mvcur_wrap(void) + { /* void */ } + +#undef _nc_mvcur_sp +int _nc_mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_mvcur +int _nc_mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur_sp +int mvcur_sp( + SCREEN *sp, + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef mvcur +int mvcur( + int yold, + int xold, + int ynew, + int xnew) + { return(*(int *)0); } + +#undef _nc_optimize_enable +int _nc_optimize_enable; + +/* ./base/lib_mvwin.c */ + +#undef mvwin +int mvwin( + WINDOW *win, + int by, + int bx) + { return(*(int *)0); } + +/* ./base/lib_newterm.c */ + +#undef filter_sp +void filter_sp( + SCREEN *sp) + { /* void */ } + +#undef filter +void filter(void) + { /* void */ } + +#undef nofilter_sp +void nofilter_sp( + SCREEN *sp) + { /* void */ } + +#undef nofilter +void nofilter(void) + { /* void */ } + +#undef newterm_sp +SCREEN *newterm_sp( + SCREEN *sp, + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +#undef newterm +SCREEN *newterm( + const char *name, + FILE *ofp, + FILE *ifp) + { return(*(SCREEN **)0); } + +/* ./base/lib_newwin.c */ + +#undef _nc_freewin +int _nc_freewin( + WINDOW *win) + { return(*(int *)0); } + +#undef newwin_sp +WINDOW *newwin_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef newwin +WINDOW *newwin( + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef derwin +WINDOW *derwin( + WINDOW *orig, + int num_lines, + int num_columns, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef subwin +WINDOW *subwin( + WINDOW *w, + int l, + int c, + int y, + int x) + { return(*(WINDOW **)0); } + +#undef _nc_makenew_sp +WINDOW *_nc_makenew_sp( + SCREEN *sp, + int num_lines, + int num_columns, + int begy, + int begx, + int flags) + { return(*(WINDOW **)0); } + +#undef _nc_curscr_of +WINDOW *_nc_curscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_newscr_of +WINDOW *_nc_newscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +#undef _nc_stdscr_of +WINDOW *_nc_stdscr_of( + SCREEN *sp) + { return(*(WINDOW **)0); } + +/* ./base/lib_nl.c */ + +#undef nl_sp +int nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nl +int nl(void) + { return(*(int *)0); } + +#undef nonl_sp +int nonl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nonl +int nonl(void) + { return(*(int *)0); } + +/* ./base/lib_overlay.c */ + +#undef overlay +int overlay( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef overwrite +int overwrite( + const WINDOW *win1, + WINDOW *win2) + { return(*(int *)0); } + +#undef copywin +int copywin( + const WINDOW *src, + WINDOW *dst, + int sminrow, + int smincol, + int dminrow, + int dmincol, + int dmaxrow, + int dmaxcol, + int over) + { return(*(int *)0); } + +/* ./base/lib_pad.c */ + +#undef newpad_sp +WINDOW *newpad_sp( + SCREEN *sp, + int l, + int c) + { return(*(WINDOW **)0); } + +#undef newpad +WINDOW *newpad( + int l, + int c) + { return(*(WINDOW **)0); } + +#undef subpad +WINDOW *subpad( + WINDOW *orig, + int l, + int c, + int begy, + int begx) + { return(*(WINDOW **)0); } + +#undef prefresh +int prefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pnoutrefresh +int pnoutrefresh( + WINDOW *win, + int pminrow, + int pmincol, + int sminrow, + int smincol, + int smaxrow, + int smaxcol) + { return(*(int *)0); } + +#undef pechochar +int pechochar( + WINDOW *pad, + const chtype ch) + { return(*(int *)0); } + +/* ./base/lib_printw.c */ + +#undef printw +int printw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wprintw +int wprintw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvprintw +int mvprintw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwprintw +int mvwprintw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef vwprintw +int vwprintw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_printw +int vw_printw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +/* ./base/lib_redrawln.c */ + +#undef wredrawln +int wredrawln( + WINDOW *win, + int beg, + int num) + { return(*(int *)0); } + +/* ./base/lib_refresh.c */ + +#undef wrefresh +int wrefresh( + WINDOW *win) + { return(*(int *)0); } + +#undef wnoutrefresh +int wnoutrefresh( + WINDOW *win) + { return(*(int *)0); } + +/* ./base/lib_restart.c */ + +#undef restartterm_sp +int restartterm_sp( + SCREEN *sp, + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +#undef restartterm +int restartterm( + const char *termp, + int filenum, + int *errret) + { return(*(int *)0); } + +/* ./base/lib_scanw.c */ + +#undef vwscanw +int vwscanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef vw_scanw +int vw_scanw( + WINDOW *win, + const char *fmt, + va_list argp) + { return(*(int *)0); } + +#undef scanw +int scanw( + const char *fmt, + ...) + { return(*(int *)0); } + +#undef wscanw +int wscanw( + WINDOW *win, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvscanw +int mvscanw( + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +#undef mvwscanw +int mvwscanw( + WINDOW *win, + int y, + int x, + const char *fmt, + ...) + { return(*(int *)0); } + +/* ./base/lib_screen.c */ + +#undef getwin_sp +WINDOW *getwin_sp( + SCREEN *sp, + FILE *filep) + { return(*(WINDOW **)0); } + +#undef getwin +WINDOW *getwin( + FILE *filep) + { return(*(WINDOW **)0); } + +#undef putwin +int putwin( + WINDOW *win, + FILE *filep) + { return(*(int *)0); } + +#undef scr_restore_sp +int scr_restore_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_restore +int scr_restore( + const char *file) + { return(*(int *)0); } + +#undef scr_dump +int scr_dump( + const char *file) + { return(*(int *)0); } + +#undef scr_init_sp +int scr_init_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_init +int scr_init( + const char *file) + { return(*(int *)0); } + +#undef scr_set_sp +int scr_set_sp( + SCREEN *sp, + const char *file) + { return(*(int *)0); } + +#undef scr_set +int scr_set( + const char *file) + { return(*(int *)0); } + +/* ./base/lib_scroll.c */ + +#undef _nc_scroll_window +void _nc_scroll_window( + WINDOW *win, + int const n, + int const top, + int const bottom, + cchar_t blank) + { /* void */ } + +#undef wscrl +int wscrl( + WINDOW *win, + int n) + { return(*(int *)0); } + +/* ./base/lib_scrollok.c */ + +#undef scrollok +int scrollok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/lib_scrreg.c */ + +#undef wsetscrreg +int wsetscrreg( + WINDOW *win, + int top, + int bottom) + { return(*(int *)0); } + +/* ./base/lib_set_term.c */ + +#undef set_term +SCREEN *set_term( + SCREEN *screenp) + { return(*(SCREEN **)0); } + +#undef delscreen +void delscreen( + SCREEN *sp) + { /* void */ } + +#undef _nc_setupscreen_sp +int _nc_setupscreen_sp( + SCREEN **spp, + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_setupscreen +int _nc_setupscreen( + int slines, + int scolumns, + FILE *output, + NCURSES_BOOL filtered, + int slk_format) + { return(*(int *)0); } + +#undef _nc_ripoffline_sp +int _nc_ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef _nc_ripoffline +int _nc_ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline_sp +int ripoffline_sp( + SCREEN *sp, + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +#undef ripoffline +int ripoffline( + int line, + int (*init)( + WINDOW *p1, + int p2)) + { return(*(int *)0); } + +/* ./base/lib_slk.c */ + +#undef _nc_format_slks +int _nc_format_slks( + SCREEN *sp, + int cols) + { return(*(int *)0); } + +#undef _nc_slk_initialize +int _nc_slk_initialize( + WINDOW *stwin, + int cols) + { return(*(int *)0); } + +#undef slk_restore_sp +int slk_restore_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_restore +int slk_restore(void) + { return(*(int *)0); } + +/* ./base/lib_slkatr_set.c */ + +#undef slk_attr_set_sp +int slk_attr_set_sp( + SCREEN *sp, + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef slk_attr_set +int slk_attr_set( + const attr_t attr, + short pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_slkatrof.c */ + +#undef slk_attroff_sp +int slk_attroff_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attroff +int slk_attroff( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatron.c */ + +#undef slk_attron_sp +int slk_attron_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attron +int slk_attron( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkatrset.c */ + +#undef slk_attrset_sp +int slk_attrset_sp( + SCREEN *sp, + const chtype attr) + { return(*(int *)0); } + +#undef slk_attrset +int slk_attrset( + const chtype attr) + { return(*(int *)0); } + +/* ./base/lib_slkattr.c */ + +#undef slk_attr_sp +attr_t slk_attr_sp( + SCREEN *sp) + { return(*(attr_t *)0); } + +#undef slk_attr +attr_t slk_attr(void) + { return(*(attr_t *)0); } + +/* ./base/lib_slkclear.c */ + +#undef slk_clear_sp +int slk_clear_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_clear +int slk_clear(void) + { return(*(int *)0); } + +/* ./base/lib_slkcolor.c */ + +#undef slk_color_sp +int slk_color_sp( + SCREEN *sp, + short pair_arg) + { return(*(int *)0); } + +#undef slk_color +int slk_color( + short pair_arg) + { return(*(int *)0); } + +#undef extended_slk_color_sp +int extended_slk_color_sp( + SCREEN *sp, + int pair_arg) + { return(*(int *)0); } + +#undef extended_slk_color +int extended_slk_color( + int pair_arg) + { return(*(int *)0); } + +/* ./base/lib_slkinit.c */ + +#undef slk_init_sp +int slk_init_sp( + SCREEN *sp, + int format) + { return(*(int *)0); } + +#undef slk_init +int slk_init( + int format) + { return(*(int *)0); } + +/* ./base/lib_slklab.c */ + +#undef slk_label_sp +char *slk_label_sp( + SCREEN *sp, + int n) + { return(*(char **)0); } + +#undef slk_label +char *slk_label( + int n) + { return(*(char **)0); } + +/* ./base/lib_slkrefr.c */ + +#undef slk_noutrefresh_sp +int slk_noutrefresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_noutrefresh +int slk_noutrefresh(void) + { return(*(int *)0); } + +#undef slk_refresh_sp +int slk_refresh_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_refresh +int slk_refresh(void) + { return(*(int *)0); } + +/* ./base/lib_slkset.c */ + +#undef slk_set_sp +int slk_set_sp( + SCREEN *sp, + int i, + const char *astr, + int format) + { return(*(int *)0); } + +#undef slk_set +int slk_set( + int i, + const char *astr, + int format) + { return(*(int *)0); } + +/* ./base/lib_slktouch.c */ + +#undef slk_touch_sp +int slk_touch_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef slk_touch +int slk_touch(void) + { return(*(int *)0); } + +/* ./base/lib_touch.c */ + +#undef is_linetouched +NCURSES_BOOL is_linetouched( + WINDOW *win, + int line) + { return(*(NCURSES_BOOL *)0); } + +#undef is_wintouched +NCURSES_BOOL is_wintouched( + WINDOW *win) + { return(*(NCURSES_BOOL *)0); } + +#undef wtouchln +int wtouchln( + WINDOW *win, + int y, + int n, + int changed) + { return(*(int *)0); } + +/* ./trace/lib_tracedmp.c */ + +#undef _tracedump +void _tracedump( + const char *name, + WINDOW *win) + { /* void */ } + +/* ./trace/lib_tracemse.c */ + +#undef _nc_trace_mmask_t +char *_nc_trace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(char **)0); } + +#undef _nc_tracemouse +char *_nc_tracemouse( + SCREEN *sp, + MEVENT const *ep) + { return(*(char **)0); } + +#undef _nc_retrace_mmask_t +mmask_t _nc_retrace_mmask_t( + SCREEN *sp, + mmask_t code) + { return(*(mmask_t *)0); } + +#undef _tracemouse +char *_tracemouse( + MEVENT const *ep) + { return(*(char **)0); } + +/* ./tty/lib_tstp.c */ + +#undef _nc_signal_handler +void _nc_signal_handler( + int enable) + { /* void */ } + +/* ./base/lib_ungetch.c */ + +#undef _nc_fifo_dump +void _nc_fifo_dump( + SCREEN *sp) + { /* void */ } + +#undef ungetch_sp +int ungetch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef ungetch +int ungetch( + int ch) + { return(*(int *)0); } + +/* ./tty/lib_vidattr.c */ + +#undef vidputs_sp +int vidputs_sp( + SCREEN *sp, + chtype newmode, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef vidputs +int vidputs( + chtype newmode, + NCURSES_OUTC outc) + { return(*(int *)0); } + +#undef vidattr_sp +int vidattr_sp( + SCREEN *sp, + chtype newmode) + { return(*(int *)0); } + +#undef vidattr +int vidattr( + chtype newmode) + { return(*(int *)0); } + +#undef termattrs_sp +chtype termattrs_sp( + SCREEN *sp) + { return(*(chtype *)0); } + +#undef termattrs +chtype termattrs(void) + { return(*(chtype *)0); } + +/* ./base/lib_vline.c */ + +#undef wvline +int wvline( + WINDOW *win, + chtype ch, + int n) + { return(*(int *)0); } + +/* ./base/lib_wattroff.c */ + +#undef wattr_off +int wattr_off( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_wattron.c */ + +#undef wattr_on +int wattr_on( + WINDOW *win, + attr_t at, + void *opts) + { return(*(int *)0); } + +/* ./base/lib_winch.c */ + +#undef winch +chtype winch( + WINDOW *win) + { return(*(chtype *)0); } + +/* ./base/lib_window.c */ + +#undef _nc_synchook +void _nc_synchook( + WINDOW *win) + { /* void */ } + +#undef mvderwin +int mvderwin( + WINDOW *win, + int y, + int x) + { return(*(int *)0); } + +#undef syncok +int syncok( + WINDOW *win, + NCURSES_BOOL bf) + { return(*(int *)0); } + +#undef wsyncup +void wsyncup( + WINDOW *win) + { /* void */ } + +#undef wsyncdown +void wsyncdown( + WINDOW *win) + { /* void */ } + +#undef wcursyncup +void wcursyncup( + WINDOW *win) + { /* void */ } + +#undef dupwin +WINDOW *dupwin( + WINDOW *win) + { return(*(WINDOW **)0); } + +/* ./base/nc_panel.c */ + +#undef _nc_panelhook_sp +struct panelhook *_nc_panelhook_sp( + SCREEN *sp) + { return(*(struct panelhook **)0); } + +#undef _nc_panelhook +struct panelhook *_nc_panelhook(void) + { return(*(struct panelhook **)0); } + +/* ./base/safe_sprintf.c */ + +#undef _nc_printf_string_sp +char *_nc_printf_string_sp( + SCREEN *sp, + const char *fmt, + va_list ap) + { return(*(char **)0); } + +#undef _nc_printf_string +char *_nc_printf_string( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./tty/tty_update.c */ + +#undef doupdate_sp +int doupdate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef doupdate +int doupdate(void) + { return(*(int *)0); } + +#undef _nc_scrolln_sp +int _nc_scrolln_sp( + SCREEN *sp, + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_scrolln +int _nc_scrolln( + int n, + int top, + int bot, + int maxy) + { return(*(int *)0); } + +#undef _nc_screen_resume_sp +void _nc_screen_resume_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_resume +void _nc_screen_resume(void) + { /* void */ } + +#undef _nc_screen_init_sp +void _nc_screen_init_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_init +void _nc_screen_init(void) + { /* void */ } + +#undef _nc_screen_wrap_sp +void _nc_screen_wrap_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_screen_wrap +void _nc_screen_wrap(void) + { /* void */ } + +#undef _nc_do_xmc_glitch_sp +void _nc_do_xmc_glitch_sp( + SCREEN *sp, + attr_t previous) + { /* void */ } + +#undef _nc_do_xmc_glitch +void _nc_do_xmc_glitch( + attr_t previous) + { /* void */ } + +/* ./trace/varargs.c */ + +#undef _nc_varargs +char *_nc_varargs( + const char *fmt, + va_list ap) + { return(*(char **)0); } + +/* ./base/vsscanf.c */ + +#undef _nc_vsscanf +void _nc_vsscanf(void) + { /* void */ } + +/* ./base/lib_freeall.c */ + +#undef _nc_freeall +void _nc_freeall(void) + { /* void */ } + +#undef _nc_free_and_exit_sp +void _nc_free_and_exit_sp( + SCREEN *sp, + int code) + { /* void */ } + +#undef _nc_free_and_exit +void _nc_free_and_exit( + int code) + { /* void */ } + +#undef exit_curses +void exit_curses( + int code) + { /* void */ } + +/* ./widechar/charable.c */ + +#undef _nc_is_charable +NCURSES_BOOL _nc_is_charable( + wchar_t ch) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_to_char +int _nc_to_char( + wint_t ch) + { return(*(int *)0); } + +#undef _nc_to_widechar +wint_t _nc_to_widechar( + int ch) + { return(*(wint_t *)0); } + +/* ./widechar/lib_add_wch.c */ + +#undef wadd_wch +int wadd_wch( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +#undef wecho_wchar +int wecho_wchar( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +/* ./widechar/lib_box_set.c */ + +#undef wborder_set +int wborder_set( + WINDOW *win, + const cchar_t *ls, + const cchar_t *rs, + const cchar_t *ts, + const cchar_t *bs, + const cchar_t *tl, + const cchar_t *tr, + const cchar_t *bl, + const cchar_t *br) + { return(*(int *)0); } + +/* ./widechar/lib_cchar.c */ + +#undef setcchar +int setcchar( + cchar_t *wcval, + const wchar_t *wch, + const attr_t attrs, + short pair_arg, + const void *opts) + { return(*(int *)0); } + +#undef getcchar +int getcchar( + const cchar_t *wcval, + wchar_t *wch, + attr_t *attrs, + short *pair_arg, + void *opts) + { return(*(int *)0); } + +/* ./widechar/lib_erasewchar.c */ + +#undef erasewchar_sp +int erasewchar_sp( + SCREEN *sp, + wchar_t *wch) + { return(*(int *)0); } + +#undef erasewchar +int erasewchar( + wchar_t *wch) + { return(*(int *)0); } + +#undef killwchar_sp +int killwchar_sp( + SCREEN *sp, + wchar_t *wch) + { return(*(int *)0); } + +#undef killwchar +int killwchar( + wchar_t *wch) + { return(*(int *)0); } + +/* ./widechar/lib_get_wch.c */ + +#undef wget_wch +int wget_wch( + WINDOW *win, + wint_t *result) + { return(*(int *)0); } + +/* ./widechar/lib_get_wstr.c */ + +#undef wgetn_wstr +int wgetn_wstr( + WINDOW *win, + wint_t *str, + int maxlen) + { return(*(int *)0); } + +/* ./widechar/lib_hline_set.c */ + +#undef whline_set +int whline_set( + WINDOW *win, + const cchar_t *ch, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_in_wch.c */ + +#undef win_wch +int win_wch( + WINDOW *win, + cchar_t *wcval) + { return(*(int *)0); } + +/* ./widechar/lib_in_wchnstr.c */ + +#undef win_wchnstr +int win_wchnstr( + WINDOW *win, + cchar_t *wchstr, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_ins_wch.c */ + +#undef _nc_insert_wch +int _nc_insert_wch( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +#undef wins_wch +int wins_wch( + WINDOW *win, + const cchar_t *wch) + { return(*(int *)0); } + +#undef wins_nwstr +int wins_nwstr( + WINDOW *win, + const wchar_t *wstr, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_inwstr.c */ + +#undef winnwstr +int winnwstr( + WINDOW *win, + wchar_t *wstr, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_key_name.c */ + +#undef key_name +const char *key_name( + wchar_t c) + { return(*(const char **)0); } + +/* ./widechar/lib_pecho_wchar.c */ + +#undef pecho_wchar +int pecho_wchar( + WINDOW *pad, + const cchar_t *wch) + { return(*(int *)0); } + +/* ./widechar/lib_slk_wset.c */ + +#undef slk_wset +int slk_wset( + int i, + const wchar_t *astr, + int format) + { return(*(int *)0); } + +/* ./widechar/lib_unget_wch.c */ + +#undef _nc_wcrtomb +size_t _nc_wcrtomb( + char *target, + wchar_t source, + mbstate_t *state) + { return(*(size_t *)0); } + +#undef unget_wch_sp +int unget_wch_sp( + SCREEN *sp, + const wchar_t wch) + { return(*(int *)0); } + +#undef unget_wch +int unget_wch( + const wchar_t wch) + { return(*(int *)0); } + +/* ./widechar/lib_vid_attr.c */ + +#undef vid_puts_sp +int vid_puts_sp( + SCREEN *sp, + attr_t newmode, + short pair_arg, + void *opts, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef vid_puts +int vid_puts( + attr_t newmode, + short pair_arg, + void *opts, + NCURSES_OUTC outc) + { return(*(int *)0); } + +#undef vid_attr_sp +int vid_attr_sp( + SCREEN *sp, + attr_t newmode, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef vid_attr +int vid_attr( + attr_t newmode, + short pair_arg, + void *opts) + { return(*(int *)0); } + +#undef term_attrs_sp +attr_t term_attrs_sp( + SCREEN *sp) + { return(*(attr_t *)0); } + +#undef term_attrs +attr_t term_attrs(void) + { return(*(attr_t *)0); } + +/* ./widechar/lib_vline_set.c */ + +#undef wvline_set +int wvline_set( + WINDOW *win, + const cchar_t *ch, + int n) + { return(*(int *)0); } + +/* ./widechar/lib_wacs.c */ + +#undef _nc_wacs +cchar_t *_nc_wacs; + +#undef _nc_init_wacs +void _nc_init_wacs(void) + { /* void */ } + +/* ./widechar/lib_wunctrl.c */ + +#undef wunctrl_sp +wchar_t *wunctrl_sp( + SCREEN *sp, + cchar_t *wc) + { return(*(wchar_t **)0); } + +#undef wunctrl +wchar_t *wunctrl( + cchar_t *wc) + { return(*(wchar_t **)0); } + +/* ./expanded.c */ + +#undef _nc_toggle_attr_on +void _nc_toggle_attr_on( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_toggle_attr_off +void _nc_toggle_attr_off( + attr_t *S, + attr_t at) + { /* void */ } + +#undef _nc_DelCharCost_sp +int _nc_DelCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost_sp +int _nc_InsCharCost_sp( + SCREEN *sp, + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs_sp +void _nc_UpdateAttrs_sp( + SCREEN *sp, + const cchar_t *c) + { /* void */ } + +#undef _nc_DelCharCost +int _nc_DelCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_InsCharCost +int _nc_InsCharCost( + int count) + { return(*(int *)0); } + +#undef _nc_UpdateAttrs +void _nc_UpdateAttrs( + const cchar_t *c) + { /* void */ } + +/* ./base/legacy_coding.c */ + +#undef use_legacy_coding_sp +int use_legacy_coding_sp( + SCREEN *sp, + int level) + { return(*(int *)0); } + +#undef use_legacy_coding +int use_legacy_coding( + int level) + { return(*(int *)0); } + +/* ./base/lib_dft_fgbg.c */ + +#undef use_default_colors_sp +int use_default_colors_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_default_colors +int use_default_colors(void) + { return(*(int *)0); } + +#undef assume_default_colors_sp +int assume_default_colors_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef assume_default_colors +int assume_default_colors( + int fg, + int bg) + { return(*(int *)0); } + +/* ./tinfo/lib_print.c */ + +#undef mcprint_sp +int mcprint_sp( + SCREEN *sp, + char *data, + int len) + { return(*(int *)0); } + +#undef mcprint +int mcprint( + char *data, + int len) + { return(*(int *)0); } + +/* ./base/new_pair.c */ + +#undef _nc_free_ordered_pairs +void _nc_free_ordered_pairs( + SCREEN *sp) + { /* void */ } + +#undef _nc_reset_color_pair +void _nc_reset_color_pair( + SCREEN *sp, + int pair, + const colorpair_t *next) + { /* void */ } + +#undef _nc_set_color_pair +void _nc_set_color_pair( + SCREEN *sp, + int pair, + int mode) + { /* void */ } + +#undef _nc_copy_pairs +void _nc_copy_pairs( + SCREEN *sp, + colorpair_t *target, + colorpair_t *source, + int length) + { /* void */ } + +#undef alloc_pair_sp +int alloc_pair_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef find_pair_sp +int find_pair_sp( + SCREEN *sp, + int fg, + int bg) + { return(*(int *)0); } + +#undef free_pair_sp +int free_pair_sp( + SCREEN *sp, + int pair) + { return(*(int *)0); } + +#undef alloc_pair +int alloc_pair( + int f, + int b) + { return(*(int *)0); } + +#undef find_pair +int find_pair( + int f, + int b) + { return(*(int *)0); } + +#undef free_pair +int free_pair( + int pair) + { return(*(int *)0); } + +/* ./base/resizeterm.c */ + +#undef is_term_resized_sp +NCURSES_BOOL is_term_resized_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef is_term_resized +NCURSES_BOOL is_term_resized( + int ToLines, + int ToCols) + { return(*(NCURSES_BOOL *)0); } + +#undef resize_term_sp +int resize_term_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resize_term +int resize_term( + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm_sp +int resizeterm_sp( + SCREEN *sp, + int ToLines, + int ToCols) + { return(*(int *)0); } + +#undef resizeterm +int resizeterm( + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./trace/trace_xnames.c */ + +#undef _nc_trace_xnames +void _nc_trace_xnames( + TERMTYPE *tp) + { /* void */ } + +/* ./tinfo/use_screen.c */ + +#undef use_screen +int use_screen( + SCREEN *screen, + NCURSES_SCREEN_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/use_window.c */ + +#undef use_window +int use_window( + WINDOW *win, + NCURSES_WINDOW_CB func, + void *data) + { return(*(int *)0); } + +/* ./base/wresize.c */ + +#undef wresize +int wresize( + WINDOW *win, + int ToLines, + int ToCols) + { return(*(int *)0); } + +/* ./tinfo/access.c */ + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE2 *to, + TERMTYPE2 *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +#undef _nc_copy_termtype2 +void _nc_copy_termtype2( + TERMTYPE2 *dst, + const TERMTYPE2 *src) + { /* void */ } + +#undef _nc_export_termtype2 +void _nc_export_termtype2( + TERMTYPE *dst, + const TERMTYPE2 *src) + { /* void */ } + +/* ./codes.c */ + +#undef boolcodes +const char *const boolcodes[] = {0}; +#undef numcodes +const char *const numcodes[] = {0}; +#undef strcodes +const char *const strcodes[] = {0}; + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE2 *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback2 +const TERMTYPE2 *_nc_fallback2( + const char *name) + { return(*(const TERMTYPE2 **)0); } + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype2 +void _nc_free_termtype2( + TERMTYPE2 *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef acs_map +chtype acs_map[128]; + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef cur_term +TERMINAL *cur_term; + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef stdscr +WINDOW *stdscr; +#undef curscr +WINDOW *curscr; +#undef newscr +WINDOW *newscr; +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef ttytype +char ttytype[256]; +#undef LINES +int LINES; +#undef COLS +int COLS; +#undef TABSIZE +int TABSIZE; + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; +#undef _nc_tputs_trace +const char *_nc_tputs_trace = {0}; +#undef _nc_outchars +long _nc_outchars; + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +#undef _tracecchar_t2 +char *_tracecchar_t2( + int bufnum, + const cchar_t *ch) + { return(*(char **)0); } + +#undef _tracecchar_t +char *_tracecchar_t( + const cchar_t *ch) + { return(*(char **)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef boolnames +const char *const boolnames[] = {0}; +#undef boolfnames +const char *const boolfnames[] = {0}; +#undef numnames +const char *const numnames[] = {0}; +#undef numfnames +const char *const numfnames[] = {0}; +#undef strnames +const char *const strnames[] = {0}; +#undef strfnames +const char *const strfnames[] = {0}; + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE2 *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE2 *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry2 +int _nc_read_entry2( + const char *const name, + char *const filename, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap_entry +int _nc_read_termcap_entry( + const char *const tn, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE2 *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswbuf2 +const char *_nc_viswbuf2( + int bufnum, + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbuf +const char *_nc_viswbuf( + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbufn +const char *_nc_viswbufn( + const wchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswibuf +const char *_nc_viswibuf( + const wint_t *buf) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +/* ./tinfo/alloc_entry.c */ + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE2 *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE2 *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-ltic b/ncurses/ncurses/llib-ltic new file mode 100644 index 0000000000..8116adec14 --- /dev/null +++ b/ncurses/ncurses/llib-ltic @@ -0,0 +1,206 @@ +/**************************************************************************** + * Copyright 2020-2021,2023 Thomas E. Dickey * + * Copyright 2012-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/alloc_entry.c */ + +#include + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } diff --git a/ncurses/ncurses/llib-ltict b/ncurses/ncurses/llib-ltict new file mode 100644 index 0000000000..49579747c5 --- /dev/null +++ b/ncurses/ncurses/llib-ltict @@ -0,0 +1,206 @@ +/**************************************************************************** + * Copyright 2020-2021,2023 Thomas E. Dickey * + * Copyright 2013-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2013-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/alloc_entry.c */ + +#include + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } diff --git a/ncurses/ncurses/llib-ltictw b/ncurses/ncurses/llib-ltictw new file mode 100644 index 0000000000..28d173c8d8 --- /dev/null +++ b/ncurses/ncurses/llib-ltictw @@ -0,0 +1,206 @@ +/**************************************************************************** + * Copyright 2020-2021,2023 Thomas E. Dickey * + * Copyright 2012-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/alloc_entry.c */ + +#include + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE2 *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE2 *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } diff --git a/ncurses/ncurses/llib-lticw b/ncurses/ncurses/llib-lticw new file mode 100644 index 0000000000..28d173c8d8 --- /dev/null +++ b/ncurses/ncurses/llib-lticw @@ -0,0 +1,206 @@ +/**************************************************************************** + * Copyright 2020-2021,2023 Thomas E. Dickey * + * Copyright 2012-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/alloc_entry.c */ + +#include + +#undef _nc_init_entry +void _nc_init_entry( + ENTRY *const tp) + { /* void */ } + +#undef _nc_copy_entry +ENTRY *_nc_copy_entry( + ENTRY *oldp) + { return(*(ENTRY **)0); } + +#undef _nc_save_str +char *_nc_save_str( + const char *string) + { return(*(char **)0); } + +#undef _nc_wrap_entry +void _nc_wrap_entry( + ENTRY *const ep, + NCURSES_BOOL copy_strings) + { /* void */ } + +#undef _nc_merge_entry +void _nc_merge_entry( + ENTRY *const target, + ENTRY *const source) + { /* void */ } + +/* ./tinfo/captoinfo.c */ + +#undef _nc_captoinfo +char *_nc_captoinfo( + const char *cap, + const char *s, + int const parameterized) + { return(*(char **)0); } + +#undef _nc_infotocap +char *_nc_infotocap( + const char *cap, + const char *str, + int const parameterized) + { return(*(char **)0); } + +/* ./tinfo/comp_expand.c */ + +#undef _nc_tic_expand +char *_nc_tic_expand( + const char *srcp, + NCURSES_BOOL tic_format, + int numbers) + { return(*(char **)0); } + +/* ./tinfo/comp_parse.c */ + +#undef _nc_check_termtype2 +void (*_nc_check_termtype2)( + TERMTYPE2 *p1, + NCURSES_BOOL p2); + +#undef _nc_entry_match +NCURSES_BOOL _nc_entry_match( + char *n1, + char *n2) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_read_entry_source +void _nc_read_entry_source( + FILE *fp, + char *buf, + int literal, + NCURSES_BOOL silent, + NCURSES_BOOL (*hook)( + ENTRY *p1)) + { /* void */ } + +#undef _nc_resolve_uses2 +int _nc_resolve_uses2( + NCURSES_BOOL fullresolve, + NCURSES_BOOL literal) + { return(*(int *)0); } + +/* ./tinfo/comp_scan.c */ + +#undef _nc_syntax +int _nc_syntax; +#undef _nc_strict_bsd +int _nc_strict_bsd; +#undef _nc_curr_file_pos +long _nc_curr_file_pos; +#undef _nc_comment_start +long _nc_comment_start; +#undef _nc_comment_end +long _nc_comment_end; +#undef _nc_start_line +long _nc_start_line; +#undef _nc_curr_token +struct token _nc_curr_token; +#undef _nc_disable_period +NCURSES_BOOL _nc_disable_period; + +#undef _nc_reset_input +void _nc_reset_input( + FILE *fp, + char *buf) + { /* void */ } + +#undef _nc_get_token +int _nc_get_token( + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_trans_string +int _nc_trans_string( + char *ptr, + const char *const last) + { return(*(int *)0); } + +#undef _nc_push_token +void _nc_push_token( + int tokclass) + { /* void */ } + +#undef _nc_panic_mode +void _nc_panic_mode( + char ch) + { /* void */ } + +/* ./tinfo/parse_entry.c */ + +#undef _nc_parse_entry +int _nc_parse_entry( + ENTRY *entryp, + int literal, + NCURSES_BOOL silent) + { return(*(int *)0); } + +#undef _nc_capcmp +int _nc_capcmp( + const char *s, + const char *t) + { return(*(int *)0); } + +/* ./tinfo/write_entry.c */ + +#undef _nc_set_writedir +void _nc_set_writedir( + const char *dir) + { /* void */ } + +#undef _nc_write_entry +void _nc_write_entry( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_write_object +int _nc_write_object( + TERMTYPE2 *tp, + char *buffer, + unsigned *offset, + unsigned limit) + { return(*(int *)0); } + +#undef _nc_tic_written +int _nc_tic_written(void) + { return(*(int *)0); } diff --git a/ncurses/ncurses/llib-ltinfo b/ncurses/ncurses/llib-ltinfo new file mode 100644 index 0000000000..cd11da5837 --- /dev/null +++ b/ncurses/ncurses/llib-ltinfo @@ -0,0 +1,1616 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 2012-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/access.c */ + +#include + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE *to, + TERMTYPE *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +/* ./codes.c */ + +#undef boolcodes +const char *const boolcodes[] = {0}; +#undef numcodes +const char *const numcodes[] = {0}; +#undef strcodes +const char *const strcodes[] = {0}; + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef acs_map +chtype acs_map[128]; + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef cur_term +TERMINAL *cur_term; + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef stdscr +WINDOW *stdscr; +#undef curscr +WINDOW *curscr; +#undef newscr +WINDOW *newscr; +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef ttytype +char ttytype[256]; +#undef LINES +int LINES; +#undef COLS +int COLS; +#undef TABSIZE +int TABSIZE; + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; +#undef _nc_tputs_trace +const char *_nc_tputs_trace = {0}; +#undef _nc_outchars +long _nc_outchars; + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef boolnames +const char *const boolnames[] = {0}; +#undef boolfnames +const char *const boolfnames[] = {0}; +#undef numnames +const char *const numnames[] = {0}; +#undef numfnames +const char *const numfnames[] = {0}; +#undef strnames +const char *const strnames[] = {0}; +#undef strfnames +const char *const strfnames[] = {0}; + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap +void _nc_read_termcap(void) + { /* void */ } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const chtype *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const chtype *buf, + int len) + { return(*(const char **)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-ltinfot b/ncurses/ncurses/llib-ltinfot new file mode 100644 index 0000000000..92835a1c4b --- /dev/null +++ b/ncurses/ncurses/llib-ltinfot @@ -0,0 +1,1728 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 2013-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2013-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/access.c */ + +#include + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE *to, + TERMTYPE *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +/* ./codes.c */ + +#undef _nc_boolcodes +const char *const *_nc_boolcodes(void) + { return(*(const char **)0); } + +#undef _nc_numcodes +const char *const *_nc_numcodes(void) + { return(*(const char **)0); } + +#undef _nc_strcodes +const char *const *_nc_strcodes(void) + { return(*(const char **)0); } + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef _nc_acs_map +chtype *_nc_acs_map(void) + { return(*(chtype **)0); } + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef _nc_get_cur_term_sp +TERMINAL *_nc_get_cur_term_sp( + SCREEN *sp) + { return(*(TERMINAL **)0); } + +#undef _nc_get_cur_term +TERMINAL *_nc_get_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef _nc_cur_term +TERMINAL *_nc_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef _nc_stdscr +WINDOW *_nc_stdscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_curscr +WINDOW *_nc_curscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_newscr +WINDOW *_nc_newscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +#undef _nc_init_pthreads +void _nc_init_pthreads(void) + { /* void */ } + +#undef _nc_mutex_init +void _nc_mutex_init( + pthread_mutex_t *obj) + { /* void */ } + +#undef _nc_mutex_lock +int _nc_mutex_lock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_trylock +int _nc_mutex_trylock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_unlock +int _nc_mutex_unlock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef _nc_ttytype +char *_nc_ttytype(void) + { return(*(char **)0); } + +#undef _nc_ptr_Lines +int *_nc_ptr_Lines( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_LINES +int _nc_LINES(void) + { return(*(int *)0); } + +#undef _nc_ptr_Cols +int *_nc_ptr_Cols( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_COLS +int _nc_COLS(void) + { return(*(int *)0); } + +#undef _nc_ptr_Tabsize +int *_nc_ptr_Tabsize( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_TABSIZE +int _nc_TABSIZE(void) + { return(*(int *)0); } + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef _nc_find_prescr +SCREEN *_nc_find_prescr(void) + { return(*(SCREEN **)0); } + +#undef _nc_forget_prescr +void _nc_forget_prescr(void) + { /* void */ } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; + +#undef _nc__nc_tputs_trace +const char *_nc__nc_tputs_trace(void) + { return(*(const char **)0); } + +#undef _nc__nc_outchars +long _nc__nc_outchars(void) + { return(*(long *)0); } + +#undef _nc_set_tputs_trace +void _nc_set_tputs_trace( + const char *s) + { /* void */ } + +#undef _nc_count_outchars +void _nc_count_outchars( + long increment) + { /* void */ } + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +#undef _nc_use_tracef +int _nc_use_tracef( + unsigned mask) + { return(*(int *)0); } + +#undef _nc_locked_tracef +void _nc_locked_tracef( + const char *fmt, + ...) + { /* void */ } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef _nc_boolnames +const char *const *_nc_boolnames(void) + { return(*(const char **)0); } + +#undef _nc_boolfnames +const char *const *_nc_boolfnames(void) + { return(*(const char **)0); } + +#undef _nc_numnames +const char *const *_nc_numnames(void) + { return(*(const char **)0); } + +#undef _nc_numfnames +const char *const *_nc_numfnames(void) + { return(*(const char **)0); } + +#undef _nc_strnames +const char *const *_nc_strnames(void) + { return(*(const char **)0); } + +#undef _nc_strfnames +const char *const *_nc_strfnames(void) + { return(*(const char **)0); } + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap +void _nc_read_termcap(void) + { /* void */ } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const chtype *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const chtype *buf, + int len) + { return(*(const char **)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-ltinfotw b/ncurses/ncurses/llib-ltinfotw new file mode 100644 index 0000000000..48f4282142 --- /dev/null +++ b/ncurses/ncurses/llib-ltinfotw @@ -0,0 +1,1790 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2012-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/access.c */ + +#include + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE2 *to, + TERMTYPE2 *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +#undef _nc_copy_termtype2 +void _nc_copy_termtype2( + TERMTYPE2 *dst, + const TERMTYPE2 *src) + { /* void */ } + +#undef _nc_export_termtype2 +void _nc_export_termtype2( + TERMTYPE *dst, + const TERMTYPE2 *src) + { /* void */ } + +/* ./codes.c */ + +#undef _nc_boolcodes +const char *const *_nc_boolcodes(void) + { return(*(const char **)0); } + +#undef _nc_numcodes +const char *const *_nc_numcodes(void) + { return(*(const char **)0); } + +#undef _nc_strcodes +const char *const *_nc_strcodes(void) + { return(*(const char **)0); } + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE2 *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback2 +const TERMTYPE2 *_nc_fallback2( + const char *name) + { return(*(const TERMTYPE2 **)0); } + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype2 +void _nc_free_termtype2( + TERMTYPE2 *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef _nc_acs_map +chtype *_nc_acs_map(void) + { return(*(chtype **)0); } + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef _nc_get_cur_term_sp +TERMINAL *_nc_get_cur_term_sp( + SCREEN *sp) + { return(*(TERMINAL **)0); } + +#undef _nc_get_cur_term +TERMINAL *_nc_get_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef _nc_cur_term +TERMINAL *_nc_cur_term(void) + { return(*(TERMINAL **)0); } + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef _nc_stdscr +WINDOW *_nc_stdscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_curscr +WINDOW *_nc_curscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_newscr +WINDOW *_nc_newscr(void) + { return(*(WINDOW **)0); } + +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +#undef _nc_init_pthreads +void _nc_init_pthreads(void) + { /* void */ } + +#undef _nc_mutex_init +void _nc_mutex_init( + pthread_mutex_t *obj) + { /* void */ } + +#undef _nc_mutex_lock +int _nc_mutex_lock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_trylock +int _nc_mutex_trylock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +#undef _nc_mutex_unlock +int _nc_mutex_unlock( + pthread_mutex_t *obj) + { return(*(int *)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef _nc_ttytype +char *_nc_ttytype(void) + { return(*(char **)0); } + +#undef _nc_ptr_Lines +int *_nc_ptr_Lines( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_LINES +int _nc_LINES(void) + { return(*(int *)0); } + +#undef _nc_ptr_Cols +int *_nc_ptr_Cols( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_COLS +int _nc_COLS(void) + { return(*(int *)0); } + +#undef _nc_ptr_Tabsize +int *_nc_ptr_Tabsize( + SCREEN *sp) + { return(*(int **)0); } + +#undef _nc_TABSIZE +int _nc_TABSIZE(void) + { return(*(int *)0); } + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef _nc_find_prescr +SCREEN *_nc_find_prescr(void) + { return(*(SCREEN **)0); } + +#undef _nc_forget_prescr +void _nc_forget_prescr(void) + { /* void */ } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; + +#undef _nc__nc_tputs_trace +const char *_nc__nc_tputs_trace(void) + { return(*(const char **)0); } + +#undef _nc__nc_outchars +long _nc__nc_outchars(void) + { return(*(long *)0); } + +#undef _nc_set_tputs_trace +void _nc_set_tputs_trace( + const char *s) + { /* void */ } + +#undef _nc_count_outchars +void _nc_count_outchars( + long increment) + { /* void */ } + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +#undef _nc_use_tracef +int _nc_use_tracef( + unsigned mask) + { return(*(int *)0); } + +#undef _nc_locked_tracef +void _nc_locked_tracef( + const char *fmt, + ...) + { /* void */ } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +#undef _tracecchar_t2 +char *_tracecchar_t2( + int bufnum, + const cchar_t *ch) + { return(*(char **)0); } + +#undef _tracecchar_t +char *_tracecchar_t( + const cchar_t *ch) + { return(*(char **)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef _nc_boolnames +const char *const *_nc_boolnames(void) + { return(*(const char **)0); } + +#undef _nc_boolfnames +const char *const *_nc_boolfnames(void) + { return(*(const char **)0); } + +#undef _nc_numnames +const char *const *_nc_numnames(void) + { return(*(const char **)0); } + +#undef _nc_numfnames +const char *const *_nc_numfnames(void) + { return(*(const char **)0); } + +#undef _nc_strnames +const char *const *_nc_strnames(void) + { return(*(const char **)0); } + +#undef _nc_strfnames +const char *const *_nc_strfnames(void) + { return(*(const char **)0); } + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE2 *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE2 *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry2 +int _nc_read_entry2( + const char *const name, + char *const filename, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap +void _nc_read_termcap(void) + { /* void */ } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE2 *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswbuf2 +const char *_nc_viswbuf2( + int bufnum, + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbuf +const char *_nc_viswbuf( + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbufn +const char *_nc_viswbufn( + const wchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswibuf +const char *_nc_viswibuf( + const wint_t *buf) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/llib-ltinfow b/ncurses/ncurses/llib-ltinfow new file mode 100644 index 0000000000..703bc9512a --- /dev/null +++ b/ncurses/ncurses/llib-ltinfow @@ -0,0 +1,1678 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2012-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2012-on * + ****************************************************************************/ +/* LINTLIBRARY */ + +/* ./tinfo/access.c */ + +#include + +#undef _nc_rootname +char *_nc_rootname( + char *path) + { return(*(char **)0); } + +#undef _nc_is_abs_path +NCURSES_BOOL _nc_is_abs_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_pathlast +unsigned _nc_pathlast( + const char *path) + { return(*(unsigned *)0); } + +#undef _nc_basename +char *_nc_basename( + char *path) + { return(*(char **)0); } + +#undef _nc_access +int _nc_access( + const char *path, + int mode) + { return(*(int *)0); } + +#undef _nc_is_dir_path +NCURSES_BOOL _nc_is_dir_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_file_path +NCURSES_BOOL _nc_is_file_path( + const char *path) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_is_path_found +NCURSES_BOOL _nc_is_path_found( + const char *path, + struct stat *sb) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_env_access +int _nc_env_access(void) + { return(*(int *)0); } + +#undef _nc_safe_fopen +FILE *_nc_safe_fopen( + const char *path, + const char *mode) + { return(*(FILE **)0); } + +#undef _nc_safe_open3 +int _nc_safe_open3( + const char *path, + int flags, + mode_t mode) + { return(*(int *)0); } + +/* ./tinfo/add_tries.c */ + +#undef _nc_add_to_try +int _nc_add_to_try( + TRIES **tree, + const char *str, + unsigned code) + { return(*(int *)0); } + +/* ./tinfo/alloc_ttype.c */ + +#undef _nc_align_termtype +void _nc_align_termtype( + TERMTYPE2 *to, + TERMTYPE2 *from) + { /* void */ } + +#undef _nc_copy_termtype +void _nc_copy_termtype( + TERMTYPE *dst, + const TERMTYPE *src) + { /* void */ } + +#undef _nc_copy_termtype2 +void _nc_copy_termtype2( + TERMTYPE2 *dst, + const TERMTYPE2 *src) + { /* void */ } + +#undef _nc_export_termtype2 +void _nc_export_termtype2( + TERMTYPE *dst, + const TERMTYPE2 *src) + { /* void */ } + +/* ./codes.c */ + +#undef boolcodes +const char *const boolcodes[] = {0}; +#undef numcodes +const char *const numcodes[] = {0}; +#undef strcodes +const char *const strcodes[] = {0}; + +/* ./comp_captab.c */ + +#undef _nc_get_table +const struct name_table_entry *_nc_get_table( + NCURSES_BOOL termcap) + { return(*(const struct name_table_entry **)0); } + +#undef _nc_get_hash_table +const HashValue *_nc_get_hash_table( + NCURSES_BOOL termcap) + { return(*(const HashValue **)0); } + +#undef _nc_get_alias_table +const struct alias *_nc_get_alias_table( + NCURSES_BOOL termcap) + { return(*(const struct alias **)0); } + +#undef _nc_get_hash_info +const HashData *_nc_get_hash_info( + NCURSES_BOOL termcap) + { return(*(const HashData **)0); } + +/* ./tinfo/comp_error.c */ + +#undef _nc_suppress_warnings +NCURSES_BOOL _nc_suppress_warnings; +#undef _nc_curr_line +int _nc_curr_line; +#undef _nc_curr_col +int _nc_curr_col; + +#undef _nc_get_source +const char *_nc_get_source(void) + { return(*(const char **)0); } + +#undef _nc_set_source +void _nc_set_source( + const char *const name) + { /* void */ } + +#undef _nc_set_type +void _nc_set_type( + const char *const name) + { /* void */ } + +#undef _nc_get_type +void _nc_get_type( + char *name) + { /* void */ } + +#undef _nc_warning +void _nc_warning( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_err_abort +void _nc_err_abort( + const char *const fmt, + ...) + { /* void */ } + +#undef _nc_syserr_abort +void _nc_syserr_abort( + const char *const fmt, + ...) + { /* void */ } + +/* ./tinfo/comp_hash.c */ + +#undef _nc_find_entry +struct name_table_entry const *_nc_find_entry( + const char *string, + const HashValue *hash_table) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_type_entry +struct name_table_entry const *_nc_find_type_entry( + const char *string, + int type, + NCURSES_BOOL termcap) + { return(*(struct name_table_entry const **)0); } + +#undef _nc_find_user_entry +struct user_table_entry const *_nc_find_user_entry( + const char *string) + { return(*(struct user_table_entry const **)0); } + +/* ./comp_userdefs.c */ + +#undef _nc_get_userdefs_table +const struct user_table_entry *_nc_get_userdefs_table(void) + { return(*(const struct user_table_entry **)0); } + +#undef _nc_get_hash_user +const HashData *_nc_get_hash_user(void) + { return(*(const HashData **)0); } + +/* ./tinfo/db_iterator.c */ + +#undef _nc_tic_dir +const char *_nc_tic_dir( + const char *path) + { return(*(const char **)0); } + +#undef _nc_keep_tic_dir +void _nc_keep_tic_dir( + const char *path) + { /* void */ } + +#undef _nc_last_db +void _nc_last_db(void) + { /* void */ } + +#undef _nc_next_db +const char *_nc_next_db( + DBDIRS *state, + int *offset) + { return(*(const char **)0); } + +#undef _nc_first_db +void _nc_first_db( + DBDIRS *state, + int *offset) + { /* void */ } + +/* ./tinfo/doalloc.c */ + +#undef _nc_doalloc +void *_nc_doalloc( + void *oldp, + size_t amount) + { return(*(void **)0); } + +/* ./tinfo/entries.c */ + +#undef _nc_head +ENTRY *_nc_head; +#undef _nc_tail +ENTRY *_nc_tail; + +#undef _nc_free_entry +void _nc_free_entry( + ENTRY *headp, + const TERMTYPE2 *tterm) + { /* void */ } + +#undef _nc_free_entries +void _nc_free_entries( + ENTRY *headp) + { /* void */ } + +#undef _nc_leaks_tinfo +void _nc_leaks_tinfo(void) + { /* void */ } + +#undef exit_terminfo +void exit_terminfo( + int code) + { /* void */ } + +/* ./fallback.c */ + +#undef _nc_fallback2 +const TERMTYPE2 *_nc_fallback2( + const char *name) + { return(*(const TERMTYPE2 **)0); } + +#undef _nc_fallback +const TERMTYPE *_nc_fallback( + const char *name) + { return(*(const TERMTYPE **)0); } + +/* ./tinfo/free_ttype.c */ + +#undef _nc_free_termtype +void _nc_free_termtype( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype1 +void _nc_free_termtype1( + TERMTYPE *ptr) + { /* void */ } + +#undef _nc_free_termtype2 +void _nc_free_termtype2( + TERMTYPE2 *ptr) + { /* void */ } + +#undef _nc_user_definable +NCURSES_BOOL _nc_user_definable; + +#undef use_extended_names +int use_extended_names( + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/getenv_num.c */ + +#undef _nc_getenv_num +int _nc_getenv_num( + const char *name) + { return(*(int *)0); } + +#undef _nc_setenv_num +void _nc_setenv_num( + const char *name, + int value) + { /* void */ } + +/* ./tinfo/home_terminfo.c */ + +#undef _nc_home_terminfo +char *_nc_home_terminfo(void) + { return(*(char **)0); } + +/* ./tinfo/init_keytry.c */ + +#undef _nc_init_keytry +void _nc_init_keytry( + SCREEN *sp) + { /* void */ } + +/* ./tinfo/lib_acs.c */ + +#undef acs_map +chtype acs_map[128]; + +#undef _nc_init_acs_sp +void _nc_init_acs_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_init_acs +void _nc_init_acs(void) + { /* void */ } + +/* ./tinfo/lib_baudrate.c */ + +struct speed { + int given_speed; + int actual_speed; +}; + +#undef _nc_baudrate +int _nc_baudrate( + int OSpeed) + { return(*(int *)0); } + +#undef _nc_ospeed +int _nc_ospeed( + int BaudRate) + { return(*(int *)0); } + +#undef baudrate_sp +int baudrate_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef baudrate +int baudrate(void) + { return(*(int *)0); } + +/* ./tinfo/lib_cur_term.c */ + +#undef cur_term +TERMINAL *cur_term; + +#undef set_curterm_sp +TERMINAL *set_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef set_curterm +TERMINAL *set_curterm( + TERMINAL *termp) + { return(*(TERMINAL **)0); } + +#undef del_curterm_sp +int del_curterm_sp( + SCREEN *sp, + TERMINAL *termp) + { return(*(int *)0); } + +#undef del_curterm +int del_curterm( + TERMINAL *termp) + { return(*(int *)0); } + +/* ./tinfo/lib_data.c */ + +#undef stdscr +WINDOW *stdscr; +#undef curscr +WINDOW *curscr; +#undef newscr +WINDOW *newscr; +#undef _nc_screen_chain +SCREEN *_nc_screen_chain; +#undef SP +SCREEN *SP; +#undef _nc_globals +NCURSES_GLOBALS _nc_globals; +#undef _nc_prescreen +NCURSES_PRESCREEN _nc_prescreen; + +#undef _nc_screen_of +SCREEN *_nc_screen_of( + WINDOW *win) + { return(*(SCREEN **)0); } + +/* ./tinfo/lib_has_cap.c */ + +#undef has_ic_sp +NCURSES_BOOL has_ic_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_ic +NCURSES_BOOL has_ic(void) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il_sp +NCURSES_BOOL has_il_sp( + SCREEN *sp) + { return(*(NCURSES_BOOL *)0); } + +#undef has_il +NCURSES_BOOL has_il(void) + { return(*(NCURSES_BOOL *)0); } + +/* ./tinfo/lib_kernel.c */ + +#undef erasechar_sp +char erasechar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef erasechar +char erasechar(void) + { return(*(char *)0); } + +#undef killchar_sp +char killchar_sp( + SCREEN *sp) + { return(*(char *)0); } + +#undef killchar +char killchar(void) + { return(*(char *)0); } + +#undef flushinp_sp +int flushinp_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef flushinp +int flushinp(void) + { return(*(int *)0); } + +/* ./lib_keyname.c */ + +struct kn { short offset; int code; }; + +#undef keyname_sp +const char *keyname_sp( + SCREEN *sp, + int c) + { return(*(const char **)0); } + +#undef keyname +const char *keyname( + int c) + { return(*(const char **)0); } + +/* ./tinfo/lib_longname.c */ + +#undef longname_sp +char *longname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef longname +char *longname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_napms.c */ + +#undef napms_sp +int napms_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef napms +int napms( + int ms) + { return(*(int *)0); } + +/* ./tinfo/lib_options.c */ + +#undef idlok +int idlok( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef idcok +void idcok( + WINDOW *win, + NCURSES_BOOL flag) + { /* void */ } + +#undef halfdelay_sp +int halfdelay_sp( + SCREEN *sp, + int t) + { return(*(int *)0); } + +#undef halfdelay +int halfdelay( + int t) + { return(*(int *)0); } + +#undef nodelay +int nodelay( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef notimeout +int notimeout( + WINDOW *win, + NCURSES_BOOL f) + { return(*(int *)0); } + +#undef wtimeout +void wtimeout( + WINDOW *win, + int delay) + { /* void */ } + +#undef keypad +int keypad( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef meta +int meta( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef curs_set_sp +int curs_set_sp( + SCREEN *sp, + int vis) + { return(*(int *)0); } + +#undef curs_set +int curs_set( + int vis) + { return(*(int *)0); } + +#undef typeahead_sp +int typeahead_sp( + SCREEN *sp, + int fd) + { return(*(int *)0); } + +#undef typeahead +int typeahead( + int fd) + { return(*(int *)0); } + +#undef has_key_sp +int has_key_sp( + SCREEN *sp, + int keycode) + { return(*(int *)0); } + +#undef has_key +int has_key( + int keycode) + { return(*(int *)0); } + +#undef _nc_putp_flush_sp +int _nc_putp_flush_sp( + SCREEN *sp, + const char *name, + const char *value) + { return(*(int *)0); } + +#undef _nc_keypad +int _nc_keypad( + SCREEN *sp, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./tinfo/lib_raw.c */ + +#undef raw_sp +int raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef raw +int raw(void) + { return(*(int *)0); } + +#undef cbreak_sp +int cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef cbreak +int cbreak(void) + { return(*(int *)0); } + +#undef qiflush_sp +void qiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef qiflush +void qiflush(void) + { /* void */ } + +#undef noraw_sp +int noraw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef noraw +int noraw(void) + { return(*(int *)0); } + +#undef nocbreak_sp +int nocbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef nocbreak +int nocbreak(void) + { return(*(int *)0); } + +#undef noqiflush_sp +void noqiflush_sp( + SCREEN *sp) + { /* void */ } + +#undef noqiflush +void noqiflush(void) + { /* void */ } + +#undef intrflush_sp +int intrflush_sp( + SCREEN *sp, + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef intrflush +int intrflush( + WINDOW *win, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef is_nl_sp +int is_nl_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_raw_sp +int is_raw_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_cbreak_sp +int is_cbreak_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_echo_sp +int is_echo_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef is_nl +int is_nl(void) + { return(*(int *)0); } + +#undef is_raw +int is_raw(void) + { return(*(int *)0); } + +#undef is_cbreak +int is_cbreak(void) + { return(*(int *)0); } + +#undef is_echo +int is_echo(void) + { return(*(int *)0); } + +/* ./tinfo/lib_setup.c */ + +#undef ttytype +char ttytype[256]; +#undef LINES +int LINES; +#undef COLS +int COLS; +#undef TABSIZE +int TABSIZE; + +#undef set_tabsize_sp +int set_tabsize_sp( + SCREEN *sp, + int value) + { return(*(int *)0); } + +#undef set_tabsize +int set_tabsize( + int value) + { return(*(int *)0); } + +#undef _nc_handle_sigwinch +int _nc_handle_sigwinch( + SCREEN *sp) + { return(*(int *)0); } + +#undef use_env_sp +void use_env_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl_sp +void use_tioctl_sp( + SCREEN *sp, + NCURSES_BOOL f) + { /* void */ } + +#undef use_env +void use_env( + NCURSES_BOOL f) + { /* void */ } + +#undef use_tioctl +void use_tioctl( + NCURSES_BOOL f) + { /* void */ } + +#undef _nc_get_screensize +void _nc_get_screensize( + SCREEN *sp, + int *linep, + int *colp) + { /* void */ } + +#undef _nc_update_screensize +void _nc_update_screensize( + SCREEN *sp) + { /* void */ } + +#undef _nc_setup_tinfo +int _nc_setup_tinfo( + const char *const tn, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_tinfo_cmdch +void _nc_tinfo_cmdch( + TERMINAL *termp, + int proto) + { /* void */ } + +#undef _nc_get_locale +char *_nc_get_locale(void) + { return(*(char **)0); } + +#undef _nc_unicode_locale +NCURSES_BOOL _nc_unicode_locale(void) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_locale_breaks_acs +int _nc_locale_breaks_acs( + TERMINAL *termp) + { return(*(int *)0); } + +#undef _nc_setupterm +int _nc_setupterm( + const char *tname, + int Filedes, + int *errret, + int reuse) + { return(*(int *)0); } + +#undef new_prescr +SCREEN *new_prescr(void) + { return(*(SCREEN **)0); } + +#undef setupterm +int setupterm( + const char *tname, + int Filedes, + int *errret) + { return(*(int *)0); } + +/* ./tinfo/lib_termcap.c */ + +#undef UP +char *UP; +#undef BC +char *BC; + +#undef tgetent_sp +int tgetent_sp( + SCREEN *sp, + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetent +int tgetent( + char *bufp, + const char *name) + { return(*(int *)0); } + +#undef tgetflag_sp +int tgetflag_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetflag +int tgetflag( + const char *id) + { return(*(int *)0); } + +#undef tgetnum_sp +int tgetnum_sp( + SCREEN *sp, + const char *id) + { return(*(int *)0); } + +#undef tgetnum +int tgetnum( + const char *id) + { return(*(int *)0); } + +#undef tgetstr_sp +char *tgetstr_sp( + SCREEN *sp, + const char *id, + char **area) + { return(*(char **)0); } + +#undef tgetstr +char *tgetstr( + const char *id, + char **area) + { return(*(char **)0); } + +/* ./tinfo/lib_termname.c */ + +#undef termname_sp +char *termname_sp( + SCREEN *sp) + { return(*(char **)0); } + +#undef termname +char *termname(void) + { return(*(char **)0); } + +/* ./tinfo/lib_tgoto.c */ + +#undef tgoto +char *tgoto( + const char *string, + int x, + int y) + { return(*(char **)0); } + +/* ./tinfo/lib_ti.c */ + +#undef tigetflag_sp +int tigetflag_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetflag +int tigetflag( + const char *str) + { return(*(int *)0); } + +#undef tigetnum_sp +int tigetnum_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef tigetnum +int tigetnum( + const char *str) + { return(*(int *)0); } + +#undef tigetstr_sp +char *tigetstr_sp( + SCREEN *sp, + const char *str) + { return(*(char **)0); } + +#undef tigetstr +char *tigetstr( + const char *str) + { return(*(char **)0); } + +/* ./tinfo/lib_tparm.c */ + +#undef _nc_tparm_err +int _nc_tparm_err; + +#undef _nc_free_tparm +void _nc_free_tparm( + TERMINAL *termp) + { /* void */ } + +#undef _nc_tparm_analyze +int _nc_tparm_analyze( + TERMINAL *term, + const char *string, + char **p_is_s, + int *_nc_popcount) + { return(*(int *)0); } + +#undef tparm +char *tparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm +char *tiparm( + const char *string, + ...) + { return(*(char **)0); } + +#undef tiparm_s +char *tiparm_s( + int num_expected, + int tparm_type, + const char *string, + ...) + { return(*(char **)0); } + +#undef tiscan_s +int tiscan_s( + int *num_expected, + int *tparm_type, + const char *string) + { return(*(int *)0); } + +#undef _nc_tiparm +char *_nc_tiparm( + int expected, + const char *string, + ...) + { return(*(char **)0); } + +#undef _nc_reset_tparm +void _nc_reset_tparm( + TERMINAL *term) + { /* void */ } + +/* ./tinfo/lib_tputs.c */ + +#undef PC +char PC; +#undef ospeed +short ospeed; +#undef _nc_nulls_sent +int _nc_nulls_sent; + +#undef _nc_set_no_padding +void _nc_set_no_padding( + SCREEN *sp) + { /* void */ } + +#undef delay_output_sp +int delay_output_sp( + SCREEN *sp, + int ms) + { return(*(int *)0); } + +#undef delay_output +int delay_output( + int ms) + { return(*(int *)0); } + +#undef _nc_flush_sp +void _nc_flush_sp( + SCREEN *sp) + { /* void */ } + +#undef _nc_flush +void _nc_flush(void) + { /* void */ } + +#undef _nc_outch_sp +int _nc_outch_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_outch +int _nc_outch( + int ch) + { return(*(int *)0); } + +#undef _nc_putchar_sp +int _nc_putchar_sp( + SCREEN *sp, + int ch) + { return(*(int *)0); } + +#undef _nc_putchar +int _nc_putchar( + int ch) + { return(*(int *)0); } + +#undef putp_sp +int putp_sp( + SCREEN *sp, + const char *string) + { return(*(int *)0); } + +#undef putp +int putp( + const char *string) + { return(*(int *)0); } + +#undef _nc_putp_sp +int _nc_putp_sp( + SCREEN *sp, + const char *name, + const char *string) + { return(*(int *)0); } + +#undef _nc_putp +int _nc_putp( + const char *name, + const char *string) + { return(*(int *)0); } + +#undef tputs_sp +int tputs_sp( + SCREEN *sp, + const char *string, + int affcnt, + NCURSES_OUTC_sp outc) + { return(*(int *)0); } + +#undef _nc_outc_wrapper +int _nc_outc_wrapper( + SCREEN *sp, + int c) + { return(*(int *)0); } + +#undef tputs +int tputs( + const char *string, + int affcnt, + int (*outc)( + int p1)) + { return(*(int *)0); } + +/* ./trace/lib_trace.c */ + +#undef _nc_tracing +unsigned _nc_tracing; +#undef _nc_tputs_trace +const char *_nc_tputs_trace = {0}; +#undef _nc_outchars +long _nc_outchars; + +#undef curses_trace +unsigned curses_trace( + unsigned tracelevel) + { return(*(unsigned *)0); } + +#undef trace +void trace( + const unsigned int tracelevel) + { /* void */ } + +#undef _tracef +void _tracef( + const char *fmt, + ...) + { /* void */ } + +#undef _nc_retrace_bool +NCURSES_BOOL _nc_retrace_bool( + NCURSES_BOOL code) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_retrace_char +char _nc_retrace_char( + int code) + { return(*(char *)0); } + +#undef _nc_retrace_int +int _nc_retrace_int( + int code) + { return(*(int *)0); } + +#undef _nc_retrace_unsigned +unsigned _nc_retrace_unsigned( + unsigned code) + { return(*(unsigned *)0); } + +#undef _nc_retrace_ptr +char *_nc_retrace_ptr( + char *code) + { return(*(char **)0); } + +#undef _nc_retrace_cptr +const char *_nc_retrace_cptr( + const char *code) + { return(*(const char **)0); } + +#undef _nc_retrace_cvoid_ptr +const void *_nc_retrace_cvoid_ptr( + const void *code) + { return(*(const void **)0); } + +#undef _nc_retrace_void_ptr +void *_nc_retrace_void_ptr( + void *code) + { return(*(void **)0); } + +#undef _nc_retrace_sp +SCREEN *_nc_retrace_sp( + SCREEN *code) + { return(*(SCREEN **)0); } + +#undef _nc_retrace_win +WINDOW *_nc_retrace_win( + WINDOW *code) + { return(*(WINDOW **)0); } + +#undef _nc_fmt_funcptr +char *_nc_fmt_funcptr( + char *target, + const char *source, + size_t size) + { return(*(char **)0); } + +/* ./trace/lib_traceatr.c */ + +#undef _traceattr2 +char *_traceattr2( + int bufnum, + chtype newmode) + { return(*(char **)0); } + +#undef _traceattr +char *_traceattr( + attr_t newmode) + { return(*(char **)0); } + +#undef _nc_retrace_int_attr_t +int _nc_retrace_int_attr_t( + attr_t code) + { return(*(int *)0); } + +#undef _nc_retrace_attr_t +attr_t _nc_retrace_attr_t( + attr_t code) + { return(*(attr_t *)0); } + +#undef _nc_altcharset_name +const char *_nc_altcharset_name( + attr_t attr, + chtype ch) + { return(*(const char **)0); } + +#undef _tracechtype2 +char *_tracechtype2( + int bufnum, + chtype ch) + { return(*(char **)0); } + +#undef _tracechtype +char *_tracechtype( + chtype ch) + { return(*(char **)0); } + +#undef _nc_retrace_chtype +chtype _nc_retrace_chtype( + chtype code) + { return(*(chtype *)0); } + +#undef _tracecchar_t2 +char *_tracecchar_t2( + int bufnum, + const cchar_t *ch) + { return(*(char **)0); } + +#undef _tracecchar_t +char *_tracecchar_t( + const cchar_t *ch) + { return(*(char **)0); } + +/* ./trace/lib_tracebits.c */ + +#undef _nc_trace_ttymode +char *_nc_trace_ttymode( + const struct termios *tty) + { return(*(char **)0); } + +#undef _nc_tracebits +char *_nc_tracebits(void) + { return(*(char **)0); } + +/* ./trace/lib_tracechr.c */ + +#undef _nc_tracechar +char *_nc_tracechar( + SCREEN *sp, + int ch) + { return(*(char **)0); } + +#undef _tracechar +char *_tracechar( + int ch) + { return(*(char **)0); } + +/* ./tinfo/lib_ttyflags.c */ + +#undef _nc_get_tty_mode_sp +int _nc_get_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_get_tty_mode +int _nc_get_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode_sp +int _nc_set_tty_mode_sp( + SCREEN *sp, + struct termios *buf) + { return(*(int *)0); } + +#undef _nc_set_tty_mode +int _nc_set_tty_mode( + struct termios *buf) + { return(*(int *)0); } + +#undef def_shell_mode_sp +int def_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_shell_mode +int def_shell_mode(void) + { return(*(int *)0); } + +#undef def_prog_mode_sp +int def_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef def_prog_mode +int def_prog_mode(void) + { return(*(int *)0); } + +#undef reset_prog_mode_sp +int reset_prog_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_prog_mode +int reset_prog_mode(void) + { return(*(int *)0); } + +#undef reset_shell_mode_sp +int reset_shell_mode_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef reset_shell_mode +int reset_shell_mode(void) + { return(*(int *)0); } + +#undef savetty_sp +int savetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef savetty +int savetty(void) + { return(*(int *)0); } + +#undef resetty_sp +int resetty_sp( + SCREEN *sp) + { return(*(int *)0); } + +#undef resetty +int resetty(void) + { return(*(int *)0); } + +/* ./tty/lib_twait.c */ + +#undef _nc_timed_wait +int _nc_timed_wait( + const SCREEN *sp, + int mode, + int milliseconds, + int *timeleft) + { return(*(int *)0); } + +/* ./tinfo/name_match.c */ + +#undef _nc_first_name +char *_nc_first_name( + const char *const sp) + { return(*(char **)0); } + +#undef _nc_name_match +int _nc_name_match( + const char *const namelst, + const char *const name, + const char *const delim) + { return(*(int *)0); } + +/* ./names.c */ + +#undef boolnames +const char *const boolnames[] = {0}; +#undef boolfnames +const char *const boolfnames[] = {0}; +#undef numnames +const char *const numnames[] = {0}; +#undef numfnames +const char *const numfnames[] = {0}; +#undef strnames +const char *const strnames[] = {0}; +#undef strfnames +const char *const strfnames[] = {0}; + +/* ./tinfo/obsolete.c */ + +#undef _nc_set_buffer_sp +void _nc_set_buffer_sp( + SCREEN *sp, + FILE *ofp, + int buffered) + { /* void */ } + +#undef _nc_set_buffer +void _nc_set_buffer( + FILE *ofp, + int buffered) + { /* void */ } + +/* ./tinfo/read_entry.c */ + +#undef _nc_init_termtype +void _nc_init_termtype( + TERMTYPE2 *const tp) + { /* void */ } + +#undef _nc_read_termtype +int _nc_read_termtype( + TERMTYPE2 *ptr, + char *buffer, + int limit) + { return(*(int *)0); } + +#undef _nc_read_file_entry +int _nc_read_file_entry( + const char *const filename, + TERMTYPE2 *ptr) + { return(*(int *)0); } + +#undef _nc_read_entry2 +int _nc_read_entry2( + const char *const name, + char *const filename, + TERMTYPE2 *const tp) + { return(*(int *)0); } + +#undef _nc_read_entry +int _nc_read_entry( + const char *const name, + char *const filename, + TERMTYPE *const tp) + { return(*(int *)0); } + +/* ./tinfo/read_termcap.c */ + +#undef _nc_read_termcap +void _nc_read_termcap(void) + { /* void */ } + +/* ./tinfo/strings.c */ + +#undef _nc_str_init +string_desc *_nc_str_init( + string_desc *dst, + char *src, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_null +string_desc *_nc_str_null( + string_desc *dst, + size_t len) + { return(*(string_desc **)0); } + +#undef _nc_str_copy +string_desc *_nc_str_copy( + string_desc *dst, + const string_desc *const src) + { return(*(string_desc **)0); } + +#undef _nc_safe_strcat +NCURSES_BOOL _nc_safe_strcat( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +#undef _nc_safe_strcpy +NCURSES_BOOL _nc_safe_strcpy( + string_desc *dst, + const char *src) + { return(*(NCURSES_BOOL *)0); } + +/* ./trace/trace_buf.c */ + +#undef _nc_trace_buf +char *_nc_trace_buf( + int bufnum, + size_t want) + { return(*(char **)0); } + +#undef _nc_trace_bufcat +char *_nc_trace_bufcat( + int bufnum, + const char *value) + { return(*(char **)0); } + +/* ./trace/trace_tries.c */ + +#undef _nc_trace_tries +void _nc_trace_tries( + TRIES *tree) + { /* void */ } + +/* ./base/tries.c */ + +#undef _nc_expand_try +char *_nc_expand_try( + TRIES *tree, + unsigned code, + int *count, + size_t len) + { return(*(char **)0); } + +#undef _nc_remove_key +int _nc_remove_key( + TRIES **tree, + unsigned code) + { return(*(int *)0); } + +#undef _nc_remove_string +int _nc_remove_string( + TRIES **tree, + const char *string) + { return(*(int *)0); } + +/* ./tinfo/trim_sgr0.c */ + +#undef _nc_trim_sgr0 +char *_nc_trim_sgr0( + TERMTYPE2 *tp) + { return(*(char **)0); } + +/* ./unctrl.c */ + +#undef unctrl_sp +const char *unctrl_sp( + SCREEN *sp, + chtype ch) + { return(*(const char **)0); } + +#undef unctrl +const char *unctrl( + chtype ch) + { return(*(const char **)0); } + +/* ./trace/visbuf.c */ + +#undef _nc_visbuf2 +const char *_nc_visbuf2( + int bufnum, + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbuf +const char *_nc_visbuf( + const char *buf) + { return(*(const char **)0); } + +#undef _nc_visbufn +const char *_nc_visbufn( + const char *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswbuf2 +const char *_nc_viswbuf2( + int bufnum, + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbuf +const char *_nc_viswbuf( + const wchar_t *buf) + { return(*(const char **)0); } + +#undef _nc_viswbufn +const char *_nc_viswbufn( + const wchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viswibuf +const char *_nc_viswibuf( + const wint_t *buf) + { return(*(const char **)0); } + +#undef _nc_viscbuf2 +const char *_nc_viscbuf2( + int bufnum, + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +#undef _nc_viscbuf +const char *_nc_viscbuf( + const cchar_t *buf, + int len) + { return(*(const char **)0); } + +/* ./base/define_key.c */ + +#undef define_key_sp +int define_key_sp( + SCREEN *sp, + const char *str, + int keycode) + { return(*(int *)0); } + +#undef define_key +int define_key( + const char *str, + int keycode) + { return(*(int *)0); } + +/* ./tinfo/hashed_db.c */ + +#undef _nc_hashed_db +void _nc_hashed_db(void) + { /* void */ } + +/* ./base/key_defined.c */ + +#undef key_defined_sp +int key_defined_sp( + SCREEN *sp, + const char *str) + { return(*(int *)0); } + +#undef key_defined +int key_defined( + const char *str) + { return(*(int *)0); } + +/* ./base/keybound.c */ + +#undef keybound_sp +char *keybound_sp( + SCREEN *sp, + int code, + int count) + { return(*(char **)0); } + +#undef keybound +char *keybound( + int code, + int count) + { return(*(char **)0); } + +/* ./base/keyok.c */ + +#undef keyok_sp +int keyok_sp( + SCREEN *sp, + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +#undef keyok +int keyok( + int c, + NCURSES_BOOL flag) + { return(*(int *)0); } + +/* ./base/version.c */ + +#undef curses_version +const char *curses_version(void) + { return(*(const char **)0); } diff --git a/ncurses/ncurses/modules b/ncurses/ncurses/modules new file mode 100644 index 0000000000..cfede2c0b6 --- /dev/null +++ b/ncurses/ncurses/modules @@ -0,0 +1,268 @@ +# $Id: modules,v 1.133 2025/12/30 15:13:55 tom Exp $ +############################################################################## +# Copyright 2019-2020,2025 Thomas E. Dickey # +# Copyright 1998-2013,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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 +# + +@ base +# Library objects +hardscroll lib $(serial) $(HEADER_DEPS) +hashmap lib $(serial) $(HEADER_DEPS) +lib_addch lib $(base) $(HEADER_DEPS) +lib_addstr lib $(base) $(HEADER_DEPS) +lib_beep lib $(base) $(HEADER_DEPS) +lib_bkgd lib $(base) $(HEADER_DEPS) +lib_box lib $(base) $(HEADER_DEPS) +lib_chgat lib $(base) $(HEADER_DEPS) +lib_clear lib $(base) $(HEADER_DEPS) +lib_clearok lib $(base) $(HEADER_DEPS) +lib_clrbot lib $(base) $(HEADER_DEPS) +lib_clreol lib $(base) $(HEADER_DEPS) +lib_color lib $(base) $(HEADER_DEPS) $(INCDIR)/tic.h $(srcdir)/new_pair.h +lib_colorset lib $(base) $(HEADER_DEPS) +lib_delch lib $(base) $(HEADER_DEPS) +lib_delwin lib $(base) $(HEADER_DEPS) +lib_echo lib $(base) $(HEADER_DEPS) +lib_endwin lib $(base) $(HEADER_DEPS) +lib_erase lib $(base) $(HEADER_DEPS) +lib_flash lib $(base) $(HEADER_DEPS) +lib_gen lib . $(HEADER_DEPS) +lib_getch lib $(base) $(HEADER_DEPS) $(srcdir)/fifo_defs.h +lib_getstr lib $(base) $(HEADER_DEPS) +lib_hline lib $(base) $(HEADER_DEPS) +lib_immedok lib $(base) $(HEADER_DEPS) +lib_inchstr lib $(base) $(HEADER_DEPS) +lib_initscr lib $(base) $(HEADER_DEPS) +lib_insch lib $(base) $(HEADER_DEPS) +lib_insdel lib $(base) $(HEADER_DEPS) +lib_insnstr lib $(base) $(HEADER_DEPS) +lib_instr lib $(base) $(HEADER_DEPS) +lib_isendwin lib $(base) $(HEADER_DEPS) +lib_leaveok lib $(base) $(HEADER_DEPS) +lib_mouse lib $(base) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_move lib $(base) $(HEADER_DEPS) +lib_mvcur lib $(serial) $(HEADER_DEPS) $(INCDIR)/tic.h $(srcdir)/../progs/dump_entry.h +lib_mvwin lib $(base) $(HEADER_DEPS) +lib_newterm lib $(base) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_newwin lib $(base) $(HEADER_DEPS) +lib_nl lib $(base) $(HEADER_DEPS) +lib_overlay lib $(base) $(HEADER_DEPS) +lib_pad lib $(base) $(HEADER_DEPS) +lib_printw lib $(base) $(HEADER_DEPS) +lib_redrawln lib $(base) $(HEADER_DEPS) +lib_refresh lib $(base) $(HEADER_DEPS) +lib_restart lib $(base) $(HEADER_DEPS) +lib_scanw lib $(base) $(HEADER_DEPS) +lib_screen lib $(base) $(HEADER_DEPS) +lib_scroll lib $(base) $(HEADER_DEPS) +lib_scrollok lib $(base) $(HEADER_DEPS) +lib_scrreg lib $(base) $(HEADER_DEPS) +lib_set_term lib $(base) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_slk lib $(base) $(HEADER_DEPS) +lib_slkatr_set lib $(base) $(HEADER_DEPS) +lib_slkatrof lib $(base) $(HEADER_DEPS) +lib_slkatron lib $(base) $(HEADER_DEPS) +lib_slkatrset lib $(base) $(HEADER_DEPS) +lib_slkattr lib $(base) $(HEADER_DEPS) +lib_slkclear lib $(base) $(HEADER_DEPS) +lib_slkcolor lib $(base) $(HEADER_DEPS) +lib_slkinit lib $(base) $(HEADER_DEPS) +lib_slklab lib $(base) $(HEADER_DEPS) +lib_slkrefr lib $(base) $(HEADER_DEPS) +lib_slkset lib $(base) $(HEADER_DEPS) +lib_slktouch lib $(base) $(HEADER_DEPS) +lib_touch lib $(base) $(HEADER_DEPS) +lib_tracedmp lib $(trace) $(HEADER_DEPS) +lib_tracemse lib $(trace) $(HEADER_DEPS) +lib_tstp lib $(serial) $(HEADER_DEPS) $(srcdir)/SigAction.h +lib_ungetch lib $(base) $(HEADER_DEPS) $(srcdir)/fifo_defs.h +lib_vidattr lib $(serial) $(HEADER_DEPS) +lib_vline lib $(base) $(HEADER_DEPS) +lib_wattroff lib $(base) $(HEADER_DEPS) +lib_wattron lib $(base) $(HEADER_DEPS) +lib_winch lib $(base) $(HEADER_DEPS) +lib_window lib $(base) $(HEADER_DEPS) +link_test lib . $(HEADER_DEPS) +nc_panel lib $(base) $(HEADER_DEPS) +safe_sprintf lib $(base) $(HEADER_DEPS) +tty_update lib $(serial) $(HEADER_DEPS) +varargs lib $(trace) $(HEADER_DEPS) + +# Modules for porting +vsscanf lib $(base) $(HEADER_DEPS) + +# actually an extension, but with its own configure option (--disable-leaks) +lib_freeall lib $(base) $(HEADER_DEPS) $(INCDIR)/tic.h + +# XSI extensions to the base library (wide-character) +@ widechar +charable lib $(wide) $(HEADER_DEPS) +lib_add_wch lib $(wide) $(HEADER_DEPS) +lib_box_set lib $(wide) $(HEADER_DEPS) +lib_cchar lib $(wide) $(HEADER_DEPS) $(srcdir)/new_pair.h +lib_erasewchar lib $(wide) $(HEADER_DEPS) +lib_get_wch lib $(wide) $(HEADER_DEPS) +lib_get_wstr lib $(wide) $(HEADER_DEPS) +lib_hline_set lib $(wide) $(HEADER_DEPS) +lib_in_wch lib $(wide) $(HEADER_DEPS) +lib_in_wchnstr lib $(wide) $(HEADER_DEPS) +lib_ins_wch lib $(wide) $(HEADER_DEPS) +lib_inwstr lib $(wide) $(HEADER_DEPS) +lib_key_name lib $(wide) $(HEADER_DEPS) +lib_pecho_wchar lib $(wide) $(HEADER_DEPS) +lib_slk_wset lib $(wide) $(HEADER_DEPS) +lib_unget_wch lib $(wide) $(HEADER_DEPS) +lib_vid_attr lib $(wide) $(HEADER_DEPS) +lib_vline_set lib $(wide) $(HEADER_DEPS) +lib_wacs lib $(wide) $(HEADER_DEPS) +lib_wunctrl lib $(wide) $(HEADER_DEPS) + +# Extensions to the base library +@ ext_funcs +expanded lib . $(HEADER_DEPS) +legacy_coding lib $(base) $(HEADER_DEPS) +lib_dft_fgbg lib $(base) $(HEADER_DEPS) +lib_print lib $(tinfo) $(HEADER_DEPS) +new_pair lib $(base) $(HEADER_DEPS) $(srcdir)/new_pair.h +resizeterm lib $(base) $(HEADER_DEPS) +trace_xnames lib $(trace) $(HEADER_DEPS) +use_screen lib $(tinfo) $(HEADER_DEPS) +use_window lib $(base) $(HEADER_DEPS) +wresize lib $(base) $(HEADER_DEPS) + +# Support for termcap (and tic, etc.), which can be a separate library +@ termlib +access lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +add_tries lib $(tinfo) $(HEADER_DEPS) +alloc_ttype lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +codes lib . $(HEADER_DEPS) +comp_captab lib . $(HEADER_DEPS) $(INCDIR)/tic.h ../include/hashsize.h +comp_error lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +comp_hash lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h ../include/hashsize.h +comp_userdefs lib . $(HEADER_DEPS) $(INCDIR)/tic.h ../include/hashsize.h +db_iterator lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +doalloc lib $(tinfo) $(HEADER_DEPS) +entries lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +fallback lib . $(HEADER_DEPS) +free_ttype lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +getenv_num lib $(tinfo) $(HEADER_DEPS) +home_terminfo lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +init_keytry lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h init_keytry.h +lib_acs lib $(tinfo) $(HEADER_DEPS) +lib_baudrate lib $(tinfo) $(HEADER_DEPS) ../include/termcap.h +lib_cur_term lib $(tinfo) $(HEADER_DEPS) ../include/termcap.h +lib_data lib $(tinfo) $(HEADER_DEPS) +lib_has_cap lib $(tinfo) $(HEADER_DEPS) +lib_kernel lib $(tinfo) $(HEADER_DEPS) +lib_keyname lib . $(HEADER_DEPS) $(INCDIR)/tic.h +lib_longname lib $(tinfo) $(HEADER_DEPS) +lib_napms lib $(tinfo) $(HEADER_DEPS) +lib_options lib $(tinfo) $(HEADER_DEPS) +lib_raw lib $(tinfo) $(HEADER_DEPS) +lib_setup lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_termcap lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h ../include/termcap.h $(INCDIR)/capdefaults.c +lib_termname lib $(tinfo) $(HEADER_DEPS) +lib_tgoto lib $(tinfo) $(HEADER_DEPS) ../include/termcap.h +lib_ti lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_tparm lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_tputs lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h ../include/termcap.h +lib_trace lib $(trace) $(HEADER_DEPS) $(INCDIR)/tic.h +lib_traceatr lib $(trace) $(HEADER_DEPS) +lib_tracebits lib $(trace) $(HEADER_DEPS) +lib_tracechr lib $(trace) $(HEADER_DEPS) +lib_ttyflags lib $(tinfo) $(HEADER_DEPS) +lib_twait lib $(serial) $(HEADER_DEPS) +name_match lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +names lib . $(HEADER_DEPS) +obsolete lib $(tinfo) $(HEADER_DEPS) +read_entry lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h $(INCDIR)/hashed_db.h +read_termcap lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +strings lib $(tinfo) $(HEADER_DEPS) +trace_buf lib $(trace) $(HEADER_DEPS) +trace_tries lib $(trace) $(HEADER_DEPS) +tries lib $(base) $(HEADER_DEPS) +trim_sgr0 lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +unctrl lib . $(HEADER_DEPS) +visbuf lib $(trace) $(HEADER_DEPS) $(INCDIR)/tic.h + +# Modules used only for tic, other programs using internal interfaces +@ ticlib +alloc_entry lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +captoinfo lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +comp_expand lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +comp_parse lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +comp_scan lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h +parse_entry lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h ../include/parametrized.h +write_entry lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h $(INCDIR)/hashed_db.h + +# Extensions to the termlib library +@ ext_tinfo +define_key lib $(base) $(HEADER_DEPS) +hashed_db lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h $(INCDIR)/hashed_db.h +key_defined lib $(base) $(HEADER_DEPS) +keybound lib $(base) $(HEADER_DEPS) +keyok lib $(base) $(HEADER_DEPS) +version lib $(base) $(HEADER_DEPS) + +# Porting +@ port_drivers +lib_driver lib $(base) $(HEADER_DEPS) + +# MSYS2, using termios +@ port_msys2 +gettimeofday lib $(win32con) $(HEADER_DEPS) +lib_win32util lib $(tinfo) $(HEADER_DEPS) +wcwidth lib $(win32con) $(HEADER_DEPS) +widechars lib $(wide) $(HEADER_DEPS) + +# MinGW, using Console API +@ port_win32con +gettimeofday lib $(win32con) $(HEADER_DEPS) +lib_win32con lib $(tinfo) $(HEADER_DEPS) +lib_win32util lib $(tinfo) $(HEADER_DEPS) +wcwidth lib $(win32con) $(HEADER_DEPS) +widechars lib $(wide) $(HEADER_DEPS) +win32_driver lib $(win32con) $(HEADER_DEPS) + +# MinGW-W64, using Console API and named pipes +@ port_win32 +gettimeofday lib $(win32con) $(HEADER_DEPS) +lib_win32con lib $(tinfo) $(HEADER_DEPS) +lib_win32util lib $(tinfo) $(HEADER_DEPS) +wcwidth lib $(win32con) $(HEADER_DEPS) +win32_driver lib $(win32con) $(HEADER_DEPS) + +@ port_tinfo +tinfo_driver lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h + +# vile:makemode diff --git a/ncurses/ncurses/new_pair.h b/ncurses/ncurses/new_pair.h new file mode 100644 index 0000000000..5f79871550 --- /dev/null +++ b/ncurses/ncurses/new_pair.h @@ -0,0 +1,142 @@ +/**************************************************************************** + * Copyright 2018-2021,2024 Thomas E. Dickey * + * Copyright 2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* + * Common type definitions and macros for new_pair.c, lib_color.c + * + * $Id: new_pair.h,v 1.16 2024/12/07 17:27:35 tom Exp $ + */ + +#ifndef NEW_PAIR_H +#define NEW_PAIR_H 1 +/* *INDENT-OFF* */ + +#include +#include + +#include + +#undef SCREEN +#define SCREEN struct screen +SCREEN; + +#define LIMIT_TYPED(n,t) \ + (t)(((n) > MAX_OF_TYPE(t)) \ + ? MAX_OF_TYPE(t) \ + : ((n) < -MAX_OF_TYPE(t)) \ + ? -MAX_OF_TYPE(t) \ + : (n)) + +#define limit_COLOR(n) LIMIT_TYPED(n,NCURSES_COLOR_T) +#define limit_PAIRS(n) LIMIT_TYPED(n,NCURSES_PAIRS_T) + +#define MAX_XCURSES_PAIR MAX_OF_TYPE(NCURSES_PAIRS_T) + +#if NCURSES_EXT_COLORS +#define OPTIONAL_PAIR GCC_UNUSED +#define get_extended_pair(opts, color_pair) \ + if ((opts) != NULL) { \ + *(int*)(opts) = color_pair; \ + } +#define set_extended_pair(opts, color_pair) \ + if ((opts) != NULL) { \ + color_pair = *(const int*)(opts); \ + } +#else +#define OPTIONAL_PAIR /* nothing */ +#define get_extended_pair(opts, color_pair) /* nothing */ +#define set_extended_pair(opts, color_pair) \ + if ((opts) != NULL) { \ + color_pair = -1; \ + } +#endif + +#ifdef NEW_PAIR_INTERNAL + +typedef enum { + cpKEEP = -1, /* color pair 0 */ + cpFREE = 0, /* free for use */ + cpINIT = 1 /* initialized */ +} CPMODE; + +typedef struct _color_pairs +{ + int fg; + int bg; +#if NCURSES_EXT_COLORS + int mode; /* tells if the entry is allocated or free */ + int prev; /* index of previous item */ + int next; /* index of next item */ +#endif +} +colorpair_t; + +#define MakeColorPair(target,f,b) target.fg = f, target.bg = b +#define isSamePair(a,b) ((a).fg == (b).fg && (a).bg == (b).bg) +#define FORE_OF(c) (c).fg +#define BACK_OF(c) (c).bg + +/* + * Ensure that we use color pairs only when colors have been started, and also + * that the index is within the limits of the table which we allocated. + */ +#define ValidPair(sp,pair) \ + ((sp != NULL) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron) + +#if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS +extern NCURSES_EXPORT(void) _nc_copy_pairs(SCREEN*, colorpair_t*, colorpair_t*, int); +extern NCURSES_EXPORT(void) _nc_free_ordered_pairs(SCREEN*); +extern NCURSES_EXPORT(void) _nc_reset_color_pair(SCREEN*, int, const colorpair_t*); +extern NCURSES_EXPORT(void) _nc_set_color_pair(SCREEN*, int, int); +#else +#define _nc_free_ordered_pairs(sp) /* nothing */ +#define _nc_reset_color_pair(sp, pair, data) /* nothing */ +#define _nc_set_color_pair(sp, pair, mode) /* nothing */ +#endif + +#else + +typedef struct _color_pairs colorpair_t; + +#endif /* NEW_PAIR_INTERNAL */ + +#if NO_LEAKS +extern NCURSES_EXPORT(void) _nc_new_pair_leaks(SCREEN*); +#endif + +/* *INDENT-ON* */ + +#endif /* NEW_PAIR_H */ diff --git a/ncurses/ncurses/report_ctype.c b/ncurses/ncurses/report_ctype.c new file mode 100644 index 0000000000..dc279f64f2 --- /dev/null +++ b/ncurses/ncurses/report_ctype.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * Copyright 2025 Thomas E. Dickey * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +MODULE_ID("$Id: report_ctype.c,v 1.1 2025/10/25 19:21:11 tom Exp $") + +#include +#include +#include + +#if HAVE_LANGINFO_CODESET +#include +#endif + +#define PER_LINE 32 + +static void +report(char *locale) +{ + int ch; + wint_t wch; + char *dot; + printf("Locale \"%s\"", locale); + if (setlocale(LC_CTYPE, locale) != NULL) { +#if HAVE_LANGINFO_CODESET + char *codeset = nl_langinfo(CODESET); + if (codeset != NULL) { + printf("\nCodeset \"%s\"", codeset); + } +#endif + for (ch = 0; ch < 256; ++ch) { + int code = '?'; + wch = ch; + if (isprint(ch) && iswprint(wch)) + code = '='; + if (!isprint(ch) && iswprint(wch)) + code = '+'; + if (isprint(ch) && !iswprint(wch)) + code = '-'; + if ((ch & (PER_LINE - 1)) == 0) + printf("\n%02X: ", ch); + putchar(code); + } + putchar('\n'); + } else { + fprintf(stderr, "Cannot set locale\n"); + } + if ((dot = strchr(locale, '.')) != NULL) { + *dot = '\0'; + report(locale); + } +} + +int +main(int argc, char *argv[]) +{ + if (argc > 1) { + int n; + for (n = 1; n < argc; ++n) { + report(argv[n]); + } + } else { + static char empty[1]; + char *locale = getenv("LC_CTYPE"); + if (locale == NULL) + locale = getenv("LC_ALL"); + if (locale == NULL) + locale = getenv("LANG"); + if (locale == NULL) + locale = empty; + report(locale); + } + return EXIT_SUCCESS; +} diff --git a/ncurses/ncurses/report_hashing.c b/ncurses/ncurses/report_hashing.c new file mode 100644 index 0000000000..7d620e0d51 --- /dev/null +++ b/ncurses/ncurses/report_hashing.c @@ -0,0 +1,76 @@ +/**************************************************************************** + * Copyright 2020,2025 Thomas E. Dickey * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 +#include + +MODULE_ID("$Id: report_hashing.c,v 1.4 2025/02/20 01:02:09 tom Exp $") + +static void +check_names(const char *name, NCURSES_CONST char *const *table, int termcap) +{ + int errs = 0; + int n; + struct name_table_entry const *entry_ptr; + const HashValue *hash_table = _nc_get_hash_table(termcap); + + printf("%s:\n", name); + for (n = 0; table[n] != NULL; ++n) { + entry_ptr = _nc_find_entry(table[n], hash_table); + if (entry_ptr == NULL) { + printf(" %s\n", table[n]); + errs++; + } + } + if (errs) + printf("%d errors\n", errs); +} + +int +main(void) +{ +#define CHECK_TI(name) check_names(#name, name, 0) +#define CHECK_TC(name) check_names(#name, name, 1) + + CHECK_TI(boolnames); + CHECK_TI(numnames); + CHECK_TI(strnames); + + CHECK_TC(boolcodes); + CHECK_TC(numcodes); + CHECK_TC(strcodes); + + return EXIT_SUCCESS; +} diff --git a/ncurses/ncurses/report_offsets.c b/ncurses/ncurses/report_offsets.c new file mode 100644 index 0000000000..517f0a32a7 --- /dev/null +++ b/ncurses/ncurses/report_offsets.c @@ -0,0 +1,280 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +#define NEW_PAIR_INTERNAL 1 +#include + +MODULE_ID("$Id: report_offsets.c,v 1.32 2025/12/27 12:34:03 tom Exp $") + +#define show_size(type) \ + flag = NULL; \ + last = 0; \ + printf("%5lu " #type "\n", (unsigned long)sizeof(type)) +#define show_name(name) \ + printf("%5lu " #name "\n", (unsigned long)(name)) +#define show_offset(type,member) \ + next = (unsigned long)offsetof(type,member); \ + if (last > next) \ + printf("?? incorrect order for " #type "." #member "\n"); \ + printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \ + last = next; \ + flag = NULL + +#if NCURSES_WIDECHAR && NCURSES_EXT_COLORS +#define show_COLORS(type,member) { flag = "c"; show_offset(type,member); } +#else +#define show_COLORS(type,member) /* nothing */ +#endif + +#if USE_TERM_DRIVER +#define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); } +#else +#define show_DRIVER(type,member) /* nothing */ +#endif + +#if NO_LEAKS +#define show_MLEAKS(type,member) { flag = "L"; show_offset(type,member); } +#else +#define show_MLEAKS(type,member) /* nothing */ +#endif + +#define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); } +#define show_OPTION(type,member) { flag = "+"; show_offset(type,member); } + +#if USE_REENTRANT +#define show_REENTR(type,member) { flag = "r"; show_offset(type,member); } +#else +#define show_REENTR(type,member) /* nothing */ +#endif + +#if NCURSES_SP_FUNCS +#define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); } +#else +#define show_SPFUNC(type,member) /* nothing */ +#endif + +#ifdef USE_PTHREADS +#define show_THREAD(type,member) { flag = "t"; show_offset(type,member); } +#else +#define show_THREAD(type,member) /* nothing */ +#endif + +#ifdef TRACE +#define show_TRACES(type,member) { flag = "T"; show_offset(type,member); } +#else +#define show_TRACES(type,member) /* nothing */ +#endif + +#if USE_WIDEC_SUPPORT +#define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); } +#else +#define show_WIDECH(type,member) /* nothing */ +#endif + +int +main(int argc, char *argv[]) +{ + const char *flag = NULL; + unsigned long last, next; + + if (argc == 2 && !strcmp(argv[1], "-?")) + return EXIT_SUCCESS; + + printf("Size/offsets of data structures:\n"); + + show_size(attr_t); + show_size(chtype); +#if USE_WIDEC_SUPPORT + show_size(cchar_t); +#endif + show_size(color_t); + show_size(colorpair_t); + show_size(mmask_t); + show_size(rgb_bits_t); + show_size(MEVENT); + show_size(NCURSES_BOOL); + show_size(TRIES); + + printf("\n"); + printf("Sizes of buffers/arrays:\n"); +#if USE_WIDEC_SUPPORT + show_name(CCHARW_MAX); +#endif + show_name(EV_MAX); + show_name(FIFO_SIZE); + show_name(NAMESIZE); + show_name(MB_LEN_MAX); + show_name(PATH_MAX); +#ifdef TRACE + show_name(TRACECHR_BUF); + show_name(TRACEMSE_MAX); +#endif + + printf("\n"); + show_size(SCREEN); + show_offset(SCREEN, _ifd); + show_offset(SCREEN, _fifo); + show_offset(SCREEN, _fifohead); + show_offset(SCREEN, _direct_color); + show_offset(SCREEN, _panelHook); + show_offset(SCREEN, jump); + show_offset(SCREEN, rsp); +#if NCURSES_NO_PADDING + show_OPTION(SCREEN, _no_padding); +#endif +#if USE_HARD_TABS + show_OPTION(SCREEN, _ht_cost); +#endif +#if USE_ITALIC + show_OPTION(SCREEN, _use_ritm); +#endif +#if USE_KLIBC_KBD + show_OPTION(SCREEN, _extended_key); +#endif +#if NCURSES_EXT_FUNCS + show_OPTION(SCREEN, _assumed_color); +#endif +#if USE_GPM_SUPPORT + show_OPTION(SCREEN, _mouse_gpm_loaded); +#ifdef HAVE_LIBDL + show_OPTION(SCREEN, _dlopen_gpm); +#endif +#endif +#if USE_EMX_MOUSE + show_OPTION(SCREEN, _emxmouse_wfd); +#endif +#if USE_SYSMOUSE + show_OPTION(SCREEN, _sysmouse_fifo); +#endif + show_DRIVER(SCREEN, _drv_mouse_fifo); +#if USE_SIZECHANGE + show_OPTION(SCREEN, _resize); +#endif +#ifdef USE_SP_WINDOWLIST + show_NORMAL(SCREEN, _windowlist); +#endif + show_REENTR(SCREEN, _ttytype); + show_SPFUNC(SCREEN, use_tioctl); + show_WIDECH(SCREEN, _screen_acs_fix); +#if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS + show_COLORS(SCREEN, _ordered_pairs); +#endif + show_TRACES(SCREEN, tracechr_buf); + + printf("\n"); + show_size(TERMINAL); + show_offset(TERMINAL, type); + show_offset(TERMINAL, Filedes); + show_offset(TERMINAL, Ottyb); + show_offset(TERMINAL, Nttyb); + show_offset(TERMINAL, _baudrate); + show_offset(TERMINAL, _termname); + show_offset(TERMINAL, tparm_state); +#if HAVE_INIT_EXTENDED_COLOR + show_COLORS(TERMINAL, type2); +#endif + + printf("\n"); + show_size(TERMTYPE); +#if NCURSES_XNAMES + show_OPTION(TERMTYPE, ext_str_table); + show_OPTION(TERMTYPE, ext_Strings); +#endif + + printf("\n"); + show_size(TPARM_STATE); + show_offset(TPARM_STATE, stack); + show_offset(TPARM_STATE, stack_ptr); + show_offset(TPARM_STATE, out_buff); + show_offset(TPARM_STATE, fmt_buff); + show_offset(TPARM_STATE, static_vars); + show_TRACES(TPARM_STATE, tname); + + printf("\n"); + show_size(WINDOW); + show_WIDECH(WINDOW, _bkgrnd); + show_COLORS(WINDOW, _color); + + printf("\n"); + show_size(NCURSES_GLOBALS); + show_offset(NCURSES_GLOBALS, init_signals); + show_offset(NCURSES_GLOBALS, tgetent_cache); + show_offset(NCURSES_GLOBALS, dbd_vars); +#if HAVE_TSEARCH + show_offset(NCURSES_GLOBALS, cached_tparm); +#endif + show_DRIVER(NCURSES_GLOBALS, term_driver); +#ifndef USE_SP_WINDOWLIST + show_NORMAL(NCURSES_GLOBALS, _nc_windowlist); +#endif +#if USE_HOME_TERMINFO + show_OPTION(NCURSES_GLOBALS, home_terminfo); +#endif +#if !USE_SAFE_SPRINTF + show_OPTION(NCURSES_GLOBALS, safeprint_rows); +#endif + show_THREAD(NCURSES_GLOBALS, mutex_curses); +#if USE_PTHREADS_EINTR + show_THREAD(NCURSES_GLOBALS, read_thread); +#endif + show_WIDECH(NCURSES_GLOBALS, key_name); + show_TRACES(NCURSES_GLOBALS, trace_opened); + show_TRACES(NCURSES_GLOBALS, trace_level); + show_MLEAKS(NCURSES_GLOBALS, leak_checking); + + printf("\n"); + show_size(NCURSES_PRESCREEN); + show_offset(NCURSES_PRESCREEN, tparm_state); + show_offset(NCURSES_PRESCREEN, saved_tty); + show_offset(NCURSES_PRESCREEN, use_tioctl); + show_offset(NCURSES_PRESCREEN, _outch); +#ifndef USE_SP_RIPOFF + show_NORMAL(NCURSES_PRESCREEN, rippedoff); +#endif +#if NCURSES_NO_PADDING + show_OPTION(NCURSES_PRESCREEN, _no_padding); +#endif +#if BROKEN_LINKER + show_offset(NCURSES_PRESCREEN, real_acs_map); +#else + show_REENTR(NCURSES_PRESCREEN, real_acs_map); +#endif +#if BROKEN_LINKER || USE_REENTRANT + show_TRACES(NCURSES_PRESCREEN, _outchars); +#endif + + return EXIT_SUCCESS; +} diff --git a/ncurses/ncurses/term.priv.h b/ncurses/ncurses/term.priv.h new file mode 100644 index 0000000000..c515917cfe --- /dev/null +++ b/ncurses/ncurses/term.priv.h @@ -0,0 +1,367 @@ +/**************************************************************************** + * Copyright 2021-2024,2025 Thomas E. Dickey * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: term.priv.h,v 1.14 2025/12/27 12:41:23 tom Exp $ + * + * term.priv.h + * + * Header file for terminfo library objects which are private to + * the library. + */ + +#ifndef _TERM_PRIV_H +#define _TERM_PRIV_H 1 +/* *INDENT-OFF* */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __NCURSES_H +#include +#endif + +#undef NCURSES_OPAQUE +#define NCURSES_INTERNALS 1 +#define NCURSES_OPAQUE 0 + +#if HAVE_LIMITS_H +# include /* PATH_MAX, MB_LEN_MAX, etc */ +#elif HAVE_SYS_PARAM_H +# include +#endif + +#include /* sig_atomic_t */ +#include /* time_t */ +#include /* time_t */ + +#ifdef USE_PTHREADS +#if USE_REENTRANT +#include +#endif +#endif + +/* + * If not properly configured to use the system's limits.h, we get gcc's + * fallback for limits.h which sets MB_LEN_MAX to 1, which is never correct. + */ +#if !HAVE_CONSISTENT_MB_LEN_MAX +#undef MB_LEN_MAX +#endif + +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 16 /* should be >= MB_CUR_MAX, but that may be a function */ +#endif + +#ifndef PATH_MAX +# if defined(_POSIX_PATH_MAX) +# define PATH_MAX _POSIX_PATH_MAX +# elif defined(MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 255 /* the Posix minimum path-size */ +# endif +#endif + +/* + * 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 { + 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 static_vars[NUM_VARS]; +#ifdef TRACE + const char * tname; +#endif +} TPARM_STATE; + +typedef struct { + char * text; + size_t size; +} TRACEBUF; + +typedef struct { + const char * name; + char * value; +} ITERATOR_VARS; + +/* + * Internals for term.h + */ +typedef struct term { /* describe an actual terminal */ + TERMTYPE type; /* terminal type description */ + short Filedes; /* file description being written to */ + TTY Ottyb; /* original state of the terminal */ + TTY Nttyb; /* current state of the terminal */ + int _baudrate; /* used to compute padding */ + char * _termname; /* used for termname() */ + TPARM_STATE tparm_state; +#if NCURSES_EXT_COLORS + TERMTYPE2 type2; /* extended terminal type description */ +#endif +#undef TERMINAL +} TERMINAL; + +/* + * Internals for soft-keys + */ +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; + +/* + * Internals for tgetent + */ +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 + +#include /* dbdLAST */ + +#if USE_TERM_DRIVER +struct DriverTCB; /* Terminal Control Block forward declaration */ +#endif + +/* + * Global data which is not specific to a screen. + */ +typedef struct { + SIG_ATOMIC_T have_sigtstp; + SIG_ATOMIC_T have_sigwinch; + SIG_ATOMIC_T cleanup_nested; + + bool init_signals; + bool init_screen; + + 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 init_keyname; + + int slk_format; + + int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */ + + char * safeprint_buf; + size_t safeprint_used; + + TGETENT_CACHE tgetent_cache[TGETENT_MAX]; + int tgetent_index; + long tgetent_sequence; + int terminal_count; + + char * dbd_blob; /* string-heap for dbd_list[] */ + char ** dbd_list; /* distinct places to look for data */ + int dbd_size; /* length of dbd_list[] */ + time_t dbd_time; /* cache last updated */ + ITERATOR_VARS dbd_vars[dbdLAST]; + +#if HAVE_TSEARCH + void * cached_tparm; + int count_tparm; +#endif /* HAVE_TSEARCH */ + +#if USE_TERM_DRIVER + int (*term_driver)(struct DriverTCB*, const char*, int*); +#endif + +#define WINDOWLIST struct _win_list + +#ifndef USE_SP_WINDOWLIST + WINDOWLIST * _nc_windowlist; +#define WindowList(sp) _nc_globals._nc_windowlist +#endif + +#if USE_HOME_TERMINFO + char * home_terminfo; +#endif + +#if !USE_SAFE_SPRINTF + int safeprint_cols; + int safeprint_rows; +#endif + +#ifdef USE_PTHREADS + pthread_mutex_t mutex_curses; + pthread_mutex_t mutex_prescreen; + pthread_mutex_t mutex_screen; + pthread_mutex_t mutex_update; + 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 +#if USE_PTHREADS_EINTR + pthread_t read_thread; /* The reading thread */ +#endif +#endif +#if USE_WIDEC_SUPPORT + char key_name[MB_LEN_MAX + 1]; +#endif + +#ifdef TRACE + bool trace_opened; + int trace_level; + FILE * trace_fp; + int trace_fd; + + 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; + + char traceatr_color_buf[2][80]; + int traceatr_color_sel; + int traceatr_color_last; +#if !defined(USE_PTHREADS) && USE_REENTRANT + int nested_tracef; +#endif +#endif /* TRACE */ + +#if NO_LEAKS + bool leak_checking; +#endif +} NCURSES_GLOBALS; + +extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; + +#define N_RIPS 5 + +#ifdef USE_PTHREADS +typedef struct _prescreen_list { + struct _prescreen_list *next; + pthread_t id; + struct screen * sp; +} PRESCREEN_LIST; +#endif + +/* + * 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 { +#ifdef USE_PTHREADS + PRESCREEN_LIST *allocated; +#else + struct screen * allocated; +#endif + bool use_env; + bool filter_mode; + attr_t previous_attr; + TPARM_STATE tparm_state; + TTY * saved_tty; /* savetty/resetty information */ + bool use_tioctl; + NCURSES_SP_OUTC _outch; /* output handler if not putc */ +#ifndef USE_SP_RIPOFF + ripoff_t rippedoff[N_RIPS]; + ripoff_t * rsp; +#endif +#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; + int _TABSIZE; + int _ESCDELAY; + TERMINAL * _cur_term; +#endif +#ifdef TRACE +#if BROKEN_LINKER || USE_REENTRANT + long _outchars; + const char * _tputs_trace; +#endif +#endif +} NCURSES_PRESCREEN; + +extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen; + +extern NCURSES_EXPORT(void) _nc_free_tparm(TERMINAL*); + +#ifdef __cplusplus +} +#endif + +/* *INDENT-ON* */ + +#endif /* _TERM_PRIV_H */ diff --git a/ncurses/ncurses/tinfo/MKcaptab.awk b/ncurses/ncurses/tinfo/MKcaptab.awk new file mode 100644 index 0000000000..dd1a1046b2 --- /dev/null +++ b/ncurses/ncurses/tinfo/MKcaptab.awk @@ -0,0 +1,98 @@ +############################################################################## +# Copyright 2020,2024 Thomas E. Dickey # +# Copyright 1998-2006,2007 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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.22 2024/12/07 20:52:55 tom 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; +} + +/^[^#]/ { + if (first) { + printf "/* generated by MKcaptab.awk %s(%d) */\n", tablename, bigstrings; + print "" + if (bigstrings) { + printf "static struct alias *_nc_%s_table = NULL;\n", tablename; + print ""; + printf "static const char %s_text[] = \"\\\n", tablename; + } else { + printf "static const struct alias _nc_%s_table[] =\n", tablename; + printf "{\n"; + } + first = 0; + } + if ($1 == tablename) { + if ($3 == "IGNORE") { + to = "(char *)NULL"; + } else { + to = "\"" $3 "\""; + } + 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/ncurses/ncurses/tinfo/MKcaptab.sh b/ncurses/ncurses/tinfo/MKcaptab.sh new file mode 100755 index 0000000000..e769af243a --- /dev/null +++ b/ncurses/ncurses/tinfo/MKcaptab.sh @@ -0,0 +1,239 @@ +#!/bin/sh +############################################################################## +# Copyright 2019-2023,2024 Thomas E. Dickey # +# Copyright 2007-2010,2011 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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.22 2024/12/07 21:30:44 tom Exp $ + +if test $# != 0 +then + AWK="$1"; shift 1 +else + AWK="awk" +fi + +if test $# != 0 +then + OPT1="$1"; shift 1 +else + OPT1="-0" +fi + +if test $# != 0 +then + OPT2="$1"; shift 1 +else + OPT2="tinfo/MKcaptab.awk" +fi + +cat < +#include +#include + +/* *INDENT-OFF* */ +EOF + +cat "$@" |./make_hash 1 info "$OPT1" +cat "$@" |./make_hash 3 cap "$OPT1" + +cat "$@" |$AWK -f "$OPT2" bigstrings="$OPT1" tablename=capalias + +cat "$@" |$AWK -f "$OPT2" bigstrings="$OPT1" tablename=infoalias + +cat <= 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, + size_t tablesize) +{ + if (*actual == NULL) { + *actual = typeCalloc(struct alias, tablesize + 1); + if (*actual != NULL) { + size_t 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 HashValue *) +_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); +} + +static HashValue +info_hash(const char *string) +{ + long sum = 0; + + DEBUG(9, ("hashing %s", string)); + while (*string) { + sum += (long) (UChar(*string) + (UChar(*(string + 1)) << 8)); + string++; + } + + DEBUG(9, ("sum is %ld", sum)); + return (HashValue) (sum % HASHTABSIZE); +} + +#define TCAP_LEN 2 /* only 1- or 2-character names are used */ + +static HashValue +tcap_hash(const char *string) +{ + char temp[TCAP_LEN + 1]; + int limit = 0; + + while (*string) { + temp[limit++] = *string++; + if (limit >= TCAP_LEN) + break; + } + temp[limit] = '\0'; + return info_hash(temp); +} + +static int +compare_tcap_names(const char *a, const char *b) +{ + return !strncmp(a, b, (size_t) TCAP_LEN); +} + +static int +compare_info_names(const char *a, const char *b) +{ + return !strcmp(a, b); +} + +static const HashData hash_data[2] = +{ + {HASHTABSIZE, _nc_info_hash_table, info_hash, compare_info_names}, + {HASHTABSIZE, _nc_cap_hash_table, tcap_hash, compare_tcap_names} +}; + +NCURSES_EXPORT(const HashData *) +_nc_get_hash_info(bool termcap) +{ + return &hash_data[(termcap != FALSE)]; +} + +#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/ncurses/ncurses/tinfo/MKcodes.awk b/ncurses/ncurses/tinfo/MKcodes.awk new file mode 100644 index 0000000000..d4534e6db7 --- /dev/null +++ b/ncurses/ncurses/tinfo/MKcodes.awk @@ -0,0 +1,179 @@ +############################################################################## +# Copyright 2019-2020,2024 Thomas E. Dickey # +# Copyright 2007-2009,2010 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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.13 2024/12/14 23:45:36 tom 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 = NULL;\n", name + print "" +} + +BEGIN { + print "/* This file was generated by MKcodes.awk */" + print "" + print "#include " + print "" + print "#define IT NCURSES_CONST char * const" + print "" + offset = 0; + offcol = 0; + bigcol = 0; + } + +$1 ~ /^#/ {next;} +$1 ~ /^(cap|info)alias/ {next;} + +$1 == "userdef" {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 "" + 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 == NULL) {" + print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != NULL) {" + print " unsigned n;" + print " for (n = 0; n < size; ++n) {" + print " (*value)[n] = (NCURSES_CONST char *) _nc_code_blob + offsets[n];" + print " }" + print " }" + print " }" + print " return *value;" + print "}" + print "" + print "#define FIX(it) NCURSES_IMPEXP IT * NCURSES_API NCURSES_PUBLIC_VAR(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 NCURSES_PUBLIC_VAR(it)(void) { return data##it; }" + } + print "" + print "/* remove public definition which conflicts with FIX() */" + print "#undef boolcodes" + print "#undef numcodes" + print "#undef strcodes" + print "" + print "/* add local definition */" + print "FIX(boolcodes)" + print "FIX(numcodes)" + print "FIX(strcodes)" + print "" + print "/* restore the public definition */" + print "" + print "#define FREE_FIX(it) if (ptr_##it) { FreeAndNull(ptr_##it); }" + print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())" + print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())" + print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())" + 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/ncurses/ncurses/tinfo/MKfallback.sh b/ncurses/ncurses/tinfo/MKfallback.sh new file mode 100755 index 0000000000..0cab302c4e --- /dev/null +++ b/ncurses/ncurses/tinfo/MKfallback.sh @@ -0,0 +1,169 @@ +#!/bin/sh +############################################################################## +# Copyright 2020-2023,2025 Thomas E. Dickey # +# Copyright 1998-2019,2020 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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.32 2025/09/20 18:24:34 tom Exp $ +# +# MKfallback.sh -- create fallback table for entry reads +# +# This script generates source code for a custom version of read_entry.c +# that (instead of reading capabilities for an argument terminal type +# from an on-disk terminfo tree) tries to match the type with one of a +# specified list of types generated in. +# + +terminfo_dir=$1 +shift + +terminfo_src=$1 +shift + +tic_path=$1 +[ -z "$tic_path" ] && tic_path=tic +shift + +infocmp_path=$1 +[ -z "$infocmp_path" ] && infocmp_path=infocmp +shift + +case "$tic_path" in #(vi +/*) + tic_head=`echo "$tic_path" | sed -e 's,/[^/]*$,,'` + PATH=$tic_head:$PATH + export PATH + ;; +esac + +if [ $# != 0 ]; then + tmp_info=`pwd`/tmp_info + echo creating temporary terminfo directory... >&2 + + rm -rf "$tmp_info" + mkdir -p "$tmp_info" + + "$tic_path" -o $tmp_info -x "$terminfo_src" >&2 +else + tmp_info= +fi + +cat < + +EOF + +if [ "$*" ] +then + opt_info= + [ -n "$tmp_info" ] && opt_info="-A $tmp_info" + cat < + +/* fallback entries for: $* */ +EOF + for x in "$@" + do + echo "/* $x */" + "$infocmp_path" -x $opt_info -E "$x" | sed -e 's/[ ]short[ ]/ NCURSES_INT2 /g' + done + + cat <term_names, name, "|")) { + return(tp); + } + } +EOF +else + echo " /* the fallback list is empty */"; +fi + +cat <&2 + rm -rf "$tmp_info" +fi diff --git a/ncurses/ncurses/tinfo/MKkeys_list.sh b/ncurses/ncurses/tinfo/MKkeys_list.sh new file mode 100755 index 0000000000..ed112fd773 --- /dev/null +++ b/ncurses/ncurses/tinfo/MKkeys_list.sh @@ -0,0 +1,74 @@ +#! /bin/sh +# $Id: MKkeys_list.sh,v 1.10 2025/06/14 16:03:56 tom Exp $ +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# Copyright 2001-2003,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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}" +: "${USE_SIGWINCH-0}" + +data=data$$ +tabs='s/[ ][ ]*/ /g' +trap 'rm -f $data; exit 1' 1 2 3 15 +trap 'rm -f $data' 0 +if [ $# != 0 ] +then + sed -e "$tabs" "$@" >$data +else + sed -e "$tabs" ../../include/Caps >$data +fi + +cat < 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 = NULL;\n", name + print "" +} + +BEGIN { + print "/* This file was generated by MKnames.awk */" + print "" + print "#include " + print "" + print "#define IT NCURSES_CONST char * const" + print "" + offset = 0; + offcol = 0; + bigcol = 0; + } + +$1 ~ /^#/ {next;} +$1 ~ /^(cap|info)alias/ {next;} + +$1 == "userdef" {next;} +$1 == "SKIPWARN" {next;} + +$3 == "bool" { + 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" { + 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" { + 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 "" + print "#if BROKEN_LINKER || USE_REENTRANT" + 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 == NULL) {" + print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != NULL) {" + 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 NCURSES_PUBLIC_VAR(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 NCURSES_PUBLIC_VAR(it)(void) { return data##it; }" + } + print "" + print "/* remove public definition which conflicts with FIX() */" + print "#undef boolnames" + print "#undef boolfnames" + print "#undef numnames" + print "#undef numfnames" + print "#undef strnames" + print "#undef strfnames" + print "" + print "/* add local definition */" + print "FIX(boolnames)" + print "FIX(boolfnames)" + print "FIX(numnames)" + print "FIX(numfnames)" + print "FIX(strnames)" + print "FIX(strfnames)" + print "" + print "/* restore the public definition */" + print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())" + print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())" + print "#define numnames NCURSES_PUBLIC_VAR(numnames())" + print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())" + print "#define strnames NCURSES_PUBLIC_VAR(strnames())" + print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())" + 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/ncurses/ncurses/tinfo/MKuserdefs.sh b/ncurses/ncurses/tinfo/MKuserdefs.sh new file mode 100755 index 0000000000..afbdc00623 --- /dev/null +++ b/ncurses/ncurses/tinfo/MKuserdefs.sh @@ -0,0 +1,149 @@ +#!/bin/sh +############################################################################## +# Copyright 2019-2024,2025 Thomas E. Dickey # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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: MKuserdefs.sh,v 1.12 2025/06/14 14:44:56 tom Exp $ +AWK=${1-awk}; shift 1 +OPT1=${1-0}; shift 1 + +cat < +#include +#include + +#if NCURSES_XNAMES +EOF + +cat "$@" | ./make_hash 1 user "$OPT1" + +cat < + +#include +#include + +#ifndef USE_ROOT_ACCESS +#if HAVE_SETFSUID && HAVE_SYS_FSUID_H +#include +#else +#include +#undef HAVE_SETFSUID +#define HAVE_SETFSUID 0 /* workaround for misconfigured system */ +#endif +#endif + +#if HAVE_GETAUXVAL && HAVE_SYS_AUXV_H && defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) +#include +#define USE_GETAUXVAL 1 +#else +#define USE_GETAUXVAL 0 +#endif + +#include + +MODULE_ID("$Id: access.c,v 1.50 2025/12/27 16:50:06 tom Exp $") + +#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c)) + +#ifdef _NC_MSC +# define ACCESS(FN, MODE) access((FN), (MODE)&(R_OK|W_OK)) +#else +# define ACCESS access +#endif + +#if USE_DOS_PATHS +#define IsPathDelim(pp) (*(pp) == '/' || *(pp) == '\\') +#define UsesDrive(pp) (isalpha(UChar((pp)[0])) && (pp)[1] == ':') +#define IsRelative(pp) (*(pp) == '.' && ((*(pp+1) == '.' && IsPathDelim(pp+2)) || IsPathDelim(pp+1))) + +static char * +last_delim(const char *path) +{ + char *result = NULL; + char *check; + if ((check = strrchr(path, '\\')) != NULL) + result = check; + if ((check = strrchr(path, '/')) != NULL) { + if ((check - path) > (result - path)) + result = check; + } + return result; +} + +/* + * MinGW32 uses an environment variable to point to the directory containing + * its executables, without a registry setting to help. + */ +static const char * +msystem_base(void) +{ + const char *result = NULL; + char *env; + + if ((env = getenv("MSYSTEM")) != NULL + && !strcmp(env, "MINGW32") + && (env = getenv("WD")) != NULL + && UsesDrive(env)) { + result = env; + } + return result; +} + +/* + * For MinGW32, convert POSIX pathnames to DOS syntax, allowing use of stat() + * and access(). + */ +NCURSES_EXPORT(const char *) +_nc_to_dospath(const char *path, char *buffer) +{ + if (UsesDrive(path) || IsRelative(path)) { + if ((strlen(path) < PATH_MAX) && (strpbrk(path, "/") != NULL)) { + char ch; + char *ptr = buffer; + while ((ch = (*ptr++ = *path++)) != '\0') { + if (ch == '/') + ptr[-1] = '\\'; + } + path = buffer; + } + } else if (last_delim(path) != NULL) { + const char *env; + char *ptr; + char *last; + size_t needed = PATH_MAX - strlen(path) - 3; + + if ((env = msystem_base()) != NULL + && strlen(env) < needed + && strcpy(buffer, env) != NULL + && (last = last_delim(buffer)) != NULL) { + char ch; + + *last = '\0'; + + /* + * If that was a trailing "\", eat more until we actually + * trim the last leaf, which corresponds to the directory + * containing MSYS executables. + */ + while (last != NULL && last[1] == '\0') { + if ((last = last_delim(buffer)) != NULL) { + *last = '\0'; + } + } + if (last != NULL) { + if (!strncmp(path, "/usr", 4)) + path += 4; + if (IsPathDelim(path)) { + while ((last = last_delim(buffer)) != NULL && last[1] == '\0') + *last = '\0'; + ptr = buffer + strlen(buffer); + } else { + ptr = buffer + strlen(buffer); + *ptr++ = '\\'; + } + while ((ch = (*ptr++ = *path++)) != '\0') { + if (ch == '/') + ptr[-1] = '\\'; + } + path = buffer; + } + } + } + return path; +} +#endif + +NCURSES_EXPORT(char *) +_nc_rootname(char *path) +{ + char *result = _nc_basename(path); +#if !MIXEDCASE_FILENAMES || defined(PROG_EXT) + static char *temp; + char *s; + + if ((temp = strdup(result)) != NULL) + result = temp; +#if !MIXEDCASE_FILENAMES + for (s = result; *s != '\0'; ++s) { + *s = (char) LOWERCASE(*s); + } +#endif +#if defined(PROG_EXT) + if ((s = strrchr(result, '.')) != NULL) { + 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) != NULL) && ((s)[0] == '/')) \ + || (((s)[0] != 0) && ((s)[1] == ':'))) +#else +#define is_pathname(s) ((s) != NULL && (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 (test == NULL) + test = strrchr(path, '\\'); +#endif + if (test == NULL) + test = path; + else + test++; + return (unsigned) (test - path); +} + +NCURSES_EXPORT(char *) +_nc_basename(char *path) +{ + return path + _nc_pathlast(path); +} + +NCURSES_EXPORT(int) +_nc_access(const char *path, int mode) +{ + int result; + + FixupPathname(path); + + if (path == NULL) { + errno = ENOENT; + result = -1; + } else if (ACCESS(path, mode) < 0) { + if ((mode & W_OK) != 0 + && errno == ENOENT + && strlen(path) < PATH_MAX) { + char head[PATH_MAX]; + char *leaf; + + _nc_STRCPY(head, path, sizeof(head)); + leaf = _nc_basename(head); + if (leaf == NULL) + leaf = head; + *leaf = '\0'; + if (head == leaf) + _nc_STRCPY(head, ".", sizeof(head)); + + result = ACCESS(head, R_OK | W_OK | X_OK); + } else { + errno = EPERM; + result = -1; + } + } else { + result = 0; + } + return result; +} + +NCURSES_EXPORT(bool) +_nc_is_dir_path(const char *path) +{ + bool result = FALSE; + struct stat sb; + + if (_nc_is_path_found(path, &sb) + && S_ISDIR(sb.st_mode)) { + result = TRUE; + } + return result; +} + +NCURSES_EXPORT(bool) +_nc_is_file_path(const char *path) +{ + bool result = FALSE; + struct stat sb; + + if (_nc_is_path_found(path, &sb) + && S_ISREG(sb.st_mode)) { + result = TRUE; + } + return result; +} + +NCURSES_EXPORT(bool) +_nc_is_path_found(const char *path, struct stat * sb) +{ + bool result = FALSE; + + FixupPathname(path); + + if (stat(path, sb) == 0) { + result = TRUE; + } + return result; +} + +#if HAVE_GETEUID && HAVE_GETEGID +#define is_posix_elevated() \ + (getuid() != geteuid() \ + || getgid() != getegid()) +#else +#define is_posix_elevated() FALSE +#endif + +#if HAVE_ISSETUGID +#define is_elevated() issetugid() +#elif USE_GETAUXVAL && defined(AT_SECURE) +#define is_elevated() \ + (getauxval(AT_SECURE) \ + ? TRUE \ + : (errno != ENOENT \ + ? FALSE \ + : is_posix_elevated())) +#else +#define is_elevated() is_posix_elevated() +#endif + +#if HAVE_SETFSUID +#define lower_privileges() \ + int save_err = errno; \ + setfsuid(getuid()); \ + setfsgid(getgid()); \ + errno = save_err +#define resume_elevation() \ + save_err = errno; \ + setfsuid(geteuid()); \ + setfsgid(getegid()); \ + errno = save_err +#else +#define lower_privileges() /* nothing */ +#define resume_elevation() /* nothing */ +#endif + +/* + * Returns true if not running as root or setuid. We use this check to allow + * applications to use environment variables that are used for searching lists + * of directories, etc. + */ +NCURSES_EXPORT(int) +_nc_env_access(void) +{ + int result = TRUE; + +#if HAVE_GETUID && HAVE_GETEUID +#if !defined(USE_SETUID_ENVIRON) + if (is_elevated()) { + result = FALSE; + } +#endif +#if !defined(USE_ROOT_ENVIRON) + if ((getuid() == ROOT_UID) || (geteuid() == ROOT_UID)) { + result = FALSE; + } +#endif +#endif /* HAVE_GETUID && HAVE_GETEUID */ + return result; +} + +#ifndef USE_ROOT_ACCESS +static int +is_a_file(int fd) +{ + int result = FALSE; + if (fd >= 0) { + struct stat sb; + if (fstat(fd, &sb) == 0) { + switch (sb.st_mode & S_IFMT) { + case S_IFBLK: + case S_IFCHR: + case S_IFDIR: + /* disallow devices and directories */ + break; + default: + /* allow regular files, fifos and sockets */ + result = TRUE; + break; + } + } + } + return result; +} + +/* + * Limit privileges if possible; otherwise disallow access for updating files. + */ +NCURSES_EXPORT(FILE *) +_nc_safe_fopen(const char *path, const char *mode) +{ + FILE *result = NULL; + +#if HAVE_SETFSUID + lower_privileges(); + FixupPathname(path); + result = fopen(path, mode); + resume_elevation(); +#else + FixupPathname(path); + if (!is_elevated() || *mode == 'r') { + result = fopen(path, mode); + } +#endif + if (result != NULL) { + if (!is_a_file(fileno(result))) { + fclose(result); + result = NULL; + } + } + return result; +} + +NCURSES_EXPORT(int) +_nc_safe_open3(const char *path, int flags, mode_t mode) +{ + int result = -1; +#if HAVE_SETFSUID + lower_privileges(); + FixupPathname(path); + result = open(path, flags, mode); + resume_elevation(); +#else + FixupPathname(path); + if (!is_elevated() || (flags & O_RDONLY)) { + result = open(path, flags, mode); + } +#endif + if (result >= 0) { + if (!is_a_file(result)) { + close(result); + result = -1; + } + } + return result; +} +#endif /* USE_ROOT_ACCESS */ diff --git a/ncurses/ncurses/tinfo/add_tries.c b/ncurses/ncurses/tinfo/add_tries.c new file mode 100644 index 0000000000..1d87a02d45 --- /dev/null +++ b/ncurses/ncurses/tinfo/add_tries.c @@ -0,0 +1,127 @@ +/**************************************************************************** + * Copyright 2019-2023,2024 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1998-on * + ****************************************************************************/ + +/* +** add_tries.c +** +** Add keycode/string to tries-tree. +** +*/ + +#include +#include + +MODULE_ID("$Id: add_tries.c,v 1.14 2024/12/07 20:04:23 tom 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(int) +_nc_add_to_try(TRIES ** tree, const char *str, unsigned code) +{ + TRIES *ptr, *savedptr; + unsigned const char *txt = (unsigned const char *) str; + + T((T_CALLED("_nc_add_to_try(%p, %s, %u)"), + (void *) *tree, _nc_visbuf(str), code)); + if (!VALID_STRING(str) || *txt == '\0' || code == 0) + returnCode(ERR); + + if ((*tree) != NULL) { + ptr = savedptr = (*tree); + + for (;;) { + unsigned char cmp = *txt; + + while (!CMP_TRY(ptr->ch, cmp) + && ptr->sibling != NULL) + ptr = ptr->sibling; + + if (CMP_TRY(ptr->ch, cmp)) { + if (*(++txt) == '\0') { + ptr->value = (unsigned short) code; + returnCode(OK); + } + if (ptr->child != NULL) + ptr = ptr->child; + else + break; + } else { + if ((ptr->sibling = typeCalloc(TRIES, 1)) == NULL) { + returnCode(ERR); + } + + savedptr = ptr = ptr->sibling; + SET_TRY(ptr, txt); + ptr->value = 0; + + break; + } + } /* end for (;;) */ + } else { /* (*tree) == 0 :: First sequence to be added */ + savedptr = ptr = (*tree) = typeCalloc(TRIES, 1); + + if (ptr == NULL) { + returnCode(ERR); + } + + SET_TRY(ptr, txt); + ptr->value = 0; + } + + /* at this point, we are adding to the try. ptr->child == 0 */ + + while (*txt) { + ptr->child = typeCalloc(TRIES, 1); + + ptr = ptr->child; + + if (ptr == NULL) { + while ((ptr = savedptr) != NULL) { + savedptr = ptr->child; + free(ptr); + } + *tree = NULL; + returnCode(ERR); + } + + SET_TRY(ptr, txt); + ptr->value = 0; + } + + ptr->value = (unsigned short) code; + returnCode(OK); +} diff --git a/ncurses/ncurses/tinfo/alloc_entry.c b/ncurses/ncurses/tinfo/alloc_entry.c new file mode 100644 index 0000000000..4a5f61ded6 --- /dev/null +++ b/ncurses/ncurses/tinfo/alloc_entry.c @@ -0,0 +1,426 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2013,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * alloc_entry.c -- allocation functions for terminfo entries + * + * _nc_copy_entry() + * _nc_init_entry() + * _nc_merge_entry() + * _nc_save_str() + * _nc_wrap_entry() + * + */ + +#include + +#include + +MODULE_ID("$Id: alloc_entry.c,v 1.83 2025/02/16 17:57:12 tom Exp $") + +#define ABSENT_OFFSET -1 +#define CANCELLED_OFFSET -2 + +static char *stringbuf; /* buffer for string capabilities */ +static size_t next_free; /* next free character in stringbuf */ + +NCURSES_EXPORT(void) +_nc_init_entry(ENTRY * const tp) +/* initialize a terminal type data block */ +{ + DEBUG(2, (T_CALLED("_nc_init_entry(tp=%p)"), (void *) tp)); + + if (tp == NULL) { +#if NO_LEAKS + if (stringbuf != NULL) { + FreeAndNull(stringbuf); + } + return; +#else + _nc_err_abort("_nc_init_entry called without initialization"); +#endif + } + + if (stringbuf == NULL) + TYPE_CALLOC(char, (size_t) MAX_ENTRY_SIZE, stringbuf); + + next_free = 0; + + _nc_init_termtype(&(tp->tterm)); + + DEBUG(2, (T_RETURN(""))); +} + +NCURSES_EXPORT(ENTRY *) +_nc_copy_entry(ENTRY * oldp) +{ + ENTRY *newp; + + DEBUG(2, (T_CALLED("_nc_copy_entry(oldp=%p)"), (void *) oldp)); + + newp = typeCalloc(ENTRY, 1); + if (newp != NULL) { + *newp = *oldp; + _nc_copy_termtype2(&(newp->tterm), &(oldp->tterm)); + } + + DEBUG(2, (T_RETURN("%p"), (void *) newp)); + return (newp); +} + +/* save a copy of string in the string buffer */ +NCURSES_EXPORT(char *) +_nc_save_str(const char *string) +{ + char *result = NULL; + size_t old_next_free = next_free; + + if (stringbuf != NULL) { + size_t len; + + if (!VALID_STRING(string)) + string = ""; + 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_ENTRY_SIZE) { + result = (stringbuf + next_free - 1); + } + } else if (next_free + len < MAX_ENTRY_SIZE) { + _nc_STRCPY(&stringbuf[next_free], string, MAX_ENTRY_SIZE); + 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: %s", string); + } + } + 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 / sizeof(short)]; + int useoffsets[HARD_MAX_USES]; + unsigned i, n; + unsigned nuses; + TERMTYPE2 *tp; + + DEBUG(2, (T_CALLED("_nc_wrap_entry(ep=%p, copy_strings=%d)"), (void *) + ep, copy_strings)); + if (ep == NULL || stringbuf == NULL) + _nc_err_abort("_nc_wrap_entry called without initialization"); + + nuses = ep->nuses; + tp = &(ep->tterm); + if (copy_strings) { + next_free = 0; /* clear static storage */ + + /* copy term_names, Strings, uses */ + tp->term_names = _nc_save_str(tp->term_names); + for_each_string(i, tp) { + if (VALID_STRING(tp->Strings[i])) { + tp->Strings[i] = _nc_save_str(tp->Strings[i]); + } + } + + for (i = 0; i < nuses; i++) { + if (ep->uses[i].name == NULL) { + ep->uses[i].name = _nc_save_str(ep->uses[i].name); + } + } + + free(tp->str_table); + } + + assert(tp->term_names >= stringbuf); + n = (unsigned) (tp->term_names - stringbuf); + for_each_string(i, &(ep->tterm)) { + 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] = (int) (tp->Strings[i] - stringbuf); + } + } + } + + for (i = 0; i < nuses; i++) { + if (ep->uses[i].name == NULL) + useoffsets[i] = ABSENT_OFFSET; + else + useoffsets[i] = (int) (ep->uses[i].name - stringbuf); + } + + TYPE_MALLOC(char, next_free, tp->str_table); + if (stringbuf == NULL) + (void) memset(tp->str_table, 0, next_free); + else + (void) memcpy(tp->str_table, stringbuf, next_free); + + tp->term_names = tp->str_table + n; + for_each_string(i, &(ep->tterm)) { + 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 = (unsigned) NUM_EXT_NAMES(tp)) != 0) { + if (n < SIZEOF(offsets)) { + size_t length = 0; + size_t offset; + for (i = 0; i < n; i++) { + length += strlen(tp->ext_Names[i]) + 1; + offsets[i] = (int) (tp->ext_Names[i] - stringbuf); + } + TYPE_MALLOC(char, length, tp->ext_str_table); + for (i = 0, offset = 0; i < n; i++) { + tp->ext_Names[i] = tp->ext_str_table + offset; + _nc_STRCPY(tp->ext_Names[i], + stringbuf + offsets[i], + length - offset); + offset += strlen(tp->ext_Names[i]) + 1; + } + } + } + } +#endif + + for (i = 0; i < nuses; i++) { + if (useoffsets[i] == ABSENT_OFFSET) { + ep->uses[i].name = NULL; + } else { + ep->uses[i].name = strdup(tp->str_table + useoffsets[i]); + } + } + DEBUG(2, (T_RETURN(""))); +} + +NCURSES_EXPORT(void) +_nc_merge_entry(ENTRY * const target, ENTRY * const source) +/* merge capabilities from `from' entry into `to' entry */ +{ + TERMTYPE2 *to = &(target->tterm); + TERMTYPE2 *from = &(source->tterm); +#if NCURSES_XNAMES + TERMTYPE2 copy; + size_t str_size, copy_size; + char *str_table; +#endif + unsigned i; + + if (source == NULL || from == NULL || target == NULL || to == NULL) + return; + +#if NCURSES_XNAMES + _nc_copy_termtype2(©, from); + from = © + _nc_align_termtype(to, from); + /* + * compute the maximum size of the string-table. + */ + str_size = strlen(to->term_names) + 1; + for_each_string(i, from) { + if (VALID_STRING(from->Strings[i])) + str_size += strlen(from->Strings[i]) + 1; + } + for_each_string(i, to) { + if (VALID_STRING(to->Strings[i])) + str_size += strlen(to->Strings[i]) + 1; + } + /* allocate a string-table large enough for both source/target, and + * copy all of the strings into that table. In the merge, we will + * select from the original source/target lists to construct a new + * target list. + */ + if (str_size != 0) { + char *str_copied; + if ((str_table = malloc(str_size)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); + str_copied = str_table; + _nc_STRCPY(str_copied, to->term_names, str_size); + to->term_names = str_copied; + copy_size = strlen(str_copied) + 1; + str_copied += copy_size; + str_size -= copy_size; + for_each_string(i, from) { + if (VALID_STRING(from->Strings[i])) { + _nc_STRCPY(str_copied, from->Strings[i], str_size); + from->Strings[i] = str_copied; + copy_size = strlen(str_copied) + 1; + str_copied += copy_size; + str_size -= copy_size; + } + } + for_each_string(i, to) { + if (VALID_STRING(to->Strings[i])) { + _nc_STRCPY(str_copied, to->Strings[i], str_size); + to->Strings[i] = str_copied; + copy_size = strlen(str_copied) + 1; + str_copied += copy_size; + str_size -= copy_size; + } + } + free(to->str_table); + to->str_table = str_table; + free(from->str_table); + } + /* + * Do the same for the extended-strings (i.e., lists of capabilities). + */ + str_size = 0; + for (i = 0; i < NUM_EXT_NAMES(from); ++i) { + if (VALID_STRING(from->ext_Names[i])) + str_size += strlen(from->ext_Names[i]) + 1; + } + for (i = 0; i < NUM_EXT_NAMES(to); ++i) { + if (VALID_STRING(to->ext_Names[i])) + str_size += strlen(to->ext_Names[i]) + 1; + } + /* allocate a string-table large enough for both source/target, and + * copy all of the strings into that table. In the merge, we will + * select from the original source/target lists to construct a new + * target list. + */ + if (str_size != 0) { + char *str_copied; + if ((str_table = malloc(str_size)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); + str_copied = str_table; + for (i = 0; i < NUM_EXT_NAMES(from); ++i) { + if (VALID_STRING(from->ext_Names[i])) { + _nc_STRCPY(str_copied, from->ext_Names[i], str_size); + from->ext_Names[i] = str_copied; + copy_size = strlen(str_copied) + 1; + str_copied += copy_size; + str_size -= copy_size; + } + } + for (i = 0; i < NUM_EXT_NAMES(to); ++i) { + if (VALID_STRING(to->ext_Names[i])) { + _nc_STRCPY(str_copied, to->ext_Names[i], str_size); + to->ext_Names[i] = str_copied; + copy_size = strlen(str_copied) + 1; + str_copied += copy_size; + str_size -= copy_size; + } + } + free(to->ext_str_table); + to->ext_str_table = str_table; + free(from->ext_str_table); + } +#endif + for_each_boolean(i, from) { + if (i >= NUM_BOOLEANS(to)) + break; + if (to->Booleans[i] != (NCURSES_SBOOL) CANCELLED_BOOLEAN) { + int mergebool = from->Booleans[i]; + + if (mergebool == CANCELLED_BOOLEAN) + to->Booleans[i] = FALSE; + else if (mergebool == TRUE) + to->Booleans[i] = (NCURSES_SBOOL) mergebool; + } + } + + for_each_number(i, from) { + if (i >= NUM_NUMBERS(to)) + break; + if (to->Numbers[i] != CANCELLED_NUMERIC) { + int mergenum = from->Numbers[i]; + + if (mergenum == CANCELLED_NUMERIC) + to->Numbers[i] = ABSENT_NUMERIC; + else if (mergenum != ABSENT_NUMERIC) + to->Numbers[i] = (NCURSES_INT2) mergenum; + } + } + + /* + * Note: the copies of strings this makes don't have their own + * storage. This is OK right now, but will be a problem if we + * we ever want to deallocate entries. + */ + for_each_string(i, from) { + if (i >= NUM_STRINGS(to)) + break; + 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 NCURSES_XNAMES + /* cleanup */ + free(copy.Booleans); + free(copy.Numbers); + free(copy.Strings); + free(copy.ext_Names); +#endif +} + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_alloc_entry_leaks(void) +{ + if (stringbuf != NULL) { + FreeAndNull(stringbuf); + } + next_free = 0; +} +#endif diff --git a/ncurses/ncurses/tinfo/alloc_ttype.c b/ncurses/ncurses/tinfo/alloc_ttype.c new file mode 100644 index 0000000000..3be99f3be9 --- /dev/null +++ b/ncurses/ncurses/tinfo/alloc_ttype.c @@ -0,0 +1,721 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1999-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999-on * + ****************************************************************************/ + +/* + * align_ttype.c -- functions for TERMTYPE + * + * _nc_align_termtype() + * _nc_copy_termtype() + * + */ + +#include + +#include + +MODULE_ID("$Id: alloc_ttype.c,v 1.55 2025/02/16 18:31:37 tom Exp $") + +#if NCURSES_XNAMES +/* + * Merge the a/b lists into dst. Both a/b are sorted (see _nc_extend_names()), + * so we do not have to worry about order dependencies. + */ +static int +merge_names(char **dst, char **a, int na, char **b, int nb) +{ + int n = 0; + while (na > 0 && nb > 0) { + int cmp = strcmp(*a, *b); + if (cmp < 0) { + dst[n++] = *a++; + na--; + } else if (cmp > 0) { + dst[n++] = *b++; + nb--; + } else { + dst[n++] = *a; + a++, b++; + na--, nb--; + } + } + while (na-- > 0) { + dst[n++] = *a++; + } + while (nb-- > 0) { + dst[n++] = *b++; + } + DEBUG(4, ("merge_names -> %d", n)); + return n; +} + +static bool +find_name(char **table, int item, int length, const char *name) +{ + int n; + int result = -1; + + for (n = item; n < length; ++n) { + if (!strcmp(table[n], name)) { + DEBUG(4, ("found name '%s' @%d", name, n)); + result = n; + break; + } + } + if (result < 0) { + DEBUG(4, ("did not find name '%s'", name)); + } + return (result >= 0); +} + +#define EXTEND_NUM(num, ext) \ + DEBUG(4, ("extending " #num " from %d to %d", \ + to->num, (unsigned short) (to->num + (ext - to->ext)))); \ + to->num = (unsigned short) (to->num + (ext - to->ext)) + +static void +realign_data(TERMTYPE2 *to, char **ext_Names, + int ext_Booleans, + int ext_Numbers, + int ext_Strings) +{ + int n, m, base; + int to_Booleans = to->ext_Booleans; + int to_Numbers = to->ext_Numbers; + int to_Strings = to->ext_Strings; + int to1, to2, from; + + DEBUG(4, ("realign_data %d/%d/%d vs %d/%d/%d", + ext_Booleans, + ext_Numbers, + ext_Strings, + to->ext_Booleans, + to->ext_Numbers, + to->ext_Strings)); + + if (to->ext_Booleans != ext_Booleans) { + to1 = 0; + to2 = to_Booleans + to1; + from = 0; + EXTEND_NUM(num_Booleans, ext_Booleans); + TYPE_REALLOC(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--) { + if (find_name(to->ext_Names, to1, to2, ext_Names[m + from])) { + to->Booleans[base + m] = to->Booleans[base + n--]; + } else { + to->Booleans[base + m] = FALSE; + } + } + to->ext_Booleans = UShort(ext_Booleans); + } + + if (to->ext_Numbers != ext_Numbers) { + to1 = to_Booleans; + to2 = to_Numbers + to1; + from = ext_Booleans; + EXTEND_NUM(num_Numbers, ext_Numbers); + TYPE_REALLOC(NCURSES_INT2, to->num_Numbers, to->Numbers); + for (n = to->ext_Numbers - 1, + m = ext_Numbers - 1, + base = to->num_Numbers - (m + 1); m >= 0; m--) { + if (find_name(to->ext_Names, to1, to2, ext_Names[m + from])) { + to->Numbers[base + m] = to->Numbers[base + n--]; + } else { + to->Numbers[base + m] = ABSENT_NUMERIC; + } + } + to->ext_Numbers = UShort(ext_Numbers); + } + + if (to->ext_Strings != ext_Strings) { + to1 = to_Booleans + to_Numbers; + to2 = to_Strings + to1; + from = ext_Booleans + ext_Numbers; + EXTEND_NUM(num_Strings, ext_Strings); + TYPE_REALLOC(char *, to->num_Strings, to->Strings); + for (n = to->ext_Strings - 1, + m = ext_Strings - 1, + base = to->num_Strings - (m + 1); m >= 0; m--) { + if (find_name(to->ext_Names, to1, to2, ext_Names[m + from])) { + to->Strings[base + m] = to->Strings[base + n--]; + } else { + to->Strings[base + m] = ABSENT_STRING; + } + } + to->ext_Strings = UShort(ext_Strings); + } +} + +/* + * Returns the first index in ext_Names[] for the given token-type + */ +static unsigned +_nc_first_ext_name(const TERMTYPE2 *tp, int token_type) +{ + unsigned first; + + switch (token_type) { + case BOOLEAN: + first = 0; + break; + case NUMBER: + first = tp->ext_Booleans; + break; + case STRING: + first = (unsigned) (tp->ext_Booleans + tp->ext_Numbers); + break; + default: + first = 0; + break; + } + return first; +} + +/* + * Returns the last index in ext_Names[] for the given token-type + */ +static unsigned +_nc_last_ext_name(const TERMTYPE2 *tp, int token_type) +{ + unsigned last; + + switch (token_type) { + case BOOLEAN: + last = tp->ext_Booleans; + break; + case NUMBER: + last = (unsigned) (tp->ext_Booleans + tp->ext_Numbers); + break; + default: + case STRING: + last = NUM_EXT_NAMES(tp); + break; + } + return last; +} + +/* + * Lookup an entry from extended-names, returning -1 if not found + */ +static int +_nc_find_ext_name(const TERMTYPE2 *tp, const char *name, int token_type) +{ + if (name != NULL) { + unsigned j; + unsigned first = _nc_first_ext_name(tp, token_type); + unsigned last = _nc_last_ext_name(tp, token_type); + + for (j = first; j < last; j++) { + if (!strcmp(name, tp->ext_Names[j])) { + return (int) j; + } + } + } + return -1; +} + +/* + * Translate an index into ext_Names[] into the corresponding index into data + * (e.g., Booleans[]). + */ +static int +_nc_ext_data_index(const TERMTYPE2 *tp, int n, int token_type) +{ + switch (token_type) { + case BOOLEAN: + n += (tp->num_Booleans - tp->ext_Booleans); + break; + case NUMBER: + n += (tp->num_Numbers - tp->ext_Numbers) + - (tp->ext_Booleans); + break; + default: + case STRING: + n += (tp->num_Strings - tp->ext_Strings) + - (tp->ext_Booleans + tp->ext_Numbers); + } + return n; +} + +/* + * Adjust tables to remove (not free) an extended name and its corresponding + * data. + */ +static bool +_nc_del_ext_name(TERMTYPE2 *tp, const char *name, int token_type) +{ + int first; + + if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) { + int j; + int last = (int) NUM_EXT_NAMES(tp) - 1; + + for (j = first; j < last; j++) { + tp->ext_Names[j] = tp->ext_Names[j + 1]; + } + first = _nc_ext_data_index(tp, first, token_type); + switch (token_type) { + case BOOLEAN: + last = tp->num_Booleans - 1; + for (j = first; j < last; j++) + tp->Booleans[j] = tp->Booleans[j + 1]; + tp->ext_Booleans--; + tp->num_Booleans--; + break; + case NUMBER: + last = tp->num_Numbers - 1; + for (j = first; j < last; j++) + tp->Numbers[j] = tp->Numbers[j + 1]; + tp->ext_Numbers--; + tp->num_Numbers--; + break; + case STRING: + last = tp->num_Strings - 1; + for (j = first; j < last; j++) + tp->Strings[j] = tp->Strings[j + 1]; + tp->ext_Strings--; + tp->num_Strings--; + break; + } + return TRUE; + } + return FALSE; +} + +/* + * Adjust tables to insert an extended name, making room for new data. The + * index into the corresponding data array is returned. + */ +static int +_nc_ins_ext_name(TERMTYPE2 *tp, char *name, int token_type) +{ + unsigned first = _nc_first_ext_name(tp, token_type); + unsigned last = _nc_last_ext_name(tp, token_type); + unsigned total = NUM_EXT_NAMES(tp) + 1; + unsigned j, k; + + for (j = first; j < last; j++) { + int cmp = strcmp(name, tp->ext_Names[j]); + if (cmp == 0) + /* already present */ + return _nc_ext_data_index(tp, (int) j, token_type); + if (cmp < 0) { + break; + } + } + + TYPE_REALLOC(char *, total, tp->ext_Names); + for (k = total - 1; k > j; k--) + tp->ext_Names[k] = tp->ext_Names[k - 1]; + tp->ext_Names[j] = name; + j = (unsigned) _nc_ext_data_index(tp, (int) j, token_type); + + switch (token_type) { + case BOOLEAN: + tp->ext_Booleans++; + tp->num_Booleans++; + TYPE_REALLOC(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans); + for (k = (unsigned) (tp->num_Booleans - 1); k > j; k--) + tp->Booleans[k] = tp->Booleans[k - 1]; + break; + case NUMBER: + tp->ext_Numbers++; + tp->num_Numbers++; + TYPE_REALLOC(NCURSES_INT2, tp->num_Numbers, tp->Numbers); + for (k = (unsigned) (tp->num_Numbers - 1); k > j; k--) + tp->Numbers[k] = tp->Numbers[k - 1]; + break; + case STRING: + tp->ext_Strings++; + tp->num_Strings++; + TYPE_REALLOC(char *, tp->num_Strings, tp->Strings); + for (k = (unsigned) (tp->num_Strings - 1); k > j; k--) + tp->Strings[k] = tp->Strings[k - 1]; + break; + } + return (int) j; +} + +/* + * Look for strings that are marked cancelled, which happen to be the same name + * as a boolean or number. We'll get this as a special case when we get a + * cancellation of a name that is inherited from another entry. + */ +static void +adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from) +{ + int first = to->ext_Booleans + to->ext_Numbers; + int last = first + to->ext_Strings; + int j, k; + + DEBUG(3, (T_CALLED("adjust_cancels(%s), from(%s)"), + NonNull(to->term_names), + NonNull(from->term_names))); + for (j = first; j < last;) { + char *name; + int j_str = to->num_Strings - first - to->ext_Strings; + + if ((j + j_str) > NUM_STRINGS(to)) + break; + name = to->ext_Names[j]; + if (to->Strings[j + j_str] == CANCELLED_STRING) { + if (_nc_find_ext_name(from, to->ext_Names[j], BOOLEAN) >= 0) { + if (_nc_del_ext_name(to, name, STRING) + || _nc_del_ext_name(to, name, NUMBER)) { + k = _nc_ins_ext_name(to, name, BOOLEAN); + to->Booleans[k] = FALSE; + } else { + j++; + } + } else if (_nc_find_ext_name(from, to->ext_Names[j], NUMBER) >= 0) { + if (_nc_del_ext_name(to, name, STRING) + || _nc_del_ext_name(to, name, BOOLEAN)) { + k = _nc_ins_ext_name(to, name, NUMBER); + to->Numbers[k] = CANCELLED_NUMERIC; + } else { + j++; + } + } else if (_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++; + } + } + DEBUG(3, (T_RETURN(""))); +} + +NCURSES_EXPORT(void) +_nc_align_termtype(TERMTYPE2 *to, TERMTYPE2 *from) +{ + int na; + int nb; + char **ext_Names; + + na = to ? ((int) NUM_EXT_NAMES(to)) : 0; + nb = from ? ((int) NUM_EXT_NAMES(from)) : 0; + + DEBUG(2, (T_CALLED("_nc_align_termtype to(%d:%s), from(%d:%s)"), + na, to ? NonNull(to->term_names) : "?", + nb, from ? NonNull(from->term_names) : "?")); + + if (to != NULL && from != NULL && (na != 0 || nb != 0)) { + int ext_Booleans, ext_Numbers, ext_Strings; + bool used_ext_Names = FALSE; + + if ((na == nb) /* check if the arrays are equivalent */ + &&(to->ext_Booleans == from->ext_Booleans) + && (to->ext_Numbers == from->ext_Numbers) + && (to->ext_Strings == from->ext_Strings)) { + int n; + bool same; + + for (n = 0, same = TRUE; n < na; n++) { + if (strcmp(to->ext_Names[n], from->ext_Names[n])) { + same = FALSE; + break; + } + } + if (same) { + DEBUG(2, (T_RETURN(""))); + return; + } + } + /* + * This is where we pay for having a simple extension representation. + * Allocate a new ext_Names array and merge the two ext_Names arrays + * into it, updating to's counts for booleans, etc. Fortunately we do + * this only for the terminfo compiler (tic) and comparer (infocmp). + */ + TYPE_MALLOC(char *, (size_t)(na + nb), ext_Names); + + if (to->ext_Strings && (from->ext_Booleans + from->ext_Numbers)) + adjust_cancels(to, from); + + if (from->ext_Strings && (to->ext_Booleans + to->ext_Numbers)) + adjust_cancels(from, to); + + ext_Booleans = merge_names(ext_Names, + to->ext_Names, + to->ext_Booleans, + from->ext_Names, + from->ext_Booleans); + ext_Numbers = merge_names(ext_Names + ext_Booleans, + to->ext_Names + + to->ext_Booleans, + to->ext_Numbers, + from->ext_Names + + from->ext_Booleans, + from->ext_Numbers); + ext_Strings = merge_names(ext_Names + ext_Numbers + ext_Booleans, + to->ext_Names + + to->ext_Booleans + + to->ext_Numbers, + to->ext_Strings, + from->ext_Names + + from->ext_Booleans + + from->ext_Numbers, + from->ext_Strings); + /* + * Now we must reallocate the Booleans, etc., to allow the data to be + * overlaid. + */ + if (na != (ext_Booleans + ext_Numbers + ext_Strings)) { + realign_data(to, ext_Names, ext_Booleans, ext_Numbers, ext_Strings); + FreeIfNeeded(to->ext_Names); + 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); + realign_data(from, ext_Names, ext_Booleans, ext_Numbers, ext_Strings); + TYPE_REALLOC(char *, (size_t) nb, from->ext_Names); + memcpy(from->ext_Names, ext_Names, sizeof(char *) * (size_t) nb); + DEBUG(2, ("realigned %d extended names for '%s' (from)", + NUM_EXT_NAMES(from), from->term_names)); + } + if (!used_ext_Names) + free(ext_Names); + } + DEBUG(2, (T_RETURN(""))); +} +#endif + +#define srcINT 1 +#define dstINT 2 + +/* + * TERMTYPE and TERMTYPE2 differ only with regard to the values in Numbers. + * Use 'mode' to decide which to use. + */ +static void +copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode) +{ + unsigned i; + int pass; + char *new_table; + size_t new_table_size; +#if NCURSES_EXT_NUMBERS + short *oldptr = NULL; + int *newptr = NULL; +#endif + + DEBUG(2, (T_CALLED("copy_termtype(dst=%p, src=%p, mode=%d)"), (void *) + dst, (const void *) src, mode)); + *dst = *src; /* ...to copy the sizes and string-tables */ + + TYPE_MALLOC(NCURSES_SBOOL, NUM_BOOLEANS(dst), dst->Booleans); + TYPE_MALLOC(char *, NUM_STRINGS(dst), dst->Strings); + + memcpy(dst->Booleans, + src->Booleans, + NUM_BOOLEANS(dst) * sizeof(dst->Booleans[0])); + memcpy(dst->Strings, + src->Strings, + NUM_STRINGS(dst) * sizeof(dst->Strings[0])); + + new_table = NULL; + new_table_size = 0; + for (pass = 0; pass < 2; ++pass) { + size_t str_size = 0; + if (src->term_names != NULL) { + if (pass) { + dst->term_names = new_table + str_size; + _nc_STRCPY(dst->term_names + str_size, + src->term_names, + new_table_size - str_size); + } + str_size += strlen(src->term_names) + 1; + } + for_each_string(i, src) { + if (VALID_STRING(src->Strings[i])) { + if (pass) { + _nc_STRCPY(new_table + str_size, + src->Strings[i], + new_table_size - str_size); + dst->Strings[i] = new_table + str_size; + } + str_size += strlen(src->Strings[i]) + 1; + } + } + if (pass) { + dst->str_table = new_table; + } else { + ++str_size; + if ((new_table = malloc(str_size)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); + new_table_size = str_size; + } + } + +#if NCURSES_EXT_NUMBERS + if ((mode & dstINT) == 0) { + DEBUG(2, ("...convert int ->short")); + TYPE_MALLOC(short, NUM_NUMBERS(dst), oldptr); + ((TERMTYPE *) dst)->Numbers = oldptr; + } else { + DEBUG(2, ("...copy without changing size")); + TYPE_MALLOC(int, NUM_NUMBERS(dst), newptr); + dst->Numbers = newptr; + } + if ((mode == srcINT) && (oldptr != NULL)) { + DEBUG(2, ("...copy int ->short")); + for (i = 0; i < NUM_NUMBERS(dst); ++i) { + if (src->Numbers[i] > MAX_OF_TYPE(short)) { + oldptr[i] = MAX_OF_TYPE(short); + } else { + oldptr[i] = (short) src->Numbers[i]; + } + } + } else if ((mode == dstINT) && (newptr != NULL)) { + DEBUG(2, ("...copy short ->int")); + for (i = 0; i < NUM_NUMBERS(dst); ++i) { + newptr[i] = ((const short *) (src->Numbers))[i]; + } + } else { + DEBUG(2, ("...copy %s without change", + (mode & dstINT) + ? "int" + : "short")); + memcpy(dst->Numbers, + src->Numbers, + NUM_NUMBERS(dst) * ((mode & dstINT) + ? sizeof(int) + : sizeof(short))); + } +#else + (void) mode; + TYPE_MALLOC(short, NUM_NUMBERS(dst), dst->Numbers); + memcpy(dst->Numbers, + src->Numbers, + NUM_NUMBERS(dst) * sizeof(dst->Numbers[0])); +#endif + +#if NCURSES_XNAMES + if ((i = NUM_EXT_NAMES(src)) != 0) { + TYPE_MALLOC(char *, i, dst->ext_Names); + memcpy(dst->ext_Names, src->ext_Names, i * sizeof(char *)); + + new_table = NULL; + new_table_size = 0; + for (pass = 0; pass < 2; ++pass) { + size_t str_size = 0; + char *raw_data = src->ext_str_table; + if (raw_data != NULL) { + for (i = 0; i < src->ext_Strings; ++i) { + size_t skip = strlen(raw_data) + 1; + if (skip != 1) { + if (pass) { + _nc_STRCPY(new_table + str_size, + raw_data, + new_table_size - str_size); + } + str_size += skip; + raw_data += skip; + } + } + } + for (i = 0; i < NUM_EXT_NAMES(dst); ++i) { + if (VALID_STRING(src->ext_Names[i])) { + if (pass) { + _nc_STRCPY(new_table + str_size, + src->ext_Names[i], + new_table_size - str_size); + dst->ext_Names[i] = new_table + str_size; + } + str_size += strlen(src->ext_Names[i]) + 1; + } + } + if (pass) { + dst->ext_str_table = new_table; + } else { + ++str_size; + if ((new_table = calloc(str_size, 1)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); + new_table_size = str_size; + } + } + } else { + dst->ext_Names = NULL; + } +#endif + (void) new_table_size; + DEBUG(2, (T_RETURN(""))); +} + +NCURSES_EXPORT(void) +_nc_copy_termtype(TERMTYPE *dst, const TERMTYPE *src) +{ + DEBUG(2, (T_CALLED("_nc_copy_termtype(dst=%p, src=%p)"), (void *) dst, + (const void *) src)); + copy_termtype((TERMTYPE2 *) dst, (const TERMTYPE2 *) src, 0); + DEBUG(2, (T_RETURN(""))); +} + +#if NCURSES_EXT_NUMBERS +NCURSES_EXPORT(void) +_nc_copy_termtype2(TERMTYPE2 *dst, const TERMTYPE2 *src) +{ + DEBUG(2, (T_CALLED("_nc_copy_termtype2(dst=%p, src=%p)"), (void *) dst, + (const void *) src)); + copy_termtype(dst, src, srcINT | dstINT); + DEBUG(2, (T_RETURN(""))); +} + +/* + * Use this for exporting the internal TERMTYPE2 to the legacy format used via + * the CUR macro by applications. + */ +NCURSES_EXPORT(void) +_nc_export_termtype2(TERMTYPE *dst, const TERMTYPE2 *src) +{ + DEBUG(2, (T_CALLED("_nc_export_termtype2(dst=%p, src=%p)"), (void *) + dst, (const void *) src)); + copy_termtype((TERMTYPE2 *) dst, src, srcINT); + DEBUG(2, (T_RETURN(""))); +} +#endif /* NCURSES_EXT_NUMBERS */ diff --git a/ncurses/ncurses/tinfo/captoinfo.c b/ncurses/ncurses/tinfo/captoinfo.c new file mode 100644 index 0000000000..105215b59d --- /dev/null +++ b/ncurses/ncurses/tinfo/captoinfo.c @@ -0,0 +1,1061 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * captoinfo.c + * + * Provide conversion in both directions between termcap and terminfo. + * + * cap-to-info --- conversion between termcap and terminfo formats + * + * The captoinfo() code was swiped from Ross Ridge's mytinfo package, + * adapted to fit ncurses by Eric S. Raymond . + * + * It has just one entry point: + * + * char *_nc_captoinfo(n, s, parameterized) + * + * Convert value s for termcap string capability named n into terminfo + * format. + * + * This code recognizes all the standard 4.4BSD %-escapes: + * + * %% output `%' + * %d output value as in printf %d + * %2 output value as in printf %2d + * %3 output value as in printf %3d + * %. output value as in printf %c + * %+x add x to value, then do %. + * %>xy if value > x then add y, no output + * %r reverse order of two parameters, no output + * %i increment by one, no output + * %n exclusive-or all parameters with 0140 (Datamedia 2500) + * %B BCD (16*(value/10)) + (value%10), no output + * %D Reverse coding (value - 2*(value%16)), no output (Delta Data). + * + * Also, %02 and %03 are accepted as synonyms for %2 and %3. + * + * Besides all the standard termcap escapes, this translator understands + * the following extended escapes: + * + * used by GNU Emacs termcap libraries + * %a[+*-/=][cp]x GNU arithmetic. + * %m xor the first two parameters by 0177 + * %b backup to previous parameter + * %f skip this parameter + * + * used by the University of Waterloo (MFCF) termcap libraries + * %-x subtract parameter FROM char x and output it as a char + * %ax add the character x to parameter + * + * If #define WATERLOO is on, also enable these translations: + * + * %sx subtract parameter FROM the character x + * + * By default, this Waterloo translations are not compiled in, because + * the Waterloo %s conflicts with the way terminfo uses %s in strings for + * function programming. + * + * Note the two definitions of %a: the GNU definition is translated if the + * characters after the 'a' are valid for it, otherwise the UW definition + * is translated. + */ + +#include + +#include +#include + +MODULE_ID("$Id: captoinfo.c,v 1.109 2025/11/23 20:22:38 tom Exp $") + +#if 0 +#define DEBUG_THIS(p) DEBUG(9, p) +#else +#define DEBUG_THIS(p) /* nothing */ +#endif + +#define MAX_PUSHED 16 /* max # args we can push onto the stack */ + +static int stack[MAX_PUSHED]; /* the stack */ +static int stackptr; /* the next empty place on the stack */ +static int onstack; /* the top of stack */ +static int seenm; /* seen a %m */ +static int seenn; /* seen a %n */ +static int seenr; /* seen a %r */ +static int param; /* current parameter */ +static char *dp; /* pointer to end of the converted string */ + +static char *my_string; +static size_t my_length; + +static char * +init_string(void) +/* initialize 'my_string', 'my_length' */ +{ + if (my_string == NULL) + TYPE_MALLOC(char, my_length = 256, my_string); + + *my_string = '\0'; + return my_string; +} + +static char * +save_string(char *d, const char *const s) +{ + size_t have = (size_t) (d - my_string); + size_t need = have + strlen(s) + 2; + if (need > my_length) { + my_string = (char *) _nc_doalloc(my_string, my_length = (need + need)); + if (my_string == NULL) + _nc_err_abort(MSG_NO_MEMORY); + d = my_string + have; + } + _nc_STRCPY(d, s, my_length - have); + return d + strlen(d); +} + +static NCURSES_INLINE char * +save_char(char *s, int c) +{ + static char temp[2]; + temp[0] = (char) c; + return save_string(s, temp); +} + +static void +push(void) +/* push onstack on to the stack */ +{ + if (stackptr >= MAX_PUSHED) + _nc_warning("string too complex to convert"); + else + stack[stackptr++] = onstack; +} + +static void +pop(void) +/* pop the top of the stack into onstack */ +{ + if (stackptr == 0) { + if (onstack == 0) + _nc_warning("I'm confused"); + else + onstack = 0; + } else + onstack = stack[--stackptr]; + param++; +} + +static int +cvtchar(register const char *sp) +/* convert a character to a terminfo push */ +{ + unsigned char c = 0; + int len; + + switch (*sp) { + case '\\': + switch (*++sp) { + case '\'': + case '$': + case '\\': + case '%': + c = UChar(*sp); + len = 2; + break; + case '\0': + c = '\\'; + len = 1; + break; + case '0': + case '1': + case '2': + case '3': + len = 1; + while (isdigit(UChar(*sp))) { + c = UChar(8 * c + (*sp++ - '0')); + len++; + } + break; + default: + c = UChar(*sp); + len = (c != '\0') ? 2 : 1; + break; + } + break; + case '^': + len = 2; + c = UChar(*++sp); + if (c == '?') { + c = 127; + } else if (c == '\0') { + len = 1; + } else { + c &= 0x1f; + } + break; + default: + c = UChar(*sp); + len = (c != '\0') ? 1 : 0; + } + if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') { + dp = save_string(dp, "%\'"); + dp = save_char(dp, c); + dp = save_char(dp, '\''); + } else if (c != '\0') { + dp = save_string(dp, "%{"); + if (c > 99) + dp = save_char(dp, c / 100 + '0'); + if (c > 9) + dp = save_char(dp, ((int) (c / 10)) % 10 + '0'); + dp = save_char(dp, c % 10 + '0'); + dp = save_char(dp, '}'); + } + return len; +} + +static void +getparam(int parameter, int n) +/* push n copies of parameter on the terminfo stack if not already there */ +{ + int nn; + + if (seenr) { + if (parameter == 1) + parameter = 2; + else if (parameter == 2) + parameter = 1; + } + + for (nn = 0; nn < n; ++nn) { + dp = save_string(dp, "%p"); + dp = save_char(dp, '0' + parameter); + } + + if (onstack == parameter) { + if (n > 1) { + _nc_warning("string may not be optimal"); + dp = save_string(dp, "%Pa"); + while (n-- > 0) { + dp = save_string(dp, "%ga"); + } + } + return; + } + if (onstack != 0) + push(); + + onstack = parameter; + + if (seenn && parameter < 3) { + dp = save_string(dp, "%{96}%^"); + } + + if (seenm && parameter < 3) { + dp = save_string(dp, "%{127}%^"); + } +} + +/* + * Convert a termcap string to terminfo format. + * 'cap' is the relevant terminfo capability index. + * 's' is the string value of the capability. + * 'parameterized' tells what type of translations to do: + * % translations if 1 + * pad translations if >=0 + */ +NCURSES_EXPORT(char *) +_nc_captoinfo(const char *cap, const char *s, int const parameterized) +{ + const char *capstart; + + stackptr = 0; + onstack = 0; + seenm = 0; + seenn = 0; + seenr = 0; + param = 1; + + DEBUG_THIS(("_nc_captoinfo params %d, %s", parameterized, s)); + + dp = init_string(); + + /* skip the initial padding (if we haven't been told not to) */ + capstart = NULL; + if (s == NULL) + s = ""; + if (parameterized >= 0 && isdigit(UChar(*s))) + for (capstart = s; *s != '\0'; s++) + if (!(isdigit(UChar(*s)) || *s == '*' || *s == '.')) + break; + + while (*s != '\0') { + switch (*s) { + case '%': + s++; + if (parameterized < 1) { + dp = save_char(dp, '%'); + break; + } + switch (*s++) { + case '%': + dp = save_string(dp, "%%"); + break; + case 'r': + if (seenr++ == 1) { + _nc_warning("saw %%r twice in %s", cap); + } + break; + case 'm': + if (seenm++ == 1) { + _nc_warning("saw %%m twice in %s", cap); + } + break; + case 'n': + if (seenn++ == 1) { + _nc_warning("saw %%n twice in %s", cap); + } + break; + case 'i': + dp = save_string(dp, "%i"); + break; + case '6': + case 'B': + getparam(param, 1); + dp = save_string(dp, "%{10}%/%{16}%*"); + getparam(param, 1); + dp = save_string(dp, "%{10}%m%+"); + break; + case '8': + case 'D': + getparam(param, 2); + dp = save_string(dp, "%{2}%*%-"); + break; + case '>': + /* %?%{x}%>%t%{y}%+%; */ + if (s[0] && s[1]) { + getparam(param, 2); + dp = save_string(dp, "%?"); + s += cvtchar(s); + dp = save_string(dp, "%>%t"); + s += cvtchar(s); + dp = save_string(dp, "%+%;"); + } else { + _nc_warning("expected two characters after %%>"); + dp = save_string(dp, "%>"); + } + break; + case 'a': + if ((*s == '=' || *s == '+' || *s == '-' + || *s == '*' || *s == '/') + && (s[1] == 'p' || s[1] == 'c') + && s[2] != '\0') { + int l; + l = 2; + if (*s != '=') + getparam(param, 1); + if (s[1] == 'p') { + getparam(param + s[2] - '@', 1); + if (param != onstack) { + pop(); + param--; + } + l++; + } else + l += cvtchar(s + 2); + switch (*s) { + case '+': + dp = save_string(dp, "%+"); + break; + case '-': + dp = save_string(dp, "%-"); + break; + case '*': + dp = save_string(dp, "%*"); + break; + case '/': + dp = save_string(dp, "%/"); + break; + case '=': + if (seenr) { + if (param == 1) + onstack = 2; + else if (param == 2) + onstack = 1; + else + onstack = param; + } else + onstack = param; + break; + } + s += l; + break; + } + getparam(param, 1); + s += cvtchar(s); + dp = save_string(dp, "%+"); + break; + case '+': + getparam(param, 1); + s += cvtchar(s); + dp = save_string(dp, "%+%c"); + pop(); + break; + case 's': +#ifdef WATERLOO + s += cvtchar(s); + getparam(param, 1); + dp = save_string(dp, "%-"); +#else + getparam(param, 1); + dp = save_string(dp, "%s"); + pop(); +#endif /* WATERLOO */ + break; + case '-': + s += cvtchar(s); + getparam(param, 1); + dp = save_string(dp, "%-%c"); + pop(); + break; + case '.': + getparam(param, 1); + dp = save_string(dp, "%c"); + pop(); + break; + case '0': /* not clear any of the historical termcaps did this */ + if (*s == '3') { + ++s; + goto see03; + } + if (*s == '2') { + ++s; + goto see02; + } + goto invalid; + case '2': + see02: + getparam(param, 1); + dp = save_string(dp, "%2d"); + pop(); + break; + case '3': + see03: + getparam(param, 1); + dp = save_string(dp, "%3d"); + pop(); + break; + case 'd': + getparam(param, 1); + dp = save_string(dp, "%d"); + pop(); + break; + case 'f': + param++; + break; + case 'b': + param--; + break; + case '\\': + dp = save_string(dp, "%\\"); + break; + default: + invalid: + dp = save_char(dp, '%'); + s--; + _nc_warning("unknown %% code %s (%#x) in %s", + unctrl((chtype) *s), UChar(*s), cap); + break; + } + break; + default: + if (*s != '\0') + dp = save_char(dp, *s++); + break; + } + } + + /* + * Now, if we stripped off some leading padding, add it at the end + * of the string as mandatory padding. + */ + if (capstart) { + dp = save_string(dp, "$<"); + for (s = capstart; *s != '\0'; s++) + if (isdigit(UChar(*s)) || *s == '*' || *s == '.') + dp = save_char(dp, *s); + else + break; + dp = save_string(dp, "/>"); + } + + (void) save_char(dp, '\0'); + + DEBUG_THIS(("... _nc_captoinfo %s", NonNull(my_string))); + + return (my_string); +} + +/* + * Check for an expression that corresponds to "%B" (BCD): + * (parameter / 10) * 16 + (parameter % 10) + */ +static int +bcd_expression(const char *str) +{ + static const char fmt[] = "%%p%c%%{10}%%/%%{16}%%*%%p%c%%{10}%%m%%+"; + int len = 0; + char ch1, ch2; + + if (sscanf(str, fmt, &ch1, &ch2) == 2 + && isdigit(UChar(ch1)) + && isdigit(UChar(ch2)) + && (ch1 == ch2)) { + len = 28; +#ifndef NDEBUG + { + char buffer[80]; + int tst; + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) fmt, ch1, ch2); + tst = (int) strlen(buffer) - 1; + assert(len == tst); + } +#endif + } + return len; +} + +static char * +save_tc_char(char *bufptr, int c1) +{ + if (is7bits(c1) && isprint(c1)) { + if (c1 == ':' || c1 == '\\') + bufptr = save_char(bufptr, '\\'); + bufptr = save_char(bufptr, c1); + } else { + char temp[80]; + + if (c1 == (c1 & 0x1f)) { /* iscntrl() returns T on 255 */ + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "%.20s", unctrl((chtype) c1)); + } else { + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "\\%03o", c1); + } + bufptr = save_string(bufptr, temp); + } + return bufptr; +} + +static char * +save_tc_inequality(char *bufptr, int c1, int c2) +{ + bufptr = save_string(bufptr, "%>"); + bufptr = save_tc_char(bufptr, c1); + bufptr = save_tc_char(bufptr, c2); + return bufptr; +} + +/* + * info-to-cap --- conversion between terminfo and termcap formats + * + * Here are the capabilities infotocap assumes it can translate to: + * + * %% output `%' + * %d output value as in printf %d + * %2 output value as in printf %2d + * %3 output value as in printf %3d + * %. output value as in printf %c + * %+c add character c to value, then do %. + * %>xy if value > x then add y, no output + * %r reverse order of two parameters, no output + * %i increment by one, no output + * %n exclusive-or all parameters with 0140 (Datamedia 2500) + * %B BCD (16*(value/10)) + (value%10), no output + * %D Reverse coding (value - 2*(value%16)), no output (Delta Data). + * %m exclusive-or all parameters with 0177 (not in 4.4BSD) + */ + +#define octal_fixup(n, c) fixups[n].ch = ((fixups[n].ch << 3) | ((c) - '0')) + +/* + * Convert a terminfo string to termcap format. Parameters are as in + * _nc_captoinfo(). + */ +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; + const char *trimmed = NULL; + int in0, in1, in2; + char ch1 = 0, ch2 = 0; + char *bufptr = init_string(); + char octal[4]; + int len; + int digits; + bool syntax_error = FALSE; + int myfix = 0; + struct { + int ch; + int offset; + } fixups[MAX_TC_FIXUPS]; + + DEBUG_THIS(("_nc_infotocap %s params %d, %s", + _nc_strict_bsd ? "strict" : "loose", + parameterized, + _nc_visbuf(str))); + + /* we may have to move some trailing mandatory padding up front */ + padding = str + strlen(str) - 1; + if (padding > str && *padding == '>') { + if (padding > (str + 1) && *--padding == '/') + --padding; + while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*') + padding--; + if (padding > str && *padding == '<' && *--padding == '$') + trimmed = padding; + padding += 2; + + while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*') + bufptr = save_char(bufptr, *padding++); + } + + for (; !syntax_error && + *str && + ((trimmed == NULL) || (str < trimmed)); str++) { + int c1, c2; + char *cp = NULL; + + if (str[0] == '^') { + if (str[1] == '\0' || (str + 1) == trimmed) { + bufptr = save_string(bufptr, "\\136"); + ++str; + } else if (str[1] == '?') { + /* + * Although the 4.3BSD termcap file has an instance of "kb=^?", + * that appears to be just cut/paste since neither 4.3BSD nor + * 4.4BSD termcap interprets "^?" as DEL. + */ + bufptr = save_string(bufptr, "\\177"); + ++str; + } else { + bufptr = save_char(bufptr, *str++); + bufptr = save_char(bufptr, *str); + } + } else if (str[0] == ':') { + bufptr = save_char(bufptr, '\\'); + bufptr = save_char(bufptr, '0'); + bufptr = save_char(bufptr, '7'); + bufptr = save_char(bufptr, '2'); + } else if (str[0] == '\\') { + if (str[1] == '\0' || (str + 1) == trimmed) { + bufptr = save_string(bufptr, "\\134"); + ++str; + } else if (str[1] == '^') { + bufptr = save_string(bufptr, "\\136"); + ++str; + } else if (str[1] == ',') { + bufptr = save_char(bufptr, *++str); + } else { + int xx1; + + bufptr = save_char(bufptr, *str++); + xx1 = *str; + if (_nc_strict_bsd) { + + if (isoctal(UChar(xx1))) { + int pad = 0; + int xx2; + int fix = 0; + + if (!isoctal(UChar(str[1]))) + pad = 2; + else if (str[1] && !isoctal(UChar(str[2]))) + pad = 1; + + /* + * Test for "\0", "\00" or "\000" and transform those + * into "\200". + */ + if (xx1 == '0' + && ((pad == 2) || (str[1] == '0')) + && ((pad >= 1) || (str[2] == '0'))) { + xx2 = '2'; + } else { + xx2 = '0'; + pad = 0; /* FIXME - optionally pad to 3 digits */ + } + if (myfix < MAX_TC_FIXUPS) { + fix = 3 - pad; + fixups[myfix].ch = 0; + fixups[myfix].offset = (int) (bufptr + - my_string + - 1); + } + while (pad-- > 0) { + bufptr = save_char(bufptr, xx2); + if (myfix < MAX_TC_FIXUPS) { + fixups[myfix].ch <<= 3; + fixups[myfix].ch |= (xx2 - '0'); + } + xx2 = '0'; + } + if (myfix < MAX_TC_FIXUPS) { + int n; + for (n = 0; n < fix; ++n) { + fixups[myfix].ch <<= 3; + fixups[myfix].ch |= (str[n] - '0'); + } + if (fixups[myfix].ch < 32) { + ++myfix; + } + } + } else if (strchr("E\\nrtbf", xx1) == NULL) { + switch (xx1) { + case 'e': + xx1 = 'E'; + break; + case 'l': + xx1 = 'n'; + break; + case 's': + bufptr = save_char(bufptr, '0'); + bufptr = save_char(bufptr, '4'); + xx1 = '0'; + break; + case ':': + /* + * Note: termcap documentation claims that ":" + * must be escaped as "\072", however the + * documentation is incorrect - read the code. + * The replacement does not work reliably, + * so the advice is not helpful. + */ + bufptr = save_char(bufptr, '0'); + bufptr = save_char(bufptr, '7'); + xx1 = '2'; + break; + default: + /* should not happen, but handle this anyway */ + _nc_SPRINTF(octal, _nc_SLIMIT(sizeof(octal)) + "%03o", UChar(xx1)); + bufptr = save_char(bufptr, octal[0]); + bufptr = save_char(bufptr, octal[1]); + xx1 = octal[2]; + break; + } + } + } else { + if (myfix < MAX_TC_FIXUPS && isoctal(UChar(xx1))) { + bool will_fix = TRUE; + int n; + + fixups[myfix].ch = 0; + fixups[myfix].offset = (int) (bufptr - my_string - 1); + for (n = 0; n < 3; ++n) { + if (isoctal(str[n])) { + octal_fixup(myfix, str[n]); + } else { + will_fix = FALSE; + break; + } + } + if (will_fix && (fixups[myfix].ch < 32)) + ++myfix; + } + } + bufptr = save_char(bufptr, xx1); + } + } else if (str[0] == '$' && str[1] == '<') { /* discard padding */ + str += 2; + while (isdigit(UChar(*str)) + || *str == '.' + || *str == '*' + || *str == '/' + || *str == '>') + str++; + --str; + } else if (sscanf(str, + "[%%?%%p1%%{8}%%<%%t%d%%p1%%d%%e%%p1%%{16}%%<%%t%d%%p1%%{8}%%-%%d%%e%d;5;%%p1%%d%%;m", + &in0, &in1, &in2) == 3 + && ((in0 == 4 && in1 == 10 && in2 == 48) + || (in0 == 3 && in1 == 9 && in2 == 38))) { + /* dumb-down an optimized case from xterm-256color for termcap */ + if ((str = strstr(str, ";m")) == NULL) + break; /* cannot happen */ + ++str; + if (in2 == 48) { + bufptr = save_string(bufptr, "[48;5;%dm"); + } else { + bufptr = save_string(bufptr, "[38;5;%dm"); + } + } else if (str[0] == '%' && str[1] == '%') { /* escaped '%' */ + bufptr = save_string(bufptr, "%%"); + ++str; + } else if (*str != '%' || (parameterized < 1)) { + bufptr = save_char(bufptr, *str); + } else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1, &c2) == 2) { + str = strchr(str, ';'); + bufptr = save_tc_inequality(bufptr, c1, c2); + } else if (sscanf(str, "%%?%%{%d}%%>%%t%%'%c'%%+%%;", &c1, &ch2) == 2) { + str = strchr(str, ';'); + bufptr = save_tc_inequality(bufptr, c1, ch2); + } else if (sscanf(str, "%%?%%'%c'%%>%%t%%{%d}%%+%%;", &ch1, &c2) == 2) { + str = strchr(str, ';'); + bufptr = save_tc_inequality(bufptr, ch1, c2); + } else if (sscanf(str, "%%?%%'%c'%%>%%t%%'%c'%%+%%;", &ch1, &ch2) == 2) { + str = strchr(str, ';'); + bufptr = save_tc_inequality(bufptr, ch1, ch2); + } else if ((len = bcd_expression(str)) != 0) { + str += len; + bufptr = save_string(bufptr, "%B"); + } else if ((sscanf(str, "%%{%d}%%+%%%c", &c1, &ch2) == 2 + || sscanf(str, "%%'%c'%%+%%%c", &ch1, &ch2) == 2) + && ch2 == 'c' + && (cp = strchr(str, '+'))) { + str = cp + 2; + bufptr = save_string(bufptr, "%+"); + + if (ch1) + c1 = ch1; + bufptr = save_tc_char(bufptr, c1); + } + /* FIXME: this "works" for 'delta' */ + else if (strncmp(str, "%{2}%*%-", (size_t) 8) == 0) { + str += 7; + bufptr = save_string(bufptr, "%D"); + } else if (strncmp(str, "%{96}%^", (size_t) 7) == 0) { + str += 6; + if (saw_m++ == 0) { + bufptr = save_string(bufptr, "%n"); + } + } else if (strncmp(str, "%{127}%^", (size_t) 8) == 0) { + str += 7; + if (saw_n++ == 0) { + bufptr = save_string(bufptr, "%m"); + } + } else { /* cm-style format element */ + str++; + switch (*str) { + case '%': + bufptr = save_char(bufptr, '%'); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + bufptr = save_char(bufptr, '%'); + ch1 = 0; + ch2 = 0; + digits = 0; + while (isdigit(UChar(*str))) { + if (++digits > 2) { + syntax_error = TRUE; + break; + } + ch2 = ch1; + ch1 = *str++; + if (digits == 2 && ch2 != '0') { + syntax_error = TRUE; + break; + } else if (_nc_strict_bsd) { + if (ch1 > '3') { + syntax_error = TRUE; + break; + } + } else { + bufptr = save_char(bufptr, ch1); + } + } + if (syntax_error) + break; + /* + * Convert %02 to %2 and %03 to %3 + */ + if (ch2 == '0' && !_nc_strict_bsd) { + ch2 = 0; + bufptr[-2] = bufptr[-1]; + *--bufptr = 0; + } + if (_nc_strict_bsd) { + if (ch2 != 0 && ch2 != '0') { + syntax_error = TRUE; + } else if (ch1 < '2') { + ch1 = 'd'; + } + bufptr = save_char(bufptr, ch1); + } + if (strchr("oxX.", *str)) { + syntax_error = TRUE; /* termcap doesn't have octal, hex */ + } + break; + + case 'd': + bufptr = save_string(bufptr, "%d"); + break; + + case 'c': + bufptr = save_string(bufptr, "%."); + break; + + /* + * %s isn't in termcap, but it is convenient to pass it through + * so we can represent things like terminfo pfkey strings in + * termcap notation. + */ + case 's': + if (_nc_strict_bsd) { + syntax_error = TRUE; + } else { + bufptr = save_string(bufptr, "%s"); + } + break; + + case 'p': + str++; + if (*str == '1') + seenone = 1; + else if (*str == '2') { + if (!seenone && !seentwo) { + bufptr = save_string(bufptr, "%r"); + seentwo++; + } + } else if (*str >= '3') { + syntax_error = TRUE; + } + break; + + case 'i': + bufptr = save_string(bufptr, "%i"); + break; + + default: + bufptr = save_char(bufptr, *str); + syntax_error = TRUE; + break; + } /* 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 != NULL); + if (str == NULL || *str == '\0') + break; + + } /* endwhile (*str) */ + + if (!syntax_error && + myfix > 0 && + ((int) strlen(my_string) - (4 * myfix)) < MIN_TC_FIXUPS) { + while (--myfix >= 0) { + char *p = fixups[myfix].offset + my_string; + *p++ = '^'; + *p++ = (char) (fixups[myfix].ch | '@'); + while ((p[0] = p[2]) != '\0') { + ++p; + } + } + } + + DEBUG_THIS(("... _nc_infotocap %s", + syntax_error + ? "" + : _nc_visbuf(my_string))); + + return (syntax_error ? NULL : my_string); +} + +#ifdef MAIN + +int curr_line; + +int +main(int argc, char *argv[]) +{ + int c, tc = FALSE; + + while ((c = getopt(argc, argv, "c")) != EOF) + switch (c) { + case 'c': + tc = TRUE; + break; + } + + curr_line = 0; + for (;;) { + char buf[BUFSIZ]; + + ++curr_line; + if (fgets(buf, sizeof(buf), stdin) == NULL) + break; + buf[strlen(buf) - 1] = '\0'; + _nc_set_source(buf); + + if (tc) { + char *cp = _nc_infotocap("to termcap", buf, 1); + + if (cp) + (void) fputs(cp, stdout); + } else + (void) fputs(_nc_captoinfo("to terminfo", buf, 1), stdout); + (void) putchar('\n'); + } + return (0); +} +#endif /* MAIN */ + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_captoinfo_leaks(void) +{ + if (my_string != NULL) { + FreeAndNull(my_string); + } + my_length = 0; +} +#endif diff --git a/ncurses/ncurses/tinfo/comp_error.c b/ncurses/ncurses/tinfo/comp_error.c new file mode 100644 index 0000000000..6be1274b93 --- /dev/null +++ b/ncurses/ncurses/tinfo/comp_error.c @@ -0,0 +1,176 @@ +/**************************************************************************** + * Copyright 2019-2023,2024 Thomas E. Dickey * + * Copyright 1998-2012,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * comp_error.c -- Error message routines + * + */ + +#include + +#include + +MODULE_ID("$Id: comp_error.c,v 1.45 2024/12/07 20:04:23 tom 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 */ + +#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) +{ + if (name == NULL) { + free(SourceName); + SourceName = NULL; + } else if (SourceName == NULL) { + SourceName = strdup(name); + } else if (strcmp(name, SourceName)) { + free(SourceName); + SourceName = strdup(name); + } +} + +NCURSES_EXPORT(void) +_nc_set_type(const char *const name) +{ +#define MY_SIZE (size_t) MAX_NAME_SIZE + if (TermType == NULL) + TermType = typeMalloc(char, MY_SIZE + 1); + if (TermType != NULL) { + TermType[0] = '\0'; + if (name) { + _nc_STRNCAT(TermType, name, MY_SIZE, MY_SIZE); + } + } +} + +NCURSES_EXPORT(void) +_nc_get_type(char *name) +{ +#if NO_LEAKS + if (name == NULL && TermType != NULL) { + FreeAndNull(TermType); + return; + } +#endif + if (name != NULL) + _nc_STRCPY(name, TermType != NULL ? TermType : "", MAX_NAME_SIZE); +} + +static NCURSES_INLINE void +where_is_problem(void) +{ + 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 != NULL && TermType[0] != '\0') + fprintf(stderr, ", terminal '%s'", TermType); + fputc(':', stderr); + fputc(' ', stderr); +} + +NCURSES_EXPORT(void) +_nc_warning(const char *const fmt, ...) +{ + va_list argp; + + if (_nc_suppress_warnings) + return; + + where_is_problem(); + va_start(argp, fmt); + vfprintf(stderr, fmt, argp); + fprintf(stderr, "\n"); + va_end(argp); +} + +NCURSES_EXPORT(void) +_nc_err_abort(const char *const fmt, ...) +{ + va_list argp; + + where_is_problem(); + va_start(argp, fmt); + vfprintf(stderr, fmt, argp); + fprintf(stderr, "\n"); + va_end(argp); + exit(EXIT_FAILURE); +} + +NCURSES_EXPORT(void) +_nc_syserr_abort(const char *const fmt, ...) +{ + va_list argp; + + where_is_problem(); + va_start(argp, fmt); + vfprintf(stderr, fmt, argp); + fprintf(stderr, "\n"); + va_end(argp); + +#if defined(TRACE) || !defined(NDEBUG) + /* If we're debugging, try to show where the problem occurred - this + * will dump core. + */ + if (_nc_env_access()) + abort(); +#endif + /* Dumping core in production code is not a good idea. + */ + exit(EXIT_FAILURE); +} + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_comp_error_leaks(void) +{ + FreeAndNull(SourceName); + FreeAndNull(TermType); +} +#endif diff --git a/ncurses/ncurses/tinfo/comp_expand.c b/ncurses/ncurses/tinfo/comp_expand.c new file mode 100644 index 0000000000..81aa84c90f --- /dev/null +++ b/ncurses/ncurses/tinfo/comp_expand.c @@ -0,0 +1,230 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1998 * + ****************************************************************************/ + +#include + +#include +#include + +MODULE_ID("$Id: comp_expand.c,v 1.37 2024/12/07 21:12:53 tom Exp $") + +#if 0 +#define DEBUG_THIS(p) DEBUG(9, p) +#else +#define DEBUG_THIS(p) /* nothing */ +#endif + +static int +trailing_spaces(const char *src) +{ + while (*src == ' ') + src++; + return *src == 0; +} + +/* this deals with differences over whether 0x7f and 0x80..0x9f are controls */ +#define REALPRINT(s) (UChar(*(s)) < 127 && isprint(UChar(*(s)))) + +#define P_LIMIT(p) (length - (size_t)(p)) + +NCURSES_EXPORT(char *) +_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 : "\0\0"; + size_t need = (2 + strlen(str)) * 4; + int ch; + int octals = 0; + struct { + int ch; + int offset; + } fixups[MAX_TC_FIXUPS]; + + if (srcp == NULL) { +#if NO_LEAKS + if (buffer != NULL) { + FreeAndNull(buffer); + length = 0; + } +#endif + return NULL; + } + if (buffer == NULL || need > length) { + if ((buffer = typeRealloc(char, length = need, buffer)) == NULL) + return NULL; + } + + DEBUG_THIS(("_nc_tic_expand %s:%s:%s", + tic_format ? "ti" : "tc", + numbers ? "#" : "", + _nc_visbuf(srcp))); + bufp = 0; + while ((ch = UChar(*str)) != 0) { + if (ch == '%' && REALPRINT(str + 1)) { + buffer[bufp++] = *str++; + /* + * Though the character literals are more compact, most + * terminal descriptions use numbers and are not easy + * to read in character-literal form. + */ + switch (numbers) { + case -1: + if (str[0] == S_QUOTE + && str[1] != '\\' + && REALPRINT(str + 1) + && str[2] == S_QUOTE) { + _nc_SPRINTF(buffer + bufp, _nc_SLIMIT(P_LIMIT(bufp)) + "{%d}", str[1]); + bufp += (int) strlen(buffer + bufp); + str += 2; + } else { + buffer[bufp++] = *str; + } + break; + /* + * If we have a "%{number}", try to translate it into + * a "%'char'" form, since that will run a little faster + * when we're interpreting it. Also, having one form + * for the constant makes it simpler to compare terminal + * descriptions. + */ + case 1: + if (str[0] == L_BRACE + && isdigit(UChar(str[1]))) { + char *dst = NULL; + long value = strtol(str + 1, &dst, 0); + if (dst != NULL + && *dst == R_BRACE + && value < 127 + && isprint(UChar(value))) { + ch = (int) value; + buffer[bufp++] = S_QUOTE; + if (ch == '\\' + || ch == S_QUOTE) + buffer[bufp++] = '\\'; + buffer[bufp++] = (char) ch; + buffer[bufp++] = S_QUOTE; + str = dst; + } else { + buffer[bufp++] = *str; + } + } else { + buffer[bufp++] = *str; + } + break; + default: + if (*str == ',') /* minitel1 uses this */ + buffer[bufp++] = '\\'; + buffer[bufp++] = *str; + break; + } + } else if (ch == 128) { + buffer[bufp++] = '\\'; + buffer[bufp++] = '0'; + } else if (ch == '\033') { + buffer[bufp++] = '\\'; + buffer[bufp++] = 'E'; + } else if (ch == '\\' && tic_format && (str == srcp || str[-1] != '^')) { + buffer[bufp++] = '\\'; + buffer[bufp++] = '\\'; + } else if (ch == ' ' && tic_format && (str == srcp || + trailing_spaces(str))) { + buffer[bufp++] = '\\'; + buffer[bufp++] = 's'; + } else if ((ch == ',' || ch == '^') && tic_format) { + buffer[bufp++] = '\\'; + buffer[bufp++] = (char) ch; + } else if (REALPRINT(str) + && (ch != ',' + && !(ch == ':' && !tic_format) + && !(ch == '!' && !tic_format) + && ch != '^')) + buffer[bufp++] = (char) ch; + else if (ch == '\r') { + buffer[bufp++] = '\\'; + buffer[bufp++] = 'r'; + } else if (ch == '\n') { + buffer[bufp++] = '\\'; + buffer[bufp++] = 'n'; + } +#define UnCtl(c) ((c) + '@') + else if (UChar(ch) < 32 + && isdigit(UChar(str[1]))) { + _nc_SPRINTF(&buffer[bufp], _nc_SLIMIT(P_LIMIT(bufp)) + "^%c", UnCtl(ch)); + bufp += 2; + } else { + _nc_SPRINTF(&buffer[bufp], _nc_SLIMIT(P_LIMIT(bufp)) + "\\%03o", ch); + if ((octals < MAX_TC_FIXUPS) && + ((tic_format && (ch == 127)) || ch < 32)) { + fixups[octals].ch = UChar(ch); + fixups[octals].offset = bufp; + ++octals; + } + bufp += 4; + } + + str++; + } + + buffer[bufp] = '\0'; + + /* + * If most of a short string is ASCII control characters, reformat the + * string to show those in up-arrow format. For longer strings, it is + * more likely that the characters are just binary coding. + * + * If we're formatting termcap, just use the shorter format (up-arrows). + */ + if (octals != 0 && (!tic_format || (bufp - (4 * octals)) < MIN_TC_FIXUPS)) { + while (--octals >= 0) { + char *p = buffer + fixups[octals].offset; + *p++ = '^'; + *p++ = (char) ((fixups[octals].ch == 127) + ? '?' + : (fixups[octals].ch + (int) '@')); + while ((p[0] = p[2]) != 0) { + ++p; + } + } + } + DEBUG_THIS(("... %s", _nc_visbuf(buffer))); + return (buffer); +} diff --git a/ncurses/ncurses/tinfo/comp_hash.c b/ncurses/ncurses/tinfo/comp_hash.c new file mode 100644 index 0000000000..ebd31cba1c --- /dev/null +++ b/ncurses/ncurses/tinfo/comp_hash.c @@ -0,0 +1,154 @@ +/**************************************************************************** + * Copyright 2019-2023,2024 Thomas E. Dickey * + * Copyright 1998-2008,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * comp_hash.c --- Routines to deal with the hashtable of capability + * names. + * + */ + +#define USE_TERMLIB 1 +#include + +#include +#include + +MODULE_ID("$Id: comp_hash.c,v 1.56 2024/12/07 20:05:08 tom Exp $") + +/* + * Finds the entry for the given string in the hash table if present. + * Returns a pointer to the entry in the table or 0 if not found. + */ +NCURSES_EXPORT(struct name_table_entry const *) +_nc_find_entry(const char *string, + const HashValue * hash_table) +{ + bool termcap = (hash_table != _nc_get_hash_table(FALSE)); + const HashData *data = _nc_get_hash_info(termcap); + int hashvalue; + struct name_table_entry const *ptr = NULL; + struct name_table_entry const *real_table; + + hashvalue = data->hash_of(string); + + if (hashvalue >= 0 + && (unsigned) hashvalue < data->table_size + && data->table_data[hashvalue] >= 0) { + + real_table = _nc_get_table(termcap); + ptr = real_table + data->table_data[hashvalue]; + while (!data->compare_names(ptr->nte_name, string)) { + if (ptr->nte_link < 0) { + ptr = NULL; + break; + } + ptr = real_table + (ptr->nte_link + + data->table_data[data->table_size]); + } + } + + return (ptr); +} + +/* + * Finds the entry for the given name with the given type in the given table if + * present (as distinct from _nc_find_entry, which finds the last entry + * regardless of type). + * + * Returns a pointer to the entry in the table or 0 if not found. + */ +NCURSES_EXPORT(struct name_table_entry const *) +_nc_find_type_entry(const char *string, + int type, + bool termcap) +{ + struct name_table_entry const *ptr = NULL; + const HashData *data = _nc_get_hash_info(termcap); + int hashvalue = data->hash_of(string); + + if (hashvalue >= 0 + && (unsigned) hashvalue < data->table_size + && data->table_data[hashvalue] >= 0) { + const struct name_table_entry *const table = _nc_get_table(termcap); + + if (table != NULL) { + ptr = table + data->table_data[hashvalue]; + while (ptr->nte_type != type + || !data->compare_names(ptr->nte_name, string)) { + if (ptr->nte_link < 0) { + ptr = NULL; + break; + } + ptr = table + (ptr->nte_link + data->table_data[data->table_size]); + } + } + } + + return ptr; +} + +#if NCURSES_XNAMES +NCURSES_EXPORT(struct user_table_entry const *) +_nc_find_user_entry(const char *string) +{ + const HashData *data = _nc_get_hash_user(); + int hashvalue; + struct user_table_entry const *ptr = NULL; + struct user_table_entry const *real_table; + + hashvalue = data->hash_of(string); + + if (hashvalue >= 0 + && (unsigned) hashvalue < data->table_size + && data->table_data[hashvalue] >= 0) { + + real_table = _nc_get_userdefs_table(); + ptr = real_table + data->table_data[hashvalue]; + while (!data->compare_names(ptr->ute_name, string)) { + if (ptr->ute_link < 0) { + ptr = NULL; + break; + } + ptr = real_table + (ptr->ute_link + + data->table_data[data->table_size]); + } + } + + return (ptr); +} +#endif /* NCURSES_XNAMES */ diff --git a/ncurses/ncurses/tinfo/comp_parse.c b/ncurses/ncurses/tinfo/comp_parse.c new file mode 100644 index 0000000000..48d277261c --- /dev/null +++ b/ncurses/ncurses/tinfo/comp_parse.c @@ -0,0 +1,802 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * comp_parse.c -- parser driver loop and use handling. + * + * 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_uses2(). To free the list + * storage, do _nc_free_entries(). + */ + +#include + +#include + +#include + +MODULE_ID("$Id: comp_parse.c,v 1.141 2025/12/27 12:33:34 tom Exp $") + +static void sanity_check2(TERMTYPE2 *, bool); +NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2; + +static void fixup_acsc(TERMTYPE2 *, int); + +static void +enqueue(ENTRY * ep) +/* add an entry to the in-core list */ +{ + ENTRY *newp; + + DEBUG(2, (T_CALLED("enqueue(ep=%p)"), (void *) ep)); + + newp = _nc_copy_entry(ep); + if (newp == NULL) + _nc_err_abort(MSG_NO_MEMORY); + + newp->last = _nc_tail; + _nc_tail = newp; + + newp->next = NULL; + if (newp->last) + newp->last->next = newp; + DEBUG(2, (T_RETURN(""))); +} + +#define NAMEBUFFER_SIZE (MAX_NAME_SIZE + 2) + +static char * +force_bar(char *dst, char *src) +{ + if (strchr(src, '|') == NULL) { + size_t len = strlen(src); + if (len > MAX_NAME_SIZE) + len = MAX_NAME_SIZE; + _nc_STRNCPY(dst, src, MAX_NAME_SIZE); + _nc_STRCPY(dst + len, "|", NAMEBUFFER_SIZE - len); + src = dst; + } + return src; +} +#define ForceBar(dst, src) ((strchr(src, '|') == NULL) ? force_bar(dst, src) : src) + +#if NCURSES_USE_TERMCAP && NCURSES_XNAMES +static char * +skip_index(char *name) +{ + char *bar = strchr(name, '|'); + + if (bar != NULL && (bar - name) == 2) + name = bar + 1; + + return name; +} +#endif + +static bool +check_collisions(char *n1, char *n2, int counter) +{ + const char *pstart; + const char *qstart; + char *pend, *qend; + char nc1[NAMEBUFFER_SIZE]; + char nc2[NAMEBUFFER_SIZE]; + + n1 = ForceBar(nc1, n1); + n2 = ForceBar(nc2, n2); + +#if NCURSES_USE_TERMCAP && NCURSES_XNAMES + if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) { + n1 = skip_index(n1); + n2 = skip_index(n2); + } +#endif + + for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1) { + for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1) { + if ((pend - pstart == qend - qstart) + && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0) { + if (counter > 0) + (void) fprintf(stderr, "Name collision '%.*s' between\n", + (int) (pend - pstart), pstart); + return (TRUE); + } + } + } + + return (FALSE); +} + +static char * +next_name(char *name) +{ + if (*name != '\0') + ++name; + return name; +} + +static char * +name_ending(char *name) +{ + if (*name == '\0') { + name = NULL; + } else { + while (*name != '\0' && *name != '|') + ++name; + } + return name; +} + +/* + * Essentially, find the conflict reported in check_collisions() and remove + * it from the second name, unless that happens to be the last alias. + */ +static bool +remove_collision(char *n1, char *n2) +{ + char *p2 = n2; + char *pstart, *qstart, *pend, *qend; + bool removed = FALSE; + +#if NCURSES_USE_TERMCAP && NCURSES_XNAMES + if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) { + n1 = skip_index(n1); + p2 = n2 = skip_index(n2); + } +#endif + + for (pstart = n1; (pend = name_ending(pstart)); pstart = next_name(pend)) { + for (qstart = n2; (qend = name_ending(qstart)); qstart = next_name(qend)) { + if ((pend - pstart == qend - qstart) + && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0) { + if (qstart != p2 || *qend == '|') { + if (*qend == '|') + ++qend; + while ((*qstart++ = *qend++) != '\0') ; + fprintf(stderr, "...now\t%s\n", p2); + removed = TRUE; + } else { + fprintf(stderr, "Cannot remove alias '%.*s'\n", + (int) (qend - qstart), qstart); + } + break; + } + } + } + + return removed; +} + +/* do any of the aliases in a pair of terminal names match? */ +NCURSES_EXPORT(bool) +_nc_entry_match(char *n1, char *n2) +{ + return check_collisions(n1, n2, 0); +} + +/**************************************************************************** + * + * Entry compiler and resolution logic + * + ****************************************************************************/ + +NCURSES_EXPORT(void) +_nc_read_entry_source(FILE *fp, char *buf, + int literal, bool silent, + bool(*hook) (ENTRY *)) +/* slurp all entries in the given file into core */ +{ + ENTRY thisentry; + bool oldsuppress = _nc_suppress_warnings; + int immediate = 0; + + DEBUG(2, + (T_CALLED("_nc_read_entry_source(" + "file=%p, buf=%p, literal=%d, silent=%d, hook=%#" + PRIxPTR ")"), + (void *) fp, buf, literal, silent, CASTxPTR(hook))); + + if (silent) + _nc_suppress_warnings = TRUE; /* shut the lexer up, too */ + + _nc_reset_input(fp, buf); + for (;;) { + memset(&thisentry, 0, sizeof(thisentry)); + if (_nc_parse_entry(&thisentry, literal, silent) == ERR) + break; + 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. That avoids consuming a lot of memory when the + * resolution code could fetch entries off disk. + */ + if (hook != NULLHOOK && (*hook) (&thisentry)) { + immediate++; + } 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); + FreeIfNeeded(thisentry.tterm.str_table); +#if NCURSES_XNAMES + FreeIfNeeded(thisentry.tterm.ext_Names); + FreeIfNeeded(thisentry.tterm.ext_str_table); +#endif + } + } + + if (_nc_tail) { + /* set up the head pointer */ + for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last) { + /* EMPTY */ ; + } + + DEBUG(2, ("head = %s", _nc_head->tterm.term_names)); + DEBUG(2, ("tail = %s", _nc_tail->tterm.term_names)); + } +#ifdef TRACE + else if (!immediate) + DEBUG(2, ("no entries parsed")); +#endif + + _nc_suppress_warnings = oldsuppress; + DEBUG(2, (T_RETURN(""))); +} + +#if 0 && NCURSES_XNAMES +static unsigned +find_capname(TERMTYPE2 *p, const char *name) +{ + unsigned num_names = NUM_EXT_NAMES(p); + unsigned n; + if (name != 0) { + for (n = 0; n < num_names; ++n) { + if (!strcmp(p->ext_Names[n], name)) + break; + } + } else { + n = num_names + 1; + } + return n; +} + +static int +extended_captype(TERMTYPE2 *p, unsigned which) +{ + int result = UNDEF; + unsigned limit = 0; + limit += p->ext_Booleans; + if (limit != 0 && which < limit) { + result = BOOLEAN; + } else { + limit += p->ext_Numbers; + if (limit != 0 && which < limit) { + result = NUMBER; + } else { + limit += p->ext_Strings; + if (limit != 0 && which < limit) { + result = ((p->Strings[STRCOUNT + which] != CANCELLED_STRING) + ? STRING + : CANCEL); + } else if (which >= limit) { + result = CANCEL; + } + } + } + return result; +} + +static const char * +name_of_captype(int which) +{ + const char *result = "?"; + switch (which) { + case BOOLEAN: + result = "boolean"; + break; + case NUMBER: + result = "number"; + break; + case STRING: + result = "string"; + break; + } + return result; +} + +#define valid_TERMTYPE2(p) \ + ((p) != 0 && \ + (p)->term_names != 0 && \ + (p)->ext_Names != 0) + +/* + * Disallow changing the type of an extended capability when doing a "use" + * if one or the other is a string. + */ +static int +invalid_merge(TERMTYPE2 *to, TERMTYPE2 *from) +{ + int rc = FALSE; + if (valid_TERMTYPE2(to) + && valid_TERMTYPE2(from)) { + char *to_name = _nc_first_name(to->term_names); + char *from_name = strdup(_nc_first_name(from->term_names)); + unsigned num_names = NUM_EXT_NAMES(from); + unsigned n; + + for (n = 0; n < num_names; ++n) { + const char *capname = from->ext_Names[n]; + int tt = extended_captype(to, find_capname(to, capname)); + int tf = extended_captype(from, n); + + if (tt <= STRING + && tf <= STRING + && (tt == STRING) != (tf == STRING)) { + if (from_name != 0 && strcmp(to_name, from_name)) { + _nc_warning("merge of %s to %s changes type of %s from %s to %s", + from_name, + to_name, + from->ext_Names[n], + name_of_captype(tf), + name_of_captype(tt)); + } else { + _nc_warning("merge of %s changes type of %s from %s to %s", + to_name, + from->ext_Names[n], + name_of_captype(tf), + name_of_captype(tt)); + } + rc = TRUE; + } + } + free(from_name); + } + return rc; +} +#define validate_merge(p, q) \ + if (invalid_merge(&((p)->tterm), &((q)->tterm))) \ + return FALSE +#else +#define validate_merge(p, q) /* nothing */ +#endif + +NCURSES_EXPORT(int) +_nc_resolve_uses2(bool fullresolve, bool literal) +/* try to resolve all use capabilities */ +{ + ENTRY *qp, *rp, *lastread = NULL; + bool keepgoing; + unsigned i, j; + int total_unresolved, multiples; + + DEBUG(2, (T_CALLED("_nc_resolve_uses2"))); + + /* + * Check for multiple occurrences of the same name. + */ + multiples = 0; + for_entry_list(qp) { + int matchcount = 0; + + for_entry_list2(rp, qp->next) { + if (qp > rp + && check_collisions(qp->tterm.term_names, + rp->tterm.term_names, + matchcount + 1)) { + if (!matchcount++) { + (void) fprintf(stderr, "\t%s\n", rp->tterm.term_names); + } + (void) fprintf(stderr, "and\t%s\n", qp->tterm.term_names); + if (!remove_collision(rp->tterm.term_names, + qp->tterm.term_names)) { + ++multiples; + } + } + } + } + if (multiples > 0) { + DEBUG(2, (T_RETURN("false"))); + return (FALSE); + } + + DEBUG(2, ("NO MULTIPLE NAME OCCURRENCES")); + + /* + * First resolution stage: compute link pointers corresponding to names. + */ + total_unresolved = 0; + _nc_curr_col = -1; + for_entry_list(qp) { + for (i = 0; i < qp->nuses; i++) { + bool foundit; + char *child = _nc_first_name(qp->tterm.term_names); + char *lookfor = qp->uses[i].name; + long lookline = qp->uses[i].line; + + if (lookfor == NULL) + continue; + + foundit = FALSE; + + _nc_set_type(child); + + /* first, try to resolve from in-core records */ + for_entry_list(rp) { + if (rp != qp + && _nc_name_match(rp->tterm.term_names, lookfor, "|")) { + DEBUG(2, ("%s: resolving use=%s %p (in core)", + child, lookfor, lookfor)); + + qp->uses[i].link = rp; + foundit = TRUE; + + /* verify that there are no earlier uses */ + for (j = 0; j < i; ++j) { + if (qp->uses[j].link != NULL + && !strcmp(qp->uses[j].link->tterm.term_names, + rp->tterm.term_names)) { + _nc_warning("duplicate use=%s", lookfor); + break; + } + } + } + } + + /* if that didn't work, try to merge in a compiled entry */ + if (!foundit) { + TERMTYPE2 thisterm; + char filename[PATH_MAX]; + + memset(&thisterm, 0, sizeof(thisterm)); + if (_nc_read_entry2(lookfor, filename, &thisterm) == 1) { + DEBUG(2, ("%s: resolving use=%s (compiled)", + child, lookfor)); + + TYPE_MALLOC(ENTRY, 1, rp); + rp->tterm = thisterm; + rp->nuses = 0; + rp->next = lastread; + lastread = rp; + + qp->uses[i].link = rp; + foundit = TRUE; + + /* verify that there are no earlier uses */ + for (j = 0; j < i; ++j) { + if (qp->uses[j].link != NULL + && !strcmp(qp->uses[j].link->tterm.term_names, + rp->tterm.term_names)) { + _nc_warning("duplicate use=%s", lookfor); + break; + } + } + } + } + + /* no good, mark this one unresolvable and complain */ + if (!foundit) { + total_unresolved++; + + _nc_curr_line = (int) lookline; + _nc_warning("resolution of use=%s failed", lookfor); + qp->uses[i].link = NULL; + } + } + } + if (total_unresolved) { + /* free entries read in off disk */ + _nc_free_entries(lastread); + DEBUG(2, (T_RETURN("false"))); + return (FALSE); + } + + DEBUG(2, ("NAME RESOLUTION COMPLETED OK")); + + /* + * 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) { + do { + bool attempts; + bool progress; + ENTRY merged; + + attempts = FALSE; + progress = FALSE; + keepgoing = FALSE; + + for_entry_list(qp) { + if (qp->nuses > 0) { + attempts = TRUE; + + DEBUG(2, ("%s: attempting merge of %d entries", + _nc_first_name(qp->tterm.term_names), + qp->nuses)); + /* + * If any of the use entries we're looking for is + * incomplete, punt. We'll catch this entry on a + * subsequent pass. + */ + for (i = 0; i < qp->nuses; i++) { + if (qp->uses[i].link + && qp->uses[i].link->nuses) { + DEBUG(2, ("%s: use entry %d unresolved", + _nc_first_name(qp->tterm.term_names), i)); + goto incomplete; + } + } + + /* + * 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_termtype2(&(merged.tterm), &(qp->tterm)); + + /* + * Now merge in each use entry in the proper + * (reverse) order. + */ + for (; qp->nuses; qp->nuses--) { + int n = (int) (qp->nuses - 1); + validate_merge(&merged, qp->uses[n].link); + _nc_merge_entry(&merged, qp->uses[n].link); + free(qp->uses[n].name); + } + + /* + * Now merge in the original entry. + */ + validate_merge(&merged, qp); + _nc_merge_entry(&merged, qp); + + /* + * Replace the original entry with the merged one. + */ + FreeIfNeeded(qp->tterm.Booleans); + FreeIfNeeded(qp->tterm.Numbers); + FreeIfNeeded(qp->tterm.Strings); + FreeIfNeeded(qp->tterm.str_table); +#if NCURSES_XNAMES + FreeIfNeeded(qp->tterm.ext_Names); + FreeIfNeeded(qp->tterm.ext_str_table); +#endif + qp->tterm = merged.tterm; + _nc_wrap_entry(qp, TRUE); + progress = TRUE; + + /* + * Every entry should be resolvable because name resolution + * did not fail. Continue if we have just made a change, + * or another entry may be changeable. + */ + /* FALLTHRU */ + incomplete: + keepgoing = TRUE; + } + } + + /* + * If we went all the way through the list without making any + * changes, while there were remaining use-linkages, something went + * wrong. Give up. + */ + if (!progress && attempts) { + for_entry_list(qp) { + for (i = 0; i < qp->nuses; ++i) { + _nc_warning("problem with use=%s", qp->uses[i].name); + } + } + _nc_warning("merge failed, infinite loop"); + DEBUG(2, (T_RETURN("false"))); + return FALSE; + } + } while + (keepgoing); + + DEBUG(2, ("MERGES COMPLETED OK")); + } + + DEBUG(2, ("RESOLUTION FINISHED")); + + if (fullresolve) { + _nc_curr_col = -1; + for_entry_list(qp) { + _nc_curr_line = (int) qp->startline; + _nc_set_type(_nc_first_name(qp->tterm.term_names)); + /* + * tic overrides this function pointer to provide more verbose + * checking. + */ + if (_nc_check_termtype2 != sanity_check2) { + SCREEN *save_SP = SP; + SCREEN fake_sp; + TERMINAL fake_tm; + TERMINAL *save_tm = cur_term; + + /* + * Setup so that tic can use ordinary terminfo interface to + * obtain capability information. + */ + memset(&fake_sp, 0, sizeof(fake_sp)); + memset(&fake_tm, 0, sizeof(fake_tm)); + fake_sp._term = &fake_tm; + TerminalType(&fake_tm) = qp->tterm; + _nc_set_screen(&fake_sp); + set_curterm(&fake_tm); +#if USE_TERM_DRIVER + ((TERMINAL_CONTROL_BLOCK *) (CurTerm))->drv = &_nc_TINFO_DRIVER; +#endif + + _nc_check_termtype2(&qp->tterm, literal); + + /* + * Checking calls tparm, which can allocate memory. Fix leaks. + */ +#define TPS(name) fake_tm.tparm_state.name + FreeAndNull(TPS(out_buff)); + FreeAndNull(TPS(fmt_buff)); +#undef TPS + + _nc_set_screen(save_SP); + set_curterm(save_tm); + } else { + fixup_acsc(&qp->tterm, literal); + } + } + DEBUG(2, ("SANITY CHECK FINISHED")); + } + + DEBUG(2, (T_RETURN("true"))); + return (TRUE); +} + +/* + * This bit of legerdemain turns all the terminfo variable names into + * references to locations in the arrays Booleans, Numbers, and Strings --- + * precisely what's needed. + */ + +#undef CUR +#define CUR tp-> + +static void +fixup_acsc(TERMTYPE2 *tp, int literal) +{ + if (!literal) { + if (acs_chars == ABSENT_STRING + && PRESENT(enter_alt_charset_mode) + && PRESENT(exit_alt_charset_mode)) + acs_chars = strdup(VT_ACSC); + } +} + +static void +sanity_check2(TERMTYPE2 *tp, bool literal) +{ + if (!PRESENT(exit_attribute_mode)) { +#ifdef __UNUSED__ /* this casts too wide a net */ + bool terminal_entry = !strchr(tp->term_names, '+'); + if (terminal_entry && + (PRESENT(set_attributes) + || PRESENT(enter_standout_mode) + || PRESENT(enter_underline_mode) + || PRESENT(enter_blink_mode) + || PRESENT(enter_bold_mode) + || PRESENT(enter_dim_mode) + || PRESENT(enter_secure_mode) + || PRESENT(enter_protected_mode) + || 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); +#if defined(enter_italics_mode) && defined(exit_italics_mode) + PAIRED(enter_italics_mode, exit_italics_mode); +#endif + } + + /* we do this check/fix in postprocess_termcap(), but some packagers + * prefer to bypass it... + */ + if (!literal) { + fixup_acsc(tp, literal); + 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_blink_mode, exit_attribute_mode); + ANDMISSING(enter_bold_mode, exit_attribute_mode); + PAIRED(exit_ca_mode, enter_ca_mode); + PAIRED(enter_delete_mode, exit_delete_mode); + ANDMISSING(enter_dim_mode, exit_attribute_mode); + PAIRED(enter_insert_mode, exit_insert_mode); + ANDMISSING(enter_secure_mode, exit_attribute_mode); + ANDMISSING(enter_protected_mode, exit_attribute_mode); + ANDMISSING(enter_reverse_mode, exit_attribute_mode); + PAIRED(from_status_line, to_status_line); + PAIRED(meta_off, meta_on); + + PAIRED(prtr_on, prtr_off); + PAIRED(save_cursor, restore_cursor); + PAIRED(enter_xon_mode, exit_xon_mode); + PAIRED(enter_am_mode, exit_am_mode); + ANDMISSING(label_off, label_on); +#if defined(display_clock) && defined(remove_clock) + PAIRED(display_clock, remove_clock); +#endif + ANDMISSING(set_color_pair, initialize_pair); +} + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_leaks_tic(void) +{ + T((T_CALLED("_nc_leaks_tic()"))); + _nc_globals.leak_checking = TRUE; + _nc_alloc_entry_leaks(); + _nc_captoinfo_leaks(); + _nc_comp_scan_leaks(); +#if BROKEN_LINKER || USE_REENTRANT + _nc_names_leaks(); + _nc_codes_leaks(); +#endif + _nc_tic_expand(NULL, FALSE, 0); + T((T_RETURN(""))); +} + +NCURSES_EXPORT(void) +_nc_free_tic(int code) +{ + T((T_CALLED("_nc_free_tic(%d)"), code)); + _nc_leaks_tic(); + exit_terminfo(code); +} +#endif diff --git a/ncurses/ncurses/tinfo/comp_scan.c b/ncurses/ncurses/tinfo/comp_scan.c new file mode 100644 index 0000000000..eb0e1dfbb4 --- /dev/null +++ b/ncurses/ncurses/tinfo/comp_scan.c @@ -0,0 +1,1068 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996 on * + ****************************************************************************/ + +/* $FreeBSD$ */ + +/* + * comp_scan.c --- Lexical scanner for terminfo compiler. + * + * _nc_reset_input() + * _nc_get_token() + * _nc_panic_mode() + * int _nc_syntax; + * int _nc_curr_line; + * long _nc_curr_file_pos; + * long _nc_comment_start; + * long _nc_comment_end; + */ + +#include + +#include +#include + +MODULE_ID("$Id: comp_scan.c,v 1.126 2024/12/07 21:17:54 tom Exp $") + +/* + * Maximum length of string capability we'll accept before raising an error. + * Yes, there is a real capability in /etc/termcap this long, an "is". + */ +#define MAXCAPLEN 600 + +#define iswhite(ch) (ch == ' ' || ch == '\t') + +NCURSES_EXPORT_VAR (int) _nc_syntax = SYN_TERMINFO; /* termcap or terminfo? */ +NCURSES_EXPORT_VAR (int) _nc_strict_bsd = 1; /* ncurses extended termcap? */ +NCURSES_EXPORT_VAR (long) _nc_curr_file_pos = 0; /* file offset of current line */ +NCURSES_EXPORT_VAR (long) _nc_comment_start = 0; /* start of comment range before name */ +NCURSES_EXPORT_VAR (long) _nc_comment_end = 0; /* end of comment range before name */ +NCURSES_EXPORT_VAR (long) _nc_start_line = 0; /* start line of current entry */ + +NCURSES_EXPORT_VAR (struct token) _nc_curr_token = +{ + NULL, 0, NULL +}; + +/***************************************************************************** + * + * Token-grabbing machinery + * + *****************************************************************************/ + +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; + +#if NCURSES_EXT_FUNCS +NCURSES_EXPORT_VAR (bool) _nc_disable_period = FALSE; /* used by tic -a option */ +#endif + +/***************************************************************************** + * + * 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) +{ + TR(TRACE_DATABASE, + (T_CALLED("_nc_reset_input(fp=%p, buf=%p)"), (void *) fp, buf)); + + pushtype = NO_PUSHBACK; + if (pushname != NULL) + pushname[0] = '\0'; + yyin = fp; + bufstart = bufptr = buf; + _nc_curr_file_pos = 0L; + if (fp != NULL) + _nc_curr_line = 0; + _nc_curr_col = 0; + + returnVoidDB; +} + +/* + * int last_char() + * + * Returns the final nonblank character on the current input buffer + */ +static int +last_char(int from_end) +{ + size_t len = strlen(bufptr); + int result = 0; + + while (len--) { + if (!isspace(UChar(bufptr[len]))) { + if (from_end <= (int) len) + result = bufptr[(int) len - from_end]; + break; + } + } + return result; +} + +/* + * Read, like fgets(), but error-out if the input contains nulls. + */ +static int +get_text(char *buffer, int length) +{ + int count = 0; + int limit = length - 1; + + while (limit-- > 0) { + int ch = fgetc(yyin); + + if (ch == '\0') { + _nc_err_abort("This is not a text-file"); + } else if (ch == EOF) { + break; + } + ++count; + *buffer++ = (char) ch; + if (ch == '\n') + break; + } + *buffer = '\0'; + return count; +} + +/* + * 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 != NULL) { + FreeAndNull(result); + FreeAndNull(pushname); + bufptr = NULL; + bufstart = NULL; + allocated = 0; + } + /* + * An string with an embedded null will truncate the input. This is + * intentional (we don't read binary files here). + */ + if (bufptr == NULL || *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 len; + + do { + size_t used = 0; + bufstart = NULL; + do { + if (used + (LEXBUFSIZ / 4) >= allocated) { + allocated += (allocated + LEXBUFSIZ); + result = typeRealloc(char, allocated, result); + if (result == NULL) + return (EOF); + if (bufstart) + bufstart = result; + } + if (used == 0) + _nc_curr_file_pos = ftell(yyin); + + if (get_text(result + used, (int) (allocated - used))) { + bufstart = result; + if (used == 0) { + if (_nc_curr_line == 0 + && IS_TIC_MAGIC(result)) { + _nc_err_abort("This is a compiled terminal description, not a source"); + } + _nc_curr_line++; + _nc_curr_col = 0; + } + } else { + if (used != 0) + _nc_STRCAT(result, "\n", allocated); + } + if ((bufptr = bufstart) != NULL) { + used = strlen(bufptr); + if (used == 0) + return (EOF); + while (iswhite(*bufptr)) { + if (*bufptr == '\t') { + _nc_curr_col = (_nc_curr_col | 7) + 1; + } else { + _nc_curr_col++; + } + bufptr++; + } + + /* + * Treat a trailing the same as a 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(int c) +/* push a character back onto the input stream */ +{ + if (bufptr == bufstart) + _nc_syserr_abort("cannot backspace off beginning of line"); + *--bufptr = (char) c; + _nc_curr_col--; +} + +static long +stream_pos(void) +/* return our current character position in the input stream */ +{ + return (yyin ? ftell(yyin) : (bufptr ? (long) (bufptr - bufstart) : 0)); +} + +static bool +end_of_stream(void) +/* are we at end of input? */ +{ + return ((yyin + ? (feof(yyin) && (bufptr == NULL || *bufptr == '\0')) + : (bufptr && *bufptr == '\0')) + ? TRUE : FALSE); +} + +/* Assume we may be looking at a termcap-style continuation */ +static NCURSES_INLINE int +eat_escaped_newline(int ch) +{ + if (ch == '\\') { + while ((ch = next_char()) == '\n' || iswhite(ch)) { + /* EMPTY */ ; + } + } + 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' + +static char *tok_buf; + +/* + * int + * get_token() + * + * Scans the input for the next token, storing the specifics in the + * global structure 'curr_token' and returning one of the following: + * + * NAMES A line beginning in column 1. 'name' + * will be set to point to everything up to but + * not including the first separator on the line. + * BOOLEAN An entry consisting of a name followed by + * a separator. 'name' will be set to point to + * the name of the capability. + * NUMBER An entry of the form + * name#digits, + * 'name' will be set to point to the capability + * name and 'valnumber' to the number given. + * STRING An entry of the form + * name=characters, + * 'name' is set to the capability name and + * 'valstring' to the string of characters, with + * input translations done. + * CANCEL An entry of the form + * name@, + * 'name' is set to the capability name and + * 'valnumber' to -1. + * EOF The end of the file has been reached. + * + * A `separator' is either a comma or a semicolon, depending on whether + * we are in termcap or terminfo mode. + * + */ + +NCURSES_EXPORT(int) +_nc_get_token(bool silent) +{ + static const char terminfo_punct[] = "@%&*!#"; + + char *after_name; /* after primary name */ + char *after_list; /* after primary and alias list */ + char *numchk; + char *tok_ptr; + char *s; + char numbuf[80]; + int ch, c0, c1; + int dot_flag = FALSE; + int type; + long number; + long token_start; + unsigned found; +#ifdef TRACE + int old_line; + int old_col; +#endif + + DEBUG(3, (T_CALLED("_nc_get_token(silent=%d)"), silent)); + + if (pushtype != NO_PUSHBACK) { + int retval = pushtype; + + _nc_set_type(pushname != NULL ? pushname : ""); + DEBUG(3, ("pushed-back token: `%s', class %d", + _nc_curr_token.tk_name, pushtype)); + + pushtype = NO_PUSHBACK; + if (pushname != NULL) + pushname[0] = '\0'; + + /* currtok wasn't altered by _nc_push_token() */ + DEBUG(3, (T_RETURN("%d"), retval)); + return (retval); + } + + if (end_of_stream()) { + yyin = NULL; + (void) next_char(); /* frees its allocated memory */ + if (tok_buf != NULL) { + if (_nc_curr_token.tk_name == tok_buf) + _nc_curr_token.tk_name = NULL; + } + DEBUG(3, (T_RETURN("%d"), EOF)); + return (EOF); + } + + start_token: + token_start = stream_pos(); + while ((ch = next_char()) == '\n' || iswhite(ch)) { + if (ch == '\n') + had_newline = TRUE; + } + + ch = eat_escaped_newline(ch); + _nc_curr_token.tk_valstring = NULL; + +#ifdef TRACE + old_line = _nc_curr_line; + old_col = _nc_curr_col; +#endif + if (ch == EOF) + type = EOF; + else { + /* if this is a termcap entry, skip a leading separator */ + if (separator == ':' && ch == ':') + ch = next_char(); + + if (ch == '.' +#if NCURSES_EXT_FUNCS + && !_nc_disable_period +#endif + ) { + dot_flag = TRUE; + DEBUG(8, ("dot-flag set")); + + while ((ch = next_char()) == '.' || iswhite(ch)) { + /* EMPTY */ ; + } + } + + if (ch == EOF) { + type = EOF; + goto end_of_token; + } + + /* have to make some punctuation chars legal for terminfo */ + if (!isalnum(UChar(ch)) +#if NCURSES_EXT_FUNCS + && !(ch == '.' && _nc_disable_period) +#endif + && ((strchr) (terminfo_punct, (char) ch) == NULL)) { + if (!silent) + _nc_warning("Illegal character (expected alphanumeric or %s) - '%s'", + terminfo_punct, unctrl(UChar(ch))); + _nc_panic_mode(separator); + goto start_token; + } + + if (tok_buf == NULL) + tok_buf = typeMalloc(char, TOK_BUF_SIZE); + +#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 = NULL; + after_list = NULL; + while ((ch = next_char()) != '\n') { + if (ch == EOF) { + _nc_err_abort(MSG_NO_INPUTS); + } else if (ch == '|') { + after_list = tok_ptr; + if (after_name == NULL) + after_name = tok_ptr; + } else if (ch == ':' && last_char(0) != ',') { + _nc_syntax = SYN_TERMCAP; + separator = ':'; + break; + } else if (ch == ',') { + _nc_syntax = SYN_TERMINFO; + separator = ','; + /* + * If we did not see a '|', then we found a name with no + * aliases or description. + */ + if (after_name == NULL) + break; + /* + * We saw a comma, but are not entirely sure this is + * terminfo format, since we can still be parsing the + * description field (for either syntax). + * + * A properly formatted termcap line ends with either a + * colon, or a backslash after a colon. It is possible + * to have a backslash in the middle of a capability, but + * then there would be no leading whitespace on the next + * line - something we want to discourage. + */ + c0 = last_char(0); + c1 = last_char(1); + if (c1 != ':' && c0 != '\\' && c0 != ':') { + bool capability = FALSE; + + /* + * Since it is not termcap, assume the line is terminfo + * format. However, the comma can be embedded in a + * description field. It also can be a separator + * between a description field and a capability. + * + * Improve the guess by checking if the next word after + * the comma does not look like a capability. In that + * case, extend the description past the comma. + */ + for (s = bufptr; isspace(UChar(*s)); ++s) { + ; + } + if (islower(UChar(*s))) { + const char *name = s; + while (isalnum(UChar(*s))) { + ++s; + } + if (*s == '#' || *s == '=' || *s == '@') { + /* + * Checking solely with syntax allows us to + * support extended capabilities with string + * values. + */ + capability = TRUE; + } else if (*s == ',') { + c0 = *s; + *s = '\0'; + /* + * Otherwise, we can handle predefined boolean + * capabilities, still aided by syntax. + */ + if (_nc_find_entry(name, + _nc_get_hash_table(FALSE))) { + capability = TRUE; + } + *s = (char) c0; + } + } + if (capability) { + break; + } + } + } else + ch = eat_escaped_newline(ch); + + if (OkToAdd()) { + AddCh(ch); + } else { + break; + } + } + *tok_ptr = '\0'; + if (_nc_syntax == ERR) { + /* + * Grrr...what we ought to do here is barf, complaining that + * the entry is malformed. But because a couple of name fields + * in the 8.2 termcap file end with |\, we just have to assume + * it is termcap syntax. + */ + _nc_syntax = SYN_TERMCAP; + separator = ':'; + } else if (_nc_syntax == SYN_TERMINFO) { + /* throw away trailing /, *$/ */ + for (--tok_ptr; + iswhite(*tok_ptr) || *tok_ptr == ','; + tok_ptr--) { + /* EMPTY */ ; + } + tok_ptr[1] = '\0'; + } + + /* + * This is the soonest we have the terminal name fetched. Set up + * for following warning messages. If there's no '|', then there + * is no description. + */ + if (after_name != NULL) { + 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. + */ + if (after_list != NULL) { + if (!silent) { + if (*after_list == '\0' || strchr("|", after_list[1]) != NULL) { + _nc_warning("empty longname field"); + } else if (strchr(after_list, ' ') == NULL) { + _nc_warning("older tic versions may treat the description field as an alias"); + } + } + } else { + after_list = tok_buf + strlen(tok_buf); + DEBUG(2, ("missing description")); + } + + /* + * 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 (s = tok_buf; s < after_list; ++s) { + if (isspace(UChar(*s))) { + if (!silent) + _nc_warning("whitespace in name or alias field"); + break; + } else if (*s == '/') { + if (!silent) + _nc_warning("slashes aren't allowed in names or aliases"); + break; + } else if (strchr("$[]!*?", *s)) { + if (!silent) + _nc_warning("dubious character `%c' in name or alias field", *s); + break; + } + } + + _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(UChar(ch))) { + if (_nc_syntax == SYN_TERMINFO) { + if (ch != '_') + break; + } else { /* allow ';' for "k;" */ + if (ch != ';') + break; + } + } + if (OkToAdd()) { + AddCh(ch); + } else { + ch = EOF; + break; + } + } + + *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 = tok_buf; + type = BOOLEAN; + break; + case '@': + if ((ch = next_char()) != separator && !silent) + _nc_warning("Missing separator after `%s', have %s", + tok_buf, unctrl(UChar(ch))); + _nc_curr_token.tk_name = tok_buf; + type = CANCEL; + break; + + case '#': + found = 0; + while (isalnum(ch = next_char())) { + numbuf[found++] = (char) ch; + if (found >= sizeof(numbuf) - 1) + break; + } + numbuf[found] = '\0'; + number = strtol(numbuf, &numchk, 0); + if (!silent) { + if (numchk == numbuf) + _nc_warning("no value given for `%s'", tok_buf); + if ((*numchk != '\0') || (ch != separator)) + _nc_warning("Missing separator for `%s'", tok_buf); + if (number < 0) + _nc_warning("value of `%s' cannot be negative", tok_buf); + if (number > MAX_OF_TYPE(NCURSES_INT2)) { + _nc_warning("limiting value of `%s' from %#lx to %#x", + tok_buf, + number, MAX_OF_TYPE(NCURSES_INT2)); + number = MAX_OF_TYPE(NCURSES_INT2); + } + } + _nc_curr_token.tk_name = tok_buf; + _nc_curr_token.tk_valnumber = (int) number; + type = NUMBER; + break; + + case '=': + ch = _nc_trans_string(tok_ptr, tok_buf + TOK_BUF_SIZE); + if (!silent && ch != separator) + _nc_warning("Missing separator"); + _nc_curr_token.tk_name = tok_buf; + _nc_curr_token.tk_valstring = tok_ptr; + type = STRING; + break; + + case EOF: + type = EOF; + break; + default: + /* just to get rid of the compiler warning */ + type = UNDEF; + if (!silent) + _nc_warning("Illegal character - '%s'", unctrl(UChar(ch))); + } + } /* end else (first_column == FALSE) */ + } /* end else (ch != EOF) */ + + end_of_token: + +#ifdef TRACE + 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: + _tracef("Token: Boolean; name='%s'", + _nc_curr_token.tk_name); + break; + + case NUMBER: + _tracef("Token: Number; name='%s', value=%d", + _nc_curr_token.tk_name, + _nc_curr_token.tk_valnumber); + break; + + case STRING: + _tracef("Token: String; name='%s', value=%s", + _nc_curr_token.tk_name, + _nc_visbuf(_nc_curr_token.tk_valstring)); + break; + + case CANCEL: + _tracef("Token: Cancel; name='%s'", + _nc_curr_token.tk_name); + break; + + case NAMES: + + _tracef("Token: Names; value='%s'", + _nc_curr_token.tk_name); + break; + + case EOF: + _tracef("Token: End of file"); + break; + + default: + _nc_warning("Bad token type"); + } + } +#endif + + if (dot_flag == TRUE) /* if commented out, use the next one */ + type = _nc_get_token(silent); + + DEBUG(3, ("token: `%s', class %d", + ((_nc_curr_token.tk_name != NULL) + ? _nc_curr_token.tk_name + : ""), + type)); + + DEBUG(3, (T_RETURN("%d"), type)); + return (type); +} + +/* + * char + * trans_string(ptr) + * + * Reads characters using next_char() until encountering a separator, nl, + * or end-of-file. The returned value is the character which caused + * reading to stop. The following translations are done on the input: + * + * ^X goes to ctrl-X (i.e. X & 037) + * {\E,\n,\r,\b,\t,\f} go to + * {ESCAPE,newline,carriage-return,backspace,tab,formfeed} + * {\^,\\} go to {carat,backslash} + * \ddd (for ddd = up to three octal digits) goes to the character ddd + * + * \e == \E + * \0 == \200 + * + */ + +NCURSES_EXPORT(int) +_nc_trans_string(char *ptr, const char *const last) +{ + int count = 0; + int number = 0; + int i, c; + int last_ch = '\0'; + bool ignored = FALSE; + bool long_warning = FALSE; + + while ((c = next_char()) != separator && c != EOF) { + if (ptr >= (last - 1)) { + if (c != EOF) { + while ((c = next_char()) != separator && c != EOF) { + ; + } + } + break; + } + if ((_nc_syntax == SYN_TERMCAP) && c == '\n') + break; + if (c == '^' && last_ch != '%') { + c = next_char(); + if (c == EOF) + _nc_err_abort(MSG_NO_INPUTS); + + if (!(is7bits(c) && isprint(c))) { + _nc_warning("Illegal ^ character - '%s'", unctrl(UChar(c))); + } + if (c == '?' && (_nc_syntax != SYN_TERMCAP)) { + *(ptr++) = '\177'; + } else { + if ((c &= 037) == 0) + c = 128; + *(ptr++) = (char) (c); + } + } else if (c == '\\') { + bool strict_bsd = ((_nc_syntax == SYN_TERMCAP) && _nc_strict_bsd); + + c = next_char(); + if (c == EOF) + _nc_err_abort(MSG_NO_INPUTS); + + if (isoctal(c) || (strict_bsd && isdigit(c))) { + number = c - '0'; + for (i = 0; i < 2; i++) { + c = next_char(); + if (c == EOF) + _nc_err_abort(MSG_NO_INPUTS); + + if (!isoctal(c)) { + if (isdigit(c)) { + if (!strict_bsd) { + _nc_warning("Non-octal digit `%c' in \\ sequence", c); + /* allow the digit; it'll do less harm */ + } + } else { + push_back(c); + break; + } + } + + number = number * 8 + c - '0'; + } + + number = UChar(number); + if (number == 0 && !strict_bsd) + number = 0200; + *(ptr++) = (char) number; + } else { + switch (c) { + case 'E': + *(ptr++) = '\033'; + break; + + case 'n': + *(ptr++) = '\n'; + break; + + case 'r': + *(ptr++) = '\r'; + break; + + case 'b': + *(ptr++) = '\010'; + break; + + case 'f': + *(ptr++) = '\014'; + break; + + case 't': + *(ptr++) = '\t'; + break; + + case '\\': + *(ptr++) = '\\'; + break; + + case '^': + *(ptr++) = '^'; + break; + + case ',': + *(ptr++) = ','; + break; + + case '\n': + continue; + + default: + if ((_nc_syntax == SYN_TERMINFO) || !_nc_strict_bsd) { + switch (c) { + case 'a': + c = '\007'; + break; + case 'e': + c = '\033'; + break; + case 'l': + c = '\n'; + break; + case 's': + c = ' '; + break; + case ':': + c = ':'; + break; + default: + _nc_warning("Illegal character '%s' in \\ sequence", + unctrl(UChar(c))); + break; + } + } + /* FALLTHRU */ + case '|': + *(ptr++) = (char) c; + } /* endswitch (c) */ + } /* endelse (c < '0' || c > '7') */ + } + /* end else if (c == '\\') */ + else if (c == '\n' && (_nc_syntax == SYN_TERMINFO)) { + /* + * Newlines embedded in a terminfo string are ignored, provided + * that the next line begins with whitespace. + */ + ignored = TRUE; + } else { + *(ptr++) = (char) c; + } + + if (!ignored) { + if (_nc_curr_col <= 1) { + push_back(c); + c = '\n'; + break; + } + last_ch = c; + count++; + } + ignored = FALSE; + + if (count > MAXCAPLEN && !long_warning) { + _nc_warning("Very long string found. Missing separator?"); + long_warning = TRUE; + } + } /* end while */ + + *ptr = '\0'; + + return (c); +} + +/* + * _nc_push_token() + * + * Push a token of given type so that it will be reread by the next + * get_token() call. + */ + +NCURSES_EXPORT(void) +_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 _nc_curr_token is static storage that nothing but + * _nc_get_token() touches. + */ + pushtype = tokclass; + if (pushname == NULL) + pushname = typeMalloc(char, MAX_NAME_SIZE + 1); + _nc_get_type(pushname); + + DEBUG(3, ("pushing token: `%s', class %d", + ((_nc_curr_token.tk_name != NULL) + ? _nc_curr_token.tk_name + : ""), + pushtype)); +} + +/* + * Panic mode error recovery - skip everything until a "ch" is found. + */ +NCURSES_EXPORT(void) +_nc_panic_mode(char ch) +{ + for (;;) { + int c = next_char(); + if (c == ch) + return; + if (c == EOF) + return; + } +} + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_comp_scan_leaks(void) +{ + if (pushname != NULL) { + FreeAndNull(pushname); + } + if (tok_buf != NULL) { + FreeAndNull(tok_buf); + } +} +#endif diff --git a/ncurses/ncurses/tinfo/db_iterator.c b/ncurses/ncurses/tinfo/db_iterator.c new file mode 100644 index 0000000000..010ce18e93 --- /dev/null +++ b/ncurses/ncurses/tinfo/db_iterator.c @@ -0,0 +1,463 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2006-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +#include +#include + +#if USE_HASHED_DB +#include +#endif + +MODULE_ID("$Id: db_iterator.c,v 1.54 2025/12/25 18:19:46 tom Exp $") + +#define HaveTicDirectory _nc_globals.have_tic_directory +#define KeepTicDirectory _nc_globals.keep_tic_directory +#define TicDirectory _nc_globals.tic_directory +#define my_blob _nc_globals.dbd_blob +#define my_list _nc_globals.dbd_list +#define my_size _nc_globals.dbd_size +#define my_time _nc_globals.dbd_time +#define my_vars _nc_globals.dbd_vars + +static void +add_to_blob(const char *text, size_t limit) +{ + (void) limit; + + if (*text != '\0') { + char *last = my_blob + strlen(my_blob); + if (last != my_blob) + *last++ = NCURSES_PATHSEP; + _nc_STRCPY(last, text, limit); + } +} + +static bool +check_existence(const char *name, struct stat *sb) +{ + bool result = FALSE; + + if (quick_prefix(name)) { + result = TRUE; + } else if (_nc_is_path_found(name, sb) + && (S_ISDIR(sb->st_mode) + || (S_ISREG(sb->st_mode) && sb->st_size))) { + result = TRUE; + } +#if USE_HASHED_DB + else if (strlen(name) < PATH_MAX - sizeof(DBM_SUFFIX)) { + char temp[PATH_MAX]; + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%s%s", name, DBM_SUFFIX); + if (_nc_is_path_found(temp, sb) && S_ISREG(sb->st_mode) && sb->st_size) { + result = TRUE; + } + } +#endif + return result; +} + +/* + * Trim newlines (and backslashes preceding those) and tab characters to + * help simplify scripting of the quick-dump feature. Leave spaces and + * other backslashes alone. + */ +static void +trim_formatting(char *source) +{ + char *target = source; + char ch; + + while ((ch = *source++) != '\0') { + if (ch == '\\' && *source == '\n') + continue; + if (ch == '\n' || ch == '\t') + continue; + *target++ = ch; + } + *target = '\0'; +} + +/* + * Store the latest value of an environment variable in my_vars[] so we can + * detect if one changes, invalidating the cached search-list. + */ +static bool +update_getenv(const char *name, DBDIRS which) +{ + bool result = FALSE; + + if (which < dbdLAST) { + char *value; + const char *cached_value = my_vars[which].value; + bool same_value; + + if ((value = getenv(name)) != NULL) { + value = strdup(value); + } + same_value = ((value == NULL && cached_value == NULL) || + (value != NULL && + cached_value != NULL && + strcmp(value, cached_value) == 0)); + + /* Set variable name to enable checks in cache_expired(). */ + my_vars[which].name = name; + + if (!same_value) { + FreeIfNeeded(my_vars[which].value); + my_vars[which].value = value; + result = TRUE; + } else { + free(value); + } + } + return result; +} + +#if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP +static char * +cache_getenv(const char *name, DBDIRS which) +{ + char *result = NULL; + + (void) update_getenv(name, which); + if (which < dbdLAST) { + result = my_vars[which].value; + } + return result; +} +#endif + +/* + * The cache expires if at least a second has passed since the initial lookup, + * or if one of the environment variables changed. + * + * Only a few applications use multiple lookups of terminal entries, seems that + * aside from bulk I/O such as tic and toe, that leaves interactive programs + * which should not be modifying the terminal databases in a way that would + * invalidate the search-list. + * + * The "1-second" is to allow for user-directed changes outside the program. + */ +static bool +cache_expired(void) +{ + bool result = FALSE; + time_t now = time((time_t *) 0); + + if (now > my_time) { + result = TRUE; + } else { + DBDIRS n; + for (n = (DBDIRS) 0; n < dbdLAST; ++n) { + if (my_vars[n].name != NULL + && update_getenv(my_vars[n].name, n)) { + result = TRUE; + break; + } + } + } + return result; +} + +static void +free_cache(void) +{ + FreeAndNull(my_blob); + FreeAndNull(my_list); +} + +static void +update_tic_dir(const char *update) +{ + free((char *) TicDirectory); + TicDirectory = update; +} + +/* + * 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) +{ + T(("_nc_tic_dir %s", NonNull(path))); + if (!KeepTicDirectory) { + if (path != NULL) { + if (path != TicDirectory) + update_tic_dir(strdup(path)); + HaveTicDirectory = TRUE; + } else if (HaveTicDirectory == 0) { + if (use_terminfo_vars()) { + const char *envp; + if ((envp = getenv("TERMINFO")) != NULL) + return _nc_tic_dir(envp); + } + } + } + return TicDirectory ? TicDirectory : TERMINFO; +} + +/* + * 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; +} + +/* + * Cleanup. + */ +NCURSES_EXPORT(void) +_nc_last_db(void) +{ + if (my_blob != NULL && cache_expired()) { + free_cache(); + } +} + +/* + * 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; + + (void) offset; + if ((int) *state < my_size + && my_list != NULL + && my_list[*state] != NULL) { + result = my_list[*state]; + (*state)++; + } else { + result = NULL; + } + if (result != NULL) { + T(("_nc_next_db %d %s", *state, result)); + } + return result; +} + +NCURSES_EXPORT(void) +_nc_first_db(DBDIRS * state, int *offset) +{ + bool cache_has_expired = FALSE; + *state = dbdTIC; + *offset = 0; + + T((T_CALLED("_nc_first_db"))); + + /* build a blob containing all of the strings we will use for a lookup + * table. + */ + if (my_blob == NULL || (cache_has_expired = cache_expired())) { + size_t blobsize = 0; + const char *values[dbdLAST]; + struct stat *my_stat; + int j; + + if (cache_has_expired) + free_cache(); + + for (j = 0; j < dbdLAST; ++j) + values[j] = NULL; + + /* + * This is the first item in the list, and is used only when tic is + * writing to the database, as a performance improvement. + */ + values[dbdTIC] = TicDirectory; + +#if NCURSES_USE_DATABASE +#ifdef TERMINFO_DIRS + values[dbdCfgList] = TERMINFO_DIRS; +#endif +#ifdef TERMINFO + values[dbdCfgOnce] = TERMINFO; +#endif +#endif + +#if NCURSES_USE_TERMCAP + values[dbdCfgList2] = TERMPATH; +#endif + + if (use_terminfo_vars()) { +#if NCURSES_USE_DATABASE + values[dbdEnvOnce] = cache_getenv("TERMINFO", dbdEnvOnce); + values[dbdHome] = _nc_home_terminfo(); + (void) cache_getenv("HOME", dbdHome); + values[dbdEnvList] = cache_getenv("TERMINFO_DIRS", dbdEnvList); + +#endif +#if NCURSES_USE_TERMCAP + values[dbdEnvOnce2] = cache_getenv("TERMCAP", dbdEnvOnce2); + /* only use $TERMCAP if it is an absolute path */ + if (values[dbdEnvOnce2] != NULL + && *values[dbdEnvOnce2] != '/') { + values[dbdEnvOnce2] = NULL; + } + values[dbdEnvList2] = cache_getenv("TERMPATH", dbdEnvList2); +#endif /* NCURSES_USE_TERMCAP */ + } + + for (j = 0; j < dbdLAST; ++j) { + if (values[j] == NULL) + values[j] = ""; + blobsize += 2 + strlen(values[j]); + } + + my_blob = malloc(blobsize); + if (my_blob != NULL) { + *my_blob = '\0'; + for (j = 0; j < dbdLAST; ++j) { + add_to_blob(values[j], blobsize); + } + + /* Now, build an array which will be pointers to the distinct + * strings in the blob. + */ + blobsize = 2; + for (j = 0; my_blob[j] != '\0'; ++j) { + if (my_blob[j] == NCURSES_PATHSEP) + ++blobsize; + } + my_list = typeCalloc(char *, blobsize); + my_stat = typeCalloc(struct stat, blobsize); + if (my_list != NULL && my_stat != NULL) { + int k = 0; + my_list[k++] = my_blob; + for (j = 0; my_blob[j] != '\0'; ++j) { + if (my_blob[j] == NCURSES_PATHSEP + && ((&my_blob[j] - my_list[k - 1]) != 3 + || !quick_prefix(my_list[k - 1]))) { + my_blob[j] = '\0'; + my_list[k++] = &my_blob[j + 1]; + } + } + + /* + * Eliminate duplicates from the list. + */ + for (j = 0; my_list[j] != NULL; ++j) { +#ifdef TERMINFO + if (*my_list[j] == '\0') { + char *my_copy = strdup(TERMINFO); + if (my_copy != NULL) + my_list[j] = my_copy; + } +#endif + trim_formatting(my_list[j]); + for (k = 0; k < j; ++k) { + if (!strcmp(my_list[j], my_list[k])) { + T(("duplicate %s", my_list[j])); + k = j - 1; + while ((my_list[j] = my_list[j + 1]) != NULL) { + ++j; + } + j = k; + break; + } + } + } + + /* + * Eliminate non-existent databases, and those that happen to + * be symlinked to another location. + */ + for (j = 0; my_list[j] != NULL; ++j) { + bool found = check_existence(my_list[j], &my_stat[j]); +#if HAVE_LINK + if (found) { + for (k = 0; k < j; ++k) { + if (my_stat[j].st_dev == my_stat[k].st_dev + && my_stat[j].st_ino == my_stat[k].st_ino) { + found = FALSE; + break; + } + } + } +#endif + if (!found) { + T(("not found %s", my_list[j])); + k = j; + while ((my_list[k] = my_list[k + 1]) != NULL) { + ++k; + } + --j; + } + } + my_size = j; + my_time = time((time_t *) 0); + } else { + FreeAndNull(my_blob); + } + free(my_stat); + } + } + returnVoid; +} + +#if NO_LEAKS +void +_nc_db_iterator_leaks(void) +{ + DBDIRS which; + + if (my_blob != NULL) + FreeAndNull(my_blob); + if (my_list != NULL) + FreeAndNull(my_list); + for (which = 0; (int) which < dbdLAST; ++which) { + my_vars[which].name = NULL; + FreeIfNeeded(my_vars[which].value); + my_vars[which].value = NULL; + } + update_tic_dir(NULL); +} +#endif diff --git a/ncurses/ncurses/tinfo/doalloc.c b/ncurses/ncurses/tinfo/doalloc.c new file mode 100644 index 0000000000..6e6c155f0c --- /dev/null +++ b/ncurses/ncurses/tinfo/doalloc.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 1998-2002,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1998 * + ****************************************************************************/ + +/* + * Wrapper for malloc/realloc. Standard implementations allow realloc with + * a null pointer, but older libraries may not (e.g., SunOS). + * + * Also if realloc fails, we discard the old memory to avoid leaks. + */ + +#include + +MODULE_ID("$Id: doalloc.c,v 1.15 2024/12/07 20:05:08 tom Exp $") + +void * +_nc_doalloc(void *oldp, size_t amount) +{ + void *newp; + + if (oldp != NULL) { + if (amount == 0) { + free(oldp); + newp = NULL; + } else if ((newp = realloc(oldp, amount)) == NULL) { + free(oldp); + errno = ENOMEM; /* just in case 'free' reset */ + } + } else { + newp = malloc(amount); + } + return newp; +} diff --git a/ncurses/ncurses/tinfo/entries.c b/ncurses/ncurses/tinfo/entries.c new file mode 100644 index 0000000000..ade46b4bbb --- /dev/null +++ b/ncurses/ncurses/tinfo/entries.c @@ -0,0 +1,197 @@ +/**************************************************************************** + * Copyright 2019-2023,2024 Thomas E. Dickey * + * Copyright 2006-2012,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Juergen Pfeifer * + ****************************************************************************/ + +#include + +#include + +#include + +MODULE_ID("$Id: entries.c,v 1.39 2024/12/14 23:48:20 tom 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 = NULL; +NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = NULL; + +static ENTRY * +_nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm) +/* delink the allocated storage for the given list entry */ +{ + ENTRY *ep, *last; + + for (last = NULL, ep = headp; ep != NULL; last = ep, ep = ep->next) { + if (&(ep->tterm) == tterm) { + if (last != NULL) { + last->next = ep->next; + } + if (ep->next != NULL) { + ep->next->last = last; + } + if (ep == _nc_head) { + _nc_head = ep->next; + } + if (ep == _nc_tail) { + _nc_tail = last; + } + break; + } + } + return ep; +} + +NCURSES_EXPORT(void) +_nc_free_entry(ENTRY * headp, const TERMTYPE2 *tterm) +/* free the allocated storage consumed by the given list entry */ +{ + ENTRY *ep; + + if ((ep = _nc_delink_entry(headp, tterm)) != NULL) { + 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 != NULL) { + _nc_free_termtype2(&(_nc_head->tterm)); + } +} + +NCURSES_EXPORT(void) +_nc_leaks_tinfo(void) +{ +#if NO_LEAKS + char *s; +#endif + + T((T_CALLED("_nc_leaks_tinfo()"))); +#if NO_LEAKS + _nc_globals.leak_checking = TRUE; + _nc_free_tparm(cur_term); + _nc_tgetent_leaks(); + +#ifdef USE_PTHREADS + /* + * Discard any prescreen data which is not used for the current screen. + */ + _nc_lock_global(screen); + { + PRESCREEN_LIST *p; + pthread_t id = GetThreadID(); + for (p = _nc_prescreen.allocated; p != NULL; p = p->next) { + if (p->id == id && p->sp != CURRENT_SCREEN) { + FreeAndNull(p->sp); + } + } + } + _nc_unlock_global(screen); +#endif + if (TerminalOf(CURRENT_SCREEN) != NULL) { + del_curterm(TerminalOf(CURRENT_SCREEN)); + } + _nc_forget_prescr(); + + _nc_comp_captab_leaks(); + _nc_comp_userdefs_leaks(); + _nc_free_entries(_nc_head); + _nc_get_type(NULL); + _nc_first_name(NULL); + _nc_db_iterator_leaks(); + _nc_keyname_leaks(); +#if BROKEN_LINKER || USE_REENTRANT + _nc_names_leaks(); + _nc_codes_leaks(); + FreeIfNeeded(_nc_prescreen.real_acs_map); +#endif + _nc_comp_error_leaks(); + + if ((s = _nc_home_terminfo()) != NULL) + free(s); + +#ifdef TRACE + T((T_RETURN(""))); + curses_trace(0); + _nc_trace_buf(-1, (size_t) 0); +#endif + +#endif /* NO_LEAKS */ + returnVoid; +} + +#if NO_LEAKS +NCURSES_EXPORT(void) +_nc_free_tinfo(int code) +{ + T((T_CALLED("_nc_free_tinfo(%d)"), code)); + _nc_leaks_tinfo(); + exit(code); +} +#endif + +NCURSES_EXPORT(void) +exit_terminfo(int code) +{ + T((T_CALLED("exit_terminfo(%d)"), code)); +#if NO_LEAKS + _nc_leaks_tinfo(); +#endif + exit(code); +} diff --git a/ncurses/ncurses/tinfo/free_ttype.c b/ncurses/ncurses/tinfo/free_ttype.c new file mode 100644 index 0000000000..7b6e8312cd --- /dev/null +++ b/ncurses/ncurses/tinfo/free_ttype.c @@ -0,0 +1,108 @@ +/**************************************************************************** + * Copyright 2020-2022,2023 Thomas E. Dickey * + * Copyright 1999-2011,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999-on * + ****************************************************************************/ + +/* + * free_ttype.c -- allocation functions for TERMTYPE + * + * _nc_free_termtype() + * use_extended_names() + * + */ + +#include + +#include + +MODULE_ID("$Id: free_ttype.c,v 1.22 2023/04/22 15:12:57 tom Exp $") + +static void +really_free_termtype(TERMTYPE2 *ptr, bool freeStrings) +{ + T(("really_free_termtype(%s) %d", ptr->term_names, freeStrings)); + + if (freeStrings) { + FreeIfNeeded(ptr->str_table); + } + FreeIfNeeded(ptr->Booleans); + FreeIfNeeded(ptr->Numbers); + FreeIfNeeded(ptr->Strings); +#if NCURSES_XNAMES + if (freeStrings) { + FreeIfNeeded(ptr->ext_str_table); + } + FreeIfNeeded(ptr->ext_Names); +#endif + memset(ptr, 0, sizeof(TERMTYPE)); + _nc_free_entry(_nc_head, ptr); +} + +NCURSES_EXPORT(void) +_nc_free_termtype(TERMTYPE *ptr) +{ + really_free_termtype((TERMTYPE2 *) ptr, !NCURSES_EXT_NUMBERS); +} + +/* + * These similar entrypoints are not used outside of ncurses. + */ +NCURSES_EXPORT(void) +_nc_free_termtype1(TERMTYPE *ptr) +{ + really_free_termtype((TERMTYPE2 *) ptr, TRUE); +} + +#if NCURSES_EXT_NUMBERS +NCURSES_EXPORT(void) +_nc_free_termtype2(TERMTYPE2 *ptr) +{ + really_free_termtype(ptr, TRUE); +} +#endif + +#if NCURSES_XNAMES +NCURSES_EXPORT_VAR(bool) _nc_user_definable = TRUE; + +NCURSES_EXPORT(int) +use_extended_names(bool flag) +{ + int oldflag = _nc_user_definable; + + START_TRACE(); + T((T_CALLED("use_extended_names(%d)"), flag)); + _nc_user_definable = flag; + returnBool(oldflag); +} +#endif diff --git a/ncurses/ncurses/tinfo/getenv_num.c b/ncurses/ncurses/tinfo/getenv_num.c new file mode 100644 index 0000000000..8c6b96b1d8 --- /dev/null +++ b/ncurses/ncurses/tinfo/getenv_num.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2012,2013 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1998 * + ****************************************************************************/ + +/* + * getenv_num.c -- obtain a number from the environment + */ + +#include + +MODULE_ID("$Id: getenv_num.c,v 1.11 2025/02/20 01:02:09 tom Exp $") + +NCURSES_EXPORT(int) +_nc_getenv_num(const char *name) +{ + char *dst = NULL; + const char *src = getenv(name); + long value; + + if ((src == NULL) + || (value = strtol(src, &dst, 0)) < 0 + || (dst == src) + || (*dst != '\0') + || (int) value < value) + value = -1; + + return (int) value; +} + +NCURSES_EXPORT(void) +_nc_setenv_num(const char *name, int value) +{ + if (name != NULL && value >= 0) { + char buffer[128]; +#if HAVE_SETENV + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "%d", value); + setenv(name, buffer, 1); +#elif HAVE_PUTENV + char *s; + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "%s=%d", name, value); + if ((s = strdup(buffer)) != NULL) + putenv(s); +#else +#error expected setenv/putenv functions +#endif + } +} diff --git a/ncurses/ncurses/tinfo/hashed_db.c b/ncurses/ncurses/tinfo/hashed_db.c new file mode 100644 index 0000000000..0544bfd0f3 --- /dev/null +++ b/ncurses/ncurses/tinfo/hashed_db.c @@ -0,0 +1,350 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 2006-2011,2013 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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-on * + ****************************************************************************/ + +#include +#include +#include + +#if USE_HASHED_DB + +MODULE_ID("$Id: hashed_db.c,v 1.22 2025/01/11 23:52:18 tom Exp $") + +#if HASHED_DB_API >= 2 +static DBC *cursor; +#endif + +typedef struct _myconn { + struct _myconn *next; + DB *db; + char *path; + bool modify; +} MYCONN; + +static MYCONN *connections; + +static void +cleanup(void) +{ + while (connections != NULL) { + _nc_db_close(connections->db); + } +} + +static DB * +find_connection(const char *path, bool modify) +{ + DB *result = NULL; + MYCONN *p; + + for (p = connections; p != NULL; p = p->next) { + if (!strcmp(p->path, path) && p->modify == modify) { + result = p->db; + break; + } + } + + return result; +} + +static void +drop_connection(DB * db) +{ + MYCONN *p, *q; + + for (p = connections, q = NULL; p != NULL; q = p, p = p->next) { + if (p->db == db) { + if (q != NULL) + q->next = p->next; + else + connections = p->next; + free(p->path); + free(p); + break; + } + } +} + +static bool +make_connection(DB * db, const char *path, bool modify) +{ + bool code = FALSE; + MYCONN *p = typeCalloc(MYCONN, 1); + + if (p != NULL) { + p->path = strdup(path); + if (p->path != NULL) { + p->db = db; + p->modify = modify; + p->next = connections; + connections = p; + code = TRUE; + } else { + free(p); + } + } + return code; +} + +/* + * Open the database. + */ +NCURSES_EXPORT(DB *) +_nc_db_open(const char *path, bool modify) +{ + DB *result = NULL; + int code; + + if (connections == NULL) + atexit(cleanup); + + if ((result = find_connection(path, modify)) == NULL) { + +#if HASHED_DB_API >= 4 + db_create(&result, NULL, 0); + if ((code = result->open(result, + NULL, + path, + NULL, + DB_HASH, + modify ? DB_CREATE : DB_RDONLY, + 0644)) != 0) { + result = NULL; + } +#elif HASHED_DB_API >= 3 + db_create(&result, NULL, 0); + if ((code = result->open(result, + path, + NULL, + DB_HASH, + modify ? DB_CREATE : DB_RDONLY, + 0644)) != 0) { + result = NULL; + } +#elif HASHED_DB_API >= 2 + if ((code = db_open(path, + DB_HASH, + modify ? DB_CREATE : DB_RDONLY, + 0644, + (DB_ENV *) 0, + (DB_INFO *) 0, + &result)) != 0) { + result = NULL; + } +#else + if ((result = dbopen(path, + modify ? (O_CREAT | O_RDWR) : O_RDONLY, + 0644, + DB_HASH, + NULL)) == NULL) { + code = errno; + } else { + code = 0; + } +#endif + if (result != NULL && make_connection(result, path, modify)) { + T(("opened %s", path)); + } else { + T(("cannot open %s: (errno %d) %s", path, code, strerror(code))); + errno = code; + } + } + 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; + + drop_connection(db); +#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, R_NEXT); +#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 = (int) 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 = (int) 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/ncurses/ncurses/tinfo/home_terminfo.c b/ncurses/ncurses/tinfo/home_terminfo.c new file mode 100644 index 0000000000..8523f8ebe1 --- /dev/null +++ b/ncurses/ncurses/tinfo/home_terminfo.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2012,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* + * home_terminfo.c -- return the $HOME/.terminfo string, expanded + */ + +#include +#include + +MODULE_ID("$Id: home_terminfo.c,v 1.19 2024/12/07 18:14:49 tom 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 = NULL; +#if USE_HOME_TERMINFO + if (use_terminfo_vars()) { + + if (MyBuffer == NULL) { + const char *home; + + if ((home = getenv("HOME")) != NULL) { + size_t want = (strlen(home) + sizeof(PRIVATE_INFO)); + TYPE_MALLOC(char, want, MyBuffer); + _nc_SPRINTF(MyBuffer, _nc_SLIMIT(want) PRIVATE_INFO, home); + } + } + result = MyBuffer; + } +#endif + return result; +} diff --git a/ncurses/ncurses/tinfo/init_keytry.c b/ncurses/ncurses/tinfo/init_keytry.c new file mode 100644 index 0000000000..f02b7b5f98 --- /dev/null +++ b/ncurses/ncurses/tinfo/init_keytry.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1999-2010,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +#include +#include /* struct tinfo_fkeys */ + +MODULE_ID("$Id: init_keytry.c,v 1.22 2024/12/07 18:14:49 tom Exp $") + +/* +** _nc_init_keytry() +** +** Construct the try for the current terminal's keypad keys. +** +*/ + +/* + * Internal entrypoints use SCREEN* parameter to obtain capabilities rather + * than cur_term. + */ +#undef CUR +#define CUR SP_TERMTYPE + +#if BROKEN_LINKER +#undef _nc_tinfo_fkeys +#endif + +/* LINT_PREPRO +#if 0*/ +#include +/* LINT_PREPRO +#endif*/ + +#if BROKEN_LINKER +const struct tinfo_fkeys * +_nc_tinfo_fkeysf(void) +{ + return _nc_tinfo_fkeys; +} +#endif + +NCURSES_EXPORT(void) +_nc_init_keytry(SCREEN *sp) +{ + T(("_nc_init_keytry(%p)", (void *) 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. + */ + + if (sp != NULL) { + unsigned n; + + 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, (int) n, strnames); + const char *value = tp->Strings[n]; + if (name != NULL + && *name == 'k' + && VALID_STRING(value) + && NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx + value) == 0) { + (void) _nc_add_to_try(&(sp->_keytry), + value, + n - STRCOUNT + KEY_MAX); + } + } + } +#endif +#ifdef TRACE + _nc_trace_tries(sp->_keytry); +#endif + } +} diff --git a/ncurses/ncurses/tinfo/lib_acs.c b/ncurses/ncurses/tinfo/lib_acs.c new file mode 100644 index 0000000000..8c2ee1bd7c --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_acs.c @@ -0,0 +1,329 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2008 * + ****************************************************************************/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_acs.c,v 1.54 2025/12/27 12:33:34 tom Exp $") + +#if BROKEN_LINKER || USE_REENTRANT +#define MyBuffer _nc_prescreen.real_acs_map +NCURSES_EXPORT(chtype *) +NCURSES_PUBLIC_VAR(acs_map) (void) +{ + if (MyBuffer == NULL) + MyBuffer = typeCalloc(chtype, ACS_LEN); + return MyBuffer; +} +#undef MyBuffer +#else +NCURSES_EXPORT_VAR (chtype) acs_map[ACS_LEN] = +{ + 0 +}; +#endif + +#if USE_TERM_DRIVER +NCURSES_EXPORT(chtype) +NCURSES_SP_NAME(_nc_acs_char) (NCURSES_SP_DCLx int c) +{ + chtype *map; + if (c < 0 || c >= ACS_LEN) + return (chtype) 0; + map = (SP_PARM != NULL) ? SP_PARM->_acs_map : +#if BROKEN_LINKER || USE_REENTRANT + _nc_prescreen.real_acs_map +#else + acs_map +#endif + ; + return map[c]; +} +#endif /* USE_TERM_DRIVER */ + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0) +{ + chtype *fake_map = acs_map; + chtype *real_map = SP_PARM != NULL ? SP_PARM->_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 | (chtype) j; + if (SP_PARM) + SP_PARM->_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. + */ + 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 */ + 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 */ + /* thick-line-drawing */ + real_map['L'] = '+'; /* upper left corner */ + real_map['M'] = '+'; /* lower left corner */ + real_map['K'] = '+'; /* upper right corner */ + real_map['J'] = '+'; /* lower right corner */ + real_map['T'] = '+'; /* tee pointing left */ + real_map['U'] = '+'; /* tee pointing right */ + real_map['V'] = '+'; /* tee pointing up */ + real_map['W'] = '+'; /* tee pointing down */ + real_map['Q'] = '-'; /* horizontal line */ + real_map['X'] = '|'; /* vertical line */ + real_map['N'] = '+'; /* large plus or crossover */ + /* double-line-drawing */ + real_map['C'] = '+'; /* upper left corner */ + real_map['D'] = '+'; /* lower left corner */ + real_map['B'] = '+'; /* upper right corner */ + real_map['A'] = '+'; /* lower right corner */ + real_map['G'] = '+'; /* tee pointing left */ + real_map['F'] = '+'; /* tee pointing right */ + real_map['H'] = '+'; /* tee pointing up */ + real_map['I'] = '+'; /* tee pointing down */ + real_map['R'] = '-'; /* horizontal line */ + real_map['Y'] = '|'; /* vertical line */ + real_map['E'] = '+'; /* large plus or crossover */ + +#if USE_TERM_DRIVER + CallDriver_2(SP_PARM, td_initacs, real_map, fake_map); +#else + if (ena_acs != NULL) { + NCURSES_PUTP2("ena_acs", ena_acs); + } +#if NCURSES_EXT_FUNCS && defined(enter_pc_charset_mode) && defined(exit_pc_charset_mode) + /* + * 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 != NULL && b != NULL && !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] = (chtype) i; + if (real_map != fake_map) { + if (SP != NULL) + SP->_screen_acs_map[i] = TRUE; + } + } + } + } +#endif + + if (acs_chars != NULL) { + size_t i = 0; + size_t length = strlen(acs_chars); + + 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; + T(("#%d real_map[%s] = %s", + (int) i, + _tracechar(UChar(acs_chars[i])), + _tracechtype(real_map[UChar(acs_chars[i])]))); + if (SP != NULL) { + 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 (USE_TRACEF(TRACE_CALLS)) { + size_t n, m; + 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++] = (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" + : (strcmp(acs_chars, show) + ? "DIFF" + : "SAME"), + _nc_visbuf(show)); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ +#endif +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_init_acs(void) +{ + NCURSES_SP_NAME(_nc_init_acs) (CURRENT_SCREEN); +} +#endif + +#if !NCURSES_WCWIDTH_GRAPHICS +NCURSES_EXPORT(int) +_nc_wacs_width(wchar_t ch) +{ + int result; + switch (ch) { + case 0x00a3: /* FALLTHRU - ncurses pound-sterling symbol */ + case 0x00b0: /* FALLTHRU - VT100 degree symbol */ + case 0x00b1: /* FALLTHRU - VT100 plus/minus */ + case 0x00b7: /* FALLTHRU - VT100 bullet */ + case 0x03c0: /* FALLTHRU - ncurses greek pi */ + case 0x2190: /* FALLTHRU - Teletype arrow pointing left */ + case 0x2191: /* FALLTHRU - Teletype arrow pointing up */ + case 0x2192: /* FALLTHRU - Teletype arrow pointing right */ + case 0x2193: /* FALLTHRU - Teletype arrow pointing down */ + case 0x2260: /* FALLTHRU - ncurses not-equal */ + case 0x2264: /* FALLTHRU - ncurses less-than-or-equal-to */ + case 0x2265: /* FALLTHRU - ncurses greater-than-or-equal-to */ + case 0x23ba: /* FALLTHRU - VT100 scan line 1 */ + case 0x23bb: /* FALLTHRU - ncurses scan line 3 */ + case 0x23bc: /* FALLTHRU - ncurses scan line 7 */ + case 0x23bd: /* FALLTHRU - VT100 scan line 9 */ + case 0x2500: /* FALLTHRU - VT100 horizontal line */ + case 0x2501: /* FALLTHRU - thick horizontal line */ + case 0x2502: /* FALLTHRU - VT100 vertical line */ + case 0x2503: /* FALLTHRU - thick vertical line */ + case 0x250c: /* FALLTHRU - VT100 upper left corner */ + case 0x250f: /* FALLTHRU - thick upper left corner */ + case 0x2510: /* FALLTHRU - VT100 upper right corner */ + case 0x2513: /* FALLTHRU - thick upper right corner */ + case 0x2514: /* FALLTHRU - VT100 lower left corner */ + case 0x2517: /* FALLTHRU - thick lower left corner */ + case 0x2518: /* FALLTHRU - VT100 lower right corner */ + case 0x251b: /* FALLTHRU - thick lower right corner */ + case 0x251c: /* FALLTHRU - VT100 tee pointing left */ + case 0x2523: /* FALLTHRU - thick tee pointing left */ + case 0x2524: /* FALLTHRU - VT100 tee pointing right */ + case 0x252b: /* FALLTHRU - thick tee pointing right */ + case 0x252c: /* FALLTHRU - VT100 tee pointing down */ + case 0x2533: /* FALLTHRU - thick tee pointing down */ + case 0x2534: /* FALLTHRU - VT100 tee pointing up */ + case 0x253b: /* FALLTHRU - thick tee pointing up */ + case 0x253c: /* FALLTHRU - VT100 large plus or crossover */ + case 0x254b: /* FALLTHRU - thick large plus or crossover */ + case 0x2550: /* FALLTHRU - double horizontal line */ + case 0x2551: /* FALLTHRU - double vertical line */ + case 0x2554: /* FALLTHRU - double upper left corner */ + case 0x2557: /* FALLTHRU - double upper right corner */ + case 0x255a: /* FALLTHRU - double lower left corner */ + case 0x255d: /* FALLTHRU - double lower right corner */ + case 0x2560: /* FALLTHRU - double tee pointing right */ + case 0x2563: /* FALLTHRU - double tee pointing left */ + case 0x2566: /* FALLTHRU - double tee pointing down */ + case 0x2569: /* FALLTHRU - double tee pointing up */ + case 0x256c: /* FALLTHRU - double large plus or crossover */ + case 0x2592: /* FALLTHRU - VT100 checker board (stipple) */ + case 0x25ae: /* FALLTHRU - Teletype solid square block */ + case 0x25c6: /* FALLTHRU - VT100 diamond */ + case 0x2603: /* FALLTHRU - Teletype lantern symbol */ + result = 1; + break; + default: + result = wcwidth((wchar_t) ch); + break; + } + return result; +} +#endif /* !NCURSES_WCWIDTH_GRAPHICS */ diff --git a/ncurses/ncurses/tinfo/lib_baudrate.c b/ncurses/ncurses/tinfo/lib_baudrate.c new file mode 100644 index 0000000000..844913842a --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_baudrate.c @@ -0,0 +1,321 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * lib_baudrate.c + * + */ + +#include +#include /* ospeed */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#include +#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 NCURSES_OSPEED_COMPAT && \ + ((defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || \ + defined(__NetBSD__) || \ + ((defined(__OpenBSD__) && OpenBSD < 201510)) || \ + defined(__APPLE__)) +#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 +#else +#undef USE_OLD_TTY +#endif /* USE_OLD_TTY */ + +MODULE_ID("$Id: lib_baudrate.c,v 1.50 2025/12/23 09:21:42 tom Exp $") + +/* + * int + * baudrate() + * + * Returns the current terminal's baud rate. + * + */ + +struct speed { + int given_speed; /* values for 'ospeed' */ + int actual_speed; /* the actual speed */ +}; + +#if !defined(USE_WIN32CON_DRIVER) +#define DATA(number) { B##number, number } + +static struct speed const speeds[] = +{ + DATA(0), + DATA(50), + DATA(75), + DATA(110), + DATA(134), + DATA(150), + DATA(200), + DATA(300), + DATA(600), + DATA(1200), + DATA(1800), + DATA(2400), + DATA(4800), + DATA(9600), +#ifdef B19200 + DATA(19200), +#elif defined(EXTA) + {EXTA, 19200}, +#endif +#ifdef B28800 + DATA(28800), +#endif +#ifdef B38400 + DATA(38400), +#elif defined(EXTB) + {EXTB, 38400}, +#endif +#ifdef B57600 + DATA(57600), +#endif + /* ifdef to prevent overflow when OLD_TTY is not available */ +#if !(NCURSES_OSPEED_COMPAT && defined(__FreeBSD__) && (__FreeBSD_version > 700000)) +#ifdef B76800 + DATA(76800), +#endif +#ifdef B115200 + DATA(115200), +#endif +#ifdef B153600 + DATA(153600), +#endif +#ifdef B230400 + DATA(230400), +#endif +#ifdef B307200 + DATA(307200), +#endif +#ifdef B460800 + DATA(460800), +#endif +#ifdef B500000 + DATA(500000), +#endif +#ifdef B576000 + DATA(576000), +#endif +#ifdef B921600 + DATA(921600), +#endif +#ifdef B1000000 + DATA(1000000), +#endif +#ifdef B1152000 + DATA(1152000), +#endif +#ifdef B1500000 + DATA(1500000), +#endif +#ifdef B2000000 + DATA(2000000), +#endif +#ifdef B2500000 + DATA(2500000), +#endif +#ifdef B3000000 + DATA(3000000), +#endif +#ifdef B3500000 + DATA(3500000), +#endif +#ifdef B4000000 + DATA(4000000), +#endif +#endif +}; +#endif /* !USE_NAMED_PIPES */ + +NCURSES_EXPORT(int) +_nc_baudrate(int OSpeed) +{ +#if defined(USE_WIN32CON_DRIVER) + /* On Windows this is a noop */ + (void) OSpeed; + return (OK); +#else +#if !USE_REENTRANT + static int last_OSpeed; + static int last_baudrate; +#endif + + int result = ERR; + + if (OSpeed < 0) + OSpeed = (NCURSES_OSPEED) OSpeed; + if (OSpeed < 0) + OSpeed = (unsigned short) OSpeed; +#if !USE_REENTRANT + if (OSpeed == last_OSpeed) { + result = last_baudrate; + } +#endif + if (result == ERR) { + if (OSpeed >= 0) { + unsigned i; + + for (i = 0; i < SIZEOF(speeds); i++) { + if (speeds[i].given_speed > OSpeed) { + break; + } + if (speeds[i].given_speed == OSpeed) { + result = speeds[i].actual_speed; + break; + } + } + } +#if !USE_REENTRANT + if (OSpeed != last_OSpeed) { + last_OSpeed = OSpeed; + last_baudrate = result; + } +#endif + } + return (result); +#endif /* !USE_NAMED_PIPES */ +} + +NCURSES_EXPORT(int) +_nc_ospeed(int BaudRate) +{ + int result = 1; +#if defined(USE_WIN32CON_DRIVER) + (void) BaudRate; +#else + if (BaudRate >= 0) { + unsigned i; + + for (i = 0; i < SIZEOF(speeds); i++) { + if (speeds[i].actual_speed == BaudRate) { + result = speeds[i].given_speed; + break; + } + } + } +#endif + return (result); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0) +{ + int result; + + T((T_CALLED("baudrate(%p)"), (void *) SP_PARM)); + +#if defined(USE_WIN32CON_DRIVER) + (void) SP_PARM; + result = OK; +#else + /* + * In debugging, allow the environment symbol to override when we're + * redirecting to a file, so we can construct repeatable test-cases + * that take into account costs that depend on baudrate. + */ +#ifdef TRACE + if (IsValidTIScreen(SP_PARM) + && !NC_ISATTY(fileno((SP_PARM && SP_PARM->_ofp) ? SP_PARM->_ofp : stdout)) + && getenv("BAUDRATE") != NULL) { + int ret; + if ((ret = _nc_getenv_num("BAUDRATE")) <= 0) + ret = 9600; + ospeed = (NCURSES_OSPEED) _nc_ospeed(ret); + returnCode(ret); + } +#endif + + if (IsValidTIScreen(SP_PARM)) { +#ifdef USE_OLD_TTY + result = (int) cfgetospeed(&(TerminalOf(SP_PARM)->Nttyb)); + ospeed = (NCURSES_OSPEED) _nc_ospeed(result); +#else /* !USE_OLD_TTY */ +#ifdef TERMIOS + ospeed = (NCURSES_OSPEED) cfgetospeed(&(TerminalOf(SP_PARM)->Nttyb)); +#else + ospeed = (NCURSES_OSPEED) TerminalOf(SP_PARM)->Nttyb.sg_ospeed; +#endif + result = _nc_baudrate(ospeed); +#endif + TerminalOf(SP_PARM)->_baudrate = result; + } else { + result = ERR; + } +#endif /* !USE_NAMED_PIPES */ + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +baudrate(void) +{ + return NCURSES_SP_NAME(baudrate) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_cur_term.c b/ncurses/ncurses/tinfo/lib_cur_term.c new file mode 100644 index 0000000000..47b266c2e9 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_cur_term.c @@ -0,0 +1,203 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997 * + ****************************************************************************/ +/* + * Module that "owns" the 'cur_term' variable: + * + * TERMINAL *set_curterm(TERMINAL *) + * int del_curterm(TERMINAL *) + */ + +#include +#include /* ospeed */ +#include /* VALID_STRING */ + +MODULE_ID("$Id: lib_cur_term.c,v 1.53 2025/12/27 12:41:23 tom Exp $") + +#undef CUR +#define CUR TerminalType(termp). + +#if USE_REENTRANT + +NCURSES_EXPORT(TERMINAL *) +NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_DCL0) +{ + return ((NULL != TerminalOf(SP_PARM)) ? TerminalOf(SP_PARM) : CurTerm); +} + +#if NCURSES_SP_FUNCS + +NCURSES_EXPORT(TERMINAL *) +_nc_get_cur_term(void) +{ + return NCURSES_SP_NAME(_nc_get_cur_term) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(TERMINAL *) +NCURSES_PUBLIC_VAR(cur_term) (void) +{ +#if NCURSES_SP_FUNCS + return NCURSES_SP_NAME(_nc_get_cur_term) (CURRENT_SCREEN); +#else + return NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_ARG); +#endif +} + +#else +NCURSES_EXPORT_VAR(TERMINAL *) cur_term = NULL; +#endif + +NCURSES_EXPORT(TERMINAL *) +NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL *termp) +{ + TERMINAL *oldterm; + + T((T_CALLED("set_curterm(%p)"), (void *) termp)); + + _nc_lock_global(curses); + oldterm = cur_term; + if (SP_PARM) + SP_PARM->_term = termp; +#if USE_REENTRANT + CurTerm = termp; +#else + cur_term = termp; +#endif + if (termp != NULL) { +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp; + ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate); + if (TCB->drv && + TCB->drv->isTerminfo && + TerminalType(termp).Strings) { + PC = (char) (VALID_STRING(pad_char) ? pad_char[0] : 0); + } + TCB->csp = SP_PARM; +#else + ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate); + if (TerminalType(termp).Strings) { + PC = (char) (VALID_STRING(pad_char) ? pad_char[0] : 0); + } +#endif +#if !USE_REENTRANT + save_ttytype(termp); +#endif + } + _nc_unlock_global(curses); + + T((T_RETURN("%p"), (void *) oldterm)); + return (oldterm); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(TERMINAL *) +set_curterm(TERMINAL *termp) +{ + return NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN, termp); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp) +{ + int rc = ERR; + + T((T_CALLED("del_curterm(%p, %p)"), (void *) SP_PARM, (void *) termp)); + + if (termp != NULL) { +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp; +#endif + TERMINAL *cur = ( +#if USE_REENTRANT + NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_ARG) +#else + cur_term +#endif + ); + +#if NCURSES_EXT_NUMBERS +#if NCURSES_EXT_COLORS + _nc_free_termtype1(&termp->type); +#else + _nc_free_termtype2(&termp->type); +#endif +#endif + _nc_free_termtype2(&TerminalType(termp)); + if (termp == cur) + NCURSES_SP_NAME(set_curterm) (NCURSES_SP_ARGx NULL); + + FreeIfNeeded(termp->_termname); +#if USE_HOME_TERMINFO + if (_nc_globals.home_terminfo != NULL) { + FreeAndNull(_nc_globals.home_terminfo); + } +#endif +#if USE_TERM_DRIVER + if (TCB->drv) + TCB->drv->td_release(TCB); +#endif +#if NO_LEAKS + /* discard memory used in tgetent's cache for this terminal */ + _nc_tgetent_leak(termp); +#endif + if (--_nc_globals.terminal_count == 0) { + _nc_free_tparm(termp); + } + + free(termp->tparm_state.fmt_buff); + free(termp->tparm_state.out_buff); + free(termp); + + rc = OK; + } + + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +del_curterm(TERMINAL *termp) +{ + int rc; + + _nc_lock_global(curses); + rc = NCURSES_SP_NAME(del_curterm) (CURRENT_SCREEN, termp); + _nc_unlock_global(curses); + + return (rc); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_data.c b/ncurses/ncurses/tinfo/lib_data.c new file mode 100644 index 0000000000..743198f065 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_data.c @@ -0,0 +1,408 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* +** lib_data.c +** +** Common data that may/may not be allocated, but is referenced globally +** +*/ + +#include + +MODULE_ID("$Id: lib_data.c,v 1.95 2025/12/27 12:33:34 tom Exp $") + +/* + * OS/2's native linker complains if we don't initialize public data when + * constructing a dll (reported by J.J.G.Ripoll). + */ +#if USE_REENTRANT +NCURSES_EXPORT(WINDOW *) +NCURSES_PUBLIC_VAR(stdscr) (void) +{ + return CURRENT_SCREEN ? StdScreen(CURRENT_SCREEN) : NULL; +} +NCURSES_EXPORT(WINDOW *) +NCURSES_PUBLIC_VAR(curscr) (void) +{ + return CURRENT_SCREEN ? CurScreen(CURRENT_SCREEN) : NULL; +} +NCURSES_EXPORT(WINDOW *) +NCURSES_PUBLIC_VAR(newscr) (void) +{ + return CURRENT_SCREEN ? NewScreen(CURRENT_SCREEN) : NULL; +} +#else +NCURSES_EXPORT_VAR(WINDOW *) stdscr = NULL; +NCURSES_EXPORT_VAR(WINDOW *) curscr = NULL; +NCURSES_EXPORT_VAR(WINDOW *) newscr = NULL; +#endif + +NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = NULL; + +/* + * The variable 'SP' will be defined as a function on systems that cannot link + * data-only modules, since it is used in a lot of places within ncurses and we + * cannot guarantee that any application will use any particular function. We + * put the WINDOW variables in this module, because it appears that any + * application that uses them will also use 'SP'. + * + * This module intentionally does not reference other ncurses modules, to avoid + * module coupling that increases the size of the executable. + */ +#if BROKEN_LINKER +static SCREEN *my_screen; + +NCURSES_EXPORT(SCREEN *) +_nc_screen(void) +{ + return my_screen; +} + +NCURSES_EXPORT(int) +_nc_alloc_screen(void) +{ + my_screen = _nc_alloc_screen_sp(); + T(("_nc_alloc_screen_sp %p", my_screen)); + return (my_screen != NULL); +} + +NCURSES_EXPORT(void) +_nc_set_screen(SCREEN *sp) +{ + my_screen = sp; +} + +#else + +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_sigtstp */ + 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 */ + NULL, /* tic_directory */ + + NULL, /* dbi_list */ + 0, /* dbi_size */ + + NULL, /* first_name */ + NULL, /* keyname_table */ + 0, /* init_keyname */ + + 0, /* slk_format */ + + 2048, /* getstr_limit */ + + NULL, /* safeprint_buf */ + 0, /* safeprint_used */ + + TGETENT_0s, /* tgetent_cache */ + 0, /* tgetent_index */ + 0, /* tgetent_sequence */ + 0, /* terminal_count */ + + NULL, /* dbd_blob */ + NULL, /* dbd_list */ + 0, /* dbd_size */ + 0, /* dbd_time */ + { { NULL, NULL } }, /* dbd_vars */ + +#if HAVE_TSEARCH + NULL, /* cached_tparm */ + 0, /* count_tparm */ +#endif /* HAVE_TSEARCH */ + +#if USE_TERM_DRIVER + NULL, /* term_driver */ +#endif + +#ifndef USE_SP_WINDOWLIST + 0, /* _nc_windowlist */ +#endif + +#if USE_HOME_TERMINFO + NULL, /* home_terminfo */ +#endif + +#if !USE_SAFE_SPRINTF + 0, /* safeprint_cols */ + 0, /* safeprint_rows */ +#endif + +#ifdef USE_PTHREADS + PTHREAD_MUTEX_INITIALIZER, /* mutex_curses */ + PTHREAD_MUTEX_INITIALIZER, /* mutex_prescreen */ + PTHREAD_MUTEX_INITIALIZER, /* mutex_screen */ + PTHREAD_MUTEX_INITIALIZER, /* mutex_update */ + PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */ + PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */ + 0, /* nested_tracef */ + 0, /* use_pthreads */ +#if USE_PTHREADS_EINTR + (pthread_t) 0, /* read_thread */ +#endif +#endif +#if USE_WIDEC_SUPPORT + CHARS_0s, /* key_name */ +#endif +#ifdef TRACE + FALSE, /* trace_opened */ + 0, /* trace_level */ + NULL, /* trace_fp */ + -1, /* trace_fd */ + + 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 */ +#if !defined(USE_PTHREADS) && USE_REENTRANT + 0, /* nested_tracef */ +#endif +#endif /* TRACE */ +#if NO_LEAKS + FALSE, /* leak_checking */ +#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 { NULL,0,NULL } +#define RIPOFF_0s { RIPOFF_0 } + +NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { + NULL, /* allocated */ + TRUE, /* use_env */ + FALSE, /* filter_mode */ + A_NORMAL, /* previous_attr */ + { /* tparm_state */ + 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, /* static_vars */ +#ifdef TRACE + NULL, /* tname */ +#endif + }, + NULL, /* saved_tty */ + FALSE, /* use_tioctl */ + NULL, /* _outch */ +#ifndef USE_SP_RIPOFF + RIPOFF_0s, /* ripoff */ + NULL, /* rsp */ +#endif +#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 */ + 8, /* TABSIZE */ + 1000, /* ESCDELAY */ + NULL, /* cur_term */ +#endif +#ifdef TRACE +#if BROKEN_LINKER || USE_REENTRANT + 0L, /* _outchars */ + NULL, /* _tputs_trace */ +#endif +#endif +}; +/* *INDENT-ON* */ + +/* + * 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 = NULL; + + if (win != NULL) { + sp = WINDOW_EXT(win, screen); + } + return (sp); +} + +/******************************************************************************/ +#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_prescreen); + _nc_mutex_init(&_nc_globals.mutex_screen); + _nc_mutex_init(&_nc_globals.mutex_update); + _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) +{ + int rc = 0; + if (_nc_use_pthreads != 0) + rc = pthread_mutex_lock(obj); + return rc; +} + +NCURSES_EXPORT(int) +_nc_mutex_trylock(pthread_mutex_t * obj) +{ + int rc = 0; + if (_nc_use_pthreads != 0) + rc = pthread_mutex_trylock(obj); + return rc; +} + +NCURSES_EXPORT(int) +_nc_mutex_unlock(pthread_mutex_t * obj) +{ + int rc = 0; + if (_nc_use_pthreads != 0) + rc = pthread_mutex_unlock(obj); + return rc; +} +#endif /* USE_PTHREADS */ + +#if defined(USE_PTHREADS) || USE_PTHREADS_EINTR +#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/ncurses/ncurses/tinfo/lib_has_cap.c b/ncurses/ncurses/tinfo/lib_has_cap.c new file mode 100644 index 0000000000..c8e983bd2d --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_has_cap.c @@ -0,0 +1,98 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2009,2013 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-2003 * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_has_cap.c +** +** The routines to query terminal capabilities +** +*/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_has_cap.c,v 1.12 2024/11/23 19:17:15 tom Exp $") + +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0) +{ + bool code = FALSE; + + T((T_CALLED("has_ic(%p)"), (void *) SP_PARM)); + + if (HasTInfoTerminal(SP_PARM)) { + code = ((insert_character || parm_ich + || (enter_insert_mode && exit_insert_mode)) + && (delete_character || parm_dch)) ? TRUE : FALSE; + } + + returnBool(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +has_ic(void) +{ + return NCURSES_SP_NAME(has_ic) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(bool) +NCURSES_SP_NAME(has_il) (NCURSES_SP_DCL0) +{ + bool code = FALSE; + T((T_CALLED("has_il(%p)"), (void *) SP_PARM)); + if (HasTInfoTerminal(SP_PARM)) { + code = ((insert_line || parm_insert_line) + && (delete_line || parm_delete_line)) ? TRUE : FALSE; + } + + returnBool(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +has_il(void) +{ + return NCURSES_SP_NAME(has_il) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_kernel.c b/ncurses/ncurses/tinfo/lib_kernel.c new file mode 100644 index 0000000000..f55ce43c21 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_kernel.c @@ -0,0 +1,204 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 2002 * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * lib_kernel.c + * + * Misc. low-level routines: + * erasechar() + * killchar() + * flushinp() + * + * The baudrate() and delay_output() functions could logically live here, + * but are in other modules to reduce the static-link size of programs + * that use only these facilities. + */ + +#include + +MODULE_ID("$Id: lib_kernel.c,v 1.40 2025/12/23 09:09:50 tom Exp $") + +#ifdef TERMIOS +static int +_nc_vdisable(void) +{ + int value = -1; +#if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H + value = _POSIX_VDISABLE; +#endif +#if defined(_PC_VDISABLE) && HAVE_FPATHCONF + if (value == -1) { + value = (int) fpathconf(0, _PC_VDISABLE); + if (value == -1) { + value = 0377; + } + } +#elif defined(VDISABLE) + if (value == -1) + value = VDISABLE; +#endif + return value; +} +#endif /* TERMIOS */ + +/* + * erasechar() + * + * Return erase character as given in cur_term->Ottyb. + * + */ + +NCURSES_EXPORT(char) +NCURSES_SP_NAME(erasechar) (NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("erasechar(%p)"), (void *) SP_PARM)); + + if (termp != NULL) { +#ifdef TERMIOS + result = termp->Ottyb.c_cc[VERASE]; + if (result == _nc_vdisable()) + result = ERR; +#elif defined(USE_WIN32CON_DRIVER) + result = ERR; +#else + result = termp->Ottyb.sg_erase; +#endif + } + returnChar((char) result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char) +erasechar(void) +{ + return NCURSES_SP_NAME(erasechar) (CURRENT_SCREEN); +} +#endif + +/* + * killchar() + * + * Return kill character as given in cur_term->Ottyb. + * + */ + +NCURSES_EXPORT(char) +NCURSES_SP_NAME(killchar) (NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("killchar(%p)"), (void *) SP_PARM)); + + if (termp != NULL) { +#ifdef TERMIOS + result = termp->Ottyb.c_cc[VKILL]; + if (result == _nc_vdisable()) + result = ERR; +#elif defined(USE_WIN32CON_DRIVER) + result = ERR; +#else + result = termp->Ottyb.sg_kill; +#endif + } + returnChar((char) result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char) +killchar(void) +{ + return NCURSES_SP_NAME(killchar) (CURRENT_SCREEN); +} +#endif + +static void +flush_input(int fd) +{ +#if defined(TERMIOS) + tcflush(fd, TCIFLUSH); +#else /* !TERMIOS */ + errno = 0; + do { +#if defined(USE_WIN32CON_DRIVER) + _nc_console_flush(_nc_console_fd2handle(fd)); +#else + ioctl(fd, TIOCFLUSH, 0); +#endif + } while + (errno == EINTR); +#endif +} + +/* + * flushinp() + * + * Flush any input on tty + */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0) +{ + T((T_CALLED("flushinp(%p)"), (void *) SP_PARM)); + + if (SP_PARM != NULL) { + if (NC_ISATTY(SP_PARM->_ifd)) + flush_input(SP_PARM->_ifd); + else if (NC_ISATTY(SP_PARM->_ofd)) + flush_input(SP_PARM->_ofd); + if (SP_PARM) { + SP_PARM->_fifohead = -1; + SP_PARM->_fifotail = 0; + SP_PARM->_fifopeek = 0; + } + returnCode(OK); + } + returnCode(ERR); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +flushinp(void) +{ + return NCURSES_SP_NAME(flushinp) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_longname.c b/ncurses/ncurses/tinfo/lib_longname.c new file mode 100644 index 0000000000..97cf55ac06 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_longname.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 1998-2010,2015 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_longname.c +** +** The routine longname(). +** +*/ + +#include + +MODULE_ID("$Id: lib_longname.c,v 1.15 2021/04/03 22:36:21 tom Exp $") + +#if USE_REENTRANT +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0) +{ + static char empty[] = + {'\0'}; + + T((T_CALLED("longname(%p)"), (void *) SP_PARM)); + + if (SP_PARM) { + char *ptr; + + for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype); + ptr > SP_PARM->_ttytype; + ptr--) + if (*ptr == '|') + returnPtr(ptr + 1); + returnPtr(SP_PARM->_ttytype); + } + return empty; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +longname(void) +{ + return NCURSES_SP_NAME(longname) (CURRENT_SCREEN); +} +#endif + +#else + +/* a dummy entrypoint is simpler than generating a conditional in curses.h */ +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0) +{ + (void) SP_PARM; + return longname(); +} +#endif + +NCURSES_EXPORT(char *) +longname(void) +{ + char *ptr; + + T((T_CALLED("longname()"))); + + for (ptr = ttytype + strlen(ttytype); + ptr > ttytype; + ptr--) + if (*ptr == '|') + returnPtr(ptr + 1); + returnPtr(ttytype); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_napms.c b/ncurses/ncurses/tinfo/lib_napms.c new file mode 100644 index 0000000000..7acf27b48f --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_napms.c @@ -0,0 +1,100 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * lib_napms.c + * + * The routine napms. + * + * (This file was originally written by Eric Raymond; however except for + * comments, none of the original code remains - T.Dickey). + */ + +#include + +#if HAVE_NANOSLEEP +#include +#if HAVE_SYS_TIME_H +#include /* needed for MacOS X DP3 */ +#endif +#endif + +MODULE_ID("$Id: lib_napms.c,v 1.33 2025/12/27 12:33:34 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms) +{ + T((T_CALLED("napms(%d)"), ms)); + + if (ms > MAX_DELAY_MSECS) + ms = MAX_DELAY_MSECS; + +#if USE_TERM_DRIVER + CallDriver_1(SP_PARM, td_nap, ms); +#else /* !USE_TERM_DRIVER */ +#if NCURSES_SP_FUNCS + (void) sp; +#endif +#if HAVE_NANOSLEEP + { + struct timespec request, remaining; + request.tv_sec = ms / 1000; + request.tv_nsec = (ms % 1000) * 1000000; + while (nanosleep(&request, &remaining) == -1 + && errno == EINTR) { + request = remaining; + } + } +#elif defined(USE_WIN32CON_DRIVER) + Sleep((DWORD) ms); +#else + _nc_timed_wait(NULL, 0, ms, (int *) 0 EVENTLIST_2nd(NULL)); +#endif +#endif /* !USE_TERM_DRIVER */ + + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +napms(int ms) +{ + return NCURSES_SP_NAME(napms) (CURRENT_SCREEN, ms); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_options.c b/ncurses/ncurses/tinfo/lib_options.c new file mode 100644 index 0000000000..0664ed2073 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_options.c @@ -0,0 +1,381 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_options.c +** +** The routines to handle option setting. +** +*/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_options.c,v 1.86 2025/12/27 12:41:23 tom Exp $") + +NCURSES_EXPORT(int) +idlok(WINDOW *win, bool flag) +{ + int res = ERR; + T((T_CALLED("idlok(%p,%d)"), (void *) win, flag)); + + if (win) { + SCREEN *sp = _nc_screen_of(win); + if (sp != NULL +#if USE_TERM_DRIVER + && IsTermInfo(sp) +#endif + ) { + sp->_nc_sp_idlok = + win->_idlok = (flag && (NCURSES_SP_NAME(has_il) (NCURSES_SP_ARG) + || change_scroll_region)); + res = OK; + } + } + returnCode(res); +} + +NCURSES_EXPORT(void) +idcok(WINDOW *win, bool flag) +{ + T((T_CALLED("idcok(%p,%d)"), (void *) win, flag)); + + if (win) { + SCREEN *sp = _nc_screen_of(win); + sp->_nc_sp_idcok = win->_idcok = (flag && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)); + } + returnVoid; +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t) +{ + T((T_CALLED("halfdelay(%p,%d)"), (void *) SP_PARM, t)); + + if (t < 1 || t > 255 || !SP_PARM || !IsValidTIScreen(SP_PARM)) + returnCode(ERR); + + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); + IsCbreak(SP_PARM) = t + 1; + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +halfdelay(int t) +{ + return NCURSES_SP_NAME(halfdelay) (CURRENT_SCREEN, t); +} +#endif + +NCURSES_EXPORT(int) +nodelay(WINDOW *win, bool flag) +{ + T((T_CALLED("nodelay(%p,%d)"), (void *) win, flag)); + + if (win) { + if (flag == TRUE) + win->_delay = 0; + else + win->_delay = -1; + returnCode(OK); + } else + returnCode(ERR); +} + +NCURSES_EXPORT(int) +notimeout(WINDOW *win, bool f) +{ + T((T_CALLED("notimeout(%p,%d)"), (void *) win, f)); + + if (win) { + win->_notimeout = f; + returnCode(OK); + } else + returnCode(ERR); +} + +NCURSES_EXPORT(void) +wtimeout(WINDOW *win, int delay) +{ + T((T_CALLED("wtimeout(%p,%d)"), (void *) win, delay)); + + if (win) { + win->_delay = delay; + } + returnVoid; +} + +NCURSES_EXPORT(int) +keypad(WINDOW *win, bool flag) +{ + T((T_CALLED("keypad(%p,%d)"), (void *) win, flag)); + + if (win) { + win->_use_keypad = flag; + returnCode(_nc_keypad(_nc_screen_of(win), flag)); + } else + returnCode(ERR); +} + +NCURSES_EXPORT(int) +meta(WINDOW *win GCC_UNUSED, bool flag) +{ + int result = ERR; + SCREEN *sp = (win == NULL) ? CURRENT_SCREEN : _nc_screen_of(win); + + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + T((T_CALLED("meta(%p,%d)"), (void *) win, flag)); + + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + + if (sp != NULL) { + sp->_use_meta = flag; +#if USE_TERM_DRIVER + if (IsTermInfo(sp)) { + if (flag) { + NCURSES_PUTP2("meta_on", meta_on); + } else { + NCURSES_PUTP2("meta_off", meta_off); + } + } +#else + if (flag) { + NCURSES_PUTP2("meta_on", meta_on); + } else { + NCURSES_PUTP2("meta_off", meta_off); + } +#endif + result = OK; + } + returnCode(result); +} + +/* curs_set() moved here to narrow the kernel interface */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis) +{ + int code = ERR; + T((T_CALLED("curs_set(%p,%d)"), (void *) SP_PARM, vis)); + + if (SP_PARM != NULL && vis >= 0 && vis <= 2) { + int cursor = SP_PARM->_cursor; + if (vis == cursor) { + code = cursor; + } else { +#if USE_TERM_DRIVER + code = CallDriver_1(SP_PARM, td_cursorSet, vis); +#else + if (IsValidTIScreen(SP_PARM)) { + switch (vis) { + case 2: + code = NCURSES_PUTP2_FLUSH("cursor_visible", + cursor_visible); + break; + case 1: + code = NCURSES_PUTP2_FLUSH("cursor_normal", + cursor_normal); + break; + case 0: + code = NCURSES_PUTP2_FLUSH("cursor_invisible", + cursor_invisible); + break; + } + } else { + code = ERR; + } +#endif + if (code != ERR) + code = (cursor == -1 ? 1 : cursor); + SP_PARM->_cursor = vis; + } + } + returnCode(code); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +curs_set(int vis) +{ + return (NCURSES_SP_NAME(curs_set) (CURRENT_SCREEN, vis)); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd) +{ + T((T_CALLED("typeahead(%p, %d)"), (void *) SP_PARM, fd)); + if (SP_PARM && IsValidTIScreen(SP_PARM)) { + SP_PARM->_checkfd = fd; + returnCode(OK); + } else { + returnCode(ERR); + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +typeahead(int fd) +{ + return NCURSES_SP_NAME(typeahead) (CURRENT_SCREEN, fd); +} +#endif + +/* +** has_key() +** +** Return TRUE if the current terminal has the given key +** +*/ + +#if NCURSES_EXT_FUNCS +static int +has_key_internal(int keycode, TRIES * tp) +{ + if (tp == NULL) + return (FALSE); + else if (tp->value == keycode) + return (TRUE); + else + return (has_key_internal(keycode, tp->child) + || has_key_internal(keycode, tp->sibling)); +} + +#if USE_TERM_DRIVER +NCURSES_EXPORT(int) +TINFO_HAS_KEY(SCREEN *sp, int keycode) +{ + return IsValidTIScreen(sp) ? + has_key_internal(keycode, sp->_keytry) : 0; +} +#else +NCURSES_EXPORT(int) +NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode) +{ + T((T_CALLED("has_key(%p,%d)"), (void *) SP_PARM, keycode)); + returnCode(SP != NULL ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +has_key(int keycode) +{ + return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode); +} +#endif +#endif +#endif /* NCURSES_EXT_FUNCS */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_DCLx + const char *name, const char *value) +{ + int rc = NCURSES_PUTP2(name, value); + if (rc != ERR) { + _nc_flush(); + } + return rc; +} + +#if 0 && NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_putp_flush(const char *name, const char *value) +{ + return NCURSES_SP_NAME(_nc_putp_flush) (CURRENT_SCREEN, name, value); +} +#endif + +/* Turn the keypad on/off + * + * Note: we flush the output because changing this mode causes some terminals + * to emit different escape sequences for cursor and keypad keys. If we don't + * flush, then the next wgetch may get the escape sequence that corresponds to + * the terminal state _before_ switching modes. + */ +NCURSES_EXPORT(int) +_nc_keypad(SCREEN *sp, bool flag) +{ + int rc = ERR; + + if (sp != NULL) { +#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 != CURRENT_SCREEN) { + SCREEN *save_sp; + + /* cannot use use_screen(), since that is not in tinfo library */ + _nc_lock_global(curses); + save_sp = CURRENT_SCREEN; + _nc_set_screen(sp); + rc = _nc_keypad(sp, flag); + _nc_set_screen(save_sp); + _nc_unlock_global(curses); + } else +#endif + { +#if USE_TERM_DRIVER + rc = CallDriver_1(sp, td_kpad, flag); + if (rc == OK) + sp->_keypad_on = flag; +#else + if (flag) { + (void) NCURSES_PUTP2_FLUSH("keypad_xmit", keypad_xmit); + } else if (keypad_local) { + (void) NCURSES_PUTP2_FLUSH("keypad_local", keypad_local); + } + + if (flag && !sp->_tried) { + _nc_init_keytry(sp); + sp->_tried = TRUE; + } + sp->_keypad_on = flag; + rc = OK; +#endif + } + } + return (rc); +} diff --git a/ncurses/ncurses/tinfo/lib_print.c b/ncurses/ncurses/tinfo/lib_print.c new file mode 100644 index 0000000000..d308905080 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_print.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2011,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + ****************************************************************************/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_print.c,v 1.35 2025/12/27 12:41:23 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) +/* ship binary character data to the printer via mc4/mc5/mc5p */ +{ + int result; + char *mybuf = NULL; + const char *switchon; + size_t onsize, offsize; + size_t need; + + errno = 0; + if (!HasTInfoTerminal(SP_PARM) + || len <= 0 + || (!prtr_non && (!prtr_on || !prtr_off))) { + errno = ENODEV; + return (ERR); + } + + if (prtr_non) { + switchon = TIPARM_1(prtr_non, len); + onsize = strlen(switchon); + offsize = 0; + } else { + switchon = prtr_on; + onsize = strlen(prtr_on); + offsize = strlen(prtr_off); + } + + need = onsize + (size_t) len + offsize; + + if (switchon == NULL + || (mybuf = typeMalloc(char, need + 1)) == NULL) { + free(mybuf); + errno = ENOMEM; + return (ERR); + } + + _nc_STRCPY(mybuf, switchon, need); + memcpy(mybuf + onsize, data, (size_t) len); + if (offsize) + _nc_STRCPY(mybuf + onsize + len, prtr_off, need); + + /* + * We're relying on the atomicity of UNIX writes here. The + * danger is that output from a refresh() might get interspersed + * with the printer data after the write call returns but before the + * data has actually been shipped to the terminal. If the write(2) + * operation is truly atomic we're protected from this. + */ + result = (int) write(SP_PARM->_ofd, mybuf, need); + + /* + * By giving up our scheduler slot here we increase the odds that the + * kernel will ship the contiguous clist items from the last write + * immediately. + */ +#ifndef _NC_WINDOWS_NATIVE + (void) sleep(0); +#endif + free(mybuf); + return (result); +} + +#if NCURSES_SP_FUNCS && !USE_TERM_DRIVER +NCURSES_EXPORT(int) +mcprint(char *data, int len) +{ + return NCURSES_SP_NAME(mcprint) (CURRENT_SCREEN, data, len); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_raw.c b/ncurses/ncurses/tinfo/lib_raw.c new file mode 100644 index 0000000000..dfa37f5ccf --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_raw.c @@ -0,0 +1,433 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1998-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * raw.c + * + * Routines: + * raw() + * cbreak() + * noraw() + * nocbreak() + * qiflush() + * noqiflush() + * intrflush() + * + */ + +#include + +MODULE_ID("$Id: lib_raw.c,v 1.35 2025/12/23 09:22:35 tom Exp $") + +#if HAVE_SYS_TERMIO_H +#include /* needed for ISC */ +#endif + +#ifdef __EMX__ +#define _nc_setmode(mode) setmode(SP_PARM->_ifd, mode) +#else +#define _nc_setmode(mode) /* nothing */ +#endif + +#if USE_KLIBC_KBD +#define INCL_KBD +#include +#endif + +#define COOKED_INPUT (IXON|BRKINT|PARMRK) + +#ifdef TRACE +#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) +#endif /* TRACE */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *termp; + + T((T_CALLED("raw(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + + BEFORE("raw"); + _nc_setmode(O_BINARY); + + buf = termp->Nttyb; +#ifdef TERMIOS + buf.c_lflag &= (unsigned) ~(ICANON | ISIG | IEXTEN); + buf.c_iflag &= (unsigned) ~(COOKED_INPUT); + buf.c_cc[VMIN] = 1; + buf.c_cc[VTIME] = 0; +#elif defined(USE_WIN32CON_DRIVER) + buf.dwFlagIn &= (unsigned long) ~CONMODE_NORAW; +#else + buf.sg_flags |= RAW; +#endif + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { +#if USE_KLIBC_KBD + KBDINFO kbdinfo; + + kbdinfo.cb = sizeof(kbdinfo); + KbdGetStatus(&kbdinfo, 0); + + kbdinfo.cb = sizeof(kbdinfo); + kbdinfo.fsMask &= ~KEYBOARD_ASCII_MODE; + kbdinfo.fsMask |= KEYBOARD_BINARY_MODE; + KbdSetStatus(&kbdinfo, 0); +#endif + if (SP_PARM) { + IsRaw(SP_PARM) = TRUE; + IsCbreak(SP_PARM) = 1; + } + termp->Nttyb = buf; + } + AFTER("raw"); + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +raw(void) +{ + return NCURSES_SP_NAME(raw) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *termp; + + T((T_CALLED("cbreak(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + + BEFORE("cbreak"); + _nc_setmode(O_BINARY); + + buf = termp->Nttyb; +#ifdef TERMIOS + buf.c_lflag &= (unsigned) ~ICANON; + buf.c_iflag &= (unsigned) ~ICRNL; + buf.c_cc[VMIN] = 1; + buf.c_cc[VTIME] = 0; +#elif defined(USE_WIN32CON_DRIVER) + buf.dwFlagIn |= CONMODE_NORAW; + buf.dwFlagIn &= (unsigned long) ~CONMODE_NOCBREAK; +#else + buf.sg_flags |= CBREAK; +#endif + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { + if (SP_PARM) { + IsCbreak(SP_PARM) = 1; + } + termp->Nttyb = buf; + } + AFTER("cbreak"); + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +cbreak(void) +{ + return NCURSES_SP_NAME(cbreak) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(qiflush) (NCURSES_SP_DCL0) +{ + TERMINAL *termp; + + T((T_CALLED("qiflush(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + int result; + + BEFORE("qiflush"); + buf = termp->Nttyb; +#ifdef TERMIOS + buf.c_lflag &= (unsigned) ~(NOFLSH); + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); +#else + result = ERR; + /* FIXME */ +#endif + if (result == OK) + termp->Nttyb = buf; + AFTER("qiflush"); + } + returnVoid; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +qiflush(void) +{ + NCURSES_SP_NAME(qiflush) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *termp; + + T((T_CALLED("noraw(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + + BEFORE("noraw"); + _nc_setmode(O_TEXT); + + buf = termp->Nttyb; +#ifdef TERMIOS + buf.c_lflag |= ISIG | ICANON | + (termp->Ottyb.c_lflag & IEXTEN); + buf.c_iflag |= COOKED_INPUT; +#elif defined(USE_WIN32CON_DRIVER) + buf.dwFlagIn |= CONMODE_NORAW; +#else + buf.sg_flags &= ~(RAW | CBREAK); +#endif + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { +#if USE_KLIBC_KBD + KBDINFO kbdinfo; + + kbdinfo.cb = sizeof(kbdinfo); + KbdGetStatus(&kbdinfo, 0); + + kbdinfo.cb = sizeof(kbdinfo); + kbdinfo.fsMask &= ~KEYBOARD_BINARY_MODE; + kbdinfo.fsMask |= KEYBOARD_ASCII_MODE; + KbdSetStatus(&kbdinfo, 0); +#endif + if (SP_PARM) { + IsRaw(SP_PARM) = FALSE; + IsCbreak(SP_PARM) = 0; + } + termp->Nttyb = buf; + } + AFTER("noraw"); + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +noraw(void) +{ + return NCURSES_SP_NAME(noraw) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0) +{ + int result = ERR; + TERMINAL *termp; + + T((T_CALLED("nocbreak(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + + BEFORE("nocbreak"); + _nc_setmode(O_TEXT); + + buf = termp->Nttyb; +#ifdef TERMIOS + buf.c_lflag |= ICANON; + buf.c_iflag |= ICRNL; +#elif defined(USE_WIN32CON_DRIVER) + buf.dwFlagIn |= (CONMODE_NOCBREAK | CONMODE_NORAW); +#else + buf.sg_flags &= ~CBREAK; +#endif + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { + if (SP_PARM) { + IsCbreak(SP_PARM) = 0; + } + termp->Nttyb = buf; + } + AFTER("nocbreak"); + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +nocbreak(void) +{ + return NCURSES_SP_NAME(nocbreak) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0) +{ + TERMINAL *termp; + + T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + int result; + + BEFORE("noqiflush"); + buf = termp->Nttyb; +#ifdef TERMIOS + buf.c_lflag |= NOFLSH; + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); +#else + /* FIXME */ + result = ERR; +#endif + if (result == OK) + termp->Nttyb = buf; + AFTER("noqiflush"); + } + returnVoid; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +noqiflush(void) +{ + NCURSES_SP_NAME(noqiflush) (CURRENT_SCREEN); +} +#endif + +/* + * This call does the same thing as the qiflush()/noqiflush() pair. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(intrflush) (NCURSES_SP_DCLx WINDOW *win GCC_UNUSED, bool flag) +{ + int result = ERR; + TERMINAL *termp; + + T((T_CALLED("intrflush(%p,%d)"), (void *) SP_PARM, flag)); + if (SP_PARM == NULL) + returnCode(ERR); + + if ((termp = TerminalOf(SP_PARM)) != NULL) { + TTY buf; + + BEFORE("intrflush"); + buf = termp->Nttyb; +#ifdef TERMIOS + if (flag) + buf.c_lflag &= (unsigned) ~(NOFLSH); + else + buf.c_lflag |= (NOFLSH); + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); +#else + /* FIXME */ +#endif + if (result == OK) { + termp->Nttyb = buf; + } + AFTER("intrflush"); + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +intrflush(WINDOW *win GCC_UNUSED, bool flag) +{ + return NCURSES_SP_NAME(intrflush) (CURRENT_SCREEN, win, flag); +} +#endif + +#if NCURSES_EXT_FUNCS +/* *INDENT-OFF* */ + +/* + * SCREEN is always opaque, but nl/raw/cbreak/echo set properties in it. + * As an extension, provide a way to query the properties. + * + * There are other properties which could be queried, e.g., filter, keypad, + * use_env, use_meta, but these particular properties are saved/restored within + * the wgetnstr() and wgetn_wstr() functions, which requires that the higher + * level curses library knows about the internal state of the lower level + * terminfo library. + */ + +#define is_TEST(show,what) \ + NCURSES_EXPORT(int) \ + NCURSES_SP_NAME(show) (NCURSES_SP_DCL0) \ + { \ + return ((SP_PARM != NULL) ? (what(SP_PARM) ? 1 : 0) : -1); \ + } + +is_TEST(is_nl, IsNl) +is_TEST(is_raw, IsRaw) +is_TEST(is_cbreak, IsCbreak) +is_TEST(is_echo, IsEcho) + +#if NCURSES_SP_FUNCS +#undef is_TEST +#define is_TEST(show) \ + NCURSES_EXPORT(int) \ + show(void) \ + { \ + return NCURSES_SP_NAME(show) (CURRENT_SCREEN); \ + } +is_TEST(is_nl) +is_TEST(is_raw) +is_TEST(is_cbreak) +is_TEST(is_echo) +#endif + +/* *INDENT-ON* */ +#endif /* extensions */ diff --git a/ncurses/ncurses/tinfo/lib_setup.c b/ncurses/ncurses/tinfo/lib_setup.c new file mode 100644 index 0000000000..a9c3a93547 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_setup.c @@ -0,0 +1,1214 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * Terminal setup routines common to termcap and terminfo: + * + * use_env(bool) + * use_tioctl(bool) + * setupterm(char *, int, int *) + */ + +#include +#include /* for MAX_NAME_SIZE */ + +#if HAVE_LOCALE_H +#include +#endif + +MODULE_ID("$Id: lib_setup.c,v 1.252 2025/12/27 12:33:34 tom Exp $") + +/**************************************************************************** + * + * Terminal size computation + * + ****************************************************************************/ + +#if HAVE_SIZECHANGE +# if !defined(sun) || !TERMIOS +# if HAVE_SYS_IOCTL_H +# include +# endif +# endif +#endif + +#if NEED_PTEM_H + /* On SCO, they neglected to define struct winsize in termios.h -- it is only + * in termio.h and ptem.h (the former conflicts with other definitions). + */ +# include +# include +#endif + +#if HAVE_LANGINFO_CODESET +#include +#endif + +/* + * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, + * Solaris, IRIX) define TIOCGWINSZ and struct winsize. + */ +#ifdef TIOCGSIZE +# define IOCTL_WINSIZE TIOCGSIZE +# define STRUCT_WINSIZE struct ttysize +# define WINSIZE_ROWS(n) (int)n.ts_lines +# define WINSIZE_COLS(n) (int)n.ts_cols +#else +# ifdef TIOCGWINSZ +# define IOCTL_WINSIZE TIOCGWINSZ +# define STRUCT_WINSIZE struct winsize +# define WINSIZE_ROWS(n) (int)n.ws_row +# define WINSIZE_COLS(n) (int)n.ws_col +# endif +#endif + +/* + * Reduce explicit use of "cur_term" global variable. + */ +#undef CUR +#define CUR TerminalType(termp). + +/* + * Wrap global variables in this module. + */ +#if USE_REENTRANT + +NCURSES_EXPORT(char *) +NCURSES_PUBLIC_VAR(ttytype) (void) +{ + static char empty[] = ""; + char *result = empty; + +#if NCURSES_SP_FUNCS + if (CURRENT_SCREEN) { + TERMINAL *termp = TerminalOf(CURRENT_SCREEN); + if (termp != NULL) { + result = TerminalType(termp).term_names; + } + } +#else + if (cur_term != NULL) { + result = TerminalType(cur_term).term_names; + } +#endif + return result; +} + +NCURSES_EXPORT(int *) +_nc_ptr_Lines(SCREEN *sp) +{ + return ptrLines(sp); +} + +NCURSES_EXPORT(int) +NCURSES_PUBLIC_VAR(LINES) (void) +{ + return *_nc_ptr_Lines(CURRENT_SCREEN); +} + +NCURSES_EXPORT(int *) +_nc_ptr_Cols(SCREEN *sp) +{ + return ptrCols(sp); +} + +NCURSES_EXPORT(int) +NCURSES_PUBLIC_VAR(COLS) (void) +{ + return *_nc_ptr_Cols(CURRENT_SCREEN); +} + +NCURSES_EXPORT(int *) +_nc_ptr_Tabsize(SCREEN *sp) +{ + return ptrTabsize(sp); +} + +NCURSES_EXPORT(int) +NCURSES_PUBLIC_VAR(TABSIZE) (void) +{ + return *_nc_ptr_Tabsize(CURRENT_SCREEN); +} +#else +NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = ""; +NCURSES_EXPORT_VAR(int) LINES = 0; +NCURSES_EXPORT_VAR(int) COLS = 0; +NCURSES_EXPORT_VAR(int) TABSIZE = 8; +#endif + +#if NCURSES_EXT_FUNCS +NCURSES_EXPORT(int) +NCURSES_SP_NAME(set_tabsize) (NCURSES_SP_DCLx int value) +{ + int code = OK; + if (value <= 0) { + code = ERR; + } else { +#if USE_REENTRANT + if (SP_PARM) { + SP_PARM->_TABSIZE = value; + } else { + code = ERR; + } +#else + (void) SP_PARM; + TABSIZE = value; +#endif + } + return code; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +set_tabsize(int value) +{ + return NCURSES_SP_NAME(set_tabsize) (CURRENT_SCREEN, value); +} +#endif +#endif /* NCURSES_EXT_FUNCS */ + +#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; + + 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) +NCURSES_SP_NAME(use_env) (NCURSES_SP_DCLx bool f) +{ + START_TRACE(); + T((T_CALLED("use_env(%p,%d)"), (void *) SP_PARM, (int) f)); +#if NCURSES_SP_FUNCS + if (IsPreScreen(SP_PARM)) { + SP_PARM->_use_env = f; + } +#else + _nc_prescreen.use_env = f; +#endif + returnVoid; +} + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(use_tioctl) (NCURSES_SP_DCLx bool f) +{ + START_TRACE(); + T((T_CALLED("use_tioctl(%p,%d)"), (void *) SP_PARM, (int) f)); +#if NCURSES_SP_FUNCS + if (IsPreScreen(SP_PARM)) { + SP_PARM->use_tioctl = f; + } +#else + _nc_prescreen.use_tioctl = f; +#endif + returnVoid; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +use_env(bool f) +{ + START_TRACE(); + T((T_CALLED("use_env(%d)"), (int) f)); + _nc_prescreen.use_env = f; + returnVoid; +} + +NCURSES_EXPORT(void) +use_tioctl(bool f) +{ + START_TRACE(); + T((T_CALLED("use_tioctl(%d)"), (int) f)); + _nc_prescreen.use_tioctl = f; + returnVoid; +} +#endif + +#if !(USE_TERM_DRIVER || USE_NAMED_PIPES) +static void +_nc_default_screensize(TERMINAL *termp, int *linep, int *colp) +{ + /* if we can't get dynamic info about the size, use static */ + if (*linep <= 0) { + *linep = (int) lines; + } + if (*colp <= 0) { + *colp = (int) columns; + } + + /* the ultimate fallback, assume fixed 24x80 size */ + if (*linep <= 0) { + *linep = 24; + } + if (*colp <= 0) { + *colp = 80; + } +} + +#if defined(USE_CHECK_SIZE) && defined(user6) && defined(user7) +static const char * +skip_csi(const char *value) +{ + if (UChar(*value) == CSI_CHR) { + ++value; + } else if (*value == ESC_CHR && value[1] == L_BLOCK) { + value += 2; + } + return value; +} + +static bool +is_expected(const char *value, const char *expected) +{ + bool result = FALSE; + if (VALID_STRING(value)) { + const char *skipped = skip_csi(value); + if (skipped != value) { + if (!strcmp(skipped, expected)) + result = TRUE; + } + } + return result; +} + +static bool +get_position(const TERMINAL *termp, int fd, int *row, int *col) +{ + bool result = FALSE; + size_t need = strlen(user7); + int have; + + have = (int) write(fd, user7, need); + + if (have == (int) need) { + int y, x; + char buf[20]; + char *s; + char cc; + const char *skipped; + + s = memset(buf, '\0', sizeof(buf)); + do { + size_t ask = (sizeof(buf) - 1 - (size_t) (s - buf)); + int got = (int) read(fd, s, ask); + if (got == 0) + break; + s += got; + *s = '\0'; + } while (strchr(buf, 'R') == NULL && (size_t) (s + 1 - buf) < sizeof(buf)); + T(("CPR response %s", _nc_visbuf(buf))); + skipped = skip_csi(buf); + cc = '\0'; + if (skipped != buf + && *skipped != '\0' + && sscanf(skip_csi(buf), "%d;%d%c", &y, &x, &cc) == 3 + && (cc == 'R')) { + *row = y; + *col = x; + result = TRUE; + } + } + T(("get_position %s %d,%d", result ? "OK" : "ERR", *row, *col)); + return result; +} + +static bool +set_position(NCURSES_SP_DCLx const TERMINAL *termp, int row, int col) +{ + bool result; + const char *actual = TIPARM_2(cursor_address, row, col); + T((T_CALLED("set_position %d,%d)"), row, col)); +#if NCURSES_SP_FUNCS + result = (NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "set_position", + actual) == OK); + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); +#else + /* This does not support padding because without sp-funcs, we have only + * the interface using stdio, but we are not guaranteed that Filedes + * is the same as fileno(stdout). + */ + result = FALSE; + if (actual != NULL) { + size_t want = strlen(actual); + int have = (int) write(termp->Filedes, actual, want); + result = ((int) want == have); + } +#endif + returnBool(result); +} + +/* + * This is a little more complicated than one might expect, because we do this + * before setting up the terminal modes, etc., and cannot use the timeout or + * buffering functions. + * + * We check if the terminal description has the ECMA-48 CPR (cursor position + * report) in u7 and the response in u6. The two variations of is_expected() + * cover the termcap style and terminfo style, and are equivalent as far as we + * are concerned. For analyzing the response, we wait (a short time) for 'R' + * to be echoed, and then check if we received two integers in the response. + * + * In principle, this could run on "any" ECMA-48 terminal, but in practice, + * there is a scenario using GNU screen where it uses ncurses with a partially + * configured pseudo-terminal, and the CPR response goes to the wrong place. + * So we do a simple check to exclude pseudo-terminals. + */ +static void +_nc_check_screensize(SCREEN *sp, TERMINAL *termp, int *linep, int *colp) +{ + int fd = termp->Filedes; + TTY saved; + const char *name = NULL; + + if (IsRealTty(fd, name) + && VALID_STRING(cursor_address) + && is_expected(user7, "6n") + && (is_expected(user6, "%i%d;%dR") || + is_expected(user6, "%i%p1%d;%p2%dR")) + && GET_TTY(fd, &saved) == OK) { + int current_y = -1, current_x = -1; + int updated_y = -1, updated_x = -1; + TTY alter = saved; + +#if NCURSES_SP_FUNCS + if (sp == NULL) { + sp = new_prescr(); + sp->_term = termp; + NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); + } +#else + (void) sp; +#endif + + T(("trying CPR (u7/u6) with %s", name)); + alter.c_lflag &= (unsigned) ~(ECHO | ICANON | ISIG | IEXTEN); + alter.c_iflag &= (unsigned) ~(IXON | BRKINT | PARMRK); + alter.c_cc[VMIN] = 0; + alter.c_cc[VTIME] = 1; + SET_TTY(fd, &alter); + + if (get_position(termp, fd, ¤t_y, ¤t_x) + && set_position(NCURSES_SP_ARGx termp, 9999, 9999) + && get_position(termp, fd, &updated_y, &updated_x)) { + *linep = updated_y; + *colp = updated_x; + set_position(NCURSES_SP_ARGx termp, current_y, current_x); + } + /* restore tty modes */ + SET_TTY(fd, &saved); + } else { + T(("NOT trying CPR with fd %d (%s): %s", + fd, NonNull(name), NC_ISATTY(fd) ? "tty" : "not a tty")); + } + + _nc_default_screensize(termp, linep, colp); +} +#else /* !USE_CHECK_SIZE */ +#define _nc_check_screensize(sp, termp, linep, colp) /* nothing */ +#endif +#endif /* !(USE_TERM_DRIVER || USE_NAMED_PIPES) */ + +NCURSES_EXPORT(void) +_nc_get_screensize(SCREEN *sp, +#if USE_TERM_DRIVER + TERMINAL *termp, +#endif + int *linep, int *colp) +/* Obtain lines/columns values from the environment and/or terminfo entry */ +{ +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB; + int my_tabsize; + + assert(termp != NULL && linep != NULL && colp != NULL); + TCB = (TERMINAL_CONTROL_BLOCK *) termp; + + my_tabsize = TCB->info.tabsize; + TCB->drv->td_size(TCB, linep, colp); + +#if USE_REENTRANT + if (sp != NULL) { + sp->_TABSIZE = my_tabsize; + } +#else + (void) sp; + TABSIZE = my_tabsize; +#endif + T(("TABSIZE = %d", my_tabsize)); +#else /* !USE_TERM_DRIVER */ + TERMINAL *termp = cur_term; + int my_tabsize; + bool useEnv = _nc_prescreen.use_env; + bool useTioctl = _nc_prescreen.use_tioctl; + + T((T_CALLED("_nc_get_screensize (%p)"), (void *) sp)); +#if USE_NAMED_PIPES + /* If we are here, then Windows console is used in terminfo mode. + We need to figure out the size using the console API + */ + _nc_console_size(linep, colp); + T(("screen size: winconsole lines = %d columns = %d", *linep, *colp)); +#else + /* figure out the size of the screen */ + T(("screen size: terminfo lines = %d columns = %d", lines, columns)); + + *linep = (int) lines; + *colp = (int) columns; +#endif + +#if NCURSES_SP_FUNCS + if (sp) { + useEnv = sp->_use_env; + useTioctl = sp->use_tioctl; + } +#endif + + T(("useEnv:%d useTioctl:%d", useEnv, useTioctl)); + if (useEnv || useTioctl) { +#ifdef __EMX__ + { + int screendata[2]; + _scrsize(screendata); + *colp = screendata[0]; + *linep = ((sp != 0 && sp->_filtered) + ? 1 + : screendata[1]); + T(("EMX screen size: environment LINES = %d COLUMNS = %d", + *linep, *colp)); + } +#endif +#if HAVE_SIZECHANGE + /* try asking the OS */ + if (NC_ISATTY(cur_term->Filedes)) { + STRUCT_WINSIZE size; + + errno = 0; + do { + if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) >= 0) { + *linep = ((sp != NULL && sp->_filtered) + ? 1 + : WINSIZE_ROWS(size)); + *colp = WINSIZE_COLS(size); + T(("SYS screen size: environment LINES = %d COLUMNS = %d", + *linep, *colp)); + break; + } + } while + (errno == EINTR); + } +#endif /* HAVE_SIZECHANGE */ + + if (useEnv) { + int value; + + if (useTioctl) { + /* + * If environment variables are used, update them. + */ + if ((sp == NULL || !sp->_filtered) && + _nc_getenv_num("LINES") > 0) { + _nc_setenv_num("LINES", *linep); + } + if (_nc_getenv_num("COLUMNS") > 0) { + _nc_setenv_num("COLUMNS", *colp); + } + } + + /* + * Finally, look for environment variables. + * + * Solaris lets users override either dimension with an environment + * variable. + */ + if ((value = _nc_getenv_num("LINES")) > 0) { + *linep = Min(value, MAX_ENV_LINES); + T(("screen size: environment LINES = %d", *linep)); + } + if ((value = _nc_getenv_num("COLUMNS")) > 0) { + *colp = Min(value, MAX_ENV_COLUMNS); + T(("screen size: environment COLUMNS = %d", *colp)); + } + + _nc_default_screensize(termp, linep, colp); + } else { + _nc_check_screensize(sp, termp, linep, colp); + } + + /* + * Put the derived values back in the screen-size caps, so + * tigetnum() and tgetnum() will do the right thing. + */ + lines = (NCURSES_INT2) (*linep); + columns = (NCURSES_INT2) (*colp); +#if NCURSES_EXT_NUMBERS +#define OldNumber(termp,name) \ + (termp)->type.Numbers[(&name - (termp)->type2.Numbers)] + OldNumber(termp, lines) = (short) (*linep); + OldNumber(termp, columns) = (short) (*colp); +#endif + } else { + _nc_check_screensize(sp, termp, linep, colp); + } + + T(("screen size is %dx%d", *linep, *colp)); + + if (VALID_NUMERIC(init_tabs)) + my_tabsize = (int) init_tabs; + else + my_tabsize = 8; + +#if USE_REENTRANT + if (sp != NULL) + sp->_TABSIZE = my_tabsize; +#else + TABSIZE = my_tabsize; +#endif + T(("TABSIZE = %d", TABSIZE)); + returnVoid; +#endif /* USE_TERM_DRIVER */ +} + +#if USE_SIZECHANGE +NCURSES_EXPORT(void) +_nc_update_screensize(SCREEN *sp) +{ + int new_lines; + int new_cols; + +#if USE_TERM_DRIVER + int old_lines; + int old_cols; + + assert(sp != NULL); + + CallDriver_2(sp, td_getsize, &old_lines, &old_cols); + +#else + TERMINAL *termp = cur_term; + int old_lines = lines; + int old_cols = columns; +#endif + + if (sp != NULL) { + TINFO_GET_SIZE(sp, sp->_term, &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->_resize != NULL) { + if ((new_lines != old_lines) || (new_cols != old_cols)) { + sp->_resize(NCURSES_SP_ARGx new_lines, new_cols); + } else if (sp->_sig_winch && (sp->_ungetch != NULL)) { + sp->_ungetch(SP_PARM, KEY_RESIZE); /* so application can know this */ + } + sp->_sig_winch = FALSE; + } + } +} +#endif /* USE_SIZECHANGE */ + +/**************************************************************************** + * + * Terminal setup + * + ****************************************************************************/ + +#if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP +/* + * Return 1 if entry found, 0 if not found, -1 if database not accessible, + * just like tgetent(). + */ +int +_nc_setup_tinfo(const char *const tn, TERMTYPE2 *const tp) +{ + char filename[PATH_MAX]; + int status = _nc_read_entry2(tn, filename, tp); + + /* + * If we have an entry, force all of the cancelled strings to null + * pointers so we don't have to test them in the rest of the library. + * (The terminfo compiler bypasses this logic, since it must know if + * a string is cancelled, for merging entries). + */ + if (status == TGETENT_YES) { + unsigned n; + T(("_nc_setup_tinfo - resetting invalid booleans/strings")); + for_each_boolean(n, tp) { + if (!VALID_BOOLEAN(tp->Booleans[n])) + tp->Booleans[n] = FALSE; + } + for_each_string(n, tp) { + if (tp->Strings[n] == CANCELLED_STRING) + tp->Strings[n] = ABSENT_STRING; + } + } + return (status); +} +#endif + +/* + * Take the real command character out of the CC environment variable + * and substitute it in for the prototype given in 'command_character'. + */ +void +_nc_tinfo_cmdch(TERMINAL *termp, int proto) +{ + char *tmp; + + /* + * Only use the character if the string is a single character, + * since it is fairly common for developers to set the C compiler + * name as an environment variable - using the same symbol. + */ + if ((tmp = getenv("CC")) != NULL && strlen(tmp) == 1) { + unsigned i; + char CC = *tmp; + + for_each_string(i, &(termp->type)) { + tmp = termp->type.Strings[i]; + if (VALID_STRING(tmp)) { + for (; *tmp; ++tmp) { + if (UChar(*tmp) == proto) + *tmp = CC; + } + } + } + } +} + +/* + * 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, NULL); +#else + if (((env = getenv("LANG")) != 0 && *env != '\0') + || ((env = getenv("LC_CTYPE")) != 0 && *env != '\0') + || ((env = getenv("LC_ALL")) != 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(bool) +_nc_unicode_locale(void) +{ + static bool initialized = FALSE; + static bool result = FALSE; + + if (!initialized) { +#if defined(_NC_WINDOWS_NATIVE) && USE_WIDEC_SUPPORT + result = TRUE; +#elif HAVE_LANGINFO_CODESET + char *env = nl_langinfo(CODESET); + result = !strcmp(env, "UTF-8") ? TRUE : FALSE; + T(("_nc_unicode_locale(%s) ->%d", env, result)); +#else + char *env = _nc_get_locale(); + if (env != NULL) { + if (strstr(env, ".UTF-8") != NULL) { + result = TRUE; + T(("_nc_unicode_locale(%s) ->%d", env, result)); + } + } +#endif + initialized = TRUE; + } + return result; +} + +#define CONTROL_N(s) ((s) != NULL && strstr(s, "\016") != NULL) +#define CONTROL_O(s) ((s) != NULL && strstr(s, "\017") != NULL) + +/* + * Check for known broken cases where a UTF-8 locale breaks the alternate + * character set. + */ +NCURSES_EXPORT(int) +_nc_locale_breaks_acs(TERMINAL *termp) +{ + const char *env_name = "NCURSES_NO_UTF8_ACS"; + const char *env; + int value; + int result = 0; + + T((T_CALLED("_nc_locale_breaks_acs:%d"), result)); + if (getenv(env_name) != NULL) { + result = _nc_getenv_num(env_name); + } else if ((value = tigetnum(UserCap(U8))) >= 0) { + result = value; /* use extension feature */ + } else if ((env = getenv("TERM")) != NULL) { + if (strstr(env, "linux")) { + result = 1; /* always broken */ + } else if (strstr(env, "screen") != NULL + && ((env = getenv("TERMCAP")) != NULL + && strstr(env, "screen") != NULL) + && strstr(env, "hhII00") != NULL) { + if (CONTROL_N(enter_alt_charset_mode) || + CONTROL_O(enter_alt_charset_mode) || + CONTROL_N(set_attributes) || + CONTROL_O(set_attributes)) { + result = 1; + } + } + } + returnCode(result); +} + +NCURSES_EXPORT(int) +TINFO_SETUP_TERM(TERMINAL **tp, + const char *tname, + int Filedes, + int *errret, + int reuse) +{ +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *TCB = NULL; +#endif + TERMINAL *termp; + SCREEN *sp = NULL; + char *myname; + int code = ERR; + + START_TRACE(); + +#if USE_TERM_DRIVER + T((T_CALLED("_nc_setupterm_ex(%p,%s,%d,%p)"), + (void *) tp, _nc_visbuf(tname), Filedes, (void *) errret)); + + if (tp == NULL) { + ret_error0(TGETENT_ERR, + "Invalid parameter, internal error.\n"); + } else + termp = *tp; +#else + termp = cur_term; + T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, (void *) errret)); +#endif + + if (tname == NULL) { + tname = getenv("TERM"); +#if USE_NAMED_PIPES + if (!VALID_TERM_ENV(tname, NO_TERMINAL)) { + T(("Failure with TERM=%s", NonNull(tname))); + ret_error0(TGETENT_ERR, "TERM environment variable not set.\n"); + } +#elif USE_TERM_DRIVER + if (!NonEmpty(tname)) + tname = "unknown"; +#else + if (!NonEmpty(tname)) { + T(("Failure with TERM=%s", NonNull(tname))); + ret_error0(TGETENT_ERR, "TERM environment variable not set.\n"); + } +#endif + } + myname = strdup(tname); + if (myname == NULL || strlen(myname) > MAX_NAME_SIZE) { + ret_error(TGETENT_ERR, + "TERM environment must be 1..%d characters.\n", + MAX_NAME_SIZE, + free(myname)); + } + + T(("your terminal name is %s", myname)); + + /* + * 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 && !NC_ISATTY(Filedes)) + Filedes = STDERR_FILENO; +#if USE_NAMED_PIPES + if (Filedes != STDERR_FILENO && NC_ISATTY(Filedes)) + _setmode(Filedes, _O_BINARY); +#endif + + /* + * 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 != NULL) + && termp->Filedes == Filedes + && termp->_termname != NULL + && !strcmp(termp->_termname, myname) + && _nc_name_match(TerminalType(termp).term_names, myname, "|")) { + T(("reusing existing terminal information and mode-settings")); + code = OK; +#if USE_TERM_DRIVER + TCB = (TERMINAL_CONTROL_BLOCK *) termp; +#endif + } else { +#if USE_TERM_DRIVER + TERMINAL_CONTROL_BLOCK *my_tcb; + termp = NULL; + if ((my_tcb = typeCalloc(TERMINAL_CONTROL_BLOCK, 1)) != NULL) + termp = &(my_tcb->term); +#else + int status; + + termp = typeCalloc(TERMINAL, 1); +#endif + if (termp == NULL) { + ret_error1(TGETENT_ERR, + "Not enough memory to create terminal structure.\n", + myname, free(myname)); + } + ++_nc_globals.terminal_count; +#if HAVE_SYSCONF + { + long limit; +#ifdef LINE_MAX + limit = LINE_MAX; +#else + limit = _nc_globals.getstr_limit; +#endif +#ifdef _SC_LINE_MAX + if (limit < sysconf(_SC_LINE_MAX)) + limit = sysconf(_SC_LINE_MAX); +#endif + if (_nc_globals.getstr_limit < (int) limit) + _nc_globals.getstr_limit = (int) limit; + } +#endif /* HAVE_SYSCONF */ + T(("using %d for getstr limit", _nc_globals.getstr_limit)); + +#if USE_TERM_DRIVER + INIT_TERM_DRIVER(); + /* + * _nc_get_driver() will call td_CanHandle() for each driver, and win_driver + * needs file descriptor to do the test, so set it before calling. + */ + termp->Filedes = (short) Filedes; + TCB = (TERMINAL_CONTROL_BLOCK *) termp; + code = _nc_globals.term_driver(TCB, myname, errret); + if (code == OK) { + termp->_termname = strdup(myname); + } else { + ret_error1(errret ? *errret : TGETENT_ERR, + "Could not find any driver to handle terminal.\n", + myname, free(myname)); + } +#else +#if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP + status = _nc_setup_tinfo(myname, &TerminalType(termp)); + T(("_nc_setup_tinfo returns %d", status)); +#else + T(("no database available")); + status = TGETENT_NO; +#endif + + /* try fallback list if entry on disk */ + if (status != TGETENT_YES) { + const TERMTYPE2 *fallback = _nc_fallback2(myname); + + if (fallback) { + T(("found fallback entry")); + _nc_copy_termtype2(&(TerminalType(termp)), fallback); + status = TGETENT_YES; + } + } + + if (status != TGETENT_YES) { + del_curterm(termp); + if (status == TGETENT_ERR) { + free(myname); + ret_error0(status, "terminals database is inaccessible\n"); + } else if (status == TGETENT_NO) { + ret_error1(status, "unknown terminal type.\n", + myname, free(myname)); + } else { + free(myname); + ret_error0(status, "unexpected return-code\n"); + } + } +#if NCURSES_EXT_NUMBERS + _nc_export_termtype2(&termp->type, &TerminalType(termp)); +#endif +#if !USE_REENTRANT + save_ttytype(termp); +#endif + + termp->Filedes = (short) Filedes; + termp->_termname = strdup(myname); + + set_curterm(termp); + + if (VALID_STRING(command_character)) + _nc_tinfo_cmdch(termp, UChar(*command_character)); + + /* + * 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. Also get the shell-mode so that erasechar() works. + */ + if (NC_ISATTY(Filedes)) { + NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG); + NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG); + NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); + } + code = OK; +#endif + } + +#if USE_TERM_DRIVER + *tp = termp; + NCURSES_SP_NAME(set_curterm) (sp, termp); + TCB->drv->td_init(TCB); +#else + sp = SP; +#endif + + /* + * We should always check the screensize, just in case. + */ + TINFO_GET_SIZE(sp, termp, ptrLines(sp), ptrCols(sp)); + + if (errret) + *errret = TGETENT_YES; + +#if !USE_TERM_DRIVER + if (generic_type) { + /* + * BSD 4.3's termcap contains mis-typed "gn" for wy99. Do a sanity + * check before giving up. + */ + if ((VALID_STRING(cursor_address) + || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home))) + && VALID_STRING(clear_screen)) { + ret_error1(TGETENT_YES, "terminal is not really generic.\n", + myname, free(myname)); + } else { + del_curterm(termp); + ret_error1(TGETENT_NO, "I need something more specific.\n", + myname, free(myname)); + } + } else if (hard_copy) { + ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", + myname, free(myname)); + } +#endif + free(myname); + returnCode(code); +} + +#ifdef USE_PTHREADS +/* + * Returns a non-null pointer unless a new screen should be allocated because + * no match was found in the pre-screen cache. + */ +NCURSES_EXPORT(SCREEN *) +_nc_find_prescr(void) +{ + SCREEN *result = NULL; + PRESCREEN_LIST *p; + pthread_t id = GetThreadID(); + for (p = _nc_prescreen.allocated; p != NULL; p = p->next) { + if (p->id == id) { + result = p->sp; + break; + } + } + return result; +} + +/* + * Tells ncurses to forget that this thread was associated with the pre-screen + * cache. It does not modify the pre-screen cache itself, since that is used + * for creating new screens. + */ +NCURSES_EXPORT(void) +_nc_forget_prescr(void) +{ + PRESCREEN_LIST *p, *q; + pthread_t id = GetThreadID(); + _nc_lock_global(screen); + for (p = _nc_prescreen.allocated, q = NULL; p != NULL; q = p, p = p->next) { + if (p->id == id) { + if (q) { + q->next = p->next; + } else { + _nc_prescreen.allocated = p->next; + } + free(p); + break; + } + } + _nc_unlock_global(screen); +} +#endif /* USE_PTHREADS */ + +#if NCURSES_SP_FUNCS +/* + * In case of handling multiple screens, we need to have a screen before + * initialization in _nc_setupscreen takes place. This is to extend the + * substitute for some of the stuff in _nc_prescreen, especially for slk and + * ripoff handling which should be done per screen. + */ +NCURSES_EXPORT(SCREEN *) +new_prescr(void) +{ + SCREEN *sp; + + START_TRACE(); + T((T_CALLED("new_prescr()"))); + + _nc_lock_global(screen); + if ((sp = _nc_find_prescr()) == NULL) { + sp = _nc_alloc_screen_sp(); + T(("_nc_alloc_screen_sp %p", (void *) sp)); + if (sp != NULL) { +#ifdef USE_PTHREADS + PRESCREEN_LIST *p = typeCalloc(PRESCREEN_LIST, 1); + if (p != NULL) { + p->id = GetThreadID(); + p->sp = sp; + p->next = _nc_prescreen.allocated; + _nc_prescreen.allocated = p; + } +#else + _nc_prescreen.allocated = sp; +#endif + sp->rsp = sp->rippedoff; + sp->_filtered = _nc_prescreen.filter_mode; + sp->_use_env = _nc_prescreen.use_env; +#if NCURSES_NO_PADDING + sp->_no_padding = _nc_prescreen._no_padding; +#endif + sp->slk_format = 0; + sp->_slk = NULL; + sp->_prescreen = TRUE; + SP_PRE_INIT(sp); +#if USE_REENTRANT + sp->_TABSIZE = _nc_prescreen._TABSIZE; + sp->_ESCDELAY = _nc_prescreen._ESCDELAY; +#endif + } + } else { + T(("_nc_alloc_screen_sp %p (reuse)", (void *) sp)); + } + _nc_unlock_global(screen); + returnSP(sp); +} +#endif + +#if USE_TERM_DRIVER +/* + * This entrypoint is called from tgetent() to allow a special case of reusing + * the same TERMINAL data (see comment). + */ +NCURSES_EXPORT(int) +_nc_setupterm(const char *tname, + int Filedes, + int *errret, + int reuse) +{ + int rc = ERR; + TERMINAL *termp = NULL; + + _nc_init_pthreads(); + _nc_lock_global(prescreen); + START_TRACE(); + if (TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse) == OK) { + _nc_forget_prescr(); + if (NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp) != NULL) { + rc = OK; + } + } + _nc_unlock_global(prescreen); + + return rc; +} +#endif + +/* + * 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(const char *tname, int Filedes, int *errret) +{ + START_TRACE(); + return _nc_setupterm(tname, Filedes, errret, FALSE); +} diff --git a/ncurses/ncurses/tinfo/lib_termcap.c b/ncurses/ncurses/tinfo/lib_termcap.c new file mode 100644 index 0000000000..b7ca8af073 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_termcap.c @@ -0,0 +1,450 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + * * + * some of the code in here was contributed by: * + * Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93) * + * (but it has changed a lot) * + ****************************************************************************/ + +/* $FreeBSD$ */ + +#define __INTERNAL_CAPS_VISIBLE +#include + +#include +#include +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_termcap.c,v 1.96 2025/12/27 12:33:34 tom Exp $") + +NCURSES_EXPORT_VAR(char *) UP = NULL; +NCURSES_EXPORT_VAR(char *) BC = NULL; + +#ifdef FREEBSD_NATIVE +extern char _nc_termcap[]; /* buffer to copy out */ +#endif + +#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 + +/* + * Termcap names are matched only using the first two bytes. + * Ignore any extended names longer than two bytes, to avoid problems + * with legacy code which passes in parameters whose use is long forgotten. + */ +#define ValidCap(cap) (((cap)[0] != '\0') && ((cap)[1] != '\0')) +#define SameCap(a,b) (((a)[0] == (b)[0]) && ((a)[1] == (b)[1])) +#define ValidExt(ext) (ValidCap(ext) && (ext)[2] == '\0') + +/*************************************************************************** + * + * tgetent(bufp, term) + * + * In termcap, this function reads in the entry for terminal `term' into the + * buffer pointed to by bufp. It must be called before any of the functions + * below are called. + * In this terminfo emulation, tgetent() simply calls setupterm() (which + * does a bit more than tgetent() in termcap does), and returns its return + * value (1 if successful, 0 if no terminal with the given name could be + * found, or -1 if no terminal descriptions have been installed on the + * system). The bufp argument is ignored. + * + ***************************************************************************/ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) +{ + int rc = ERR; + int n; + bool found_cache = FALSE; +#if USE_TERM_DRIVER + TERMINAL *termp = NULL; +#endif + + START_TRACE(); + T((T_CALLED("tgetent()"))); + + TINFO_SETUP_TERM(&termp, name, STDOUT_FILENO, &rc, TRUE); + +#if USE_TERM_DRIVER + if (termp == NULL || + !((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo) + returnCode(rc); +#endif + + /* + * 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 != NULL) { + FreeAndNull(FIX_SGR0); + } + /* + * Also free the terminfo data that we loaded (much bigger leak). + */ + if (LAST_TRM != NULL && LAST_TRM != TerminalOf(SP_PARM)) { + const TERMINAL *trm = LAST_TRM; + NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx LAST_TRM); + for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) + if (LAST_TRM == trm) + LAST_TRM = NULL; + 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; + } + if (rc == 1) { + LAST_TRM = TerminalOf(SP_PARM); + LAST_SEQ = ++CacheSeq; + } else { + LAST_TRM = NULL; + } + + PC = 0; + UP = NULL; + BC = NULL; + FIX_SGR0 = NULL; /* don't free it - application may still use */ + + if (rc == 1) { + + if (cursor_left) + if ((backspaces_with_bs = (char) !strcmp(cursor_left, "\b")) == 0) + backspace_if_not_bs = cursor_left; + + /* we're required to export these */ + if (pad_char != NULL) + PC = pad_char[0]; + if (cursor_up != NULL) + UP = cursor_up; + if (backspace_if_not_bs != NULL) + BC = backspace_if_not_bs; + + if ((FIX_SGR0 = _nc_trim_sgr0(&TerminalType(TerminalOf(SP_PARM)))) + != NULL) { + if (!strcmp(FIX_SGR0, exit_attribute_mode)) { + if (FIX_SGR0 != exit_attribute_mode) { + free(FIX_SGR0); + } + FIX_SGR0 = NULL; + } + } + LAST_BUF = bufp; + LAST_USE = TRUE; + + SetNoPadding(SP_PARM); + (void) NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets ospeed as a side effect */ + +/* LINT_PREPRO +#if 0*/ +#include +/* LINT_PREPRO +#endif*/ + + } + +#ifdef FREEBSD_NATIVE + /* + * This is a REALLY UGLY hack. Basically, if we originate with + * a termcap source, try and copy it out. + */ + if (bufp && _nc_termcap[0]) + strncpy(bufp, _nc_termcap, 1024); +#endif + + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tgetent(char *bufp, const char *name) +{ + return NCURSES_SP_NAME(tgetent) (CURRENT_SCREEN, bufp, name); +} +#endif + +#if 0 +static bool +same_tcname(const char *a, const char *b) +{ + bool code = SameCap(a, b); + fprintf(stderr, "compare(%s,%s) %s\n", a, b, code ? "same" : "diff"); + return code; +} + +#else +#define same_tcname(a,b) SameCap(a,b) +#endif + +/*************************************************************************** + * + * tgetflag(str) + * + * Look up boolean termcap capability str and return its value (TRUE=1 if + * present, FALSE=0 if not). + * + ***************************************************************************/ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx const char *id) +{ + int result = 0; /* Solaris returns zero for missing flag */ + + T((T_CALLED("tgetflag(%p, %s)"), (void *) SP_PARM, id)); + if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) { + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); + struct name_table_entry const *entry_ptr; + int j = -1; + + entry_ptr = _nc_find_type_entry(id, BOOLEAN, TRUE); + if (entry_ptr != NULL) { + j = entry_ptr->nte_index; + } +#if NCURSES_XNAMES + else { + int i; + for_each_ext_boolean(i, tp) { + const char *capname = ExtBoolname(tp, i, boolcodes); + if (same_tcname(id, capname) && ValidExt(capname)) { + j = i; + break; + } + } + } +#endif + if (j >= 0) { + /* note: setupterm forces invalid booleans to false */ + result = tp->Booleans[j]; + } + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tgetflag(const char *id) +{ + return NCURSES_SP_NAME(tgetflag) (CURRENT_SCREEN, id); +} +#endif + +/*************************************************************************** + * + * tgetnum(str) + * + * Look up numeric termcap capability str and return its value, or -1 if + * not given. + * + ***************************************************************************/ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx const char *id) +{ + int result = ABSENT_NUMERIC; + + T((T_CALLED("tgetnum(%p, %s)"), (void *) SP_PARM, id)); + assert(result < 0); + + if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) { + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); + struct name_table_entry const *entry_ptr; + int j = -1; + + entry_ptr = _nc_find_type_entry(id, NUMBER, TRUE); + if (entry_ptr != NULL) { + j = entry_ptr->nte_index; + } +#if NCURSES_XNAMES + else { + int i; + for_each_ext_number(i, tp) { + const char *capname = ExtNumname(tp, i, numcodes); + if (same_tcname(id, capname) && ValidExt(capname)) { + j = i; + break; + } + } + } +#endif + if (j >= 0) { + if (VALID_NUMERIC(tp->Numbers[j])) + result = tp->Numbers[j]; + } + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tgetnum(const char *id) +{ + return NCURSES_SP_NAME(tgetnum) (CURRENT_SCREEN, id); +} +#endif + +/*************************************************************************** + * + * tgetstr(str, area) + * + * Look up string termcap capability str and return a pointer to its value, + * or NULL if not given. + * + ***************************************************************************/ + +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx const char *id, char **area) +{ + char *result = NULL; + + T((T_CALLED("tgetstr(%s,%p)"), id, (void *) area)); + if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) { + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); + struct name_table_entry const *entry_ptr; + int j = -1; + + entry_ptr = _nc_find_type_entry(id, STRING, TRUE); + if (entry_ptr != NULL) { + j = entry_ptr->nte_index; + } +#if NCURSES_XNAMES + else { + int i; + for_each_ext_string(i, tp) { + const char *capname = ExtStrname(tp, i, strcodes); + if (same_tcname(id, capname) && ValidExt(capname)) { + j = i; + break; + } + } + } +#endif + if (j >= 0) { + result = tp->Strings[j]; + TR(TRACE_DATABASE, ("found match %d: %s", j, _nc_visbuf(result))); + /* setupterm forces canceled strings to null */ + if (VALID_STRING(result)) { + if (result == exit_attribute_mode + && FIX_SGR0 != NULL) { + result = FIX_SGR0; + TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result))); + } + if (area != NULL + && *area != NULL) { + _nc_STRCPY(*area, result, 1024); + result = *area; + *area += strlen(*area) + 1; + } + } + } + } + returnPtr(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +tgetstr(const char *id, char **area) +{ + return NCURSES_SP_NAME(tgetstr) (CURRENT_SCREEN, id, area); +} +#endif + +#if NO_LEAKS +#undef CacheInx +#define CacheInx num +NCURSES_EXPORT(void) +_nc_tgetent_leak(const TERMINAL *const termp) +{ + if (termp != NULL) { + int num; + for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) { + if (LAST_TRM == termp) { + FreeAndNull(FIX_SGR0); + if (LAST_TRM != NULL) { + LAST_TRM = NULL; + } + break; + } + } + } +} + +NCURSES_EXPORT(void) +_nc_tgetent_leaks(void) +{ + int num; + for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) { + if (LAST_TRM != NULL) { + del_curterm(LAST_TRM); + _nc_tgetent_leak(LAST_TRM); + } + } +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_termname.c b/ncurses/ncurses/tinfo/lib_termname.c new file mode 100644 index 0000000000..eeaed21499 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_termname.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2003,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: lib_termname.c,v 1.15 2025/01/12 00:41:56 tom Exp $") + +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(termname) (NCURSES_SP_DCL0) +{ + char *name = NULL; + + T((T_CALLED("termname(%p)"), (void *) SP_PARM)); + +#if NCURSES_SP_FUNCS + if (TerminalOf(SP_PARM) != NULL) { + name = TerminalOf(SP_PARM)->_termname; + } +#else + if (cur_term != NULL) + name = cur_term->_termname; +#endif + + returnPtr(name); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +termname(void) +{ + return NCURSES_SP_NAME(termname) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_tgoto.c b/ncurses/ncurses/tinfo/lib_tgoto.c new file mode 100644 index 0000000000..c05c884512 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_tgoto.c @@ -0,0 +1,225 @@ +/**************************************************************************** + * Copyright 2018-2023,2025 Thomas E. Dickey * + * Copyright 2000-2008,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +#include +#include + +MODULE_ID("$Id: lib_tgoto.c,v 1.24 2025/01/12 00:41:56 tom Exp $") + +#if !PURE_TERMINFO +static bool +is_termcap(const char *string) +{ + bool result = TRUE; + + if (string == NULL || *string == '\0') { + result = FALSE; /* tparm() handles empty strings */ + } else { + while ((*string != '\0') && result) { + if (*string == '%') { + switch (*++string) { + case 'p': + result = FALSE; + break; + case '\0': + string--; + break; + } + } else if (string[0] == '$' && string[1] == '<') { + result = FALSE; + } + string++; + } + } + return result; +} + +static char * +tgoto_internal(const char *string, int x, int y) +{ + static char *result; + static size_t length; + + int swap_arg; + int param[3]; + size_t used = 0; + size_t need = 10; + int *value = param; + bool need_BC = FALSE; + + if (BC) + need += strlen(BC); + + param[0] = y; + param[1] = x; + param[2] = 0; + + while (*string != 0) { + if ((used + need) > length) { + length += (used + need); + if ((result = typeRealloc(char, length, result)) == NULL) { + length = 0; + break; + } + } + if (*string == '%') { + const char *fmt = NULL; + + switch (*++string) { + case '\0': + string--; + break; + case 'd': + fmt = "%d"; + break; + case '2': + fmt = "%02d"; + *value %= 100; + break; + case '3': + fmt = "%03d"; + *value %= 1000; + break; + case '+': + *value += UChar(*++string); + /* FALLTHRU */ + case '.': + /* + * Guard against tputs() seeing a truncated string. The + * termcap documentation refers to a similar fixup for \n + * and \r, but I don't see that it could work -TD + */ + if (*value == 0) { + if (BC != NULL) { + *value += 1; + need_BC = TRUE; + } else { + /* tputs will pretend this is \0, which will almost + * always work since ANSI-compatible terminals ignore + * the character. ECMA-48 does not document a C1 + * control for this value. A few (obsolete) terminals + * can use this value in special cases, such as cursor + * addressing using single-byte coordinates. + */ + *value = 0200; + } + } + result[used++] = (char) *value++; + break; + case '%': + result[used++] = *string; + break; + case 'r': + swap_arg = param[0]; + param[0] = param[1]; + param[1] = swap_arg; + break; + case 'i': + param[0] += 1; + param[1] += 1; + break; + case '>': + if (*value > string[1]) + *value += string[2]; + string += 2; + break; + case 'n': /* Datamedia 2500 */ + param[0] ^= 0140; + param[1] ^= 0140; + break; + case 'B': /* BCD */ + *value = 16 * (*value / 10) + (*value % 10); + break; + case 'D': /* Reverse coding (Delta Data) */ + *value -= 2 * (*value % 16); + break; + } + if (fmt != NULL) { + _nc_SPRINTF(result + used, _nc_SLIMIT(length - used) + fmt, *value++); + used += strlen(result + used); + fmt = NULL; + } + if (value - param > 2) { + value = param + 2; + *value = 0; + } + } else { + result[used++] = *string; + } + string++; + } + if (result != NULL) { + if (need_BC) { + _nc_STRCPY(result + used, BC, length - used); + used += strlen(BC); + } + result[used] = '\0'; + } + return result; +} +#endif + +/* + * Retained solely for upward compatibility. Note the intentional reversing of + * the last two arguments when invoking tparm(). + */ +NCURSES_EXPORT(char *) +tgoto(const char *string, int x, int y) +{ + char *result; + + T((T_CALLED("tgoto(%s, %d, %d)"), _nc_visbuf(string), x, y)); +#if !PURE_TERMINFO + if (is_termcap(string)) + result = tgoto_internal(string, x, y); + else +#endif + if ((result = TIPARM_2(string, y, x)) == NULL) { + /* + * Because termcap did not provide a more general solution such as + * tparm(), it was necessary to handle single-parameter capabilities + * using tgoto(). The internal _nc_tiparm() function returns a NULL + * for that case; retry for the single-parameter case. + */ + if ((result = TIPARM_1(string, y)) == NULL) { + result = TIPARM_0(string); + } + } + returnPtr(result); +} diff --git a/ncurses/ncurses/tinfo/lib_ti.c b/ncurses/ncurses/tinfo/lib_ti.c new file mode 100644 index 0000000000..7f992e9984 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_ti.c @@ -0,0 +1,193 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +#include + +#include + +MODULE_ID("$Id: lib_ti.c,v 1.36 2025/11/23 18:58:04 tom Exp $") + +#if 0 +static bool +same_name(const char *a, const char *b) +{ + fprintf(stderr, "compare(%s,%s)\n", a, b); + return !strcmp(a, b); +} +#else +#define same_name(a,b) !strcmp(a,b) +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx const char *str) +{ + int result = ABSENT_BOOLEAN; + + T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM, str)); + assert(result < 0); + + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); + struct name_table_entry const *entry_ptr; + int j = -1; + + entry_ptr = _nc_find_type_entry(str, BOOLEAN, FALSE); + if (entry_ptr != NULL) { + j = entry_ptr->nte_index; + } +#if NCURSES_XNAMES + else { + int i; + for_each_ext_boolean(i, tp) { + const char *capname = ExtBoolname(tp, i, boolnames); + if (same_name(str, capname)) { + j = i; + break; + } + } + } +#endif + if (j >= 0) { + /* note: setupterm forces invalid booleans to false */ + result = tp->Booleans[j]; + } + } + + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tigetflag(const char *str) +{ + return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx const char *str) +{ + int result = CANCELLED_NUMERIC; /* Solaris returns a -1 on error */ + + T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM, str)); + assert(result < 0); + + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); + struct name_table_entry const *entry_ptr; + int j = -1; + + entry_ptr = _nc_find_type_entry(str, NUMBER, FALSE); + if (entry_ptr != NULL) { + j = entry_ptr->nte_index; + } +#if NCURSES_XNAMES + else { + int i; + for_each_ext_number(i, tp) { + const char *capname = ExtNumname(tp, i, numnames); + if (same_name(str, capname)) { + j = i; + break; + } + } + } +#endif + if (j >= 0) { + if (VALID_NUMERIC(tp->Numbers[j])) + result = tp->Numbers[j]; + else + result = ABSENT_NUMERIC; + } + } + + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tigetnum(const char *str) +{ + return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str); +} +#endif + +NCURSES_EXPORT(char *) +NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx const char *str) +{ + char *result = CANCELLED_STRING; + + T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM, str)); + + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); + struct name_table_entry const *entry_ptr; + int j = -1; + + entry_ptr = _nc_find_type_entry(str, STRING, FALSE); + if (entry_ptr != NULL) { + j = entry_ptr->nte_index; + } +#if NCURSES_XNAMES + else { + int i; + for_each_ext_string(i, tp) { + const char *capname = ExtStrname(tp, i, strnames); + if (same_name(str, capname)) { + j = i; + break; + } + } + } +#endif + if (j >= 0) { + /* note: setupterm forces cancelled strings to null */ + result = tp->Strings[j]; + } + } + + returnPtr(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +tigetstr(const char *str) +{ + return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_tparm.c b/ncurses/ncurses/tinfo/lib_tparm.c new file mode 100644 index 0000000000..f11456a8b0 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_tparm.c @@ -0,0 +1,1411 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey, 1996 on * + ****************************************************************************/ + +/* + * tparm.c + * + */ + +#define entry _ncu_entry +#define ENTRY _ncu_ENTRY + +#include + +#undef entry +#undef ENTRY + +#if HAVE_TSEARCH +#include +#endif + +#include +#include + +MODULE_ID("$Id: lib_tparm.c,v 1.157 2025/02/15 15:20:16 tom Exp $") + +/* + * char * + * tparm(string, ...) + * + * Substitute the given parameters into the given string by the following + * rules (taken from terminfo(5)): + * + * Cursor addressing and other strings requiring parame- + * ters in the terminal are described by a parameterized string + * capability, with escapes like %x in it. For example, to + * address the cursor, the cup capability is given, using two + * parameters: the row and column to address to. (Rows and + * columns are numbered from zero and refer to the physical + * screen visible to the user, not to any unseen memory.) If + * the terminal has memory relative cursor addressing, that can + * be indicated by + * + * The parameter mechanism uses a stack and special % + * codes 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. + * + * The % encodings have the following meanings: + * + * %% outputs `%' + * %c print pop() like %c in printf() + * %s print pop() like %s in printf() + * %[[:]flags][width[.precision]][doxXs] + * as in printf, flags are [-+#] and space + * The ':' is used to avoid making %+ or %- + * patterns (see below). + * + * %p[1-9] push ith param + * %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 + * %l push strlen(pop) + * %'c' push char constant c + * %{nn} push integer constant nn + * + * %+ %- %* %/ %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 params (for ANSI terminals) + * + * %? expr %t thenpart %e elsepart %; + * if-then-else, %e elsepart is optional. + * else-if's are possible ala Algol 68: + * %? c1 %t b1 %e c2 %t b2 %e c3 %t b3 %e c4 %t b4 %e b5 %; + * + * For those of the above operators which are binary and not commutative, + * the stack works in the usual way, with + * %gx %gy %m + * resulting in x mod y, not the reverse. + */ + +NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0; + +#define TPS(var) tps->var +#define popcount _nc_popcount /* workaround for NetBSD 6.0 defect */ + +#define get_tparm_state(term) \ + (term != NULL \ + ? &(term->tparm_state) \ + : &(_nc_prescreen.tparm_state)) + +#define isUPPER(c) ((c) >= 'A' && (c) <= 'Z') +#define isLOWER(c) ((c) >= 'a' && (c) <= 'z') +#define tc_BUMP() if (level < 0 && number < 2) number++ + +typedef struct { + const char *format; /* format-string can be used as cache-key */ + int tparm_type; /* bit-set for each string-parameter */ + int num_actual; + int num_parsed; + int num_popped; + TPARM_ARG param[NUM_PARM]; + char *p_is_s[NUM_PARM]; +} TPARM_DATA; + +#if HAVE_TSEARCH +#define MyCache _nc_globals.cached_tparm +#define MyCount _nc_globals.count_tparm +static int which_tparm; +static TPARM_DATA **delete_tparm; +#endif /* HAVE_TSEARCH */ + +static char dummy[] = ""; /* avoid const-cast */ + +#if HAVE_TSEARCH +static int +cmp_format(const void *p, const void *q) +{ + const char *a = *(char *const *) p; + const char *b = *(char *const *) q; + return strcmp(a, b); +} +#endif + +#if HAVE_TSEARCH +static void +visit_nodes(const void *nodep, VISIT which, int depth) +{ + (void) depth; + if (which == preorder || which == leaf) { + delete_tparm[which_tparm] = *(TPARM_DATA **) nodep; + which_tparm++; + } +} +#endif + +NCURSES_EXPORT(void) +_nc_free_tparm(TERMINAL *termp) +{ + TPARM_STATE *tps = get_tparm_state(termp); +#if HAVE_TSEARCH + if (MyCount != 0) { + delete_tparm = typeCalloc(TPARM_DATA *, MyCount); + if (delete_tparm != NULL) { + which_tparm = 0; + twalk(MyCache, visit_nodes); + for (which_tparm = 0; which_tparm < MyCount; ++which_tparm) { + TPARM_DATA *ptr = delete_tparm[which_tparm]; + if (ptr != NULL) { + tdelete(ptr, &MyCache, cmp_format); + free((char *) ptr->format); + free(ptr); + } + } + which_tparm = 0; + twalk(MyCache, visit_nodes); + FreeAndNull(delete_tparm); + } + MyCount = 0; + which_tparm = 0; + } +#endif + FreeAndNull(TPS(out_buff)); + TPS(out_size) = 0; + TPS(out_used) = 0; + + FreeAndNull(TPS(fmt_buff)); + TPS(fmt_size) = 0; +} + +static int +tparm_error(TPARM_STATE *tps, const char *message) +{ + (void) tps; + (void) message; + DEBUG(2, ("%s: %s", message, _nc_visbuf(TPS(tparam_base)))); + return ++_nc_tparm_err; +} + +#define get_space(tps, need) \ +{ \ + size_t need2get = need + TPS(out_used); \ + if (need2get > TPS(out_size)) { \ + TPS(out_size) = need2get * 2; \ + TYPE_REALLOC(char, TPS(out_size), TPS(out_buff)); \ + } \ +} + +#if NCURSES_EXPANDED +static NCURSES_INLINE void + (get_space) (TPARM_STATE *tps, size_t need) { + get_space(tps, need); +} + +#undef get_space +#endif + +#define save_text(tps, fmt, s, len) \ +{ \ + size_t s_len = (size_t) len + strlen(s) + strlen(fmt); \ + get_space(tps, s_len + 1); \ + _nc_SPRINTF(TPS(out_buff) + TPS(out_used), \ + _nc_SLIMIT(TPS(out_size) - TPS(out_used)) \ + fmt, s); \ + TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used)); \ +} + +#if NCURSES_EXPANDED +static NCURSES_INLINE void + (save_text) (TPARM_STATE *tps, const char *fmt, const char *s, int len) { + save_text(tps, fmt, s, len); +} + +#undef save_text +#endif + +#define save_number(tps, fmt, number, len) \ +{ \ + size_t s_len = (size_t) len + 30 + strlen(fmt); \ + get_space(tps, s_len + 1); \ + _nc_SPRINTF(TPS(out_buff) + TPS(out_used), \ + _nc_SLIMIT(TPS(out_size) - TPS(out_used)) \ + fmt, number); \ + TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used)); \ +} + +#if NCURSES_EXPANDED +static NCURSES_INLINE void + (save_number) (TPARM_STATE *tps, const char *fmt, int number, int len) { + save_number(tps, fmt, number, len); +} + +#undef save_number +#endif + +#define save_char(tps, c) \ +{ \ + get_space(tps, (size_t) 1); \ + TPS(out_buff)[TPS(out_used)++] = (char) ((c == 0) ? 0200 : c); \ +} + +#if NCURSES_EXPANDED +static NCURSES_INLINE void + (save_char) (TPARM_STATE *tps, int c) { + save_char(tps, c); +} + +#undef save_char +#endif + +#define npush(tps, x) \ +{ \ + 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 { \ + (void) tparm_error(tps, "npush: stack overflow"); \ + } \ +} + +#if NCURSES_EXPANDED +static NCURSES_INLINE void + (npush) (TPARM_STATE *tps, int x) { + npush(tps, x); +} + +#undef npush +#endif + +#define spush(tps, x) \ +{ \ + 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 { \ + (void) tparm_error(tps, "spush: stack overflow"); \ + } \ +} + +#if NCURSES_EXPANDED +static NCURSES_INLINE void + (spush) (TPARM_STATE *tps, char *x) { + spush(tps, x); +} + +#undef spush +#endif + +#define npop(tps) \ + ((TPS(stack_ptr)-- > 0) \ + ? ((TPS(stack)[TPS(stack_ptr)].num_type) \ + ? TPS(stack)[TPS(stack_ptr)].data.num \ + : 0) \ + : (tparm_error(tps, "npop: stack underflow"), \ + TPS(stack_ptr) = 0)) + +#if NCURSES_EXPANDED +static NCURSES_INLINE int + (npop) (TPARM_STATE *tps) { + return npop(tps); +} +#undef npop +#endif + +#define spop(tps) \ + ((TPS(stack_ptr)-- > 0) \ + ? ((!TPS(stack)[TPS(stack_ptr)].num_type \ + && TPS(stack)[TPS(stack_ptr)].data.str != NULL) \ + ? TPS(stack)[TPS(stack_ptr)].data.str \ + : dummy) \ + : (tparm_error(tps, "spop: stack underflow"), \ + dummy)) + +#if NCURSES_EXPANDED +static NCURSES_INLINE char * + (spop) (TPARM_STATE *tps) { + return spop(tps); +} +#undef spop +#endif + +static NCURSES_INLINE const char * +parse_format(const char *s, char *format, int *len) +{ + *len = 0; + if (format != NULL) { + 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': +#ifdef EXP_XTERM_1005 + case 'u': +#endif + *format++ = *s; + done = TRUE; + 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++; + 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) { + my_width = my_prec = value = 0; + format = fmt; + *format++ = '%'; + *format++ = *s; + } + + /* + * 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; +} + +/* + * 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(TERMINAL *term, const char *string, char **p_is_s, int *popcount) +{ + TPARM_STATE *tps = get_tparm_state(term); + size_t len2; + int i; + int lastpop = -1; + int len; + int number = 0; + int level = -1; + const char *cp = string; + + if (cp == NULL) + return 0; + + if ((len2 = strlen(cp)) + 2 > TPS(fmt_size)) { + TPS(fmt_size) += len2 + 2; + TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff)); + if (TPS(fmt_buff) == NULL) + return 0; + } + + memset(p_is_s, 0, sizeof(p_is_s[0]) * NUM_PARM); + *popcount = 0; + + while ((cp - string) < (int) len2) { + if (*cp == '%') { + cp++; + cp = parse_format(cp, TPS(fmt_buff), &len); + switch (*cp) { + default: + break; + + case 'd': /* FALLTHRU */ + case 'o': /* FALLTHRU */ + case 'x': /* FALLTHRU */ + case 'X': /* FALLTHRU */ + case 'c': /* FALLTHRU */ +#ifdef EXP_XTERM_1005 + case 'u': +#endif + if (lastpop <= 0) { + tc_BUMP(); + } + level -= 1; + lastpop = -1; + break; + + case 'l': + case 's': + if (lastpop > 0) { + level -= 1; + p_is_s[lastpop - 1] = dummy; + } + tc_BUMP(); + break; + + case 'p': + cp++; + i = (UChar(*cp) - '0'); + if (i >= 0 && i <= NUM_PARM) { + ++level; + lastpop = i; + if (lastpop > *popcount) + *popcount = lastpop; + } + break; + + case 'P': + ++cp; + break; + + case 'g': + ++level; + cp++; + break; + + case S_QUOTE: + ++level; + cp += 2; + lastpop = -1; + break; + + case L_BRACE: + ++level; + cp++; + while (isdigit(UChar(*cp))) { + cp++; + } + break; + + case '+': + case '-': + case '*': + case '/': + case 'm': + case 'A': + case 'O': + case '&': + case '|': + case '^': + case '=': + case '<': + case '>': + tc_BUMP(); + level -= 1; /* pop 2, operate, push 1 */ + lastpop = -1; + break; + + case '!': + case '~': + tc_BUMP(); + lastpop = -1; + break; + + case 'i': + /* will add 1 to first (usually two) parameters */ + break; + } + } + if (*cp != '\0') + cp++; + } + + if (number > NUM_PARM) + number = NUM_PARM; + return number; +} + +/* + * Analyze the capability string, finding the number of parameters and their + * types. + * + * TODO: cache the result so that this is done once per capability per term. + */ +static int +tparm_setup(TERMINAL *term, const char *string, TPARM_DATA *result) +{ + TPARM_STATE *tps = get_tparm_state(term); + int rc = OK; + + TPS(out_used) = 0; + memset(result, 0, sizeof(*result)); + + if (!VALID_STRING(string)) { + TR(TRACE_CALLS, ("%s: format is invalid", TPS(tname))); + rc = ERR; + } else { +#if HAVE_TSEARCH + TPARM_DATA *fs; + void *ft; + + result->format = string; + if ((ft = tfind(result, &MyCache, cmp_format)) != NULL) { + size_t len2; + fs = *(TPARM_DATA **) ft; + *result = *fs; + if ((len2 = strlen(string)) + 2 > TPS(fmt_size)) { + TPS(fmt_size) += len2 + 2; + TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff)); + if (TPS(fmt_buff) == NULL) + return ERR; + } + } else +#endif + { + /* + * 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. + */ + result->num_parsed = _nc_tparm_analyze(term, string, + result->p_is_s, + &(result->num_popped)); + if (TPS(fmt_buff) == NULL) { + TR(TRACE_CALLS, ("%s: error in analysis", TPS(tname))); + rc = ERR; + } else { + int n; + + if (result->num_parsed > NUM_PARM) + result->num_parsed = NUM_PARM; + if (result->num_popped > NUM_PARM) + result->num_popped = NUM_PARM; + result->num_actual = Max(result->num_popped, result->num_parsed); + + for (n = 0; n < result->num_actual; ++n) { + if (result->p_is_s[n]) + result->tparm_type |= (1 << n); + } +#if HAVE_TSEARCH + if ((fs = typeCalloc(TPARM_DATA, 1)) != NULL) { + *fs = *result; + if ((fs->format = strdup(string)) != NULL) { + if (tsearch(fs, &MyCache, cmp_format) != NULL) { + ++MyCount; + } else { + free(fs); + rc = ERR; + } + } else { + free(fs); + rc = ERR; + } + } else { + rc = ERR; + } +#endif + } + } + } + + return rc; +} + +/* + * 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. The normal prototype for tparm uses 9 + * long's, which is consistent with our va_arg() usage. + */ +static void +tparm_copy_valist(TPARM_DATA *data, int use_TPARM_ARG, va_list ap) +{ + int i; + + for (i = 0; i < data->num_actual; i++) { + if (data->p_is_s[i] != NULL) { + char *value = va_arg(ap, char *); + if (value == NULL) + value = dummy; + data->p_is_s[i] = value; + data->param[i] = 0; + } else if (use_TPARM_ARG) { + data->param[i] = va_arg(ap, TPARM_ARG); + } else { + data->param[i] = (TPARM_ARG) va_arg(ap, int); + } + } +} + +/* + * This is a termcap compatibility hack. If there are no explicit pop + * operations in the string, load the stack in such a way that successive pops + * will grab successive parameters. That will make the expansion of (for + * example) \E[%d;%dH work correctly in termcap style, which means tparam() + * will expand termcap strings OK. + */ +static bool +tparm_tc_compat(TPARM_STATE *tps, TPARM_DATA *data) +{ + bool termcap_hack = FALSE; + + TPS(stack_ptr) = 0; + + if (data->num_popped == 0) { + int i; + + termcap_hack = TRUE; + for (i = data->num_parsed - 1; i >= 0; i--) { + if (data->p_is_s[i]) { + spush(tps, data->p_is_s[i]); + } else { + npush(tps, (int) data->param[i]); + } + } + } + return termcap_hack; +} + +#ifdef TRACE +static void +tparm_trace_call(TPARM_STATE *tps, const char *string, TPARM_DATA *data) +{ + if (USE_TRACEF(TRACE_CALLS)) { + int i; + for (i = 0; i < data->num_actual; i++) { + if (data->p_is_s[i] != NULL) { + save_text(tps, ", %s", _nc_visbuf(data->p_is_s[i]), 0); + } else if ((long) data->param[i] > MAX_OF_TYPE(NCURSES_INT2) || + (long) data->param[i] < 0) { + _tracef("BUG: problem with tparm parameter #%d of %d", + i + 1, data->num_actual); + break; + } else { + save_number(tps, ", %d", (int) data->param[i], 0); + } + } + _tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(string), TPS(out_buff)); + TPS(out_used) = 0; + _nc_unlock_global(tracef); + } +} + +#else +#define tparm_trace_call(tps, string, data) /* nothing */ +#endif /* TRACE */ + +#define init_vars(name) \ + if (!name##_used) { \ + name##_used = TRUE; \ + memset(name##_vars, 0, sizeof(name##_vars)); \ + } + +static NCURSES_INLINE char * +tparam_internal(TPARM_STATE *tps, const char *string, TPARM_DATA *data) +{ + int number; + int len; + int level; + int x, y; + int i; + const char *s; + const char *cp = string; + size_t len2 = strlen(cp); + bool incremented_two = FALSE; + bool termcap_hack = tparm_tc_compat(tps, data); + /* + * SVr4 curses stores variables 'A' to 'Z' in the TERMINAL structure (so + * they are initialized once to zero), and variables 'a' to 'z' on the + * stack in tparm, referring to the former as "static" and the latter as + * "dynamic". However, it makes no check to ensure that the "dynamic" + * variables are initialized. + * + * Solaris xpg4 curses makes no distinction between the upper/lower, and + * stores the common set of 26 variables on the stack, without initializing + * them. + * + * In ncurses, both sets of variables are initialized on the first use. + */ + bool dynamic_used = FALSE; + int dynamic_vars[NUM_VARS]; + + tparm_trace_call(tps, string, data); + + if (TPS(fmt_buff) == NULL) { + T((T_RETURN(""))); + return NULL; + } + + while ((cp - string) < (int) len2) { + if (*cp != '%') { + save_char(tps, UChar(*cp)); + } else { + TPS(tparam_base) = cp++; + cp = parse_format(cp, TPS(fmt_buff), &len); + switch (*cp) { + default: + break; + case '%': + save_char(tps, '%'); + break; + + case 'd': /* FALLTHRU */ + case 'o': /* FALLTHRU */ + case 'x': /* FALLTHRU */ + case 'X': /* FALLTHRU */ + x = npop(tps); + save_number(tps, TPS(fmt_buff), x, len); + break; + + case 'c': /* FALLTHRU */ + x = npop(tps); + save_char(tps, x); + break; + +#ifdef EXP_XTERM_1005 + case 'u': + { + unsigned char target[10]; + unsigned source = (unsigned) npop(tps); + int rc = _nc_conv_to_utf8(target, source, (unsigned) + sizeof(target)); + int n; + for (n = 0; n < rc; ++n) { + save_char(tps, target[n]); + } + } + break; +#endif + case 'l': + s = spop(tps); + npush(tps, (int) strlen(s)); + break; + + case 's': + s = spop(tps); + save_text(tps, TPS(fmt_buff), s, len); + break; + + case 'p': + cp++; + i = (UChar(*cp) - '1'); + if (i >= 0 && i < NUM_PARM) { + if (data->p_is_s[i]) { + spush(tps, data->p_is_s[i]); + } else { + npush(tps, (int) data->param[i]); + } + } + break; + + case 'P': + cp++; + if (isUPPER(*cp)) { + i = (UChar(*cp) - 'A'); + TPS(static_vars)[i] = npop(tps); + } else if (isLOWER(*cp)) { + i = (UChar(*cp) - 'a'); + init_vars(dynamic); + dynamic_vars[i] = npop(tps); + } + break; + + case 'g': + cp++; + if (isUPPER(*cp)) { + i = (UChar(*cp) - 'A'); + npush(tps, TPS(static_vars)[i]); + } else if (isLOWER(*cp)) { + i = (UChar(*cp) - 'a'); + init_vars(dynamic); + npush(tps, dynamic_vars[i]); + } + break; + + case S_QUOTE: + cp++; + npush(tps, UChar(*cp)); + cp++; + break; + + case L_BRACE: + number = 0; + cp++; + while (isdigit(UChar(*cp))) { + number = (number * 10) + (UChar(*cp) - '0'); + cp++; + } + npush(tps, number); + break; + + case '+': + y = npop(tps); + x = npop(tps); + npush(tps, x + y); + break; + + case '-': + y = npop(tps); + x = npop(tps); + npush(tps, x - y); + break; + + case '*': + y = npop(tps); + x = npop(tps); + npush(tps, x * y); + break; + + case '/': + y = npop(tps); + x = npop(tps); + npush(tps, y ? (x / y) : 0); + break; + + case 'm': + y = npop(tps); + x = npop(tps); + npush(tps, y ? (x % y) : 0); + break; + + case 'A': + y = npop(tps); + x = npop(tps); + npush(tps, y && x); + break; + + case 'O': + y = npop(tps); + x = npop(tps); + npush(tps, y || x); + break; + + case '&': + y = npop(tps); + x = npop(tps); + npush(tps, x & y); + break; + + case '|': + y = npop(tps); + x = npop(tps); + npush(tps, x | y); + break; + + case '^': + y = npop(tps); + x = npop(tps); + npush(tps, x ^ y); + break; + + case '=': + y = npop(tps); + x = npop(tps); + npush(tps, x == y); + break; + + case '<': + y = npop(tps); + x = npop(tps); + npush(tps, x < y); + break; + + case '>': + y = npop(tps); + x = npop(tps); + npush(tps, x > y); + break; + + case '!': + x = npop(tps); + npush(tps, !x); + break; + + case '~': + x = npop(tps); + npush(tps, ~x); + break; + + case 'i': + /* + * Increment the first two parameters -- if they are numbers + * rather than strings. As a side effect, assign into the + * stack; if this is termcap, then the stack was populated + * using the termcap hack above rather than via the terminfo + * 'p' case. + */ + if (!incremented_two) { + incremented_two = TRUE; + if (data->p_is_s[0] == NULL) { + data->param[0]++; + if (termcap_hack) + TPS(stack)[0].data.num = (int) data->param[0]; + } + if (data->p_is_s[1] == NULL) { + data->param[1]++; + if (termcap_hack) + TPS(stack)[1].data.num = (int) data->param[1]; + } + } + break; + + case '?': + break; + + case 't': + x = npop(tps); + if (!x) { + /* scan forward for %e or %; at level zero */ + cp++; + level = 0; + while (*cp) { + if (*cp == '%') { + cp++; + if (*cp == '?') + level++; + else if (*cp == ';') { + if (level > 0) + level--; + else + break; + } else if (*cp == 'e' && level == 0) + break; + } + + if (*cp) + cp++; + } + } + break; + + case 'e': + /* scan forward for a %; at level zero */ + cp++; + level = 0; + while (*cp) { + if (*cp == '%') { + cp++; + if (*cp == '?') + level++; + else if (*cp == ';') { + if (level > 0) + level--; + else + break; + } + } + + if (*cp) + cp++; + } + break; + + case ';': + break; + + } /* endswitch (*cp) */ + } /* endelse (*cp == '%') */ + + if (*cp == '\0') + break; + + cp++; + } /* endwhile (*cp) */ + + get_space(tps, (size_t) 1); + TPS(out_buff)[TPS(out_used)] = '\0'; + + if (TPS(stack_ptr) && !_nc_tparm_err) { + DEBUG(2, ("tparm: stack has %d item%s on return", + TPS(stack_ptr), + TPS(stack_ptr) == 1 ? "" : "s")); + _nc_tparm_err++; + } + + T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff)))); + return (TPS(out_buff)); +} + +#ifdef CUR +/* + * Only a few standard capabilities accept string parameters. The others that + * are parameterized accept only numeric parameters. + */ +static bool +check_string_caps(const TPARM_DATA *data, const char *string) +{ + bool result = FALSE; + +#define CHECK_CAP(name) (VALID_STRING(name) && !strcmp(name, string)) + + /* + * Disallow string parameters unless we can check them against a terminal + * description. + */ + if (cur_term != NULL) { + int want_type = 0; + + if (CHECK_CAP(pkey_key)) + want_type = 2; /* function key #1, type string #2 */ + else if (CHECK_CAP(pkey_local)) + want_type = 2; /* function key #1, execute string #2 */ + else if (CHECK_CAP(pkey_xmit)) + want_type = 2; /* function key #1, transmit string #2 */ + else if (CHECK_CAP(plab_norm)) + want_type = 2; /* label #1, show string #2 */ +#ifdef pkey_plab + else if (CHECK_CAP(pkey_plab)) + want_type = 6; /* function key #1, type string #2, show string #3 */ +#endif +#if NCURSES_XNAMES + else { + const char *check; + + check = tigetstr(UserCap(Cs)); + if (CHECK_CAP(check)) + want_type = 1; /* style #1 */ + + check = tigetstr(UserCap(Ms)); + if (CHECK_CAP(check)) + want_type = 3; /* storage unit #1, content #2 */ + } +#endif + + if (want_type == data->tparm_type) { + result = TRUE; + } else { + T(("unexpected string-parameter")); + } + } + return result; +} + +#define ValidCap(allow_strings) (myData.tparm_type == 0 || \ + (allow_strings && \ + check_string_caps(&myData, string))) +#else +#define ValidCap(allow_strings) 1 +#endif + +#if NCURSES_TPARM_VARARGS + +NCURSES_EXPORT(char *) +tparm(const char *string, ...) +{ + TPARM_STATE *tps = get_tparm_state(cur_term); + TPARM_DATA myData; + char *result = NULL; + + _nc_tparm_err = 0; +#ifdef TRACE + tps->tname = "tparm"; +#endif /* TRACE */ + + if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(TRUE)) { + va_list ap; + + va_start(ap, string); + tparm_copy_valist(&myData, TRUE, ap); + va_end(ap); + + result = tparam_internal(tps, string, &myData); + } + return result; +} + +#else /* !NCURSES_TPARM_VARARGS */ + +NCURSES_EXPORT(char *) +tparm(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) +{ + TPARM_STATE *tps = get_tparm_state(cur_term); + TPARM_DATA myData; + char *result = NULL; + + _nc_tparm_err = 0; +#ifdef TRACE + tps->tname = "tparm"; +#endif /* TRACE */ + +#define string_ok (sizeof(char*) <= sizeof(TPARM_ARG)) + + if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(string_ok)) { + + myData.param[0] = a1; + myData.param[1] = a2; + myData.param[2] = a3; + myData.param[3] = a4; + myData.param[4] = a5; + myData.param[5] = a6; + myData.param[6] = a7; + myData.param[7] = a8; + myData.param[8] = a9; + + result = tparam_internal(tps, string, &myData); + } + return result; +} + +#endif /* NCURSES_TPARM_VARARGS */ + +NCURSES_EXPORT(char *) +tiparm(const char *string, ...) +{ + TPARM_STATE *tps = get_tparm_state(cur_term); + TPARM_DATA myData; + char *result = NULL; + + _nc_tparm_err = 0; +#ifdef TRACE + tps->tname = "tiparm"; +#endif /* TRACE */ + + if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(TRUE)) { + va_list ap; + + va_start(ap, string); + tparm_copy_valist(&myData, FALSE, ap); + va_end(ap); + + result = tparam_internal(tps, string, &myData); + } + return result; +} + +/* + * Use tparm if the formatting string matches the expected number of parameters + * counting string-parameters. + */ +NCURSES_EXPORT(char *) +tiparm_s(int num_expected, int tparm_type, const char *string, ...) +{ + TPARM_STATE *tps = get_tparm_state(cur_term); + TPARM_DATA myData; + char *result = NULL; + + _nc_tparm_err = 0; +#ifdef TRACE + tps->tname = "tiparm_s"; +#endif /* TRACE */ + if (num_expected >= 0 && + num_expected <= 9 && + tparm_type >= 0 && + tparm_type < 7 && /* limit to 2 string parameters */ + tparm_setup(cur_term, string, &myData) == OK && + myData.tparm_type == tparm_type && + myData.num_actual == num_expected) { + va_list ap; + + va_start(ap, string); + tparm_copy_valist(&myData, FALSE, ap); + va_end(ap); + + result = tparam_internal(tps, string, &myData); + } + return result; +} + +/* + * Analyze the formatting string, return the analysis. + */ +NCURSES_EXPORT(int) +tiscan_s(int *num_expected, int *tparm_type, const char *string) +{ + TPARM_DATA myData; + int result = ERR; + +#ifdef TRACE + TPARM_STATE *tps = get_tparm_state(cur_term); + tps->tname = "tiscan_s"; +#endif /* TRACE */ + + if (tparm_setup(cur_term, string, &myData) == OK) { + *num_expected = myData.num_actual; + *tparm_type = myData.tparm_type; + result = OK; + } + return result; +} + +/* + * The internal-use flavor ensures that parameters are numbers, not strings. + * In addition to ensuring that they are numbers, it ensures that the parameter + * count is consistent with intended usage. + * + * Unlike the general-purpose tparm/tiparm, these internal calls are fairly + * well defined: + * + * expected == 0 - not applicable + * expected == 1 - set color, or vertical/horizontal addressing + * expected == 2 - cursor addressing + * expected == 4 - initialize color or color pair + * expected == 9 - set attributes + * + * Only for the last case (set attributes) should a parameter be optional. + * Also, a capability which calls for more parameters than expected should be + * ignored. + * + * Return a null if the parameter-checks fail. Otherwise, return a pointer to + * the formatted capability string. + */ +NCURSES_EXPORT(char *) +_nc_tiparm(int expected, const char *string, ...) +{ + TPARM_STATE *tps = get_tparm_state(cur_term); + TPARM_DATA myData; + char *result = NULL; + + _nc_tparm_err = 0; + T((T_CALLED("_nc_tiparm(%d, %s, ...)"), expected, _nc_visbuf(string))); +#ifdef TRACE + tps->tname = "_nc_tiparm"; +#endif /* TRACE */ + + if (tparm_setup(cur_term, string, &myData) == OK && ValidCap(FALSE)) { +#ifdef CUR + if (myData.num_actual != expected && cur_term != NULL) { + int needed = expected; + if (CHECK_CAP(to_status_line)) { + needed = 0; /* allow for xterm's status line */ + } else if (CHECK_CAP(set_a_background)) { + needed = 0; /* allow for monochrome fakers */ + } else if (CHECK_CAP(set_a_foreground)) { + needed = 0; + } else if (CHECK_CAP(set_background)) { + needed = 0; + } else if (CHECK_CAP(set_foreground)) { + needed = 0; + } +#if NCURSES_XNAMES + else { + const char *check; + + check = tigetstr(UserCap(xm)); + if (CHECK_CAP(check)) { + needed = 3; + } + check = tigetstr(UserCap(S0)); + if (CHECK_CAP(check)) { + needed = 0; /* used in screen-base */ + } + } +#endif + if (myData.num_actual >= needed && myData.num_actual <= expected) + expected = myData.num_actual; + } +#endif + if (myData.num_actual == 0 && expected) { + T(("missing parameter%s, expected %s%d", + expected > 1 ? "s" : "", + expected == 9 ? "up to " : "", + expected)); + } else if (myData.num_actual > expected) { + T(("too many parameters, have %d, expected %d", + myData.num_actual, + expected)); + } else if (expected != 9 && myData.num_actual != expected) { + T(("expected %d parameters, have %d", + myData.num_actual, + expected)); + } else { + va_list ap; + + va_start(ap, string); + tparm_copy_valist(&myData, FALSE, ap); + va_end(ap); + + result = tparam_internal(tps, string, &myData); + } + } + returnPtr(result); +} + +/* + * Improve tic's checks by resetting the terminfo "static variables" before + * calling functions which may update them. + */ +NCURSES_EXPORT(void) +_nc_reset_tparm(TERMINAL *term) +{ + TPARM_STATE *tps = get_tparm_state(term); + memset(TPS(static_vars), 0, sizeof(TPS(static_vars))); +} diff --git a/ncurses/ncurses/tinfo/lib_tputs.c b/ncurses/ncurses/tinfo/lib_tputs.c new file mode 100644 index 0000000000..d90efbb078 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_tputs.c @@ -0,0 +1,463 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * tputs.c + * delay_output() + * _nc_outch() + * tputs() + * + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +#include +#include /* ospeed */ +#include + +MODULE_ID("$Id: lib_tputs.c,v 1.116 2025/01/12 00:41:56 tom 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(int) _nc_nulls_sent = 0; + +#if NCURSES_NO_PADDING +NCURSES_EXPORT(void) +_nc_set_no_padding(SCREEN *sp) +{ + bool no_padding = (getenv("NCURSES_NO_PADDING") != NULL); + + 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 + +#if NCURSES_SP_FUNCS +#define SetOutCh(func) if (SP_PARM) SP_PARM->_outch = func; else _nc_prescreen._outch = func +#define GetOutCh() (SP_PARM ? SP_PARM->_outch : _nc_prescreen._outch) +#else +#define SetOutCh(func) static_outch = func +#define GetOutCh() static_outch +static NCURSES_SP_OUTC static_outch = NCURSES_SP_NAME(_nc_outch); +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(delay_output) (NCURSES_SP_DCLx int ms) +{ + T((T_CALLED("delay_output(%p,%d)"), (void *) SP_PARM, ms)); + + if (ms > MAX_DELAY_MSECS) + ms = MAX_DELAY_MSECS; + + if (!HasTInfoTerminal(SP_PARM)) + returnCode(ERR); + + if (no_pad_char) { + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + napms(ms); + } else { + NCURSES_SP_OUTC my_outch = GetOutCh(); + register int nullcount; + + nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000); + for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--) + my_outch(NCURSES_SP_ARGx PC); + if (my_outch == NCURSES_SP_NAME(_nc_outch)) + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + } + + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +delay_output(int ms) +{ + return NCURSES_SP_NAME(delay_output) (CURRENT_SCREEN, ms); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0) +{ + T((T_CALLED("_nc_flush(%p)"), (void *) SP_PARM)); + if (SP_PARM != NULL && SP_PARM->_ofd >= 0) { + TR(TRACE_CHARPUT, ("ofd:%d inuse:%lu buffer:%p", + SP_PARM->_ofd, + (unsigned long) SP_PARM->out_inuse, + SP_PARM->out_buffer)); + if (SP_PARM->out_inuse) { + char *buf = SP_PARM->out_buffer; + size_t amount = SP_PARM->out_inuse; + + TR(TRACE_CHARPUT, ("flushing %ld/%ld bytes", + (unsigned long) amount, _nc_outchars)); + while (amount) { + ssize_t res = write(SP_PARM->_ofd, buf, amount); + if (res > 0) { + /* if the write was incomplete, try again */ + amount -= (size_t) res; + buf += res; + } else if (errno == EAGAIN) { + continue; + } else if (errno == EINTR) { + continue; + } else { + break; /* an error we can not recover from */ + } + } + } else if (SP_PARM->out_buffer == NULL) { + TR(TRACE_CHARPUT, ("flushing stdout/stderr")); + fflush(stdout); + fflush(stderr); + } + } else { + TR(TRACE_CHARPUT, ("flushing stdout/stderr")); + fflush(stdout); + fflush(stderr); + } + if (SP_PARM != NULL) + SP_PARM->out_inuse = 0; + returnVoid; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_flush(void) +{ + NCURSES_SP_NAME(_nc_flush) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch) +{ + int rc = OK; + + COUNT_OUTCHARS(1); + + if (HasTInfoTerminal(SP_PARM) + && SP_PARM != NULL) { + if (SP_PARM->out_buffer != NULL) { + if (SP_PARM->out_inuse + 1 >= SP_PARM->out_limit) + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + SP_PARM->out_buffer[SP_PARM->out_inuse++] = (char) ch; + } else { + char tmp = (char) ch; + /* + * POSIX says write() is safe in a signal handler, but the + * buffered I/O is not. + */ + if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, (size_t) 1) == -1) + rc = ERR; + } + } else { + char tmp = (char) ch; + if (write(fileno(stdout), &tmp, (size_t) 1) == -1) + rc = ERR; + } + return rc; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_outch(int ch) +{ + return NCURSES_SP_NAME(_nc_outch) (CURRENT_SCREEN, ch); +} +#endif + +/* + * This is used for the putp special case. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_putchar) (NCURSES_SP_DCLx int ch) +{ + (void) SP_PARM; + return putchar(ch); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_putchar(int ch) +{ + return putchar(ch); +} +#endif + +/* + * putp is special - per documentation it calls tputs with putchar as the + * parameter for outputting characters. This means that it uses stdio, which + * is not signal-safe. Applications call this entrypoint; we do not call it + * from within the library. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(putp) (NCURSES_SP_DCLx const char *string) +{ + return NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + string, 1, NCURSES_SP_NAME(_nc_putchar)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +putp(const char *string) +{ + return NCURSES_SP_NAME(putp) (CURRENT_SCREEN, string); +} +#endif + +/* + * Use these entrypoints rather than "putp" within the library. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_DCLx + const char *name GCC_UNUSED, + const char *string) +{ + int rc = ERR; + + if (string != NULL) { + TPUTS_TRACE(name); + rc = NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + string, 1, NCURSES_SP_NAME(_nc_outch)); + } + return rc; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_putp(const char *name, const char *string) +{ + return NCURSES_SP_NAME(_nc_putp) (CURRENT_SCREEN, name, string); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx + const char *string, + int affcnt, + NCURSES_SP_OUTC outc) +{ + NCURSES_SP_OUTC my_outch = GetOutCh(); + bool always_delay = FALSE; + bool normal_delay = FALSE; + int number; +#if BSD_TPUTS + int trailpad; +#endif /* BSD_TPUTS */ + +#ifdef TRACE + if (USE_TRACEF(TRACE_TPUTS)) { + char addrbuf[32]; + TR_FUNC_BFR(1); + + if (outc == NCURSES_SP_NAME(_nc_outch)) { + _nc_STRCPY(addrbuf, "_nc_outch", sizeof(addrbuf)); + } else { + _nc_SPRINTF(addrbuf, _nc_SLIMIT(sizeof(addrbuf)) "%s", + TR_FUNC_ARG(0, outc)); + } + if (_nc_tputs_trace) { + _tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace, + _nc_visbuf(string), affcnt, addrbuf); + } else { + _tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf); + } + TPUTS_TRACE(NULL); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + + if (!VALID_STRING(string)) + return ERR; + + if (SP_PARM != NULL && HasTInfoTerminal(SP_PARM)) { + if ( +#if NCURSES_SP_FUNCS + (SP_PARM != NULL && SP_PARM->_term == NULL) +#else + cur_term == NULL +#endif + ) { + always_delay = FALSE; + normal_delay = TRUE; + } else { + always_delay = (string == bell) || (string == flash_screen); + normal_delay = + !xon_xoff + && padding_baud_rate +#if NCURSES_NO_PADDING + && !GetNoPadding(SP_PARM) +#endif + && (_nc_baudrate(ospeed) >= padding_baud_rate); + } + } +#if BSD_TPUTS + /* + * This ugly kluge deals with the fact that some ancient BSD programs + * (like nethack) actually do the likes of tputs("50") to get delays. + */ + trailpad = 0; + if (isdigit(UChar(*string))) { + while (isdigit(UChar(*string))) { + trailpad = trailpad * 10 + (*string - '0'); + string++; + } + trailpad *= 10; + if (*string == '.') { + string++; + if (isdigit(UChar(*string))) { + trailpad += (*string - '0'); + string++; + } + while (isdigit(UChar(*string))) + string++; + } + + if (*string == '*') { + trailpad *= affcnt; + string++; + } + } +#endif /* BSD_TPUTS */ + + SetOutCh(outc); /* redirect delay_output() */ + while (*string) { + if (*string != '$') + (*outc) (NCURSES_SP_ARGx *string); + else { + string++; + if (*string != '<') { + (*outc) (NCURSES_SP_ARGx '$'); + if (*string) + (*outc) (NCURSES_SP_ARGx *string); + } else { + bool mandatory; + + string++; + if ((!isdigit(UChar(*string)) && *string != '.') + || !strchr(string, '>')) { + (*outc) (NCURSES_SP_ARGx '$'); + (*outc) (NCURSES_SP_ARGx '<'); + continue; + } + + number = 0; + while (isdigit(UChar(*string))) { + number = number * 10 + (*string - '0'); + string++; + } + number *= 10; + if (*string == '.') { + string++; + if (isdigit(UChar(*string))) { + number += (*string - '0'); + string++; + } + while (isdigit(UChar(*string))) + string++; + } + + mandatory = FALSE; + while (*string == '*' || *string == '/') { + if (*string == '*') { + number *= affcnt; + string++; + } else { /* if (*string == '/') */ + mandatory = TRUE; + string++; + } + } + + if (number > 0 + && (always_delay + || normal_delay + || mandatory)) + NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx number / 10); + + } /* endelse (*string == '<') */ + } /* endelse (*string == '$') */ + + if (*string == '\0') + break; + + string++; + } + +#if BSD_TPUTS + /* + * Emit any BSD-style prefix padding that we've accumulated now. + */ + if (trailpad > 0 + && (always_delay || normal_delay)) + NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx trailpad / 10); +#endif /* BSD_TPUTS */ + + SetOutCh(my_outch); + return OK; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_outc_wrapper(SCREEN *sp, int c) +{ + if (NULL == sp) { + return fputc(c, stdout); + } else { + return sp->jump(c); + } +} + +NCURSES_EXPORT(int) +tputs(const char *string, int affcnt, int (*outc) (int)) +{ + SetSafeOutcWrapper(outc); + return NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx string, affcnt, _nc_outc_wrapper); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_ttyflags.c b/ncurses/ncurses/tinfo/lib_ttyflags.c new file mode 100644 index 0000000000..8049888a11 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_ttyflags.c @@ -0,0 +1,333 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* + * def_prog_mode() + * def_shell_mode() + * reset_prog_mode() + * reset_shell_mode() + * savetty() + * resetty() + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_ttyflags.c,v 1.40 2025/12/27 12:33:34 tom Exp $") + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf) +{ + TERMINAL *termp = TerminalOf(SP_PARM); + int result = OK; + + if (buf == NULL || termp == NULL) { + result = ERR; + } else { + +#if USE_TERM_DRIVER + if (SP_PARM != NULL) { + result = CallDriver_2(SP_PARM, td_sgmode, FALSE, buf); + } else { + result = ERR; + } +#else + for (;;) { + if (GET_TTY(termp->Filedes, buf) != 0) { + if (errno == EINTR) + continue; + result = ERR; + } + break; + } +#endif + + TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s", + termp ? termp->Filedes : -1, + _nc_trace_ttymode(buf))); + } + if (result == ERR && buf != NULL) + memset(buf, 0, sizeof(*buf)); + + return (result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_get_tty_mode(TTY * buf) +{ + return NCURSES_SP_NAME(_nc_get_tty_mode) (CURRENT_SCREEN, buf); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf) +{ + int result = OK; + + if (buf == NULL || SP_PARM == NULL) { + result = ERR; + } else { + TERMINAL *termp = TerminalOf(SP_PARM); + + if (NULL == termp) { + result = ERR; + } else { +#if USE_TERM_DRIVER + result = CallDriver_2(SP_PARM, td_sgmode, TRUE, buf); +#else + for (;;) { + if ((SET_TTY(termp->Filedes, buf) != 0) +#if USE_KLIBC_KBD + && !NC_ISATTY(termp->Filedes) +#endif + ) { + if (errno == EINTR) + continue; + if ((errno == ENOTTY) && (SP_PARM != NULL)) + SP_PARM->_notty = TRUE; + result = ERR; + } + break; + } +#endif + } + TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s", + termp ? termp->Filedes : -1, + _nc_trace_ttymode(buf))); + } + return (result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_set_tty_mode(TTY * buf) +{ + return NCURSES_SP_NAME(_nc_set_tty_mode) (CURRENT_SCREEN, buf); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0) +{ + int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("def_shell_mode(%p) ->term %p"), + (void *) SP_PARM, (void *) termp)); + + if (termp != NULL) { +#if USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, td_mode, FALSE, TRUE); +#else + /* + * If XTABS was on, remove the tab and backtab capabilities. + */ + if (_nc_get_tty_mode(&termp->Ottyb) == OK) { +#ifdef TERMIOS + if (termp->Ottyb.c_oflag & OFLAGS_TABS) + tab = back_tab = NULL; +#elif USE_NAMED_PIPES + /* noop */ +#else + if (termp->Ottyb.sg_flags & XTABS) + tab = back_tab = NULL; +#endif + rc = OK; + } +#endif + } + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +def_shell_mode(void) +{ + return NCURSES_SP_NAME(def_shell_mode) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0) +{ + int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("def_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp)); + + if (termp != NULL) { +#if USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, td_mode, TRUE, TRUE); +#else + /* + * Turn off the XTABS bit in the tty structure if it was on. + */ + if (_nc_get_tty_mode(&termp->Nttyb) == OK) { +#ifdef TERMIOS + termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS); +#elif USE_NAMED_PIPES + /* noop */ +#else + termp->Nttyb.sg_flags &= (unsigned) (~XTABS); +#endif + rc = OK; + } +#endif + } + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +def_prog_mode(void) +{ + return NCURSES_SP_NAME(def_prog_mode) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0) +{ + int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("reset_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp)); + + if (termp != NULL) { +#if USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, td_mode, TRUE, FALSE); +#else + if (_nc_set_tty_mode(&termp->Nttyb) == OK) { + if (SP_PARM) { + if (SP_PARM->_keypad_on) + _nc_keypad(SP_PARM, TRUE); + } + rc = OK; + } +#endif + } + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +reset_prog_mode(void) +{ + return NCURSES_SP_NAME(reset_prog_mode) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0) +{ + int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("reset_shell_mode(%p) ->term %p"), + (void *) SP_PARM, (void *) termp)); + + if (termp != NULL) { +#if USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, td_mode, FALSE, FALSE); +#else + if (SP_PARM) { + _nc_keypad(SP_PARM, FALSE); + _nc_flush(); + } + rc = _nc_set_tty_mode(&termp->Ottyb); +#endif + } + returnCode(rc); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +reset_shell_mode(void) +{ + return NCURSES_SP_NAME(reset_shell_mode) (CURRENT_SCREEN); +} +#endif + +static TTY * +saved_tty(NCURSES_SP_DCL0) +{ + TTY *result = NULL; + + if (SP_PARM != NULL) { + result = (TTY *) & (SP_PARM->_saved_tty); + } else { + if (_nc_prescreen.saved_tty == NULL) { + _nc_prescreen.saved_tty = typeCalloc(TTY, 1); + } + result = _nc_prescreen.saved_tty; + } + return result; +} + +/* +** savetty() and resetty() +** +*/ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(savetty) (NCURSES_SP_DCL0) +{ + T((T_CALLED("savetty(%p)"), (void *) SP_PARM)); + returnCode(NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx saved_tty(NCURSES_SP_ARG))); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +savetty(void) +{ + return NCURSES_SP_NAME(savetty) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(resetty) (NCURSES_SP_DCL0) +{ + T((T_CALLED("resetty(%p)"), (void *) SP_PARM)); + returnCode(NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx saved_tty(NCURSES_SP_ARG))); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +resetty(void) +{ + return NCURSES_SP_NAME(resetty) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/tinfo/lib_win32con.c b/ncurses/ncurses/tinfo/lib_win32con.c new file mode 100644 index 0000000000..d51aa476b3 --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_win32con.c @@ -0,0 +1,1271 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Thomas E. Dickey * + ****************************************************************************/ + +/* + * TODO - GetMousePos(POINT * result) from ntconio.c + */ + +#define TTY int /* FIXME: TTY originalMode */ +#include +#include + +#ifndef _O_BINARY +#define _O_BINARY 0 /* FIXME: not defined in MSYS2 base */ +#endif + +MODULE_ID("$Id: lib_win32con.c,v 1.50 2025/12/27 21:49:45 tom Exp $") + +#if defined(_NC_WINDOWS) + +#define CONTROL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) + +static bool read_screen_data(void); + +#define GenMap(vKey,key) MAKELONG(key, vKey) +/* *INDENT-OFF* */ +static const LONG keylist[] = +{ + GenMap(VK_PRIOR, KEY_PPAGE), + GenMap(VK_NEXT, KEY_NPAGE), + GenMap(VK_END, KEY_END), + GenMap(VK_HOME, KEY_HOME), + GenMap(VK_LEFT, KEY_LEFT), + GenMap(VK_UP, KEY_UP), + GenMap(VK_RIGHT, KEY_RIGHT), + GenMap(VK_DOWN, KEY_DOWN), + GenMap(VK_DELETE, KEY_DC), + GenMap(VK_INSERT, KEY_IC) +}; +static const LONG ansi_keys[] = +{ + GenMap(VK_PRIOR, 'I'), + GenMap(VK_NEXT, 'Q'), + GenMap(VK_END, 'O'), + GenMap(VK_HOME, 'H'), + GenMap(VK_LEFT, 'K'), + GenMap(VK_UP, 'H'), + GenMap(VK_RIGHT, 'M'), + GenMap(VK_DOWN, 'P'), + GenMap(VK_DELETE, 'S'), + GenMap(VK_INSERT, 'R') +}; +/* *INDENT-ON* */ +#define array_length(a) (sizeof(a)/sizeof(a[0])) +#define N_INI ((int)array_length(keylist)) +#define FKEYS 24 +#define MAPSIZE (FKEYS + N_INI) + +static bool console_initialized = FALSE; + +/* A process can only have a single console, so it is safe + to maintain all the information about it in a single + static structure. + */ +NCURSES_EXPORT_VAR(ConsoleInfo) _nc_CONSOLE; + +#define EnsureInit() (void)(console_initialized ? TRUE : _nc_console_checkinit(USE_NAMED_PIPES)) + +#define REQUIRED_MAX_V (DWORD)10 +#define REQUIRED_MIN_V (DWORD)0 +#define REQUIRED_BUILD (DWORD)17763 +/* + This function returns 0 if the Windows version has no support for + the modern Console interface, otherwise it returns 1 + */ +NCURSES_EXPORT(int) +_nc_console_vt_supported(void) +{ + OSVERSIONINFO osvi; + int res = 0; + + T((T_CALLED("lib_win32con::_nc_console_vt_supported"))); + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + GetVersionEx(&osvi); + T(("GetVersionEx returnedMajor=%lu, Minor=%lu, Build=%lu", + (unsigned long) osvi.dwMajorVersion, + (unsigned long) osvi.dwMinorVersion, + (unsigned long) osvi.dwBuildNumber)); + if (osvi.dwMajorVersion >= REQUIRED_MAX_V) { + if (osvi.dwMajorVersion == REQUIRED_MAX_V) { + if (((osvi.dwMinorVersion == REQUIRED_MIN_V) && + (osvi.dwBuildNumber >= REQUIRED_BUILD)) || + ((osvi.dwMinorVersion > REQUIRED_MIN_V))) + res = 1; + } else + res = 1; + } + returnCode(res); +} + +NCURSES_EXPORT(void) +_nc_console_size(int *Lines, int *Cols) +{ + EnsureInit(); + if (Lines != NULL && Cols != NULL) { + if (WINCONSOLE.buffered) { + *Lines = (int) (WINCONSOLE.SBI.dwSize.Y); + *Cols = (int) (WINCONSOLE.SBI.dwSize.X); + } else { + *Lines = (int) (WINCONSOLE.SBI.srWindow.Bottom + 1 - + WINCONSOLE.SBI.srWindow.Top); + *Cols = (int) (WINCONSOLE.SBI.srWindow.Right + 1 - + WINCONSOLE.SBI.srWindow.Left); + } + } +} + +/* Convert a file descriptor into a HANDLE + That's not necessarily a console HANDLE +*/ +NCURSES_EXPORT(HANDLE) +_nc_console_handle(int fd) +{ + intptr_t value = _get_osfhandle(fd); + return (HANDLE) value; +} + +/* Validate that a HANDLE is actually a + console HANDLE +*/ +static BOOL +IsConsoleHandle(HANDLE hdl) +{ + DWORD dwFlag = 0; + BOOL result = FALSE; + + T((T_CALLED("lib_win32con::IsConsoleHandle(HANDLE=%p"), hdl)); + + EnsureInit(); + + if (!GetConsoleMode(hdl, &dwFlag)) { + T(("GetConsoleMode failed")); + } else { + result = TRUE; + } + + returnBool(result); +} + +/* This is used when running in terminfo mode to discover, + whether or not the "terminal" is actually a Windows + Console. It is the responsibility of the console to deal + with the terminal escape sequences that are sent by + terminfo. + */ +NCURSES_EXPORT(int) +_nc_console_test(int fd) +{ + int code = 0; + HANDLE hdl = INVALID_HANDLE_VALUE; + T((T_CALLED("lib_win32con::_nc_console_test(%d)"), fd)); + hdl = _nc_console_handle(fd); + code = (int) IsConsoleHandle(hdl); + returnCode(code); +} + +#define OutHandle() ((WINCONSOLE.isTermInfoConsole || WINCONSOLE.progMode) ? WINCONSOLE.hdl : WINCONSOLE.out) + +NCURSES_EXPORT(void) +_nc_console_selectActiveHandle(void) +{ + if (WINCONSOLE.lastOut != WINCONSOLE.hdl) { + WINCONSOLE.lastOut = WINCONSOLE.hdl; + SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut); + } +} + +NCURSES_EXPORT(HANDLE) +_nc_console_fd2handle(int fd) +{ + HANDLE hdl = _nc_console_handle(fd); + if (hdl == WINCONSOLE.inp) { + T(("lib_win32con:validateHandle %d -> WINCONSOLE.inp", fd)); + } else if (hdl == WINCONSOLE.hdl) { + T(("lib_win32con:validateHandle %d -> WINCONSOLE.hdl", fd)); + } else if (hdl == WINCONSOLE.out) { + T(("lib_win32con:validateHandle %d -> WINCONSOLE.out", fd)); + } else if (hdl == GetStdHandle(STD_INPUT_HANDLE)) { + T(("lib_win32con:validateHandle %d -> STD_INPUT_HANDLE", fd)); + if (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode) { + hdl = WINCONSOLE.inp; + } + } else { + T(("lib_win32con:validateHandle %d maps to unknown HANDLE", fd)); + hdl = INVALID_HANDLE_VALUE; + } + if (hdl != INVALID_HANDLE_VALUE) { + if (hdl != WINCONSOLE.inp && (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode)) { + if (hdl == WINCONSOLE.out && hdl != WINCONSOLE.hdl) { + T(("lib_win32con:validateHandle forcing WINCONSOLE.out -> WINCONSOLE.hdl")); + hdl = WINCONSOLE.hdl; + } + } + } + return hdl; +} + +#if defined(_NC_WINDOWS) && USE_WINCONMODE +NCURSES_EXPORT(int) +_nc_console_setmode(HANDLE hdl, const TTY * arg) +{ + DWORD dwFlag = 0; + int code = ERR; + HANDLE alt; + + if (arg) { +#ifdef TRACE + TTY TRCTTY; +#define TRCTTYOUT(flag) TRCTTY.dwFlagOut = flag +#define TRCTTYIN(flag) TRCTTY.dwFlagIn = flag +#else +#define TRCTTYOUT(flag) +#define TRCTTYIN(flag) +#endif + T(("lib_win32con:_nc_console_setmode %s", _nc_trace_ttymode(arg))); + if (hdl == WINCONSOLE.inp) { + dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT | VT_FLAG_IN; + TRCTTYIN(dwFlag); + SetConsoleMode(hdl, dwFlag); + + alt = OutHandle(); + dwFlag = arg->dwFlagOut; + TRCTTYOUT(dwFlag); + SetConsoleMode(alt, dwFlag); + } else { + dwFlag = arg->dwFlagOut; + TRCTTYOUT(dwFlag); + SetConsoleMode(hdl, dwFlag); + + alt = WINCONSOLE.inp; + dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT; + TRCTTYIN(dwFlag); + SetConsoleMode(alt, dwFlag); + T(("effective mode set %s", _nc_trace_ttymode(&TRCTTY))); + } + code = OK; + } + return (code); +} + +NCURSES_EXPORT(int) +_nc_console_getmode(HANDLE hdl, TTY * arg) +{ + int code = ERR; + + if (arg) { + DWORD dwFlag = 0; + HANDLE alt; + + if (hdl == WINCONSOLE.inp) { + if (GetConsoleMode(hdl, &dwFlag)) { + arg->dwFlagIn = dwFlag; + alt = OutHandle(); + if (GetConsoleMode(alt, &dwFlag)) { + arg->dwFlagOut = dwFlag; + code = OK; + } + } + } else { + if (GetConsoleMode(hdl, &dwFlag)) { + arg->dwFlagOut = dwFlag; + alt = WINCONSOLE.inp; + if (GetConsoleMode(alt, &dwFlag)) { + arg->dwFlagIn = dwFlag; + code = OK; + } + } + } + } + T(("lib_win32con:_nc_console_getmode %s", _nc_trace_ttymode(arg))); + return (code); +} +#endif /* defined(_NC_WINDOWS) && USE_WINCONMODE */ + +NCURSES_EXPORT(int) +_nc_console_flush(HANDLE hdl) +{ + int code = OK; + + T((T_CALLED("lib_win32con::_nc_console_flush(hdl=%p"), hdl)); + + if (hdl != INVALID_HANDLE_VALUE) { + if (hdl == WINCONSOLE.hdl || + hdl == WINCONSOLE.inp || + hdl == WINCONSOLE.out) { + if (!FlushConsoleInputBuffer(WINCONSOLE.inp)) + code = ERR; + } else { + code = ERR; + T(("_nc_console_flush not requesting a handle owned by console.")); + } + } + returnCode(code); +} + +NCURSES_EXPORT(WORD) +_nc_console_MapColor(bool fore, int color) +{ + static const int _cmap[] = + {0, 4, 2, 6, 1, 5, 3, 7}; + int a; + if (color < 0 || color > 7) + a = fore ? 7 : 0; + else + a = _cmap[color]; + if (!fore) + a = a << 4; + return (WORD) a; +} + +/* + * Attempt to save the screen contents. PDCurses does this if + * PDC_RESTORE_SCREEN is set, giving the same visual appearance on + * restoration as if the library had allocated a console buffer. MSDN + * says that the data which can be read is limited to 64Kb (and may be + * less). + */ +static bool +save_original_screen(void) +{ + bool result = FALSE; + + WINCONSOLE.save_region.Top = 0; + WINCONSOLE.save_region.Left = 0; + WINCONSOLE.save_region.Bottom = (SHORT) (WINCONSOLE.SBI.dwSize.Y - 1); + WINCONSOLE.save_region.Right = (SHORT) (WINCONSOLE.SBI.dwSize.X - 1); + + if (read_screen_data()) { + result = TRUE; + } else { + + WINCONSOLE.save_region.Top = WINCONSOLE.SBI.srWindow.Top; + WINCONSOLE.save_region.Left = WINCONSOLE.SBI.srWindow.Left; + WINCONSOLE.save_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom; + WINCONSOLE.save_region.Right = WINCONSOLE.SBI.srWindow.Right; + + WINCONSOLE.window_only = TRUE; + + if (read_screen_data()) { + result = TRUE; + } + } + + T(("... save original screen contents %s", result ? "ok" : "err")); + return result; +} + +#if defined(_NC_WINDOWS) +static bool +restore_original_screen(void) +{ + COORD bufferCoord; + bool result = FALSE; + SMALL_RECT save_region = WINCONSOLE.save_region; + + T(("... restoring %s", + WINCONSOLE.window_only ? "window" : "entire buffer")); + + bufferCoord.X = (SHORT) (WINCONSOLE.window_only ? + WINCONSOLE.SBI.srWindow.Left : 0); + bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ? + WINCONSOLE.SBI.srWindow.Top : 0); + + if (write_screen(WINCONSOLE.hdl, + WINCONSOLE.save_screen, + WINCONSOLE.save_size, + bufferCoord, + &save_region)) { + result = TRUE; + SetConsoleCursorPosition(WINCONSOLE.hdl, WINCONSOLE.save_SBI.dwCursorPosition); + T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)", + WINCONSOLE.save_size.Y, + WINCONSOLE.save_size.X, + save_region.Top, + save_region.Left, + save_region.Bottom, + save_region.Right)); + } else { + T(("... restore original screen contents err")); + } + return result; +} +#endif + +static bool +read_screen_data(void) +{ + bool result = FALSE; + COORD bufferCoord; + size_t want; + + WINCONSOLE.save_size.X = (SHORT) (WINCONSOLE.save_region.Right + - WINCONSOLE.save_region.Left + 1); + WINCONSOLE.save_size.Y = (SHORT) (WINCONSOLE.save_region.Bottom + - WINCONSOLE.save_region.Top + 1); + + want = (size_t) (WINCONSOLE.save_size.X * WINCONSOLE.save_size.Y); + + if ((WINCONSOLE.save_screen = malloc(want * sizeof(CHAR_INFO))) != NULL) { + bufferCoord.X = (SHORT) (WINCONSOLE.window_only + ? WINCONSOLE.SBI.srWindow.Left + : 0); + bufferCoord.Y = (SHORT) (WINCONSOLE.window_only + ? WINCONSOLE.SBI.srWindow.Top + : 0); + + T(("... reading console %s %dx%d into %d,%d - %d,%d at %d,%d", + WINCONSOLE.window_only ? "window" : "buffer", + WINCONSOLE.save_size.Y, WINCONSOLE.save_size.X, + WINCONSOLE.save_region.Top, + WINCONSOLE.save_region.Left, + WINCONSOLE.save_region.Bottom, + WINCONSOLE.save_region.Right, + bufferCoord.Y, + bufferCoord.X)); + + if (read_screen(WINCONSOLE.hdl, + WINCONSOLE.save_screen, + WINCONSOLE.save_size, + bufferCoord, + &WINCONSOLE.save_region)) { + result = TRUE; + } else { + T((" error %#lx", (unsigned long) GetLastError())); + FreeAndNull(WINCONSOLE.save_screen); + } + } + + return result; +} + +NCURSES_EXPORT(bool) +_nc_console_get_SBI(void) +{ + bool rc = FALSE; + if (GetConsoleScreenBufferInfo(WINCONSOLE.hdl, &(WINCONSOLE.SBI))) { + T(("GetConsoleScreenBufferInfo")); + T(("... buffer(X:%d Y:%d)", + WINCONSOLE.SBI.dwSize.X, + WINCONSOLE.SBI.dwSize.Y)); + T(("... window(X:%d Y:%d)", + WINCONSOLE.SBI.dwMaximumWindowSize.X, + WINCONSOLE.SBI.dwMaximumWindowSize.Y)); + T(("... cursor(X:%d Y:%d)", + WINCONSOLE.SBI.dwCursorPosition.X, + WINCONSOLE.SBI.dwCursorPosition.Y)); + T(("... display(Top:%d Bottom:%d Left:%d Right:%d)", + WINCONSOLE.SBI.srWindow.Top, + WINCONSOLE.SBI.srWindow.Bottom, + WINCONSOLE.SBI.srWindow.Left, + WINCONSOLE.SBI.srWindow.Right)); + if (WINCONSOLE.buffered) { + WINCONSOLE.origin.X = 0; + WINCONSOLE.origin.Y = 0; + } else { + WINCONSOLE.origin.X = WINCONSOLE.SBI.srWindow.Left; + WINCONSOLE.origin.Y = WINCONSOLE.SBI.srWindow.Top; + } + rc = TRUE; + } else { + T(("GetConsoleScreenBufferInfo ERR")); + } + return rc; +} + +#define MIN_WIDE 80 +#define MIN_HIGH 24 + +/* + * In "normal" mode, reset the buffer- and window-sizes back to their original values. + */ +NCURSES_EXPORT(void) +_nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info) +{ + SMALL_RECT rect; + COORD coord; + bool changed = FALSE; + + T((T_CALLED("lib_win32con::_nc_console_set_scrollback(%s)"), + (normal + ? "normal" + : "application"))); + + T(("... SBI.srWindow %d,%d .. %d,%d", + info->srWindow.Top, + info->srWindow.Left, + info->srWindow.Bottom, + info->srWindow.Right)); + T(("... SBI.dwSize %dx%d", + info->dwSize.Y, + info->dwSize.X)); + + if (normal) { + rect = info->srWindow; + coord = info->dwSize; + if (memcmp(info, &WINCONSOLE.SBI, sizeof(*info)) != 0) { + changed = TRUE; + WINCONSOLE.SBI = *info; + } + } else { + int high = info->srWindow.Bottom - info->srWindow.Top + 1; + int wide = info->srWindow.Right - info->srWindow.Left + 1; + + if (high < MIN_HIGH) { + T(("... height %d < %d", high, MIN_HIGH)); + high = MIN_HIGH; + changed = TRUE; + } + if (wide < MIN_WIDE) { + T(("... width %d < %d", wide, MIN_WIDE)); + wide = MIN_WIDE; + changed = TRUE; + } + + rect.Left = + rect.Top = 0; + rect.Right = (SHORT) (wide - 1); + rect.Bottom = (SHORT) (high - 1); + + coord.X = (SHORT) wide; + coord.Y = (SHORT) high; + + if (info->dwSize.Y != high || + info->dwSize.X != wide || + info->srWindow.Top != 0 || + info->srWindow.Left != 0) { + changed = TRUE; + } + + } + + if (changed) { + T(("... coord %d,%d", coord.Y, coord.X)); + T(("... rect %d,%d - %d,%d", + rect.Top, rect.Left, + rect.Bottom, rect.Right)); + SetConsoleScreenBufferSize(WINCONSOLE.hdl, coord); /* dwSize */ + SetConsoleWindowInfo(WINCONSOLE.hdl, TRUE, &rect); /* srWindow */ + _nc_console_get_SBI(); + } + returnVoid; +} + +static ULONGLONG +tdiff(FILETIME fstart, FILETIME fend) +{ + ULARGE_INTEGER ustart; + ULARGE_INTEGER uend; + ULONGLONG diff; + + ustart.LowPart = fstart.dwLowDateTime; + ustart.HighPart = fstart.dwHighDateTime; + uend.LowPart = fend.dwLowDateTime; + uend.HighPart = fend.dwHighDateTime; + + diff = (uend.QuadPart - ustart.QuadPart) / 10000; + return diff; +} + +static int +Adjust(int milliseconds, int diff) +{ + if (milliseconds != NC_INFINITY) { + milliseconds -= diff; + if (milliseconds < 0) + milliseconds = 0; + } + return milliseconds; +} + +#define BUTTON_MASK (FROM_LEFT_1ST_BUTTON_PRESSED | \ + FROM_LEFT_2ND_BUTTON_PRESSED | \ + FROM_LEFT_3RD_BUTTON_PRESSED | \ + FROM_LEFT_4TH_BUTTON_PRESSED | \ + RIGHTMOST_BUTTON_PRESSED) + +static mmask_t +decode_mouse(const SCREEN *sp, int mask) +{ + mmask_t result = 0; + + (void) sp; + assert(sp && console_initialized); + + if (mask & FROM_LEFT_1ST_BUTTON_PRESSED) + result |= BUTTON1_PRESSED; + if (mask & FROM_LEFT_2ND_BUTTON_PRESSED) + result |= BUTTON2_PRESSED; + if (mask & FROM_LEFT_3RD_BUTTON_PRESSED) + result |= BUTTON3_PRESSED; + if (mask & FROM_LEFT_4TH_BUTTON_PRESSED) + result |= BUTTON4_PRESSED; + + if (mask & RIGHTMOST_BUTTON_PRESSED) { + switch (WINCONSOLE.numButtons) { + case 1: + result |= BUTTON1_PRESSED; + break; + case 2: + result |= BUTTON2_PRESSED; + break; + case 3: + result |= BUTTON3_PRESSED; + break; + case 4: + result |= BUTTON4_PRESSED; + break; + } + } + + return result; +} + +#define AdjustY() (WINCONSOLE.buffered \ + ? 0 \ + : (int) WINCONSOLE.SBI.srWindow.Top) + +static bool +handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer) +{ + MEVENT work; + bool result = FALSE; + + assert(sp); + + sp->_drv_mouse_old_buttons = sp->_drv_mouse_new_buttons; + sp->_drv_mouse_new_buttons = mer.dwButtonState & BUTTON_MASK; + + /* + * We're only interested if the button is pressed or released. + * FIXME: implement continuous event-tracking. + */ + if (sp->_drv_mouse_new_buttons != sp->_drv_mouse_old_buttons) { + memset(&work, 0, sizeof(work)); + + if (sp->_drv_mouse_new_buttons) { + work.bstate |= decode_mouse(sp, sp->_drv_mouse_new_buttons); + } else { + /* cf: BUTTON_PRESSED, BUTTON_RELEASED */ + work.bstate |= (decode_mouse(sp, sp->_drv_mouse_old_buttons) + >> 1); + result = TRUE; + } + + work.x = mer.dwMousePosition.X; + work.y = mer.dwMousePosition.Y - AdjustY(); + + sp->_drv_mouse_fifo[sp->_drv_mouse_tail] = work; + sp->_drv_mouse_tail += 1; + } + return result; +} + +static int +rkeycompare(const void *el1, const void *el2) +{ + WORD key1 = (LOWORD((*((const LONG *) el1)))) & 0x7fff; + WORD key2 = (LOWORD((*((const LONG *) el2)))) & 0x7fff; + + return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1)); +} + +static int +keycompare(const void *el1, const void *el2) +{ + WORD key1 = HIWORD((*((const LONG *) el1))); + WORD key2 = HIWORD((*((const LONG *) el2))); + + return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1)); +} + +static int +MapKey(WORD vKey) +{ + int code = -1; + + if (!WINCONSOLE.isTermInfoConsole) { + WORD nKey = 0; + void *res; + LONG key = GenMap(vKey, 0); + + res = bsearch(&key, + WINCONSOLE.map, + (size_t) (N_INI + FKEYS), + sizeof(keylist[0]), + keycompare); + if (res) { + key = *((LONG *) res); + nKey = LOWORD(key); + code = (int) (nKey & 0x7fff); + if (nKey & 0x8000) + code = -code; + } + } + return code; +} + +static int +AnsiKey(WORD vKey) +{ + int code = -1; + + if (!WINCONSOLE.isTermInfoConsole) { + WORD nKey = 0; + void *res; + LONG key = GenMap(vKey, 0); + + res = bsearch(&key, + WINCONSOLE.ansi_map, + (size_t) (N_INI + FKEYS), + sizeof(keylist[0]), + keycompare); + if (res) { + key = *((LONG *) res); + nKey = LOWORD(key); + code = (int) (nKey & 0x7fff); + if (nKey & 0x8000) + code = -code; + } + } + return code; +} + +NCURSES_EXPORT(int) +_nc_console_keyok(int keycode, int flag) +{ + int code = ERR; + WORD nKey; + WORD vKey; + void *res; + LONG key = GenMap(0, (WORD) keycode); + + T((T_CALLED("lib_win32con::_nc_console_keyok(%d, %d)"), keycode, flag)); + + res = bsearch(&key, + WINCONSOLE.rmap, + (size_t) (N_INI + FKEYS), + sizeof(keylist[0]), + rkeycompare); + if (res) { + key = *((LONG *) res); + vKey = HIWORD(key); + nKey = (LOWORD(key)) & 0x7fff; + if (!flag) + nKey |= 0x8000; + *(LONG *) res = GenMap(vKey, nKey); + } + returnCode(code); +} + +NCURSES_EXPORT(bool) +_nc_console_keyExist(int keycode) +{ + WORD nKey; + void *res; + bool found = FALSE; + LONG key = GenMap(0, (WORD) keycode); + + T((T_CALLED("lib_win32con::_nc_console_keyExist(%d)"), keycode)); + res = bsearch(&key, + WINCONSOLE.rmap, + (size_t) (N_INI + FKEYS), + sizeof(keylist[0]), + rkeycompare); + if (res) { + key = *((LONG *) res); + nKey = LOWORD(key); + if (!(nKey & 0x8000)) + found = TRUE; + } + returnCode(found); +} + +NCURSES_EXPORT(int) +_nc_console_twait( + const SCREEN *sp, + HANDLE hdl, + int mode, + int milliseconds, + int *timeleft + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + INPUT_RECORD inp_rec; + BOOL b; + DWORD nRead = 0, rc = WAIT_FAILED; + int code = 0; + FILETIME fstart; + FILETIME fend; + int diff; + bool isNoDelay = (milliseconds == 0); + +#ifdef NCURSES_WGETCH_EVENTS + (void) evl; /* TODO: implement wgetch-events */ +#endif + +#define IGNORE_CTRL_KEYS (SHIFT_PRESSED | \ + LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED | \ + LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) +#define CONSUME() read_keycode(hdl, &inp_rec, 1, &nRead) + + assert(sp); + + TR(TRACE_IEVENT, ("start twait: hdl=%p, %d milliseconds, mode: %d", + hdl, milliseconds, mode)); + + if (milliseconds < 0) + milliseconds = NC_INFINITY; + + memset(&inp_rec, 0, sizeof(inp_rec)); + + while (true) { + if (!isNoDelay) { + GetSystemTimeAsFileTime(&fstart); + rc = WaitForSingleObject(hdl, (DWORD) milliseconds); + GetSystemTimeAsFileTime(&fend); + diff = (int) tdiff(fstart, fend); + milliseconds = Adjust(milliseconds, diff); + if (milliseconds < 0) + break; + } + + if (isNoDelay || (rc == WAIT_OBJECT_0)) { + if (mode) { + nRead = 0; + b = GetNumberOfConsoleInputEvents(hdl, &nRead); + if (!b) { + T(("twait:err GetNumberOfConsoleInputEvents")); + } + if (isNoDelay && b) { + T(("twait: Events Available: %lu", (unsigned long) nRead)); + if (nRead == 0) { + code = 0; + goto end; + } else { + DWORD n = 0; + MakeArray(pInpRec, INPUT_RECORD, nRead); + if (pInpRec != NULL) { + DWORD i; + BOOL f; + memset(pInpRec, 0, sizeof(INPUT_RECORD) * nRead); + f = PeekConsoleInput(hdl, pInpRec, nRead, &n); + if (f) { + for (i = 0; i < n; i++) { + if (pInpRec[i].EventType == KEY_EVENT) { + if (pInpRec[i].Event.KeyEvent.bKeyDown) { + DWORD ctrlMask = + (pInpRec[i].Event.KeyEvent.dwControlKeyState & + IGNORE_CTRL_KEYS); + if (!ctrlMask) { + code = TW_INPUT; + goto end; + } + } + } + } + } else { + T(("twait:err PeekConsoleInput")); + } + code = 0; + goto end; + } else { + T(("twait:err could not alloca input records")); + } + } + } + if (b && nRead > 0) { + b = PeekConsoleInput(hdl, &inp_rec, 1, &nRead); + if (!b) { + T(("twait:err PeekConsoleInput")); + } + if (b && nRead > 0) { + switch (inp_rec.EventType) { + case KEY_EVENT: + if (mode & TW_INPUT) { + WORD vk = inp_rec.Event.KeyEvent.wVirtualKeyCode; + WORD ch = inp_rec.Event.KeyEventChar; + + T(("twait:event KEY_EVENT")); + T(("twait vk=%d, ch=%d, keydown=%d", + vk, ch, inp_rec.Event.KeyEvent.bKeyDown)); + + if (inp_rec.Event.KeyEvent.bKeyDown) { + T(("twait:event KeyDown")); + if (!WINCONSOLE.isTermInfoConsole && + (0 == ch)) { + int nKey = MapKey(vk); + if (nKey < 0) { + CONSUME(); + continue; + } + } + code = TW_INPUT; + goto end; + } else { + CONSUME(); + } + } + continue; + case MOUSE_EVENT: + T(("twait:event MOUSE_EVENT")); + if (decode_mouse(sp, + (inp_rec.Event.MouseEvent.dwButtonState + & BUTTON_MASK)) == 0) { + CONSUME(); + } else if (mode & TW_MOUSE) { + code = TW_MOUSE; + goto end; + } + continue; + /* e.g., FOCUS_EVENT */ + default: + T(("twait:event Type %d", inp_rec.EventType)); + CONSUME(); + _nc_console_selectActiveHandle(); + continue; + } + } + } + } + continue; + } else { + if (rc != WAIT_TIMEOUT) { + code = -1; + break; + } else { + code = 0; + break; + } + } + } + end: + + TR(TRACE_IEVENT, ("end twait: returned %d (%lu), remaining time %d msec", + code, (unsigned long) GetLastError(), milliseconds)); + + if (timeleft) + *timeleft = milliseconds; + + return code; +} + +NCURSES_EXPORT(int) +_nc_console_testmouse( + const SCREEN *sp, + HANDLE hdl, + int delay + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + int rc = 0; + + assert(sp); + + if (sp->_drv_mouse_head < sp->_drv_mouse_tail) { + rc = TW_MOUSE; + } else { + rc = _nc_console_twait(sp, + hdl, + TWAIT_MASK, + delay, + (int *) 0 + EVENTLIST_2nd(evl)); + } + return rc; +} + +NCURSES_EXPORT(int) +_nc_console_read( + SCREEN *sp, + HANDLE hdl, + int *buf) +{ + int rc = -1; + INPUT_RECORD inp_rec; + BOOL b; + DWORD nRead; + WORD vk; + + assert(sp); + assert(buf); + + memset(&inp_rec, 0, sizeof(inp_rec)); + + T((T_CALLED("lib_win32con::_nc_console_read(%p)"), sp)); + + while ((b = read_keycode(hdl, &inp_rec, 1, &nRead))) { + if (b && nRead > 0) { + if (rc < 0) + rc = 0; + rc = rc + (int) nRead; + if (inp_rec.EventType == KEY_EVENT) { + if (!inp_rec.Event.KeyEvent.bKeyDown) + continue; + *buf = (int) inp_rec.Event.KeyEventChar; + vk = inp_rec.Event.KeyEvent.wVirtualKeyCode; + /* + * There are 24 virtual function-keys, and typically + * 12 function-keys on a keyboard. Use the shift-modifier + * to provide the remaining 12 keys. + */ + if (vk >= VK_F1 && vk <= VK_F12) { + if (inp_rec.Event.KeyEvent.dwControlKeyState & + SHIFT_PRESSED) { + vk = (WORD) (vk + 12); + } + } + if (*buf == 0) { + int key = MapKey(vk); + if (key < 0) + continue; + if (sp->_keypad_on) { + *buf = key; + } else { + ungetch('\0'); + *buf = AnsiKey(vk); + } + } else if (vk == VK_BACK) { + if (!(inp_rec.Event.KeyEvent.dwControlKeyState + & (SHIFT_PRESSED | CONTROL_PRESSED))) { + *buf = KEY_BACKSPACE; + } + } else if (vk == VK_TAB) { + if ((inp_rec.Event.KeyEvent.dwControlKeyState + & (SHIFT_PRESSED | CONTROL_PRESSED))) { + *buf = KEY_BTAB; + } + } + break; + } else if (inp_rec.EventType == MOUSE_EVENT) { + if (handle_mouse(sp, + inp_rec.Event.MouseEvent)) { + *buf = KEY_MOUSE; + break; + } + } + continue; + } + } + returnCode(rc); +} + +#if USE_TERM_DRIVER && (USE_NAMED_PIPES || defined(USE_WIN32CON_DRIVER)) +/* Our replacement for the systems _isatty to include also + a test for mintty. This is called from the NC_ISATTY macro + defined in curses.priv.h + + Return codes: + - 0 : Not a TTY + - 1 : A Windows character device detected by _isatty + - 2 : A future implementation may return 2 for mintty + */ +NCURSES_EXPORT(int) +_nc_console_isatty(int fd) +{ + int result = 0; + T((T_CALLED("lib_win32con::_nc_console_isatty(%d"), fd)); + + if (isatty(fd)) + result = 1; +#ifdef _NC_CHECK_MINTTY + else { + if (_nc_console_checkmintty(fd, NULL)) { + result = 2; + fprintf(stderr, + "ncurses on Windows must run in a Windows console.\n" + "On newer versions of Windows, the calling program should create a PTY-like.\n" + "device using the CreatePseudoConsole Windows API call.\n"); + exit(EXIT_FAILURE); + } + } +#endif + returnCode(result); +} +#endif /* USE_TERM_DRIVER && (USE_NAMED_PIPES || defined(USE_WIN32CON_DRIVER)) */ + +#if USE_WINCONMODE +NCURSES_EXPORT(bool) +_nc_console_checkinit(bool assumeTermInfo) +{ + bool res = FALSE; + + T((T_CALLED("lib_win32con::_nc_console_checkinit(assumeTermInfo=%d)"), + assumeTermInfo)); + + /* initialize once, or not at all */ + if (!console_initialized) { + int i; + DWORD num_buttons; + WORD a; + BOOL buffered = FALSE; + BOOL b; + + START_TRACE(); + WINCONSOLE.isTermInfoConsole = assumeTermInfo; + + WINCONSOLE.map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE); + WINCONSOLE.rmap = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE); + WINCONSOLE.ansi_map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE); + + for (i = 0; i < (N_INI + FKEYS); i++) { + if (i < N_INI) { + WINCONSOLE.rmap[i] = WINCONSOLE.map[i] = + (DWORD) keylist[i]; + WINCONSOLE.ansi_map[i] = (DWORD) ansi_keys[i]; + } else { + WINCONSOLE.rmap[i] = WINCONSOLE.map[i] = + (DWORD) GenMap((VK_F1 + (i - N_INI)), + (KEY_F(1) + (i - N_INI))); + WINCONSOLE.ansi_map[i] = + (DWORD) GenMap((VK_F1 + (i - N_INI)), + (';' + (i - N_INI))); + } + } + qsort(WINCONSOLE.ansi_map, + (size_t) (MAPSIZE), + sizeof(keylist[0]), + keycompare); + qsort(WINCONSOLE.map, + (size_t) (MAPSIZE), + sizeof(keylist[0]), + keycompare); + qsort(WINCONSOLE.rmap, + (size_t) (MAPSIZE), + sizeof(keylist[0]), + rkeycompare); + + if (GetNumberOfConsoleMouseButtons(&num_buttons)) { + WINCONSOLE.numButtons = (int) num_buttons; + } else { + WINCONSOLE.numButtons = 1; + } + + a = _nc_console_MapColor(true, COLOR_WHITE) | + _nc_console_MapColor(false, COLOR_BLACK); + for (i = 0; i < CON_NUMPAIRS; i++) + WINCONSOLE.pairs[i] = a; + +#define SaveConsoleMode(handle, value) \ + GetConsoleMode(WINCONSOLE.handle, &WINCONSOLE.originalMode.value) + + if (WINCONSOLE.isTermInfoConsole) { + WINCONSOLE.inp = GetStdHandle(STD_INPUT_HANDLE); + WINCONSOLE.out = GetStdHandle(STD_OUTPUT_HANDLE); + WINCONSOLE.hdl = WINCONSOLE.out; + + SaveConsoleMode(inp, dwFlagIn); + SaveConsoleMode(out, dwFlagOut); + + } else { + b = AllocConsole(); + + if (!b) + b = AttachConsole(ATTACH_PARENT_PROCESS); + + WINCONSOLE.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ); + WINCONSOLE.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE); + + SaveConsoleMode(inp, dwFlagIn); + SaveConsoleMode(out, dwFlagOut); + + if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) { + WINCONSOLE.hdl = WINCONSOLE.out; + buffered = FALSE; + T(("... will not buffer console")); + } else { + T(("... creating console buffer")); + WINCONSOLE.hdl = + CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + CONSOLE_TEXTMODE_BUFFER, + NULL); + buffered = TRUE; + } + } + + /* We set binary I/O even when using the console + driver to cover the situation, that the + TERM variable is set to #win32con, but actually + Windows supports virtual terminal processing. + So if terminfo functions are used in this setup, + they actually may work. + */ + _setmode(fileno(stdin), _O_BINARY); + _setmode(fileno(stdout), _O_BINARY); + + if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) { + WINCONSOLE.buffered = buffered; + _nc_console_get_SBI(); + WINCONSOLE.save_SBI = WINCONSOLE.SBI; + if (!buffered) { + save_original_screen(); + _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI); + } + GetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI); + T(("... initial cursor is %svisible, %d%%", + (WINCONSOLE.save_CI.bVisible ? "" : "not-"), + (int) WINCONSOLE.save_CI.dwSize)); + } + + WINCONSOLE.initialized = TRUE; + console_initialized = TRUE; + } + res = (WINCONSOLE.hdl != INVALID_HANDLE_VALUE); + returnBool(res); +} +#endif /* USE_WINCONMODE */ + +NCURSES_EXPORT(bool) +_nc_console_restore(void) +{ + bool res = FALSE; + + T((T_CALLED("lib_win32con::_nc_console_restore"))); + if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) { + res = TRUE; + if (!WINCONSOLE.buffered) { + _nc_console_set_scrollback(TRUE, &WINCONSOLE.save_SBI); + if (!restore_original_screen()) + res = FALSE; + } + SetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI); + } + returnBool(res); +} + +#endif // _NC_WINDOWS diff --git a/ncurses/ncurses/tinfo/lib_win32util.c b/ncurses/ncurses/tinfo/lib_win32util.c new file mode 100644 index 0000000000..427ca93f2d --- /dev/null +++ b/ncurses/ncurses/tinfo/lib_win32util.c @@ -0,0 +1,136 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2009,2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Thomas E. Dickey * + ****************************************************************************/ + +#include +#include + +MODULE_ID("$Id: lib_win32util.c,v 1.7 2025/06/28 16:58:13 tom Exp $") + +#ifdef _NC_WINDOWS_NATIVE + +#ifdef _NC_CHECK_MINTTY +#define PSAPI_VERSION 2 +#include + +#define array_length(a) (sizeof(a)/sizeof(a[0])) + +/* This function tests, whether or not the ncurses application + is running as a descendant of MSYS2/cygwin mintty terminal + application. mintty doesn't use Windows Console for its screen + I/O, so the native Windows _isatty doesn't recognize it as + character device. But we can discover we are at the end of an + Pipe and can query the server side of the pipe, looking whether + or not this is mintty. + For now we terminate the program if we discover that situation. + Although in theory it would be possible, to remotely manipulate + the terminal state of mintty, this is out of scope for now and + not worth the significant effort. + */ +NCURSES_EXPORT(int) +_nc_console_checkmintty(int fd, LPHANDLE pMinTTY) +{ + HANDLE handle = _nc_console_handle(fd); + DWORD dw; + int code = 0; + + T((T_CALLED("lib_winhelper::_nc_console_checkmintty(%d, %p)"), fd, pMinTTY)); + + if (handle != INVALID_HANDLE_VALUE) { + dw = GetFileType(handle); + if (dw == FILE_TYPE_PIPE) { + if (GetNamedPipeInfo(handle, 0, 0, 0, 0)) { + ULONG pPid; + /* Requires NT6 */ + if (GetNamedPipeServerProcessId(handle, &pPid)) { + TCHAR buf[MAX_PATH]; + DWORD len = 0; + /* These security attributes may allow us to + create a remote thread in mintty to manipulate + the terminal state remotely */ + HANDLE pHandle = OpenProcess(PROCESS_CREATE_THREAD + | PROCESS_QUERY_INFORMATION + | PROCESS_VM_OPERATION + | PROCESS_VM_WRITE + | PROCESS_VM_READ, + FALSE, + pPid); + if (pMinTTY) + *pMinTTY = INVALID_HANDLE_VALUE; + if (pHandle != INVALID_HANDLE_VALUE) { + if ((len = GetProcessImageFileName(pHandle, + buf, + (DWORD) + array_length(buf)))) { + TCHAR *pos = _tcsrchr(buf, _T('\\')); + if (pos) { + pos++; + if (_tcsnicmp(pos, _TEXT("mintty.exe"), 10) + == 0) { + if (pMinTTY) + *pMinTTY = pHandle; + code = 1; + } + } + } + } + } + } + } + } + returnCode(code); +} +#endif /* _NC_CHECK_MINTTY */ + +#if HAVE_GETTIMEOFDAY == 2 +#define JAN1970 116444736000000000LL /* the value for 01/01/1970 00:00 */ + +NCURSES_EXPORT(int) +_nc_gettimeofday(struct timeval *tv, void *tz GCC_UNUSED) +{ + union { + FILETIME ft; + long long since1601; /* time since 1 Jan 1601 in 100ns units */ + } data; + + GetSystemTimeAsFileTime(&data.ft); + tv->tv_usec = (long) ((data.since1601 / 10LL) % 1000000LL); + tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL); + return (0); +} +#endif // HAVE_GETTIMEOFDAY == 2 + +#endif // _NC_WINDOWS_NATIVE diff --git a/ncurses/ncurses/tinfo/make_hash.c b/ncurses/ncurses/tinfo/make_hash.c new file mode 100644 index 0000000000..36d854483a --- /dev/null +++ b/ncurses/ncurses/tinfo/make_hash.c @@ -0,0 +1,453 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2009-2013,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * make_hash.c --- build-time program for constructing comp_captab.c + */ + +#include + +#include +#include + +#include + +MODULE_ID("$Id: make_hash.c,v 1.37 2025/10/18 15:39:43 tom Exp $") + +/* + * _nc_make_hash_table() + * + * Takes the entries in table[] and hashes them into hash_table[] + * by name. There are CAPTABSIZE entries in the predefined table[] + * and HASHTABSIZE slots in hash_table[]. + * + */ + +#undef MODULE_ID +#define MODULE_ID(id) /*nothing */ +#include + +#define L_PAREN "(" +#define R_PAREN ")" +#define L_BRACE "{" +#define R_BRACE "}" + +static const char *typenames[] = +{"BOOLEAN", "NUMBER", "STRING"}; + +static void +failed(const char *s) +{ + perror(s); + exit(EXIT_FAILURE); +} + +static char * +strmalloc(char *s) +{ + size_t need = strlen(s) + 1; + char *result = malloc(need); + if (result == NULL) + failed("strmalloc"); + _nc_STRCPY(result, s, need); + return result; +} + +/* + * int hash_function(string) + * + * Computes the hashing function on the given string. + * + * The current hash function is the sum of each consecutive pair + * of characters, taken as two-byte integers, mod HASHTABSIZE. + * + */ + +static int +hash_function(const char *string) +{ + long sum = 0; + + while (*string) { + sum += (long) (UChar(*string) + (UChar(*(string + 1)) << 8)); + string++; + } + + return (int) (sum % HASHTABSIZE); +} + +#define UNUSED -1 + +static void +_nc_make_hash_table(struct user_table_entry *table, + HashValue * hash_table, + unsigned tablesize) +{ + unsigned i; + int hashvalue; + int collisions = 0; + + for (i = 0; i < HASHTABSIZE; i++) { + hash_table[i] = UNUSED; + } + for (i = 0; i < tablesize; i++) { + hashvalue = hash_function(table[i].ute_name); + + if (hash_table[hashvalue] >= 0) + collisions++; + + if (hash_table[hashvalue] != UNUSED) { + table[i].ute_link = hash_table[hashvalue]; + } + hash_table[hashvalue] = (HashValue) i; + } + + printf("/* %d collisions out of %d entries */\n", collisions, tablesize); +} + +/* + * This filter reads from standard input a list of tab-delimited columns, + * (e.g., from Caps.filtered) computes the hash-value of a specified column and + * writes the hashed tables to standard output. + * + * By compiling the hash table at build time, we're able to make the entire + * set of terminfo and termcap tables readonly (and also provide some runtime + * performance enhancement). + */ + +#define MAX_COLUMNS BUFSIZ /* this _has_ to be worst-case */ + +static int +count_columns(char **list) +{ + int result = 0; + if (list != NULL) { + while (*list++) { + ++result; + } + } + return result; +} + +static char ** +parse_columns(char *buffer) +{ + static char **list; + + int col = 0; + + if (buffer == NULL) { + free(list); + list = NULL; + return NULL; + } + + if (*buffer != '#') { + if (list == NULL) { + list = typeCalloc(char *, (MAX_COLUMNS + 1)); + if (list == NULL) + return (NULL); + } + 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 : NULL; +} + +#define SetType(n,t) \ + if (is_user) \ + name_table[n].ute_type |= (int)(1 << (t)); \ + else \ + name_table[n].ute_type = (t) + +#define GetType(n) \ + (is_user \ + ? get_type(name_table[n].ute_type) \ + : typenames[name_table[n].ute_type]) + +static char * +get_type(int type_mask) +{ + static char result[80]; + unsigned n; + _nc_STRCPY(result, L_PAREN, sizeof(result)); + for (n = 0; n < 3; ++n) { + if ((1 << n) & type_mask) { + size_t want = 5 + strlen(typenames[n]); + if (want > sizeof(result)) { + fprintf(stderr, "Buffer is not large enough for %s + %s\n", + result, typenames[n]); + exit(EXIT_FAILURE); + } + if (result[1]) + _nc_STRCAT(result, "|", sizeof(result)); + _nc_STRCAT(result, "1<<", sizeof(result)); + _nc_STRCAT(result, typenames[n], sizeof(result)); + } + } + _nc_STRCAT(result, R_PAREN, sizeof(result)); + return result; +} + +int +main(int argc, char **argv) +{ + unsigned tablesize = CAPTABSIZE; + struct user_table_entry *name_table; + HashValue *hash_table; + const char *root_name; + int column = 0; + int bigstring = 0; + unsigned n; + unsigned nn; + unsigned tableused = 0; + bool is_user; + const char *table_name; + char buffer[BUFSIZ]; + + short BoolCount = 0; + short NumCount = 0; + short StrCount = 0; + + if (argc == 2 && !strcmp(argv[1], "-?")) + return EXIT_SUCCESS; + + name_table = typeCalloc(struct user_table_entry, tablesize); + hash_table = typeCalloc(HashValue, HASHTABSIZE); + + /* 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 == NULL + || hash_table == NULL) { + fprintf(stderr, "usage: make_hash column root_name bigstring\n"); + exit(EXIT_FAILURE); + } + is_user = (*root_name == 'u'); + table_name = (is_user ? "user" : "name"); + + /* + * Read the table into our arrays. + */ + for (n = 0; (n < tablesize) && fgets(buffer, BUFSIZ, stdin);) { + char **list; + char *nlp = strchr(buffer, '\n'); + if (nlp) + *nlp = '\0'; + else + buffer[sizeof(buffer) - 2] = '\0'; + list = parse_columns(buffer); + if (list == NULL) /* blank or comment */ + continue; + if (is_user) { + if (strcmp(list[0], "userdef")) + continue; + } else if (!strcmp(list[0], "userdef")) { + continue; + } + if (column < 0 || column > count_columns(list)) { + fprintf(stderr, "expected %d columns, have %d:\n%s\n", + column, + count_columns(list), + buffer); + exit(EXIT_FAILURE); + } + nn = tableused; + if (is_user) { + unsigned j; + for (j = 0; j < tableused; ++j) { + if (!strcmp(list[column], name_table[j].ute_name)) { + nn = j; + break; + } + } + } + if (nn == tableused) { + name_table[nn].ute_link = -1; /* end-of-hash */ + name_table[nn].ute_name = strmalloc(list[column]); + ++tableused; + } + + if (!strcmp(list[2], "bool")) { + SetType(nn, BOOLEAN); + name_table[nn].ute_index = BoolCount++; + } else if (!strcmp(list[2], "num")) { + SetType(nn, NUMBER); + name_table[nn].ute_index = NumCount++; + } else if (!strcmp(list[2], "str")) { + SetType(nn, STRING); + name_table[nn].ute_index = StrCount++; + if (is_user) { + if (*list[3] != '-') { + unsigned j; + name_table[nn].ute_argc = (unsigned) strlen(list[3]); + for (j = 0; j < name_table[nn].ute_argc; ++j) { + if (list[3][j] == 's') { + name_table[nn].ute_args |= (1U << j); + } + } + } + } + } else { + fprintf(stderr, "Unknown type: %s\n", list[2]); + exit(EXIT_FAILURE); + } + n++; + } + if (tablesize > tableused) + tablesize = tableused; + _nc_make_hash_table(name_table, hash_table, tablesize); + + /* + * 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 < tablesize; n++) { + nxt = (int) strlen(name_table[n].ute_name) + 5; + if (nxt + len > 72) { + printf("\\\n"); + len = 0; + } + printf("\"%s\\0\" ", name_table[n].ute_name); + len += nxt; + } + printf(";\n\n"); + + len = 0; + printf("static %s_table_data const %s_names_data[] =\n", + table_name, + root_name); + printf("%s\n", L_BRACE); + for (n = 0; n < tablesize; n++) { + printf("\t%s %15d,\t%10s,", L_BRACE, len, GetType(n)); + if (is_user) + printf("\t%d,%d,", + name_table[n].ute_argc, + name_table[n].ute_args); + printf("\t%3d, %3d %s%s\n", + name_table[n].ute_index, + name_table[n].ute_link, + R_BRACE, + n < tablesize - 1 ? "," : ""); + len += (int) strlen(name_table[n].ute_name) + 1; + } + printf("%s;\n\n", R_BRACE); + printf("static struct %s_table_entry *_nc_%s_table = NULL;\n\n", + table_name, + root_name); + } else { + + printf("static struct %s_table_entry const _nc_%s_table[] =\n", + table_name, + root_name); + printf("%s\n", L_BRACE); + for (n = 0; n < tablesize; n++) { + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "\"%s\"", + name_table[n].ute_name); + printf("\t%s %15s,\t%10s,", L_BRACE, buffer, GetType(n)); + if (is_user) + printf("\t%d,%d,", + name_table[n].ute_argc, + name_table[n].ute_args); + printf("\t%3d, %3d %s%s\n", + name_table[n].ute_index, + name_table[n].ute_link, + R_BRACE, + n < tablesize - 1 ? "," : ""); + } + printf("%s;\n\n", R_BRACE); + } + + printf("static const HashValue _nc_%s_hash_table[%d] =\n", + root_name, + HASHTABSIZE + 1); + printf("%s\n", L_BRACE); + for (n = 0; n < HASHTABSIZE; n++) { + printf("\t%3d,\n", hash_table[n]); + } + printf("\t0\t/* base-of-table */\n"); + printf("%s;\n\n", R_BRACE); + + if (!is_user) { + 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); + for (n = 0; (n < tablesize); ++n) { + free((void *) name_table[n].ute_name); + } + free(name_table); + parse_columns(NULL); + + return EXIT_SUCCESS; +} diff --git a/ncurses/ncurses/tinfo/make_keys.c b/ncurses/ncurses/tinfo/make_keys.c new file mode 100644 index 0000000000..e439eed8d5 --- /dev/null +++ b/ncurses/ncurses/tinfo/make_keys.c @@ -0,0 +1,173 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2011,2015 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + ****************************************************************************/ + +/* + * This replaces an awk script which translated keys.list into keys.tries by + * 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 + +MODULE_ID("$Id: make_keys.c,v 1.25 2025/10/18 15:41:07 tom Exp $") + +#include + +static unsigned +unknown(void) +{ + static unsigned result = 0; + + if (result == 0) { + unsigned n; + for (n = 0; strnames[n] != NULL; n++) { + ++result; + } + for (n = 0; strfnames[n] != NULL; n++) { + ++result; + } + } + return result; +} + +static unsigned +lookup(const char *name) +{ + unsigned n; + bool found = FALSE; + for (n = 0; strnames[n] != NULL; n++) { + if (!strcmp(name, strnames[n])) { + found = TRUE; + break; + } + } + if (!found) { + for (n = 0; strfnames[n] != NULL; n++) { + if (!strcmp(name, strfnames[n])) { + found = TRUE; + break; + } + } + } + return found ? n : unknown(); +} + +static void +make_keys(FILE *ifp, FILE *ofp) +{ + char buffer[BUFSIZ]; + char from[256]; + char to[256]; + unsigned ignore = unknown(); + unsigned maxlen = 16; + int scanned; + + while (fgets(buffer, (int) sizeof(buffer), ifp) != NULL) { + if (*buffer == '#') + continue; + + to[sizeof(to) - 1] = '\0'; + from[sizeof(from) - 1] = '\0'; + + scanned = sscanf(buffer, "%255s %255s", to, from); + if (scanned == 2) { + unsigned code = lookup(from); + if (code == ignore) + continue; + if (strlen(from) > maxlen) + maxlen = (unsigned) strlen(from); + fprintf(ofp, "\t{ %4u, %-*.*s },\t/* %s */\n", + code, + (int) maxlen, (int) maxlen, + to, + from); + } + } +} + +static void +write_list(FILE *ofp, const char **list) +{ + while (*list != NULL) + fprintf(ofp, "%s\n", *list++); +} + +int +main(int argc, char *argv[]) +{ + static const char *prefix[] = + { + "#ifndef _INIT_KEYTRY_H", + "#define _INIT_KEYTRY_H 1", + "", + "/* This file was generated by MAKE_KEYS */", + "", + "#include ", + "", + "#if BROKEN_LINKER", + "static", + "#endif", + "const struct tinfo_fkeys _nc_tinfo_fkeys[] = {", + NULL + }; + static const char *suffix[] = + { + "\t{ 0, 0} };", + "", + "#endif /* _INIT_KEYTRY_H */", + NULL + }; + + if (argc == 2 && !strcmp(argv[1], "-?")) + return EXIT_SUCCESS; + + write_list(stdout, prefix); + if (argc > 1) { + int n; + for (n = 1; n < argc; n++) { + FILE *fp = fopen(argv[n], "r"); + if (fp != NULL) { + make_keys(fp, stdout); + fclose(fp); + } + } + } else { + make_keys(stdin, stdout); + } + write_list(stdout, suffix); + return EXIT_SUCCESS; +} diff --git a/ncurses/ncurses/tinfo/name_match.c b/ncurses/ncurses/tinfo/name_match.c new file mode 100644 index 0000000000..ecbf7cae59 --- /dev/null +++ b/ncurses/ncurses/tinfo/name_match.c @@ -0,0 +1,129 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2013,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999-on * + ****************************************************************************/ + +#include +#include + +MODULE_ID("$Id: name_match.c,v 1.27 2025/01/12 00:41:56 tom Exp $") + +#define FirstName _nc_globals.first_name + +#if NCURSES_USE_TERMCAP && NCURSES_XNAMES +static const char * +skip_index(const char *name) +{ + if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) { + const char *bar = strchr(name, '|'); + if (bar != NULL && (bar - name) == 2) + name = bar + 1; + } + return name; +} +#endif + +/* + * Get the primary name from the given name list. For terminfo, this is the + * first name. For termcap, this may be the second name, if the first one + * happens to be two characters. + */ +NCURSES_EXPORT(char *) +_nc_first_name(const char *const sp) +{ +#if NO_LEAKS + if (sp == NULL) { + if (FirstName != NULL) { + FreeAndNull(FirstName); + } + } else +#endif + { + if (FirstName == NULL) + FirstName = typeMalloc(char, MAX_NAME_SIZE + 1); + + if (FirstName != NULL) { + unsigned n; + const char *src = sp; +#if NCURSES_USE_TERMCAP && NCURSES_XNAMES + src = skip_index(sp); +#endif + for (n = 0; n < MAX_NAME_SIZE; n++) { + if ((FirstName[n] = src[n]) == '\0' + || (FirstName[n] == '|')) + break; + } + FirstName[n] = '\0'; + } + } + return (FirstName); +} + +/* + * Is the given name matched in namelist? + */ +NCURSES_EXPORT(int) +_nc_name_match(const char *const namelst, const char *const name, const char *const delim) +{ + const char *s; + + if ((s = namelst) != NULL) { + while (*s != '\0') { + const char *d, *t; + int code, found; + + for (d = name; *d != '\0'; d++) { + if (*s != *d) + break; + s++; + } + found = FALSE; + for (code = TRUE; *s != '\0'; code = FALSE, s++) { + for (t = delim; *t != '\0'; t++) { + if (*s == *t) { + found = TRUE; + break; + } + } + if (found) + break; + } + if (code && *d == '\0') + return code; + if (*s++ == 0) + break; + } + } + return FALSE; +} diff --git a/ncurses/ncurses/tinfo/obsolete.c b/ncurses/ncurses/tinfo/obsolete.c new file mode 100644 index 0000000000..d577f6fbc1 --- /dev/null +++ b/ncurses/ncurses/tinfo/obsolete.c @@ -0,0 +1,338 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 2013-2014,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2013-on * + ****************************************************************************/ + +/* +** Support for obsolete/unusual features. +*/ + +#include + +MODULE_ID("$Id: obsolete.c,v 1.13 2025/02/20 01:12:11 tom Exp $") + +/* + * Obsolete entrypoint retained for binary compatibility. + */ +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, int buffered) +{ +#if NCURSES_SP_FUNCS + (void) SP_PARM; +#endif + (void) ofp; + (void) buffered; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_set_buffer(FILE *ofp, int buffered) +{ + NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered); +} +#endif + +#if !HAVE_STRDUP +NCURSES_EXPORT(char *) +_nc_strdup(const char *s) +{ + char *result = NULL; + if (s != NULL) { + size_t need = strlen(s); + result = malloc(need + 1); + if (result != NULL) { + _nc_STRCPY(result, s, need); + } + } + return result; +} +#endif + +#if USE_MY_MEMMOVE +#define DST ((char *)s1) +#define SRC ((const char *)s2) +NCURSES_EXPORT(void *) +_nc_memmove(void *s1, const void *s2, size_t n) +{ + if (n != 0) { + if ((DST + n > SRC) && (SRC + n > DST)) { + static char *bfr; + static size_t length; + register size_t j; + if (length < n) { + length = (n * 3) / 2; + bfr = typeRealloc(char, length, bfr); + } + for (j = 0; j < n; j++) + bfr[j] = SRC[j]; + s2 = bfr; + } + while (n-- != 0) + DST[n] = SRC[n]; + } + return s1; +} +#endif /* USE_MY_MEMMOVE */ + +#ifdef EXP_XTERM_1005 +NCURSES_EXPORT(int) +_nc_conv_to_utf8(unsigned char *target, unsigned source, unsigned limit) +{ +#define CH(n) UChar((source) >> ((n) * 8)) + int rc = 0; + + if (source <= 0x0000007f) + rc = 1; + else if (source <= 0x000007ff) + rc = 2; + else if (source <= 0x0000ffff) + rc = 3; + else if (source <= 0x001fffff) + rc = 4; + else if (source <= 0x03ffffff) + rc = 5; + else /* (source <= 0x7fffffff) */ + rc = 6; + + if ((unsigned) rc > limit) { /* whatever it is, we cannot decode it */ + rc = 0; + } + + if (target != NULL) { + switch (rc) { + case 1: + target[0] = CH(0); + break; + + case 2: + target[1] = UChar(0x80 | (CH(0) & 0x3f)); + target[0] = UChar(0xc0 | (CH(0) >> 6) | ((CH(1) & 0x07) << 2)); + break; + + case 3: + target[2] = UChar(0x80 | (CH(0) & 0x3f)); + target[1] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2)); + target[0] = UChar(0xe0 | ((int) (CH(1) & 0xf0) >> 4)); + break; + + case 4: + target[3] = UChar(0x80 | (CH(0) & 0x3f)); + target[2] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2)); + target[1] = UChar(0x80 | + ((int) (CH(1) & 0xf0) >> 4) | + ((int) (CH(2) & 0x03) << 4)); + target[0] = UChar(0xf0 | ((int) (CH(2) & 0x1f) >> 2)); + break; + + case 5: + target[4] = UChar(0x80 | (CH(0) & 0x3f)); + target[3] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2)); + target[2] = UChar(0x80 | + ((int) (CH(1) & 0xf0) >> 4) | + ((int) (CH(2) & 0x03) << 4)); + target[1] = UChar(0x80 | (CH(2) >> 2)); + target[0] = UChar(0xf8 | (CH(3) & 0x03)); + break; + + case 6: + target[5] = UChar(0x80 | (CH(0) & 0x3f)); + target[4] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2)); + target[3] = UChar(0x80 | (CH(1) >> 4) | ((CH(2) & 0x03) << 4)); + target[2] = UChar(0x80 | (CH(2) >> 2)); + target[1] = UChar(0x80 | (CH(3) & 0x3f)); + target[0] = UChar(0xfc | ((int) (CH(3) & 0x40) >> 6)); + break; + } + } + + return rc; /* number of bytes needed in target */ +#undef CH +} + +NCURSES_EXPORT(int) +_nc_conv_to_utf32(unsigned *target, const char *source, unsigned limit) +{ +#define CH(n) UChar((*target) >> ((n) * 8)) + int rc = 0; + int j; + unsigned mask = 0; + + /* + * Find the number of bytes we will need from the source. + */ + if ((*source & 0x80) == 0) { + rc = 1; + mask = (unsigned) *source; + } else if ((*source & 0xe0) == 0xc0) { + rc = 2; + mask = (unsigned) (*source & 0x1f); + } else if ((*source & 0xf0) == 0xe0) { + rc = 3; + mask = (unsigned) (*source & 0x0f); + } else if ((*source & 0xf8) == 0xf0) { + rc = 4; + mask = (unsigned) (*source & 0x07); + } else if ((*source & 0xfc) == 0xf8) { + rc = 5; + mask = (unsigned) (*source & 0x03); + } else if ((*source & 0xfe) == 0xfc) { + rc = 6; + mask = (unsigned) (*source & 0x01); + } + + if ((unsigned) rc > limit) { /* whatever it is, we cannot decode it */ + rc = 0; + } + + /* + * sanity-check. + */ + if (rc > 1) { + for (j = 1; j < rc; j++) { + if ((source[j] & 0xc0) != 0x80) + break; + } + if (j != rc) { + rc = 0; + } + } + + if (target != NULL) { + int shift = 0; + *target = 0; + for (j = 1; j < rc; j++) { + *target |= (unsigned) (source[rc - j] & 0x3f) << shift; + shift += 6; + } + *target |= mask << shift; + } + return rc; +#undef CH +} +#endif /* EXP_XTERM_1005 */ + +#ifdef EXP_OOM_TESTING +/* + * Out-of-memory testing, suitable for checking if initialization (and limited + * running) recovers from errors due to insufficient memory. In practice, this + * is unlikely except with artificially constructed tests (or poorly behaved + * applications). + */ +#undef malloc +#undef calloc +#undef realloc +#undef free +#undef strdup + +#define TR_OOM(stmt) T(stmt) + +static long oom_limit = -1; +static long oom_count = 0; + +static bool +oom_check(void) +{ + static bool initialized = FALSE; + static bool triggered = FALSE; + bool result = FALSE; + + if (!initialized) { + char *env = getenv("NCURSES_OOM_TESTING"); + initialized = TRUE; + if (env != NULL) { + char *check; + oom_limit = strtol(env, &check, 0); + if (check != NULL && *check != '\0') + oom_limit = 0; + } + } + ++oom_count; + if (oom_limit >= 0) { + result = (oom_count > oom_limit); + if (result && !triggered) { + triggered = TRUE; + TR_OOM(("out-of-memory")); + } + } + return result; +} + +NCURSES_EXPORT(void *) +_nc_oom_malloc(size_t size) +{ + char *result = (oom_check() + ? NULL + : malloc(size)); + TR_OOM(("oom #%ld malloc(%ld) %p", oom_count, size, result)); + return result; +} + +NCURSES_EXPORT(void *) +_nc_oom_calloc(size_t nmemb, size_t size) +{ + char *result = (oom_check() + ? NULL + : calloc(nmemb, size)); + TR_OOM(("oom #%ld calloc(%ld, %ld) %p", oom_count, nmemb, size, result)); + return result; +} + +NCURSES_EXPORT(void *) +_nc_oom_realloc(void *ptr, size_t size) +{ + char *result = (oom_check() + ? NULL + : realloc(ptr, size)); + TR_OOM(("oom #%ld realloc(%p, %ld) %p", oom_count, ptr, size, result)); + return result; +} + +NCURSES_EXPORT(void) +_nc_oom_free(void *ptr) +{ + ++oom_count; + TR_OOM(("oom #%ld free(%p)", oom_count, ptr)); + free(ptr); +} + +NCURSES_EXPORT(char *) +_nc_oom_strdup(const char *ptr) +{ + char *result = (oom_check() + ? NULL + : strdup(ptr)); + TR_OOM(("oom #%ld strdup(%p) %p", oom_count, ptr, result)); + return result; +} +#endif /* EXP_OOM_TESTING */ diff --git a/ncurses/ncurses/tinfo/parse_entry.c b/ncurses/ncurses/tinfo/parse_entry.c new file mode 100644 index 0000000000..598764ee24 --- /dev/null +++ b/ncurses/ncurses/tinfo/parse_entry.c @@ -0,0 +1,1169 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * parse_entry.c -- compile one terminfo or termcap entry + * + * Get an exact in-core representation of an entry. Don't + * try to resolve use or tc capabilities, that is someone + * else's job. Depends on the lexical analyzer to get tokens + * from the input stream. + */ + +#define __INTERNAL_CAPS_VISIBLE +#include + +#include +#include + +MODULE_ID("$Id: parse_entry.c,v 1.117 2025/11/23 20:25:15 tom Exp $") + +#ifdef LINT +static short const parametrized[] = +{0}; +#else +#include +#endif + +static void postprocess_termcap(TERMTYPE2 *, bool); +static void postprocess_terminfo(TERMTYPE2 *); +static struct name_table_entry const *lookup_fullname(const char *name); + +#if NCURSES_XNAMES + +static struct name_table_entry const * +_nc_extend_names(ENTRY * entryp, const char *name, int token_type) +{ + static struct name_table_entry temp; + TERMTYPE2 *tp = &(entryp->tterm); + unsigned offset = 0; + unsigned actual; + unsigned tindex; + unsigned first, last, n; + bool found; + + switch (token_type) { + case BOOLEAN: + first = 0; + last = tp->ext_Booleans; + offset = tp->ext_Booleans; + tindex = tp->num_Booleans; + break; + case NUMBER: + first = tp->ext_Booleans; + last = tp->ext_Numbers + first; + offset = (unsigned) (tp->ext_Booleans + tp->ext_Numbers); + tindex = tp->num_Numbers; + break; + case STRING: + first = (unsigned) (tp->ext_Booleans + tp->ext_Numbers); + last = tp->ext_Strings + first; + offset = (unsigned) (tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings); + tindex = tp->num_Strings; + break; + case CANCEL: + actual = NUM_EXT_NAMES(tp); + for (n = 0; n < actual; n++) { + if (!strcmp(name, tp->ext_Names[n])) { + if (n > (unsigned) (tp->ext_Booleans + tp->ext_Numbers)) { + token_type = STRING; + } else if (n > tp->ext_Booleans) { + token_type = NUMBER; + } else { + token_type = BOOLEAN; + } + return _nc_extend_names(entryp, name, token_type); + } + } + /* Well, we are given a cancel for a name that we don't recognize */ + return _nc_extend_names(entryp, name, STRING); + default: + return NULL; + } + + /* Adjust the 'offset' (insertion-point) to keep the lists of extended + * names sorted. + */ + for (n = first, found = FALSE; n < last; n++) { + int cmp = strcmp(tp->ext_Names[n], name); + if (cmp == 0) + found = TRUE; + if (cmp >= 0) { + offset = n; + tindex = n - first; + switch (token_type) { + case BOOLEAN: + tindex += BOOLCOUNT; + break; + case NUMBER: + tindex += NUMCOUNT; + break; + case STRING: + tindex += STRCOUNT; + break; + } + break; + } + } + +#define for_each_value(max) \ + for (last = (unsigned) (max - 1); last > tindex; last--) + + if (!found) { + char *saved; + + if ((saved = _nc_save_str(name)) == NULL) + return NULL; + + switch (token_type) { + case BOOLEAN: + tp->ext_Booleans++; + tp->num_Booleans++; + TYPE_REALLOC(NCURSES_SBOOL, tp->num_Booleans, tp->Booleans); + for_each_value(tp->num_Booleans) + tp->Booleans[last] = tp->Booleans[last - 1]; + break; + case NUMBER: + tp->ext_Numbers++; + tp->num_Numbers++; + TYPE_REALLOC(NCURSES_INT2, tp->num_Numbers, tp->Numbers); + for_each_value(tp->num_Numbers) + tp->Numbers[last] = tp->Numbers[last - 1]; + break; + case STRING: + tp->ext_Strings++; + tp->num_Strings++; + TYPE_REALLOC(char *, tp->num_Strings, tp->Strings); + for_each_value(tp->num_Strings) + tp->Strings[last] = tp->Strings[last - 1]; + break; + } + actual = NUM_EXT_NAMES(tp); + TYPE_REALLOC(char *, actual, tp->ext_Names); + while (--actual > offset) + tp->ext_Names[actual] = tp->ext_Names[actual - 1]; + tp->ext_Names[offset] = saved; + } + + temp.nte_name = tp->ext_Names[offset]; + temp.nte_type = token_type; + temp.nte_index = (short) tindex; + temp.nte_link = -1; + + return &temp; +} + +static const char * +usertype2s(int mask) +{ + const char *result = "unknown"; + if (mask & (1 << BOOLEAN)) { + result = "boolean"; + } else if (mask & (1 << NUMBER)) { + result = "number"; + } else if (mask & (1 << STRING)) { + result = "string"; + } + return result; +} + +static bool +expected_type(const char *name, int token_type, bool silent) +{ + struct user_table_entry const *entry = _nc_find_user_entry(name); + bool result = TRUE; + if ((entry != NULL) && (token_type != CANCEL)) { + int have_type = (1 << token_type); + if (!(entry->ute_type & have_type)) { + if (!silent) + _nc_warning("expected %s-type for %s, have %s", + usertype2s(entry->ute_type), + name, + usertype2s(have_type)); + result = FALSE; + } + } + return result; +} +#endif /* NCURSES_XNAMES */ + +/* + * A valid entry name uses characters from the "portable character set" + * (more commonly referred to as US-ASCII), and disallows some of the + * punctuation characters: + * + * '/' is a pathname separator + * '\' may be a pathname separator, but more important, is an escape + * '|' delimits names and description + * '#' denotes a numeric value + * '=' denotes a string value + * '@' denotes a cancelled symbol + * ',' separates terminfo capabilities + * ':' separates termcap capabilities + * + * Termcap capability names may begin with a '#' or '@' (since they have + * exactly two characters). + */ +static bool +valid_entryname(const char *name) +{ + bool result = TRUE; + bool first = TRUE; + int ch; + while ((ch = UChar(*name++)) != '\0') { + if (ch <= ' ' || ch > '~' || strchr("/\\|=,:", ch) != NULL) { + result = FALSE; + break; + } + if (!first && strchr("#@", ch) != NULL) { + result = FALSE; + break; + } + first = FALSE; + } + return result; +} + +/* + * int + * _nc_parse_entry(entry, literal, silent) + * + * Compile one entry. Doesn't try to resolve use or tc capabilities. + * + * found-forward-use = FALSE + * re-initialise internal arrays + * get_token(); + * if the token was not a name in column 1, complain and die + * save names in entry's string table + * while (get_token() is not EOF and not NAMES) + * check for existence and type-correctness + * enter cap into structure + * if STRING + * save string in entry's string table + * 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"); } + +#define MAX_NUMBER MAX_OF_TYPE(NCURSES_INT2) + +NCURSES_EXPORT(int) +_nc_parse_entry(ENTRY * entryp, int literal, bool silent) +{ + int token_type; + struct name_table_entry const *entry_ptr; + char *ptr, *base; + const char *name; + bool bad_tc_usage = FALSE; + + TR(TRACE_DATABASE, + (T_CALLED("_nc_parse_entry(entry=%p, literal=%d, silent=%d)"), + (void *) entryp, literal, silent)); + + token_type = _nc_get_token(silent); + + if (token_type == EOF) + returnDB(EOF); + if (token_type != NAMES) + _nc_err_abort("Entry does not start with terminal names in column one"); + + _nc_init_entry(entryp); + + entryp->cstart = _nc_comment_start; + entryp->cend = _nc_comment_end; + entryp->startline = _nc_start_line; + DEBUG(2, ("Comment range is %ld to %ld", entryp->cstart, entryp->cend)); + + /* + * 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. + */ +#define ok_TC2(s) (isgraph(UChar(s)) && (s) != '|') + ptr = _nc_curr_token.tk_name; + if (_nc_syntax == SYN_TERMCAP +#if NCURSES_XNAMES + && !_nc_user_definable +#endif + ) { + if (ok_TC2(ptr[0]) && ok_TC2(ptr[1]) && (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 == NULL) + returnDB(ERR); + + DEBUG(2, ("Starting '%s'", ptr)); + + /* + * We do this because the one-token lookahead in the parse loop + * results in the terminal type getting prematurely set to correspond + * to that of the next entry. + */ + name = _nc_first_name(entryp->tterm.term_names); + if (!valid_entryname(name)) { + _nc_warning("invalid entry name \"%s\"", name); + name = "invalid"; + } + _nc_set_type(name); + + /* check for overly-long names and aliases */ + for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != NULL; + base = ptr + 1) { + if (ptr - base > MAX_ALIAS) { + _nc_warning("%s `%.*s' may be too long", + (base == entryp->tterm.term_names) + ? "primary name" + : "alias", + (int) (ptr - base), base); + } + } + + entryp->nuses = 0; + + for (token_type = _nc_get_token(silent); + token_type != EOF && token_type != NAMES; + token_type = _nc_get_token(silent)) { + 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) { + char *saved; + + if (!VALID_STRING(_nc_curr_token.tk_valstring) + || _nc_curr_token.tk_valstring[0] == '\0') { + _nc_warning("missing name for use-clause"); + continue; + } else if (!valid_entryname(_nc_curr_token.tk_valstring)) { + _nc_warning("invalid name for use-clause \"%s\"", + _nc_curr_token.tk_valstring); + continue; + } else if (entryp->nuses >= HARD_MAX_USES) { + _nc_warning("too many use-clauses, ignored \"%s\"", + _nc_curr_token.tk_valstring); + continue; + } else if (entryp->nuses >= WARN_MAX_USES) { + _nc_warning("possibly too many use-clauses (%d vs %d), \"%s\"", + entryp->nuses, + WARN_MAX_USES, + _nc_curr_token.tk_valstring); + } + if ((saved = _nc_save_str(_nc_curr_token.tk_valstring)) != NULL) { + entryp->uses[entryp->nuses].name = saved; + 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_get_hash_table(_nc_syntax == SYN_TERMCAP)); + + /* + * Our kluge to handle aliasing. The reason it is done + * this ugly way, with a linear search, is so the hashing + * machinery doesn't have to be made really complicated + * (also we get better warnings this way). No point in + * making this case fast, aliased caps aren't common now + * and will get rarer. + */ + if (entry_ptr == NOTFOUND) { + const struct alias *ap; + + if (_nc_syntax == SYN_TERMCAP) { + 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", + ap->from, ap->source); + goto nexttok; + } + + 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_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", + ap->from, ap->source); + goto nexttok; + } + + 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); + break; + } + + if (entry_ptr == NOTFOUND) { + entry_ptr = lookup_fullname(_nc_curr_token.tk_name); + } + } + } +#if NCURSES_XNAMES + /* + * If we have extended-names active, we will automatically + * define a name based on its context. + */ + if (entry_ptr == NOTFOUND + && _nc_user_definable) { + if (expected_type(_nc_curr_token.tk_name, token_type, silent)) { + if ((entry_ptr = _nc_extend_names(entryp, + _nc_curr_token.tk_name, + token_type)) != NULL) { + if (_nc_tracing >= DEBUG_LEVEL(1)) { + _nc_warning("extended capability '%s'", + _nc_curr_token.tk_name); + } + } + } else { + /* ignore it: we have already printed error message */ + continue; + } + } +#endif /* NCURSES_XNAMES */ + + /* can't find this cap name, not even as an alias */ + if (entry_ptr == NOTFOUND) { + if (!silent) + _nc_warning("unknown capability '%s'", + _nc_curr_token.tk_name); + continue; + } + + /* deal with bad type/value combinations. */ + if (token_type == CANCEL) { + /* + * Prefer terminfo in this (long-obsolete) ambiguity: + */ + if (!strcmp("ma", _nc_curr_token.tk_name)) { + entry_ptr = _nc_find_type_entry("ma", NUMBER, + _nc_syntax != SYN_TERMINFO); + assert(entry_ptr != NULL); + } + } else if (entry_ptr->nte_type != token_type) { + /* + * Nasty special cases here handle situations in which type + * information can resolve name clashes. Normal lookup + * finds the last instance in the capability table of a + * given name, regardless of type. find_type_entry looks + * for a first matching instance with given type. So as + * long as all ambiguous names occur in pairs of distinct + * type, this will do the job. + */ + + 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_syntax != SYN_TERMINFO); + assert(entry_ptr != NULL); + + } 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_syntax != SYN_TERMINFO); + assert(entry_ptr != NULL); + + } else if (token_type == BOOLEAN + && entry_ptr->nte_type == STRING) { + /* treat strings without following "=" as empty strings */ + token_type = STRING; + } else { + /* we couldn't recover; skip this token */ + if (!silent) { + const char *type_name; + switch (entry_ptr->nte_type) { + case BOOLEAN: + type_name = "boolean"; + break; + case STRING: + type_name = "string"; + break; + case NUMBER: + type_name = "numeric"; + break; + default: + type_name = "unknown"; + break; + } + _nc_warning("wrong type used for %s capability '%s'", + type_name, _nc_curr_token.tk_name); + } + continue; + } + } + + /* now we know that the type/value combination is OK */ + switch (token_type) { + case CANCEL: + switch (entry_ptr->nte_type) { + case BOOLEAN: + entryp->tterm.Booleans[entry_ptr->nte_index] = + (NCURSES_SBOOL) CANCELLED_BOOLEAN; + break; + + case NUMBER: + entryp->tterm.Numbers[entry_ptr->nte_index] = CANCELLED_NUMERIC; + break; + + case STRING: + entryp->tterm.Strings[entry_ptr->nte_index] = CANCELLED_STRING; + break; + } + break; + + case BOOLEAN: + entryp->tterm.Booleans[entry_ptr->nte_index] = TRUE; + break; + + case NUMBER: +#if !NCURSES_EXT_NUMBERS + if (_nc_curr_token.tk_valnumber > MAX_NUMBER) { + entryp->tterm.Numbers[entry_ptr->nte_index] = MAX_NUMBER; + } else +#endif + { + entryp->tterm.Numbers[entry_ptr->nte_index] = + (NCURSES_INT2) _nc_curr_token.tk_valnumber; + } + break; + + case STRING: + ptr = _nc_curr_token.tk_valstring; + if (_nc_syntax == SYN_TERMCAP) { + int n = entry_ptr->nte_index; + ptr = _nc_captoinfo(_nc_curr_token.tk_name, + ptr, + (n < (int) SIZEOF(parametrized)) + ? parametrized[n] + : 0); + } + entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr); + break; + + default: + if (!silent) + _nc_warning("unknown token type"); + _nc_panic_mode((char) ((_nc_syntax == SYN_TERMCAP) ? ':' : ',')); + continue; + } + } /* end else cur_token.name != "use" */ + nexttok: + continue; /* cannot have a label w/o statement */ + } /* endwhile (not EOF and not NAMES) */ + + _nc_push_token(token_type); + _nc_set_type(_nc_first_name(entryp->tterm.term_names)); + + /* + * Try to deduce as much as possible from extension capabilities + * (this includes obsolete BSD capabilities). Sigh...it would be more + * space-efficient to call this after use resolution, but it has + * to be done before entry allocation is wrapped up. + */ + if (!literal) { + if (_nc_syntax == SYN_TERMCAP) { + bool has_base_entry = FALSE; + + /* + * Don't insert defaults if this is a `+' entry meant only + * for inclusion in other entries (not sure termcap ever + * had these, actually). + */ + if (strchr(entryp->tterm.term_names, '+')) { + has_base_entry = TRUE; + } else { + unsigned i; + /* + * Otherwise, look for a base entry that will already + * have picked up defaults via translation. + */ + for (i = 0; i < entryp->nuses; i++) { + if (entryp->uses[i].name != NULL + && !strchr(entryp->uses[i].name, '+')) + has_base_entry = TRUE; + } + } + + postprocess_termcap(&entryp->tterm, has_base_entry); + } else + postprocess_terminfo(&entryp->tterm); + } + _nc_wrap_entry(entryp, FALSE); + + returnDB(OK); +} + +NCURSES_EXPORT(int) +_nc_capcmp(const char *s, const char *t) +/* compare two string capabilities, stripping out padding */ +{ + bool ok_s = VALID_STRING(s); + bool ok_t = VALID_STRING(t); + + if (ok_s && ok_t) { + for (;;) { + if (s[0] == '$' && s[1] == '<') { + for (s += 2;; s++) { + if (!(isdigit(UChar(*s)) + || *s == '.' + || *s == '*' + || *s == '/' + || *s == '>')) { + break; + } + } + } + + if (t[0] == '$' && t[1] == '<') { + for (t += 2;; t++) { + if (!(isdigit(UChar(*t)) + || *t == '.' + || *t == '*' + || *t == '/' + || *t == '>')) { + break; + } + } + } + + /* we've now pushed s and t past any padding they pointed at */ + + if (*s == '\0' && *t == '\0') + return (0); + + if (*s != *t) + return (*t - *s); + + /* else *s == *t but one is not NUL, so continue */ + s++, t++; + } + } else if (ok_s || ok_t) { + return 1; + } + return 0; +} + +static void +append_acs0(string_desc * dst, int code, const char *src, size_t off) +{ + if (src != NULL && off < strlen(src)) { + char temp[3]; + temp[0] = (char) code; + temp[1] = src[off]; + temp[2] = 0; + _nc_safe_strcat(dst, temp); + } +} + +static void +append_acs(string_desc * dst, int code, const char *src) +{ + if (VALID_STRING(src) && strlen(src) == 1) { + append_acs0(dst, code, src, 0); + } +} + +/* + * The ko capability, if present, consists of a comma-separated capability + * list. For each capability, we may assume there is a keycap that sends the + * string which is the value of that capability. + */ +#define DATA(from, to) { { from }, { to } } +typedef struct { + const char from[3]; + const char to[6]; +} assoc; +static assoc const ko_xlate[] = +{ + DATA("al", "kil1"), /* insert line key -> KEY_IL */ + DATA("bt", "kcbt"), /* back tab -> KEY_BTAB */ + DATA("cd", "ked"), /* clear-to-eos key -> KEY_EOL */ + DATA("ce", "kel"), /* clear-to-eol key -> KEY_EOS */ + DATA("cl", "kclr"), /* clear key -> KEY_CLEAR */ + DATA("ct", "tbc"), /* clear all tabs -> KEY_CATAB */ + DATA("dc", "kdch1"), /* delete char -> KEY_DC */ + DATA("dl", "kdl1"), /* delete line -> KEY_DL */ + DATA("do", "kcud1"), /* down key -> KEY_DOWN */ + DATA("ei", "krmir"), /* exit insert key -> KEY_EIC */ + DATA("ho", "khome"), /* home key -> KEY_HOME */ + DATA("ic", "kich1"), /* insert char key -> KEY_IC */ + DATA("im", "kIC"), /* insert-mode key -> KEY_SIC */ + DATA("le", "kcub1"), /* le key -> KEY_LEFT */ + DATA("nd", "kcuf1"), /* nd key -> KEY_RIGHT */ + DATA("nl", "kent"), /* new line key -> KEY_ENTER */ + DATA("st", "khts"), /* set-tab key -> KEY_STAB */ + DATA("ta", ""), + DATA("up", "kcuu1"), /* up-arrow key -> KEY_UP */ +}; + +/* + * This routine fills in string caps that either had defaults under + * termcap or can be manufactured from obsolete termcap capabilities. + * It was lifted from Ross Ridge's mytinfo package. + */ + +static const char C_CR[] = "\r"; +static const char C_LF[] = "\n"; +static const char C_BS[] = "\b"; +static const char C_HT[] = "\t"; + +/* + * This bit of legerdemain turns all the terminfo variable names into + * references to locations in the arrays Booleans, Numbers, and Strings --- + * precisely what's needed. + */ + +#undef CUR +#define CUR tp-> + +static void +postprocess_termcap(TERMTYPE2 *tp, bool has_base) +{ + char buf[MAX_LINE * 2 + 2]; + string_desc result; + + TR(TRACE_DATABASE, + (T_CALLED("postprocess_termcap(tp=%p, has_base=%d)"), + (void *) tp, has_base)); + + /* + * TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS + * + * This first part of the code is the functional inverse of the + * fragment in capdefaults.c. + * ---------------------------------------------------------------------- + */ + + /* if there was a tc entry, assume we picked up defaults via that */ + if (!has_base) { + if (WANTED(init_3string) && PRESENT(termcap_init2)) + init_3string = _nc_save_str(termcap_init2); + + if (WANTED(reset_2string) && PRESENT(termcap_reset)) + reset_2string = _nc_save_str(termcap_reset); + + if (WANTED(carriage_return)) { + if (carriage_return_delay > 0) { + _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) + "%s$<%d>", C_CR, carriage_return_delay); + carriage_return = _nc_save_str(buf); + } else + carriage_return = _nc_save_str(C_CR); + } + if (WANTED(cursor_left)) { + if (backspace_delay > 0) { + _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) + "%s$<%d>", C_BS, backspace_delay); + cursor_left = _nc_save_str(buf); + } else if (backspaces_with_bs == 1) + cursor_left = _nc_save_str(C_BS); + else if (PRESENT(backspace_if_not_bs)) + cursor_left = backspace_if_not_bs; + } + /* vi doesn't use "do", but it does seem to use nl (or '\n') instead */ + if (WANTED(cursor_down)) { + if (PRESENT(linefeed_if_not_lf)) + cursor_down = linefeed_if_not_lf; + else if (linefeed_is_newline != 1) { + if (new_line_delay > 0) { + _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) + "%s$<%d>", C_LF, new_line_delay); + cursor_down = _nc_save_str(buf); + } else + cursor_down = _nc_save_str(C_LF); + } + } + if (WANTED(scroll_forward) && crt_no_scrolling != 1) { + if (PRESENT(linefeed_if_not_lf)) + cursor_down = linefeed_if_not_lf; + else if (linefeed_is_newline != 1) { + if (new_line_delay > 0) { + _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) + "%s$<%d>", C_LF, new_line_delay); + scroll_forward = _nc_save_str(buf); + } else + scroll_forward = _nc_save_str(C_LF); + } + } + if (WANTED(newline)) { + if (linefeed_is_newline == 1) { + if (new_line_delay > 0) { + _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) + "%s$<%d>", C_LF, new_line_delay); + newline = _nc_save_str(buf); + } else + newline = _nc_save_str(C_LF); + } else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) { + _nc_str_init(&result, buf, sizeof(buf)); + if (_nc_safe_strcat(&result, carriage_return) + && _nc_safe_strcat(&result, scroll_forward)) + newline = _nc_save_str(buf); + } else if (PRESENT(carriage_return) && PRESENT(cursor_down)) { + _nc_str_init(&result, buf, sizeof(buf)); + if (_nc_safe_strcat(&result, carriage_return) + && _nc_safe_strcat(&result, cursor_down)) + newline = _nc_save_str(buf); + } + } + } + + /* + * Inverse of capdefaults.c code ends here. + * ---------------------------------------------------------------------- + * + * TERMCAP-TO TERMINFO MAPPINGS FOR SOURCE TRANSLATION + * + * These translations will *not* be inverted by tgetent(). + */ + + if (!has_base) { + /* + * We wait until now to decide if we've got a working cr because even + * one that doesn't work can be used for newline. Unfortunately the + * space allocated for it is wasted. + */ + if (return_does_clr_eol == 1 || no_correctly_working_cr == 1) + carriage_return = ABSENT_STRING; + + /* + * Supposedly most termcap entries have ta now and '\t' is no longer a + * default, but it doesn't seem to be true... + */ + if (WANTED(tab)) { + if (horizontal_tab_delay > 0) { + _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) + "%s$<%d>", C_HT, horizontal_tab_delay); + tab = _nc_save_str(buf); + } else + tab = _nc_save_str(C_HT); + } + if (init_tabs == ABSENT_NUMERIC && has_hardware_tabs == TRUE) + init_tabs = 8; + + /* + * Assume we can beep with ^G unless we're given bl@. + */ + if (WANTED(bell)) + bell = _nc_save_str("\007"); + } + + /* + * Translate the old termcap :pt: capability to it#8 + ht=\t + */ + if (has_hardware_tabs == TRUE) { + if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC) + _nc_warning("hardware tabs with a width other than 8: %d", init_tabs); + else { + if (PRESENT(tab) && _nc_capcmp(tab, C_HT)) + _nc_warning("hardware tabs with a non-^I tab string %s", + _nc_visbuf(tab)); + else { + if (WANTED(tab)) + tab = _nc_save_str(C_HT); + init_tabs = 8; + } + } + } + /* + * Now translate the ko capability, if there is one. This + * isn't from mytinfo... + */ + if (PRESENT(other_non_function_keys)) { + char *base; + char *bp, *cp, *dp; + struct name_table_entry const *from_ptr; + struct name_table_entry const *to_ptr; + char buf2[MAX_TERMINFO_LENGTH]; + bool foundim; + + /* we're going to use this for a special case later */ + dp = strchr(other_non_function_keys, 'i'); + foundim = (dp != NULL) && (dp[1] == 'm'); + + /* look at each comma-separated capability in the ko string... */ + for (base = other_non_function_keys; + (cp = strchr(base, ',')) != NULL; + base = cp + 1) { + size_t len = (unsigned) (cp - base); + size_t n; + assoc const *ap = NULL; + + for (n = 0; n < SIZEOF(ko_xlate); ++n) { + if (len == strlen(ko_xlate[n].from) + && strncmp(ko_xlate[n].from, base, len) == 0) { + ap = ko_xlate + n; + break; + } + } + if (ap == NULL) { + _nc_warning("unknown capability `%.*s' in ko string", + (int) len, base); + continue; + } else if (ap->to[0] == '\0') /* ignore it */ + continue; + + /* now we know we found a match in ko_table, so... */ + + 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"); + + if (WANTED(tp->Strings[from_ptr->nte_index])) { + _nc_warning("no value for ko capability %s", ap->from); + continue; + } + + if (tp->Strings[to_ptr->nte_index]) { + const char *s = tp->Strings[from_ptr->nte_index]; + const char *t = tp->Strings[to_ptr->nte_index]; + /* There's no point in warning about it if it is the same + * string; that's just an inefficiency. + */ + if (VALID_STRING(s) && VALID_STRING(t) && strcmp(s, t) != 0) + _nc_warning("%s (%s) already has an explicit value %s, ignoring ko", + ap->to, ap->from, t); + continue; + } + + /* + * The magic moment -- copy the mapped key string over, + * stripping out padding. + */ + bp = tp->Strings[from_ptr->nte_index]; + if (VALID_STRING(bp)) { + for (dp = buf2; *bp; bp++) { + if ((size_t) (dp - buf2) >= (sizeof(buf2) - sizeof(TERMTYPE2))) + break; + if (bp[0] == '$' && bp[1] == '<') { + while (*bp && *bp != '>') { + ++bp; + } + } else + *dp++ = *bp; + } + *dp = '\0'; + + tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2); + } else { + tp->Strings[to_ptr->nte_index] = bp; + } + } + + /* + * Note: ko=im and ko=ic both want to grab the `Insert' + * keycap. There's a kich1 but no ksmir, so the ic capability + * got mapped to kich1 and im to kIC to avoid a collision. + * If the description has im but not ic, hack kIC back to kich1. + */ + if (foundim && WANTED(key_ic) && PRESENT(key_sic)) { + key_ic = key_sic; + key_sic = ABSENT_STRING; + } + } + + if (!has_base) { + if (!hard_copy) { + if (WANTED(key_backspace)) + key_backspace = _nc_save_str(C_BS); + if (WANTED(key_left)) + key_left = _nc_save_str(C_BS); + if (WANTED(key_down)) + key_down = _nc_save_str(C_LF); + } + } + + /* + * Translate XENIX forms characters. + */ + if (PRESENT(acs_ulcorner) || + PRESENT(acs_llcorner) || + PRESENT(acs_urcorner) || + PRESENT(acs_lrcorner) || + PRESENT(acs_ltee) || + PRESENT(acs_rtee) || + PRESENT(acs_btee) || + PRESENT(acs_ttee) || + PRESENT(acs_hline) || + PRESENT(acs_vline) || + PRESENT(acs_plus)) { + char buf2[MAX_TERMCAP_LENGTH]; + + _nc_str_init(&result, buf2, sizeof(buf2)); + _nc_safe_strcat(&result, acs_chars); + + append_acs(&result, 'j', acs_lrcorner); + append_acs(&result, 'k', acs_urcorner); + append_acs(&result, 'l', acs_ulcorner); + append_acs(&result, 'm', acs_llcorner); + append_acs(&result, 'n', acs_plus); + append_acs(&result, 'q', acs_hline); + append_acs(&result, 't', acs_ltee); + append_acs(&result, 'u', acs_rtee); + append_acs(&result, 'v', acs_btee); + append_acs(&result, 'w', acs_ttee); + append_acs(&result, 'x', acs_vline); + + if (buf2[0]) { + acs_chars = _nc_save_str(buf2); + _nc_warning("acsc string synthesized from XENIX capabilities"); + } + } else if (acs_chars == ABSENT_STRING + && PRESENT(enter_alt_charset_mode) + && PRESENT(exit_alt_charset_mode)) { + acs_chars = _nc_save_str(VT_ACSC); + } + returnVoidDB; +} + +static void +postprocess_terminfo(TERMTYPE2 *tp) +{ + TR(TRACE_DATABASE, + (T_CALLED("postprocess_terminfo(tp=%p)"), + (void *) tp)); + + /* + * TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION + * ---------------------------------------------------------------------- + */ + + /* + * Translate AIX forms characters. + */ + if (PRESENT(box_chars_1)) { + char buf2[MAX_TERMCAP_LENGTH]; + string_desc result; + + _nc_str_init(&result, buf2, sizeof(buf2)); + _nc_safe_strcat(&result, acs_chars); + + append_acs0(&result, 'l', box_chars_1, 0); /* ACS_ULCORNER */ + append_acs0(&result, 'q', box_chars_1, 1); /* ACS_HLINE */ + append_acs0(&result, 'k', box_chars_1, 2); /* ACS_URCORNER */ + append_acs0(&result, 'x', box_chars_1, 3); /* ACS_VLINE */ + append_acs0(&result, 'j', box_chars_1, 4); /* ACS_LRCORNER */ + append_acs0(&result, 'm', box_chars_1, 5); /* ACS_LLCORNER */ + append_acs0(&result, 'w', box_chars_1, 6); /* ACS_TTEE */ + append_acs0(&result, 'u', box_chars_1, 7); /* ACS_RTEE */ + append_acs0(&result, 'v', box_chars_1, 8); /* ACS_BTEE */ + append_acs0(&result, 't', box_chars_1, 9); /* ACS_LTEE */ + append_acs0(&result, 'n', box_chars_1, 10); /* ACS_PLUS */ + + if (buf2[0]) { + acs_chars = _nc_save_str(buf2); + _nc_warning("acsc string synthesized from AIX capabilities"); + box_chars_1 = ABSENT_STRING; + } + } + /* + * ---------------------------------------------------------------------- + */ + returnVoidDB; +} + +/* + * Do a linear search through the terminfo tables to find a given full-name. + * We don't expect to do this often, so there's no hashing function. + * + * In effect, this scans through the 3 lists of full-names, and looks them + * up in _nc_info_table, which is organized so that the nte_index fields are + * sorted, but the nte_type fields are not necessarily grouped together. + */ +static struct name_table_entry const * +lookup_fullname(const char *find) +{ + int state = -1; + + for (;;) { + int count = 0; + NCURSES_CONST char *const *names; + + switch (++state) { + case BOOLEAN: + names = boolfnames; + break; + case STRING: + names = strfnames; + break; + case NUMBER: + names = numfnames; + break; + default: + return NOTFOUND; + } + + for (count = 0; names[count] != NULL; count++) { + if (!strcmp(names[count], find)) { + struct name_table_entry const *entry_ptr = _nc_get_table(FALSE); + while (entry_ptr->nte_type != state + || entry_ptr->nte_index != count) + entry_ptr++; + return entry_ptr; + } + } + } +} + +/* parse_entry.c ends here */ diff --git a/ncurses/ncurses/tinfo/read_entry.c b/ncurses/ncurses/tinfo/read_entry.c new file mode 100644 index 0000000000..5a4acda78d --- /dev/null +++ b/ncurses/ncurses/tinfo/read_entry.c @@ -0,0 +1,936 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * read_entry.c -- Routine for reading in a compiled terminfo file + */ + +#include +#include + +#include + +MODULE_ID("$Id: read_entry.c,v 1.175 2025/01/11 23:52:18 tom Exp $") + +#define MyNumber(n) (short) LOW_MSB(n) + +#define SIZEOF_32BITS 4 + +#if NCURSES_USE_DATABASE +#if NCURSES_EXT_NUMBERS +static size_t +convert_16bits(const char *buf, NCURSES_INT2 *Numbers, int count) +{ + int i; + size_t j; + size_t size = SIZEOF_SHORT; + for (i = 0; i < count; i++) { + unsigned mask = 0xff; + unsigned char ch = 0; + Numbers[i] = 0; + for (j = 0; j < size; ++j) { + ch = UChar(*buf++); + Numbers[i] |= (ch << (8 * j)); + mask <<= 8; + } + if (ch & 0x80) { + while (mask != 0) { + Numbers[i] |= (int) mask; + mask <<= 8; + } + } + TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i])); + } + return size; +} + +static size_t +convert_32bits(const char *buf, NCURSES_INT2 *Numbers, int count) +{ + int i; + size_t j; + size_t size = SIZEOF_INT2; + unsigned char ch; + + assert(sizeof(NCURSES_INT2) == size); + for (i = 0; i < count; i++) { + Numbers[i] = 0; + for (j = 0; j < size; ++j) { + ch = UChar(*buf++); + Numbers[i] |= (ch << (8 * j)); + } + /* "unsigned" and NCURSES_INT2 are the same size - no sign-extension */ + TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i])); + } + return size; +} +#else +static size_t +convert_32bits(const char *buf, NCURSES_INT2 *Numbers, int count) +{ + int i, j; + unsigned char ch; + for (i = 0; i < count; i++) { + int value = 0; + for (j = 0; j < SIZEOF_32BITS; ++j) { + ch = UChar(*buf++); + value |= (ch << (8 * j)); + } + if (value == -1) + Numbers[i] = ABSENT_NUMERIC; + else if (value == -2) + Numbers[i] = CANCELLED_NUMERIC; + else if (value > MAX_OF_TYPE(NCURSES_INT2)) + Numbers[i] = MAX_OF_TYPE(NCURSES_INT2); + else + Numbers[i] = (short) value; + TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i])); + } + return SIZEOF_SHORT; +} + +static size_t +convert_16bits(const char *buf, NCURSES_INT2 *Numbers, int count) +{ + int i; + for (i = 0; i < count; i++) { + if (IS_NEG1(buf + 2 * i)) + Numbers[i] = ABSENT_NUMERIC; + else if (IS_NEG2(buf + 2 * i)) + Numbers[i] = CANCELLED_NUMERIC; + else + Numbers[i] = MyNumber(buf + 2 * i); + TR(TRACE_DATABASE, ("get Numbers[%d]=%d", i, Numbers[i])); + } + return SIZEOF_SHORT; +} +#endif + +static bool +convert_strings(char *buf, char **Strings, int count, int size, + char *table, bool always) +{ + int i; + char *p; + bool success = TRUE; + + for (i = 0; i < count; i++) { + if (IS_NEG1(buf + 2 * i)) { + Strings[i] = ABSENT_STRING; + } else if (IS_NEG2(buf + 2 * i)) { + Strings[i] = CANCELLED_STRING; + } else if (MyNumber(buf + 2 * i) > size) { + Strings[i] = ABSENT_STRING; + } else { + int nn = MyNumber(buf + 2 * i); + if (nn >= 0 && nn < size) { + Strings[i] = (nn + table); + TR(TRACE_DATABASE, ("Strings[%d] = %s", i, + _nc_visbuf(Strings[i]))); + } else { + TR(TRACE_DATABASE, + ("found out-of-range index %d to Strings[%d]", nn, i)); + success = FALSE; + break; + } + } + + /* make sure all strings are NUL terminated */ + if (VALID_STRING(Strings[i])) { + for (p = Strings[i]; p < table + size; p++) + if (*p == '\0') + break; + /* if there is no NUL, ignore the string */ + if (p >= table + size) { + Strings[i] = ABSENT_STRING; + } else if (p == Strings[i] && always) { + TR(TRACE_DATABASE, + ("found empty but required Strings[%d]", i)); + success = FALSE; + break; + } + } else if (always) { /* names are always needed */ + TR(TRACE_DATABASE, + ("found invalid but required Strings[%d]", i)); + success = FALSE; + break; + } + } + if (!success) { + _nc_warning("corrupt data found in convert_strings"); + } + return success; +} + +static int +fake_read(const char *src, int *offset, int limit, char *dst, unsigned want) +{ + int have = (limit - *offset); + + if (have > 0) { + if ((int) want > have) + want = (unsigned) have; + memcpy(dst, src + *offset, (size_t) want); + *offset += (int) want; + } else { + want = 0; + } + return (int) want; +} + +#define Read(buf, count) fake_read(buffer, &offset, limit, (char *) buf, (unsigned) count) + +#define read_shorts(buf, count) \ + (Read(buf, (count)*SIZEOF_SHORT) == (int) (count)*SIZEOF_SHORT) + +#define read_numbers(buf, count) \ + (Read(buf, (count)*(unsigned)size_of_numbers) == (int) (count)*size_of_numbers) + +#define even_boundary(value) \ + if ((value) % 2 != 0) Read(buf, 1) +#endif + +NCURSES_EXPORT(void) +_nc_init_termtype(TERMTYPE2 *const tp) +{ + unsigned i; + + DEBUG(2, (T_CALLED("_nc_init_termtype(tp=%p)"), (void *) tp)); + +#if NCURSES_XNAMES + tp->num_Booleans = BOOLCOUNT; + tp->num_Numbers = NUMCOUNT; + tp->num_Strings = STRCOUNT; + tp->ext_Booleans = 0; + tp->ext_Numbers = 0; + tp->ext_Strings = 0; +#endif + if (tp->Booleans == NULL) + TYPE_MALLOC(NCURSES_SBOOL, BOOLCOUNT, tp->Booleans); + if (tp->Numbers == NULL) + TYPE_MALLOC(NCURSES_INT2, NUMCOUNT, tp->Numbers); + if (tp->Strings == NULL) + TYPE_MALLOC(char *, STRCOUNT, tp->Strings); + + for_each_boolean(i, tp) + tp->Booleans[i] = FALSE; + + for_each_number(i, tp) + tp->Numbers[i] = ABSENT_NUMERIC; + + for_each_string(i, tp) + tp->Strings[i] = ABSENT_STRING; + + DEBUG(2, (T_RETURN(""))); +} + +#if NCURSES_USE_DATABASE +#if NCURSES_XNAMES +static bool +valid_shorts(char *buffer, int limit) +{ + bool result = FALSE; + int n; + for (n = 0; n < limit; ++n) { + if (MyNumber(buffer + (n * 2)) > 0) { + result = TRUE; + break; + } + } + return result; +} +#endif + +/* + * Return TGETENT_YES if read, TGETENT_NO if not found or garbled. + */ +NCURSES_EXPORT(int) +_nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit) +{ + int offset = 0; + int name_size, bool_count, num_count, str_count, str_size; + int i; + char buf[MAX_ENTRY_SIZE + 2]; + char *string_table; + unsigned want, have; + size_t (*convert_numbers) (const char *, NCURSES_INT2 *, int); + int size_of_numbers; + int max_entry_size = MAX_ENTRY_SIZE; + + TR(TRACE_DATABASE, + (T_CALLED("_nc_read_termtype(ptr=%p, buffer=%p, limit=%d)"), + (void *) ptr, buffer, limit)); + + TR(TRACE_DATABASE, ("READ termtype header @%d", offset)); + + memset(ptr, 0, sizeof(*ptr)); + + /* grab the header */ + if (!read_shorts(buf, 6) + || !IS_TIC_MAGIC(buf)) { + returnDB(TGETENT_NO); + } +#if NCURSES_EXT_NUMBERS + if (LOW_MSB(buf) == MAGIC2) { + convert_numbers = convert_32bits; + size_of_numbers = SIZEOF_INT2; + } else { + max_entry_size = MAX_ENTRY_SIZE1; + convert_numbers = convert_16bits; + size_of_numbers = SIZEOF_SHORT; + } +#else + if (LOW_MSB(buf) == MAGIC2) { + convert_numbers = convert_32bits; + size_of_numbers = SIZEOF_32BITS; + } else { + convert_numbers = convert_16bits; + size_of_numbers = SIZEOF_INT2; + } +#endif + + /* *INDENT-EQLS* */ + name_size = MyNumber(buf + 2); + bool_count = MyNumber(buf + 4); + num_count = MyNumber(buf + 6); + str_count = MyNumber(buf + 8); + str_size = MyNumber(buf + 10); + + TR(TRACE_DATABASE, + ("TERMTYPE name_size=%d, bool=%d/%d, num=%d/%d str=%d/%d(%d)", + name_size, bool_count, BOOLCOUNT, num_count, NUMCOUNT, + str_count, STRCOUNT, str_size)); + if (name_size < 0 + || bool_count < 0 + || num_count < 0 + || str_count < 0 + || bool_count > BOOLCOUNT + || num_count > NUMCOUNT + || str_count > STRCOUNT + || str_size < 0) { + returnDB(TGETENT_NO); + } + + want = (unsigned) (str_size + name_size + 1); + /* try to allocate space for the string table */ + if (str_count * SIZEOF_SHORT >= max_entry_size + || (string_table = typeMalloc(char, want)) == NULL) { + returnDB(TGETENT_NO); + } + + /* 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 = (unsigned) Read(ptr->term_names, want)) != want) { + memset(ptr->term_names + have, 0, (size_t) (want - have)); + } + ptr->term_names[want] = '\0'; + string_table += (want + 1); + + if (have > MAX_NAME_SIZE) + offset = (int) (have - MAX_NAME_SIZE); + + /* grab the booleans */ + TYPE_CALLOC(NCURSES_SBOOL, Max(BOOLCOUNT, bool_count), ptr->Booleans); + if (Read(ptr->Booleans, (unsigned) bool_count) < bool_count) { + returnDB(TGETENT_NO); + } + + /* + * If booleans end on an odd byte, skip it. The machine they + * originally wrote terminfo on must have been a 16-bit + * word-oriented machine that would trap out if you tried a + * word access off a 2-byte boundary. + */ + even_boundary(name_size + bool_count); + + /* grab the numbers */ + TYPE_CALLOC(NCURSES_INT2, Max(NUMCOUNT, num_count), ptr->Numbers); + if (!read_numbers(buf, num_count)) { + returnDB(TGETENT_NO); + } + convert_numbers(buf, ptr->Numbers, num_count); + + TYPE_CALLOC(char *, Max(STRCOUNT, str_count), ptr->Strings); + + if (str_count) { + /* grab the string offsets */ + if (!read_shorts(buf, str_count)) { + returnDB(TGETENT_NO); + } + /* finally, grab the string table itself */ + if (Read(string_table, (unsigned) str_size) != str_size) { + returnDB(TGETENT_NO); + } + if (!convert_strings(buf, ptr->Strings, str_count, str_size, + string_table, FALSE)) { + returnDB(TGETENT_NO); + } + } +#if NCURSES_XNAMES + + ptr->num_Booleans = BOOLCOUNT; + ptr->num_Numbers = NUMCOUNT; + ptr->num_Strings = STRCOUNT; + + /* + * Read extended entries, if any, after the normal end of terminfo data. + */ + even_boundary(str_size); + TR(TRACE_DATABASE, ("READ extended_header @%d", offset)); + if (_nc_user_definable && read_shorts(buf, 5) && valid_shorts(buf, 5)) { + int ext_bool_count = MyNumber(buf + 0); + int ext_num_count = MyNumber(buf + 2); + int ext_str_count = MyNumber(buf + 4); + int ext_str_usage = MyNumber(buf + 6); + int ext_str_limit = MyNumber(buf + 8); + unsigned need = (unsigned) (ext_bool_count + ext_num_count + ext_str_count); + int base = 0; + + if ((int) need >= (max_entry_size / 2) + || ext_str_usage >= max_entry_size + || ext_str_limit >= max_entry_size + || ext_bool_count < 0 + || ext_num_count < 0 + || ext_str_count < 0 + || ext_str_usage < 0 + || ext_str_limit < 0) { + returnDB(TGETENT_NO); + } + + ptr->num_Booleans = UShort(BOOLCOUNT + ext_bool_count); + ptr->num_Numbers = UShort(NUMCOUNT + ext_num_count); + ptr->num_Strings = UShort(STRCOUNT + ext_str_count); + + TYPE_REALLOC(NCURSES_SBOOL, ptr->num_Booleans, ptr->Booleans); + TYPE_REALLOC(NCURSES_INT2, ptr->num_Numbers, ptr->Numbers); + TYPE_REALLOC(char *, ptr->num_Strings, ptr->Strings); + + TR(TRACE_DATABASE, ("extended header: " + "bool %d, " + "number %d, " + "string %d(%d:%d)", + ext_bool_count, + ext_num_count, + ext_str_count, + ext_str_usage, + ext_str_limit)); + + TR(TRACE_DATABASE, ("READ %d extended-booleans @%d", + ext_bool_count, offset)); + if ((ptr->ext_Booleans = UShort(ext_bool_count)) != 0) { + if (Read(ptr->Booleans + BOOLCOUNT, (unsigned) + ext_bool_count) != ext_bool_count) { + returnDB(TGETENT_NO); + } + } + even_boundary(ext_bool_count); + + TR(TRACE_DATABASE, ("READ %d extended-numbers @%d", + ext_num_count, offset)); + if ((ptr->ext_Numbers = UShort(ext_num_count)) != 0) { + if (!read_numbers(buf, ext_num_count)) { + returnDB(TGETENT_NO); + } + TR(TRACE_DATABASE, ("Before converting extended-numbers")); + convert_numbers(buf, ptr->Numbers + NUMCOUNT, ext_num_count); + } + + TR(TRACE_DATABASE, ("READ extended-offsets @%d", offset)); + if ((ext_str_count + (int) need) >= (max_entry_size / 2)) { + returnDB(TGETENT_NO); + } + if ((ext_str_count || need) + && !read_shorts(buf, ext_str_count + (int) need)) { + returnDB(TGETENT_NO); + } + + TR(TRACE_DATABASE, ("READ %d bytes of extended-strings @%d", + ext_str_limit, offset)); + + if (ext_str_limit) { + ptr->ext_str_table = typeMalloc(char, (size_t) ext_str_limit); + if (ptr->ext_str_table == NULL) { + returnDB(TGETENT_NO); + } + if (Read(ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit) { + returnDB(TGETENT_NO); + } + TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table))); + } + + if ((ptr->ext_Strings = UShort(ext_str_count)) != 0) { + int check = (ext_bool_count + ext_num_count + ext_str_count); + + TR(TRACE_DATABASE, + ("Before computing extended-string capabilities " + "str_count=%d, ext_str_count=%d", + str_count, ext_str_count)); + if (!convert_strings(buf, ptr->Strings + str_count, ext_str_count, + ext_str_limit, ptr->ext_str_table, FALSE)) { + returnDB(TGETENT_NO); + } + for (i = ext_str_count - 1; i >= 0; i--) { + TR(TRACE_DATABASE, ("MOVE from [%d:%d] %s", + i, i + str_count, + _nc_visbuf(ptr->Strings[i + str_count]))); + ptr->Strings[i + STRCOUNT] = ptr->Strings[i + str_count]; + if (VALID_STRING(ptr->Strings[i + STRCOUNT])) { + base += (int) (strlen(ptr->Strings[i + STRCOUNT]) + 1); + ++check; + } + TR(TRACE_DATABASE, ("... to [%d] %s", + i + STRCOUNT, + _nc_visbuf(ptr->Strings[i + STRCOUNT]))); + } + TR(TRACE_DATABASE, ("Check table-size: %d/%d", check, ext_str_usage)); +#if 0 + /* + * Phasing in a proper check will be done "later". + */ + if (check != ext_str_usage) + returnDB(TGETENT_NO); +#endif + } + + if (need) { + if (ext_str_count >= (max_entry_size / 2)) { + returnDB(TGETENT_NO); + } + TYPE_CALLOC(char *, need, ptr->ext_Names); + TR(TRACE_DATABASE, + ("ext_NAMES starting @%d in extended_strings, first = %s", + base, _nc_visbuf(ptr->ext_str_table + base))); + if (!convert_strings(buf + (2 * ext_str_count), + ptr->ext_Names, + (int) need, + ext_str_limit, ptr->ext_str_table + base, + TRUE)) { + returnDB(TGETENT_NO); + } + } + + TR(TRACE_DATABASE, + ("...done reading terminfo bool %d(%d) num %d(%d) str %d(%d)", + ptr->num_Booleans, ptr->ext_Booleans, + ptr->num_Numbers, ptr->ext_Numbers, + ptr->num_Strings, ptr->ext_Strings)); + + TR(TRACE_DATABASE, ("extend: num_Booleans:%d", ptr->num_Booleans)); + } else +#endif /* NCURSES_XNAMES */ + { + TR(TRACE_DATABASE, ("...done reading terminfo bool %d num %d str %d", + bool_count, num_count, str_count)); +#if NCURSES_XNAMES + TR(TRACE_DATABASE, ("normal: num_Booleans:%d", ptr->num_Booleans)); +#endif + } + + for (i = bool_count; i < BOOLCOUNT; i++) + ptr->Booleans[i] = FALSE; + for (i = num_count; i < NUMCOUNT; i++) + ptr->Numbers[i] = ABSENT_NUMERIC; + for (i = str_count; i < STRCOUNT; i++) + ptr->Strings[i] = ABSENT_STRING; + + returnDB(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, TERMTYPE2 *ptr) +/* return 1 if read, 0 if not found or garbled */ +{ + FILE *fp = NULL; + int code; + + if (_nc_access(filename, R_OK) < 0 + || (fp = safe_fopen(filename, BIN_R)) == NULL) { + TR(TRACE_DATABASE, ("cannot open terminfo %s (errno=%d)", filename, errno)); + code = TGETENT_NO; + } else { + int limit; + char buffer[MAX_ENTRY_SIZE + 1]; + + limit = (int) fread(buffer, sizeof(char), sizeof(buffer), fp); + if (limit > 0) { + const char *old_source = _nc_get_source(); + + TR(TRACE_DATABASE, ("read terminfo %s", filename)); + if (old_source == NULL) + _nc_set_source(filename); + if ((code = _nc_read_termtype(ptr, buffer, limit)) == TGETENT_NO) { + _nc_free_termtype2(ptr); + } + _nc_set_source(old_source); + } else { + code = TGETENT_NO; + } + fclose(fp); + } + + return (code); +} + +#if USE_HASHED_DB +/* + * Return if if we can build the filename of a ".db" file. + */ +static bool +make_db_filename(char *filename, unsigned limit, const char *const path) +{ + static const char suffix[] = DBM_SUFFIX; + + size_t lens = sizeof(suffix) - 1; + size_t size = strlen(path); + size_t test = lens + size; + bool result = FALSE; + + if (test < limit) { + if (size >= lens + && !strcmp(path + size - lens, suffix)) + _nc_STRCPY(filename, path, limit); + else + _nc_SPRINTF(filename, _nc_SLIMIT(limit) "%s%s", path, suffix); + result = TRUE; + } + return result; +} +#endif + +/* + * Return true if we can build the name of a filesystem entry. + */ +static bool +make_dir_filename(char *filename, + unsigned limit, + const char *const path, + const char *name) +{ + bool result = FALSE; + +#if NCURSES_USE_TERMCAP + if (_nc_is_dir_path(path)) +#endif + { + unsigned need = (unsigned) (LEAF_LEN + 3 + strlen(path) + strlen(name)); + + if (need <= limit) { + _nc_SPRINTF(filename, _nc_SLIMIT(limit) + "%s/" LEAF_FMT "/%s", path, *name, name); + result = TRUE; + } + } + return result; +} + +static int +lookup_b64(int *target, const char **source) +{ + int result = 3; + int j; + /* + * ncurses' quickdump writes only RFC 4648 "url/filename-safe" encoding, + * but accepts RFC-3548 + */ + for (j = 0; j < 4; ++j) { + int ch = UChar(**source); + *source += 1; + if (ch >= 'A' && ch <= 'Z') { + target[j] = (ch - 'A'); + } else if (ch >= 'a' && ch <= 'z') { + target[j] = 26 + (ch - 'a'); + } else if (ch >= '0' && ch <= '9') { + target[j] = 52 + (ch - '0'); + } else if (ch == '-' || ch == '+') { + target[j] = 62; + } else if (ch == '_' || ch == '/') { + target[j] = 63; + } else if (ch == '=') { + target[j] = 64; + result--; + } else { + result = -1; + break; + } + } + return result; +} + +static int +decode_hex(const char **source) +{ + int result = 0; + int nibble; + + for (nibble = 0; nibble < 2; ++nibble) { + int ch = UChar(**source); + result <<= 4; + *source += 1; + if (ch >= '0' && ch <= '9') { + ch -= '0'; + } else if (ch >= 'A' && ch <= 'F') { + ch -= 'A'; + ch += 10; + } else if (ch >= 'a' && ch <= 'f') { + ch -= 'a'; + ch += 10; + } else { + result = -1; + break; + } + result |= ch; + } + return result; +} + +static int +decode_quickdump(char *target, const char *source) +{ + const char *base = target; + int result = 0; + + if (!strncmp(source, "b64:", (size_t) 4)) { + source += 4; + while (*source != '\0') { + int bits[4]; + int ch = lookup_b64(bits, &source); + if (ch < 0 || (ch + target - base) >= MAX_ENTRY_SIZE) { + result = 0; + break; + } + result += ch; + *target++ = (char) ((bits[0] << 2) | (bits[1] >> 4)); + if (bits[2] < 64) { + *target++ = (char) ((bits[1] << 4) | (bits[2] >> 2)); + if (bits[3] < 64) { + *target++ = (char) ((bits[2] << 6) | bits[3]); + } + } + } + } else if (!strncmp(source, "hex:", (size_t) 4)) { + source += 4; + while (*source != '\0') { + int ch = decode_hex(&source); + if (ch < 0 || (target - base) >= MAX_ENTRY_SIZE) { + result = 0; + break; + } + *target++ = (char) ch; + ++result; + } + } + return result; +} + +/* + * 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 *filename, + unsigned limit, + const char *const path, + const char *name, + TERMTYPE2 *const tp) +{ + int code = TGETENT_NO; +#if USE_HASHED_DB + DB *capdbp; +#endif + char buffer[MAX_ENTRY_SIZE + 1]; + int used; + + TR(TRACE_DATABASE, + (T_CALLED("_nc_read_tic_entry(file=%p, path=%s, name=%s)"), + filename, path, name)); + + assert(TGETENT_YES == TRUE); /* simplify call for _nc_name_match */ + + if ((used = decode_quickdump(buffer, path)) != 0 + && (code = _nc_read_termtype(tp, buffer, used)) == TGETENT_YES + && (code = _nc_name_match(tp->term_names, name, "|")) == TGETENT_YES) { + TR(TRACE_DATABASE, ("loaded quick-dump for %s", name)); + /* shorten name shown by infocmp */ + _nc_STRCPY(filename, "$TERMINFO", limit); + } else +#if USE_HASHED_DB + if (make_db_filename(filename, limit, path) + && (capdbp = _nc_db_open(filename, FALSE)) != NULL) { + + DBT key, data; + int reccnt = 0; + char *save = strdup(name); + + if (save == NULL) + returnDB(code); + + 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) { + char *have = (char *) data.data; + used = (int) data.size - 1; + + if (*have++ == 0) { + if (data.size > key.size + && IS_TIC_MAGIC(have)) { + code = _nc_read_termtype(tp, have, used); + if (code == TGETENT_NO) { + _nc_free_termtype2(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; + } + + free(save); + } else /* may be either filesystem or flat file */ +#endif + if (make_dir_filename(filename, limit, path, name)) { + code = _nc_read_file_entry(filename, tp); + } +#if NCURSES_USE_TERMCAP + if (code != TGETENT_YES) { + code = _nc_read_termcap_entry(name, tp); + _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX) + "%.*s", PATH_MAX - 1, _nc_get_source()); + } +#endif + returnDB(code); +} +#endif /* NCURSES_USE_DATABASE */ + +/* + * Find and read the compiled entry for a given terminal type, if it exists. + * We take pains here to make sure no combination of environment variables and + * terminal type name can be used to overrun the file buffer. + */ +NCURSES_EXPORT(int) +_nc_read_entry2(const char *const name, char *const filename, TERMTYPE2 *const tp) +{ + int code = TGETENT_NO; + + if (name == NULL) + return _nc_read_entry2("", filename, tp); + + _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX) + "%.*s", PATH_MAX - 1, name); + + if (strlen(name) == 0 + || strcmp(name, ".") == 0 + || strcmp(name, "..") == 0 + || _nc_pathlast(name) != 0 + || strchr(name, NCURSES_PATHSEP) != NULL) { + TR(TRACE_DATABASE, ("illegal or missing entry name '%s'", name)); + } else { +#if NCURSES_USE_DATABASE + DBDIRS state; + int offset; + const char *path; + + _nc_first_db(&state, &offset); + code = TGETENT_ERR; + while ((path = _nc_next_db(&state, &offset)) != NULL) { + code = _nc_read_tic_entry(filename, PATH_MAX, path, name, tp); + if (code == TGETENT_YES) { + _nc_last_db(); + break; + } + } +#elif NCURSES_USE_TERMCAP + if (code != TGETENT_YES) { + code = _nc_read_termcap_entry(name, tp); + _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX) + "%.*s", PATH_MAX - 1, _nc_get_source()); + } +#endif + } + return code; +} + +#if NCURSES_EXT_NUMBERS +NCURSES_EXPORT(int) +_nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp) +{ + TERMTYPE2 dummy; + int rc; + rc = _nc_read_entry2(name, filename, &dummy); + if (rc == TGETENT_YES) + _nc_export_termtype2(tp, &dummy); + return rc; +} +#endif diff --git a/ncurses/ncurses/tinfo/read_termcap.c b/ncurses/ncurses/tinfo/read_termcap.c new file mode 100644 index 0000000000..f0e9a7efc3 --- /dev/null +++ b/ncurses/ncurses/tinfo/read_termcap.c @@ -0,0 +1,1205 @@ +/**************************************************************************** + * Copyright 2018-2023,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * Termcap compatibility support + * + * If your OS integrator didn't install a terminfo database, you can call + * _nc_read_termcap_entry() to support reading and translating capabilities + * from the system termcap file. This is a kludge; it will bulk up and slow + * down every program that uses ncurses, and translated termcap entries cannot + * use full terminfo capabilities. Don't use it unless you absolutely have to; + * instead, get your system people to run tic(1) from root on the terminfo + * master included with ncurses to translate it into a terminfo database. + * + * If USE_GETCAP is enabled, we use what is effectively a copy of the 4.4BSD + * getcap code to fetch entries. There are disadvantages to this; mainly that + * getcap(3) does its own resolution, meaning that entries read in in this way + * can't reference the terminfo tree. The only thing it buys is faster startup + * time, getcap(3) is much faster than our tic parser. + */ + +#include + +#include +#include +#include + +MODULE_ID("$Id: read_termcap.c,v 1.107 2025/12/25 18:20:22 tom Exp $") + +#if !PURE_TERMINFO + +#define TC_SUCCESS 0 +#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 const char * +get_termpath(void) +{ + const char *result; + + if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == NULL) + result = TERMPATH; + TR(TRACE_DATABASE, ("TERMPATH is %s", result)); + return result; +} + +/* + * Note: + * getcap(), cgetent(), etc., are BSD functions. A copy of those was added to + * this file in November 1995, derived from the BSD4.4 Lite sources. + * + * The initial adaptation uses 518 lines from that source. + * The current source (in 2009) uses 183 lines of BSD4.4 Lite (441 ignoring + * whitespace). + */ +#if USE_GETCAP + +#if HAVE_BSD_CGETENT +#define _nc_cgetcap cgetcap +#define _nc_cgetent(buf, oline, db_array, name) cgetent(buf, db_array, name) +#define _nc_cgetmatch cgetmatch +#define _nc_cgetset cgetset +#else +static int _nc_cgetmatch(char *, const char *); +static int _nc_getent(char **, unsigned *, int *, int, char **, int, const char + *, int, char *); +static int _nc_nfcmp(const char *, char *); + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Casey Leedom of Lawrence Livermore National Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; */ + +#define BFRAG 1024 +#define BSIZE 1024 +#define MAX_RECURSION 32 /* maximum getent recursion */ + +static size_t topreclen; /* toprec length */ +static char *toprec; /* Additional record specified by cgetset() */ +static int gottoprec; /* Flag indicating retrieval of toprecord */ + +/* + * Cgetset() allows the addition of a user specified buffer to be added to the + * database array, in effect "pushing" the buffer on top of the virtual + * database. 0 is returned on success, -1 on failure. + */ +static int +_nc_cgetset(const char *ent) +{ + if (ent == 0) { + FreeIfNeeded(toprec); + toprec = 0; + topreclen = 0; + return (0); + } + topreclen = strlen(ent); + if ((toprec = typeMalloc(char, topreclen + 1)) == 0) { + errno = ENOMEM; + return (-1); + } + gottoprec = 0; + _nc_STRCPY(toprec, ent, topreclen); + return (0); +} + +/* + * Cgetcap searches the capability record buf for the capability cap with type + * `type'. A pointer to the value of cap is returned on success, 0 if the + * requested capability couldn't be found. + * + * Specifying a type of ':' means that nothing should follow cap (:cap:). In + * this case a pointer to the terminating ':' or NUL will be returned if cap is + * found. + * + * If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator) + * return 0. + */ +static char * +_nc_cgetcap(char *buf, const char *cap, int type) +{ + register const char *cp; + register char *bp; + + bp = buf; + for (;;) { + /* + * Skip past the current capability field - it is either the + * name field if this is the first time through the loop, or + * the remainder of a field whose name failed to match cap. + */ + for (;;) { + if (*bp == '\0') + return (0); + else if (*bp++ == ':') + break; + } + + /* + * Try to match (cap, type) in buf. + */ + for (cp = cap; *cp == *bp && *bp != '\0'; cp++, bp++) + continue; + if (*cp != '\0') + continue; + if (*bp == '@') + return (0); + if (type == ':') { + if (*bp != '\0' && *bp != ':') + continue; + return (bp); + } + if (*bp != type) + continue; + bp++; + return (*bp == '@' ? 0 : bp); + } + /* NOTREACHED */ +} + +/* + * Cgetent extracts the capability record name from the NULL terminated file + * array db_array and returns a pointer to a malloc'd copy of it in buf. Buf + * must be retained through all subsequent calls to cgetcap, cgetnum, cgetflag, + * and cgetstr, but may then be freed. + * + * Returns: + * + * positive # on success (i.e., the index in db_array) + * 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) +{ + unsigned dummy; + + return (_nc_getent(buf, &dummy, oline, 0, db_array, -1, name, 0, 0)); +} + +/* + * Getent implements the functions of cgetent. If fd is non-negative, + * *db_array has already been opened and fd is the open file descriptor. We + * do this to save time and avoid using up file descriptors for tc= + * recursions. + * + * Getent returns the same success/failure codes as cgetent. On success, a + * pointer to a malloc'd capability record with all tc= capabilities fully + * expanded and its length (not including trailing ASCII NUL) are left in + * *cap and *len. + * + * Basic algorithm: + * + Allocate memory incrementally as needed in chunks of size BFRAG + * for capability buffer. + * + Recurse for each tc=name and interpolate result. Stop when all + * names interpolated, a name can't be found, or depth exceeds + * MAX_RECURSION. + */ +#define DOALLOC(size) typeRealloc(char, size, record) +static int +_nc_getent( + char **cap, /* termcap-content */ + unsigned *len, /* length, needed for recursion */ + int *beginning, /* line-number at match */ + int in_array, /* index in 'db_array[] */ + char **db_array, /* list of files to search */ + int fd, + const char *name, + int depth, + char *nfield) +{ + register char *r_end, *rp; + int myfd = FALSE; + char *record = NULL; + int tc_not_resolved; + int current; + int lineno; + + /* + * Return with ``loop detected'' error if we've recurred more than + * MAX_RECURSION times. + */ + if (depth > MAX_RECURSION) + return (TC_REF_LOOP); + + /* + * Check if we have a top record from cgetset(). + */ + if (depth == 0 && toprec != 0 && _nc_cgetmatch(toprec, name) == 0) { + if ((record = DOALLOC(topreclen + BFRAG)) == NULL) { + errno = ENOMEM; + return (TC_SYS_ERR); + } + _nc_STRCPY(record, toprec, topreclen + BFRAG); + rp = record + topreclen + 1; + r_end = rp + BFRAG; + current = in_array; + } else { + int foundit; + + /* + * Allocate first chunk of memory. + */ + if ((record = DOALLOC(BFRAG)) == NULL) { + errno = ENOMEM; + return (TC_SYS_ERR); + } + rp = r_end = record + BFRAG; + foundit = FALSE; + + /* + * Loop through database array until finding the record. + */ + for (current = in_array; db_array[current] != NULL; current++) { + int eof = FALSE; + + /* + * Open database if not already open. + */ + if (fd >= 0) { + (void) lseek(fd, (off_t) 0, SEEK_SET); + } else if ((_nc_access(db_array[current], R_OK) < 0) + || (fd = safe_open2(db_array[current], O_RDONLY)) < 0) { + /* No error on unfound file. */ + if (errno == ENOENT) + continue; + free(record); + return (TC_SYS_ERR); + } else { + myfd = TRUE; + } + lineno = 0; + + /* + * Find the requested capability record ... + */ + { + char buf[2048]; + register char *b_end = buf; + register char *bp = buf; + register int c; + + /* + * Loop invariants: + * There is always room for one more character in record. + * R_end always points just past end of record. + * Rp always points just past last character in record. + * B_end always points just past last character in buf. + * Bp always points at next character in buf. + */ + + for (;;) { + int first = lineno + 1; + + /* + * Read in a line implementing (\, newline) + * line continuation. + */ + rp = record; + for (;;) { + if (bp >= b_end) { + int n; + + n = (int) read(fd, buf, sizeof(buf)); + if (n <= 0) { + if (myfd) + (void) close(fd); + if (n < 0) { + free(record); + return (TC_SYS_ERR); + } + fd = -1; + eof = TRUE; + break; + } + b_end = buf + n; + bp = buf; + } + + c = *bp++; + if (c == '\n') { + lineno++; + /* + * Unlike BSD 4.3, this ignores a backslash at the + * end of a comment-line. That makes it consistent + * with the rest of ncurses -TD + */ + if (rp == record + || *record == '#' + || *(rp - 1) != '\\') + break; + } + *rp++ = (char) c; + + /* + * Enforce loop invariant: if no room + * left in record buffer, try to get + * some more. + */ + if (rp >= r_end) { + unsigned pos; + size_t newsize; + + pos = (unsigned) (rp - record); + newsize = (size_t) (r_end - record + BFRAG); + record = DOALLOC(newsize); + if (record == NULL) { + if (myfd) + (void) close(fd); + errno = ENOMEM; + return (TC_SYS_ERR); + } + r_end = record + newsize; + rp = record + pos; + } + } + /* loop invariant lets us do this */ + *rp++ = '\0'; + + /* + * If encountered eof check next file. + */ + if (eof) + break; + + /* + * Toss blank lines and comments. + */ + if (*record == '\0' || *record == '#') + continue; + + /* + * See if this is the record we want ... + */ + if (_nc_cgetmatch(record, name) == 0 + && (nfield == 0 + || !_nc_nfcmp(nfield, record))) { + foundit = TRUE; + *beginning = first; + break; /* found it! */ + } + } + } + if (foundit) + break; + } + + if (!foundit) { + free(record); + return (TC_NOT_FOUND); + } + } + + /* + * Got the capability record, but now we have to expand all tc=name + * references in it ... + */ + { + register char *newicap, *s; + register int newilen; + unsigned ilen; + int diff, iret, tclen, oline; + char *icap = NULL, *scan, *tc, *tcstart, *tcend; + + /* + * Loop invariants: + * There is room for one more character in record. + * R_end points just past end of record. + * Rp points just past last character in record. + * Scan points at remainder of record that needs to be + * scanned for tc=name constructs. + */ + scan = record; + tc_not_resolved = FALSE; + for (;;) { + if ((tc = _nc_cgetcap(scan, "tc", '=')) == NULL) { + break; + } + + /* + * Find end of tc=name and stomp on the trailing `:' + * (if present) so we can use it to call ourselves. + */ + s = tc; + while (*s != '\0') { + if (*s++ == ':') { + *(s - 1) = '\0'; + break; + } + } + tcstart = tc - 3; + tclen = (int) (s - tcstart); + tcend = s; + + icap = 0; + iret = _nc_getent(&icap, &ilen, &oline, current, db_array, fd, + tc, depth + 1, 0); + newicap = icap; /* Put into a register. */ + newilen = (int) ilen; + if (iret != TC_SUCCESS) { + /* an error */ + if (iret < TC_NOT_FOUND) { + if (myfd) + (void) close(fd); + free(record); + FreeIfNeeded(icap); + return (iret); + } + if (iret == TC_UNRESOLVED) { + tc_not_resolved = TRUE; + /* couldn't resolve tc */ + } else if (iret == TC_NOT_FOUND) { + *(s - 1) = ':'; + scan = s - 1; + tc_not_resolved = TRUE; + continue; + } + } + + /* not interested in name field of tc'ed record */ + s = newicap; + while (*s != '\0' && *s++ != ':') ; + newilen -= (int) (s - newicap); + newicap = s; + + /* make sure interpolated record is `:'-terminated */ + s += newilen; + if (*(s - 1) != ':') { + *s = ':'; /* overwrite NUL with : */ + newilen++; + } + + /* + * Make sure there's enough room to insert the + * new record. + */ + diff = newilen - tclen; + if (diff >= r_end - rp) { + unsigned pos, tcpos, tcposend; + size_t newsize; + + pos = (unsigned) (rp - record); + newsize = (size_t) (r_end - record + diff + BFRAG); + tcpos = (unsigned) (tcstart - record); + tcposend = (unsigned) (tcend - record); + record = DOALLOC(newsize); + if (record == NULL) { + if (myfd) + (void) close(fd); + free(icap); + errno = ENOMEM; + return (TC_SYS_ERR); + } + r_end = record + newsize; + rp = record + pos; + tcstart = record + tcpos; + tcend = record + tcposend; + } + + /* + * Insert tc'ed record into our record. + */ + s = tcstart + newilen; + memmove(s, tcend, (size_t) (rp - tcend)); + memmove(tcstart, newicap, (size_t) newilen); + rp += diff; + free(icap); + + /* + * Start scan on `:' so next cgetcap works properly + * (cgetcap always skips first field). + */ + scan = s - 1; + } + } + + /* + * Close file (if we opened it), give back any extra memory, and + * return capability, length and success. + */ + if (myfd) + (void) close(fd); + *len = (unsigned) (rp - record - 1); /* don't count NUL */ + if (r_end > rp) { + if ((record = DOALLOC((size_t) (rp - record))) == NULL) { + errno = ENOMEM; + return (TC_SYS_ERR); + } + } + + *cap = record; + if (tc_not_resolved) { + return (TC_UNRESOLVED); + } + return (current); +} + +/* + * Cgetmatch will return 0 if name is one of the names of the capability + * record buf, -1 if not. + */ +static int +_nc_cgetmatch(char *buf, const char *name) +{ + register const char *np; + register char *bp; + + /* + * Start search at beginning of record. + */ + bp = buf; + for (;;) { + /* + * Try to match a record name. + */ + np = name; + for (;;) { + if (*np == '\0') { + if (*bp == '|' || *bp == ':' || *bp == '\0') + return (0); + else + break; + } else if (*bp++ != *np++) { + break; + } + } + + /* + * Match failed, skip to next name in record. + */ + bp--; /* a '|' or ':' may have stopped the match */ + for (;;) { + if (*bp == '\0' || *bp == ':') + return (-1); /* match failed totally */ + else if (*bp++ == '|') + break; /* found next name */ + } + } +} + +/* + * Compare name field of record. + */ +static int +_nc_nfcmp(const char *nf, char *rec) +{ + char *cp, tmp; + int ret; + + for (cp = rec; *cp != ':'; cp++) ; + + tmp = *(cp + 1); + *(cp + 1) = '\0'; + ret = strcmp(nf, rec); + *(cp + 1) = tmp; + + return (ret); +} +#endif /* HAVE_BSD_CGETENT */ + +/* + * Since ncurses provides its own 'tgetent()', we cannot use the native one. + * So we reproduce the logic to get down to cgetent() -- or our cut-down + * version of that -- to circumvent the problem of configuring against the + * termcap library. + */ +#define USE_BSD_TGETENT 1 + +#if USE_BSD_TGETENT +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93" */ + +#define PBUFSIZ 512 /* max length of filename path */ +#define PVECSIZ 32 /* max number of names in path */ +#define TBUFSIZ (2048*2) + +/* + * On entry, srcp points to a non ':' character which is the beginning of the + * token, if any. We'll try to return a string that doesn't end with a ':'. + */ +static char * +get_tc_token(char **srcp, int *endp) +{ + int ch; + bool found = FALSE; + char *s, *base; + char *tok = NULL; + + *endp = TRUE; + for (s = base = *srcp; *s != '\0';) { + ch = *s++; + if (ch == '\\') { + if (*s == '\0') { + break; + } else if (*s++ == '\n') { + while (isspace(UChar(*s))) + s++; + } else { + found = TRUE; + } + } else if (ch == ':') { + if (found) { + tok = base; + s[-1] = '\0'; + *srcp = s; + *endp = FALSE; + break; + } + base = s; + } else if (isgraph(UChar(ch))) { + found = TRUE; + } + } + + /* malformed entry may end without a ':' */ + if (tok == NULL && found) { + tok = base; + } + + return tok; +} + +static char * +copy_tc_token(char *dst, const char *src, size_t len) +{ + int ch; + + while ((ch = *src++) != '\0') { + if (ch == '\\' && *src == '\n') { + while (isspace(UChar(*src))) + src++; + continue; + } + if (--len == 0) { + dst = NULL; + break; + } + *dst++ = (char) ch; + } + return dst; +} + +/* + * Get an entry for terminal name in buffer bp from the termcap file. + */ +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; + CGETENT_CONST char **fname; + char *home; + int i; + char pathbuf[PBUFSIZ]; /* holds raw path of filenames */ + CGETENT_CONST char *pathvec[PVECSIZ]; /* point to names in pathbuf */ + const char *termpath; + string_desc desc; + + *lineno = 1; + fname = pathvec; + p = pathbuf; + cp = use_terminfo_vars()? getenv("TERMCAP") : NULL; + + /* + * TERMCAP can have one of two things in it. It can be the name of a file + * to use instead of /etc/termcap. In this case it better start with a + * "/". Or it can be an entry to use so we don't have to read the file. + * In this case it has to already have the newlines crunched out. If + * TERMCAP does not hold a file name then a path of names is searched + * instead. The path is found in the TERMPATH variable, or becomes + * "$HOME/.termcap /etc/termcap" if no TERMPATH exists. + */ + _nc_str_init(&desc, pathbuf, sizeof(pathbuf)); + if (cp == NULL) { + _nc_safe_strcpy(&desc, get_termpath()); + } else if (!_nc_is_abs_path(cp)) { /* TERMCAP holds an entry */ + if ((termpath = get_termpath()) != NULL) { + _nc_safe_strcat(&desc, termpath); + } else { + char temp[PBUFSIZ]; + temp[0] = 0; + if ((home = getenv("HOME")) != NULL && *home != '\0' + && strchr(home, ' ') == NULL + && strlen(home) < sizeof(temp) - 10) { /* setup path */ + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "%s/", home); /* $HOME first */ + } + /* if no $HOME look in current directory */ + _nc_STRCAT(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 */ + } + + *fname++ = pathbuf; /* tokenize path into vector of names */ + while (*++p) { + if (*p == ' ' || *p == NCURSES_PATHSEP) { + *p = '\0'; + while (*++p) + if (*p != ' ' && *p != NCURSES_PATHSEP) + break; + if (*p == '\0') + break; + *fname++ = p; + if (fname >= pathvec + PVECSIZ) { + fname--; + break; + } + } + } + *fname = NULL; /* mark end of vector */ +#if !HAVE_BSD_CGETENT + (void) _nc_cgetset(0); +#endif + if (_nc_is_abs_path(cp)) { + if (_nc_cgetset(cp) < 0) { + return (TC_SYS_ERR); + } + } + + i = _nc_cgetent(&dummy, lineno, pathvec, name); + + /* ncurses' termcap-parsing routines cannot handle multiple adjacent + * empty fields, and mistakenly use the last valid cap entry instead of + * the first (breaks tc= includes) + */ + *bp = '\0'; + if (i >= 0) { + char *pd, *ps, *tok; + int endflag = FALSE; + char *list[1023]; + size_t n, count = 0; + + pd = bp; + ps = dummy; + while (!endflag && (tok = get_tc_token(&ps, &endflag)) != NULL) { + bool ignore = FALSE; + + for (n = 1; n < count; n++) { + char *s = list[n]; + if (s[0] == tok[0] + && s[1] == tok[1]) { + ignore = TRUE; + break; + } + } + if (ignore != TRUE) { + list[count++] = tok; + pd = copy_tc_token(pd, tok, (size_t) (TBUFSIZ - (2 + pd - bp))); + if (pd == NULL) { + i = -1; + break; + } + *pd++ = ':'; + *pd = '\0'; + } + } + } + + FreeIfNeeded(dummy); + FreeIfNeeded(the_source); + the_source = NULL; + + /* This is not related to the BSD cgetent(), but to fake up a suitable + * filename for ncurses' error reporting. (If we are not using BSD + * 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)) != NULL) + *sourcename = the_source; +#else + if ((the_source = strdup(pathvec[i])) != NULL) + *sourcename = the_source; +#endif + } + + return (i); +} +#endif /* USE_BSD_TGETENT */ +#endif /* USE_GETCAP */ + +#define MAXPATHS 32 + +/* + * Add a filename to the list in 'termpaths[]', checking that we really have + * a right to open the file. + */ +#if !USE_GETCAP +static int +add_tc(char *termpaths[], char *path, int count) +{ + char *save = strchr(path, NCURSES_PATHSEP); + if (save != NULL) + *save = '\0'; + if (count < MAXPATHS + && _nc_access(path, R_OK) == 0) { + termpaths[count++] = path; + TR(TRACE_DATABASE, ("Adding termpath %s", path)); + } + termpaths[count] = 0; + if (save != NULL) + *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, TERMTYPE2 *const tp) +{ + int found = TGETENT_NO; + ENTRY *ep; +#if USE_GETCAP_CACHE + char cwd_buf[PATH_MAX]; +#endif +#if USE_GETCAP + char *p, tc[TBUFSIZ]; + char *tc_buf = NULL; +#define MY_SIZE sizeof(tc) - 1 + int status; + static char *source; + static int lineno; + + TR(TRACE_DATABASE, ("read termcap entry for %s", tn)); + + if (strlen(tn) == 0 + || strcmp(tn, ".") == 0 + || strcmp(tn, "..") == 0 + || _nc_pathlast(tn) != 0) { + TR(TRACE_DATABASE, ("illegal or missing entry name '%s'", tn)); + return TGETENT_NO; + } + + if (use_terminfo_vars() && (p = getenv("TERMCAP")) != NULL + && !_nc_is_abs_path(p) && _nc_name_match(p, tn, "|:")) { + /* TERMCAP holds a termcap entry */ + tc_buf = strdup(p); + _nc_set_source("TERMCAP"); + } else { + /* we're using getcap(3) */ + if ((status = _nc_tgetent(tc, &source, &lineno, tn)) < 0) + return (status == TC_NOT_FOUND ? TGETENT_NO : TGETENT_ERR); + + _nc_curr_line = lineno; + _nc_set_source(source); + tc_buf = tc; + } + if (tc_buf == NULL) + return (TGETENT_ERR); + _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, TRUE, NULLHOOK); + if (tc_buf != tc) + free(tc_buf); +#else + /* + * Here is what the 4.4BSD termcap(3) page prescribes: + * + * It will look in the environment for a TERMCAP variable. If found, and + * the value does not begin with a slash, and the terminal type name is the + * same as the environment string TERM, the TERMCAP string is used instead + * of reading a termcap file. If it does begin with a slash, the string is + * used as a path name of the termcap file to search. If TERMCAP does not + * begin with a slash and name is different from TERM, tgetent() searches + * the files $HOME/.termcap and /usr/share/misc/termcap, in that order, + * unless the environment variable TERMPATH exists, in which case it + * specifies a list of file pathnames (separated by spaces or colons) to be + * searched instead. + * + * It goes on to state: + * + * Whenever multiple files are searched and a tc field occurs in the + * requested entry, the entry it names must be found in the same file or + * one of the succeeding files. + * + * However, this restriction is relaxed in ncurses; tc references to + * previous files are permitted. + * + * This routine returns 1 if an entry is found, 0 if not found, and -1 if + * the database is not accessible. + */ + FILE *fp; + char *tc, *termpaths[MAXPATHS]; + int filecount = 0; + int j, k; + bool use_buffer = FALSE; + bool normal = TRUE; + char *tc_buf = NULL; + char pathbuf[PATH_MAX]; + char *copied = NULL; + char *cp; + struct stat test_stat[MAXPATHS]; + + termpaths[filecount] = NULL; + if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != NULL) { + 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 */ + tc_buf = strdup(tc); + use_buffer = (tc_buf != NULL); + normal = FALSE; + } + } + + if (normal) { /* normal case */ + char envhome[PATH_MAX], *h; + + if ((copied = strdup(get_termpath())) != NULL) { + 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 */ + _nc_STRCPY(envhome, h, sizeof(envhome)); + _nc_SPRINTF(pathbuf, _nc_SLIMIT(sizeof(pathbuf)) + PRIVATE_CAP, + (int) (sizeof(pathbuf) - sizeof(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 (!_nc_is_path_found(termpaths[j], &test_stat[j]) + || !S_ISREG(test_stat[j].st_mode)) { + 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) { + TR(TRACE_DATABASE, ("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"); + + /* + * We don't suppress warning messages here. The presumption is + * that since it is just a single entry, they won't be a pain. + */ + _nc_read_entry_source((FILE *) 0, tc_buf, FALSE, FALSE, NULLHOOK); + free(tc_buf); + } else { + int i; + + for (i = 0; i < filecount; i++) { + + TR(TRACE_DATABASE, ("Looking for %s in %s", tn, termpaths[i])); + if (_nc_access(termpaths[i], R_OK) == 0 + && (fp = safe_fopen(termpaths[i], "r")) != (FILE *) 0) { + _nc_set_source(termpaths[i]); + + /* + * Suppress warning messages. Otherwise you get 400 lines of + * crap from archaic termcap files as ncurses complains about + * all the obsolete capabilities. + */ + _nc_read_entry_source(fp, (char *) 0, FALSE, TRUE, NULLHOOK); + + (void) fclose(fp); + } + } + } + if (copied != NULL) + free(copied); +#endif /* USE_GETCAP */ + + if (_nc_head == NULL) + return (TGETENT_ERR); + + /* resolve all use references */ + if (_nc_resolve_uses2(TRUE, FALSE) != TRUE) + return (TGETENT_ERR); + + /* find a terminal matching tn, if we can */ +#if USE_GETCAP_CACHE + if (getcwd(cwd_buf, sizeof(cwd_buf)) != NULL) { + _nc_set_writedir((char *) 0); /* note: this does a chdir */ +#endif + for_entry_list(ep) { + if (_nc_name_match(ep->tterm.term_names, tn, "|:")) { + /* + * Make a local copy of the terminal capabilities, delinked + * from the list. + */ + *tp = ep->tterm; + _nc_free_entry(_nc_head, &(ep->tterm)); + + /* + * OK, now try to write the type to user's terminfo directory. + * Next time he loads this, it will come through terminfo. + * + * Advantage: Second and subsequent fetches of this entry will + * be very fast. + * + * Disadvantage: After the first time a termcap type is loaded + * by its user, editing it in the /etc/termcap file, or in + * TERMCAP, or in a local ~/.termcap, will be ineffective + * unless the terminfo entry is explicitly removed. + */ +#if USE_GETCAP_CACHE + (void) _nc_write_entry(tp); +#endif + found = TGETENT_YES; + break; + } + } +#if USE_GETCAP_CACHE + chdir(cwd_buf); + } +#endif + + return (found); +} +#else +extern +NCURSES_EXPORT(void) +_nc_read_termcap(void); +NCURSES_EXPORT(void) +_nc_read_termcap(void) +{ +} +#endif /* PURE_TERMINFO */ diff --git a/ncurses/ncurses/tinfo/strings.c b/ncurses/ncurses/tinfo/strings.c new file mode 100644 index 0000000000..ef0972b81a --- /dev/null +++ b/ncurses/ncurses/tinfo/strings.c @@ -0,0 +1,147 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 2000-2012,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* +** lib_mvcur.c +**/ + +#include +#include + +MODULE_ID("$Id: strings.c,v 1.12 2024/12/07 21:24:18 tom Exp $") + +/**************************************************************************** + * Useful string functions (especially for mvcur) + ****************************************************************************/ + +#if !HAVE_STRSTR +NCURSES_EXPORT(char *) +_nc_strstr(const char *haystack, const char *needle) +{ + size_t len1 = strlen(haystack); + size_t len2 = strlen(needle); + char *result = 0; + + while ((len1 != 0) && (len1-- >= len2)) { + if (!strncmp(haystack, needle, len2)) { + result = (char *) haystack; + break; + } + haystack++; + } + return result; +} +#endif + +/* + * 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) +{ + if (dst != NULL) { + dst->s_head = src; + dst->s_tail = src; + dst->s_size = len - 1; + dst->s_init = dst->s_size; + if (src != NULL) + *src = 0; + } + return dst; +} + +/* + * Initialize the descriptor for only tracking the amount of memory used. + */ +NCURSES_EXPORT(string_desc *) +_nc_str_null(string_desc * dst, size_t len) +{ + return _nc_str_init(dst, NULL, len); +} + +/* + * Copy a descriptor + */ +NCURSES_EXPORT(string_desc *) +_nc_str_copy(string_desc * dst, const string_desc * const src) +{ + *dst = *src; + return dst; +} + +/* + * Replaces strcat into a fixed buffer, returning false on failure. + */ +NCURSES_EXPORT(bool) +_nc_safe_strcat(string_desc * dst, const char *src) +{ + if (PRESENT(src)) { + size_t len = strlen(src); + + if (len < dst->s_size) { + if (dst->s_tail != NULL) { + _nc_STRCPY(dst->s_tail, src, dst->s_size); + dst->s_tail += len; + } + dst->s_size -= len; + return TRUE; + } + } + return FALSE; +} + +/* + * Replaces strcpy into a fixed buffer, returning false on failure. + */ +NCURSES_EXPORT(bool) +_nc_safe_strcpy(string_desc * dst, const char *src) +{ + if (PRESENT(src)) { + size_t len = strlen(src); + + if (len < dst->s_size) { + if (dst->s_head != NULL) { + _nc_STRCPY(dst->s_head, src, dst->s_size); + dst->s_tail = dst->s_head + len; + } + dst->s_size = dst->s_init - len; + return TRUE; + } + } + return FALSE; +} diff --git a/ncurses/ncurses/tinfo/tinfo_driver.c b/ncurses/ncurses/tinfo/tinfo_driver.c new file mode 100644 index 0000000000..554c20fa22 --- /dev/null +++ b/ncurses/ncurses/tinfo/tinfo_driver.c @@ -0,0 +1,1570 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2008-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Thomas E. Dickey * + ****************************************************************************/ + +#include +#define CUR TerminalType((TERMINAL*)TCB). +#include +#include /* ospeed */ + +#if HAVE_NANOSLEEP +#include +#if HAVE_SYS_TIME_H +#include /* needed for MacOS X DP3 */ +#endif +#endif + +#if HAVE_SIZECHANGE +# if !defined(sun) || !TERMIOS +# if HAVE_SYS_IOCTL_H +# include +# endif +# endif +#endif + +MODULE_ID("$Id: tinfo_driver.c,v 1.88 2025/12/27 12:33:34 tom Exp $") + +/* + * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, + * Solaris, IRIX) define TIOCGWINSZ and struct winsize. + */ +#ifdef TIOCGSIZE +# define IOCTL_WINSIZE TIOCGSIZE +# define STRUCT_WINSIZE struct ttysize +# define WINSIZE_ROWS(n) (int)n.ts_lines +# define WINSIZE_COLS(n) (int)n.ts_cols +#else +# ifdef TIOCGWINSZ +# define IOCTL_WINSIZE TIOCGWINSZ +# define STRUCT_WINSIZE struct winsize +# define WINSIZE_ROWS(n) (int)n.ws_row +# define WINSIZE_COLS(n) (int)n.ws_col +# endif +#endif + +/* + * 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. + */ +#if USE_REENTRANT +NCURSES_EXPORT(int) +NCURSES_PUBLIC_VAR(COLOR_PAIRS) (void) +{ + return CURRENT_SCREEN ? CURRENT_SCREEN->_pair_count : -1; +} +NCURSES_EXPORT(int) +NCURSES_PUBLIC_VAR(COLORS) (void) +{ + return CURRENT_SCREEN ? CURRENT_SCREEN->_color_count : -1; +} +#else +NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0; +NCURSES_EXPORT_VAR(int) COLORS = 0; +#endif + +#define TCBMAGIC NCDRV_MAGIC(NCDRV_TINFO) +#define AssertTCB() assert(TCB != NULL && TCB->magic == TCBMAGIC) +#define SetSP() assert(TCB->csp != NULL); sp = TCB->csp; (void) sp + +/* + * This routine needs to do all the work to make curscr look + * like newscr. + */ +static int +drv_doupdate(TERMINAL_CONTROL_BLOCK * TCB) +{ + AssertTCB(); + return TINFO_DOUPDATE(TCB->csp); +} + +static const char * +drv_Name(TERMINAL_CONTROL_BLOCK * TCB) +{ + (void) TCB; + return "tinfo"; +} + +static void +get_baudrate(TERMINAL *termp) +{ + int my_ospeed; + int result; + if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) { +#ifdef TERMIOS + termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS); +#elif defined(USE_WIN32CON_DRIVER) + /* noop */ +#else + termp->Nttyb.sg_flags &= (unsigned) (~XTABS); +#endif + } +#ifdef USE_OLD_TTY + result = (int) cfgetospeed(&(termp->Nttyb)); + my_ospeed = (NCURSES_OSPEED) _nc_ospeed(result); +#else /* !USE_OLD_TTY */ +#ifdef TERMIOS + my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb)); +#elif defined(USE_WIN32CON_DRIVER) + /* noop */ + my_ospeed = 0; +#else + my_ospeed = (NCURSES_OSPEED) termp->Nttyb.sg_ospeed; +#endif + result = _nc_baudrate(my_ospeed); +#endif + termp->_baudrate = result; + ospeed = (NCURSES_OSPEED) my_ospeed; +} + +#undef SETUP_FAIL +#define SETUP_FAIL FALSE + +#define NO_COPY {} + +static bool +drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) +{ + bool result = FALSE; + int status; + TERMINAL *termp; + SCREEN *sp; + + START_TRACE(); + T((T_CALLED("tinfo::drv_CanHandle(%p,%s,%p)"), + (void *) TCB, NonNull(tname), (void *) errret)); + + assert(TCB != NULL && tname != NULL); + termp = (TERMINAL *) TCB; + sp = TCB->csp; + TCB->magic = TCBMAGIC; + +#if (NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP) + status = _nc_setup_tinfo(tname, &TerminalType(termp)); + T(("_nc_setup_tinfo returns %d", status)); +#else + T(("no database available")); + status = TGETENT_NO; +#endif + + /* try fallback list if entry on disk */ + if (status != TGETENT_YES) { + const TERMTYPE2 *fallback = _nc_fallback2(tname); + + if (fallback) { + T(("found fallback entry")); + TerminalType(termp) = *fallback; + status = TGETENT_YES; + } + } + + if (status != TGETENT_YES) { + NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx termp); + if (status == TGETENT_ERR) { + ret_error0(status, "terminals database is inaccessible\n"); + } else if (status == TGETENT_NO) { + ret_error1(status, "unknown terminal type.\n", + tname, NO_COPY); + } else { + ret_error0(status, "unexpected return-code\n"); + } + } + result = TRUE; +#if NCURSES_EXT_NUMBERS + _nc_export_termtype2(&termp->type, &TerminalType(termp)); +#endif +#if !USE_REENTRANT + save_ttytype(termp); +#endif + + if (VALID_STRING(command_character)) + _nc_tinfo_cmdch(termp, UChar(*command_character)); + + /* + * 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 (sp == NULL && NC_ISATTY(termp->Filedes)) { + get_baudrate(termp); + } +#if NCURSES_EXT_NUMBERS +#define cleanup_termtype() \ + _nc_free_termtype2(&TerminalType(termp)); \ + _nc_free_termtype(&termp->type) +#else +#define cleanup_termtype() \ + _nc_free_termtype2(&TerminalType(termp)) +#endif + + if (generic_type) { + /* + * BSD 4.3's termcap contains mis-typed "gn" for wy99. Do a sanity + * check before giving up. + */ + if ((VALID_STRING(cursor_address) + || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home))) + && VALID_STRING(clear_screen)) { + cleanup_termtype(); + ret_error1(TGETENT_YES, "terminal is not really generic.\n", + tname, NO_COPY); + } else { + cleanup_termtype(); + ret_error1(TGETENT_NO, "I need something more specific.\n", + tname, NO_COPY); + } + } + if (hard_copy) { + cleanup_termtype(); + ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", + tname, NO_COPY); + } + + returnBool(result); +} + +static int +drv_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB, int beepFlag) +{ + SCREEN *sp; + int res = ERR; + + AssertTCB(); + SetSP(); + + /* FIXME: should make sure that we are not in altchar mode */ + if (beepFlag) { + if (bell) { + res = NCURSES_PUTP2("bell", bell); + NCURSES_SP_NAME(_nc_flush) (sp); + } else if (flash_screen) { + res = NCURSES_PUTP2("flash_screen", flash_screen); + NCURSES_SP_NAME(_nc_flush) (sp); + } + } else { + if (flash_screen) { + res = NCURSES_PUTP2("flash_screen", flash_screen); + NCURSES_SP_NAME(_nc_flush) (sp); + } else if (bell) { + res = NCURSES_PUTP2("bell", bell); + NCURSES_SP_NAME(_nc_flush) (sp); + } + } + return res; +} + +/* + * SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly + * to maintain compatibility with a pre-ANSI scheme. The same scheme is + * also used in the FreeBSD syscons. + */ +static int +toggled_colors(int c) +{ + if (c < 16) { + static const int table[] = + {0, 4, 2, 6, 1, 5, 3, 7, + 8, 12, 10, 14, 9, 13, 11, 15}; + c = table[c]; + } + return c; +} + +static int +drv_print(TERMINAL_CONTROL_BLOCK * TCB, char *data, int len) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +#if NCURSES_EXT_FUNCS + return NCURSES_SP_NAME(mcprint) (TCB->csp, data, len); +#else + return ERR; +#endif +} + +static int +drv_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB, int fg, int bg) +{ + SCREEN *sp; + int code = ERR; + + AssertTCB(); + SetSP(); + + if (sp != NULL && orig_pair && orig_colors && (initialize_pair != NULL)) { +#if NCURSES_EXT_FUNCS + sp->_default_color = isDefaultColor(fg) || isDefaultColor(bg); + sp->_has_sgr_39_49 = (NCURSES_SP_NAME(tigetflag) (NCURSES_SP_ARGx + UserCap(AX)) + == TRUE); + sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg; + sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg; + if (sp->_color_pairs != NULL) { + bool save = sp->_default_color; + sp->_default_color = TRUE; + NCURSES_SP_NAME(init_pair) (NCURSES_SP_ARGx + 0, + (short)fg, + (short)bg); + sp->_default_color = save; + } +#endif + code = OK; + } + return (code); +} + +static void +drv_setcolor(TERMINAL_CONTROL_BLOCK * TCB, + int fore, + int color, + NCURSES_SP_OUTC outc) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); + + if (fore) { + if (set_a_foreground) { + TPUTS_TRACE("set_a_foreground"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_a_foreground, color), 1, outc); + } else { + TPUTS_TRACE("set_foreground"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_foreground, + toggled_colors(color)), 1, outc); + } + } else { + if (set_a_background) { + TPUTS_TRACE("set_a_background"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_a_background, color), 1, outc); + } else { + TPUTS_TRACE("set_background"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_background, + toggled_colors(color)), 1, outc); + } + } +} + +static bool +drv_rescol(TERMINAL_CONTROL_BLOCK * TCB) +{ + bool result = FALSE; + SCREEN *sp; + + AssertTCB(); + SetSP(); + + if (orig_pair != NULL) { + NCURSES_PUTP2("orig_pair", orig_pair); + result = TRUE; + } + return result; +} + +static bool +drv_rescolors(TERMINAL_CONTROL_BLOCK * TCB) +{ + int result = FALSE; + SCREEN *sp; + + AssertTCB(); + SetSP(); + + if (orig_colors != NULL) { + NCURSES_PUTP2("orig_colors", orig_colors); + result = TRUE; + } + return result; +} + +static int +drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) +{ + SCREEN *sp; + bool useEnv = TRUE; + bool useTioctl = TRUE; + + AssertTCB(); + sp = TCB->csp; /* can be null here */ + + if (sp) { + useEnv = sp->_use_env; + useTioctl = sp->use_tioctl; + } else { + useEnv = _nc_prescreen.use_env; + useTioctl = _nc_prescreen.use_tioctl; + } + +#ifdef USE_WIN32CON_DRIVER + /* If we are here, then Windows console is used in terminfo mode. + We need to figure out the size using the console API + */ + _nc_console_size(linep, colp); + T(("screen size: winconsole lines = %d columns = %d", *linep, *colp)); +#else + /* figure out the size of the screen */ + T(("screen size: terminfo lines = %d columns = %d", lines, columns)); + + *linep = (int) lines; + *colp = (int) columns; +#endif + if (useEnv || useTioctl) { + int value; + +#ifdef __EMX__ + { + int screendata[2]; + _scrsize(screendata); + *colp = screendata[0]; + *linep = ((sp != 0 && sp->_filtered) + ? 1 + : screendata[1]); + T(("EMX screen size: environment LINES = %d COLUMNS = %d", + *linep, *colp)); + } +#endif +#if HAVE_SIZECHANGE + /* try asking the OS */ + { + TERMINAL *termp = (TERMINAL *) TCB; + if (NC_ISATTY(termp->Filedes)) { + STRUCT_WINSIZE size; + + errno = 0; + do { + if (ioctl(termp->Filedes, IOCTL_WINSIZE, &size) >= 0) { + *linep = ((sp != NULL && sp->_filtered) + ? 1 + : WINSIZE_ROWS(size)); + *colp = WINSIZE_COLS(size); + T(("SYS screen size: environment LINES = %d COLUMNS = %d", + *linep, *colp)); + break; + } + } while + (errno == EINTR); + } + } +#endif /* HAVE_SIZECHANGE */ + + if (useEnv) { + if (useTioctl) { + /* + * If environment variables are used, update them. + */ + if ((sp == NULL || !sp->_filtered) + && _nc_getenv_num("LINES") > 0) { + _nc_setenv_num("LINES", *linep); + } + if (_nc_getenv_num("COLUMNS") > 0) { + _nc_setenv_num("COLUMNS", *colp); + } + } + + /* + * Finally, look for environment variables. + * + * Solaris lets users override either dimension with an environment + * variable. + */ + if ((value = _nc_getenv_num("LINES")) > 0) { + *linep = Min(value, MAX_ENV_LINES); + T(("screen size: environment LINES = %d", *linep)); + } + if ((value = _nc_getenv_num("COLUMNS")) > 0) { + *colp = Min(value, MAX_ENV_COLUMNS); + T(("screen size: environment COLUMNS = %d", *colp)); + } + } + + /* if we can't get dynamic info about the size, use static */ + if (*linep <= 0) { + *linep = (int) lines; + } + if (*colp <= 0) { + *colp = (int) columns; + } + + /* the ultimate fallback, assume fixed 24x80 size */ + if (*linep <= 0) { + *linep = 24; + } + if (*colp <= 0) { + *colp = 80; + } + + /* + * Put the derived values back in the screen-size caps, so + * tigetnum() and tgetnum() will do the right thing. + */ + lines = (short) (*linep); + columns = (short) (*colp); + } + + T(("screen size is %dx%d", *linep, *colp)); + return OK; +} + +static int +drv_getsize(TERMINAL_CONTROL_BLOCK * TCB, int *l, int *c) +{ + AssertTCB(); + assert(l != NULL && c != NULL); + *l = lines; + *c = columns; + return OK; +} + +static int +drv_setsize(TERMINAL_CONTROL_BLOCK * TCB, int l, int c) +{ + AssertTCB(); + lines = (short) l; + columns = (short) c; + return OK; +} + +static int +drv_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf) +{ + SCREEN *sp = TCB->csp; + TERMINAL *_term = (TERMINAL *) TCB; + int result = OK; + + AssertTCB(); + if (setFlag) { + for (;;) { + if (SET_TTY(_term->Filedes, buf) != 0) { + if (errno == EINTR) + continue; + if (errno == ENOTTY) { + if (sp) + sp->_notty = TRUE; + } + result = ERR; + } + break; + } + } else { + for (;;) { + if (GET_TTY(_term->Filedes, buf) != 0) { + if (errno == EINTR) + continue; + result = ERR; + } + break; + } + } + return result; +} + +static int +drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag) +{ + SCREEN *sp; + TERMINAL *_term = (TERMINAL *) TCB; + int code = ERR; + + AssertTCB(); + sp = TCB->csp; + + T((T_CALLED("tinfo:drv_mode(%p,%d,%d)"), (void *) sp, progFlag, defFlag)); + + if (progFlag) /* prog mode */ + { + if (defFlag) { + /* def_prog_mode */ + /* + * Turn off the XTABS bit in the tty structure if it was on. + */ + if ((drv_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) { +#ifdef TERMIOS + _term->Nttyb.c_oflag &= (unsigned) ~OFLAGS_TABS; +#elif defined(USE_WIN32CON_DRIVER) + /* noop */ +#else + _term->Nttyb.sg_flags &= (unsigned) ~XTABS; +#endif + code = OK; + } + } else { + /* reset_prog_mode */ + if (drv_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) { + if (sp) { + if (sp->_keypad_on) + _nc_keypad(sp, TRUE); + } +#if defined(USE_WIN32CON_DRIVER) + if (!WINCONSOLE.buffered) + _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI); +#endif + code = OK; + } + } + } else { /* shell mode */ + if (defFlag) { + /* def_shell_mode */ + /* + * If XTABS was on, remove the tab and backtab capabilities. + */ + if (drv_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) { +#ifdef TERMIOS + if (_term->Ottyb.c_oflag & OFLAGS_TABS) + tab = back_tab = NULL; +#elif defined(USE_WIN32CON_DRIVER) + /* noop */ +#else + if (_term->Ottyb.sg_flags & XTABS) + tab = back_tab = NULL; +#endif + code = OK; + } + } else { + /* reset_shell_mode */ + if (sp) { + _nc_keypad(sp, FALSE); + NCURSES_SP_NAME(_nc_flush) (sp); + } + code = drv_sgmode(TCB, TRUE, &(_term->Ottyb)); +#if defined(USE_WIN32CON_DRIVER) + if (!_nc_console_restore()) + code = ERR; +#endif + } + } + returnCode(code); +} + +static void +drv_wrap(SCREEN *sp) +{ + if (sp) { + sp->_mouse_wrap(sp); + NCURSES_SP_NAME(_nc_screen_wrap) (sp); + NCURSES_SP_NAME(_nc_mvcur_wrap) (sp); /* wrap up cursor addressing */ + } +} + +static void +drv_release(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED) +{ +} + +# define SGR0_TEST(mode) (mode != NULL) && (exit_attribute_mode == NULL || strcmp(mode, exit_attribute_mode)) + +static void +drv_screen_init(SCREEN *sp) +{ + TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp); + + AssertTCB(); + + /* + * 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->_use_rmso = SGR0_TEST(exit_standout_mode); + sp->_use_rmul = SGR0_TEST(exit_underline_mode); + + /* + * 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))); + + NCURSES_SP_NAME(baudrate) (sp); + + NCURSES_SP_NAME(_nc_mvcur_init) (sp); + /* initialize terminal to a sane state */ + NCURSES_SP_NAME(_nc_screen_init) (sp); +} + +static void +drv_init(TERMINAL_CONTROL_BLOCK * TCB) +{ + TERMINAL *trm; + + AssertTCB(); + + trm = (TERMINAL *) TCB; + + TCB->info.initcolor = VALID_STRING(initialize_color); + TCB->info.canchange = can_change; + TCB->info.hascolor = ((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs) + && (((set_foreground != NULL) + && (set_background != NULL)) + || ((set_a_foreground != NULL) + && (set_a_background != NULL)) + || set_color_pair)) ? TRUE : FALSE); + + TCB->info.caninit = !(exit_ca_mode && non_rev_rmcup); + + TCB->info.maxpairs = VALID_NUMERIC(max_pairs) ? max_pairs : 0; + TCB->info.maxcolors = VALID_NUMERIC(max_colors) ? max_colors : 0; + TCB->info.numlabels = VALID_NUMERIC(num_labels) ? num_labels : 0; + TCB->info.labelwidth = VALID_NUMERIC(label_width) ? label_width : 0; + TCB->info.labelheight = VALID_NUMERIC(label_height) ? label_height : 0; + TCB->info.nocolorvideo = VALID_NUMERIC(no_color_video) ? no_color_video + : 0; + TCB->info.tabsize = VALID_NUMERIC(init_tabs) ? (int) init_tabs : 8; + + TCB->info.defaultPalette = hue_lightness_saturation ? _nc_hls_palette : _nc_cga_palette; + + /* + * 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 (NC_ISATTY(trm->Filedes)) { + TCB->drv->td_mode(TCB, TRUE, TRUE); + } +} + +#define MAX_PALETTE 8 +#define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE) + +static void +drv_initpair(TERMINAL_CONTROL_BLOCK * TCB, int pair, int f, int b) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); + + if ((initialize_pair != NULL) && InPalette(f) && InPalette(b)) { + const color_t *tp = InfoOf(sp).defaultPalette; + + 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)); + + NCURSES_PUTP2("initialize_pair", + TIPARM_7(initialize_pair, + pair, + tp[f].red, tp[f].green, tp[f].blue, + tp[b].red, tp[b].green, tp[b].blue)); + } +} + +static int +default_fg(SCREEN *sp) +{ +#if NCURSES_EXT_FUNCS + return (sp != NULL) ? sp->_default_fg : COLOR_WHITE; +#else + return COLOR_WHITE; +#endif +} + +static int +default_bg(SCREEN *sp) +{ +#if NCURSES_EXT_FUNCS + return sp != NULL ? sp->_default_bg : COLOR_BLACK; +#else + return COLOR_BLACK; +#endif +} + +static void +drv_initcolor(TERMINAL_CONTROL_BLOCK * TCB, + int color, int r, int g, int b) +{ + SCREEN *sp = TCB->csp; + + AssertTCB(); + if (initialize_color != NULL) { + NCURSES_PUTP2("initialize_color", + TIPARM_4(initialize_color, color, r, g, b)); + } +} + +static void +drv_do_color(TERMINAL_CONTROL_BLOCK * TCB, + int old_pair, + int pair, + int reverse, + NCURSES_SP_OUTC outc) +{ + SCREEN *sp = TCB->csp; + int fg = COLOR_DEFAULT; + int bg = COLOR_DEFAULT; + int old_fg, old_bg; + + AssertTCB(); + if (sp == NULL) + return; + + if (pair < 0 || pair >= COLOR_PAIRS) { + return; + } else if (pair != 0) { + if (set_color_pair) { + TPUTS_TRACE("set_color_pair"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(set_color_pair, pair), 1, outc); + return; + } else if (sp != NULL) { + _nc_pair_content(SP_PARM, pair, &fg, &bg); + } + } + + if (old_pair >= 0 + && sp != NULL + && _nc_pair_content(SP_PARM, 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 + && isDefaultColor(old_bg) + && !isDefaultColor(old_fg)) { + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc); + } else if (sp->_has_sgr_39_49 + && isDefaultColor(old_fg) + && !isDefaultColor(old_bg)) { + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc); + } else +#endif + drv_rescol(TCB); + } + } else { + drv_rescol(TCB); + if (old_pair < 0) + return; + } + +#if NCURSES_EXT_FUNCS + if (isDefaultColor(fg)) + fg = default_fg(sp); + if (isDefaultColor(bg)) + bg = default_bg(sp); +#endif + + if (reverse) { + int xx = fg; + fg = bg; + bg = xx; + } + + TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair, + fg, bg)); + + if (!isDefaultColor(fg)) { + drv_setcolor(TCB, TRUE, fg, outc); + } + if (!isDefaultColor(bg)) { + drv_setcolor(TCB, FALSE, bg, outc); + } +} + +#define xterm_kmous "\033[M" +static void +init_xterm_mouse(SCREEN *sp) +{ + sp->_mouse_type = M_XTERM; + sp->_mouse_xtermcap = NCURSES_SP_NAME(tigetstr) (NCURSES_SP_ARGx UserCap(XM)); + if (!VALID_STRING(sp->_mouse_xtermcap)) + sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;"; +} + +static void +drv_initmouse(TERMINAL_CONTROL_BLOCK * TCB) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); + + /* we know how to recognize mouse events under "xterm" */ + if (sp != NULL) { + if (NonEmpty(key_mouse)) { + init_xterm_mouse(sp); + } else if (strstr(SP_TERMTYPE term_names, "xterm") != NULL) { + if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK) + init_xterm_mouse(sp); + } + } +} + +static int +drv_testmouse(TERMINAL_CONTROL_BLOCK * TCB, + int delay + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + int rc = 0; + SCREEN *sp; + + AssertTCB(); + SetSP(); + +#if USE_SYSMOUSE + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail)) { + rc = TW_MOUSE; + } else +#endif + { +#if defined(USE_WIN32CON_DRIVER) + rc = _nc_console_testmouse(sp, + _nc_console_handle(sp->_ifd), + delay + EVENTLIST_2nd(evl)); +#else + rc = TCBOf(sp)->drv->td_twait(TCBOf(sp), + TWAIT_MASK, + delay, + (int *) 0 + EVENTLIST_2nd(evl)); +#endif +#if USE_SYSMOUSE + if ((sp->_mouse_type == M_SYSMOUSE) + && (sp->_sysmouse_head < sp->_sysmouse_tail) + && (rc == 0) + && (errno == EINTR)) { + rc |= TW_MOUSE; + } +#endif + } + return rc; +} + +static int +drv_mvcur(TERMINAL_CONTROL_BLOCK * TCB, int yold, int xold, int ynew, int xnew) +{ + SCREEN *sp = TCB->csp; + AssertTCB(); + return NCURSES_SP_NAME(_nc_mvcur) (sp, yold, xold, ynew, xnew); +} + +static void +drv_hwlabel(TERMINAL_CONTROL_BLOCK * TCB, int labnum, char *text) +{ + SCREEN *sp = TCB->csp; + + AssertTCB(); + if (labnum > 0 && labnum <= num_labels) { + NCURSES_PUTP2("plab_norm", + TPARM_2(plab_norm, labnum, text)); + } +} + +static void +drv_hwlabelOnOff(TERMINAL_CONTROL_BLOCK * TCB, int OnFlag) +{ + SCREEN *sp = TCB->csp; + + AssertTCB(); + if (OnFlag) { + NCURSES_PUTP2("label_on", label_on); + } else { + NCURSES_PUTP2("label_off", label_off); + } +} + +static chtype +drv_conattr(TERMINAL_CONTROL_BLOCK * TCB) +{ + SCREEN *sp = TCB->csp; + chtype attrs = A_NORMAL; + + AssertTCB(); + if (enter_alt_charset_mode) + attrs |= A_ALTCHARSET; + + if (enter_blink_mode) + attrs |= A_BLINK; + + if (enter_bold_mode) + attrs |= A_BOLD; + + if (enter_dim_mode) + attrs |= A_DIM; + + if (enter_reverse_mode) + attrs |= A_REVERSE; + + if (enter_standout_mode) + attrs |= A_STANDOUT; + + if (enter_protected_mode) + attrs |= A_PROTECT; + + if (enter_secure_mode) + attrs |= A_INVIS; + + if (enter_underline_mode) + attrs |= A_UNDERLINE; + + if (sp && sp->_coloron) + attrs |= A_COLOR; + +#if USE_ITALIC + if (enter_italics_mode) + attrs |= A_ITALIC; +#endif + + return (attrs); +} + +static void +drv_setfilter(TERMINAL_CONTROL_BLOCK * TCB) +{ + AssertTCB(); + + /* *INDENT-EQLS* */ + clear_screen = ABSENT_STRING; + cursor_address = ABSENT_STRING; + cursor_down = ABSENT_STRING; + cursor_up = ABSENT_STRING; + parm_down_cursor = ABSENT_STRING; + parm_up_cursor = ABSENT_STRING; + row_address = ABSENT_STRING; + cursor_home = carriage_return; + + if (back_color_erase) + clr_eos = ABSENT_STRING; +} + +static void +drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map) +{ + SCREEN *sp = TCB->csp; + + AssertTCB(); + assert(sp != NULL); + if (ena_acs != NULL) { + NCURSES_PUTP2("ena_acs", ena_acs); + } +#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 != NULL && b != NULL && !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] = (chtype) i; + if (real_map != fake_map) { + if (sp != NULL) + sp->_screen_acs_map[i] = TRUE; + } + } + } + } +#endif + + if (acs_chars != NULL) { + size_t i = 0; + size_t length = strlen(acs_chars); + + 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; + T(("#%d real_map[%s] = %s", + (int) i, + _tracechar(UChar(acs_chars[i])), + _tracechtype(real_map[UChar(acs_chars[i])]))); + if (sp != NULL) { + 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 (USE_TRACEF(TRACE_CALLS)) { + size_t n, m; + 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++] = (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" + : (strcmp(acs_chars, show) + ? "DIFF" + : "SAME"), + _nc_visbuf(show)); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ +} + +#define ENSURE_TINFO(sp) (TCBOf(sp)->drv->isTerminfo) + +NCURSES_EXPORT(void) +_nc_cookie_init(SCREEN *sp) +{ + bool support_cookies = USE_XMC_SUPPORT; + TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) (sp->_term); + + if (sp == NULL || !ENSURE_TINFO(sp)) + return; + +#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) { + if (getenv("NCURSES_NO_MAGIC_COOKIE") != NULL) { + 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 & XMC_CONFLICT; +#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 the cookie support simple, suppress all of the optimization + * hooks except for clear_screen and the cursor addressing. + */ + 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(sp->_term)) { + acs_chars = NULL; + ena_acs = NULL; + enter_alt_charset_mode = NULL; + exit_alt_charset_mode = NULL; + set_attributes = NULL; + } +#endif +} + +static int +drv_twait(TERMINAL_CONTROL_BLOCK * TCB, + int mode, + int milliseconds, + int *timeleft + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +#if defined(USE_WIN32CON_DRIVER) + return _nc_console_twait(sp, + _nc_console_handle(sp->_ifd), + mode, + milliseconds, + timeleft EVENTLIST_2nd(evl)); +#else + return _nc_timed_wait(sp, mode, milliseconds, timeleft EVENTLIST_2nd(evl)); +#endif +} + +static int +drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf) +{ + SCREEN *sp; + int n; +#if !defined(USE_WIN32CON_DRIVER) + unsigned char c2 = 0; +#endif + + AssertTCB(); + assert(buf); + SetSP(); + + _nc_set_read_thread(TRUE); +#if defined(USE_WIN32CON_DRIVER) + n = _nc_console_read(sp, + _nc_console_handle(sp->_ifd), + buf); +#else + n = (int) read(sp->_ifd, &c2, (size_t) 1); +#endif + _nc_set_read_thread(FALSE); +#if !defined(USE_WIN32CON_DRIVER) + *buf = (int) c2; +#endif + return n; +} + +static int +drv_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms) +{ +#if HAVE_NANOSLEEP + { + struct timespec request, remaining; + request.tv_sec = ms / 1000; + request.tv_nsec = (ms % 1000) * 1000000; + while (nanosleep(&request, &remaining) == -1 + && errno == EINTR) { + request = remaining; + } + } +#elif defined(USE_WIN32CON_DRIVER) + Sleep((DWORD) ms); +#else + _nc_timed_wait(NULL, 0, ms, (int *) 0 EVENTLIST_2nd(NULL)); +#endif + return OK; +} + +static int +__nc_putp(SCREEN *sp, const char *name GCC_UNUSED, const char *value) +{ + int rc = ERR; + + if (value) { + rc = NCURSES_PUTP2(name, value); + } + return rc; +} + +static int +__nc_putp_flush(SCREEN *sp, const char *name, const char *value) +{ + int rc = __nc_putp(sp, name, value); + if (rc != ERR) { + NCURSES_SP_NAME(_nc_flush) (sp); + } + return rc; +} + +static int +drv_kpad(TERMINAL_CONTROL_BLOCK * TCB, int flag) +{ + int ret = ERR; + SCREEN *sp; + + AssertTCB(); + + sp = TCB->csp; + + if (sp) { + if (flag) { + (void) __nc_putp_flush(sp, "keypad_xmit", keypad_xmit); + } else if (!flag && keypad_local) { + (void) __nc_putp_flush(sp, "keypad_local", keypad_local); + } + if (flag && !sp->_tried) { + _nc_init_keytry(sp); + sp->_tried = TRUE; + } + ret = OK; + } + + return ret; +} + +static int +drv_keyok(TERMINAL_CONTROL_BLOCK * TCB, int c, int flag) +{ + SCREEN *sp; + int code = ERR; + int count = 0; + char *s; + + AssertTCB(); + SetSP(); + + if (c >= 0) { + unsigned ch = (unsigned) c; + if (flag) { + while ((s = _nc_expand_try(sp->_key_ok, + ch, &count, (size_t) 0)) != NULL) { + if (_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 { + free(s); + } + } + } else { + while ((s = _nc_expand_try(sp->_keytry, + ch, &count, (size_t) 0)) != NULL) { + if (_nc_remove_key(&(sp->_keytry), ch)) { + code = _nc_add_to_try(&(sp->_key_ok), s, ch); + free(s); + count = 0; + if (code != OK) + break; + } else { + free(s); + } + } + } + } + return (code); +} + +static int +drv_cursorSet(TERMINAL_CONTROL_BLOCK * TCB, int vis) +{ + SCREEN *sp; + int code = ERR; + + AssertTCB(); + SetSP(); + + T((T_CALLED("tinfo:drv_cursorSet(%p,%d)"), (void *) SP_PARM, vis)); + + if (SP_PARM != NULL && IsTermInfo(SP_PARM)) { + switch (vis) { + case 2: + code = NCURSES_PUTP2_FLUSH("cursor_visible", cursor_visible); + break; + case 1: + code = NCURSES_PUTP2_FLUSH("cursor_normal", cursor_normal); + break; + case 0: + code = NCURSES_PUTP2_FLUSH("cursor_invisible", cursor_invisible); + break; + } + } else { + code = ERR; + } + returnCode(code); +} + +static bool +drv_kyExist(TERMINAL_CONTROL_BLOCK * TCB, int key) +{ + bool res = FALSE; + + AssertTCB(); + if (TCB->csp) + res = TINFO_HAS_KEY(TCB->csp, key) == 0 ? FALSE : TRUE; + + return res; +} + +NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_TINFO_DRIVER = { + TRUE, + drv_Name, /* Name */ + drv_CanHandle, /* CanHandle */ + drv_init, /* init */ + drv_release, /* release */ + drv_size, /* size */ + drv_sgmode, /* sgmode */ + drv_conattr, /* conattr */ + drv_mvcur, /* hwcur */ + drv_mode, /* mode */ + drv_rescol, /* rescol */ + drv_rescolors, /* rescolors */ + drv_setcolor, /* color */ + drv_dobeepflash, /* doBeepOrFlash */ + drv_initpair, /* initpair */ + drv_initcolor, /* initcolor */ + drv_do_color, /* docolor */ + drv_initmouse, /* initmouse */ + drv_testmouse, /* testmouse */ + drv_setfilter, /* setfilter */ + drv_hwlabel, /* hwlabel */ + drv_hwlabelOnOff, /* hwlabelOnOff */ + drv_doupdate, /* update */ + drv_defaultcolors, /* defaultcolors */ + drv_print, /* print */ + drv_getsize, /* getsize */ + drv_setsize, /* setsize */ + drv_initacs, /* initacs */ + drv_screen_init, /* scinit */ + drv_wrap, /* scexit */ + drv_twait, /* twait */ + drv_read, /* read */ + drv_nap, /* nap */ + drv_kpad, /* kpad */ + drv_keyok, /* kyOk */ + drv_kyExist, /* kyExist */ + drv_cursorSet /* cursorSet */ +}; + +#if USE_TERM_DRIVER +/* + * The terminfo driver is mandatory and must always be present. + * So this is the natural place for the driver initialisation + * logic. + */ + +typedef struct DriverEntry { + const char *name; + TERM_DRIVER *driver; +} DRIVER_ENTRY; + +static DRIVER_ENTRY DriverTable[] = +{ +#ifdef USE_WIN32CON_DRIVER + {"win32console", &_nc_WIN_DRIVER}, +#endif + {"tinfo", &_nc_TINFO_DRIVER} /* must be last */ +}; + +NCURSES_EXPORT(int) +_nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret) +{ + int code = ERR; + size_t i; + TERM_DRIVER *res = (TERM_DRIVER *) 0; + TERM_DRIVER *use = NULL; + + T((T_CALLED("_nc_get_driver(%p, %s, %p)"), + (void *) TCB, NonNull(name), (void *) errret)); + + assert(TCB != NULL); + + for (i = 0; i < SIZEOF(DriverTable); i++) { + res = DriverTable[i].driver; +#if defined(USE_WIN32CON_DRIVER) + if ((i + 1) == SIZEOF(DriverTable)) { + /* For Windows >= 10.0.17763 Windows Console interface implements + virtual Terminal functionality. + If on Windows td_CanHandle returned FALSE although the terminal + name is empty, we default to ms-terminal as tinfo TERM type. + */ + if (name == NULL || *name == 0 || (strcmp(name, "unknown") == 0)) { + name = DEFAULT_TERM_ENV; + T(("Set TERM=%s", name)); + } + } +#endif + if (strcmp(DriverTable[i].name, res->td_name(TCB)) == 0) { + if (res->td_CanHandle(TCB, name, errret)) { + T(("matched driver %s with TERM=%s", DriverTable[i].name, name)); + use = res; + break; + } + } + } + if (use != 0) { + TCB->drv = use; + code = OK; + } + returnCode(code); +} +#endif /* USE_TERM_DRIVER */ diff --git a/ncurses/ncurses/tinfo/trim_sgr0.c b/ncurses/ncurses/tinfo/trim_sgr0.c new file mode 100644 index 0000000000..de73c70abf --- /dev/null +++ b/ncurses/ncurses/tinfo/trim_sgr0.c @@ -0,0 +1,407 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 2005-2012,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +#include + +#include + +MODULE_ID("$Id: trim_sgr0.c,v 1.27 2024/12/21 20:15:26 tom Exp $") + +#undef CUR +#define CUR tp-> + +/* + * Skip a padding token, e.g., "<5>", "<5.1>", "<5/>", "<5*>", or "<5/>". + * If the pattern does not match, return null. + */ +static char * +skip_padding(char *value) +{ + char *result = NULL; + if (*value++ == '$' && *value++ == '<') { + int ch; + int state = 0; /* 1=integer, 2=decimal, 3=fraction */ + while ((ch = UChar(*value++)) != '\0') { + if (ch == '*' || ch == '/') { + if (!state) + break; + } else if (ch == '>') { + if (state) + result = value; + break; + } else if (ch == '.') { + if (state < 2) { + state = 2; + } else { + break; /* a single decimal point is allowed */ + } + } else if (isdigit(ch)) { + if (state < 2) { + state = 1; + } else if (state == 2) { + state = 3; + } else { + break; /* only a single digit after decimal point */ + } + } else { + break; + } + } + } + return result; +} + +static void +strip_padding(char *value) +{ + char *s = value; + char ch; + + while ((ch = *s) != '\0') { + if (ch == '\\') { + if (*++s == '\0') + break; + ++s; + } else { + char *d = NULL; + if (ch == '$') + d = skip_padding(s); + if (d != NULL) { + char *t = s; + while ((*t++ = *d++) != '\0') ; + } else { + ++s; + } + } + } +} + +static char * +set_attribute_9(const TERMTYPE2 *tp, int flag) +{ + const char *value; + char *result; + + value = TIPARM_9(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag); + if (PRESENT(value)) { + result = strdup(value); + if (result != NULL) + strip_padding(result); + } else { + result = NULL; + } + return result; +} + +static int +is_csi(const char *s) +{ + int result = 0; + if (s != NULL) { + if (UChar(s[0]) == CSI_CHR) + result = 1; + else if (s[0] == ESC_CHR && s[1] == L_BLOCK) + result = 2; + } + return result; +} + +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, const char *attr) +{ + if (s != NULL) { + if (PRESENT(attr)) { + size_t len_s = strlen(s); + size_t 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]; + } + _nc_STRCPY(s + n, attr, strlen(s) + 1); + TR(TRACE_DATABASE, ("to:\n\t%s", s)); + } + } + return TRUE; + } + return FALSE; /* oops */ +} + +static bool +similar_sgr(char *a, char *b) +{ + bool result = FALSE; + if (a != NULL && b != NULL) { + int csi_a = is_csi(a); + int csi_b = is_csi(b); + size_t len_a; + size_t 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 unsigned +compare_part(const char *part, const char *full) +{ + const char *next_part; + const char *next_full; + unsigned used_full = 0; + unsigned used_delay = 0; + + while (*part != 0) { + if (*part != *full) { + used_full = 0; + break; + } + + /* + * Adjust the return-value to allow the rare case of + * stringstring + * 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 += (unsigned) (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(TERMTYPE2 *tp) +{ + char *result = exit_attribute_mode; + + T((T_CALLED("_nc_trim_sgr0()"))); + + if (PRESENT(exit_attribute_mode) + && PRESENT(set_attributes)) { + char *on = set_attribute_9(tp, 1); + char *off = set_attribute_9(tp, 0); + char *end = strdup(exit_attribute_mode); + char *tmp; + + 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)) { + bool found = FALSE; + size_t i, j; + + 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 (PRESENT(exit_alt_charset_mode)) { + size_t k; + + 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) { + unsigned k2 = compare_part(exit_alt_charset_mode, + off + i); + if (k2 != 0) { + found = TRUE; + chop_out(off, (unsigned) i, (unsigned) (i + k2)); + break; + } + } + } + } + /* + * SGR 10 would reset to normal font. + */ + if (!found) { + if ((i = (size_t) 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 = (size_t) (tmp - off); + if (off[i - 1] == ';') + i--; + j = (size_t) (skip_zero(tmp + 1) - off); + (void) chop_out(off, (unsigned) i, (unsigned) j); + found = TRUE; + } + } + } + if (!found + && (tmp = strstr(end, off)) != NULL + && strcmp(end, off) != 0) { + i = (size_t) (tmp - end); + j = strlen(off); + tmp = strdup(end); + chop_out(tmp, (unsigned) i, (unsigned) 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/ncurses/ncurses/tinfo/use_screen.c b/ncurses/ncurses/tinfo/use_screen.c new file mode 100644 index 0000000000..4bb1847196 --- /dev/null +++ b/ncurses/ncurses/tinfo/use_screen.c @@ -0,0 +1,66 @@ +/**************************************************************************** + * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2007-2009,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +MODULE_ID("$Id: use_screen.c,v 1.12 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(int) +use_screen(SCREEN *screen, NCURSES_SCREEN_CB func, void *data) +{ + SCREEN *save_SP; + int code = OK; + TR_FUNC_BFR(1); + + T((T_CALLED("use_screen(%p,%s,%p)"), + (void *) screen, + TR_FUNC_ARG(0, func), + (void *) 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 = CURRENT_SCREEN; + set_term(screen); + + code = func(screen, data); + + set_term(save_SP); + _nc_unlock_global(curses); + returnCode(code); +} diff --git a/ncurses/ncurses/tinfo/write_entry.c b/ncurses/ncurses/tinfo/write_entry.c new file mode 100644 index 0000000000..8a3371682d --- /dev/null +++ b/ncurses/ncurses/tinfo/write_entry.c @@ -0,0 +1,984 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * write_entry.c -- write a terminfo structure onto the file system + */ + +#include +#include + +#include + +MODULE_ID("$Id: write_entry.c,v 1.144 2025/12/28 00:33:30 tom Exp $") + +#if 1 +#define TRACE_OUT(p) DEBUG(2, p) +#define TRACE_NUM(n) if (VALID_NUMERIC(Numbers[n])) { \ + TRACE_OUT(("put Numbers[%u]=%d", (unsigned) (n), Numbers[n])); } +#else +#define TRACE_OUT(p) /*nothing */ +#define TRACE_NUM(n) /* nothing */ +#endif + +/* + * FIXME: special case to work around Cygwin bug in link(), which updates + * the target file's timestamp. + */ +#if HAVE_LINK && !USE_SYMLINKS && !MIXEDCASE_FILENAMES && defined(__CYGWIN__) +#define LINK_TOUCHES 1 +#else +#define LINK_TOUCHES 0 +#endif + +static int total_written; +static int total_parts; +static int total_size; + +static int make_db_root(const char *); + +#if !USE_HASHED_DB +static void +write_file(const char *filename, TERMTYPE2 *tp) +{ + char buffer[MAX_ENTRY_SIZE]; + unsigned limit = sizeof(buffer); + unsigned offset = 0; + + if (_nc_write_object(tp, buffer, &offset, limit) == ERR) { + _nc_warning("entry is larger than %u bytes", limit); + } else { + FILE *fp = ((_nc_access(filename, W_OK) == 0) + ? safe_fopen(filename, BIN_W) + : NULL); + size_t actual; + + if (fp == NULL) { + _nc_syserr_abort("cannot open %s/%s: (errno %d) %s", + _nc_tic_dir(NULL), + filename, + errno, + strerror(errno)); + } + + actual = fwrite(buffer, sizeof(char), (size_t) offset, fp); + if (actual != offset) { + int myerr = ferror(fp) ? errno : 0; + if (myerr) { + _nc_syserr_abort("error writing %s/%s: (errno %d) %s", + _nc_tic_dir(NULL), + filename, + myerr, + strerror(myerr)); + } else { + _nc_syserr_abort("error writing %s/%s: %u bytes vs actual %lu", + _nc_tic_dir(NULL), + filename, + offset, + (unsigned long) actual); + } + } else { + fclose(fp); + DEBUG(1, ("Created %s", filename)); + } + } +} + +/* + * 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_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)]; + + const char *s = NULL; + + if (code == 0 || (s = (strchr) (dirnames, code)) == NULL) { + _nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", UChar(code)); + } else if (!verified[s - dirnames]) { + char dir[sizeof(LEAF_FMT)]; + _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, UChar(code)); + if (make_db_root(dir) < 0) { + _nc_err_abort("%s/%s: (errno %d) %s", + _nc_tic_dir(NULL), + dir, + errno, + strerror(errno)); + } else { + verified[s - dirnames] = TRUE; + } + } +} +#endif /* !USE_HASHED_DB */ + +static int +make_db_path(char *dst, const char *src, size_t limit) +{ + int rc = -1; + const char *top = _nc_tic_dir(NULL); + + if (src == top || _nc_is_abs_path(src)) { + if (strlen(src) + 1 <= limit) { + _nc_STRCPY(dst, src, limit); + rc = 0; + } + } else { + size_t len_top = strlen(top); + size_t len_src = strlen(src); + if ((len_top + len_src + 6) <= limit) { + _nc_SPRINTF(dst, _nc_SLIMIT(limit) "%.*s/%.*s", + (int) len_top, top, + (int) len_src, src); + rc = 0; + } + } +#if USE_HASHED_DB + if (rc == 0) { + static const char suffix[] = DBM_SUFFIX; + size_t have = strlen(dst); + size_t need = strlen(suffix); + if (have > need && strcmp(dst + (int) (have - need), suffix)) { + if (have + need <= limit) { + _nc_STRCAT(dst, suffix, limit); + } else { + rc = -1; + } + } else if (_nc_is_dir_path(dst)) { + rc = -1; + } + } +#endif + return rc; +} + +/* + * Make a database-root if it doesn't exist. + */ +static int +make_db_root(const char *path) +{ + int rc; + char fullpath[PATH_MAX]; + + FixupPathname(path); + 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; + + rc = 0; + if (!_nc_is_path_found(path, &statbuf)) { + rc = mkdir(path +#ifndef _NC_WINDOWS_NATIVE + ,0777 +#endif + ); + } else if (_nc_access(path, R_OK | W_OK | X_OK) < 0) { + rc = -1; /* permission denied */ + } else if (!(S_ISDIR(statbuf.st_mode))) { + errno = ENOTDIR; + rc = -1; /* not a directory */ + } +#endif + } + return rc; +} + +/* + * Set the write directory for compiled entries. + */ +NCURSES_EXPORT(void) +_nc_set_writedir(const char *dir) +{ + const char *destination; + char actual[PATH_MAX]; + bool specific = (dir != NULL); + + if (!specific && use_terminfo_vars()) + dir = getenv("TERMINFO"); + + if (dir != NULL) + (void) _nc_tic_dir(dir); + + destination = _nc_tic_dir(NULL); + if (make_db_root(destination) < 0) { + bool success = FALSE; + + if (!specific) { + char *home = _nc_home_terminfo(); + + if (home != NULL) { + destination = home; + if (make_db_root(destination) == 0) + success = TRUE; + } + } + if (!success) { + _nc_err_abort("%s: (errno %d) %s", + destination, + errno, + strerror(errno)); + } + } + + /* + * 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 + FixupPathname2(destination, actual); + if (chdir(_nc_tic_dir(destination)) < 0 + || getcwd(actual, sizeof(actual)) == NULL) + _nc_err_abort("%s: not a directory", destination); +#endif + _nc_keep_tic_dir(actual); +} + +/* + * Save the compiled version of a description in the filesystem. + * + * make a copy of the name-list + * break it up into first-name and all-but-last-name + * creat(first-name) + * write object information to first-name + * close(first-name) + * for each name in all-but-last-name + * link to first-name + * + * Using 'time()' to obtain a reference for file timestamps is unreliable, + * e.g., with NFS, because the filesystem may have a different time + * reference. We check for pre-existence of links by latching the first + * timestamp from a file that we create. + * + * The _nc_warning() calls will report a correct line number only if + * _nc_curr_line is properly set before the write_entry() call. + */ + +NCURSES_EXPORT(void) +_nc_write_entry(TERMTYPE2 *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 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 */ + + unsigned limit2 = sizeof(filename) - (2 + LEAF_LEN); + char saved = '\0'; + + static int call_count; + static time_t start_time; /* time at start of writes */ + +#endif /* USE_HASHED_DB */ + + char name_list[MAX_TERMINFO_LENGTH]; + char *first_name, *other_names; + char *ptr; + char *term_names = tp->term_names; + size_t name_size = strlen(term_names); + + if (name_size == 0) { + _nc_syserr_abort("no terminal name found."); + } else if (name_size >= sizeof(name_list) - 1) { + _nc_syserr_abort("terminal name too long: %s", term_names); + } + + _nc_STRCPY(name_list, term_names, sizeof(name_list)); + DEBUG(7, ("Name list = '%s'", name_list)); + + first_name = name_list; + + ptr = &name_list[name_size - 1]; + other_names = ptr + 1; + + while (ptr > name_list && *ptr != '|') + ptr--; + + if (ptr != name_list) { + *ptr = '\0'; + + for (ptr = name_list; *ptr != '\0' && *ptr != '|'; ptr++) { + /* EMPTY */ ; + } + + if (*ptr == '\0') + other_names = ptr; + else { + *ptr = '\0'; + other_names = ptr + 1; + } + } + + DEBUG(7, ("First name = '%s'", first_name)); + DEBUG(7, ("Other names = '%s'", other_names)); + + _nc_set_type(first_name); + +#if USE_HASHED_DB + if (_nc_write_object(tp, buffer + 1, &offset, limit - 1) != ERR) { + DB *capdb = _nc_db_open(_nc_tic_dir(NULL), TRUE); + DBT key, data; + + if (capdb != NULL) { + buffer[0] = 0; + + memset(&key, 0, sizeof(key)); + key.data = term_names; + key.size = name_size; + + 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); + + _nc_STRCPY(buffer + 1, + term_names, + sizeof(buffer) - 1); + data.size = name_size + 1; + + total_size += (int) data.size; + total_parts++; + _nc_db_put(capdb, &key, &data); + + while (*other_names != '\0') { + ptr = other_names++; + assert(ptr < buffer + sizeof(buffer) - 1); + while (*other_names != '|' && *other_names != '\0') + other_names++; + + if (*other_names != '\0') + *(other_names++) = '\0'; + + key.data = ptr; + key.size = strlen(ptr); + + total_size += (int) data.size; + total_parts++; + _nc_db_put(capdb, &key, &data); + } + } + } +#else /* !USE_HASHED_DB */ + if (call_count++ == 0) { + start_time = 0; + } + + if (strlen(first_name) >= limit2) { + _nc_warning("terminal name too long."); + saved = first_name[limit2]; + first_name[limit2] = '\0'; + } + + _nc_SPRINTF(filename, _nc_SLIMIT(sizeof(filename)) + LEAF_FMT "/%.*s", UChar(first_name[0]), + (int) (sizeof(filename) - (LEAF_LEN + 2)), + first_name); + + if (saved) + first_name[limit2] = saved; + + /* + * Has this primary name been written since the first call to + * write_entry()? If so, the newer write will step on the older, + * so warn the user. + */ + if (start_time > 0 && + _nc_is_path_found(filename, &statbuf) + && statbuf.st_mtime >= start_time) { +#if HAVE_LINK && !USE_SYMLINKS + /* + * If the file has more than one link, the reason for the previous + * write could be that the current primary name used to be an alias for + * the previous entry. In that case, unlink the file so that we will + * not modify the previous entry as we write this one. + */ + if (statbuf.st_nlink > 1) { + _nc_warning("name redefined."); + unlink(filename); + } else { + _nc_warning("name multiply defined."); + } +#else + _nc_warning("name multiply defined."); +#endif + } + + check_writeable(first_name[0]); + write_file(filename, tp); + + if (start_time == 0) { + if (!_nc_is_path_found(filename, &statbuf) + || (start_time = statbuf.st_mtime) == 0) { + _nc_syserr_abort("error obtaining time from %s/%s", + _nc_tic_dir(NULL), filename); + } + } + while (*other_names != '\0') { + ptr = other_names++; + while (*other_names != '|' && *other_names != '\0') + other_names++; + + if (*other_names != '\0') + *(other_names++) = '\0'; + + if (strlen(ptr) > sizeof(linkname) - (2 + LEAF_LEN)) { + _nc_warning("terminal alias %s too long.", ptr); + continue; + } + if (strchr(ptr, '/') != NULL) { + _nc_warning("cannot link alias %s.", ptr); + continue; + } + + check_writeable(ptr[0]); + _nc_SPRINTF(linkname, _nc_SLIMIT(sizeof(linkname)) + LEAF_FMT "/%.*s", UChar(ptr[0]), + (int) sizeof(linkname) - (2 + LEAF_LEN), ptr); + + if (strcmp(filename, linkname) == 0) { + _nc_warning("self-synonym ignored"); + } +#if !LINK_TOUCHES + else if (_nc_is_path_found(linkname, &statbuf) && + statbuf.st_mtime < start_time) { + _nc_warning("alias %s multiply defined.", ptr); + } +#endif + else if (_nc_access(linkname, W_OK) == 0) +#if HAVE_LINK + { + int code; +#if USE_SYMLINKS +#define MY_SIZE sizeof(symlinkname) - 1 + if (first_name[0] == linkname[0]) { + _nc_STRNCPY(symlinkname, first_name, MY_SIZE); + } else { + _nc_STRCPY(symlinkname, "../", sizeof(symlinkname)); + _nc_STRNCPY(symlinkname + 3, filename, MY_SIZE - 3); + } + symlinkname[MY_SIZE] = '\0'; +#endif /* USE_SYMLINKS */ +#if HAVE_REMOVE + code = remove(linkname); +#else + code = unlink(linkname); +#endif + if (code != 0 && errno == ENOENT) + code = 0; +#if USE_SYMLINKS + if (symlink(symlinkname, linkname) < 0) +#else + if (link(filename, linkname) < 0) +#endif /* USE_SYMLINKS */ + { + /* + * If there wasn't anything there, and we cannot + * link to the target because it is the same as the + * target, then the source must be on a filesystem + * that uses caseless filenames, such as Win32, etc. + */ + if (code == 0 && errno == EEXIST) + _nc_warning("can't link %s to %s", filename, linkname); + else if (code == 0 && (errno == EPERM || errno == ENOENT)) + write_file(linkname, tp); + else { +#if MIXEDCASE_FILENAMES + _nc_syserr_abort("cannot link %s to %s", filename, linkname); +#else + _nc_warning("cannot link %s to %s (errno=%d)", filename, + linkname, errno); +#endif + } + } else { + DEBUG(1, ("Linked %s", linkname)); + } + } +#else /* just make copies */ + write_file(linkname, tp); +#endif /* HAVE_LINK */ + } +#endif /* USE_HASHED_DB */ +} + +static size_t +fake_write(char *dst, + unsigned *offset, + size_t limit, + const char *src, + size_t want, + size_t size) +{ + size_t have = (limit - *offset); + + want *= size; + if (have > 0) { + if (want > have) + want = have; + memcpy(dst + *offset, src, want); + *offset += (unsigned) want; + } else { + want = 0; + } + return (want / size); +} + +#define Write(buf, size, count) fake_write(buffer, offset, (size_t) limit, (char *) buf, (size_t) count, (size_t) 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] = (unsigned char)LO(x), \ + (p)[1] = (unsigned char)HI(x) + +#define WRITE_STRING(str) (Write(str, sizeof(char), strlen(str) + 1) == strlen(str) + 1) + +static int +compute_offsets(char **Strings, size_t strmax, short *offsets) +{ + int nextfree = 0; + size_t i; + + for (i = 0; i < strmax; i++) { + if (Strings[i] == ABSENT_STRING) { + offsets[i] = -1; + } else if (Strings[i] == CANCELLED_STRING) { + offsets[i] = -2; + } else { + offsets[i] = (short) nextfree; + nextfree += (int) strlen(Strings[i]) + 1; + TRACE_OUT(("put Strings[%d]=%s(%d)", (int) i, + _nc_visbuf(Strings[i]), (int) nextfree)); + } + } + return nextfree; +} + +static size_t +convert_shorts(unsigned char *buf, short *Numbers, size_t count) +{ + size_t 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; + } else if (Numbers[i] == CANCELLED_NUMERIC) { /* HI/LO won't work */ + buf[2 * i] = 0376; + buf[2 * i + 1] = 0377; + } else { + LITTLE_ENDIAN(buf + 2 * i, Numbers[i]); + TRACE_OUT(("put Numbers[%u]=%d", (unsigned) i, Numbers[i])); + } + } + return SIZEOF_SHORT; +} + +#if NCURSES_EXT_NUMBERS +static size_t +convert_16bit(unsigned char *buf, NCURSES_INT2 *Numbers, size_t count) +{ + size_t i, j; + size_t size = SIZEOF_SHORT; + for (i = 0; i < count; i++) { + unsigned value = (unsigned) Numbers[i]; + TRACE_NUM(i); + for (j = 0; j < size; ++j) { + *buf++ = value & 0xff; + value >>= 8; + } + } + return size; +} + +static size_t +convert_32bit(unsigned char *buf, NCURSES_INT2 *Numbers, size_t count) +{ + size_t i, j; + size_t size = SIZEOF_INT2; + for (i = 0; i < count; i++) { + unsigned value = (unsigned) Numbers[i]; + TRACE_NUM(i); + for (j = 0; j < size; ++j) { + *buf++ = value & 0xff; + value >>= 8; + } + } + return size; +} +#endif + +#define even_boundary(value) \ + ((value) % 2 != 0 && Write(&zero, sizeof(char), 1) != 1) + +#if NCURSES_XNAMES +static unsigned +extended_Booleans(const TERMTYPE2 *tp) +{ + unsigned result = 0; + unsigned i; + + for (i = 0; i < tp->ext_Booleans; ++i) { + if (tp->Booleans[BOOLCOUNT + i] == TRUE) + result = (i + 1); + } + return result; +} + +static unsigned +extended_Numbers(const TERMTYPE2 *tp) +{ + unsigned result = 0; + unsigned 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(const TERMTYPE2 *tp) +{ + unsigned short result = 0; + unsigned short i; + + for (i = 0; i < tp->ext_Strings; ++i) { + if (tp->Strings[STRCOUNT + i] != ABSENT_STRING) + result = (unsigned short) (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(const TERMTYPE2 *tp) +{ + bool result = FALSE; + + if (_nc_user_definable) { + result = ((extended_Booleans(tp) + + extended_Numbers(tp) + + extended_Strings(tp)) != 0); + } + return result; +} +#endif + +NCURSES_EXPORT(int) +_nc_write_object(TERMTYPE2 *tp, char *buffer, unsigned *offset, unsigned limit) +{ + char *namelist; + size_t namelen, boolmax, nummax, strmax, numlen; + char zero = '\0'; + size_t i; + int nextfree; + short offsets[MAX_ENTRY_SIZE / 2]; + unsigned char buf[MAX_ENTRY_SIZE]; + unsigned last_bool = BOOLWRITE; + unsigned last_num = NUMWRITE; + unsigned last_str = STRWRITE; +#if NCURSES_EXT_NUMBERS + bool need_ints = FALSE; + size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t); +#else +#define convert_numbers convert_shorts +#endif + +#if NCURSES_XNAMES + /* + * Normally we limit the list of values to exclude the "obsolete" + * capabilities. However, if we are accepting extended names, add + * these as well, since they are used for supporting translation + * to/from termcap. + */ + if (_nc_user_definable) { + last_bool = BOOLCOUNT; + last_num = NUMCOUNT; + last_str = STRCOUNT; + } +#endif + + namelist = tp->term_names; + namelen = strlen(namelist) + 1; + + boolmax = 0; + for (i = 0; i < last_bool; i++) { + if (tp->Booleans[i] == TRUE) { + boolmax = i + 1; + } + } + + nummax = 0; + for (i = 0; i < last_num; i++) { + if (tp->Numbers[i] != ABSENT_NUMERIC) { + nummax = i + 1; +#if NCURSES_EXT_NUMBERS + if (tp->Numbers[i] > MAX_OF_TYPE(NCURSES_COLOR_T)) { + need_ints = TRUE; + } +#endif + } + } + + strmax = 0; + for (i = 0; i < last_str; i++) { + if (tp->Strings[i] != ABSENT_STRING) + strmax = i + 1; + } + + nextfree = compute_offsets(tp->Strings, strmax, offsets); + + /* fill in the header */ +#if NCURSES_EXT_NUMBERS + if (need_ints) { + convert_numbers = convert_32bit; + LITTLE_ENDIAN(buf, MAGIC2); + } else { + convert_numbers = convert_16bit; + LITTLE_ENDIAN(buf, MAGIC); + } +#else + LITTLE_ENDIAN(buf, MAGIC); +#endif + namelen = Min(namelen, MAX_NAME_SIZE + 1); + LITTLE_ENDIAN(buf + 2, namelen); + LITTLE_ENDIAN(buf + 4, boolmax); + LITTLE_ENDIAN(buf + 6, nummax); + LITTLE_ENDIAN(buf + 8, strmax); + LITTLE_ENDIAN(buf + 10, nextfree); + + /* write out the header */ + 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++) { + if (tp->Booleans[i] == TRUE) { + buf[i] = TRUE; + } else { + buf[i] = FALSE; + } + } + if (Write(buf, sizeof(char), boolmax) != boolmax) { + return (ERR); + } + + if (even_boundary(namelen + boolmax)) { + return (ERR); + } + + TRACE_OUT(("Numerics begin at %04x", *offset)); + + /* the numerics */ + numlen = convert_numbers(buf, tp->Numbers, nummax); + if (Write(buf, numlen, nummax) != nummax) { + return (ERR); + } + + TRACE_OUT(("String offsets begin at %04x", *offset)); + + /* the string offsets */ + convert_shorts(buf, offsets, strmax); + if (Write(buf, SIZEOF_SHORT, strmax) != strmax) { + return (ERR); + } + + TRACE_OUT(("String table begins at %04x", *offset)); + + /* the strings */ + for (i = 0; i < strmax; i++) { + if (VALID_STRING(tp->Strings[i])) { + if (!WRITE_STRING(tp->Strings[i])) { + return (ERR); + } + } + } + +#if NCURSES_XNAMES + if (extended_object(tp)) { + unsigned ext_total = (unsigned) NUM_EXT_NAMES(tp); + unsigned ext_usage = ext_total; + + if (even_boundary(nextfree)) { + return (ERR); + } + + nextfree = compute_offsets(tp->Strings + STRCOUNT, + (size_t) tp->ext_Strings, + offsets); + TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree)); + + if (tp->ext_Strings >= SIZEOF(offsets)) { + return (ERR); + } + + nextfree += compute_offsets(tp->ext_Names, + (size_t) ext_total, + offsets + tp->ext_Strings); + TRACE_OUT(("after extended capnames, nextfree=%d", nextfree)); + strmax = tp->ext_Strings + ext_total; + for (i = 0; i < tp->ext_Strings; ++i) { + if (VALID_STRING(tp->Strings[i + STRCOUNT])) { + ext_usage++; + } + } + TRACE_OUT(("will write %u/%lu strings", ext_usage, (unsigned long) strmax)); + + /* + * Write the extended header + */ + LITTLE_ENDIAN(buf + 0, tp->ext_Booleans); + LITTLE_ENDIAN(buf + 2, tp->ext_Numbers); + LITTLE_ENDIAN(buf + 4, tp->ext_Strings); + LITTLE_ENDIAN(buf + 6, ext_usage); + LITTLE_ENDIAN(buf + 8, nextfree); + TRACE_OUT(("WRITE extended-header @%d", *offset)); + if (Write(buf, 10, 1) != 1) { + return (ERR); + } + + TRACE_OUT(("WRITE %d booleans @%d", tp->ext_Booleans, *offset)); + if (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 @%d", tp->ext_Numbers, *offset)); + if (tp->ext_Numbers) { + numlen = convert_numbers(buf, tp->Numbers + NUMCOUNT, (size_t) tp->ext_Numbers); + if (Write(buf, numlen, tp->ext_Numbers) != tp->ext_Numbers) { + return (ERR); + } + } + + /* + * Convert the offsets for the ext_Strings and ext_Names tables, + * in that order. + */ + convert_shorts(buf, offsets, strmax); + TRACE_OUT(("WRITE offsets @%d", *offset)); + if (Write(buf, SIZEOF_SHORT, strmax) != strmax) { + return (ERR); + } + + /* + * Write the string table after the offset tables so we do not + * have to do anything about alignment. + */ + for (i = 0; i < tp->ext_Strings; i++) { + if (VALID_STRING(tp->Strings[i + STRCOUNT])) { + TRACE_OUT(("WRITE ext_Strings[%d]=%s", (int) i, + _nc_visbuf(tp->Strings[i + STRCOUNT]))); + if (!WRITE_STRING(tp->Strings[i + STRCOUNT])) { + return (ERR); + } + } + } + + /* + * Write the extended names + */ + for (i = 0; i < ext_total; i++) { + TRACE_OUT(("WRITE ext_Names[%d]=%s", (int) i, tp->ext_Names[i])); + if (!WRITE_STRING(tp->ext_Names[i])) { + return (ERR); + } + } + + } +#endif /* NCURSES_XNAMES */ + + total_written++; + total_parts++; + total_size = total_size + (int) (*offset + 1); + return (OK); +} + +/* + * Returns the total number of entries written by this process + */ +NCURSES_EXPORT(int) +_nc_tic_written(void) +{ + TR(TRACE_DATABASE, ("_nc_tic_written %d entries, %d parts, %d size", + total_written, total_parts, total_size)); + return total_written; +} diff --git a/ncurses/ncurses/trace/README b/ncurses/ncurses/trace/README new file mode 100644 index 0000000000..3e22d468e4 --- /dev/null +++ b/ncurses/ncurses/trace/README @@ -0,0 +1,37 @@ +------------------------------------------------------------------------------- +-- Copyright 2020 Thomas E. Dickey -- +-- Copyright 1998,2006 Free Software Foundation, Inc. -- +-- -- +-- Copyright (c) 2026 -- +-- Project Tick. All rights reserved. -- +-- -- +-- 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: README,v 1.3 2020/02/02 23:34:34 tom Exp $ +------------------------------------------------------------------------------- + +The files in this directory (trace) support both the terminfo and ncurses +libraries. Most of the functions are linked in only when the libraries +are compiled with TRACE defined. diff --git a/ncurses/ncurses/trace/lib_trace.c b/ncurses/ncurses/trace/lib_trace.c new file mode 100644 index 0000000000..ab13288c2e --- /dev/null +++ b/ncurses/ncurses/trace/lib_trace.c @@ -0,0 +1,462 @@ +/**************************************************************************** + * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* + * 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 +#include + +#include + +MODULE_ID("$Id: lib_trace.c,v 1.109 2024/12/07 21:02:00 tom Exp $") + +NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */ + +#ifdef TRACE + +#if USE_REENTRANT +NCURSES_EXPORT(const char *) +NCURSES_PUBLIC_VAR(_nc_tputs_trace) (void) +{ + return CURRENT_SCREEN ? CURRENT_SCREEN->_tputs_trace : _nc_prescreen._tputs_trace; +} +NCURSES_EXPORT(long) +NCURSES_PUBLIC_VAR(_nc_outchars) (void) +{ + return CURRENT_SCREEN ? CURRENT_SCREEN->_outchars : _nc_prescreen._outchars; +} +NCURSES_EXPORT(void) +_nc_set_tputs_trace(const char *s) +{ + if (CURRENT_SCREEN) + CURRENT_SCREEN->_tputs_trace = s; + else + _nc_prescreen._tputs_trace = s; +} +NCURSES_EXPORT(void) +_nc_count_outchars(long increment) +{ + if (CURRENT_SCREEN) + CURRENT_SCREEN->_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 MyFP _nc_globals.trace_fp +#define MyFD _nc_globals.trace_fd +#define MyInit _nc_globals.trace_opened +#define MyLevel _nc_globals.trace_level +#define MyNested _nc_globals.nested_tracef +#endif /* TRACE */ + +#if USE_REENTRANT +#define Locked(statement) \ + do { \ + _nc_lock_global(tst_tracef); \ + statement; \ + _nc_unlock_global(tst_tracef); \ + } while (0) +#else +#define Locked(statement) statement +#endif + +NCURSES_EXPORT(unsigned) +curses_trace(unsigned tracelevel) +{ + unsigned result; + +#if defined(TRACE) + int bit; + +#define DATA(name) { name, #name } + static struct { + unsigned mask; + const char *name; + } trace_names[] = { + DATA(TRACE_TIMES), + DATA(TRACE_TPUTS), + DATA(TRACE_UPDATE), + DATA(TRACE_MOVE), + DATA(TRACE_CHARPUT), + DATA(TRACE_CALLS), + DATA(TRACE_VIRTPUT), + DATA(TRACE_IEVENT), + DATA(TRACE_BITS), + DATA(TRACE_ICALLS), + DATA(TRACE_CCALLS), + DATA(TRACE_DATABASE), + DATA(TRACE_ATTRS) + }; +#undef DATA + + Locked(result = _nc_tracing); + + if ((MyFP == NULL) && tracelevel) { + MyInit = TRUE; + if (MyFD >= 0) { + MyFP = fdopen(MyFD, BIN_W); + } else { + char myFile[80]; + + _nc_STRCPY(myFile, "trace", sizeof(myFile)); + if (_nc_is_dir_path(myFile)) { + _nc_STRCAT(myFile, ".log", sizeof(myFile)); + } +#define SAFE_MODE (O_CREAT | O_EXCL | O_RDWR) + if (_nc_access(myFile, W_OK) < 0 + || (MyFD = safe_open3(myFile, SAFE_MODE, 0600)) < 0 + || (MyFP = fdopen(MyFD, BIN_W)) == NULL) { + ; /* EMPTY */ + } + } + Locked(_nc_tracing = tracelevel); + /* Try to set line-buffered mode, or (failing that) unbuffered, + * so that the trace-output gets flushed automatically at the + * end of each line. This is useful in case the program dies. + */ + if (MyFP != NULL) { +#if HAVE_SETVBUF /* ANSI */ + (void) setvbuf(MyFP, (char *) 0, _IOLBF, (size_t) 0); +#elif HAVE_SETBUF /* POSIX */ + (void) setbuffer(MyFP, (char *) 0); +#endif + } + _tracef("TRACING NCURSES version %s.%d (tracelevel=%#x)", + NCURSES_VERSION, + NCURSES_VERSION_PATCH, + tracelevel); + +#define SPECIAL_MASK(mask) \ + if ((tracelevel & mask) == mask) \ + _tracef("- %s (%u)", #mask, mask) + + for (bit = 0; bit < TRACE_SHIFT; ++bit) { + unsigned mask = (1U << bit) & tracelevel; + if ((mask & trace_names[bit].mask) != 0) { + _tracef("- %s (%u)", trace_names[bit].name, mask); + } + } + SPECIAL_MASK(TRACE_MAXIMUM); + else + SPECIAL_MASK(TRACE_ORDINARY); + + if (tracelevel > TRACE_MAXIMUM) { + _tracef("- DEBUG_LEVEL(%u)", tracelevel >> TRACE_SHIFT); + } + } else if (tracelevel == 0) { + if (MyFP != NULL) { + MyFD = dup(MyFD); /* allow reopen of same file */ + fclose(MyFP); + MyFP = NULL; + } + Locked(_nc_tracing = tracelevel); + } else if (_nc_tracing != tracelevel) { + Locked(_nc_tracing = tracelevel); + _tracef("tracelevel=%#x", tracelevel); + } +#else + (void) tracelevel; + result = 0; +#endif + return result; +} + +#if defined(TRACE) +NCURSES_EXPORT(void) +trace(const unsigned int tracelevel) +{ + curses_trace(tracelevel); +} + +static void +_nc_va_tracef(const char *fmt, va_list ap) +{ + static const char Called[] = T_CALLED(""); + static const char Return[] = T_RETURN(""); + + bool before = FALSE; + bool after = FALSE; + unsigned doit = _nc_tracing; + int save_err = errno; + FILE *fp = MyFP; + +#ifdef TRACE + /* verbose-trace in the command-line utilities relies on this */ + if (fp == NULL && !MyInit && _nc_tracing >= DEBUG_LEVEL(1)) + fp = stderr; +#endif + + if (strlen(fmt) >= sizeof(Called) - 1) { + if (!strncmp(fmt, Called, sizeof(Called) - 1)) { + before = TRUE; + MyLevel++; + } else if (!strncmp(fmt, Return, sizeof(Return) - 1)) { + after = TRUE; + } + if (before || after) { + if ((MyLevel <= 1) + || (doit & TRACE_ICALLS) != 0) + doit &= (TRACE_CALLS | TRACE_CCALLS); + else + doit = 0; + } + } + + if (doit != 0 && fp != NULL) { +#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(fp, "%#" PRIxPTR ":", +#ifdef _NC_WINDOWS_NATIVE + CASTxPTR(pthread_self().p) +#else + CASTxPTR(pthread_self()) +#endif + ); +#endif + if (before || after) { + int n; + for (n = 1; n < MyLevel; n++) + fputs("+ ", fp); + } + vfprintf(fp, fmt, ap); + fputc('\n', fp); + fflush(fp); + } + + if (after && MyLevel) + MyLevel--; + + 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(bool) +_nc_retrace_bool(bool code) +{ + T((T_RETURN("%s"), code ? "TRUE" : "FALSE")); + return code; +} + +/* Trace 'char' return-values */ +NCURSES_EXPORT(char) +_nc_retrace_char(int code) +{ + T((T_RETURN("%c"), code)); + return (char) code; +} + +/* Trace 'int' return-values */ +NCURSES_EXPORT(int) +_nc_retrace_int(int code) +{ + T((T_RETURN("%d"), 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) +{ + T((T_RETURN("%s"), _nc_visbuf(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"), (void *) code)); + return code; +} + +/* Trace 'WINDOW *' return-values */ +NCURSES_EXPORT(WINDOW *) +_nc_retrace_win(WINDOW *code) +{ + T((T_RETURN("%p"), (void *) code)); + return code; +} + +NCURSES_EXPORT(char *) +_nc_fmt_funcptr(char *target, const char *source, size_t size) +{ + size_t n; + char *dst = target; + bool leading = TRUE; + + union { + int value; + char bytes[sizeof(int)]; + } byteorder; + + byteorder.value = 0x1234; + + *dst++ = '0'; + *dst++ = 'x'; + + for (n = 0; n < size; ++n) { + unsigned ch = ((byteorder.bytes[0] == 0x34) + ? UChar(source[size - n - 1]) + : UChar(source[n])); + if (ch != 0 || (n + 1) >= size) + leading = FALSE; + if (!leading) { + _nc_SPRINTF(dst, _nc_SLIMIT(TR_FUNC_LEN - (size_t) (dst - target)) + "%02x", ch & 0xff); + dst += 2; + } + } + *dst = '\0'; + return target; +} + +#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 (!MyNested++) { + 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() */ + MyNested = 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 (--(MyNested) == 0) { + _nc_unlock_global(tracef); + } +} +#endif /* USE_REENTRANT */ + +#endif /* TRACE */ diff --git a/ncurses/ncurses/trace/lib_traceatr.c b/ncurses/ncurses/trace/lib_traceatr.c new file mode 100644 index 0000000000..8cd6352ae7 --- /dev/null +++ b/ncurses/ncurses/trace/lib_traceatr.c @@ -0,0 +1,426 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2017,2018 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1996-on * + * and: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Juergen Pfeifer * + ****************************************************************************/ + +/* + * lib_traceatr.c - Tracing/Debugging routines (attributes) + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_traceatr.c,v 1.101 2025/11/16 16:08:54 tom Exp $") + +#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name)) + +#define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size) +#define COLOR_BUF_SIZE(num) (sizeof(my_buffer[num])) + +#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 (isDefaultColor(c)) + _nc_STRCPY(my_buffer[my_select], "default", + COLOR_BUF_SIZE(my_select)); + else + _nc_SPRINTF(my_buffer[my_select], + _nc_SLIMIT(COLOR_BUF_SIZE(my_select)) + "color%d", c); + } + return my_buffer[my_select]; +} + +#undef my_buffer +#undef my_select +#endif /* !USE_TERMLIB */ + +NCURSES_EXPORT(char *) +_traceattr2(int bufnum, chtype newmode) +{ +#define DATA(name) { name, { #name } } + static const struct { + unsigned int val; + const char name[14]; + } names[] = + { + DATA(A_STANDOUT), + DATA(A_UNDERLINE), + DATA(A_REVERSE), + DATA(A_BLINK), + DATA(A_DIM), + DATA(A_BOLD), + DATA(A_ALTCHARSET), + DATA(A_INVIS), + DATA(A_PROTECT), + DATA(A_CHARTEXT), + DATA(A_NORMAL), + DATA(A_COLOR), +#if USE_ITALIC + DATA(A_ITALIC), +#endif + } +#ifndef USE_TERMLIB + , + colors[] = + { + DATA(COLOR_BLACK), + DATA(COLOR_RED), + DATA(COLOR_GREEN), + DATA(COLOR_YELLOW), + DATA(COLOR_BLUE), + DATA(COLOR_MAGENTA), + DATA(COLOR_CYAN), + DATA(COLOR_WHITE), + } +#endif /* !USE_TERMLIB */ + ; +#undef DATA + char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); + + if (result != NULL) { + size_t n; + unsigned save_nc_tracing = _nc_tracing; + + _nc_tracing = 0; + + _nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum)); + + for (n = 0; n < SIZEOF(names); n++) { + + if ((newmode & names[n].val) != 0) { + if (result[1] != '\0') + (void) _nc_trace_bufcat(bufnum, "|"); + result = _nc_trace_bufcat(bufnum, names[n].name); + + if (names[n].val == A_COLOR) { + char temp[80]; + short pairnum = (short) PairNumber(newmode); +#ifdef USE_TERMLIB + /* pair_content lives in libncurses */ + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "{%d}", pairnum); +#else + NCURSES_COLOR_T fg, bg; + + if (pair_content(pairnum, &fg, &bg) == OK) { + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "{%d = {%s, %s}}", + pairnum, + COLOR_OF(fg), + COLOR_OF(bg)); + } else { + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "{%d}", pairnum); + } +#endif + result = _nc_trace_bufcat(bufnum, temp); + } + } + } + if (ChAttrOf(newmode) == A_NORMAL) { + if (result != NULL && result[1] != '\0') + (void) _nc_trace_bufcat(bufnum, "|"); + (void) _nc_trace_bufcat(bufnum, "A_NORMAL"); + } + + _nc_tracing = save_nc_tracing; + result = _nc_trace_bufcat(bufnum, r_brace); + } + return result; +} + +NCURSES_EXPORT(char *) +_traceattr(attr_t newmode) +{ + return _traceattr2(0, newmode); +} + +/* Trace 'int' return-values */ +NCURSES_EXPORT(int) +_nc_retrace_int_attr_t(attr_t code) +{ + T((T_RETURN("%s"), _traceattr(code))); + return (int) code; +} + +/* Trace 'attr_t' return-values */ +NCURSES_EXPORT(attr_t) +_nc_retrace_attr_t(attr_t code) +{ + T((T_RETURN("%s"), _traceattr(code))); + return code; +} + +const char * +_nc_altcharset_name(attr_t attr, chtype ch) +{ +#define DATA(code, name) { code, { #name } } + typedef struct { + unsigned int val; + const char name[13]; + } ALT_NAMES; +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif + static const ALT_NAMES names[] = + { + DATA('l', ACS_ULCORNER), /* upper left corner */ + DATA('m', ACS_LLCORNER), /* lower left corner */ + DATA('k', ACS_URCORNER), /* upper right corner */ + DATA('j', ACS_LRCORNER), /* lower right corner */ + DATA('t', ACS_LTEE), /* tee pointing right */ + DATA('u', ACS_RTEE), /* tee pointing left */ + DATA('v', ACS_BTEE), /* tee pointing up */ + DATA('w', ACS_TTEE), /* tee pointing down */ + DATA('q', ACS_HLINE), /* horizontal line */ + DATA('x', ACS_VLINE), /* vertical line */ + DATA('n', ACS_PLUS), /* large plus or crossover */ + DATA('o', ACS_S1), /* scan line 1 */ + DATA('s', ACS_S9), /* scan line 9 */ + DATA('`', ACS_DIAMOND), /* diamond */ + DATA('a', ACS_CKBOARD), /* checker board (stipple) */ + DATA('f', ACS_DEGREE), /* degree symbol */ + DATA('g', ACS_PLMINUS), /* plus/minus */ + DATA('~', ACS_BULLET), /* bullet */ + DATA(',', ACS_LARROW), /* arrow pointing left */ + DATA('+', ACS_RARROW), /* arrow pointing right */ + DATA('.', ACS_DARROW), /* arrow pointing down */ + DATA('-', ACS_UARROW), /* arrow pointing up */ + DATA('h', ACS_BOARD), /* board of squares */ + DATA('i', ACS_LANTERN), /* lantern symbol */ + DATA('0', ACS_BLOCK), /* solid square block */ + DATA('p', ACS_S3), /* scan line 3 */ + DATA('r', ACS_S7), /* scan line 7 */ + DATA('y', ACS_LEQUAL), /* less/equal */ + DATA('z', ACS_GEQUAL), /* greater/equal */ + DATA('{', ACS_PI), /* Pi */ + DATA('|', ACS_NEQUAL), /* not equal */ + DATA('}', ACS_STERLING), /* UK pound sign */ + }; +#undef DATA + + const char *result = NULL; + +#if NCURSES_SP_FUNCS + (void) sp; +#endif + if (SP_PARM != NULL && (attr & A_ALTCHARSET) && (acs_chars != NULL)) { + char *cp; + const char *found = NULL; + + for (cp = acs_chars; cp[0] && cp[1]; cp += 2) { + if (ChCharOf(UChar(cp[1])) == ChCharOf(ch)) { + found = cp; + /* don't exit from loop - there may be redefinitions */ + } + } + + if (found != NULL) { + size_t n; + + ch = ChCharOf(UChar(*found)); + for (n = 0; n < SIZEOF(names); ++n) { + if (names[n].val == ch) { + result = names[n].name; + break; + } + } + } + } + return result; +} + +NCURSES_EXPORT(char *) +_tracechtype2(int bufnum, chtype ch) +{ + char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); + + if (result != NULL) { + const char *found; + attr_t attr = ChAttrOf(ch); + + _nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum)); + if ((found = _nc_altcharset_name(attr, ch)) != NULL) { + (void) _nc_trace_bufcat(bufnum, found); + attr &= ~A_ALTCHARSET; + } else + (void) _nc_trace_bufcat(bufnum, + _nc_tracechar(CURRENT_SCREEN, + (int) ChCharOf(ch))); + + 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 *) +_tracechtype(chtype ch) +{ + return _tracechtype2(0, ch); +} + +/* Trace 'chtype' return-values */ +NCURSES_EXPORT(chtype) +_nc_retrace_chtype(chtype code) +{ + T((T_RETURN("%s"), _tracechtype(code))); + return code; +} + +#if USE_WIDEC_SUPPORT +NCURSES_EXPORT(char *) +_tracecchar_t2(int bufnum, const cchar_t *ch) +{ + char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); + + if (result != NULL) { + _nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum)); + if (ch != NULL) { + const char *found; + attr_t attr = AttrOfD(ch); + + if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != NULL) { + (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; + int assume_unicode = _nc_unicode_locale()? 128 : 255; + + (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') { + if (PUTC_i == 0) + (void) _nc_trace_bufcat(bufnum, "\\000"); + break; + } + PUTC_INIT; + PUTC_n = (int) 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(CURRENT_SCREEN, + UChar(ch->chars[PUTC_i]))); + } + break; + } else if ((int) ch->chars[PUTC_i] > assume_unicode) { + char temp[80]; + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "{%d:\\u%04lx}", + _nc_wacs_width(ch->chars[PUTC_i]), + (unsigned long) ch->chars[PUTC_i]); + (void) _nc_trace_bufcat(bufnum, temp); + attr &= ~A_CHARTEXT; /* ignore WidecExt(ch) */ + } else if (PUTC_n > 1 || !is8bits(ch->chars[PUTC_i])) { + for (n = 0; n < PUTC_n; n++) { + if (n) + (void) _nc_trace_bufcat(bufnum, ", "); + (void) _nc_trace_bufcat(bufnum, + _nc_tracechar(CURRENT_SCREEN, + UChar(PUTC_buf[n]))); + } + } else { + char temp[2]; + temp[0] = (char) ch->chars[PUTC_i]; + temp[1] = 0; + (void) _nc_trace_bufcat(bufnum, temp); + } + } + (void) _nc_trace_bufcat(bufnum, " }"); + } + if (attr != A_NORMAL) { + (void) _nc_trace_bufcat(bufnum, " | "); + (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); + } +#if NCURSES_EXT_COLORS + /* + * Just in case the extended color is different from the chtype + * value, trace both. + */ + if (ch->ext_color != PairNumber(attr)) { + char temp[80]; + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + " X_COLOR{%d:%d}", ch->ext_color, PairNumber(attr)); + (void) _nc_trace_bufcat(bufnum, temp); + } +#endif + } + + 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/ncurses/ncurses/trace/lib_tracebits.c b/ncurses/ncurses/trace/lib_tracebits.c new file mode 100644 index 0000000000..48babc7132 --- /dev/null +++ b/ncurses/ncurses/trace/lib_tracebits.c @@ -0,0 +1,302 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2012,2015 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: lib_tracebits.c,v 1.37 2025/12/23 09:23:38 tom Exp $") + +#if HAVE_SYS_TERMIO_H +#include /* needed for ISC */ +#endif + +/* may be undefined if we're using termio.h */ +#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 + +#if defined(USE_WIN32CON_DRIVER) +#define BITNAMELEN 36 +#else +#define BITNAMELEN 8 +#endif + +typedef struct { + unsigned long val; + const char name[BITNAMELEN]; +} BITNAMES; + +#define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size) + +static void +lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned long val) +{ + const BITNAMES *sp; + + _nc_STRCAT(buf, label, TRACE_BUF_SIZE(0)); + _nc_STRCAT(buf, ": {", TRACE_BUF_SIZE(0)); + for (sp = table; sp->name[0]; sp++) + if (sp->val != 0 + && (val & sp->val) == sp->val) { + _nc_STRCAT(buf, sp->name, TRACE_BUF_SIZE(0)); + _nc_STRCAT(buf, ", ", TRACE_BUF_SIZE(0)); + } + if (buf[strlen(buf) - 2] == ',') + buf[strlen(buf) - 2] = '\0'; + _nc_STRCAT(buf, "} ", TRACE_BUF_SIZE(0)); +} + +NCURSES_EXPORT(char *) +_nc_trace_ttymode(const TTY * tty) +/* describe the state of the terminal control bits exactly */ +{ + char *buf; + +#ifdef TERMIOS +#define DATA(name) { name, { #name } } +#define DATA2(name,name2) { name, { #name2 } } +#define DATAX() { 0, { "" } } + static const BITNAMES iflags[] = + { + DATA(BRKINT), + DATA(IGNBRK), + DATA(IGNPAR), + DATA(PARMRK), + DATA(INPCK), + DATA(ISTRIP), + DATA(INLCR), + DATA(IGNCR), + DATA(ICRNL), + DATA(IXON), + DATA(IXOFF), + DATAX() +#define ALLIN (BRKINT|IGNBRK|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF) + }, oflags[] = + { + DATA(OPOST), + DATA2(OFLAGS_TABS, XTABS), + DATA(ONLCR), + DATA(OCRNL), + DATA(ONOCR), + DATA(ONLRET), + DATAX() +#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET|OFLAGS_TABS) + }, cflags[] = + { + DATA(CLOCAL), + DATA(CREAD), + DATA(CSTOPB), +#if !defined(CS5) || !defined(CS8) + DATA(CSIZE), +#endif + DATA(HUPCL), + DATA(PARENB), + DATA2(PARODD | PARENB, PARODD), + DATAX() +#define ALLCTRL (CLOCAL|CREAD|CSIZE|CSTOPB|HUPCL|PARENB|PARODD) + }, lflags[] = + { + DATA(ECHO), + DATA2(ECHOE | ECHO, ECHOE), + DATA2(ECHOK | ECHO, ECHOK), + DATA(ECHONL), + DATA(ICANON), + DATA(ISIG), + DATA(NOFLSH), + DATA(TOSTOP), + DATA(IEXTEN), + DATAX() +#define ALLLOCAL (ECHO|ECHONL|ICANON|ISIG|NOFLSH|TOSTOP|IEXTEN) + }; + + buf = _nc_trace_buf(0, + 8 + sizeof(iflags) + + 8 + sizeof(oflags) + + 8 + sizeof(cflags) + + 8 + sizeof(lflags) + + 8); + if (buf != NULL) { + + if (tty->c_iflag & ALLIN) + lookup_bits(buf, iflags, "iflags", tty->c_iflag); + + if (tty->c_oflag & ALLOUT) + lookup_bits(buf, oflags, "oflags", tty->c_oflag); + + if (tty->c_cflag & ALLCTRL) + lookup_bits(buf, cflags, "cflags", tty->c_cflag); + +#if defined(CS5) && defined(CS8) + { + static const struct { + int value; + const char name[5]; + } csizes[] = { +#define CS_DATA(name) { name, { #name " " } } + CS_DATA(CS5), +#ifdef CS6 + CS_DATA(CS6), +#endif +#ifdef CS7 + CS_DATA(CS7), +#endif + CS_DATA(CS8), + }; + const char *result = "CSIZE? "; + int value = (int) (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; + } + } + } + _nc_STRCAT(buf, result, TRACE_BUF_SIZE(0)); + } +#endif + + if (tty->c_lflag & ALLLOCAL) + lookup_bits(buf, lflags, "lflags", tty->c_lflag); + } +#elif defined(USE_WIN32CON_DRIVER) +#define DATA(name) { name, { #name } } + static const BITNAMES dwFlagsOut[] = + { + DATA(ENABLE_PROCESSED_OUTPUT), + DATA(ENABLE_WRAP_AT_EOL_OUTPUT), + DATA(ENABLE_VIRTUAL_TERMINAL_PROCESSING), + DATA(DISABLE_NEWLINE_AUTO_RETURN), + DATA(ENABLE_LVB_GRID_WORLDWIDE) + }; + static const BITNAMES dwFlagsIn[] = + { + DATA(ENABLE_PROCESSED_INPUT), + DATA(ENABLE_LINE_INPUT), + DATA(ENABLE_ECHO_INPUT), + DATA(ENABLE_MOUSE_INPUT), + DATA(ENABLE_INSERT_MODE), + DATA(ENABLE_QUICK_EDIT_MODE), + DATA(ENABLE_EXTENDED_FLAGS), + DATA(ENABLE_AUTO_POSITION), + DATA(ENABLE_VIRTUAL_TERMINAL_INPUT) + }; + + buf = _nc_trace_buf(0, + 8 + sizeof(dwFlagsOut) + + 8 + sizeof(dwFlagsIn)); + if (buf != NULL) { + lookup_bits(buf, dwFlagsIn, "dwIn", tty->dwFlagIn); + lookup_bits(buf, dwFlagsOut, "dwOut", tty->dwFlagOut); + } +#else + /* reference: ttcompat(4M) on SunOS 4.1 */ +#ifndef EVENP +#define EVENP 0 +#endif +#ifndef LCASE +#define LCASE 0 +#endif +#ifndef LLITOUT +#define LLITOUT 0 +#endif +#ifndef ODDP +#define ODDP 0 +#endif +#ifndef TANDEM +#define TANDEM 0 +#endif + + static const BITNAMES cflags[] = + { + DATA(CBREAK), + DATA(CRMOD), + DATA(ECHO), + DATA(EVENP), + DATA(LCASE), + DATA(LLITOUT), + DATA(ODDP), + DATA(RAW), + DATA(TANDEM), + DATA(XTABS), + DATAX() +#define ALLCTRL (CBREAK|CRMOD|ECHO|EVENP|LCASE|LLITOUT|ODDP|RAW|TANDEM|XTABS) + }; + + buf = _nc_trace_buf(0, + 8 + sizeof(cflags)); + if (buf != NULL) { + 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 +EMPTY_MODULE(_nc_empty_lib_tracebits) +#endif /* TRACE */ diff --git a/ncurses/ncurses/trace/lib_tracechr.c b/ncurses/ncurses/trace/lib_tracechr.c new file mode 100644 index 0000000000..d886ef5cb6 --- /dev/null +++ b/ncurses/ncurses/trace/lib_tracechr.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2009,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * lib_tracechr.c - Tracing/Debugging routines + */ +#include + +#include + +MODULE_ID("$Id: lib_tracechr.c,v 1.26 2024/12/07 21:02:00 tom Exp $") + +#ifdef TRACE + +#define MyBufSize sizeof(_nc_globals.tracechr_buf) + +NCURSES_EXPORT(char *) +_nc_tracechar(SCREEN *sp, int ch) +{ + NCURSES_CONST char *name; + char *MyBuffer = ((sp != NULL) + ? sp->tracechr_buf + : _nc_globals.tracechr_buf); + + if ((ch > KEY_MIN && !_nc_unicode_locale()) || ch < 0) { + name = safe_keyname(SP_PARM, ch); + if (name == NULL || *name == '\0') + name = "NULL"; + _nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize) + "'%.30s' = \\x%02x", name, UChar(ch)); + } else if (!is8bits(ch) + || (_nc_unicode_locale() && !is7bits(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. + */ + _nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize) + "\\x%02x", ch); + } else { + name = safe_unctrl(SP_PARM, (chtype) ch); + if (name == NULL || *name == 0) + name = "null"; /* shouldn't happen */ + _nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize) + "'%.30s' = \\x%02x", name, ch); + } + return (MyBuffer); +} + +NCURSES_EXPORT(char *) +_tracechar(int ch) +{ + return _nc_tracechar(CURRENT_SCREEN, ch); +} +#else +EMPTY_MODULE(_nc_lib_tracechr) +#endif diff --git a/ncurses/ncurses/trace/lib_tracedmp.c b/ncurses/ncurses/trace/lib_tracedmp.c new file mode 100644 index 0000000000..650260dca0 --- /dev/null +++ b/ncurses/ncurses/trace/lib_tracedmp.c @@ -0,0 +1,190 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2012,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * lib_tracedmp.c - Tracing/Debugging routines + */ + +#include +#include + +MODULE_ID("$Id: lib_tracedmp.c,v 1.38 2024/12/07 20:06:49 tom 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) { + n = 0; + 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 = (unsigned) (2 * (width + 1)); + my_buffer = typeRealloc(char, my_length, my_buffer); + } + if (my_buffer == NULL) + return; + + for (n = 0; n <= win->_maxy; ++n) { + char *ep = my_buffer; + bool havecolors; + + /* + * 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 = (chtype) 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] = '\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 (GetPair(win->_line[n].text[j]) != 0) { + havecolors = TRUE; + break; + } + if (havecolors) { + 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) { + const char *hex = " 123456789ABCDEF"; + attr_t mask = (attr_t) (0xf << ((i + 4) * 4)); + bool haveattrs = FALSE; + + for (j = 0; j < width; ++j) + if (AttrOf(win->_line[n].text[j]) & mask) { + haveattrs = TRUE; + break; + } + if (haveattrs) { + 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 = NULL; + my_length = 0; +#endif +} + +#else +EMPTY_MODULE(_nc_lib_tracedmp) +#endif /* TRACE */ diff --git a/ncurses/ncurses/trace/lib_tracemse.c b/ncurses/ncurses/trace/lib_tracemse.c new file mode 100644 index 0000000000..f9ed47a4f7 --- /dev/null +++ b/ncurses/ncurses/trace/lib_tracemse.c @@ -0,0 +1,161 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2012,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* + * lib_tracemse.c - Tracing/Debugging routines (mouse events) + */ + +#include + +MODULE_ID("$Id: lib_tracemse.c,v 1.24 2024/12/07 20:06:49 tom Exp $") + +#ifdef TRACE + +#define my_buffer sp->tracemse_buf + +NCURSES_EXPORT(char *) +_nc_trace_mmask_t(SCREEN *sp, mmask_t code) +{ +#define SHOW(m, s) \ + if ((code & m) == m) { \ + size_t n = strlen(my_buffer); \ + if (n && (my_buffer[n-1] != '{')) \ + _nc_STRCAT(my_buffer, ", ", sizeof(my_buffer)); \ + _nc_STRCAT(my_buffer, s, sizeof(my_buffer)); \ + } + + 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 (my_buffer[strlen(my_buffer) - 1] == ' ') + my_buffer[strlen(my_buffer) - 2] = '\0'; + + return (my_buffer); +} + +NCURSES_EXPORT(char *) +_nc_tracemouse(SCREEN *sp, MEVENT const *ep) +{ + char *result = NULL; + + if (sp != NULL) { + _nc_SPRINTF(my_buffer, _nc_SLIMIT(sizeof(my_buffer)) + TRACEMSE_FMT, + ep->id, + ep->x, + ep->y, + ep->z, + (unsigned long) ep->bstate); + + (void) _nc_trace_mmask_t(sp, ep->bstate); + _nc_STRCAT(my_buffer, "}", sizeof(my_buffer)); + result = (my_buffer); + } + return result; +} + +NCURSES_EXPORT(mmask_t) +_nc_retrace_mmask_t(SCREEN *sp, mmask_t code) +{ + if (sp != NULL) { + *my_buffer = '\0'; + T((T_RETURN("{%s}"), _nc_trace_mmask_t(sp, code))); + } else { + T((T_RETURN("{?}"))); + } + return code; +} + +NCURSES_EXPORT(char *) +_tracemouse(MEVENT const *ep) +{ + return _nc_tracemouse(CURRENT_SCREEN, ep); +} + +#else /* !TRACE */ +EMPTY_MODULE(_nc_lib_tracemouse) +#endif diff --git a/ncurses/ncurses/trace/trace_buf.c b/ncurses/ncurses/trace/trace_buf.c new file mode 100644 index 0000000000..9e8da5116f --- /dev/null +++ b/ncurses/ncurses/trace/trace_buf.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 1998-2011,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + ****************************************************************************/ +/* + * trace_buf.c - Tracing/Debugging buffers (attributes) + */ + +#include + +MODULE_ID("$Id: trace_buf.c,v 1.23 2024/12/07 21:24:18 tom Exp $") + +#ifdef TRACE + +#define MyList _nc_globals.tracebuf_ptr +#define MySize _nc_globals.tracebuf_used + +static char * +_nc_trace_alloc(int bufnum, size_t want) +{ + char *result = NULL; + + if (bufnum >= 0) { + if ((size_t) (bufnum + 1) > MySize) { + size_t need = (size_t) (bufnum + 1) * 2; + if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != NULL) { + while (need > MySize) + MyList[MySize++].text = NULL; + } + } + + if (MyList != NULL) { + if (MyList[bufnum].text == NULL + || want > MyList[bufnum].size) { + MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text); + if (MyList[bufnum].text != NULL) + MyList[bufnum].size = want; + } + result = MyList[bufnum].text; + } + } +#if NO_LEAKS + else { + if (MySize) { + if (MyList) { + while (MySize--) { + if (MyList[MySize].text != NULL) { + free(MyList[MySize].text); + } + } + free(MyList); + MyList = NULL; + } + MySize = 0; + } + } +#endif + return result; +} + +/* + * (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 != NULL) + *result = '\0'; + return result; +} + +/* + * Append a new string to an existing buffer. + */ +NCURSES_EXPORT(char *) +_nc_trace_bufcat(int bufnum, const char *value) +{ + char *buffer; + + if (value == NULL) + value = ""; + buffer = _nc_trace_alloc(bufnum, (size_t) 0); + if (buffer != NULL) { + size_t have = strlen(buffer); + size_t need = strlen(value) + have; + + buffer = _nc_trace_alloc(bufnum, 1 + need); + if (buffer != NULL) + _nc_STRCPY(buffer + have, value, need); + + } + return buffer; +} +#else +EMPTY_MODULE(_nc_empty_trace_buf) +#endif /* TRACE */ diff --git a/ncurses/ncurses/trace/trace_tries.c b/ncurses/ncurses/trace/trace_tries.c new file mode 100644 index 0000000000..82953bbb0b --- /dev/null +++ b/ncurses/ncurses/trace/trace_tries.c @@ -0,0 +1,85 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1999-2011,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999 * + ****************************************************************************/ +/* + * trace_tries.c - Tracing/Debugging buffers (keycode tries-trees) + */ + +#include + +MODULE_ID("$Id: trace_tries.c,v 1.19 2024/12/07 21:24:18 tom Exp $") + +#ifdef TRACE +#define my_buffer _nc_globals.tracetry_buf +#define my_length _nc_globals.tracetry_used + +static void +recur_tries(TRIES * tree, unsigned level) +{ + if (level > my_length) { + my_length = (level + 1) * 4; + my_buffer = (unsigned char *) _nc_doalloc(my_buffer, my_length); + } + + if (my_buffer != NULL) { + while (tree != NULL) { + 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 *) my_buffer), keyname(tree->value)); + } + if (tree->child) + recur_tries(tree->child, level + 1); + tree = tree->sibling; + } + } +} + +NCURSES_EXPORT(void) +_nc_trace_tries(TRIES * tree) +{ + if ((my_buffer = typeMalloc(unsigned char, my_length = 80)) != NULL) { + _tracef("BEGIN tries %p", (void *) tree); + recur_tries(tree, 0); + _tracef(". . . tries %p", (void *) tree); + free(my_buffer); + } +} + +#else +EMPTY_MODULE(_nc_empty_trace_tries) +#endif diff --git a/ncurses/ncurses/trace/trace_xnames.c b/ncurses/ncurses/trace/trace_xnames.c new file mode 100644 index 0000000000..18707bdca7 --- /dev/null +++ b/ncurses/ncurses/trace/trace_xnames.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * Copyright 2020 Thomas E. Dickey * + * Copyright 1999-2010,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1999 * + ****************************************************************************/ +/* + * trace_xnames.c - Tracing/Debugging buffers (TERMTYPE extended names) + */ + +#include + +MODULE_ID("$Id: trace_xnames.c,v 1.8 2020/02/02 23:34:34 tom Exp $") + +NCURSES_EXPORT(void) +_nc_trace_xnames(TERMTYPE *tp GCC_UNUSED) +{ +#ifdef TRACE +#if NCURSES_XNAMES + int limit = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings; + + if (limit) { + int n; + int begin_num = tp->ext_Booleans; + int begin_str = tp->ext_Booleans + tp->ext_Numbers; + + _tracef("extended names (%s) %d = %d+%d+%d of %d+%d+%d", + tp->term_names, + limit, + tp->ext_Booleans, tp->ext_Numbers, tp->ext_Strings, + tp->num_Booleans, tp->num_Numbers, tp->num_Strings); + + for (n = 0; n < limit; n++) { + int m; + + if ((m = n - begin_str) >= 0) { + _tracef("[%d] %s = %s", n, + tp->ext_Names[n], + _nc_visbuf(tp->Strings[tp->num_Strings + m - tp->ext_Strings])); + } else if ((m = n - begin_num) >= 0) { + _tracef("[%d] %s = %d (num)", n, + tp->ext_Names[n], + tp->Numbers[tp->num_Numbers + m - tp->ext_Numbers]); + } else { + _tracef("[%d] %s = %d (bool)", n, + tp->ext_Names[n], + tp->Booleans[tp->num_Booleans + n - tp->ext_Booleans]); + } + } + } +#endif +#endif +} diff --git a/ncurses/ncurses/trace/varargs.c b/ncurses/ncurses/trace/varargs.c new file mode 100644 index 0000000000..9e8c9ac9a8 --- /dev/null +++ b/ncurses/ncurses/trace/varargs.c @@ -0,0 +1,193 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 2001-2008,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +#include + +MODULE_ID("$Id: varargs.c,v 1.16 2025/02/15 15:22:14 tom Exp $") + +#ifdef TRACE + +#define MAX_PARMS 10 + +typedef enum { + atUnknown = 0, atInteger, atFloat, atPoint, atString +} ARGTYPE; + +#define VA_INT(type) ival = (int) 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) +{ + char buffer[BUFSIZ]; + const char *value; + int n; + + if (fmt == NULL || *fmt == '\0') + return NULL; + if (MyLength == 0) + MyBuffer = typeMalloc(char, MyLength = BUFSIZ); + if (MyBuffer == NULL) + return NULL; + *MyBuffer = '\0'; + + while (*fmt != '\0') { + if (*fmt == '%') { + const char *pval = NULL; /* avoid const-cast */ + const char *sval = ""; + double fval = 0.0; + int done = FALSE; + int ival = 0; + int type = 0; + ARGTYPE param[MAX_PARMS]; + int params = 0; + ARGTYPE used = atUnknown; + + while (*++fmt != '\0' && !done) { + + if (*fmt == '*') { + VA_INT(int); + if (params < MAX_PARMS) + param[params++] = 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 && params < MAX_PARMS) { + param[params++] = used; + for (n = 0; n < params; ++n) { + used = param[n]; + value = buffer; + switch (used) { + case atInteger: + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) + "%d", ival); + break; + case atFloat: + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) + "%f", fval); + break; + case atPoint: + _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) + "%p", pval); + break; + case atString: + value = _nc_visbuf2(1, sval); + break; + case atUnknown: + default: + _nc_STRCPY(buffer, "?", sizeof(buffer)); + break; + } + MyLength += strlen(value) + 2; + MyBuffer = typeRealloc(char, MyLength, MyBuffer); + if (MyBuffer != NULL) { + _nc_SPRINTF(MyBuffer + strlen(MyBuffer), + _nc_SLIMIT(MyLength - strlen(MyBuffer)) + ", %s", value); + } + } + } + used = atUnknown; + } + } else { + fmt++; + } + } + + return (MyBuffer ? MyBuffer : NULL); +} +#else +EMPTY_MODULE(_nc_varargs) +#endif diff --git a/ncurses/ncurses/trace/visbuf.c b/ncurses/ncurses/trace/visbuf.c new file mode 100644 index 0000000000..1e1208a4ef --- /dev/null +++ b/ncurses/ncurses/trace/visbuf.c @@ -0,0 +1,383 @@ +/**************************************************************************** + * Copyright 2019-2023,2024 Thomas E. Dickey * + * Copyright 2001-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * visbuf.c - Tracing/Debugging support routines + */ + +#define NEED_NCURSES_CH_T +#include + +#include +#include + +MODULE_ID("$Id: visbuf.c,v 1.56 2024/12/07 21:12:53 tom Exp $") + +#define NUM_VISBUFS 4 + +#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4) +#define WideLen(len) (size_t) (((size_t)(len) + 1) * 4 * (size_t) 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 + +#if USE_STRING_HACKS && HAVE_SNPRINTF +#define VisChar(tp, chr, limit) _nc_vischar(tp, chr, limit) +#define LIMIT_ARG ,size_t limit +#else +#define VisChar(tp, chr, limit) _nc_vischar(tp, chr) +#define LIMIT_ARG /* nothing */ +#endif + +static char * +_nc_vischar(char *tp, unsigned c LIMIT_ARG) +{ + if (tp == NULL) { + return NULL; + } else if (c == '"' || c == '\\') { + *tp++ = '\\'; + *tp++ = (char) c; + } else if (is7bits(UChar(c)) && (isgraph(UChar(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 == '\t') { + *tp++ = '\\'; + *tp++ = 't'; + } 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 { + _nc_SPRINTF(tp, _nc_SLIMIT(limit) + "\\%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 = NULL; + char *tp; + int count; + + if (buf == NULL) + return ("(null)"); + if (buf == CANCELLED_STRING) + return ("(cancelled)"); + + if (len < 0) + len = (int) strlen(buf); + + count = len; +#ifdef TRACE + vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len)); +#else + { + static char *mybuf[NUM_VISBUFS]; + int c; + + if (bufnum < 0) { + for (c = 0; c < NUM_VISBUFS; ++c) { + FreeAndNull(mybuf[c]); + } + tp = 0; + } else { + mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]); + vbuf = tp = mybuf[bufnum]; + } + } +#endif + if (tp != NULL) { + int c; + + *tp++ = D_QUOTE; + while ((--count >= 0) && (c = *buf++) != '\0') { + tp = VisChar(tp, UChar(c), NormalLen(len)); + } + *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; + int count; + + if (buf == NULL) + return ("(null)"); + + if (len < 0) + len = (int) wcslen(buf); + + count = len; +#ifdef TRACE + vbuf = tp = _nc_trace_buf(bufnum, WideLen(len)); +#else + { + static char *mybuf[NUM_VISBUFS]; + mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]); + vbuf = tp = mybuf[bufnum]; + } +#endif + if (tp != NULL) { + wchar_t c; + + *tp++ = D_QUOTE; + while ((--count >= 0) && (c = *buf++) != '\0') { + char temp[CCHARW_MAX + 80]; + int j = wctomb(temp, c), k; + if (j <= 0) { + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "\\u%08X", (unsigned) c); + j = (int) strlen(temp); + } + for (k = 0; k < j; ++k) { + tp = VisChar(tp, UChar(temp[k]), WideLen(len)); + } + } + *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) { + ; /* empty */ + } + if (mylen < ++n) { + mylen = n + 80; + if (mybuf != NULL) + mybuf = typeRealloc(wchar_t, mylen, mybuf); + else + mybuf = typeMalloc(wchar_t, mylen); + } + if (mybuf != NULL) { + for (n = 0; buf[n] != 0; ++n) { + mybuf[n] = (wchar_t) buf[n]; + } + mybuf[n] = L'\0'; + } + + 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, (size_t) BUFSIZ); + + if (result != NULL) { + int first = 0; + +#if USE_WIDEC_SUPPORT + if (len < 0) + len = _nc_wchstrlen(buf); +#endif /* USE_WIDEC_SUPPORT */ + + /* + * Display one or more strings followed by attributes. + */ + 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; + } + } + + (void) _nc_trace_bufcat(bufnum, l_brace); + (void) _nc_trace_bufcat(bufnum, d_quote); + for (j = first; j <= last; ++j) { + const char *found = _nc_altcharset_name(attr, (chtype) + CharOf(buf[j])); + if (found != NULL) { + (void) _nc_trace_bufcat(bufnum, found); + attr &= ~A_ALTCHARSET; + } else +#if USE_WIDEC_SUPPORT + if (!isWidecExt(buf[j])) { + PUTC_DATA; + + for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { + int k; + char temp[80]; + + PUTC_ch = buf[j].chars[PUTC_i]; + if (PUTC_ch == L'\0') { + if (PUTC_i == 0) + (void) _nc_trace_bufcat(bufnum, "\\000"); + break; + } + PUTC_INIT; + PUTC_n = (int) wcrtomb(PUTC_buf, + buf[j].chars[PUTC_i], &PUT_st); + if (PUTC_n <= 0 || buf[j].chars[PUTC_i] > 255) { + _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) + "{%d:\\u%lx}", + _nc_wacs_width(buf[j].chars[PUTC_i]), + (unsigned long) buf[j].chars[PUTC_i]); + (void) _nc_trace_bufcat(bufnum, temp); + break; + } + for (k = 0; k < PUTC_n; k++) { + VisChar(temp, UChar(PUTC_buf[k]), sizeof(temp)); + (void) _nc_trace_bufcat(bufnum, temp); + } + } + } +#else + { + char temp[80]; + VisChar(temp, UChar(buf[j]), sizeof(temp)); + (void) _nc_trace_bufcat(bufnum, temp); + } +#endif /* USE_WIDEC_SUPPORT */ + } + (void) _nc_trace_bufcat(bufnum, d_quote); + 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); + 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/ncurses/ncurses/tty/MKexpanded.sh b/ncurses/ncurses/tty/MKexpanded.sh new file mode 100755 index 0000000000..1daf8f648d --- /dev/null +++ b/ncurses/ncurses/tty/MKexpanded.sh @@ -0,0 +1,144 @@ +#! /bin/sh +############################################################################## +# Copyright 2019-2021,2024 Thomas E. Dickey # +# Copyright 1998-2015,2017 Free Software Foundation, Inc. # +# # +# Copyright (c) 2026 # +# Project Tick. All rights reserved. # +# # +# 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, 1997-on +# +# $Id: MKexpanded.sh,v 1.25 2024/12/07 20:48:46 tom Exp $ +# +# Script to generate 'expanded.c', a dummy source that contains functions +# corresponding to complex macros used in this library. By making functions, +# we simplify analysis and debugging. + +if test $# != 0; then +preprocessor="$1" +else +preprocessor="cc -E" +fi +shift +if test $# != 0 ; then + preprocessor="$preprocessor $*" +else + preprocessor="$preprocessor -DHAVE_CONFIG_H -I. -I../include" +fi + +TMP=gen$$.c +trap "rm -f $TMP; exit 1" 1 2 3 15 +trap "rm -f $TMP" 0 + +cat < + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +#if NCURSES_EXPANDED +EOF + +cat >$TMP < +#undef NCURSES_EXPANDED /* this probably is set in ncurses_cfg.h */ +#include +/* these are names we'd like to see */ +#undef ALL_BUT_COLOR +#undef PAIR_NUMBER +#undef TRUE +#undef FALSE +/* this is a marker */ +IGNORE +NCURSES_EXPORT(void) +_nc_toggle_attr_on (attr_t *S, attr_t at) +{ + toggle_attr_on(*S,at); +} + +NCURSES_EXPORT(void) +_nc_toggle_attr_off (attr_t *S, attr_t at) +{ + toggle_attr_off(*S,at); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int count) +{ + return DelCharCost(SP_PARM, count); +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int count) +{ + return InsCharCost(SP_PARM, count); +} + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T c) +{ + UpdateAttrs(SP_PARM, CHDEREF(c)); +} + +@if_NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_DelCharCost (int count) +{ + return NCURSES_SP_NAME(_nc_DelCharCost) (CURRENT_SCREEN, count); +} + +NCURSES_EXPORT(int) +_nc_InsCharCost (int count) +{ + return NCURSES_SP_NAME(_nc_InsCharCost)(CURRENT_SCREEN, count); +} + +NCURSES_EXPORT(void) +_nc_UpdateAttrs (CARG_CH_T c) +{ + NCURSES_SP_NAME(_nc_UpdateAttrs)(CURRENT_SCREEN,c); +} +@endif +EOF + +$preprocessor $TMP 2>/dev/null | \ + sed -e '1,/^IGNORE$/d' \ + -e 's/^@/#/' \ + -e 's/^#[ ]*if_/#if /' \ + -e "s,$TMP,expanded.c," \ + -e 's/[ ][ ]*$//' \ + -e '/^#[ ]*[0-9]/d' + +cat < 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Alexander V Lukyanov 1997-1998 * + ****************************************************************************/ + +/****************************************************************************** + +NAME + hardscroll.c -- hardware-scrolling optimization for ncurses + +SYNOPSIS + void _nc_scroll_optimize(void) + +DESCRIPTION + OVERVIEW + +This algorithm for computes optimum hardware scrolling to transform an +old screen (curscr) into a new screen (newscr) via vertical line moves. + +Because the screen has a `grain' (there are insert/delete/scroll line +operations but no insert/delete/scroll column operations), it is efficient +break the update algorithm into two pieces: a first stage that does only line +moves, optimizing the end product of user-invoked insertions, deletions, and +scrolls; and a second phase (corresponding to the present doupdate code in +ncurses) that does only line transformations. + +The common case we want hardware scrolling for is to handle line insertions +and deletions in screen-oriented text-editors. This two-stage approach will +accomplish that at a low computation and code-size cost. + + LINE-MOVE COMPUTATION + +Now, to a discussion of the line-move computation. + +For expository purposes, consider the screen lines to be represented by +integers 0..23 (with the understanding that the value of 23 may vary). +Let a new line introduced by insertion, scrolling, or at the bottom of +the screen following a line delete be given the index -1. + +Assume that the real screen starts with lines 0..23. Now, we have +the following possible line-oriented operations on the screen: + +Insertion: inserts a line at a given screen row, forcing all lines below +to scroll forward. The last screen line is lost. For example, an insertion +at line 5 would produce: 0..4 -1 5..23. + +Deletion: deletes a line at a given screen row, forcing all lines below +to scroll forward. The last screen line is made new. For example, a deletion +at line 7 would produce: 0..6 8..23 -1. + +Scroll up: move a range of lines up 1. The bottom line of the range +becomes new. For example, scrolling up the region from 9 to 14 will +produce 0..8 10..14 -1 15..23. + +Scroll down: move a range of lines down 1. The top line of the range +becomes new. For example, scrolling down the region from 12 to 16 will produce +0..11 -1 12..15 17..23. + +Now, an obvious property of all these operations is that they preserve the +order of old lines, though not their position in the sequence. + +The key trick of this algorithm is that the original line indices described +above are actually maintained as _line[].oldindex fields in the window +structure, and stick to each line through scroll and insert/delete operations. + +Thus, it is possible at update time to look at the oldnum fields and compute +an optimal set of il/dl/scroll operations that will take the real screen +lines to the virtual screen lines. Once these vertical moves have been done, +we can hand off to the second stage of the update algorithm, which does line +transformations. + +Note that the move computation does not need to have the full generality +of a diff algorithm (which it superficially resembles) because lines cannot +be moved out of order. + + THE ALGORITHM + +The scrolling is done in two passes. The first pass is from top to bottom +scrolling hunks UP. The second one is from bottom to top scrolling hunks DOWN. +Obviously enough, no lines to be scrolled will be destroyed. (lav) + +HOW TO TEST THIS: + +Use the following production: + +hardscroll: hardscroll.c + $(CC) -g -DSCROLLDEBUG hardscroll.c -o hardscroll + +Then just type scramble vectors and watch. The following test loads are +a representative sample of cases: + +----------------------------- CUT HERE ------------------------------------ +# No lines moved + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 +# +# A scroll up + 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 -1 +# +# A scroll down +-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 +# +# An insertion (after line 12) + 0 1 2 3 4 5 6 7 8 9 10 11 12 -1 13 14 15 16 17 18 19 20 21 22 +# +# A simple deletion (line 10) + 0 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 23 -1 +# +# A more complex case +-1 -1 -1 -1 -1 3 4 5 6 7 -1 -1 8 9 10 11 12 13 14 15 16 17 -1 -1 +----------------------------- CUT HERE ------------------------------------ + +AUTHOR + Eric S. Raymond , November 1994 + New algorithm by Alexander V. Lukyanov , Aug 1997 + +*****************************************************************************/ + +#include + +MODULE_ID("$Id: hardscroll.c,v 1.61 2025/02/15 15:12:54 tom Exp $") + +#if defined(SCROLLDEBUG) || defined(HASHDEBUG) + +# undef screen_lines +# define screen_lines(sp) MAXLINES +NCURSES_EXPORT_VAR (int) + oldnums[MAXLINES]; +# define OLDNUM(sp,n) oldnums[n] +# define _tracef printf +# 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 = NULL; /* obsolete: keep for ABI compat */ + +# if USE_HASHMAP +# define oldnums(sp) (sp)->_oldnum_list +# define OLDNUM(sp,n) oldnums(sp)[n] +# else /* !USE_HASHMAP */ +# define OLDNUM(sp,n) NewScreen(sp)->_line[n].oldindex +# endif /* !USE_HASHMAP */ + +#define OLDNUM_SIZE(sp) (sp)->_oldnum_size + +#endif /* defined(SCROLLDEBUG) || defined(HASHDEBUG) */ + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_DCL0) +/* scroll optimization to transform curscr to newscr */ +{ + int i; + int start, end, shift; + + TR(TRACE_ICALLS, (T_CALLED("_nc_scroll_optimize(%p)"), (void *) SP_PARM)); + +#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG) +#if USE_HASHMAP + /* get enough storage */ + assert(OLDNUM_SIZE(SP_PARM) >= 0); + assert(screen_lines(SP_PARM) > 0); + if ((oldnums(SP_PARM) == NULL) + || (OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM))) { + int need_lines = ((OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM)) + ? screen_lines(SP_PARM) + : OLDNUM_SIZE(SP_PARM)); + int *new_oldnums = typeRealloc(int, + (size_t) need_lines, + oldnums(SP_PARM)); + if (!new_oldnums) { + TR(TRACE_ICALLS, (T_RETURN(""))); + return; + } + oldnums(SP_PARM) = new_oldnums; + OLDNUM_SIZE(SP_PARM) = need_lines; + } + /* calculate the indices */ + NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_ARG); + if (SP_PARM->hashtab_len < screen_lines(SP_PARM)) { + TR(TRACE_ICALLS, (T_RETURN(""))); + return; + } +#endif +#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */ + +#ifdef TRACE + if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) { + NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_ARG); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + + /* pass 1 - from top to bottom scrolling up */ + for (i = 0; i < screen_lines(SP_PARM);) { + while (i < screen_lines(SP_PARM) + && (OLDNUM(SP_PARM, i) == _NEWINDEX || OLDNUM(SP_PARM, i) <= i)) + i++; + if (i >= screen_lines(SP_PARM)) + break; + + shift = OLDNUM(SP_PARM, i) - i; /* shift > 0 */ + start = i; + + i++; + while (i < screen_lines(SP_PARM) + && OLDNUM(SP_PARM, i) != _NEWINDEX + && OLDNUM(SP_PARM, i) - i == shift) + i++; + end = i - 1 + shift; + + TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift)); +#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG) + if (NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_ARGx + shift, + start, + end, + screen_lines(SP_PARM) - 1) == ERR) { + TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll")); + continue; + } +#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */ + } + + /* pass 2 - from bottom to top scrolling down */ + for (i = screen_lines(SP_PARM) - 1; i >= 0;) { + while (i >= 0 + && (OLDNUM(SP_PARM, i) == _NEWINDEX + || OLDNUM(SP_PARM, i) >= i)) { + i--; + } + if (i < 0) + break; + + shift = OLDNUM(SP_PARM, i) - i; /* shift < 0 */ + end = i; + + i--; + while (i >= 0 + && OLDNUM(SP_PARM, i) != _NEWINDEX + && OLDNUM(SP_PARM, i) - i == shift) { + i--; + } + start = i + 1 - (-shift); + + TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift)); +#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG) + if (NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_ARGx + shift, + start, + end, + screen_lines(SP_PARM) - 1) == ERR) { + TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll")); + continue; + } +#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */ + } + TR(TRACE_ICALLS, (T_RETURN(""))); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_scroll_optimize(void) +{ + NCURSES_SP_NAME(_nc_scroll_optimize) (CURRENT_SCREEN); +} +#endif + +#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_DCL0) +/* dump the state of the real and virtual oldnum fields */ +{ + if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) { + char *buf = NULL; + size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4; + (void) SP_PARM; + + if ((buf = typeMalloc(char, want)) != NULL) { + int n; + + *buf = '\0'; + for (n = 0; n < screen_lines(SP_PARM); n++) { + int number = OLDNUM(SP_PARM, n); + if (number >= -99 && number < 999) { + _nc_SPRINTF(buf + strlen(buf), + _nc_SLIMIT(want - strlen(buf)) + " %02d", number); + } else { + _nc_STRCAT(buf, " ??", want - strlen(buf)); + } + } + free(buf); + } + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_linedump(void) +{ + NCURSES_SP_NAME(_nc_linedump) (CURRENT_SCREEN); +} +#endif + +#endif /* defined(TRACE) || defined(SCROLLDEBUG) */ + +#ifdef SCROLLDEBUG + +int +main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +{ + char line[BUFSIZ], *st; + +#ifdef TRACE + _nc_tracing = TRACE_MOVE; +#endif + for (;;) { + int n; + + for (n = 0; n < screen_lines(sp); n++) + oldnums[n] = _NEWINDEX; + + /* grab the test vector */ + if (fgets(line, sizeof(line), stdin) == (char *) NULL) + exit(EXIT_SUCCESS); + + /* parse it */ + n = 0; + if (line[0] == '#') { + (void) fputs(line, stderr); + continue; + } + st = strtok(line, " "); + do { + oldnums[n++] = atoi(st); + } while + ((st = strtok((char *) NULL, " ")) != NULL); + + /* display it */ + (void) fputs("Initial input:\n", stderr); + _nc_linedump(); + + _nc_scroll_optimize(); + } +} + +#endif /* SCROLLDEBUG */ + +/* hardscroll.c ends here */ diff --git a/ncurses/ncurses/tty/hashmap.c b/ncurses/ncurses/tty/hashmap.c new file mode 100644 index 0000000000..4b2bd1e431 --- /dev/null +++ b/ncurses/ncurses/tty/hashmap.c @@ -0,0 +1,598 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 1998-2015,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/****************************************************************************** + +NAME + hashmap.c -- fill in scramble vector based on text hashes + +SYNOPSIS + void _nc_hash_map(void) + +DESCRIPTION: + This code attempts to recognize pairs of old and new lines in the physical +and virtual screens. When a line pair is recognized, the old line index is +placed in the oldindex member of the virtual screen line, to be used by the +vertical-motion optimizer portion of the update logic (see hardscroll.c). + + Line pairs are recognized by applying a modified Heckel's algorithm, +sped up by hashing. If a line hash is unique in both screens, those +lines must be a pair. Then if the lines just before or after the pair +are the same or similar, they are a pair too. + + We don't worry about false pairs produced by hash collisions, on the +assumption that such cases are rare and will only make the latter stages +of update less efficient, not introduce errors. + +HOW TO TEST THIS: + +Use the following production: + +hashmap: hashmap.c + $(CC) -g -DHASHDEBUG hashmap.c hardscroll.c ../objects/lib_trace.o -o hashmap + +AUTHOR + Eric S. Raymond , May 1996 + Bug fixes and improvements by Alexander V. Lukyanov , 1997 + +*****************************************************************************/ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: hashmap.c,v 1.75 2025/07/26 19:48:34 tom Exp $") + +#ifdef HASHDEBUG + +# define _tracef printf +# undef TR +# ifdef TRACE +# define TR(n, a) if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); } +# else +# define TR(n, a) { _tracef a ; putchar('\n'); } +# endif +# undef screen_lines +# define screen_lines(sp) MAXLINES +# define TEXTWIDTH(sp) 1 +static int oldnums[MAXLINES], reallines[MAXLINES]; +static NCURSES_CH_T oldtext[MAXLINES][TEXTWIDTH(sp)]; +static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH(sp)]; +# define OLDNUM(sp,n) oldnums[n] +# define OLDTEXT(sp,n) oldtext[n] +# define NEWTEXT(sp,m) newtext[m] +# define PENDING(sp,n) 1 + +#else /* !HASHDEBUG */ + +# define OLDNUM(sp,n) (sp)->_oldnum_list[n] +# define OLDTEXT(sp,n) CurScreen(sp)->_line[n].text +# define NEWTEXT(sp,m) NewScreen(sp)->_line[m].text +# define TEXTWIDTH(sp) (CurScreen(sp)->_maxx + 1) +# define PENDING(sp,n) (NewScreen(sp)->_line[n].firstchar != _NOCHANGE) + +#endif /* !HASHDEBUG */ + +#define oldhash(sp) ((sp)->oldhash) +#define newhash(sp) ((sp)->newhash) +#define hashtab(sp) ((sp)->hashtab) +#define lines_alloc(sp) ((sp)->hashtab_len) + +#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(SCREEN *sp, const NCURSES_CH_T *text) +{ + int i; + unsigned long result = 0; + (void) sp; + + for (i = TEXTWIDTH(sp); i > 0; i--) { + NCURSES_CH_T ch = *text++; + result += (result << 5) + (unsigned long) HASH_VAL(ch); + } + return result; +} + +/* approximate update cost */ +static int +update_cost(SCREEN *sp, NCURSES_CH_T *from, NCURSES_CH_T *to) +{ + int cost = 0; + int i; + (void) sp; + + for (i = TEXTWIDTH(sp); i > 0; i--, from++, to++) + if (!(CharEq(*from, *to))) + cost++; + + return cost; +} + +static int +update_cost_from_blank(SCREEN *sp, NCURSES_CH_T *to) +{ + int cost = 0; + int i; + NCURSES_CH_T blank = blankchar; + (void) sp; + + if (back_color_erase) + SetPair(blank, GetPair(stdscr->_nc_bkgd)); + + for (i = TEXTWIDTH(sp); i > 0; i--, to++) + if (!(CharEq(blank, *to))) + cost++; + + return cost; +} + +/* + * Returns true when moving line 'from' to line 'to' seems to be cost + * effective. 'blank' indicates whether the line 'to' would become blank. + */ +static NCURSES_INLINE bool +cost_effective(SCREEN *sp, const int from, const int to, const int blank) +{ + int new_from; + + if (from == to) + return FALSE; + + new_from = OLDNUM(sp, from); + if (new_from == _NEWINDEX) + new_from = from; + + /* + * On the left side of >= is the cost before moving; + * on the right side -- cost after moving. + */ + return (((blank ? update_cost_from_blank(sp, NEWTEXT(sp, to)) + : update_cost(sp, OLDTEXT(sp, to), NEWTEXT(sp, to))) + + update_cost(sp, OLDTEXT(sp, new_from), NEWTEXT(sp, from))) + >= ((new_from == from ? update_cost_from_blank(sp, NEWTEXT(sp, from)) + : update_cost(sp, OLDTEXT(sp, new_from), NEWTEXT(sp, from))) + + update_cost(sp, OLDTEXT(sp, from), NEWTEXT(sp, to)))) + ? TRUE : FALSE; +} + +static void +grow_hunks(SCREEN *sp) +{ + int back_limit; /* limits for cells to fill */ + int back_ref_limit; /* limit for references */ + int i; + int next_hunk; + + /* + * This is tricky part. We have unique pairs to use as anchors. + * Use these to deduce the presence of spans of identical lines. + */ + back_limit = 0; + back_ref_limit = 0; + + i = 0; + while (i < screen_lines(sp) && OLDNUM(sp, i) == _NEWINDEX) + i++; + for (; i < screen_lines(sp); i = next_hunk) { + int forward_limit; + int forward_ref_limit; + int end; + int start = i; + int shift = OLDNUM(sp, i) - i; + + /* get forward limit */ + i = start + 1; + while (i < screen_lines(sp) + && OLDNUM(sp, i) != _NEWINDEX + && OLDNUM(sp, i) - i == shift) + i++; + end = i; + while (i < screen_lines(sp) && OLDNUM(sp, i) == _NEWINDEX) + i++; + next_hunk = i; + forward_limit = i; + if (i >= screen_lines(sp) || OLDNUM(sp, i) >= i) + forward_ref_limit = i; + else + forward_ref_limit = OLDNUM(sp, i); + + i = start - 1; + /* grow back */ + if (shift < 0) + back_limit = back_ref_limit + (-shift); + while (i >= back_limit) { + if (newhash(sp)[i] == oldhash(sp)[i + shift] + || cost_effective(sp, i + shift, i, shift < 0)) { + OLDNUM(sp, i) = i + shift; + TR(TRACE_UPDATE | TRACE_MOVE, + ("connected new line %d to old line %d (backward continuation)", + i, i + shift)); + } else { + TR(TRACE_UPDATE | TRACE_MOVE, + ("not connecting new line %d to old line %d (backward continuation)", + i, i + shift)); + break; + } + i--; + } + + i = end; + /* grow forward */ + if (shift > 0) + forward_limit = forward_ref_limit - shift; + while (i < forward_limit) { + if (newhash(sp)[i] == oldhash(sp)[i + shift] + || cost_effective(sp, i + shift, i, shift > 0)) { + OLDNUM(sp, i) = i + shift; + TR(TRACE_UPDATE | TRACE_MOVE, + ("connected new line %d to old line %d (forward continuation)", + i, i + shift)); + } else { + TR(TRACE_UPDATE | TRACE_MOVE, + ("not connecting new line %d to old line %d (forward continuation)", + i, i + shift)); + break; + } + i++; + } + + back_ref_limit = back_limit = i; + if (shift > 0) + back_ref_limit += shift; + } +} + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0) +{ + HASHMAP *hsp; + register int i; + + if (screen_lines(SP_PARM) > lines_alloc(SP_PARM)) { + if (hashtab(SP_PARM)) + free(hashtab(SP_PARM)); + hashtab(SP_PARM) = typeMalloc(HASHMAP, + ((size_t) screen_lines(SP_PARM) + 1) * 2); + if (!hashtab(SP_PARM)) { + if (oldhash(SP_PARM)) { + FreeAndNull(oldhash(SP_PARM)); + } + lines_alloc(SP_PARM) = 0; + return; + } + lines_alloc(SP_PARM) = screen_lines(SP_PARM); + } + + if (oldhash(SP_PARM) && newhash(SP_PARM)) { + /* re-hash only changed lines */ + for (i = 0; i < screen_lines(SP_PARM); i++) { + if (PENDING(SP_PARM, i)) + newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i)); + } + } else { + /* re-hash all */ + if (oldhash(SP_PARM) == NULL) + oldhash(SP_PARM) = typeCalloc(unsigned long, + (size_t) screen_lines(SP_PARM)); + if (newhash(SP_PARM) == NULL) + newhash(SP_PARM) = typeCalloc(unsigned long, + (size_t) screen_lines(SP_PARM)); + if (!oldhash(SP_PARM) || !newhash(SP_PARM)) { + FreeAndNull(oldhash(SP_PARM)); + FreeAndNull(newhash(SP_PARM)); + return; /* malloc failure */ + } + for (i = 0; i < screen_lines(SP_PARM); i++) { + newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i)); + oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i)); + } + } + +#ifdef HASH_VERIFY + for (i = 0; i < screen_lines(SP_PARM); i++) { + if (newhash(SP_PARM)[i] != hash(SP_PARM, NEWTEXT(SP_PARM, i))) + fprintf(stderr, "error in newhash[%d]\n", i); + if (oldhash(SP_PARM)[i] != hash(SP_PARM, OLDTEXT(SP_PARM, i))) + fprintf(stderr, "error in oldhash[%d]\n", i); + } +#endif + + /* + * Set up and count line-hash values. + */ + memset(hashtab(SP_PARM), '\0', + sizeof(*(hashtab(SP_PARM))) + * ((size_t) screen_lines(SP_PARM) + 1) * 2); + for (i = 0; i < screen_lines(SP_PARM); i++) { + unsigned long hashval = oldhash(SP_PARM)[i]; + + for (hsp = hashtab(SP_PARM); hsp->hashval; hsp++) + if (hsp->hashval == hashval) + break; + hsp->hashval = hashval; /* in case this is a new entry */ + hsp->oldcount++; + hsp->oldindex = i; + } + for (i = 0; i < screen_lines(SP_PARM); i++) { + unsigned long hashval = newhash(SP_PARM)[i]; + + for (hsp = hashtab(SP_PARM); hsp->hashval; hsp++) + if (hsp->hashval == hashval) + break; + hsp->hashval = hashval; /* in case this is a new entry */ + hsp->newcount++; + hsp->newindex = i; + + OLDNUM(SP_PARM, i) = _NEWINDEX; /* initialize old indices array */ + } + + /* + * Mark line pairs corresponding to unique hash pairs. + * + * We don't mark lines with offset 0, because it can make fail + * extending hunks by cost_effective. Otherwise, it does not + * have any side effects. + */ + for (hsp = hashtab(SP_PARM); hsp->hashval; hsp++) + if (hsp->oldcount == 1 && hsp->newcount == 1 + && hsp->oldindex != hsp->newindex) { + TR(TRACE_UPDATE | TRACE_MOVE, + ("new line %d is hash-identical to old line %d (unique)", + hsp->newindex, hsp->oldindex)); + OLDNUM(SP_PARM, hsp->newindex) = hsp->oldindex; + } + + grow_hunks(SP_PARM); + + /* + * Eliminate bad or impossible shifts -- this includes removing + * those hunks which could not grow because of conflicts, as well + * those which are to be moved too far, they are likely to destroy + * more than carry. + */ + for (i = 0; i < screen_lines(SP_PARM);) { + int start, shift, size; + + while (i < screen_lines(SP_PARM) && OLDNUM(SP_PARM, i) == _NEWINDEX) + i++; + if (i >= screen_lines(SP_PARM)) + break; + start = i; + shift = OLDNUM(SP_PARM, i) - i; + i++; + while (i < screen_lines(SP_PARM) + && OLDNUM(SP_PARM, i) != _NEWINDEX + && OLDNUM(SP_PARM, i) - i == shift) + i++; + size = i - start; + if (size < 3 || size + Min(size / 8, 2) < abs(shift)) { + while (start < i) { + OLDNUM(SP_PARM, start) = _NEWINDEX; + start++; + } + } + } + + /* After clearing invalid hunks, try grow the rest. */ + grow_hunks(SP_PARM); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_hash_map(void) +{ + NCURSES_SP_NAME(_nc_hash_map) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_DCLx int i) +{ + if (oldhash(SP_PARM)) + oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i)); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_make_oldhash(int i) +{ + NCURSES_SP_NAME(_nc_make_oldhash) (CURRENT_SCREEN, i); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_DCLx int n, int top, int bot) +{ + size_t size; + int i; + + if (!oldhash(SP_PARM)) + return; + + size = sizeof(*(oldhash(SP_PARM))) * (size_t) (bot - top + 1 - abs(n)); + if (n > 0) { + memmove(oldhash(SP_PARM) + top, oldhash(SP_PARM) + top + n, size); + for (i = bot; i > bot - n; i--) + oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i)); + } else { + memmove(oldhash(SP_PARM) + top - n, oldhash(SP_PARM) + top, size); + for (i = top; i < top - n; i++) + oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i)); + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_scroll_oldhash(int n, int top, int bot) +{ + NCURSES_SP_NAME(_nc_scroll_oldhash) (CURRENT_SCREEN, n, top, bot); +} +#endif + +#ifdef HASHDEBUG +static void +usage(void) +{ + static const char *table[] = + { + "hashmap test-driver", + "", + "# comment", + "l get initial line number vector", + "n use following letters as text of new lines", + "o use following letters as text of old lines", + "d dump state of test arrays", + "h apply hash mapper and see scroll optimization", + "? this message" + }; + size_t n; + for (n = 0; n < sizeof(table) / sizeof(table[0]); n++) + fprintf(stderr, "%s\n", table[n]); +} + +int +main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +{ + char line[BUFSIZ], *st; + int n; + + if (setupterm(NULL, fileno(stdout), (int *) 0) == ERR) + return EXIT_FAILURE; + (void) _nc_alloc_screen(); + + for (n = 0; n < screen_lines(sp); n++) { + reallines[n] = n; + oldnums[n] = _NEWINDEX; + SetChar(oldtext[n][0], '.', A_NORMAL); + SetChar(newtext[n][0], '.', A_NORMAL); + } + + if (NC_ISATTY(fileno(stdin))) + usage(); + +#ifdef TRACE + _nc_tracing = TRACE_MOVE; +#endif + for (;;) { + /* grab a test command */ + if (fgets(line, sizeof(line), stdin) == (char *) NULL) + break; + + switch (line[0]) { + case '#': /* comment */ + (void) fputs(line, stderr); + break; + + case 'l': /* get initial line number vector */ + for (n = 0; n < screen_lines(sp); n++) { + reallines[n] = n; + oldnums[n] = _NEWINDEX; + } + n = 0; + st = strtok(line, " "); + do { + oldnums[n++] = atoi(st); + } while + ((st = strtok((char *) NULL, " ")) != NULL); + break; + + case 'n': /* use following letters as text of new lines */ + for (n = 0; n < screen_lines(sp); n++) + SetChar(newtext[n][0], '.', A_NORMAL); + for (n = 0; n < screen_lines(sp); n++) + if (line[n + 1] == '\n') + break; + else + SetChar(newtext[n][0], line[n + 1], A_NORMAL); + break; + + case 'o': /* use following letters as text of old lines */ + for (n = 0; n < screen_lines(sp); n++) + SetChar(oldtext[n][0], '.', A_NORMAL); + for (n = 0; n < screen_lines(sp); n++) + if (line[n + 1] == '\n') + break; + else + SetChar(oldtext[n][0], line[n + 1], A_NORMAL); + break; + + case 'd': /* dump state of test arrays */ +#ifdef TRACE + _nc_linedump(); +#endif + (void) fputs("Old lines: [", stdout); + for (n = 0; n < screen_lines(sp); n++) + putchar(CharOf(oldtext[n][0])); + putchar(']'); + putchar('\n'); + (void) fputs("New lines: [", stdout); + for (n = 0; n < screen_lines(sp); n++) + putchar(CharOf(newtext[n][0])); + putchar(']'); + putchar('\n'); + break; + + case 'h': /* apply hash mapper and see scroll optimization */ + _nc_hash_map(); + (void) fputs("Result:\n", stderr); +#ifdef TRACE + _nc_linedump(); +#endif + _nc_scroll_optimize(); + (void) fputs("Done.\n", stderr); + break; + default: + case '?': + usage(); + break; + } + } + exit_curses(EXIT_SUCCESS); +} + +#endif /* HASHDEBUG */ + +/* hashmap.c ends here */ diff --git a/ncurses/ncurses/tty/lib_mvcur.c b/ncurses/ncurses/tty/lib_mvcur.c new file mode 100644 index 0000000000..0bbb55f10c --- /dev/null +++ b/ncurses/ncurses/tty/lib_mvcur.c @@ -0,0 +1,1438 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* +** lib_mvcur.c +** +** The routines for moving the physical cursor and scrolling: +** +** void _nc_mvcur_init(void) +** +** void _nc_mvcur_resume(void) +** +** int mvcur(int old_y, int old_x, int new_y, int new_x) +** +** void _nc_mvcur_wrap(void) +** +** Comparisons with older movement optimizers: +** SVr3 curses mvcur() can't use cursor_to_ll or auto_left_margin. +** 4.4BSD curses can't use cuu/cud/cuf/cub/hpa/vpa/tab/cbt for local +** motions. It doesn't use tactics based on auto_left_margin. Weirdly +** enough, it doesn't use its own hardware-scrolling routine to scroll up +** destination lines for out-of-bounds addresses! +** old ncurses optimizer: less accurate cost computations (in fact, +** it was broken and had to be commented out!). +** +** Compile with -DMAIN to build an interactive tester/timer for the movement +** optimizer. You can use it to investigate the optimizer's behavior. +** You can also use it for tuning the formulas used to determine whether +** or not full optimization is attempted. +** +** This code has a nasty tendency to find bugs in terminfo entries, because it +** exercises the non-cup movement capabilities heavily. If you think you've +** found a bug, try deleting subsets of the following capabilities (arranged +** in decreasing order of suspiciousness): it, tab, cbt, hpa, vpa, cuu, cud, +** cuf, cub, cuu1, cud1, cuf1, cub1. It may be that one or more are wrong. +** +** Note: you should expect this code to look like a resource hog in a profile. +** That's because it does a lot of I/O, through the tputs() calls. The I/O +** cost swamps the computation overhead (and as machines get faster, this +** will become even more true). Comments in the test exerciser at the end +** go into detail about tuning and how you can gauge the optimizer's +** effectiveness. +**/ + +/**************************************************************************** + * + * Constants and macros for optimizer tuning. + * + ****************************************************************************/ + +/* + * The average overhead of a full optimization computation in character + * transmission times. If it is too high, the algorithm will be a bit + * over-biased toward using cup rather than local motions; if it is too + * low, the algorithm may spend more time than is strictly optimal + * looking for non-cup motions. Profile the optimizer using the `t' + * command of the exerciser (see below), and round to the nearest integer. + * + * Yes, I (esr) thought about computing expected overhead dynamically, say + * by derivation from a running average of optimizer times. But the + * whole point of this optimization is to *decrease* the frequency of + * system calls. :-) + */ +#define COMPUTE_OVERHEAD 1 /* I use a 90MHz Pentium @ 9.6Kbps */ + +/* + * LONG_DIST is the distance we consider to be just as costly to move over as a + * cup sequence is to emit. In other words, it is the length of a cup sequence + * adjusted for average computation overhead. The magic number is the length + * of "\033[yy;xxH", the typical cup sequence these days. + */ +#define LONG_DIST (8 - COMPUTE_OVERHEAD) + +/* + * Tell whether a motion is optimizable by local motions. Needs to be cheap to + * compute. In general, all the fast moves go to either the right or left edge + * of the screen. So any motion to a location that is (a) further away than + * LONG_DIST and (b) further inward from the right or left edge than LONG_DIST, + * we'll consider nonlocal. + */ +#define NOT_LOCAL(sp, fy, fx, ty, tx) ((tx > LONG_DIST) \ + && (tx < screen_columns(sp) - 1 - LONG_DIST) \ + && (abs(ty-fy) + abs(tx-fx) > LONG_DIST)) + +/**************************************************************************** + * + * External interfaces + * + ****************************************************************************/ + +/* + * For this code to work OK, the following components must live in the + * screen structure: + * + * 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 (back_tab) + *#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 _ech_cost; // cost of (erase_chars) + * int _rep_cost; // cost of (repeat_char) + * + * The USE_HARD_TABS switch controls whether it is reliable to use tab/backtabs + * for local motions. On many systems, it is not, due to uncertainties about + * tab delays and whether or not tabs will be expanded in raw mode. If you + * have parm_right_cursor, tab motions don't win you a lot anyhow. + */ + +#include +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_mvcur.c,v 1.167 2025/12/27 12:34:03 tom Exp $") + +#define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x] /* desired state */ + +#if NCURSES_SP_FUNCS +#define BAUDRATE(sp) sp->_term->_baudrate /* bits per second */ +#else +#define BAUDRATE(sp) cur_term->_baudrate /* bits per second */ +#endif + +#if defined(MAIN) || defined(NCURSES_TEST) +#include + +static bool profiling = FALSE; +static float diff; +#endif /* MAIN */ + +#undef NCURSES_OUTC_FUNC +#define NCURSES_OUTC_FUNC myOutCh + +#define OPT_SIZE 512 + +static int normalized_cost(NCURSES_SP_DCLx const char *const cap, int affcnt); + +/**************************************************************************** + * + * Initialization/wrapup (including cost pre-computation) + * + ****************************************************************************/ + +#ifdef TRACE +static int +trace_cost_of(NCURSES_SP_DCLx const char *capname, const char *cap, int affcnt) +{ + int result = NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_ARGx cap, affcnt); + TR(TRACE_CHARPUT | TRACE_MOVE, + ("CostOf %s %d %s", capname, result, _nc_visbuf(cap))); + return result; +} +#define CostOf(cap,affcnt) trace_cost_of(NCURSES_SP_ARGx #cap, cap, affcnt) + +static int +trace_normalized_cost(NCURSES_SP_DCLx const char *capname, const char *cap, int affcnt) +{ + int result = normalized_cost(NCURSES_SP_ARGx cap, affcnt); + TR(TRACE_CHARPUT | TRACE_MOVE, + ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap))); + return result; +} +#define NormalizedCost(cap,affcnt) trace_normalized_cost(NCURSES_SP_ARGx #cap, cap, affcnt) + +#else + +#define CostOf(cap,affcnt) NCURSES_SP_NAME(_nc_msec_cost)(NCURSES_SP_ARGx cap, affcnt) +#define NormalizedCost(cap,affcnt) normalized_cost(NCURSES_SP_ARGx cap, affcnt) + +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_DCLx const char *const cap, int affcnt) +/* compute the cost of a given operation */ +{ + if (cap == NULL) + return (NC_INFINITY); + else { + const char *cp; + float cum_cost = 0.0; + + for (cp = cap; *cp; cp++) { + /* extract padding, either mandatory or required */ + if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) { + float number = 0.0; + int state = 0; + + for (cp += 2; *cp != '>'; cp++) { + if (isdigit(UChar(*cp))) { + switch (state) { + case 0: + number = number * 10 + (float) (*cp - '0'); + break; + case 2: + number += (float) ((*cp - '0') / 10.0); + ++state; + break; + } + } else if (*cp == '*') { + /* padding is always a suffix */ + if (state < 4) { + number *= (float) affcnt; + state = 4; + } + } else if (*cp == '.') { + /* a single decimal point is allowed */ + state = (state == 0) ? 2 : 3; + } + if (number > MAX_DELAY_MSECS) { + number = MAX_DELAY_MSECS; + break; + } + } + +#if NCURSES_NO_PADDING + if (!GetNoPadding(SP_PARM)) +#endif + cum_cost += number * 10; + } else if (SP_PARM) { + cum_cost += (float) SP_PARM->_char_padding; + } + } + + return ((int) cum_cost); + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_msec_cost(const char *const cap, int affcnt) +{ + return NCURSES_SP_NAME(_nc_msec_cost) (CURRENT_SCREEN, cap, affcnt); +} +#endif + +static int +normalized_cost(NCURSES_SP_DCLx const char *const cap, int affcnt) +/* compute the effective character-count for an operation (round up) */ +{ + int cost = NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_ARGx cap, affcnt); + if (cost != NC_INFINITY) + cost = (cost + SP_PARM->_char_padding - 1) / SP_PARM->_char_padding; + return cost; +} + +static void +reset_scroll_region(NCURSES_SP_DCL0) +/* Set the scroll-region to a known state (the default) */ +{ + if (change_scroll_region) { + NCURSES_PUTP2("change_scroll_region", + TIPARM_2(change_scroll_region, + 0, screen_lines(SP_PARM) - 1)); + } +} + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_DCL0) +/* what to do at initialization time and after each shellout */ +{ + if (!SP_PARM || !IsTermInfo(SP_PARM)) + return; + + /* initialize screen for cursor access */ + if (enter_ca_mode) { + NCURSES_PUTP2("enter_ca_mode", enter_ca_mode); + } + + /* + * Doing this here rather than in _nc_mvcur_wrap() ensures that + * ncurses programs will see a reset scroll region even if a + * program that messed with it died ungracefully. + * + * This also undoes the effects of terminal init strings that assume + * they know the screen size. This is useful when you're running + * a vt100 emulation through xterm. + */ + reset_scroll_region(NCURSES_SP_ARG); + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + + /* restore cursor shape */ + if (SP_PARM->_cursor != -1) { + int cursor = SP_PARM->_cursor; + SP_PARM->_cursor = -1; + NCURSES_SP_NAME(curs_set) (NCURSES_SP_ARGx cursor); + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_mvcur_resume(void) +{ + NCURSES_SP_NAME(_nc_mvcur_resume) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0) +/* initialize the cost structure */ +{ + if (SP_PARM->_ofp && NC_ISATTY(fileno(SP_PARM->_ofp))) { + SP_PARM->_char_padding = ((BAUDBYTE * 1000 * 10) + / (BAUDRATE(SP_PARM) > 0 + ? BAUDRATE(SP_PARM) + : 9600)); + } else { + SP_PARM->_char_padding = 1; /* must be nonzero */ + } + if (SP_PARM->_char_padding <= 0) + SP_PARM->_char_padding = 1; /* must be nonzero */ + TR(TRACE_CHARPUT | TRACE_MOVE, ("char_padding %d msecs", SP_PARM->_char_padding)); + + /* non-parameterized local-motion strings */ + SP_PARM->_cr_cost = CostOf(carriage_return, 0); + SP_PARM->_home_cost = CostOf(cursor_home, 0); + SP_PARM->_ll_cost = CostOf(cursor_to_ll, 0); +#if USE_HARD_TABS + if (getenv("NCURSES_NO_HARD_TABS") == NULL + && dest_tabs_magic_smso == 0 + && HasHardTabs()) { + SP_PARM->_ht_cost = CostOf(tab, 0); + SP_PARM->_cbt_cost = CostOf(back_tab, 0); + } else { + SP_PARM->_ht_cost = NC_INFINITY; + SP_PARM->_cbt_cost = NC_INFINITY; + } +#endif /* USE_HARD_TABS */ + SP_PARM->_cub1_cost = CostOf(cursor_left, 0); + SP_PARM->_cuf1_cost = CostOf(cursor_right, 0); + SP_PARM->_cud1_cost = CostOf(cursor_down, 0); + SP_PARM->_cuu1_cost = CostOf(cursor_up, 0); + + SP_PARM->_smir_cost = CostOf(enter_insert_mode, 0); + SP_PARM->_rmir_cost = CostOf(exit_insert_mode, 0); + SP_PARM->_ip_cost = 0; + if (insert_padding) { + SP_PARM->_ip_cost = CostOf(insert_padding, 0); + } + + /* + * Assumption: if the terminal has memory_relative addressing, the + * initialization strings or smcup will set single-page mode so we + * can treat it like absolute screen addressing. This seems to be true + * for all cursor_mem_address terminal types in the terminfo database. + */ + SP_PARM->_address_cursor = cursor_address ? cursor_address : cursor_mem_address; + + /* + * Parametrized local-motion strings. This static cost computation + * depends on the following assumptions: + * + * (1) They never have * padding. In the entire master terminfo database + * as of March 1995, only the obsolete Zenith Z-100 pc violates this. + * (Proportional padding is found mainly in insert, delete and scroll + * capabilities). + * + * (2) The average case of cup has two two-digit parameters. Strictly, + * the average case for a 24 * 80 screen has ((10*10*(1 + 1)) + + * (14*10*(1 + 2)) + (10*70*(2 + 1)) + (14*70*4)) / (24*80) = 3.458 + * digits of parameters. On a 25x80 screen the average is 3.6197. + * On larger screens the value gets much closer to 4. + * + * (3) The average case of cub/cuf/hpa/ech/rep has 2 digits of parameters + * (strictly, (((10 * 1) + (70 * 2)) / 80) = 1.8750). + * + * (4) The average case of cud/cuu/vpa has 2 digits of parameters + * (strictly, (((10 * 1) + (14 * 2)) / 24) = 1.5833). + * + * All these averages depend on the assumption that all parameter values + * are equally probable. + */ + SP_PARM->_cup_cost = CostOf(TIPARM_2(SP_PARM->_address_cursor, 23, 23), 1); + SP_PARM->_cub_cost = CostOf(TIPARM_1(parm_left_cursor, 23), 1); + SP_PARM->_cuf_cost = CostOf(TIPARM_1(parm_right_cursor, 23), 1); + SP_PARM->_cud_cost = CostOf(TIPARM_1(parm_down_cursor, 23), 1); + SP_PARM->_cuu_cost = CostOf(TIPARM_1(parm_up_cursor, 23), 1); + SP_PARM->_hpa_cost = CostOf(TIPARM_1(column_address, 23), 1); + SP_PARM->_vpa_cost = CostOf(TIPARM_1(row_address, 23), 1); + + /* non-parameterized screen-update strings */ + SP_PARM->_ed_cost = NormalizedCost(clr_eos, 1); + SP_PARM->_el_cost = NormalizedCost(clr_eol, 1); + SP_PARM->_el1_cost = NormalizedCost(clr_bol, 1); + SP_PARM->_dch1_cost = NormalizedCost(delete_character, 1); + SP_PARM->_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_PARM->_el_cost = 0; + + /* parameterized screen-update strings */ + SP_PARM->_dch_cost = NormalizedCost(TIPARM_1(parm_dch, 23), 1); + SP_PARM->_ich_cost = NormalizedCost(TIPARM_1(parm_ich, 23), 1); + SP_PARM->_ech_cost = NormalizedCost(TIPARM_1(erase_chars, 23), 1); + SP_PARM->_rep_cost = NormalizedCost(TIPARM_2(repeat_char, ' ', 23), 1); + + SP_PARM->_cup_ch_cost = NormalizedCost(TIPARM_2(SP_PARM->_address_cursor, + 23, 23), + 1); + SP_PARM->_hpa_ch_cost = NormalizedCost(TIPARM_1(column_address, 23), 1); + SP_PARM->_cuf_ch_cost = NormalizedCost(TIPARM_1(parm_right_cursor, 23), 1); + SP_PARM->_inline_cost = Min(SP_PARM->_cup_ch_cost, + Min(SP_PARM->_hpa_ch_cost, + SP_PARM->_cuf_ch_cost)); + + /* + * If save_cursor is used within enter_ca_mode, we should not use it for + * scrolling optimization, since the corresponding restore_cursor is not + * nested on the various terminals (vt100, xterm, etc.) which use this + * feature. + */ + if (save_cursor != NULL + && enter_ca_mode != NULL + && strstr(enter_ca_mode, save_cursor) != NULL) { + T(("...suppressed sc/rc capability due to conflict with smcup/rmcup")); + save_cursor = NULL; + restore_cursor = NULL; + } + + /* + * A different, possibly better way to arrange this would be to set the + * SCREEN's _endwin at window initialization time and let this be called by + * doupdate's return-from-shellout code. + */ + NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_mvcur_init(void) +{ + NCURSES_SP_NAME(_nc_mvcur_init) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_mvcur_wrap) (NCURSES_SP_DCL0) +/* wrap up cursor-addressing mode */ +{ + if (!SP_PARM || !IsTermInfo(SP_PARM)) + return; + + /* leave cursor at screen bottom */ + TINFO_MVCUR(NCURSES_SP_ARGx -1, -1, screen_lines(SP_PARM) - 1, 0); + + /* set cursor to normal mode */ + if (SP_PARM->_cursor != -1) { + int cursor = SP_PARM->_cursor; + NCURSES_SP_NAME(curs_set) (NCURSES_SP_ARGx 1); + SP_PARM->_cursor = cursor; + } + + if (exit_ca_mode) { + NCURSES_PUTP2("exit_ca_mode", exit_ca_mode); + } + /* + * Reset terminal's tab counter. There's a long-time bug that + * if you exit a "curses" program such as vi or more, tab + * forward, and then backspace, the cursor doesn't go to the + * right place. The problem is that the kernel counts the + * escape sequences that reset things as column positions. + * Utter a \r to reset this invisibly. + */ + NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx '\r'); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_mvcur_wrap(void) +{ + NCURSES_SP_NAME(_nc_mvcur_wrap) (CURRENT_SCREEN); +} +#endif + +/**************************************************************************** + * + * Optimized cursor movement + * + ****************************************************************************/ + +/* + * Perform repeated-append, returning cost + */ +static NCURSES_INLINE int +repeated_append(string_desc * target, int total, int num, int repeat, const char *src) +{ + size_t need = (size_t) repeat * strlen(src); + + if (need < target->s_size) { + while (repeat-- > 0) { + if (_nc_safe_strcat(target, src)) { + total += num; + } else { + total = NC_INFINITY; + break; + } + } + } else { + total = NC_INFINITY; + } + return total; +} + +#ifndef NO_OPTIMIZE +#define NEXTTAB(fr) (fr + init_tabs - (fr % init_tabs)) + +/* + * Assume back_tab (CBT) does not wrap backwards at the left margin, return + * a negative value at that point to simplify the loop. + */ +#define LASTTAB(fr) ((fr > 0) ? ((fr - 1) / init_tabs) * init_tabs : -1) + +static int +relative_move(NCURSES_SP_DCLx + string_desc * target, + int from_y, + int from_x, + int to_y, + int to_x, + int ovw) +/* move via local motions (cuu/cuu1/cud/cud1/cub1/cub/cuf1/cuf/vpa/hpa) */ +{ + string_desc save; + int n, vcost = 0, hcost = 0; + + (void) _nc_str_copy(&save, target); + + if (to_y != from_y) { + vcost = NC_INFINITY; + + if (row_address != NULL + && _nc_safe_strcat(target, TIPARM_1(row_address, to_y))) { + vcost = SP_PARM->_vpa_cost; + } + + if (to_y > from_y) { + n = (to_y - from_y); + + if (parm_down_cursor + && SP_PARM->_cud_cost < vcost + && _nc_safe_strcat(_nc_str_copy(target, &save), + TIPARM_1(parm_down_cursor, n))) { + vcost = SP_PARM->_cud_cost; + } + + if (cursor_down + && (*cursor_down != '\n') + && (n * SP_PARM->_cud1_cost < vcost)) { + vcost = repeated_append(_nc_str_copy(target, &save), 0, + SP_PARM->_cud1_cost, n, cursor_down); + } + } else { /* (to_y < from_y) */ + n = (from_y - to_y); + + if (parm_up_cursor + && SP_PARM->_cuu_cost < vcost + && _nc_safe_strcat(_nc_str_copy(target, &save), + TIPARM_1(parm_up_cursor, n))) { + vcost = SP_PARM->_cuu_cost; + } + + if (cursor_up && (n * SP_PARM->_cuu1_cost < vcost)) { + vcost = repeated_append(_nc_str_copy(target, &save), 0, + SP_PARM->_cuu1_cost, n, cursor_up); + } + } + + if (vcost == NC_INFINITY) + return (NC_INFINITY); + } + + save = *target; + + if (to_x != from_x) { + char str[OPT_SIZE]; + string_desc check; + + hcost = NC_INFINITY; + + if (column_address + && _nc_safe_strcat(_nc_str_copy(target, &save), + TIPARM_1(column_address, to_x))) { + hcost = SP_PARM->_hpa_cost; + } + + if (to_x > from_x) { + n = to_x - from_x; + + if (parm_right_cursor + && SP_PARM->_cuf_cost < hcost + && _nc_safe_strcat(_nc_str_copy(target, &save), + TIPARM_1(parm_right_cursor, n))) { + hcost = SP_PARM->_cuf_cost; + } + + if (cursor_right) { + int lhcost = 0; + + (void) _nc_str_init(&check, str, sizeof(str)); + +#if USE_HARD_TABS + /* use hard tabs, if we have them, to do as much as possible */ + if (init_tabs > 0 && tab) { + int nxt, fr; + + for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) { + lhcost = repeated_append(&check, lhcost, + SP_PARM->_ht_cost, 1, tab); + if (lhcost == NC_INFINITY) + break; + } + + n = to_x - fr; + from_x = fr; + } +#endif /* USE_HARD_TABS */ + + if (n <= 0 || n >= (int) check.s_size) + ovw = FALSE; +#if BSD_TPUTS + /* + * If we're allowing BSD-style padding in tputs, don't generate + * a string with a leading digit. Otherwise, that will be + * interpreted as a padding value rather than sent to the + * screen. + */ + if (ovw + && n > 0 + && n < (int) check.s_size + && vcost == 0 + && str[0] == '\0') { + int wanted = CharOf(WANT_CHAR(SP_PARM, to_y, from_x)); + if (is8bits(wanted) && isdigit(wanted)) + ovw = FALSE; + } +#endif + /* + * If we have no attribute changes, overwrite is cheaper. + * Note: must suppress this by passing in ovw = FALSE whenever + * WANT_CHAR would return invalid data. In particular, this + * is true between the time a hardware scroll has been done + * and the time the structure WANT_CHAR would access has been + * updated. + */ + if (ovw && to_y >= 0) { + int i; + + for (i = 0; i < n; i++) { + NCURSES_CH_T ch = WANT_CHAR(SP_PARM, to_y, from_x + i); + if (!SameAttrOf(ch, SCREEN_ATTRS(SP_PARM)) +#if USE_WIDEC_SUPPORT + || !Charable(ch) +#endif + ) { + ovw = FALSE; + break; + } + } + } + if (ovw && to_y >= 0) { + int i; + + for (i = 0; i < n; i++) + *check.s_tail++ = (char) CharOf(WANT_CHAR(SP_PARM, to_y, + from_x + i)); + *check.s_tail = '\0'; + check.s_size -= (size_t) n; + lhcost += n * SP_PARM->_char_padding; + } else { + lhcost = repeated_append(&check, lhcost, SP_PARM->_cuf1_cost, + n, cursor_right); + } + + if (lhcost < hcost + && _nc_safe_strcat(_nc_str_copy(target, &save), str)) { + hcost = lhcost; + } + } + } else { /* (to_x < from_x) */ + n = from_x - to_x; + + if (parm_left_cursor + && SP_PARM->_cub_cost < hcost + && _nc_safe_strcat(_nc_str_copy(target, &save), + TIPARM_1(parm_left_cursor, n))) { + hcost = SP_PARM->_cub_cost; + } + + if (cursor_left) { + int lhcost = 0; + + (void) _nc_str_init(&check, str, sizeof(str)); + +#if USE_HARD_TABS + if (init_tabs > 0 && back_tab) { + int nxt, fr; + + for (fr = from_x; (nxt = LASTTAB(fr)) >= to_x; fr = nxt) { + lhcost = repeated_append(&check, lhcost, + SP_PARM->_cbt_cost, + 1, back_tab); + if (lhcost == NC_INFINITY) + break; + } + + n = fr - to_x; + } +#endif /* USE_HARD_TABS */ + + lhcost = repeated_append(&check, lhcost, + SP_PARM->_cub1_cost, + n, cursor_left); + + if (lhcost < hcost + && _nc_safe_strcat(_nc_str_copy(target, &save), str)) { + hcost = lhcost; + } + } + } + + if (hcost == NC_INFINITY) + return (NC_INFINITY); + } + + return (vcost + hcost); +} +#endif /* !NO_OPTIMIZE */ + +/* + * With the machinery set up above, it is conceivable that + * onscreen_mvcur could be modified into a recursive function that does + * an alpha-beta search of motion space, as though it were a chess + * move tree, with the weight function being boolean and the search + * depth equated to length of string. However, this would jack up the + * computation cost a lot, especially on terminals without a cup + * capability constraining the search tree depth. So we settle for + * the simpler method below. + */ + +static NCURSES_INLINE int +onscreen_mvcur(NCURSES_SP_DCLx + int yold, int xold, + int ynew, int xnew, int ovw, + NCURSES_SP_OUTC myOutCh) +/* onscreen move from (yold, xold) to (ynew, xnew) */ +{ + string_desc result; + char buffer[OPT_SIZE]; + int tactic = 0, newcost, usecost = NC_INFINITY; + int t5_cr_cost; + +#if defined(MAIN) || defined(NCURSES_TEST) + struct timeval before, after; + + gettimeofday(&before, NULL); +#endif /* MAIN */ + +#define NullResult _nc_str_null(&result, sizeof(buffer)) +#define InitResult _nc_str_init(&result, buffer, sizeof(buffer)) + + /* tactic #0: use direct cursor addressing */ + if (_nc_safe_strcpy(InitResult, TIPARM_2(SP_PARM->_address_cursor, + ynew, xnew))) { + tactic = 0; + usecost = SP_PARM->_cup_cost; + +#if defined(TRACE) || defined(NCURSES_TEST) + if (!(_nc_optimize_enable & OPTIMIZE_MVCUR)) + goto nonlocal; +#endif /* TRACE */ + + /* + * We may be able to tell in advance that the full optimization + * will probably not be worth its overhead. Also, don't try to + * use local movement if the current attribute is anything but + * A_NORMAL...there are just too many ways this can screw up + * (like, say, local-movement \n getting mapped to some obscure + * character because A_ALTCHARSET is on). + */ + if (yold == -1 || xold == -1 || NOT_LOCAL(SP_PARM, yold, xold, ynew, xnew)) { +#if defined(MAIN) || defined(NCURSES_TEST) + if (!profiling) { + (void) fputs("nonlocal\n", stderr); + goto nonlocal; /* always run the optimizer if profiling */ + } +#else + goto nonlocal; +#endif /* MAIN */ + } + } +#ifndef NO_OPTIMIZE + /* tactic #1: use local movement */ + if (yold != -1 && xold != -1 + && ((newcost = relative_move(NCURSES_SP_ARGx + NullResult, + yold, xold, + ynew, xnew, ovw)) != NC_INFINITY) + && newcost < usecost) { + tactic = 1; + usecost = newcost; + } + + /* tactic #2: use carriage-return + local movement */ + if (yold != -1 && carriage_return + && ((newcost = relative_move(NCURSES_SP_ARGx + NullResult, + yold, 0, + ynew, xnew, ovw)) != NC_INFINITY) + && SP_PARM->_cr_cost + newcost < usecost) { + tactic = 2; + usecost = SP_PARM->_cr_cost + newcost; + } + + /* tactic #3: use home-cursor + local movement */ + if (cursor_home + && ((newcost = relative_move(NCURSES_SP_ARGx + NullResult, + 0, 0, + ynew, xnew, ovw)) != NC_INFINITY) + && SP_PARM->_home_cost + newcost < usecost) { + tactic = 3; + usecost = SP_PARM->_home_cost + newcost; + } + + /* tactic #4: use home-down + local movement */ + if (cursor_to_ll + && ((newcost = relative_move(NCURSES_SP_ARGx + NullResult, + screen_lines(SP_PARM) - 1, 0, + ynew, xnew, ovw)) != NC_INFINITY) + && SP_PARM->_ll_cost + newcost < usecost) { + tactic = 4; + usecost = SP_PARM->_ll_cost + newcost; + } + + /* + * tactic #5: use left margin for wrap to right-hand side, + * unless strange wrap behavior indicated by xenl might hose us. + */ + t5_cr_cost = (xold > 0 ? SP_PARM->_cr_cost : 0); + if (auto_left_margin && !eat_newline_glitch + && yold > 0 && cursor_left + && ((newcost = relative_move(NCURSES_SP_ARGx + NullResult, + yold - 1, screen_columns(SP_PARM) - 1, + ynew, xnew, ovw)) != NC_INFINITY) + && t5_cr_cost + SP_PARM->_cub1_cost + newcost < usecost) { + tactic = 5; + usecost = t5_cr_cost + SP_PARM->_cub1_cost + newcost; + } + + /* + * These cases are ordered by estimated relative frequency. + */ + if (tactic) + InitResult; + switch (tactic) { + case 1: + (void) relative_move(NCURSES_SP_ARGx + &result, + yold, xold, + ynew, xnew, ovw); + break; + case 2: + (void) _nc_safe_strcpy(&result, carriage_return); + (void) relative_move(NCURSES_SP_ARGx + &result, + yold, 0, + ynew, xnew, ovw); + break; + case 3: + (void) _nc_safe_strcpy(&result, cursor_home); + (void) relative_move(NCURSES_SP_ARGx + &result, 0, 0, + ynew, xnew, ovw); + break; + case 4: + (void) _nc_safe_strcpy(&result, cursor_to_ll); + (void) relative_move(NCURSES_SP_ARGx + &result, + screen_lines(SP_PARM) - 1, 0, + ynew, xnew, ovw); + break; + case 5: + if (xold > 0) + (void) _nc_safe_strcat(&result, carriage_return); + (void) _nc_safe_strcat(&result, cursor_left); + (void) relative_move(NCURSES_SP_ARGx + &result, + yold - 1, screen_columns(SP_PARM) - 1, + ynew, xnew, ovw); + break; + } +#endif /* !NO_OPTIMIZE */ + + nonlocal: +#if defined(MAIN) || defined(NCURSES_TEST) + gettimeofday(&after, NULL); + diff = (float) (after.tv_usec - before.tv_usec + + (after.tv_sec - before.tv_sec) * 1000000); + if (!profiling) + (void) fprintf(stderr, + "onscreen: %d microsec, %f 28.8Kbps char-equivalents\n", + (int) diff, diff / 288); +#endif /* MAIN */ + + if (usecost != NC_INFINITY) { + TR(TRACE_MOVE, ("mvcur tactic %d", tactic)); + TPUTS_TRACE("mvcur"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + buffer, 1, myOutCh); + SP_PARM->_cursrow = ynew; + SP_PARM->_curscol = xnew; + return (OK); + } else + return (ERR); +} + +/* + * optimized cursor move from (yold, xold) to (ynew, xnew) + */ +static int +_nc_real_mvcur(NCURSES_SP_DCLx + int yold, int xold, + int ynew, int xnew, + NCURSES_SP_OUTC myOutCh, + int ovw) +{ + NCURSES_CH_T oldattr; + int code; + + TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("_nc_real_mvcur(%p,%d,%d,%d,%d)"), + (void *) SP_PARM, yold, xold, ynew, xnew)); + + if (SP_PARM == NULL) { + code = ERR; + } else if (yold == ynew && xold == xnew) { + code = OK; + } else { + + /* + * 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(SP_PARM)) { + ynew += xnew / screen_columns(SP_PARM); + xnew %= screen_columns(SP_PARM); + } + + /* + * 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_PARM); + 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)))); + VIDPUTS(SP_PARM, A_NORMAL, 0); + } + + if (xold >= screen_columns(SP_PARM)) { + + int l = (xold + 1) / screen_columns(SP_PARM); + + yold += l; + if (yold >= screen_lines(SP_PARM)) + l -= (yold - screen_lines(SP_PARM) - 1); + + if (l > 0) { + if (carriage_return) { + NCURSES_PUTP2("carriage_return", carriage_return); + } else { + myOutCh(NCURSES_SP_ARGx '\r'); + } + xold = 0; + + while (l > 0) { + if (newline) { + NCURSES_PUTP2("newline", newline); + } else { + myOutCh(NCURSES_SP_ARGx '\n'); + } + l--; + } + } + } + + if (yold > screen_lines(SP_PARM) - 1) + yold = screen_lines(SP_PARM) - 1; + if (ynew > screen_lines(SP_PARM) - 1) + ynew = screen_lines(SP_PARM) - 1; + + /* destination location is on screen now */ + code = onscreen_mvcur(NCURSES_SP_ARGx yold, xold, ynew, xnew, ovw, myOutCh); + + /* + * Restore attributes if we disabled them before moving. + */ + if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP_PARM))) { + TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move", + (unsigned long) AttrOf(oldattr), + _traceattr(AttrOf(oldattr)))); + VIDPUTS(SP_PARM, AttrOf(oldattr), GetPair(oldattr)); + } + } + returnCode(code); +} + +/* + * These entrypoints are used within the library. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_mvcur) (NCURSES_SP_DCLx + int yold, int xold, + int ynew, int xnew) +{ + int rc; + rc = _nc_real_mvcur(NCURSES_SP_ARGx yold, xold, ynew, xnew, + NCURSES_SP_NAME(_nc_outch), + TRUE); + /* + * With the terminal-driver, we cannot distinguish between internal and + * external calls. Flush the output if the screen has not been + * initialized, e.g., when used from low-level terminfo programs. + */ + if ((SP_PARM != NULL) && (SP_PARM->_endwin == ewInitial)) + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + return rc; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_mvcur(int yold, int xold, + int ynew, int xnew) +{ + return NCURSES_SP_NAME(_nc_mvcur) (CURRENT_SCREEN, yold, xold, ynew, xnew); +} +#endif + +#if USE_TERM_DRIVER +/* + * The terminal driver does not support the external "mvcur()". + */ +NCURSES_EXPORT(int) +TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew) +{ + int rc; + rc = _nc_real_mvcur(NCURSES_SP_ARGx + yold, xold, + ynew, xnew, + NCURSES_SP_NAME(_nc_outch), + TRUE); + if ((SP_PARM != NULL) && (SP_PARM->_endwin == ewInitial)) + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + return rc; +} + +#else /* !USE_TERM_DRIVER */ + +/* + * These entrypoints support users of the library. + */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx int yold, int xold, int ynew, + int xnew) +{ + return _nc_real_mvcur(NCURSES_SP_ARGx + yold, xold, + ynew, xnew, + NCURSES_SP_NAME(_nc_putchar), + FALSE); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +mvcur(int yold, int xold, int ynew, int xnew) +{ + return NCURSES_SP_NAME(mvcur) (CURRENT_SCREEN, yold, xold, ynew, xnew); +} +#endif +#endif /* USE_TERM_DRIVER */ + +#if defined(TRACE) || defined(NCURSES_TEST) +NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL; +#endif + +#if defined(MAIN) || defined(NCURSES_TEST) +/**************************************************************************** + * + * Movement optimizer test code + * + ****************************************************************************/ + +#include +#include +#include + +NCURSES_EXPORT_VAR(const char *) _nc_progname = "mvcur"; + +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) +/* stub tputs() that dumps sequences in a visible form */ +{ + if (profiling) + xmits += strlen(string); + else + (void) fputs(_nc_visbuf(string), stdout); + return (OK); +} + +NCURSES_EXPORT(int) +putp(const char *string) +{ + return (tputs(string, 1, _nc_outch)); +} + +NCURSES_EXPORT(int) +_nc_outch(int ch) +{ + putc(ch, stdout); + return OK; +} + +NCURSES_EXPORT(int) +delay_output(int ms GCC_UNUSED) +{ + return OK; +} + +static char tname[PATH_MAX]; + +static void +load_term(void) +{ + (void) setupterm(tname, STDOUT_FILENO, NULL); +} + +static int +roll(int n) +{ + int i, j; + + i = (RAND_MAX / n) * n; + while ((j = rand()) >= i) + continue; + return (j % n); +} + +int +main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +{ + _nc_STRCPY(tname, getenv("TERM"), sizeof(tname)); + load_term(); + _nc_setupscreen(lines, columns, stdout, FALSE, 0); + baudrate(); + + _nc_mvcur_init(); + + (void) puts("The mvcur tester. Type ? for help"); + + fputs("smcup:", stdout); + putchar('\n'); + + for (;;) { + int fy, fx, ty, tx, n, i; + char buf[BUFSIZ], capname[BUFSIZ]; + + if (fputs("> ", stdout) == EOF) + break; + if (fgets(buf, sizeof(buf), stdin) == NULL) + break; + +#define PUTS(s) (void) puts(s) +#define PUTF(s,t) (void) printf(s,t) + if (buf[0] == '?') { + PUTS("? -- display this help message"); + PUTS("fy fx ty tx -- (4 numbers) display (fy,fx)->(ty,tx) move"); + PUTS("s[croll] n t b m -- display scrolling sequence"); + PUTF("r[eload] -- reload terminal info for %s\n", + termname()); + PUTS("l[oad] -- load terminal info for type "); + PUTS("d[elete] -- delete named capability"); + PUTS("i[nspect] -- display terminal capabilities"); + PUTS("c[ost] -- dump cursor-optimization cost table"); + PUTS("o[optimize] -- toggle movement optimization"); + PUTS("t[orture] -- torture-test with random moves"); + PUTS("q[uit] -- quit the program"); + } else if (sscanf(buf, "%d %d %d %d", &fy, &fx, &ty, &tx) == 4) { + struct timeval before, after; + + putchar('"'); + + gettimeofday(&before, NULL); + mvcur(fy, fx, ty, tx); + gettimeofday(&after, NULL); + + printf("\" (%ld msec)\n", + (long) (after.tv_usec - before.tv_usec + + (after.tv_sec - before.tv_sec) + * 1000000)); + } else if (sscanf(buf, "s %d %d %d %d", &fy, &fx, &ty, &tx) == 4) { + struct timeval before, after; + + putchar('"'); + + gettimeofday(&before, NULL); + _nc_scrolln(fy, fx, ty, tx); + gettimeofday(&after, NULL); + + printf("\" (%ld msec)\n", + (long) (after.tv_usec - before.tv_usec + (after.tv_sec - + before.tv_sec) + * 1000000)); + } else if (buf[0] == 'r') { + _nc_STRCPY(tname, termname(), sizeof(tname)); + 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_get_hash_table(FALSE)); + + if (np == NULL) + (void) printf("No such capability as \"%s\"\n", capname); + else { + switch (np->nte_type) { + case BOOLEAN: + cur_term->type.Booleans[np->nte_index] = FALSE; + (void) + printf("Boolean capability `%s' (%d) turned off.\n", + np->nte_name, np->nte_index); + break; + + case NUMBER: + cur_term->type.Numbers[np->nte_index] = ABSENT_NUMERIC; + (void) printf("Number capability `%s' (%d) set to -1.\n", + np->nte_name, np->nte_index); + break; + + case STRING: + cur_term->type.Strings[np->nte_index] = ABSENT_STRING; + (void) printf("String capability `%s' (%d) deleted.\n", + np->nte_name, np->nte_index); + break; + } + } + } else if (buf[0] == 'i') { + dump_init(NULL, F_TERMINFO, S_TERMINFO, + FALSE, 70, 0, 0, FALSE, FALSE, 0); + dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, NULL); + putchar('\n'); + } else if (buf[0] == 'o') { + if (_nc_optimize_enable & OPTIMIZE_MVCUR) { + _nc_optimize_enable &= ~OPTIMIZE_MVCUR; + (void) puts("Optimization is now off."); + } else { + _nc_optimize_enable |= OPTIMIZE_MVCUR; + (void) puts("Optimization is now on."); + } + } + /* + * You can use the `t' test to profile and tune the movement + * optimizer. Use iteration values in three digits or more. + * At above 5000 iterations the profile timing averages are stable + * to within a millisecond or three. + * + * The `overhead' field of the report will help you pick a + * COMPUTE_OVERHEAD figure appropriate for your processor and + * expected line speed. The `total estimated time' is + * computation time plus a character-transmission time + * estimate computed from the number of transmits and the baud + * rate. + * + * Use this together with the `o' command to get a read on the + * optimizer's effectiveness. Compare the total estimated times + * for `t' runs of the same length in both optimized and un-optimized + * modes. As long as the optimized times are less, the optimizer + * is winning. + */ + else if (sscanf(buf, "t %d", &n) == 1) { + double cumtime = 0.0, perchar; + int speeds[] = + {2400, 9600, 14400, 19200, 28800, 38400, 0}; + + srand((unsigned) (getpid() + time((time_t *) 0))); + profiling = TRUE; + xmits = 0; + for (i = 0; i < n; i++) { + /* + * This does a move test between two random locations, + * Random moves probably short-change the optimizer, + * which will work better on the short moves probably + * typical of doupdate()'s usage pattern. Still, + * until we have better data... + */ +#ifdef FIND_COREDUMP + int from_y = roll(lines); + int to_y = roll(lines); + int from_x = roll(columns); + int to_x = roll(columns); + + printf("(%d,%d) -> (%d,%d)\n", from_y, from_x, to_y, to_x); + mvcur(from_y, from_x, to_y, to_x); +#else + mvcur(roll(lines), roll(columns), roll(lines), roll(columns)); +#endif /* FIND_COREDUMP */ + if (diff) + cumtime += diff; + } + profiling = FALSE; + + /* + * Average milliseconds per character optimization time. + * This is the key figure to watch when tuning the optimizer. + */ + perchar = cumtime / n; + + (void) printf("%d moves (%ld chars) in %d msec, %f msec each:\n", + n, xmits, (int) cumtime, perchar); + + for (i = 0; speeds[i]; i++) { + /* + * Total estimated time for the moves, computation and + * transmission both. Transmission time is an estimate + * assuming 9 bits/char, 8 bits + 1 stop bit. + */ + double totalest = cumtime + (double) xmits * 9 * 1e6 / speeds[i]; + + /* + * Per-character optimization overhead in character transmits + * at the current speed. Round this to the nearest integer + * to figure COMPUTE_OVERHEAD for the speed. + */ + double overhead = speeds[i] * perchar / 1e6; + + (void) + printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n", + speeds[i], overhead, totalest); + } + } else if (buf[0] == 'c') { + (void) printf("char padding: %d\n", CURRENT_SCREEN->_char_padding); + (void) printf("cr cost: %d\n", CURRENT_SCREEN->_cr_cost); + (void) printf("cup cost: %d\n", CURRENT_SCREEN->_cup_cost); + (void) printf("home cost: %d\n", CURRENT_SCREEN->_home_cost); + (void) printf("ll cost: %d\n", CURRENT_SCREEN->_ll_cost); +#if USE_HARD_TABS + (void) printf("ht cost: %d\n", CURRENT_SCREEN->_ht_cost); + (void) printf("cbt cost: %d\n", CURRENT_SCREEN->_cbt_cost); +#endif /* USE_HARD_TABS */ + (void) printf("cub1 cost: %d\n", CURRENT_SCREEN->_cub1_cost); + (void) printf("cuf1 cost: %d\n", CURRENT_SCREEN->_cuf1_cost); + (void) printf("cud1 cost: %d\n", CURRENT_SCREEN->_cud1_cost); + (void) printf("cuu1 cost: %d\n", CURRENT_SCREEN->_cuu1_cost); + (void) printf("cub cost: %d\n", CURRENT_SCREEN->_cub_cost); + (void) printf("cuf cost: %d\n", CURRENT_SCREEN->_cuf_cost); + (void) printf("cud cost: %d\n", CURRENT_SCREEN->_cud_cost); + (void) printf("cuu cost: %d\n", CURRENT_SCREEN->_cuu_cost); + (void) printf("hpa cost: %d\n", CURRENT_SCREEN->_hpa_cost); + (void) printf("vpa cost: %d\n", CURRENT_SCREEN->_vpa_cost); + } else if (buf[0] == 'x' || buf[0] == 'q') + break; + else + (void) puts("Invalid command."); + } + + (void) fputs("rmcup:", stdout); + _nc_mvcur_wrap(); + putchar('\n'); + + return (0); +} + +#endif /* MAIN */ + +/* lib_mvcur.c ends here */ diff --git a/ncurses/ncurses/tty/lib_tstp.c b/ncurses/ncurses/tty/lib_tstp.c new file mode 100644 index 0000000000..41f3c0931f --- /dev/null +++ b/ncurses/ncurses/tty/lib_tstp.c @@ -0,0 +1,431 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1995-on * + ****************************************************************************/ + +/* +** lib_tstp.c +** +** The routine _nc_signal_handler(). +** +*/ +#include + +#include + +MODULE_ID("$Id: lib_tstp.c,v 1.59 2025/02/15 14:52:13 tom Exp $") + +#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) +#define USE_SIGTSTP 1 +#else +#define USE_SIGTSTP 0 +#endif + +#ifdef TRACE +static const char * +signal_name(int sig) +{ + switch (sig) { +#ifdef SIGALRM + case SIGALRM: + return "SIGALRM"; +#endif +#ifdef SIGCONT + case SIGCONT: + return "SIGCONT"; +#endif + case SIGINT: + return "SIGINT"; +#ifdef SIGQUIT + case SIGQUIT: + return "SIGQUIT"; +#endif + 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. + * The ncurses code needs signal-call restart to happen -- otherwise, + * interrupted wgetch() calls will return FAIL, probably making the + * application think the input stream has ended and it should + * terminate. In particular, you know you have this problem if, when + * you suspend an ncurses-using lynx with ^Z and resume, it dies + * immediately. + * + * Default behavior of POSIX sigaction(2) is not to restart + * interrupted system calls, but Linux's sigaction does it anyway (at + * least, on and after the 1.1.47 I (esr) use). Thus this code works + * OK under Linux. The 4.4BSD sigaction(2) supports a (non-portable) + * SA_RESTART flag that forces the right behavior. Thus, this code + * should work OK under BSD/OS, NetBSD, and FreeBSD (let us know if it + * does not). + * + * Stock System Vs (and anything else using a strict-POSIX + * sigaction(2) without SA_RESTART) may have a problem. Possible + * solutions: + * + * sigvec restarts by default (SV_INTERRUPT flag to not restart) + * signal restarts by default in SVr4 (assuming you link with -lucb) + * and BSD, but not SVr3. + * sigset restarts, but is only available under SVr4/Solaris. + * + * The signal(3) call is mandated by the ANSI standard, and its + * interaction with sigaction(2) is described in the POSIX standard + * (3.3.4.2, page 72,line 934). According to section 8.1, page 191, + * however, signal(3) itself is not required by POSIX.1. And POSIX is + * silent on whether it is required to restart signals. + * + * So. The present situation is, we use sigaction(2) with no + * guarantee of restart anywhere but on Linux and BSD. We could + * switch to signal(3) and collar Linux, BSD, and SVr4. Any way + * we slice it, System V UNIXes older than SVr4 will probably lose + * (this may include XENIX). + * + * This implementation will probably be changed to use signal(3) in + * the future. If nothing else, it is simpler... + */ + +#if USE_SIGTSTP +static void +handle_SIGTSTP(int dummy GCC_UNUSED) +{ + SCREEN *sp = CURRENT_SCREEN; + sigset_t mask, omask; + sigaction_t act, oact; + +#ifdef SIGTTOU + int sigttou_blocked; +#endif + + _nc_globals.have_sigtstp = 1; + T(("handle_SIGTSTP() called")); + + /* + * The user may have changed the prog_mode tty bits, so save them. + * + * But first try to detect whether we still are in the foreground + * process group - if not, an interactive shell may already have + * taken ownership of the tty and modified the settings when our + * parent was stopped before us, and we would likely pick up the + * settings already modified by the shell. + * + * Don't do this if we're not in curses - + */ + if (sp != NULL && (sp->_endwin == ewRunning)) +#if HAVE_TCGETPGRP + if (tcgetpgrp(STDIN_FILENO) == getpgrp()) +#endif + NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG); + + /* + * Block window change and timer signals. The latter + * is because applications use timers to decide when + * to repaint the screen. + */ + (void) sigemptyset(&mask); +#ifdef SIGALRM + (void) sigaddset(&mask, SIGALRM); +#endif +#if USE_SIGWINCH + (void) sigaddset(&mask, SIGWINCH); +#endif + (void) sigprocmask(SIG_BLOCK, &mask, &omask); + +#ifdef SIGTTOU + sigttou_blocked = sigismember(&omask, SIGTTOU); + if (!sigttou_blocked) { + (void) sigemptyset(&mask); + (void) sigaddset(&mask, SIGTTOU); + (void) sigprocmask(SIG_BLOCK, &mask, NULL); + } +#endif + + /* + * End window mode, which also resets the terminal state to the + * original (pre-curses) modes. + */ + NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG); + + /* Unblock SIGTSTP. */ + (void) sigemptyset(&mask); + (void) sigaddset(&mask, SIGTSTP); +#ifdef SIGTTOU + if (!sigttou_blocked) { + /* Unblock this too if it wasn't blocked on entry */ + (void) sigaddset(&mask, SIGTTOU); + } +#endif + (void) sigprocmask(SIG_UNBLOCK, &mask, NULL); + + /* Now we want to resend SIGSTP to this process and suspend it */ + act.sa_handler = SIG_DFL; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; +#ifdef SA_RESTART + act.sa_flags |= SA_RESTART; +#endif /* SA_RESTART */ + sigaction(SIGTSTP, &act, &oact); + kill(getpid(), SIGTSTP); + + /* Process gets suspended...time passes...process resumes */ + + T(("SIGCONT received")); + sigaction(SIGTSTP, &oact, NULL); + NCURSES_SP_NAME(flushinp) (NCURSES_SP_ARG); + + /* + * If the user modified the tty state while suspended, he wants + * those changes to stick. So save the new "default" terminal state. + */ + NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG); + + /* + * This relies on the fact that doupdate() will restore the + * program-mode tty state, and issue enter_ca_mode if need be. + */ + NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG); + + /* Reset the signals. */ + (void) sigprocmask(SIG_SETMASK, &omask, NULL); +} +#endif /* USE_SIGTSTP */ + +static void +handle_SIGINT(int sig) +{ + SCREEN *sp = CURRENT_SCREEN; + + /* + * Much of this is unsafe from a signal handler. But we'll _try_ to clean + * up the screen and terminal settings on the way out. + * + * There are at least the following problems: + * 1) Walking the SCREEN list is unsafe, since all list management + * is done without any signal blocking. + * 2) On systems which have REENTRANT turned on, set_term() uses + * _nc_lock_global() which could deadlock or misbehave in other ways. + * 3) endwin() calls all sorts of stuff, many of which use stdio or + * other library functions which are clearly unsafe. + */ + if (!_nc_globals.cleanup_nested++ + && (sig == SIGINT || sig == SIGTERM)) { +#if HAVE_SIGACTION || HAVE_SIGVEC + sigaction_t act; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = SIG_IGN; + if (sigaction(sig, &act, NULL) == 0) +#else + if (signal(sig, SIG_IGN) != SIG_ERR) +#endif + { + SCREEN *scan; + for (each_screen(scan)) { + if (scan->_ofp != NULL + && NC_ISATTY(fileno(scan->_ofp))) { + scan->_outch = NCURSES_SP_NAME(_nc_outch); + } + set_term(scan); + NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG); + if (sp) + sp->_endwin = ewInitial; /* in case of reuse */ + } + } + } + _exit(EXIT_FAILURE); +} + +# ifndef _nc_set_read_thread +NCURSES_EXPORT(void) +_nc_set_read_thread(bool enable) +{ + _nc_lock_global(curses); + if (enable) { +# if USE_WEAK_SYMBOLS + if ((pthread_self) && (pthread_kill) && (pthread_equal)) +# endif + _nc_globals.read_thread = pthread_self(); + } else { + _nc_globals.read_thread = (pthread_t) 0; + } + _nc_unlock_global(curses); +} +# endif + +#if USE_SIGWINCH + +static void +handle_SIGWINCH(int sig GCC_UNUSED) +{ + _nc_globals.have_sigwinch = 1; +# if USE_PTHREADS_EINTR + if (_nc_globals.read_thread) { + if (!pthread_equal(pthread_self(), _nc_globals.read_thread)) + pthread_kill(_nc_globals.read_thread, SIGWINCH); + _nc_globals.read_thread = (pthread_t) 0; + } +# endif +} +#endif /* USE_SIGWINCH */ + +/* + * If the given signal is still in its default state, set it to the given + * handler. + */ +static int +CatchIfDefault(int sig, void (*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, 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, &new_act, NULL); + result = TRUE; + } else { + result = FALSE; + } +#else /* !HAVE_SIGACTION */ + void (*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); + result = TRUE; + } else { + signal(sig, ohandler); + result = FALSE; + } +#endif + T(("CatchIfDefault - will%s catch %s", + result ? "" : " not", signal_name(sig))); + return result; +} + +/* + * This is invoked once at the beginning (e.g., from 'initscr()'), to + * initialize the signal catchers, and thereafter when spawning a shell (and + * returning) to disable/enable the SIGTSTP (i.e., ^Z) catcher. + * + * If the application has already set one of the signals, we'll not modify it + * (during initialization). + * + * The XSI document implies that we shouldn't keep the SIGTSTP handler if + * the caller later changes its mind, but that doesn't seem correct. + */ +NCURSES_EXPORT(void) +_nc_signal_handler(int enable) +{ + T((T_CALLED("_nc_signal_handler(%d)"), enable)); +#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */ + { + 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 + new_sigaction.sa_flags |= SA_RESTART; +#endif /* SA_RESTART */ + new_sigaction.sa_handler = handle_SIGTSTP; + (void) sigaction(SIGTSTP, &new_sigaction, NULL); + } else { + ignore_tstp = TRUE; + } + } + } +#endif /* !USE_SIGTSTP */ + + if (!_nc_globals.init_signals) { + if (enable) { + CatchIfDefault(SIGINT, handle_SIGINT); + CatchIfDefault(SIGTERM, handle_SIGINT); +#if USE_SIGWINCH + CatchIfDefault(SIGWINCH, handle_SIGWINCH); +#endif + _nc_globals.init_signals = TRUE; + } + } + returnVoid; +} diff --git a/ncurses/ncurses/tty/lib_twait.c b/ncurses/ncurses/tty/lib_twait.c new file mode 100644 index 0000000000..226fda7a18 --- /dev/null +++ b/ncurses/ncurses/tty/lib_twait.c @@ -0,0 +1,526 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2015,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + ****************************************************************************/ + +/* +** lib_twait.c +** +** The routine _nc_timed_wait(). +** +** (This file was originally written by Eric Raymond; however except for +** comments, none of the original code remains - T.Dickey). +*/ + +#include + +#if defined __HAIKU__ && defined __BEOS__ +#undef __BEOS__ +#endif + +#ifdef __BEOS__ +#undef false +#undef true +#include +#endif + +#if USE_KLIBC_KBD +#define INCL_KBD +#include +#endif + +#if USE_FUNC_POLL +# if HAVE_SYS_TIME_H +# include +# endif +#elif HAVE_SELECT +# if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT +# include +# endif +# if HAVE_SYS_SELECT_H +# include +# endif +#endif +#if HAVE_SYS_TIME_H +# include +#endif +#undef CUR + +MODULE_ID("$Id: lib_twait.c,v 1.85 2025/03/01 17:07:19 tom Exp $") + +/* + * Returns an elapsed time, in milliseconds (if possible). + */ +static long +_nc_gettime(TimeType * t0, int first) +{ + long res; + +#if PRECISE_GETTIME + TimeType t1; + if (GetClockTime(&t1) == -1) { + *t0 = t1; + res = first ? 0 : 1; + } else if (first) { + *t0 = t1; + res = 0; + } else { + /* .tv_sec and .tv_usec are unsigned, be careful when subtracting */ + if (t0->sub_secs > t1.sub_secs) { + t1.sub_secs += TimeScale; + t1.tv_sec--; + } + res = (long) ((t1.tv_sec - t0->tv_sec) * 1000L + + (t1.sub_secs - t0->sub_secs) / (TimeScale / 1000L)); + } +#else + time_t t1 = time((time_t *) 0); + if (first) { + *t0 = t1; + } + res = (long) ((t1 - *t0) * 1000); +#endif + 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; + + if (evl != NULL) { + int n; + + for (n = 0; n < evl->count; ++n) { + _nc_event *ev = evl->events[n]; + + if (ev->type == _NC_EVENT_TIMEOUT_MSEC) { + event_delay = (int) ev->data.timeout_msec; + if (event_delay < 0) + event_delay = INT_MAX; /* FIXME Is this defined? */ + } + } + } + return event_delay; +} +#endif /* NCURSES_WGETCH_EVENTS */ + +#if (USE_FUNC_POLL || HAVE_SELECT) +# define MAYBE_UNUSED +#else +# define MAYBE_UNUSED GCC_UNUSED +#endif + +#if (USE_FUNC_POLL || HAVE_SELECT) +# define MAYBE_UNUSED +#else +# define MAYBE_UNUSED GCC_UNUSED +#endif + +/* + * Wait a specified number of milliseconds, returning nonzero if the timer + * didn't expire before there is activity on the specified file descriptors. + * The file-descriptors are specified by the mode: + * TW_NONE 0 - none (absolute time) + * TW_INPUT 1 - ncurses' normal input-descriptor + * TW_MOUSE 2 - mouse descriptor, if any + * TW_ANY 3 - either input or mouse. + * TW_EVENT 4 - + * 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(const SCREEN *sp MAYBE_UNUSED, + int mode MAYBE_UNUSED, + int milliseconds, + int *timeleft + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + int count; + int result = TW_NONE; + TimeType t0; +#if (USE_FUNC_POLL || HAVE_SELECT) + int fd; +#endif + +#ifdef NCURSES_WGETCH_EVENTS + int timeout_is_event = 0; + int n; +#endif + +#if USE_FUNC_POLL +#define MIN_FDS 2 + struct pollfd fd_list[MIN_FDS]; + struct pollfd *fds = fd_list; +#elif defined(__BEOS__) +#elif HAVE_SELECT + fd_set set; +#endif + +#if USE_KLIBC_KBD + fd_set saved_set; + KBDKEYINFO ki; + struct timeval tv; +#endif + + long starttime, returntime; + +#ifdef NCURSES_WGETCH_EVENTS + (void) timeout_is_event; +#endif + + TR(TRACE_IEVENT, ("start twait: %d milliseconds, mode: %d", + milliseconds, mode)); + +#ifdef NCURSES_WGETCH_EVENTS + if (mode & TW_EVENT) { + 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(&t0, TRUE); + + count = 0; + (void) count; + +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && evl) + evl->result_flags = 0; +#endif + +#if USE_FUNC_POLL + memset(fd_list, 0, sizeof(fd_list)); + +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && evl) { + if (fds == fd_list) + fds = typeMalloc(struct pollfd, MIN_FDS + evl->count); + if (fds == NULL) + return TW_NONE; + } +#endif + + if (mode & TW_INPUT) { + fds[count].fd = sp->_ifd; + fds[count].events = POLLIN; + count++; + } + if ((mode & TW_MOUSE) + && (fd = sp->_mouse_fd) >= 0) { + fds[count].fd = fd; + fds[count].events = POLLIN; + count++; + } +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && 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 = (int) poll(fds, (size_t) count, milliseconds); + +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && 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; + } + } + } +#endif + +#elif defined(__BEOS__) + /* + * BeOS's select() is declared in socket.h, so the configure script does + * not see it. That's just as well, since that function works only for + * sockets. This (using snooze and ioctl) was distilled from Be's patch + * for ncurses which uses a separate thread to simulate select(). + * + * 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 = TW_NONE; + if (mode & TW_INPUT) { + 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 */ + useconds = 1; + + 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 && 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 !USE_KLIBC_KBD + if (mode & TW_INPUT) { + FD_SET(sp->_ifd, &set); + count = sp->_ifd + 1; + } +#endif + if ((mode & TW_MOUSE) + && (fd = sp->_mouse_fd) >= 0) { + FD_SET(fd, &set); + count = Max(fd, count) + 1; + } +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && 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)) { + FD_SET(ev->data.fev.fd, &set); + count = Max(ev->data.fev.fd + 1, count); + } + } + } +#endif + +#if USE_KLIBC_KBD + for (saved_set = set;; set = saved_set) { + if ((mode & TW_INPUT) + && (sp->_extended_key + || (KbdPeek(&ki, 0) == 0 + && (ki.fbStatus & KBDTRF_FINAL_CHAR_IN)))) { + FD_ZERO(&set); + FD_SET(sp->_ifd, &set); + result = 1; + break; + } + + tv.tv_sec = 0; + tv.tv_usec = (milliseconds == 0) ? 0 : (10 * 1000); + + if ((result = select(count, &set, NULL, NULL, &tv)) != 0) + break; + + /* Time out ? */ + if (milliseconds >= 0 && _nc_gettime(&t0, FALSE) >= milliseconds) { + result = 0; + break; + } + } +#else + if (milliseconds >= 0) { + struct timeval ntimeout; + ntimeout.tv_sec = milliseconds / 1000; + ntimeout.tv_usec = (milliseconds % 1000) * 1000; + result = select(count, &set, NULL, NULL, &ntimeout); + } else { + result = select(count, &set, NULL, NULL, NULL); + } +#endif + +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && 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 + +#endif /* USE_FUNC_POLL, etc */ + + returntime = _nc_gettime(&t0, FALSE); + + if (milliseconds >= 0) + milliseconds -= (int) (returntime - starttime); + +#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 + * alone so that it can complete. Make this process sleep, + * then come back for more. + */ + if (result == 0 && milliseconds > 100) { + napms(100); /* FIXME: this won't be right if I recur! */ + milliseconds -= 100; + goto retry; + } +#endif + + /* return approximate time left in milliseconds */ + if (timeleft) + *timeleft = 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 + * that are active. Translate this back to the mask that denotes which + * file-descriptors, so that we don't need all of this system-specific + * code everywhere. + */ + if (result != 0) { + if (result > 0) { + result = 0; +#if USE_FUNC_POLL + for (count = 0; count < MIN_FDS; count++) { + if ((mode & (1 << count)) + && (fds[count].revents & POLLIN)) { + result |= (1 << count); + } + } +#elif defined(__BEOS__) + result = TW_INPUT; /* redundant, but simple */ +#elif HAVE_SELECT + if ((mode & TW_MOUSE) + && (fd = sp->_mouse_fd) >= 0 + && FD_ISSET(fd, &set)) + result |= TW_MOUSE; + if ((mode & TW_INPUT) + && FD_ISSET(sp->_ifd, &set)) + result |= TW_INPUT; +#endif + } else + result = 0; + } +#ifdef NCURSES_WGETCH_EVENTS + if ((mode & TW_EVENT) && evl && evl->result_flags) + result |= TW_EVENT; +#endif + +#if USE_FUNC_POLL +#ifdef NCURSES_WGETCH_EVENTS + if (fds != fd_list) + free((char *) fds); +#endif +#endif + + return (result); +} diff --git a/ncurses/ncurses/tty/lib_vidattr.c b/ncurses/ncurses/tty/lib_vidattr.c new file mode 100644 index 0000000000..aad25868bb --- /dev/null +++ b/ncurses/ncurses/tty/lib_vidattr.c @@ -0,0 +1,436 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/* + * vidputs(newmode, outc) + * + * newmode is taken to be the logical 'or' of the symbols in curses.h + * representing graphic renditions. The terminal is set to be in all of + * the given modes, if possible. + * + * if the new attribute is normal + * if exit-alt-char-set exists + * emit it + * emit exit-attribute-mode + * else if set-attributes exists + * use it to set exactly what you want + * else + * if exit-attribute-mode exists + * turn off everything + * else + * turn off those which can be turned off and aren't in + * newmode. + * turn on each mode which should be on and isn't, one by one + * + * NOTE that this algorithm won't achieve the desired mix of attributes + * in some cases, but those are probably just those cases in which it is + * actually impossible, anyway, so... + * + * NOTE that we cannot assume that there's no interaction between color + * and other attribute resets. So each time we reset color (or other + * attributes) we'll have to be prepared to restore the other. + */ + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_vidattr.c,v 1.81 2025/12/27 12:41:23 tom Exp $") + +#define doPut(mode) \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc) + +#define TurnOn(mask, mode) \ + if ((turn_on & mask) && mode) { \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \ + } + +#define TurnOff(mask, mode) \ + if ((turn_off & mask) && mode) { \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \ + turn_off &= ~mask; \ + } + + /* if there is no current screen, assume we *can* do color */ +#define SetColorsIf(why, old_attr) \ + if (can_color && (why)) { \ + int old_pair = PairNumber(old_attr); \ + TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \ + if ((pair != old_pair) \ + || (fix_pair0 && (pair == 0)) \ + || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \ + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \ + (short) old_pair, \ + (short) pair, \ + reverse, outc); \ + } \ + } + +#define PreviousAttr _nc_prescreen.previous_attr + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx + chtype newmode, + NCURSES_SP_OUTC outc) +{ + attr_t turn_on, turn_off; + int pair; + bool reverse = FALSE; + bool can_color = (SP_PARM == NULL || SP_PARM->_coloron); +#if NCURSES_EXT_FUNCS + bool fix_pair0 = (SP_PARM != NULL && SP_PARM->_coloron && !SP_PARM->_default_color); +#else +#define fix_pair0 FALSE +#endif + + newmode &= A_ATTRIBUTES; + + T((T_CALLED("vidputs(%p,%s)"), (void *) SP_PARM, _traceattr(newmode))); + + if (!IsValidTIScreen(SP_PARM)) + returnCode(ERR); + + /* this allows us to go on whether or not newterm() has been called */ + if (SP_PARM) + PreviousAttr = AttrOf(SCREEN_ATTRS(SP_PARM)); + + TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(PreviousAttr))); + + if ((SP_PARM != NULL) + && (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, +#if USE_ITALIC + A_ITALIC, +#endif + }; + unsigned n; + int used = 0; +#ifdef max_attributes /* not in U/Win */ + int limit = (max_attributes <= 0) ? 1 : max_attributes; +#else + int limit = 1; +#endif + 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_PARM->_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_PARM->_xmc_suppress); +#endif + TR(TRACE_ATTRS, ("suppressed attribute is %s", _traceattr(newmode))); + } + + /* + * If we have a terminal that cannot combine color with video + * attributes, use the colors in preference. + */ + if (((newmode & A_COLOR) != 0 + || fix_pair0) + && (no_color_video > 0)) { + /* + * If we had chosen the A_xxx definitions to correspond to the + * no_color_video mask, we could simply shift it up and mask off the + * attributes. But we did not (actually copied Solaris' definitions). + * However, this is still simpler/faster than a lookup table. + * + * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK, + * A_DIM, A_BOLD which are 1:1 with no_color_video. The bits that + * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and + * A_ALTCHARSET (256) down 2 to line up. We use the NCURSES_BITS + * macro so this will work properly for the wide-character layout. + */ + unsigned value = (unsigned) no_color_video; + attr_t mask = NCURSES_BITS((value & 63) + | ((value & 192) << 1) + | ((value & 256) >> 2), 8); + + if ((mask & A_REVERSE) != 0 + && (newmode & A_REVERSE) != 0) { + reverse = TRUE; + mask &= ~A_REVERSE; + } + newmode &= ~mask; + } + + if (newmode == PreviousAttr) + returnCode(OK); + + pair = PairNumber(newmode); + + if (reverse) { + newmode &= ~A_REVERSE; + } + + turn_off = (~newmode & PreviousAttr) & ALL_BUT_COLOR; + turn_on = (newmode & ~(PreviousAttr & TPARM_ATTR)) & ALL_BUT_COLOR; + + SetColorsIf(((pair == 0) && !fix_pair0), PreviousAttr); + + if (newmode == A_NORMAL) { + if ((PreviousAttr & A_ALTCHARSET) && exit_alt_charset_mode) { + doPut(exit_alt_charset_mode); + PreviousAttr &= ~A_ALTCHARSET; + } + if (PreviousAttr) { + if (exit_attribute_mode) { + doPut(exit_attribute_mode); + } else { + if (!SP_PARM || SP_PARM->_use_rmul) { + TurnOff(A_UNDERLINE, exit_underline_mode); + } + if (!SP_PARM || SP_PARM->_use_rmso) { + TurnOff(A_STANDOUT, exit_standout_mode); + } +#if USE_ITALIC + if (!SP_PARM || SP_PARM->_use_ritm) { + TurnOff(A_ITALIC, exit_italics_mode); + } +#endif + (void) turn_off; + } + PreviousAttr &= ALL_BUT_COLOR; + } + + SetColorsIf((pair != 0) || fix_pair0, PreviousAttr); + } else if (set_attributes) { + if (turn_on || turn_off) { + TPUTS_TRACE("set_attributes"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_9(set_attributes, + (newmode & A_STANDOUT) != 0, + (newmode & A_UNDERLINE) != 0, + (newmode & A_REVERSE) != 0, + (newmode & A_BLINK) != 0, + (newmode & A_DIM) != 0, + (newmode & A_BOLD) != 0, + (newmode & A_INVIS) != 0, + (newmode & A_PROTECT) != 0, + (newmode & A_ALTCHARSET) != 0), + 1, outc); + PreviousAttr &= ALL_BUT_COLOR; + } +#if USE_ITALIC + if (!SP_PARM || SP_PARM->_use_ritm) { + if (turn_on & A_ITALIC) { + TurnOn(A_ITALIC, enter_italics_mode); + } else if (turn_off & A_ITALIC) { + TurnOff(A_ITALIC, exit_italics_mode); + } + (void) turn_off; + } +#endif + SetColorsIf((pair != 0) || fix_pair0, PreviousAttr); + } else { + + TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off))); + + TurnOff(A_ALTCHARSET, exit_alt_charset_mode); + + if (!SP_PARM || SP_PARM->_use_rmul) { + TurnOff(A_UNDERLINE, exit_underline_mode); + } + + if (!SP_PARM || SP_PARM->_use_rmso) { + TurnOff(A_STANDOUT, exit_standout_mode); + } +#if USE_ITALIC + if (!SP_PARM || SP_PARM->_use_ritm) { + TurnOff(A_ITALIC, exit_italics_mode); + } +#endif + if (turn_off && exit_attribute_mode) { + doPut(exit_attribute_mode); + turn_on |= (newmode & ALL_BUT_COLOR); + PreviousAttr &= ALL_BUT_COLOR; + } + SetColorsIf((pair != 0) || fix_pair0, PreviousAttr); + + TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on))); + /* *INDENT-OFF* */ + TurnOn(A_ALTCHARSET, enter_alt_charset_mode); + TurnOn(A_BLINK, enter_blink_mode); + TurnOn(A_BOLD, enter_bold_mode); + TurnOn(A_DIM, enter_dim_mode); + TurnOn(A_REVERSE, enter_reverse_mode); + TurnOn(A_STANDOUT, enter_standout_mode); + TurnOn(A_PROTECT, enter_protected_mode); + TurnOn(A_INVIS, enter_secure_mode); + TurnOn(A_UNDERLINE, enter_underline_mode); +#if USE_ITALIC + TurnOn(A_ITALIC, enter_italics_mode); +#endif +#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode) + 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* */ + } + + if (reverse) + newmode |= A_REVERSE; + + if (SP_PARM) + SetAttr(SCREEN_ATTRS(SP_PARM), newmode); + else + PreviousAttr = newmode; + + returnCode(OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +vidputs(chtype newmode, NCURSES_OUTC outc) +{ + SetSafeOutcWrapper(outc); + return NCURSES_SP_NAME(vidputs) (CURRENT_SCREEN, + newmode, + _nc_outc_wrapper); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(vidattr) (NCURSES_SP_DCLx chtype newmode) +{ + T((T_CALLED("vidattr(%p,%s)"), (void *) SP_PARM, _traceattr(newmode))); + returnCode(NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx + newmode, + NCURSES_SP_NAME(_nc_putchar))); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +vidattr(chtype newmode) +{ + return NCURSES_SP_NAME(vidattr) (CURRENT_SCREEN, newmode); +} +#endif + +NCURSES_EXPORT(chtype) +NCURSES_SP_NAME(termattrs) (NCURSES_SP_DCL0) +{ + chtype attrs = A_NORMAL; + + T((T_CALLED("termattrs(%p)"), (void *) SP_PARM)); + + if (HasTerminal(SP_PARM)) { +#if USE_TERM_DRIVER + attrs = CallDriver(SP_PARM, td_conattr); +#else /* ! USE_TERM_DRIVER */ + + if (enter_alt_charset_mode) + attrs |= A_ALTCHARSET; + + if (enter_blink_mode) + attrs |= A_BLINK; + + if (enter_bold_mode) + attrs |= A_BOLD; + + if (enter_dim_mode) + attrs |= A_DIM; + + if (enter_reverse_mode) + attrs |= A_REVERSE; + + if (enter_standout_mode) + attrs |= A_STANDOUT; + + if (enter_protected_mode) + attrs |= A_PROTECT; + + if (enter_secure_mode) + attrs |= A_INVIS; + + if (enter_underline_mode) + attrs |= A_UNDERLINE; + + if (SP_PARM->_coloron) + attrs |= A_COLOR; + +#if USE_ITALIC + if (enter_italics_mode) + attrs |= A_ITALIC; +#endif + +#endif /* USE_TERM_DRIVER */ + } + returnChtype(attrs); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(chtype) +termattrs(void) +{ + return NCURSES_SP_NAME(termattrs) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/tty/tty_update.c b/ncurses/ncurses/tty/tty_update.c new file mode 100644 index 0000000000..1450728bf1 --- /dev/null +++ b/ncurses/ncurses/tty/tty_update.c @@ -0,0 +1,2303 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * + ****************************************************************************/ + +/*----------------------------------------------------------------- + * + * lib_doupdate.c + * + * The routine doupdate() and its dependents. + * All physical output is concentrated here (except _nc_outch() + * in lib_tputs.c). + * + *-----------------------------------------------------------------*/ + +#define NEW_PAIR_INTERNAL 1 + +#include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +#if defined __HAIKU__ && defined __BEOS__ +#undef __BEOS__ +#endif + +#ifdef __BEOS__ +#undef false +#undef true +#include +#endif + +#if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES +#define USE_TRACE_TIMES 1 +#else +#define USE_TRACE_TIMES 0 +#endif + +#if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT +#include +#endif + +#if USE_TRACE_TIMES +#include +#endif + +#if USE_FUNC_POLL +#elif HAVE_SELECT +#if HAVE_SYS_SELECT_H +#include +#endif +#endif + +#include + +#if USE_WIDEC_SUPPORT +#if HAVE_WCTYPE_H +#include +#endif +#endif + +MODULE_ID("$Id: tty_update.c,v 1.323 2025/12/27 12:34:03 tom Exp $") + +/* + * This define controls the line-breakout optimization. Every once in a + * while during screen refresh, we want to check for input and abort the + * update if there's some waiting. CHECK_INTERVAL controls the number of + * changed lines to be emitted between input checks. + * + * Note: Input-check-and-abort is no longer done if the screen is being + * updated from scratch. This is a feature, not a bug. + */ +#define CHECK_INTERVAL 5 + +#define FILL_BCE(sp) (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 + * work ONLY on ANSI-compatible terminals! + */ +/* #define POSITION_DEBUG */ + +static NCURSES_INLINE NCURSES_CH_T ClrBlank(NCURSES_SP_DCLx WINDOW *win); + +#if NCURSES_SP_FUNCS +static int ClrBottom(SCREEN *, int total); +static void ClearScreen(SCREEN *, NCURSES_CH_T blank); +static void ClrUpdate(SCREEN *); +static void DelChar(SCREEN *, int count); +static void InsStr(SCREEN *, NCURSES_CH_T *line, int count); +static void TransformLine(SCREEN *, int const lineno); +#else +static int ClrBottom(int total); +static void ClearScreen(NCURSES_CH_T blank); +static void ClrUpdate(void); +static void DelChar(int count); +static void InsStr(NCURSES_CH_T *line, int count); +static void TransformLine(int const lineno); +#endif + +#ifdef POSITION_DEBUG +/**************************************************************************** + * + * Debugging code. Only works on ANSI-standard terminals. + * + ****************************************************************************/ + +static void +position_check(NCURSES_SP_DCLx int expected_y, int expected_x, const char *legend) +/* check to see if the real cursor position matches the virtual */ +{ + char buf[20]; + char *s; + int y, x; + + if (!_nc_tracing || (expected_y < 0 && expected_x < 0)) + return; + + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + memset(buf, '\0', sizeof(buf)); + NCURSES_PUTP2_FLUSH("cpr", "\033[6n"); /* only works on ANSI-compatibles */ + *(s = buf) = 0; + do { + int ask = sizeof(buf) - 1 - (s - buf); + int got = read(0, s, ask); + if (got == 0) + break; + s += got; + } while (strchr(buf, 'R') == 0); + _tracef("probe returned %s", _nc_visbuf(buf)); + + /* try to interpret as a position report */ + if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) { + _tracef("position probe failed in %s", legend); + } else { + if (expected_x < 0) + expected_x = x - 1; + if (expected_y < 0) + expected_y = y - 1; + if (y - 1 != expected_y || x - 1 != expected_x) { + NCURSES_SP_NAME(beep) (NCURSES_SP_ARG); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_2("\033[%d;%dH", + expected_y + 1, + expected_x + 1), + 1, NCURSES_SP_NAME(_nc_outch)); + _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s", + y - 1, x - 1, expected_y, expected_x, legend); + } else { + _tracef("position matches OK in %s", legend); + } + } +} +#else +#define position_check(expected_y, expected_x, legend) /* nothing */ +#endif /* POSITION_DEBUG */ + +/**************************************************************************** + * + * Optimized update code + * + ****************************************************************************/ + +static NCURSES_INLINE void +GoTo(NCURSES_SP_DCLx int const row, int const col) +{ + TR(TRACE_MOVE, ("GoTo(%p, %d, %d) from (%d, %d)", + (void *) SP_PARM, row, col, SP_PARM->_cursrow, SP_PARM->_curscol)); + + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, "GoTo"); + + TINFO_MVCUR(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + row, col); + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, "GoTo2"); +} + +#if !NCURSES_WCWIDTH_GRAPHICS +#define is_wacs_value(ch) (_nc_wacs_width((wchar_t) ch) == 1 && wcwidth(ch) > 1) +#endif /* !NCURSES_WCWIDTH_GRAPHICS */ + +static NCURSES_INLINE void +PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) +{ + int chlen = 1; + NCURSES_CH_T my_ch; +#if USE_WIDEC_SUPPORT + PUTC_DATA; +#endif + NCURSES_CH_T tilde; + NCURSES_CH_T attr = CHDEREF(ch); + + TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)", + _tracech_t(ch), + SP_PARM->_cursrow, SP_PARM->_curscol)); +#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 = _nc_wacs_width(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))) +#if USE_WIDEC_SUPPORT + || iswprint((wint_t) CharOf(CHDEREF(ch))) +#endif + || (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160) + || (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128) + || (AttrOf(attr) & A_ALTCHARSET + && ((CharOfD(ch) < ACS_LEN + && SP_PARM->_acs_map != NULL + && SP_PARM->_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_PARM->_acs_map != NULL + && ((CharOfD(ch) < ACS_LEN) +#if !NCURSES_WCWIDTH_GRAPHICS + || is_wacs_value(CharOfD(ch)) +#endif + )) { + int c8; + my_ch = CHDEREF(ch); /* work around const param */ + c8 = (int) CharOf(my_ch); +#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_PARM->_screen_unicode + && _nc_wacs[CharOf(my_ch)].chars[0]) { + if (SP_PARM->_screen_acs_map[CharOf(my_ch)]) { + if (SP_PARM->_screen_acs_fix) { + RemAttr(attr, A_ALTCHARSET); + my_ch = _nc_wacs[CharOf(my_ch)]; + } + } else { + RemAttr(attr, A_ALTCHARSET); + my_ch = _nc_wacs[CharOf(my_ch)]; + } +#if !NCURSES_WCWIDTH_GRAPHICS + if (!(AttrOf(attr) & A_ALTCHARSET)) { + chlen = 1; + } +#endif /* !NCURSES_WCWIDTH_GRAPHICS */ + } else +#endif + if (!SP_PARM->_screen_acs_map[c8]) { + /* + * If we found no mapping for a given alternate-character set item + * in the terminal description, attempt to use the ASCII fallback + * code which is populated in the _acs_map[] array. If that did + * not correspond to a line-drawing, etc., graphics character, the + * array entry would be empty. + */ + chtype temp = UChar(SP_PARM->_acs_map[c8]); + if (temp) { + RemAttr(attr, A_ALTCHARSET); + SetChar(my_ch, temp, AttrOf(attr)); + } + } + + /* + * 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 = (int) CharOfD(ch); + chtype temp = UChar(SP_PARM->_acs_map[j]); + + if (temp != 0) { + SetChar(my_ch, temp, AttrOf(attr)); + } else { + my_ch = CHDEREF(ch); + RemAttr(attr, A_ALTCHARSET); + } + } + ch = CHREF(my_ch); + } +#if USE_WIDEC_SUPPORT && !NCURSES_WCWIDTH_GRAPHICS + else if (chlen > 1 && is_wacs_value(CharOfD(ch))) { + chlen = 1; + } +#endif + if (tilde_glitch && (CharOfD(ch) == L('~'))) { + SetChar(tilde, L('`'), AttrOf(attr)); + ch = CHREF(tilde); + } + + UpdateAttrs(SP_PARM, attr); + PUTC(CHDEREF(ch)); +#if !USE_WIDEC_SUPPORT + COUNT_OUTCHARS(1); +#endif + SP_PARM->_curscol += chlen; + if (char_padding) { + NCURSES_PUTP2("char_padding", char_padding); + } +} + +static bool +check_pending(NCURSES_SP_DCL0) +/* check for pending input */ +{ + bool have_pending = FALSE; + + /* + * Only carry out this check when the flag is zero, otherwise we'll + * have the refreshing slow down drastically (or stop) if there's an + * unread character available. + */ + if (SP_PARM->_fifohold != 0) + return FALSE; + + if (SP_PARM->_checkfd >= 0) { +#if USE_FUNC_POLL + struct pollfd fds[1]; + fds[0].fd = SP_PARM->_checkfd; + fds[0].events = POLLIN; + if (poll(fds, (size_t) 1, 0) > 0) { + have_pending = TRUE; + } +#elif defined(__BEOS__) + /* + * BeOS's select() is declared in socket.h, so the configure script does + * not see it. That's just as well, since that function works only for + * sockets. This (using snooze and ioctl) was distilled from Be's patch + * for ncurses which uses a separate thread to simulate select(). + * + * FIXME: the return values from the ioctl aren't very clear if we get + * interrupted. + */ + int n = 0; + int howmany = ioctl(0, 'ichr', &n); + if (howmany >= 0 && n > 0) { + have_pending = TRUE; + } +#elif HAVE_SELECT + fd_set fdset; + struct timeval ktimeout; + + ktimeout.tv_sec = + ktimeout.tv_usec = 0; + + FD_ZERO(&fdset); + FD_SET(SP_PARM->_checkfd, &fdset); + if (select(SP_PARM->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) { + have_pending = TRUE; + } +#endif + } + if (have_pending) { + SP_PARM->_fifohold = 5; + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + } + return FALSE; +} + +/* put char at lower right corner */ +static void +PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch) +{ + if (!auto_right_margin) { + /* we can put the char directly */ + PutAttrChar(NCURSES_SP_ARGx ch); + } else if (enter_am_mode && exit_am_mode) { + int oldcol = SP_PARM->_curscol; + /* we can suppress automargin */ + NCURSES_PUTP2("exit_am_mode", exit_am_mode); + + PutAttrChar(NCURSES_SP_ARGx ch); + SP_PARM->_curscol = oldcol; + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + "exit_am_mode"); + + NCURSES_PUTP2("enter_am_mode", enter_am_mode); + } else if ((enter_insert_mode && exit_insert_mode) + || insert_character || parm_ich) { + GoTo(NCURSES_SP_ARGx + screen_lines(SP_PARM) - 1, + screen_columns(SP_PARM) - 2); + PutAttrChar(NCURSES_SP_ARGx ch); + GoTo(NCURSES_SP_ARGx + screen_lines(SP_PARM) - 1, + screen_columns(SP_PARM) - 2); + InsStr(NCURSES_SP_ARGx + NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text + + screen_columns(SP_PARM) - 2, 1); + } +} + +/* + * Wrap the cursor position, i.e., advance to the beginning of the next line. + */ +static void +wrap_cursor(NCURSES_SP_DCL0) +{ + 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. + * + * 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 is safe to just tell the code that the cursor is in hyperspace and + * let the next mvcur() call straighten things out. + */ + SP_PARM->_curscol = -1; + SP_PARM->_cursrow = -1; + } else if (auto_right_margin) { + SP_PARM->_curscol = 0; + SP_PARM->_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_PARM))) { + TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping", + (unsigned long) AttrOf(SCREEN_ATTRS(SP_PARM)), + _traceattr(AttrOf(SCREEN_ATTRS(SP_PARM))))); + VIDPUTS(SP_PARM, A_NORMAL, 0); + } + } else { + SP_PARM->_curscol--; + } + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + "wrap_cursor"); +} + +static NCURSES_INLINE void +PutChar(NCURSES_SP_DCLx const ARG_CH_T ch) +/* insert character, handling automargin stuff */ +{ + if (SP_PARM->_cursrow == screen_lines(SP_PARM) - 1 && + SP_PARM->_curscol == screen_columns(SP_PARM) - 1) { + PutCharLR(NCURSES_SP_ARGx ch); + } else { + PutAttrChar(NCURSES_SP_ARGx ch); + } + + if (SP_PARM->_curscol >= screen_columns(SP_PARM)) + wrap_cursor(NCURSES_SP_ARG); + + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, "PutChar"); +} + +/* + * Check whether the given character can be output by clearing commands. This + * includes test for being a space and not including any 'bad' attributes, such + * 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 NCURSES_INLINE bool +can_clear_with(NCURSES_SP_DCLx ARG_CH_T ch) +{ + if (!back_color_erase && SP_PARM->_coloron) { +#if NCURSES_EXT_FUNCS + int pair; + + if (!SP_PARM->_default_color) + return FALSE; + if (!(isDefaultColor(SP_PARM->_default_fg) && + isDefaultColor(SP_PARM->_default_bg))) + return FALSE; + if ((pair = GetPair(CHDEREF(ch))) != 0) { + NCURSES_COLOR_T fg, bg; + if (NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx + (short) pair, + &fg, &bg) == ERR + || !(isDefaultColor(fg) && isDefaultColor(bg))) { + return FALSE; + } + } +#else + if (AttrOfD(ch) & A_COLOR) + return FALSE; +#endif + } + return (ISBLANK(CHDEREF(ch)) && + (AttrOfD(ch) & ~(NONBLANK_ATTR | A_COLOR)) == BLANK_ATTR); +} + +/* + * Issue a given span of characters from an array. + * Must be functionally equivalent to: + * for (i = 0; i < num; i++) + * PutChar(ntext[i]); + * but can leave the cursor positioned at the middle of the interval. + * + * Returns: 0 - cursor is at the end of interval + * 1 - cursor is somewhere in the middle + * + * This code is optimized using ech and rep. + */ +static int +EmitRange(NCURSES_SP_DCLx 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; + NCURSES_CH_T ntext0; + + while (num > 1 && !CharEq(ntext[0], ntext[1])) { + PutChar(NCURSES_SP_ARGx CHREF(ntext[0])); + ntext++; + num--; + } + ntext0 = ntext[0]; + if (num == 1) { + PutChar(NCURSES_SP_ARGx CHREF(ntext0)); + return 0; + } + runcount = 2; + + while (runcount < num && CharEq(ntext[runcount], ntext0)) + runcount++; + + /* + * The cost expression in the middle isn't exactly right. + * _cup_ch_cost is an upper bound on the cost for moving to the + * end of the erased area, but not the cost itself (which we + * can't compute without emitting the move). This may result + * in erase_chars not getting used in some situations for + * which it would be marginally advantageous. + */ + if (erase_chars + && runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost + && can_clear_with(NCURSES_SP_ARGx CHREF(ntext0))) { + UpdateAttrs(SP_PARM, ntext0); + NCURSES_PUTP2("erase_chars", TIPARM_1(erase_chars, runcount)); + + /* + * If this is the last part of the given interval, + * don't bother moving cursor, since it can be the + * last update on the line. + */ + if (runcount < num) { + GoTo(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol + runcount); + } else { + return 1; /* cursor stays in the middle */ + } + } else if (repeat_char != NULL && +#if BSD_TPUTS + !isdigit(UChar(CharOf(ntext0))) && +#endif +#if USE_WIDEC_SUPPORT + (!SP_PARM->_screen_unicode && + (CharOf(ntext0) < ((AttrOf(ntext0) & A_ALTCHARSET) + ? ACS_LEN + : 256))) && +#endif + runcount > SP_PARM->_rep_cost) { + NCURSES_CH_T temp; + bool wrap_possible = (SP_PARM->_curscol + runcount >= + screen_columns(SP_PARM)); + int rep_count = runcount; + + if (wrap_possible) + rep_count--; + + UpdateAttrs(SP_PARM, ntext0); + temp = ntext0; + if ((AttrOf(temp) & A_ALTCHARSET) && + SP_PARM->_acs_map != NULL && + (SP_PARM->_acs_map[CharOf(temp)] & A_CHARTEXT) != 0) { + SetChar(temp, + (SP_PARM->_acs_map[CharOf(ntext0)] & A_CHARTEXT), + AttrOf(ntext0) | A_ALTCHARSET); + } + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_2(repeat_char, + CharOf(temp), + rep_count), + 1, + NCURSES_SP_NAME(_nc_outch)); + SP_PARM->_curscol += rep_count; + + if (wrap_possible) + PutChar(NCURSES_SP_ARGx CHREF(ntext0)); + } else { + for (i = 0; i < runcount; i++) + PutChar(NCURSES_SP_ARGx CHREF(ntext[i])); + } + ntext += runcount; + num -= runcount; + } + return 0; + } + + for (i = 0; i < num; i++) + PutChar(NCURSES_SP_ARGx CHREF(ntext[i])); + return 0; +} + +/* + * Output the line in the given range [first .. last] + * + * If there's a run of identical characters that's long enough to justify + * cursor movement, use that also. + * + * Returns: same as EmitRange + */ +static int +PutRange(NCURSES_SP_DCLx + const NCURSES_CH_T *otext, + const NCURSES_CH_T *ntext, + int row, + int first, int last) +{ + int rc; + + TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)", + (void *) SP_PARM, + (const void *) otext, + (const void *) ntext, + row, first, last)); + + if (otext != ntext + && (last - first + 1) > SP_PARM->_inline_cost) { + int i, j, same; + + for (j = first, same = 0; j <= last; j++) { + if (!same && isWidecExt(otext[j])) + continue; + if (CharEq(otext[j], ntext[j])) { + same++; + } else { + if (same > SP_PARM->_inline_cost) { + EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first); + GoTo(NCURSES_SP_ARGx row, first = j); + } + same = 0; + } + } + i = EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first); + /* + * Always return 1 for the next GoTo() after a PutRange() if we found + * identical characters at end of interval + */ + rc = (same == 0 ? i : 1); + } else { + rc = EmitRange(NCURSES_SP_ARGx ntext + first, last - first + 1); + } + return rc; +} + +/* leave unbracketed here so 'indent' works */ +#define MARK_NOCHANGE(win,row) \ + win->_line[row].firstchar = _NOCHANGE; \ + win->_line[row].lastchar = _NOCHANGE; \ + if_USE_SCROLL_HINTS(win->_line[row].oldindex = row) + +NCURSES_EXPORT(int) +TINFO_DOUPDATE(NCURSES_SP_DCL0) +{ + int i; + int nonempty; +#if USE_TRACE_TIMES + struct tms before, after; +#endif /* USE_TRACE_TIMES */ + + T((T_CALLED("_nc_tinfo:doupdate(%p)"), (void *) SP_PARM)); + + _nc_lock_global(update); + + if (SP_PARM == NULL) { + _nc_unlock_global(update); + returnCode(ERR); + } +#if !USE_REENTRANT + /* + * It is "legal" but unlikely that an application could assign a new + * value to one of the standard windows. Check for that possibility + * and try to recover. + * + * We do not allow applications to assign new values in the reentrant + * model. + */ +#if NCURSES_SP_FUNCS + if (SP_PARM == CURRENT_SCREEN) { +#endif +#define SyncScreens(internal,exported) \ + if (internal == NULL) internal = exported; \ + if (internal != exported) exported = internal + + SyncScreens(CurScreen(SP_PARM), curscr); + SyncScreens(NewScreen(SP_PARM), newscr); + SyncScreens(StdScreen(SP_PARM), stdscr); +#if NCURSES_SP_FUNCS + } +#endif +#endif /* !USE_REENTRANT */ + + if (CurScreen(SP_PARM) == NULL + || NewScreen(SP_PARM) == NULL + || StdScreen(SP_PARM) == NULL) { + _nc_unlock_global(update); + returnCode(ERR); + } +#ifdef TRACE + if (USE_TRACEF(TRACE_UPDATE)) { + if (CurScreen(SP_PARM)->_clear) + _tracef("curscr is clear"); + else + _tracedump("curscr", CurScreen(SP_PARM)); + _tracedump("newscr", NewScreen(SP_PARM)); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + + _nc_signal_handler(FALSE); + + if (SP_PARM->_fifohold) + SP_PARM->_fifohold--; + +#if USE_SIZECHANGE + if ((SP_PARM->_endwin == ewSuspend) + || _nc_handle_sigwinch(SP_PARM)) { + /* + * This is a transparent extension: XSI does not address it, + * and applications need not know that ncurses can do it. + * + * Check if the terminal size has changed while curses was off + * (this can happen in an xterm, for example), and resize the + * ncurses data structures accordingly. + */ + _nc_update_screensize(SP_PARM); + } +#endif + + if (SP_PARM->_endwin == ewSuspend) { + + T(("coming back from shell mode")); + NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG); + + NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG); + NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG); + SP_PARM->_mouse_resume(SP_PARM); + + SP_PARM->_endwin = ewRunning; + } +#if USE_TRACE_TIMES + /* zero the metering machinery */ + 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 is 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) { + int j, k; + attr_t rattr = A_NORMAL; + + for (i = 0; i < screen_lines(SP_PARM); i++) { + for (j = 0; j < screen_columns(SP_PARM); j++) { + bool failed = FALSE; + NCURSES_CH_T *thisline = NewScreen(SP_PARM)->_line[i].text; + attr_t thisattr = AttrOf(thisline[j]) & SP_PARM->_xmc_triggers; + attr_t turnon = thisattr & ~rattr; + + /* is an attribute turned on here? */ + if (turnon == 0) { + rattr = thisattr; + continue; + } + + TR(TRACE_ATTRS, ("At (%d, %d): from %s...", i, j, _traceattr(rattr))); + 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. + */ +#define SAFE(scr,a) (!((a) & (scr)->_xmc_triggers)) + if (ISBLANK(thisline[j]) && SAFE(SP_PARM, 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 + || !ISBLANK(thisline[j - k]) + || !SAFE(SP_PARM, 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(SP_PARM, AttrOf(thisline[j - k])) + ? "" + : ":unsafe"))); + break; + } + } + if (!failed) { + bool end_onscreen = FALSE; + int m, n = j; + + /* find end of span, if it is onscreen */ + for (m = i; m < screen_lines(SP_PARM); m++) { + for (; n < screen_columns(SP_PARM); n++) { + attr_t testattr = + AttrOf(NewScreen(SP_PARM)->_line[m].text[n]); + if ((testattr & SP_PARM->_xmc_triggers) == rattr) { + end_onscreen = TRUE; + TR(TRACE_ATTRS, + ("Range attributed with %s ends at (%d, %d)", + _traceattr(turnon), m, n)); + goto foundit; + } + } + n = 0; + } + TR(TRACE_ATTRS, + ("Range attributed with %s ends offscreen", + _traceattr(turnon))); + foundit:; + + if (end_onscreen) { + NCURSES_CH_T *lastline = + NewScreen(SP_PARM)->_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. + */ + while (n >= 0 + && ISBLANK(lastline[n]) + && SAFE(SP_PARM, 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++) { + if (n + k >= screen_columns(SP_PARM) + || !ISBLANK(lastline[n + k]) + || !SAFE(SP_PARM, 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(SP_PARM, AttrOf(lastline[n + k])) + ? "" + : ":unsafe"))); + break; + } + } + } + } + + if (failed) { + int p, q = j; + + TR(TRACE_ATTRS, + ("Clearing %s beginning at (%d, %d)", + _traceattr(turnon), i, j)); + + /* turn off new attributes over span */ + for (p = i; p < screen_lines(SP_PARM); p++) { + for (; q < screen_columns(SP_PARM); q++) { + attr_t testattr = AttrOf(newscr->_line[p].text[q]); + if ((testattr & SP_PARM->_xmc_triggers) == rattr) + goto foundend; + RemAttr(NewScreen(SP_PARM)->_line[p].text[q], turnon); + } + q = 0; + } + foundend:; + } else { + TR(TRACE_ATTRS, + ("Cookie space for %s found before (%d, %d)", + _traceattr(turnon), i, j)); + + /* + * 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++) + AddAttr(thisline[j - k], turnon); + } + + rattr = thisattr; + } + } + +#ifdef TRACE + /* show altered highlights after magic-cookie check */ + if (USE_TRACEF(TRACE_UPDATE)) { + _tracef("After magic-cookie check..."); + _tracedump("newscr", NewScreen(SP_PARM)); + _nc_unlock_global(tracef); + } +#endif /* TRACE */ + } +#endif /* USE_XMC_SUPPORT */ + + nonempty = 0; + if (CurScreen(SP_PARM)->_clear || NewScreen(SP_PARM)->_clear) { /* force refresh ? */ + ClrUpdate(NCURSES_SP_ARG); + CurScreen(SP_PARM)->_clear = FALSE; /* reset flag */ + NewScreen(SP_PARM)->_clear = FALSE; /* reset flag */ + } else { + int changedlines = CHECK_INTERVAL; + + if (check_pending(NCURSES_SP_ARG)) + goto cleanup; + + nonempty = Min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1); + + if (SP_PARM->_scrolling) { + NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_ARG); + } + + nonempty = ClrBottom(NCURSES_SP_ARGx nonempty); + + TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty)); + for (i = 0; i < nonempty; i++) { + /* + * Here is our line-breakout optimization. + */ + if (changedlines == CHECK_INTERVAL) { + if (check_pending(NCURSES_SP_ARG)) + goto cleanup; + changedlines = 0; + } + + /* + * newscr->line[i].firstchar is normally set + * by wnoutrefresh. curscr->line[i].firstchar + * is normally set by _nc_scroll_window in the + * vertical-movement optimization code, + */ + if (NewScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE + || CurScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE) { + TransformLine(NCURSES_SP_ARGx i); + changedlines++; + } + + /* mark line changed successfully */ + if (i <= NewScreen(SP_PARM)->_maxy) { + MARK_NOCHANGE(NewScreen(SP_PARM), i); + } + if (i <= CurScreen(SP_PARM)->_maxy) { + MARK_NOCHANGE(CurScreen(SP_PARM), i); + } + } + } + + /* put everything back in sync */ + for (i = nonempty; i <= NewScreen(SP_PARM)->_maxy; i++) { + MARK_NOCHANGE(NewScreen(SP_PARM), i); + } + for (i = nonempty; i <= CurScreen(SP_PARM)->_maxy; i++) { + MARK_NOCHANGE(CurScreen(SP_PARM), i); + } + + if (!NewScreen(SP_PARM)->_leaveok) { + CurScreen(SP_PARM)->_curx = NewScreen(SP_PARM)->_curx; + CurScreen(SP_PARM)->_cury = NewScreen(SP_PARM)->_cury; + + GoTo(NCURSES_SP_ARGx CurScreen(SP_PARM)->_cury, CurScreen(SP_PARM)->_curx); + } + + cleanup: + /* + * 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. + */ +#if USE_XMC_SUPPORT + if (magic_cookie_glitch != 0) +#endif + UpdateAttrs(SP_PARM, normal); + + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); + WINDOW_ATTRS(CurScreen(SP_PARM)) = WINDOW_ATTRS(NewScreen(SP_PARM)); + +#if USE_TRACE_TIMES + (void) times(&after); + TR(TRACE_TIMES, + ("Update cost: %ld chars, %ld clocks system time, %ld clocks user time", + _nc_outchars, + (long) (after.tms_stime - before.tms_stime), + (long) (after.tms_utime - before.tms_utime))); +#endif /* USE_TRACE_TIMES */ + + _nc_signal_handler(TRUE); + + _nc_unlock_global(update); + returnCode(OK); +} + +#if NCURSES_SP_FUNCS && !USE_TERM_DRIVER +NCURSES_EXPORT(int) +doupdate(void) +{ + return TINFO_DOUPDATE(CURRENT_SCREEN); +} +#endif + +/* + * ClrBlank(win) + * + * Returns the attributed character that corresponds to the "cleared" + * screen. If the terminal has the back-color-erase feature, this will be + * colored according to the wbkgd() call. + * + * We treat 'curscr' specially because it isn't supposed to be set directly + * in the wbkgd() call. Assume 'stdscr' for this case. + */ +#define BCE_ATTRS (A_NORMAL|A_COLOR) +#define BCE_BKGD(sp,win) (((win) == CurScreen(sp) ? StdScreen(sp) : (win))->_nc_bkgd) + +static NCURSES_INLINE NCURSES_CH_T +ClrBlank(NCURSES_SP_DCLx WINDOW *win) +{ + NCURSES_CH_T blank = blankchar; + if (back_color_erase) + AddAttr(blank, (AttrOf(BCE_BKGD(SP_PARM, win)) & BCE_ATTRS)); + return blank; +} + +/* +** ClrUpdate() +** +** Update by clearing and redrawing the entire screen. +** +*/ + +static void +ClrUpdate(NCURSES_SP_DCL0) +{ + TR(TRACE_UPDATE, (T_CALLED("ClrUpdate"))); + if (NULL != SP_PARM) { + int i; + NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); + int nonempty = Min(screen_lines(SP_PARM), + NewScreen(SP_PARM)->_maxy + 1); + + ClearScreen(NCURSES_SP_ARGx blank); + + TR(TRACE_UPDATE, ("updating screen from scratch")); + + nonempty = ClrBottom(NCURSES_SP_ARGx nonempty); + + for (i = 0; i < nonempty; i++) + TransformLine(NCURSES_SP_ARGx i); + } + TR(TRACE_UPDATE, (T_RETURN(""))); +} + +/* +** ClrToEOL(blank) +** +** Clear to end of current line, starting at the cursor position +*/ + +static void +ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear) +{ + if (CurScreen(SP_PARM) != NULL + && SP_PARM->_cursrow >= 0) { + int j; + + for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) { + if (j >= 0) { + NCURSES_CH_T *cp = + &(CurScreen(SP_PARM)->_line[SP_PARM->_cursrow].text[j]); + + if (!CharEq(*cp, blank)) { + *cp = blank; + needclear = TRUE; + } + } + } + } + + if (needclear) { + UpdateAttrs(SP_PARM, blank); + if (clr_eol && SP_PARM->_el_cost <= (screen_columns(SP_PARM) - SP_PARM->_curscol)) { + NCURSES_PUTP2("clr_eol", clr_eol); + } else { + int count = (screen_columns(SP_PARM) - SP_PARM->_curscol); + while (count-- > 0) + PutChar(NCURSES_SP_ARGx CHREF(blank)); + } + } +} + +/* +** ClrToEOS(blank) +** +** Clear to end of screen, starting at the cursor position +*/ + +static void +ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank) +{ + int row, col; + + row = SP_PARM->_cursrow; + col = SP_PARM->_curscol; + + if (row < 0) + row = 0; + if (col < 0) + col = 0; + + UpdateAttrs(SP_PARM, blank); + TPUTS_TRACE("clr_eos"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + clr_eos, + screen_lines(SP_PARM) - row, + NCURSES_SP_NAME(_nc_outch)); + + while (col < screen_columns(SP_PARM)) + CurScreen(SP_PARM)->_line[row].text[col++] = blank; + + for (row++; row < screen_lines(SP_PARM); row++) { + for (col = 0; col < screen_columns(SP_PARM); col++) + CurScreen(SP_PARM)->_line[row].text[col] = blank; + } +} + +/* + * ClrBottom(total) + * + * Test if clearing the end of the screen would satisfy part of the + * screen-update. Do this by scanning backwards through the lines in the + * screen, checking if each is blank, and one or more are changed. + */ +static int +ClrBottom(NCURSES_SP_DCLx int total) +{ + int top = total; + int last = Min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1); + NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1]; + + if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) { + int row; + + for (row = total - 1; row >= 0; row--) { + int col; + bool ok; + + for (col = 0, ok = TRUE; ok && col < last; col++) { + ok = (CharEq(NewScreen(SP_PARM)->_line[row].text[col], blank)); + } + if (!ok) + break; + + for (col = 0; ok && col < last; col++) { + ok = (CharEq(CurScreen(SP_PARM)->_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) { + GoTo(NCURSES_SP_ARGx top, 0); + ClrToEOS(NCURSES_SP_ARGx blank); + if (SP_PARM->oldhash && SP_PARM->newhash) { + for (row = top; row < screen_lines(SP_PARM); row++) + SP_PARM->oldhash[row] = SP_PARM->newhash[row]; + } + } + } + return top; +} + +#if USE_XMC_SUPPORT +#if USE_WIDEC_SUPPORT +#define check_xmc_transition(sp, a, b) \ + ((((a)->attr ^ (b)->attr) & ~((a)->attr) & (sp)->_xmc_triggers) != 0) +#define xmc_turn_on(sp,a,b) check_xmc_transition(sp,&(a), &(b)) +#else +#define xmc_turn_on(sp,a,b) ((((a)^(b)) & ~(a) & (sp)->_xmc_triggers) != 0) +#endif + +#define xmc_new(sp,r,c) NewScreen(sp)->_line[r].text[c] +#define xmc_turn_off(sp,a,b) xmc_turn_on(sp,b,a) +#endif /* USE_XMC_SUPPORT */ + +/* +** TransformLine(lineno) +** +** Transform the given line in curscr to the one in newscr, using +** Insert/Delete Character if idcok && has_ic(). +** +** firstChar = position of first different character in line +** oLastChar = position of last different character in old line +** nLastChar = position of last different character in new line +** +** move to firstChar +** overwrite chars up to Min(oLastChar, nLastChar) +** if oLastChar < nLastChar +** insert newLine[oLastChar+1..nLastChar] +** else +** delete oLastChar - nLastChar spaces +*/ + +static void +TransformLine(NCURSES_SP_DCLx int const lineno) +{ + int firstChar, oLastChar, nLastChar; + NCURSES_CH_T *newLine = NewScreen(SP_PARM)->_line[lineno].text; + NCURSES_CH_T *oldLine = CurScreen(SP_PARM)->_line[lineno].text; + int n; + bool attrchanged = FALSE; + + TR(TRACE_UPDATE, (T_CALLED("TransformLine(%p, %d)"), (void *) SP_PARM, lineno)); + + /* copy new hash value to old one */ + if (SP_PARM->oldhash && SP_PARM->newhash) + SP_PARM->oldhash[lineno] = SP_PARM->newhash[lineno]; + + /* + * 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 + * for this case, and update the old line with the new line's colors when + * they are equivalent. + */ + if (SP_PARM->_coloron) { + int oldPair; + int newPair; + + for (n = 0; n < screen_columns(SP_PARM); n++) { + if (!CharEq(newLine[n], oldLine[n])) { + oldPair = GetPair(oldLine[n]); + newPair = GetPair(newLine[n]); + if (oldPair != newPair + && unColor(oldLine[n]) == unColor(newLine[n])) { + if (oldPair < SP_PARM->_pair_alloc + && newPair < SP_PARM->_pair_alloc + && (isSamePair(SP_PARM->_color_pairs[oldPair], + SP_PARM->_color_pairs[newPair]))) { + SetPair(oldLine[n], GetPair(newLine[n])); + } + } + } + } + } + + if (ceol_standout_glitch && clr_eol) { + firstChar = 0; + while (firstChar < screen_columns(SP_PARM)) { + if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) { + attrchanged = TRUE; + break; + } + firstChar++; + } + } + + firstChar = 0; + + if (attrchanged) { /* we may have to disregard the whole line */ + GoTo(NCURSES_SP_ARGx lineno, firstChar); + ClrToEOL(NCURSES_SP_ARGx + ClrBlank(NCURSES_SP_ARGx + CurScreen(SP_PARM)), FALSE); + PutRange(NCURSES_SP_ARGx + oldLine, newLine, lineno, 0, + screen_columns(SP_PARM) - 1); +#if USE_XMC_SUPPORT + + /* + * This is a very simple loop to paint characters which may have the + * magic cookie glitch embedded. It doesn't know much about video + * attributes which are continued from one line to the next. It + * assumes that we have filtered out requests for attribute changes + * that do not get mapped to blank positions. + * + * FIXME: we are not keeping track of where we put the cookies, so this + * will work properly only once, since we may overwrite a cookie in a + * following operation. + */ + } else if (magic_cookie_glitch > 0) { + GoTo(NCURSES_SP_ARGx lineno, firstChar); + for (n = 0; n < screen_columns(SP_PARM); n++) { + int m = n + magic_cookie_glitch; + + /* check for turn-on: + * If we are writing an attributed blank, where the + * previous cell is not attributed. + */ + if (ISBLANK(newLine[n]) + && ((n > 0 + && xmc_turn_on(SP_PARM, newLine[n - 1], newLine[n])) + || (n == 0 + && lineno > 0 + && xmc_turn_on(SP_PARM, + xmc_new(SP_PARM, lineno - 1, + screen_columns(SP_PARM) - 1), + newLine[n])))) { + n = m; + } + + PutChar(NCURSES_SP_ARGx 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 (!ISBLANK(newLine[n]) + && ((n + 1 < screen_columns(SP_PARM) + && xmc_turn_off(SP_PARM, newLine[n], newLine[n + 1])) + || (n + 1 >= screen_columns(SP_PARM) + && lineno + 1 < screen_lines(SP_PARM) + && xmc_turn_off(SP_PARM, + newLine[n], + xmc_new(SP_PARM, lineno + 1, 0))))) { + n = m; + } + + } +#endif + } else { + NCURSES_CH_T blank; + + /* it may be cheap to clear leading whitespace with clr_bol */ + blank = newLine[0]; + if (clr_bol && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) { + int oFirstChar, nFirstChar; + + for (oFirstChar = 0; + oFirstChar < screen_columns(SP_PARM); + oFirstChar++) + if (!CharEq(oldLine[oFirstChar], blank)) + break; + for (nFirstChar = 0; + nFirstChar < screen_columns(SP_PARM); + nFirstChar++) + if (!CharEq(newLine[nFirstChar], blank)) + break; + + if (nFirstChar == oFirstChar) { + firstChar = nFirstChar; + /* find the first differing character */ + while (firstChar < screen_columns(SP_PARM) + && CharEq(newLine[firstChar], oldLine[firstChar])) + firstChar++; + } else if (oFirstChar > nFirstChar) { + firstChar = nFirstChar; + } else { /* oFirstChar < nFirstChar */ + firstChar = oFirstChar; + if (SP_PARM->_el1_cost < nFirstChar - oFirstChar) { + if (nFirstChar >= screen_columns(SP_PARM) + && SP_PARM->_el_cost <= SP_PARM->_el1_cost) { + GoTo(NCURSES_SP_ARGx lineno, 0); + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("clr_eol", clr_eol); + } else { + GoTo(NCURSES_SP_ARGx lineno, nFirstChar - 1); + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("clr_bol", clr_bol); + } + + while (firstChar < nFirstChar) + oldLine[firstChar++] = blank; + } + } + } else { + /* find the first differing character */ + while (firstChar < screen_columns(SP_PARM) + && CharEq(newLine[firstChar], oldLine[firstChar])) + firstChar++; + } + /* if there wasn't one, we're done */ + if (firstChar >= screen_columns(SP_PARM)) { + TR(TRACE_UPDATE, (T_RETURN(""))); + return; + } + + blank = newLine[screen_columns(SP_PARM) - 1]; + + if (!can_clear_with(NCURSES_SP_ARGx CHREF(blank))) { + /* find the last differing character */ + nLastChar = screen_columns(SP_PARM) - 1; + + while (nLastChar > firstChar + && CharEq(newLine[nLastChar], oldLine[nLastChar])) + nLastChar--; + + if (nLastChar >= firstChar) { + GoTo(NCURSES_SP_ARGx lineno, firstChar); + PutRange(NCURSES_SP_ARGx + oldLine, + newLine, + lineno, + firstChar, + nLastChar); + memcpy(oldLine + firstChar, + newLine + firstChar, + (unsigned) (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T)); + } + TR(TRACE_UPDATE, (T_RETURN(""))); + return; + } + + /* find last non-blank character on old line */ + oLastChar = screen_columns(SP_PARM) - 1; + while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank)) + oLastChar--; + + /* find last non-blank character on new line */ + nLastChar = screen_columns(SP_PARM) - 1; + while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank)) + nLastChar--; + + if ((nLastChar == firstChar) + && (SP_PARM->_el_cost < (oLastChar - nLastChar))) { + GoTo(NCURSES_SP_ARGx lineno, firstChar); + if (!CharEq(newLine[firstChar], blank)) + PutChar(NCURSES_SP_ARGx CHREF(newLine[firstChar])); + ClrToEOL(NCURSES_SP_ARGx blank, FALSE); + } else if ((nLastChar != oLastChar) + && (!CharEq(newLine[nLastChar], oldLine[oLastChar]) + || !(SP_PARM->_nc_sp_idcok + && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)))) { + GoTo(NCURSES_SP_ARGx lineno, firstChar); + if ((oLastChar - nLastChar) > SP_PARM->_el_cost) { + if (PutRange(NCURSES_SP_ARGx + oldLine, + newLine, + lineno, + firstChar, + nLastChar)) { + GoTo(NCURSES_SP_ARGx lineno, nLastChar + 1); + } + ClrToEOL(NCURSES_SP_ARGx blank, FALSE); + } else { + n = Max(nLastChar, oLastChar); + PutRange(NCURSES_SP_ARGx + oldLine, + newLine, + lineno, + firstChar, + n); + } + } else { + int nLastNonblank = nLastChar; + int oLastNonblank = oLastChar; + + /* find the last characters that really differ */ + /* 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); + if (n >= firstChar) { + GoTo(NCURSES_SP_ARGx lineno, firstChar); + PutRange(NCURSES_SP_ARGx + oldLine, + newLine, + lineno, + firstChar, + n); + } + + if (oLastChar < nLastChar) { + int m = Max(nLastNonblank, oLastNonblank); +#if USE_WIDEC_SUPPORT + if (n) { + while (isWidecExt(newLine[n + 1]) && n) { + --n; + --oLastChar; /* increase cost */ + } + } else if (n >= firstChar && + isWidecBase(newLine[n])) { + while (isWidecExt(newLine[n + 1])) { + ++n; + ++oLastChar; /* decrease cost */ + } + } +#endif + GoTo(NCURSES_SP_ARGx lineno, n + 1); + if ((nLastChar < nLastNonblank) + || InsCharCost(SP_PARM, nLastChar - oLastChar) > (m - n)) { + PutRange(NCURSES_SP_ARGx + oldLine, + newLine, + lineno, + n + 1, + m); + } else { + InsStr(NCURSES_SP_ARGx &newLine[n + 1], nLastChar - oLastChar); + } + } else if (oLastChar > nLastChar) { + GoTo(NCURSES_SP_ARGx lineno, n + 1); + if (DelCharCost(SP_PARM, oLastChar - nLastChar) + > SP_PARM->_el_cost + nLastNonblank - (n + 1)) { + if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno, + n + 1, nLastNonblank)) { + GoTo(NCURSES_SP_ARGx lineno, nLastNonblank + 1); + } + ClrToEOL(NCURSES_SP_ARGx blank, FALSE); + } else { + /* + * The delete-char sequence will + * effectively shift in blanks from the + * right margin of the screen. Ensure + * that they are the right color by + * setting the video attributes from + * the last character on the row. + */ + UpdateAttrs(SP_PARM, blank); + DelChar(NCURSES_SP_ARGx oLastChar - nLastChar); + } + } + } + } + + /* update the code's internal representation */ + if (screen_columns(SP_PARM) > firstChar) + memcpy(oldLine + firstChar, + newLine + firstChar, + (unsigned) (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T)); + TR(TRACE_UPDATE, (T_RETURN(""))); + return; +} + +/* +** ClearScreen(blank) +** +** Clear the physical screen and put cursor at home +** +*/ + +static void +ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) +{ + int i, j; + bool fast_clear = (clear_screen || clr_eos || clr_eol); + + TR(TRACE_UPDATE, ("ClearScreen() called")); + +#if NCURSES_EXT_FUNCS + if (SP_PARM->_coloron + && !SP_PARM->_default_color) { + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx + (short) GET_SCREEN_PAIR(SP_PARM), + 0, + FALSE, + NCURSES_SP_NAME(_nc_outch)); + if (!back_color_erase) { + fast_clear = FALSE; + } + } +#endif + + if (fast_clear) { + if (clear_screen) { + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("clear_screen", clear_screen); + SP_PARM->_cursrow = SP_PARM->_curscol = 0; + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + "ClearScreen"); + } else if (clr_eos) { + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + GoTo(NCURSES_SP_ARGx 0, 0); + UpdateAttrs(SP_PARM, blank); + TPUTS_TRACE("clr_eos"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + clr_eos, + screen_lines(SP_PARM), + NCURSES_SP_NAME(_nc_outch)); + } else if (clr_eol) { + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + UpdateAttrs(SP_PARM, blank); + for (i = 0; i < screen_lines(SP_PARM); i++) { + GoTo(NCURSES_SP_ARGx i, 0); + NCURSES_PUTP2("clr_eol", clr_eol); + } + GoTo(NCURSES_SP_ARGx 0, 0); + } + } else { + UpdateAttrs(SP_PARM, blank); + for (i = 0; i < screen_lines(SP_PARM); i++) { + GoTo(NCURSES_SP_ARGx i, 0); + for (j = 0; j < screen_columns(SP_PARM); j++) + PutChar(NCURSES_SP_ARGx CHREF(blank)); + } + GoTo(NCURSES_SP_ARGx 0, 0); + } + + for (i = 0; i < screen_lines(SP_PARM); i++) { + for (j = 0; j < screen_columns(SP_PARM); j++) + CurScreen(SP_PARM)->_line[i].text[j] = blank; + } + + TR(TRACE_UPDATE, ("screen cleared")); +} + +/* +** InsStr(line, count) +** +** Insert the count characters pointed to by line. +** +*/ + +static void +InsStr(NCURSES_SP_DCLx NCURSES_CH_T *line, int count) +{ + TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called", + (void *) SP_PARM, + (void *) line, count)); + + /* Prefer parm_ich as it has the smallest cost - no need to shift + * the whole line on each character. */ + /* The order must match that of InsCharCost. */ + if (parm_ich) { + TPUTS_TRACE("parm_ich"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_ich, count), + 1, + NCURSES_SP_NAME(_nc_outch)); + while (count > 0) { + PutAttrChar(NCURSES_SP_ARGx CHREF(*line)); + line++; + count--; + } + } else if (enter_insert_mode && exit_insert_mode) { + NCURSES_PUTP2("enter_insert_mode", enter_insert_mode); + while (count > 0) { + PutAttrChar(NCURSES_SP_ARGx CHREF(*line)); + if (insert_padding) { + NCURSES_PUTP2("insert_padding", insert_padding); + } + line++; + count--; + } + NCURSES_PUTP2("exit_insert_mode", exit_insert_mode); + } else { + while (count > 0) { + NCURSES_PUTP2("insert_character", insert_character); + PutAttrChar(NCURSES_SP_ARGx CHREF(*line)); + if (insert_padding) { + NCURSES_PUTP2("insert_padding", insert_padding); + } + line++; + count--; + } + } + position_check(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, "InsStr"); +} + +/* +** DelChar(count) +** +** Delete count characters at current position +** +*/ + +static void +DelChar(NCURSES_SP_DCLx int count) +{ + TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)", + (void *) SP_PARM, count, + (long) NewScreen(SP_PARM)->_cury, + (long) NewScreen(SP_PARM)->_curx)); + + if (parm_dch) { + TPUTS_TRACE("parm_dch"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_dch, count), + 1, + NCURSES_SP_NAME(_nc_outch)); + } else { + int n; + + for (n = 0; n < count; n++) { + NCURSES_PUTP2("delete_character", delete_character); + } + } +} + +/* + * Physical-scrolling support + * + * This code was adapted from Keith Bostic's hardware scrolling + * support for 4.4BSD curses. I (esr) translated it to use terminfo + * capabilities, narrowed the call interface slightly, and cleaned + * up some convoluted tests. I also added support for the memory_above + * memory_below, and non_dest_scroll_region capabilities. + * + * For this code to work, we must have either + * change_scroll_region and scroll forward/reverse commands, or + * insert and delete line capabilities. + * When the scrolling region has been set, the cursor has to + * be at the last line of the region to make the scroll up + * happen, or on the first line of region to scroll down. + * + * This code makes one aesthetic decision in the opposite way from + * BSD curses. BSD curses preferred pairs of il/dl operations + * over scrolls, allegedly because il/dl looked faster. We, on + * the other hand, prefer scrolls because (a) they're just as fast + * on many terminals and (b) using them avoids bouncing an + * unchanged bottom section of the screen up and down, which is + * visually nasty. + * + * (lav): added more cases, used dl/il when bot==maxy and in csr case. + * + * I used assumption that capabilities il/il1/dl/dl1 work inside + * changed scroll region not shifting screen contents outside of it. + * If there are any terminals behaving different way, it would be + * necessary to add some conditions to scroll_csr_forward/backward. + */ + +/* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */ +static int +scroll_csr_forward(NCURSES_SP_DCLx + int n, + int top, + int bot, + int miny, + int maxy, + NCURSES_CH_T blank) +{ + int i; + + if (n == 1 && scroll_forward && top == miny && bot == maxy) { + GoTo(NCURSES_SP_ARGx bot, 0); + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("scroll_forward", scroll_forward); + } else if (n == 1 && delete_line && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("delete_line", delete_line); + } else if (parm_index && top == miny && bot == maxy) { + GoTo(NCURSES_SP_ARGx bot, 0); + UpdateAttrs(SP_PARM, blank); + TPUTS_TRACE("parm_index"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_index, n), + n, + NCURSES_SP_NAME(_nc_outch)); + } else if (parm_delete_line && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + TPUTS_TRACE("parm_delete_line"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_delete_line, n), + n, + NCURSES_SP_NAME(_nc_outch)); + } else if (scroll_forward && top == miny && bot == maxy) { + GoTo(NCURSES_SP_ARGx bot, 0); + UpdateAttrs(SP_PARM, blank); + for (i = 0; i < n; i++) { + NCURSES_PUTP2("scroll_forward", scroll_forward); + } + } else if (delete_line && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + for (i = 0; i < n; i++) { + NCURSES_PUTP2("delete_line", delete_line); + } + } else + return ERR; + +#if NCURSES_EXT_FUNCS + if (FILL_BCE(SP_PARM)) { + int j; + for (i = 0; i < n; i++) { + GoTo(NCURSES_SP_ARGx bot - i, 0); + for (j = 0; j < screen_columns(SP_PARM); j++) + PutChar(NCURSES_SP_ARGx CHREF(blank)); + } + } +#endif + return OK; +} + +/* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */ +/* n > 0 */ +static int +scroll_csr_backward(NCURSES_SP_DCLx + int n, + int top, + int bot, + int miny, + int maxy, + NCURSES_CH_T blank) +{ + int i; + + if (n == 1 && scroll_reverse && top == miny && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("scroll_reverse", scroll_reverse); + } else if (n == 1 && insert_line && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + NCURSES_PUTP2("insert_line", insert_line); + } else if (parm_rindex && top == miny && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + TPUTS_TRACE("parm_rindex"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_rindex, n), + n, + NCURSES_SP_NAME(_nc_outch)); + } else if (parm_insert_line && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + TPUTS_TRACE("parm_insert_line"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_insert_line, n), + n, + NCURSES_SP_NAME(_nc_outch)); + } else if (scroll_reverse && top == miny && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + for (i = 0; i < n; i++) { + NCURSES_PUTP2("scroll_reverse", scroll_reverse); + } + } else if (insert_line && bot == maxy) { + GoTo(NCURSES_SP_ARGx top, 0); + UpdateAttrs(SP_PARM, blank); + for (i = 0; i < n; i++) { + NCURSES_PUTP2("insert_line", insert_line); + } + } else + return ERR; + +#if NCURSES_EXT_FUNCS + if (FILL_BCE(SP_PARM)) { + int j; + for (i = 0; i < n; i++) { + GoTo(NCURSES_SP_ARGx top + i, 0); + for (j = 0; j < screen_columns(SP_PARM); j++) + PutChar(NCURSES_SP_ARGx CHREF(blank)); + } + } +#endif + return OK; +} + +/* scroll by using delete_line at del and insert_line at ins */ +/* n > 0 */ +static int +scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank) +{ + int i; + + if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line))) + return ERR; + + GoTo(NCURSES_SP_ARGx del, 0); + UpdateAttrs(SP_PARM, blank); + if (n == 1 && delete_line) { + NCURSES_PUTP2("delete_line", delete_line); + } else if (parm_delete_line) { + TPUTS_TRACE("parm_delete_line"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_delete_line, n), + n, + NCURSES_SP_NAME(_nc_outch)); + } else { /* if (delete_line) */ + for (i = 0; i < n; i++) { + NCURSES_PUTP2("delete_line", delete_line); + } + } + + GoTo(NCURSES_SP_ARGx ins, 0); + UpdateAttrs(SP_PARM, blank); + if (n == 1 && insert_line) { + NCURSES_PUTP2("insert_line", insert_line); + } else if (parm_insert_line) { + TPUTS_TRACE("parm_insert_line"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_1(parm_insert_line, n), + n, + NCURSES_SP_NAME(_nc_outch)); + } else { /* if (insert_line) */ + for (i = 0; i < n; i++) { + NCURSES_PUTP2("insert_line", 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) +NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx + int n, + int top, + int bot, + int maxy) +/* scroll region from top to bot by n lines */ +{ + NCURSES_CH_T blank; + int i; + bool cursor_saved = FALSE; + int res; + + TR(TRACE_MOVE, ("_nc_scrolln(%p, %d, %d, %d, %d)", + (void *) SP_PARM, n, top, bot, maxy)); + + if (!IsValidScreen(SP_PARM)) + return (ERR); + + blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); + +#if USE_XMC_SUPPORT + /* + * If we scroll, we might remove a cookie. + */ + if (magic_cookie_glitch > 0) { + return (ERR); + } +#endif + + if (n > 0) { /* scroll up (forward) */ + /* + * Explicitly clear if stuff pushed off top of region might + * be saved by the terminal. + */ + res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, 0, maxy, blank); + + if (res == ERR && change_scroll_region) { + if ((((n == 1 && scroll_forward) || parm_index) + && (SP_PARM->_cursrow == bot || SP_PARM->_cursrow == bot - 1)) + && save_cursor && restore_cursor) { + cursor_saved = TRUE; + NCURSES_PUTP2("save_cursor", save_cursor); + } + NCURSES_PUTP2("change_scroll_region", + TIPARM_2(change_scroll_region, top, bot)); + if (cursor_saved) { + NCURSES_PUTP2("restore_cursor", restore_cursor); + } else { + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + } + + res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank); + + NCURSES_PUTP2("change_scroll_region", + TIPARM_2(change_scroll_region, 0, maxy)); + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + } + + if (res == ERR && SP_PARM->_nc_sp_idlok) + res = scroll_idl(NCURSES_SP_ARGx n, top, bot - n + 1, blank); + + /* + * Clear the newly shifted-in text. + */ + 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(NCURSES_SP_ARGx bot - n + 1, 0); + ClrToEOS(NCURSES_SP_ARGx blank2); + } else { + for (i = 0; i < n; i++) { + GoTo(NCURSES_SP_ARGx bot - i, 0); + ClrToEOL(NCURSES_SP_ARGx blank2, FALSE); + } + } + } + + } else { /* (n < 0) - scroll down (backward) */ + res = scroll_csr_backward(NCURSES_SP_ARGx -n, top, bot, 0, maxy, blank); + + if (res == ERR && change_scroll_region) { + if (top != 0 + && (SP_PARM->_cursrow == top || + SP_PARM->_cursrow == top - 1) + && save_cursor && restore_cursor) { + cursor_saved = TRUE; + NCURSES_PUTP2("save_cursor", save_cursor); + } + NCURSES_PUTP2("change_scroll_region", + TIPARM_2(change_scroll_region, top, bot)); + if (cursor_saved) { + NCURSES_PUTP2("restore_cursor", restore_cursor); + } else { + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + } + + res = scroll_csr_backward(NCURSES_SP_ARGx + -n, top, bot, top, bot, blank); + + NCURSES_PUTP2("change_scroll_region", + TIPARM_2(change_scroll_region, 0, maxy)); + SP_PARM->_cursrow = SP_PARM->_curscol = -1; + } + + if (res == ERR && SP_PARM->_nc_sp_idlok) + res = scroll_idl(NCURSES_SP_ARGx -n, bot + n + 1, top, blank); + + /* + * Clear the newly shifted-in text. + */ + 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(NCURSES_SP_ARGx i + top, 0); + ClrToEOL(NCURSES_SP_ARGx blank2, FALSE); + } + } + } + + if (res == ERR) + return (ERR); + + _nc_scroll_window(CurScreen(SP_PARM), n, + (NCURSES_SIZE_T) top, + (NCURSES_SIZE_T) bot, + blank); + + /* shift hash values too - they can be reused */ + NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot); + + return (OK); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_scrolln(int n, int top, int bot, int maxy) +{ + return NCURSES_SP_NAME(_nc_scrolln) (CURRENT_SCREEN, n, top, bot, maxy); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0) +{ + assert(SP_PARM); + + /* make sure terminal is in a sane known state */ + SetAttr(SCREEN_ATTRS(SP_PARM), A_NORMAL); + NewScreen(SP_PARM)->_clear = TRUE; + + /* reset color pairs and definitions */ + if (SP_PARM->_coloron || SP_PARM->_color_defs) + NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG); + + /* restore user-defined colors, if any */ + if (SP_PARM->_color_defs < 0 && !SP_PARM->_direct_color.value) { + int n; + SP_PARM->_color_defs = -(SP_PARM->_color_defs); + for (n = 0; n < SP_PARM->_color_defs; ++n) { + if (SP_PARM->_color_table[n].init) { + _nc_init_color(SP_PARM, + n, + SP_PARM->_color_table[n].r, + SP_PARM->_color_table[n].g, + SP_PARM->_color_table[n].b); + } + } + } + + if (exit_attribute_mode) + NCURSES_PUTP2("exit_attribute_mode", exit_attribute_mode); + else { + /* turn off attributes */ + if (exit_alt_charset_mode) + NCURSES_PUTP2("exit_alt_charset_mode", exit_alt_charset_mode); + if (exit_standout_mode) + NCURSES_PUTP2("exit_standout_mode", exit_standout_mode); + if (exit_underline_mode) + NCURSES_PUTP2("exit_underline_mode", exit_underline_mode); + } + if (exit_insert_mode) + NCURSES_PUTP2("exit_insert_mode", exit_insert_mode); + if (enter_am_mode && exit_am_mode) { + if (auto_right_margin) { + NCURSES_PUTP2("enter_am_mode", enter_am_mode); + } else { + NCURSES_PUTP2("exit_am_mode", exit_am_mode); + } + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_screen_resume(void) +{ + NCURSES_SP_NAME(_nc_screen_resume) (CURRENT_SCREEN); +} +#endif + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_screen_init) (NCURSES_SP_DCL0) +{ + NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_screen_init(void) +{ + NCURSES_SP_NAME(_nc_screen_init) (CURRENT_SCREEN); +} +#endif + +/* wrap up screen handling */ +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0) +{ + if (SP_PARM != NULL) { + + UpdateAttrs(SP_PARM, normal); +#if NCURSES_EXT_FUNCS + if (SP_PARM->_coloron + && !SP_PARM->_default_color) { + static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); + SP_PARM->_default_color = TRUE; + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx + -1, + 0, + FALSE, + NCURSES_SP_NAME(_nc_outch)); + SP_PARM->_default_color = FALSE; + + TINFO_MVCUR(NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + screen_lines(SP_PARM) - 1, + 0); + + ClrToEOL(NCURSES_SP_ARGx blank, TRUE); + } +#endif + if (SP_PARM->_color_defs) { + NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG); + } + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_screen_wrap(void) +{ + NCURSES_SP_NAME(_nc_screen_wrap) (CURRENT_SCREEN); +} +#endif + +#if USE_XMC_SUPPORT +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_do_xmc_glitch) (NCURSES_SP_DCLx attr_t previous) +{ + if (SP_PARM != NULL) { + attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP_PARM))); + + while (chg != 0) { + if (chg & 1) { + SP_PARM->_curscol += magic_cookie_glitch; + if (SP_PARM->_curscol >= SP_PARM->_columns) + wrap_cursor(NCURSES_SP_ARG); + TR(TRACE_UPDATE, ("bumped to %d,%d after cookie", + SP_PARM->_cursrow, SP_PARM->_curscol)); + } + chg >>= 1; + } + } +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_do_xmc_glitch(attr_t previous) +{ + NCURSES_SP_NAME(_nc_do_xmc_glitch) (CURRENT_SCREEN, previous); +} +#endif + +#endif /* USE_XMC_SUPPORT */ diff --git a/ncurses/ncurses/wcwidth.h b/ncurses/ncurses/wcwidth.h new file mode 100644 index 0000000000..2d242ca365 --- /dev/null +++ b/ncurses/ncurses/wcwidth.h @@ -0,0 +1,1003 @@ +/* $Id: wcwidth.h,v 1.10 2025/10/31 23:10:59 tom Exp $ */ + +/* + * Copyright 2002-2024,2025 by Thomas E. Dickey + * Copyright (c) 2026 Project Tick + * + * All Rights Reserved + * + * 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, 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 LISTED COPYRIGHT HOLDER(S) 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 is an updated version of Markus Kuhn's implementation of wcwidth. + * + * Originally added to xterm in 2000 (patch #141), there were a couple of + * updates from Kuhn until 2005 (patch #202), renaming entrypoints and applying + * data from Unicode.org (e.g., 3.2, 4.0, 4.1.0). The Unicode data is + * transformed into tables in this file by a script "uniset" written by Kuhn. + * + * While Kuhn implemented the original CJK variant, it was unused by xterm + * until Jungshik Shin used it in 2002 to implement the -cjk_width command-line + * option. + * + * Kuhn added a check for the vertical forms block (double-width) in 2007; + * other updates were derived from the Unicode.org data (release 5.0). + * + * Since then, additional updates have been made: + * + data-type fixes + * + new Unicode releases (6.2.0, 9.0.0, etc), + * + additional special symbol blocks have been added to the special cases. + * + soft-hyphen behavior has been made configurable. + * + added table shows when a character is not part of Unicode. + * + * Kuhn's original header follows giving the design information: + *----------------------------------------------------------------------------- + * This is an implementation of wcwidth() and wcswidth() (defined in + * IEEE Std 1002.1-2001) for Unicode. + * + * http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html + * http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html + * + * In fixed-width output devices, Latin characters all occupy a single + * "cell" position of equal width, whereas ideographic CJK characters + * occupy two such cells. Interoperability between terminal-line + * applications and (teletype-style) character terminals using the + * UTF-8 encoding requires agreement on which character should advance + * the cursor by how many cell positions. No established formal + * standards exist at present on which Unicode character shall occupy + * how many cell positions on character terminals. These routines are + * a first attempt of defining such behavior based on simple rules + * applied to data provided by the Unicode Consortium. + * + * For some graphical characters, the Unicode standard explicitly + * defines a character-cell width via the definition of the East Asian + * FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes. + * In all these cases, there is no ambiguity about which width a + * terminal shall use. For characters in the East Asian Ambiguous (A) + * class, the width choice depends purely on a preference of backward + * compatibility with either historic CJK or Western practice. + * Choosing single-width for these characters is easy to justify as + * the appropriate long-term solution, as the CJK practice of + * displaying these characters as double-width comes from historic + * implementation simplicity (8-bit encoded characters were displayed + * single-width and 16-bit ones double-width, even for Greek, + * Cyrillic, etc.) and not any typographic considerations. + * + * Much less clear is the choice of width for the Not East Asian + * (Neutral) class. Existing practice does not dictate a width for any + * of these characters. It would nevertheless make sense + * typographically to allocate two character cells to characters such + * as for instance EM SPACE or VOLUME INTEGRAL, which cannot be + * represented adequately with a single-width glyph. The following + * routines at present merely assign a single-cell width to all + * neutral characters, in the interest of simplicity. This is not + * entirely satisfactory and should be reconsidered before + * establishing a formal standard in this area. At the moment, the + * decision which Not East Asian (Neutral) characters should be + * represented by double-width glyphs cannot yet be answered by + * applying a simple rule from the Unicode database content. Setting + * up a proper standard for the behavior of UTF-8 character terminals + * will require a careful analysis not only of each Unicode character, + * but also of each presentation form, something the author of these + * routines has avoided to do so far. + * + * http://www.unicode.org/unicode/reports/tr11/ + * + * Markus Kuhn -- 2007-05-25 (Unicode 5.0) + * + * Permission to use, copy, modify, and distribute this software + * for any purpose and without fee is hereby granted. The author + * disclaims all warranties with regard to this software. + * + * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c + *----------------------------------------------------------------------------- + */ + +#ifndef _WCWIDTH_H_incl +#define _WCWIDTH_H_incl 1 + +#ifdef TEST_DRIVER +#include +#include /* EXIT_SUCCESS, etc. */ +#include /* getopt() */ +#include /* strncmp() */ +#include /* setlocale() */ +#include /* this module */ +#endif + +#include +#include + +#include +#include + +struct interval { + unsigned long first; + unsigned long last; +}; + +static int use_latin1 = 1; + +/* auxiliary function for binary search in interval table */ +static int +bisearch(unsigned long ucs, const struct interval *table, int max) +{ + + if (ucs >= table[0].first && ucs <= table[max].last) { + int min = 0; + + while (max >= min) { + int mid; + + mid = (min + max) / 2; + if (ucs > table[mid].last) + min = mid + 1; + else if (ucs < table[mid].first) + max = mid - 1; + else + return 1; + } + } + + return 0; +} + +/* + * Provide a way to change the behavior of soft-hyphen. + */ +void +mk_wcwidth_init(int mode) +{ + use_latin1 = (mode == 0); +} + +/* The following two functions define the column width of an ISO 10646 + * character as follows: + * + * - The null character (U+0000) has a column width of 0. + * + * - Other C0/C1 control characters and DEL will lead to a return + * value of -1. + * + * - Non-spacing and enclosing combining characters (general + * category code Mn or Me in the Unicode database) have a + * column width of 0. + * + * - A few spacing combining marks have a column width of 0. + * + * - SOFT HYPHEN (U+00AD) has a column width of 1 in Latin-1, 0 in Unicode. + * An initialization function is used to switch between the two. + * + * - Other format characters (general category code Cf in the Unicode + * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. + * + * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) + * have a column width of 0. + * + * - Hangul Jamo Extended-B medial vowels and final consonants for old + * Korean (U+D7B0-U+D7FF) have a column width of 0. + * + * - Spacing characters in the East Asian Wide (W) or East Asian + * Full-width (F) category as defined in Unicode Technical + * Report #11 have a column width of 2. In that report, some codes + * were unassigned. Characters in these blocks use a column width of 1: + * 4DC0..4DFF; Yijing Hexagram Symbols + * A960..A97F; Hangul Jamo Extended-A + * + * - All remaining characters (including all printable + * ISO 8859-1 and WGL4 characters, Unicode control characters, + * etc.) have a column width of 1. + * + * - Codes which do not correspond to a Unicode character have a column + * width of -1. + * + * This implementation assumes that wchar_t characters are encoded + * in ISO 10646. + */ + +NCURSES_EXPORT(int) +mk_wcwidth(uint32_t ucs) +{ + unsigned long cmp = (unsigned long) ucs; + + /* sorted list of non-overlapping intervals of formatting characters */ + /* generated by + * uniset +cat=Cf -00AD -0600-0605 -061C -06DD -070F c + */ + /* *INDENT-OFF* */ + /* generated by run-uniset_ctl 1.2 */ + static const struct interval formatting[] = { + { 0x0890, 0x0891 }, { 0x08E2, 0x08E2 }, { 0x180E, 0x180E }, + { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2064 }, + { 0x2066, 0x206F }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, + { 0x110BD, 0x110BD }, { 0x110CD, 0x110CD }, { 0x13430, 0x1343F }, + { 0x1BCA0, 0x1BCA3 }, { 0x1D173, 0x1D17A }, { 0xE0001, 0xE0001 }, + { 0xE0020, 0xE007F } + }; + /* *INDENT-ON* */ + + /* sorted list of non-overlapping intervals of non-spacing characters */ + /* generated by + * uniset +cat=Me +cat=Mn +0600-0605 +061C +06DD +070F +1160-11FF +D7B0-D7C6 +D7CB-D7FB c + */ + /* *INDENT-OFF* */ + /* generated by run-uniset 1.10 */ + static const struct interval combining[] = { + { 0x0300, 0x036F }, { 0x0483, 0x0489 }, { 0x0591, 0x05BD }, + { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, { 0x05C4, 0x05C5 }, + { 0x05C7, 0x05C7 }, { 0x0600, 0x0605 }, { 0x0610, 0x061A }, + { 0x061C, 0x061C }, { 0x064B, 0x065F }, { 0x0670, 0x0670 }, + { 0x06D6, 0x06DD }, { 0x06DF, 0x06E4 }, { 0x06E7, 0x06E8 }, + { 0x06EA, 0x06ED }, { 0x070F, 0x070F }, { 0x0711, 0x0711 }, + { 0x0730, 0x074A }, { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, + { 0x07FD, 0x07FD }, { 0x0816, 0x0819 }, { 0x081B, 0x0823 }, + { 0x0825, 0x0827 }, { 0x0829, 0x082D }, { 0x0859, 0x085B }, + { 0x0897, 0x089F }, { 0x08CA, 0x08E1 }, { 0x08E3, 0x0902 }, + { 0x093A, 0x093A }, { 0x093C, 0x093C }, { 0x0941, 0x0948 }, + { 0x094D, 0x094D }, { 0x0951, 0x0957 }, { 0x0962, 0x0963 }, + { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, + { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, { 0x09FE, 0x09FE }, + { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, + { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A51, 0x0A51 }, + { 0x0A70, 0x0A71 }, { 0x0A75, 0x0A75 }, { 0x0A81, 0x0A82 }, + { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, + { 0x0ACD, 0x0ACD }, { 0x0AE2, 0x0AE3 }, { 0x0AFA, 0x0AFF }, + { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, + { 0x0B41, 0x0B44 }, { 0x0B4D, 0x0B4D }, { 0x0B55, 0x0B56 }, + { 0x0B62, 0x0B63 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 }, + { 0x0BCD, 0x0BCD }, { 0x0C00, 0x0C00 }, { 0x0C04, 0x0C04 }, + { 0x0C3C, 0x0C3C }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, + { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0C62, 0x0C63 }, + { 0x0C81, 0x0C81 }, { 0x0CBC, 0x0CBC }, { 0x0CBF, 0x0CBF }, + { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, { 0x0CE2, 0x0CE3 }, + { 0x0D00, 0x0D01 }, { 0x0D3B, 0x0D3C }, { 0x0D41, 0x0D44 }, + { 0x0D4D, 0x0D4D }, { 0x0D62, 0x0D63 }, { 0x0D81, 0x0D81 }, + { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, + { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, + { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EBC }, { 0x0EC8, 0x0ECE }, + { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, + { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, + { 0x0F86, 0x0F87 }, { 0x0F8D, 0x0F97 }, { 0x0F99, 0x0FBC }, + { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1037 }, + { 0x1039, 0x103A }, { 0x103D, 0x103E }, { 0x1058, 0x1059 }, + { 0x105E, 0x1060 }, { 0x1071, 0x1074 }, { 0x1082, 0x1082 }, + { 0x1085, 0x1086 }, { 0x108D, 0x108D }, { 0x109D, 0x109D }, + { 0x1160, 0x11FF }, { 0x135D, 0x135F }, { 0x1712, 0x1714 }, + { 0x1732, 0x1733 }, { 0x1752, 0x1753 }, { 0x1772, 0x1773 }, + { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, + { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, { 0x180B, 0x180D }, + { 0x180F, 0x180F }, { 0x1885, 0x1886 }, { 0x18A9, 0x18A9 }, + { 0x1920, 0x1922 }, { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, + { 0x1939, 0x193B }, { 0x1A17, 0x1A18 }, { 0x1A1B, 0x1A1B }, + { 0x1A56, 0x1A56 }, { 0x1A58, 0x1A5E }, { 0x1A60, 0x1A60 }, + { 0x1A62, 0x1A62 }, { 0x1A65, 0x1A6C }, { 0x1A73, 0x1A7C }, + { 0x1A7F, 0x1A7F }, { 0x1AB0, 0x1ADD }, { 0x1AE0, 0x1AEB }, + { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, { 0x1B36, 0x1B3A }, + { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, { 0x1B6B, 0x1B73 }, + { 0x1B80, 0x1B81 }, { 0x1BA2, 0x1BA5 }, { 0x1BA8, 0x1BA9 }, + { 0x1BAB, 0x1BAD }, { 0x1BE6, 0x1BE6 }, { 0x1BE8, 0x1BE9 }, + { 0x1BED, 0x1BED }, { 0x1BEF, 0x1BF1 }, { 0x1C2C, 0x1C33 }, + { 0x1C36, 0x1C37 }, { 0x1CD0, 0x1CD2 }, { 0x1CD4, 0x1CE0 }, + { 0x1CE2, 0x1CE8 }, { 0x1CED, 0x1CED }, { 0x1CF4, 0x1CF4 }, + { 0x1CF8, 0x1CF9 }, { 0x1DC0, 0x1DFF }, { 0x20D0, 0x20F0 }, + { 0x2CEF, 0x2CF1 }, { 0x2D7F, 0x2D7F }, { 0x2DE0, 0x2DFF }, + { 0x302A, 0x302D }, { 0x3099, 0x309A }, { 0xA66F, 0xA672 }, + { 0xA674, 0xA67D }, { 0xA69E, 0xA69F }, { 0xA6F0, 0xA6F1 }, + { 0xA802, 0xA802 }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, + { 0xA825, 0xA826 }, { 0xA82C, 0xA82C }, { 0xA8C4, 0xA8C5 }, + { 0xA8E0, 0xA8F1 }, { 0xA8FF, 0xA8FF }, { 0xA926, 0xA92D }, + { 0xA947, 0xA951 }, { 0xA980, 0xA982 }, { 0xA9B3, 0xA9B3 }, + { 0xA9B6, 0xA9B9 }, { 0xA9BC, 0xA9BD }, { 0xA9E5, 0xA9E5 }, + { 0xAA29, 0xAA2E }, { 0xAA31, 0xAA32 }, { 0xAA35, 0xAA36 }, + { 0xAA43, 0xAA43 }, { 0xAA4C, 0xAA4C }, { 0xAA7C, 0xAA7C }, + { 0xAAB0, 0xAAB0 }, { 0xAAB2, 0xAAB4 }, { 0xAAB7, 0xAAB8 }, + { 0xAABE, 0xAABF }, { 0xAAC1, 0xAAC1 }, { 0xAAEC, 0xAAED }, + { 0xAAF6, 0xAAF6 }, { 0xABE5, 0xABE5 }, { 0xABE8, 0xABE8 }, + { 0xABED, 0xABED }, { 0xD7B0, 0xD7C6 }, { 0xD7CB, 0xD7FB }, + { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, { 0xFE20, 0xFE2F }, + { 0x101FD, 0x101FD }, { 0x102E0, 0x102E0 }, { 0x10376, 0x1037A }, + { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, + { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x10AE5, 0x10AE6 }, + { 0x10D24, 0x10D27 }, { 0x10D69, 0x10D6D }, { 0x10EAB, 0x10EAC }, + { 0x10EFA, 0x10EFF }, { 0x10F46, 0x10F50 }, { 0x10F82, 0x10F85 }, + { 0x11001, 0x11001 }, { 0x11038, 0x11046 }, { 0x11070, 0x11070 }, + { 0x11073, 0x11074 }, { 0x1107F, 0x11081 }, { 0x110B3, 0x110B6 }, + { 0x110B9, 0x110BA }, { 0x110C2, 0x110C2 }, { 0x11100, 0x11102 }, + { 0x11127, 0x1112B }, { 0x1112D, 0x11134 }, { 0x11173, 0x11173 }, + { 0x11180, 0x11181 }, { 0x111B6, 0x111BE }, { 0x111C9, 0x111CC }, + { 0x111CF, 0x111CF }, { 0x1122F, 0x11231 }, { 0x11234, 0x11234 }, + { 0x11236, 0x11237 }, { 0x1123E, 0x1123E }, { 0x11241, 0x11241 }, + { 0x112DF, 0x112DF }, { 0x112E3, 0x112EA }, { 0x11300, 0x11301 }, + { 0x1133B, 0x1133C }, { 0x11340, 0x11340 }, { 0x11366, 0x1136C }, + { 0x11370, 0x11374 }, { 0x113BB, 0x113C0 }, { 0x113CE, 0x113CE }, + { 0x113D0, 0x113D0 }, { 0x113D2, 0x113D2 }, { 0x113E1, 0x113E2 }, + { 0x11438, 0x1143F }, { 0x11442, 0x11444 }, { 0x11446, 0x11446 }, + { 0x1145E, 0x1145E }, { 0x114B3, 0x114B8 }, { 0x114BA, 0x114BA }, + { 0x114BF, 0x114C0 }, { 0x114C2, 0x114C3 }, { 0x115B2, 0x115B5 }, + { 0x115BC, 0x115BD }, { 0x115BF, 0x115C0 }, { 0x115DC, 0x115DD }, + { 0x11633, 0x1163A }, { 0x1163D, 0x1163D }, { 0x1163F, 0x11640 }, + { 0x116AB, 0x116AB }, { 0x116AD, 0x116AD }, { 0x116B0, 0x116B5 }, + { 0x116B7, 0x116B7 }, { 0x1171D, 0x1171D }, { 0x1171F, 0x1171F }, + { 0x11722, 0x11725 }, { 0x11727, 0x1172B }, { 0x1182F, 0x11837 }, + { 0x11839, 0x1183A }, { 0x1193B, 0x1193C }, { 0x1193E, 0x1193E }, + { 0x11943, 0x11943 }, { 0x119D4, 0x119D7 }, { 0x119DA, 0x119DB }, + { 0x119E0, 0x119E0 }, { 0x11A01, 0x11A0A }, { 0x11A33, 0x11A38 }, + { 0x11A3B, 0x11A3E }, { 0x11A47, 0x11A47 }, { 0x11A51, 0x11A56 }, + { 0x11A59, 0x11A5B }, { 0x11A8A, 0x11A96 }, { 0x11A98, 0x11A99 }, + { 0x11B60, 0x11B60 }, { 0x11B62, 0x11B64 }, { 0x11B66, 0x11B66 }, + { 0x11C30, 0x11C36 }, { 0x11C38, 0x11C3D }, { 0x11C3F, 0x11C3F }, + { 0x11C92, 0x11CA7 }, { 0x11CAA, 0x11CB0 }, { 0x11CB2, 0x11CB3 }, + { 0x11CB5, 0x11CB6 }, { 0x11D31, 0x11D36 }, { 0x11D3A, 0x11D3A }, + { 0x11D3C, 0x11D3D }, { 0x11D3F, 0x11D45 }, { 0x11D47, 0x11D47 }, + { 0x11D90, 0x11D91 }, { 0x11D95, 0x11D95 }, { 0x11D97, 0x11D97 }, + { 0x11EF3, 0x11EF4 }, { 0x11F00, 0x11F01 }, { 0x11F36, 0x11F3A }, + { 0x11F40, 0x11F40 }, { 0x11F42, 0x11F42 }, { 0x11F5A, 0x11F5A }, + { 0x13440, 0x13440 }, { 0x13447, 0x13455 }, { 0x1611E, 0x16129 }, + { 0x1612D, 0x1612F }, { 0x16AF0, 0x16AF4 }, { 0x16B30, 0x16B36 }, + { 0x16F4F, 0x16F4F }, { 0x16F8F, 0x16F92 }, { 0x16FE4, 0x16FE4 }, + { 0x1BC9D, 0x1BC9E }, { 0x1CF00, 0x1CF2D }, { 0x1CF30, 0x1CF46 }, + { 0x1D167, 0x1D169 }, { 0x1D17B, 0x1D182 }, { 0x1D185, 0x1D18B }, + { 0x1D1AA, 0x1D1AD }, { 0x1D242, 0x1D244 }, { 0x1DA00, 0x1DA36 }, + { 0x1DA3B, 0x1DA6C }, { 0x1DA75, 0x1DA75 }, { 0x1DA84, 0x1DA84 }, + { 0x1DA9B, 0x1DA9F }, { 0x1DAA1, 0x1DAAF }, { 0x1E000, 0x1E006 }, + { 0x1E008, 0x1E018 }, { 0x1E01B, 0x1E021 }, { 0x1E023, 0x1E024 }, + { 0x1E026, 0x1E02A }, { 0x1E08F, 0x1E08F }, { 0x1E130, 0x1E136 }, + { 0x1E2AE, 0x1E2AE }, { 0x1E2EC, 0x1E2EF }, { 0x1E4EC, 0x1E4EF }, + { 0x1E5EE, 0x1E5EF }, { 0x1E6E3, 0x1E6E3 }, { 0x1E6E6, 0x1E6E6 }, + { 0x1E6EE, 0x1E6EF }, { 0x1E6F5, 0x1E6F5 }, { 0x1E8D0, 0x1E8D6 }, + { 0x1E944, 0x1E94A }, { 0xE0100, 0xE01EF } + }; + /* *INDENT-ON* */ + + /* sorted list of non-overlapping intervals of non-characters */ + /* generated by + * uniset +0000..DFFF -4e00..9fd5 +F900..10FFFD unknown +2028..2029 c + */ + /* *INDENT-OFF* */ + /* generated by run-uniset_unk 1.7 */ + static const struct interval unknowns[] = { + { 0x0378, 0x0379 }, { 0x0380, 0x0383 }, { 0x038B, 0x038B }, + { 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0530, 0x0530 }, + { 0x0557, 0x0558 }, { 0x058B, 0x058C }, { 0x0590, 0x0590 }, + { 0x05C8, 0x05CF }, { 0x05EB, 0x05EE }, { 0x05F5, 0x05FF }, + { 0x070E, 0x070E }, { 0x074B, 0x074C }, { 0x07B2, 0x07BF }, + { 0x07FB, 0x07FC }, { 0x082E, 0x082F }, { 0x083F, 0x083F }, + { 0x085C, 0x085D }, { 0x085F, 0x085F }, { 0x086B, 0x086F }, + { 0x0892, 0x0896 }, { 0x0984, 0x0984 }, { 0x098D, 0x098E }, + { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 }, { 0x09B1, 0x09B1 }, + { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB }, { 0x09C5, 0x09C6 }, + { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 }, { 0x09D8, 0x09DB }, + { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 }, { 0x09FF, 0x0A00 }, + { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E }, { 0x0A11, 0x0A12 }, + { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 }, { 0x0A34, 0x0A34 }, + { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B }, { 0x0A3D, 0x0A3D }, + { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A }, { 0x0A4E, 0x0A50 }, + { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D }, { 0x0A5F, 0x0A65 }, + { 0x0A77, 0x0A80 }, { 0x0A84, 0x0A84 }, { 0x0A8E, 0x0A8E }, + { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 }, { 0x0AB1, 0x0AB1 }, + { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB }, { 0x0AC6, 0x0AC6 }, + { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF }, { 0x0AD1, 0x0ADF }, + { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0AF8 }, { 0x0B00, 0x0B00 }, + { 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 }, + { 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 }, + { 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A }, + { 0x0B4E, 0x0B54 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E }, + { 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 }, + { 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 }, + { 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 }, + { 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD }, + { 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF }, + { 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0BFF }, + { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 }, { 0x0C29, 0x0C29 }, + { 0x0C3A, 0x0C3B }, { 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 }, + { 0x0C4E, 0x0C54 }, { 0x0C57, 0x0C57 }, { 0x0C5B, 0x0C5B }, + { 0x0C5E, 0x0C5F }, { 0x0C64, 0x0C65 }, { 0x0C70, 0x0C76 }, + { 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 }, + { 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 }, + { 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDB }, + { 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 }, + { 0x0CF4, 0x0CFF }, { 0x0D0D, 0x0D0D }, { 0x0D11, 0x0D11 }, + { 0x0D45, 0x0D45 }, { 0x0D49, 0x0D49 }, { 0x0D50, 0x0D53 }, + { 0x0D64, 0x0D65 }, { 0x0D80, 0x0D80 }, { 0x0D84, 0x0D84 }, + { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 }, { 0x0DBC, 0x0DBC }, + { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 }, { 0x0DCB, 0x0DCE }, + { 0x0DD5, 0x0DD5 }, { 0x0DD7, 0x0DD7 }, { 0x0DE0, 0x0DE5 }, + { 0x0DF0, 0x0DF1 }, { 0x0DF5, 0x0E00 }, { 0x0E3B, 0x0E3E }, + { 0x0E5C, 0x0E80 }, { 0x0E83, 0x0E83 }, { 0x0E85, 0x0E85 }, + { 0x0E8B, 0x0E8B }, { 0x0EA4, 0x0EA4 }, { 0x0EA6, 0x0EA6 }, + { 0x0EBE, 0x0EBF }, { 0x0EC5, 0x0EC5 }, { 0x0EC7, 0x0EC7 }, + { 0x0ECF, 0x0ECF }, { 0x0EDA, 0x0EDB }, { 0x0EE0, 0x0EFF }, + { 0x0F48, 0x0F48 }, { 0x0F6D, 0x0F70 }, { 0x0F98, 0x0F98 }, + { 0x0FBD, 0x0FBD }, { 0x0FCD, 0x0FCD }, { 0x0FDB, 0x0FFF }, + { 0x10C6, 0x10C6 }, { 0x10C8, 0x10CC }, { 0x10CE, 0x10CF }, + { 0x1249, 0x1249 }, { 0x124E, 0x124F }, { 0x1257, 0x1257 }, + { 0x1259, 0x1259 }, { 0x125E, 0x125F }, { 0x1289, 0x1289 }, + { 0x128E, 0x128F }, { 0x12B1, 0x12B1 }, { 0x12B6, 0x12B7 }, + { 0x12BF, 0x12BF }, { 0x12C1, 0x12C1 }, { 0x12C6, 0x12C7 }, + { 0x12D7, 0x12D7 }, { 0x1311, 0x1311 }, { 0x1316, 0x1317 }, + { 0x135B, 0x135C }, { 0x137D, 0x137F }, { 0x139A, 0x139F }, + { 0x13F6, 0x13F7 }, { 0x13FE, 0x13FF }, { 0x169D, 0x169F }, + { 0x16F9, 0x16FF }, { 0x1716, 0x171E }, { 0x1737, 0x173F }, + { 0x1754, 0x175F }, { 0x176D, 0x176D }, { 0x1771, 0x1771 }, + { 0x1774, 0x177F }, { 0x17DE, 0x17DF }, { 0x17EA, 0x17EF }, + { 0x17FA, 0x17FF }, { 0x181A, 0x181F }, { 0x1879, 0x187F }, + { 0x18AB, 0x18AF }, { 0x18F6, 0x18FF }, { 0x191F, 0x191F }, + { 0x192C, 0x192F }, { 0x193C, 0x193F }, { 0x1941, 0x1943 }, + { 0x196E, 0x196F }, { 0x1975, 0x197F }, { 0x19AC, 0x19AF }, + { 0x19CA, 0x19CF }, { 0x19DB, 0x19DD }, { 0x1A1C, 0x1A1D }, + { 0x1A5F, 0x1A5F }, { 0x1A7D, 0x1A7E }, { 0x1A8A, 0x1A8F }, + { 0x1A9A, 0x1A9F }, { 0x1AAE, 0x1AAF }, { 0x1ADE, 0x1ADF }, + { 0x1AEC, 0x1AFF }, { 0x1B4D, 0x1B4D }, { 0x1BF4, 0x1BFB }, + { 0x1C38, 0x1C3A }, { 0x1C4A, 0x1C4C }, { 0x1C8B, 0x1C8F }, + { 0x1CBB, 0x1CBC }, { 0x1CC8, 0x1CCF }, { 0x1CFB, 0x1CFF }, + { 0x1F16, 0x1F17 }, { 0x1F1E, 0x1F1F }, { 0x1F46, 0x1F47 }, + { 0x1F4E, 0x1F4F }, { 0x1F58, 0x1F58 }, { 0x1F5A, 0x1F5A }, + { 0x1F5C, 0x1F5C }, { 0x1F5E, 0x1F5E }, { 0x1F7E, 0x1F7F }, + { 0x1FB5, 0x1FB5 }, { 0x1FC5, 0x1FC5 }, { 0x1FD4, 0x1FD5 }, + { 0x1FDC, 0x1FDC }, { 0x1FF0, 0x1FF1 }, { 0x1FF5, 0x1FF5 }, + { 0x1FFF, 0x1FFF }, { 0x2028, 0x2029 }, { 0x2065, 0x2065 }, + { 0x2072, 0x2073 }, { 0x208F, 0x208F }, { 0x209D, 0x209F }, + { 0x20C2, 0x20CF }, { 0x20F1, 0x20FF }, { 0x218C, 0x218F }, + { 0x242A, 0x243F }, { 0x244B, 0x245F }, { 0x2B74, 0x2B75 }, + { 0x2CF4, 0x2CF8 }, { 0x2D26, 0x2D26 }, { 0x2D28, 0x2D2C }, + { 0x2D2E, 0x2D2F }, { 0x2D68, 0x2D6E }, { 0x2D71, 0x2D7E }, + { 0x2D97, 0x2D9F }, { 0x2DA7, 0x2DA7 }, { 0x2DAF, 0x2DAF }, + { 0x2DB7, 0x2DB7 }, { 0x2DBF, 0x2DBF }, { 0x2DC7, 0x2DC7 }, + { 0x2DCF, 0x2DCF }, { 0x2DD7, 0x2DD7 }, { 0x2DDF, 0x2DDF }, + { 0x2E5E, 0x2E7F }, { 0x2E9A, 0x2E9A }, { 0x2EF4, 0x2EFF }, + { 0x2FD6, 0x2FEF }, { 0x3040, 0x3040 }, { 0x3097, 0x3098 }, + { 0x3100, 0x3104 }, { 0x3130, 0x3130 }, { 0x318F, 0x318F }, + { 0x31E6, 0x31EE }, { 0x321F, 0x321F }, { 0x4DB6, 0x4DBF }, + { 0x9FD6, 0x9FFF }, { 0xA48D, 0xA48F }, { 0xA4C7, 0xA4CF }, + { 0xA62C, 0xA63F }, { 0xA6F8, 0xA6FF }, { 0xA7DD, 0xA7F0 }, + { 0xA82D, 0xA82F }, { 0xA83A, 0xA83F }, { 0xA878, 0xA87F }, + { 0xA8C6, 0xA8CD }, { 0xA8DA, 0xA8DF }, { 0xA954, 0xA95E }, + { 0xA97D, 0xA97F }, { 0xA9CE, 0xA9CE }, { 0xA9DA, 0xA9DD }, + { 0xA9FF, 0xA9FF }, { 0xAA37, 0xAA3F }, { 0xAA4E, 0xAA4F }, + { 0xAA5A, 0xAA5B }, { 0xAAC3, 0xAADA }, { 0xAAF7, 0xAB00 }, + { 0xAB07, 0xAB08 }, { 0xAB0F, 0xAB10 }, { 0xAB17, 0xAB1F }, + { 0xAB27, 0xAB27 }, { 0xAB2F, 0xAB2F }, { 0xAB6C, 0xAB6F }, + { 0xABEE, 0xABEF }, { 0xABFA, 0xABFF }, { 0xD7A4, 0xD7AF }, + { 0xD7C7, 0xD7CA }, { 0xD7FC, 0xDFFF }, { 0xFA6E, 0xFA6F }, + { 0xFADA, 0xFAFF }, { 0xFB07, 0xFB12 }, { 0xFB18, 0xFB1C }, + { 0xFB37, 0xFB37 }, { 0xFB3D, 0xFB3D }, { 0xFB3F, 0xFB3F }, + { 0xFB42, 0xFB42 }, { 0xFB45, 0xFB45 }, { 0xFDD0, 0xFDEF }, + { 0xFE1A, 0xFE1F }, { 0xFE53, 0xFE53 }, { 0xFE67, 0xFE67 }, + { 0xFE6C, 0xFE6F }, { 0xFE75, 0xFE75 }, { 0xFEFD, 0xFEFE }, + { 0xFF00, 0xFF00 }, { 0xFFBF, 0xFFC1 }, { 0xFFC8, 0xFFC9 }, + { 0xFFD0, 0xFFD1 }, { 0xFFD8, 0xFFD9 }, { 0xFFDD, 0xFFDF }, + { 0xFFE7, 0xFFE7 }, { 0xFFEF, 0xFFF8 }, { 0xFFFE, 0xFFFF }, + { 0x1000C, 0x1000C }, { 0x10027, 0x10027 }, { 0x1003B, 0x1003B }, + { 0x1003E, 0x1003E }, { 0x1004E, 0x1004F }, { 0x1005E, 0x1007F }, + { 0x100FB, 0x100FF }, { 0x10103, 0x10106 }, { 0x10134, 0x10136 }, + { 0x1018F, 0x1018F }, { 0x1019D, 0x1019F }, { 0x101A1, 0x101CF }, + { 0x101FE, 0x1027F }, { 0x1029D, 0x1029F }, { 0x102D1, 0x102DF }, + { 0x102FC, 0x102FF }, { 0x10324, 0x1032C }, { 0x1034B, 0x1034F }, + { 0x1037B, 0x1037F }, { 0x1039E, 0x1039E }, { 0x103C4, 0x103C7 }, + { 0x103D6, 0x103FF }, { 0x1049E, 0x1049F }, { 0x104AA, 0x104AF }, + { 0x104D4, 0x104D7 }, { 0x104FC, 0x104FF }, { 0x10528, 0x1052F }, + { 0x10564, 0x1056E }, { 0x1057B, 0x1057B }, { 0x1058B, 0x1058B }, + { 0x10593, 0x10593 }, { 0x10596, 0x10596 }, { 0x105A2, 0x105A2 }, + { 0x105B2, 0x105B2 }, { 0x105BA, 0x105BA }, { 0x105BD, 0x105BF }, + { 0x105F4, 0x105FF }, { 0x10737, 0x1073F }, { 0x10756, 0x1075F }, + { 0x10768, 0x1077F }, { 0x10786, 0x10786 }, { 0x107B1, 0x107B1 }, + { 0x107BB, 0x107FF }, { 0x10806, 0x10807 }, { 0x10809, 0x10809 }, + { 0x10836, 0x10836 }, { 0x10839, 0x1083B }, { 0x1083D, 0x1083E }, + { 0x10856, 0x10856 }, { 0x1089F, 0x108A6 }, { 0x108B0, 0x108DF }, + { 0x108F3, 0x108F3 }, { 0x108F6, 0x108FA }, { 0x1091C, 0x1091E }, + { 0x1093A, 0x1093E }, { 0x1095A, 0x1097F }, { 0x109B8, 0x109BB }, + { 0x109D0, 0x109D1 }, { 0x10A04, 0x10A04 }, { 0x10A07, 0x10A0B }, + { 0x10A14, 0x10A14 }, { 0x10A18, 0x10A18 }, { 0x10A36, 0x10A37 }, + { 0x10A3B, 0x10A3E }, { 0x10A49, 0x10A4F }, { 0x10A59, 0x10A5F }, + { 0x10AA0, 0x10ABF }, { 0x10AE7, 0x10AEA }, { 0x10AF7, 0x10AFF }, + { 0x10B36, 0x10B38 }, { 0x10B56, 0x10B57 }, { 0x10B73, 0x10B77 }, + { 0x10B92, 0x10B98 }, { 0x10B9D, 0x10BA8 }, { 0x10BB0, 0x10BFF }, + { 0x10C49, 0x10C7F }, { 0x10CB3, 0x10CBF }, { 0x10CF3, 0x10CF9 }, + { 0x10D28, 0x10D2F }, { 0x10D3A, 0x10D3F }, { 0x10D66, 0x10D68 }, + { 0x10D86, 0x10D8D }, { 0x10D90, 0x10E5F }, { 0x10E7F, 0x10E7F }, + { 0x10EAA, 0x10EAA }, { 0x10EAE, 0x10EAF }, { 0x10EB2, 0x10EC1 }, + { 0x10EC8, 0x10ECF }, { 0x10ED9, 0x10EF9 }, { 0x10F28, 0x10F2F }, + { 0x10F5A, 0x10F6F }, { 0x10F8A, 0x10FAF }, { 0x10FCC, 0x10FDF }, + { 0x10FF7, 0x10FFF }, { 0x1104E, 0x11051 }, { 0x11076, 0x1107E }, + { 0x110C3, 0x110CC }, { 0x110CE, 0x110CF }, { 0x110E9, 0x110EF }, + { 0x110FA, 0x110FF }, { 0x11135, 0x11135 }, { 0x11148, 0x1114F }, + { 0x11177, 0x1117F }, { 0x111E0, 0x111E0 }, { 0x111F5, 0x111FF }, + { 0x11212, 0x11212 }, { 0x11242, 0x1127F }, { 0x11287, 0x11287 }, + { 0x11289, 0x11289 }, { 0x1128E, 0x1128E }, { 0x1129E, 0x1129E }, + { 0x112AA, 0x112AF }, { 0x112EB, 0x112EF }, { 0x112FA, 0x112FF }, + { 0x11304, 0x11304 }, { 0x1130D, 0x1130E }, { 0x11311, 0x11312 }, + { 0x11329, 0x11329 }, { 0x11331, 0x11331 }, { 0x11334, 0x11334 }, + { 0x1133A, 0x1133A }, { 0x11345, 0x11346 }, { 0x11349, 0x1134A }, + { 0x1134E, 0x1134F }, { 0x11351, 0x11356 }, { 0x11358, 0x1135C }, + { 0x11364, 0x11365 }, { 0x1136D, 0x1136F }, { 0x11375, 0x1137F }, + { 0x1138A, 0x1138A }, { 0x1138C, 0x1138D }, { 0x1138F, 0x1138F }, + { 0x113B6, 0x113B6 }, { 0x113C1, 0x113C1 }, { 0x113C3, 0x113C4 }, + { 0x113C6, 0x113C6 }, { 0x113CB, 0x113CB }, { 0x113D6, 0x113D6 }, + { 0x113D9, 0x113E0 }, { 0x113E3, 0x113FF }, { 0x1145C, 0x1145C }, + { 0x11462, 0x1147F }, { 0x114C8, 0x114CF }, { 0x114DA, 0x1157F }, + { 0x115B6, 0x115B7 }, { 0x115DE, 0x115FF }, { 0x11645, 0x1164F }, + { 0x1165A, 0x1165F }, { 0x1166D, 0x1167F }, { 0x116BA, 0x116BF }, + { 0x116CA, 0x116CF }, { 0x116E4, 0x116FF }, { 0x1171B, 0x1171C }, + { 0x1172C, 0x1172F }, { 0x11747, 0x117FF }, { 0x1183C, 0x1189F }, + { 0x118F3, 0x118FE }, { 0x11907, 0x11908 }, { 0x1190A, 0x1190B }, + { 0x11914, 0x11914 }, { 0x11917, 0x11917 }, { 0x11936, 0x11936 }, + { 0x11939, 0x1193A }, { 0x11947, 0x1194F }, { 0x1195A, 0x1199F }, + { 0x119A8, 0x119A9 }, { 0x119D8, 0x119D9 }, { 0x119E5, 0x119FF }, + { 0x11A48, 0x11A4F }, { 0x11AA3, 0x11AAF }, { 0x11AF9, 0x11AFF }, + { 0x11B0A, 0x11B5F }, { 0x11B68, 0x11BBF }, { 0x11BE2, 0x11BEF }, + { 0x11BFA, 0x11BFF }, { 0x11C09, 0x11C09 }, { 0x11C37, 0x11C37 }, + { 0x11C46, 0x11C4F }, { 0x11C6D, 0x11C6F }, { 0x11C90, 0x11C91 }, + { 0x11CA8, 0x11CA8 }, { 0x11CB7, 0x11CFF }, { 0x11D07, 0x11D07 }, + { 0x11D0A, 0x11D0A }, { 0x11D37, 0x11D39 }, { 0x11D3B, 0x11D3B }, + { 0x11D3E, 0x11D3E }, { 0x11D48, 0x11D4F }, { 0x11D5A, 0x11D5F }, + { 0x11D66, 0x11D66 }, { 0x11D69, 0x11D69 }, { 0x11D8F, 0x11D8F }, + { 0x11D92, 0x11D92 }, { 0x11D99, 0x11D9F }, { 0x11DAA, 0x11DAF }, + { 0x11DDC, 0x11DDF }, { 0x11DEA, 0x11EDF }, { 0x11EF9, 0x11EFF }, + { 0x11F11, 0x11F11 }, { 0x11F3B, 0x11F3D }, { 0x11F5B, 0x11FAF }, + { 0x11FB1, 0x11FBF }, { 0x11FF2, 0x11FFE }, { 0x1239A, 0x123FF }, + { 0x1246F, 0x1246F }, { 0x12475, 0x1247F }, { 0x12544, 0x12F8F }, + { 0x12FF3, 0x12FFF }, { 0x13456, 0x1345F }, { 0x143FB, 0x143FF }, + { 0x14647, 0x160FF }, { 0x1613A, 0x167FF }, { 0x16A39, 0x16A3F }, + { 0x16A5F, 0x16A5F }, { 0x16A6A, 0x16A6D }, { 0x16ABF, 0x16ABF }, + { 0x16ACA, 0x16ACF }, { 0x16AEE, 0x16AEF }, { 0x16AF6, 0x16AFF }, + { 0x16B46, 0x16B4F }, { 0x16B5A, 0x16B5A }, { 0x16B62, 0x16B62 }, + { 0x16B78, 0x16B7C }, { 0x16B90, 0x16D3F }, { 0x16D7A, 0x16E3F }, + { 0x16E9B, 0x16E9F }, { 0x16EB9, 0x16EBA }, { 0x16ED4, 0x16EFF }, + { 0x16F4B, 0x16F4E }, { 0x16F88, 0x16F8E }, { 0x16FA0, 0x16FDF }, + { 0x16FE5, 0x16FEF }, { 0x16FF7, 0x187FF }, { 0x18CD6, 0x18CFE }, + { 0x18D00, 0x18D7F }, { 0x18DF3, 0x1AFEF }, { 0x1AFF4, 0x1AFF4 }, + { 0x1AFFC, 0x1AFFC }, { 0x1AFFF, 0x1AFFF }, { 0x1B123, 0x1B131 }, + { 0x1B133, 0x1B14F }, { 0x1B153, 0x1B154 }, { 0x1B156, 0x1B163 }, + { 0x1B168, 0x1B16F }, { 0x1B2FC, 0x1BBFF }, { 0x1BC6B, 0x1BC6F }, + { 0x1BC7D, 0x1BC7F }, { 0x1BC89, 0x1BC8F }, { 0x1BC9A, 0x1BC9B }, + { 0x1BCA4, 0x1CBFF }, { 0x1CCFD, 0x1CCFF }, { 0x1CEB4, 0x1CEB9 }, + { 0x1CED1, 0x1CEDF }, { 0x1CEF1, 0x1CEFF }, { 0x1CF2E, 0x1CF2F }, + { 0x1CF47, 0x1CF4F }, { 0x1CFC4, 0x1CFFF }, { 0x1D0F6, 0x1D0FF }, + { 0x1D127, 0x1D128 }, { 0x1D1EB, 0x1D1FF }, { 0x1D246, 0x1D2BF }, + { 0x1D2D4, 0x1D2DF }, { 0x1D2F4, 0x1D2FF }, { 0x1D357, 0x1D35F }, + { 0x1D379, 0x1D3FF }, { 0x1D455, 0x1D455 }, { 0x1D49D, 0x1D49D }, + { 0x1D4A0, 0x1D4A1 }, { 0x1D4A3, 0x1D4A4 }, { 0x1D4A7, 0x1D4A8 }, + { 0x1D4AD, 0x1D4AD }, { 0x1D4BA, 0x1D4BA }, { 0x1D4BC, 0x1D4BC }, + { 0x1D4C4, 0x1D4C4 }, { 0x1D506, 0x1D506 }, { 0x1D50B, 0x1D50C }, + { 0x1D515, 0x1D515 }, { 0x1D51D, 0x1D51D }, { 0x1D53A, 0x1D53A }, + { 0x1D53F, 0x1D53F }, { 0x1D545, 0x1D545 }, { 0x1D547, 0x1D549 }, + { 0x1D551, 0x1D551 }, { 0x1D6A6, 0x1D6A7 }, { 0x1D7CC, 0x1D7CD }, + { 0x1DA8C, 0x1DA9A }, { 0x1DAA0, 0x1DAA0 }, { 0x1DAB0, 0x1DEFF }, + { 0x1DF1F, 0x1DF24 }, { 0x1DF2B, 0x1DFFF }, { 0x1E007, 0x1E007 }, + { 0x1E019, 0x1E01A }, { 0x1E022, 0x1E022 }, { 0x1E025, 0x1E025 }, + { 0x1E02B, 0x1E02F }, { 0x1E06E, 0x1E08E }, { 0x1E090, 0x1E0FF }, + { 0x1E12D, 0x1E12F }, { 0x1E13E, 0x1E13F }, { 0x1E14A, 0x1E14D }, + { 0x1E150, 0x1E28F }, { 0x1E2AF, 0x1E2BF }, { 0x1E2FA, 0x1E2FE }, + { 0x1E300, 0x1E4CF }, { 0x1E4FA, 0x1E5CF }, { 0x1E5FB, 0x1E5FE }, + { 0x1E600, 0x1E6BF }, { 0x1E6DF, 0x1E6DF }, { 0x1E6F6, 0x1E6FD }, + { 0x1E700, 0x1E7DF }, { 0x1E7E7, 0x1E7E7 }, { 0x1E7EC, 0x1E7EC }, + { 0x1E7EF, 0x1E7EF }, { 0x1E7FF, 0x1E7FF }, { 0x1E8C5, 0x1E8C6 }, + { 0x1E8D7, 0x1E8FF }, { 0x1E94C, 0x1E94F }, { 0x1E95A, 0x1E95D }, + { 0x1E960, 0x1EC70 }, { 0x1ECB5, 0x1ED00 }, { 0x1ED3E, 0x1EDFF }, + { 0x1EE04, 0x1EE04 }, { 0x1EE20, 0x1EE20 }, { 0x1EE23, 0x1EE23 }, + { 0x1EE25, 0x1EE26 }, { 0x1EE28, 0x1EE28 }, { 0x1EE33, 0x1EE33 }, + { 0x1EE38, 0x1EE38 }, { 0x1EE3A, 0x1EE3A }, { 0x1EE3C, 0x1EE41 }, + { 0x1EE43, 0x1EE46 }, { 0x1EE48, 0x1EE48 }, { 0x1EE4A, 0x1EE4A }, + { 0x1EE4C, 0x1EE4C }, { 0x1EE50, 0x1EE50 }, { 0x1EE53, 0x1EE53 }, + { 0x1EE55, 0x1EE56 }, { 0x1EE58, 0x1EE58 }, { 0x1EE5A, 0x1EE5A }, + { 0x1EE5C, 0x1EE5C }, { 0x1EE5E, 0x1EE5E }, { 0x1EE60, 0x1EE60 }, + { 0x1EE63, 0x1EE63 }, { 0x1EE65, 0x1EE66 }, { 0x1EE6B, 0x1EE6B }, + { 0x1EE73, 0x1EE73 }, { 0x1EE78, 0x1EE78 }, { 0x1EE7D, 0x1EE7D }, + { 0x1EE7F, 0x1EE7F }, { 0x1EE8A, 0x1EE8A }, { 0x1EE9C, 0x1EEA0 }, + { 0x1EEA4, 0x1EEA4 }, { 0x1EEAA, 0x1EEAA }, { 0x1EEBC, 0x1EEEF }, + { 0x1EEF2, 0x1EFFF }, { 0x1F02C, 0x1F02F }, { 0x1F094, 0x1F09F }, + { 0x1F0AF, 0x1F0B0 }, { 0x1F0C0, 0x1F0C0 }, { 0x1F0D0, 0x1F0D0 }, + { 0x1F0F6, 0x1F0FF }, { 0x1F1AE, 0x1F1E5 }, { 0x1F203, 0x1F20F }, + { 0x1F23C, 0x1F23F }, { 0x1F249, 0x1F24F }, { 0x1F252, 0x1F25F }, + { 0x1F266, 0x1F2FF }, { 0x1F6D9, 0x1F6DB }, { 0x1F6ED, 0x1F6EF }, + { 0x1F6FD, 0x1F6FF }, { 0x1F7DA, 0x1F7DF }, { 0x1F7EC, 0x1F7EF }, + { 0x1F7F1, 0x1F7FF }, { 0x1F80C, 0x1F80F }, { 0x1F848, 0x1F84F }, + { 0x1F85A, 0x1F85F }, { 0x1F888, 0x1F88F }, { 0x1F8AE, 0x1F8AF }, + { 0x1F8BC, 0x1F8BF }, { 0x1F8C2, 0x1F8CF }, { 0x1F8D9, 0x1F8FF }, + { 0x1FA58, 0x1FA5F }, { 0x1FA6E, 0x1FA6F }, { 0x1FA7D, 0x1FA7F }, + { 0x1FA8B, 0x1FA8D }, { 0x1FAC7, 0x1FAC7 }, { 0x1FAC9, 0x1FACC }, + { 0x1FADD, 0x1FADE }, { 0x1FAEB, 0x1FAEE }, { 0x1FAF9, 0x1FAFF }, + { 0x1FB93, 0x1FB93 }, { 0x1FBFB, 0x1FFFF }, { 0x2A6D7, 0x2F7FF }, + { 0x2FA1E, 0xE0000 }, { 0xE0002, 0xE001F }, { 0xE0080, 0xE00FF }, + { 0xE01F0, 0x10FFFD } + }; + /* *INDENT-ON* */ + + /* sorted list of non-overlapping intervals of non-characters */ + /* generated by + * uniset +WIDTH-W +emoji/emoji-data.txt -0000..00ff -cat=Cn -cat=Mn c + */ + /* *INDENT-OFF* */ + /* generated by run-uniset_dbl 1.4 */ + static const struct interval doublewidth[] = { + { 0x1100, 0x115F }, { 0x200D, 0x200D }, { 0x203C, 0x203C }, + { 0x2049, 0x2049 }, { 0x20E3, 0x20E3 }, { 0x2122, 0x2122 }, + { 0x2139, 0x2139 }, { 0x2194, 0x2194 }, { 0x21A9, 0x21A9 }, + { 0x231A, 0x231B }, { 0x2328, 0x232A }, { 0x23CF, 0x23CF }, + { 0x23E9, 0x23ED }, { 0x23EF, 0x23F1 }, { 0x23F3, 0x23F3 }, + { 0x23F8, 0x23F8 }, { 0x24C2, 0x24C2 }, { 0x25AA, 0x25AA }, + { 0x25B6, 0x25B6 }, { 0x25C0, 0x25C0 }, { 0x25FB, 0x25FB }, + { 0x25FD, 0x25FE }, { 0x2600, 0x2600 }, { 0x2602, 0x2602 }, + { 0x2604, 0x2604 }, { 0x260E, 0x260E }, { 0x2611, 0x2611 }, + { 0x2614, 0x2615 }, { 0x2618, 0x2618 }, { 0x261D, 0x261D }, + { 0x2620, 0x2620 }, { 0x2622, 0x2622 }, { 0x2626, 0x2626 }, + { 0x262A, 0x262A }, { 0x262E, 0x2638 }, { 0x263A, 0x263A }, + { 0x2640, 0x2640 }, { 0x2642, 0x2642 }, { 0x2648, 0x2653 }, + { 0x265F, 0x2660 }, { 0x2663, 0x2663 }, { 0x2665, 0x2665 }, + { 0x2668, 0x2668 }, { 0x267B, 0x267B }, { 0x267E, 0x267F }, + { 0x268A, 0x268F }, { 0x2692, 0x2696 }, { 0x2699, 0x2699 }, + { 0x269B, 0x269B }, { 0x26A0, 0x26A1 }, { 0x26A7, 0x26A7 }, + { 0x26AA, 0x26AB }, { 0x26B0, 0x26B0 }, { 0x26BD, 0x26BE }, + { 0x26C4, 0x26C5 }, { 0x26C8, 0x26C8 }, { 0x26CE, 0x26CF }, + { 0x26D1, 0x26D1 }, { 0x26D3, 0x26D4 }, { 0x26E9, 0x26EA }, + { 0x26F0, 0x26F0 }, { 0x26F2, 0x26F5 }, { 0x26F7, 0x26F7 }, + { 0x26F9, 0x26FA }, { 0x26FD, 0x26FD }, { 0x2702, 0x2702 }, + { 0x2705, 0x2705 }, { 0x2708, 0x2708 }, { 0x270A, 0x270B }, + { 0x270D, 0x270D }, { 0x270F, 0x270F }, { 0x2712, 0x2712 }, + { 0x2714, 0x2714 }, { 0x2716, 0x2716 }, { 0x271D, 0x271D }, + { 0x2721, 0x2721 }, { 0x2728, 0x2728 }, { 0x2733, 0x2733 }, + { 0x2744, 0x2744 }, { 0x2747, 0x2747 }, { 0x274C, 0x274C }, + { 0x274E, 0x274E }, { 0x2753, 0x2755 }, { 0x2757, 0x2757 }, + { 0x2763, 0x2764 }, { 0x2795, 0x2797 }, { 0x27A1, 0x27A1 }, + { 0x27B0, 0x27B0 }, { 0x27BF, 0x27BF }, { 0x2934, 0x2934 }, + { 0x2B05, 0x2B05 }, { 0x2B1B, 0x2B1C }, { 0x2B50, 0x2B50 }, + { 0x2B55, 0x2B55 }, { 0x2E80, 0x2E99 }, { 0x2E9B, 0x2EF3 }, + { 0x2F00, 0x2FD5 }, { 0x2FF0, 0x3029 }, { 0x302E, 0x303E }, + { 0x3041, 0x3096 }, { 0x309B, 0x30FF }, { 0x3105, 0x312F }, + { 0x3131, 0x318E }, { 0x3190, 0x31E5 }, { 0x31EF, 0x321E }, + { 0x3220, 0x3247 }, { 0x3250, 0xA48C }, { 0xA490, 0xA4C6 }, + { 0xA960, 0xA97C }, { 0xAC00, 0xD7A3 }, { 0xF900, 0xFA6D }, + { 0xFA70, 0xFAD9 }, { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE52 }, + { 0xFE54, 0xFE66 }, { 0xFE68, 0xFE6B }, { 0xFF01, 0xFF60 }, + { 0xFFE0, 0xFFE6 }, { 0x16FE0, 0x16FE3 }, { 0x16FF0, 0x16FF6 }, + { 0x17000, 0x18CD5 }, { 0x18CFF, 0x18D1E }, { 0x18D80, 0x18DF2 }, + { 0x1AFF0, 0x1AFF3 }, { 0x1AFF5, 0x1AFFB }, { 0x1AFFD, 0x1AFFE }, + { 0x1B000, 0x1B122 }, { 0x1B132, 0x1B132 }, { 0x1B150, 0x1B152 }, + { 0x1B155, 0x1B155 }, { 0x1B164, 0x1B167 }, { 0x1B170, 0x1B2FB }, + { 0x1D300, 0x1D356 }, { 0x1D360, 0x1D376 }, { 0x1F004, 0x1F004 }, + { 0x1F02C, 0x1F02C }, { 0x1F094, 0x1F094 }, { 0x1F0AF, 0x1F0AF }, + { 0x1F0C0, 0x1F0C0 }, { 0x1F0CF, 0x1F0D0 }, { 0x1F0F6, 0x1F0F6 }, + { 0x1F170, 0x1F170 }, { 0x1F17E, 0x1F17E }, { 0x1F18E, 0x1F18E }, + { 0x1F191, 0x1F19A }, { 0x1F1AE, 0x1F1AE }, { 0x1F1E6, 0x1F1E6 }, + { 0x1F200, 0x1F203 }, { 0x1F210, 0x1F23C }, { 0x1F240, 0x1F249 }, + { 0x1F250, 0x1F252 }, { 0x1F260, 0x1F266 }, { 0x1F300, 0x1F321 }, + { 0x1F324, 0x1F324 }, { 0x1F32D, 0x1F393 }, { 0x1F396, 0x1F396 }, + { 0x1F399, 0x1F399 }, { 0x1F39E, 0x1F39E }, { 0x1F3A0, 0x1F3CB }, + { 0x1F3CF, 0x1F3D4 }, { 0x1F3E0, 0x1F3F0 }, { 0x1F3F3, 0x1F3F5 }, + { 0x1F3F7, 0x1F4FD }, { 0x1F4FF, 0x1F53D }, { 0x1F549, 0x1F549 }, + { 0x1F54B, 0x1F54E }, { 0x1F550, 0x1F567 }, { 0x1F56F, 0x1F56F }, + { 0x1F573, 0x1F574 }, { 0x1F57A, 0x1F57A }, { 0x1F587, 0x1F587 }, + { 0x1F58A, 0x1F58A }, { 0x1F590, 0x1F590 }, { 0x1F595, 0x1F596 }, + { 0x1F5A4, 0x1F5A5 }, { 0x1F5A8, 0x1F5A8 }, { 0x1F5B1, 0x1F5B1 }, + { 0x1F5BC, 0x1F5BC }, { 0x1F5C2, 0x1F5C2 }, { 0x1F5D1, 0x1F5D1 }, + { 0x1F5DC, 0x1F5DC }, { 0x1F5E1, 0x1F5E1 }, { 0x1F5E3, 0x1F5E3 }, + { 0x1F5E8, 0x1F5E8 }, { 0x1F5EF, 0x1F5EF }, { 0x1F5F3, 0x1F5F3 }, + { 0x1F5FA, 0x1F64F }, { 0x1F680, 0x1F6C5 }, { 0x1F6CB, 0x1F6CD }, + { 0x1F6D0, 0x1F6D2 }, { 0x1F6D5, 0x1F6D9 }, { 0x1F6DC, 0x1F6E0 }, + { 0x1F6E9, 0x1F6E9 }, { 0x1F6EB, 0x1F6ED }, { 0x1F6F0, 0x1F6F0 }, + { 0x1F6F3, 0x1F6FD }, { 0x1F7DA, 0x1F7DA }, { 0x1F7E0, 0x1F7EC }, + { 0x1F7F0, 0x1F7F1 }, { 0x1F80C, 0x1F80C }, { 0x1F848, 0x1F848 }, + { 0x1F85A, 0x1F85A }, { 0x1F888, 0x1F888 }, { 0x1F8AE, 0x1F8AE }, + { 0x1F8BC, 0x1F8BC }, { 0x1F8C2, 0x1F8C2 }, { 0x1F8D9, 0x1F8D9 }, + { 0x1F90C, 0x1F93A }, { 0x1F93C, 0x1F945 }, { 0x1F947, 0x1F9FF }, + { 0x1FA58, 0x1FA58 }, { 0x1FA6E, 0x1FA6E }, { 0x1FA70, 0x1FA7D }, + { 0x1FA80, 0x1FA8B }, { 0x1FA8E, 0x1FAC9 }, { 0x1FACD, 0x1FADD }, + { 0x1FADF, 0x1FAEB }, { 0x1FAEF, 0x1FAF9 }, { 0x1FC00, 0x1FC00 }, + { 0x20000, 0x2A6DF }, { 0x2A700, 0x2B81D }, { 0x2B820, 0x2CEAD }, + { 0x2CEB0, 0x2EBE0 }, { 0x2EBF0, 0x2EE5D }, { 0x2F800, 0x2FA1D }, + { 0x30000, 0x3134A }, { 0x31350, 0x33479 }, { 0xE0020, 0xE0020 } + }; + /* *INDENT-ON* */ + + int result; + +#define Lookup(cmp, table) \ + bisearch(cmp, table, \ + (int) (sizeof(table) / sizeof(struct interval) - 1)) + + /* test for 8-bit control characters */ + if (cmp == 0) { + result = 0; + } else if (cmp < 32 || (cmp >= 0x7f && cmp < 0xa0)) { + result = -1; + } else if (cmp == 0xad) { + result = use_latin1; + } else if (Lookup(cmp, formatting)) { + /* treat formatting characters like control characters */ + result = 0; + } else if (Lookup(cmp, combining)) { + /* binary search in table of non-spacing characters */ + result = 0; + } else { + /* if we arrive here, cmp is not a combining or C0/C1 control character */ + result = 1; + + if (Lookup(cmp, doublewidth)) { + result = 2; + } else if (cmp >= 0xd800 && cmp <= 0xdfff) { +#if HAVE_WCWIDTH + result = (wcwidth) (ucs); +#else + result = -1; +#endif + } else if (cmp >= unknowns[0].first && Lookup(cmp, unknowns)) { + result = -1; + } + } + return result; +} + +#ifdef UNUSED +int +mk_wcswidth(const wchar_t *pwcs, size_t n) +{ + int width = 0; + + for (; *pwcs && n-- > 0; pwcs++) { + int w; + + if ((w = mk_wcwidth(*pwcs)) < 0) + return -1; + else + width += w; + } + + return width; +} +#endif /* UNUSED */ + +/* + * The following functions are the same as mk_wcwidth() and + * mk_wcwidth_cjk(), except that spacing characters in the East Asian + * Ambiguous (A) category as defined in Unicode Technical Report #11 + * have a column width of 2. This variant might be useful for users of + * CJK legacy encodings who want to migrate to UCS without changing + * the traditional terminal character-width behaviour. It is not + * otherwise recommended for general use. + */ +NCURSES_EXPORT(int) +mk_wcwidth_cjk(uint32_t ucs) +{ + /* sorted list of non-overlapping intervals of East Asian Ambiguous + * characters, generated by + * + * uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf \ + * +E000..F8FF \ + * +F0000..FFFFD \ + * +100000..10FFFD c + * + * "WIDTH-A" is a file extracted from EastAsianWidth.txt by selecting + * only those with width "A", and omitting: + * + * 0xAD + * all lines with "COMBINING" + */ + /* *INDENT-OFF* */ + /* generated by run-uniset_cjk 1.6 */ + static const struct interval ambiguous[] = { + { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, + { 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 }, + { 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 }, + { 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 }, + { 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED }, + { 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA }, + { 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 }, + { 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B }, + { 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 }, + { 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 }, + { 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 }, + { 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE }, + { 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 }, + { 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA }, + { 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 }, + { 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB }, + { 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB }, + { 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0391, 0x03A1 }, + { 0x03A3, 0x03A9 }, { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, + { 0x0401, 0x0401 }, { 0x0410, 0x044F }, { 0x0451, 0x0451 }, + { 0x2010, 0x2010 }, { 0x2013, 0x2016 }, { 0x2018, 0x2019 }, + { 0x201C, 0x201D }, { 0x2020, 0x2022 }, { 0x2024, 0x2027 }, + { 0x2030, 0x2030 }, { 0x2032, 0x2033 }, { 0x2035, 0x2035 }, + { 0x203B, 0x203B }, { 0x203E, 0x203E }, { 0x2074, 0x2074 }, + { 0x207F, 0x207F }, { 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, + { 0x2103, 0x2103 }, { 0x2105, 0x2105 }, { 0x2109, 0x2109 }, + { 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 }, + { 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 }, + { 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 }, + { 0x2189, 0x2189 }, { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, + { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, + { 0x2200, 0x2200 }, { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, + { 0x220B, 0x220B }, { 0x220F, 0x220F }, { 0x2211, 0x2211 }, + { 0x2215, 0x2215 }, { 0x221A, 0x221A }, { 0x221D, 0x2220 }, + { 0x2223, 0x2223 }, { 0x2225, 0x2225 }, { 0x2227, 0x222C }, + { 0x222E, 0x222E }, { 0x2234, 0x2237 }, { 0x223C, 0x223D }, + { 0x2248, 0x2248 }, { 0x224C, 0x224C }, { 0x2252, 0x2252 }, + { 0x2260, 0x2261 }, { 0x2264, 0x2267 }, { 0x226A, 0x226B }, + { 0x226E, 0x226F }, { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, + { 0x2295, 0x2295 }, { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, + { 0x22BF, 0x22BF }, { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, + { 0x24EB, 0x254B }, { 0x2550, 0x2573 }, { 0x2580, 0x258F }, + { 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, + { 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, + { 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, + { 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, + { 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F }, + { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 }, + { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 }, + { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F }, + { 0x269E, 0x269F }, { 0x26BF, 0x26BF }, { 0x26C6, 0x26CD }, + { 0x26CF, 0x26D3 }, { 0x26D5, 0x26E1 }, { 0x26E3, 0x26E3 }, + { 0x26E8, 0x26E9 }, { 0x26EB, 0x26F1 }, { 0x26F4, 0x26F4 }, + { 0x26F6, 0x26F9 }, { 0x26FB, 0x26FC }, { 0x26FE, 0x26FF }, + { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0x2B56, 0x2B59 }, + { 0x3248, 0x324F }, { 0xE000, 0xF8FF }, { 0xFFFD, 0xFFFD }, + { 0x1F100, 0x1F10A }, { 0x1F110, 0x1F12D }, { 0x1F130, 0x1F169 }, + { 0x1F170, 0x1F18D }, { 0x1F18F, 0x1F190 }, { 0x1F19B, 0x1F1AC }, + { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD } + }; + /* *INDENT-ON* */ + + /* binary search in table of non-spacing characters */ + if (Lookup((unsigned long) ucs, ambiguous)) + return 2; + + return mk_wcwidth(ucs); +} + +#ifdef UNUSED +NCURSES_EXPORT(int) +mk_wcswidth_cjk(const uint32_t *pwcs, size_t n) +{ + int width = 0; + + for (; *pwcs && n-- > 0; pwcs++) { + int w; + + if ((w = mk_wcwidth_cjk(*pwcs)) < 0) + return -1; + else + width += w; + } + + return width; +} +#endif /* UNUSED */ + +#ifdef TEST_DRIVER +static int opt_all = 0; +static int opt_quiet = 0; +static int opt_wider = 0; +static long total_test = 0; +static long total_errs = 0; + +static void +usage(void) +{ + static const char *msg[] = + { + "Usage: test_wcwidth [options] [c1[-c1b] [c2-[c2b] [...]]]", + "", + "Options:", + " -a show all data, rather than just differences", + " -s show only summary", + " -w use width-characters for ambiguous-width" + }; + size_t n; + for (n = 0; n < sizeof(msg) / sizeof(msg[0]); ++n) { + fprintf(stderr, "%s\n", msg[n]); + } + exit(EXIT_FAILURE); +} + +static int +decode_one(const char *source, char **target) +{ + int result = -1; + long check; + int radix = 0; + if ((source[0] == 'u' || source[0] == 'U') && source[1] == '+') { + source += 2; + radix = 16; + } + check = strtol(source, target, radix); + if (*target != NULL && *target != source) + result = (int) check; + return result; +} + +static int +decode_range(const char *source, int *lo, int *hi) +{ + int result = 0; + char *after1; + char *after2; + if ((*lo = decode_one(source, &after1)) >= 0) { + after1 += strspn(after1, ":-.\t "); + if ((*hi = decode_one(after1, &after2)) < 0) { + *hi = *lo; + } + result = 1; + } + return result; +} + +static void +do_range(const char *source) +{ + int lo, hi; + if (decode_range(source, &lo, &hi)) { + while (lo <= hi) { + wchar_t wlo = (wchar_t) lo; + int local_rc = opt_wider ? mk_wcwidth_cjk(wlo) : mk_wcwidth(wlo); + int other_rc = wcwidth(wlo); + ++total_test; + if (opt_all || (local_rc != other_rc)) { + if (!opt_quiet) + printf("U+%04X\t%d\t%d\n", lo, local_rc, other_rc); + } + if (local_rc != other_rc) { + ++total_errs; + } + ++lo; + } + } +} + +int +main(int argc, char **argv) +{ + int ch; + + setlocale(LC_ALL, ""); + while ((ch = getopt(argc, argv, "asw")) != -1) { + switch (ch) { + case 'a': + opt_all = 1; + break; + case 's': + opt_quiet = 1; + break; + case 'w': + opt_wider = 1; + break; + default: + usage(); + } + } + if (optind >= argc) + usage(); + while (optind < argc) { + do_range(argv[optind++]); + } + if (total_test) { + printf("%ld/%ld mismatches (%.0f%%)\n", + total_errs, + total_test, + (100.0 * (double) total_errs) / (double) total_test); + } + return EXIT_SUCCESS; +} +#endif /* TEST_DRIVER 1 */ + +#endif /* _WCWIDTH_H_incl 1 */ diff --git a/ncurses/ncurses/widechar/charable.c b/ncurses/ncurses/widechar/charable.c new file mode 100644 index 0000000000..4f13d95df6 --- /dev/null +++ b/ncurses/ncurses/widechar/charable.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * Copyright 2018-2020,2025 Thomas E. Dickey * + * Copyright 2003-2005,2008 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* +** Support functions for wide/narrow conversion. +*/ + +#include + +MODULE_ID("$Id: charable.c,v 1.9 2025/09/13 10:55:44 tom Exp $") + +NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch) +{ + bool result; +#if HAVE_WCTOB + result = (wctob((wint_t) ch) == (int) ch); +#else + result = (_nc_to_char(ch) >= 0); +#endif + return result; +} + +NCURSES_EXPORT(int) _nc_to_char(wint_t ch) +{ + int result; +#if HAVE_WCTOB + result = wctob(ch); +#elif HAVE_WCTOMB + char temp[MB_LEN_MAX + 1]; + if (wctomb(temp, ch) == 1) + result = UChar(temp[0]); + else + result = -1; +#else +#error expected either wctob/wctomb +#endif + return result; +} + +NCURSES_EXPORT(wint_t) _nc_to_widechar(int ch) +{ + wint_t result; +#if HAVE_BTOWC + result = btowc(ch); +#elif HAVE_MBTOWC + wchar_t convert; + char temp[2]; + temp[0] = ch; + temp[1] = '\0'; + if (mbtowc(&convert, temp, 1) >= 0) + result = convert; + else + result = WEOF; +#else +#error expected either btowc/mbtowc +#endif + return result; +} diff --git a/ncurses/ncurses/widechar/lib_add_wch.c b/ncurses/ncurses/widechar/lib_add_wch.c new file mode 100644 index 0000000000..0d43cd5a31 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_add_wch.c @@ -0,0 +1,453 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 2004-2011,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* +** lib_add_wch.c +** +** The routine wadd_wch(). +** +*/ + +#include + +#if HAVE_WCTYPE_H +#include +#endif + +MODULE_ID("$Id: lib_add_wch.c,v 1.22 2025/01/19 00:51:54 tom Exp $") + +/* clone/adapt lib_addch.c */ +static const cchar_t blankchar = NewChar(BLANK_TEXT); + +/* + * Ugly microtweaking alert. Everything from here to end of module is + * likely to be speed-critical -- profiling data sure says it is! + * Most of the important screen-painting functions are shells around + * wadd_wch(). So we make every effort to reduce function-call overhead + * by inlining stuff, even at the cost of making wrapped copies for + * export. Also we supply some internal versions that don't call the + * window sync hook, for use by string-put functions. + */ + +/* Return bit mask for clearing color pair number if given ch has color */ +#define COLOR_MASK(ch) (~(attr_t)(((ch) & A_COLOR) ? A_COLOR : 0)) + +static NCURSES_INLINE cchar_t +render_char(WINDOW *win, cchar_t ch) +/* compute a rendition of the given char correct for the current context */ +{ + 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 bkgrnd */ + a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a); + /* color in ch has precedence */ + if (pair == 0) { + if ((pair = GET_WINDOW_PAIR(win)) == 0) + pair = GetPair(win->_nc_bkgd); + } + AddAttr(ch, (a & COLOR_MASK(AttrOf(ch)))); + SetPair(ch, pair); + } + + 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); +} + +/* check if position is legal; if not, return error */ +#ifndef NDEBUG /* treat this like an assertion */ +#define CHECK_POSITION(win, x, y) \ + if (y > win->_maxy \ + || x > win->_maxx \ + || y < 0 \ + || x < 0) { \ + TR(TRACE_VIRTPUT, ("Alert! Win=%p _curx = %d, _cury = %d " \ + "(_maxx = %d, _maxy = %d)", win, x, y, \ + win->_maxx, win->_maxy)); \ + return(ERR); \ + } +#else +#define CHECK_POSITION(win, x, y) /* nothing */ +#endif + +static bool +newline_forces_scroll(const WINDOW *win, NCURSES_SIZE_T *ypos) +{ + bool result = FALSE; + + if (*ypos >= win->_regtop && *ypos == win->_regbottom) { + *ypos = win->_regbottom; + result = TRUE; + } else { + *ypos = (NCURSES_SIZE_T) (*ypos + 1); + } + return result; +} + +/* + * 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); + scroll(win); + } + win->_curx = 0; + return (OK); +} + +static int wadd_wch_literal(WINDOW *, cchar_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) +{ + cchar_t blank = blankchar; + int save_x = win->_curx; + int save_y = win->_cury; + + while (count-- > 0) { + if (wadd_wch_literal(win, blank) == ERR) + break; + } + win->_curx = (NCURSES_SIZE_T) save_x; + win->_cury = (NCURSES_SIZE_T) save_y; +} + +static int +wadd_wch_literal(WINDOW *win, cchar_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); + + line = win->_line + y; + + CHANGED_CELL(line, x); + + /* + * Non-spacing characters are added to the current cell. + * + * Spacing characters that are wider than one column require some display + * adjustments. + */ + { + int len = _nc_wacs_width(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) { + for (j = x - 1; j > 0; --j) { + if (!isWidecExt(win->_line[y].text[j])) { + break; + } + } + chars = (win->_line[y].text[j].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; + line = win->_line + y; + } + /* + * 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) { + cchar_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. + */ + testwrapping: + + TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s", + (long) win->_cury, (long) win->_curx, x - 1, + _tracech_t(CHREF(ch)))); + + if (x > win->_maxx) { + return wrap_to_next_line(win); + } + win->_curx = (NCURSES_SIZE_T) x; + return OK; +} + +static NCURSES_INLINE int +wadd_wch_nosync(WINDOW *win, cchar_t ch) +/* the workhorse function -- add a character to the given window */ +{ + NCURSES_SIZE_T x, y; + const wchar_t *s; + int tabsize = 8; +#if USE_REENTRANT + SCREEN *sp = _nc_screen_of(win); +#endif + + /* + * If we are using the alternate character set, forget about locale. + * Otherwise, if the locale claims the code is printable, treat it that + * way. + */ + if ((AttrOf(ch) & A_ALTCHARSET) + || iswprint((wint_t) CharOf(ch))) + return wadd_wch_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; + + switch (CharOf(ch)) { + case '\t': +#if USE_REENTRANT + tabsize = *ptrTabsize(sp); +#else + tabsize = TABSIZE; +#endif + x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize))); + /* + * Space-fill the tab on the bottom line so that we'll get the + * "correct" cursor position. + */ + if ((!win->_scroll && (y == win->_regbottom)) + || (x <= win->_maxx)) { + cchar_t blank = blankchar; + AddAttr(blank, AttrOf(ch)); + while (win->_curx < x) { + if (wadd_wch_literal(win, blank) == ERR) + return (ERR); + } + break; + } else { + wclrtoeol(win); + win->_flags |= _WRAPPED; + if (newline_forces_scroll(win, &y)) { + x = win->_maxx; + if (win->_scroll) { + scroll(win); + x = 0; + } + } else { + x = 0; + } + } + break; + case '\n': + wclrtoeol(win); + if (newline_forces_scroll(win, &y)) { + if (win->_scroll) + scroll(win); + else + return (ERR); + } + /* FALLTHRU */ + case '\r': + x = 0; + win->_flags &= ~_WRAPPED; + break; + case '\b': + if (x == 0) + return (OK); + x--; + win->_flags &= ~_WRAPPED; + break; + default: + if ((s = wunctrl(&ch)) != NULL) { + while (*s) { + cchar_t sch; + SetChar(sch, *s++, AttrOf(ch)); + if_EXT_COLORS(SetPair(sch, GetPair(ch))); + if (wadd_wch_literal(win, sch) == ERR) + return ERR; + } + return OK; + } + return ERR; + } + + win->_curx = x; + win->_cury = y; + + return OK; +} + +/* + * 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. + */ + +/* These are actual entry points */ + +NCURSES_EXPORT(int) +wadd_wch(WINDOW *win, const cchar_t *wch) +{ + int code = ERR; + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), + (void *) win, + _tracecchar_t(wch))); + + if (win && (wadd_wch_nosync(win, *wch) != ERR)) { + _nc_synchook(win); + code = OK; + } + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} + +NCURSES_EXPORT(int) +wecho_wchar(WINDOW *win, const cchar_t *wch) +{ + int code = ERR; + + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"), + (void *) win, + _tracecchar_t(wch))); + + if (win && (wadd_wch_nosync(win, *wch) != ERR)) { + bool save_immed = win->_immed; + win->_immed = TRUE; + _nc_synchook(win); + win->_immed = save_immed; + code = OK; + } + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/ncurses/ncurses/widechar/lib_box_set.c b/ncurses/ncurses/widechar/lib_box_set.c new file mode 100644 index 0000000000..f71994626c --- /dev/null +++ b/ncurses/ncurses/widechar/lib_box_set.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2002-2009,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/**************************************************************************** + * Authors: Sven Verdoolaege and Thomas Dickey 2001,2002 * + ****************************************************************************/ + +/* +** lib_box_set.c +** +** The routine wborder_set(). +** +*/ + +#include + +MODULE_ID("$Id: lib_box_set.c,v 1.8 2024/12/07 20:08:15 tom Exp $") + +NCURSES_EXPORT(int) +wborder_set(WINDOW *win, + const ARG_CH_T ls, const ARG_CH_T rs, + const ARG_CH_T ts, const ARG_CH_T bs, + const ARG_CH_T tl, const ARG_CH_T tr, + const ARG_CH_T bl, const ARG_CH_T br) +{ + NCURSES_SIZE_T i; + NCURSES_SIZE_T endx, endy; + NCURSES_CH_T wls, wrs, wts, wbs, wtl, wtr, wbl, wbr; + + T((T_CALLED("wborder_set(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), + (void *) win, + _tracech_t2(1, ls), + _tracech_t2(2, rs), + _tracech_t2(3, ts), + _tracech_t2(4, bs), + _tracech_t2(5, tl), + _tracech_t2(6, tr), + _tracech_t2(7, bl), + _tracech_t2(8, br))); + + if (!win) + returnCode(ERR); + +#define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == NULL) ? *(const ARG_CH_T)def : *ch) + + RENDER_WITH_DEFAULT(ls, WACS_VLINE); + RENDER_WITH_DEFAULT(rs, WACS_VLINE); + RENDER_WITH_DEFAULT(ts, WACS_HLINE); + RENDER_WITH_DEFAULT(bs, WACS_HLINE); + RENDER_WITH_DEFAULT(tl, WACS_ULCORNER); + RENDER_WITH_DEFAULT(tr, WACS_URCORNER); + RENDER_WITH_DEFAULT(bl, WACS_LLCORNER); + RENDER_WITH_DEFAULT(br, WACS_LRCORNER); + + T(("using %s, %s, %s, %s, %s, %s, %s, %s", + _tracech_t2(1, CHREF(wls)), + _tracech_t2(2, CHREF(wrs)), + _tracech_t2(3, CHREF(wts)), + _tracech_t2(4, CHREF(wbs)), + _tracech_t2(5, CHREF(wtl)), + _tracech_t2(6, CHREF(wtr)), + _tracech_t2(7, CHREF(wbl)), + _tracech_t2(8, CHREF(wbr)))); + + endx = win->_maxx; + endy = win->_maxy; + + for (i = 0; i <= endx; i++) { + win->_line[0].text[i] = wts; + 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] = wls; + win->_line[i].text[endx] = wrs; + win->_line[i].firstchar = 0; + win->_line[i].lastchar = endx; + } + win->_line[0].text[0] = wtl; + win->_line[0].text[endx] = wtr; + win->_line[endy].text[0] = wbl; + win->_line[endy].text[endx] = wbr; + + _nc_synchook(win); + returnCode(OK); +} diff --git a/ncurses/ncurses/widechar/lib_cchar.c b/ncurses/ncurses/widechar/lib_cchar.c new file mode 100644 index 0000000000..ed426da16a --- /dev/null +++ b/ncurses/ncurses/widechar/lib_cchar.c @@ -0,0 +1,161 @@ +/**************************************************************************** + * Copyright 2019-2022,2024 Thomas E. Dickey * + * Copyright 2001-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* +** lib_cchar.c +** +** The routines setcchar() and getcchar(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_cchar.c,v 1.40 2024/12/07 18:07:52 tom Exp $") + +/* + * The SuSv2 description leaves some room for interpretation. We'll assume wch + * points to a string which is L'\0' terminated, contains at least one + * character with strictly positive width, which must be the first, and + * contains no characters of negative width. + */ +NCURSES_EXPORT(int) +setcchar(cchar_t *wcval, + const wchar_t *wch, + const attr_t attrs, + NCURSES_PAIRS_T pair_arg, + const void *opts) +{ + int code = OK; + int color_pair = pair_arg; + unsigned len; + + TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,attrs=%lu,pair=%d,%p)"), + (void *) wcval, _nc_viswbuf(wch), + (unsigned long) attrs, color_pair, opts)); + + set_extended_pair(opts, color_pair); + if (wch == NULL + || ((len = (unsigned) wcslen(wch)) > 1 && _nc_wacs_width(wch[0]) < 0) + || color_pair < 0) { + code = ERR; + } else { + unsigned i; + + if (len > CCHARW_MAX) + len = CCHARW_MAX; + + /* + * If we have a following spacing-character, stop at that point. We + * are only interested in adding non-spacing characters. + */ + for (i = 1; i < len; ++i) { + if (_nc_wacs_width(wch[i]) != 0) { + len = i; + break; + } + } + + memset(wcval, 0, sizeof(*wcval)); + + if (len != 0) { + SetAttr(*wcval, attrs); + SetPair(CHDEREF(wcval), color_pair); + memcpy(&wcval->chars, wch, len * sizeof(wchar_t)); + TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len, + _tracecchar_t(wcval))); + } + } + + TR(TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} + +NCURSES_EXPORT(int) +getcchar(const cchar_t *wcval, + wchar_t *wch, + attr_t *attrs, + NCURSES_PAIRS_T *pair_arg, + void *opts) +{ + int code = ERR; + + TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"), + (const void *) wcval, + (void *) wch, + (void *) attrs, + (void *) pair_arg, + opts)); + +#if !NCURSES_EXT_COLORS + if (opts != NULL) { + ; /* empty */ + } else +#endif + if (wcval != NULL) { + const wchar_t *wp; + int len; + +#if HAVE_WMEMCHR + len = ((wp = wmemchr(wcval->chars, L'\0', (size_t) CCHARW_MAX)) + ? (int) (wp - wcval->chars) + : CCHARW_MAX); +#else + len = wcsnlen(wcval->chars, CCHARW_MAX); +#endif + if (wch == NULL) { + /* + * If the value is a null, set the length to 1. + * If the value is not a null, return the length plus 1 for null. + */ + code = (len < CCHARW_MAX) ? (len + 1) : CCHARW_MAX; + } else if (attrs == NULL || pair_arg == NULL) { + code = ERR; + } else if (len >= 0) { + int color_pair; + + TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len, + _tracecchar_t(wcval))); + *attrs = AttrOf(*wcval) & A_ATTRIBUTES; + color_pair = GetPair(*wcval); + get_extended_pair(opts, color_pair); + *pair_arg = limit_PAIRS(color_pair); + wmemcpy(wch, wcval->chars, (size_t) len); + wch[len] = L'\0'; + if (*pair_arg >= 0) + code = OK; + } + } + + TR(TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/ncurses/ncurses/widechar/lib_erasewchar.c b/ncurses/ncurses/widechar/lib_erasewchar.c new file mode 100644 index 0000000000..94d81cc8dc --- /dev/null +++ b/ncurses/ncurses/widechar/lib_erasewchar.c @@ -0,0 +1,99 @@ +/**************************************************************************** + * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 2002-2010,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: lib_erasewchar.c,v 1.5 2021/05/22 23:51:14 tom Exp $") + +/* + * erasewchar() + * + * Return erase character as given in cur_term->Ottyb. + */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch); +NCURSES_EXPORT(int) +NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch) +{ + int value; + int result = ERR; + + T((T_CALLED("erasewchar()"))); + if ((value = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG)) != ERR) { + *wch = (wchar_t) value; + result = OK; + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +erasewchar(wchar_t *wch) +{ + return NCURSES_SP_NAME(erasewchar) (CURRENT_SCREEN, wch); +} +#endif + +/* + * killwchar() + * + * Return kill character as given in cur_term->Ottyb. + */ + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch); +NCURSES_EXPORT(int) +NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch) +{ + int value; + int result = ERR; + + T((T_CALLED("killwchar()"))); + if ((value = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG)) != ERR) { + *wch = (wchar_t) value; + result = OK; + } + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +killwchar(wchar_t *wch) +{ + return NCURSES_SP_NAME(killwchar) (CURRENT_SCREEN, wch); +} +#endif diff --git a/ncurses/ncurses/widechar/lib_get_wch.c b/ncurses/ncurses/widechar/lib_get_wch.c new file mode 100644 index 0000000000..a92e7142ca --- /dev/null +++ b/ncurses/ncurses/widechar/lib_get_wch.c @@ -0,0 +1,124 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 2002-2011,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002-on * + ****************************************************************************/ + +/* +** lib_get_wch.c +** +** The routine get_wch(). +** +*/ + +#include +#include + +MODULE_ID("$Id: lib_get_wch.c,v 1.28 2025/11/01 20:16:24 tom Exp $") + +NCURSES_EXPORT(int) +wget_wch(WINDOW *win, wint_t *result) +{ + SCREEN *sp; + int code; + int value = 0; +#ifndef state_unused + mbstate_t state; +#endif + + T((T_CALLED("wget_wch(%p)"), (void *) win)); + + /* + * We can get a stream of single-byte characters and KEY_xxx codes from + * _nc_wgetch(), while we want to return a wide character or KEY_xxx code. + */ + _nc_lock_global(curses); + sp = _nc_screen_of(win); + + if (sp != NULL) { + size_t count = 0; + + for (;;) { + char buffer[(MB_LEN_MAX * 9) + 1]; /* allow some redundant shifts */ + + T(("reading %d of %d", (int) count + 1, (int) sizeof(buffer))); + code = _nc_wgetch(win, &value, TRUE EVENTLIST_2nd((_nc_eventlist + *) 0)); + if (code == ERR) { + break; + } else if (code == KEY_CODE_YES) { + /* + * If we were processing an incomplete multibyte character, + * return an error since we have a KEY_xxx code which + * interrupts it. For some cases, we could improve this by + * writing a new version of lib_getch.c(!), but it is not clear + * whether the improvement would be worth the effort. + */ + if (count != 0) { + safe_ungetch(SP_PARM, value); + code = ERR; + } + break; + } else if (count + 1 >= sizeof(buffer)) { + safe_ungetch(SP_PARM, value); + code = ERR; + break; + } else { + int status; + + buffer[count++] = (char) UChar(value); + reset_mbytes(state); + status = count_mbytes(buffer, count, state); + if (status >= 0) { + wchar_t wch; + reset_mbytes(state); + if (check_mbytes(wch, buffer, count, state) != status) { + code = ERR; /* the two calls should match */ + safe_ungetch(SP_PARM, value); + } + value = (int) wch; + break; + } + } + } + } else { + code = ERR; + } + + if (result != NULL) + *result = (wint_t) value; + + _nc_unlock_global(curses); + T(("result %#o", value)); + returnCode(code); +} diff --git a/ncurses/ncurses/widechar/lib_get_wstr.c b/ncurses/ncurses/widechar/lib_get_wstr.c new file mode 100644 index 0000000000..07581a7865 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_get_wstr.c @@ -0,0 +1,230 @@ +/**************************************************************************** + * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 2002-2009,2011 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* +** lib_get_wstr.c +** +** The routine wgetn_wstr(). +** +*/ + +#include + +MODULE_ID("$Id: lib_get_wstr.c,v 1.22 2024/07/27 19:22:23 tom Exp $") + +static int +wadd_wint(WINDOW *win, const wint_t *src) +{ + cchar_t tmp; + wchar_t wch[2]; + + wch[0] = (wchar_t) (*src); + wch[1] = 0; + setcchar(&tmp, wch, A_NORMAL, (short) 0, NULL); + return wadd_wch(win, &tmp); +} + +/* + * This wipes out the last character, no matter whether it was a tab, control + * or other character, and handles reverse wraparound. + */ +static wint_t * +WipeOut(WINDOW *win, int y, int x, const wint_t *first, wint_t *last, int echoed) +{ + if (last > first) { + *--last = '\0'; + if (echoed) { + int y1 = win->_cury; + int x1 = win->_curx; + int n; + + wmove(win, y, x); + for (n = 0; first[n] != 0; ++n) { + wadd_wint(win, first + n); + } + getyx(win, y, x); + while (win->_cury < y1 + || (win->_cury == y1 && win->_curx < x1)) + waddch(win, (chtype) ' '); + + wmove(win, y, x); + } + } + return last; +} + +NCURSES_EXPORT(int) +wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) +{ + SCREEN *sp = _nc_screen_of(win); + TTY buf; + TTY_FLAGS save_flags; + wchar_t erasec = 0; + wchar_t killc = 0; + wint_t *oldstr = str; + wint_t *tmpstr = str; + wint_t ch; + int y, x, code; + + T((T_CALLED("wgetn_wstr(%p,%p, %d)"), (void *) win, (void *) str, maxlen)); + + if (!win) + returnCode(ERR); + + maxlen = _nc_getstr_limit(maxlen); + + _nc_get_tty_mode(&buf); + + save_flags = sp->_tty_flags; + NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); + if (!save_flags._raw) + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); + + NCURSES_SP_NAME(erasewchar) (NCURSES_SP_ARGx &erasec); + NCURSES_SP_NAME(killwchar) (NCURSES_SP_ARGx &killc); + + getyx(win, y, x); + + if (is_wintouched(win) || (win->_flags & _HASMOVED)) + wrefresh(win); + + while ((code = wget_wch(win, &ch)) != ERR) { + /* + * Map special characters into key-codes. + */ + if (ch == '\r') + ch = '\n'; + if (ch == '\n') { + code = KEY_CODE_YES; + ch = KEY_ENTER; + } + if (ch != 0 && ch < KEY_MIN) { + if (ch == (wint_t) erasec) { + ch = KEY_BACKSPACE; + code = KEY_CODE_YES; + } + if (ch == (wint_t) killc) { + ch = KEY_EOL; + code = KEY_CODE_YES; + } + } + if (code == KEY_CODE_YES) { + /* + * Some terminals (the Wyse-50 is the most common) generate a \n + * from the down-arrow key. With this logic, it is the user's + * choice whether to set kcud=\n for wget_wch(); terminating + * *getn_wstr() with \n should work either way. + */ + if (ch == KEY_DOWN || ch == KEY_ENTER) { + if (save_flags._echo == TRUE + && win->_cury == win->_maxy + && win->_scroll) + wechochar(win, (chtype) '\n'); + break; + } + if (ch == KEY_LEFT || ch == KEY_BACKSPACE) { + if (tmpstr > oldstr) { + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo); + } + } else if (ch == KEY_EOL) { + while (tmpstr > oldstr) { + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo); + } + } else { + beep(); + } + } else if (tmpstr - oldstr >= maxlen) { + beep(); + } else { + *tmpstr++ = ch; + *tmpstr = 0; + if (save_flags._echo == TRUE) { + int oldy = win->_cury; + + if (wadd_wint(win, tmpstr - 1) == ERR) { + /* + * We can't really use the lower-right corner for input, + * since it'll mess up bookkeeping for erases. + */ + win->_flags &= ~_WRAPPED; + waddch(win, (chtype) ' '); + tmpstr = WipeOut(win, y, x, oldstr, tmpstr, save_flags._echo); + continue; + } else if (IS_WRAPPED(win)) { + /* + * If the last waddch forced a wrap & scroll, adjust our + * reference point for erasures. + */ + if (win->_scroll + && oldy == win->_maxy + && win->_cury == win->_maxy) { + if (--y <= 0) { + y = 0; + } + } + win->_flags &= ~_WRAPPED; + } + wrefresh(win); + } + } + } + + win->_curx = 0; + win->_flags &= ~_WRAPPED; + if (win->_cury < win->_maxy) + win->_cury++; + wrefresh(win); + + /* Restore with a single I/O call, to fix minor asymmetry between + * raw/noraw, etc. + */ + sp->_tty_flags = save_flags; + (void) _nc_set_tty_mode(&buf); + + *tmpstr = 0; + if (code == ERR) { + if (tmpstr == oldstr) { + *tmpstr++ = WEOF; + *tmpstr = 0; + } + returnCode(ERR); + } + + T(("wgetn_wstr returns %s", _nc_viswibuf(oldstr))); + + returnCode(OK); +} diff --git a/ncurses/ncurses/widechar/lib_hline_set.c b/ncurses/ncurses/widechar/lib_hline_set.c new file mode 100644 index 0000000000..b39e89fa18 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_hline_set.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2002-2010,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002 * + ****************************************************************************/ + +/* +** lib_hline_set.c +** +** The routine whline_set(). +** +*/ + +#include + +MODULE_ID("$Id: lib_hline_set.c,v 1.7 2024/12/07 20:08:15 tom Exp $") + +NCURSES_EXPORT(int) +whline_set(WINDOW *win, const cchar_t *ch, int n) +{ + int code = ERR; + + T((T_CALLED("whline_set(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n)); + + if (win) { + struct ldat *line = &(win->_line[win->_cury]); + NCURSES_CH_T wch; + int start = win->_curx; + int end = start + n - 1; + + if (end > win->_maxx) + end = win->_maxx; + + CHANGED_RANGE(line, start, end); + + if (ch == NULL) + wch = *WACS_HLINE; + else + wch = *ch; + wch = _nc_render(win, wch); + + while (end >= start) { + line->text[end] = wch; + end--; + } + + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/widechar/lib_in_wch.c b/ncurses/ncurses/widechar/lib_in_wch.c new file mode 100644 index 0000000000..6fb2c53ef4 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_in_wch.c @@ -0,0 +1,68 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2002-2009,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* +** lib_in_wch.c +** +** The routine win_wch(). +** +*/ + +#include + +MODULE_ID("$Id: lib_in_wch.c,v 1.8 2024/12/07 20:08:15 tom Exp $") + +NCURSES_EXPORT(int) +win_wch(WINDOW *win, cchar_t *wcval) +{ + int code = OK; + + TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), (void *) win, (void *) wcval)); + + if (win != NULL + && wcval != NULL) { + int row, col; + + getyx(win, row, col); + + *wcval = win->_line[row].text[col]; + TR(TRACE_CCALLS, ("data %s", _tracecchar_t(wcval))); + } else { + code = ERR; + } + TR(TRACE_CCALLS, (T_RETURN("%d"), code)); + return (code); +} diff --git a/ncurses/ncurses/widechar/lib_in_wchnstr.c b/ncurses/ncurses/widechar/lib_in_wchnstr.c new file mode 100644 index 0000000000..0657fe4ab5 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_in_wchnstr.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2002-2007,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* +** lib_in_wchnstr.c +** +** The routine win_wchnstr(). +** +*/ + +#include + +MODULE_ID("$Id: lib_in_wchnstr.c,v 1.11 2024/12/07 18:03:14 tom Exp $") + +NCURSES_EXPORT(int) +win_wchnstr(WINDOW *win, cchar_t *wchstr, int n) +{ + int code = OK; + + T((T_CALLED("win_wchnstr(%p,%p,%d)"), (void *) win, (void *) wchstr, n)); + if (win != NULL + && wchstr != NULL) { + const NCURSES_CH_T *src; + int row, col; + int j, k, limit; + + getyx(win, row, col); + limit = getmaxx(win) - col; + src = &(win->_line[row].text[col]); + + if (n < 0) { + n = limit; + } else if (n > limit) { + n = limit; + } + for (j = k = 0; j < n; ++j) { + if (j == 0 || !WidecExt(src[j]) || isWidecBase(src[j])) { + wchstr[k++] = src[j]; + } + } + memset(&(wchstr[k]), 0, sizeof(*wchstr)); + T(("result = %s", _nc_viscbuf(wchstr, n))); + } else { + code = ERR; + } + returnCode(code); +} diff --git a/ncurses/ncurses/widechar/lib_ins_wch.c b/ncurses/ncurses/widechar/lib_ins_wch.c new file mode 100644 index 0000000000..d45f09dab5 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_ins_wch.c @@ -0,0 +1,173 @@ +/**************************************************************************** + * Copyright 2019-2024,2025 Thomas E. Dickey * + * Copyright 2002-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002 * + ****************************************************************************/ + +/* +** lib_ins_wch.c +** +** The routine wins_wch(). +** +*/ + +#include + +MODULE_ID("$Id: lib_ins_wch.c,v 1.34 2025/06/21 22:26:21 tom Exp $") + +/* + * Insert the given character, updating the current location to simplify + * inserting a string. + */ +NCURSES_EXPORT(int) +_nc_insert_wch(WINDOW *win, const cchar_t *wch) +{ + int cells = _nc_wacs_width(CharOf(CHDEREF(wch))); + int code = OK; + + if (cells < 0) { + code = winsch(win, (chtype) CharOf(CHDEREF(wch))); + } else { + if (cells == 0) + cells = 1; + + if (win->_curx <= win->_maxx) { + int cell; + struct ldat *line = &(win->_line[win->_cury]); + NCURSES_CH_T *end = &(line->text[win->_curx]); + NCURSES_CH_T *temp1 = &(line->text[win->_maxx]); + const NCURSES_CH_T *temp2 = temp1 - cells; + + CHANGED_TO_EOL(line, win->_curx, win->_maxx); + while (temp1 > end) + *temp1-- = *temp2--; + + *temp1 = _nc_render(win, *wch); + for (cell = 1; cell < cells; ++cell) { + SetWidecExt(temp1[cell], cell); + } + + win->_curx = (NCURSES_SIZE_T) (win->_curx + cells); + } + } + return code; +} + +NCURSES_EXPORT(int) +wins_wch(WINDOW *win, const cchar_t *wch) +{ + int code = ERR; + + T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch))); + + if (win != NULL) { + NCURSES_SIZE_T oy = win->_cury; + NCURSES_SIZE_T ox = win->_curx; + + code = _nc_insert_wch(win, wch); + + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + } + returnCode(code); +} + +static int +flush_wchars(WINDOW *win, wchar_t *wchars) +{ + cchar_t tmp_cchar; + (void) setcchar(&tmp_cchar, wchars, WA_NORMAL, (short) 0, (void *) 0); + return _nc_insert_wch(win, &tmp_cchar); +} + +NCURSES_EXPORT(int) +wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) +{ + int code = ERR; + + T((T_CALLED("wins_nwstr(%p,%s,%d)"), + (void *) win, _nc_viswbufn(wstr, n), n)); + + if (win != NULL + && wstr != NULL) { + + if (n < 0) { + n = INT_MAX; + } + code = OK; + + if (n > 0) { + const wchar_t *cp; + SCREEN *sp = _nc_screen_of(win); + NCURSES_SIZE_T oy = win->_cury; + NCURSES_SIZE_T ox = win->_curx; + wchar_t tmp_wchars[1 + CCHARW_MAX]; + int num_wchars = 0; + + for (cp = wstr; ((cp - wstr) < n) && (*cp != L'\0'); cp++) { + int len = _nc_wacs_width(*cp); + + if (is7bits(*cp) && len <= 0) { + if (num_wchars) { + if ((code = flush_wchars(win, tmp_wchars)) != OK) + break; + num_wchars = 0; + } + /* tabs, other ASCII stuff */ + code = _nc_insert_ch(sp, win, (chtype) (*cp)); + } else { + if (num_wchars > 0 && len > 0) { + if ((code = flush_wchars(win, tmp_wchars)) != OK) + break; + num_wchars = 0; + } + if (num_wchars < CCHARW_MAX) { + tmp_wchars[num_wchars++] = *cp; + tmp_wchars[num_wchars] = L'\0'; + } + } + if (code != OK) + break; + } + if (code == OK && num_wchars) { + code = flush_wchars(win, tmp_wchars); + } + + win->_curx = ox; + win->_cury = oy; + _nc_synchook(win); + } + } + returnCode(code); +} diff --git a/ncurses/ncurses/widechar/lib_inwstr.c b/ncurses/ncurses/widechar/lib_inwstr.c new file mode 100644 index 0000000000..5b8cc4589d --- /dev/null +++ b/ncurses/ncurses/widechar/lib_inwstr.c @@ -0,0 +1,100 @@ +/**************************************************************************** + * Copyright 2020-2024,2025 Thomas E. Dickey * + * Copyright 2002-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* +** lib_inwstr.c +** +** The routine winnwstr(). +** +*/ + +#include + +MODULE_ID("$Id: lib_inwstr.c,v 1.14 2025/01/19 00:51:54 tom Exp $") + +NCURSES_EXPORT(int) +winnwstr(WINDOW *win, wchar_t *wstr, int n) +{ + int count = 0; + const cchar_t *text; + + T((T_CALLED("winnwstr(%p,%p,%d)"), (void *) win, (void *) wstr, n)); + if (wstr != NULL) { + if (win) { + int row, col; + int last = 0; + bool done = FALSE; + + getyx(win, row, col); + + if (n < 0) + n = CCHARW_MAX * (win->_maxx - win->_curx + 1); + + text = win->_line[row].text; + while (count < n && !done && count != ERR) { + + if (!isWidecExt(text[col])) { + int inx; + wchar_t wch; + + for (inx = 0; (inx < CCHARW_MAX) + && ((wch = text[col].chars[inx]) != 0); + ++inx) { + if (count + 1 > n) { + done = TRUE; + if (last == 0) { + count = ERR; /* error if we store nothing */ + } else { + count = last; /* only store complete chars */ + } + break; + } + wstr[count++] = wch; + } + } + last = count; + if (++col > win->_maxx) { + break; + } + } + } + if (count > 0) { + wstr[count] = '\0'; + T(("winnwstr returns %s", _nc_viswbuf(wstr))); + } + } + returnCode(count); +} diff --git a/ncurses/ncurses/widechar/lib_key_name.c b/ncurses/ncurses/widechar/lib_key_name.c new file mode 100644 index 0000000000..2a8bac0a90 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_key_name.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 2007-2008,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* +** lib_key_name.c +** +** The routine key_name(). +** +*/ + +#include + +MODULE_ID("$Id: lib_key_name.c,v 1.7 2024/07/27 19:23:59 tom Exp $") + +#define MyData _nc_globals.key_name + +NCURSES_EXPORT(NCURSES_CONST char *) +key_name(wchar_t c) +{ + cchar_t my_cchar; + const wchar_t *my_wchars; + size_t len; + NCURSES_CONST char *result = NULL; + + memset(&my_cchar, 0, sizeof(my_cchar)); + my_cchar.chars[0] = c; + my_cchar.chars[1] = L'\0'; + + my_wchars = wunctrl(&my_cchar); + /* + * wunctrl() could return a wide character rather than just a "printable" + * representation. Check for that and return a corresponding multibyte + * character string. + */ + len = wcstombs(MyData, my_wchars, sizeof(MyData) - 1); + if (!isEILSEQ(len) && (len != 0) && (len <= MB_LEN_MAX)) { + MyData[len] = '\0'; + result = MyData; + } + return result; +} diff --git a/ncurses/ncurses/widechar/lib_pecho_wchar.c b/ncurses/ncurses/widechar/lib_pecho_wchar.c new file mode 100644 index 0000000000..6797de83c0 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_pecho_wchar.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * Copyright 2020-2021,2024 Thomas E. Dickey * + * Copyright 2004,2009 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +MODULE_ID("$Id: lib_pecho_wchar.c,v 1.5 2024/12/07 20:08:15 tom Exp $") + +NCURSES_EXPORT(int) +pecho_wchar(WINDOW *pad, const cchar_t *wch) +{ + T((T_CALLED("pecho_wchar(%p, %s)"), (void *) pad, _tracech_t(wch))); + + if (pad == NULL) + returnCode(ERR); + + if (!IS_PAD(pad)) + returnCode(wecho_wchar(pad, wch)); + + wadd_wch(pad, wch); + prefresh(pad, pad->_pad._pad_y, + pad->_pad._pad_x, + pad->_pad._pad_top, + pad->_pad._pad_left, + pad->_pad._pad_bottom, + pad->_pad._pad_right); + + returnCode(OK); +} diff --git a/ncurses/ncurses/widechar/lib_slk_wset.c b/ncurses/ncurses/widechar/lib_slk_wset.c new file mode 100644 index 0000000000..cedd014b2b --- /dev/null +++ b/ncurses/ncurses/widechar/lib_slk_wset.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2003-2011,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + ****************************************************************************/ + +/* + * lib_slk_wset.c + * Set soft label text. + */ +#include + +#if HAVE_WCTYPE_H +#include +#endif + +MODULE_ID("$Id: lib_slk_wset.c,v 1.16 2024/12/07 20:08:15 tom Exp $") + +NCURSES_EXPORT(int) +slk_wset(int i, const wchar_t *astr, int format) +{ + int result = ERR; + const wchar_t *str; + mbstate_t state; + + T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format)); + + if (astr != NULL) { + size_t arglen; + + init_mb(state); + str = astr; + + if ((arglen = wcsrtombs(NULL, &str, (size_t) 0, &state)) != (size_t) -1) { + char *mystr; + + if ((mystr = (char *) _nc_doalloc(NULL, arglen + 1)) != NULL) { + str = astr; + if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) { + /* glibc documentation claims that the terminating L'\0' + * is written, but it is not... + */ + mystr[arglen] = 0; + result = slk_set(i, mystr, format); + } + free(mystr); + } + } + } + returnCode(result); +} diff --git a/ncurses/ncurses/widechar/lib_unget_wch.c b/ncurses/ncurses/widechar/lib_unget_wch.c new file mode 100644 index 0000000000..b189217cc1 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_unget_wch.c @@ -0,0 +1,118 @@ +/**************************************************************************** + * Copyright 2020-2023,2024 Thomas E. Dickey * + * Copyright 2002-2011,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002 * + ****************************************************************************/ + +/* +** lib_unget_wch.c +** +** The routine unget_wch(). +** +*/ + +#include + +MODULE_ID("$Id: lib_unget_wch.c,v 1.19 2024/12/07 20:08:15 tom Exp $") + +/* + * Wrapper for wcrtomb() which obtains the length needed for the given + * wide-character 'source'. + */ +NCURSES_EXPORT(size_t) +_nc_wcrtomb(char *target, wchar_t source, mbstate_t * state) +{ + int result; + + if (target == NULL) { + wchar_t temp[2]; + const wchar_t *tempp = temp; + temp[0] = source; + temp[1] = 0; + result = (int) wcsrtombs(NULL, &tempp, (size_t) 0, state); + } else { + result = (int) wcrtomb(target, source, state); + } + if (!isEILSEQ(result) && ((result == 0) || (result > MB_LEN_MAX))) + result = 1; + return (size_t) result; +} + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(unget_wch) (NCURSES_SP_DCLx const wchar_t wch) +{ + int result = OK; + mbstate_t state; + size_t length; + + T((T_CALLED("unget_wch(%p, %#lx)"), (void *) SP_PARM, (unsigned long) wch)); + + init_mb(state); + length = _nc_wcrtomb(NULL, wch, &state); + + if (length != (size_t) (-1) + && length != 0) { + char *string; + + if ((string = (char *) malloc(length)) != NULL) { + int n; + + init_mb(state); + /* ignore the result, since we already validated the character */ + IGNORE_RC((int) wcrtomb(string, wch, &state)); + + for (n = (int) (length - 1); n >= 0; --n) { + if (NCURSES_SP_NAME(ungetch) (NCURSES_SP_ARGx + UChar(string[n])) !=OK) { + result = ERR; + break; + } + } + free(string); + } else { + result = ERR; + } + } else { + result = ERR; + } + + returnCode(result); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +unget_wch(const wchar_t wch) +{ + return NCURSES_SP_NAME(unget_wch) (CURRENT_SCREEN, wch); +} +#endif diff --git a/ncurses/ncurses/widechar/lib_vid_attr.c b/ncurses/ncurses/widechar/lib_vid_attr.c new file mode 100644 index 0000000000..a1bb25e07d --- /dev/null +++ b/ncurses/ncurses/widechar/lib_vid_attr.c @@ -0,0 +1,372 @@ +/**************************************************************************** + * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 2002-2014,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_vid_attr.c,v 1.32 2024/12/07 20:08:59 tom Exp $") + +#define doPut(mode) \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc) + +#define TurnOn(mask, mode) \ + if ((turn_on & mask) && mode) { \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \ + } + +#define TurnOff(mask, mode) \ + if ((turn_off & mask) && mode) { \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc); \ + turn_off &= ~mask; \ + } + + /* if there is no current screen, assume we *can* do color */ +#define SetColorsIf(why, old_attr, old_pair) \ + if (can_color && (why)) { \ + TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, color_pair)); \ + if ((color_pair != old_pair) \ + || (fix_pair0 && (color_pair == 0)) \ + || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \ + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \ + old_pair, color_pair, \ + reverse, outc); \ + } \ + } + +#define set_color(mode, pair) \ + mode &= ALL_BUT_COLOR; \ + mode |= (attr_t) ColorPair(pair) + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx + attr_t newmode, + NCURSES_PAIRS_T pair_arg, + void *opts OPTIONAL_PAIR, + NCURSES_SP_OUTC outc) +{ + int color_pair = pair_arg; +#if NCURSES_EXT_COLORS + static attr_t previous_attr = A_NORMAL; + static int previous_pair = 0; + + attr_t turn_on, turn_off; + bool reverse = FALSE; + bool can_color = (SP_PARM == NULL || SP_PARM->_coloron); +#if NCURSES_EXT_FUNCS + bool fix_pair0 = (SP_PARM != NULL && SP_PARM->_coloron && !SP_PARM->_default_color); +#else +#define fix_pair0 FALSE +#endif + + if (!IsValidTIScreen(SP_PARM)) + returnCode(ERR); + + newmode &= A_ATTRIBUTES; + set_extended_pair(opts, color_pair); + T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), color_pair)); + + /* this allows us to go on whether or not newterm() has been called */ + if (SP_PARM) { + previous_attr = AttrOf(SCREEN_ATTRS(SP_PARM)); + previous_pair = GetPair(SCREEN_ATTRS(SP_PARM)); + } + + TR(TRACE_ATTRS, ("previous attribute was %s, %d", + _traceattr(previous_attr), previous_pair)); + +#if !USE_XMC_SUPPORT + if ((SP_PARM != 0) + && (magic_cookie_glitch > 0)) + newmode &= ~(SP_PARM->_xmc_suppress); +#endif + + /* + * If we have a terminal that cannot combine color with video + * attributes, use the colors in preference. + */ + if ((color_pair != 0 + || fix_pair0) + && (no_color_video > 0)) { + /* + * If we had chosen the A_xxx definitions to correspond to the + * no_color_video mask, we could simply shift it up and mask off the + * attributes. But we did not (actually copied Solaris' definitions). + * However, this is still simpler/faster than a lookup table. + * + * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK, + * A_DIM, A_BOLD which are 1:1 with no_color_video. The bits that + * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and + * A_ALTCHARSET (256) down 2 to line up. We use the NCURSES_BITS + * macro so this will work properly for the wide-character layout. + */ + unsigned value = (unsigned) no_color_video; + attr_t mask = NCURSES_BITS((value & 63) + | ((value & 192) << 1) + | ((value & 256) >> 2), 8); + + if ((mask & A_REVERSE) != 0 + && (newmode & A_REVERSE) != 0) { + reverse = TRUE; + mask &= ~A_REVERSE; + } + newmode &= ~mask; + } + + if (newmode == previous_attr + && color_pair == previous_pair) + returnCode(OK); + + if (reverse) { + newmode &= ~A_REVERSE; + } + + turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR; + turn_on = (newmode & ~(previous_attr & TPARM_ATTR)) & ALL_BUT_COLOR; + + SetColorsIf(((color_pair == 0) && !fix_pair0), previous_attr, previous_pair); + + if (newmode == A_NORMAL) { + if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) { + doPut(exit_alt_charset_mode); + previous_attr &= ~A_ALTCHARSET; + } + if (previous_attr) { + if (exit_attribute_mode) { + doPut(exit_attribute_mode); + } else { + if (!SP_PARM || SP_PARM->_use_rmul) { + TurnOff(A_UNDERLINE, exit_underline_mode); + } + if (!SP_PARM || SP_PARM->_use_rmso) { + TurnOff(A_STANDOUT, exit_standout_mode); + } +#if USE_ITALIC + if (!SP_PARM || SP_PARM->_use_ritm) { + TurnOff(A_ITALIC, exit_italics_mode); + } +#endif + (void) turn_off; + } + previous_attr &= ALL_BUT_COLOR; + previous_pair = 0; + } + + SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair); + } else if (set_attributes) { + if (turn_on || turn_off) { + TPUTS_TRACE("set_attributes"); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TIPARM_9(set_attributes, + (newmode & A_STANDOUT) != 0, + (newmode & A_UNDERLINE) != 0, + (newmode & A_REVERSE) != 0, + (newmode & A_BLINK) != 0, + (newmode & A_DIM) != 0, + (newmode & A_BOLD) != 0, + (newmode & A_INVIS) != 0, + (newmode & A_PROTECT) != 0, + (newmode & A_ALTCHARSET) != 0), + 1, outc); + previous_attr &= ALL_BUT_COLOR; + previous_pair = 0; + } +#if USE_ITALIC + if (!SP_PARM || SP_PARM->_use_ritm) { + if (turn_on & A_ITALIC) { + TurnOn(A_ITALIC, enter_italics_mode); + } else if (turn_off & A_ITALIC) { + TurnOff(A_ITALIC, exit_italics_mode); + } + (void) turn_off; + } +#endif + SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair); + } else { + + TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off))); + + TurnOff(A_ALTCHARSET, exit_alt_charset_mode); + + if (!SP_PARM || SP_PARM->_use_rmul) { + TurnOff(A_UNDERLINE, exit_underline_mode); + } + + if (!SP_PARM || SP_PARM->_use_rmso) { + TurnOff(A_STANDOUT, exit_standout_mode); + } +#if USE_ITALIC + if (!SP_PARM || SP_PARM->_use_ritm) { + TurnOff(A_ITALIC, exit_italics_mode); + } +#endif + if (turn_off && exit_attribute_mode) { + doPut(exit_attribute_mode); + turn_on |= (newmode & ALL_BUT_COLOR); + previous_attr &= ALL_BUT_COLOR; + previous_pair = 0; + } + SetColorsIf((color_pair != 0) || fix_pair0, previous_attr, previous_pair); + + TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on))); + /* *INDENT-OFF* */ + TurnOn(A_ALTCHARSET, enter_alt_charset_mode); + TurnOn(A_BLINK, enter_blink_mode); + TurnOn(A_BOLD, enter_bold_mode); + TurnOn(A_DIM, enter_dim_mode); + TurnOn(A_REVERSE, enter_reverse_mode); + TurnOn(A_STANDOUT, enter_standout_mode); + TurnOn(A_PROTECT, enter_protected_mode); + TurnOn(A_INVIS, enter_secure_mode); + TurnOn(A_UNDERLINE, enter_underline_mode); +#if USE_ITALIC + TurnOn(A_ITALIC, enter_italics_mode); +#endif +#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode) + 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* */ + } + + if (reverse) + newmode |= A_REVERSE; + + if (SP_PARM) { + SetAttr(SCREEN_ATTRS(SP_PARM), newmode); + SetPair(SCREEN_ATTRS(SP_PARM), color_pair); + } else { + previous_attr = newmode; + previous_pair = color_pair; + } + + returnCode(OK); +#else + T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), color_pair)); + (void) opts; + set_color(newmode, color_pair); + returnCode(NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx newmode, outc)); +#endif +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +vid_puts(attr_t newmode, + NCURSES_PAIRS_T pair_arg, + void *opts GCC_UNUSED, + NCURSES_OUTC outc) +{ + SetSafeOutcWrapper(outc); + return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN, + newmode, + pair_arg, + opts, + _nc_outc_wrapper); +} +#endif + +#undef vid_attr +NCURSES_EXPORT(int) +NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx + attr_t newmode, + NCURSES_PAIRS_T pair_arg, + void *opts) +{ + T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), (int) pair_arg)); + returnCode(NCURSES_SP_NAME(vid_puts) (NCURSES_SP_ARGx + newmode, + pair_arg, + opts, + NCURSES_SP_NAME(_nc_putchar))); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +vid_attr(attr_t newmode, NCURSES_PAIRS_T pair_arg, void *opts) +{ + return NCURSES_SP_NAME(vid_attr) (CURRENT_SCREEN, newmode, pair_arg, opts); +} +#endif + +/* + * This implementation uses the same mask values for A_xxx and WA_xxx, so + * we can use termattrs() for part of the logic. + */ +NCURSES_EXPORT(attr_t) +NCURSES_SP_NAME(term_attrs) (NCURSES_SP_DCL0) +{ + attr_t attrs = 0; + + T((T_CALLED("term_attrs()"))); + if (SP_PARM) { + attrs = NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG); + +#if USE_WIDEC_SUPPORT && defined(enter_horizontal_hl_mode) + /* these are only supported for wide-character mode */ + if (enter_horizontal_hl_mode) + attrs |= WA_HORIZONTAL; + if (enter_left_hl_mode) + attrs |= WA_LEFT; + if (enter_low_hl_mode) + attrs |= WA_LOW; + if (enter_right_hl_mode) + attrs |= WA_RIGHT; + if (enter_top_hl_mode) + attrs |= WA_TOP; + if (enter_vertical_hl_mode) + attrs |= WA_VERTICAL; +#endif + } + + returnAttr(attrs); +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(attr_t) +term_attrs(void) +{ + return NCURSES_SP_NAME(term_attrs) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/ncurses/widechar/lib_vline_set.c b/ncurses/ncurses/widechar/lib_vline_set.c new file mode 100644 index 0000000000..fde5892b95 --- /dev/null +++ b/ncurses/ncurses/widechar/lib_vline_set.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2002-2010,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002 * + ****************************************************************************/ + +/* +** lib_vline_set.c +** +** The routine wvline_set(). +** +*/ + +#include + +MODULE_ID("$Id: lib_vline_set.c,v 1.7 2024/12/07 20:08:15 tom Exp $") + +NCURSES_EXPORT(int) +wvline_set(WINDOW *win, const cchar_t *ch, int n) +{ + int code = ERR; + + T((T_CALLED("wvline(%p,%s,%d)"), (void *) win, _tracecchar_t(ch), n)); + + if (win) { + NCURSES_CH_T wch; + int row = win->_cury; + int col = win->_curx; + int end = row + n - 1; + + if (end > win->_maxy) + end = win->_maxy; + + if (ch == NULL) + wch = *WACS_VLINE; + else + wch = *ch; + wch = _nc_render(win, wch); + + while (end >= row) { + struct ldat *line = &(win->_line[end]); + line->text[col] = wch; + CHANGED_CELL(line, col); + end--; + } + + _nc_synchook(win); + code = OK; + } + returnCode(code); +} diff --git a/ncurses/ncurses/widechar/lib_wacs.c b/ncurses/ncurses/widechar/lib_wacs.c new file mode 100644 index 0000000000..2c80b485ba --- /dev/null +++ b/ncurses/ncurses/widechar/lib_wacs.c @@ -0,0 +1,151 @@ +/**************************************************************************** + * Copyright 2018-2020,2024 Thomas E. Dickey * + * Copyright 2002-2015,2016 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 2002 * + ****************************************************************************/ + +#include + +MODULE_ID("$Id: lib_wacs.c,v 1.21 2024/12/07 20:08:32 tom Exp $") + +NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = NULL; + +NCURSES_EXPORT(void) +_nc_init_wacs(void) +{ + /* *INDENT-OFF* */ + static const struct { + unsigned map; + int value[2]; + } table[] = { + /* VT100 symbols */ + { 'l', { '+', 0x250c }}, /* upper left corner */ + { 'm', { '+', 0x2514 }}, /* lower left corner */ + { 'k', { '+', 0x2510 }}, /* upper right corner */ + { 'j', { '+', 0x2518 }}, /* lower right corner */ + { 't', { '+', 0x251c }}, /* tee pointing left */ + { 'u', { '+', 0x2524 }}, /* tee pointing right */ + { 'v', { '+', 0x2534 }}, /* tee pointing up */ + { 'w', { '+', 0x252c }}, /* tee pointing down */ + { 'q', { '-', 0x2500 }}, /* horizontal line */ + { 'x', { '|', 0x2502 }}, /* vertical line */ + { 'n', { '+', 0x253c }}, /* large plus or crossover */ + { 'o', { '~', 0x23ba }}, /* scan line 1 */ + { 's', { '_', 0x23bd }}, /* scan line 9 */ + { '`', { '+', 0x25c6 }}, /* diamond */ + { 'a', { ':', 0x2592 }}, /* checker board (stipple) */ + { 'f', { '\'', 0x00b0 }}, /* degree symbol */ + { 'g', { '#', 0x00b1 }}, /* plus/minus */ + { '~', { 'o', 0x00b7 }}, /* bullet */ + /* Teletype 5410v1 symbols */ + { ',', { '<', 0x2190 }}, /* arrow pointing left */ + { '+', { '>', 0x2192 }}, /* arrow pointing right */ + { '.', { 'v', 0x2193 }}, /* arrow pointing down */ + { '-', { '^', 0x2191 }}, /* arrow pointing up */ + { 'h', { '#', 0x2592 }}, /* board of squares */ + { 'i', { '#', 0x2603 }}, /* lantern symbol */ + { '0', { '#', 0x25ae }}, /* solid square block */ + /* these defaults were invented for ncurses */ + { 'p', { '-', 0x23bb }}, /* scan line 3 */ + { 'r', { '-', 0x23bc }}, /* scan line 7 */ + { 'y', { '<', 0x2264 }}, /* less-than-or-equal-to */ + { 'z', { '>', 0x2265 }}, /* greater-than-or-equal-to */ + { '{', { '*', 0x03c0 }}, /* greek pi */ + { '|', { '!', 0x2260 }}, /* not-equal */ + { '}', { 'f', 0x00a3 }}, /* pound-sterling symbol */ + /* thick-line-drawing */ + { 'L', { '+', 0x250f }}, /* upper left corner */ + { 'M', { '+', 0x2517 }}, /* lower left corner */ + { 'K', { '+', 0x2513 }}, /* upper right corner */ + { 'J', { '+', 0x251b }}, /* lower right corner */ + { 'T', { '+', 0x2523 }}, /* tee pointing left */ + { 'U', { '+', 0x252b }}, /* tee pointing right */ + { 'V', { '+', 0x253b }}, /* tee pointing up */ + { 'W', { '+', 0x2533 }}, /* tee pointing down */ + { 'Q', { '-', 0x2501 }}, /* horizontal line */ + { 'X', { '|', 0x2503 }}, /* vertical line */ + { 'N', { '+', 0x254b }}, /* large plus or crossover */ + /* double-line-drawing */ + { 'C', { '+', 0x2554 }}, /* upper left corner */ + { 'D', { '+', 0x255a }}, /* lower left corner */ + { 'B', { '+', 0x2557 }}, /* upper right corner */ + { 'A', { '+', 0x255d }}, /* lower right corner */ + { 'G', { '+', 0x2563 }}, /* tee pointing left */ + { 'F', { '+', 0x2560 }}, /* tee pointing right */ + { 'H', { '+', 0x2569 }}, /* tee pointing up */ + { 'I', { '+', 0x2566 }}, /* tee pointing down */ + { 'R', { '-', 0x2550 }}, /* horizontal line */ + { 'Y', { '|', 0x2551 }}, /* vertical line */ + { 'E', { '+', 0x256c }}, /* large plus or crossover */ + }; + /* *INDENT-ON* */ + + int active = _nc_unicode_locale(); + + /* + * If we're running in a UTF-8 locale, will use the Unicode equivalents + * rather than the terminfo information. Actually the terminfo should + * be the rule, but there are people who are offended by the notion that + * a Unicode-capable terminal would have something resembling a mode. + * So the smacs/rmacs may be disabled -- sometime. + */ + T(("initializing WIDE-ACS map (Unicode is%s active)", + active ? "" : " not")); + + if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != NULL) { + unsigned n; + + for (n = 0; n < SIZEOF(table); ++n) { + unsigned m; +#if NCURSES_WCWIDTH_GRAPHICS + int wide = wcwidth((wchar_t) table[n].value[active]); +#else + int wide = 1; +#endif + + m = table[n].map; + if (active && (wide == 1)) { + SetChar(_nc_wacs[m], table[n].value[1], A_NORMAL); + } else if (acs_map[m] & A_ALTCHARSET) { + SetChar(_nc_wacs[m], m, A_ALTCHARSET); + } else { + SetChar(_nc_wacs[m], table[n].value[0], A_NORMAL); + } + + T(("#%d, width:%d SetChar(%c, %s) = %s", + n, wide, m, + _tracechar(table[n].value[active]), + _tracecchar_t(&_nc_wacs[m]))); + } + } +} diff --git a/ncurses/ncurses/widechar/lib_wunctrl.c b/ncurses/ncurses/widechar/lib_wunctrl.c new file mode 100644 index 0000000000..ca3867bd6e --- /dev/null +++ b/ncurses/ncurses/widechar/lib_wunctrl.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2001-2011,2012 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +/* +** lib_wunctrl.c +** +** The routine wunctrl(). +** +*/ + +#include + +MODULE_ID("$Id: lib_wunctrl.c,v 1.19 2024/12/07 18:03:14 tom Exp $") + +NCURSES_EXPORT(wchar_t *) +NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc) +{ + static wchar_t str[CCHARW_MAX + 1]; + wchar_t *result; + + if (wc == NULL) { + result = NULL; + } else if (SP_PARM != NULL && Charable(*wc)) { + wchar_t *wsp; + const char *p = + NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx + (unsigned) _nc_to_char((wint_t)CharOf(*wc))); + + for (wsp = str; *p; ++p) { + *wsp++ = (wchar_t) _nc_to_widechar(*p); + } + *wsp = 0; + result = str; + } else { + result = wc->chars; + } + return result; +} + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(wchar_t *) +wunctrl(cchar_t *wc) +{ + return NCURSES_SP_NAME(wunctrl) (CURRENT_SCREEN, wc); +} +#endif diff --git a/ncurses/ncurses/widechar/widechars.c b/ncurses/ncurses/widechar/widechars.c new file mode 100644 index 0000000000..277a1e7dd0 --- /dev/null +++ b/ncurses/ncurses/widechar/widechars.c @@ -0,0 +1,156 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2012,2013 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +#include + +#if USE_WIDEC_SUPPORT + +MODULE_ID("$Id: widechars.c,v 1.11 2025/02/20 01:02:09 tom Exp $") + +#if defined(_NC_MINGW) +/* + * MinGW has wide-character functions, but they do not work correctly. + */ + +int +_nc_mbtowc(wchar_t *pwc, const char *s, size_t n) +{ + int result; + int count; + int try; + + if (s != NULL && n != 0) { + /* + * MultiByteToWideChar() can decide to return more than one + * wide-character. We want only one. Ignore any trailing null, both + * in the initial count and in the conversion. + */ + count = 0; + for (try = 1; try <= (int) n; ++try) { + count = MultiByteToWideChar(CP_UTF8, + MB_ERR_INVALID_CHARS, + s, + try, + pwc, + 0); + TR(TRACE_BITS, ("...try %d:%d", try, count)); + if (count > 0) { + break; + } + } + if (count < 1 || count > 2) { + result = -1; + } else { + wchar_t actual[2]; + memset(&actual, 0, sizeof(actual)); + count = MultiByteToWideChar(CP_UTF8, + MB_ERR_INVALID_CHARS, + s, + try, + actual, + 2); + TR(TRACE_BITS, ("\twin32 ->%#x, %#x", actual[0], actual[1])); + *pwc = actual[0]; + if (actual[1] != 0) + result = -1; + else + result = try; + } + } else { + result = 0; + } + + return result; +} + +int +_nc_mblen(const char *s, size_t n) +{ + int result = -1; + int count; + wchar_t temp; + + if (s != NULL && n != 0) { + count = _nc_mbtowc(&temp, s, n); + if (count == 1) { + int check = WideCharToMultiByte(CP_UTF8, + 0, + &temp, + 1, + NULL, + 0, /* compute length only */ + NULL, + NULL); + TR(TRACE_BITS, ("\tcheck ->%d\n", check)); + if (check > 0 && (size_t) check <= n) { + result = check; + } + } + } else { + result = 0; + } + + return result; +} + +int __MINGW_NOTHROW +_nc_wctomb(char *s, wchar_t wc) +{ + int result; + int check; + + check = WideCharToMultiByte(CP_UTF8, + 0, + &wc, + 1, + NULL, + 0, /* compute length only */ + NULL, + NULL); + if (check > 0) { + result = WideCharToMultiByte(CP_UTF8, + 0, + &wc, + 1, + s, + check + 1, + NULL, + NULL); + } else { + result = -1; + } + return result; +} + +#endif /* _NC_MINGW */ + +#endif /* USE_WIDEC_SUPPORT */ diff --git a/ncurses/ncurses/win32con/gettimeofday.c b/ncurses/ncurses/win32con/gettimeofday.c new file mode 100644 index 0000000000..5a682c403d --- /dev/null +++ b/ncurses/ncurses/win32con/gettimeofday.c @@ -0,0 +1,55 @@ +/**************************************************************************** + * Copyright 2020-2023,2025 Thomas E. Dickey * + * Copyright 2008-2010,2014 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ + +#include + +#include + +MODULE_ID("$Id: gettimeofday.c,v 1.8 2025/08/30 17:59:42 tom Exp $") + +#if HAVE_GETTIMEOFDAY == 2 +#define JAN1970 116444736000000000LL /* the value for 01/01/1970 00:00 */ + +NCURSES_EXPORT(int) +gettimeofday(struct timeval *tv, void *tz GCC_UNUSED) +{ + union { + FILETIME ft; + long long since1601; /* time since 1 Jan 1601 in 100ns units */ + } data; + + GetSystemTimeAsFileTime(&data.ft); + tv->tv_usec = (long) ((data.since1601 / 10LL) % 1000000LL); + tv->tv_sec = (long) ((data.since1601 - JAN1970) / 10000000LL); + return (0); +} +#endif // HAVE_GETTIMEOFDAY == 2 diff --git a/ncurses/ncurses/win32con/wcwidth.c b/ncurses/ncurses/win32con/wcwidth.c new file mode 100644 index 0000000000..a7d99bcea2 --- /dev/null +++ b/ncurses/ncurses/win32con/wcwidth.c @@ -0,0 +1,55 @@ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 2010 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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. * + ****************************************************************************/ +#include + +MODULE_ID("$Id: wcwidth.c,v 1.5 2024/05/04 18:31:39 tom Exp $") + +#if USE_WIDEC_SUPPORT +#define mk_wcwidth(ucs) _nc_wcwidth(ucs) +#define mk_wcswidth(pwcs, n) _nc_wcswidth(pwcs, n) +#define mk_wcwidth_cjk(ucs) _nc_wcwidth_cjk(ucs) +#define mk_wcswidth_cjk(pwcs, n) _nc_wcswidth_cjk(pwcs, n) + +NCURSES_EXPORT(void) mk_wcwidth_init(int); +NCURSES_EXPORT(int) mk_wcwidth(uint32_t); +NCURSES_EXPORT(int) mk_wcswidth(const uint32_t *, size_t); +NCURSES_EXPORT(int) mk_wcwidth_cjk(uint32_t); +NCURSES_EXPORT(int) mk_wcswidth_cjk(const uint32_t *, size_t); + +#include +#else +void _nc_empty_wcwidth(void); +void +_nc_empty_wcwidth(void) +{ +} +#endif diff --git a/ncurses/ncurses/win32con/win32_driver.c b/ncurses/ncurses/win32con/win32_driver.c new file mode 100644 index 0000000000..107dde49c6 --- /dev/null +++ b/ncurses/ncurses/win32con/win32_driver.c @@ -0,0 +1,1217 @@ +/**************************************************************************** + * Copyright 2018-2024,2025 Thomas E. Dickey * + * Copyright 2008-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 * + * and: Thomas E. Dickey * + ****************************************************************************/ + +/* + * TODO - improve screen-repainting performance, using implied wraparound to reduce write's + * TODO - make it optional whether screen is restored or not when non-buffered + */ + +#include + +#define CUR TerminalType(my_term). + +MODULE_ID("$Id: win32_driver.c,v 1.20 2025/12/30 19:34:50 tom Exp $") + +#define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE) +#define EXP_OPTIMIZE 0 + +#define AssertTCB() assert(TCB != NULL && (TCB->magic == WINMAGIC)) +#define validateConsoleHandle() (AssertTCB(), console_initialized || \ + (console_initialized = \ + _nc_console_checkinit(USE_NAMED_PIPES))) +#define SetSP() assert(TCB->csp != NULL); sp = TCB->csp; (void) sp + +#define AdjustY() (WINCONSOLE.buffered \ + ? 0 \ + : (int) WINCONSOLE.SBI.srWindow.Top) + +#define RevAttr(attr) (WORD) (((attr) & 0xff00) | \ + ((((attr) & 0x07) << 4) | \ + (((attr) & 0x70) >> 4))) + +static bool console_initialized = FALSE; + +static WORD +MapAttr(WORD res, attr_t ch) +{ + if (ch & A_COLOR) { + int p; + + p = PairNumber(ch); + if (p > 0 && p < CON_NUMPAIRS) { + WORD a; + a = WINCONSOLE.pairs[p]; + res = (WORD) ((res & 0xff00) | a); + } + } + + if (ch & A_REVERSE) { + res = RevAttr(res); + } + + if (ch & A_STANDOUT) { + res = RevAttr(res) | BACKGROUND_INTENSITY; + } + + if (ch & A_BOLD) + res |= FOREGROUND_INTENSITY; + + if (ch & A_DIM) + res |= BACKGROUND_INTENSITY; + + return res; +} + +#if 0 /* def TRACE */ +static void +dump_screen(const char *fn, int ln) +{ + int max_cells = (WINCONSOLE.SBI.dwSize.Y * + (1 + WINCONSOLE.SBI.dwSize.X)) + 1; + char output[max_cells]; + CHAR_INFO save_screen[max_cells]; + COORD save_size; + SMALL_RECT save_region; + COORD bufferCoord; + + T(("dump_screen %s@%d", fn, ln)); + + save_region.Top = WINCONSOLE.SBI.srWindow.Top; + save_region.Left = WINCONSOLE.SBI.srWindow.Left; + save_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom; + save_region.Right = WINCONSOLE.SBI.srWindow.Right; + + save_size.X = (SHORT) (save_region.Right - save_region.Left + 1); + save_size.Y = (SHORT) (save_region.Bottom - save_region.Top + 1); + + bufferCoord.X = bufferCoord.Y = 0; + + if (read_screen(WINCONSOLE.hdl, + save_screen, + save_size, + bufferCoord, + &save_region)) { + int i, j; + int ij = 0; + int k = 0; + + for (i = save_region.Top; i <= save_region.Bottom; ++i) { + for (j = save_region.Left; j <= save_region.Right; ++j) { + output[k++] = save_screen[ij++].CharInfoChar; + } + output[k++] = '\n'; + } + output[k] = 0; + + T(("DUMP: %d,%d - %d,%d", + save_region.Top, + save_region.Left, + save_region.Bottom, + save_region.Right)); + T(("%s", output)); + } +} + +#else +#define dump_screen(fn,ln) /* nothing */ +#endif + +#if USE_WIDEC_SUPPORT +/* + * TODO: support surrogate pairs + * TODO: support combining characters + * TODO: support acsc + * TODO: _nc_wacs should be part of sp. + */ +static BOOL +con_write16(TERMINAL_CONTROL_BLOCK * TCB, + int y, int x, cchar_t *str, int limit) +{ + int actual = 0; + MakeArray(ci, CHAR_INFO, limit); + COORD loc, siz; + SMALL_RECT rec; + int i; + cchar_t ch; + SCREEN *sp; + + AssertTCB(); + SetSP(); + + for (i = actual = 0; i < limit; i++) { + ch = str[i]; + if (isWidecExt(ch)) + continue; + ci[actual].CharInfoChar = CharOf(ch); + ci[actual].Attributes = MapAttr(WINCONSOLE.SBI.wAttributes, + AttrOf(ch)); + if (AttrOf(ch) & A_ALTCHARSET) { + if (_nc_wacs) { + int which = CharOf(ch); + if (which > 0 + && which < ACS_LEN + && CharOf(_nc_wacs[which]) != 0) { + ci[actual].CharInfoChar = CharOf(_nc_wacs[which]); + } else { + ci[actual].CharInfoChar = ' '; + } + } + } + ++actual; + } + + loc.X = (SHORT) 0; + loc.Y = (SHORT) 0; + siz.X = (SHORT) actual; + siz.Y = 1; + + rec.Left = (SHORT) x; + rec.Top = (SHORT) (y + AdjustY()); + rec.Right = (SHORT) (x + limit - 1); + rec.Bottom = rec.Top; + + return write_screen(WINCONSOLE.hdl, ci, siz, loc, &rec); +} +#define con_write(tcb, y, x, str, n) con_write16(tcb, y, x, str, n) +#else +static BOOL +con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n) +{ + MakeArray(ci, CHAR_INFO, n); + COORD loc, siz; + SMALL_RECT rec; + int i; + chtype ch; + SCREEN *sp; + + AssertTCB(); + SetSP(); + + for (i = 0; i < n; i++) { + ch = str[i]; + ci[i].CharInfoChar = ChCharOf(ch); + ci[i].Attributes = MapAttr(WINCONSOLE.SBI.wAttributes, + ChAttrOf(ch)); + if (ChAttrOf(ch) & A_ALTCHARSET) { + if (sp->_acs_map) + ci[i].CharInfoChar = + ChCharOf(NCURSES_SP_NAME(_nc_acs_char) (sp, ChCharOf(ch))); + } + } + + loc.X = (short) 0; + loc.Y = (short) 0; + siz.X = (short) n; + siz.Y = 1; + + rec.Left = (short) x; + rec.Top = (short) y; + rec.Right = (short) (x + n - 1); + rec.Bottom = rec.Top; + + return write_screen(WINCONSOLE.hdl, ci, siz, loc, &rec); +} +#define con_write(tcb, y, x, str, n) con_write8(tcb, y, x, str, n) +#endif + +#if EXP_OPTIMIZE +/* + * Comparing new/current screens, determine the last column-index for a change + * beginning on the given row,col position. Unlike a serial terminal, there is + * no cost for "moving" the "cursor" on the line as we update it. + */ +static int +find_end_of_change(SCREEN *sp, int row, int col) +{ + int result = col; + struct ldat *curdat = CurScreen(sp)->_line + row; + struct ldat *newdat = NewScreen(sp)->_line + row; + + while (col <= newdat->lastchar) { +#if USE_WIDEC_SUPPORT + if (isWidecExt(curdat->text[col]) || + isWidecExt(newdat->text[col])) { + result = col; + } else if (memcmp(&curdat->text[col], + &newdat->text[col], + sizeof(curdat->text[0]))) { + result = col; + } else { + break; + } +#else + if (curdat->text[col] != newdat->text[col]) { + result = col; + } else { + break; + } +#endif + ++col; + } + return result; +} + +/* + * Given a row,col position at the end of a change-chunk, look for the + * beginning of the next change-chunk. + */ +static int +find_next_change(SCREEN *sp, int row, int col) +{ + struct ldat *curdat = CurScreen(sp)->_line + row; + struct ldat *newdat = NewScreen(sp)->_line + row; + int result = newdat->lastchar + 1; + + while (++col <= newdat->lastchar) { +#if USE_WIDEC_SUPPORT + if (isWidecExt(curdat->text[col]) != + isWidecExt(newdat->text[col])) { + result = col; + break; + } else if (memcmp(&curdat->text[col], + &newdat->text[col], + sizeof(curdat->text[0]))) { + result = col; + break; + } +#else + if (curdat->text[col] != newdat->text[col]) { + result = col; + break; + } +#endif + } + return result; +} + +#define EndChange(first) \ + find_end_of_change(sp, y, first) +#define NextChange(last) \ + find_next_change(sp, y, last) + +#endif /* EXP_OPTIMIZE */ + +#define MARK_NOCHANGE(win,row) \ + win->_line[row].firstchar = _NOCHANGE; \ + win->_line[row].lastchar = _NOCHANGE + +static bool +restore_original_screen(void) +{ + COORD bufferCoord; + bool result = FALSE; + SMALL_RECT save_region = WINCONSOLE.save_region; + + T(("... restoring %s", WINCONSOLE.window_only ? + "window" : "entire buffer")); + + bufferCoord.X = (SHORT) (WINCONSOLE.window_only ? + WINCONSOLE.SBI.srWindow.Left : 0); + bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ? + WINCONSOLE.SBI.srWindow.Top : 0); + + if (write_screen(WINCONSOLE.hdl, + WINCONSOLE.save_screen, + WINCONSOLE.save_size, + bufferCoord, + &save_region)) { + result = TRUE; + mvcur(-1, -1, LINES - 2, 0); + T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)", + WINCONSOLE.save_size.Y, + WINCONSOLE.save_size.X, + save_region.Top, + save_region.Left, + save_region.Bottom, + save_region.Right)); + } else { + T(("... restore original screen contents err")); + } + return result; +} + +static const char * +wcon_name(TERMINAL_CONTROL_BLOCK * TCB) +{ + (void) TCB; + return "win32console"; +} + +static int +wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB) +{ + int result = ERR; + int y, nonempty, n, x0, x1, Width, Height; + SCREEN *sp; + + T((T_CALLED("win32con::wcon_doupdate(%p)"), TCB)); + if (validateConsoleHandle()) { + SetSP(); + + Width = screen_columns(sp); + Height = screen_lines(sp); + nonempty = Min(Height, NewScreen(sp)->_maxy + 1); + + T(("... %dx%d clear cur:%d new:%d", + Height, Width, + CurScreen(sp)->_clear, + NewScreen(sp)->_clear)); + + if (SP_PARM->_endwin == ewSuspend) { + + T(("coming back from shell mode")); + NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG); + + NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG); + NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG); + SP_PARM->_mouse_resume(SP_PARM); + + SP_PARM->_endwin = ewRunning; + } + + if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) { + int x; +#if USE_WIDEC_SUPPORT + MakeArray(empty, cchar_t, Width); + wchar_t blank[2] = + { + L' ', L'\0' + }; + + for (x = 0; x < Width; x++) + setcchar(&empty[x], blank, 0, 0, NULL); +#else + MakeArray(empty, chtype, Width); + + for (x = 0; x < Width; x++) + empty[x] = ' '; +#endif + + for (y = 0; y < nonempty; y++) { + con_write(TCB, y, 0, empty, Width); + memcpy(empty, + CurScreen(sp)->_line[y].text, + (size_t) Width * sizeof(empty[0])); + } + CurScreen(sp)->_clear = FALSE; + NewScreen(sp)->_clear = FALSE; + touchwin(NewScreen(sp)); + T(("... cleared %dx%d lines @%d of screen", nonempty, Width, + AdjustY())); + } + + for (y = 0; y < nonempty; y++) { + x0 = NewScreen(sp)->_line[y].firstchar; + if (x0 != _NOCHANGE) { +#if EXP_OPTIMIZE + int x2; + int limit = NewScreen(sp)->_line[y].lastchar; + while ((x1 = EndChange(x0)) <= limit) { + while ((x2 = NextChange(x1)) <= + limit && x2 <= (x1 + 2)) { + x1 = x2; + } + n = x1 - x0 + 1; + memcpy(&CurScreen(sp)->_line[y].text[x0], + &NewScreen(sp)->_line[y].text[x0], + n * sizeof(CurScreen(sp)->_line[y].text[x0])); + con_write(TCB, + y, + x0, + &CurScreen(sp)->_line[y].text[x0], n); + x0 = NextChange(x1); + } + + /* mark line changed successfully */ + if (y <= NewScreen(sp)->_maxy) { + MARK_NOCHANGE(NewScreen(sp), y); + } + if (y <= CurScreen(sp)->_maxy) { + MARK_NOCHANGE(CurScreen(sp), y); + } +#else + x1 = NewScreen(sp)->_line[y].lastchar; + n = x1 - x0 + 1; + if (n > 0) { + memcpy(&CurScreen(sp)->_line[y].text[x0], + &NewScreen(sp)->_line[y].text[x0], + (size_t) n * + sizeof(CurScreen(sp)->_line[y].text[x0])); + con_write(TCB, + y, + x0, + &CurScreen(sp)->_line[y].text[x0], n); + + /* mark line changed successfully */ + if (y <= NewScreen(sp)->_maxy) { + MARK_NOCHANGE(NewScreen(sp), y); + } + if (y <= CurScreen(sp)->_maxy) { + MARK_NOCHANGE(CurScreen(sp), y); + } + } +#endif + } + } + + /* put everything back in sync */ + for (y = nonempty; y <= NewScreen(sp)->_maxy; y++) { + MARK_NOCHANGE(NewScreen(sp), y); + } + for (y = nonempty; y <= CurScreen(sp)->_maxy; y++) { + MARK_NOCHANGE(CurScreen(sp), y); + } + + if (!NewScreen(sp)->_leaveok) { + CurScreen(sp)->_curx = NewScreen(sp)->_curx; + CurScreen(sp)->_cury = NewScreen(sp)->_cury; + + TCB->drv->td_hwcur(TCB, + 0, + 0, + CurScreen(sp)->_cury, + CurScreen(sp)->_curx); + } + _nc_console_selectActiveHandle(); + result = OK; + } + returnCode(result); +} + +static bool +wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, + const char *tname, + int *errret GCC_UNUSED) +{ + bool code = FALSE; + + T((T_CALLED("win32con::wcon_CanHandle(%p,%s,%p)"), + (void *) TCB, NonNull(tname), (void *) errret)); + + assert(TCB != NULL); + + TCB->magic = WINMAGIC; + + if (tname == NULL || *tname == 0) { + if (!_nc_console_vt_supported()) + code = TRUE; + } else if (tname != NULL && *tname == '#') { + /* + * Use "#" (a character which cannot begin a terminal's name) to + * select specific driver from the table. + * + * In principle, we could have more than one non-terminfo driver, + * e.g., "win32gui". + */ + size_t n = strlen(tname + 1); + if (n != 0 + && ((strncmp(tname + 1, "win32console", n) == 0) + || (strncmp(tname + 1, "win32con", n) == 0))) { + code = TRUE; + } + } else if (tname != NULL && stricmp(tname, "unknown") == 0) { + code = TRUE; + } +#if !USE_NAMED_PIPES + else if (_isatty(TCB->term.Filedes)) { + code = TRUE; + } +#endif + + /* + * This is intentional, to avoid unnecessary breakage of applications + * using symbols. + */ + if (code && (TerminalType(&TCB->term).Booleans == 0)) { + _nc_init_termtype(&TerminalType(&TCB->term)); +#if NCURSES_EXT_NUMBERS + _nc_export_termtype2(&TCB->term.type, &TerminalType(&TCB->term)); +#endif + } + + if (!code) { + if (_nc_console_test(0)) { + T(("isTermInfoConsole=TRUE")); + WINCONSOLE.isTermInfoConsole = TRUE; + } + } + returnBool(code); +} + +static int +wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB, + int beepFlag) +{ + SCREEN *sp; + int res = ERR; + + int high = (WINCONSOLE.SBI.srWindow.Bottom - + WINCONSOLE.SBI.srWindow.Top + 1); + int wide = (WINCONSOLE.SBI.srWindow.Right - + WINCONSOLE.SBI.srWindow.Left + 1); + int max_cells = (high * wide); + int i; + + MakeArray(this_screen, CHAR_INFO, max_cells); + MakeArray(that_screen, CHAR_INFO, max_cells); + COORD this_size; + SMALL_RECT this_region; + COORD bufferCoord; + + if (validateConsoleHandle()) { + SetSP(); + this_region.Top = WINCONSOLE.SBI.srWindow.Top; + this_region.Left = WINCONSOLE.SBI.srWindow.Left; + this_region.Bottom = WINCONSOLE.SBI.srWindow.Bottom; + this_region.Right = WINCONSOLE.SBI.srWindow.Right; + + this_size.X = (SHORT) wide; + this_size.Y = (SHORT) high; + + bufferCoord.X = this_region.Left; + bufferCoord.Y = this_region.Top; + + if (!beepFlag && + read_screen(WINCONSOLE.hdl, + this_screen, + this_size, + bufferCoord, + &this_region)) { + + memcpy(that_screen, + this_screen, + sizeof(CHAR_INFO) * (size_t) max_cells); + + for (i = 0; i < max_cells; i++) { + that_screen[i].Attributes = + RevAttr(that_screen[i].Attributes); + } + + write_screen(WINCONSOLE.hdl, that_screen, this_size, + bufferCoord, &this_region); + Sleep(200); + write_screen(WINCONSOLE.hdl, this_screen, this_size, + bufferCoord, &this_region); + + } else { + MessageBeep(MB_ICONWARNING); /* MB_OK might be better */ + } + res = OK; + } + return res; +} + +static int +wcon_print(TERMINAL_CONTROL_BLOCK * TCB, + char *data GCC_UNUSED, + int len GCC_UNUSED) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); + + return ERR; +} + +static int +wcon_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB, + int fg GCC_UNUSED, + int bg GCC_UNUSED) +{ + SCREEN *sp; + int code = ERR; + + AssertTCB(); + SetSP(); + + return (code); +} + +static void +wcon_setcolor(TERMINAL_CONTROL_BLOCK * TCB, + int fore, + int color, + int (*outc) (SCREEN *, int) GCC_UNUSED) +{ + (void) TCB; + if (validateConsoleHandle()) { + WORD a = _nc_console_MapColor(fore, color); + a |= (WORD) ((WINCONSOLE.SBI.wAttributes) & (fore ? 0xfff8 : 0xff8f)); + SetConsoleTextAttribute(WINCONSOLE.hdl, a); + _nc_console_get_SBI(); + } +} + +static bool +wcon_rescol(TERMINAL_CONTROL_BLOCK * TCB) +{ + bool res = FALSE; + + (void) TCB; + if (validateConsoleHandle()) { + WORD a = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN; + SetConsoleTextAttribute(WINCONSOLE.hdl, a); + _nc_console_get_SBI(); + res = TRUE; + } + return res; +} + +static bool +wcon_rescolors(TERMINAL_CONTROL_BLOCK * TCB) +{ + int result = FALSE; + SCREEN *sp; + + AssertTCB(); + SetSP(); + + return result; +} + +static int +wcon_size(TERMINAL_CONTROL_BLOCK * TCB, int *Lines, int *Cols) +{ + int result = ERR; + + T((T_CALLED("win32con::wcon_size(%p)"), TCB)); + + if (validateConsoleHandle() && + (Lines != NULL) && (Cols != NULL)) { + _nc_console_size(Lines, Cols); + result = OK; + } + returnCode(result); +} + +static int +wcon_setsize(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, + int l GCC_UNUSED, + int c GCC_UNUSED) +{ + AssertTCB(); + return ERR; +} + +static int +wcon_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf) +{ + int result = ERR; + + T((T_CALLED("win32con::wcon_sgmode(TCB=(%p),setFlag=%d,TTY=(%p)"), + TCB, setFlag, buf)); + if (buf != NULL && validateConsoleHandle()) { + + if (setFlag) { + _nc_console_setmode(WINCONSOLE.hdl, buf); + TCB->term.Nttyb = *buf; + } else { + _nc_console_getmode(WINCONSOLE.hdl, &(TCB->term.Nttyb)); + *buf = TCB->term.Nttyb; + } + result = OK; + } + returnCode(result); +} + +static int +wcon_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag) +{ + SCREEN *sp; + TERMINAL *_term = (TERMINAL *) TCB; + int code = ERR; + + T((T_CALLED("win32con::wcon_mode(%p, progFlag=%d, defFlag=%d)"), + TCB, progFlag, defFlag)); + + if (validateConsoleHandle()) { + sp = TCB->csp; + + WINCONSOLE.progMode = progFlag; + WINCONSOLE.lastOut = progFlag ? WINCONSOLE.hdl : WINCONSOLE.out; + SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut); + + if (progFlag) /* prog mode */ { + if (defFlag) { + if ((wcon_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) { + code = OK; + } + } else { + /* reset_prog_mode */ + if (wcon_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) { + if (sp) { + if (sp->_keypad_on) + _nc_keypad(sp, TRUE); + } + if (!WINCONSOLE.buffered) { + _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI); + } + code = OK; + } + } + T(("... buffered:%d, clear:%d", + WINCONSOLE.buffered, CurScreen(sp)->_clear)); + } else { /* shell mode */ + if (defFlag) { + /* def_shell_mode */ + if (wcon_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) { + code = OK; + } + } else { + /* reset_shell_mode */ + if (sp) { + _nc_keypad(sp, FALSE); + NCURSES_SP_NAME(_nc_flush) (sp); + } + code = wcon_sgmode(TCB, TRUE, &(_term->Ottyb)); + if (!WINCONSOLE.buffered) { + _nc_console_set_scrollback(TRUE, &WINCONSOLE.save_SBI); + if (!restore_original_screen()) + code = ERR; + } + SetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI); + } + } + + } + returnCode(code); +} + +static void +wcon_screen_init(SCREEN *sp GCC_UNUSED) +{ +} + +static void +wcon_wrap(SCREEN *sp GCC_UNUSED) +{ +} + +static void +wcon_release(TERMINAL_CONTROL_BLOCK * TCB) +{ + T((T_CALLED("win32con::wcon_release(%p)"), TCB)); + + AssertTCB(); + if (TCB->prop) + free(TCB->prop); + + returnVoid; +} + +static void +wcon_init(TERMINAL_CONTROL_BLOCK * TCB) +{ + T((T_CALLED("win32con::wcon_init(%p)"), TCB)); + + AssertTCB(); + + if (!(console_initialized = _nc_console_checkinit(USE_NAMED_PIPES))) { + returnVoid; + } + + if (TCB) { + TCB->info.initcolor = TRUE; + TCB->info.canchange = FALSE; + TCB->info.hascolor = TRUE; + TCB->info.caninit = TRUE; + + TCB->info.maxpairs = CON_NUMPAIRS; + TCB->info.maxcolors = 8; + TCB->info.numlabels = 0; + TCB->info.labelwidth = 0; + TCB->info.labelheight = 0; + TCB->info.nocolorvideo = 1; + TCB->info.tabsize = 8; + + TCB->info.numbuttons = WINCONSOLE.numButtons; + TCB->info.defaultPalette = _nc_cga_palette; + + } + returnVoid; +} + +static void +wcon_initpair(TERMINAL_CONTROL_BLOCK * TCB, + int pair, + int f, + int b) +{ + SCREEN *sp; + + if (validateConsoleHandle()) { + SetSP(); + + if ((pair > 0) && (pair < CON_NUMPAIRS) && (f >= 0) && (f < 8) + && (b >= 0) && (b < 8)) { + WINCONSOLE.pairs[pair] = + _nc_console_MapColor(true, f) | + _nc_console_MapColor(false, b); + } + } +} + +static void +wcon_initcolor(TERMINAL_CONTROL_BLOCK * TCB, + int color GCC_UNUSED, + int r GCC_UNUSED, + int g GCC_UNUSED, + int b GCC_UNUSED) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +} + +static void +wcon_do_color(TERMINAL_CONTROL_BLOCK * TCB, + int old_pair GCC_UNUSED, + int pair GCC_UNUSED, + int reverse GCC_UNUSED, + int (*outc) (SCREEN *, int) GCC_UNUSED +) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +} + +static void +wcon_initmouse(TERMINAL_CONTROL_BLOCK * TCB) +{ + SCREEN *sp; + + T((T_CALLED("win32con::wcon_initmouse(%p)"), TCB)); + + if (validateConsoleHandle()) { + SetSP(); + + sp->_mouse_type = M_TERM_DRIVER; + } + returnVoid; +} + +static int +wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB, + int delay + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + int rc = 0; + SCREEN *sp; + + T((T_CALLED("win32con::wcon_testmouse(%p)"), TCB)); + if (validateConsoleHandle()) { + SetSP(); + + if (sp->_drv_mouse_head < sp->_drv_mouse_tail) { + rc = TW_MOUSE; + } else { + rc = TCBOf(sp)->drv->td_twait(TCBOf(sp), + TWAIT_MASK, + delay, + (int *) 0 + EVENTLIST_2nd(evl)); + } + } + + returnCode(rc); +} + +static int +wcon_mvcur(TERMINAL_CONTROL_BLOCK * TCB, + int yold GCC_UNUSED, int xold GCC_UNUSED, + int y, int x) +{ + int ret = ERR; + + (void) TCB; + if (validateConsoleHandle()) { + COORD loc; + loc.X = (short) x; + loc.Y = (short) (y + AdjustY()); + SetConsoleCursorPosition(WINCONSOLE.hdl, loc); + ret = OK; + } + return ret; +} + +static void +wcon_hwlabel(TERMINAL_CONTROL_BLOCK * TCB, + int labnum GCC_UNUSED, + char *text GCC_UNUSED) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +} + +static void +wcon_hwlabelOnOff(TERMINAL_CONTROL_BLOCK * TCB, + int OnFlag GCC_UNUSED) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +} + +static chtype +wcon_conattr(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED) +{ + chtype res = A_NORMAL; + res |= (A_BOLD | A_DIM | A_REVERSE | A_STANDOUT | A_COLOR); + return res; +} + +static void +wcon_setfilter(TERMINAL_CONTROL_BLOCK * TCB) +{ + SCREEN *sp; + + AssertTCB(); + SetSP(); +} + +static void +wcon_initacs(TERMINAL_CONTROL_BLOCK * TCB, + chtype *real_map GCC_UNUSED, + chtype *fake_map GCC_UNUSED) +{ +#define DATA(a,b) { a, b } + static struct { + int acs_code; + int use_code; + } table[] = { + DATA('a', 0xb1), /* ACS_CKBOARD */ + DATA('f', 0xf8), /* ACS_DEGREE */ + DATA('g', 0xf1), /* ACS_PLMINUS */ + DATA('j', 0xd9), /* ACS_LRCORNER */ + DATA('l', 0xda), /* ACS_ULCORNER */ + DATA('k', 0xbf), /* ACS_URCORNER */ + DATA('m', 0xc0), /* ACS_LLCORNER */ + DATA('n', 0xc5), /* ACS_PLUS */ + DATA('q', 0xc4), /* ACS_HLINE */ + DATA('t', 0xc3), /* ACS_LTEE */ + DATA('u', 0xb4), /* ACS_RTEE */ + DATA('v', 0xc1), /* ACS_BTEE */ + DATA('w', 0xc2), /* ACS_TTEE */ + DATA('x', 0xb3), /* ACS_VLINE */ + DATA('y', 0xf3), /* ACS_LEQUAL */ + DATA('z', 0xf2), /* ACS_GEQUAL */ + DATA('0', 0xdb), /* ACS_BLOCK */ + DATA('{', 0xe3), /* ACS_PI */ + DATA('}', 0x9c), /* ACS_STERLING */ + DATA(',', 0xae), /* ACS_LARROW */ + DATA('+', 0xaf), /* ACS_RARROW */ + DATA('~', 0xf9), /* ACS_BULLET */ + }; +#undef DATA + unsigned n; + + SCREEN *sp; + if (validateConsoleHandle()) { + SetSP(); + + for (n = 0; n < SIZEOF(table); ++n) { + real_map[table[n].acs_code] = + (chtype) table[n].use_code | A_ALTCHARSET; + if (sp != NULL) + sp->_screen_acs_map[table[n].acs_code] = TRUE; + } + } +} + +static int +wcon_twait(TERMINAL_CONTROL_BLOCK * TCB, + int mode, + int milliseconds, + int *timeleft + EVENTLIST_2nd(_nc_eventlist * evl)) +{ + SCREEN *sp; + int code = 0; + + if (validateConsoleHandle()) { + SetSP(); + + code = _nc_console_twait(sp, + WINCONSOLE.inp, + mode, + milliseconds, + timeleft EVENTLIST_2nd(evl)); + } + return code; +} + +static int +wcon_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf) +{ + SCREEN *sp; + int n = -1; + + T((T_CALLED("win32con::wcon_read(%p)"), TCB)); + + assert(buf); + if (validateConsoleHandle()) { + SetSP(); + + n = _nc_console_read(sp, WINCONSOLE.inp, buf); + } + returnCode(n); +} + +static int +wcon_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms) +{ + T((T_CALLED("win32con::wcon_nap(%p, %d)"), TCB, ms)); + Sleep((DWORD) ms); + returnCode(OK); +} + +static int +wcon_cursorSet(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int mode) +{ + int res = -1; + + T((T_CALLED("win32con:wcon_cursorSet(%d)"), mode)); + if (validateConsoleHandle()) { + CONSOLE_CURSOR_INFO this_CI = WINCONSOLE.save_CI; + switch (mode) { + case 0: + this_CI.bVisible = FALSE; + break; + case 1: + break; + case 2: + this_CI.dwSize = 100; + break; + } + SetConsoleCursorInfo(WINCONSOLE.hdl, &this_CI); + } + returnCode(res); +} + +static bool +wcon_kyExist(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int keycode) +{ + bool found = FALSE; + + T((T_CALLED("win32con::wcon_kyExist(%d)"), keycode)); + found = _nc_console_keyExist(keycode); + returnBool(found); +} + +static int +wcon_kpad(TERMINAL_CONTROL_BLOCK * TCB, int flag GCC_UNUSED) +{ + SCREEN *sp; + int code = ERR; + + T((T_CALLED("win32con::wcon_kpad(%p, %d)"), TCB, flag)); + + if (validateConsoleHandle()) { + SetSP(); + + if (sp) { + code = OK; + } + } + returnCode(code); +} + +static int +wcon_keyok(TERMINAL_CONTROL_BLOCK * TCB, + int keycode, + int flag) +{ + int code = ERR; + SCREEN *sp; + + T((T_CALLED("win32con::wcon_keyok(%p, %d, %d)"), TCB, keycode, flag)); + + if (validateConsoleHandle()) { + SetSP(); + if (sp) { + code = _nc_console_keyok(keycode, flag); + } + } + returnCode(code); +} + +NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_WIN_DRIVER = { + FALSE, + wcon_name, /* Name */ + wcon_CanHandle, /* CanHandle */ + wcon_init, /* init */ + wcon_release, /* release */ + wcon_size, /* size */ + wcon_sgmode, /* sgmode */ + wcon_conattr, /* conattr */ + wcon_mvcur, /* hwcur */ + wcon_mode, /* mode */ + wcon_rescol, /* rescol */ + wcon_rescolors, /* rescolors */ + wcon_setcolor, /* color */ + wcon_dobeepflash, /* DoBeepFlash */ + wcon_initpair, /* initpair */ + wcon_initcolor, /* initcolor */ + wcon_do_color, /* docolor */ + wcon_initmouse, /* initmouse */ + wcon_testmouse, /* testmouse */ + wcon_setfilter, /* setfilter */ + wcon_hwlabel, /* hwlabel */ + wcon_hwlabelOnOff, /* hwlabelOnOff */ + wcon_doupdate, /* update */ + wcon_defaultcolors, /* defaultcolors */ + wcon_print, /* print */ + wcon_size, /* getsize */ + wcon_setsize, /* setsize */ + wcon_initacs, /* initacs */ + wcon_screen_init, /* scinit */ + wcon_wrap, /* scexit */ + wcon_twait, /* twait */ + wcon_read, /* read */ + wcon_nap, /* nap */ + wcon_kpad, /* kpad */ + wcon_keyok, /* kyOk */ + wcon_kyExist, /* kyExist */ + wcon_cursorSet /* cursorSet */ +}; diff --git a/ncurses/ncurses_cfg.h b/ncurses/ncurses_cfg.h new file mode 100644 index 0000000000..1ebe0b4055 --- /dev/null +++ b/ncurses/ncurses_cfg.h @@ -0,0 +1,270 @@ +/* include/ncurses_cfg.h. Generated automatically by configure. */ +/**************************************************************************** + * Copyright 2020,2024 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * + * * + * Copyright (c) 2026 * + * Project Tick. All rights reserved. * + * * + * 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 1997-on * + ****************************************************************************/ +/* + * $Id: ncurses_cfg.hin,v 1.15 2024/06/08 14:04:14 tom Exp $ + * + * Both ncurses_cfg.h and ncurses_def.h are internal header-files used when + * building ncurses. + * + * This is a template-file used to generate the "ncurses_cfg.h" file. + * + * Rather than list every definition, the configuration script substitutes the + * definitions that it finds using 'sed'. You need a patch (original date + * 971222) to autoconf 2.12 or 2.13 to do this. + * + * See: + * https://invisible-island.net/autoconf/ + * https://invisible-island.net/archives/autoconf/ + */ +#ifndef NC_CONFIG_H +#define NC_CONFIG_H + +#define PACKAGE "ncurses" +#define NCURSES_VERSION "6.6" +#define NCURSES_PATCHDATE 20251230 +#define SYSTEM_NAME "Linux" +#if 0 +#include +#endif +#define HAVE_LONG_FILE_NAMES 1 +#define MIXEDCASE_FILENAMES 1 +#define STDC_HEADERS 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_DIRENT_H 1 +#define USE_SYSMOUSE 0 +#define TERMINFO_DIRS "/etc/terminfo:/lib/terminfo:/usr/share/terminfo:/usr/local/share/terminfo" +#define TERMINFO "/usr/share/terminfo" +#define HAVE_BIG_CORE 1 +#define TERMPATH "/etc/termcap:/usr/share/misc/termcap" +#define USE_GETCAP 1 +#define USE_HOME_TERMINFO 1 +#define USE_ROOT_ENVIRON 1 +#define USE_ROOT_ACCESS 1 +#define USE_SETUID_ENVIRON 1 +#define HAVE_UNISTD_H 1 +#define HAVE_REMOVE 1 +#define HAVE_UNLINK 1 +#define HAVE_LINK 1 +#define HAVE_SYMLINK 1 +#define USE_LINKS 1 +#define BSD_TPUTS 1 +#define HAVE_LANGINFO_CODESET 1 +#define USE_WIDEC_SUPPORT 1 +#define NCURSES_WIDECHAR 1 +#define HAVE_WCHAR_H 1 +#define HAVE_WCTYPE_H 1 +#define HAVE_PUTWC 1 +#define HAVE_BTOWC 1 +#define HAVE_WCTOB 1 +#define HAVE_WMEMCHR 1 +#define HAVE_MBTOWC 1 +#define HAVE_WCTOMB 1 +#define HAVE_MBLEN 1 +#define HAVE_MBRLEN 1 +#define HAVE_MBRTOWC 1 +#define HAVE_WCSRTOMBS 1 +#define HAVE_MBSRTOWCS 1 +#define HAVE_WCSTOMBS 1 +#define HAVE_MBSTOWCS 1 +#define HAVE_WCWIDTH 1 +#define NEED_WCHAR_H 1 +#define HAVE_FSEEKO 1 +#define RGB_PATH "no" +#define SIZEOF_SIGNED_CHAR 1 +#define NCURSES_EXT_FUNCS 1 +#define HAVE_ASSUME_DEFAULT_COLORS 1 +#define HAVE_CURSES_VERSION 1 +#define HAVE_HAS_KEY 1 +#define HAVE_RESIZETERM 1 +#define HAVE_RESIZE_TERM 1 +#define HAVE_TERM_ENTRY_H 1 +#define HAVE_USE_DEFAULT_COLORS 1 +#define HAVE_USE_SCREEN 1 +#define HAVE_USE_WINDOW 1 +#define HAVE_WRESIZE 1 +#define NCURSES_SP_FUNCS 1 +#define HAVE_TPUTS_SP 1 +#define NCURSES_EXT_COLORS 1 +#define HAVE_ALLOC_PAIR 1 +#define HAVE_INIT_EXTENDED_COLOR 1 +#define HAVE_RESET_COLOR_PAIRS 1 +#define NCURSES_EXT_PUTWIN 1 +#define NCURSES_NO_PADDING 1 +#define USE_SIGWINCH 1 +#define NCURSES_XNAMES 1 +#define NCURSES_WRAP_PREFIX "_nc_" +#define USE_ASSUMED_COLOR 1 +#define USE_HASHMAP 1 +#define USE_COLORFGBG 1 +#define GCC_SCANF 1 +#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) +#define GCC_PRINTF 1 +#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) +#define GCC_UNUSED __attribute__((unused)) +#define GCC_NORETURN __attribute__((noreturn)) +#define HAVE_NC_ALLOC_H 1 +#define HAVE_MATH_FUNCS 1 +#define TIME_WITH_SYS_TIME 1 +#define HAVE_REGEX_H_FUNCS 1 +#define HAVE_FCNTL_H 1 +#define HAVE_GETOPT_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_LOCALE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_POLL_H 1 +#define HAVE_SYS_AUXV_H 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_TIME_H 1 +#define HAVE_SYS_TIMES_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_WCTYPE_H 1 +#define HAVE_GETOPT_H 1 +#define HAVE_GETOPT_HEADER 1 +#define DECL_ENVIRON 1 +#define HAVE_ENVIRON 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_STRDUP 1 +#define HAVE_SYS_TIME_SELECT 1 +#define SIG_ATOMIC_T volatile sig_atomic_t +#define HAVE_CLOCK_GETTIME 1 +#define HAVE_FPATHCONF 1 +#define HAVE_GETCWD 1 +#define HAVE_GETEGID 1 +#define HAVE_GETEUID 1 +#define HAVE_GETOPT 1 +#define HAVE_GETUID 1 +#define HAVE_ISSETUGID 0 +#define HAVE_LOCALECONV 1 +#define HAVE_POLL 1 +#define HAVE_REMOVE 1 +#define HAVE_SELECT 1 +#define HAVE_SETBUF 1 +#define HAVE_SETBUFFER 1 +#define HAVE_SETVBUF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SIGVEC 0 +#define HAVE_SNPRINTF 1 +#define HAVE_STRDUP 1 +#define HAVE_STRSTR 1 +#define HAVE_SYSCONF 1 +#define HAVE_TCGETPGRP 1 +#define HAVE_TIMES 1 +#define HAVE_TSEARCH 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_PATH_TTYS 0 +#define HAVE_GETTTYNAM 0 +#define HAVE_BSD_CGETENT 0 +#define HAVE_ISASCII 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_TCGETATTR 1 +#define HAVE_VSSCANF 1 +#define HAVE_UNISTD_H 1 +#define HAVE_MKSTEMP 1 +#define HAVE_SIZECHANGE 1 +#define HAVE_WORKING_POLL 1 +#define HAVE_CONSISTENT_MB_LEN_MAX 1 +#define HAVE_VA_COPY 1 +#define HAVE_UNISTD_H 1 +#define HAVE_FORK 1 +#define HAVE_VFORK 1 +#define HAVE_WORKING_VFORK 1 +#define HAVE_WORKING_FORK 1 +#define USE_FOPEN_BIN_R 1 +#define HAVE_CC_T 1 +#define HAVE_SPEED_T 1 +#define HAVE_TCFLAG_T 1 +#define HAVE_SIGSET_T 1 +#define USE_OPENPTY_HEADER +#define USE_XTERM_PTY 1 +#define USE_STDBOOL_H 1 +#define HAVE_NEW 1 +#define HAVE_EXCEPTION 1 +#define HAVE_TYPEINFO 1 +#define HAVE_IOSTREAM 1 +#define IOSTREAM_NAMESPACE 1 +#define SIZEOF_BOOL 1 +#define CPP_HAS_OVERRIDE 1 +#define CPP_HAS_STATIC_CAST 1 +#define SIZEOF_WCHAR_T 4 +#define HAVE_SLK_COLOR 1 +#define HAVE_PANEL_H 1 +#define HAVE_LIBPANEL 1 +#define HAVE_MENU_H 1 +#define HAVE_LIBMENU 1 +#define HAVE_FORM_H 1 +#define HAVE_LIBFORM 1 +#define NCURSES_PATHSEP ':' +#define NCURSES_VERSION_STRING "6.6.20251230" +#define NCURSES_OSPEED_COMPAT 1 + +#include + + /* The C compiler may not treat these properly but C++ has to */ +#ifdef __cplusplus +#undef const +#undef inline +#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 + +/* + * vile:cmode + */ +#endif /* NC_CONFIG_H */ diff --git a/ncurses/pathnames.h b/ncurses/pathnames.h new file mode 100644 index 0000000000..64bcf1cdff --- /dev/null +++ b/ncurses/pathnames.h @@ -0,0 +1,36 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Copyright (c) 2026 + * Project Tick. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define _PATH_DEF ".termcap /etc/termcap /usr/share/misc/termcap" +#define _PATH_DEF_SEC "/etc/termcap" diff --git a/tcsh/FAQ b/tcsh/FAQ new file mode 100644 index 0000000000..93773c5243 --- /dev/null +++ b/tcsh/FAQ @@ -0,0 +1,243 @@ + * Home + * FAQ + * Y2K + __________________________________________________________________ + +FAQ + + For the people who do not read the manual! + + Why is the meta key broken in tcsh-5.20 and up? + + On some machines the tty is not set up to pass 8 bit characters by + default. Tcsh 5.19 used to try to determine if pass8 should be set by + looking at the terminal's meta key. Unfortunately there is no good way + of determining if the terminal can really pass 8 characters or not. + Consider if you are logged in through a modem line with 7 bits and + parity and your terminal has a meta key. Then tcsh 5.19 would set + wrongly set pass8. + + If you did like the previous behavior you can add in /etc/csh.login, or + in .login: + if ( $?tcsh && $?prompt ) then + if ( "`echotc meta`" == "yes" ) then + stty pass8 + endif + endif + + If you don't have pass8, maybe one of these would work: + stty -parity -evenp -oddp cs8 -istrip (rs6000) + stty -parenb -istrip cs8 + + Finally, tcsh will bind all printable meta characters to the self + insert command. If you don't want that to happen (i.e. use the + printable meta characters for commands) setenv NOREBIND. + + I ran dbxtool & and shelltool & from tcsh, and they end up in cbreak and no + echo mode? + + These programs are broken. Background jobs should not try to look at + the tty. What happens is that dbxtool looks in stderr to inherit the + tty setups, but tcsh sets up the tty in cbreak and -echo modes, so that + it can do line editing. This cannot be fixed because tcsh cannot give + away the tty. Pick one of the following as a workaround: + dbxtool < /dev/null >& /dev/null & + /usr/etc/setsid dbxtool & + + If that does not work, for dbxtool at least you can add sh stty sane in + your .dbxinit file. + + I tried to compile tcsh and it cannot find ? + + Your system does not support NLS. Undefine NLS in config_f.h and it + should work fine. + + Where can I get csh sources? + + Csh sources are now available with the 4.4BSD networking distributions. + You don't need csh sources to compile tcsh-6.0x. + + I just made tcsh my login shell, and I cannot ftp any more? + + Newer versions of the ftp daemon check for the validity of the user's + shell before they allow logins. The list of valid login shells is + either hardcoded or it is usually in a file called /etc/shells. If it + is hard-coded, then you are out of luck and your best bet is to get a + newer version of ftpd. Otherwise add tcsh to the list of shells. (For + AIX this file is called /etc/security/login.cfg.) Remember that the + full path is required. If there is no /etc/shells, and you are creating + one, remember to add /bin/csh, /bin/sh, and any other valid shells for + your system, so that other people can ftp too. + + I am using SunView or OpenWindows and editing is screwed up. In particular my + arrow keys and backspace don't work right. What am I doing wrong? + + Well, cmdtool tries to do its own command line editing and the effect + you get is one of using an editor inside an editor. Both try to + interpret the arrow key sequences and cmdtool wins since it gets them + first. The solutions are in my order of preference: + * Don't use suntools + * Use shelltool instead of cmdtool. + * Unset edit in tcsh. + + On a SPARCstation running Solaris 2.x and OpenWindows 3.1, inside a cmdtool, + the short-cut key sequence to clear log (i.e. Meta-e or Diamond-e) doesn't + work: it just echos ‘e’; or + + Unset edit in tcsh. + + On a SPARCstation running Solaris 2.x and OpenWindows 3.1, maketool (within + SPARCworks) doesn't work: it just does a `cd’ to the working directory then + stops. + + Unset edit in tcsh. Using shelltool instead of cmdtool does not fix + this. + + I rlogin to another machine, and then no matter what I tell stty I cannot get + it to pass 8 bit characters? + + Maybe you need to use rlogin -8 to tell rlogin to pass 8 bit + characters. + + Where do I get the public domain directory library? + + Anonymous ftp to ftp://prep.ai.mit.edu/pub/gnu/dirent.tar.Z + + I compiled tcsh using gcc, and when I start up it says: tcsh: Warning no + access to tty (Invalid Argument). Thus no job control in this shell + + Your file is not ansi compliant. You have one of 3 + choices: + * Run fixincludes from the gcc distribution. + * Add -traditional to the gcc flags. + * Compile with cc. + + I compiled tcsh with the SunOS unbundled compiler and now things get echoed + twice. + + It is a bug in the unbundled optimizer. Lower the optimization level. + + How can I use the arrow keys with hpterm? + + Hp terminals use the arrow keys internally. You can tell hpterm not to + do that, by sending it the termcap sequence smkx. Since this has to be + done all the time, the easiest thing is to put it as an alias for + precmd, or inside the prompt: + if ($term == "hp") then + set prompt="%{`echotc smkx`%}$prompt" + endif + + Note that by doing that you cannot use pgup and pgdn to scroll… Also if + you are using termcap, replace smkx with ks. + + On POSIX machines ^C and ^Z do not work when tcsh is a login shell? + + Make sure that the interrupt character is set to ^C and suspend is set + to ^Z; stty -a will show you the current stty settings; stty intr ^C + susp ^Z will set them to ^C and ^Z respectively. + + I am trying to compile tcsh and I am getting compile errors that look like: + + sh.c:???: `STR???' undeclared, outside of functions [gcc] + "sh.c", line ???: STR??? undefined [cc] + + You interrupted make, while it was making the automatically generated + headers. Type make clean; make + + On the cray, sometimes the CR/LF mapping gets screwed up. + + You are probably logged in to the cray via telnet. Cray's telnetd + implements line mode selection the telnet client you are using does not + implement telnet line mode. This cause the Cray's telnetd to try to use + KLUDGELINEMODE. You can turn off telnet line mode from the cray side by + doing a stty -extproc, or you can get the Cray AIC to build a telnetd + without KLUDGELINEMODE, or you can compile a new telnet client (from + the BSD net2 tape), or at least on the suns use: mode character. + + On AU/X, I made tcsh my startup shell, but the mac desktop is not starting up + (no X11 or Finder), and I only get console emulation. + + Add the pathname to tcsh in /etc/shells and everything should work + fine. + + On machines that use YP (NIS) tilde expansion might end up in /dev/null + + If this happens complain to your vendor, to get a new version of NIS. + You can fix that in tcsh by defining YPBUGS in config.h + + Script on SGI 4.0.5 does not give us a tty, so we cannot have job control. + + Their csh does not have job control either. Try: + % script + % cat > /dev/tty + + I start tcsh and it takes a couple of minutes to get the prompt. + + You have defined REMOTEHOST and your DNS is not responding. Either + undefine REMOTEHOST and recompile or fix your DNS. + + If you need help generating your .cshrc file, check out: + + * https://github.com/tcsh-org/tcsh/blob/master/dot.tcshrc + * https://github.com/tcsh-org/tcsh/blob/master/dot.login + + On POSIX systems the kernel will send hup signals to all the processes in the + foreground process group if ‘stty hupcl’ is set. + + For example + ./tcsh + echo $$ + 591 + ./tcsh + kill -6 591 + + Will kill everything, since hup will be sent to all tcsh processes. To + avoid that you can set stty -hupcl, but it is not recommended. + + When I rsh the meta key stops working on the remote machine. + + Try using rsh -8; this option is undocumented on some systems, but it + works. If that does not work, get and use ssh/sshd. You'll be better + off from a security point of view anyway. + + Tcsh compiled under hp/ux-10.x does not pass resource limits correctly when + ran on hp/ux-11.x systems. + + This is a problem with lack of ABI compatibility between the two + systems. The only solution is to recompile. + + Refreshing in command line editing can appear broken on some OS's + + This is because the termcap/terminfo description lies about the ability + of the terminal to use tabs. At least on Compaq/DEC Alpha OSF/1 3.x and + 4.x systems, stty -tabs will cause problems. + + Where can I learn the merits of tcsh vs. bash vs. csh vs. sh etc? + + You can read the manual page section titled [NEW FEATURES] listing + features that tcsh adds to csh. + + You can read Tom Christiansen's Csh Programming Considered Harmful, a + document advocating that csh (and by extension, tcsh) should not be + used for writing shell scripts. + + XXX: Need to find something about bash, but bash is sh-compatible and + has many of the same interactive features of tcsh (command completion + does not appear to be as flexible, though). + + Curtains up: introducing the Z shell has a pretty good rundown on zsh. + Aside from the arguments about csh being evil, tcsh appears to compare + well with zsh. Zsh is sh and ksh compatible, with many of the + interactive features of tcsh. + + Why does FreeBSD's tcsh do history browsing differently than I expect? + + On FreeBSD, by default, the up arrow is set to history-search-backward, + rather than the default up-history. As a result, if you type (part of) + a word and press up arrow, you'll see previous commands that match the + prefix. Pretty useful, actually, although it takes some getting used + to. You can use bindkey to see your settings, and to rebind up & down + differently if desired. + __________________________________________________________________ + + Page content last updated on 2019-12-31 diff --git a/tcsh/FREEBSD-Xlist b/tcsh/FREEBSD-Xlist new file mode 100644 index 0000000000..1f6a5fb261 --- /dev/null +++ b/tcsh/FREEBSD-Xlist @@ -0,0 +1,23 @@ +*/BUGS +*/Imakefile +*/MAKEDIFFS +*/MAKESHAR +*/Makefile.ADMIN +*/Makefile.in +*/Makefile.std +*/Makefile.vms +*/config.guess +*/config.h.in +*/config.rpath +*/config.sub +*/configure +*/imake.config +*/install-sh +*/svn +*/config/a* +*/config/bs2000 +*/config/bsd +*/config/bsdreno +*/config/[c-z]* +*/tests +*/win32 diff --git a/tcsh/FREEBSD-upgrade b/tcsh/FREEBSD-upgrade new file mode 100644 index 0000000000..2abb920e62 --- /dev/null +++ b/tcsh/FREEBSD-upgrade @@ -0,0 +1,11 @@ +Christos Zoulas `tcsh' + originals can be found at: ftp://ftp.astron.com/pub/tcsh/ + +The stripped down version was created using FREEBSD-Xlist during extraction: + + tar -X FREEBSD-Xlist -xzf tcsh-6.15.00.tar.gz + +Imported by: + + cvs import -m "Import of tcsh-6.15.00" \ + src/contrib/tcsh ZOULAS tcsh_6_15 diff --git a/tcsh/Fixes b/tcsh/Fixes new file mode 100644 index 0000000000..76fdede0c4 --- /dev/null +++ b/tcsh/Fixes @@ -0,0 +1,2198 @@ + 15. V6.22.04 - 20210426 + 14. Don't crash with 'bindkey "^0" clear-screen' (Karl Jeacle) + 13. Fix $x:q:h and $x:q:t return the whole string for strings not containing / + 12. V6.22.03 - 20201118 + 11. Fix $x:q:h and $x:q:t to not crash (alzwded) with strings containing / + 10. Block SIGHUP while writing history/directory stack (Brett Frankenberger) + 9. Fixed reversed test that broke history merging (Brett Frankenberger) + 8. Prevent recursive entry for writing history (Brett Frankenberger) + 7. alxwded@github, keep track of the :g and :a modifiers per modifier they + affect. + 6. alzwded@github, fix infinite loop with :gas variable modifier + 5. PR/88: Add a Q: modifier that preserves empty arguments leaving :q + alone. + 4. V6.22.02 - 20191204 + 3. Fix version in configure.ac + 2. V6.22.01 - 20191201 + 1. undo PR/88: Preserve empty arguments in :q, since it breaks + $ set x="" + $ alias test "echo "\""$x:q"\"" is working." + $ alias test + echo " + + 6. V6.22.00 - 20191128 + 5. PR/113: Sobomax: avoid infinite loops for -c commands when stdout is + not a tty. + 4. Avoid infinite loops during history loads when merging, print a better + error for errors during history load. + 3. PR/88: Preserve empty arguments in :q + 2. PR/94: Small apple issues (SAVESIGVEC, HOSTTYPE) + 1. PR/81: Fix range matching issue where we were comparing with the + range character instead of the start of range. [l-z]* would match foo + + 12. V6.21.00 - 20190508 + 11. Abort history loading on words and lines too long + https://bugzilla.redhat.com/show_bug.cgi?id=1598502 + 10. PR/37: Introduce GetCmdChar() to avoid open coding array access. + 9. make closem() not close sockets so as not to affect nss_ldap. + tcsh never creates sockets so that's ok (Miloslav Trmac) + 8. PR/597: Make rmstar work with aliased rm + 7. convert match() from recursive to backtracking. + 6. Handle 8 bit characters in bindkey (Werner Fink) + 5. Look for tgetent in libtinfo as well (Werner Fink) + 4. Don't play pointer tricks that are undefined in modern c (Brooks Davis) + 3. Fix out of bounds read (Brooks Davis) + 2. Fix type of read in prompt confirmation (eg. rmstar) (David Kaspar) + 1. PR/471: Delay arginp parsing + + 20. V6.20.00 - 20161124 + 19. Don't resize the screen if it did not change size. + 18. V6.19.01 - 20161025 + 17. restore file description when cleaning up after eval: + repeat 99 time + 16. PR/572: Fix $SHLVL issue when exec'ing subshells. + 15. PR/403: Fix backquote expansion for multi-byte character sets. + 14. Fix drawing issu with multi-line prompt (Kensuke Iwahashi/David Kaspar) + 13. always send prusage to stdout. + 12. PR/526: Fix double \\ printing from previous fix in history expansion. + 11. Android updates from Corinna Vinschen + 10. PR/526: Quote backslashes properly so they can be preserved in `` + expansions + 9. Fix memory leak for paraml + 8. Add notempty and ask values for the noclobber setting (Martin Tournoij) + 7. more correct $wordchars for vimode (Luke Mewburn) + 6. expose VImode in $vimode (Luke Mewburn) + 5. display what the compiled in editor is in bindkey -d (Luke Mewburn) + 4. run-fg-editor improvements and documentation (Luke Mewburn) + 3. Fix parsing of 'if (cond)then' (Fridolin Pokorny) + 2. PR/437: Fix handling of invalid unicode characters. + 1. PR/451: Fix error messages containing %c to be always '%c' + + 41. V6.19.00 - 20150521 + 40. V6.18.05 - 20150510 + 39. fix reseting when interrupted inside an eval "eval sleep 10^C" + (paulo.cesar.pereira.de.andrade) + 38. rename handle_intr -> handle_interrupt as originally intended. + 37. fix input tests that need stdin on a tty + 36. V6.18.04 - 20150504 + 35. revert fix echo "\1", it is incorrect. + 34. revert fix to PR/437, breaks short strings. + 33. V6.18.03 - 20150503 + 32. PR/437: Nakajima Akira: Fix segmentation fault reading input files + 31. PR/291: Print job status messages to stderr. + 30. Fridolin Pokorny NUL in `` does not mean EOF. + 29. Pavel Raiskup fix hang with: + while (1) + ( date & ; wait ) + end + 28. Add cdtohome special variable (Martin Tournoij) + 27. Fix root prompt char for windows (Corinna Vinschen) + 26. For "next" completion matches only consider exact matches of the previous + word (Jamie Landeg-Jones) + 25. Fix echo "\1" for echo_style=both where the first character was + not processed properly (Gary Duzan) + 24. V6.18.02 - 20140618 + 23. fix ls-F /non printing exit value twice. + 22. rename configure.in to configure.ac, add aclocal.m4 to CVS + 21. set foo="aabaabaa"; echo $foo:as/a// should produce bb + 20. Add locked merge history support (Marcin Konarski) + 19. Support more resource limits from various BSD's + 18. Cache history count to speed up thing + 17. PR/240: minix support + 16. revert fix for 15. Causes extra quoting, for example (foo is a program + that prints its arguments): + $ ./foo 'abc' * + '\a\b\c' + 15. fix globbing for ``, stripping backslashes. Example: + cat << _EOF > huh + echo 'hello\;world' + _EOF + echo `./huh 0` + echo `./huh $?` + 14. fix for `` that causes hang. Example: + cat << _EOF > huh + #!/bin/sh + echo "[$@]" + echo "I am running" + echo "I am running ($$)" >> huh.out + _EOF + cat << _EOF > huh.tcsh + #!/bin/tcsh -f + + ./huh \ + `#comment blah blah blah` \ + parameter a \ + `#comment blah blah blah` \ + parameter b \ + `#comment blah blah blah` \ + parameter c + echo ok + _EOF + 13. remove AsciiOnly fix now that the real issue has been fixed (Roman Kollar) + 12. define utmp file for aix (Laurence Darby) + 11. fix if history in loops + 10. make ls-F print to stderr and set the exit code + 9. make rmstar interruptible on linux + 8. Get rid of pret_t and make the printf functions return the number of + characters printed as the system ones do. + 7. Parse a FreeBSD compat $LSCOLORS. What to do when both LSCOLORS and + LS_COLORS are set. I am not documenting this until we decide. + 6. V6.18.01 - 20120214 + 5. fix interruptible wait again + 4. ignore bogus compiler overflow message + 3. cleanup ifdefs in utmp code, and provide default array entries + 2. Ignore #machine entries in host.defs + 1. Detect missing ) in gethost.c (Corinna Vinschen) + +104. V6.18.00 - 20120114 +103. remove unused variables. +102. Make gethost use definitions for x __x__ and __x automatically. +101. More utmp fixes +100. V6.17.10 - 20120105 + 99. Add more FreeBSD/NetBSD machines + 98. Add portability wrapper for gencat + 97. Fix warning for write in SYSMALLOC systems. + 96. V6.17.09 - 20120102 + 95. revert gencat handling to pre-cygwin fixes (without the env settings) + 94. remove stray endutent() + 93. V6.17.08 - 20111230 + 92. Remove - from gencat + 91. Provide support for malloc_usable_size() so that linux works again + without SYSMALLOC + 90. Add support for FreeBSD's utmpx. + 89. V6.17.07 - 20111227 + 88. Fix debian bug #645238: tcsh segfaults when prompt includes %j and + there are more than 10 jobs. + 87. PR/155: Default $anyerror to set for backward compatibility + 86. PR/149: Don't print -1 in %j (Vojtech Vitek) + 85. handle -- on chdir commands as the end of options processing so that + they can process a directory like -x without resorting to ./-x + (Andrew Stevenson) + 84. Handle write(2) returning ENOENT from SoFS, thanks ++HAL (Robert Byrnes) + 83. PR/38: Null check for jobs (Kurt Miller) + 82. Fix spelling correction correcting ./foo -> ../foo2 (jean-luc leger) + 81. PR/120: string0 in filetest does not have enough space. + 80. V6.17.06 - 20110415 + 79. PR/110: Add $anyerror to select behavior. Default to the new one. + 78. Don't try to spell commands that are correct (Rouben Rostamian) + [./tcsh -f; set path=($path 2); mkdir foo2; cd foo2; touch foo; + chmod +x foo; set correct=cmd; ./foo -> ../foo] + 77. Don't push the syntax struct on the cleanup stack, because on foo;bar + if foo fails, we will free bar prematurely (Ben Miller) + 76. Avoid infinite loop while trying to print the pid of a dying process + to a closed file (Bob Arendt) + 75. Handle completion of ${ variables (Anthony Mallet) + 74. Add --disable-nls-catalogs (Corinna Vinschen) + 73. convert message catalogs to UTF-8 (Werner Fink) + 72. check that the NLS path works before setting $NLSPATH. + 71. use SYSMALLOC for GLIBC (Werner Fink) + 70. use mallinfo for SYSMALLOC (Corinna Vinschen) + 69. V6.17.05 - 20110201 + 68. Use mkstemp() if there for here docs (Werner Fink) + 67. Fix handling of errors and exit values in builtins (Werner Fink) + 66. Better pty name detection (Werner Fink) + 65. Enable NLS catalogs on Cygwin (Corinna Vinschen) + 64. NLSPATH handling fixes (Corinna Vinschen) + 63. Avoid infrequent exit when tcsh cd's into a non-existent directory + https://bugzilla.novell.com/show_bug.cgi?id=293395 (Werner Fink) + 62. Don't try to spell check full path binaries that are correct because + they can cause hangs when other nfs partitions are hung. (Werner Fink) + 61. Avoid nested interrupts when exiting causing history writing to fail + https://bugzilla.novell.com/show_bug.cgi?id=331627 (Werner Fink) + 60. Instead of giving an error or ignoring lines with missing eol at eof, + process them. + 59. Avoid leaking fd's in mail check (Werner Fink) + 58. Add cygwin_xcrypt() (Corinna Vinschen) + 57. Recognize i686 (Corinna Vinschen) + 56. Rename cygwin32 to cygwin and bring it up-to-date with modern cygwin + settings (Corinna Vinschen) + 55. Avoid double slashes in cdpath (Corinna Vinschen) + 54. V6.17.04 - 20110118 + 53. Revert PR/110, breaks the test suite. + 52. V6.17.03 - 20110117 + 51. PR/102: Complain on input files with missing trailing \n + 50. PR/104: If atime == mtime we don't have new mail. + 49. PR/113: Don't allow illegal variable names to be set. + 48. PR/112: don't set $REMOTEHOST on the local machine. + 47. PR/110: exit status of the pipeline should be the status of the last + command. + 46. Android support (Corinna Vinschen) + 45. Add AUTOSET_KANJI which works around the Shift-JIS encoding that + translates unshifted 7 bit ASCII (Werner Fink) + 44. Handle mb{r,}towc() returning 0 by setting the return value to NUL + (Jean-Luc Leger) + 43. PR/109: make wait interruptible (Vojtech Vitek) + 42. resource limit fixes: signed vs. unsigned, megabyte issue, doc issues + (Robert Byrnes) + 41. remove .bat and .cmd handling for executables on cygwin (Corinna Vinschen) + 40. Don't echo history while history -L or history -M + 39. Check for EOS before ** from Greg Dionne + 38. Don't fork in backeval from Bryan Mason + 37. Better globstar support from Greg Dionne + 36. Error out when processing the last incomplete line instead of silently + ignoring it (Anders Kaseorg) + 35. Fix SEGV from echo `` + 34. Better fixes for histchars and promptchars (nargs) + 33. Fix win32 issue calling fmalloc/ffree from non-thread-safe context. + (Fabio Fabbri) + 32. V6.17.02 - 20100512 + 31. PR/79: nargs: Better handling for promptchars. + 30. PR/97: Add parseoctal to retain compatibility with previous versions (Jim + Zajkowski) + 29. PR/84: Performance fixes for large history merges (add + hashtable (Ted Anderson) + 28. Revert previous #23; people should use $histlit if they want this + feature. + 27. Don't kill "hup" background jobs when a child of the shell exits. + From Debian. + 26. Ignore \r\n in the command line options for OS's that don't strip + these from #!; from Debian + 25. Fix enhanced missing patch (Greg Dionne) + 24. Callers of rt_mbtowc don't grok -2 as a return. Return -1 for now. + (Corinna Vinschen) + 23. Turn HistLit on while recording history to avoid \!\! losing its \. + From Debian + 22. set autoexpand; set histchars="";\n crash. From Debian + 21. V6.17.01 - 20100506 + 20. unset verbose while we are reading the history file to avoid echoing + to the terminal. (Jeffrey Bastian) + 19. globstar addition, Enhance addition, euid, euser, gid variables + (Greg Dionne) + 18. Make 'e' in vi mode work like 'b' - use wordchars (Alistair Crooks) + 17. Handle UTF-16 surrogates (Corinna Vinschen) + 16. Make tcsh work on systems where sizeof(wchar_t) == 2 (Corinna Vinschen) + 15. Better support for Solaris >= 2.9 (Thomas Uhle) + 14. Change internal expression calculations to long long so that we can + deal with > 32 bit time, inodes, uids, file sizes etc. + 13. Add new linux resource limits. + 12. Don't print 'Exit X' when printexitvalue is set in `` expressions + (Jeff Bastian) + 11. Add more LS_COLORS vars (M.H. Anderson) + 10. Reduce whitespace in Makefile (Don Estabrook) + 9. Manual page fixes (Alan R. S. Bueno) + 8. Remove history in loops bug from the documentation (Holger Weiss) + 7. Add autorehash (Holger Weiss) + 6. Add history.at (Ted Anderson) + 5. Better NLSPATH handling (Norm Jacobs) + 4. Fix hostname building from utmp (Cyrus Rahman) + 3. Handle pending signals before flush so that the the history file does + not get truncated. (Ted Anderson) + 2. Fix AsciiOnly setting that broke 8 bit input. (Juergen Keil) + 1. remember to closedir in mailchk (from Werner Fink, reported by + David Binderman) + + 21. V6.17.00 - 20090710 + 20. Fix dataroot autoconf issue. + 19. Fix directory stuff for unit tests. + 18. Fix small bug in history in loops. + 17. Provide newer config.{guess,sub} + 16. Fix gcc 4 warnings. + 15. Fix memory trashing bug introduced in 10. + 14. V6.16.01 - 20090624 + 13. add missing sigemptyset in goodbye() + 12. add rlimit swapsize from FreeBSD. + 11. restore behavior where a[n-] never prints an error. + 10. always save the whole command, not just the first 80 chars of it. + 9. fix short2str/short2qstr length adjustment in wide chars + (Vitezslav Crhonek) + 8. set histfile=/tmp/history.temp; set savehist=(100 merge); + alias precmd history -S. After that justpr is not restored and commands + don't execute. (Andriy Gapon) + 7. Fix "as" $ modifier from corrupting memory. + set t=demfonsftraftionf; echo $t:as/f// + 6. Make $% work with environment variable (Ron Johnston) + 5. Dragonfly script support (Matthias Schmidt, m65) + 4. Add autoexpand=onlyhistory (Don Estabrook, m66) + 3. Add history in loops (Laurence Darby, m48) + 2. Add missing colorls "rs" variable (Shlomi Fish, m70) + 1. Fix pts detection issue (Ruslan Ermilov) + + 33. V6.16.00 - 20080930 + 32. longjmp clobbered variable fixes. + 31. __GNX__ addition + 30. Windows fork fixes + 28. V6.15.02 - 20080830 + 27. Fix an eval free'ing botch (Per Hedeland) + 26. /bin/echo "`" coredumped because stderror() calls longjmp corrupting + the stack (Mark Davies). We should vet the code for all stderror() + calls that cleanup local stack variables. + 25. foo > ${undef} caused coredumps because of vfork() child corrupting + the state of the parent stack. + 24. $x[A-B] did not complain for A out of range. (Cai Xianchao) + 23. rename setp -> tcsh_setp to avoid conflict with mach (Javier Vasquez) + 22. Fix degree handling by defining __XPG4_CHAR_CLASS__ for solaris + (Mike Sullivan) + 21. Change 'od' to 'od -c' in tests so that they work on big endian machines. + (Martin Kraemer) + 20. Add environment variable COMMAND_LINE to be available in completions + (Marcin Konarski) + 19. V6.15.01 - 20070928 + 18. Evaluate expressions in the proper order (Li Zefan), controlled by + compat_expr. + 17. Don't need to flush() if we are silent. Prevents recursive error issue. + (joshua stein) + 16. Don't execute the jobcmd if the output is not a tty (Charles Ross) + 15. Quote the history in the examples (Johann 'Myrkraverk' Oskarsson) + 14. Mismatch clarification patch (Per Hedeland) + 13. Fix 'repeat n cmd &' abort() (Mike Sullivan) + 12. Fix octal parsing (Li Zefan) + 11. Fix pty detection for autologout setting (Kris Kennaway, Giorgos Keramidas) + 10. kill `foo` got stuck because sigchld was disabled too soon (Mark Peek) + 9. Avoid null pointer dereference in proc cwd (Kurt Miller) + 8. eval "foreach a b c" exits (Anthony Menasse) + 7. Quoting was broken in substitutions (Joe Wells) + 6. QNX patches via pkgsrc + 5. cd - twice from a directory that contained a glob pattern, + expands the glob twice (Mark Santcroos) + 4. MidnightBsd support (Lucas Holt) + 3. Fix history substitution core-dump with no history entries + 2. Merge two character tables that are the same (Martin Kraemer) + 1. On ancient 7 bit locales, punctuation characters are used to + denote special characters such as umlaut, adiaresis, etc. + These characters return true for isalpha/isalnum. Ignore them + because they break parsing (Martin Kraemer) + + 74. V6.15.00 - 20070303 + 73. fix extension eating windows code (christos) + 72. fix loop in %R history expansion (christos) + 71. sched +X source file disables interrupts (Mike Sullivan) + 70. One off copying macro buffers (Jean-Luc Leger) + 69. Avoid infinite loops in :ga modifiers when the LHS is a substring of the + RHS. + 68. Automatically disable WIDE_STRINGS with --disable-nls (Miloslav Trmac) + 67. V6.14.07 - 20060825 + 66. rename set to setv to avoid clashes (christos) + 65. Eliminate sighold/sigrelse (christos) + 64. Compilation cleanups. (Martin Kraemer) + 63. Don't rebuild needlessly when generated files are unchanged + (Martin Kraemer) + 62. Fix confusion between Char and eChar (Martin Kraemer) + 61. V6.14.06 - 20060824 + 60. set PROGRAM_ENVIRONMENT for OSD_POSIX (Martin Kraemer) + 59. EBCDIC patch (Martin Kraemer) + 58. Remove globbing support in history rearches (Ryan Barrett) + 57. Highlighting patch (Ryan Barrett) + 56. Mark-Cursor exchange emacs editing fix (Martin Kraemer) + 55. V6.14.05 - 20060304 + 54. don't limit termcap strings to 1K (Alan Ferrency) + 53. protect against null path. + 52. Be more conservative in wide_read PR#29 + 51. remove HAVE_STRCOLL; not needed anymore (Miloslav Trmac) + 50. remove imake support and make nls configurable by configure + (Miloslav Trmac) + 49. V6.14.04 - 20060214 + 48. Fixes build failure with !SHORT_STRINGS (Miloslav Trmac) + 47. Fixes constness warnings with !SHORT_STRINGS: short2str is "strip()", + which modifies its argument. Rather than verify this is safe in all + callers, I have added caching_strip() to mirror the behavior of other + modes. (Miloslav Trmac) + 46. Fixes some constness warnings with SHORT_STRINGS; this is orthogonal + to both build errors with SHORT_STRINGS in 6.14.03, and + short_strings.patch. (Miloslav Trmac) + 45. config-catalogs.patch: Autodetect catalog support (#14). (Miloslav Trmac) + 44. auth.patch: Handle false positives in getauthid() detection, + IIRC on FreeBSD. (Miloslav Trmac) + 43. crypt.patch: Autodetect whether is available. (Miloslav Trmac) + 42. sigint.patch: Block SIGINT while waiting on children. + This is necessary, but I'll still have to look on the older + releases to find out why it was not necessary before + ("before" = 6.13 on Linux). (Miloslav Trmac) + 41. config-package.patch: Readd package version to configure.in, + the testsuite uses it. + (TODO: a better integration with package.h) (Miloslav Trmac) + 40. item_len.patch: Truncate item.len when truncating the string, + just to be sure. (Miloslav Trmac) + 39. va_list.patch: Add missing va_end(). (Miloslav Trmac) + 38. Use va_copy in xvasprintf(); emulate va_copy as suggested in + Autoconf manual if it is not available. (Miloslav Trmac) + 37. declarations.patch: Replace some #ifdef nests by autodetecting + whether the guarded declaration is necessary. + I'm only guessing this is the intent of the #ifdefs, though. + Declare environ unconditionally, it is a bit hard to detect + and the declaration is correct for Linux, anyway. (Miloslav Trmac) + 36. warning.patch: Fix a const warning. + 35. More color-ls variables (Jean-Luc Leger) + 34. V6.14.03 - 20060212 + 33. Signal related changes (Miloslav Trmac) + 32. Misc cast cleanups and code clarification (Miloslav Trmac) + 31. Use dynamically allocated buffers everywhere (Miloslav Trmac) + 30. Fix reading of invalid byte sequences (Miloslav Trmac) + 29. read should only increment count when it succeeds (Miloslav Trmac) + 28. testsuiteadditions (Miloslav Trmac) + 27. -n fixes (Miloslav Trmac) + 26. signness warnings (Miloslav Trmac) + 25. Prevent infinite recursion in catclose (Gerhard Niklasch) + 24. Add Dragonfly (Joerg Sonnenberger) + 23. Check for wcwidth returning a negative number (TOMITA Yoshinori) + 22. recognize "li" and "co" in echotc (Martin Kraemer) [PR/7] + 21. Don't use T_Cols for wrapping purposes; use TermH consistently + (Martin Kraemer) [PR/8] + 20. Don't display duplicate utmp records (Miloslav Trmac) [PR/17] + 19. Clarify hashing and -f sections of man page (Volker Quetschke) [PR/20] + 18. Dave Yearke: configure did not recognize solaris 10 [PR/18] + 17. CYGWIN: Don't lowercase commands and allow foo.exe on command line. + (Corinna Vinschen) [PR/19] + 16. CYGWIN: cd /foo && cd .. ends up erroneously in // for systems that + HAVE_SLASHSLASH [PR/21] + 15. %j was broken (Peter Kruse) + 14. Extend // handling in pathnames from being apollo specific to also + cygwin (Corinna Vinschen) + 13. Fix uppercase/lowercase transformations (Jean-Luc Leger) + 12. Fix symlink expansion (revert from 6.10.00) (Jean-Luc Leger and Christos) + 11. Fix literal sequence in prompt (Miloslav Trmac) + 10. V6.14.02 - 20050412 + 9. Prototype fixes (Miloslav Trmac and Jean-Luc Leger) + 8. V6.14.01 - 20050411 + 7. Make =- refer to $owd (H.Merijn Brand) + 6. Use prototypes (almost) everywhere (Miloslav Trmac) (issue #5) + 5. Fix doc path in Cygwin installation (Corinna Vinschen) + 4. Fix column size calculation (Martin Kraemer) + 3. Implement newline-and-hold and newline-and-down-history (Per Hedeland) + 2. Messages fixes for the ja (Japanese) locale (NAKAMURA Takeshi) (issue #4) + 1. Enable charset conversion in nls (Miloslav Trmac) (issue #3) + + 76. V6.14.00 - 20050325 + 75. Additional messages for the ja (Japanese) locale (NAKAMURA Takeshi) + 74. V6.13.10 - 20050321 + 73. Implement --help (Tom Warzeka) + 72. Clamp solaris autologout time + 71. Add support for "limit heapsize" (Martin Kraemer) + 70. Improved autoconf for utmp/utmpx (Miloslav Trmac) + 69. V6.13.09 - 20050303 + 68. Autoconf additions (Miloslav Trmac and Jean-Luc Leger) + 67. Fix erroneous sign extension when printing huge numbers (Martin Kraemer) + 66. Handle delay in termcap entries (Martin Kraemer) + 65. EBCDIC and BS2000 fixes (Martin Kraemer) + 64. Avoid the SCCS percent-S-percent sequence differently (Kimmo Suominen) + 63. Mark position update fixes (Martin Kraemer) + 62. Define BSDLIMIT and BSDTIMES for Cygwin (Corinna Vinschen) + 61. Fix NLSFrom prototype (Martin Kraemer) + 60. V6.13.08 - 20050303 + 59. Add test for socklen_t in autoconf + 58. Fix problems with NLSFrom prototype + 57. Deal with AIX's utmpx lossage + 56. V6.13.07 - 20050118 + 55. constifications, XXX: duplicate prototype on setpgrp(). + 54. iconv fixes (Miloslav Trmac) + 53. literal code cleanups (Miloslav Trmac) + 52. move intptr_t definition to sh.h and include both stdint.h and inttypes.h + 51. Fix dup2() issues, and introduce FSAFE as the highest file descriptor + to be left untouched. This is to avoid closing hesiod/nis etc file + descriptors behind their backs. I need to really fix file descriptor + handling one day. + 50. forward<->reverse char conversion verification (Miloslav Trmac) + 49. japanese locale additions (Yoshiyuki Sakakibara) + 48. wide character/utf 8 cleanups (Michael Schroeder) + 47. V6.13.06 - 20050105 + 46. autoconf cleanup (Miloslav Trmac) + 45. Fix literal refresh code (Michael Schroeder) + 44. Fix history printing bug with WIDE_STRINGS + 43. V6.13.05 - 20041121 + 42. deal with not having intptr_t + 41. get rid of bool. + 40. Protect HAVE_ICONV with NLS_CATALOGS + 39. Deal with wchar_t being unsigned. + 38. If we HAVEUTMPX redefine some utmp functions in terms of utmpx ones. + 37. V6.13.04 - 20041120 + 36. Fix display problems with two-column characters when using WIDE_STRINGS. + (Miloslav Trmac) + 35. Change charset declarations for some of the translations. + (Miloslav Trmac) + 34. Set O_LARGEFILE properly (Miloslav Trmac) + 33. Use libc functions to access utmp data (Miloslav Trmac) + 32. t_pmatch() was not really case-insensitive when cs == 8 + (Miloslav Trmac) + 31. Fix escaping of "control" bytes 0x80..0x9F when they are actually + parts of UTF-8 character representation. (Miloslav Trmac) + 30. V6.13.03 - 20041120 + 29. More close_on_exec fixes (Miloslav Trmac) + 28. SUSE dspmbyte fixes (via Harald) + 27. Newline handling in command substitution controlled by csubstnonl + (Miloslav Trmac) + 26. Fix UNC prompt expansion (WIN32) (Yasuhiro Matsumoto) + 25. Fix incorrect xprintf() usage (Miloslav Trmac) + 24. Additional architectures support for $HOSTTYPE and $MACHTYPE + (Miloslav Trmac) + 23. Use nl_langinfo(CODESET) to determine $dspmbyte (Miloslav Trmac) + 22. Complete arguments that contant a # (Steven Grady) + 21. Set close-on-exec in subshells + 20. Compilation fixes (Miloslav Trmac) + 19. V6.13.02 - 20040804 + 18. de-register, de-extern, de-shadow, and const poison. + 17. WIDE_STRINGS support (Miloslav Trmac) + 16. warning cleanups (Miloslav Trmac) + 15. nlsclose() arg passing, exp2 is now a gcc builtin (Mark Peek) + 14. iconv malloc portability fix. + 13. make automatic dspmbyte determination case insensitive + 12. V6.13.01 - 20040724 + 11. bug fix in automatic dspmbyte setting (Miloslav Trmac) + 10. iconv patches (Miloslav Trmac) + 9. cygwin signal fixes; only init 32 signals, don't set bit flag on error; + breaks SIGHUP. (Corinna Vinschen) + 8. Make sure terminal size change takes effect immediately. + 7. Obey $printexitvalue for builtins. + 6. FreeBSD PR/66420: Allow history parsing to be special so that it + can handle inline # characters (Oliver Eikemeier) + 5. new termname builtin from (Andrew Stevenson) + 4. if ($var =~ *[^0-9]*) echo not numeric, fix (Andrew Stevenson) + 3. completion fix to avoid dup hosts from ssh_known_hosts + (Eric D. Hendrickson) + 2. vc++ 7.1 compilation fix (Steve Schockley) + 1. UTF-8 handling for both single and double width characters, but + no combining character support. (Michael Schroeder) + + 36. V6.13.00 - 20040519 + 35. V6.12.03 - 20040322 + 34. turn on kanji and dspmbyte by default; add check for utf8 locales, + and turn parsing of that automatically based on $LANG. + 33. Fix compilation issue under Windows/NT and charset incorrect patch + (Yoshiyuki Sakakibara) + 32. completion additions (Tom Warzeka) + 31. compilation fix (Martin Kraemer) + 30. V6.12.02 - 20040221 + 29. Glob completion listing addition (Tom Warzeka) + 28. BS2000 bs2cmd builtin. (Martin Kraemer) + 27. Fix interrupt resetting code when /etc startup scripts have syntax errors + (Mark A. Grondona) + 26. Clarification of kill-ring commands (Per Hedeland) + 25. Debian completion additions (Martin Godisch) + 24. Japanese character set fixes (Juehiro-san) from debian + 23. NLS charset fixes; disabled since they only work with gnu gencat + (Martin Godisch) + 22. Fix HPUX >= 11 resource (Jack Cummings) + 21. Handle breaksw that jumps out of loops. + 20. Revert #16. It causes worse problems. + 19. Avoid using execl() because the last NULL does not always promoted to + a pointer because the function is variadic (Harti Brandt) + 18. revert ignoreeof to the 6.11.00 behavior and document it (Martin Godisch) + 17. do a case insensitive comparison for the multibyte vars (Martin Godisch) + 16. don't sigsuspend() for an already exited job + 15. glob all arguments in source (Martin Godisch) + 14. various debian fixes (Martin Godisch) + 13. setenv syntax check revert (Satoshi I. Nozawa) + 12. EAGAIN typo (dan harkless) + 11. filec compilation issue on hpux (beebe) + 10. win32 compilation fixes for O_LARGEFILE (amol) + 9. Don't go into an infinite loop when tcgetpgrp() returns an error. + 8. Cygwin fixes (Corinna Vinschen) + 7. NLS catclose() bug avoidance (KAJIMOTO Masato) + 6. V6.12.01 - 20030208 + 5. Misc NT cleanup. No more GPL code (amol) + 4. use strtol() to detect errors in builtin kill (Peter Jeremy) + 3. Recognize linux systems on mips* (Maciej W. Rozycki) + 2. Enable complete=igncase on unix (Stephen Krauth) + 1. Eliminate maxitems (Todd Miller) + + 58. V6.12.00 - 20020732 + 57. misc cleanups. + 56. V6.11.05 - 20020712 + 55. We should have socklen_t in the INET6 case, but we leave int otherwise. + 54. Fixed for Darwin/Rhapsody (Mark Peek) + 53. provide new config.sub and config.guess from ftp://ftp.gnu.org/gnu/config/ + (Nelson Beebe) + 52. V6.11.04 - 20020709 + 51. Dissallow setting of environment variables that do not contain + alphanumeric names (Ton Voon) + 50. Don't expand path components that don't resolve to path names (Jonathan + Chen) + 49. Make $ignoreeof agree with the man page (Matias Moreno Meringer) + 48. Fix argument passing in tc.prompt.c expdollar (Nelson Beebe) + 47. Completion fixes from FreeBSD (Mark Peek) + 46. FreeBSD's sbsize limit (Mark Peek) + 45. Fix repeat 3 repeat 2 echo foo + 44. Fix I/O redirection in scripts (Ian D Allen) + 43. Fix ` \\\n ` evaluation (Jean-Luc Leger) + 42. add --version (Nelson Beebe) + 41. portability fixes for sed (Nelson Beebe) + 40. undef sv_handler for AIX's benefit. (Nelson Beebe) + 39. Add a test for ss_family that disables IPV6 (linux/ppc, osf/1 have + problems) (Nelson Beebe) + 38. Disable ipv6 for Apple (Nelson Beebe) + 37. Fix darwin configure entry (Nelson Beebe) + 36. V6.11.03 - 20020701 + 35. Add Ian D. Allen's bug list. + 34. If we are invoked as csh, default to bsd echo (Matej Vela) + 33. Don't close file descriptors too early because setuid scripts fail. + (Jill Pryse-Davies) + 32. Completion updates (Tom Warzeka) + 31. Fix compilation issue on SunOS4 with _POSIX_VDISABLE (Tom Warzeka) + 30. ukrainian update (Olexander Kunytsa) + 29. DSPMBYTE=utf8 patch (Jean-Luc Leger) + 28. fix ipv4 only compilation, remove extra sigsetmask() call (Takayuki Nakao) + 27. window change can cause free to be re-entered causing abort (Mark Peek) + 26. vp->vec vetting, suggested by Ian Dall. + 25. V6.11.02 - 20020516 + 24. Fix prompt bugs in $var and %c0n (TAKAI Kousuke) + 23. Add Cray SV2 config (Rafal Maszkowski) + 22. Add pdf manual page (Warren Ferguson) + 21. Fix REMOTEHOST lossage in with AF_LOCAL sockets (Tom Mander) + 20. Fix win32 break because of TIOCSTI (Amol) + 19. Fix TIOCSTI for hpux 11 (Igor Schein) + 18. Avoid collapsing paths that refer to non-existent components + (Martin Kraemer) + 17. Make -shell invocations always treated as a login shell. + 16. V6.11.01 - 20020308 + 15. Fixes to polish nls locale (Pawe³ Niewiadomski) + 14. russian locale fixes (Alexey Dokuchaev) + 13. document door support (Shaen) + 12. tcsh euc handling extensions (Alexey Zelkin) + 11. Make sure that jobcmd does not clobber the current job (Rob McMahon) + 10. Make sure that the output of verbose and echo do not end up in the + command output (Victor I. Pasko) + 9. Add %j in prompt [needs more work; is not right the first time + after proclist changes] (Hr. Peter Kruse) + 8. `` commands with embedded newlines would ignore commands following + the new line (Victor I. Pasko) + 7. Re-initialize nls if NLSPATH is changed (Naoki Wakamatsu) + 6. Fix 64 bit compilation with linux and resource limits. + 5. Avoid double globbing when ls-F needs to fork (Joe Townsend) + 4. put back csh filec compatible support. + 3. add support for quads in xprintf in the presence of gcc. + 2. unlimit should set rlim.rlim_max to rlim.rlim_cur if max < cur. + 1. Make ~user work again when the home directory is '/'. + + 40. V6.11.00 - 20010902 + 39. Completion fixes (Tom Warzeka) + 38. make c_insert not static so that it can be used from win32 (amol) + 37. Fix rmstar not to corrupt memory when we say no. (Mark Peek) + 36. V6.10.02 - 20010806 + 35. polish nls locale (Pawe³ Niewiadomski)) + 34. Fix a tcsetattr race running background jobs as the last line on an xterm + window (Andrew Brown) + 33. jobcmd alias (Greg Parker) + 32. hpux11 support (Joshua Weage) + 31. Fix SHORT_STRINGS compilation (Daniel Trinkle) + 30. Add kill -s (Mark Peek) + 29. Don't recognize all mips as dec (Bjorn Knutsson) + 28. Fix GLOB_QUOTE problem (noted by Per) I introduced in 6.10.01. + 27. Port to concurrent's powermaxos (Matt Majka) + 26. New builtin srcfile (Amol) + 25. Fix bindkey "\\" cmd (reported by Ismail H. Tuncer) + 24. %0Xc was broken in the prompt if the user's home directory was '/'. + (reported by Edward Glowacki) + 23. V6.10.01 - 20010426 + 22. LARGEFILE support on Linux. + 21. Add big5 multibyte support (Yen-Ming Lee) + 20. Check the return value of setpriority (Dima Dorfman) + 19. Avoid constructing paths with // on DomainOS (Nickolai Zeldovich) + 18. Russian translation (Ilmar S. Habibulin) + 17. Fix hostdefs for alpha support in FreeBSD (Andrey A. Chernov) + 16. Add door support in colorls (Shaen) + 15. Add BSD_STYLE_COLORLS for FreeBSD (Anand) + 14. MAXHOSTNAMELEN needs to be 256 (Kris Kennaway) + 13. Document stty -tabs problems on compaq (Nelson H. F. Beebe) + 12. Fix broken comment, and new versions of config.guess and config.sub + (H.Merijn Brand) + 11. fix redrawing in the recognize case (Andrew Brown) + 10. don't call qsort with 0 items. (Luke Mewburn) + 9. fix echo;echo;echo; not outputing anything (Andrey A. Chernov) + 8. Fix shell word parsing in dabbrev-expand (Per Hedeland) + 7. hpux fixes (Chienting Lin) + 6. Implement kill ring (Per Hedeland) + 5. Avoid core-dumping when a very long $HOME gets passed in (Kris Kennaway) + 4. Add rlimit_vmem for linux based on rlimit_as (N KomaZaki) + 3. back out symlink=expand path check. + 2. Add Estonian translation (Toomas Soome) + 1. Accept empty $savedirs to mean infinity. + + 57. V6.10.00 - 20001119 + 56. Completion fixes (Tom Warzeka) + 55. add missing linux kanji define (Tsuyoshi Kawabe) + 54. More WINNT_NATIVE fixes (amol) + 53. Fix compile error on winnt (Yoshiyuki Sakakibara) + 52. nonstopux configure and makefile fixes (Tom Bates) + 51. V6.09.04 - 20001111 + 50. Order of initialization for multibyte display was wrong + (HyunChul Kim) + 49. Follow the guideline for linux for japanese locale: + http://www.linux.or.jp/JF/JFdocs/Japanese-Locale-Policy.txt + (Tomohiro KUBOTA) + 48. Ukrainian nls map (Olexander Kunytsa) + 47. exit immeditiately if we get an error while we are setting up + (Michael Shalayeff) + 46. (unset path; unsetenv PATH; rehash) -> crash (Kent Vander Velden) + 45. change winnt to winnt_native (Randolph Fritz) + 44. Support home/end in the editor (Andrey A. Chernov) + 43. Typo s/gycwin/cygwin/ in tc.os.h (Andreas Schott) + 42. Alpha ev6 addition (Karen R. McArthur) + 41. DSPMBYTE patch from (Issei Suzuki) + 40. Security fix for here-doc tmp files (proton@ENERGYMECH.NET) + 39. Fix resource limit rounding *again* (Johannes Gross) + 38. Fix $ expansion in prompt (Takashi Sumiyoshi) + 37. V6.09.03 - 20000715 + 36. cygwin port fixes (Arihiro Yoshida) + 35. Add a new "catalog" variable that specifies which NLS catalog + to be used (Issei Suzuki) + 34. cleanup and addition of page up/down (amol) + 33. fix vfork compile problem. + 32. use inet_addr instead of inet_aton for portability. + 31. V6.09.02 - 20000704 + 30. lots more completions (George Cox) + 29. change FILSIZ to BUFSIZE [now that BUFSIZE >> MAXPATHLEN] and + avoid a potential buffer overflow in sh.dir.c (Volker Schmidt) + 28. _MINIX_VMD port (Martijn van Buul) + 27. inet6 handling for remotehost and configure (Hajimu UMEMOTO) + 26. aix-4 does not need gethostname (Darren Reed) + 25. IBM OS/390 Unix Systems Services support (Peter Prymmer) + 24. Fix prompt formatting (Andrey A. Chernov) + 23. Use HostType from Imakefile correctly (Kjetil Torgrim Homme) + 22. Handle long and expanded history lines better (Boleslaw Ciesielski) + 21. With symlinks=expand expand valid paths only (Martin Kraemer) + 20. Make one-byte charsets work with KANJI (Andrey A. Chernov) + 19. NT-specific executable detection moved to NT code (amol) + 18. New "complete module" (Dan Nicolaescu) + 17. Correctly display scaling string in limit error messages (Nathan Ahlstrom) + 16. Don't display "unset watch" message when not appropriate (kim) + 15. V6.09.01 - 20000114 + 14. Circumvent IRIX4D ESTALE bug by exiting. + 13. IRIS4D de-linting. + 12. Finnish nls catalogs (Jukka A. Ukkonen) + 11. Even more multibyte fixes (Taga Nayuta) + 10. Patches to statically link tcsh under solaris-2.6 (John Hawkinson) + 9. Manual page typos (R. Bernstein) + 8. HP/UX-11 (9000/800) HP/UX-10.20 (9000/820) (Haflidi Sigtryggur Magnusson) + 7. Color-ls fixes (Luis Francisco Gonzalez) + 6. Don't re-use time0 to compare to stat's st_mtime, cause it could be + the value returned from times(2) which is the ticks since system + startup (Frank van der Linden) + 5. Time percentage wrap fix (Simon Burge) + 4. EUCKR support (HyunChul Kim) + 3. Grammar and typo fixes for tcsh.man (Steve Kelem) + 2. More multibyte fixes (Rodney Ruddock) + 1. Change 6.08 -> 6.09 where I missed it; update for utlrix 4.5 (Simon Burge) + + 65. V6.09.00 - 19990816 + 64. Add csh emacs mode (Dan Harkless) + 63. Make sure the the glob buffer matches the word buffer size (Brian Biswas) + 62. Fix periodic to work without tperiod set (Kenny McCormack) + 61. V6.08.07 - 19990813 + 60. Fix e_dabbrev_expand (Bjorn Knutsson) + 59. Make \builtin work again (by calling the command not the builtin) + 58. Add NLS_BUGS for OS's that keep file descriptors open for NLS (Ian Dowse) + 57. Make NONLSREBIND work after tcsh starts up. + 56. Fix AIX stupid exit bug. (Dan Harkless) + 55. More irix fixes (Kaveh) + 54. V6.08.06 - 19990701 + 53. module command completion (Dan Nicolaescu) + 52. Man command completion enhancement (Tom) + 51. Fixes for irix configuration (Kaveh) + 50. Support \a and \e in echo command. From (Keith Thompson) + 49. Alpha configure nit from Kaveh + 48. V6.08.05 - 19990511 + 47. In some system, when a builtin fails immediately after we start + tcsh and before we print any messages, NLS messages fail (some + descriptor might be closed) [FreeBSD, HP/UX?]. So we force reading + the NLS catalogs in errinit() (Yoshiyuki Sakakibara) + 46. typos in ja/set1 and ja/set29 (Yoshiyuki Sakakibara) + 45. "dspmbyte autoset trap" support to HP-UX 10.20. (Yoshiyuki Sakakibara) + 44. misnumbered NLS message in tw.help.c (Yoshiyuki Sakakibara) + 43. colorcat variable for NLS color messages (Yoshiyuki Sakakibara) + 42. autoconf fixes from Kaveh (and if it broke, me) + 41. SGI irix fixes from Glenn Coombs. + 40. Don't spin writing the history file when quota is exceeded (Rob McMahon) + 39. V6.08.04 - 19990419 + 38. complete additions (John Gotts) + 37. Port to amiga with geek gadgets (Arto Huusko) + 36. Ignore case in setenv for windows (amol) + 35. Bug fixes for NT unc stuff (amol) + 34. Hash spell check (amol) + 33. V6.08.03 - 19990211 + 32. Helpcommand documentation (Vladimir Alexiev) + 31. small Y2K fix [%y in prompt would be formatted as 10 not 00 at year 2000], + and new Itoa() code (Chris Torek) + 30. OpenBSD m68k patches (Paul DuBois) + 29. Avoid redefinition of getpeername on Solaris-2.7 + 28. fix problems with savedups=erase, savehist=merge (Randy Gobbel) + 27. Don't set $shell to csh, if we were invoked as tcsh (Tomas Persson) + 26. added $_ + 25. added postcmd + 24. V6.08.02 - 19981124 + 23. document continue and continue_args + 22. wrong test in slowexec made NT optimization a noop (Amol) + 21. Rhapsody fixes + separate CFLAGS/CPPFLAGS (Wilfredo Sanchez) + 20. literals in both prompt at rprompt did not work properly (Taga Nayuta) + 19. multibyte deletion fixes (Yoshiyuki.Sakakibara) + 18. clean up key binding stuff for NT by moving the nt dependent code to + the NT source (amol) + 17. dspmbyte fixes for AIX, typos in man page and nls (Yoshiyuki Sakakibara) + 16. Convex fixes (Ron Echeverri) + 15. V6.08.01 - 19981025 + 14. SX4 port; this adds many casts for machines where ptrdiff_t is 64 bits. + (Andreas Schott) + 13. U/Win port; does not work properly with U/Win 1.6, wait for the next + version (Chris Jones) + 12. Sgi does not need gethostname prototype (John Bogan) + 11. Logic in sh.dir.c was wrong for NT (Amol) + 10. HP_CXD_SPP stat64 fixes (Scott Garee) + 9. Documentation spelling fixes (Keith Thompson) + 8. Documentation fix for savedirs (Amol) + 7. Siemens OSD_POSIX fixes (Martin Kraemer) + 6. include for all the BSD's (Trevor Johnson) + 5. Multibyte display fixes for gnu ls (Taga Nayuta) + 4. Configure/Makefile hesiod and bindir fixes (Dan Winship) + 3. Use winnt not win32 in tc.os.h (Amol) + 2. Cygwin32 port (Raj Menon) + 1. Ported Fixes (Tom) + + 95. V6.08.00 - 19981002 + 94. where builtin nt fix (Amol) + 93. V6.07.13 - 19980926 + 96. NT multibyte fixes (Amol) + 95. NeXT needs getcwd. + 94. fix new bug introduced by strncpy'fication in sh.dir.c (Taga Nayuta) + 93. V6.07.12 - 19980918 + 92. add cray in configure script (Tom) + 91. nls fixes + 90. Avoid buffer overflows in directory code (kim) + 89. Add multibyte character display support (Yoshiyuki Sakakibara) + 88. Make tcsh use getcwd instead of getwd and supply a getcwd. + 87. Fix remotehost again (kim) + 86. V6.07.11 - 19980913 + 85. Leave remotehost ip addresses alone (don't try to resolve them) (Kim) + 84. Read vs. force_read fixes (Amol) + 83. Make colorls if color is set before the first LS_COLORS setenv + (Taga Nayuta) + 82. Use _PATH_DEFPATH on BSD4_4 systems. (Jim Bernard) + 81. Cursor bounds checks (Michael Schroeder) + 80. Syntax error nits (Michael Schroeder) + 79. configure fixes (Michael Schroeder) + 78. V6.07.10 - 19980904 + 77. Off by one error in NO_ERRORS... + 76. Japanese NLS messages (Yoshiyuki Sakakibara) + 75. Add ENXIO and EBADF in the test for write failures for Irix Zombies + (Ralf W. Grosse-Kunstleve) + 74. Missed a test for NOSTRCOLL in glob.c (Michael Liepelt) + 73. Another ABSOLUTEP change (Amol) + 72. Italian NLS messages (Massimo Bertozzi) + 71. WIN32 fixes for ntslowexec and color_ls literal printing in prompt (Amol) + 70. a few missed WIN32 merges (Amol) + 69. defined YPBUGS for sgi (Kaveh) + 68. V6.07.09 - 19980707 + 67. Separate the nt builtins (Amol) + 66. completion fixes (Tom) + 65. color ls fixes (Taga Nayuta) + 64. V6.07.08 - 19980629 + 63. add config.h.in (Kaveh) + 62. win32 updates (Amol) + 61. warning and portability cleanups on the new changes (Kaveh) + 60. V6.07.07 - 19980628 + 59. Fast execute by-pass for win32 (Amol Deshpande) + 58. Clean up const usage a bit, and fix gcc 2.8.1 warnings. + 57. Use @bindir@ for DESTBIN in Makefile.in (Edgar Hoch) + 56. Avoid overflow in time builtin computation (Nobue Adachi) + 55. Color ls additions (Taga Nayuta) + 54. unsigned char vs. char warning fixes (Kaveh) + 53. Solaris 64 bit fixes (fix directory offset bug) (Thomas-Martin Kruel) + 52. More win32 patches (Amol) + 51. autoconf lossage from (Kaveh) + 50. V6.07.06 - 04/08/98 + 49. Collation fix for globbing (Andrey A. Chernov) + 48. We might have NLS_CATALOGS and not LC_MESSAGES (Andrey A. Chernov) + 47. 4.4BSD header fixes (Andrey A. Chernov) + 46. Signed char prompt fixes (Andrey A. Chernov) + 45. Pattern match fix for directory searches (Mike Patnode) + 44. Pentium DGUX fixes (Miko Nahum) + 43. Spanish nls message catalogs (Luis Francisco Gonzalez) + 42. Fix trailing whitespace parsing in HASHBANG code (Martin Kraemer) + 41. Remove stray debuggin message from unmatched substitutions. + (from Amol Deshpande) + 40. Fix reversed arguments in Usagae message. (from Amol Deshpande) + 39. Fix bug introduced at tcsh-7.06.03 [expdollar] that affected %.n prompt + format. + 38. Fix typos introduced in last batch of changes. + 37. Fix interrupted script using onintr, exiting parent shell problem. + 36. Cleanup prototypes. + 35. V6.07.05 - 10/28/97 + 34. Integrate Amol Deshpande's WINNT fixes to the tcsh source. Note that + this is not complete yet; we are missing the NT glue code and the message + catalogs. + 33. Fix ^T at the first character in the line (Chuck Silvers) + 32. Eliminate xsprintf and xvsprintf + 31. Qmail patch from (Matthew Zahorik) + 30. Added missing linux signals (Vadim Vygonets) + 29. fixed problem where complete complete 'p/*/t:*.txt/' would not honor + the pattern. + 28. Port to an EBCDIC machine: BS2000 by Siemens Nixdorf that has an + IBM/390 compatible processor (Martin.Kraemer) + 27. Detect when we have errors writing to stdout (Vadim Vygonets) + 26. Ignore quotes in the comparisons for builtins, so that \builtin works + (Amol Deshpande). + 25. HPUX, portability fixes; make sure that we have the right config file + (Jonathan Kamens) + 24. Don't do lookups for x displays and figure out ttys properly + (Leonard N. Zubkoff) + 23. make print_by_columns print in a single column when the output is not a tty + 22. use rlim_t for Solaris2 (Casper Dik) + 21. V6.07.04 - 05/04/97 + 20. set -f -l patch (Michael Veksler) + 19. SGI patches (Tomasz J. Cholewo). Also fix completion code to take into + account aliases that start with a period. + 18. SCO patches (Boyd Lynn Gerber) + 17. Fujitsu patches (Toshiaki Nomura) + 16. autoconf patches (Kaveh Ghazi) + 15. BSDI patches (Paul Vixie) + 14. %Q formatting character addition. + 13. Fix set=#123; echo $i:s/#// (Quoting problem) + 12. V6.07.03 - 02/23/97 + 11. Understand %$variable in the prompt. + 10. Quote directory names properly in .cshdirs + 9. USE_ACCESS and autoconfig patches from (Larry Schwimmer) + 8. Pyramid att config file (Andrew Lister) + 7. $rprompt code (Luke Mewburn) + 6. Kanji patches (Huw Rogers) + 5. Cray T3E port (Jorn Amundsen) + 4. Avoid html redirects in tcsh.man2html (from Kimmo) + 3. HP/UX 10.0 fix for filesize resource limit; don't scale by 512 anymore. + 2. Workaround for TIOCSTAT for NetBSD from lukem@netbsd.org + 1. Return exit status from 0..255 not -128...127, as POSIX mandates. + +V6.07.02, 10/27/96 + 58. More configure fixes from Kaveh. + 57. Fix histdup=erase again: Don't renumber events, or access uninitialized + storage. + 56. 6.07.01 - 10/19/96 + 55. Fix histdup=erase, where after some repetitions, we would get negative + history events (kim@gw.com) + 54. NLS fixes and typo in sh.err.c (Martin.Kraemer@deejai.mch.sni.de) + 53. Output history in raw format in the history file (mveksler@VNET.IBM.COM) + 52. Fix possible core dump when !: in autoexpand mode (rbrown@ERA.COM) + 51. 6.07.00 - 10/11/96 + 50. Avoid stdio.h inclusion problem in SCO (gethost.c). + 49. A bit of housekeeping in host.defs + 48. 6.06.04 - 10/05/96 + 47. Fix tellmewhat() code to return true if found. + 46. Change register foo to register int foo to avoid compiler warnings. + 45. Fix problem with sticky non editing mode from Casper Dik. + 44. history lex fix from Martin Kraemer; history events that ended with 0 + were not properly parsed. + 43. SNI fixes from Martin Kraemer. + 42. SGI fixes from Ralf W. Grosse-Kunstleve. + 41. BSDI2.1 fixes from Paul Vixie. + 40. 6.06.03 - 09/24/96 + 39. undef TIOCGLTC for HP/UX 10.0 from Michael Shroeder + 38. Sinix fixes + 37. 6.06.02 - 06/22/96 + 36. Added implicitcd + 35. Added configure.in and Makefile.in from Kaveh. + 34. unset path, unsetenv PATH, ./foo did not work. + 33. Add VAR_NOGLOB, and use it to avoid globbing directory names when + cd'ing into them. + 32. Fix bug introduced in the new tty parsing code. + 31. Avoid pushing string back to the parsing string in ${ errors. + 30. Patches for the manual page from Dave. + 29. 6.06.01 - 05/24/96 + 28. Use sysconf to get NCARGS if available Robert Daniel Kennedy + + 27. Grab the program name and use that instead of tcsh in error messages. + 26. Fix histdup, so that it does not leave gaps in the event sequence. + 25. HP/UX v10.0 fixes: Don't use bsdtty.h and avoid clobbering memory + since SIGRT??? is defined as -1. + 24. Avoid coredumps when $TERMCAP exceeds 1024 characters + Michael Schroeder + 23. Fix memory clobbering when SHORT_STRINGS is not defined. + Todd J Derr + 22. Only restart stopped editors. Robert Webb + 21. Recognize pts sysv ptys when checking to set autologout Bob Myers + + 20. Magic space incomplete modified core dump fix. Chris Metcalf + , Bradley White + 19. Linux nls fixes Rik Faith + 18. SGI RS8000, Ported notes. Ralf W. Grosse-Kunstleve + + 17. Greek nls messages. Aggelos P. Varvitsiotis + 16. Imakefile linux and libcrypt fixes. Jonathan Kamens + 15. FreeBSD fixes Jukka Ukkonen + 14. Expand the environment space for path Steve Kelem + 13. Don't overwrite the environment randomly Steve Kelem + + 12. Don't turn the editor on when we have dumb or unknown terminals. This + breaks emacs when compiled with terminfo Jonathan Kamens + 11. Fix F- parsing in tc.bind.c (Bob Meyers) + 10. Added -T option in history to force timestamp printing. -h alone does + not print timestamps anymore for compatibility with csh. + 9. Typo in tc.bind.c [with -DOBSOLETE] (misplaced parenthesis) + 8. Recognize convex models properly. + 7. suppress the DING! option using the noding variable. + 6. negative nice values did not work. + 5. Harris CX/UX 7.x support. + 4. ERR_DMMODE was used on the crays but not defined. I changed the error + messages in tc.os.c to use ERR_STRING instead, and fixed a missing error + message in the catalogs. Someone will need to retranslate #30 and #31 + in set23. + 3. Bug setting listflags... Workaround: set listflags=(A /bin/ls) + 2. Typo in Imakefile (# comment instead of c comment) + 1. Typo in ma.setp.c (missing parenthesis) + + +V6.06.00, 05/13/95 + 88. Cleanup off-by-one error ed.defns.c. + 87. 6.05.09 - 05/06/95 + 86. Small memory leak in dosetenv() + 85. Make sure that the number of editing functions defined is correct + and abort otherwise. + 84. Completion Fixes from Tom + 83. Don't add yp stuff in the tilde cache [names that start with + or -] + 82. Don't let children catclose() in xexit(), because the parent will lose + access to the nls catalogs. From Michael. + 81. 6.05.08 - 04/29/95 + 80. Update to the newest csh sh.file.c + 79. More completions from Tom. + 78. Fix the Imakefile to use XCOMM + 77. Update for AIX 3.2. + 76. French catalog from J.M.Vansteene@frcl.bull.fr (fwd Michael Schmidt) + 75. Nls fixes and small typos from Michael + 74. PDP11 BSD type fixes. + 73. More manual page fixes. + 72. 6.05.07 - 04/19/95 + 71. More NLS catalog fixes. + 70. Bruce's jumbo patch. + 69. 6.05.06 - 03/15/95 + 68. make clean does not clobber config.h if Makefile.std is used. + make veryclean does. + 67. New config define NISPLUS. Reportedly fixes vanishing output of ~expansion + on solaris 2.4. + 66. showdots has been removed; use listflags instead. [handles -x too] + 65. more nls catalog fixes. + 64. set histchars=,. did not have any effect in .cshrc + 63. fix "-c command" new core dump. + 62. more completions from Tom + 61. call catclose() before exiting, so that svr4 cleans up the symlinks before + exiting. + 60. Per's fix for insert-last-word + 59. Per's emacs abbreviation mode. + 58. Makefile fixes for catalog stuff. + 57. fixed again complete-word-raw and list-word-raw + 56. 6.05.05 - 03/11/95 + 55. Made %?str work again + 54. IRIX sigalarm problem should be fixed + 53. complete-word-raw and list-word-raw should work + 52. nls catalogs complete reworking. + 51. sh.init.c: Signal complete rewrite. + 50. Signal fixes from Bruce. + 49. Added promptchars, like histchars; affect %# in the prompt. The first + char is for the user and the second is for root. + 48. 6.05.04 - 03/03/95 + 47. Add NODOT config, $command [that holds the command passed with -c] + $GROUP and $group + 46. AFS fixes from Larry Schwimmer + 45. Real NLS catalogs from Michael Schmidt + 44. patch to allow ^? binding. + 43. completion patch from Paul DuBois. + 42. Don't spell check in here docs. + 41. Incorrect normalization of usec in sh.time.c + 40. directory printing and option parsing fixes [from Paul DuBois] + 39. realloc_searchlen should be static to avoid conflicts with OS's that + use the same malloc package. + 38. LOGINFIRST now applies to /etc/csh.login + 37. Fixes in bind compatibility code to bindkey. + 36. 6.05.03 - 01/17/95 + 35. Don't print the whole watchlist on startup. One can use explicitly + the log builtin for that. + 34. Don't display the $watch value in the log command. + 33. Don't delete the unmatched portion if we try to complete a spelling error. + 32. Solaris 2.4 workaround for isprint('\t') lossage (From Casper) + 31. Fixed csh bug: [Reported by Jaap] + set test="one\ + two\ + three" + echo "$test:q" + 30. Fixed the lossage in setting the looking mode in tw.parse.c before + calling t_search; $x/$y will not append the right suffix. + 29. Another attempt at the gethost timeout code. + 28. Cray dmmode and filetests -m -k [need documentation!] + 27. More manual patches. + 26. Don't glob the path; security problem and core-dump. [from beto] + 25. Avoid waiting for jobs that failed to restart, thus hanging the shell. + eg, run job in background, attach to debugger; kill it inside the + debugger. Get out of the debugger and you are stuck if you fg that job. + 24. 6.05.02 - 09/04/94 + 23. remhost code could pass the wrong length to getpeername() + 22. too eager sed'ing broke convex getwarpbyvalue() to getwarpbyvarval() + 21. Fixed new bindings bug. + 20. Fixed bug in newgrp code; execv was called incorrectly. + 19. Take into account programmable completion hints when spell checking. + 18. Unconditionally change stty modes in Rawmode() + 17. Change date in $version to be ISO 8601 per Keith's suggestion + 16. Fixed portability problems in the new counted-strings codes (From Kaveh) + 15. Fixed binding problem with the new counted-strings code [all key bindings + ended up in the extended map] + 14. 6.05.01 - 07/08/94 + 13. Changed key bindings to use counted strings instead of Null terminated + strings, so that binding ^@ works. + 12. Fix parsing bug, where words that contained keywords caused incorrect + word breaks: + switch (iftagd) + case iftagd: + echo It works + breaksw + default: + echo It is broken. + endsw + 11. Fix sh.c for systems with no job control. [the new hup builtin sends + SIGCONT]. + 10. Don't add the suffix character when all completions fail, from michael + 9. Added histdup=erase, that deletes the oldest duplicate instead of + the newest. + 8. Don't call .logout recursively if we receive more than one hup, + and don't process hangups when we execute the .logout. + 7. $logout was set to a static string. + 6. Non printable binding listing was broken. + 5. Recursive sourced scripts would get mangled up because of input buffer + confusion (thanks michael) + 4. M-space should not be counted as a space. Leads to infinite loop in + word splitting. + 3. Pyramid fixes. + 2. Fixed '\' in sysv echo (from Mika) + 1. Missed fix_yp_bugs() when setting REMOTEHOST (From Casper) + + +V6.05.00, 06/19/94 +113. 6.04.17 06/18/94 +112. Realloc debug fix from John. +111. Completion fixes from Bruce. +110. Added -b option to bind. +109. Added tcsh.man2html from Dave. Looks great! +108. 6.04.16 06/06/94 +107. Allow multi word glob in "`foo`" expressions. + > if ("`ls`" == "a b c") then +106. Michaels lex() buffer patch version 2. + the previous version core-dumped with + > sleep | echo +105. Fix seg fault in find_cmd, when path is unset. +104. 6.04.15 05/28/94 +103. the previous =~ fix, was a bit broken. +102. 6.04.14 05/25/94 +101. expression parser fix for !~ and =~. + if (foo =~ *) echo ok + the * was taken for a multiply and parsed as 0 * 0 returning 0. + and asked to match "foo" with "0" +100. Michael's lex() buffer patch. + 99. Bruce's Jumbo cleanup + 98. fixed Imakefile for X11R6 + 97. fixed argument parsing in source command. + 96. added $sched to format scheduled events. + 95. 6.04.13 05/07/94 + 94. added expand-command + 93. Alpha OSF-2.0 fixes + 92. 6.04.12 04/28/94 + 91. Ignoreeof patch from Bruce. + 90. Dan's completion fix. + 89. 6.04.11 04/12/94 + 88. Don't source .logout when killed with -HUP unless we are a login shell. + [ actually $loginsh controls the behavior now ] + 87. ISC-4.0 posix exec() bug workaround + (from Jonathan Broome ) + 86. Dan's patch for complete=enhance + 85. Kaveh's patches for memset, host.defs, _{U,G}ID_T + 84. 6.04.10 03/29/94 + 83. Pathname completion bug fixes... + 82. Completion pathname(p) changes: Completion 'C' -> 'X'. + Replaced 'p' with 'F' and added D,T,C. + 81. Next NLS fixes + (From Paul Nevai ) + 80. make spelling correction obey the current histchars setting. + 79. Fix rounding in limits so that 0 is a true 0. + (From Ken Lalonde ) + 78. 6.04.09 03/12/94 + 77. Alarm race with remotehost. + 76. If you have in your .cshrc + set savehist=(100 merge) + and execute + #!./tcsh + exec ps + you get no output; [fixed] + 75. setenv SHLVL -1; tcsh = Segmentation fault [fixed] + 74. 6.04.08 02/10/94 + 73. new machtype, ostype, vendor + 72. execute .logout on hangup. + 71. more man page fixes. + 70. 6.04.07 02/04/94 + 69. Dynamic hash changes, globbing for which command from Michael. + 68. INBUFSIZE fixes for history. + 67. printenv returns 1 when a variable is not found, like the non builtin one + 66. Add quotes to the mismatch array so that: + > touch foo + > mail "oo bar" + does not get corrected. The right fix would be to do correct parsing + and quote the space... + 65. NULL terminate mismatch[] array in ed.inputl.c, since it is used in + Strchr(). + 64. renamed stat to filetest + 63. Afs and Hesiod patches. + 62. More manual page patches. + 61. 6.04.06 12/19/93 + 60. Alarm for resolver timeouts (untested) + 59. Fixes for Henry Spenser's regex in the Makefiles + 58. Modifiers now work with $< and $< does not do :q by default. + [incompatibility with csh] and $< can be interrupted. + 57. Added $histdup. + 56. source /etc/.login for Solaris 2.x + 55. don't remove trailing spaces in history searches. + 54. dirs -L and dirs -S spurious warning elimination. + 53. man page fixes from David. + 52. Kimmo's patch [makefile, gcc warning, netdb.h include] + 51. 6.04.05 12/12/93 + 50. rewrote srcunit() to use st_save and st_restore. The code was + too messy to be useful before. + 49. recdirs and rechist patches again! + 48. Harris hck port, and ISC imake update + 47. Eliminate the x windows :display.screen before looking for the + hostname in REMOTEHOST + 46. Patch for CDF filetype() recognition (hpux) + 45. 6.04.04 11/12/93 + 44. Made =x obey nonomatch. + 43. Fixed rechist and recdirs not to depend on savehist and savedirs + 42. Removed aliases, bind, linedit builtins [ifdef'ed out as OBSOLETE] + 41. change REMHOST to REMOTEHOST for compatibility with SGI. + 40. $owd was not working correctly. + 39. Debugging printf elimination (from Kimmo) + 38. Typos in the new hup code in sh.c (from Matt) + 37. Imakefile fix for sequent (from Jaap) + 36. 6.04.03, 10/30/93 + 35. New manual page in place. + 34. Fixed Makefile sed RE to work with gnu sed. + 33. Added hup builtin. + 32. Added $REMHOST in config_f.h + 31. Fixed random parsing bug in sh.exp.c in isa(). It checked cp[1] + without checking cp[0] first... (should propagate to 4.4BSD) + 30. More sh.exp.c fixes from Bruce + 29. Always exit when the user types exit. + cat | tcsh -f -s + exit + ls + 28. savedirs fix and readlink() null termination fix from Peter. + 27. Added -p flag (force dirs printing in all directory functions and $owd + variable + 26. Let $dirstack work by default without needing to be set. + 25. Fixed history -h to work with other history flags. + 24. Renamed ed-functions more consistently (dcs) + 23. Added missing filetests (dcs) + 22. Added NEWGRP define in config_f.h (dcs) + 21. More fixes for non blocking io recovery from Bruce + 20. 6.04.02, 10/08/93 + 19. changed default prompt to %# + 18. New group 'g' completion. + 17. removed IIASA defs. + 16. fix for history -SL and dirs -SL to work when savedirs and savehist are + not set. + 15. fix magic-space to understand :p + 14. make :u,:l work for history. + 13. Fixes for non-blocking i/o recovery. trap all non blocking styles under + sunos. + 12. 6.04.01, 08/10/93 + 11. Vi mode word moves [they work like vi and don't obey wordchars anymore]. + 10. New file operators and stat builtin + 9. David's FIONREAD patch for SVR4 + 8. Bruce's ignoreeof=n patch + 7. Dan's complete/correct enhancement + 6. Abort corrections patch. + 5. Print_by_columns, now does not use the rightmost column. + 4. Renamed config/config.$i to $i to avoid once and for all filename length + problems. + 3. bbn butterfly config + 2. Beto's proc fixes + 1. Bruce's bug fix for ed.chared.c, signals + + +V6.04.00, 07/03/93 + 92. Alpha prototypes, for gcc -Wall clean compile. + 91. Fixed alpha hashing. Did not work for directories > 31, Thanks to + Dan Mosedale for all the help! + 90. Added USE(a) for unused parameters, to avoid compiler warnings. + 89. 6.03.10, 06/25/93 + 88. Makefile and lint patches from Bruce. + 87. Posixsig patch from Peter for svr4 + 86. 6.03.09, 06/11/93 + 85. signal handling broke with the last job control patch... + > (does-not-compute;) + would hang. + 84. don't quit after the first modifier fails: + > set i=aabbcc + > echo $i:s/a/A/:s/b/B/ + AaBbcc + > echo $i:s/x/A/:s/b/B/ + aabbcc + 83. Imakefile fixes for sequents from Jaap. + 82. Move past the bottom of input when we hit ^C, so that multi-line + input commands don't get trashed. + 81. Look only at the first word in ${EDITOR,VISUAL} to determine the + editor name. + 80. Last patch broke listmax. + 79. Remove extra sandbagging in exitstat(). Not needed anymore as value() + will never return NULL. + 78. Save $status before calling aliasrun() otherwise: + > alias precmd 'cd .' + > true + > echo $status + 0 + > false + > echo $status + 0 + 77. 6.03.08, 06/07/93 + 76. missing prototypes/unused variables under SYSV4. + 75. savedirs should glob the filename argument. + 74. 6.03.07, 06/05/93 + 73. Changed _Q, _Q1 macros in sh.lex.c, sh.dol.c, sh.char.? to _QF and _QB + because today 4.4BSD defined _Q to be ``Phonetics'' + 72. listmaxrows variable. + 71. set -r would not make existing variables readonly. + 70. print usernames with ~user where possible in dirs and job cwd's + 69. Mika's fixes (missing args in sh.c set(), linux Makefile, SIGCHLD) + 68. FIONREAD argument is int everywhere except on SunOS where it is long. + Tcsh used to think that it was long, and so it broke on the alpha where + sizeof(int) != sizeof(long) + 67. 6.03.06 05/16/93 + 66. Pipeline fixes. This should get rid of the dreaded Stopped tty output + message. + 65. Michael's fix for history buffer cleanup: + > alias foo 'echo \!:1:h' + > foo a/b + a + > ^P [nothing happens] + 64. Unsigned long rlimit type for 64 bit machines (alpha) + 63. Fixed Imakefile for alpha + 62. tilde expansion now obeys $nonomatch + 61. readonly veriables. 'set -r x=3' will set x to a very sticky 3... + 60. Fixed bug in the new tab'ed completion that interfered with old listing. + 59. Fixed entry -> item in tw.parse.c + 58. Added -f option to unlimit + 57. Define __STDC__ in Imakefile for Irix + 56. Static redeclarations in tw.parse.c + 55. 6.03.05 04/26/93 + 54. Don't echo history expansion in loops: + > alias junk 'foreach i (\!:2*) \ + foreach? echo \!:1 $i; \ + foreach? end' + > junk a b c d + echo a $i ; + a b + echo a $i ; + a c + echo a $i ; + a d + 53. Added complete-word-fwd and complete-word-back that scroll through + the list of possible completions... Neat addition from + jfink@csugrad.cs.vt.edu (Jeff "$DOTDIR" Fink) + 52. Workaround hpux9.01 broken optimizer in sh.glob.c where 'ls *' breaks. + 51. Michael's editor fix. With "magic margins" and 80 char width, try: + > set prompt= + 20aa76bac + 50. Reverted fix that does not glob the expanded back-quote text again. + 49. > cd /., echo $cwd + /. + Eliminate the . in this case... + 48. Matt's optimization in glob.c [retracted] + 47. Fixed bug with -S + 46. Renamed Makefile Makefile.std, and fixed the readme file + 45. 6.03.04 04/07/93 + 44. Changed -s == !-z and -S == socket + 43. Fixed typo in sh.c, in phup [shpgrp != pr->pgrp] + 42. Multi-line aliases are not entered into the history when executed. + 41. Changed f_seek to a union to avoid gcc warnings on 4.4BSD + 40. Fixed 'unset home; dirs' bug + 39. fixed $HOME->$home memory problem. + 38. $?0 returns false now on interactive shells for csh compatibility. + 37. Default watch inteval was 10 hours not 10 minutes as advertized in the + manual! + 36. Fixed clobbered veriable warning from gcc-1.39 in tw.parse.c + 35. Fixed typo with INVPTR in sh.lex.c + 34. 6.03.03 03/04/93 + 33. Eliminate 'Reset tty pgrp error message'. It is normal for the + walking process group stuff. Check about the killpg() above? + 32. More portability for 64 bit machines. + 31. Improved completion error messages. + 30. Fix bug with double globbing expansion on mirrored variables: + > setenv TERM '?vt100' + 29. Avoid hanging when writing to pipes etc. (From Paul Close) + 28. Typo in the $HOME->$home mirroring. + 27. %p %P 'p'recise time formats that include seconds for prompt strings. + 26. Signal list fixes from Paul Close. nsig is now a variable. + 25. 6.03.02 02/12/93 + 24. NEC SX3 "entry" is a reserved word!, changed entry to item... + [this is as bad as cray typedefining "word" to int. Next thing I know, + I'll have to prefix all the variables with tcsh_!] + 23. xxx + 22. Protected all include files to avoid warnings from lcc. + 21. Finally resolved the job control problems with linux and ISC (from Beto) + 20. More HUP,XFSZ,XCPU fixes. (with Beto) + 19. Dcanon would not canonicalize correctly in case where dnormalize() + failed to find a directory, but the directory existed when not + crossing the symbolic link. + 18. sh.init.c fixes; give 65 signals for all POSIX machines. + 17. AMS mail fixes and cmu wm handling. + 16. Setenv would not ignore trim quoted names... + > alias foo 'setenv "\!:1" bar' + > setenv FOO 123 + > foo FOO + > printenv + ... + FOO=123 + FOO=bar + ... + 15. 6.03.01 08/01/93 + 14. #undef SHORT_STRINGS gcc warning fixes... + 13. csh bug fix in foreach [quoteing problem] + > foreach i ("*") + > echo $i:q + > end + Should print * + 12. ls-F obeys showdots... + 11. After scheduled commands get executed, the editor could stay disabled + until the first enter. + 10. sigset() bug in ed.init.c; ^C could get disabled sometimes. + 9. Don't glob in dowhich(); otherwise \pat does not work if pat is aliased. + 8. When completion patterns are used $ and ~ expansion did not work right. + 7. Printenv builtin and long backquote expansion fix from Harald. + 6. $:-1, $:-0 enhancement from Paul and Michael. + 5. Lynx/OS patches + 4. Apollo bugs [Setenv -> tsetenv, typedef in pid_t] + 3. ^@ did not work correctly in bindkey. + 2. Fix vms/posix ifdefs in tc.alloc.c + 1. Elide gcc-2.3.1 warnings + + +V6.03.00, 11/20/92 +102. Solaris2 patches, renamed sunosX to sosX to fit in 14 character filenames. +101. 6.02.12 11/12/92 +100. Decreased BUFSIZE to 1K... +99. Don't use sbrk() in tc.alloc.c on VMS +98. EINTR error handling from Michael +97. Overwrite mode takes effect immediately, not delayed by a command. +96. Emx fixes. +95. SIGHUP gain... +94. Coherent times()/ fixes. +93. 6.02.11 10/27/92 +92. Mach setpath fixes. +91. Which now globs its arguments +90. Again POSIX SIGHUP fixes... Maybe we got it right this time... +89. Increased BUFSIZE to 4K. Smaller machines may want to decrease this. + [ Now one can edit up to 4K of buffer! ]. From Harald. +88. : is now a true builtin that does nothing, instead of being treated like + the last character of a label. This is so it can take args. From Harald. +87. More fixes for hpux limits from Harald. +86. Login shell if ppid == 1 and argc == 1 for VMS. +85. Typo in sh.exec.c from Harry. +84. Per's editor fixes. +83. 6.02.10 10/17/92 +82. Don't free STRNULL in freelex(). Update linked list in copylex() to + do the same insert as in lex(). +81. Fixed spurious tilde printing in %c prompt. +80. Fixed dumb wild free in AddXKey... + (thanks Harald for the complex bindings! :-) + > bindkey "\e10z" expand-line # Any editor command will do + > bindkey -[cs] "\e10z" "foo" # Any string or command will do + Free(%x) .... +79. coherent additions. +78. fixes for hpux8 resource limits [Thanks Harald] +77. 6.02.09 10/10/92 +76. More vms cleanups. +75. Removed #include CONFIGH from sh.h. There was no way to make it work + under VMS/POSIX +74. Added t completion (Gray Watson) +73. Memory leaks in sh.dir.c and sh.glob.c [thanks purify :-)] +72. IRIX 5.0 patches (from Paul Close) +71. BSD resource limits for hpux8.0 (From Andreas Stolcke) +70. NGROUPS_MAX fixes (from Matt Day) +69. 6.02.08 10/04/92 +68. VMS port additions. +67. Added $%var, which == strlen(var) +66. Added ^X^I and ^X^D to override programmable listing+completion +65. Added case insensitive globbing for OS/2 +64. FIOCLEX and FIONCLEX are only used if we don't have FD_CLOEXEC. +63. Added emx termio support, and emx pathsep support; emx compiles and runs: + needs job-debugging and finishing touches. +62. Horrible bug with the lex linked list; from Loic Grenie, grenie@ens.fr + > echo a !# + echoed 'echo a echo a echo'! +61. Shell -w,-x were incompatible with the same for test [POSIX] (beto) +60. builtin newgrp did not accept the - argument. +59. FIOCLEX for the masses (POSIX FD_CLOEXEC addition) +58. Old style csh completion bug fix [not used] (beto) +57. A background process waiting for input from tty + blocks when being foregrounded doesn't read its input and + doesn't get and signals. + It can only be killed from another session. (beto) + > cat > foo + #!/bin/csh -f + echo ">>>>>>" + set x = $< + echo $x + ^D + > chmod +x foo + > foo & + > fg + ^Z,^C # Nothing happens +56. history > 1000 fix (beto) +55. 6.02.07 9/18/92 +54. Added e_stuff_char() to put back a character in cooked mode in + the input stream... Useful for status (^T) +53. $? == $status and $# == $#argv like in the bourne shell. +52. Added $dirstack. Problems: off by one since =0 == $cwd, but + $dirstack[1] == $cwd... Suggestions welcome. +51. Leading spaces would confuse the run-help function. +50. Don't expand imported environment variables: + > setenv HOME \* + > tcsh + > echo "$home" + > echo "$HOME" +49. %C0n displays the number of directories omitted as /usr/local/bin /<2>bin/ +48. Added POSIXSIGS as a configuration option. +47. Per's fixes for history format and arrow key binding. +46. Expand-variables expands array variables too +45. 6.02.06 8/14/92 +44. Separated limit stuff from BSDTIMES and added BSDLIMIT +43. History searching inconsistent with HistLit: + > echo foo + foo + > ^foo^bar + bar + > ec[M-p] + echo foo +42. 6.02.05 8/8/92 +41. sourcing a script that contains 'onintr -; onintr' would disable + interrupts on the command line +40. cd ../... with symlinks=ignore would work !@#!@ +39. No more BACKPIPE for POSIX machines... +38. SUNOS NLS bug workarounds... +37. New HASHBANG define for #! emulation... even 386BSD does not have it + yet... +36. Added new -b -c file operators from SGI csh. +35. 6.02.04 7/23/92 +34. Walking process group fixes. +33. $0 contains now argv[0] when we are not executing a shell script. +32. New Getwd() was broken. +31. 6.02.03 7/17/92 +30. We kill our last foreground process group on HUP, for POSIX systems. +29. Walking process group fix. +28. $shlvl gets reset to 1 for login shells. +27. Macros can now involve multiple commands, i.e. + bindkey -s "^[OP" "ls\n^P" +26. 6.02.02 7/6/92 +25. nostat accepts now a list shell patterns. +24. Avoid print_exit_value in if ( { foo } ) +23. Symbolic key names for bindkey [arrow keys]. +22. Smarter getwd() that avoids some of the NFS hangs... +21. Use memmove() where possible. +20. 6.02.01 6/16/92 +19. Fix automatic correction to work with the new completion. +18. Globbing bug with brace expansion, when arguments need to be realloced... + e.g. echo 134{6,7}{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9} +17. shift and left operators update variables correcly ('shift path' did not + work) +16. apollo fixes for cd. +15. STRNULL <-> NULL bug fixes. +14. %S in xprintf for short strings. +13. history -LSc, dirs -LSc additions, builtins builtin [oxymoron] +12. history formatting string, who formatting string, prompt formatting + all use tprintf() now. +11. $history accepts a second formatting argument.. +10. History timestamps preserved in .history +9. Backquotes were broken: echo hi | cat > `echo foo` +8. SGI -t operator problem. +7. Dnix fixes. +6. Fix history file writing bug when autologout. +5. Change from TCSETA to TCSETAW, since we affect the output. +4. Per's fixes for display margin bugs. +3. Linux fixes. +2. Collapse adjacent stars in glob.c to avoid exponential behavior. +1. Fixed parseescape to put ^ literally if not followed by alpha. + + +V6.02.00, 5/15/92 +94. Default echo_style was not being set correctly. +93. $< did not work correctly with NLS chars. +92. 6.01.15 (5/11/92) +91. Minor cleanups in refresh code. +90. 6.01.14 (5/8/92) +89. Print \n in the right margin always to be consistent. +88. Linux patches. +87. 6.01.13 (5/2/92) +86. Fixes in listing and completion of non-unique commands. +85. Fix =stack entries > 9... from Bill Petro +84. Fix for last character at margin. [on terminals that have am & xm move + the cursor manually to the next line] +83. Fix for complete completions +82. small typo in tc.alloc.c from Mark Moraes. +81. small typo in tw.parse.c from Richard. +80. Man page fixes from Per. +79. 6.01.12 (4/24/92) [release version for 6.02] +78. Autosuffix was not getting reset all the time. +77. Don't limit completion patterns to 1K. +76. Naming changes in ed.screen.c from Justin. +75. 6.01.11 (4/10/92) +74. Fixed magic-space ! expand bug: + > echo a b123 45.{6,7} + > echo !:2!:3[magic-space] +73. Work-around for apollo optimizer in tc.bind.c +72. Problem with setjmp in tw.parse.c +71. symlinks=expand from Yumin. +70. tenematch() fixes from Michael; +69. 6.01.10 (4/3/92) +68. Fixed Gnmatch. +67. Removed ignore_symlinks and chase_symlinks. Replaced by symlinks variable. +66. Backquote from completion was broken for machines with no dup2() +65. No $printexitvalue for `` jobs. +64. Added ultrix stuff for PW_AUTH [from Mike Potter mpotter@lampf.lanl.gov] +63. Fixed bug in Gnmatch(), added 'N' command 'x' completion. +62. Fixed fg_proc_entry() so autologout gets disabled when a process + is foregrounded. +61. 6.01.09 (3/26/92) +60. source builtin takes arguments now that are passed in the script e.g.: + > ./tcsh -i a b c + > cat test + echo $argv + > echo $argv + a b c + > source test 1 2 3 + 1 2 3 + > echo $argv + a b c +59. Eliminate $margin_bug, add more intelligent margin code [from Justin] +58. expand_symlinks variable Urgh... +57. SGI CONTROL() fixes... +56. new dnormalize(), expand_symlinks flag. +55. interrupting completion restores the current line. [from Marc] +54. 6.01.08 (3/20/92) +53. inputmode affects the first line too. +52. Searches in vi do not destroy the current line. +51. -drwX test enhancement. +50. Generalized completion syntax and added more completion builtins. +49. Don't print '\n' on the right margin if we can avoid it. +48. 6.01.07 (3/9/92) +47. New completion style. [[[ ]],=] +46. 6.01.06 (3/7/92) +45. complete styles are ignored after shell metachars eg. + > complete mail =u + > mail christos < [tab] + completes filenames. +44. $echo_style is initialized to the default style of the machine. +43. SGI 4.0 CTRL() macro is busted. So we ignore it. +42. Fixed bug with the new margin code (thanks justin) +41. Fixed mirroring of variables. Now set and setenv affect + HOME, TERM, PATH, SHLVL, USER and their csh counterparts. Unset affects + affects only the csh copies of the variables, and unsetenv only the + environment variables. +40. Fixed gcc-2.0 warnings in sh.sem.c (needed for vfork() -O2 optimization) +39. 6.01.05 (2/21/92) +38. signal masking for BSD machines was still wrong in tw.init.c +37. Added $margin_bug, and now the editor outputs on the rightmost + column by default. This should fix the xterm cut-n-paste problem. +36. AU/X 2.0 and SGI compiles with POSIX as a default now. +35. sysv_echo is gone too. Now we have a variable called echo_style + which can be set to "none", "bsd", "sysv", "both" that defines + the builtin echo_style. The default is "bsd" for systems with + SYSVREL == 0, "sysv" otherwise. This can be overriden in config.h + by defining ECHO_STYLE ro be BSD_ECHO, SYSV_ECHO, BOTH_ECHO, + or NONE_ECHO. +34. asynchronous notification in run-fg-editor would try to change the + tty settings and print an extra prompt. + > set notify + > sleep 10 & + > vi^Z + > ^[^Z +33. alias x /bin/true + x? + reported .//bin/true instead of /bin/true +32. 6.01.04 (2/12/92) +31. fixed vi_substitute_line +30. binding completion addition. +29. showdots=-A addition +28. sysv_echo addition; deleted bsd_echo which is now the default. +27. dunique could crash. +26. Don't clear lines after an asynchronous notification, because it + might erase the message. +25. 6.01.03 (1/29/92) +24. `` were not working correctly when tcsh is started with 0,1,2 closed. +23. Correction was picking up the wrong thing in cases like .rhosts hosts +22. Correction with names with quoted spaces was broken. +21. Added sysv_echo and bsd_echo. +20. Added and documented the complete builtin. +19. Added dunique and cd -. +18. Per's fix for alarm functions. Things would break if time went backwards. +17. Realloc bug fix (copy min of old and new size) +16. Fix for csh compatible braces. +15. Brace globbing and negation globbing for Gmatch. +14. 6.01.02 (1/16/92) +13. Completion builtin, new tw* files. +12. 6.01.01 (1/6/92) +11. Changed w_ fields in tc.who.c to who_ to avoid redefinitions in + in some os's. +10. Setting savehist to an empty string makes savehist use the value + in $history. +9. echotc did not use the internal termcap descriptions. +8. echotc did not work right for single argument termcap strings. +7. DGUX needs SAVESIGVEC, updated type protection, and disabled CSWTCH. +6. Changed SVID to SYSVREL, since there is no SVID == 4 (yet). +5. Typo in tc.sig.h: UNRELSIGS was not getting defined. +4. Globbing bug fix. tglob() should ignore globbing characters inside + backquotes otherwise things get expanded twice: + % echo 'bar?' > 'foo?' + % echo `cat foo\?` + echo: No match. +3. Mach setpath fix. +2. Alliant process group fix. +1. Xenix fixes for broken vi and help path with no suffixes. + + +V6.01.00, 12/19/91 [for comp.sources.unix] +22. Restore the original prompt in automatic correction when the user + asks to re-edit the command. +21. Better error for unreadable files in tw.parse.c +20. Sequent patches. +19. (V6.00.08 beta 12/14/91) +18. Filenames containing # were spelled/expanded incorrectly. +17. Stellar/stellix port. +16. Hpux 8.0 has SIGWINDOW but we cannot get the window size. Protect + against window changes updating $LINES and $COLUMNS. +15. Mach setpath did not work right. +14. Mach does not need setenv in lib; in fact that does not work right. +13. shell level gets decremented when we exec. +12. restart_fg_editor picked the wrong editor if arg contained a slash. + e.g vi ~/.cshrc +11. (V6.00.07 beta 12/08/91) +10. Allow use of vfork() on systems that do not have job control. +9. Avoid NUMCC from being defined twice. +8. (V6.00.06 beta 12/05/91) +7. SunOS3's FIOCLEX dups... +6. Yet another globbing bug fix from Michael (echo .[^.]) +5. Ultrix now wants __ before cpp symbols. +4. Workaround sun's header files inconsistency so tcsh can be compiled + with #undef POSIX +3. Fixed limit stuff so that large values don't cause errors. +2. Fixed =1 and ~user error messages (Per) +1. (beta-5 6.00.04 == 6.00.05) + +$#* +$#* New numbering scheme (The last 2 digits are reserved for beta releases +$#* from now on. So we start at 6.00.06 which is 6.00.04 beta 6, and we are +$#* going to release 6.01.00... +$#* + +V6.00.04, (never released) +34. (beta-5 11/25/91) +33. Simplify code in BindArrowKeys() +32. Get rid of the PNULL's +31. Support for shadow password in locking code. (From Kimmo) +30. Normalize-path editor function. +29. (beta-4 11/21/91) +28. minix additions +27. bindkey fixes (-c addition, casting cleanups) +26. (beta-3 11/16/91) +25. Prompt length checking. +24. Michael's fixes for the watching code. Tcsh could core dump when using + a corrupted utmp. +23. overwrite mode flag, and autologout locking code. +22. overwrite mode would still insert digits! +21. Get the value of _POSIX_VDISABLE from pathconf... +20. Hpux 8.0 fixes. Sigstack botches with shared libraries. Ansi mode + static initialization of structures with prototyped function pointers + gives spurious warnings... +19. Onintr in /etc rc files is disabled. +18. (beta-2 11/03/91) +17. Multi-line aliases with `` bug fix. +16. Sticky emacs overwrite mode. +15. Autolist option. +14. Fix for redirection with wildcard filanames. +13. No error correction for multi-line commands. +12. Esix-4 re-defines p_pid. Argh... +11. (beta-1 10/28/91) +10. Foreach loops were broken again. +9. SUNOS localtime() bug does not only happen on the 8th byte. [Michael] +8. sh.dir.c, memory corruption in dinit(). Thanks Michael. +7. uts broken work-around, and has a wait3() +6. SGI (-t filename) extension, returns true when filename is a tty. +5. 'default:' addition in all switch() statements. +4. oflag was not being updated correctly in Rawmode() +3. missing 'break;' in prompt code '%y'. +2. infinite loop in :a code. +1. hashstat was not reporting hits+misses + + +V6.00.03, 10/21/91 +31. watch code now accepts shell patterns. +30. new hashing code portability fixes. +29. $foo:gs/:/ / fix and 'a' modifier addition. +28. Added $! (the pid of the last background job forked) +27. exec does not kill the shell when it fails. +26. Irix4.0 decls. +25. SVR4 uthost fixes from Kimmo Suominen +24. Imake addition from marc +23. New i-search from Per. +22. ibmesa fixes +21. convex fixes. +20. t command for vi. +19. SVR4 fixes (reverse pipeline and sigaction()) from David Dawes. +18. New hashing from Marc +17. Added : to the ~name separators so ~foo:~bar works. +16. New ed.init.c. Added ed.term.c +15. Still can't get the history exactly csh-like... !-2$ was broken... +14. vi character searches. +13. -Dvar=name command line option for the apollos. +12. Prompt format changes for date/directory. +11. Vi searches. +10. Emacs i-search. [currently not bound] +9. Vi additions ([dc]-{w,$,f},Undo) +8. tcsh -n parses now builtin structures. +7. seek to the end on errors in loops. +6. echotc -s was broken +5. Better !event parsing. !foo;!bar was broken. +4. foreach loops and if statements in aliases. +3. .cshdirs would corrupt the heap if some directories were not there. +2. System V echo was broken with \ +1. Fixed echo '!-1', history would eat the quote. + +V6.00.02, 08/05/91 [For comp.sources.unix] +8. tcsh will always set $LOGNAME and $USER if not already set in the + environment. +7. added $histfile. +6. echo `echo` * and echo ~ {} were broken +5. setty builtin addition +4. Multiple : modifiers [experimental, disabled with -DCOMPAT] +3. 7 bit fixes, and hp9000s500. +2. #undef DEBUG in tc.alloc.c, so we continue if we get a bad free() +1. getn() is now protected against NULL strings. + +V6.00.01, 07/16/91 +17. added beepcmd, and fixed small tenematch bugs. +16. Renamed DUP2 flag to HAVEDUP2 cause AIXPS2 defines DUP2 already. +15. More ANSI fixes, and mit additions (load-average) +14. don't clear ECHOE, background programs might need it. +13. Refresh bug fix... +12. getpwent() should not be interrupted (yellow pages), cause it might + leave dangling pointers, that endpwent() will trash. +11. ChangeSize is now responsible to set the screen size to something + sane, but it should not affect the environment if the information + it received is not valid +10. Find out if we are running under emacs using $TERM. It is more + reliable. +9. tcsh was broken if SHORT_STRINGS was not defined (glob() problem) +8. If GetSize() fails it should always return reasonable screen sizes. +7. globbing should not fail if one or more patterns match. +6. increased the number of aliases in the loop detection code. +5. DGUX has size_t and pid_t defined now... +4. ESIX does not have EWOULDBLOCK or EAGAIN & POSIX... That was not handled + correctly. +3. rs6000 needs BSDWAIT. +2. Hpux susp key could not be changed. +1. Apollo fixes. + +V6.00.00, 07/04/91 +45. Fixed quoting of VSTART/VSTOP on termios +44. Memory leak every time you pipe in or out. +43. echo {foo bar.[ch]}. Did not check for end of word. +42. ANSI prototypes +41. dmove() would leave the source descriptor open when using dup2() + e.g. + while (1) + echo foo >>! bar + end + runs out of file descriptors +40. recursive `` expanded via aliases would abort. +39. set home=../relative-path-name was broken. + e.g. + set home=../..; cd ..; + +38. Incorrect error when changing to directory: + e.g. + mkdir not-in-cd-path; chmod -x not-in-cd-path; cd not-in-cd-path; + echoed: + not-in-cd-path: No such file or directory. + it should have said + not-in-cd-path: Permission denied. +37. if ( \! =~ [\!] ) echo ok, did not echo ok. Quoting inside [] pattern. +36. More than 127 jobs caused job # to go negative +35. unsetenv ... Added support for more than one pattern. +34. More background process status report fixes. +33. Apollo builtin support. +32. Glob fix. echo '*' * was not handled properly. +31. Glob fix. setenv FOO `sleep 1` would either cause a segmentation fault. + or print ambiguous. +30. Glob fix. Quoted characters inside [] were not handled properly. +29. Removed TELL and VMUNIX defines. I think we cannot compile on V6 anyway +28. Overflow check for expansions. +27. Added matchbeep, shell pattern history searching. +26. Added code to handle /dev/std{in,out,err} +25. Fixed POSIX speed handling in raw mode. +24. Fixed a flushing bug in the filec code in sh.file.c +23. Compiled and added hp9000s700 to the list of hosts. +22. Fixed horrible bug in gmatch() + switch (4) + case [a-z]: + echo bug; + breaksw; + case 4: + echo ok; + breaksw; + endsw +21. Fixes for _SEQUENT_ ut_host. +20. FLUSHO added +19. mkdir foo\`bar; cd foo\`bar; was broken +18. EWOULDBLOCK == EAGAIN on RENO check for that too. +17. Dword() simplified and removed the gotos. +16. Hpux now compiles with POSIX. Moved the local chars modes in ed.init.c + after the tty modes. +15. Process group fixes for POSIX +14. We need on the suns for FIOCLEX!!! We did not close + our file descriptors before... +13. A/UX fixes. +12. History events that start with a number are not necessarily numeric: + > !3d + 3d: Event not fount +11. History loop detection added. + > alias a \!# + > b; a +10. Alias loop detection code was ineffective on eager optimizers. + 9. All errors should now go through our table. Next step we should + add nls error messages. + 8. Unsetenv now globs its arguments! Before it did not... + 7. Added tilde cache and -l flag. + 6. Added autocorrect + 5. Fixed for so that background jobs in scripts get process groups + 4. Fixed amazing memory leak in setenv()... + 3. Added short2qstr() so that we can form quoted strings to be used with glob() + 2. str2short and short2str allocate space dynamically. + 1. Fixed bug related to the is*() routines called with shorts. + [only if NLS and SHORT_STRINGS are defined]. + (The _ctype_ was getting indexed with shorts...) + 0. Complete overhaul. Brought in the 4.4 csh stuff. Separated most + tcsh and csh code except where I would have to add more global + variables. Compiled correctly with both lint and gcc -Wall on + a sparc running 4.1 + +V5.20.03, 03/20/91. - Never released +25. Kanji, SXA additions. +24. (exec foo) should not fail if they are suspended jobs. +23. Support kernel paging stuff on aix 370. +22. Now we handle correctly the environment variables LINES, COLUMNS, + TERMCAP for window size changes... +21. Tcsh 5.18c+ had broken NULL chars on scripts. + > cat > foo + #!/usr/local/bin/tcsh -f + echo "foo" + echo "^V^@" + echo "bar" + ^D + > chmod +x foo; foo + foo +20. Posix has EAGAIN and not EWOULDBLOCK +19. Don't set ECHOK; makes kill ^U ugly. +18. $shell is SHELLPATH and not $SHELL any more. +17. Added -n flag to cd, pushd, popd and dirs. Documented -l and -v + flags. +16. Documented and fixed chase_symlinks and ignore_symlinks. +15. Call endpwent() when you get interrupted... + cd ~chri^C + cd ~christos/ + +14. Exec when you have suspended jobs asks for verification. +13. Variable length fixes: + >set abcdefghijklmnopqrstuvwxyz=1 + >echo $abcdefghijklmnopqrstuvwxyz + abcdefghijklmnopqrs: Undefined variable + Now we have better messages too... +12. Icon fixes... +11. Quote expanded glob and history chars too. +10. If someone sets SHIN to O_NDELAY we died... Now we set it back... + 9. unset path; unsetenv PATH; ls-F; (poof) fixed... + 8. Patches for masscomp, and ${var123} lexical analysis fix... + 7. Patch for sunview bug: A partially covered suntool sends SIGWINCH every + time the text is scrolled, causing annoying redraw effects. Now tcsh + checks if the size really changed before doing anything. + 6. Interrupt in the middle of cwdcmd, and periodic does not remove the + aliases. + 5. prompt2 and prompt3 fixes: + Prompt2 now prints the status of the parser by default. + Prompt3 can now have the standard prompt escape sequences. + 4. eval file descriptor re-direction fix. + >set p='w | tail +3' + >eval $p + (originally | tail +3 was ignored) + 3. $edit != emacs anymore; it was misleading, 'set edit' enables editing + 'unset edit' disables it. + 2. PERROR define fix. + 1. irix3.3.1 line discipline fix. + +V5.20.02, 12/15/90. +32. /etc/Logout added and merged with /etc/Login flag. +31. Fixed tty chars in ed.init.c. Some of them were not handled correctly. +30. Command execution does not leak memory any more, and doing + ~ four times does not core-dump. +29. Fixed the notorious csh 'if(' bug (part of the convex fixes) +28. Intelligent getwd() on startup, and canonicalization. +27. Intelligent directory stack. Gets updated when $HOME changes. +26. Directory stack/save-restore additions +25. Convex Fixes. +24. Fixed onlret, and echonl getting stuck on svid. +23. Shouldn't leave tty in raw mode at auto-logout (e.g. when su'ing from a + csh, this is annoying). +22. Some users had environment EMACS set to something, and with my bad fix + at pl 1 found that they didn't have echo... (of course, even before my + "fix", they didn't have editing...). Anyway, refined the check to be + for EMACS=t, which is what emacs sets when running a subshell. +21. kill -CONT %job, would not update the status of the job, but it would + just restart it. +20. Sequent fixes. +19. AIX370 signal and TCF fixes. +18. fixed ls-F -l, SIGINT problem. +17. aix on the ps2 does not have strcoll() either. +16. Bind [A - [D and OA to OD in vi mode to the arrow key functions + so that they work from insert mode. +15. %~ was not working correctly for /home/news and /home/newsbin... +14. Removed Rcs Log +13. ISC unix fixes. +12. sunos3.x wants not +11. Remove precmd's, cwdcmd's and periodic cmds that had errors. +10. Compile sunos4.1 using termio. + 9. Rs6000 line discipline fixes. + 8. T_Tabs was wrong for termio machines. + 7. Don't bind single keystroke arrow keys, when they are already bound! + 6. Test for newline and tab before deciding not to send shell scripts + to the bourne shell. + 5. Added LITERAL prompt stuff. + 4. Fixed gethostname() in sh.rest.c to return the nodename. + 3. Do not quote spell checked stuff. This is not very intelligent but + works better than before. + 2. Fixes for relative path components. (paths that start with a .) + 1. Fixed so that Rawmode() is not called when we are not editing + (breaks running under emacs) + +V5.20.01, 11/15/90. +12. Recognize environment variables too. +11. Always start in Rawmode() +10. don't try to execute binary files using the bourne shell. + 9. Vi change to end of line updates correctly now. + 8. Prompt in continuation lines. + 7. Prompt in if statements fix. + 6. System V ^C works right now. + 5. ^Z works correctly in bindings + 4. Better error messages for variables. + 3. dinit() now is more robust. + 2. Added aux2.0 patches. + 1. Fixed bug with arrow key bindings in ed.screen.c. All the keys + were bound to up-history! + +V5.20.00, 11/10/90. +26. Fixed system V and POSIX time reporting. +25. Fixed ed.screen.c so that it does not use malloc(). +24. Fixed SIGWINCH on the iris +23. Fixed ed.screen.c, so that settc works correcly. It used to set + the termcap with a string that was allocated from the stack! +22. Fixed listing of commands, where the last command was not checked. +21. Fixed which command. It did not work for + \, if command was aliased. +20. Eliminated CSH4.3 define. You've had enough time to upgrade from 4.2 +19. Fixed GotTermCaps to be called only once. +18. Added bindkey -r +17. Attributes were not getting reset correctly. +16. history -t does not print the time-stamp. +15. AddXkey, works now for single character xkeys. +14. filetype() knows better about symlinks. +13. ls-F works with filenames that have metachars +12. Completion/spelling works with quoted things. +11. Fixed refresh bug. Repeat by: + On an intelligent terminal that has insert and delete chars (xterm) + > orphan + > vi orphan.c + > ^P^P +10. Fixed so that if we don't have a tty on stdin editing is disabled. + 9. Check for nested process forking, to avoid loops such as: + > alias foo 'set bar=`foo`' + > foo + 8. Fix setting of AsciiOnly (Per) + 7. tw.spell.c, defined F_OK for systems that don't have it. + 6. ourwait.h had typo in ifdef. + 5. BSD compilers need a cast to int for enums used in + switches (Matthew Day) + 4. Found the cause for the core-dump in long backquote + expansions (Mark Davies) + 3. Some externs in ed.h needed to be truly externs... + reported by Mark Davies, bug appeared only on hp9000s800. + 2. Changed $tcsh, and $version strings. + 1. Added internal sprintf function, renamed putchar to CSHputchar, + printf to CSHprintf, sprintf to CSHsprintf. + +V5.19.02, 10/23/90. +36. Added /etc/cshrc for the SGI irises. +35. Added expand-variables function. +34. Documented $time in tcsh.man +33. Shell variables are now 'recognized' when expanding/listing things. +32. ls-F does not eat the last slash on the / directory! +31. Strings bound to keys are printed inside double quotes. +30. History now remembers the exact line, not just an unparsed version of + the tokens. +29. Renamed itoa to Itoa(), so things in libc that use itoa() don't break. +28. Ported to IBM aix/ps2. +27. Fixed eval so that it forks when the output is piped + Repeat by: + > who | grep $user + > eval who | grep $user +26. Fixed so that 'nice ' does not + nice or fork. + Consider doing: + nice cd /tmp && rm *.c (don't try it!!!) + [what actually happens is that nice has to fork, then the child executes + chdir, and the parent stays where it was] +25. Added Dan's patches (nls, builtin bindkey, fixes to the editor). +24. Added aix370, migrate, getspath, getspath, getxvers, setxvers +23. Added builtin echotc, removed sl and el. +22. Ported to 4.4 BSD. This involved changing the way lots of flags worked, + cleanup of the SVID stuff, and addition of more compilation flags. + Now POSIX can work whed BSD is defined... +21. Fixed so that el, sl work. Actually they are to be removed soon and + be replaced with echotc. +20. Avoid the Quoted Space hack for alias when printing jobs! + [aliases to the same name avoid further alias expansion, by + inserting a quoted space in front of the command. In SHORT_STRINGS + QUOTE is the 15th bit so print ignores it thinking it is the + end of the string. So we just skip the Quoted Space....] + Repeat by: + > set notify + > alias ls ls -F + > (ls) & + Prints Exit 0 ( + Should print: Exit 0 ( ls -F ) +19. Fixed so that "", '', ``, all produce ': Command not found', + and not the spurious messages. + Repeat by: + > set path = (/bin /usr/bin .... .) + > "" + /some/path/name/: Command not found +18. Enable the use of macros if they exist and NLS is defined. + NLS code is not ready yet. +17. Fixed rmstar and continue_jobs code, so that they are not compile + options, but shell variables. Now you need to 'set rmstar' to get + enable rmstar. +16. Fixed SIGWINCH, SIGWINDOW, and setting of li, co, that broke + suntools, and others. + Repeat by: + Start a shelltool of size other than 80x34 + > telltc + > stty -a + do not report the same number of lines and columns. +15. More fixes to tw.parse.c, and tw.spell.c. +14. More fixes to sh.char.c. +13. Fixed coredump caused by ``. +12. Fixed spell-line code.. +11. Trapped SIGCHLD in sh.sem.c, while forking. Still there is a small + race, but the probability of happening is smaller! +10. Fixed sh.char.c to be ISO compliant. + 9. Added expand-glob + 8. Fixed ourwait.h for little endians. + 7. Fixed that foreach i (^D expands correctly. + 6. Fixed so that listmax is ignored in ls-F. + 5. Fixed spelling correction so that single letter words and words that + contain globbing chars do not get spell checked. + 4. Changed NeXT HOSTTYPE to next, since all HOSTTYPE's are lower case. + 3. Fixed symmetry, and changed symmetry HOSTTYPE from sequent to symmetry. + 2. Added boldfacing, underlining chars. + 1. Added IRIX3.3.1 support. + +V5.19.01, 9/26/90. + 7. Brought the README file up-to-date, and changed the bug report + address to point to me. + 6. sh.lex.c. In addla(), overflow computation was wrong. + 5. Fixed SHELLPATH, to be set correctly when $SHELL is not set. + 4. Fixed print statement in sh.proc.c that contained \215. + 3. Fixed the Makefile and MAKEDIFFS so that a tahoe diff can be made. + 2. RS6000: hacked around execv bug, and ed.init.c warning. + 1. Editor should not be enabled when we don't have a tty. diff --git a/tcsh/NewThings b/tcsh/NewThings new file mode 100644 index 0000000000..a372fbb228 --- /dev/null +++ b/tcsh/NewThings @@ -0,0 +1,169 @@ +This file contains visible (incompatible) changes to the users. +This version of tcsh has the following new things: + +6.08 +* %$variables are now expanded in the prompt. +* print_by_columns prints in a single column if the output is not a tty. +* REMOTEHOST contains only the IP address, not the host name of the machine. +* names in .cshdirs are quoted. +* exit value from 0..255 not -128..127 as posix mandates. + +6.07 +* Implicit cd when the variable implicitcd is set or set to verbose + +6.06 +* NLS Message Catalog support. + +6.05 +* The bind, aliases, linedit builtins are not used anymore; they are + #ifdef'ed OBSOLETE and will be really removed in the next version +* new filetest builtin +* new hup builtin +* =x obeys nonomatch +* tcsh.man2html nroff to HTML converter for the tcsh manpage +* prompt is now %# by default. +* $REMOTEHOST contains the name of the remote host (optional) +* $HOSTTYPE is going away. New variables $OSTYPE, $MACHTYPE, $VENDOR similar + to the gnu ones. +* $< can be interrupted and takes modifiers. Does not quote args by default + like csh. + +6.04 +* Variable modifiers do not stop processing after the first one fails + > set i=aabbcc + > echo $i:s/a/A/:s/b/B/ + AaBbcc + > echo $i:s/x/A/:s/b/B/ + aabbcc +* set -r makes variables readonly +* set nonomatch, echo ~notaser returns ~notauser instead of an error +* file operators: Changed -s == !-z and -S == socket +* $?0 returns false now on interactive shells for csh compatibility. +* %p%P include seconds in prompt strings. + +6.03 +* $%var contains the number of characters in $var. +* Shell -w -x are now POSIX compliant on POSIX machines. +* Imported environment variables are not globbed. +* $dirstack can be used to set and examine the directory stack. +* $? == $status and $# == $#argv like in the bourne shell. +* expand variables expands arrays too (but not array elements yet). +* $0 contains argv[0] on interactive shells. +* new -b -c etc file operators from SGI csh. +* nostat takes a list of shell patterns. +* symbolic names for arrow key bindings [left, right, up, down] +* shift, left operators update variables correctly. +* builtins builtin. +* history and dirs accept now -LSc flags. +* $history accepts an optional second argument, that can change the + history builtin output similar to the $time format. +* History timestamps preserved in .history. The history file contains + now the timestamps as csh comments. + + +6.02 +* ignore_symlinks and chase_symlinks are replaced with symlinks=ignore + and symlinks=chase; symlinks=expand addition +* complete and uncomplete builtins; user-programmable completion additions. +* Tcsh now uses the rightmost column of the terminal, allowing cut-and-paste + operations in terminal emulators that work [xterm R5 not R4] +* echo_style controls now the behaviour of the builtin echo; the default + should match the builtin echo of /bin/csh; if your system does not + come with csh, then the default echo should match /bin/echo. +* cd -; changes to the previous directory. +* setting dunique variable pushes only unique directories on the directory + stack. +* source builtin allows additional arguments that get passed in $argv in + the sourced script. +* tcsh now mirrors correctly all exported csh variables [term=TERM,path=PATH + etc.] +* showdots=-A makes listing behave like ls -A. +* directory stack access = allows for entries > 9. +* $a:u uppercase the first character in $a, $a:l downcases the first + character in $a. +* Shorthand for file tests in 'if' expressions ( -dx file ) is the + same as ( -d file && -x file ) + +6.01 +* Nothing new. + +6.00 PL3 +* %d in the prompt is the week-day and no longer $cwd; use %/ instead. +* changes in the prompt format. Date changes to accomodate people from + down under. +* vi insert mode to command mode transition does not move the cursor. + +6.00 PL2 +* setty builtin + This is used to specify what tcsh modes can be altered using stty, + Modes that should be set are specified as +, modes that should + be cleared are specified as -, and the ones that should be + untouched are specified as . setty with no arguments prints + the modes that are affected by tcsh, and setty -a prints all modes. +* multiple : modifiers in variables and ! escapes. Things like: + > set prompt="$host:r:$cwd>" + don't work any more, they should be replaced with + > set prompt="${host:r}:$cwd>" + or + > set prompt="$host:r"":$cwd>" + the reason is that now you can + > set foo=/usr/local/a.b.c + > echo $foo:t:r:e + b + If for some reason you don't like this change you can disable it with + -DCOMPAT. -DCOMPAT may go away in future tcsh versions and the way tcsh + works now is the way the 4.4BSD csh works. + +6.00 PL1 +* There is no more config.iris4d, use config.sgi instead + +6.00 +* History searching searches using shell patterns too. +* The autolist values that controlled beeping are not supported any more; + used matchbeep instead. +* /etc/Login and /etc/Logout were renamed to /etc/csh.login /etc/csh.logout + and /etc/csh.cshrc was added +* prompt2 and prompt3 can have prompt escapes. +* eval pipes work +* ignore_symlinks works + +5.20 PL2 +* %{..%} escapes in prompt + +5.20 PL0 +* bindkey -r +* history -t +* shell variables in paths expand correctly. +* variable expansion +* quoted expansions now work. +* new version and tcsh variable format + +5.19 PL2 +* NLS support +* New bindkey and echotc builtins +* Underline and Bold in the prompt; additions and changes to the prompt and + who syntax (%u is now %n, so that %u can be used to turn undeline off, + and %n is now \n). +* rmstar needs to be set to protect from accidental removal +* Fixed editor, and spell line. +* Glob-expand, on arguments. +* Added process migration builtins for aix370 + +5.19 PL1 +* Maintainance release for mainly the rs6000 + +5.19 PL0 +* 8 bit clean code, by using 16 bit strings. +* Mostly shared strings (a side-effect) +* Highlights everywhere (and in ls-F) filenames that contain characters + with the eighth bit set (or passes them unchanged depending on the + variable 'nometa') +* Newline in the prompt via %n. +* dirs takes also a -v flag for `vertical display' +* There is a new variable `listjobs' which controls if and how jobs + are displayed when a new job is suspended. [Idea from the mtXinu + code, very useful for novice users who hit control-Z 10 times on + the same job!] + set listjobs=long, jobs -l is executed every time a job is suspended. + set listjobs=short, jobs is executed every time a job is suspended. +* Passes lint... At least on a sun. diff --git a/tcsh/Ported b/tcsh/Ported new file mode 100644 index 0000000000..f1151c7267 --- /dev/null +++ b/tcsh/Ported @@ -0,0 +1,1073 @@ + +Hello, + +This file contains a list of machines used, libraries compiler etc. If you +find it out-of-date, or you have additions or changes, please let me know. + +christos + + +VENDOR : Sun +MODELS : sun3, sun4, sun386i +COMPILER: cc, gcc, acc +CFLAGS : normal +LIBES : -ltermcap +OS : sunos 3.5, 4.0, 4.1, 4.1.1, 4.1.2, 4.1.3, 4.1.4 +CONFIG : sunos* +ENVIRON : n/a +NOTES : Don't compile with /usr/5bin/cc +VERSION : 6.08 + +VENDOR : Sun +MODELS : sun4, ultra +COMPILER: cc, gcc +CFLAGS : normal +LIBES : -lcurses -lsocket -lnsl +OS : solaris 2.1, 2.2, 2.3, 2.4, 2.5, 2.5.1 +CONFIG : sol* +ENVIRON : n/a +NOTES : The sunpro compiler cannot compile tcsh with -O, it crashes + : on some files. In any case do not use -O with any of the + : tcsh files, because the optimized code assumes that the + : floating point is already initialized and does not do the + : necessary initializations. This results in weird floating + : point failures of programs exec'ed from tcsh. +VERSION : 6.08 + +VENDOR : Sun +MODELS : ultra +COMPILER: WorkShop cc +CFLAGS : normal +LIBES : -lcurses -lsocket -lnsl +OS : solaris 2.6, 2.7, 8 +CONFIG : sol26 +ENVIRON : n/a +NOTES : none +VERSION : 6.08 + +VENDOR : Sun +MODELS : ultra, i686, x86_64 +COMPILER: Sun Studio cc +CFLAGS : normal +LIBES : -lcurses -lsocket -lnsl +OS : solaris 9, 10 +CONFIG : sol29 +ENVIRON : n/a +NOTES : none +VERSION : 6.18 + +VENDOR : Sun +MODELS : i386 +COMPILER: cc, gcc +CFLAGS : -D__STDC__=0 +LIBES : -lcurses -lsocket -lnsl +OS : solaris 2.1 +CONFIG : sol2 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.04.13 + +VENDOR : Sun +MODELS : sun4 +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermcap +OS : linux 2.0.x, 2.1.x +CONFIG : linux +ENVIRON : n/a +NOTES : none +VERSION : 6.07.03 + +VENDOR : hp +MODELS : apollo +COMPILER: cc +CFLAGS : -U__STDC__ -I. -O +LIBES : -ltermcap +OS : domain 10.4.3 +CONFIG : bsd +ENVIRON : bsd4.3 +NOTES : Don't use gcc; breaks tc.os.c +VERSION : 6.01.00 + +VENDOR : hp +MODELS : hp9000s300, hp9000s700, hp9000s800 +COMPILER: cc, gcc +CFLAGS : normal (-Aa -O3 hpux 8.0, 8.07, 9.05) +LIBES : -ltermcap +OS : hpux 6.5, 7.0.x, 8.0, 9.05 +CONFIG : hpux{7,8} +ENVIRON : n/a +NOTES : Don't use -lBSD; breaks getpgrp(). Config.hp-3.2 obsolete? + : Some versions of the compiler are broken with -O3. Try 'ls *' + : If it does not work, lower the optimization level... +VERSION : 6.05.06 + +VENDOR : hp +MODELS : hp9000s700 +COMPILER: cc, c89, gcc +CFLAGS : +O3 -Aa (cc), +O3 (c89), normal (gcc) +LIBES : -ltermcap +OS : hpux 10.00, 10.01 +CONFIG : hpux8 +ENVIRON : n/a +NOTES : Carl-Olof Almbladh (coa@teorfys.lu.se) + : To make a statically linked version: in config_f.h, #undef NLS + : and use these LDFLAGS in the Makefile: LDFLAGS= -Wl,-a,archive + : [orban@kato.den.csci.csc.com (Tom Orban) +VERSION : 6.08 + +VENDOR : hp +MODELS : SPP-1200 SPP-1600 S-2X00 X-2X00 +COMPILER: cc +CFLAGS : -Ae +LIBES : -ltermcap +OS : SPP-UX 5.X +CONFIG : hpux8 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.07.02 + +VENDOR : hp +MODELS : hp9000s500 +COMPILER: cc +CFLAGS : -I. -O +LIBES : -ltermcap +OS : hpux 5.2 +CONFIG : hp-5.2 +ENVIRON : n/a +NOTES : very slow in executing commands (I think the reason is +NOTES : a very slow fork) +VERSION : 6.00.01 + +VENDOR : digital +MODELS : vax +COMPILER: cc, gcc +CFLAGS : normal +LIBES : -ltermcap +OS : bsd4.3, bsd4.4 +CONFIG : bsd* +ENVIRON : n/a +NOTES : cc broken: typedef void sigret_t; typedef void pret_t; +VERSION : 6.00.03 + +VENDOR : digital +MODELS : vax +COMPILER: cc, gcc +CFLAGS : normal +LIBES : -ltermcap +OS : mtXinu 4.3 +CONFIG : mtxinu +ENVIRON : n/a +NOTES : cc broken: typedef void sigret_t; typedef void pret_t; +VERSION : 6.03.09 + +VENDOR : digital +MODELS : vax, DECstation +COMPILER: cc, gcc +CFLAGS : -O -Olimit 2000 (cc), normal (gcc) +LIBES : -ltermcap +OS : ultrix 3.0 (vax), 4.0, 4.1, 4.2, 4.3, 4.4, 4.5 +CONFIG : ultrix +ENVIRON : n/a +NOTES : pcc broken: typedef void sigret_t (vax); +NOTES : mips compiler on ultrix 3.5 needs -Dvoid=int +NOTES : vax compiler on ultrix 3.0 needs -Dvoid=int +NOTES : Does Ultrix 4.x still need YPBUGS? +NOTES : Ultrix4.2 may need NAMEI_BUG +VERSION : 6.09.00 + +VENDOR : Apple +MODELS : macII +COMPILER: cc +CFLAGS : normal (-ZP) +LIBES : -ltermcap (-lposix -ltermcap) +OS : aux 2.0 +CONFIG : mac2 (-DPOSIX -DPOSIXJOBS) +ENVIRON : n/a +NOTES : Tcsh can compile both in non POSIX and POSIX mode. The +NOTES : default configuration is non POSIX. The flags in parentheses +NOTES : are the changes that are needed to compile in POSIX mode +VERSION : 6.00.01 + +VENDOR : ibm +MODELS : ps/2, rs6000, ibm370, ibmESA +COMPILER: cc +CFLAGS : normal +LIBES : -lcurses -lbsd [No -lbsd for 4.1] +OS : aix 3.1,3.2,4.1 (rs6000) aix 1.1 (ps/2) aix G9.9 (ibm370) + : aix (ibmESA) +CONFIG : aix +ENVIRON : n/a +NOTES : aix G9.9 sfname() frees bad pointers. Use TCF with care! +NOTES : aix 3.2 may need NAMEI_BUG +NOTES : aix 3.2 may need _BSD_INCLUDES defined in h +NOTES : aix 4.1 does not need -lbsd anymore. +VERSION : 6.06.00 (rs6000) + +VENDOR : ibm +MODELS : ibm390 +COMPILER: c89 +CFLAGS : normal +LIBES : -lcurses +OS : os390 R 2.7 +CONFIG : os390 +ENVIRON : USS (formerly OpenEdition, aka POSIX) +NOTES : Used GNU make for OS/390. +NOTES : Use `CFLAGS="" ./configure` to avoid -g and make binary +NOTES : half as large. +VERSION : 6.09.00 + +VENDOR : ibm +MODELS : rt +COMPILER: hc, gcc +CFLAGS : -I. -U__STDC__ +LIBES : -ltermcap +OS : aos 4.3 +CONFIG : bsd +ENVIRON : n/a +NOTES : Old versions of the compiler break with -O. No ansi include +NOTES : files so we have to undef __STDC__ +VERSION : 6.05.06 + +VENDOR : ibm +MODELS : rt +COMPILER: pcc +CFLAGS : -I. -U__STDC__ -DPCC +LIBES : -ltermcap +OS : aos 4.3 +CONFIG : bsd +ENVIRON : n/a +NOTES : Old versions of the compiler break with -O. No ansi include +NOTES : files so we have to undef __STDC__ +NOTES : pcc broken: typedef void sigret_t; typedef void pret_t; +VERSION : 6.05.06 + +VENDOR : ibm +MODELS : rt +COMPILER: cc +CFLAGS : -I. -Nd4000 -Nn3000 +LIBES : -lcurses +OS : aix 2.2.1 +CONFIG : aix +ENVIRON : n/a +NOTES : Stacksize limit is 1K off? +VERSION : 6.00.03 + +VENDOR : sequent +MODELS : balance, symmetry +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap -lseq +OS : Dynix 3.1, 3.2, ptx 1.2 +CONFIG : sequent +ENVIRON : universe on Dynix 3.1, 3.2: ucb +NOTES : none +VERSION : 6.04.00 + +VENDOR : sequent +MODELS : symmetry +COMPILER: gcc 2.6.2 +CFLAGS : -m486 +LIBES : -ltermcap -lseq -lsocket -linet -lnsl +OS : DYNIX/ptx 2.1.0, 4.1.3 +CONFIG : sequent +ENVIRON : +NOTES : Didn't work for me with Sequent's /bin/cc +NOTES : 4.1.3 does not need libinet anymore. +VERSION : 6.05.00 + +VENDOR : encore +MODELS : multimax +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermcap +OS : umax 4.2 +CONFIG : bsd +ENVIRON : n/a +NOTES : none +VERSION : 6.00.00 + +VENDOR : sony +MODELS : news 1850, 1750 +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermcap +OS : bsd 4.3, news-os 3.3,4.1C +CONFIG : bsd +ENVIRON : n/a +NOTES : none +VERSION : 6.05.06 + +VENDOR : ibm + compatibles +MODELS : i386,i286 +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap -ldir -lx +OS : xenix +CONFIG : xenix +ENVIRON : n/a +NOTES : none +VERSION : 6.00.01 + +VENDOR : hp +MODELS : hp300 +COMPILER: cc, gcc +CFLAGS : normal +LIBES : -ltermcap +OS : MORE/bsd 4.3+ +CONFIG : mtxinu +ENVIRON : n/a +NOTES : none +VERSION : 6.05.06 + +VENDOR : hp, motorola +MODELS : hp300, m68k +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermcap -lcrypt +OS : NetBSD 1.0A +CONFIG : bsd4.4 +ENVIRON : n/a +NOTES : none +VERSION : 6.05.06 + +VENDOR : digital +MODELS : vax +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermcap +OS : bsd 4.3reno +CONFIG : bsdreno +NOTES : ttyname() is buggy. calls closedir() twice. See BUILDING +ENVIRON : n/a +VERSION : 6.00.04 + +VENDOR : Cray Research +MODELS : Y-MP +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap +OS : Unicos 6.0 +CONFIG : cray +ENVIRON : n/a +NOTES : none +VERSION : 6.00.01 + +VENDOR : Cray Research +MODELS : C90 +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap +OS : Unicos 9.0.2.1 +CONFIG : cray +ENVIRON : n/a +NOTES : none +VERSION : 6.08 + +VENDOR : Cray Research +MODELS : SV1, probably also SV2 +COMPILER: cc +CFLAGS : normal +LIBES : -ltermlib +OS : Unicos 10.0.1.0 +CONFIG : cray +ENVIRON : n/a +NOTES : none +VERSION : 6.11 + +VENDOR : pyramid +MODELS : MIS4/2T +COMPILER: cc +CFLAGS : -OG +LIBES : -ltermcap +OS : OSx5.1,6.4 +CONFIG : pyr +ENVIRON : n/a +NOTES : If there are problems with the global optimizer, use -OP +NOTES : If you only have the AT&T universe, use the pyratt config +NOTES : file and define -D_PID_T -Dpyr. +VERSION : 6.06.00 + +VENDOR : next +MODELS : any +COMPILER: gcc or cc -arch m68k -arch i386 +CFLAGS : -O2 -g +LIBES : -ltermcap # [-lcs 2.0] +OS : next os 2.x, 3.x +CONFIG : mach +ENVIRON : n/a +NOTES : NeXTSTeP 3.3 on intel defines speed_t so compile with -D_SPEED_T +NOTES : NeXT's cc -E adds spaces before and after array brackets! +NOTES : You'll need to change the sed expression in the Makefile to +NOTES : something like: +NOTES : 's/Char \([a-zA-Z0-9_]*\) *\[ *\].*/extern Char \1[];/' +VERSION : 6.04.00 + +VENDOR : Apple +MODELS : any +COMPILER: cc +CFLAGS : -O3 -pipe -g -arch ppc -arch i386 -UNeXT +OS : Rhapsody 5 +CONFIG : rhapsody +ENVIRON : n/a +NOTES : CFLAGS="-O3 -pipe -g -UNeXT" configure && make +VERSION : 6.08.00 + +VENDOR : Apple +MODELS : any +COMPILER: cc +CFLAGS : -O3 -pipe -g -arch ppc -arch i386 +OS : Darwin +CONFIG : darwin +ENVIRON : n/a +NOTES : CFLAGS="-O3 -pipe -g -arch ppc -arch i386 -UNeXT" configure && make +VERSION : 6.11.05 + +VENDOR : Heurikon +MODELS : HK68 +COMPILER: gcc (Green Hills C-68000) +CFLAGS : -ga -X138 -X25 -I. +LDFLAGS : -n +LIBES : -lcurses -ltermcap -ldirent +OS : UniPlus+ 5.0 +CONFIG : hk68 +ENVIRON : n/a +NOTES : Need Doug Gwyn's POSIX directory library (libdirent.a) +VERSION : 6.00.01 + +VENDOR : Amdahl +MODELS : n/a +COMPILER: cc/gcc +CFLAGS : normal +LIBES : -lcurses -lsocket -lbsd +CONFIG : amdahl +ENVIRON : n/a +VERSION : 6.00.01 + +VENDOR : prime +MODELS : exl 300 series +COMPILER: cc +CFLAGS : -O -s -I. +LIBES : -lcurses -lstcp +OS : system v.3.1.2 +CONFIG : sysv +ENVIRON : sysv +NOTES : Is libstcp.a on all exl 300s? +VERSION : 6.00.01 + +VENDOR : convex +MODELS : c220 +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap +OS : 9.0.6 (bsd 4.3) +CONFIG : convex +ENVIRON : n/a +NOTES : Dont use the -pcc flag. + : Use setty to fix the default tty settings. +VERSION : 6.00.01 + +VENDOR : Norsk Data +MODELS : nd5000 +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap +OS : Ndix Version C +CONFIG : bsd +ENVIRON : n/a +NOTES : The -O option makes the compiler run for ages! +VERSION : 6.00.03 + +VENDOR : SGI +MODELS : 4D, 3000 +COMPILER: cc +CFLAGS : -D__STDC__ +LIBES : -lcurses -lsun -lbsd -lc_s +OS : IRIX (3.?) 3.2 3.3 4.0 +CONFIG : sgi +ENVIRON : n/a +NOTES : AUTOLOGOUT is probably best undef'ed +NOTES : For 4.0, the NLS define in h can be enabled. +NOTES : 4.0.5a cc does not have -O3 anymore. +NOTES : If you don't like -lbsd, you can define POSIXJOBS in +NOTES : config.h and omit it. +VERSION : 6.06.00 + +VENDOR : SGI +MODELS : R8000 PowerIndigo2 +COMPILER: cc -n32 +CFLAGS : -D__STDC__ +LIBES : -lcurses -lsun -lbsd -lc_s +OS : IRIX 6.2 +CONFIG : sgi +ENVIRON : n/a +NOTES : CCOPTIONS=-OPT:fold_arith_limit=4000 +NOTES : SHLIBDIR=/usr/lib32 +NOTES : LDPOSTLIB = -nostdlib -L$(ROOT)$(SHLIBDIR)/mips3 \ +NOTES : -L$(ROOT)$(SHLIBDIR) +NOTES : In config.h #undef NLS and #undef NLS_CATALOGS +VERSION : 6.06.00 + +VENDOR : SGI +MODELS : Onyx R10000 +COMPILER: gcc-2.7.2.1 configured for mips-sgi-irix5.3 +CFLAGS : none +LIBES : -ltermcap -lbsd +OS : IRIX 6.2 +CONFIG : sgi +ENVIRON : n/a +VERSION : 6.07.02 + +VENDOR : ibm + compatibles +MODELS : i386,i486 +COMPILER: /bin/cc +CFLAGS : normal +LIBES : -ltermlib -lsocket -lnsl (without BSDTIMES) +LIBES : -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a (BSDTIMES) +OS : SVR4 (DELL, ESIX, ISC, UHC) +CONFIG : sysv4 +ENVIRON : n/a +NOTES : none +VERSION : 6.05.06 + +VENDOR : ibm + compatibles +MODELS : i386,i486 +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermcap +OS : linux 0.8x, 0.9x, 1.x +CONFIG : linux +ENVIRON : n/a +NOTES : none +VERSION : 6.05.06 + +VENDOR : ibm + compatibles +MODELS : i386,i486 +COMPILER: gcc +CFLAGS : normal +LIBES : -lcurses -lc_s [for crypt] +OS : SVR3.2.2 [SCO] +CONFIG : sco32v2 +ENVIRON : n/a +NOTES : none +VERSION : 6.03.00 + +VENDOR : stardent +MODELS : gs2600 +COMPILER: /bin/cc +CFLAGS : -O +LIBES : -lcurses +OS : stellix +CONFIG : stellar +ENVIRON : n/a +NOTES : works but not worth compiling with -O4... +NOTES : setpgrp() and SIGCHLD work the BSD way, not the way documented. +NOTES : we need to define BACKPIPE +VERSION : 6.00.04 + +VENDOR : stardent +MODELS : titan 3000 series +COMPILER: /bin/cc +CFLAGS : -O -43 +LIBES : -ltermcap +OS : OS 3.0.3 +CONFIG : bsd +ENVIRON : n/a +NOTES : Kernel bug with SIGTTIN, Try vi, ^Z, bg, fg.... +VERSION : 6.01.01 + +VENDOR : stardent +MODELS : titan 1500 series +COMPILER: cc +CFLAGS : -O -43 +LIBES : -ltermcap +OS : OS 2.5 +CONFIG : bsd +ENVIRON : n/a +NOTES : Kernel bug with SIGTTIN, Try vi, ^Z, bg, fg.... +NOTES : You can add -w to the CFLAGS to suppress the warnings. +VERSION : 6.02.07 + +VENDOR : SGI +MODELS : INDIGO +COMPILER: cc +CFLAGS : -D__STDC__ +LIBES : -lcurses -lsun -lbsd -lc_s +OS : IRIX (3.?) 3.2 3.3 4.0 +CONFIG : sgi +ENVIRON : n/a +NOTES : AUTOLOGOUT is probably best undef'ed +NOTES : For 4.0, the NLS define in h can be enabled. +VERSION : 6.01 + +VENDOR : SGI +MODELS : INDY +COMPILER: cc +CFLAGS : +LIBES : -lcurses -lbsd +OS : IRIX 5.1 +CONFIG : sgi +ENVIRON : n/a +NOTES : it will build without -lbsd but then job control +NOTES : won't actually work. +VERSION : 6.04.00 + +VENDOR : alliant +MODELS : FX/2800 series +COMPILER: scc +CFLAGS : normal +LIBES : -ltermcap +OS : Alliant Concentrix 2800 2.2.00 +CONFIG : bsd +ENVIRON : n/a +NOTES : For a newer version of the operating system try defining + : NEW_OS in alliant [or better find a way to tell + : them apart. +VERSION : 6.03.00 + +VENDOR : stardent +MODELS : Vistra 800 +COMPILER: /bin/cc +CFLAGS : -O +LIBES : -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a +OS : SYSVR4 +CONFIG : sysv4 +ENVIRON : n/a +NOTES : Works like a charm +VERSION : 6.01 + +VENDOR : Evans & Sutherland +MODELS : ESV +COMPILER: cc +CFLAGS : mips systems +LIBES : -ltermcap +OS : ES/os 2.2 (UMIPS mips ATT_V3_0) +CONFIG : mips +ENVIRON : bsd4.3 +NOTES : would it be preferable to have HOSTTYPE of +NOTES : "esv" instead of "mips"? +VERSION : 6.01.00 + +VENDOR : masscomp +MODELS : Masscomp 6000 +COMPILER: cc +CFLAGS : production +LIBES : -ltermcap +OS : RTU 5.0 +CONFIG : masscomp +ENVIRON : Link in the "bsd" universe as opposed to "att". +NOTES : For pre RTU 6.0, remember to remove the #define RTU6 in the +NOTES : masscomp file. +NOTES : As of tcsh v6.02.07, try putting "bindkey ^t stuff-char" +NOTES : in your /etc/csh.cshrc for masscomp kernel (ctrl-t) status. +VERSION : 6.02.07 + +VENDOR : masscomp +MODELS : Masscomp 5400 +COMPILER: cc +CFLAGS : normal +LIBES : -ltermcap -lndir -lsocket -ljobs +OS : RTU 6.0 +CONFIG : masscomp +ENVIRON : Link in the "bsd" universe as opposed to "att". +NOTES : n/a +VERSION : 6.01.00 + +VENDOR : Cray Computer +MODELS : CRAY-2 & CRAY-3 +COMPILER: cc +CFLAGS : normal +LIBES : -lcurses -lnet +OS : CSOS 1.0 +CONFIG : csos +ENVIRON : n/a +NOTES : none +VERSION : 6.02 + +VENDOR : Motorola +MODELS : Delta 3000/Delta 4000 +COMPILER: cc +CFLAGS : normal +LIBES : -lcurses +OS : System V/68 R3V6.2, R3V7 +CONFIG : sysV68 +ENVIRON : n/a +NOTES : none +VERSION : 6.01.00, 6.02.00 + +VENDOR : Motorola +MODELS : MPC 3062 +COMPILER: cc +CFLAGS : Broken optimizers... +LIBES : -lcurses -lsec +OS : System V/88 R32V2 +CONFIG : sysV88 +ENVIRON : n/a +NOTES : If you're using the bundled Greenhills compiler, don't use -O. +NOTES : One error -O causes is failure to exec scripts with /bin/sh +NOTES : if they don't have a #! header on top. +VERSION : 6.02.07 + +VENDOR : alliant +MODELS : FX/8X series +COMPILER: pcc +CFLAGS : normal +LIBES : -ltermcap +OS : Concentrix 6.0.00 beta +CONFIG : bsd +ENVIRON : n/a +NOTES : Needs to define DIRENT in h +VERSION : 6.02.00 + +VENDOR : alliant +MODELS : FX/8X series +COMPILER: pcc +CFLAGS : normal +LIBES : -ltermcap +OS : Concentrix 5.7.00 +CONFIG : bsd +ENVIRON : n/a +NOTES : n/a +VERSION : 6.00.01 + +VENDOR : gould (encore) +MODELS : NP1 +COMPILER: cc +CFLAGS : production +LIBES : -ltermcap +OS : UTX/32 3.1A +CONFIG : bsd +ENVIRON : n/a +NOTES : n/a +VERSION : 6.02.00 + +VENDOR : gould (encore) +MODELS : 9050 +COMPILER: cc +CFLAGS : production +LIBES : -ltermcap +OS : UTX/32 2.1A +CONFIG : bsd +ENVIRON : n/a +NOTES : n/a +VERSION : 6.02.00 + +VENDOR : ibm & compatible +MODELS : i386 +COMPILER: cc +CFLAGS : production +LIBES : -lcurses -lcposix +OS : 3.2 +CONFIG : isc +ENVIRON : ISC386 +NOTES : n/a +VERSION : 6.02.00 + +VENDOR : att +MODELS : 3b2-600GR (RISC) +COMPILER: cc +CFLAGS : production +LIBES : -lcurses +OS : SystemV R4.0 +CONFIG : sysv4 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.02.00 + +VENDOR : att +MODELS : 3b2-600G +COMPILER: cc +CFLAGS : production +LIBES : -lcurses +OS : SystemV R3.2.3 +CONFIG : sysv3 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.02.00 + +VENDOR : tektronix +MODELS : XD88/10 +COMPILER: cc +CFLAGS : Broken optimizers... +LIBES : -ltermcap -lsec +OS : UTekV 3.2e +CONFIG : tekXD88 +ENVIRON : n/a +NOTES : If you're using the bundled Greenhills compiler, don't use -O. +NOTES : One error -O causes is failure to exec scripts with /bin/sh +NOTES : if they don't have a #! header on top. +VERSION : 6.02.07 + +VENDOR : tektronix +MODELS : 4300 +COMPILER: cc +CFLAGS : production +LIBES : -ltermcap +OS : UTek 4.0 (BSD 4.2) +CONFIG : bsd +ENVIRON : n/a +NOTES : set DFLAGS = -DUTek -DBSD in the Makefile +VERSION : 6.02.07 + +VENDOR : BBN +MODELS : butterfly gp1000 +COMPILER: cc +CFLAGS : production +LIBES : -ltermcap +OS : Mach 1000 version 2.5 +CONFIG : mach +ENVIRON : n/a +NOTES : n/a +VERSION : 6.02.07 + +VENDOR : sony +MODELS : news 3700 +COMPILER: cc +CFLAGS : -O -Wf,-XNp15000,-XNd15000,-XNh15000 +LIBES : -lcurses -lc /usr/ucblib/libucb.a +OS : sysvr4, news-os 5.02 +CONFIG : sysv4 +ENVIRON : n/a +NOTES : Use /usr/bin/cc, not /usr/ucb/cc. +VERSION : 6.00.03 + +VENDOR : ibm & compatible +MODELS : i386, i486 +COMPILER: cc +CFLAGS : production +LIBES : -lterm +OS : Coherent 4.0 +CONFIG : coh3 +ENVIRON : gnu tools (see below) +NOTES : The standard make, /bin/sh and sed that come with Coherent are +NOTES : not quite up to the makefile. Either use gnu make or change +NOTES : occurances of '# to '\# since Coherent's make takes all '#'s to +NOTES : be a comment, even when quoted, except when escaped by '\'. +NOTES : Coherent's /bin/sh does not allow you to set VERSION, etc. +NOTES : since they are hard-wired internal variables. Either use +NOTES : /usr/bin/ksh, another sh or change the name of the offending +NOTES : variables. Coherent's sed, unfortunately, is broken beyond a +NOTES : workaround. Either get gnu sed or run that portion of the +NOTES : makefile on a machine with a full sed and import the output. +VERSION : 6.02.08 + +VENDOR : Control Data Systems +MODELS : CD4680 +COMPILER: cc, cc2.20 (mips) +CFLAGS : mips systems, DFLAGS=-DCDC +LIBES : -ltermcap +OS : EP/IX 1.4.3 (RiscOS based) +CONFIG : mips +ENVIRON : bsd4.3 (if sysv, need "set path=(/usr/bsd43/bin $path)" ) +NOTES : n/a +VERSION : 6.02.00 + +VENDOR : alliant +MODELS : FX/8X series +COMPILER: pcc +CFLAGS : normal +LIBES : -ltermcap -lresolv +OS : Concentrix 6.0.00 beta +CONFIG : alliant (see NOTES) +ENVIRON : n/a +NOTES : Needs to define DIRENT and BSDLIMIT in h. The +NOTES : beta release of the Concentrix 6.0.00 has some errors +NOTES : in the system header files, namely, /usr/include/sys/dir.h. +VERSION : 6.03.00 + +VENDOR : hp +MODELS : hp9000s700 +COMPILER: cc +CFLAGS : No -O here!!! Breaks quoting! Try echo 'foo | bar'... +LIBES : -ltermcap +OS : HP OSF/1 1.0 +CONFIG : hposf1 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.03.00 + +VENDOR : digital +MODELS : DEC 3000/400 (alpha) +COMPILER: cc +CFLAGS : -call_shared -I. -I.. -O -Olimit 2000 -std1 +LIBES : -lcurses +OS : OSF1 1.2 +CONFIG : decosf1 +ENVIRON : n/a +NOTES : none +VERSION : 6.03 + +VENDOR : digital +MODELS : DEC 3000/400 (alpha) +COMPILER: cc +CFLAGS : -O2 -I. -I.. -Olimit 2000 +LIBES : -lcurses +OS : OSF1 (Digital Unix) 1.3, 2.0, 3.0, 3.2, 4.0 +CONFIG : decosf1 +ENVIRON : n/a +NOTES : none +VERSION : 6.07.11 + +VENDOR : Intel +MODELS : Paragon +COMPILER: icc +CFLAGS : -O2 +LIBES : -ltermcap +OS : Paragon OSF/1 Release 1.0.1 Server 1.0 R1.0 +CONFIG : parosf1 +ENVIRON : n/a +NOTES : I have gotten two different config files that both seem to + : work! +VERSION : 6.03.00 + +VENDOR : Data General +MODELS : AViiON mc88000 +COMPILER: cc +CFLAGS : -O2 +LIBES : -lcurses +OS : DGUX 5.4R2.01 +CONFIG : dgux5.4 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.04.00 + +VENDOR : Data General +MODELS : Aviion +COMPILER: gcc 2.5.8 +CFLAGS : -g -O2 -msvr4 +LIBES : -ltermcap +OS : DGUX 5.4.1 +CONFIG : dgux5.4 +ENVIRON : sde m88kdguxelf +VERSION : 6.05.00 + +VENDOR : Harris +MODELS : Tahoe +COMPILER: cc, gcc 1.42 +CFLAGS : -O +LIBES : -ltermcap +OS : CX/UX 5.1 CX/UX 7.1 +CONFIG : hcx +ENVIRON : universe bsd +NOTES : n/a +VERSION : 6.06.01 + +VENDOR : Multiflow +MODELS : multiflow +COMPILER: cc +CFLAGS : -O5 -sb_trace 0 -DMULTIFLOW +LIBES : -ltermcap -lcrypt +OS : 4.3 BSD TRACE/UNIX +CONFIG : bsd +ENVIRON : n/a +NOTES : Lower the optimization or you'll get a 5M binary! +NOTES : cc broken: typedef void sigret_t; typedef void pret_t; +VERSION : 6.04.00 + +VENDOR : Unixware +MODELS : all +COMPILER: cc +CFLAGS : normal +LIBES : -lcrypt -ltermlib -lsocket -lnsl -lgen +OS : Unixware 2.03 (4.2MP) +CONFIG : svr4 +ENVIRON : n/a +NOTES : Remove PW_SHADOW from config file, or add -lgen for getspnam +VERSION : 6.07.00 + +VENDOR : Intergraph +MODELS : clipper +COMPILER: cc +CFLAGS : n/a +LIBES : -ltermcap -lbsd +OS : clix 7.1.3 +CONFIG : clipper +ENVIRON : n/a +NOTES : n/a +VERSION : 6.05.00 + +VENDOR : SNI (Siemens Nixdorf Information Systems) +MODELS : rm400 (R4000 mips) +COMPILER: /usr/bin/cc +CFLAGS : -kansi; xmkmf (=> -DSVR4 -DSNI -DSMSINFO -DR3000) +LIBES : -ltermcap -lc -L/usr/ucblib -lucb +OS : SINIX 5.42 +CONFIG : sysv4 +ENVIRON : +NOTES : This is a POSIX (XPG-4) system. +NOTES : Make sure that -lucb is included _last_ (even after -lc) +NOTES : so use: -ltermcap -lc -L/usr/ucblib -lucb +NOTES : In config.h, set HAVEUTMPX und unset BSDSIGS and BSDTIMES +NOTES : +VERSION : 6.06.03 + +VENDOR : U/WIN +MODELS : i386 +COMPILER: cc +CFLAGS : -O +LIBES : -lcurses +OS : Windows NT with U/WIN +CONFIG : uwin +ENVIRON : +NOTES : Needs POSIX.DLL from U/WIN version later than 1.6 +NOTES : Did not function correctly when using #define SYSMALLOC +VERSION : 6.07.02 + +VENDOR : SNI (Siemens Nixdorf Information Systems) +MODELS : rm600 (R4000 mips) +COMPILER: /usr/bin/cc +CFLAGS : -kansi -DSVR4 -DSNI -DSMSINFO -DR3000 +LIBES : -ltermcap -lsocket -lxnet -lc -L/usr/ucblib -lucb +OS : SINIX 5.43 +CONFIG : sysv4 +ENVIRON : +NOTES : In config.h, set HAVEUTMPX und unset BSDSIGS, +NOTES : BSDTIMES, and BSDLIMIT, since otherwise resource.h +NOTES : is falsely searched in /usr/ucbinclude/sys/ +NOTES : +VERSION : 6.07.02 + +VENDOR : FUJITSU +MODELS : ds90 +COMPILER: cc +CFLAGS : -O -I. -DSVR4 -DANSICPP +LIBES : -lsocket -lnsl -ltermcap +OS : UXP/DS V20L10(SVR4.2) +CONFIG : sysv4 +ENVIRON : n/a +NOTES : n/a +VERSION : 6.07.02 + +VENDOR : Fujitsu ICL +MODELS : SuperServer Intel based +COMPILER: gcc 2.7.2 +CFLAGS : normal for gcc 2.1+ .... -O2 $(INCLUDES) +LIBES : -ltermlib -lsocket -lnsl -lcrypt -lgen +OS : SCO UnixWare 2.1 SysVR4.2 i386 x86at +CONFIG : sysv4 +ENVIRON : n/a +NOTES : none +VERSION : 6.06.00 + +VENDOR : NEC +MODELS : SX-4, SX-5 +COMPILER: cc +CFLAGS : -h0,ansi,novector,float0 # for NEC SX-4 +LIBES : -Gsmall +OS : NEC's +CONFIG : superux8 +ENVIRON : n/a +NOTES : none +VERSION : 6.08.01 + +VENDOR : Unixware 7.1.0 +MODELS : all +COMPILER: gcc +CFLAGS : normal +LIBES : -ltermlib -lsocket -lgen +OS : Unixware 7.1.0 +CONFIG : svr5 +ENVIRON : n/a +NOTES : none +VERSION : 6.09.00 + diff --git a/tcsh/README.md b/tcsh/README.md new file mode 100644 index 0000000000..df6671b031 --- /dev/null +++ b/tcsh/README.md @@ -0,0 +1,29 @@ +# TCSH + +*C shell with file name completion and command line editing* + +The Tcsh source code is available on GitHub as a read-only repo +mirror at: + +> https://github.com/tcsh-org/tcsh + +Instructions for compiling Tcsh can be found in [BUILDING]. + +PLEASE file any bug reports, fixes, and code for new features at: + +> https://bugs.astron.com/ + +Comments, questions, etc. (even flames) are welcome via email to +the tcsh mailing list: + +> tcsh@astron.com +> https://mailman.astron.com/mailman/listinfo/tcsh + +[![Build Status][status]][travis] +[![Coverity Scan][badge]][coverity] + +[BUILDING]: BUILDING +[badge]: https://scan.coverity.com/projects/20307/badge.svg +[coverity]: https://scan.coverity.com/projects/tcsh-org-tcsh +[status]: https://travis-ci.com/tcsh-org/tcsh.svg?branch=master +[travis]: https://travis-ci.com/tcsh-org/tcsh diff --git a/tcsh/WishList b/tcsh/WishList new file mode 100644 index 0000000000..6a2a0d97a9 --- /dev/null +++ b/tcsh/WishList @@ -0,0 +1,309 @@ + + [Home] WishList + + Home | RecentChanges | Preferences + _________________________________________________________________ + + Surprised by this behavior...is this a bug? + + (Goal: e.g. distinguish between completely numeric args/names and + those containing non-numerics) + + % touch 1023 pex103 pex103a 104a z101 16a02 1999 2001 2001_A_Space_Odyssey + % ls -1 *[^0-9]* + 104a + 16a02 + 2001_A_Space_Odyssey + pex103 + pex103a + z101 + # (great, looks good to me. Got everything containing a nonnumeric, no more, n +o less.) + + % foreach p ( 1023 pex103 pex103a 104a z101 16a02 1999 2001 2001_A_Space_Odyss +ey ) + foreach? if ( $p !~ *[^0-9]* ) echo $p + foreach? end + # (no output. Huh?) + + % foreach p ( 1023 pex103 pex103a 104a z101 16a02 1999 2001 2001_A_Space_Odyss +ey ) + foreach? if ( $p =~ *[^0-9]* ) echo $p + foreach? end + 1023 (!) + pex103 + pex103a + 104a + z101 + 16a02 + 1999 (!) + 2001 (!) + 2001_A_Space_Odyssey + # (Huh?) + + The [MAN page description] for =~ and !~ just refer to "(see [Filename + substitution])', but evidently there is a (unexplained) difference. + The actual filename globbing looks correct to me, but the pattern + matching operator behavior is unexpected, if I'm not missing + something. + + tcsh 6.09.00 + + - bhooglan + _________________________________________________________________ + + Wish "tcsh -l" would accept other flags. At least "-c". + + Currently I can't get ssh to have the right environment unless it is a + login shell. The .ssh/environment doesn't work for me because I login + to different machines with different environments. One thing to do + would be to not have the different environment for login compared to + other shells, but what I would really like is something like... + + ssh remote_application_server "tcsh -l -c application" + + The "ssh -t" doesn't work for me and I don't know why. + + Thanks Tim + + Fix limit vmemoryuse in Linux + + In Linux tcsh is unable to limit vmemoryuse. This is because + RLIMIT_VMEM isn't defined, instead Linux has RLIMIT_AS which means the + same. On Google groups I found patches suggested by Komazaki at + http://groups.google.com/groups?hl=sv&lr=&ie=UTF-8&oe=ISO-2022-JP&selm + =m3snmczvfc.wl%40thinkpad.osk.3web.ne.jp.osk.3web.ne.jp and Ogawa + Hirofumi suggests a patch at + http://groups.google.com/groups?hl=sv&lr=&ie=UTF-8&selm=87snmba4id.fsf + %40devron.myhome.or.jp None of these patches seems to have been + included in version 6.12 as 6.12 still has this problem. + + /Henrik?? + + New idea: use last line (or n'th line) of output as input to new + command. + + I often find myself typing something like: + + >locate lshort + /usr/local/stow/share/texmf/doc/latex/general/lshort.dvi . . . + /usr/local/store/share/texmf/doc/latex/general/lshort.dvi + + >xdvi /usr/local/store/share/texmf/doc/latex/general/lshort.dvi + + Now the way I accomplish writing the last line, is by moving the mouse + over the last line, and the copy paste it. It would be very nice, if + the shell could keep the last n lines of output in a buffer. This way + one could avoid using the mouse by typing something like: + + >xdvi + + which would insert the last line of output, similarly could + insert the second last line of output. (the exact commands used is of + course configured via bindkey). + + This could save me a couple of times to the mouse everyday - + di010070@diku.dk + + The shell does not capture any output from commands it runs, so + this is really more a feature for the terminal (be it hardware + or software). --Kim + + Fix memory leak related to aliasrun(). Precmd, Cwdcmd etc. leak + memory. + + Fix migrate -site $$... Seems to hang... (aix370) + + Fix history in loops. + + New idea: sed operations on variables. + + Lots of people seem to like the idea to be able to do sed type + operations on shell variables. Maybe we can extend the syntax of the + variable editing to understand string operations. So I would like to + be able to use: + +> set a="this is a STRING" +> echo $a:[3-] +is is a STRING +> echo $a:[#] +16 +> echo $a:[6-7] +is +> echo $a:[-2] +ng +> echo $a:[-20] +Subscript out of bounds. +> echo $a:[2-20] +Subscript out of bounds. +> echo $a:[1-1]:u$a:[2-]. +This is a string. + + + + Fix pipelines that contain builtins so that they behave correctly. + + I tried to fix that (most of the code is in sh.sem.c, but it works + only for non POSIX machines cause otherwise the setpgid() I added + fails). + + Fix the correct code... How to do that involves A.I.... + + Rewrite the whole thing. It has taken to much beating over the + years... + + Add another hook like precmd to be executed after the prompt but + before the command. + + Add instructions for using configure in the README file. + + Make manual page references links in the HTML version of the manual. + + It is possible to match the words with ([0-9]) after them. Links could + be using the manual page CGI at http://www.tac.eu.org/cgi-bin/man-cgi + for content. + + Add OpenBSD?? to the Makefile, etc. + + A Csh compatability mode would be nice: I know tcsh is supposed to be + fully csh compatible, but csh scripts containing such constructs as + '$<' , 'if ( -d $file ) cd $file' or any of a great number of other + valid csh commands, will produce syntax errors or the like with tcsh, + which is frustrating when writing/maintaining csh scripts which have + to run on systems with only tcsh and systems with only csh. If such a + thing exists, I couldn't find it after searching the man page for two + hours, and it should be better documented + + Add hooks for command completion Either for a dynamically loaded + library, or a callback to another program that allows another pass to + complete the command. As a trivial example, the module could duplicate + the functionality of aliases. A tcsh_mud.so could define sigh, groan, + cheer, lol, etc to produce output if they weren't actually valid + commands. + + Properly deal with : in filename substitution + + Given something like + + blah.foo:*.foo + + expand it properly to something like + + blah.foo:baz.foo:bob.foo:bar.foo + + It already does this, if you have a file named like that... --Kim + + Directory commands don't handle blanks in filenames. If I have an + environment variable such as: + +% setenv TOMCAT '/c/Program? Files/Apache? Software Foundation/Tomcat? 5.0' +and then do the following, setenv complains that it has too many arguments. +% cd /tmp +% cd "$TOMCAT" +setenv: Too many arguments +% dirs +/c/Program? Files/Apache? Software Foundation/Tomcat? 5.0 /tmp +% pushd "$TOMCAT" +/c/Program? Files/Apache? Software Foundation/Tomcat? 5.0 +setenv: Too many arguments. +% pushd /tmp +/tmp /c/Program? Files/Apache? Software Foundation/Tomcat? 5.0 +% pushd +/c/Program? Files/Apache? Software Foundation/Tomcat? 5.0 /tmp +setenv: Too many arguments. + + Wish tcsh would feature fc (fix command) as in bash !Wish tcsh would + featuer fc (fix command) as in bash ! + + i wish for read-only CVS access to the sources (as i am on the + bleeding egde) + + Functions would be useful! As would being able to redirect stderr (or + other file descriptors) independently of stdout! -- Rohan Talip + + Don't complete commands with non-executable files. For example if I + have a file called README in a directory in the PATH, and I type R TAB + tcsh will complete README as a command. But README does not have the x + bit set, so it's kind of pointless to have that completion. + + --> Setting the shell variable "recognize_only_executables" will give + you this behavior. --Waz + + If I have in my .tcshrc: complete {cd,pushd} p/1/d/ and I type + "complete cd" at the shell prompt nothing is printed. It would be nice + if {cd,pushd} p/1/d/ was printed. + + --> I had programmed this feature a while ago but have not submitted + it because the implementation is not robust enough to keep TCSH from + crashing when special characters are part of the pattern. I'll get + back to it at some point! --Waz + + It would be nice if "set autolist" would be on by default. + + --- + + Unicode (UTF-8) doesn't seem to work. It's not even possible to "make + catalogs" in unicode environment. Also unicode support (and other + multibyte encodings) should depend on environment variables + (LC_CTYPE), not on "set dspmbyte". On unicode terminal translations + show empty characters instead of messages. + + In addition to message catalogs, there are more problems: +ipi:~/test/tcsh/bin> ls +tcsh åäö +ipi:~/test/tcsh/bin> set dspmbyte utf8 +ipi:~/test/tcsh/bin> ls ??? +ls: No match. + + Unicode is used more and more, and is default on many environments, so + this really should be fixed. --mpaananen + _________________________________________________________________ + + When I have a script called from complete I would like to have the the + existing text from the command line passed to that script so that it + can look at all existing words to detemine what it should output as + the completion list. + + For example: + + complete prog 'n/-x/`myscript`' + + Then when I do this: + + > prog -a A -b B -x + + The script would get 'prog -a A -b B -x ' which would allow the script + to base its -x completions on the options given for -a and -b (or if + they aren't present give nothing - or a message saying that they are + required). Setting a temporary environment variable before executing + the command would also work and would probably be safer. + + Perhaps this info is already available as a special variable that can + be manually passed to the script: complete prog 'n/-x/`myscript + $cmd_line`'? + + Update: I looked into this further by actually downloading the code + and looking through it. It doesn't seem that this information is + available anywhere, but I did manage to achieve what I wanted by + adding the following two lines around the call to tw_complete (line + 278, tw.parse.c 6.12.00): + + added> tsetenv(STRCURRCMDLINE, (Char *)&qline); + looking = tw_complete(cmd_start, &wordp, &pat, looking, &suf); + + added> Unsetenv(STRCURRCMDLINE); + + And I added a definition for STRCURRCMDLINE to be "CURRCMDLINE". + + This provides the environment variable CURRCMDLINE to any + script/program running under complete. The only issue I see is picking + a sufficiently obscure environment variable that noone else is likely + to use, but have it readable enough to understand what it is for. It + also shouldn't overwrite an existing ENV variable if it is already in + use. + _________________________________________________________________ + + Home | RecentChanges | Preferences + Edit text of this page | View other revisions + Last edited March 25, 2004 10:27 (diff) + Search: ____________________ diff --git a/tcsh/Y2K b/tcsh/Y2K new file mode 100644 index 0000000000..daf6cd0993 --- /dev/null +++ b/tcsh/Y2K @@ -0,0 +1,10 @@ +The tcsh code has been tested on a solaris-2.6 machine and a +NetBSD-1.3H machine running before, and after the year 2000. The +code has been also visually inspected for Y2K compliance problems. +Tcsh does not use time functions for anything but display purposes, +so its operation should not be affected assuming that the time +related functions of the c library work properly. + +Note: Since the last audit, tcsh-6.08.00 has been found to have +a minor problem with %y in the prompt (it will print 10 instead +of 00 in y2k). This has been fixed in tcsh-6.09.00. diff --git a/tcsh/complete.tcsh b/tcsh/complete.tcsh new file mode 100644 index 0000000000..657888c5b9 --- /dev/null +++ b/tcsh/complete.tcsh @@ -0,0 +1,1280 @@ +# +# example file using the new completion code +# +# Debian GNU/Linux +# /usr/share/doc/tcsh/examples/complete.gz +# +# This file may be read from user's ~/.cshrc or ~/.tcshrc file by +# decompressing it into the home directory as ~/.complete and +# then adding the line "source ~/.complete" and maybe defining +# some of the shell variables described below. +# +# Added two Debian-specific completions: dpkg and dpkg-deb (who +# wrote them?). Changed completions of several commands. The ones +# are evaluated if the `traditional_complete' shell variable is +# defined. +# +# Debian enhancements by Vadim Vygonets . +# Bugfixes and apt completions by Miklos Quartus . +# Cleanup by Martin A. Godisch . + +onintr - +if ( ! $?prompt ) goto end + +if ( $?tcsh ) then + if ( $tcsh != 1 ) then + set rev=$tcsh:r:r + set rel=$tcsh:r:e + if ( $rev > 6 || ( $rev > 5 && $rel > 1 ) ) then + set _has_complete=1 + endif + endif + unset rev rel +endif + +if ( ! $?_has_complete ) goto end + +if ( ! $?noglob ) set noglob _unset_noglob + +# Old TCSH versions don't define OSTYPE. +# Use a close approximation instead. + +if ( ! $?OSTYPE ) then + setenv OSTYPE `echo "$HOSTTYPE" | sed -e 's/^(i[3456]86|(amd|x86_)64)-//'` +endif + +if ( ! $?hosts ) set hosts + +foreach f ( "$HOME/."{,r,ssh/known_}hosts* \ + /usr/local/etc/csh.hosts /etc/hosts.equiv ) + if ( -r "$f" ) then + set hosts=($hosts `sed \ + -e 's/#.*//' \ + -e '/^[+-]@/d' \ + -e 's/^[-+]//' \ + -e 's/[[:space:]].*//' \ + -e 's/,/\n/g' "$f" \ + | sed -e '/^[.:[:xdigit:][:space:]]*$/d'`) + endif +end +unset f + +if ( -r "$HOME/.netrc" ) then + set hosts=($hosts `awk '$1 == "machine" { print $2 }' "$HOME/.netrc"`) +endif + +set hosts=(`echo $hosts | tr ' ' '\012' | sort -u`) + +if ( ! $#hosts ) then + # This is just a hint for the user. + set hosts=(ftp.funet.fi ftp.gnu.org ftp.uu.net) +endif + +complete ywho n/*/\$hosts/ # argument from list in $hosts +complete rsh p/1/\$hosts/ c/-/"(l n)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/ +complete ssh p/1/\$hosts/ c/-/"(l n)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/ +complete xrsh p/1/\$hosts/ c/-/"(l 8 e)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/ +complete rlogin p/1/\$hosts/ c/-/"(l 8 e)"/ n/-l/u/ +complete telnet p/1/\$hosts/ p/2/x:''/ n/*/n/ + +complete cd p/1/d/ # Directories only +complete chdir p/1/d/ +complete pushd p/1/d/ +complete popd p/1/d/ +complete pu p/1/d/ +complete po p/1/d/ +complete complete p/1/X/ # Completions only +complete uncomplete n/*/X/ +complete exec p/1/c/ # Commands only +complete trace p/1/c/ +complete strace p/1/c/ +complete which n/*/c/ +complete where n/*/c/ +complete skill p/1/c/ +complete dde p/1/c/ +complete adb c/-I/d/ n/-/c/ N/-/"(core)"/ p/1/c/ p/2/"(core)"/ +complete sdb p/1/c/ +complete dbx c/-I/d/ n/-/c/ N/-/"(core)"/ p/1/c/ p/2/"(core)"/ +complete xdb p/1/c/ +complete gdb n/-d/d/ n/*/c/ +complete ups p/1/c/ +complete set 'c/*=/f/' 'p/1/s/=' 'n/=/f/' +complete unset n/*/s/ +complete alias p/1/a/ # only aliases are valid +complete unalias n/*/a/ +complete xdvi n/*/f:*.dvi/ +complete dvips n/*/f:*.dvi/ +complete tex n/*/f:*.{tex,texi}/ +complete latex n/*/f:*.{tex,ltx}/ + +complete su \ + c/--/"(login fast preserve-environment command shell help version)"/ \ + c/-/"(f l m p c s -)"/ \ + n/{-c,--command}/c/ \ + n@{-s,--shell}@'`cat /etc/shells`'@ \ + n/*/u/ +complete cc \ + c/-[IL]/d/ \ + c@-l@'`\ls -1 /usr/lib/lib*.a | sed s%^.\*/lib%%\;s%\\.a\$%%`'@ \ + c/-/"(o l c g L I D U)"/ n/*/f:*.[coasi]/ +complete acc \ + c/-[IL]/d/ \ + c@-l@'`\ls -1 /usr/lang/SC1.0/lib*.a | sed s%^.\*/lib%%\;s%\\.a\$%%`'@ \ + c/-/"(o l c g L I D U)"/ n/*/f:*.[coasi]/ +complete gcc \ + c/-[IL]/d/ \ + c/-f/"(caller-saves cse-follow-jumps delayed-branch elide-constructors \ + expensive-optimizations float-store force-addr force-mem inline \ + inline-functions keep-inline-functions memoize-lookups \ + no-default-inline no-defer-pop no-function-cse omit-frame-pointer \ + rerun-cse-after-loop schedule-insns schedule-insns2 strength-reduce \ + thread-jumps unroll-all-loops unroll-loops syntax-only all-virtual \ + cond-mismatch dollars-in-identifiers enum-int-equiv no-asm no-builtin \ + no-strict-prototype signed-bitfields signed-char this-is-variable \ + unsigned-bitfields unsigned-char writable-strings call-saved-reg \ + call-used-reg fixed-reg no-common no-gnu-binutils nonnull-objects \ + pcc-struct-return pic PIC shared-data short-enums short-double \ + volatile)"/ \ + c/-W/"(all aggregate-return cast-align cast-qual comment conversion \ + enum-clash error format id-clash-len implicit missing-prototypes \ + no-parentheses pointer-arith return-type shadow strict-prototypes \ + switch uninitialized unused write-strings)"/ \ + c/-m/"(68000 68020 68881 bitfield fpa nobitfield rtd short c68000 c68020 \ + soft-float g gnu unix fpu no-epilogue)"/ \ + c/-d/"(D M N)"/ \ + c/-/"(f W vspec v vpath ansi traditional traditional-cpp trigraphs pedantic \ + x o l c g L I D U O O2 C E H B b V M MD MM i dynamic nodtdlib static \ + nostdinc undef)"/ \ + c/-l/f:*.a/ \ + n/*/f:*.{c,C,cc,o,a,s,i}/ +complete g++ n/*/f:*.{C,cc,o,s,i}/ +complete CC n/*/f:*.{C,cc,cpp,o,s,i}/ +complete rm \ + c/--/"(directory force interactive verbose recursive help version)"/ \ + c/-/"(d f i v r R -)"/ \ + n/*/f:^*.{c,cc,C,h,in}/ + # Protect precious files +complete vi n/*/f:^*.[oa]/ +complete bindkey \ + N/-a/b/ N/-c/c/ n/-[ascr]/'x:'/ \ + n/-[svedlr]/n/ c/-[vedl]/n/ c/-/"(a s k c v e d l r)"/ \ + n/-k/"(left right up down)"/ p/2-/b/ \ + p/1/'x:'/ + +complete find \ + n/-fstype/"(nfs 4.2)"/ \ + n/-name/f/ \ + n/-type/"(c b d f p l s)"/ \ + n/-user/u/ \ + n/-group/g/ \ + n/-exec/c/ \ + n/-ok/c/ \ + n/-cpio/f/ \ + n/-ncpio/f/ \ + n/-newer/f/ \ + c/-/"(fstype name perm prune type user nouser group nogroup size inum \ + atime mtime ctime exec ok print ls cpio ncpio newer xdev depth \ + daystart follow maxdepth mindepth noleaf version anewer cnewer \ + amin cmin mmin true false uid gid ilname iname ipath iregex links \ + lname empty path regex used xtype fprint fprint0 fprintf print0 \ + printf not a and o or)"/ \ + n/*/d/ + +complete -%* c/%/j/ # fill in the jobs builtin +complete {fg,bg,stop} c/%/j/ p/1/"(%)"// + +complete limit c/-/"(h)"/ n/*/l/ +complete unlimit c/-/"(h)"/ n/*/l/ + +#complete -co* p/0/"(compress)"/ # make compress completion +# # not ambiguous + +# "zcat" may be linked to "compress" or "gzip" +if (-X zcat) then + zcat --version >& /dev/null + if ($status != 0) then + complete zcat n/*/f:*.Z/ + else + complete zcat c/--/"(force help license quiet version)"/ \ + c/-/"(f h L q V -)"/ \ + n/*/f:*.{gz,Z,z,zip}/ + endif +endif + +complete finger c/*@/\$hosts/ n/*/u/@ +complete ping p/1/\$hosts/ +complete traceroute p/1/\$hosts/ + +complete {talk,ntalk,phone} \ + p/1/'`users | tr " " "\012" | uniq`'/ \ + n/*/\`who\ \|\ grep\ \$:1\ \|\ awk\ \'\{\ print\ \$2\ \}\'\`/ + +complete ftp c/-/"(d i g n v)"/ n/-/\$hosts/ p/1/\$hosts/ n/*/n/ + +# this one is simple... +#complete rcp c/*:/f/ C@[./\$~]*@f@ n/*/\$hosts/: +# From Michael Schroeder +# This one will rsh to the file to fetch the list of files! +complete rcp 'c%*@*:%`set q=$:-0;set q="$q:s/@/ /";set q="$q:s/:/ /";set q=($q " ");rsh $q[2] -l $q[1] ls -dp $q[3]\*`%' 'c%*:%`set q=$:-0;set q="$q:s/:/ /";set q=($q " ");rsh $q[1] ls -dp $q[2]\*`%' 'c%*@%$hosts%:' 'C@[./$~]*@f@' 'n/*/$hosts/:' + +complete dd \ + c/--/"(help version)"/ c/[io]f=/f/ \ + c/conv=*,/"(ascii ebcdic ibm block unblock \ + lcase notrunc ucase swab noerror sync)"/,\ + c/conv=/"(ascii ebcdic ibm block unblock \ + lcase notrunc ucase swab noerror sync)"/,\ + c/*=/x:''/ \ + n/*/"(if of conv ibs obs bs cbs files skip file seek count)"/= + +complete nslookup p/1/x:''/ p/2/\$hosts/ + +complete ar \ + c/[dmpqrtx]/"(c l o u v a b i)"/ \ + p/1/"(d m p q r t x)"// \ + p/2/f:*.a/ \ + p/*/f:*.o/ + +# these should be merged with the MH completion hacks below - jgotts +complete {refile,sprev,snext,scan,pick,rmm,inc,folder,show} \ + "c@+@F:$HOME/Mail/@" + +# these and interrupt handling from Jaap Vermeulen +complete {rexec,rxexec,rxterm,rmterm} \ + 'p/1/$hosts/' \ + 'c/-/(l L E)/' \ + 'n/-l/u/' \ + 'n/-L/f/' \ + 'n/-E/e/' \ + 'n/*/c/' +complete kill \ + 'c/-/S/' \ + 'c/%/j/' \ + 'n/*/`ps -u $LOGNAME | awk '"'"'{print $1}'"'"'`/' + +# these from Marc Horowitz +complete attach \ + 'n/-mountpoint/d/' \ + 'n/-m/d/' \ + 'n/-type/(afs nfs rvd ufs)/' \ + 'n/-t/(afs nfs rvd ufs)/' \ + 'n/-user/u/' \ + 'n/-U/u/' \ + 'c/-/(verbose quiet force printpath lookup debug map nomap remap zephyr \ + nozephyr readonly write mountpoint noexplicit explicit type \ + mountoptions nosetuid setuid override skipfsck lock user host)/' \ + 'n/-e/f/' \ + 'n/*/()/' +complete hesinfo \ + 'p/1/u/' \ + 'p/2/(passwd group uid grplist pcap pobox cluster filsys sloc service)/' + +complete ./configure \ + 'c@--{prefix,exec-prefix,bindir,sbindir,libexecdir,datadir,sysconfdir,sharedstatedir,localstatedir,infodir,mandir,srcdir,x-includes,x-libraries}=*@x:'@ \ + 'c/--cachefile=*/x:/' \ + 'c/--{enable,disable,with}-*/x://' \ + 'c/--*=/x://' \ + 'c/--/(prefix= exec-prefix= bindir= sbindir= libexecdir= datadir= \ + sysconfdir= sharedstatedir= localstatedir= infodir= mandir= \ + srcdir= x-includes= x-libraries= cachefile= enable- disable- \ + with- help no-create quiet silent version verbose )//' + +complete gs \ + 'c/-sDEVICE=/(x11 cdjmono cdj550 epson eps9high epsonc dfaxhigh dfaxlow \ + laserjet ljet4 sparc pbm pbmraw pgm pgmraw ppm ppmraw bit)/' \ + 'c/-sOutputFile=/f/' 'c/-s/(DEVICE OutputFile)/=' \ + 'c/-d/(NODISPLAY NOPLATFONTS NOPAUSE)/' 'n/*/f/' +complete perl 'n/-S/c/' +complete sccs \ + p/1/"(admin cdc check clean comb deledit delget delta diffs edit enter \ + fix get help info print prs prt rmdel sccsdiff tell unedit unget \ + val what)"/ + +complete printenv 'n/*/e/' +complete setenv 'p/1/e/' 'c/*:/f/' + +# these and method of setting hosts from Kimmo Suominen +if ( -f "$HOME/.mh_profile" && -X folders ) then + if ( ! $?FOLDERS ) setenv FOLDERS "`folders -fast -recurse`" + if ( ! $?MHA ) setenv MHA "`ali | sed -e '/^ /d' -e 's/:.*//'`" + + set folders = ( $FOLDERS ) + set mha = ( $MHA ) + + complete ali \ + 'c/-/(alias nolist list nonormalize normalize nouser user help)/' \ + 'n,-alias,f,' + + complete anno \ + 'c/-/(component noinplace inplace nodate date text help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete burst \ + 'c/-/(noinplace inplace noquiet quiet noverbose verbose help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete comp \ + 'c/-/(draftfolder draftmessage nodraftfolder editor noedit file form nouse use whatnowproc nowhatnowproc help)/' \ + 'c,+,$folders,' \ + 'n,-whatnowproc,c,' \ + 'n,-file,f,'\ + 'n,-form,f,'\ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete dist \ + 'c/-/(noannotate annotate draftfolder draftmessage nodraftfolder editor noedit form noinplace inplace whatnowproc nowhatnowproc help)/' \ + 'c,+,$folders,' \ + 'n,-whatnowproc,c,' \ + 'n,-form,f,'\ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete folder \ + 'c/-/(all nofast fast noheader header nopack pack noverbose verbose norecurse recurse nototal total noprint print nolist list push pop help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete folders \ + 'c/-/(all nofast fast noheader header nopack pack noverbose verbose norecurse recurse nototal total noprint print nolist list push pop help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete forw \ + 'c/-/(noannotate annotate draftfolder draftmessage nodraftfolder editor noedit filter form noformat format noinplace inplace digest issue volume whatnowproc nowhatnowproc help)/' \ + 'c,+,$folders,' \ + 'n,-whatnowproc,c,' \ + 'n,-filter,f,'\ + 'n,-form,f,'\ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete inc \ + 'c/-/(audit file noaudit nochangecur changecur file form format nosilent silent notruncate truncate width help)/' \ + 'c,+,$folders,' \ + 'n,-audit,f,'\ + 'n,-form,f,' + + complete mark \ + 'c/-/(add delete list sequence nopublic public nozero zero help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete mhmail \ + 'c/-/(body cc from subject help)/' \ + 'n,-cc,$mha,' \ + 'n,-from,$mha,' \ + 'n/*/$mha/' + + complete mhpath \ + 'c/-/(help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete msgchk \ + 'c/-/(nodate date nonotify notify help)/' + + complete msh \ + 'c/-/(prompt noscan scan notopcur topcur help)/' + + complete next \ + 'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \ + 'c,+,$folders,' \ + 'n,-moreproc,c,' \ + 'n,-showproc,c,' \ + 'n,-form,f,' + + complete packf \ + 'c/-/(file help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete pick \ + 'c/-/(and or not lbrace rbrace cc date from search subject to othercomponent after before datefield sequence nopublic public nozero zero nolist list help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete prev \ + 'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \ + 'c,+,$folders,' \ + 'n,-moreproc,c,' \ + 'n,-showproc,c,' \ + 'n,-form,f,' + + complete prompter \ + 'c/-/(erase kill noprepend prepend norapid rapid nodoteof doteof help)/' + + complete refile \ + 'c/-/(draft nolink link nopreserve preserve src file help)/' \ + 'c,+,$folders,' \ + 'n,-file,f,'\ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete rmf \ + 'c/-/(nointeractive interactive help)/' \ + 'c,+,$folders,' + + complete rmm \ + 'c/-/(help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete scan \ + 'c/-/(noclear clear form format noheader header width noreverse reverse file help)/' \ + 'c,+,$folders,' \ + 'n,-form,f,'\ + 'n,-file,f,'\ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete send \ + 'c/-/(alias draft draftfolder draftmessage nodraftfolder filter nofilter noformat format noforward forward nomsgid msgid nopush push noverbose verbose nowatch watch width help)/' \ + 'n,-alias,f,'\ + 'n,-filter,f,' + + complete show \ + 'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \ + 'c,+,$folders,' \ + 'n,-moreproc,c,' \ + 'n,-showproc,c,' \ + 'n,-form,f,'\ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete sortm \ + 'c/-/(datefield textfield notextfield limit nolimit noverbose verbose help)/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete vmh \ + 'c/-/(prompt vmhproc novmhproc help)/' \ + 'n,-vmhproc,c,' + + complete whatnow \ + 'c/-/(draftfolder draftmessage nodraftfolder editor noedit prompt help)/' + + complete whom \ + 'c/-/(alias nocheck check draft draftfolder draftmessage nodraftfolder help)/' \ + 'n,-alias,f,' + + complete plum \ + 'c/-/()/' \ + 'c,+,$folders,' \ + 'n,*,`(mark | sed "s/:.*//" ; echo next cur prev first last)|tr " " "\012" | sort -u`,' + + complete mail \ + 'c/-/()/' \ + 'n/*/$mha/' + +endif + +#from Dan Nicolaescu +if ( $?MODULESHOME ) then + alias Compl_module \ + 'find ${MODULEPATH:as/:/ /} -name .version -o -name .modulea\* -prune \ + -o -print | sed `echo "-e s@${MODULEPATH:as%:%/\*@@g -e s@%}/\*@@g"`' + complete module \ + 'p%1%(add load unload switch display avail use unuse update purge list \ + clear help initadd initrm initswitch initlist initclear)%' \ + 'n%{unl*,sw*,inits*}%`echo "$LOADEDMODULES:as/:/ /"`%' \ + 'n%{lo*,di*,he*,inita*,initr*}%`eval Compl_module`%' \ + 'N%{sw*,initsw*}%`eval Compl_module`%' \ + 'C%-%(-append)%' \ + 'n%{use,unu*,av*}%d%' \ + 'n%-append%d%' \ + 'C%[^-]*%`eval Compl_module`%' +endif + +# from George Cox +complete acroread 'p/*/f:*.{pdf,PDF}/' +complete apachectl 'c/*/(start stop restart fullstatus status graceful \ + configtest help)/' +complete appletviewer 'p/*/f:*.class/' +complete bison 'c/--/(debug defines file-prefix= fixed-output-files \ + help name-prefix= no-lines no-parser output= \ + token-table verbose version yacc)/' \ + 'c/-/(b d h k l n o p t v y V)/' \ + 'n/-b/f/' 'n/-o/f/' 'n/-p/f/' +complete bzcat c/--/"(help test quiet verbose license version)"/ \ + c/-/"(h t L V -)"/ n/*/f:*.{bz2,tbz}/ +complete bunzip2 c/--/"(help keep force test stdout quiet verbose \ + license version)"/ \ + c/-/"(h k f t c q v L V -)"/ \ + n/*/f:*.{bz2,tbz}/ +complete bzip2 c/--/"(help decompress compress keep force test \ + stdout quiet verbose license version small)"/ \ + c/-/"(h d z k f t c q v L V s 1 2 3 4 5 6 7 8 9 -)"/ \ + n/{-d,--decompress}/f:*.{bz2,tbz}/ \ + N/{-d,--decompress}/f:*.{bz2,tbz}/ n/*/f:^*.{bz2,tbz}/ +complete c++ 'p/*/f:*.{c++,cxx,c,cc,C,cpp}/' +complete co 'p@1@`\ls -1a RCS | sed -e "s/\(.*\),v/\1/"`@' +complete crontab 'n/-u/u/' +complete camcontrol 'p/1/(cmd debug defects devlist eject inquiry \ + modepage negotiate periphlist rescan reset \ + start stop tags tur)/' +complete ctlinnd 'p/1/(addhist allow begin cancel changegroup \ + checkfile drop feedinfo flush flushlogs go \ + hangup logmode mode name newgroup param pause \ + readers refile reject reload renumber reserve \ + rmgroup send shutdown kill throttle trace \ + xabort xexec)/' +complete cvs 'c/--/(help help-commands help-synonyms)/' \ + 'p/1/(add admin annotate checkout commit diff edit \ + editors export history import init log login \ + logout rdiff release remove rtag status tag \ + unedit update watch watchers)/' \ + 'n/-a/(edit unedit commit all none)/' \ + 'n/watch/(on off add remove)/' +complete svn 'C@file:///@`'"${HOME}/etc/tcsh/complete.d/svn"'`@@' \ + 'n@ls@(file:/// svn+ssh:// svn://)@@' \ + 'n@help@(add blame cat checkout cleanup commit copy \ + delete export help import info list ls \ + lock log merge mkdir move propdel propedit \ + propget proplist propset resolved revert \ + status switch unlock update)@' \ + 'p@1@(add blame cat checkout cleanup commit copy \ + delete export help import info list ls lock \ + log merge mkdir move propdel propedit propget \ + proplist propset resolved revert status switch \ + unlock update)@' + +complete cxx 'p/*/f:*.{c++,cxx,c,cc,C,cpp}/' +complete detex 'p/*/f:*.tex/' +complete edquota 'n/*/u/' +complete exec 'p/1/c/' +complete ghostview 'p/*/f:*.ps/' +complete gv 'p/*/f:*.ps/' +complete ifconfig 'p@1@`ifconfig -l`@' \ + 'n/*/(range phase link netmask mtu vlandev vlan \ + metric mediaopt down delete broadcast arp debug)/' +complete imake 'c/-I/d/' +complete ipfw 'p/1/(flush add delete list show zero)/' \ + 'n/add/(allow permit accept pass deny drop reject \ + reset count skipto num divert port tee port)/' +complete javac 'p/*/f:*.java/' +complete ldif2ldbm 'n/-i/f:*.ldif/' +complete libtool 'c/--mode=/(compile execute finish install link \ + uninstall)/' \ + 'c/--/(config debug dry-run features finish help \ + quiet silent version mode=)/' +complete libtoolize 'c/--/(automake copy debug dry-run force help ltdl \ + ltdl-tar version)/' +complete links 'c/-/(assume-codepage async-dns download-dir \ + format-cache-size ftp-proxy help http-proxy \ + max-connections max-connections-to-host \ + memory-cache-size receive-timeout retries \ + unrestartable-receive-timeout version)/' +complete natd c/-/'(alias_address config deny_incoming dynamic \ + inport interface log log_denied log_facility \ + outport outport port pptpalias proxy_only \ + proxy_rule redirect_address redirect_port \ + reverse same_ports unregistered_only use_sockets \ + verbose)'/ \ + 'n@-interface@`ifconfig -l`@' +complete netstat 'n@-I@`ifconfig -l`@' +complete objdump 'c/--/(adjust-vma= all-headers architecture= \ + archive-headers debugging demangle disassemble \ + disassemble-all disassemble-zeroes dynamic-reloc \ + dynamic-syms endian= file-headers full-contents \ + headers help info line-numbers no-show-raw-insn \ + prefix-addresses private-headers reloc \ + section-headers section=source stabs \ + start-address= stop-address= syms target= \ + version wide)/' \ + 'c/-/(a h i f C d D p r R t T x s S l w)/' +complete xmodmap 'c/-/(display help grammar verbose quiet n e pm pk \ + pke pp)/' +complete lynx 'c/-/(accept_all_cookies anonymous assume_charset= \ + assume_local_charset= assume_unrec_charset= \ + auth= base book buried_news cache= case cfg= \ + child cookie_file= cookies core crawl \ + debug_partial display= dump editor= emacskeys \ + enable_scrollback error_file= force_html \ + force_secure forms_options from ftp get_data \ + head help hiddenlinks= historical homepage= \ + image_links index= ismap link= localhost \ + mime_header minimal newschunksize= \ + newsmaxchunk= nobrowse nocc nocolor \ + nofilereferer nolist nolog nopause noprint \ + noredir noreferer nostatus number_links \ + partial partial_thres pauth= popup post_data \ + preparsed print pseudo_inlines raw realm \ + reload restrictions= resubmit_posts rlogin \ + selective show_cursor soft_dquotes source \ + stack_dump startfile_ok tagsoup telnet term= \ + tlog trace traversal underscore useragent= \ + validate verbose version vikeys width=)/' \ + 'c/(http|ftp)/$URLS/' +complete gmake 'c/{--directory=,--include-dir=}/d/' \ + 'c/{--assume-new,--assume-old,--makefile,--new-file,--what-if,--file}/f/' \ + 'c/--/(assume-new= assume-old= debug directory= \ + dry-run environment-overrides file= help \ + ignore-errors include-dir= jobs[=N] just-print \ + keep-going load-average[=N] makefile= \ + max-load[=N] new-file= no-builtin-rules \ + no-keep-going no-print-directory old-file= \ + print-data-base print-directory question quiet \ + recon silent stop touch version \ + warn-undefined-variables what-if=)/' \ + 'n@*@`cat -s GNUMakefile Makefile makefile |& sed -n -e "/No such file/d" -e "s/^\([A-Za-z0-9-]*\):.*/\1/p"`@' \ + 'n/=/f/' \ + 'n/-f/f/' +complete mixer p/1/'(vol bass treble synth pcm speaker mic cd mix \ + pcm2 rec igain ogain line1 line2 line3)'/ \ + p@2@'`mixer $:-1 | awk \{\ print\ \$7\ \}`'@ + +complete mpg123 'c/--/(2to1 4to1 8bit aggressive au audiodevice auth \ + buffer cdr check doublespeed equalizer frames \ + gain halfspeed headphones left lineout list \ + mix mono proxy quiet random rate reopen resync \ + right scale shuffle single0 single1 skip \ + speaker stdout stereo test verbose wav)/' +complete mysqladmin 'n/*/(create drop extended-status flush-hosts \ + flush-logs flush-status flush-tables \ + flush-privileges kill password ping \ + processlist reload refresh shutdown status \ + variables version)/' + +complete mutt \ + "c@-f=@F:${HOME}/Mail/@" \ + n/-a/f/ \ + n/-F/f/ \ + n/-H/f/ \ + n/-s/x:''/ \ + n/-e/x:''/ \ + n@-b@'`cat "${HOME}/.muttrc-alias" | awk '"'"'{print $2 }'"'"\`@ \ + n@-c@'`cat "${HOME}/.muttrc-alias" | awk '"'"'{print $2 }'"'"\`@ \ + n@*@'`cat "${HOME}/.muttrc-alias" | awk '"'"'{print $2 }'"'"\`@ + +complete ndc 'n/*/(status dumpdb reload stats trace notrace \ + querylog start stop restart )/' + +complete nm \ + 'c/--radix=/x:/' \ + 'c/--target=/x:/' \ + 'c/--format=/(bsd sysv posix)/n/' \ + 'c/--/(debugsyms extern-only demangle dynamic print-armap \ + print-file-name numeric-sort no-sort reverse-sort \ + size-sort undefined-only portability target= radix= \ + format= defined-only\ line-numbers no-demangle version \ + help)//' \ + 'n/*/f:^*.{h,c,cc,s,S}/' + +complete nmap 'n@-e@`ifconfig -l`@' 'p/*/$hostnames/' +complete perldoc 'n@*@`\ls -1 /usr/libdata/perl/5.*/pod | sed s%\\.pod.\*\$%%`@' +complete postfix 'n/*/(start stop reload abort flush check)/' +complete postmap 'n/1/(hash: regexp:)/' 'c/hash:/f/' 'c/regexp:/f/' +complete rcsdiff 'p@1@`\ls -1a RCS | sed -e "s/\(.*\),v/\1/"`@' +complete X 'c/-/(I a ac allowMouseOpenFail allowNonLocalModInDev \ + allowNonLocalXvidtune ar1 ar2 audit auth bestRefresh \ + bgamma bpp broadcast bs c cc class co core deferglyphs \ + disableModInDev disableVidMode displayID dpi dpms f fc \ + flipPixels fn fp gamma ggamma help indirect kb keeptty \ + ld lf logo ls nolisten string noloadxkb nolock nopn \ + once p pn port probeonly query quiet r rgamma s \ + showconfig sp su t terminate to tst v verbose version \ + weight wm x xkbdb xkbmap)/' +complete users 'c/--/(help version)/' 'p/1/x:""/' +complete vidcontrol 'p/1/(132x25 132x30 132x43 132x50 132x60 40x25 80x25 \ + 80x30 80x43 80x50 80x60 EGA_80x25 EGA_80x43 \ + VESA_132x25 VESA_132x30 VESA_132x43 VESA_132x50 \ + VESA_132x60 VESA_800x600 VGA_320x200 VGA_40x25 \ + VGA_80x25 VGA_80x30 VGA_80x50 VGA_80x60)/' +complete vim 'n/*/f:^*.[oa]/' +complete where 'n/*/c/' +complete which 'n/*/c/' +complete wmsetbg 'c/-/(display D S a b c d e m p s t u w)/' \ + 'c/--/(back-color center colors dither help match \ + maxscale parse scale smooth tile update-domain \ + update-wmaker version workspace)/' +complete xdb 'p/1/c/' +complete xdvi 'c/-/(allowshell debug display expert gamma hushchars \ + hushchecksums hushspecials install interpreter keep \ + margins nogrey noinstall nomakepk noscan paper safer \ + shrinkbuttonn thorough topmargin underlink version)/' \ + 'n/-paper/(a4 a4r a5 a5r)/' 'p/*/f:*.dvi/' +complete xlock 'c/-/(allowaccess allowroot debug description \ + echokeys enablesaver grabmouse grabserver hide inroot \ + install inwindow mono mousemotion nolock remote \ + resetsaver sound timeelapsed use3d usefirst verbose \ + wireframe background batchcount bg bitmap both3d \ + count cycles delay delta3d display dpmsoff \ + dpmsstandby dpmssuspend endCmd erasedelay erasemode \ + erasetime fg font foreground geometry help \ + icongeometry info invalid left3d lockdelay logoutCmd \ + mailCmd mailIcon message messagefile messagefont \ + messagesfile mode name ncolors nice nomailIcon none3d \ + parent password planfont program resources right3d \ + saturation size startCmd timeout username validate \ + version visual)/' 'n/-mode/(ant atlantis ball bat \ + blot bouboule bounce braid bubble bubble3d bug cage \ + cartoon clock coral crystal daisy dclock decay deco \ + demon dilemma discrete drift eyes fadeplot flag flame \ + flow forest galaxy gears goop grav helix hop hyper \ + ico ifs image invert julia kaleid kumppa lament laser \ + life life1d life3d lightning lisa lissie loop lyapunov \ + mandelbrot marquee matrix maze moebius morph3d \ + mountain munch nose pacman penrose petal pipes puzzle \ + pyro qix roll rotor rubik shape sierpinski slip sphere \ + spiral spline sproingies stairs star starfish strange \ + superquadrics swarm swirl tetris thornbird triangle \ + tube turtle vines voters wator wire world worm xjack \ + blank bomb random)/' +complete xfig 'c/-/(display)/' 'p/*/f:*.fig/' +complete wget c/--/"(accept= append-output= background cache= \ + continue convert-links cut-dirs= debug \ + delete-after directory-prefix= domains= \ + dont-remove-listing dot-style= exclude-directories= \ + exclude-domains= execute= follow-ftp \ + force-directories force-html glob= header= help \ + http-passwd= http-user= ignore-length \ + include-directories= input-file= level= mirror \ + no-clobber no-directories no-host-directories \ + no-host-lookup no-parent non-verbose \ + output-document= output-file= passive-ftp \ + proxy-passwd= proxy-user= proxy= quiet quota= \ + recursive reject= relative retr-symlinks save-headers \ + server-response span-hosts spider timeout= \ + timestamping tries= user-agent= verbose version wait=)"/ + +# these from Tom Warzeka + +# this one works but is slow and doesn't descend into subdirectories +# complete cd C@[./\$~]*@d@ \ +# p@1@'`\ls -1F . $cdpath | grep /\$ | sort -u`'@ n@*@n@ + +if ( -r /etc/shells ) then + complete setenv p@1@e@ n@DISPLAY@\$hosts@: n@SHELL@'`cat /etc/shells`'@ +else + complete setenv p@1@e@ n@DISPLAY@\$hosts@: +endif +complete unsetenv n/*/e/ + +set _maildir = /var/mail +if (-r "$HOME/.mailrc") then + complete mail c/-/"(e i f n s u v)"/ c/*@/\$hosts/ \ + "c@+@F:$HOME/Mail@" C@[./\$~]@f@ n/-s/x:''/ \ + n@-u@T:$_maildir@ n/-f/f/ \ + n@*@'`sed -n s/alias//p "$HOME/.mailrc" | \ + tr -s " " " " | cut -f 2`'@ +else + complete mail c/-/"(e i f n s u v)"/ c/*@/\$hosts/ \ + "c@+@F:$HOME/Mail@" C@[./\$~]@f@ n/-s/x:''/ \ + n@-u@T:$_maildir@ n/-f/f/ n/*/u/ +endif +unset _maildir + +if (! $?MANPATH) then + if (-r /usr/share/man) then + setenv MANPATH /usr/share/man: + else + setenv MANPATH /usr/man: + endif +endif + +if ($?traditional_complete) then + # use of $MANPATH from Dan Nicolaescu + # use of 'find' adapted from Lubomir Host + complete man \ + 'n@1@`set q = "$MANPATH:as%:%/man1 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.1.\*\$%%`@'\ + 'n@2@`set q = "$MANPATH:as%:%/man2 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.2.\*\$%%`@'\ + 'n@3@`set q = "$MANPATH:as%:%/man3 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.3.\*\$%%`@'\ + 'n@4@`set q = "$MANPATH:as%:%/man4 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.4.\*\$%%`@'\ + 'n@5@`set q = "$MANPATH:as%:%/man5 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.5.\*\$%%`@'\ + 'n@6@`set q = "$MANPATH:as%:%/man6 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.6.\*\$%%`@'\ + 'n@7@`set q = "$MANPATH:as%:%/man7 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.7.\*\$%%`@'\ + 'n@8@`set q = "$MANPATH:as%:%/man8 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.8.\*\$%%`@'\ + 'n@9@`set q = "$MANPATH:as%:%/man9 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.9.\*\$%%`@'\ + 'n@0@`set q = "$MANPATH:as%:%/man0 %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.0.\*\$%%`@'\ + 'n@n@`set q = "$MANPATH:as%:%/mann %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.n.\*\$%%`@'\ + 'n@o@`set q = "$MANPATH:as%:%/mano %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.o.\*\$%%`@'\ + 'n@l@`set q = "$MANPATH:as%:%/manl %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.l.\*\$%%`@'\ + 'n@p@`set q = "$MANPATH:as%:%/manp %" ; \ls -1 $q |& sed -e s%^.\*:.\*\$%% -e s%\\.p.\*\$%%`@'\ + c@-@"(- f k M P s S t)"@ n@-f@c@ n@-k@x:''@ n@-[MP]@d@ \ + 'N@-[MP]@`\ls -1 $:-1/man? |& sed -n s%\\..\\+\$%%p`@' \ + 'n@-[sS]@`\ls -1 $MANPATH:as%:% % |& sed -n s%^man%%p | sort -u`@'\ + 'n@*@`find $MANPATH:as%:% % \( -type f -o -type l \) -printf "%f " |& sed -e "s%find: .*: No such file or directory%%" -e "s%\([^\.]\+\)\.\([^ ]*\) %\1 %g"`@' + #n@*@c@ # old way -- commands only +else + complete man n@1@'`\ls -1 /usr/man/man1 | sed s%\\.1.\*\$%%`'@ \ + n@2@'`\ls -1 /usr/man/man2 | sed s%\\.2.\*\$%%`'@ \ + n@3@'`\ls -1 /usr/man/man3 | sed s%\\.3.\*\$%%`'@ \ + n@4@'`\ls -1 /usr/man/man4 | sed s%\\.4.\*\$%%`'@ \ + n@5@'`\ls -1 /usr/man/man5 | sed s%\\.5.\*\$%%`'@ \ + n@6@'`\ls -1 /usr/man/man6 | sed s%\\.6.\*\$%%`'@ \ + n@7@'`\ls -1 /usr/man/man7 | sed s%\\.7.\*\$%%`'@ \ + n@8@'`\ls -1 /usr/man/man8 | sed s%\\.8.\*\$%%`'@ \ +n@9@'`[ -r /usr/man/man9 ] && \ls -1 /usr/man/man9 | sed s%\\.9.\*\$%%`'@ \ +n@0@'`[ -r /usr/man/man0 ] && \ls -1 /usr/man/man0 | sed s%\\.0.\*\$%%`'@ \ +n@new@'`[ -r /usr/man/mann ] && \ls -1 /usr/man/mann | sed s%\\.n.\*\$%%`'@ \ +n@old@'`[ -r /usr/man/mano ] && \ls -1 /usr/man/mano | sed s%\\.o.\*\$%%`'@ \ +n@local@'`[ -r /usr/man/manl ] && \ls -1 /usr/man/manl | sed s%\\.l.\*\$%%`'@ \ +n@public@'`[ -r /usr/man/manp ]&& \ls -1 /usr/man/manp | sed s%\\.p.\*\$%%`'@ \ + c/-/"(- f k P s t)"/ n/-f/c/ n/-k/x:''/ n/-P/d/ \ + N@-P@'`\ls -1 $:-1/man? | sed s%\\..\*\$%%`'@ n/*/c/ +endif + +complete ps c/-t/x:''/ c/-/"(a c C e g k l S t u v w x)"/ \ + n/-k/x:''/ N/-k/x:''/ n/*/x:''/ +complete compress c/-/"(c f v b)"/ n/-b/x:''/ n/*/f:^*.Z/ +complete uncompress c/-/"(c f v)"/ n/*/f:*.Z/ + +complete uuencode p/1/f/ p/2/x:''/ n/*/n/ +complete uudecode c/-/"(f)"/ n/-f/f:*.{uu,UU}/ p/1/f:*.{uu,UU}/ n/*/n/ + +complete xhost c/[+-]/\$hosts/ n/*/\$hosts/ +complete xpdf c/-/"(z g remote raise quit cmap rgb papercolor \ + eucjp t1lib freetype ps paperw paperh level1 \ + upw fullscreen cmd q v h help)"/ \ + n/-z/x:''/ \ + n/-g/x:''/ n/-remote/x:''/ \ + n/-rgb/x:''/ n/-papercolor/x:''/ \ + n/-{t1lib,freetype}/x:''/ \ + n/-ps/x:''/ n/-paperw/x:''/ \ + n/-paperh/x:''/ n/-upw/x:''/ \ + n/-/f:*.{pdf,PDF}/ \ + N/-{z,g,remote,rgb,papercolor,t1lib,freetype,ps,paperw,paperh,upw}/f:*.{pdf,PDF}/ \ + N/-/x:''/ p/1/f:*.{pdf,PDF}/ p/2/x:''/ + +complete tcsh c/-D*=/'x:'/ c/-D/'x:'/ \ + c/-/"(b c d D e f F i l m n q s t v V x X -version)"/ \ + n/-c/c/ n/{-l,--version}/n/ n/*/'f:*.{,t}csh'/ + +complete rpm c/--/"(query verify nodeps nofiles nomd5 noscripts \ + nogpg nopgp install upgrade freshen erase allmatches \ + notriggers repackage test rebuild recompile initdb \ + rebuilddb addsign resign querytags showrc setperms \ + setugids all file group package querybynumber qf \ + triggeredby whatprovides whatrequires changelog \ + configfiles docfiles dump filesbypkg info last list \ + provides queryformat requires scripts state triggers \ + triggerscripts allfiles badreloc excludepath checksig \ + excludedocs force hash ignoresize ignorearch ignoreos \ + includedocs justdb noorder oldpackage percent prefix \ + relocate replace-files replacepkgs buildroot clean \ + nobuild rmsource rmspec short-circuit sign target \ + help version quiet rcfile pipe dbpath root specfile)"/\ + c/-/"(q V K i U F e ba bb bp bc bi bl bs ta tb tp tc \ + ti tl ts a f g p c d l R s h ? v vv -)"/ \ + n/{-f,--file}/f/ n/{-g,--group}/g/ n/--pipe/c/ n/--dbpath/d/ \ + n/--querybynumber/x:''/ n/--triggeredby/x:''/\ + n/--what{provides,requires}/x:''/ n/--root/d/ \ + n/--{qf,queryformat}/x:''/ n/--buildroot/d/ \ + n/--excludepath/x:''/ n/--prefix/x:''/ \ + n/--relocate/x:''/ n/--target/x:''/\ + n/--rcfile/x:''/ n/--specfile/x:''/ \ + n/{-[iUFep],--{install,upgrade,freshen,erase,package}}/f:*.rpm/ + +# these conform to the latest GNU versions available at press time ... +# updates by John Gotts +if (-X emacs) then + # TW note: if your version of GNU Emacs supports the "--version" option, + # uncomment this line and comment the next to automatically + # detect the version, else set "_emacs_ver" to your version. + #set _emacs_ver=`emacs --version | sed -e 's%GNU Emacs %%' -e q | cut -d . -f1-2` + set _emacs_ver=21.3 + set _emacs_dir=`which emacs | sed s%/bin/emacs%%` + complete emacs c/--/"(batch terminal display no-windows no-init-file \ + user debug-init unibyte multibyte version help \ + no-site-file funcall load eval insert kill)"/ \ + c/-/"(t d nw q u f l -)"/ c/+/x:''/ \ + n/{-t,--terminal}/x:''/ n/{-d,--display}/x:''/ \ + n/{-u,--user}/u/ n/{-f,--funcall}/x:''/ \ + n@{-l,--load}@F:$_emacs_dir/share/emacs/$_emacs_ver/lisp@ \ + n/--eval/x:''/ n/--insert/f/ n/*/f:^*[\#~]/ + unset _emacs_ver _emacs_dir +endif + +complete gzcat c/--/"(force help license quiet version)"/ \ + c/-/"(f h L q V -)"/ n/*/f:*.{gz,Z,z,zip}/ +complete gzip c/--/"(stdout to-stdout decompress uncompress \ + force help list license no-name quiet recurse \ + suffix test verbose version fast best)"/ \ + c/-/"(c d f h l L n q r S t v V 1 2 3 4 5 6 7 8 9 -)"/\ + n/{-S,--suffix}/x:''/ \ + n/{-d,--{de,un}compress}/f:*.{gz,Z,z,zip,taz,tgz}/ \ + N/{-d,--{de,un}compress}/f:*.{gz,Z,z,zip,taz,tgz}/ \ + n/*/f:^*.{gz,Z,z,zip,taz,tgz}/ +complete {gunzip,ungzip} c/--/"(stdout to-stdout force help list license \ + no-name quiet recurse suffix test verbose version)"/ \ + c/-/"(c f h l L n q r S t v V -)"/ \ + n/{-S,--suffix}/x:''/ \ + n/*/f:*.{gz,Z,z,zip,taz,tgz}/ +complete zgrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\ + c/-/"(A b B c C e f h i l n s v V w x)"/ \ + p/1/x:''/ N/-*e/f/ \ + n/-*e/x:''/ n/-*f/f/ n/*/f/ +complete zegrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\ + c/-/"(A b B c C e f h i l n s v V w x)"/ \ + p/1/x:''/ N/-*e/f/ \ + n/-*e/x:''/ n/-*f/f/ n/*/f/ +complete zfgrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\ + c/-/"(A b B c C e f h i l n s v V w x)"/ \ + p/1/x:''/ N/-*e/f/ \ + n/-*e/x:''/ n/-*f/f/ n/*/f/ +complete znew c/-/"(f t v 9 P K)"/ n/*/f:*.Z/ +complete zmore n/*/f:*.{gz,Z,z,zip}/ +complete zfile n/*/f:*.{gz,Z,z,zip,taz,tgz}/ +complete ztouch n/*/f:*.{gz,Z,z,zip,taz,tgz}/ +complete zforce n/*/f:^*.{gz,tgz}/ + +complete dcop 'p/1/`$:0`/ /' \ + 'p/2/`$:0 $:1 | awk \{print\ \$1\}`/ /' \ + 'p/3/`$:0 $:1 $:2 | sed "s%.* \(.*\)(.*%\1%"`/ /' + + +complete grep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\ + c/--/"(extended-regexp fixed-regexp basic-regexp \ + regexp file ignore-case word-regexp line-regexp \ + no-messages revert-match version help byte-offset \ + line-number with-filename no-filename quiet silent \ + text directories recursive files-without-match \ + files-with-matches count before-context after-context \ + context binary unix-byte-offsets)"/ \ + c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \ + v w x)"/ \ + p/1/x:''/ N/-*e/f/ \ + n/-*e/x:''/ n/-*f/f/ n/*/f/ +complete egrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\ + c/--/"(extended-regexp fixed-regexp basic-regexp \ + regexp file ignore-case word-regexp line-regexp \ + no-messages revert-match version help byte-offset \ + line-number with-filename no-filename quiet silent \ + text directories recursive files-without-match \ + files-with-matches count before-context after-context \ + context binary unix-byte-offsets)"/ \ + c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \ + v w x)"/ \ + p/1/x:''/ N/-*e/f/ \ + n/-*e/x:''/ n/-*f/f/ n/*/f/ +complete fgrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\ + c/--/"(extended-regexp fixed-regexp basic-regexp \ + regexp file ignore-case word-regexp line-regexp \ + no-messages revert-match version help byte-offset \ + line-number with-filename no-filename quiet silent \ + text directories recursive files-without-match \ + files-with-matches count before-context after-context \ + context binary unix-byte-offsets)"/ \ + c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \ + v w x)"/ \ + p/1/x:''/ N/-*e/f/ \ + n/-*e/x:''/ n/-*f/f/ n/*/f/ + +complete sed c/--/"(quiet silent version help expression file)"/ \ + c/-/"(n V e f -)"/ n/{-e,--expression}/x:'