Posts

Showing posts from May, 2014

Clear console screen in Windows and Linux

Image
In case of develop of a console mode application it could be quite frequently to clear all the console screen for prepare new output. Here some examples of codes for clear screen in both operating systems.

Set console cursor position in Windows and Linux

Image
In console mode the typical need for set cursor position would be to "update" data in the same fixed position creating a refresh effect. This requirement need to set the cursor in the same point every time and start print characters. Each new print will overwrite the old data and this will create the dynamic update effect.

Set window icon in Windows console application

Image
Console application is a special Windows interface that doesn't need any GUI window since show only a console prompt as input. Each MS-DOS executable or batch file is automatically executed using this special mode. However is possible to develop a pure Windows application using this modality.

Get console screen size in Windows and Linux

Image
Console application in both operating systems Windows and Linux measure the screen size using the number of columns and lines instead of use pixels. This because console mode allow only characters output inside the ASCII range and each character block have a fixed width and height size.

Disable terminal echo in Linux

Image
Very short code snippet to disable/enable the terminal echo in Linux. If, as example, in your tool you need user to insert a password and don't want show it in the typing terminal you simply can disable echo. Once echo disabled your tool will receive keyboard input but the letters will not be showed on the screen.

Detect arrow keys pressure under Linux

Image
Manage pressure of keyboard arrow keys under Linux is not a very easy task. This because, contrary to other keys having a specific unique code, the pressure of one of the arrow keys return not a single scancode but a sequence of three codes.