SMG$ routines and Esc


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

SMG$ routines and Esc

Post by fim » Thu Feb 09, 2023 7:14 am

I am trying to use SMG$ routines to color fields on the display.
For that I use Escape sequences.
It doesn't go well, the SMG$ routines refuse to send the Esc character (hex 1B) to the monitor.
If I use COBOL's DISPLAY it works perfectly.
A line declared in COBOL like this:

Code: Select all

01 LINE-ESC.
     10 FILLER PIC X(1)  VALUE X'1B'.
     10 FILLER PIC X(10) VALUE "[1;31;144m".
     10 FILLER PIC X(18) VALUE "Bright red on blue".
     10 FILLER PIC X(1)  VALUE X'1B'.
     10 FILLER PIC X(3)  VALUE "[0m".

Gives a completely correct result, red text on a blue background.
If I use "SMG$PUT_LINE" with the same data, the printable characters are printed at the top left of the screen and no coloring.
I have tried other SMG$ functions to send the Esc character on the screen, all fail.
Anyone know how to do it?
/Fim W.


tim.stegner
VSI Expert
Valued Contributor
Posts: 55
Joined: Wed Jul 21, 2021 9:14 am
Reputation: 0
Status: Offline

Re: SMG$ routines and Esc

Post by tim.stegner » Thu Feb 09, 2023 8:33 am

SMG$PUT_CHARS_MULTI would be a better choice if you want to change visual characteristics. See sections 2.2.5.6 and 2.2.6 of the OpenVMS RTL Screen Management guide (available on VMSSoftware.com/documentation).


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

Re: SMG$ routines and Esc

Post by fim » Thu Feb 09, 2023 9:43 am

Unfortunately, MG$PUT_CHARS_MULTI is just as bad.
It is not possible to put different colors on the text printed with that function.
Or do you mean that via "rendition-string" you can somehow set color attributes?
/Fim W.


tim.stegner
VSI Expert
Valued Contributor
Posts: 55
Joined: Wed Jul 21, 2021 9:14 am
Reputation: 0
Status: Offline

Re: SMG$ routines and Esc

Post by tim.stegner » Thu Feb 09, 2023 9:50 am

yes, exactly. That's what the rendition functionality is for; else you get default settings.

If you aren't already reading it, i recommend the RTL guide to Screen Management from the vmssoftware.com website. look under the 'resources' link at the top right.


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

Re: SMG$ routines and Esc

Post by fim » Thu Feb 09, 2023 10:05 am

I will read it.
We'll see if I get it.
/Fim W.

User avatar

arne_v
Master
Posts: 308
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: SMG$ routines and Esc

Post by arne_v » Thu Feb 09, 2023 7:42 pm

I don't see how one can set colors via rendition string. At least it is not documented.

The documentation only lists:

SMG$M_BLINK
SMG$M_BOLD
SMG$M_REVERSE
SMG$M_UNDERLINE
SMG$M_INVISIBLE

Added in 24 minutes 5 seconds:
Not sure what there are of options.

Builtin Cobol screens support colors.

Example:

Code: Select all

identification division.
program-id.col.
*
data division.
working-storage section.
01 s pic x(50).
screen section.
01 test-screen.
   05 value "Screen test" blank screen
                          background-color is 1 foreground-color is 4
                          line 1 column 1.
   05 value "Please enter" line 2 column 1.
   05 s-input line 2 column 20 pic x(50) to s.
*
procedure division.
main-paragraph.
    display test-screen
    accept test-screen
    display s line 3 column 1
    stop run.
And if you decide to write escape sequences yourself then you can do anything.

But I suspect neither work well with SMG$.
Arne
arne@vajhoej.dk
VMS user since 1986


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

Re: SMG$ routines and Esc

Post by fim » Fri Feb 10, 2023 6:22 am

Arne,
I want to work with the SMG routines because then I get an opportunity for a certain form of window management.
If I were to abandon the idea of window management, I have no problem with coloring different fields on the monitor, there are several different methods, including the one you showed.
/Fim W.

Added in 4 minutes 55 seconds:
Tim,
From what I understand, in the COBOL program you have to include $SMGDEF.
The only one I have found is for Basic, SYS$LIBRARY:BASIC$STARLET.
I took a chance on SYS$LIBRARY:COBOL$STARLET, but there was no hit.
Help!

User avatar

martin
Valued Contributor
Posts: 70
Joined: Tue Mar 22, 2022 6:47 pm
Reputation: 0
Location: England
Status: Offline

Re: SMG$ routines and Esc

Post by martin » Fri Feb 10, 2023 7:43 am

I've just had a look at SYS$LIBRARY:STARLET.MLB and found the following:

$EQU SMG$C_COLOR_UNKNOWN 0
$EQU SMG$C_COLOR_WHITE 1
$EQU SMG$C_COLOR_BLACK 2
$EQU SMG$C_COLOR_BLUE 3
$EQU SMG$C_COLOR_CYAN 4
$EQU SMG$C_COLOR_GREEN 5
$EQU SMG$C_COLOR_MAGENTA 6
$EQU SMG$C_COLOR_RED 7
$EQU SMG$C_COLOR_YELLOW 8
$EQU SMG$C_COLOR_LIGHT 9
$EQU SMG$C_COLOR_DARK 10
$EQU SMG$C_COLOR_USER1 11
$EQU SMG$C_COLOR_USER2 12
$EQU SMG$C_COLOR_USER3 13
$EQU SMG$C_COLOR_USER4 14
$EQU SMG$C_COLOR_USER5 15
$EQU SMG$C_COLOR_USER6 16
$EQU SMG$C_COLOR_USER7 17
$EQU SMG$C_COLOR_USER8 18

The ones you quote (SMG$M_BLINK etc) are bit masks to set up the characteristics of VT100 and later type terminals. The colours above are constants, so would be in a different field. Have a look at SMG$CHANGE_PBD_CHARACTERISTICS where you can set the background colour. I'm sorry but I've not found a way to set the text colour yet.
Martin
  • Retired System Manager: VMS/UNIX/UNICOS/Linux.
  • Started on a VAX 11/782 in 1984 with VMS 3.6.


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

Re: SMG$ routines and Esc

Post by fim » Fri Feb 10, 2023 7:53 am

Martin,
At least a little along the way.
Apparently there is a lot of information in SYS$LIBRARY.

User avatar

arne_v
Master
Posts: 308
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: SMG$ routines and Esc

Post by arne_v » Fri Feb 10, 2023 4:26 pm

I did some googling.

According to a 15 year old post from Hoff, then SMG$CHANGE_RENDITION with SMG$M_USERx should be able to do the trick.

I have no idea about how to associate SMG$M_USERx with foreground and background. And Google cannot find anything,

Added in 2 hours 13 minutes 55 seconds:
SMG manual 2.2.6:

In order to use one of the user-defined renditions SMG$M_USER1 through SMG$M_USER8, you
must provide an appropriate definition in the file TERMTABLE.TXT, using STRING_2 capabilities.
The TERMTABLE definitions and STRING_2 capabilities are discussed in Chapter 5
Arne
arne@vajhoej.dk
VMS user since 1986

Post Reply