Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2020,2023 Thomas E. Dickey * |
| 3 | * Copyright 1998-2012,2015 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | * * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | * copy of this software and associated documentation files (the * |
| 7 | * "Software"), to deal in the Software without restriction, including * |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | * distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | * copies of the Software, and to permit persons to whom the Software is * |
| 11 | * furnished to do so, subject to the following conditions: * |
| 12 | * * |
| 13 | * The above copyright notice and this permission notice shall be included * |
| 14 | * in all copies or substantial portions of the Software. * |
| 15 | * * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | * * |
| 24 | * Except as contained in this notice, the name(s) of the above copyright * |
| 25 | * holders shall not be used in advertising or otherwise to promote the * |
| 26 | * sale, use or other dealings in this Software without prior written * |
| 27 | * authorization. * |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * |
| 32 | * and: Eric S. Raymond <esr@snark.thyrsus.com> * |
| 33 | * and: Thomas E. Dickey 1996-on * |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 34 | * and: Juergen Pfeifer 2008 * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 35 | ****************************************************************************/ |
| 36 | |
| 37 | /* |
| 38 | * Terminfo-only terminal setup routines: |
| 39 | * |
| 40 | * int restartterm(const char *, int, int *) |
| 41 | */ |
| 42 | |
| 43 | #include <curses.priv.h> |
| 44 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 45 | MODULE_ID("$Id: lib_restart.c,v 1.18 2023/04/29 19:01:25 tom Exp $") |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 46 | |
| 47 | NCURSES_EXPORT(int) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 48 | NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx |
| 49 | NCURSES_CONST char *termp, |
| 50 | int filenum, |
| 51 | int *errret) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 52 | { |
| 53 | int result; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 54 | #ifdef USE_TERM_DRIVER |
| 55 | TERMINAL *new_term = 0; |
| 56 | #endif |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 57 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 58 | START_TRACE(); |
| 59 | T((T_CALLED("restartterm(%p,%s,%d,%p)"), |
| 60 | (void *) SP_PARM, |
| 61 | termp, |
| 62 | filenum, |
| 63 | (void *) errret)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 64 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 65 | if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 66 | result = ERR; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 67 | } else if (SP_PARM != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 68 | TTY_FLAGS save_flags = SP_PARM->_tty_flags; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 70 | #ifdef USE_TERM_DRIVER |
| 71 | SP_PARM->_term = new_term; |
| 72 | #endif |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 73 | if (save_flags._echo) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 74 | NCURSES_SP_NAME(echo) (NCURSES_SP_ARG); |
| 75 | } else { |
| 76 | NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); |
| 77 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 78 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 79 | if (save_flags._cbreak) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 80 | NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); |
| 81 | NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 82 | } else if (save_flags._raw) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 83 | NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); |
| 84 | NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 85 | } else { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 86 | NCURSES_SP_NAME(nocbreak) (NCURSES_SP_ARG); |
| 87 | NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 88 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 89 | if (save_flags._nl) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 90 | NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); |
| 91 | } else { |
| 92 | NCURSES_SP_NAME(nonl) (NCURSES_SP_ARG); |
| 93 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 94 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 95 | NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 96 | |
| 97 | #if USE_SIZECHANGE |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 98 | _nc_update_screensize(SP_PARM); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 99 | #endif |
| 100 | |
| 101 | result = OK; |
| 102 | } else { |
| 103 | result = ERR; |
| 104 | } |
| 105 | returnCode(result); |
| 106 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 107 | |
| 108 | #if NCURSES_SP_FUNCS |
| 109 | NCURSES_EXPORT(int) |
| 110 | restartterm(NCURSES_CONST char *termp, int filenum, int *errret) |
| 111 | { |
| 112 | START_TRACE(); |
| 113 | return NCURSES_SP_NAME(restartterm) (CURRENT_SCREEN, termp, filenum, errret); |
| 114 | } |
| 115 | #endif |