Skip to content

Commit

Permalink
Merge SVN 5288
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Feb 17, 2025
1 parent ff2962a commit 9b14e76
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@

* numeric.c (cob_decimal_set_binar): C89 fix

2024-06-10 Chuck Haatvedt <[email protected]>

* screenio.c (cob_sys_scr_dump, cob_sys_scr_restore) added new functions
* common.h added exports for the two new functions
* system.def: added as system library call CBL_GC_SCR_DUMP,
CBL_GC_SCR_RESTORE

2024-06-08 David Declerck <[email protected]>

* fileio.c (apply_file_paths): extracted from cob_chk_file_mapping
Expand Down
2 changes: 2 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,8 @@ COB_EXPIMP int cob_sys_clear_screen (void);
COB_EXPIMP int cob_sys_sound_bell (void);
COB_EXPIMP int cob_sys_get_scr_size (unsigned char *, unsigned char *);
COB_EXPIMP int cob_sys_set_scr_size (unsigned char *, unsigned char *);
COB_EXPIMP int cob_sys_scr_dump (unsigned char *);
COB_EXPIMP int cob_sys_scr_restore (unsigned char *);
COB_EXPIMP int cob_sys_get_char (unsigned char *);
COB_EXPIMP int cob_get_text (char *, int);
COB_EXPIMP int cob_get_scr_cols (void);
Expand Down
52 changes: 52 additions & 0 deletions libcob/screenio.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
/* include internal and external libcob definitions, forcing exports */
#define COB_LIB_EXPIMP
#include "coblocal.h"
#include "cobcapi.h"

#ifdef HAVE_CURSES_FREEALL
extern void _nc_freeall (void);
Expand Down Expand Up @@ -4924,6 +4925,57 @@ cob_sys_set_scr_size (unsigned char *line, unsigned char *col)
}
return 0;
#endif
}

/* save the current stdscr screen to a file */
int
cob_sys_scr_dump(unsigned char *parm)
{
#ifdef WITH_EXTENDED_SCREENIO
const char *filename = cob_get_param_str_buffered (1);
int result;
FILE *filep;

if (filename && (filep = fopen(filename, "wb")) != NULL)
{
refresh();
result = putwin(stdscr, filep);
fclose(filep);
return result;
}

return ERR;
#else
return -1;
#endif
}


/* restore the current stdscr screen from a file */
int cob_sys_scr_restore(unsigned char *parm)
{
#ifdef WITH_EXTENDED_SCREENIO
const char *filename = cob_get_param_str_buffered (1);
FILE *filep;

if (filename && (filep = fopen(filename, "rb")) != NULL)
{
WINDOW *replacement = getwin(filep);
fclose(filep);

if (replacement)
{
int result = overwrite(replacement, stdscr);
refresh();
delwin(replacement);
return result;
}
}

return ERR;
#else
return -1;
#endif
}

int
Expand Down
2 changes: 2 additions & 0 deletions libcob/system.def
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ COB_SYSTEM_GEN ("CBL_FLUSH_FILE", 1, 1, cob_sys_flush_file)
COB_SYSTEM_GEN ("CBL_GET_CSR_POS", 1, 1, cob_sys_get_csr_pos)
COB_SYSTEM_GEN ("CBL_GET_CURRENT_DIR", 3, 3, cob_sys_get_current_dir)
COB_SYSTEM_GEN ("CBL_GET_SCR_SIZE", 2, 2, cob_sys_get_scr_size)
COB_SYSTEM_GEN ("CBL_GC_SCR_DUMP", 1, 1, cob_sys_scr_dump)
COB_SYSTEM_GEN ("CBL_GC_SCR_RESTORE", 1, 1, cob_sys_scr_restore)
COB_SYSTEM_GEN ("CBL_IMP", 3, 3, cob_sys_imp)
COB_SYSTEM_GEN ("CBL_NIMP", 3, 3, cob_sys_nimp)
COB_SYSTEM_GEN ("CBL_NOR", 3, 3, cob_sys_nor)
Expand Down

0 comments on commit 9b14e76

Please sign in to comment.