Skip to content

Commit 6253328

Browse files
flagardeflagarde
andauthored
Co-authored-by: flagarde <flagarde.program@pm.me>
1 parent f45ebe3 commit 6253328

31 files changed

+592
-260
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ BreakBeforeTernaryOperators: true
4848
BreakConstructorInitializers: AfterColon
4949
BreakAfterJavaFieldAnnotations: false
5050
BreakStringLiterals: false
51-
ColumnLimit: 260
51+
ColumnLimit: 450
5252
CommentPragmas: '^ IWYU pragma:'
5353
CompactNamespaces: false
5454
ConstructorInitializerIndentWidth: 2

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
Checks: 'abseil-*,altera-*,android-*,boost-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,darwin-*,fuchsia-*,google-*,hicpp-*,linuxkernel-*,llvm-*,misc-*,modernize-*,mpi-*,openmp-*,performance-*,portability-*,readability-*,zircon-*'
3+
WarningsAsErrors: false
4+
...

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ project(cpp-terminal
99
LANGUAGES CXX)
1010

1111
# see https://cmake.org/cmake/help/latest/policy/CMP0092.html
12-
message(STATUS "${CMAKE_CXX_FLAGS}")
1312
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
1413
set(CMAKE_CXX_FLAGS_OLD "${CMAKE_CXX_FLAGS}")
1514
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")

cmake/Warnings.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ set(GCC_LIKE_WARNINGS
2424
set(GCC_LIKE_CXX_WARNINGS)
2525
#GCC
2626
set(GCC_WARNINGS
27-
"$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,4.8.0>:-Wpedantic>"
28-
"$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,4.9.0>:-fdiagnostics-color=auto>"
29-
"-Wno-implicit-fallthrough"
30-
"-Wno-maybe-uninitialized"
31-
"-Wno-strict-overflow"
27+
"$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.8.0>:-Wpedantic>"
28+
"$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.9.0>:-fdiagnostics-color=auto>"
3229
"-Wpointer-arith"
3330
"-Wredundant-decls"
3431
"-Wundef"
3532
"-Wwrite-strings")
3633
set(GCC_CXX_WARNINGS
3734
"-Wdelete-non-virtual-dtor"
35+
"$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,4.8.0>:-Wpedantic>"
36+
"$<$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,4.9.0>:-fdiagnostics-color=auto>"
3837
"-Wnoexcept")
3938
#Clang like
4039
set(CLANG_LIKE_WARNINGS

cpp-terminal/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ configure_file(version.cpp.in version.cpp)
44
add_subdirectory(platforms)
55

66
# create and configure library target
7-
add_library(cpp-terminal args.cpp buffer.cpp iostream.cpp stream.cpp prompt.cpp window.cpp input.cpp terminal.cpp color.cpp key.cpp event.cpp screen.cpp options.cpp cursor.cpp style.cpp "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")
7+
add_library(cpp-terminal args.cpp buffer.cpp iostream.cpp stream.cpp prompt.cpp window.cpp terminal.cpp color.cpp key.cpp event.cpp screen.cpp options.cpp cursor.cpp style.cpp "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")
88
target_link_libraries(cpp-terminal PRIVATE Warnings::Warnings cpp-terminal::cpp-terminal-platforms)
99
target_compile_options(cpp-terminal PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/utf-8>)
1010
target_include_directories(cpp-terminal PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}> $<INSTALL_INTERFACE:include>)

cpp-terminal/event.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,19 @@ void Term::Event::parse(const std::string& str)
310310
m_container.m_Key = Key(Term::Key::Value::Numeric5);
311311
else if(Term::Private::is_valid_utf8_code_unit(str))
312312
m_container.m_Key = Key(static_cast<Term::Key::Value>(Term::Private::utf8_to_utf32(str)[0]));
313+
else
314+
{
315+
m_Type = Type::CopyPaste;
316+
m_str = str;
317+
return;
318+
}
319+
m_Type = Type::Key;
313320
}
314321
else
315322
{
316323
m_Type = Type::CopyPaste;
317324
m_str = str;
318325
}
319-
if(!m_container.m_Key.empty()) { m_Type = Type::Key; }
320326
}
321327

322328
Term::Event::operator Term::Key() const

cpp-terminal/input.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

cpp-terminal/input.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22

33
#include "cpp-terminal/event.hpp"
44

5-
#include <string>
6-
75
namespace Term
86
{
97

10-
namespace Platform
11-
{
12-
// Returns true if a character is read, otherwise immediately returns false
13-
// This can't be made inline
14-
Term::Event read_raw();
15-
} // namespace Platform
16-
17-
// Waits for an event (key press, screen resizing ...)
188
Term::Event read_event();
199

2010
} // namespace Term

cpp-terminal/key.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ bool Term::MetaKey::operator==(const Term::MetaKey& meta) const { return (meta.m
3232

3333
bool Term::MetaKey::operator!=(const Term::MetaKey& meta) const { return !(meta == *this); }
3434

35+
Term::MetaKey& Term::MetaKey::operator+=(const MetaKey& meta)
36+
{
37+
this->m_value = static_cast<Term::MetaKey::Value>(static_cast<Term::MetaKey::Value>(this->m_value) + static_cast<Term::MetaKey::Value>(meta.m_value));
38+
return *this;
39+
}
40+
3541
Term::Key::Key(const Term::Key::Value& value) : m_value(value) {}
3642

3743
Term::Key::operator Term::Key::Value() const { return m_value; }

cpp-terminal/key.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,13 @@ class MetaKey
250250
};
251251
MetaKey() = default;
252252
MetaKey(const MetaKey::Value& value);
253-
Term::MetaKey operator+(const MetaKey& meta) const;
254-
Term::Key operator+(const Key& key) const;
255-
bool operator==(const Term::MetaKey& meta) const;
256-
bool operator!=(const Term::MetaKey& meta) const;
257-
bool hasAlt() const;
258-
bool hasCtrl() const;
253+
Term::MetaKey operator+(const MetaKey& meta) const;
254+
Term::Key operator+(const Key& key) const;
255+
Term::MetaKey& operator+=(const MetaKey& meta);
256+
bool operator==(const Term::MetaKey& meta) const;
257+
bool operator!=(const Term::MetaKey& meta) const;
258+
bool hasAlt() const;
259+
bool hasCtrl() const;
259260

260261
private:
261262
MetaKey::Value m_value{Value::None};

0 commit comments

Comments
 (0)