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

antonvw / wex / 20860019414

09 Jan 2026 05:20PM UTC coverage: 64.293% (+0.002%) from 64.291%
20860019414

push

github

web-flow
keep select process dialog pos and size (#1146)

18530 of 31594 branches covered (58.65%)

Branch coverage included in aggregate %.

14756 of 20178 relevant lines covered (73.13%)

1514.97 hits per line

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

74.18
/src/vcs/process.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      process.cpp
3
// Purpose:   Implementation of class wex::process
4
// Author:    Anton van Wezenbeek
5
// Copyright: (c) 2011-2025 Anton van Wezenbeek
6
////////////////////////////////////////////////////////////////////////////////
7

8
#include <boost/algorithm/string.hpp>
9

10
#include <wex/core/config.h>
11
#include <wex/core/core.h>
12
#include <wex/core/log.h>
13
#include <wex/stc/shell.h>
14
#include <wex/ui/debug-entry.h>
15
#include <wex/ui/frame.h>
16
#include <wex/ui/item-dialog.h>
17
#include <wex/vcs/process.h>
18
#include <wx/valtext.h>
19

20
#include <algorithm>
21

22
#include "util.h"
23

24
/* NOLINTNEXTLINE */
25
std::string wex::process::m_working_dir_key = _("Process folder");
26

27
wex::process::process()
189✔
28
  : m_frame(dynamic_cast<frame*>(wxTheApp->GetTopWindow()))
189✔
29
{
30
}
189✔
31

32
bool wex::process::async_system(const process_data& data_in)
7✔
33
{
34
  set_frame();
7✔
35
  process_data data(data_in);
7✔
36

37
  if (data.exe().empty())
7!
38
  {
39
    if (config(_("Process")).get_first_of().empty())
×
40
    {
41
      if (config_dialog() == wxID_CANCEL)
×
42
      {
43
        return false;
×
44
      }
45
    }
46

47
    data.start_dir(config(m_working_dir_key).get_first_of())
×
48
      .exe(config(_("Process")).get_first_of());
×
49
  }
50
  else
51
  {
52
    if (auto* stc = dynamic_cast<wex::stc*>(m_frame->get_stc()); stc != nullptr)
7✔
53
    {
54
      expand_macro(data, stc);
4✔
55
    }
56
  }
57

58
  // We need a shell for output.
59
  if (m_shell == nullptr)
7!
60
  {
61
    log("async_system") << "no shell";
×
62
    return false;
×
63
  }
64

65
  m_shell->set_process(this);
7✔
66

67
  if (data.exe().starts_with("git"))
7✔
68
  {
69
    if (process p;
1✔
70
        p.system(process_data(data).exe("git rev-parse --show-toplevel")) == 0)
3!
71
    {
72
      m_shell->add_search_path(path(boost::algorithm::trim_copy(p.std_out())));
1✔
73
    }
1✔
74
  }
75

76
  if (
7✔
77
    m_frame->debug_entry() != nullptr &&
13✔
78
    !m_frame->debug_entry()->name().empty() &&
13!
79
    m_frame->debug_entry()->name() == find_before(data.exe(), " "))
19!
80
  {
81
    log::debug("async_system debug handler") << m_frame->debug_entry()->name();
1✔
82
    set_handler_dbg(m_frame->debug_handler());
1✔
83
    m_shell->get_lexer().set(m_frame->debug_entry()->name());
1✔
84
  }
85
  else
86
  {
87
    m_shell->SetFocus();
6✔
88
    m_frame->show_process(true);
6✔
89
  }
90

91
  return factory::process::async_system(data);
7✔
92
}
7✔
93

94
int wex::process::config_dialog(const data::window& par)
1✔
95
{
96
  const data::window data(data::window(par).title(_("Select Process")));
1✔
97

98
  if (m_config_dialog == nullptr)
1!
99
  {
100
    wxTextValidator validator(wxFILTER_EXCLUDE_CHAR_LIST);
1✔
101
    validator.SetCharExcludes("?%*\"");
1✔
102

103
    const std::vector<item> v{
104
      {_("Process"),
2✔
105
       item::COMBOBOX,
106
       std::any(),
1✔
107
       data::control().validator(&validator).is_required(true)},
2✔
108
      {m_working_dir_key,
109
       item::COMBOBOX_DIR,
110
       std::any(),
×
111
       data::control().is_required(true)}};
8!
112

113
    m_config_dialog = new item_dialog(v, data);
1!
114
  }
1✔
115

116
  if (data.button() & wxAPPLY)
1!
117
  {
118
    return m_config_dialog->Show();
1✔
119
  }
120

121
  return m_config_dialog->ShowModal();
×
122
}
4!
123

124
wex::shell* wex::process::prepare_output(wxWindow* parent)
42✔
125
{
126
  if (m_shell == nullptr)
42✔
127
  {
128
    m_shell = new shell(
×
129
      data::stc().window(data::window().parent(parent)),
82✔
130
      std::string()); // empty prompt
123✔
131
  }
132

133
  return m_shell;
42✔
134
}
135

136
void wex::process::set_frame()
37✔
137
{
138
  if (m_frame == nullptr)
37✔
139
  {
140
    m_frame = dynamic_cast<frame*>(wxTheApp->GetTopWindow());
1!
141
  }
142
}
37✔
143

144
void wex::process::show_output(const std::string& caption) const
5✔
145
{
146
  if (
5✔
147
    (!std_out().empty() || !std_err().empty()) && m_shell != nullptr &&
9!
148
    m_frame != nullptr)
4!
149
  {
150
    m_frame->show_process(true);
4✔
151
    m_shell->AppendText(!std_out().empty() ? std_out() : std_err());
4!
152
  }
153
  else if (std_out().empty())
1!
154
  {
155
    log::status("No output");
2✔
156
  }
157
}
5✔
158

159
int wex::process::system(const process_data& data_in)
30✔
160
{
161
  process_data data(data_in);
30✔
162
  set_frame();
30✔
163

164
  if (auto* stc = dynamic_cast<wex::stc*>(m_frame->get_stc()); stc != nullptr)
30✔
165
  {
166
    expand_macro(data, stc);
22✔
167
  }
168

169
  return factory::process::system(data);
60✔
170
}
30✔
171

172
bool wex::process::write(const std::string& text)
4✔
173
{
174
  if (!is_debug() && m_frame != nullptr)
4!
175
  {
176
    m_frame->show_process(true);
4✔
177
  }
178

179
  return factory::process::write(text);
4✔
180
}
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