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

2020-03-01 21:13:35 +08:00
 banxi1988

仓库地址: 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++, 欢迎批评指正.

1765 次点击
所在节点    C++
3 条回复
qinfensky
2020-03-14 20:13:46 +08:00
太强了,刚好我也想入门下 C++ 17
c0xt30a
2020-04-28 05:28:17 +08:00
@banxi1988 挂完了代码就跑?给你提的两个 issue 好几个月了
banxi1988
2020-04-28 14:01:27 +08:00
@c0xt30a #2 sorry, 之前都没有看到 GitHub 的通知. 主要是被各种没用的通知淹没了.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/648930

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX