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

KazDragon / munin / 31000645644

05 Aug 2026 11:14AM UTC coverage: 98.216% (-0.1%) from 98.322%
31000645644

push

github

web-flow
Expose more automation with a component ID field and more complete JSON representations (#284)

* Hide composite internals from automation JSON

* Lock button automation JSON as a leaf

* Expose automation ids on Munin components

* Report automation ids on composite Munin widgets

* doc: add CONTEXT.md for AI clarity

* feat: with_id() helper for assigning IDs in flow

* doc: add CONTEXT.md for AI clarity

* Expose button accessible name in JSON

* Expose image accessible name in JSON

* Derive button accessible name from content

* Expose edit text in introspection JSON

* Report edit content in introspection JSON

* Report edit caret in introspection JSON

* Name edit JSON snapshot in tests

* Move focus on tab key in containers

* Move focus on back tab key in containers

* Name container virtual key extraction

* Share container keypress test helper

* Document normal keyboard focus navigation

* Add button JSON coverage

* Cover unfocused button JSON state

* Cover image JSON bounds

* Cover image JSON automation id

* Cover image JSON preferred size

* Cover image JSON focus and cursor state

* Cover image JSON fill changes

* Cover image JSON single-line content changes

* Join image JSON accessible names across lines

* Cover image JSON multi-line constructor names

* Cover image JSON empty name boundary

* Cover focused image JSON state

* Cover cleared image JSON content

* Cover edit JSON type and base fields

* Cover edit JSON preferred size

* Cover unfocused edit JSON state

* Cover focused edit JSON state

* Cover edit JSON cursor state

* Cover edit JSON set text

* Cover container JSON automation id

* Cover container JSON position

* Cover container JSON size

* Refactor container JSON shape assertions

* Cover container JSON current layout

* Refactor container JSON mock layout setup

* Add text area JSON type snapshot

* Report text area text in JSON

* Report text area caret position in JSON

* Cover text area component JSON fiel... (continued)

147 of 151 new or added lines in 14 files covered. (97.35%)

1 existing line in 1 file now uncovered.

2643 of 2691 relevant lines covered (98.22%)

496.27 hits per line

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

94.59
/src/button.cpp
1
#include "munin/button.hpp"
2

3
#include "munin/framed_component.hpp"
4
#include "munin/grid_layout.hpp"
5
#include "munin/image.hpp"
6
#include "munin/solid_frame.hpp"
7

8
#include <terminalpp/mouse.hpp>
9
#include <terminalpp/virtual_key.hpp>
10

11
#include <algorithm>
12
#include <cctype>
13
#include <utility>
14

15
namespace munin {
16

17
namespace {
18

19
auto stripped(terminalpp::string const &text) -> std::string
7 ✔
20
{
21
    auto result = terminalpp::to_string(text);
7 ✔
22
    auto const is_not_space = [](unsigned char ch) {
22 ✔
23
        return !std::isspace(ch);
22 ✔
24
    };
25

26
    result.erase(
14 ✔
27
        result.begin(),
7 ✔
28
        std::ranges::find_if(result, is_not_space));
7 ✔
29
    result.erase(
14 ✔
30
        std::ranges::find_if(result.rbegin(), result.rend(), is_not_space)
7 ✔
31
            .base(),
7 ✔
32
        result.end());
7 ✔
33
    return result;
14 ✔
NEW
34
}
×
35

36
}  // namespace
37

38
// ==========================================================================
39
// CONSTRUCTOR
40
// ==========================================================================
41
button::button(terminalpp::string text)
18 ✔
42
{
43
    auto image = make_image(std::move(text));
18 ✔
44
    image->set_can_receive_focus(true);
18 ✔
45

46
    set_layout(make_grid_layout({1, 1}));
18 ✔
47
    add_component(make_framed_component(make_solid_frame(), image));
18 ✔
48

49
    on_click.connect([this] { set_focus(); });
22 ✔
50
}
18 ✔
51

52
// ==========================================================================
53
// DO_EVENT
54
// ==========================================================================
55
void button::do_event(std::any const &ev)
8 ✔
56
{
57
    if (auto const *mouse_event = std::any_cast<terminalpp::mouse::event>(&ev);
8 ✔
58
        mouse_event != nullptr)
59
    {
60
        if (mouse_event->action_
4 ✔
61
            == terminalpp::mouse::event_type::left_button_down)
62
        {
63
            on_click();
2 ✔
64
        }
65
    }
66
    else if (auto const *vk = std::any_cast<terminalpp::virtual_key>(&ev);
4 ✔
67
             vk != nullptr)
68
    {
69
        if (vk->key == terminalpp::vk::enter
4 ✔
70
            || vk->key == terminalpp::vk::space)
3 ✔
71
        {
72
            on_click();
2 ✔
73
        }
74
    }
75
}
8 ✔
76

77
// ==========================================================================
78
// DO_TO_JSON
79
// ==========================================================================
80
nlohmann::json button::do_to_json() const
7 ✔
81
{
82
    static auto const patch = R"([
7 ✔
83
        { "op": "replace", "path": "/type", "value": "button" }
84
    ])"_json;
85

86
    auto json = composite_component::do_to_json().patch(patch);
7 ✔
87
    json["name"] = stripped(json.value("name", ""));
7 ✔
88
    return json;
7 ✔
UNCOV
89
}
×
90

91
// ==========================================================================
92
// MAKE_BUTTON
93
// ==========================================================================
94
std::shared_ptr<button> make_button(terminalpp::string const &text)
2 ✔
95
{
96
    return std::make_shared<button>(text);
2 ✔
97
}
98

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

© 2026 Coveralls, Inc