Skip to content

Commit

Permalink
Merge branch 'main' into fix/consoleio-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Freaxed authored Dec 19, 2024
2 parents a38cdda + ab2f72d commit 34bc4f3
Show file tree
Hide file tree
Showing 14 changed files with 503 additions and 1,779 deletions.
5 changes: 5 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ v4.0 (development)
- Improved search panel. Now you can also search in non-active projects.
- Improved run toolbar.
- Improved build indicator.
- Updated documentation (Humdinger).
- Added a status bar to show build status.
- Added option for smaller icons, and made icons scale with font size.
- Added menu to select the active project.
- Added new stylable Console I/O.
- Remove some useless toolbar icons.
- Improved handling of appearance settings.
- ProjectBrowser: added handling of DEL key to delete files.
- Improve confusing alert name when creating a new branch.
- Editor status bar: use a fixed font.
- Avoid converting end lines when opening files.
- Fixed concurrency issue which could cause settings corruption.
- Fixed selecting collapsed items in Config window.
- Fixed ReplaceFindPrevious/Next for real.
- Fixed ProjectBrowser losing focus after renaming a file.
- Fixed build and missing resources when building Genio with Clang.
- Fixed possible memory corruption issues in git clone code path.
- Fixed some small memory leaks.
- Removed "Default" button in project settings.
---
v3.1
Expand Down
1,716 changes: 90 additions & 1,626 deletions Genio.rdef

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions src/GenioApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ GenioApp::GenioApp()
fExtensionManager = new ExtensionManager();

fGenioWindow = new GenioWindow(BRect(gCFG["ui_bounds"]));
fGenioWindow->MoveOnScreen();
}


Expand Down Expand Up @@ -185,8 +186,14 @@ GenioApp::MessageReceived(BMessage* message)
else if (::strcmp(key, "log_level") == 0)
Logger::SetLevel(log_level(int32(gCFG["log_level"])));
}
gCFG.SaveToFile({fConfigurationPath});
LogInfo("Configuration file saved! (updating %s)", message->GetString("key", "ERROR!"));
BString context = message->GetString("context", "");
if (context.IsEmpty() || context.Compare("reset_to_defaults_end") == 0) {
gCFG.SaveToFile({fConfigurationPath});
LogInfo("Configuration file saved! (updating %s)", message->GetString("key", "ERROR!"));
} else {
LogInfo("Configuration updated! (updating %s)", message->GetString("key", "ERROR!"));
}

}
break;
}
Expand Down Expand Up @@ -441,6 +448,20 @@ GenioApp::_PrepareConfig(ConfigManager& cfg)
GMessage zooms = { {"min", -9}, {"max", 19} };
cfg.AddConfig(editorVisual.String(), "editor_zoom", B_TRANSLATE("Editor zoom:"), 0, &zooms);

GMessage console_styles = { {"mode", "options"} };
console_styles["option_1"] = { {"value", 0}, {"label", B_TRANSLATE("(follow system style)") } };
console_styles["option_2"] = { {"value", 1}, {"label", B_TRANSLATE("(follow editor style)") } };
style_index = 3;
for (auto style : allStyles) {
BString opt("option_");
opt << style_index;

console_styles[opt.String()] = { {"value", style_index - 1}, {"label", style.c_str() } };
style_index++;
}
cfg.AddConfig("Console", "console_style", B_TRANSLATE("Console style:"), B_TRANSLATE("(follow system style)"), &console_styles);


BString build(B_TRANSLATE("Build"));
cfg.AddConfig(build.String(), "wrap_console", B_TRANSLATE("Wrap lines in console"), false);
cfg.AddConfig(build.String(), "console_banner", B_TRANSLATE_COMMENT("Console banner",
Expand Down
43 changes: 35 additions & 8 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PermanentStorageProvider {
enum kPSPMode { kPSPReadMode, kPSPWriteMode };

PermanentStorageProvider() {};
virtual ~PermanentStorageProvider(){};
virtual ~PermanentStorageProvider() {};

virtual status_t Open(const BPath& destination, kPSPMode mode) = 0;
virtual status_t Close() = 0;
Expand Down Expand Up @@ -163,6 +163,7 @@ class NoStorePSP : public PermanentStorageProvider {
};


// ConfigManager
ConfigManager::ConfigManager(const int32 messageWhat)
:
fLocker("ConfigManager lock")
Expand All @@ -179,7 +180,16 @@ ConfigManager::~ConfigManager()
for (int32 i = 0; i< kStorageTypeCountNb; i++) {
delete fPSPList[i];
fPSPList[i] = nullptr;
}
}
}


status_t
ConfigManager::FindConfigMessage(const char* name, int32 index,
BMessage* message)
{
BAutolock lock(fLocker);
return fConfiguration.FindMessage(name, index, message);
}


Expand Down Expand Up @@ -209,7 +219,7 @@ ConfigManager::operator[](const char* key) -> ConfigManagerReturn


bool
ConfigManager::HasKey(const char* key)
ConfigManager::HasKey(const char* key) const
{
BAutolock lock(fLocker);
type_code type;
Expand Down Expand Up @@ -243,7 +253,8 @@ ConfigManager::LoadFromFile(std::array<BPath, kStorageTypeCountNb> paths)
if (status == B_OK) {
LogInfo("Config file: loaded value for key [%s] (StorageType %d)", key, storageType);
} else {
LogError("Config file: unable to get valid key [%s] (%s) (StorageType %d)", key, strerror(status), storageType);
LogError("Config file: unable to get valid key [%s] (%s) (StorageType %d)",
key, ::strerror(status), storageType);
}
}
for (int32 i = 0; i < kStorageTypeCountNb; i++) {
Expand Down Expand Up @@ -280,7 +291,8 @@ ConfigManager::SaveToFile(std::array<BPath, kStorageTypeCountNb> paths)
if (status == B_OK) {
LogInfo("Config file: saved value for key [%s] (StorageType %d)", key, storageType);
} else {
LogError("Config file: unable to store valid key [%s] (%s) (StorageType %d)", key, strerror(status), storageType);
LogError("Config file: unable to store valid key [%s] (%s) (StorageType %d)",
key, ::strerror(status), storageType);
}
}
for (int32 i = 0; i < kStorageTypeCountNb; i++) {
Expand All @@ -298,10 +310,24 @@ ConfigManager::ResetToDefaults()
// Will also send notifications for every setting change
GMessage msg;
int32 i = 0;
type_code typeFound;
int32 countFound = 0;
if (fConfiguration.GetInfo("config", &typeFound, &countFound) != B_OK) {
LogError("ResetToDefaults: no config configured!");
return;
}

fNoticeMessage.RemoveData("context");
fNoticeMessage.AddString("context", "reset_to_defaults");
while (fConfiguration.FindMessage("config", i++, &msg) == B_OK) {
if (countFound == i)
fNoticeMessage.ReplaceString("context", "reset_to_defaults_end");

fStorage[msg["key"]] = msg["default_value"]; //to force the key creation
(*this)[msg["key"]] = msg["default_value"]; //to force the update
}

fNoticeMessage.RemoveData("context");
}


Expand All @@ -322,15 +348,16 @@ ConfigManager::HasAllDefaultValues()


void
ConfigManager::PrintAll()
ConfigManager::PrintAll() const
{
BAutolock lock(fLocker);
PrintValues();
fConfiguration.PrintToStream();
}


void
ConfigManager::PrintValues()
ConfigManager::PrintValues() const
{
BAutolock lock(fLocker);
fStorage.PrintToStream();
Expand All @@ -341,7 +368,7 @@ bool
ConfigManager::_CheckKeyIsValid(const char* key) const
{
assert(fLocker.IsLocked());

type_code type;
if (fStorage.GetInfo(key, &type) != B_OK) {
BString detail("No config key: ");
Expand Down
22 changes: 12 additions & 10 deletions src/config/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,20 @@ class ConfigManager {
void ResetToDefaults();
bool HasAllDefaultValues();

void PrintAll();
void PrintValues();
void PrintAll() const;
void PrintValues() const;

auto operator[](const char* key) -> ConfigManagerReturn;

bool HasKey(const char* key);

GMessage& Configuration() { return fConfiguration; }
bool HasKey(const char* key) const;

int32 UpdateMessageWhat() const { return fNoticeMessage.what; }

BMessage* NoticeMessage() { return &fNoticeMessage; }

status_t FindConfigMessage(const char* name, int32 index,
BMessage* message);

private:
friend ConfigManagerReturn;

Expand All @@ -108,16 +109,17 @@ friend ConfigManagerReturn;
GMessage noticeMessage = fNoticeMessage;
noticeMessage["key"] = key;
noticeMessage["value"] = fStorage[key];

if (be_app != nullptr)
be_app->SendNotices(noticeMessage.what, &noticeMessage);
}

private:
GMessage fStorage;
GMessage fConfiguration;
BLocker fLocker;
GMessage fNoticeMessage;
PermanentStorageProvider* fPSPList[kStorageTypeCountNb];
GMessage fStorage; //access must be protected by fLocker
GMessage fConfiguration; //access must be protected by fLocker
mutable BLocker fLocker;
GMessage fNoticeMessage;
PermanentStorageProvider* fPSPList[kStorageTypeCountNb];

bool _CheckKeyIsValid(const char* key) const;
PermanentStorageProvider* CreatePSPByType(StorageType type);
Expand Down
8 changes: 6 additions & 2 deletions src/config/ConfigWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,13 @@ ConfigWindow::MessageReceived(BMessage* message)
GMessage m(kSetValueNoUpdate);
m["key"] = key.String();
control->MessageReceived(&m);
}
}

BString context = message->GetString("context", "");
if (context.IsEmpty() || context.Compare("reset_to_defaults_end") == 0) {
if (fDefaultsButton != nullptr)
fDefaultsButton->SetEnabled(!fConfigManager.HasAllDefaultValues());
}
}
}
break;
Expand All @@ -282,7 +286,7 @@ ConfigWindow::_PopulateListView()
std::vector<GMessage> dividedByGroup;
GMessage msg;
int i = 0;
while (fConfigManager.Configuration().FindMessage("config", i++, &msg) == B_OK) {
while (fConfigManager.FindConfigMessage("config", i++, &msg) == B_OK) {
std::vector<GMessage>::iterator i = dividedByGroup.begin();
while (i != dividedByGroup.end()) {
if (strcmp((*i)["group"], (const char*)msg["group"]) == 0) {
Expand Down
Loading

0 comments on commit 34bc4f3

Please sign in to comment.