Newer
Older
libj / modules / j / base / src / term.cpp
#include <string>

namespace j
{
    namespace io
    {
        namespace Term
        {
            namespace Cursor
            {
                /**
                 * 指定されたコード、値をもとにエスケープシーケンスを作成します。
                 *
                 * @param code コード
                 * @param n 移動量など
                 * @param delim  区切り文字
                 * @param m 移動量など
                 * @return エスケープシーケンス文字列
                 */
                std::string_view MAKE_ESC_SEQ(const char *code, int n, const char *delim, int m)
                {
                    thread_local static std::string result;
                    result = "\x1b[" + std::to_string(n);
                    if (delim)
                    {
                        result += delim + std::to_string(m);
                    }
                    result += code;
                    return {result};
                }
            }
        }
    }
}