Skip to content

Commit

Permalink
Showing Tags in the UI (#98)
Browse files Browse the repository at this point in the history
* Working on infrastructure to support Finder tags

* Reading from files

* Reading from FinderInfo as well

* A bit of loggic in the unit test

* Trying to fix a failing test

* Grey -> Gray

* Use flistxattr() first instead of probing via fgetxattr()

* VFS support for FinderTags

* Working on the presentation of the tags

* Build paths for tags only once, explicit colors

* Drawing tags in brief and list presentations

* Supporting cases where tags are written only as text labels without specifying the color index explicitly

* updated the version of the Frozen library

* Now storing the predefined colors in a frozen map

* Working on infrastructure to support Finder tags

* Reading from files

* Reading from FinderInfo as well

* A bit of loggic in the unit test

* Trying to fix a failing test

* Grey -> Gray

* Use flistxattr() first instead of probing via fgetxattr()

* VFS support for FinderTags

* Working on the presentation of the tags

* Build paths for tags only once, explicit colors

* Drawing tags in brief and list presentations

* Supporting cases where tags are written only as text labels without specifying the color index explicitly

* updated the version of the Frozen library

* Now storing the predefined colors in a frozen map

* Adjust the presentation to closer match what Finder does
mikekazakov authored Jan 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 083893c commit a3f4573
Showing 44 changed files with 1,974 additions and 419 deletions.
2 changes: 1 addition & 1 deletion 3rd_Party/frozen/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ TMP_DIR=${CUR_DIR}/frozen.tmp
mkdir ${TMP_DIR}
cd ${TMP_DIR}

git clone -b 1.0.1 --single-branch https://github.com/serge-sans-paille/frozen
git clone -b 1.1.1 --single-branch https://github.com/serge-sans-paille/frozen

cd ..

7 changes: 7 additions & 0 deletions 3rd_Party/frozen/include/frozen/bits/basic_types.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@

#include "frozen/bits/exceptions.h"

#include <array>
#include <utility>
#include <iterator>
#include <string>
@@ -115,6 +116,12 @@ class carray {
{
static_assert(M >= N, "Cannot initialize a carray with an smaller array");
}
template <std::size_t M>
constexpr carray(std::array<T, M> const &init)
: carray(&init[0], std::make_index_sequence<N>())
{
static_assert(M >= N, "Cannot initialize a carray with an smaller array");
}
constexpr carray(std::initializer_list<T> init)
: carray(init.begin(), std::make_index_sequence<N>())
{
8 changes: 8 additions & 0 deletions 3rd_Party/frozen/include/frozen/bits/defines.h
Original file line number Diff line number Diff line change
@@ -55,4 +55,12 @@
#define FROZEN_LETITGO_HAS_CHAR8T
#endif

#if __cpp_deduction_guides >= 201703L
#define FROZEN_LETITGO_HAS_DEDUCTION_GUIDES
#endif

#if __cpp_lib_constexpr_string >= 201907L
#define FROZEN_LETITGO_HAS_CONSTEXPR_STRING
#endif

#endif // FROZEN_LETITGO_DEFINES_H
9 changes: 8 additions & 1 deletion 3rd_Party/frozen/include/frozen/bits/elsa.h
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@

namespace frozen {

template <class T> struct elsa {
template <class T = void> struct elsa {
static_assert(std::is_integral<T>::value || std::is_enum<T>::value,
"only supports integral types, specialize for other types");

@@ -44,6 +44,13 @@ template <class T> struct elsa {
}
};

template <> struct elsa<void> {
template<class T>
constexpr std::size_t operator()(T const &value, std::size_t seed) const {
return elsa<T>{}(value, seed);
}
};

template <class T> using anna = elsa<T>;
} // namespace frozen

40 changes: 40 additions & 0 deletions 3rd_Party/frozen/include/frozen/bits/elsa_std.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef FROZEN_LETITGO_BITS_ELSA_STD_H
#define FROZEN_LETITGO_BITS_ELSA_STD_H

#include "elsa.h"
#include "hash_string.h"

#ifdef FROZEN_LETITGO_HAS_STRING_VIEW
#include <string_view>
#endif
#include <string>

namespace frozen {

#ifdef FROZEN_LETITGO_HAS_STRING_VIEW

template <typename CharT> struct elsa<std::basic_string_view<CharT>>
{
constexpr std::size_t operator()(const std::basic_string_view<CharT>& value) const {
return hash_string(value);
}
constexpr std::size_t operator()(const std::basic_string_view<CharT>& value, std::size_t seed) const {
return hash_string(value, seed);
}
};

#endif

template <typename CharT> struct elsa<std::basic_string<CharT>>
{
constexpr std::size_t operator()(const std::basic_string<CharT>& value) const {
return hash_string(value);
}
constexpr std::size_t operator()(const std::basic_string<CharT>& value, std::size_t seed) const {
return hash_string(value, seed);
}
};

} // namespace frozen

#endif // FROZEN_LETITGO_BITS_ELSA_STD_H
28 changes: 28 additions & 0 deletions 3rd_Party/frozen/include/frozen/bits/hash_string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef FROZEN_LETITGO_BITS_HASH_STRING_H
#define FROZEN_LETITGO_BITS_HASH_STRING_H

#include <cstddef>

namespace frozen {

template <typename String>
constexpr std::size_t hash_string(const String& value) {
std::size_t d = 5381;
for (const auto& c : value)
d = d * 33 + static_cast<size_t>(c);
return d;
}

// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
// With the lowest bits removed, based on experimental setup.
template <typename String>
constexpr std::size_t hash_string(const String& value, std::size_t seed) {
std::size_t d = (0x811c9dc5 ^ seed) * static_cast<size_t>(0x01000193);
for (const auto& c : value)
d = (d ^ static_cast<size_t>(c)) * static_cast<size_t>(0x01000193);
return d >> 8 ;
}

} // namespace frozen

#endif // FROZEN_LETITGO_BITS_HASH_STRING_H
13 changes: 9 additions & 4 deletions 3rd_Party/frozen/include/frozen/bits/pmh.h
Original file line number Diff line number Diff line change
@@ -156,13 +156,18 @@ struct pmh_tables {
carray<std::size_t, M> second_table_;
Hasher hash_;

// Looks up a given key, to find its expected index in carray<Item, N>
// Always returns a valid index, must use KeyEqual test after to confirm.
template <typename KeyType>
constexpr std::size_t lookup(const KeyType & key) const {
auto const d = first_table_[hash_(key, static_cast<size_t>(first_seed_)) % M];
return lookup(key, hash_);
}

// Looks up a given key, to find its expected index in carray<Item, N>
// Always returns a valid index, must use KeyEqual test after to confirm.
template <typename KeyType, typename HasherType>
constexpr std::size_t lookup(const KeyType & key, const HasherType& hasher) const {
auto const d = first_table_[hasher(key, static_cast<size_t>(first_seed_)) % M];
if (!d.is_seed()) { return static_cast<std::size_t>(d.value()); } // this is narrowing uint64 -> size_t but should be fine
else { return second_table_[hash_(key, static_cast<std::size_t>(d.value())) % M]; }
else { return second_table_[hasher(key, static_cast<std::size_t>(d.value())) % M]; }
}
};

2 changes: 1 addition & 1 deletion 3rd_Party/frozen/include/frozen/bits/version.h
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
#define FROZEN_LETITGO_VERSION_H

#define FROZEN_MAJOR_VERSION 1
#define FROZEN_MINOR_VERSION 0
#define FROZEN_MINOR_VERSION 1
#define FROZEN_PATCH_VERSION 1

#endif
Loading

0 comments on commit a3f4573

Please sign in to comment.