• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KazDragon / munin / 23712240864

29 Mar 2026 03:20PM UTC coverage: 98.291%. Remained the same
23712240864

push

github

web-flow
Vcpkg metaproject support (#276)

* feat: add gitattributes for sane cross-platform line endings

* Add transitive dependencies to CMake package config

* Generated files now generated in binary directory

* Update CI runner to use vcpkg

* Cache vcpkg in appveyor

* Fix runner script

* Correct linkage of test to "local" munin target

* include GoogleTest for gmock

* Build diagnostic.

* Fix terminalpp import to have a build type

* Fix line endings

* Revert diagnostic patch

---------

Co-authored-by: PerdixOfMars <perdix.p76l@googlemail.com>

706 of 712 new or added lines in 11 files covered. (99.16%)

2530 of 2574 relevant lines covered (98.29%)

470.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.44
/src/basic_component.cpp
1
#include "munin/basic_component.hpp"
2

3
#include "munin/detail/json_adaptors.hpp"
4

5
#include <terminalpp/mouse.hpp>
6

7
namespace munin {
8

9
namespace {
10

11
// ==========================================================================
12
// TOGGLE_FOCUS
13
// ==========================================================================
14
void toggle_focus(bool &has_focus, component &comp)
4✔
15
{
16
    if (std::exchange(has_focus, !has_focus))
4✔
17
    {
18
        comp.on_focus_lost();
2✔
19
    }
20
    else
21
    {
22
        comp.on_focus_set();
2✔
23
    }
24
}
4✔
25

26
}  // namespace
27

28
// ==========================================================================
29
// CONSTRUCTOR
30
// ==========================================================================
31
basic_component::basic_component() : has_focus_(false)
1,589✔
32
{
33
}
1,589✔
34

35
// ==========================================================================
36
// CAN_RECEIVE_FOCUS
37
// ==========================================================================
38
bool basic_component::can_receive_focus() const
79✔
39
{
40
    return do_can_receive_focus();
79✔
41
}
42

43
// ==========================================================================
44
// DO_CAN_RECEIVE_FOCUS
45
// ==========================================================================
46
bool basic_component::do_can_receive_focus() const
26✔
47
{
48
    return true;
26✔
49
}
50

51
// ==========================================================================
52
// DO_SET_POSITION
53
// ==========================================================================
54
void basic_component::do_set_position(terminalpp::point const &position)
5,128✔
55
{
56
    bounds_.origin_ = position;
5,128✔
57
}
5,128✔
58

59
// ==========================================================================
60
// DO_GET_POSITION
61
// ==========================================================================
62
terminalpp::point basic_component::do_get_position() const
472✔
63
{
64
    return bounds_.origin_;
472✔
65
}
66

67
// ==========================================================================
68
// DO_SET_SIZE
69
// ==========================================================================
70
void basic_component::do_set_size(terminalpp::extent const &size)
5,602✔
71
{
72
    bounds_.size_ = size;
5,602✔
73
}
5,602✔
74

75
// ==========================================================================
76
// DO_GET_SIZE
77
// ==========================================================================
78
terminalpp::extent basic_component::do_get_size() const
2,420✔
79
{
80
    return bounds_.size_;
2,420✔
81
}
82

83
// ==========================================================================
84
// DO_HAS_FOCUS
85
// ==========================================================================
86
bool basic_component::do_has_focus() const
421✔
87
{
88
    return has_focus_;
421✔
89
}
90

91
// ==========================================================================
92
// DO_SET_FOCUS
93
// ==========================================================================
94
void basic_component::do_set_focus()
73✔
95
{
96
    if (can_receive_focus())
73✔
97
    {
98
        if (!std::exchange(has_focus_, true))
28✔
99
        {
100
            on_focus_set();
27✔
101
        }
102
    }
103
}
73✔
104

105
// ==========================================================================
106
// DO_LOSE_FOCUS
107
// ==========================================================================
108
void basic_component::do_lose_focus()
3✔
109
{
110
    if (std::exchange(has_focus_, false))
3✔
111
    {
112
        on_focus_lost();
1✔
113
    }
114
}
3✔
115

116
// ==========================================================================
117
// DO_FOCUS_NEXT
118
// ==========================================================================
119
void basic_component::do_focus_next()
3✔
120
{
121
    if (can_receive_focus())
3✔
122
    {
123
        toggle_focus(has_focus_, *this);
2✔
124
    }
125
}
3✔
126

127
// ==========================================================================
128
// DO_FOCUS_PREVIOUS
129
// ==========================================================================
130
void basic_component::do_focus_previous()
3✔
131
{
132
    if (can_receive_focus())
3✔
133
    {
134
        toggle_focus(has_focus_, *this);
2✔
135
    }
136
}
3✔
137

138
// ==========================================================================
139
// DO_GET_CURSOR_STATE
140
// ==========================================================================
141
bool basic_component::do_get_cursor_state() const
118✔
142
{
143
    // By default, a component has no cursor.
144
    return false;
118✔
145
}
146

147
// ==========================================================================
148
// DO_GET_CURSOR_POSITION
149
// ==========================================================================
150
terminalpp::point basic_component::do_get_cursor_position() const
117✔
151
{
152
    // By default, a component has no cursor, so we choose a sentinel
153
    // value of (0,0) for its non-existent location.
154
    return {};
117✔
155
}
156

157
// ==========================================================================
158
// DO_SET_CURSOR_POSITION
159
// ==========================================================================
NEW
160
void basic_component::do_set_cursor_position(terminalpp::point const &position)
×
161
{
NEW
162
}
×
163

164
// ==========================================================================
165
// DO_EVENT
166
// ==========================================================================
167
void basic_component::do_event(std::any const &event)
4✔
168
{
169
    if (auto const *mouse = std::any_cast<terminalpp::mouse::event>(&event);
4✔
170
        mouse != nullptr
171
        && mouse->action_ != terminalpp::mouse::event_type::button_up)
4✔
172
    {
173
        if (!has_focus())
2✔
174
        {
175
            set_focus();
2✔
176
        }
177
    }
178
}
4✔
179

180
// ==========================================================================
181
// DO_TO_JSON
182
// ==========================================================================
183
nlohmann::json basic_component::do_to_json() const
116✔
184
{
185
    return {
186
        {"type",            "basic_component"                     },
187
        {"position",        detail::to_json(get_position())       },
232✔
188
        {"size",            detail::to_json(get_size())           },
232✔
189
        {"preferred_size",  detail::to_json(get_preferred_size()) },
232✔
NEW
190
        {"has_focus",       has_focus()                           },
×
NEW
191
        {"cursor_state",    get_cursor_state()                    },
×
192
        {"cursor_position", detail::to_json(get_cursor_position())}
232✔
193
    };
2,668✔
194
}
2,784✔
195

196
}  // namespace munin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc