A lightweight, beginner-friendly C++ library for Windows console manipulation. Perfect for creating colorful console applications, simple games, and learning Windows Console API.
Author: C.Brown Original Version: 1.2 (2001) Current Version: 2.0 (C++17 Modernized, 2025) License: MIT Platform: Windows only
ConCol provides simple, easy-to-use functions for manipulating the Windows console:
- Colors: Set foreground and background colors (16 colors each)
- Cursor Control: Move cursor to any position
- Screen Manipulation: Clear screen or sections
- Window Sizing: Resize console window
- Query Functions: Get console dimensions
- Simple to understand - Great for beginners learning console programming
- Well-documented - Clear API with usage examples
- Minimal dependencies - Just Windows API and C++ Standard Library
- Modern C++17 - Learn current best practices
- Just 2 files -
concol.hppandconcol.cpp - No external libraries - Pure Windows API
- Small footprint - Under 200 lines of code
- Fast compilation - Include and go
- Easy API - Intuitive function names
- Color constants - Use
Red,Blue,LtGreeninstead of numbers - Forgiving - Handles edge cases gracefully
- Great for learning - Perfect first step before ncurses or other libraries
- Windows OS (XP or later)
- C++17 compatible compiler (MinGW g++, MSVC, clang)
-
Copy files to your project:
concol.hpp concol.cpp -
Include header in your code:
#include "concol.hpp"
-
Compile with C++17:
g++ -std=c++17 your_program.cpp concol.cpp -o your_program
#include "concol.hpp"
#include <iostream>
int main()
{
concol con;
con.setForeground(LtGreen);
con.setBackground(bBlue);
con.ClearScreen();
con.goto_XY(30, 10);
std::cout << "Hello, Colorful World!";
con.goto_XY(0, 20);
return 0;
}Black, Blue, Red, Green, Cyan, Magenta, Orange, DkGray,
LtGray, LtRed, LtGreen, LtBlue, LtCyan, LtMagenta, Yellow, WhitebBlue, bRed, bGreen, bCyan, bMagenta, bOrange, bDkGray,
bLtGray, bLtRed, bLtGreen, bLtBlue, bLtCyan, bLtMagenta, bYellow, bWhite// Set text color only
void setForeground(int fore);
con.setForeground(LtGreen);
// Set background color only
void setBackground(int back);
con.setBackground(bBlue);
// Set both colors at once (-1 to keep current)
void setColour(int fore, int back);
con.setColour(Yellow, bRed);
con.setColour(White, -1); // Change foreground only
con.setColour(-1, bBlack); // Change background only// Move cursor to position (0-based)
void goto_XY(short x, short y);
con.goto_XY(10, 5); // Column 10, Row 5// Clear entire screen
void ClearScreen();
con.ClearScreen();
// Clear from position to end of screen
void ClearSect(short x, short y);
con.ClearSect(0, 20); // Clear from row 20 onwards// Resize console window
void resizeWindow(short width, short height);
con.resizeWindow(80, 25); // Classic 80x25
// Get console dimensions
short getPosX(); // Get width
short getPosY(); // Get height
int width = con.getPosX();
int height = con.getPosY();See the examples/ directory for complete programs:
- color_demo.cpp - Demonstrates all 16 colors
- rainbow_text.cpp - Animated rainbow effect
- simple_menu.cpp - Basic menu system
- bouncing_ball.cpp - Simple animation
#include "concol.hpp"
#include <iostream>
int main()
{
concol con;
con.ClearScreen();
const int colors[] = {Red, Green, Blue, Yellow, Cyan,
Magenta, LtRed, LtGreen, LtBlue,
LtCyan, LtMagenta, White};
const char* names[] = {"Red", "Green", "Blue", "Yellow", "Cyan",
"Magenta", "LtRed", "LtGreen", "LtBlue",
"LtCyan", "LtMagenta", "White"};
con.goto_XY(5, 2);
std::cout << "ConCol Color Demonstration";
for (int i = 0; i < 12; i++) {
con.setForeground(colors[i]);
con.goto_XY(5, 4 + i);
std::cout << names[i] << " - The quick brown fox jumps over the lazy dog";
}
con.setForeground(White);
con.goto_XY(0, 18);
return 0;
}#include "concol.hpp"
#include <iostream>
#include <windows.h>
int main()
{
concol con;
con.ClearScreen();
con.setForeground(LtCyan);
// Bouncing ball across screen
for (int x = 0; x < 70; x++) {
con.goto_XY(x, 12);
std::cout << "O";
Sleep(50);
con.goto_XY(x, 12);
std::cout << " ";
}
con.goto_XY(0, 20);
return 0;
}g++ -std=c++17 -Wall examples/color_demo.cpp concol.cpp -o color_demo
./color_democl /std:c++17 /EHsc examples/color_demo.cpp concol.cpp
color_demo.exe- Always reset cursor - Use
goto_XY(0, lastLine)before program exit - Clear before drawing - Call
ClearScreen()at start for clean slate - Test colors - Run the color demo to see all options
- Coordinate system - (0,0) is top-left, X is column, Y is row
- Screen buffering - Use
std::cout << std::flushfor immediate display
| Feature | ConCol | ncurses | pdcurses | termcolor |
|---|---|---|---|---|
| Complexity | ⭐ Simple | ⭐⭐⭐ Complex | ⭐⭐ Moderate | ⭐ Simple |
| Platform | Windows | Unix/Linux | Cross-platform | Cross-platform |
| Features | Basic | Full TUI | Full TUI | Colors only |
| Learning Curve | Gentle | Steep | Moderate | Gentle |
| Best For | Beginners | Production TUIs | Cross-platform | Simple color |
Choose ConCol if:
- You're learning C++ console programming
- You need simple Windows console manipulation
- You want minimal dependencies
- You're building a small game or utility
Choose others if:
- You need cross-platform support (ncurses/pdcurses)
- You need advanced TUI features (windows, panels, forms)
- You're building a production terminal application
- Windows-only - Uses Windows Console API directly
- No Unicode - Basic ASCII/ANSI support only
- 16 colors - Standard console palette only
- Basic features - No advanced TUI elements (menus, forms, etc.)
- No input - Only output; use
std::cinor_getch()for input
Q: Can I use this on Linux/Mac? A: No, ConCol uses Windows Console API. For cross-platform, consider ncurses or pdcurses.
Q: Does it work with modern Windows Terminal? A: Yes! Works with cmd.exe, PowerShell, and Windows Terminal.
Q: Can I use this commercially? A: Yes, MIT license allows commercial use.
Q: How do I handle keyboard input?
A: ConCol handles output only. Use std::cin, _getch(), or Windows input functions.
Q: Can I change font size? A: No, console font is controlled by user's terminal settings.
[[nodiscard]]attributesnoexceptspecifications- Defaulted constructors/destructors (
= default) nullptrinstead of NULLstatic_castfor type safety- Modern include guards
GetStdHandle()- Get console handleSetConsoleTextAttribute()- Set colorsSetConsoleCursorPosition()- Move cursorFillConsoleOutputCharacter()- Clear screenGetConsoleScreenBufferInfo()- Query console stateSetConsoleWindowInfo()- Resize window
-
v2.0 (2025) - C++17 modernization
- Added noexcept, const correctness
- Fixed all compiler warnings
- Improved documentation
- Added examples
- Defaulted special members
-
v1.2 (2001) - Original version
- Basic color and cursor control
- Screen clearing
- Window resizing
- Created for Scrabble game project
I wrote the first version of ConCol back in 2001 as a first-year uni project. I needed colour and cursor control for a Scrabble assignment, so I poked around the WinAPI and built a ~200-line helper that just worked.
Fast-forward to 2025: I found the old code, cleaned it up, and kept the spirit the same — tiny, readable, and useful.
What changed
- Updated to modern C++ (C++17)
- Tidied warnings and rough edges
- Wrote proper docs and examples
- Kept it small — still under 200 lines
Why share it now Not everything needs a framework. Sometimes you just want to paint text, move a cursor, and crack on. If you’re learning C++ on Windows or you want a no-fuss console helper, this will get you moving without the faff.
If you’re curious where it started, the old Scrabble project lives here: https://github.com/Coralesoft/Scrabble
Contributions welcome! This is an educational project, so:
- Keep code simple and readable
- Document new features clearly
- Maintain beginner-friendliness
- Add examples for new functionality
MIT License - see LICENSE file for details
Copyright (c) 2001-2025 C Brown
- Created for a C++ Scrabble game assignment (2001)
- Modernized to C++17 standards (2025)
- Inspired by the need for simple console manipulation without the complexity of ncurses
- Windows Console API Documentation
- C++17 Standard
- Original project: Scrabble Game
Happy Console Programming! 🎨
If you find ConCol useful for learning, please star the repository and share with others!