Recent

Author Topic: how to restore default characteristics of terminal in fpc + crt program?  (Read 434 times)

anchar

  • Newbie
  • Posts: 3
Default terminal characteristics (on linux mint) are: black background and grey font. After launching fpc program with TextColor(Red) and TextBackground(White) and quit out of a program, terminal still has red font and white background. The goal is to find a solution wich will restore default characteristics (black background and grey font) of terminal. thanks for your attention.

Handoko

  • Hero Member
  • *****
  • Posts: 3181
  • My goal: build my own game engine using Lazarus
Re: how to restore default characteristics of terminal in fpc + crt program?
« Reply #1 on: September 17, 2019, 02:32:37 pm »
Have you tried to run these right before exit the program:

TextColor(White); // or maybe Grey
TextBackground(Black);

anchar

  • Newbie
  • Posts: 3
Re: how to restore default characteristics of terminal in fpc + crt program?
« Reply #2 on: September 17, 2019, 03:23:03 pm »
you are right, but i would like to find a solution which take into account settings of user`s terminal (TextColor, for example, will be red or black and TextBackground will be blue or green)

Handoko

  • Hero Member
  • *****
  • Posts: 3181
  • My goal: build my own game engine using Lazarus
Re: how to restore default characteristics of terminal in fpc + crt program?
« Reply #3 on: September 17, 2019, 03:58:38 pm »
My Ubuntu Mate Terminal has black text with white background.

As far as I know Linuxes are very flexible with terminal. Users can install any one she/he likes, and each terminal may has its own default color.

I haven't tried, but maybe this is what you need:
https://www.freepascal.org/docs-html/rtl/crt/normvideo.html

lucamar

  • Hero Member
  • *****
  • Posts: 2075
Re: how to restore default characteristics of terminal in fpc + crt program?
« Reply #4 on: September 17, 2019, 04:27:07 pm »
In case it matters, I did a quick test: changing colors (twice, just in case) and then using NormVideo did (more or less) work in gnome-terminal.

"More or less" because some colors don't show right (most notably in the background, even if in Black..DarkGray), but that is irrelevant for this thread :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

winni

  • Sr. Member
  • ****
  • Posts: 415
Re: how to restore default characteristics of terminal in fpc + crt program?
« Reply #5 on: September 17, 2019, 05:08:56 pm »
Hi!

A Linux terminal is reset to his default values with

Code: Bash  [Select]
  1. reset
  2.  

If you only want to clear the terminal and the color stuff then use

Code: Bash  [Select]
  1. clear
  2.  


Winni

anchar

  • Newbie
  • Posts: 3
Re: how to restore default characteristics of terminal in fpc + crt program?
« Reply #6 on: September 18, 2019, 02:34:57 pm »
the solution is not pretty nice, but worked (from here: https://wiki.freepascal.org/Executing_External_Programs#TProcess).
you should paste the code to the relevant places in a program:
Code: Pascal  [Select]
  1. uses
  2.     process;
  3. var
  4.     reset_process: TProcess;
  5. begin
  6.     reset_process := TProcess.Create(nil);
  7.     reset_process.Executable := 'reset';
  8.     reset_process.Options := reset_process.Options + [poWaitOnExit];
  9.     reset_process.Execute;
  10.     reset_process.Free
  11. end.
« Last Edit: September 18, 2019, 03:17:35 pm by anchar »