-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from HsuanTingLu/release/v1.4.0
Merge branch 'release/v1.4.0'
- Loading branch information
Showing
24 changed files
with
190 additions
and
1,140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
# | ||
# Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
# | ||
# CMake configs | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope tha it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
# Most widely used distributions have cmake 3.5 or greater available as of March | ||
# 2019. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
# | ||
# Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
# | ||
# Wrap some CSI escape codes with string streams | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope tha it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
add_library(aesc) # Depends on option:BUILD_SHARED_LIBS | ||
|
||
target_sources(aesc | ||
|
@@ -80,7 +61,7 @@ if(ENABLE_UBSAN_SYMBOLIZED_OUTPUTS) | |
if(NOT llvm_symbolizer_path STREQUAL "llvm_symbolizer_path-NOTFOUND") | ||
message(VERBOSE "\"llvm-symbolizer\"\t program path: ${llvm_symbolizer_path}") | ||
set(ENV{UBSAN_SYMBOLIZER_PATH} "${llvm_symbolizer_path}") | ||
set(ENV{UBSAN_OPTIONS} "print_stacktrace=1") | ||
set(ENV{UBSAN_OPTIONS} "print_stacktrace=1") | ||
else() | ||
message(WARNING "llvm-symbolizer not found") | ||
endif() | ||
|
@@ -97,7 +78,7 @@ target_compile_options(aesc | |
$<$<BOOL:${ENABLE_UBSAN}>:-fsanitize=undefined;-g;-fno-omit-frame-pointer> | ||
$<$<AND:$<BOOL:${ENABLE_UBSAN}>,$<CONFIG:RelWithDebInfo>>:-fsanitize=-fsanitize-minimal-runtime> | ||
|
||
-march=native # FIXME: be cautious | ||
# -march=native # FIXME: be cautious | ||
-Wall | ||
-Wextra | ||
-pedantic | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
/* | ||
* Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
* | ||
* Wrap some terminal control sequences with string streams | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope tha it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef AESC_AESC_HPP_ | ||
#define AESC_AESC_HPP_ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
# | ||
# Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
# | ||
# Wrap some CSI escape codes with string streams | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope tha it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
target_sources(aesc | ||
PRIVATE | ||
${PROJECT_SOURCE_DIR}/aesc/control/cursor.hpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
/* | ||
* Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
* | ||
* Wraps cursor control sequences | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope tha it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "aesc/control/cursor.hpp" | ||
|
||
#include "aesc/internal/sequences.hpp" | ||
|
||
namespace aesc { // Ansi Escape Terminal | ||
|
||
inline namespace cursor { | ||
|
||
namespace internal { | ||
|
||
namespace { | ||
constexpr const char* up_expr = "A"; | ||
constexpr const char* down_expr = "B"; | ||
|
@@ -38,76 +22,50 @@ constexpr const char* save_cursor_expr = "s"; | |
constexpr const char* restore_cursor_expr = "u"; | ||
} // anonymous namespace | ||
|
||
manipulator::smanip up(const int n) { | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << up_expr; | ||
return s; | ||
}; | ||
return {h, n}; | ||
auto up(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << up_expr; | ||
return s; | ||
} | ||
|
||
manipulator::smanip down(const int n) { | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << down_expr; | ||
return s; | ||
}; | ||
return {h, n}; | ||
} | ||
auto down(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << down_expr; | ||
return s; | ||
}; | ||
|
||
manipulator::smanip forward(const int n) { | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << forward_expr; | ||
return s; | ||
}; | ||
return {h, n}; | ||
} | ||
auto forward(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << forward_expr; | ||
return s; | ||
}; | ||
|
||
manipulator::smanip back(const int n) { | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << back_expr; | ||
return s; | ||
}; | ||
return {h, n}; | ||
} | ||
auto back(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << back_expr; | ||
return s; | ||
}; | ||
|
||
manipulator::smanip next_line(const int n) { | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << next_line_expr; | ||
return s; | ||
}; | ||
return {h, n}; | ||
} | ||
auto next_line(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << next_line_expr; | ||
return s; | ||
}; | ||
|
||
manipulator::smanip prev_line(const int n) { | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << prev_line_expr; | ||
return s; | ||
}; | ||
return {h, n}; | ||
} | ||
auto prev_line(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << prev_line_expr; | ||
return s; | ||
}; | ||
|
||
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 line | ||
* | ||
* Cursor position does NOT change | ||
*/ | ||
auto h = [](std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << erase_in_line_expr; | ||
return s; | ||
}; | ||
return {h, static_cast<int>(n)}; | ||
} | ||
auto EL(std::ostream& s, const int x) -> std::ostream& { | ||
s << CSI_expr << x << erase_in_line_expr; | ||
return s; | ||
}; | ||
|
||
} // namespace internal | ||
|
||
std::ostream& save_pos(std::ostream& stream) { | ||
stream << CSI_expr << save_cursor_expr; | ||
stream << CSI_expr << internal::save_cursor_expr; | ||
return stream; | ||
} | ||
|
||
std::ostream& restore_pos(std::ostream& stream) { | ||
stream << CSI_expr << restore_cursor_expr; | ||
stream << CSI_expr << internal::restore_cursor_expr; | ||
return stream; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,80 @@ | ||
/* | ||
* Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
* | ||
* Wraps cursor control sequences | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope tha it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef AESC_CONTROL_CURSOR_HPP_ | ||
#define AESC_CONTROL_CURSOR_HPP_ | ||
|
||
#include "aesc/internal/manipulator.hpp" | ||
#include "aesc/internal/sequences.hpp" | ||
|
||
namespace aesc { // Ansi Escape Terminal | ||
|
||
inline namespace cursor { // Cursor controls | ||
|
||
enum class clear : int { to_end = 0, to_beginning = 1, entire = 2 }; | ||
|
||
manipulator::smanip up(const int n = 1); | ||
manipulator::smanip down(const int n = 1); | ||
manipulator::smanip forward(const int n = 1); | ||
manipulator::smanip back(const int n = 1); | ||
namespace internal { | ||
|
||
std::ostream& up(std::ostream& s, int x); | ||
|
||
std::ostream& down(std::ostream& s, int x); | ||
|
||
std::ostream& forward(std::ostream& s, int x); | ||
|
||
std::ostream& back(std::ostream& s, int x); | ||
|
||
std::ostream& next_line(std::ostream& s, int x); | ||
|
||
std::ostream& prev_line(std::ostream& s, int x); | ||
|
||
std::ostream& EL(std::ostream& s, int x); | ||
|
||
} // namespace internal | ||
|
||
constexpr manipulator::smanip up(int n = 1) { | ||
return manipulator::smanip(internal::up, n); | ||
} | ||
|
||
constexpr manipulator::smanip down(int n = 1) { | ||
return manipulator::smanip(internal::down, n); | ||
} | ||
|
||
constexpr manipulator::smanip forward(int n = 1) { | ||
return manipulator::smanip(internal::forward, n); | ||
} | ||
|
||
constexpr manipulator::smanip back(int n = 1) { | ||
return manipulator::smanip(internal::back, n); | ||
} | ||
|
||
// moves to beginning of next line | ||
manipulator::smanip next_line(const int n = 1); | ||
constexpr manipulator::smanip next_line(int n = 1) { | ||
return manipulator::smanip(internal::next_line, n); | ||
} | ||
|
||
// moves to beginning of previous line | ||
manipulator::smanip prev_line(const int n = 1); | ||
constexpr manipulator::smanip prev_line(int n = 1) { | ||
return manipulator::smanip(internal::prev_line, n); | ||
} | ||
|
||
// erases from cursor to EOL if 0 | ||
// clear from cursor to beginning if 1 | ||
// clears entire line if 2 | ||
manipulator::smanip EL(const clear n); | ||
constexpr 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 line | ||
* | ||
* Cursor position does NOT change | ||
*/ | ||
return manipulator::smanip(internal::EL, static_cast<int>(n)); | ||
} | ||
|
||
// Saves cursor position and state | ||
std::ostream& save_pos(std::ostream& stream); | ||
|
||
// Restores cursor position and state | ||
std::ostream& restore_pos(std::ostream& stream); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
# | ||
# Copyright (C) 2019 Hsuan-Ting Lu <[email protected]> | ||
# | ||
# Wrap some CSI escape codes with string streams | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope tha it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
target_sources(aesc | ||
PRIVATE | ||
${PROJECT_SOURCE_DIR}/aesc/internal/manipulator.hpp | ||
|
Oops, something went wrong.