Created
November 5, 2012 22:08
-
-
Save dimitarcl/4020713 to your computer and use it in GitHub Desktop.
Brackets in Coherent UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appshell.fs.readdir = function (path, callback) { | |
var resultString = engine.Call('ReadDir', path, wrapCallback(callback)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appshell.app.getApplicationSupportDirectory = function () { | |
return appshell.app.applicationSupportDirectory; | |
} | |
appshell.app.applicationSupportDirectory = '.'; | |
engine.on('SetApplicationSupportDirectory', function (directory) { | |
appshell.app.applicationSupportDirectory = directory; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="underscore-min.js"></script> | |
<script src="backbone-min.js"></script> | |
<script src="coherent.js"></script> | |
<script src="brackets_extensions.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<std::string> Brackets::ReadDir(const std::string& path) | |
{ | |
boost::system::error_code error; | |
boost::filesystem::directory_iterator entry(path, error); | |
boost::filesystem::directory_iterator end; | |
std::vector<std::string> entries; | |
if (!error) | |
{ | |
std::vector<std::string> files; | |
while (entry != end) | |
{ | |
if (entry->status().type() == boost::filesystem::directory_file) | |
{ | |
entries.push_back(entry->path().leaf().string()); | |
} | |
else | |
{ | |
files.push_back(entry->path().leaf().string()); | |
} | |
++entry; | |
} | |
entries.reserve(entries.size() + files.size()); | |
std::copy(files.begin(), files.end(), std::back_inserter(entries)); | |
} | |
else | |
{ | |
m_View->SetScriptError(Coherent::UI::SCE_NoResult, ToBracketsError(error)); | |
} | |
return entries; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Brackets::RegisterBindings(Coherent::UI::View* view) | |
{ | |
view->BindCall("OpenLiveBrowser", Coherent::UI::MakeHandler(this, &Brackets::OpenLiveBrowser)); | |
view->BindCall("CloseLiveBrowser", Coherent::UI::MakeHandler(this, &Brackets::CloseLiveBrowser)); | |
view->BindCall("ShowOpenDialog", Coherent::UI::MakeHandler(this, &Brackets::ShowOpenDialog)); | |
view->BindCall("ReadDir", Coherent::UI::MakeHandler(this, &Brackets::ReadDir)); | |
view->BindCall("MakeDir", Coherent::UI::MakeHandler(this, &Brackets::MakeDir)); | |
view->BindCall("Rename", Coherent::UI::MakeHandler(this, &Brackets::Rename)); | |
view->BindCall("GetFileModificationTime", Coherent::UI::MakeHandler(this, &Brackets::GetFileModificationTime)); | |
view->BindCall("ReadFile", Coherent::UI::MakeHandler(this, &Brackets::ReadFile)); | |
view->BindCall("WriteFile", Coherent::UI::MakeHandler(this, &Brackets::WriteFile)); | |
view->BindCall("SetPosixPermissions", Coherent::UI::MakeHandler(this, &Brackets::SetPosixPermissions)); | |
view->BindCall("DeleteFileOrDirectory", Coherent::UI::MakeHandler(this, &Brackets::DeleteFileOrDirectory)); | |
view->BindCall("ShowDeveloperTools", Coherent::UI::MakeHandler(this, &Brackets::ShowDeveloperTools)); | |
view->BindCall("AbortQuit", Coherent::UI::MakeHandler(this, &Brackets::AbortQuit)); | |
view->BindCall("OpenURLInDefaultBrowser", Coherent::UI::MakeHandler(this, &Brackets::OpenURLInDefaultBrowser)); | |
view->BindCall("ShowOSFolder", Coherent::UI::MakeHandler(this, &Brackets::ShowOSFolder)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Brackets::RegisterBindings(Coherent::UI::View* view) | |
{ | |
// ... | |
boost::filesystem::path path(GetExecutableDirectory()); | |
path /= "www"; | |
view->TriggerEvent("SetApplicationSupportDirectory", path.string()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment