Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/1234248685c7aae2255007750b084a00b4dadd41
>---------------------------------------------------------------
commit 1234248685c7aae2255007750b084a00b4dadd41
Author: Alex Alabuzhev <
alab...@gmail.com>
Date: Tue Jul 21 19:58:02 2026 +0100
Refactoring
>---------------------------------------------------------------
1234248685c7aae2255007750b084a00b4dadd41
far/common/optional_bitset.hpp | 85 ++++++++++++++++++++++++++++++++++++++++++
far/diskmenu.cpp | 33 +---------------
far/far.vcxproj | 1 +
far/far.vcxproj.filters | 3 ++
4 files changed, 91 insertions(+), 31 deletions(-)
diff --git a/far/common/optional_bitset.hpp b/far/common/optional_bitset.hpp
new file mode 100644
index 000000000..ba6143321
--- /dev/null
+++ b/far/common/optional_bitset.hpp
@@ -0,0 +1,85 @@
+#ifndef OPTIONAL_BITSET_HPP_2F835FC0_7824_407C_8018_3013F670DF15
+#define OPTIONAL_BITSET_HPP_2F835FC0_7824_407C_8018_3013F670DF15
+#pragma once
+
+/*
+optional_bitset.hpp
+*/
+/*
+Copyright © 2026 Far Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <bitset>
+
+//----------------------------------------------------------------------------
+
+enum class optional_bitset_state
+{
+ unknown,
+ yes,
+ no
+};
+
+template<size_t N>
+class optional_bitset
+{
+public:
+ void assign(size_t const Bit, bool const Value)
+ {
+ m_Bits.set(Bit, Value);
+ m_Bits.set(N + Bit);
+ }
+
+ void assign(size_t const Bit, optional_bitset_state const Value)
+ {
+ if (Value == optional_bitset_state::unknown)
+ {
+ m_Bits.reset(N + Bit);
+ return;
+ }
+
+ assign(Bit, Value == optional_bitset_state::yes);
+ }
+
+
+ void reset()
+ {
+ m_Bits.reset();
+ }
+
+ optional_bitset_state check(size_t const Bit) const
+ {
+ if (!m_Bits[N + Bit])
+ return optional_bitset_state::unknown;
+
+ return m_Bits[Bit] ? optional_bitset_state::yes : optional_bitset_state::no;
+ }
+
+private:
+ std::bitset<N * 2> m_Bits;
+};
+
+#endif // OPTIONAL_BITSET_HPP_2F835FC0_7824_407C_8018_3013F670DF15
diff --git a/far/diskmenu.cpp b/far/diskmenu.cpp
index a506446ef..b1b8bf8ac 100644
--- a/far/diskmenu.cpp
+++ b/far/diskmenu.cpp
@@ -78,43 +78,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Common:
#include "common/view/enumerate.hpp"
+#include "common/optional_bitset.hpp"
// External:
#include "format.hpp"
//----------------------------------------------------------------------------
-namespace
-{
- enum class state
- {
- unknown,
- yes,
- no
- };
-}
-
-template<size_t N>
-class optional_bitset
-{
-public:
- void assign(size_t const Bit, bool const Value)
- {
- m_Bits.set(Bit, Value);
- m_Bits.set(N + Bit);
- }
-
- state check(size_t const Bit) const
- {
- if (!m_Bits[N + Bit])
- return state::unknown;
-
- return m_Bits[Bit] ? state::yes : state::no;
- }
-
-private:
- std::bitset<N * 2> m_Bits;
-};
+using state = optional_bitset_state;
enum
{
diff --git a/far/far.vcxproj b/far/far.vcxproj
index 4034de77a..ee81b56ff 100644
--- a/far/far.vcxproj
+++ b/far/far.vcxproj
@@ -285,6 +285,7 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c
<ClInclude Include="common\nifty_counter.hpp" />
<ClInclude Include="common\noncopyable.hpp" />
<ClInclude Include="common\null_iterator.hpp" />
+ <ClInclude Include="common\optional_bitset.hpp" />
<ClInclude Include="common\placement.hpp" />
<ClInclude Include="common\polyfills.hpp" />
<ClInclude Include="common\preprocessor.hpp" />
diff --git a/far/far.vcxproj.filters b/far/far.vcxproj.filters
index 707ae3024..84f450553 100644
--- a/far/far.vcxproj.filters
+++ b/far/far.vcxproj.filters
@@ -646,6 +646,9 @@
<ClInclude Include="common\polyfills.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
+ <ClInclude Include="common\optional_bitset.hpp">
+ <Filter>Header Files\common</Filter>
+ </ClInclude>
<ClInclude Include="common\preprocessor.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>