Change Windows Terminal font programmatically - winapi

I want to write a 2D chess program.
It does not require much user input so it will use only the Windows Console, not any GUI.
I know how to access the Windows Console API and change its font using Assembly language or C++.
Using the same method for Windows Terminal does not work as it is written to behave as font agnostic terminal.
However, in Windows Terminal you can set the font to your liking through the settings.
I want to change the Windows Terminal font from the outside, before or during when Windows Terminal launches.
I know all Windows Terminal settings are stored in a JSON file so I can manipulate it before lanching.
I'm looking for a more straight forward approach like a command line option or a WINAPI call.
I could not find any.
Is there any way to programmaticaly change the Windows Terminal font?

Have a look at SetCurrentConsoleFontEx()
Sets extended information about the current console font.

Related

Win32 Detect if my window is running in Dark Mode on Windows 10+

I would like my Win32 application to be able to detect if a window is actually running in Dark Mode. I know about this answer, which suggests reading a registry key for the user setting. That's fine, and it works for me. But many applications do not honor that setting.
I would like to find out which appearance my actual window has. My program is a 3rd-party plugin that runs inside an application I do not control. Currently that host application does not support Dark Mode on Windows, but a new version could potentially start supporting it. I would like to allow my program to detect if it does. I would also like to continue to support older versions of the app, without having to resort to a manual list of versions that do or don't support Dark Mode.
For readers that know something about macOS APIs, I am hoping to find something similar to the effectiveAppearance property on macOS views.
Individual windows do not have light/dark modes, as far as the OS is concerned, so there is nothing you can query for that. A window doesn't report back to the OS whether or not it is honoring the user's display setting. If it honors the user's setting, it simply draws its UI using appropriate colorings as it deems fit. If it don't honor the user's setting, it simply draws itself using whatever normal/custom colors it wants.

How to get color in Lua console/terminal

Is there a simple way to have the generic Lua console/terminal in windows display colors?
I am basically running the lua53.exe terminal in windows and want to display things with colors.
Mainly in my lua code, I'd like to display debug and error messages in a different color then the default text color. My default color is white in the lua terminal and I would like to output error messages that I print in red and debug in yellow.
I don't want to use other external applications/tools/etc to handle this. I've seen some links for using LOVE to create its own console to get color; and I've seen several ANSI code blocks that don't work natively in windows.
You cannot use colored output on Windows console cmd.exe. It's not Lua dependent.
Starting with Windows 10, you can use ANSI colors escape sequences on cmd.exe or with the Windows Terminal application (available on the Windows Store).
Another option is to use a Lua binary Module that deals with the Windows API to use colored output on the console.
if you are on windows, use os.execute('color')
for the color command read the color command Microsoft docs

How do you get the Windows Console \ Command Prompt to display color?

My problem is as follows:
I used to code on Linux (Ubuntu, to be more precise), but now I am using a Windows machine (7 and 8.1). One of the major caveats for me is that the Command Prompt in either Windows does not display other colors or font styles other than the default one, resulting in a monotone terminal.
This is useful for debugging Symfony projects (as errors have colors, making them easier to read) and more. This happens out of the box in the Linux terminal and wish to have the same behavior in Windows.
Is there a way to achieve this in the default Command Prompt (how?) or is there a 3-rd party application that achieves this (I've already tried PowerCMD but apparently it doesn't allow php to output to the console)?
I had the same problem and solved it by switching to another terminal.
I Use "cmder" terminal for windows which supports all the color codes out of the box. Symfony3 console looks pretty much as the one you know from Linux.
Check out this comparison article: Comparison to other window terminal
Download cmder terminal from: cmder homepage
Cmder terminal comes with build in color themes for terminal window. The one below comes by default "Monokai", but if you like the standard look feel free to switch to "Ubuntu" or "xterm" theme (those are also build in themes - there are more themes available out of the box).
"Monokai"
"Ubuntu"
"xterm"
If you like transparency for active and inactive terminal window you can set it too (Settings shortcut -> "Ctrl + Alt + P").
As Symfony2 console component documentation says, windows doesn't support natively ANSI colors. You could install ANSICON as suggested there or you can try with cygwin, it has full shell support (bash or zsh) so you can have colors and many more things.

Show text in the center of terminal screen in golang

I am playing with golang and want to create a simple terminal tool (on mac, but it should work on linux too). I need to display character "x" in the center of the terminal window. How can I detect width and height of terminal window and detect its changes?
A terminal package exists in the Go crypto repository:
In particular, check out the GetSize function
A lightweight alternative to the usual ncurses option, is termbox-go. This is a pure-go implementation of termbox.
It offers a simple API to get some 'graphical' stuff done in a terminal and is pretty decent as far as support for different terminal implementations goes.

How does edit.exe work?

There is an exe in system32 called edit.com . It is an old text editor. I'm wondering how they made a console app have a gui, and work with the mouse? Thanks
There are no shortcuts.The mouse had to be interfaced with through assembly code.You would call interrupt 33 to have access to several functions like reading the mouse motion counters and button states. Then you'd read the CPU registers to get those numbers. From there on you could do everything else in C, including the GUI-like interface. There's no shortcut to that either - it must be manually done, each individual square has to be painted the correct color.
edit.com is REALLY old. It was written before the Windows GUI was really popular. They probably use special DOS functions to create the graphics and recognize the mouse.
Well prior to Windows 3.1 there used to be an operating system call DOS and I believe the mouse thing came with DOS 5.0 or DOS 4.0.
Your best bet for adding mouse and color support to a console is to use some kind of TextArea control and make your own console instead of using the DOS console. You could also look into ncurses for Windows but I don't recommend it. If you just want color you could also look at this tutorial.

Resources