40 #define PDC_DLL_BUILD 1
44 #if defined(HAVE_NCURSESW_NCURSES_H)
45 #include <ncursesw/ncurses.h>
46 #define COB_GEN_SCREENIO
47 #elif defined(HAVE_NCURSESW_CURSES_H)
48 #include <ncursesw/curses.h>
49 #define COB_GEN_SCREENIO
50 #elif defined(HAVE_NCURSES_H)
52 #define COB_GEN_SCREENIO
53 #elif defined(HAVE_NCURSES_NCURSES_H)
54 #include <ncurses/ncurses.h>
55 #define COB_GEN_SCREENIO
56 #elif defined(HAVE_PDCURSES_H)
58 #define COB_GEN_SCREENIO
59 #elif defined(HAVE_CURSES_H)
61 #define COB_GEN_SCREENIO
65 #define COB_LIB_EXPIMP
70 #ifdef HAVE_CURSES_FREEALL
71 extern void _nc_freeall (
void);
82 #define COB_INP_FLD_MAX 512U
84 #define COB_INP_SIZE (COB_INP_FLD_MAX * sizeof(struct cob_inp_struct))
86 #define COB_CH_UL ((const chtype)'_')
87 #define COB_CH_SP ((const chtype)' ')
88 #define COB_CH_AS ((const chtype)'*')
97 #ifdef COB_GEN_SCREENIO
119 fd = fileno (stdout);
121 (void)write (fd,
"\a", (
size_t)1);
125 #ifdef COB_GEN_SCREENIO
161 *keyp = KEY_BACKSPACE;
170 *keyp = KEY_PREVIOUS;
210 #if defined(__PDCURSES__) && defined(PADSLASH)
307 getmaxyx (stdscr, max_y, max_x);
308 if (line < 0 || line >= max_y) {
311 if (column < 0 || column >= max_x) {
319 int status = move (line, column);
334 getmaxyx (stdscr, max_y, max_x);
374 styles |= A_UNDERLINE;
385 fgcolor = COLOR_BLACK;
388 fgcolor = COLOR_BLUE;
391 fgcolor = COLOR_GREEN;
394 fgcolor = COLOR_CYAN;
400 fgcolor = COLOR_MAGENTA;
403 fgcolor = COLOR_YELLOW;
406 fgcolor = COLOR_WHITE;
415 bgcolor = COLOR_BLACK;
418 bgcolor = COLOR_BLUE;
421 bgcolor = COLOR_GREEN;
424 bgcolor = COLOR_CYAN;
430 bgcolor = COLOR_MAGENTA;
433 bgcolor = COLOR_YELLOW;
436 bgcolor = COLOR_WHITE;
442 for (i = 0; i < (int)COLOR_PAIRS; i++) {
443 pair_content ((
short)i, &fgdef, &bgdef);
444 if (fgdef == fgcolor && bgdef == bgcolor) {
447 if (fgdef == 0 && bgdef == 0) {
448 init_pair ((
short)i, fgcolor, bgcolor);
452 if (i != (
int)COLOR_PAIRS) {
453 #ifdef HAVE_COLOR_SET
454 color_set ((
short)COLOR_PAIR(i),
NULL);
456 attrset (COLOR_PAIR(i));
458 bkgdset (COLOR_PAIR(i));
467 getyx (stdscr, line, column);
475 getyx (stdscr, line, column);
493 #ifdef HAVE_LIBPDCURSES
518 signal(SIGTTIN, SIG_IGN);
521 signal(SIGTTOU, SIG_IGN);
527 #ifdef HAVE_SETLOCALE
542 #ifdef HAVE_USE_LEGACY_CODING
543 use_legacy_coding (2);
547 #ifdef HAVE_SETLOCALE
550 setlocale (LC_CTYPE,
"C");
563 #ifdef HAVE_LIBPDCURSES
566 for (i = 1; i < (size_t)COLOR_PAIRS; ++i) {
567 init_pair ((
short)i, 0, 0);
593 sprintf(datbuf,
"%4.4d", fret);
599 getyx (stdscr, sline, scolumn);
610 sprintf(datbuf,
"%4.4d", sline);
611 memcpy (f->
data, datbuf, (
size_t)4);
615 sprintf(datbuf,
"%6.6d", sline);
616 memcpy (f->
data, datbuf, (
size_t)6);
633 getyx (stdscr, y, x);
634 getmaxyx (stdscr, max_y, max_x);
636 if (x + item_size - 1 > max_x) {
645 addnstr (data, size);
668 for (count = 0; count < n; count++) {
717 #define UPDATE_CLAUSE_FUNC(clause_name_upper, clause_name_lower) \
719 update_##clause_name_lower (cob_screen *s, int * const count, \
720 int * const found_clause) \
722 if (s->attr & COB_SCREEN_##clause_name_upper##_PLUS) { \
723 *count += cob_get_int (s->clause_name_lower); \
724 } else if (s->attr & COB_SCREEN_##clause_name_upper##_MINUS) { \
725 *count -= cob_get_int (s->clause_name_lower); \
727 *count += cob_get_int (s->clause_name_lower) - 1; \
735 #undef UPDATE_CLAUSE_FUNC
753 int is_screen_to_display = 1;
771 is_parent = !!s->
child;
773 if (!is_screen_to_display && !is_parent) {
792 is_screen_to_display = 0;
827 for (size = 0; size < f->
size; size++, p++) {
830 }
else if (*p <=
' ') {
836 }
else if (!is_input) {
840 column += (int)f->
size;
860 for (i = 0; i < size; ++i) {
861 if (!isspace (data[i])) {
877 for (i = 0; i < size; ++i) {
878 if (!(isspace (data[i]) || data[i] ==
'0'
879 || data[i] == decimal_point)) {
892 for (i = 0; pic[i] !=
'\0'; i += 5) {
897 if (pic[i] ==
'Z' || pic[i] ==
'*') {
913 for (i = 0; pic[i] !=
'\0'; i += 5) {
914 if (pic[i] ==
'9' || pic[i] ==
'Z' || pic[i] ==
'*') {
915 times_repeated = (
int *) (pic + i + 1);
916 num_digits += *times_repeated;
917 }
else if (!(pic[i] == numeric_separator
918 || pic[i] ==
'B' || pic[i] ==
'0' || pic[i] ==
'/')
919 && num_digits != 0) {
934 int num_integer_digits;
935 int num_digits_seen = 0;
947 for (i = 0; i < size; ++i) {
948 if (isdigit (data[i])) {
949 if (data[i] !=
'0' || num_digits_seen != 0) {
952 }
else if (!isspace (data[i]) && num_digits_seen != 0) {
957 return num_digits_seen >= num_integer_digits;
968 return !isspace (*data) && !isspace (*(data + size - 1));
1019 getyx (stdscr, y, x);
1029 unsigned char *data;
1075 for (; sptr < end; ++sptr) {
1087 size_t curr_index = (size_t)initial_curs;
1092 int sline = sptr->
this_y;
1093 int scolumn = sptr->
this_x;
1096 int rightpos = scolumn + (int)s->
field->
size - 1;
1114 timeout (gettimeout);
1121 if (keyp > KEY_F0 && keyp < KEY_F(65)) {
1133 getyx (stdscr, cline, ccolumn);
1162 sptr = cob_base_inp + curr_index;
1168 rightpos = scolumn + (int)s->
field->
size - 1;
1177 if (curr_index > 0) {
1182 sptr = cob_base_inp + curr_index;
1188 rightpos = scolumn + (int)s->
field->
size - 1;
1204 sptr = cob_base_inp + curr_index;
1210 rightpos = scolumn + (int)s->
field->
size - 1;
1220 sptr = cob_base_inp + curr_index;
1226 rightpos = scolumn + (int)s->
field->
size - 1;
1242 rightpos = scolumn + (int)s->
field->
size - 1;
1252 sptr = cob_base_inp + curr_index;
1258 rightpos = scolumn + (int)s->
field->
size - 1;
1265 if (ccolumn > scolumn) {
1266 if (gotbacksp || ccolumn != rightpos) {
1284 ungetch (KEY_BACKSPACE);
1290 if (ccolumn > scolumn) {
1301 if (ccolumn < rightpos) {
1313 if (keyp > 037 && keyp < (
int)A_CHARTEXT) {
1315 if (keyp < '0' || keyp >
'9') {
1322 if (islower (keyp)) {
1323 keyp = toupper (keyp);
1326 if (isupper (keyp)) {
1327 keyp = tolower (keyp);
1331 *p = (
unsigned char) keyp;
1340 if (ccolumn == rightpos) {
1401 getyx (stdscr, y, x);
1429 column = x + column;
1431 column = x - column;
1472 for (n = 1; n < s->
occurs; ++n) {
1507 for (n = 1; n < s->
occurs; ++n) {
1529 getyx (stdscr, *sline, *scolumn);
1543 int max_line_column;
1545 if (pos->
size < 4) {
1546 *line = pos_val - 1;
1551 if (pos->
size == 4) {
1552 max_line_column = 100;
1553 }
else if (pos->
size == 6) {
1554 max_line_column = 1000;
1557 max_line_column = 1;
1559 *line = (pos_val / max_line_column) - 1;
1560 *column = (pos_val % max_line_column) - 1;
1565 cob_field *column,
int *sline,
int *scolumn)
1567 if (column ==
NULL) {
1620 if (!cob_base_inp) {
1648 if (gettimeout >= 0 && gettimeout < 500) {
1668 sptr = cob_base_inp + n;
1670 initial_curs = (int)n;
1672 if (sptr->
this_y > starty) {
1677 sptr2 = cob_base_inp + posd;
1678 for (idx = posd; idx < n; idx++, sptr2++) {
1688 for (n = 0; n < firsty; n++, sptr++) {
1692 if (initial_curs < 0) {
1720 size_display = (int)f->
size;
1725 if (ssize_is > 0 && ssize_is < (
int)f->
size) {
1726 size_display = ssize_is;
1735 scrollok (stdscr, 1);
1737 scrollok (stdscr, 0);
1750 && (
int)f->
size == 1) {
1751 fig_const = f->
data[0];
1754 addnstr ((
char *)f->
data, size_display);
1760 if (++sline >=
LINES) {
1787 int size_accept = 0;
1791 unsigned char space_buff[4];
1798 char_temp.
data = space_buff;
1801 space_buff[0] =
' ';
1810 promptchar = prompt->
data[0];
1818 if (gettimeout >= 0 && gettimeout < 500) {
1830 scrollok (stdscr, 1);
1832 scrollok (stdscr, 0);
1843 size_accept = (int)f->
size;
1848 if (ssize_is > 0 && ssize_is < (
int)f->
size) {
1849 size_accept = ssize_is;
1854 temp.
size = size_accept;
1859 if (ssize_is > (
int)f->
size) {
1864 for (count = 0; count < size_accept; count++) {
1869 }
else if (fattr & COB_SCREEN_UPDATE) {
1882 if (!(fattr & COB_SCREEN_UPDATE)) {
1890 rightpos = scolumn + size_accept - 1;
1903 getyx (stdscr, cline, ccolumn);
1910 prompt_char = promptchar;
1914 for (count = rightpos; count > scolumn - 1; count--) {
1921 if (move_char ==
'0') {
1926 if (fattr & COB_SCREEN_NO_ECHO) {
1936 if (move_char ==
' ') {
1941 if (fattr & COB_SCREEN_NO_ECHO) {
1956 timeout (gettimeout);
1967 if (keyp > KEY_F0 && keyp < KEY_F(65)) {
1968 fret = 1000 + keyp - KEY_F0;
2032 if (ccolumn > scolumn) {
2034 for (count = ccolumn; count < rightpos + 1; count++) {
2043 if (fattr & COB_SCREEN_NO_ECHO) {
2053 if (fattr & COB_SCREEN_NO_ECHO) {
2073 for (count = scolumn; count <= rightpos; count++) {
2078 if (move_char !=
' ') {
2099 for (count = rightpos; count >= scolumn; count--) {
2104 if (move_char !=
' ') {
2110 if (move_char !=
' ' && ccolumn != rightpos) {
2127 if (ccolumn > scolumn) {
2144 if (ccolumn < rightpos) {
2164 count = curs_set(1);
2169 count = curs_set(2);
2175 for (count = ccolumn; count < rightpos; count++) {
2184 if (fattr & COB_SCREEN_NO_ECHO) {
2194 if (fattr & COB_SCREEN_NO_ECHO) {
2206 for (count = ccolumn; count <= rightpos; count++) {
2218 if (fattr & COB_SCREEN_NO_ECHO) {
2234 if (keyp >
'\037' && keyp < (
int)A_CHARTEXT) {
2237 if (keyp < '0' || keyp >
'9') {
2243 if (islower (keyp)) {
2244 keyp = toupper (keyp);
2247 if (isupper (keyp)) {
2248 keyp = tolower (keyp);
2254 for (count = rightpos; count > ccolumn - 1; count--) {
2262 if (count > scolumn) {
2264 if (move_char !=
' ') {
2265 if (fattr & COB_SCREEN_NO_ECHO) {
2277 *p = (
unsigned char)keyp;
2282 }
else if (fattr & COB_SCREEN_NO_ECHO) {
2287 if (ccolumn == rightpos) {
2349 field_display (f, sline, scolumn, fgc, bgc, fscroll, size_is, fattr);
2362 field_accept (f, sline, scolumn, fgc, bgc, fscroll, ftimeout, prompt, size_is, fattr);
2412 #ifdef HAVE_CURSES_FREEALL
2417 cob_base_inp =
NULL;
2511 #ifdef COB_GEN_SCREENIO
2532 #ifdef COB_GEN_SCREENIO
2539 #ifdef COB_GEN_SCREENIO
2540 getyx (stdscr, cline, ccol);
2541 fld[0] = (
unsigned char)cline;
2542 fld[1] = (
unsigned char)ccol;
2556 #ifdef COB_GEN_SCREENIO
2557 *line = (
unsigned char)
LINES;
2558 *col = (
unsigned char)
COLS;
#define COB_SCREEN_SCROLL_DOWN
static size_t cob_has_color
void cob_free(void *mptr)
static size_t get_size(cob_screen *s)
static size_t cob_prep_input(cob_screen *s)
#define COB_FERROR_CODEGEN
static void screen_accept(cob_screen *s, const int line, const int column, cob_field *ftimeout)
#define COB_SCREEN_TYPE_VALUE
#define COB_FIELD_DATA(f)
int cob_sys_get_csr_pos(unsigned char *fld)
static COB_INLINE COB_A_INLINE int cob_field_is_numeric_or_numeric_edited(cob_field *field)
static struct cob_inp_struct * cob_base_inp
static void raise_ec_on_invalid_line_or_col(const int line, const int column)
int cob_sys_clear_screen(void)
#define COB_SCREEN_TYPE_FIELD
#define COB_FIELD_IS_NUMERIC(f)
void cob_move(cob_field *, cob_field *)
static void cob_move_cursor(const int line, const int column)
#define COB_TYPE_ALPHANUMERIC
static void cob_screen_init(void)
#define COB_CHK_PARMS(x, z)
static int pic_has_zero_suppression(const char *pic)
#define COB_SCREEN_NO_ECHO
#define COB_FIELD_TYPE(f)
int cob_sys_sound_bell(void)
static cob_screen * get_last_child(cob_screen *const s)
static void pos_to_line_column(cob_field *pos, int *line, int *column)
#define COB_SCREEN_COLUMN_PLUS
static void cob_speaker_beep(void)
static void get_screen_item_line_and_col(cob_screen *s, int *const line, int *const col)
#define COB_SCREEN_LINE_MINUS
static void cob_check_pos_status(const int fret)
static void cob_addch(const chtype c)
static int satisfied_full_clause(cob_screen *s)
static void cob_move_to_beg_of_last_line(void)
#define COB_SCREEN_YELLOW
struct __cob_screen * next
static int satisfied_required_clause(cob_screen *s)
static void cob_beep(void)
int cob_get_int(cob_field *)
#define COB_SCREEN_ERASE_EOL
void cob_field_display(cob_field *f, cob_field *line, cob_field *column, cob_field *fgc, cob_field *bgc, cob_field *fscroll, cob_field *size_is, const int fattr)
#define COB_TIMEOUT_SCALE
#define COB_SCREEN_UNDERLINE
#define COB_ACCEPT_STATUS
struct __cob_screen * prev
static void get_line_column(cob_field *fline, cob_field *fcol, int *line, int *col)
void cob_init_screenio(cob_global *lptr, cob_settings *sptr)
static void format_field(cob_screen *s)
void cob_fatal_error(const int fatal_error)
#define COB_SCREEN_EMULATE_NL
static void cob_screen_get_all(const int initial_curs, const int gettimeout)
void cob_field_accept(cob_field *f, cob_field *line, cob_field *column, cob_field *fgc, cob_field *bgc, cob_field *fscroll, cob_field *ftimeout, cob_field *prompt, cob_field *size_is, const int fattr)
void cob_runtime_error(const char *,...) COB_A_FORMAT12
static int compare_yx(const void *m1, const void *m2)
static void field_display(cob_field *f, const int line, const int column, cob_field *fgc, cob_field *bgc, cob_field *fscroll, cob_field *size_is, const int fattr)
#define COB_SCREEN_REVERSE
static void cob_screen_attr(cob_field *fgc, cob_field *bgc, const int attr, const enum screen_statement stmt)
#define COB_FIELD_INIT(x, y, z)
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
static void cob_screen_iterate(cob_screen *s)
static cob_screen * get_prev_screen_item(cob_screen *const s)
static int field_is_empty(cob_screen *s)
static int field_is_zero(cob_screen *s)
void cob_set_exception(const int id)
static int finalize_all_fields(struct cob_inp_struct *sptr, const size_t total_idx)
#define COB_SCREEN_TYPE_ATTRIBUTE
static int valid_field_data(cob_field *field)
#define UPDATE_CLAUSE_FUNC(clause_name_upper, clause_name_lower)
#define COB_SCREEN_LOWLIGHT
static void cob_screen_puts(cob_screen *s, cob_field *f, const cob_u32_t is_input, const enum screen_statement stmt)
#define COB_SCREEN_MAGENTA
void cob_screen_display(cob_screen *s, cob_field *line, cob_field *column)
#define COB_TYPE_NUMERIC_DISPLAY
static COB_INLINE COB_A_INLINE void set_default_line_column(const int is_screen, int *sline, int *scolumn)
void cob_set_int(cob_field *, const int)
#define COB_EXTENDED_STATUS
#define COB_TYPE_ALPHANUMERIC_ALL
#define COB_SCREEN_INITIAL
#define COB_SCREEN_REQUIRED
void cob_screen_accept(cob_screen *s, cob_field *line, cob_field *column, cob_field *ftimeout)
static void extract_line_and_col_vals(const int is_screen, cob_field *line, cob_field *column, int *sline, int *scolumn)
static int field_is_full(cob_screen *s)
cob_field * cob_intr_numval(cob_field *)
struct __cob_screen * child
int cob_sys_get_scr_size(unsigned char *line, unsigned char *col)
void cob_screen_line_col(cob_field *f, const int l_or_c)
void cob_screen_set_mode(const cob_u32_t smode)
#define COB_SCREEN_BLANK_LINE
static void update_line(cob_screen *s, int *const count, int *const found_clause)
int cob_check_numval(const cob_field *, const cob_field *, const int, const int)
#define COB_SCREEN_SECURE
#define COB_SCREEN_HIGHLIGHT
#define COB_SCREEN_PROMPT
static void field_accept(cob_field *f, const int sline, const int scolumn, cob_field *fgc, cob_field *bgc, cob_field *fscroll, cob_field *ftimeout, cob_field *prompt, cob_field *size_is, const int fattr)
unsigned int cob_screen_initialized
static const cob_field_attr const_alpha_attr
#define COB_SCREEN_ERASE_EOS
#define COB_SCREEN_LINE_PLUS
static cob_settings * cobsetptr
if fold fold static computed alternate extra correct stack on syntax debugging line
struct __cob_screen * parent
static void raise_ec_on_truncation(const int item_size)
static void screen_display(cob_screen *s, const int line, const int column)
#define COB_SCREEN_NO_DISP
void cob_exit_screen(void)
static void cob_addch_no_trunc_check(const chtype c)
const cob_field_attr * attr
#define COB_SCREEN_UPDATE
static void cob_convert_key(int *keyp, const cob_u32_t field_accept)
void * cob_malloc(const size_t size)
void cob_accept_escape_key(cob_field *f)
cob_field * cob_intr_numval_c(cob_field *, cob_field *)
static void cob_addnstr(const char *data, const int size)
static void refresh_field(cob_screen *s)
static int get_num_int_digits_for_no_zero_sup(const char *pic)
#define COB_SCREEN_TYPE_GROUP
static int finalize_field_input(cob_screen *s)
#define COB_SCREEN_COLUMN_MINUS
static cob_global * cobglobptr
static COB_INLINE COB_A_INLINE void init_cob_screen_if_needed(void)
static void cob_screen_moveyx(cob_screen *s)
#define COB_SCREEN_BLANK_SCREEN
static void update_column(cob_screen *s, int *const count, int *const found_clause)
#define COB_TYPE_NUMERIC_EDITED
#define COB_FIELD_SIZE(f)
static int is_first_screen_item(cob_screen *s)
static int field_is_zero_or_no_zero_suppression(cob_screen *s)
static void cob_addnch(const int n, const chtype c)
void cob_stop_run(const int status)