Skip to content

Commit 03adc57

Browse files
[pre-commit.ci] pre-commit autoupdate (#410)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/mirrors-clang-format: v20.1.8 → v21.1.0](pre-commit/mirrors-clang-format@v20.1.8...v21.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e6486dd commit 03adc57

18 files changed

+147
-43
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ repos:
4545
name: check .editorconfig rules
4646

4747
- repo: https://github.com/pre-commit/mirrors-clang-format
48-
rev: v20.1.8
48+
rev: v21.1.0
4949
hooks:
5050
- id: clang-format
5151

cpp-terminal/buffer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ Term::Buffer::int_type Term::Buffer::underflow()
7171
m_buffer.clear();
7272
if(terminal.getOptions().has(Option::Raw))
7373
{
74-
do {
74+
do
75+
{
7576
std::string ret{Term::Private::in.read()};
7677
if(!ret.empty())
7778
{
@@ -96,7 +97,8 @@ Term::Buffer::int_type Term::Buffer::underflow()
9697
}
9798
else
9899
{
99-
do {
100+
do
101+
{
100102
std::string ret{Term::Private::in.read()};
101103
m_buffer += ret;
102104
} while(m_buffer.empty());

cpp-terminal/event.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ class Event
4848
Event& operator=(const Term::Event& event);
4949
bool empty() const;
5050
Type type() const;
51-
operator Term::Key() const;
52-
operator Term::Screen() const;
53-
operator Term::Cursor() const;
54-
operator Term::Focus() const;
55-
operator Term::Mouse() const;
56-
operator std::string() const;
51+
operator Term::Key() const;
52+
operator Term::Screen() const;
53+
operator Term::Cursor() const;
54+
operator Term::Focus() const;
55+
operator Term::Mouse() const;
56+
operator std::string() const;
5757

5858
// getters
5959
Key* get_if_key();

cpp-terminal/private/exception.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ Term::Exception::Exception(const std::int64_t& code) noexcept : m_code(code) {}
5757
void Term::Exception::build_what() const noexcept
5858
{
5959
if(0 == m_code) { m_what = m_message; }
60-
else { m_what = "error " + std::to_string(m_code) + ": " + m_message; }
60+
else
61+
{
62+
m_what = "error " + std::to_string(m_code) + ": " + m_message;
63+
}
6164
}
6265

6366
void Term::Exception::setMessage(const std::string& message) noexcept { m_message = message; }
@@ -100,7 +103,10 @@ Term::Private::WindowsException::WindowsException(const std::int64_t& error, con
100103
if(ret.size() >= 2 && ret[ret.size() - 1] == '\n' && ret[ret.size() - 2] == '\r') ret.erase(ret.size() - 2);
101104
setMessage(ret);
102105
}
103-
else { throw Term::Exception(::GetLastError(), "Error in FormatMessageW"); }
106+
else
107+
{
108+
throw Term::Exception(::GetLastError(), "Error in FormatMessageW");
109+
}
104110
}
105111

106112
void Term::Private::WindowsException::build_what() const noexcept

cpp-terminal/private/file.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ try : m_mutex(mutex)
6767
flag &= ~static_cast<std::size_t>(O_NONBLOCK);
6868
if(mode.find('r') != std::string::npos) { flag |= O_RDONLY; } //NOLINT(abseil-string-find-str-contains)
6969
else if(mode.find('w') != std::string::npos) { flag |= O_WRONLY; } //NOLINT(abseil-string-find-str-contains)
70-
else { flag |= O_RDWR; }
70+
else
71+
{
72+
flag |= O_RDWR;
73+
}
7174
m_fd = {::open(file.c_str(), static_cast<int>(flag))}; //NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
7275
if(m_fd == -1)
7376
{

cpp-terminal/private/sigwinch.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ volatile std::sig_atomic_t m_signalStatus{0};
2929
static void sigwinchHandler(int sig)
3030
{
3131
if(sig == SIGWINCH) { m_signalStatus = 1; }
32-
else { m_signalStatus = 0; }
32+
else
33+
{
34+
m_signalStatus = 0;
35+
}
3336
}
3437
} // namespace Private
3538
} // namespace Term

cpp-terminal/private/terminfo.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ void Term::Terminfo::checkColorMode()
154154
else if(WindowsVersionGreater(10, 0, 10586) && !m_booleans[static_cast<std::size_t>(Terminfo::Bool::Legacy)]) { m_colorMode = Term::Terminfo::ColorMode::Bit24; }
155155
else if(m_booleans[static_cast<std::size_t>(Terminfo::Bool::Legacy)]) { m_colorMode = Term::Terminfo::ColorMode::Bit4; }
156156
#endif
157-
else { m_colorMode = Term::Terminfo::ColorMode::Bit24; }
157+
else
158+
{
159+
m_colorMode = Term::Terminfo::ColorMode::Bit24;
160+
}
158161
std::string colorterm = Private::getenv("COLORTERM").second;
159162
if((colorterm == "truecolor" || colorterm == "24bit") && m_colorMode != ColorMode::Unset) { m_colorMode = Term::Terminfo::ColorMode::Bit24; }
160163
}
@@ -163,7 +166,10 @@ void Term::Terminfo::checkControlSequences()
163166
{
164167
#ifdef _WIN32
165168
if(WindowsVersionGreater(10, 0, 10586)) { set(Term::Terminfo::Bool::ControlSequences, true); }
166-
else { set(Term::Terminfo::Bool::ControlSequences, false); }
169+
else
170+
{
171+
set(Term::Terminfo::Bool::ControlSequences, false);
172+
}
167173
#else
168174
set(Term::Terminfo::Bool::ControlSequences, true);
169175
#endif
@@ -180,7 +186,10 @@ void Term::Terminfo::checkUTF8()
180186
Term::Cursor cursor_after{Term::cursor_position()};
181187
std::size_t moved{cursor_after.column() - cursor_before.column()};
182188
if(moved == 1) { set(Terminfo::Bool::UTF8, true); }
183-
else { set(Terminfo::Bool::UTF8, false); }
189+
else
190+
{
191+
set(Terminfo::Bool::UTF8, false);
192+
}
184193
for(std::size_t i = 0; i != moved; ++i) { Term::Private::out.write("\b \b"); }
185194
#endif
186195
}

cpp-terminal/private/unicode.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ std::string Term::Private::utf32_to_utf8(const char32_t& codepoint, const bool&
6868
else if(codepoint <= size[2]) { ret = {static_cast<char>(((codepoint >> shift[2]) & mask_first[1]) | add_first[1]), static_cast<char>(((codepoint >> shift[1]) & add) | mask), static_cast<char>(((codepoint >> shift[0]) & add) | mask)}; }
6969
else if(codepoint <= size[3]) { ret = {static_cast<char>(((codepoint >> shift[3]) & mask_first[2]) | add_first[2]), static_cast<char>(((codepoint >> shift[2]) & add) | mask), static_cast<char>(((codepoint >> shift[1]) & add) | mask), static_cast<char>(((codepoint >> shift[0]) & add) | mask)}; }
7070
else if(exception) { throw Term::Exception("Invalid UTF32 codepoint."); }
71-
else { ret = "\xEF\xBF\xBD"; }
71+
else
72+
{
73+
ret = "\xEF\xBF\xBD";
74+
}
7275
return ret;
7376
}
7477

cpp-terminal/prompt.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ std::vector<std::string> Term::split(const std::string& s)
161161
j++;
162162
lines.emplace_back("");
163163
}
164-
else { lines[j].push_back(s[i]); }
164+
else
165+
{
166+
lines[j].push_back(s[i]);
167+
}
165168
}
166169
return lines;
167170
}
@@ -345,7 +348,10 @@ std::string Term::prompt_multiline(const std::string& prompt_string, std::vector
345348
// Not at the bottom row, can't push back
346349
model.lines.insert(model.lines.begin() + static_cast<long>(model.cursor_row), after);
347350
}
348-
else { model.lines.push_back(after); }
351+
else
352+
{
353+
model.lines.push_back(after);
354+
}
349355
model.cursor_col = 1;
350356
model.cursor_row++;
351357
if(model.lines.size() > scr.columns()) { scr.set_h(model.lines.size()); }

cpp-terminal/window.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ const Rows& Term::Window::rows() const noexcept { return m_size.rows(); }
4646
void Term::Window::set_char(const std::size_t& column, const std::size_t& row, const char32_t& character)
4747
{
4848
if(insideWindow(column, row)) { m_chars[index(column, row)] = character; }
49-
else { throw Term::Exception("set_char(): (x,y) out of bounds"); }
49+
else
50+
{
51+
throw Term::Exception("set_char(): (x,y) out of bounds");
52+
}
5053
}
5154

5255
void Term::Window::set_fg_reset(const std::size_t& column, const std::size_t& row)
@@ -91,7 +94,10 @@ void Term::Window::set_h(const std::size_t& new_h)
9194
m_style.insert(m_style.end(), dc, Style::Reset);
9295
m_size = {Term::Columns(m_size.columns()), Term::Rows(new_h)};
9396
}
94-
else { throw Term::Exception("Shrinking height not supported."); }
97+
else
98+
{
99+
throw Term::Exception("Shrinking height not supported.");
100+
}
95101
}
96102

97103
void Term::Window::print_str(const std::size_t& x, const std::size_t& y, const std::string& s, const std::size_t& indent, bool move_cursor)
@@ -109,12 +115,18 @@ void Term::Window::print_str(const std::size_t& x, const std::size_t& y, const s
109115
{
110116
for(std::size_t j = 0; j < indent; ++j) { set_char(x + j, ypos, '.'); }
111117
}
112-
else { return; }
118+
else
119+
{
120+
return;
121+
}
113122
}
114123
else
115124
{
116125
if(insideWindow(xpos, ypos)) { set_char(xpos, y, i); }
117-
else { return; }
126+
else
127+
{
128+
return;
129+
}
118130
++xpos;
119131
}
120132
}

0 commit comments

Comments
 (0)