如何恢复fpc程序(+crt库)中终端的默认特性?

how to restore default characteristics of terminal in fpc program (+ crt library)?

默认终端特征(在 linux mint 上)是:黑色背景和灰色字体。使用 TextColor(Red) 和 TextBackground(White) 启动 fpc 程序并退出程序后,终端仍然是红色字体和白色背景。 目标是找到一个解决方案来恢复终端的默认特性(黑色背景和灰色字体)。 感谢您的关注

最简单的解决方案是以编程方式将文本背景和文本颜色设置回 black/grey,在 end.

之前使用 TextColorTextBackground

该解决方案不是很好,但有效(来自此处:https://wiki.freepascal.org/Executing_External_Programs#TProcess)。 您应该将代码粘贴到程序中的相关位置:

uses
    process;
var
    reset_process: TProcess;
begin
    reset_process := TProcess.Create(nil);
    reset_process.Executable := 'reset';
    reset_process.Options := reset_process.Options + [poWaitOnExit];
    reset_process.Execute;
    reset_process.Free
end.