Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/gnucobol-3.x' into gcos4gnucob…
Browse files Browse the repository at this point in the history
…ol-3.x
  • Loading branch information
ddeclerck committed Aug 22, 2024
2 parents 8b7350a + 816bd2b commit 2ed1057
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 22 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ NEWS - user visible changes -*- outline -*-
** support the COLLATING SEQUENCE clause on indexed files
(currently only with the BDB backend)

** Support for time profiling of modules, sections, paragraphs, entries
** support for time profiling of modules, sections, paragraphs, entries
and external CALLs. This feature is activated by compiling the modules
to be profiled with -fprof, and then executing the code with environment
variable COB_PROF_ENABLE. The output is stored in a CSV file. Further
customization can be done using COB_PROF_FILE, COB_PROF_MAX_DEPTH and
COB_PROF_FORMAT

** new runtime configuraiton COB_HIDE_CURSOR, allows to hide the cursor during
extended ScreenIO operations

more work in progress

* Important Bugfixes
Expand Down
5 changes: 5 additions & 0 deletions config/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2024-08-17 Ammar Almoris <[email protected]>

FR #474: add runtime configuration to hide cursor for extended screenio
* runtime.cfg: add COB_HIDE_CURSOR

2024-07-11 David Declerck <[email protected]>

* general: fix minor alignment / tab issues
Expand Down
7 changes: 7 additions & 0 deletions config/runtime.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@
# Note: also sets the cursor type (if available)
# Example: insert_mode Y

# Environment name: COB_HIDE_CURSOR
# Parameter name: hide_cursor
# Purpose: hide the cursor; 0=visible, 1=hidden
# Type: boolean
# Default: false
# Example: hide_cursor Y

# Environment name: COB_MOUSE_FLAGS
# Parameter name: mouse_flags
# Purpose: specify which mouse events will be sent as function key
Expand Down
12 changes: 12 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@

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

* common.c (DllMain) [_MSC_VER]: added calls to _CrtSetReportMode
to disable Windows error popups and redirect them to stderr

2024-08-17 Ammar Almorsi <[email protected]>

FR #474: add runtime configuration to hide cursor for extended screenio
* common.c, coblocal.h (cob_settings): added boolean COB_HIDE_CURSOR
* screenio.c (cob_settings_screenio): implemented runtime config to hide
the cursor

2024-07-29 Chuck Haatvedt <[email protected]>

* move.c (optimized_move_display_to_edited): fixed small bug
Expand Down
2 changes: 2 additions & 0 deletions libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ Note: also defined together with __clang__ in both frontends:
#define COB_BEEP_VALUE cobsetptr->cob_beep_value
#define COB_TIMEOUT_SCALE cobsetptr->cob_timeout_scale
#define COB_INSERT_MODE cobsetptr->cob_insert_mode
#define COB_HIDE_CURSOR cobsetptr->cob_hide_cursor
#define COB_EXTENDED_STATUS cobsetptr->cob_extended_status
#define COB_MOUSE_FLAGS cobsetptr->cob_mouse_flags
#define COB_MOUSE_INTERVAL cobsetptr->cob_mouse_interval
Expand Down Expand Up @@ -335,6 +336,7 @@ typedef struct __cob_settings {
unsigned int cob_use_esc; /* Check ESC key */
unsigned int cob_timeout_scale; /* timeout scale */
unsigned int cob_insert_mode; /* insert toggle, 0=off, 1=on */
unsigned int cob_hide_cursor; /* hide cursor, 0=visible, 1=hidden */
unsigned int cob_exit_wait; /* wait on program exit if no ACCEPT came after last DISPLAY */
const char *cob_exit_msg; /* message for cob_exit_wait */

Expand Down
32 changes: 31 additions & 1 deletion libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ static struct config_tbl gc_conf[] = {
{"COB_SCREEN_EXCEPTIONS", "screen_exceptions", "0", NULL, GRP_SCREEN, ENV_BOOL, SETPOS (cob_extended_status)},
{"COB_TIMEOUT_SCALE", "timeout_scale", "0", timeopts, GRP_SCREEN, ENV_UINT, SETPOS (cob_timeout_scale)},
{"COB_INSERT_MODE", "insert_mode", "0", NULL, GRP_SCREEN, ENV_BOOL, SETPOS (cob_insert_mode)},
{"COB_HIDE_CURSOR", "hide_cursor", "0", NULL, GRP_SCREEN, ENV_BOOL, SETPOS (cob_hide_cursor)},
{"COB_MOUSE_FLAGS", "mouse_flags", "1", NULL, GRP_SCREEN, ENV_UINT, SETPOS (cob_mouse_flags)},
{"MOUSE_FLAGS", "mouse_flags", NULL, NULL, GRP_HIDE, ENV_UINT, SETPOS (cob_mouse_flags)},
#ifdef HAVE_MOUSEINTERVAL /* possibly add an internal option for mouse support, too */
Expand Down Expand Up @@ -8080,7 +8081,8 @@ set_config_val (char *value, int pos)
if (data == (char *)&cobsetptr->cob_debugging_mode) {
/* Copy variables from settings (internal) to global structure, each time */
cobglobptr->cob_debugging_mode = cobsetptr->cob_debugging_mode;
} else if (data == (char *)&cobsetptr->cob_insert_mode) {
} else if (data == (char *)&cobsetptr->cob_insert_mode
|| data == (char *)&cobsetptr->cob_hide_cursor) {
cob_settings_screenio ();
} else if (data == (char *)&cobsetptr->cob_debugging_mode) {
cob_switch[11 + 'D' - 'A'] = (int)numval;
Expand Down Expand Up @@ -11223,3 +11225,31 @@ void cob_cleanup_thread ()
{
cob_exit_strings ();
}

#ifdef _MSC_VER

#include <debugapi.h>
#include <crtdbg.h>

BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
COB_UNUSED (hinstDLL);
COB_UNUSED (lpReserved);

if (fdwReason == DLL_PROCESS_ATTACH) {
/* Programs compiled with MSVC will by default display a popup
window on some errors. In general, we do not want that,
so we disable them, unless explicitly requested. */
if (!IsDebuggerPresent() && !getenv ("DEBUG_POPUPS_WANTED")) {
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
}
}
return TRUE;
}

#endif
30 changes: 15 additions & 15 deletions libcob/screenio.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2012, 2014-2023 Free Software Foundation, Inc.
Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc.
Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart,
Chuck Haatvedt
Expand Down Expand Up @@ -161,7 +161,6 @@ static int accept_cursor_y;
static int accept_cursor_x;
static int pending_accept;
static int got_sys_char;
static unsigned int curr_setting_insert_mode = INT_MAX;
#ifdef HAVE_MOUSEMASK
static unsigned int curr_setting_mouse_flags = UINT_MAX;
#endif
Expand Down Expand Up @@ -5008,21 +5007,22 @@ cob_settings_screenio (void)
return;
}

/* Extended ACCEPT status returns */
if (cobsetptr->cob_extended_status == 0) {
cobsetptr->cob_use_esc = 0;
/* requesting cursor type depending on both settings, 0 = hide,
1 = vertical bar cursor, 2 = square cursor; note: the cursor change
may not have an effect in all curses implementations / terminals */
{
static unsigned int prev_cursor_mode = UINT_MAX;
const unsigned int new_cursor_mode
= (COB_HIDE_CURSOR)?0U:((COB_INSERT_MODE)?1U:2U);
if (prev_cursor_mode != new_cursor_mode) {
(void) curs_set (new_cursor_mode);
prev_cursor_mode = new_cursor_mode;
}
}

if (curr_setting_insert_mode != COB_INSERT_MODE) {
/* Depending on insert mode set vertical bar cursor (on)
or square cursor (off) - note: the cursor change may has no
effect in all curses implementations / terminals */
if (COB_INSERT_MODE == 0) {
(void)curs_set (2); /* set square cursor */
} else {
(void)curs_set (1); /* set vertical bar cursor */
}
curr_setting_insert_mode = COB_INSERT_MODE;
/* extended ACCEPT status returns */
if (cobsetptr->cob_extended_status == 0) {
cobsetptr->cob_use_esc = 0;
}

#ifdef HAVE_MOUSEINTERVAL
Expand Down
70 changes: 65 additions & 5 deletions tests/testsuite.src/run_manual_screen.at
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (C) 2014-2018,2020-2023 Free Software Foundation, Inc.
## Copyright (C) 2014-2018,2020-2024 Free Software Foundation, Inc.
## Written by Edward Hart, Simon Sobisch
##
## This file is part of GnuCOBOL.
Expand Down Expand Up @@ -2747,7 +2747,7 @@ AT_CLEANUP


AT_SETUP([END key])
AT_KEYWORDS([END SIZE])
AT_KEYWORDS([END SIZE position])

AT_SKIP_IF([test "$COB_HAS_CURSES" != "yes"])

Expand Down Expand Up @@ -2794,7 +2794,7 @@ AT_CLEANUP


AT_SETUP([INSERT key])
AT_KEYWORDS([INSERT SIZE])
AT_KEYWORDS([COB_INSERT_MODE SIZE])

AT_SKIP_IF([test "$COB_HAS_CURSES" != "yes"])

Expand Down Expand Up @@ -2842,8 +2842,68 @@ MANUAL_CHECK([$COBCRUN_DIRECT ./prog], [0], [], [])
AT_CLEANUP


AT_SETUP([cursor visibility])
AT_KEYWORDS([COB_HIDE_CURSOR])

AT_SKIP_IF([test "$COB_HAS_CURSES" != "yes"])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 success-flag PIC X VALUE 'Y'.
88 fail VALUE 'N'.
01 ws-input PIC X.
88 success VALUE 'Y', 'y'.
PROCEDURE DIVISION.
DISPLAY "Type 'Y' if you see the cursor"
LINE 1 COLUMN 1.

ACCEPT WS-INPUT
LINE 1 COLUMN 50
WITH AUTO-SKIP
UPDATE.
IF NOT success SET fail TO TRUE.

SET ENVIRONMENT 'COB_HIDE_CURSOR' TO 'TRUE'.

DISPLAY "Type 'Y' if you do not see the cursor"
LINE 3 COLUMN 1.

ACCEPT WS-INPUT
LINE 3 COLUMN 50
WITH AUTO-SKIP
UPDATE.
IF NOT success SET fail TO TRUE.

SET ENVIRONMENT 'COB_INSERT_MODE' TO 'TRUE'.

DISPLAY "Type 'Y' if you still do not see the cursor"
LINE 5 COLUMN 1.

ACCEPT WS-INPUT
LINE 5 COLUMN 50
WITH AUTO-SKIP
UPDATE.
IF NOT success SET fail TO TRUE.

IF fail
GOBACK RETURNING 1
ELSE
GOBACK RETURNING 0
END-IF
.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
MANUAL_CHECK([$COBCRUN_DIRECT ./prog], [0], [], [])

AT_CLEANUP


AT_SETUP([BACKSPACE key])
AT_KEYWORDS([BACKSPACE SIZE CURSOR])
AT_KEYWORDS([SIZE CURSOR position])

AT_SKIP_IF([test "$COB_HAS_CURSES" != "yes"])

Expand Down Expand Up @@ -2898,7 +2958,7 @@ AT_CLEANUP


AT_SETUP([DELETE key])
AT_KEYWORDS([DELETE SIZE])
AT_KEYWORDS([SIZE position])

AT_SKIP_IF([test "$COB_HAS_CURSES" != "yes"])

Expand Down

0 comments on commit 2ed1057

Please sign in to comment.