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

antonvw / wex / 30751126890

02 Aug 2026 01:59PM UTC coverage: 64.146% (-0.01%) from 64.156%
30751126890

push

github

web-flow
1293 more lsp updates (#1294)

* clang-tidy updates, added lsp-server-path to lexer, and more lsp fixings

* fixed compile error, added tests

* added lsp_config_dialog, and dynamic setup of lsp clients

* changes after review

* minor updates

19523 of 33401 branches covered (58.45%)

Branch coverage included in aggregate %.

15716 of 21535 relevant lines covered (72.98%)

1583.91 hits per line

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

10.0
/src/del/dirctrl.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      dirctrl.cpp
3
// Purpose:   Implementation of class wex::del::dirctrl
4
// Author:    Anton van Wezenbeek
5
// Copyright: (c) 2010-2026 Anton van Wezenbeek
6
////////////////////////////////////////////////////////////////////////////////
7

8
#include <wex/wex.h>
9
#include <wx/stockitem.h> // for wxGetStockLabel
10

11
const int id_compare     = wxWindow::NewControlId();
12
const int id_show_hidden = wxWindow::NewControlId();
13

14
wex::del::dirctrl::dirctrl(frame* frame, const data::window& data)
2✔
15
  : wxGenericDirCtrl(
16
      data.parent(),
17
      data.id(),
18
      wxDirDialogDefaultFolderStr,
19
      data.pos(),
20
      data.size(),
21
      data.style(),
22
      "*", // filter
23
      0,   // filter index
24
      data.name())
2✔
25
{
26
  if (config(_("Show hidden")).get(false))
2!
27
  {
28
    ShowHidden(true);
×
29
  }
30

31
  lexers::get()->apply_default_style(
4✔
32
    [=, this](const std::string& back)
×
33
    {
34
      GetTreeCtrl()->SetBackgroundColour(wxColour(back));
×
35
    },
×
36
    [=, this](const std::string& fore)
×
37
    {
38
      GetTreeCtrl()->SetForegroundColour(wxColour(fore));
×
39
    });
×
40

41
  bind(this).command(
22!
42
    {{[=, this](const wxCommandEvent& event)
×
43
      {
44
        vcs_execute(
×
45
          frame,
46
          event.GetId() - ID_EDIT_VCS_LOWEST - 1,
×
47
          to_vector_path(*this).get());
×
48
      },
×
49
      ID_EDIT_VCS_LOWEST},
×
50
     {[=, this](const wxCommandEvent& event)
×
51
      {
52
        const auto v(to_vector_string(*this).get());
×
53
        clipboard_add(
×
54
          std::ranges::fold_left(
×
55
            v,
56
            std::string(),
×
57
            [](const std::string& a, const std::string& b)
×
58
            {
59
              return a + b + "\n";
×
60
            }));
61
      },
×
62
      ID_TREE_COPY},
×
63
     {[=, this](const wxCommandEvent& event)
×
64
      {
65
        open_files(
×
66
          frame,
67
          to_vector_path(*this).get(),
×
68
          data::stc(),
×
69
          data::dir::type_t().set(data::dir::FILES));
×
70
      },
×
71
      ID_EDIT_OPEN},
×
72
     {[=, this](const wxCommandEvent& event)
×
73
      {
74
        on_selected_paths(
×
75
          [=, this](const std::vector<path>& p)
×
76
          {
77
            build(path_lexer(p[0]));
×
78
          });
×
79
      },
×
80
      ID_TREE_RUN_BUILD},
×
81
     {[=, this](const wxCommandEvent& event)
×
82
      {
83
        frame->find_in_files(
×
84
          to_vector_path(*this).get(),
×
85
          tool((wex::window_id)event.GetId()));
×
86
      },
×
87
      ID_TOOL_REPORT_FIND},
×
88
     {[=, this](const wxCommandEvent& event)
×
89
      {
90
        frame->find_in_files(
×
91
          to_vector_path(*this).get(),
×
92
          tool((wex::window_id)event.GetId()));
×
93
      },
×
94
      ID_TOOL_REPLACE},
×
95
     {[=, this](const wxCommandEvent& event)
×
96
      {
97
        if (const auto v(to_vector_path(*this).get()); v.size() == 2)
×
98
        {
99
          compare_file(v[0], v[1]);
×
100
        }
×
101
      },
×
102
      id_compare},
103
     {[=, this](const wxCommandEvent& event)
×
104
      {
105
        ShowHidden(!config(_("Show hidden")).get(false));
×
106
        config(_("Show hidden")).set(!config(_("Show hidden")).get(false));
×
107
      },
×
108
      id_show_hidden}});
109

110
  Bind(
2✔
111
    wxEVT_TREE_ITEM_ACTIVATED,
112
    [=, this](wxTreeEvent& event)
2✔
113
    {
114
      on_selected_paths(
×
115
        [=, this](const std::vector<path>& p)
×
116
        {
117
          if (const auto& fn(p[0]); !fn.file_exists() && fn.dir_exists())
×
118
          {
119
            if (!GetTreeCtrl()->IsExpanded(event.GetItem()))
×
120
            {
121
              expand_and_select_path(fn);
×
122
            }
123
            else
124
            {
125
              CollapsePath(fn.string());
×
126
            }
127
          }
128
          else
129
          {
130
            open_files(
×
131
              frame,
132
              p,
133
              data::stc(),
×
134
              data::dir::type_t().set(data::dir::FILES));
×
135
          }
136
        });
×
137
    });
×
138

139
  Bind(
2✔
140
    wxEVT_TREE_ITEM_MENU,
141
    [=, this](const wxTreeEvent& event)
2✔
142
    {
143
      on_selected_paths(
×
144
        [=, this](const std::vector<path>& p)
×
145
        {
146
          const wex::path_lexer filename(p[0]);
×
147

148
          wex::menu menu(
149
            menu::menu_t_def().set(menu::IS_POPUP).set(menu::IS_VISUAL));
×
150

151
          if (filename.file_exists())
×
152
          {
153
            menu.append({{ID_EDIT_OPEN, _("&Open")}, {}});
×
154

155
            if (
×
156
              p.size() == 2 &&
×
157
              !config(_("list.Comparator")).get_first_of().empty())
×
158
            {
159
              menu.append({{id_compare, _("&Compare")}, {}});
×
160
            }
161
          }
162

163
          menu.append(
×
164
            {{ID_TREE_COPY,
165
              wxGetStockLabel(wxID_COPY),
×
166
              data::menu().art(wxART_COPY)}});
×
167

168
          // If the filename is under vcs append vcs submenu.
169
          if (vcs::dir_exists(filename))
×
170
          {
171
            menu.append({{}, {filename, frame}});
×
172
          }
173

174
          if (filename.is_build())
×
175
          {
176
            menu.append({{}, {ID_TREE_RUN_BUILD, "&Build"}});
×
177
          }
178

179
          menu.append(
×
180
            {{},
181
             {ID_TOOL_REPORT_FIND,
182
              ellipsed(frame->find_in_files_title(ID_TOOL_REPORT_FIND))},
×
183
             {ID_TOOL_REPLACE,
184
              ellipsed(frame->find_in_files_title(ID_TOOL_REPLACE))},
×
185
             {}});
186

187
          if (
×
188
            auto* item = menu.AppendCheckItem(id_show_hidden, _("Show hidden"));
×
189
            config(_("Show hidden")).get(false))
×
190
          {
191
            item->Check();
×
192
          }
193

194
          PopupMenu(&menu);
×
195
        });
×
196
    });
×
197

198
  Bind(
2✔
199
    wxEVT_TREE_SEL_CHANGED,
200
    [=, this](const wxTreeEvent& event)
2✔
201
    {
202
      on_selected_paths(
×
203
        [=, this](const std::vector<path>& p)
×
204
        {
205
          log::status() << p[0];
×
206
        });
×
207
    });
×
208
}
4!
209

210
bool wex::del::dirctrl::expand_and_select_path(const wex::path& path)
2✔
211
{
212
  if (!ExpandPath(path.string()))
2!
213
  {
214
    return false;
2✔
215
  }
216

217
  SelectPath(path.string());
×
218

219
  return true;
×
220
}
221

222
std::vector<wex::path> wex::del::dirctrl::on_selected_paths(
×
223
  const std::function<void(std::vector<path> p)>& f) const
224
{
225
  const auto v(wex::to_vector_path(*this).get());
×
226

227
  if (!v.empty())
×
228
  {
229
    f(v);
×
230
  }
231

232
  return v;
×
233
}
×
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