mirror of https://github.com/stella-emu/stella.git
Fixes from clang-tidy-19 that didn't make it for the last release.
This commit is contained in:
parent
18db75df5e
commit
2d184b6754
|
@ -381,8 +381,7 @@ string HighScoresManager::formattedScore(Int32 score, Int32 width) const
|
||||||
|
|
||||||
if(scoreBCD(jprops))
|
if(scoreBCD(jprops))
|
||||||
{
|
{
|
||||||
if(width > digits)
|
digits = std::max(width, digits);
|
||||||
digits = width;
|
|
||||||
buf << std::setw(digits) << std::setfill(' ') << score;
|
buf << std::setw(digits) << std::setfill(' ') << score;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -188,8 +188,7 @@ json JoyMap::saveMapping(EventMode mode) const
|
||||||
using MapType = std::pair<JoyMapping, Event::Type>;
|
using MapType = std::pair<JoyMapping, Event::Type>;
|
||||||
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
||||||
|
|
||||||
std::sort(sortedMap.begin(), sortedMap.end(),
|
std::ranges::sort(sortedMap, [](const MapType& a, const MapType& b)
|
||||||
[](const MapType& a, const MapType& b)
|
|
||||||
{
|
{
|
||||||
// Event::Type first
|
// Event::Type first
|
||||||
if(a.first.button != b.first.button)
|
if(a.first.button != b.first.button)
|
||||||
|
@ -285,17 +284,17 @@ int JoyMap::loadMapping(const json& eventMappings, EventMode mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
json JoyMap::convertLegacyMapping(string list)
|
json JoyMap::convertLegacyMapping(string lst)
|
||||||
{
|
{
|
||||||
json eventMappings = json::array();
|
json eventMappings = json::array();
|
||||||
|
|
||||||
// Since istringstream swallows whitespace, we have to make the
|
// Since istringstream swallows whitespace, we have to make the
|
||||||
// delimiters be spaces
|
// delimiters be spaces
|
||||||
std::replace(list.begin(), list.end(), '|', ' ');
|
std::ranges::replace(lst, '|', ' ');
|
||||||
std::replace(list.begin(), list.end(), ':', ' ');
|
std::ranges::replace(lst, ':', ' ');
|
||||||
std::replace(list.begin(), list.end(), ',', ' ');
|
std::ranges::replace(lst, ',', ' ');
|
||||||
|
|
||||||
istringstream buf(list);
|
istringstream buf(lst);
|
||||||
int event = 0, button = 0, axis = 0, adir = 0, hat = 0, hdir = 0;
|
int event = 0, button = 0, axis = 0, adir = 0, hat = 0, hdir = 0;
|
||||||
|
|
||||||
while(buf >> event && buf >> button
|
while(buf >> event && buf >> button
|
||||||
|
|
|
@ -112,7 +112,7 @@ class JoyMap
|
||||||
nlohmann::json saveMapping(EventMode mode) const;
|
nlohmann::json saveMapping(EventMode mode) const;
|
||||||
int loadMapping(const nlohmann::json& eventMappings, EventMode mode);
|
int loadMapping(const nlohmann::json& eventMappings, EventMode mode);
|
||||||
|
|
||||||
static nlohmann::json convertLegacyMapping(string list);
|
static nlohmann::json convertLegacyMapping(string lst);
|
||||||
|
|
||||||
/** Erase all mappings for given mode */
|
/** Erase all mappings for given mode */
|
||||||
void eraseMode(EventMode mode);
|
void eraseMode(EventMode mode);
|
||||||
|
|
|
@ -222,8 +222,7 @@ json KeyMap::saveMapping(EventMode mode) const
|
||||||
using MapType = std::pair<Mapping, Event::Type>;
|
using MapType = std::pair<Mapping, Event::Type>;
|
||||||
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
||||||
|
|
||||||
std::sort(sortedMap.begin(), sortedMap.end(),
|
std::ranges::sort(sortedMap, [](const MapType& a, const MapType& b)
|
||||||
[](const MapType& a, const MapType& b)
|
|
||||||
{
|
{
|
||||||
// Event::Type first
|
// Event::Type first
|
||||||
if(a.first.key != b.first.key)
|
if(a.first.key != b.first.key)
|
||||||
|
@ -290,11 +289,11 @@ json KeyMap::convertLegacyMapping(string_view lm)
|
||||||
|
|
||||||
// Since istringstream swallows whitespace, we have to make the
|
// Since istringstream swallows whitespace, we have to make the
|
||||||
// delimiters be spaces
|
// delimiters be spaces
|
||||||
string list{lm};
|
string lst{lm};
|
||||||
std::replace(list.begin(), list.end(), '|', ' ');
|
std::ranges::replace(lst, '|', ' ');
|
||||||
std::replace(list.begin(), list.end(), ':', ' ');
|
std::ranges::replace(lst, ':', ' ');
|
||||||
std::replace(list.begin(), list.end(), ',', ' ');
|
std::ranges::replace(lst, ',', ' ');
|
||||||
istringstream buf(list);
|
istringstream buf(lst);
|
||||||
int event = 0, key = 0, mod = 0;
|
int event = 0, key = 0, mod = 0;
|
||||||
|
|
||||||
while(buf >> event && buf >> key && buf >> mod)
|
while(buf >> event && buf >> key && buf >> mod)
|
||||||
|
|
|
@ -478,9 +478,9 @@ void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const
|
||||||
float G = Y + dotProduct(IQ[chroma], IQG);
|
float G = Y + dotProduct(IQ[chroma], IQG);
|
||||||
float B = Y + dotProduct(IQ[chroma], IQB);
|
float B = Y + dotProduct(IQ[chroma], IQB);
|
||||||
|
|
||||||
if(R < 0) R = 0;
|
R = std::max(R, 0.F);
|
||||||
if(G < 0) G = 0;
|
G = std::max(G, 0.F);
|
||||||
if(B < 0) B = 0;
|
B = std::max(B, 0.F);
|
||||||
|
|
||||||
R = powf(R, 0.9F);
|
R = powf(R, 0.9F);
|
||||||
G = powf(G, 0.9F);
|
G = powf(G, 0.9F);
|
||||||
|
|
|
@ -112,26 +112,26 @@ json PhysicalJoystick::convertLegacyMapping(string_view mapping, string_view nam
|
||||||
{
|
{
|
||||||
istringstream buf(string{mapping}); // TODO: fixed in C++23
|
istringstream buf(string{mapping}); // TODO: fixed in C++23
|
||||||
json convertedMapping = json::object();
|
json convertedMapping = json::object();
|
||||||
string map;
|
string lmap;
|
||||||
|
|
||||||
// Skip joystick name
|
// Skip joystick name
|
||||||
getline(buf, map, MODE_DELIM);
|
getline(buf, lmap, MODE_DELIM);
|
||||||
|
|
||||||
while (getline(buf, map, MODE_DELIM))
|
while (getline(buf, lmap, MODE_DELIM))
|
||||||
{
|
{
|
||||||
int mode{0};
|
int mode{0};
|
||||||
|
|
||||||
// Get event mode
|
// Get event mode
|
||||||
std::replace(map.begin(), map.end(), '|', ' ');
|
std::ranges::replace(lmap, '|', ' ');
|
||||||
istringstream modeBuf(map);
|
istringstream modeBuf(lmap);
|
||||||
modeBuf >> mode;
|
modeBuf >> mode;
|
||||||
|
|
||||||
// Remove leading "<mode>|" string
|
// Remove leading "<mode>|" string
|
||||||
map.erase(0, 2);
|
lmap.erase(0, 2);
|
||||||
|
|
||||||
const json mappingForMode = JoyMap::convertLegacyMapping(map);
|
const json lmappingForMode = JoyMap::convertLegacyMapping(lmap);
|
||||||
|
|
||||||
convertedMapping[jsonName(static_cast<EventMode>(mode))] = mappingForMode;
|
convertedMapping[jsonName(static_cast<EventMode>(mode))] = lmappingForMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
convertedMapping["name"] = name;
|
convertedMapping["name"] = name;
|
||||||
|
|
|
@ -479,7 +479,7 @@ void SoundSDL2::WavHandlerSDL2::processWav(uInt8* stream, uInt32 len)
|
||||||
const int newFreq =
|
const int newFreq =
|
||||||
std::round(static_cast<double>(mySpec.freq) * origLen / len);
|
std::round(static_cast<double>(mySpec.freq) * origLen / len);
|
||||||
|
|
||||||
if(len > myRemaining)
|
if(len > myRemaining) // NOLINT(readability-use-std-min-max)
|
||||||
len = myRemaining;
|
len = myRemaining;
|
||||||
|
|
||||||
SDL_AudioCVT cvt;
|
SDL_AudioCVT cvt;
|
||||||
|
@ -505,7 +505,7 @@ void SoundSDL2::WavHandlerSDL2::processWav(uInt8* stream, uInt32 len)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(len > myRemaining)
|
if(len > myRemaining) // NOLINT(readability-use-std-min-max)
|
||||||
len = myRemaining;
|
len = myRemaining;
|
||||||
|
|
||||||
// Mix volume adjusted WAV data into silent buffer
|
// Mix volume adjusted WAV data into silent buffer
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#ifndef VERSION_HXX
|
#ifndef VERSION_HXX
|
||||||
#define VERSION_HXX
|
#define VERSION_HXX
|
||||||
|
|
||||||
#define STELLA_VERSION "7.0"
|
#define STELLA_VERSION "7.1_pre"
|
||||||
#define STELLA_BUILD "8005"
|
#define STELLA_BUILD "8005"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -266,8 +266,7 @@ void ZipHandler::ZipFile::readEcd()
|
||||||
uInt64 read_length = 0;
|
uInt64 read_length = 0;
|
||||||
|
|
||||||
// Max out the buf length at the size of the file
|
// Max out the buf length at the size of the file
|
||||||
if(buflen > myLength)
|
buflen = std::min(buflen, myLength);
|
||||||
buflen = myLength;
|
|
||||||
|
|
||||||
// Allocate buffer
|
// Allocate buffer
|
||||||
const ByteBuffer buffer = make_unique<uInt8[]>(buflen + 1);
|
const ByteBuffer buffer = make_unique<uInt8[]>(buflen + 1);
|
||||||
|
|
|
@ -56,6 +56,7 @@ using uInt64 = uint64_t;
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <numbers>
|
#include <numbers>
|
||||||
|
#include <ranges>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -189,12 +190,12 @@ namespace BSPF
|
||||||
// Convert string to given case
|
// Convert string to given case
|
||||||
inline const string& toUpperCase(string& s)
|
inline const string& toUpperCase(string& s)
|
||||||
{
|
{
|
||||||
transform(s.begin(), s.end(), s.begin(), ::toupper);
|
std::ranges::transform(s, s.begin(), ::toupper);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
inline const string& toLowerCase(string& s)
|
inline const string& toLowerCase(string& s)
|
||||||
{
|
{
|
||||||
transform(s.begin(), s.end(), s.begin(), ::tolower);
|
std::ranges::transform(s, s.begin(), ::tolower);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,9 +427,9 @@ namespace BSPF
|
||||||
const auto currtime = std::time(nullptr);
|
const auto currtime = std::time(nullptr);
|
||||||
std::tm tm_snapshot{};
|
std::tm tm_snapshot{};
|
||||||
#if (defined BSPF_WINDOWS || defined __WIN32__) && (!defined __GNUG__ || defined __MINGW32__)
|
#if (defined BSPF_WINDOWS || defined __WIN32__) && (!defined __GNUG__ || defined __MINGW32__)
|
||||||
localtime_s(&tm_snapshot, &currtime);
|
std::ignore = localtime_s(&tm_snapshot, &currtime);
|
||||||
#else
|
#else
|
||||||
localtime_r(&currtime, &tm_snapshot);
|
std::ignore = localtime_r(&currtime, &tm_snapshot);
|
||||||
#endif
|
#endif
|
||||||
return tm_snapshot;
|
return tm_snapshot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#include "CheatManager.hxx"
|
#include "CheatManager.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Parse the commandline arguments and store into the appropriate hashmap.
|
Parse the commandline arguments and store into the appropriate hashmap.
|
||||||
|
|
||||||
|
@ -47,39 +49,6 @@
|
||||||
Some keys are used only by the main function; these are placed in localOpts.
|
Some keys are used only by the main function; these are placed in localOpts.
|
||||||
The rest are needed globally, and are placed in globalOpts.
|
The rest are needed globally, and are placed in globalOpts.
|
||||||
*/
|
*/
|
||||||
void parseCommandLine(int ac, const char* const av[],
|
|
||||||
Settings::Options& globalOpts, Settings::Options& localOpts);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Checks the commandline for special settings that are used by various ports
|
|
||||||
to use a specific 'base directory'.
|
|
||||||
|
|
||||||
This needs to be done separately, before either an OSystem or Settings
|
|
||||||
object can be created, since they both depend on each other, and a
|
|
||||||
variable basedir implies a different location for the settings file.
|
|
||||||
|
|
||||||
This function will call OSystem::overrideBaseDir() when either of the
|
|
||||||
applicable arguments are found, and then remove them from the argument
|
|
||||||
list.
|
|
||||||
*/
|
|
||||||
void checkForCustomBaseDir(Settings::Options& options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Checks whether the commandline contains an argument corresponding to
|
|
||||||
starting a profile session.
|
|
||||||
*/
|
|
||||||
bool isProfilingRun(int ac, char* av[]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
In Windows, attach console to allow command line output (e.g. for -help).
|
|
||||||
This is needed since by default Windows doesn't set up stdout/stderr
|
|
||||||
correctly.
|
|
||||||
*/
|
|
||||||
void attachConsole();
|
|
||||||
void freeConsole();
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
void parseCommandLine(int ac, const char* const av[],
|
void parseCommandLine(int ac, const char* const av[],
|
||||||
Settings::Options& globalOpts, Settings::Options& localOpts)
|
Settings::Options& globalOpts, Settings::Options& localOpts)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +105,18 @@ void parseCommandLine(int ac, const char* const av[],
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/**
|
||||||
|
Checks the commandline for special settings that are used by various ports
|
||||||
|
to use a specific 'base directory'.
|
||||||
|
|
||||||
|
This needs to be done separately, before either an OSystem or Settings
|
||||||
|
object can be created, since they both depend on each other, and a
|
||||||
|
variable basedir implies a different location for the settings file.
|
||||||
|
|
||||||
|
This function will call OSystem::overrideBaseDir() when either of the
|
||||||
|
applicable arguments are found, and then remove them from the argument
|
||||||
|
list.
|
||||||
|
*/
|
||||||
void checkForCustomBaseDir(Settings::Options& options)
|
void checkForCustomBaseDir(Settings::Options& options)
|
||||||
{
|
{
|
||||||
// If both of these are activated, the 'base in app dir' takes precedence
|
// If both of these are activated, the 'base in app dir' takes precedence
|
||||||
|
@ -150,14 +130,22 @@ void checkForCustomBaseDir(Settings::Options& options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/**
|
||||||
bool isProfilingRun(int ac, char* av[]) {
|
Checks whether the commandline contains an argument corresponding to
|
||||||
|
starting a profile session.
|
||||||
|
*/
|
||||||
|
bool isProfilingRun(int ac, char* av[])
|
||||||
|
{
|
||||||
if (ac <= 1) return false;
|
if (ac <= 1) return false;
|
||||||
|
|
||||||
return string(av[1]) == "-profile";
|
return string(av[1]) == "-profile";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/**
|
||||||
|
In Windows, attach console to allow command line output (e.g. for -help).
|
||||||
|
This is needed since by default Windows doesn't set up stdout/stderr
|
||||||
|
correctly.
|
||||||
|
*/
|
||||||
void attachConsole()
|
void attachConsole()
|
||||||
{
|
{
|
||||||
#if defined(BSPF_WINDOWS)
|
#if defined(BSPF_WINDOWS)
|
||||||
|
@ -183,7 +171,6 @@ void attachConsole()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
void freeConsole()
|
void freeConsole()
|
||||||
{
|
{
|
||||||
#if defined(BSPF_WINDOWS)
|
#if defined(BSPF_WINDOWS)
|
||||||
|
@ -192,6 +179,9 @@ void freeConsole()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
#if defined(BSPF_MACOS)
|
#if defined(BSPF_MACOS)
|
||||||
int stellaMain(int ac, char* av[])
|
int stellaMain(int ac, char* av[])
|
||||||
|
|
|
@ -28,12 +28,14 @@
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class KeyValueRepositoryFile : public KeyValueRepository {
|
class KeyValueRepositoryFile : public KeyValueRepository {
|
||||||
public:
|
public:
|
||||||
explicit KeyValueRepositoryFile(const FSNode& node);
|
|
||||||
|
|
||||||
KVRMap load() override;
|
KVRMap load() override;
|
||||||
|
|
||||||
bool save(const KVRMap& values) override;
|
bool save(const KVRMap& values) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit KeyValueRepositoryFile(const FSNode& node);
|
||||||
|
friend T;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
const FSNode& myNode; // NOLINT: we want a reference here
|
const FSNode& myNode; // NOLINT: we want a reference here
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
#include "NTSCFilter.hxx"
|
#include "NTSCFilter.hxx"
|
||||||
|
|
||||||
constexpr float scaleFrom100(float x) { return (x / 50.F) - 1.F; }
|
namespace {
|
||||||
constexpr uInt32 scaleTo100(float x) { return static_cast<uInt32>(50.0001F * (x + 1.F)); }
|
constexpr float scaleFrom100(float x) { return (x / 50.F) - 1.F; }
|
||||||
|
constexpr uInt32 scaleTo100(float x) { return static_cast<uInt32>(50.0001F * (x + 1.F)); }
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string NTSCFilter::setPreset(Preset preset)
|
string NTSCFilter::setPreset(Preset preset)
|
||||||
|
|
|
@ -793,8 +793,8 @@ bool Debugger::addFunction(string_view name, string_view definition,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool Debugger::isBuiltinFunction(string_view name)
|
bool Debugger::isBuiltinFunction(string_view name)
|
||||||
{
|
{
|
||||||
return std::any_of(ourBuiltinFunctions.cbegin(), ourBuiltinFunctions.cend(),
|
return std::ranges::any_of(ourBuiltinFunctions,
|
||||||
[&](const auto& func) { return name == func.name; });
|
[&name](const auto& func) { return name == func.name; });
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -845,10 +845,8 @@ string Debugger::builtinHelp()
|
||||||
// Get column widths for aligned output (functions)
|
// Get column widths for aligned output (functions)
|
||||||
for(const auto& func: ourBuiltinFunctions)
|
for(const auto& func: ourBuiltinFunctions)
|
||||||
{
|
{
|
||||||
size_t len = func.name.size();
|
c_maxlen = std::max(func.name.size(), c_maxlen);
|
||||||
if(len > c_maxlen) c_maxlen = len;
|
i_maxlen = std::max(func.defn.size(), i_maxlen);
|
||||||
len = func.defn.size();
|
|
||||||
if(len > i_maxlen) i_maxlen = len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buf << std::setfill(' ') << "\nBuilt-in functions:\n";
|
buf << std::setfill(' ') << "\nBuilt-in functions:\n";
|
||||||
|
@ -865,10 +863,7 @@ string Debugger::builtinHelp()
|
||||||
// Get column widths for aligned output (pseudo-registers)
|
// Get column widths for aligned output (pseudo-registers)
|
||||||
c_maxlen = 0;
|
c_maxlen = 0;
|
||||||
for(const auto& reg: ourPseudoRegisters)
|
for(const auto& reg: ourPseudoRegisters)
|
||||||
{
|
c_maxlen = std::max(reg.name.size(), c_maxlen);
|
||||||
const size_t len = reg.name.size();
|
|
||||||
if(len > c_maxlen) c_maxlen = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf << "\nPseudo-registers:\n";
|
buf << "\nPseudo-registers:\n";
|
||||||
for(const auto& reg: ourPseudoRegisters)
|
for(const auto& reg: ourPseudoRegisters)
|
||||||
|
|
|
@ -1481,10 +1481,7 @@ void DebuggerParser::executeHelp()
|
||||||
// Find length of longest command
|
// Find length of longest command
|
||||||
size_t clen = 0;
|
size_t clen = 0;
|
||||||
for(const auto& c: commands)
|
for(const auto& c: commands)
|
||||||
{
|
clen = std::max(clen, c.cmdString.length());
|
||||||
const size_t len = c.cmdString.length();
|
|
||||||
if(len > clen) clen = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
commandResult << setfill(' ');
|
commandResult << setfill(' ');
|
||||||
for(const auto& c: commands)
|
for(const auto& c: commands)
|
||||||
|
|
|
@ -69,8 +69,7 @@ int CartDebugWidget::addBaseInformation(size_t bytes, string_view manufacturer,
|
||||||
const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) /
|
const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) /
|
||||||
myFontWidth);
|
myFontWidth);
|
||||||
const StringList& sl = bs.stringList();
|
const StringList& sl = bs.stringList();
|
||||||
size_t lines = sl.size();
|
size_t lines = std::max<size_t>(sl.size(), 3);
|
||||||
if(lines < 3) lines = 3;
|
|
||||||
bool useScrollbar = false;
|
bool useScrollbar = false;
|
||||||
if(lines > maxlines)
|
if(lines > maxlines)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,10 +64,9 @@ CartRamWidget::CartRamWidget(
|
||||||
constexpr uInt16 maxlines = 6;
|
constexpr uInt16 maxlines = 6;
|
||||||
const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth);
|
const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth);
|
||||||
const StringList& sl = bs.stringList();
|
const StringList& sl = bs.stringList();
|
||||||
auto lines = static_cast<uInt32>(sl.size());
|
|
||||||
bool useScrollbar = false;
|
|
||||||
|
|
||||||
if(lines < 2) lines = 2;
|
bool useScrollbar = false;
|
||||||
|
auto lines = std::max<uInt32>(static_cast<uInt32>(sl.size()), 2);
|
||||||
if(lines > maxlines)
|
if(lines > maxlines)
|
||||||
{
|
{
|
||||||
lines = maxlines;
|
lines = maxlines;
|
||||||
|
|
|
@ -118,10 +118,8 @@ void DataGridWidget::setList(const IntArray& alist, const IntArray& vlist,
|
||||||
const size_t size = vlist.size(); // assume the alist is the same size
|
const size_t size = vlist.size(); // assume the alist is the same size
|
||||||
|
|
||||||
const bool dirty = _editMode
|
const bool dirty = _editMode
|
||||||
|| !std::equal(_valueList.begin(), _valueList.end(),
|
|| !std::ranges::equal(_valueList, vlist)
|
||||||
vlist.begin(), vlist.end())
|
|| !std::ranges::equal(_changedList, changed);
|
||||||
|| !std::equal(_changedList.begin(), _changedList.end(),
|
|
||||||
changed.begin(), changed.end());
|
|
||||||
|
|
||||||
_addrList.clear();
|
_addrList.clear();
|
||||||
_valueList.clear();
|
_valueList.clear();
|
||||||
|
|
|
@ -170,9 +170,8 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
|
||||||
if(_scrollLine < _currentPos / _lineWidth)
|
if(_scrollLine < _currentPos / _lineWidth)
|
||||||
{
|
{
|
||||||
// Scroll page by page when not at cursor position:
|
// Scroll page by page when not at cursor position:
|
||||||
_scrollLine += _linesPerPage;
|
_scrollLine = std::min(_scrollLine + _linesPerPage,
|
||||||
if(_scrollLine > _promptEndPos / _lineWidth)
|
_promptEndPos / _lineWidth);
|
||||||
_scrollLine = _promptEndPos / _lineWidth;
|
|
||||||
updateScrollBuffer();
|
updateScrollBuffer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -293,9 +292,8 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
|
||||||
if(_scrollLine < _linesPerPage)
|
if(_scrollLine < _linesPerPage)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_scrollLine -= _linesPerPage - 1;
|
_scrollLine = std::max(_scrollLine - (_linesPerPage - 1),
|
||||||
if(_scrollLine < _firstLineInBuffer + _linesPerPage - 1)
|
_firstLineInBuffer + _linesPerPage - 1);
|
||||||
_scrollLine = _firstLineInBuffer + _linesPerPage - 1;
|
|
||||||
updateScrollBuffer();
|
updateScrollBuffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -304,9 +302,8 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
|
||||||
if(_scrollLine >= _promptEndPos / _lineWidth)
|
if(_scrollLine >= _promptEndPos / _lineWidth)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_scrollLine += _linesPerPage - 1;
|
_scrollLine = std::min(_scrollLine + (_linesPerPage - 1),
|
||||||
if(_scrollLine > _promptEndPos / _lineWidth)
|
_promptEndPos / _lineWidth);
|
||||||
_scrollLine = _promptEndPos / _lineWidth;
|
|
||||||
updateScrollBuffer();
|
updateScrollBuffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -316,9 +313,7 @@ bool PromptWidget::handleKeyDown(StellaKey key, StellaMod mod)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::UIEnd:
|
case Event::UIEnd:
|
||||||
_scrollLine = _promptEndPos / _lineWidth;
|
_scrollLine = std::max(_promptEndPos / _lineWidth, _linesPerPage - 1);
|
||||||
if(_scrollLine < _linesPerPage - 1)
|
|
||||||
_scrollLine = _linesPerPage - 1;
|
|
||||||
updateScrollBuffer();
|
updateScrollBuffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -727,8 +722,7 @@ bool PromptWidget::autoComplete(int direction)
|
||||||
|
|
||||||
if(_tabCount != -1)
|
if(_tabCount != -1)
|
||||||
len = static_cast<int>(strlen(_inputStr));
|
len = static_cast<int>(strlen(_inputStr));
|
||||||
if(len > kLineBufferSize - 1)
|
len = std::min(len, kLineBufferSize - 1);
|
||||||
len = kLineBufferSize - 1;
|
|
||||||
|
|
||||||
int lastDelimPos = -1;
|
int lastDelimPos = -1;
|
||||||
char delimiter = '\0';
|
char delimiter = '\0';
|
||||||
|
@ -748,11 +742,11 @@ bool PromptWidget::autoComplete(int direction)
|
||||||
if(_tabCount == -1)
|
if(_tabCount == -1)
|
||||||
_inputStr[len] = '\0';
|
_inputStr[len] = '\0';
|
||||||
|
|
||||||
StringList list;
|
StringList lst;
|
||||||
|
|
||||||
if(lastDelimPos == -1)
|
if(lastDelimPos == -1)
|
||||||
// no delimiters, do only command completion:
|
// no delimiters, do only command completion:
|
||||||
DebuggerParser::getCompletions(_inputStr, list);
|
DebuggerParser::getCompletions(_inputStr, lst);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const size_t strLen = len - lastDelimPos - 1;
|
const size_t strLen = len - lastDelimPos - 1;
|
||||||
|
@ -761,29 +755,29 @@ bool PromptWidget::autoComplete(int direction)
|
||||||
{
|
{
|
||||||
// Special case for 'help' command
|
// Special case for 'help' command
|
||||||
if(BSPF::startsWithIgnoreCase(_inputStr, "help"))
|
if(BSPF::startsWithIgnoreCase(_inputStr, "help"))
|
||||||
DebuggerParser::getCompletions(_inputStr + lastDelimPos + 1, list);
|
DebuggerParser::getCompletions(_inputStr + lastDelimPos + 1, lst);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we got a delimiter, so this must be a label or a function
|
// we got a delimiter, so this must be a label or a function
|
||||||
const Debugger& dbg = instance().debugger();
|
const Debugger& dbg = instance().debugger();
|
||||||
|
|
||||||
dbg.cartDebug().getCompletions(_inputStr + lastDelimPos + 1, list);
|
dbg.cartDebug().getCompletions(_inputStr + lastDelimPos + 1, lst);
|
||||||
dbg.getCompletions(_inputStr + lastDelimPos + 1, list);
|
dbg.getCompletions(_inputStr + lastDelimPos + 1, lst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(list.empty())
|
if(lst.empty())
|
||||||
return false;
|
return false;
|
||||||
sort(list.begin(), list.end());
|
std::ranges::sort(lst);
|
||||||
|
|
||||||
if(direction < 0)
|
if(direction < 0)
|
||||||
{
|
{
|
||||||
if(--_tabCount < 0)
|
if(--_tabCount < 0)
|
||||||
_tabCount = static_cast<int>(list.size()) - 1;
|
_tabCount = static_cast<int>(lst.size()) - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_tabCount = (_tabCount + 1) % list.size();
|
_tabCount = (_tabCount + 1) % lst.size();
|
||||||
|
|
||||||
nextLine();
|
nextLine();
|
||||||
_currentPos = _promptStartPos;
|
_currentPos = _promptStartPos;
|
||||||
|
@ -796,7 +790,7 @@ bool PromptWidget::autoComplete(int direction)
|
||||||
putcharIntern(delimiter);
|
putcharIntern(delimiter);
|
||||||
|
|
||||||
// ...and add current autocompletion string
|
// ...and add current autocompletion string
|
||||||
print(list[_tabCount]);
|
print(lst[_tabCount]);
|
||||||
putcharIntern(' ');
|
putcharIntern(' ');
|
||||||
_promptEndPos = _currentPos;
|
_promptEndPos = _currentPos;
|
||||||
|
|
||||||
|
|
|
@ -164,11 +164,7 @@ void RomListWidget::setHighlighted(int item)
|
||||||
|
|
||||||
// Only scroll the list if we're about to pass the page boundary
|
// Only scroll the list if we're about to pass the page boundary
|
||||||
if (_highlightedItem < _currentPos)
|
if (_highlightedItem < _currentPos)
|
||||||
{
|
_currentPos = std::max(_currentPos - _rows, 0);
|
||||||
_currentPos -= _rows;
|
|
||||||
if (_currentPos < 0)
|
|
||||||
_currentPos = 0;
|
|
||||||
}
|
|
||||||
else if(_highlightedItem == _currentPos + _rows)
|
else if(_highlightedItem == _currentPos + _rows)
|
||||||
_currentPos += _rows;
|
_currentPos += _rows;
|
||||||
|
|
||||||
|
@ -187,10 +183,7 @@ void RomListWidget::recalc()
|
||||||
{
|
{
|
||||||
const int size = static_cast<int>(myDisasm->list.size());
|
const int size = static_cast<int>(myDisasm->list.size());
|
||||||
|
|
||||||
if (_currentPos >= size)
|
_currentPos = BSPF::clamp(_currentPos, 0, size - 1);
|
||||||
_currentPos = size - 1;
|
|
||||||
if (_currentPos < 0)
|
|
||||||
_currentPos = 0;
|
|
||||||
|
|
||||||
if(_selectedItem < 0 || _selectedItem >= size)
|
if(_selectedItem < 0 || _selectedItem >= size)
|
||||||
_selectedItem = 0;
|
_selectedItem = 0;
|
||||||
|
@ -378,15 +371,12 @@ bool RomListWidget::handleEvent(Event::Type e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::UIPgUp:
|
case Event::UIPgUp:
|
||||||
_selectedItem -= _rows - 1;
|
_selectedItem = std::max(_selectedItem - (_rows - 1), 0);
|
||||||
if (_selectedItem < 0)
|
|
||||||
_selectedItem = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::UIPgDown:
|
case Event::UIPgDown:
|
||||||
_selectedItem += _rows - 1;
|
_selectedItem = std::min(_selectedItem + (_rows - 1),
|
||||||
if (_selectedItem >= static_cast<int>(myDisasm->list.size()))
|
static_cast<int>(myDisasm->list.size()) - 1);
|
||||||
_selectedItem = static_cast<int>(myDisasm->list.size()) - 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::UIHome:
|
case Event::UIHome:
|
||||||
|
|
|
@ -68,8 +68,7 @@ void ToggleBitWidget::setList(const StringList& off, const StringList& on)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed)
|
void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed)
|
||||||
{
|
{
|
||||||
if(!std::equal(_changedList.begin(), _changedList.end(),
|
if(!std::ranges::equal(_changedList, changed))
|
||||||
changed.begin(), changed.end()))
|
|
||||||
setDirty();
|
setDirty();
|
||||||
|
|
||||||
_stateList.clear();
|
_stateList.clear();
|
||||||
|
@ -78,7 +77,6 @@ void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed)
|
||||||
_changedList = changed;
|
_changedList = changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string ToggleBitWidget::getToolTip(const Common::Point& pos) const
|
string ToggleBitWidget::getToolTip(const Common::Point& pos) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
#include "CartELF.hxx"
|
#include "CartELF.hxx"
|
||||||
|
|
||||||
|
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||||
|
|
||||||
using namespace elfEnvironment;
|
using namespace elfEnvironment;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -178,7 +180,7 @@ namespace {
|
||||||
{
|
{
|
||||||
if (!props) return SystemType::ntsc;
|
if (!props) return SystemType::ntsc;
|
||||||
|
|
||||||
const string displayFormat = props->get(PropType::Display_Format);
|
const string& displayFormat = props->get(PropType::Display_Format);
|
||||||
|
|
||||||
if(displayFormat == "PAL" || displayFormat == "SECAM") return SystemType::pal;
|
if(displayFormat == "PAL" || displayFormat == "SECAM") return SystemType::pal;
|
||||||
if(displayFormat == "PAL60") return SystemType::pal60;
|
if(displayFormat == "PAL60") return SystemType::pal60;
|
||||||
|
@ -767,3 +769,5 @@ void CartridgeELF::resetWithConfig()
|
||||||
|
|
||||||
switchExecutionStage();
|
switchExecutionStage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||||
|
|
|
@ -2051,15 +2051,15 @@ void EventHandler::setComboMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
json EventHandler::convertLegacyComboMapping(string list)
|
json EventHandler::convertLegacyComboMapping(string lst)
|
||||||
{
|
{
|
||||||
json convertedMapping = json::array();
|
json convertedMapping = json::array();
|
||||||
|
|
||||||
// Since istringstream swallows whitespace, we have to make the
|
// Since istringstream swallows whitespace, we have to make the
|
||||||
// delimiters be spaces
|
// delimiters be spaces
|
||||||
std::replace(list.begin(), list.end(), ':', ' ');
|
std::ranges::replace(lst, ':', ' ');
|
||||||
std::replace(list.begin(), list.end(), ',', ' ');
|
std::ranges::replace(lst, ',', ' ');
|
||||||
istringstream buf(list);
|
istringstream buf(lst);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -475,7 +475,7 @@ class EventHandler
|
||||||
void setActionMappings(EventMode mode);
|
void setActionMappings(EventMode mode);
|
||||||
void setDefaultKeymap(Event::Type, EventMode mode);
|
void setDefaultKeymap(Event::Type, EventMode mode);
|
||||||
void setDefaultJoymap(Event::Type, EventMode mode);
|
void setDefaultJoymap(Event::Type, EventMode mode);
|
||||||
static nlohmann::json convertLegacyComboMapping(string list);
|
static nlohmann::json convertLegacyComboMapping(string lst);
|
||||||
void saveComboMapping();
|
void saveComboMapping();
|
||||||
|
|
||||||
static StringList getActionList(EventMode mode);
|
static StringList getActionList(EventMode mode);
|
||||||
|
|
|
@ -89,8 +89,7 @@ bool FSNode::getAllChildren(FSList& fslist, ListMode mode,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::sort(fslist.begin(), fslist.end(),
|
std::ranges::sort(fslist, [](const FSNode& node1, const FSNode& node2)
|
||||||
[](const FSNode& node1, const FSNode& node2)
|
|
||||||
{
|
{
|
||||||
if(node1.isDirectory() != node2.isDirectory())
|
if(node1.isDirectory() != node2.isDirectory())
|
||||||
return node1.isDirectory();
|
return node1.isDirectory();
|
||||||
|
@ -153,7 +152,7 @@ bool FSNode::getChildren(FSList& fslist, ListMode mode,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::sort(tmp.begin(), tmp.end(),
|
std::ranges::sort(tmp,
|
||||||
[](const AbstractFSNodePtr& node1, const AbstractFSNodePtr& node2)
|
[](const AbstractFSNodePtr& node1, const AbstractFSNodePtr& node2)
|
||||||
{
|
{
|
||||||
if(node1->isDirectory() != node2->isDirectory())
|
if(node1->isDirectory() != node2->isDirectory())
|
||||||
|
|
|
@ -478,7 +478,7 @@ void PlusROM::receive()
|
||||||
// and start over
|
// and start over
|
||||||
const auto [responseSize, response] = (*iter)->getResponse();
|
const auto [responseSize, response] = (*iter)->getResponse();
|
||||||
|
|
||||||
for(uInt8 i = 0; i < responseSize; i++)
|
for(size_t i = 0; i < responseSize; ++i)
|
||||||
myRxBuffer[myRxWritePos++] = response[i];
|
myRxBuffer[myRxWritePos++] = response[i];
|
||||||
|
|
||||||
myPendingRequests.erase(iter);
|
myPendingRequests.erase(iter);
|
||||||
|
|
|
@ -38,9 +38,9 @@
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
|
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
|
@ -366,7 +366,7 @@ void Settings::validate()
|
||||||
if(i < -5 || i > 5) setValue("tia.vsizeadjust", 0);
|
if(i < -5 || i > 5) setValue("tia.vsizeadjust", 0);
|
||||||
|
|
||||||
string s = getString("tia.dbgcolors");
|
string s = getString("tia.dbgcolors");
|
||||||
sort(s.begin(), s.end());
|
std::ranges::sort(s);
|
||||||
if(s != "bgopry") setValue("tia.dbgcolors", "roygpb");
|
if(s != "bgopry") setValue("tia.dbgcolors", "roygpb");
|
||||||
|
|
||||||
if(PhosphorHandler::toPhosphorMode(getString(PhosphorHandler::SETTING_MODE)) == PhosphorHandler::ByRom)
|
if(PhosphorHandler::toPhosphorMode(getString(PhosphorHandler::SETTING_MODE)) == PhosphorHandler::ByRom)
|
||||||
|
|
|
@ -181,7 +181,7 @@ void VcsLib::vcsWrite5(uInt8 zpAddress, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void VcsLib::vcsCopyOverblankToRiotRam()
|
void VcsLib::vcsCopyOverblankToRiotRam()
|
||||||
{
|
{
|
||||||
for (uInt8 i = 0; i < OVERBLANK_PROGRAM_SIZE; i++)
|
for (uInt32 i = 0; i < OVERBLANK_PROGRAM_SIZE; ++i)
|
||||||
vcsWrite5(0x80 + i, OVERBLANK_PROGRAM[i]);
|
vcsWrite5(0x80 + i, OVERBLANK_PROGRAM[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -987,9 +987,8 @@ void Dialog::addOKBGroup(WidgetArray& wid, const GUI::Font& font,
|
||||||
VBORDER = Dialog::vBorder(),
|
VBORDER = Dialog::vBorder(),
|
||||||
HBORDER = Dialog::hBorder();
|
HBORDER = Dialog::hBorder();
|
||||||
|
|
||||||
buttonWidth = std::max(buttonWidth,
|
buttonWidth = std::max({buttonWidth, Dialog::buttonWidth(okText),
|
||||||
std::max(Dialog::buttonWidth(okText),
|
Dialog::buttonWidth("Cancel")});
|
||||||
Dialog::buttonWidth("Cancel")));
|
|
||||||
_w = std::max(HBORDER * 2 + buttonWidth * 2 + BUTTON_GAP, _w);
|
_w = std::max(HBORDER * 2 + buttonWidth * 2 + BUTTON_GAP, _w);
|
||||||
|
|
||||||
addOKWidget(new ButtonWidget(this, font, (_w - buttonWidth) / 2,
|
addOKWidget(new ButtonWidget(this, font, (_w - buttonWidth) / 2,
|
||||||
|
@ -1007,10 +1006,10 @@ void Dialog::addOKCancelBGroup(WidgetArray& wid, const GUI::Font& font,
|
||||||
VBORDER = Dialog::vBorder(),
|
VBORDER = Dialog::vBorder(),
|
||||||
HBORDER = Dialog::hBorder();
|
HBORDER = Dialog::hBorder();
|
||||||
|
|
||||||
buttonWidth = std::max(buttonWidth,
|
buttonWidth = std::max({buttonWidth,
|
||||||
std::max(Dialog::buttonWidth("Defaults"),
|
Dialog::buttonWidth("Defaults"),
|
||||||
std::max(Dialog::buttonWidth(okText),
|
Dialog::buttonWidth(okText),
|
||||||
Dialog::buttonWidth(cancelText))));
|
Dialog::buttonWidth(cancelText)});
|
||||||
|
|
||||||
_w = std::max(HBORDER * 2 + buttonWidth * 2 + BUTTON_GAP, _w);
|
_w = std::max(HBORDER * 2 + buttonWidth * 2 + BUTTON_GAP, _w);
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,8 @@ void EditableWidget::setText(string_view str, bool changed)
|
||||||
_caretPos = static_cast<int>(_editString.size());
|
_caretPos = static_cast<int>(_editString.size());
|
||||||
_selectSize = 0;
|
_selectSize = 0;
|
||||||
|
|
||||||
_editScrollOffset = (_font.getStringWidth(_editString) - (getEditRect().w()));
|
_editScrollOffset = std::max<int>(0,
|
||||||
if (_editScrollOffset < 0)
|
_font.getStringWidth(_editString) - getEditRect().w());
|
||||||
_editScrollOffset = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -424,8 +423,8 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
|
||||||
if(handled)
|
if(handled)
|
||||||
{
|
{
|
||||||
// Put caret at last difference
|
// Put caret at last difference
|
||||||
myUndoHandler->lastDiff(_editString, oldString);
|
UndoHandler::lastDiff(_editString, oldString);
|
||||||
setCaretPos(myUndoHandler->lastDiff(_editString, oldString));
|
setCaretPos(UndoHandler::lastDiff(_editString, oldString));
|
||||||
_selectSize = 0;
|
_selectSize = 0;
|
||||||
sendCommand(EditableWidget::kChangedCmd, key, _id);
|
sendCommand(EditableWidget::kChangedCmd, key, _id);
|
||||||
}
|
}
|
||||||
|
@ -583,9 +582,7 @@ bool EditableWidget::adjustOffset()
|
||||||
if (strWidth - _editScrollOffset < editWidth)
|
if (strWidth - _editScrollOffset < editWidth)
|
||||||
{
|
{
|
||||||
// scroll right
|
// scroll right
|
||||||
_editScrollOffset = (strWidth - editWidth);
|
_editScrollOffset = std::max(strWidth - editWidth, 0);
|
||||||
if (_editScrollOffset < 0)
|
|
||||||
_editScrollOffset = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,7 @@ const FavoritesManager::UserList& FavoritesManager::userList() const
|
||||||
sortedList.assign(myUserSet.begin(), myUserSet.end());
|
sortedList.assign(myUserSet.begin(), myUserSet.end());
|
||||||
|
|
||||||
if(!mySettings.getBool("altsorting"))
|
if(!mySettings.getBool("altsorting"))
|
||||||
std::sort(sortedList.begin(), sortedList.end(),
|
std::ranges::sort(sortedList, [](string_view a, string_view b)
|
||||||
[](string_view a, string_view b)
|
|
||||||
{
|
{
|
||||||
// Sort without path
|
// Sort without path
|
||||||
const FSNode aNode(a);
|
const FSNode aNode(a);
|
||||||
|
@ -221,7 +220,7 @@ void FavoritesManager::addRecent(string_view path)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool FavoritesManager::removeRecent(string_view path)
|
bool FavoritesManager::removeRecent(string_view path)
|
||||||
{
|
{
|
||||||
auto it = std::find(myRecentList.begin(), myRecentList.end(), path);
|
auto it = std::ranges::find(myRecentList, path);
|
||||||
|
|
||||||
if(it != myRecentList.end())
|
if(it != myRecentList.end())
|
||||||
myRecentList.erase(it);
|
myRecentList.erase(it);
|
||||||
|
@ -246,8 +245,7 @@ const FavoritesManager::RecentList& FavoritesManager::recentList() const
|
||||||
{
|
{
|
||||||
sortedList.assign(myRecentList.begin(), myRecentList.end());
|
sortedList.assign(myRecentList.begin(), myRecentList.end());
|
||||||
|
|
||||||
std::sort(sortedList.begin(), sortedList.end(),
|
std::ranges::sort(sortedList, [](string_view a, string_view b)
|
||||||
[](string_view a, string_view b)
|
|
||||||
{
|
{
|
||||||
// Sort alphabetical, without path
|
// Sort alphabetical, without path
|
||||||
const FSNode aNode(a);
|
const FSNode aNode(a);
|
||||||
|
@ -324,8 +322,7 @@ FavoritesManager::sortedPopularList(bool sortByName) const
|
||||||
sortedList.clear();
|
sortedList.clear();
|
||||||
sortedList.assign(myPopularMap.begin(), myPopularMap.end());
|
sortedList.assign(myPopularMap.begin(), myPopularMap.end());
|
||||||
|
|
||||||
std::sort(sortedList.begin(), sortedList.end(),
|
std::ranges::sort(sortedList, [sortByName](const PopularType& a, const PopularType& b)
|
||||||
[sortByName](const PopularType& a, const PopularType& b)
|
|
||||||
{
|
{
|
||||||
// 1. sort by most popular
|
// 1. sort by most popular
|
||||||
if(!sortByName && a.second != b.second)
|
if(!sortByName && a.second != b.second)
|
||||||
|
|
|
@ -141,17 +141,14 @@ void ListWidget::setHighlighted(int item)
|
||||||
const string& ListWidget::getSelectedString() const
|
const string& ListWidget::getSelectedString() const
|
||||||
{
|
{
|
||||||
return (_selectedItem >= 0 && _selectedItem < static_cast<int>(_list.size()))
|
return (_selectedItem >= 0 && _selectedItem < static_cast<int>(_list.size()))
|
||||||
? _list[_selectedItem] : EmptyString;
|
? _list[_selectedItem]
|
||||||
|
: EmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ListWidget::scrollTo(int item)
|
void ListWidget::scrollTo(int item)
|
||||||
{
|
{
|
||||||
const int size = static_cast<int>(_list.size());
|
item = BSPF::clamp(item, 0, static_cast<int>(_list.size() - 1));
|
||||||
if (item >= size)
|
|
||||||
item = size - 1;
|
|
||||||
if (item < 0)
|
|
||||||
item = 0;
|
|
||||||
|
|
||||||
if(_currentPos != item)
|
if(_currentPos != item)
|
||||||
{
|
{
|
||||||
|
@ -178,14 +175,8 @@ void ListWidget::recalc()
|
||||||
else
|
else
|
||||||
_currentPos = size - _rows;
|
_currentPos = size - _rows;
|
||||||
}
|
}
|
||||||
if (_currentPos < 0)
|
_currentPos = std::max(_currentPos, 0);
|
||||||
_currentPos = 0;
|
_selectedItem = BSPF::clamp(_selectedItem, 0, size - 1);
|
||||||
|
|
||||||
if(_selectedItem >= size)
|
|
||||||
_selectedItem = size - 1;
|
|
||||||
if(_selectedItem < 0)
|
|
||||||
_selectedItem = 0;
|
|
||||||
|
|
||||||
_editMode = false;
|
_editMode = false;
|
||||||
|
|
||||||
if(_useScrollbar)
|
if(_useScrollbar)
|
||||||
|
@ -351,16 +342,12 @@ bool ListWidget::handleEvent(Event::Type e)
|
||||||
|
|
||||||
case Event::UIPgUp:
|
case Event::UIPgUp:
|
||||||
case Event::UILeft:
|
case Event::UILeft:
|
||||||
_selectedItem -= _rows - 1;
|
_selectedItem = std::max(_selectedItem - (_rows - 1), 0);
|
||||||
if (_selectedItem < 0)
|
|
||||||
_selectedItem = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::UIPgDown:
|
case Event::UIPgDown:
|
||||||
case Event::UIRight:
|
case Event::UIRight:
|
||||||
_selectedItem += _rows - 1;
|
_selectedItem = std::min(_selectedItem + (_rows - 1), size - 1);
|
||||||
if (_selectedItem >= size)
|
|
||||||
_selectedItem = size - 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::UIHome:
|
case Event::UIHome:
|
||||||
|
|
|
@ -244,8 +244,8 @@ bool RomImageWidget::getImageList(const string& propName, const string& romName,
|
||||||
|
|
||||||
// Sort again, not considering extensions, else <filename.png|jpg> would be at
|
// Sort again, not considering extensions, else <filename.png|jpg> would be at
|
||||||
// the end of the list
|
// the end of the list
|
||||||
std::sort(myImageList.begin(), myImageList.end(),
|
std::ranges::sort(myImageList, [oldFileName]
|
||||||
[oldFileName](const FSNode& node1, const FSNode& node2)
|
(const FSNode& node1, const FSNode& node2)
|
||||||
{
|
{
|
||||||
const int compare = BSPF::compareIgnoreCase(
|
const int compare = BSPF::compareIgnoreCase(
|
||||||
node1.getNameWithExt(), node2.getNameWithExt());
|
node1.getNameWithExt(), node2.getNameWithExt());
|
||||||
|
@ -395,9 +395,9 @@ void RomImageWidget::zoomSurfaces(bool zoomed, bool force)
|
||||||
const Int32 lh = maxSize.h - b * 2;
|
const Int32 lh = maxSize.h - b * 2;
|
||||||
const Int32 iw = mySrcRect.w() * scaleDpi;
|
const Int32 iw = mySrcRect.w() * scaleDpi;
|
||||||
const Int32 ih = mySrcRect.h() * scaleDpi;
|
const Int32 ih = mySrcRect.h() * scaleDpi;
|
||||||
const float zoom = std::min(1.F, // do not zoom beyond original size
|
const float zoom = std::min({1.F, // do not zoom beyond original size
|
||||||
std::min(static_cast<float>(lw) / iw,
|
static_cast<float>(lw) / iw,
|
||||||
static_cast<float>(lh) / ih));
|
static_cast<float>(lh) / ih});
|
||||||
const Int32 w = iw * zoom;
|
const Int32 w = iw * zoom;
|
||||||
const Int32 h = ih * zoom;
|
const Int32 h = ih * zoom;
|
||||||
|
|
||||||
|
|
|
@ -184,15 +184,10 @@ void ScrollBarWidget::handleMouseMoved(int x, int y)
|
||||||
|
|
||||||
if(_draggingPart == Part::Slider)
|
if(_draggingPart == Part::Slider)
|
||||||
{
|
{
|
||||||
|
_sliderPos = BSPF::clamp(y - _sliderDeltaMouseDownPos,
|
||||||
|
_upDownBoxHeight, _h - _upDownBoxHeight - _sliderHeight);
|
||||||
|
|
||||||
const int old_pos = _currentPos;
|
const int old_pos = _currentPos;
|
||||||
_sliderPos = y - _sliderDeltaMouseDownPos;
|
|
||||||
|
|
||||||
if(_sliderPos < _upDownBoxHeight)
|
|
||||||
_sliderPos = _upDownBoxHeight;
|
|
||||||
|
|
||||||
if(_sliderPos > _h - _upDownBoxHeight - _sliderHeight)
|
|
||||||
_sliderPos = _h - _upDownBoxHeight - _sliderHeight;
|
|
||||||
|
|
||||||
_currentPos = (_sliderPos - _upDownBoxHeight) * (_numEntries - _entriesPerPage) /
|
_currentPos = (_sliderPos - _upDownBoxHeight) * (_numEntries - _entriesPerPage) /
|
||||||
(_h - 2 * _upDownBoxHeight - _sliderHeight);
|
(_h - 2 * _upDownBoxHeight - _sliderHeight);
|
||||||
checkBounds(old_pos);
|
checkBounds(old_pos);
|
||||||
|
@ -256,14 +251,12 @@ void ScrollBarWidget::recalc()
|
||||||
|
|
||||||
if(_numEntries > _entriesPerPage)
|
if(_numEntries > _entriesPerPage)
|
||||||
{
|
{
|
||||||
_sliderHeight = (_h - 2 * _upDownBoxHeight) * _entriesPerPage / _numEntries;
|
_sliderHeight = std::max(_upDownBoxHeight,
|
||||||
if(_sliderHeight < _upDownBoxHeight)
|
(_h - 2 * _upDownBoxHeight) * _entriesPerPage / _numEntries);
|
||||||
_sliderHeight = _upDownBoxHeight;
|
|
||||||
|
|
||||||
_sliderPos = _upDownBoxHeight + (_h - 2 * _upDownBoxHeight - _sliderHeight) *
|
_sliderPos = std::max(0,
|
||||||
_currentPos / (_numEntries - _entriesPerPage);
|
_upDownBoxHeight + (_h - 2 * _upDownBoxHeight - _sliderHeight) *
|
||||||
if(_sliderPos < 0)
|
_currentPos / (_numEntries - _entriesPerPage));
|
||||||
_sliderPos = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -309,10 +302,9 @@ void ScrollBarWidget::drawWidget(bool hilite)
|
||||||
if(!isSinglePage)
|
if(!isSinglePage)
|
||||||
{
|
{
|
||||||
// align slider to scroll intervals
|
// align slider to scroll intervals
|
||||||
int alignedPos = _upDownBoxHeight + (_h - 2 * _upDownBoxHeight - _sliderHeight) *
|
const int alignedPos = std::max(0,
|
||||||
_currentPos / (_numEntries - _entriesPerPage);
|
_upDownBoxHeight + (_h - 2 * _upDownBoxHeight - _sliderHeight) *
|
||||||
if(alignedPos < 0)
|
_currentPos / (_numEntries - _entriesPerPage));
|
||||||
alignedPos = 0;
|
|
||||||
|
|
||||||
s.fillRect(_x + 1, _y + alignedPos - 1, _w - 2, _sliderHeight + 2,
|
s.fillRect(_x + 1, _y + alignedPos - 1, _w - 2, _sliderHeight + 2,
|
||||||
(hilite && _part == Part::Slider) ? kScrollColorHi : kScrollColor);
|
(hilite && _part == Part::Slider) ? kScrollColorHi : kScrollColor);
|
||||||
|
|
|
@ -81,14 +81,12 @@ int TabWidget::addTab(string_view title, int tabWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tabWidth == NO_WIDTH)
|
if(tabWidth == NO_WIDTH)
|
||||||
if(_tabWidth < newWidth)
|
_tabWidth = std::max(_tabWidth, newWidth);
|
||||||
_tabWidth = newWidth;
|
|
||||||
|
|
||||||
if(numTabs - fixedTabs)
|
if(numTabs - fixedTabs)
|
||||||
{
|
{
|
||||||
const int maxWidth = (_w - kTabLeftOffset - fixedWidth) / (numTabs - fixedTabs) - kTabLeftOffset;
|
const int maxWidth = (_w - kTabLeftOffset - fixedWidth) / (numTabs - fixedTabs) - kTabLeftOffset;
|
||||||
if(_tabWidth > maxWidth)
|
_tabWidth = std::min(_tabWidth, maxWidth);
|
||||||
_tabWidth = maxWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate the new tab
|
// Activate the new tab
|
||||||
|
|
|
@ -157,7 +157,7 @@ void ToolTip::show(string_view tip)
|
||||||
{
|
{
|
||||||
string leftStr, rightStr;
|
string leftStr, rightStr;
|
||||||
|
|
||||||
surface()->splitString(*myFont, inStr, maxWidth, leftStr, rightStr);
|
FBSurface::splitString(*myFont, inStr, maxWidth, leftStr, rightStr);
|
||||||
width = std::max(width, static_cast<uInt32>(myFont->getStringWidth(leftStr)));
|
width = std::max(width, static_cast<uInt32>(myFont->getStringWidth(leftStr)));
|
||||||
inStr = rightStr;
|
inStr = rightStr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
run-clang-tidy-18 -header-filter=\(.*\.hxx\) \
|
run-clang-tidy-19 -header-filter=\(.*\.hxx\) \
|
||||||
-checks=*,\
|
-checks=*,\
|
||||||
-abseil*,\
|
-abseil*,\
|
||||||
-altera*,\
|
-altera*,\
|
||||||
-android*,\
|
-android*,\
|
||||||
-fuchsia*,\
|
-fuchsia*,\
|
||||||
-llvmlibc-inline-function-decl,\
|
-llvmlibc-inline-function-decl,\
|
||||||
|
-boost-use-ranges,\
|
||||||
-bugprone-assignment-in-if-condition,\
|
-bugprone-assignment-in-if-condition,\
|
||||||
-bugprone-branch-clone,\
|
-bugprone-branch-clone,\
|
||||||
-bugprone-easily-swappable-parameters,\
|
-bugprone-easily-swappable-parameters,\
|
||||||
|
@ -15,6 +16,7 @@ run-clang-tidy-18 -header-filter=\(.*\.hxx\) \
|
||||||
-cert-dcl37-c,\
|
-cert-dcl37-c,\
|
||||||
-cert-dcl51-cpp,\
|
-cert-dcl51-cpp,\
|
||||||
-cert-err58-cpp,\
|
-cert-err58-cpp,\
|
||||||
|
-cert-int09-c,\
|
||||||
-clang-analyzer-cplusplus.NewDeleteLeaks,\
|
-clang-analyzer-cplusplus.NewDeleteLeaks,\
|
||||||
-clang-analyzer-optin.performance.Padding,\
|
-clang-analyzer-optin.performance.Padding,\
|
||||||
-cppcoreguidelines-avoid-c-arrays,\
|
-cppcoreguidelines-avoid-c-arrays,\
|
||||||
|
@ -60,6 +62,7 @@ run-clang-tidy-18 -header-filter=\(.*\.hxx\) \
|
||||||
-modernize-avoid-bind,\
|
-modernize-avoid-bind,\
|
||||||
-modernize-avoid-c-arrays,\
|
-modernize-avoid-c-arrays,\
|
||||||
-modernize-pass-by-value,\
|
-modernize-pass-by-value,\
|
||||||
|
-modernize-use-designated-initializers,\
|
||||||
-modernize-use-equals-delete,\
|
-modernize-use-equals-delete,\
|
||||||
-modernize-use-nodiscard,\
|
-modernize-use-nodiscard,\
|
||||||
-modernize-use-trailing-return-type,\
|
-modernize-use-trailing-return-type,\
|
||||||
|
@ -67,11 +70,13 @@ run-clang-tidy-18 -header-filter=\(.*\.hxx\) \
|
||||||
-readability-avoid-unconditional-preprocessor-if,\
|
-readability-avoid-unconditional-preprocessor-if,\
|
||||||
-readability-braces-around-statements,\
|
-readability-braces-around-statements,\
|
||||||
-readability-else-after-return,\
|
-readability-else-after-return,\
|
||||||
|
-readability-enum-initial-value,\
|
||||||
-readability-function-cognitive-complexity,\
|
-readability-function-cognitive-complexity,\
|
||||||
-readability-identifier-length,\
|
-readability-identifier-length,\
|
||||||
-readability-implicit-bool-conversion,\
|
-readability-implicit-bool-conversion,\
|
||||||
-readability-isolate-declaration,\
|
-readability-isolate-declaration,\
|
||||||
-readability-magic-numbers,\
|
-readability-magic-numbers,\
|
||||||
|
-readability-math-missing-parentheses,\
|
||||||
-readability-named-parameter,\
|
-readability-named-parameter,\
|
||||||
-readability-redundant-access-specifiers,\
|
-readability-redundant-access-specifiers,\
|
||||||
-readability-simplify-boolean-expr,\
|
-readability-simplify-boolean-expr,\
|
||||||
|
|
Loading…
Reference in New Issue