fix for windows

main
Tri11Paragon 2025-03-13 13:47:44 -07:00
parent 19f9dead27
commit 0bd3519e7e
6 changed files with 28 additions and 12 deletions

View File

@ -23,7 +23,9 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "GCC libs: ${Green}stdc++fs${ColourReset}")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
if (NOT WIN32)
target_link_options(${PROJECT_NAME} PUBLIC -rdynamic)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
include(GNUInstallDirs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")

View File

@ -82,14 +82,14 @@ namespace blt
}
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:
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):
iterator::iterator_container<iterator::enumerate_wrapper<Iter>>(
iterator::enumerate_wrapper<Iter>{0, std::move(begin)}, iterator::enumerate_wrapper<Iter>{size, std::move(end)})
blt::iterator::iterator_container<blt::iterator::enumerate_wrapper<Iter>>(
blt::iterator::enumerate_wrapper<Iter>{0, std::move(begin)}, blt::iterator::enumerate_wrapper<Iter>{size, std::move(end)})
{
}
};

View File

@ -112,11 +112,11 @@ namespace blt
class zip_iterator_container : public iterator::iterator_container<iterator::zip_wrapper<Iter...>>
{
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):
iterator::iterator_container<iterator::zip_wrapper<Iter...>>(iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...})
explicit zip_iterator_container(blt::iterator::iterator_pair<Iter>... iterator_pairs):
blt::iterator::iterator_container<blt::iterator::zip_wrapper<Iter...>>(blt::iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.begin)...},
blt::iterator::zip_wrapper<Iter...>{std::move(iterator_pairs.end)...})
{}
};

View File

@ -223,8 +223,12 @@ namespace blt
std::string_view from_last()
{
if (!hasNext())
return std::string_view(&raw_string[last_read_index], raw_string.size() - last_read_index);
if (!hasNext()) {
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 len = ((&token.token.back()) - &raw_string[last_read_index]);
auto str = std::string_view(&raw_string[last_read_index], len);

View File

@ -204,7 +204,7 @@ namespace blt::logging
if (end == std::string::npos)
{
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());
}
m_last_fmt_pos = end + 1;

View File

@ -17,8 +17,10 @@
*/
#include <cstdio>
#include <iostream>
#ifdef unix
#include <termios.h>
#include <unistd.h>
#endif
#include <blt/logging/ansi.h>
#include <blt/logging/fmt_tokenizer.h>
#include <blt/logging/logging.h>
@ -30,6 +32,7 @@ namespace blt::logging
{
vec2i get_cursor_position()
{
#ifdef unix
termios save{}, raw{};
tcgetattr(0, &save);
@ -68,12 +71,16 @@ namespace blt::logging
tcsetattr(0,TCSANOW, &save);
return vec2i{row, col};
#else
return {0,0};
#endif
}
#define SIZE 100
vec2i get_screen_size()
{
#ifdef unix
char in[SIZE] = "";
int each = 0;
int ch = 0;
@ -113,6 +120,9 @@ namespace blt::logging
return {rows, cols};
}
throw std::runtime_error("Could not get screen size");
#else
return {0,0};
#endif
}
i32 get_size_no_ansi(const std::string& str)