xsharp.eu • Problem with class VO.Console - Page 2
Page 2 of 2

Problem with class VO.Console

Posted: Thu Feb 20, 2020 12:37 pm
by leon-ts
Robert,

Yes, I will be very glad to help. I will try to find the time either tonight or on the weekend (if this suits you).

Best regards,
Leonid

Problem with class VO.Console

Posted: Thu Feb 20, 2020 8:17 pm
by leon-ts
Robert,

Updates in the attachment.

Best regards,
Leonid

Problem with class VO.Console

Posted: Thu Feb 20, 2020 11:54 pm
by leon-ts
The code in the attachment implies that we do not know the values of the ConsoleColor enum and the numeric values of the attributes of the console text in win32. But if you make conditional assumptions, the code will be even simpler:

Code: Select all

PROPERTY TextAttribute AS WORD
    GET
        RETURN (WORD)System.Console.ForegroundColor | (WORD)(System.Console.BackgroundColor) << 4
    END GET
    SET
        System.Console.ForegroundColor := (ConsoleColor) (WORD)(VALUE & 0x000F)
        System.Console.BackgroundColor := (ConsoleColor) (WORD)((VALUE >> 4) & 0x000F)
    END SET
END PROPERTY
and nothing changes in the constructor.

Best regards,
Leonid

Problem with class VO.Console

Posted: Fri Feb 21, 2020 6:58 am
by robert
Leonid,

I think I like this one better.
I'll also add the FOREGROUND_ and BACKGROUND_ defines to the Console classes so no reference to Win32 is needed anymore.

Robert