最近在写一个网络模块, 用Windows自带的命令行输出调试信息, 调试信息有点多, 单色略显单调, 于是花了点时间做了如下小模块.
代码非常少, 使用方法极其简单, 我就不再赘述了, 下面有例子. 时间少, 话少说.
有任何bug, 或有任何需要值得改进的, 记得随时联系我咯~~
效果图/调色板:
示例代码:
1 #include <iostream> 2 3 #include "color_term.h" 4 5 int main() 6 { 7 color_term::color_term cterm; 8 9 cterm.title("Color-Terminal (by twofei, http://twofei.com)"); 10 11 std::cout << cterm(8+7,8+4) 12 << "---------------------" 13 << "twofei‘s Color-Terminal" 14 << "--------------------" 15 << "\n" << std::endl; 16 17 std::cout << cterm(8+2,-1) 18 << "\t blog: http://www.cnblogs.com/memset" 19 << std::endl; 20 21 std::cout << cterm(8+1+4, -1) 22 << "\t\t Author: twofei <[email protected]>" 23 << std::endl; 24 25 std::cout << cterm(8+6, -1) 26 << "\t\t Date: Sun, Nov 9 2014" 27 << std::endl; 28 29 std::cout<< cterm(-1,-1) << std::endl; 30 31 for (int fg = 0; fg < 16; fg++){ 32 for (int bg = 0; bg < 16; bg++){ 33 std::cout << cterm(fg,bg) 34 << ‘(‘ << char(fg>=10?fg-10+‘A‘:fg+‘0‘) 35 << char(bg>=10?bg-10+‘A‘:bg+‘0‘) << ‘)‘; 36 } 37 std::cout << std::endl; 38 } 39 40 cterm.restore(); 41 42 return 0; 43 }
源代码项目及示例(VC6.0): http://alioss.twofei.com/windows/colorterminal.7z
女孩不哭 @ cnblogs.com/memset @ 2014.11.09
时间: 2024-12-08 03:41:57