+
diff --git a/templates/panel.html b/templates/panel.html
new file mode 100644
index 0000000..0ec312f
--- /dev/null
+++ b/templates/panel.html
@@ -0,0 +1,7 @@
+
diff --git a/templates/shellPanel.html b/templates/shellPanel.html
deleted file mode 100644
index 61c3c20..0000000
--- a/templates/shellPanel.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
diff --git a/templates/tabs.html b/templates/tabs.html
new file mode 100644
index 0000000..77783dc
--- /dev/null
+++ b/templates/tabs.html
@@ -0,0 +1,20 @@
+
diff --git a/tests/index.html b/tests/index.html
new file mode 100644
index 0000000..30245ff
--- /dev/null
+++ b/tests/index.html
@@ -0,0 +1,23 @@
+
+
+
+
+
hdy Brackets Shell Tests
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/shell/shell.tests.js b/tests/shell/shell.tests.js
new file mode 100644
index 0000000..44a205c
--- /dev/null
+++ b/tests/shell/shell.tests.js
@@ -0,0 +1,17 @@
+/* global describe, it, require */
+
+//define(['../shell'], function (Shell) {
+ describe('Shell', function(){
+ describe('#Constructor', function(){
+ it('should create Shell object which is not undefined or null', function(){
+
+ var s = require("");
+ var shell = new Shell();
+
+ shell.should.not.equal(undefined);
+ shell.should.not.equal(null);
+
+ });
+ });
+ });
+//});
diff --git a/vendor/jquery.droptabs.js b/vendor/jquery.droptabs.js
new file mode 100644
index 0000000..ca51ac3
--- /dev/null
+++ b/vendor/jquery.droptabs.js
@@ -0,0 +1,160 @@
+/* Copyright (c) 2014 Alexandru Boboc
+ * Droptabs v.1.1 Jquery Plugin
+ * Tested with JQuery 1.11.1
+ */
+
+(function($) {
+
+ $.fn.droptabs = function(o) {
+
+ //Default options
+ var s = $.extend({
+ dropdownSelector : "li.dropdown",
+ dropdownMenuSelector : "ul.dropdown-menu",
+ dropdownTabsSelector : "li",
+ visibleTabsSelector : ">li:not(.dropdown)",
+ developmentId : "dt-devInfo",
+ autoArrangeTabs : true,
+ development : false
+ }, o);
+
+ return this.each( function( ) {
+
+ var $container = $(this);
+ var dropdown = $(s.dropdownSelector, this);
+ var dropdownMenu = $(s.dropdownMenuSelector, dropdown);
+
+ var $dropdownTabs = function () {
+ return $(s.dropdownTabsSelector, dropdownMenu);
+ }
+
+ var $visibleTabs = function () {
+ return $(s.visibleTabsSelector, $container);
+ }
+
+ function getFirstHiddenElementWidth() {
+ var tempElem=$dropdownTabs().first().clone().appendTo($container).css("position","fixed");
+ var hiddenElementWidth = $(tempElem).outerWidth();
+ $(tempElem).remove();
+ return hiddenElementWidth;
+ }
+
+ function getHiddenElementWidth(elem) {
+ var tempElem=$(elem).clone().appendTo($container).css("position","fixed");
+ var hiddenElementWidth = $(tempElem).outerWidth();
+ $(tempElem).remove();
+ return hiddenElementWidth;
+ }
+
+ function manageActive(elem) {
+ //fixes a bug where Bootstrap can't remove the 'active' class on elements after they've been hidden inside the dropdown
+ $('a', $(elem)).on('show.bs.tab', function (e) {
+ $(e.relatedTarget).parent().removeClass('active');
+ })
+ $('a', $(elem)).on('shown.bs.tab', function (e) {
+ if ($(dropdown).hasClass('active')) {
+ $('>a', dropdown).html(($('>li.active>a', dropdownMenu).html()).substring(0,10) + '...
');
+ } else {
+ $('>a', dropdown).html('Dropdown
');
+ }
+ })
+
+ }
+
+ //Start Development info
+ if ( s.development ) {
+ $('body').append('
');
+ var $developmentDiv = $('#' + s.developmentId);
+ $($developmentDiv).css('position','fixed').css('right','20px').css('bottom','20px');
+ function devPrint(label, elem) {
+ var labelId = label.replace(/\s+/g, '-').toLowerCase();
+ if ($('#'+labelId).length > 0) {
+ $('#'+labelId).text(label + ': ' + elem);
+ } else {
+ $('#dt-devInfo').append('
' + label + ': ' + elem + '
');
+ }
+ return true;
+ }
+ }
+ //End Development info
+
+ var visibleTabsWidth = function () {
+ var visibleTabsWidth = 0;
+ $($visibleTabs()).each(function( index ) {
+ visibleTabsWidth += parseInt($(this).outerWidth(), 10);
+ });
+ visibleTabsWidth = visibleTabsWidth + parseInt($(dropdown).outerWidth(), 10);
+ return visibleTabsWidth;
+ }
+
+ var availableSpace = function () {
+ return $container.outerWidth()-visibleTabsWidth();
+ }
+
+ var arrangeTabs = function () {
+ //Start Development info
+ if ( s.development ) {
+ devPrint("Container width", $container.outerWidth());
+ devPrint("Visible tabs width", visibleTabsWidth());
+ devPrint("Available space", availableSpace());
+ devPrint("First hidden", getFirstHiddenElementWidth());
+ }
+ //End Development info
+
+ if (availableSpace()<0) {//we will hide tabs here
+ var x = availableSpace();
+ $($visibleTabs().get().reverse()).each(function( index ){
+ if (!($(this).hasClass('always-visible'))){
+ $(this).prependTo(dropdownMenu);
+ x=x+$(this).outerWidth();
+ }
+ if (x>=0) {return false;}
+ });
+ }
+
+ if (availableSpace()>getFirstHiddenElementWidth()) { //and here we bring the tabs out
+ var x = availableSpace();
+ $($dropdownTabs()).each(function( index ){
+ if (getHiddenElementWidth(this) < x && !($(this).hasClass('always-dropdown'))){
+ $(this).appendTo($container);
+ x = x-$(this).outerWidth();
+ } else {return false;}
+ });
+ }
+
+ if ($dropdownTabs().length <= 0) {dropdown.hide();} else {dropdown.show();}
+ }
+
+ //init
+
+ if (s.autoArrangeTabs) {
+ var tempTabs = [];
+ $($visibleTabs().get().reverse()).each(function( index ){
+ if ($(this).hasClass('always-visible')) {
+ tempTabs.push($(this));
+ $(this).remove();
+ }
+ });
+ for (var i = 0; i < tempTabs.length; i++ ) {
+ $container.prepend(tempTabs[i]);
+ }
+ }
+
+ $(document).ready(function(){
+ arrangeTabs();
+ $dropdownTabs().each( function() {
+ manageActive($(this));
+ });
+
+ $visibleTabs().each( function() {
+ manageActive($(this));
+ });
+ });
+
+ $( window ).resize(function() {
+ arrangeTabs();
+ });
+ return this;
+ });
+ }
+}(jQuery));
diff --git a/online.js b/vendor/online.js
similarity index 100%
rename from online.js
rename to vendor/online.js
diff --git a/shellPanel.js b/views/shellPanelView.js
similarity index 79%
rename from shellPanel.js
rename to views/shellPanelView.js
index a76d388..edf73ec 100644
--- a/shellPanel.js
+++ b/views/shellPanelView.js
@@ -6,27 +6,53 @@ define(function (require, exports, module) {
"use strict";
var WorkspaceManager = brackets.getModule("view/WorkspaceManager"),
+ Shell = require("shell"),
AppInit = brackets.getModule("utils/AppInit"),
KeyEvent = brackets.getModule("utils/KeyEvent"),
_shellPanelHtml = require("text!templates/shellPanel.html"),
$commandTemplateHtml = $(require("text!templates/commandTemplate.html")),
- ShellPanel = WorkspaceManager.createBottomPanel("hdy.brackets.shell.panel",
+ ShellPanelBottom = WorkspaceManager.createBottomPanel("hdy.brackets.shell.panel",
$(_shellPanelHtml), 100),
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
NodeDomain = brackets.getModule("utils/NodeDomain"),
ShellDomain = new NodeDomain("hdyShellDomain",
ExtensionUtils.getModulePath(module,
- "node/hdyShellDomain")),
+ "../node/shellDomain")),
CommandRoll = [],
CommandRollIndex = -1,
KillProcess = $('.hdy-brackets-shell-kill'),
- ansiFormat = require("shellAnsiFormat"),
_preferencesManager = brackets.getModule("preferences/PreferencesManager"),
_preferences = _preferencesManager.getExtensionPrefs("hdy.brackets-shell"),
PROMPT_TERMINATOR = ">";
+ function ShellPanelView(title, cwd) {
+
+ this.watch('title', function(prop, oldValue, newValue) {
+
+ return newValue;
+ });
+
+ this.watch('cwd', function(prop, oldValue, newValue) {
+ _addShellLine(newValue);
+
+ return newValue;
+ });
+
+ this.shell = new Shell();
+
+ this.shell.kill();
+
+ this.title = title;
+ this.cwd = cwd;
+ }
+
+ ShellPanelView.prototype.toggle = _toggle;
+ ShellPanelView.prototype.show = _show;
+ ShellPanelView.prototype.hide = _hide;
+ ShellPanelView.prototype.isVisible = _isVisible;
+
function _toggle() {
- if (ShellPanel.isVisible()) {
+ if (ShellPanelBottom.isVisible()) {
_hide();
}
else {
@@ -35,7 +61,7 @@ define(function (require, exports, module) {
}
function _show() {
- ShellPanel.show();
+ ShellPanelBottom.show();
$("a.hdy-shell-icon").removeClass("hdy-shell-icon-off");
$("a.hdy-shell-icon").addClass("hdy-shell-icon-on");
_focus();
@@ -44,11 +70,11 @@ define(function (require, exports, module) {
function _hide() {
$("a.hdy-shell-icon").removeClass("hdy-shell-icon-on");
$("a.hdy-shell-icon").addClass("hdy-shell-icon-off");
- ShellPanel.hide();
+ ShellPanelBottom.hide();
}
function _isVisible() {
- return ShellPanel.isVisible();
+ return ShellPanelBottom.isVisible();
}
function _executeCommand(e) {
@@ -148,7 +174,6 @@ define(function (require, exports, module) {
_clearOutput();
});
-
function _clearOutput() {
var commandGroups = $(".hdy-command-groups"),
@@ -180,16 +205,16 @@ define(function (require, exports, module) {
$("pre", currentCommandResult).addClass('hdy-dark-theme');
}
- if(ansiFormat.hasAceptedAnsiFormat(data)){
- ansiFormat.formattedText(data, currentCommandResult);
- } else {
- for (var i = 0; i < data.length; i++) {
- if (data.charCodeAt(i) === 65533) {
- data = replaceCharAtIndex(data, i, ".");
- }
- }
+// if(ansiFormat.hasAceptedAnsiFormat(data)){
+// ansiFormat.formattedText(data, currentCommandResult);
+// } else {
+// for (var i = 0; i < data.length; i++) {
+// if (data.charCodeAt(i) === 65533) {
+// data = replaceCharAtIndex(data, i, ".");
+// }
+// }
$("pre", currentCommandResult).append(document.createTextNode(data));
- }
+// }
_scrollToBottom();
}
@@ -205,10 +230,10 @@ define(function (require, exports, module) {
currentCommandGroup.removeClass("hdy-current");
}
- var element = $(".scrollPoint", currentCommandGroup);
- if (element.length) {
- currentCommandGroup[0].removeChild(element[0]);
- }
+// var element = $(".hdy-command-result:nth-last-of-type(1)", currentCommandGroup);
+// if (element.length) {
+// currentCommandGroup[0].removeChild(element[0]);
+// }
newCommand.attr("data-cwd", cwd + PROMPT_TERMINATOR);
commandGroups.append(newCommandGroup);
@@ -226,22 +251,20 @@ define(function (require, exports, module) {
function _focus() {
var commandInput = $(".hdy-current .hdy-command")[0];
- var scrollPoint = $(".scrollPoint")[0];
- if (scrollPoint) {
- scrollPoint.scrollIntoView(false);
- commandInput.focus();
- }
+ commandInput.focus();
+ commandInput.scrollIntoView(false);
+
}
- // Initialize the shellPanel
+ // Initialize the ShellPanelBottom
AppInit.appReady(function () {
KillProcess.click(function() {
ShellDomain.exec("kill");
});
KillProcess.attr('disabled', 'disabled');
- $(".close", ShellPanel.$panel).click(_toggle);
+ $(".close", ShellPanelBottom.$panel).click(_toggle);
// $(".hdy-command-groups .hdy-current .hdy-command")
// .attr("data-cwd", cwd);
@@ -278,9 +301,11 @@ define(function (require, exports, module) {
_addShellLine(cwd);
}
- exports.toggle = _toggle;
- exports.hide = _hide;
- exports.show = _show;
- exports.isVisible = _isVisible;
- exports.setDirectory = _setDirectory;
+ module.exports = ShellPanelView;
+
+// exports.toggle = _toggle;
+// exports.hide = _hide;
+// exports.show = _show;
+// exports.isVisible = _isVisible;
+// exports.setDirectory = _setDirectory;
});