fix for windows
parent
19f9dead27
commit
0bd3519e7e
|
@ -23,7 +23,9 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
message(STATUS "GCC libs: ${Green}stdc++fs${ColourReset}")
|
message(STATUS "GCC libs: ${Green}stdc++fs${ColourReset}")
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
|
||||||
target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
|
target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
|
||||||
target_link_options(${PROJECT_NAME} PUBLIC -rdynamic)
|
if (NOT WIN32)
|
||||||
|
target_link_options(${PROJECT_NAME} PUBLIC -rdynamic)
|
||||||
|
endif()
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
|
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
|
|
|
@ -82,14 +82,14 @@ namespace blt
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
class enumerate_iterator_container : public iterator::iterator_container<iterator::enumerate_wrapper<Iter>>
|
class enumerate_iterator_container : public blt::iterator::iterator_container<blt::iterator::enumerate_wrapper<Iter>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using iterator::iterator_container<iterator::enumerate_wrapper<Iter>>::iterator_container;
|
using blt::iterator::iterator_container<blt::iterator::enumerate_wrapper<Iter>>::iterator_container;
|
||||||
|
|
||||||
enumerate_iterator_container(Iter begin, Iter end, blt::size_t size):
|
enumerate_iterator_container(Iter begin, Iter end, blt::size_t size):
|
||||||
iterator::iterator_container<iterator::enumerate_wrapper<Iter>>(
|
blt::iterator::iterator_container<blt::iterator::enumerate_wrapper<Iter>>(
|
||||||
iterator::enumerate_wrapper<Iter>{0, std::move(begin)}, iterator::enumerate_wrapper<Iter>{size, std::move(end)})
|
blt::iterator::enumerate_wrapper<Iter>{0, std::move(begin)}, blt::iterator::enumerate_wrapper<Iter>{size, std::move(end)})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,11 +112,11 @@ namespace blt
|
||||||
class zip_iterator_container : public iterator::iterator_container<iterator::zip_wrapper<Iter...>>
|
class zip_iterator_container : public iterator::iterator_container<iterator::zip_wrapper<Iter...>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using iterator::iterator_container<iterator::zip_wrapper<Iter...>>::iterator_container;
|
using blt::iterator::iterator_container<blt::iterator::zip_wrapper<Iter...>>::iterator_container;
|
||||||
|
|
||||||
explicit zip_iterator_container(iterator::iterator_pair<Iter>... iterator_pairs):
|
explicit zip_iterator_container(blt::iterator::iterator_pair<Iter>... iterator_pairs):
|
||||||
iterator::iterator_container<iterator::zip_wrapper<Iter...>>(iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
|
blt::iterator::iterator_container<blt::iterator::zip_wrapper<Iter...>>(blt::iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
|
||||||
iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...})
|
blt::iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...})
|
||||||
{}
|
{}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -223,8 +223,12 @@ namespace blt
|
||||||
|
|
||||||
std::string_view from_last()
|
std::string_view from_last()
|
||||||
{
|
{
|
||||||
if (!hasNext())
|
if (!hasNext()) {
|
||||||
return std::string_view(&raw_string[last_read_index], raw_string.size() - last_read_index);
|
auto size = raw_string.size() - last_read_index;
|
||||||
|
if (size > 0)
|
||||||
|
return std::string_view(&raw_string[last_read_index], size);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
auto token = storage[getCurrentIndex()];
|
auto token = storage[getCurrentIndex()];
|
||||||
auto len = ((&token.token.back()) - &raw_string[last_read_index]);
|
auto len = ((&token.token.back()) - &raw_string[last_read_index]);
|
||||||
auto str = std::string_view(&raw_string[last_read_index], len);
|
auto str = std::string_view(&raw_string[last_read_index], len);
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace blt::logging
|
||||||
if (end == std::string::npos)
|
if (end == std::string::npos)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Invalid format string, missing closing '}' near " << m_fmt.substr(std::min(static_cast<i64>(begin) - 5, 0l));
|
ss << "Invalid format string, missing closing '}' near " << m_fmt.substr(std::min(static_cast<i64>(begin) - 5, 0ll));
|
||||||
throw std::runtime_error(ss.str());
|
throw std::runtime_error(ss.str());
|
||||||
}
|
}
|
||||||
m_last_fmt_pos = end + 1;
|
m_last_fmt_pos = end + 1;
|
||||||
|
|
|
@ -17,8 +17,10 @@
|
||||||
*/
|
*/
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#ifdef unix
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#include <blt/logging/ansi.h>
|
#include <blt/logging/ansi.h>
|
||||||
#include <blt/logging/fmt_tokenizer.h>
|
#include <blt/logging/fmt_tokenizer.h>
|
||||||
#include <blt/logging/logging.h>
|
#include <blt/logging/logging.h>
|
||||||
|
@ -30,6 +32,7 @@ namespace blt::logging
|
||||||
{
|
{
|
||||||
vec2i get_cursor_position()
|
vec2i get_cursor_position()
|
||||||
{
|
{
|
||||||
|
#ifdef unix
|
||||||
termios save{}, raw{};
|
termios save{}, raw{};
|
||||||
|
|
||||||
tcgetattr(0, &save);
|
tcgetattr(0, &save);
|
||||||
|
@ -68,12 +71,16 @@ namespace blt::logging
|
||||||
tcsetattr(0,TCSANOW, &save);
|
tcsetattr(0,TCSANOW, &save);
|
||||||
|
|
||||||
return vec2i{row, col};
|
return vec2i{row, col};
|
||||||
|
#else
|
||||||
|
return {0,0};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SIZE 100
|
#define SIZE 100
|
||||||
|
|
||||||
vec2i get_screen_size()
|
vec2i get_screen_size()
|
||||||
{
|
{
|
||||||
|
#ifdef unix
|
||||||
char in[SIZE] = "";
|
char in[SIZE] = "";
|
||||||
int each = 0;
|
int each = 0;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
|
@ -113,6 +120,9 @@ namespace blt::logging
|
||||||
return {rows, cols};
|
return {rows, cols};
|
||||||
}
|
}
|
||||||
throw std::runtime_error("Could not get screen size");
|
throw std::runtime_error("Could not get screen size");
|
||||||
|
#else
|
||||||
|
return {0,0};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 get_size_no_ansi(const std::string& str)
|
i32 get_size_no_ansi(const std::string& str)
|
||||||
|
|
Loading…
Reference in New Issue