| e8555c89 Andy McCall |
1 |
#include "BooleanSetting.hh" |
| 2 |
|
| 3 |
#include "Completer.hh" |
| 4 |
|
| 5 |
#include <array> |
| 6 |
|
| 7 |
namespace openmsx { |
| 8 |
|
| 9 |
BooleanSetting::BooleanSetting( |
| 10 |
CommandController& commandController_, std::string_view name, |
| 11 |
static_string_view description_, bool initialValue, Save save_) |
| 12 |
: Setting(commandController_, name, description_, |
| 13 |
TclObject(toString(initialValue)), save_) |
| 14 |
{ |
| 15 |
auto& interp = getInterpreter(); |
| 16 |
setChecker([&interp](TclObject& newValue) { |
| 17 |
|
| 18 |
|
| 19 |
newValue = toString(newValue.getBoolean(interp)); |
| 20 |
}); |
| 21 |
init(); |
| 22 |
} |
| 23 |
|
| 24 |
std::string_view BooleanSetting::getTypeString() const |
| 25 |
{ |
| 26 |
return "boolean"; |
| 27 |
} |
| 28 |
|
| 29 |
void BooleanSetting::tabCompletion(std::vector<std::string>& tokens) const |
| 30 |
{ |
| 31 |
using namespace std::literals; |
| 32 |
static constexpr std::array values = { |
| 33 |
"true"sv, "on"sv, "yes"sv, |
| 34 |
"false"sv, "off"sv, "no"sv, |
| 35 |
}; |
| 36 |
Completer::completeString(tokens, values, false); |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
} |