"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/tcurses.c" between
tin-2.4.1.tar.gz and tin-2.4.2.tar.xz

About: TIN is a threaded NNTP and spool based UseNet newsreader.

tcurses.c  (tin-2.4.1):tcurses.c  (tin-2.4.2.tar.xz)
/* /*
* Project : tin - a Usenet reader * Project : tin - a Usenet reader
* Module : tcurses.c * Module : tcurses.c
* Author : Thomas Dickey <dickey@invisible-island.net> * Author : Thomas Dickey <dickey@invisible-island.net>
* Created : 1997-03-02 * Created : 1997-03-02
* Updated : 2012-02-20 * Updated : 2017-10-18
* Notes : This is a set of wrapper functions adapting the termcap * Notes : This is a set of wrapper functions adapting the termcap
* interface of tin to use SVr4 curses (e.g., ncurses). * interface of tin to use SVr4 curses (e.g., ncurses).
* *
* Copyright (c) 1997-2017 Thomas Dickey <dickey@invisible-island.net> * Copyright (c) 1997-2018 Thomas Dickey <dickey@invisible-island.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
skipping to change at line 563 skipping to change at line 563
res = get_wch(&wch); res = get_wch(&wch);
# endif /* KEY_RESIZE && USE_CURSES */ # endif /* KEY_RESIZE && USE_CURSES */
# else # else
wch = (wint_t) getch(); wch = (wint_t) getch();
if (wch == (wint_t) ERR) if (wch == (wint_t) ERR)
goto again; goto again;
if (wch < KEY_MIN) { if (wch < KEY_MIN) {
/* read in the multibyte sequence */ /* read in the multibyte sequence */
char *mbs = my_malloc(MB_CUR_MAX + 1); char *mbs = my_calloc(1, MB_CUR_MAX + 1);
int i, ch; int i, ch;
wchar_t wc; wchar_t wc;
mbs[0] = (char) wch; mbs[0] = (char) wch;
nodelay(stdscr, TRUE); nodelay(stdscr, TRUE);
for (i = 1; i < (int) MB_CUR_MAX; i++) { res = mbtowc(&wc, mbs, MB_CUR_MAX);
for (i = 1; i < (int) MB_CUR_MAX && res == -1; i++) {
if ((res = mbtowc(&wc, mbs, MB_CUR_MAX)) > 0)
break;
if ((ch = getch()) != ERR) if ((ch = getch()) != ERR)
mbs[i] = (char) ch; mbs[i] = (char) ch;
else else
break; break;
} }
nodelay(stdscr, FALSE); nodelay(stdscr, FALSE);
mbs[i] = '\0';
res = mbtowc(&wc, mbs, MB_CUR_MAX);
free(mbs); free(mbs);
if (res == -1) if (res == -1)
return WEOF; /* error */ return WEOF; /* error */
else { else {
res = OK; res = OK;
wch = wc; wch = wc;
} }
} else { } else {
res = KEY_CODE_YES; res = KEY_CODE_YES;
# if defined(KEY_RESIZE) && defined(USE_CURSES) # if defined(KEY_RESIZE) && defined(USE_CURSES)
skipping to change at line 666 skipping to change at line 667
Raw(TRUE); Raw(TRUE);
} else } else
vwprintw(stdscr, fmt, ap); vwprintw(stdscr, fmt, ap);
va_end(ap); va_end(ap);
} }
void void
my_fputc( my_fputc(
int ch, int ch,
FILE *fp) FILE *stream)
{ {
TRACE(("my_fputc(%s)", tin_tracechar(ch))); TRACE(("my_fputc(%s)", tin_tracechar(ch)));
if (cmd_line) { if (cmd_line) {
if (_inraw && ch == '\n') if (_inraw && ch == '\n')
fputc('\r', fp); fputc('\r', stream);
fputc(ch, fp); fputc(ch, stream);
} else } else
addch((unsigned char) ch); addch((unsigned char) ch);
} }
void void
my_fputs( my_fputs(
const char *str, const char *str,
FILE *fp) FILE *stream)
{ {
TRACE(("my_fputs(%s)", _nc_visbuf(str))); TRACE(("my_fputs(%s)", _nc_visbuf(str)));
if (cmd_line) { if (cmd_line) {
if (_inraw) { if (_inraw) {
while (*str) while (*str)
my_fputc(*str++, fp); my_fputc(*str++, stream);
} else } else
fputs(str, fp); fputs(str, stream);
} else { } else {
addstr(str); addstr(str);
} }
} }
# if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE) # if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
void void
my_fputwc( my_fputwc(
wint_t wc, wint_t wc,
FILE *fp) FILE *fp)
 End of changes. 10 change blocks. 
12 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)