Problem with class VO.Console

This forum is meant for questions and discussions about the X# language and tools
leon-ts
Posts: 430
Joined: Fri Feb 03, 2017 1:43 pm

Problem with class VO.Console

Post 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
Best regards,
Leonid
leon-ts
Posts: 430
Joined: Fri Feb 03, 2017 1:43 pm

Problem with class VO.Console

Post by leon-ts »

Robert,

Updates in the attachment.

Best regards,
Leonid
Attachments
VOConsoleClass_OnlyUpdatedMethods.zip
(970 Bytes) Downloaded 22 times
Best regards,
Leonid
leon-ts
Posts: 430
Joined: Fri Feb 03, 2017 1:43 pm

Problem with class VO.Console

Post 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
Best regards,
Leonid
User avatar
robert
Posts: 4326
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Problem with class VO.Console

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply