Merge branch 'hotfix-1.7' into develop
This commit is contained in:
commit
a08e274088
@ -108,11 +108,16 @@ namespace std {
|
|||||||
{
|
{
|
||||||
using namespace experimental::filesystem;
|
using namespace experimental::filesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __cpp_lib_experimental_filesystem
|
||||||
|
# define __cpp_lib_experimental_filesystem 201406
|
||||||
|
#endif
|
||||||
} // std
|
} // std
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# undef NANA_USING_STD_FILESYSTEM
|
# undef NANA_USING_STD_FILESYSTEM
|
||||||
# define NANA_USING_STD_FILESYSTEM 1
|
# define NANA_USING_STD_FILESYSTEM 1
|
||||||
|
//Detects whether the compiler supports std::filesystem under current options
|
||||||
# if ((defined(_MSC_VER) && (_MSC_VER >= 1912) && defined(_MSVC_LANG) && _MSVC_LANG >= 201703)) || \
|
# if ((defined(_MSC_VER) && (_MSC_VER >= 1912) && defined(_MSVC_LANG) && _MSVC_LANG >= 201703)) || \
|
||||||
((__cplusplus >= 201703L) && \
|
((__cplusplus >= 201703L) && \
|
||||||
(defined(__clang__) && (__clang_major__ >= 7) || \
|
(defined(__clang__) && (__clang_major__ >= 7) || \
|
||||||
@ -125,14 +130,11 @@ namespace std {
|
|||||||
using namespace std::experimental::filesystem;
|
using namespace std::experimental::filesystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# undef NANA_USING_STD_EXPERIMENTAL_FILESYSTEM
|
||||||
|
# define NANA_USING_STD_EXPERIMENTAL_FILESYSTEM
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef __cpp_lib_experimental_filesystem
|
|
||||||
# define __cpp_lib_experimental_filesystem 201406
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if NANA_USING_NANA_FILESYSTEM
|
#if NANA_USING_NANA_FILESYSTEM
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -558,7 +560,23 @@ namespace std {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // std
|
} // std
|
||||||
|
#else
|
||||||
|
|
||||||
|
//Implements the missing functions for various version of experimental/filesystem
|
||||||
|
# if defined(NANA_USING_STD_EXPERIMENTAL_FILESYSTEM)
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
namespace filesystem
|
||||||
|
{
|
||||||
|
//Visual Studio 2017
|
||||||
|
#if (defined(_MSC_VER) && (_MSC_VER > 1912)) || \
|
||||||
|
(!defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 801))
|
||||||
|
path weakly_canonical(const path& p);
|
||||||
|
path weakly_canonical(const path& p, std::error_code& err);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif //NANA_USING_NANA_FILESYSTEM
|
#endif //NANA_USING_NANA_FILESYSTEM
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* A Tree Container class implementation
|
* A Tree Container class implementation
|
||||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -193,6 +193,11 @@ namespace detail
|
|||||||
node_type* insert(const std::string& key, const element_type& elem)
|
node_type* insert(const std::string& key, const element_type& elem)
|
||||||
{
|
{
|
||||||
auto node = _m_locate<true>(key);
|
auto node = _m_locate<true>(key);
|
||||||
|
|
||||||
|
//Doesn't return the root node
|
||||||
|
if (node == &root_)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if(node)
|
if(node)
|
||||||
node->value.second = elem;
|
node->value.second = elem;
|
||||||
return node;
|
return node;
|
||||||
@ -206,12 +211,14 @@ namespace detail
|
|||||||
|
|
||||||
node_type* find(const std::string& path) const
|
node_type* find(const std::string& path) const
|
||||||
{
|
{
|
||||||
return _m_locate(path);
|
auto p = _m_locate(path);
|
||||||
|
return (&root_ == p ? nullptr : p);
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type* ref(const std::string& path)
|
node_type* ref(const std::string& path)
|
||||||
{
|
{
|
||||||
return _m_locate<true>(path);
|
auto p = _m_locate<true>(path);
|
||||||
|
return (&root_ == p ? nullptr : p);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned indent_size(const node_type* node) const
|
unsigned indent_size(const node_type* node) const
|
||||||
@ -479,42 +486,42 @@ namespace detail
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// foreach elements of key.
|
|
||||||
// the root name "/" and "\\" are treated as a node. This is a feature that can easily support the UNIX-like path.
|
|
||||||
template<typename Function>
|
template<typename Function>
|
||||||
void _m_for_each(const ::std::string& key, Function function) const
|
void _m_for_each(const ::std::string& key, Function function) const
|
||||||
{
|
{
|
||||||
if(key.size())
|
//Ignores separaters at the begin of key.
|
||||||
|
::std::string::size_type beg = key.find_first_not_of("\\/");
|
||||||
|
if (key.npos == beg)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto end = key.find_first_of("\\/", beg);
|
||||||
|
|
||||||
|
|
||||||
|
while(end != ::std::string::npos)
|
||||||
{
|
{
|
||||||
::std::string::size_type beg = 0;
|
if(beg != end)
|
||||||
auto end = key.find_first_of("\\/");
|
|
||||||
|
|
||||||
while(end != ::std::string::npos)
|
|
||||||
{
|
{
|
||||||
if(beg != end)
|
if(!function(key.substr(beg, end - beg)))
|
||||||
{
|
|
||||||
if(!function(key.substr(beg, end - beg)))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto next = key.find_first_not_of("\\/", end);
|
|
||||||
|
|
||||||
if ((next == ::std::string::npos) && end)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (0 == end)
|
|
||||||
{
|
|
||||||
if ((!function(key.substr(0, 1))) || (next == ::std::string::npos))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beg = next;
|
|
||||||
end = key.find_first_of("\\/", beg);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function(key.substr(beg, key.size() - beg));
|
auto next = key.find_first_not_of("\\/", end);
|
||||||
|
|
||||||
|
if ((next == ::std::string::npos) && end)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (0 == end)
|
||||||
|
{
|
||||||
|
if ((!function(key.substr(0, 1))) || (next == ::std::string::npos))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beg = next;
|
||||||
|
end = key.find_first_of("\\/", beg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function(key.substr(beg, key.size() - beg));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool CreateIfNotExists>
|
template<bool CreateIfNotExists>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A float_listbox Implementation
|
* A float_listbox Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -46,8 +46,10 @@ namespace nana
|
|||||||
class item_renderer
|
class item_renderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef widget& widget_reference;
|
using widget_reference = widget&;
|
||||||
typedef paint::graphics& graph_reference;
|
using graph_reference = paint::graphics&;
|
||||||
|
using item_interface = float_listbox::item_interface;
|
||||||
|
|
||||||
enum state_t{StateNone, StateHighlighted};
|
enum state_t{StateNone, StateHighlighted};
|
||||||
|
|
||||||
virtual ~item_renderer() = default;
|
virtual ~item_renderer() = default;
|
||||||
|
|||||||
@ -480,6 +480,8 @@ namespace nana
|
|||||||
*/
|
*/
|
||||||
void scroll_into_view(item_proxy item);
|
void scroll_into_view(item_proxy item);
|
||||||
|
|
||||||
|
/// Gets the current hovered node.
|
||||||
|
item_proxy hovered(bool exclude_expander) const;
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<scroll_operation_interface> _m_scroll_operation() override;
|
std::shared_ptr<scroll_operation_interface> _m_scroll_operation() override;
|
||||||
|
|
||||||
|
|||||||
@ -1130,7 +1130,7 @@ namespace nana { namespace experimental { namespace filesystem
|
|||||||
::fclose(stream);
|
::fclose(stream);
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
ec.assign(static_cast<int>(::errno), std::generic_category());
|
ec.assign(static_cast<int>(errno), std::generic_category());
|
||||||
#endif
|
#endif
|
||||||
return static_cast<std::uintmax_t>(-1);
|
return static_cast<std::uintmax_t>(-1);
|
||||||
}
|
}
|
||||||
@ -1265,7 +1265,7 @@ namespace std
|
|||||||
return p; // p.is_absolute() is true
|
return p; // p.is_absolute() is true
|
||||||
}
|
}
|
||||||
|
|
||||||
path absolute(const path& p, std::error_code& err)
|
path absolute(const path& p, std::error_code& /*err*/)
|
||||||
{
|
{
|
||||||
return absolute(p);
|
return absolute(p);
|
||||||
}
|
}
|
||||||
@ -1350,7 +1350,7 @@ namespace std
|
|||||||
{ //error
|
{ //error
|
||||||
if (nullptr == ec)
|
if (nullptr == ec)
|
||||||
throw (filesystem_error(
|
throw (filesystem_error(
|
||||||
"nana::filesystem::canonical", p,
|
message, p,
|
||||||
error_code(err_val, generic_category())));
|
error_code(err_val, generic_category())));
|
||||||
else
|
else
|
||||||
ec->assign(err_val, system_category());
|
ec->assign(err_val, system_category());
|
||||||
@ -1435,5 +1435,162 @@ namespace std
|
|||||||
}//end namespace filesystem
|
}//end namespace filesystem
|
||||||
}//end namespace std
|
}//end namespace std
|
||||||
|
|
||||||
#endif
|
#else //NANA_USING_NANA_FILESYSTEM
|
||||||
|
# if defined(NANA_USING_STD_EXPERIMENTAL_FILESYSTEM)
|
||||||
|
|
||||||
|
//Defines the functions that are not provided by experimental/filesystem
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
namespace filesystem
|
||||||
|
{
|
||||||
|
#if (defined(_MSC_VER) && (_MSC_VER > 1912)) || \
|
||||||
|
(!defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 801))
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
bool try_throw(int err_val, const path& p, std::error_code* ec, const char* message)
|
||||||
|
{
|
||||||
|
if (0 == err_val)
|
||||||
|
{
|
||||||
|
if (ec) ec->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ //error
|
||||||
|
if (nullptr == ec)
|
||||||
|
throw (filesystem_error(
|
||||||
|
message, p,
|
||||||
|
error_code(err_val, generic_category())));
|
||||||
|
else
|
||||||
|
ec->assign(err_val, system_category());
|
||||||
|
}
|
||||||
|
return err_val != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
path lexically_normal(path p)
|
||||||
|
{
|
||||||
|
if (p.empty())
|
||||||
|
return p;
|
||||||
|
|
||||||
|
std::vector<path> elements;
|
||||||
|
|
||||||
|
while (!p.empty())
|
||||||
|
{
|
||||||
|
elements.emplace_back(p.filename());
|
||||||
|
p.remove_filename();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto start = elements.begin();
|
||||||
|
auto last = elements.end();
|
||||||
|
auto stop = last--;
|
||||||
|
for (auto itr(start); itr != stop; ++itr)
|
||||||
|
{
|
||||||
|
// ignore "." except at start and last
|
||||||
|
if (itr->native().size() == 1
|
||||||
|
&& (itr->native())[0] == '.'
|
||||||
|
&& itr != start
|
||||||
|
&& itr != last) continue;
|
||||||
|
|
||||||
|
// ignore a name and following ".."
|
||||||
|
if (!p.empty()
|
||||||
|
&& itr->native().size() == 2
|
||||||
|
&& (itr->native())[0] == '.'
|
||||||
|
&& (itr->native())[1] == '.') // dot dot
|
||||||
|
{
|
||||||
|
auto lf(p.filename().native());
|
||||||
|
if (lf.size() > 0
|
||||||
|
&& (lf.size() != 1
|
||||||
|
|| (lf[0] != '.'
|
||||||
|
&& (lf[0] != '/' && lf[0] != '\\')))
|
||||||
|
&& (lf.size() != 2
|
||||||
|
|| (lf[0] != '.'
|
||||||
|
&& lf[1] != '.'
|
||||||
|
# ifdef NANA_WINDOWS
|
||||||
|
&& lf[1] != ':'
|
||||||
|
# endif
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
p.remove_filename();
|
||||||
|
auto next = itr;
|
||||||
|
if (p.empty() && ++next != stop
|
||||||
|
&& next == last && last->string() == ".")
|
||||||
|
{
|
||||||
|
p /= ".";
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p /= *itr;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (p.empty())
|
||||||
|
p = ".";
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path weakly_canonical(const path& p, std::error_code* err)
|
||||||
|
{
|
||||||
|
path head{ p };
|
||||||
|
|
||||||
|
std::error_code tmp_err;
|
||||||
|
std::vector<path> elements;
|
||||||
|
while (!head.empty())
|
||||||
|
{
|
||||||
|
auto head_status = status(head, tmp_err);
|
||||||
|
|
||||||
|
if (head_status.type() == file_type::unknown)
|
||||||
|
{
|
||||||
|
if (detail::try_throw(static_cast<int>(errc::invalid_argument), head, err, "nana::filesystem::weakly_canonical"))
|
||||||
|
return path{};
|
||||||
|
}
|
||||||
|
if (head_status.type() != file_type::not_found)
|
||||||
|
break;
|
||||||
|
|
||||||
|
elements.emplace_back(head.filename());
|
||||||
|
head.remove_filename();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tail_has_dots = false;
|
||||||
|
path tail;
|
||||||
|
|
||||||
|
for (auto & e : elements)
|
||||||
|
{
|
||||||
|
tail /= e;
|
||||||
|
// for a later optimization, track if any dot or dot-dot elements are present
|
||||||
|
if (e.native().size() <= 2
|
||||||
|
&& e.native()[0] == '.'
|
||||||
|
&& (e.native().size() == 1 || e.native()[1] == '.'))
|
||||||
|
tail_has_dots = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (head.empty())
|
||||||
|
return detail::lexically_normal(p);
|
||||||
|
head = canonical(head, tmp_err);
|
||||||
|
if (detail::try_throw(tmp_err.value(), head, err, "nana::filesystem::weakly_canonical"))
|
||||||
|
return path();
|
||||||
|
return tail.empty()
|
||||||
|
? head
|
||||||
|
: (tail_has_dots // optimization: only normalize if tail had dot or dot-dot element
|
||||||
|
? detail::lexically_normal(head / tail)
|
||||||
|
: head / tail);
|
||||||
|
}
|
||||||
|
|
||||||
|
path weakly_canonical(const path& p)
|
||||||
|
{
|
||||||
|
return weakly_canonical(p, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
path weakly_canonical(const path& p, std::error_code& err)
|
||||||
|
{
|
||||||
|
return weakly_canonical(p, &err);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif //NANA_USING_NANA_FILESYSTEM
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
* Benjamin Navarro(pr#81)
|
* Benjamin Navarro(pr#81)
|
||||||
* besh81(pr#130)
|
* besh81(pr#130)
|
||||||
* dankan1890(pr#158)
|
* dankan1890(pr#158)
|
||||||
|
* ErrorFlynn(pr#418)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -5455,9 +5456,12 @@ namespace nana
|
|||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
|
|
||||||
if (_m_ess().lister.enable_ordered(enable))
|
if (_m_ess().lister.enable_ordered(enable))
|
||||||
|
{
|
||||||
_m_ess().update();
|
_m_ess().update();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void listbox::auto_draw(bool enabled) noexcept
|
void listbox::auto_draw(bool enabled) noexcept
|
||||||
|
|||||||
@ -2371,6 +2371,19 @@ namespace nana
|
|||||||
API::refresh_window(*this);
|
API::refresh_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
treebox::item_proxy treebox::hovered(bool exclude_expander) const
|
||||||
|
{
|
||||||
|
internal_scope_guard lock;
|
||||||
|
auto dw = &get_drawer_trigger();
|
||||||
|
if (dw->impl()->node_state.pointed)
|
||||||
|
{
|
||||||
|
//Returns empty item_proxy if the mouse is on expander and exclude_expander is required.
|
||||||
|
if (exclude_expander && (dw->impl()->node_state.comp_pointed == drawerbase::treebox::component::expander))
|
||||||
|
return item_proxy{};
|
||||||
|
}
|
||||||
|
return item_proxy(const_cast<drawer_trigger_t*>(dw), dw->impl()->node_state.pointed);
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<scroll_operation_interface> treebox::_m_scroll_operation()
|
std::shared_ptr<scroll_operation_interface> treebox::_m_scroll_operation()
|
||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user