V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
banxi1988
V2EX  ›  C++

[重学 C++]分享我写的一个 C++的终端格式库 chalks

  •  
  •   banxi1988 ·
    banxi1988 · 2020-03-01 21:13:35 +08:00 · 1771 次点击
    这是一个创建于 1761 天前的主题,其中的信息可能已经有所发展或是发生改变。

    仓库地址: GitHub chalks

    效果图: 效果图

    对应使用代码:

    #include "chalks/chalks.hpp"
    #include <iostream>
    using chalks::chalk;
    using chalks::chalk_style;
    using std::cout;
    using std::endl;
    
    int main(int argc, char const *argv[]) {
      cout << chalk("bold red", chalk_style().bold().red()) << "\t"
           << chalk("dim green", chalk_style().dim().green()) << "\t"
           << chalk("italic blue", chalk_style().italic().blue()) << "\t"
           << chalk("underline yellow", chalk_style().underline().yellow()) << "\t"
           << chalk("bold gray", chalk_style().bold().gray24()) << "\t"
           << chalk("strike magenta", chalk_style().strike().magenta()) << endl
           << chalk("color19", chalk_style().color256(196)) << "\t"
           << chalk("color196", chalk_style().color256(19)) << "\t"
           << chalk("color26", chalk_style().color256(26)) << "\t"
           << chalk("color88", chalk_style().color256(88)) << "\t"
           << chalk("color208", chalk_style().color256(208)) << "\t"
           << chalk("color100", chalk_style().color256(100)) << "\t"
           << chalk("color50", chalk_style().color256(50)) << "\t"
           << chalk("color52", chalk_style().color6x6x6(1, 0, 0)) << "\t" << endl
           << chalk("light green", chalk_style().green(true)) << "\t"
           << chalk("light blue", chalk_style().blue(true)) << "\t"
           << chalk("light yellow", chalk_style().yellow(true)) << "\t"
           << chalk("light gray", chalk_style().gray24(4)) << "\t"
           << chalk("light magenta", chalk_style().magenta(true)) << endl
           << chalk("bg_red", chalk_style().bold().bg_red()) << "\t"
           << chalk("bg_green", chalk_style().bold().bg_green()) << "\t"
           << chalk("bg_yellow", chalk_style().bold().bg_yellow()) << "\t"
           << chalk("bg_blue", chalk_style().bold().bg_blue()) << "\t"
           << chalk("bg_magenta", chalk_style().bold().bg_magenta()) << "\t"
           << chalk("bg_cyan", chalk_style().bold().bg_cyan()) << "\t"
           << chalk("bg_white", chalk_style().bold().bg_white()) << endl;
      return 0;
    }
    
    

    PS: 最近重学 C++, 欢迎批评指正.

    3 条回复    2020-04-28 14:01:27 +08:00
    qinfensky
        1
    qinfensky  
       2020-03-14 20:13:46 +08:00
    太强了,刚好我也想入门下 C++ 17
    c0xt30a
        2
    c0xt30a  
       2020-04-28 05:28:17 +08:00
    @banxi1988 挂完了代码就跑?给你提的两个 issue 好几个月了
    banxi1988
        3
    banxi1988  
    OP
       2020-04-28 14:01:27 +08:00
    @c0xt30a #2 sorry, 之前都没有看到 GitHub 的通知. 主要是被各种没用的通知淹没了.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1705 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:43 · PVG 00:43 · LAX 08:43 · JFK 11:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.