便携式基于文本的控制台操纵器 [英] Portable text based console manipulator

查看:24
本文介绍了便携式基于文本的控制台操纵器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序可以操作基于文本的控制台或终端,并更改它们的颜色、设置光标位置.支持的方法是:

Applications can manipulate text based consoles or terminals, and change their colors, set cursor position. The supported approaches are:

但是,是否有任何轻量级和可移植的 C/C++ 库可以处理操作系统之间的差异,仅针对颜色和光标?并且如果技术上不可能但尽最大努力什么都不做.

but, is there any lightweight and portable C/C++ library which handles differences between operating systems just for colors and cursor? and do nothing if it was technically impossible but best effort.

注意:我不是在寻找大量的外部工具来模拟类 Unix 终端(如 Cygwin、Msys-rxvt 等).我认为使用 Windows API 和 ANSI 转义码可以实现简单的可移植性. 而不是 ncurses,因为它很重,并且有很多功能可以完全控制控制台,我认为它需要模拟.>

推荐答案

好吧,我终于找到了一个可移植且易于使用的库:rlutil.h

Alright, i finally found a portable and easy to use library: rlutil.h

用法:

#include <iostream>
#include "rlutil.h"
int main()
{
    for (int i = 0; i < 16; i++)
    {
        rlutil::setColor(i);
        std::cout << i << " ";
    }
    std::cout << std::endl;
    return 0;
}

但是,我很乐意提供其他建议.

这篇关于便携式基于文本的控制台操纵器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆