Skip to content

Commit

Permalink
Merge pull request #13 from HsuanTingLu/release/v1.3.1
Browse files Browse the repository at this point in the history
Merge branch 'release/v1.3.1'
  • Loading branch information
moshiba authored Sep 29, 2020
2 parents 6722777 + 8c97b45 commit af80793
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 76 deletions.
21 changes: 0 additions & 21 deletions .buckconfig

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Build system
.clangd/
## Buck
.buckd/
buck-out/
Expand Down
Empty file removed BUCK
Empty file.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
cmake_minimum_required(VERSION 3.9)
project(aesc LANGUAGES CXX)

option(BUILD_SHARED_LIBS "Build as shared library." ON)

option(ENABLE_IPO "Enable interprocedural optimization." ON)
if(ENABLE_IPO)
include(CheckIPOSupported)
Expand All @@ -43,5 +45,7 @@ if(ENABLE_UBSAN_SYMBOLIZED_OUTPUTS)
set(ENABLE_UBSAN ON)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_subdirectory(aesc)
add_subdirectory(examples EXCLUDE_FROM_ALL)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ brew install ansi-escape

### Build with CMake

CMake is the official build system. At least version 3.5 is needed.
CMake is the official build system. At least version 3.9 is needed.

```bash
mkdir build; cd build/
Expand Down
15 changes: 0 additions & 15 deletions aesc/BUCK

This file was deleted.

2 changes: 1 addition & 1 deletion aesc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

add_library(aesc SHARED)
add_library(aesc) # Depends on option:BUILD_SHARED_LIBS

target_sources(aesc
INTERFACE
Expand Down
4 changes: 3 additions & 1 deletion aesc/control/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ manipulator::smanip EL(clear n) {
/*
* n = 0: clear from cursor to end of screen
* n = 1: clear from cursor to beginning of the screen
* n = 2: clear entire screen, and moves cursor to upper left
* n = 2: clear entire line
*
* Cursor position does NOT change
*/
auto h = [](std::ostream& s, const int x) -> std::ostream& {
s << CSI_expr << x << erase_in_line_expr;
Expand Down
2 changes: 1 addition & 1 deletion aesc/render/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace aesc { // Ansi Escape Terminal

namespace color {
inline namespace color {

inline namespace { // 4-bit
// foreground colors, 30-39
Expand Down
2 changes: 1 addition & 1 deletion aesc/render/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace aesc { // Ansi Escape Terminal

namespace color {
inline namespace color {

std::ostream& black(std::ostream& stream);
std::ostream& red(std::ostream& stream);
Expand Down
8 changes: 8 additions & 0 deletions aesc/render/color256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ manipulator::smanipiii background(const int r, const int g, const int b) {
return {h, r, g, b};
}

auto& fg = foreground;

auto& bg = background;

} // namespace RGB

namespace grey {
Expand Down Expand Up @@ -92,6 +96,10 @@ manipulator::smanip background(const int n) {
return {h, n};
}

auto& fg = foreground;

auto& bg = background;

} // namespace grey

} // namespace color256
Expand Down
18 changes: 8 additions & 10 deletions aesc/render/color256.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ namespace color256 {

namespace RGB {

manipulator::smanipiii foreground(const int r = 0, const int g = 0,
const int b = 0);
manipulator::smanipiii background(const int r = 0, const int g = 0,
const int b = 0);
auto& fg = foreground;
auto& bg = background;
manipulator::smanipiii foreground(int r = 0, int g = 0, int b = 0);
manipulator::smanipiii background(int r = 0, int g = 0, int b = 0);
extern decltype(foreground)& fg;
extern decltype(background)& bg;

} // namespace RGB

Expand All @@ -49,10 +47,10 @@ namespace grey {
* 24 step grey:
* <n> ranges from 0 to 23, from white to black
*/
manipulator::smanip foreground(const int n = 1);
manipulator::smanip background(const int n = 1);
auto& fg = foreground;
auto& bg = background;
manipulator::smanip foreground(int n = 1);
manipulator::smanip background(int n = 1);
extern decltype(foreground)& fg;
extern decltype(background)& bg;

} // namespace grey

Expand Down
4 changes: 4 additions & 0 deletions aesc/render/truecolor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ manipulator::smanipiii background(const int r, const int g, const int b) {
return {h, r, g, b};
}

auto& fg = foreground;

auto& bg = background;

} // namespace RGB

} // namespace truecolor
Expand Down
10 changes: 4 additions & 6 deletions aesc/render/truecolor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ namespace truecolor {

inline namespace RGB {

manipulator::smanipiii foreground(const int r = 0, const int g = 0,
const int b = 0);
manipulator::smanipiii background(const int r = 0, const int g = 0,
const int b = 0);
auto& fg = foreground;
auto& bg = background;
manipulator::smanipiii foreground(int r = 0, int g = 0, int b = 0);
manipulator::smanipiii background(int r = 0, int g = 0, int b = 0);
extern decltype(foreground)& fg;
extern decltype(background)& bg;

} // namespace RGB

Expand Down
1 change: 1 addition & 0 deletions compile_commands.json
48 changes: 29 additions & 19 deletions examples/show_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,29 @@
*
*/
#include <iostream>

#include "aesc.hpp"

int main() {
std::cout << "line1" << std::endl
<< "line2" << std::endl
<< aesc::up(1) << "33" << aesc::cursor::EL(aesc::cursor::clear::entire) << "a"
<< std::endl;
std::cout << aesc::render::bold << aesc::render::blink::slow << " bold" << aesc::render::reverse_color
<< " reversed" << aesc::render::reset_intensity << " reset bold"
<< aesc::render::cancel_blink << " reset blink" << aesc::render::cancel_inverse
<< " cancel reverse" << std::endl;
std::cout << " pre-reset" << aesc::render::reset << " post-reset" << std::endl;

std::cout << aesc::color::red << aesc::color::background::cyan << " bg_cyan, fg_red"
<< aesc::render::reset << std::endl;
std::cout << aesc::color::bright::red << aesc::color::bright::background::cyan
<< " bright bg_cyan, bright fg_red" << aesc::render::reset << std::endl;
<< "line2" << std::endl
<< aesc::up(1) << "33"
<< aesc::cursor::EL(aesc::cursor::clear::entire) << "a"
<< std::endl;
std::cout << aesc::render::bold << aesc::render::blink::slow << " bold"
<< aesc::render::reverse_color << " reversed"
<< aesc::render::reset_intensity << " reset bold"
<< aesc::render::cancel_blink << " reset blink"
<< aesc::render::cancel_inverse << " cancel reverse" << std::endl;
std::cout << " pre-reset" << aesc::render::reset << " post-reset"
<< std::endl;

std::cout << aesc::color::red << aesc::color::background::cyan
<< " bg_cyan, fg_red" << aesc::render::reset << std::endl;
std::cout << aesc::color::bright::red
<< aesc::color::bright::background::cyan
<< " bright bg_cyan, bright fg_red" << aesc::render::reset
<< std::endl;

std::cout << "24 level grey FOREground:" << std::endl << "start";
for (int i = 0; i != 24; ++i) {
Expand All @@ -47,15 +53,19 @@ int main() {
}
std::cout << aesc::render::reset << "done" << std::endl;

std::cout << aesc::color256::RGB::foreground(2, 3, 0) << "256 color RGB test sequence"
<< aesc::render::reset << std::endl;
std::cout << aesc::RGB::fg(2, 3, 0) << "256 color RGB alias"
<< aesc::render::reset << std::endl;
std::cout << aesc::color256::RGB::foreground(2, 3, 0)
<< "256 color RGB test sequence" << aesc::render::reset
<< std::endl;
std::cout << aesc::RGB::fg(2, 3, 0) << "256 color RGB alias"
<< aesc::render::reset << std::endl;

std::cout << aesc::truecolor::RGB::foreground(130, 250, 0)
<< "24-bit true color RGB test sequence" << aesc::render::reset << std::endl;
<< "24-bit true color RGB test sequence" << aesc::render::reset
<< std::endl;

std::cout << "aaaa\nbbbb\n" << aesc::cursor::up(2) << "cccc" << std::endl << aesc::cursor::down(3) << "down" << std::endl;
std::cout << "aaaa\nbbbb\n"
<< aesc::cursor::up(2) << "cccc" << std::endl
<< aesc::cursor::down(3) << "down" << std::endl;

return 0;
}

0 comments on commit af80793

Please sign in to comment.