diff options
Diffstat (limited to 'scripts/kconfig/libcurses/addstr.c')
| -rw-r--r-- | scripts/kconfig/libcurses/addstr.c | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/addstr.c b/scripts/kconfig/libcurses/addstr.c new file mode 100644 index 000000000..bc286d4b5 --- /dev/null +++ b/scripts/kconfig/libcurses/addstr.c | |||
| @@ -0,0 +1,241 @@ | |||
| 1 | /* PDCurses */ | ||
| 2 | |||
| 3 | #include "curspriv.h" | ||
| 4 | |||
| 5 | /*man-start************************************************************** | ||
| 6 | |||
| 7 | addstr | ||
| 8 | ------ | ||
| 9 | |||
| 10 | ### Synopsis | ||
| 11 | |||
| 12 | int addstr(const char *str); | ||
| 13 | int addnstr(const char *str, int n); | ||
| 14 | int waddstr(WINDOW *win, const char *str); | ||
| 15 | int waddnstr(WINDOW *win, const char *str, int n); | ||
| 16 | int mvaddstr(int y, int x, const char *str); | ||
| 17 | int mvaddnstr(int y, int x, const char *str, int n); | ||
| 18 | int mvwaddstr(WINDOW *win, int y, int x, const char *str); | ||
| 19 | int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n); | ||
| 20 | |||
| 21 | int addwstr(const wchar_t *wstr); | ||
| 22 | int addnwstr(const wchar_t *wstr, int n); | ||
| 23 | int waddwstr(WINDOW *win, const wchar_t *wstr); | ||
| 24 | int waddnwstr(WINDOW *win, const wchar_t *wstr, int n); | ||
| 25 | int mvaddwstr(int y, int x, const wchar_t *wstr); | ||
| 26 | int mvaddnwstr(int y, int x, const wchar_t *wstr, int n); | ||
| 27 | int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr); | ||
| 28 | int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n); | ||
| 29 | |||
| 30 | ### Description | ||
| 31 | |||
| 32 | These routines write all the characters of the null-terminated string | ||
| 33 | str or wide-character string wstr to the given window. The | ||
| 34 | functionality is similar to calling waddch() once for each character | ||
| 35 | in the string; except that, when PDCurses is built with wide- | ||
| 36 | character support enabled, the narrow-character functions treat the | ||
| 37 | string as a multibyte string in the current locale, and convert it. | ||
| 38 | The routines with n as the last argument write at most n characters; | ||
| 39 | if n is negative, then the entire string will be added. | ||
| 40 | |||
| 41 | ### Return Value | ||
| 42 | |||
| 43 | All functions return OK or ERR. | ||
| 44 | |||
| 45 | ### Portability | ||
| 46 | |||
| 47 | Function | X/Open | ncurses | NetBSD | ||
| 48 | :---------------------|:------:|:-------:|:------: | ||
| 49 | addstr | Y | Y | Y | ||
| 50 | waddstr | Y | Y | Y | ||
| 51 | mvaddstr | Y | Y | Y | ||
| 52 | mvwaddstr | Y | Y | Y | ||
| 53 | addnstr | Y | Y | Y | ||
| 54 | waddnstr | Y | Y | Y | ||
| 55 | mvaddnstr | Y | Y | Y | ||
| 56 | mvwaddnstr | Y | Y | Y | ||
| 57 | addwstr | Y | Y | Y | ||
| 58 | waddwstr | Y | Y | Y | ||
| 59 | mvaddwstr | Y | Y | Y | ||
| 60 | mvwaddwstr | Y | Y | Y | ||
| 61 | addnwstr | Y | Y | Y | ||
| 62 | waddnwstr | Y | Y | Y | ||
| 63 | mvaddnwstr | Y | Y | Y | ||
| 64 | mvwaddnwstr | Y | Y | Y | ||
| 65 | |||
| 66 | **man-end****************************************************************/ | ||
| 67 | |||
| 68 | int waddnstr(WINDOW *win, const char *str, int n) | ||
| 69 | { | ||
| 70 | int i = 0; | ||
| 71 | |||
| 72 | PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n)); | ||
| 73 | |||
| 74 | if (!win || !str) | ||
| 75 | return ERR; | ||
| 76 | |||
| 77 | while (str[i] && (i < n || n < 0)) | ||
| 78 | { | ||
| 79 | #ifdef PDC_WIDE | ||
| 80 | wchar_t wch; | ||
| 81 | int retval = PDC_mbtowc(&wch, str + i, n >= 0 ? n - i : 6); | ||
| 82 | |||
| 83 | if (retval <= 0) | ||
| 84 | return OK; | ||
| 85 | |||
| 86 | i += retval; | ||
| 87 | #else | ||
| 88 | chtype wch = (unsigned char)(str[i++]); | ||
| 89 | #endif | ||
| 90 | if (waddch(win, wch) == ERR) | ||
| 91 | return ERR; | ||
| 92 | } | ||
| 93 | |||
| 94 | return OK; | ||
| 95 | } | ||
| 96 | |||
| 97 | int addstr(const char *str) | ||
| 98 | { | ||
| 99 | PDC_LOG(("addstr() - called: string=\"%s\"\n", str)); | ||
| 100 | |||
| 101 | return waddnstr(stdscr, str, -1); | ||
| 102 | } | ||
| 103 | |||
| 104 | int addnstr(const char *str, int n) | ||
| 105 | { | ||
| 106 | PDC_LOG(("addnstr() - called: string=\"%s\" n %d \n", str, n)); | ||
| 107 | |||
| 108 | return waddnstr(stdscr, str, n); | ||
| 109 | } | ||
| 110 | |||
| 111 | int waddstr(WINDOW *win, const char *str) | ||
| 112 | { | ||
| 113 | PDC_LOG(("waddstr() - called: string=\"%s\"\n", str)); | ||
| 114 | |||
| 115 | return waddnstr(win, str, -1); | ||
| 116 | } | ||
| 117 | |||
| 118 | int mvaddstr(int y, int x, const char *str) | ||
| 119 | { | ||
| 120 | PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str)); | ||
| 121 | |||
| 122 | if (move(y, x) == ERR) | ||
| 123 | return ERR; | ||
| 124 | |||
| 125 | return waddnstr(stdscr, str, -1); | ||
| 126 | } | ||
| 127 | |||
| 128 | int mvaddnstr(int y, int x, const char *str, int n) | ||
| 129 | { | ||
| 130 | PDC_LOG(("mvaddnstr() - called: y %d x %d string=\"%s\" n %d \n", | ||
| 131 | y, x, str, n)); | ||
| 132 | |||
| 133 | if (move(y, x) == ERR) | ||
| 134 | return ERR; | ||
| 135 | |||
| 136 | return waddnstr(stdscr, str, n); | ||
| 137 | } | ||
| 138 | |||
| 139 | int mvwaddstr(WINDOW *win, int y, int x, const char *str) | ||
| 140 | { | ||
| 141 | PDC_LOG(("mvwaddstr() - called: string=\"%s\"\n", str)); | ||
| 142 | |||
| 143 | if (wmove(win, y, x) == ERR) | ||
| 144 | return ERR; | ||
| 145 | |||
| 146 | return waddnstr(win, str, -1); | ||
| 147 | } | ||
| 148 | |||
| 149 | int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n) | ||
| 150 | { | ||
| 151 | PDC_LOG(("mvwaddnstr() - called: y %d x %d string=\"%s\" n %d \n", | ||
| 152 | y, x, str, n)); | ||
| 153 | |||
| 154 | if (wmove(win, y, x) == ERR) | ||
| 155 | return ERR; | ||
| 156 | |||
| 157 | return waddnstr(win, str, n); | ||
| 158 | } | ||
| 159 | |||
| 160 | #ifdef PDC_WIDE | ||
| 161 | int waddnwstr(WINDOW *win, const wchar_t *wstr, int n) | ||
| 162 | { | ||
| 163 | int i = 0; | ||
| 164 | |||
| 165 | PDC_LOG(("waddnwstr() - called\n")); | ||
| 166 | |||
| 167 | if (!win || !wstr) | ||
| 168 | return ERR; | ||
| 169 | |||
| 170 | while (wstr[i] && (i < n || n < 0)) | ||
| 171 | { | ||
| 172 | chtype wch = wstr[i++]; | ||
| 173 | |||
| 174 | if (waddch(win, wch) == ERR) | ||
| 175 | return ERR; | ||
| 176 | } | ||
| 177 | |||
| 178 | return OK; | ||
| 179 | } | ||
| 180 | |||
| 181 | int addwstr(const wchar_t *wstr) | ||
| 182 | { | ||
| 183 | PDC_LOG(("addwstr() - called\n")); | ||
| 184 | |||
| 185 | return waddnwstr(stdscr, wstr, -1); | ||
| 186 | } | ||
| 187 | |||
| 188 | int addnwstr(const wchar_t *wstr, int n) | ||
| 189 | { | ||
| 190 | PDC_LOG(("addnwstr() - called\n")); | ||
| 191 | |||
| 192 | return waddnwstr(stdscr, wstr, n); | ||
| 193 | } | ||
| 194 | |||
| 195 | int waddwstr(WINDOW *win, const wchar_t *wstr) | ||
| 196 | { | ||
| 197 | PDC_LOG(("waddwstr() - called\n")); | ||
| 198 | |||
| 199 | return waddnwstr(win, wstr, -1); | ||
| 200 | } | ||
| 201 | |||
| 202 | int mvaddwstr(int y, int x, const wchar_t *wstr) | ||
| 203 | { | ||
| 204 | PDC_LOG(("mvaddstr() - called\n")); | ||
| 205 | |||
| 206 | if (move(y, x) == ERR) | ||
| 207 | return ERR; | ||
| 208 | |||
| 209 | return waddnwstr(stdscr, wstr, -1); | ||
| 210 | } | ||
| 211 | |||
| 212 | int mvaddnwstr(int y, int x, const wchar_t *wstr, int n) | ||
| 213 | { | ||
| 214 | PDC_LOG(("mvaddnstr() - called\n")); | ||
| 215 | |||
| 216 | if (move(y, x) == ERR) | ||
| 217 | return ERR; | ||
| 218 | |||
| 219 | return waddnwstr(stdscr, wstr, n); | ||
| 220 | } | ||
| 221 | |||
| 222 | int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr) | ||
| 223 | { | ||
| 224 | PDC_LOG(("mvwaddstr() - called\n")); | ||
| 225 | |||
| 226 | if (wmove(win, y, x) == ERR) | ||
| 227 | return ERR; | ||
| 228 | |||
| 229 | return waddnwstr(win, wstr, -1); | ||
| 230 | } | ||
| 231 | |||
| 232 | int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n) | ||
| 233 | { | ||
| 234 | PDC_LOG(("mvwaddnstr() - called\n")); | ||
| 235 | |||
| 236 | if (wmove(win, y, x) == ERR) | ||
| 237 | return ERR; | ||
| 238 | |||
| 239 | return waddnwstr(win, wstr, n); | ||
| 240 | } | ||
| 241 | #endif | ||
