* * *

Author Topic: How to find out text / background colors in console app?  (Read 479 times)

glorfin

  • New member
  • *
  • Posts: 24
How to find out text / background colors in console app?
« on: February 04, 2018, 05:15:45 pm »
Hi!
I am writing a console program using CRT unit. Is there a cross-platform way to find out text and background colors of a console?
And another question: at least in windows 10, WindMaxY reports not physical size of the window, which in my case is 25 lines but, apparently, console buffer size (300 lines). Is there a way to find the window height?

Thank you in advance!

jamie

  • Sr. Member
  • ****
  • Posts: 426
Re: How to find out text / background colors in console app?
« Reply #1 on: February 04, 2018, 09:23:43 pm »
There is a TConsoleBuf Type which is an array of the screen.

Then there is the PconsoleBuf a type of TConsoleBuf which is an array of


TCharAttr

Declaration

Source position: crt.pp line 29

type TCharAttr = packed record
  ch: Char;        Character code
  attr: Byte;        Attributes
end;

Documentation generated on: Feb 06 2017

glorfin

  • New member
  • *
  • Posts: 24
Re: How to find out text / background colors in console app?
« Reply #2 on: February 05, 2018, 11:42:12 pm »
Thank you, Jamie!
But looks like this is true only for CRT for UNIX. Looks like cross-platform way does not exist. OK, I'll use this way for Unix and GetConsoleScreenBufferInfo for Windows.
There is a TConsoleBuf Type which is an array of the screen.

Then there is the PconsoleBuf a type of TConsoleBuf which is an array of


TCharAttr

Declaration

Source position: crt.pp line 29

type TCharAttr = packed record
  ch: Char;        Character code
  attr: Byte;        Attributes
end;

Documentation generated on: Feb 06 2017

jamie

  • Sr. Member
  • ****
  • Posts: 426
Re: How to find out text / background colors in console app?
« Reply #3 on: February 07, 2018, 01:16:18 am »
for windows its

 "ReadConsoleOutPutAttribute"

  (OutputHandle, Abuffer to receive_atts, number_Of_Atts_To_receive,Coordinates of First Cell, Number of cells Read);

 Not sure why this isn't in the CRT already ?

  :-[

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus