-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/extensions/manager #408
base: main
Are you sure you want to change the base?
Conversation
extension.ShowInToolsMenu = msg.GetBool("ShowInToolsMenu", false); | ||
extension.ShowInContextMenu = msg.GetBool("ShowInContextMenu", false); | ||
auto shortcut = msg.GetString("Shortcut", ""); | ||
if (shortcut == nullptr || strlen(shortcut) > 1) |
Check notice
Code scanning / Flawfinder (reported by Codacy)
Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). Note
@@ -300,6 +302,17 @@ void | |||
GenioWindow::MessageReceived(BMessage* message) | |||
{ | |||
switch (message->what) { | |||
case MSG_INVOKE_EXTENSION: | |||
{ | |||
printf("window "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf left
case MSG_INVOKE_EXTENSION: | ||
{ | ||
printf("window "); | ||
message->PrintToStream(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrintToStream left
auto context = [&]() { | ||
ExtensionContext context = { | ||
.menuKind = ExtensionToolsMenu, | ||
.editor = fTabManager->CountTabs()>0 ? fTabManager->SelectedEditor() : nullptr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SelectedEditor return null if no tabs are present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before introducing the lambda, it used to crash if no editors were opened. Now it is probably safe to remove the additional check.
|
||
extension.ShowInToolsMenu = msg.GetBool("ShowInToolsMenu", false); | ||
extension.ShowInContextMenu = msg.GetBool("ShowInContextMenu", false); | ||
auto shortcut = msg.GetString("Shortcut", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use BString here, so you can skip the if (nullptr) and avoid using strlen()
{ | ||
BString scope; | ||
int i = 0; | ||
while(msg.FindString("Scope", i, &scope) == B_OK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between while and (
{ | ||
BString fileType; | ||
int i = 0; | ||
while(msg.FindString("FileTypes", i, &fileType) == B_OK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
} else if (strcmp(attrName, "BEOS:APP_SIG") == 0) { | ||
extension.Signature = buf; | ||
// printf("Signature %s\n", extension.Signature.String()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug printf leftovers
|
||
extension.ShowInToolsMenu = msg.GetBool("ShowInToolsMenu", false); | ||
extension.ShowInContextMenu = msg.GetBool("ShowInContextMenu", false); | ||
auto shortcut = msg.GetString("Shortcut", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use BString here, so you can avoid the if (nullptr) and the strlen() call
{ | ||
BString scope; | ||
int i = 0; | ||
while(msg.FindString("Scope", i, &scope) == B_OK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: space between while and (
{ | ||
BString fileType; | ||
int i = 0; | ||
while(msg.FindString("FileTypes", i, &fileType) == B_OK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
extension.LongDescription = BString(buf+5*sizeof(uint32)+64, 256); | ||
// printf("version %s\n", extension.Version.String()); | ||
// printf("ShortDescription %s\n", extension.ShortDescription.String()); | ||
// printf("LongDescription %s\n", extension.LongDescription.String()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
various debug leftovers
(context.projectItem != nullptr && | ||
std::count(extension.Scope.begin(), extension.Scope.end(), "ProjectBrowser"))) { | ||
auto filePath = context.editor->FilePath(); | ||
for(auto& ft: extension.FileTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between for and (
This PR enables the ExtensionManager and the tools and context menus in Editors and the ProjectBrowser. Currently it implements only extensions type "Script"