Skip to content

Commit

Permalink
Merge pull request #343 from adamfowleruk/develop
Browse files Browse the repository at this point in the history
Translation catkey and build fixes
  • Loading branch information
adamfowleruk authored Dec 30, 2019
2 parents f21059c + 48aa5ad commit 11dc4af
Show file tree
Hide file tree
Showing 21 changed files with 492 additions and 462 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ libpaladin.so
*.gcda
*.gcno
*.info
*.bbg
*.bb
*.da
Tests/out
Paladin/Templates/Sample\ VerticalSlider/VerticalSlider
Paladin/Templates/Sample\ AwesomeSaver/AwesomeSaver
Expand Down
15 changes: 10 additions & 5 deletions Paladin/BuildSystem/CompileCommandWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@
* Authors:
* Adam Fowler, adamfowleruk@gmail.com
*/
#include "CompileCommandWriter.h"

#include <sstream>
#include <vector>
#include <iterator>

#include "CompileCommandWriter.h"
#include "CompileCommand.h"

int
CompileCommandWriter::ToJSONFile(std::ostream& oss,std::vector<CompileCommand>& commands)
{
bool first = true;
oss << "[" << std::endl;
for (auto& command: commands)
// C++11: for (auto& cmd: commands)
for (std::vector<CompileCommand>::iterator iter = commands.begin();iter < commands.end();iter++)
{
CompileCommand cmd = *iter;

if (!first)
{
oss << "," << std::endl;
}
oss << " { \"directory:\": \"" << command.directory << "\"," << std::endl;
oss << " \"command\": \"" << command.command << "\"," << std::endl;
oss << " \"file\": \"" << command.file << "\" }"; // leave for comma or endl
oss << " { \"directory:\": \"" << cmd.directory << "\"," << std::endl;
oss << " \"command\": \"" << std::string(cmd.command) << "\"," << std::endl;
oss << " \"file\": \"" << cmd.file << "\" }"; // leave for comma or endl
first = false;
}
oss << std::endl << "]" << std::endl; // start with endl to finish last json object line
Expand Down
11 changes: 10 additions & 1 deletion Paladin/BuildSystem/ProjectBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ ProjectBuilder::DoPostBuild(void)
jsonFile += std::string("/compile_commands.json");
STRACE(1,("Writing out compile commands\n"));
STRACE(1,(jsonFile.c_str()));
std::ofstream ofs(jsonFile, std::ofstream::out);
std::ofstream ofs(jsonFile.c_str(), std::ofstream::out);
CompileCommandWriter::ToJSONFile(ofs,fCommands);

// It's really silly to try to run a library! ;-)
Expand Down Expand Up @@ -405,11 +405,20 @@ ProjectBuilder::BuildThread(void *data)
return B_OK;
}

((ProjectBuilder*)data)->fCommands.push_back(
CompileCommand(
std::string(file->GetPath().GetFileName()),
std::string(file->GetCompileCommand(*proj->GetBuildInfo(),NULL).String()),
std::string(proj->GetBuildInfo()->objectFolder.GetFullPath())
)
);
/*
((ProjectBuilder*)data)->fCommands.emplace_back(
std::string(file->GetPath().GetFileName()),
std::string(file->GetCompileCommand(*proj->GetBuildInfo(),NULL).String()),
std::string(proj->GetBuildInfo()->objectFolder.GetFullPath())
);
*/

proj->CompileFile(file);

Expand Down
2 changes: 1 addition & 1 deletion Paladin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ OPTIMIZE := SOME
# will recreate only the "locales/en.catkeys" file. Use it as a template
# for creating catkeys for other languages. All localization files must be
# placed in the "locales" subdirectory.
LOCALES = de en es it pt ro fr en_GB hr sv
LOCALES = de en

# Specify all the preprocessor symbols to be defined. The symbols will not
# have their values set automatically; you must supply the value (if any) to
Expand Down
65 changes: 33 additions & 32 deletions Paladin/Paladin.pld

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions Paladin/PreviewFeatures/MonitorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ MonitorWindow::AddView(MonitorViewInfo info)
info.view = v;

// Add view
fViews.emplace_back(info); // invokes copy constructor
//fViews.emplace_back(info); // invokes copy constructor
fViews.push_back(MonitorViewInfo(info));
// Show view in tab view
fTabView->AddTab(info.view);
} else {
Expand All @@ -120,7 +121,8 @@ void
MonitorWindow::Launch(BMessage* commandMessage, const char* stdoutViewName, const char* stderrViewName)
{
uint32 ctxId = fNextContextId++;
void* ctx = new CommandContext{ctxId,commandMessage,strdup(stdoutViewName),strdup(stderrViewName)};
void* ctx = new CommandContext(ctxId,commandMessage,strdup(stdoutViewName),strdup(stderrViewName));


// Make this tab visible
/*
Expand Down Expand Up @@ -164,8 +166,10 @@ MonitorWindow::ReceiveError(BMessage* threadMessage)
MonitorViewInfo*
MonitorWindow::FindInfo(const char* name)
{
for (auto& info: fViews)
// C++11 for (auto& info: fViews)
for (std::vector<MonitorViewInfo>::iterator iter = fViews.begin();iter < fViews.end();iter++)
{
MonitorViewInfo info = *iter;
printf("Testing view with name:-\n");
printf(info.name);
printf("\n");
Expand All @@ -174,7 +178,7 @@ MonitorWindow::FindInfo(const char* name)
printf("\n");
if (0 == strcmp(info.name,name))
{
return &info;
return &*iter;
}
}
return NULL;
Expand Down
15 changes: 11 additions & 4 deletions Paladin/PreviewFeatures/MonitorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ enum
struct MonitorViewInfo
{
public:
const char* name = "";
const char* title = "";
bool visible = true;
BView* view = NULL;
const char* name;
const char* title;
bool visible;
BView* view;
MonitorViewInfo(const char* n,const char* t,const bool b,BView* v)
: name(n), title(t), visible(b), view(v){}

Expand All @@ -45,6 +45,13 @@ struct CommandContext
BMessage* commandMessage;
const char* stdoutViewName;
const char* stderrViewName;
CommandContext(uint32 tid,BMessage* tmsg,const char* tstdoutViewName,const char* tstderrViewName)
:
id(tid),
commandMessage(tmsg),
stdoutViewName(tstdoutViewName),
stderrViewName(tstderrViewName)
{}
};

class MonitorWindow : public BWindow
Expand Down
6 changes: 3 additions & 3 deletions Paladin/ProjectWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,9 +1342,9 @@ ProjectWindow::EnsureMonitorWindow()
const char* tsb = B_TRANSLATE("Build");
const char* tso = B_TRANSLATE("Standard Out");
const char* tse = B_TRANSLATE("Standard Error");
MonitorViewInfo miBuild = {bo,tsb};
MonitorViewInfo miOut = {so,tso};
MonitorViewInfo miErr = {se,tse};
MonitorViewInfo miBuild(bo,tsb);
MonitorViewInfo miOut(so,tso);
MonitorViewInfo miErr(se,tse);
fMonitorWindow->AddView(miBuild);
fMonitorWindow->AddView(miOut);
fMonitorWindow->AddView(miErr);
Expand Down
8 changes: 3 additions & 5 deletions Paladin/QuickFindWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/
#include "QuickFindWindow.h"

#include <locale>
#include <string>

#include <Application.h>
Expand Down Expand Up @@ -541,7 +540,7 @@ QuickFindWindow::DoSearchDirectory(const char* text, BMessage* reply,BEntry& dir
BDirectory dir(&dirEntry);
if (B_OK != dir.InitCheck())
{
printf(B_TRANSLATE("Directory InitCheck failed\n"));
printf(B_TRANSLATE("Directory Init Check failed\n"));
return;
}
dir.Rewind();
Expand Down Expand Up @@ -582,12 +581,11 @@ QuickFindWindow::DoSearchFile(const char* text, BMessage* reply,BEntry& entry)
matches = true;
} else if (strlen(text) < 10) {
// Grab filename capitals, lowercase them, and see if it matches
std::locale loc;
char caps[20];
int idx = 0;
for (int sIdx = 0;sIdx < strlen(entryName) && idx < 20;sIdx++)
{
if (std::isupper(entryName[sIdx],loc))
if (isupper(entryName[sIdx]))
{
caps[idx++] = entryName[sIdx];
}
Expand All @@ -596,7 +594,7 @@ QuickFindWindow::DoSearchFile(const char* text, BMessage* reply,BEntry& entry)
char textCaps[strlen(text)];
for (int tci = 0;tci < strlen(text);tci++)
{
textCaps[tci] = std::toupper(text[tci],loc);
textCaps[tci] = toupper(text[tci]);
}
textCaps[strlen(text)] = '\0';
STRACE(1,("Caps follows\n"));
Expand Down
Loading

0 comments on commit 11dc4af

Please sign in to comment.