Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-5137-async-li…
Browse files Browse the repository at this point in the history
…nting

Conflicts:
	src/nls/root/strings.js
  • Loading branch information
busykai committed Apr 5, 2014
2 parents a46b9df + 377b4e2 commit c3411bb
Show file tree
Hide file tree
Showing 66 changed files with 13,683 additions and 418 deletions.
4 changes: 4 additions & 0 deletions .brackets.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"src/thirdparty/CodeMirror2/**/*.js": {
"spaceUnits": 2,
"linting.enabled": false
},
"src/thirdparty/globmatch.js": {
"spaceUnits": 2,
"linting.enabled": false
}
},
"spaceUnits": 4,
Expand Down
5 changes: 3 additions & 2 deletions src/brackets.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"about_icon" : "styles/images/brackets_icon.svg",
"update_info_url" : "http://dev.brackets.io/updates/stable/",
"how_to_use_url" : "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets",
"support_url" : "http://help.brackets.io",
"get_involved_url" : "https://github.com/adobe/brackets",
"support_url" : "https://github.com/adobe/brackets/wiki/Troubleshooting",
"suggest_feature_url" : "https://github.com/adobe/brackets/wiki/Suggest-a-Feature",
"get_involved_url" : "https://github.com/adobe/brackets/blob/master/CONTRIBUTING.md",
"glob_help_url" : "https://github.com/adobe/brackets/wiki/Using-File-Filters",
"release_notes_url" : "https://github.com/adobe/brackets/wiki/Release-Notes",
"twitter_url" : "https://twitter.com/brackets",
Expand Down
1 change: 1 addition & 0 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ define(function (require, exports, module) {
exports.HELP_CHECK_FOR_UPDATE = "help.checkForUpdate"; // HelpCommandHandlers.js _handleCheckForUpdates()
exports.HELP_HOW_TO_USE_BRACKETS = "help.howToUseBrackets"; // HelpCommandHandlers.js _handleLinkMenuItem()
exports.HELP_SUPPORT = "help.support"; // HelpCommandHandlers.js _handleLinkMenuItem()
exports.HELP_SUGGEST = "help.suggest"; // HelpCommandHandlers.js _handleLinkMenuItem()
exports.HELP_RELEASE_NOTES = "help.releaseNotes"; // HelpCommandHandlers.js _handleLinkMenuItem()
exports.HELP_GET_INVOLVED = "help.getInvolved"; // HelpCommandHandlers.js _handleLinkMenuItem()
exports.HELP_SHOW_EXT_FOLDER = "help.showExtensionsFolder"; // HelpCommandHandlers.js _handleShowExtensionsFolder()
Expand Down
3 changes: 3 additions & 0 deletions src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ define(function (require, exports, module) {
if (brackets.config.support_url) {
menu.addMenuItem(Commands.HELP_SUPPORT);
}
if (brackets.config.suggest_feature_url) {
menu.addMenuItem(Commands.HELP_SUGGEST);
}
if (brackets.config.release_notes_url) {
menu.addMenuItem(Commands.HELP_RELEASE_NOTES);
}
Expand Down
5 changes: 3 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"about_icon": "styles/images/brackets_icon.svg",
"update_info_url": "http://dev.brackets.io/updates/stable/",
"how_to_use_url": "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets",
"support_url": "http://help.brackets.io",
"get_involved_url": "https://github.com/adobe/brackets",
"support_url": "https://github.com/adobe/brackets/wiki/Troubleshooting",
"suggest_feature_url": "https://github.com/adobe/brackets/wiki/Suggest-a-Feature",
"get_involved_url": "https://github.com/adobe/brackets/blob/master/CONTRIBUTING.md",
"glob_help_url": "https://github.com/adobe/brackets/wiki/Using-File-Filters",
"release_notes_url": "https://github.com/adobe/brackets/wiki/Release-Notes",
"twitter_url": "https://twitter.com/brackets",
Expand Down
38 changes: 19 additions & 19 deletions src/editor/CSSInlineEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ define(function (require, exports, module) {
// class="error-dialog modal hide"
// and the insertion point is inside "modal", we want ".modal"
var attributeValue = tagInfo.attr.value;
var startIndex = attributeValue.substr(0, tagInfo.position.offset).lastIndexOf(" ");
var endIndex = attributeValue.indexOf(" ", tagInfo.position.offset);
selectorName = "." +
attributeValue.substring(
startIndex === -1 ? 0 : startIndex + 1,
endIndex === -1 ? attributeValue.length : endIndex
);

// If the insertion point is surrounded by space, selectorName is "."
// Check for that here
if (selectorName === ".") {
selectorName = "";
}

if (selectorName === "") {
if (attributeValue.trim()) {
var startIndex = attributeValue.substr(0, tagInfo.position.offset).lastIndexOf(" ");
var endIndex = attributeValue.indexOf(" ", tagInfo.position.offset);
selectorName = "." +
attributeValue.substring(
startIndex === -1 ? 0 : startIndex + 1,
endIndex === -1 ? attributeValue.length : endIndex
);

// If the insertion point is surrounded by space between two classnames, selectorName is "."
if (selectorName === ".") {
selectorName = "";
reason = Strings.ERROR_CSSQUICKEDIT_BETWEENCLASSES;
}
} else {
reason = Strings.ERROR_CSSQUICKEDIT_CLASSNOTFOUND;
}
} else if (tagInfo.attr.name === "id") {
Expand Down Expand Up @@ -121,7 +121,7 @@ define(function (require, exports, module) {
*/
function _addRule(selectorName, inlineEditor, path) {
DocumentManager.getDocumentForPath(path).done(function (styleDoc) {
var newRuleInfo = CSSUtils.addRuleToDocument(styleDoc, selectorName, Editor.getUseTabChar(), Editor.getSpaceUnits());
var newRuleInfo = CSSUtils.addRuleToDocument(styleDoc, selectorName, Editor.getUseTabChar(path), Editor.getSpaceUnits(path));
inlineEditor.addAndSelectRange(selectorName, styleDoc, newRuleInfo.range.from.line, newRuleInfo.range.to.line);
inlineEditor.editor.setCursorPos(newRuleInfo.pos.line, newRuleInfo.pos.ch);
});
Expand Down Expand Up @@ -160,9 +160,9 @@ define(function (require, exports, module) {
*
* @param {!Editor} editor
* @param {!{line:Number, ch:Number}} pos
* @return {?$.Promise} synchronously resolved with an InlineWidget, or
* {string} if pos is in tag but not in tag name, class attr, or id attr, or
* null if we're not going to provide anything.
* @return {?$.Promise} synchronously resolved with an InlineWidget; or error
* {string} if pos is in tag but not in tag name, class attr, or id attr; or null if the
* selection isn't even close to a context where we could provide anything.
*/
function htmlToCSSProvider(hostEditor, pos) {

Expand Down
142 changes: 100 additions & 42 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ define(function (require, exports, module) {
Strings = require("strings"),
TextRange = require("document/TextRange").TextRange,
TokenUtils = require("utils/TokenUtils"),
ValidationUtils = require("utils/ValidationUtils"),
ViewUtils = require("utils/ViewUtils"),
_ = require("thirdparty/lodash");

Expand All @@ -92,6 +93,14 @@ define(function (require, exports, module) {

var cmOptions = {};

/** @type {number} Constants */
var MIN_SPACE_UNITS = 0,
MIN_TAB_SIZE = 1,
DEFAULT_SPACE_UNITS = 4,
DEFAULT_TAB_SIZE = 4,
MAX_SPACE_UNITS = 10,
MAX_TAB_SIZE = 10;

// Mappings from Brackets preferences to CodeMirror options
cmOptions[CLOSE_BRACKETS] = "autoCloseBrackets";
cmOptions[CLOSE_TAGS] = "autoCloseTags";
Expand All @@ -100,7 +109,7 @@ define(function (require, exports, module) {
cmOptions[SMART_INDENT] = "smartIndent";
cmOptions[SPACE_UNITS] = "indentUnit";
cmOptions[STYLE_ACTIVE_LINE] = "styleActiveLine";
cmOptions[TAB_SIZE] = "indentUnit";
cmOptions[TAB_SIZE] = "tabSize";
cmOptions[USE_TAB_CHAR] = "indentWithTabs";
cmOptions[WORD_WRAP] = "lineWrapping";

Expand All @@ -110,9 +119,13 @@ define(function (require, exports, module) {
PreferencesManager.definePreference(SHOW_LINE_NUMBERS, "boolean", true);
PreferencesManager.definePreference(SMART_INDENT, "boolean", true);
PreferencesManager.definePreference(SOFT_TABS, "boolean", true);
PreferencesManager.definePreference(SPACE_UNITS, "number", 4);
PreferencesManager.definePreference(SPACE_UNITS, "number", DEFAULT_SPACE_UNITS, {
validator: _.partialRight(ValidationUtils.isIntegerInRange, MIN_SPACE_UNITS, MAX_SPACE_UNITS)
});
PreferencesManager.definePreference(STYLE_ACTIVE_LINE, "boolean", false);
PreferencesManager.definePreference(TAB_SIZE, "number", 4);
PreferencesManager.definePreference(TAB_SIZE, "number", DEFAULT_TAB_SIZE, {
validator: _.partialRight(ValidationUtils.isIntegerInRange, MIN_TAB_SIZE, MAX_TAB_SIZE)
});
PreferencesManager.definePreference(USE_TAB_CHAR, "boolean", false);
PreferencesManager.definePreference(WORD_WRAP, "boolean", true);

Expand Down Expand Up @@ -2005,7 +2018,6 @@ define(function (require, exports, module) {

if (oldValue !== newValue) {
this._currentOptions[prefName] = newValue;
var useTabChar = this._currentOptions[USE_TAB_CHAR];

if (prefName === USE_TAB_CHAR) {
this._codeMirror.setOption(cmOptions[prefName], newValue);
Expand All @@ -2018,9 +2030,6 @@ define(function (require, exports, module) {
} else if (prefName === SCROLL_PAST_END && this._visibleRange) {
// Do not apply this option to inline editors
return;
} else if ((useTabChar && prefName === SPACE_UNITS) || (!useTabChar && prefName === TAB_SIZE)) {
// This change conflicts with the useTabChar setting, so do not change the CodeMirror option
return;
} else {
this._codeMirror.setOption(cmOptions[prefName], newValue);
}
Expand Down Expand Up @@ -2050,100 +2059,149 @@ define(function (require, exports, module) {
* Sets whether to use tab characters (vs. spaces) when inserting new text.
* Affects any editors that share the same preference location.
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setUseTabChar = function (value) {
PreferencesManager.set(USE_TAB_CHAR, value);
Editor.setUseTabChar = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(USE_TAB_CHAR, value, options);
};

/** @type {boolean} Gets whether the current editor uses tab characters (vs. spaces) when inserting new text */
Editor.getUseTabChar = function () {
return PreferencesManager.get(USE_TAB_CHAR);
/**
* Gets whether the specified or current file uses tab characters (vs. spaces) when inserting new text
* @param {string=} fullPath Path to file to get preference for
* @return {boolean}
*/
Editor.getUseTabChar = function (fullPath) {
return PreferencesManager.get(USE_TAB_CHAR, fullPath);
};

/**
* Sets tab character width.
* Affects any editors that share the same preference location.
* @param {number} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setTabSize = function (value) {
PreferencesManager.set(TAB_SIZE, value);
Editor.setTabSize = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(TAB_SIZE, value, options);
};

/** @type {number} Get indent unit */
Editor.getTabSize = function () {
return PreferencesManager.get(TAB_SIZE);
/**
* Get indent unit
* @param {string=} fullPath Path to file to get preference for
* @return {number}
*/
Editor.getTabSize = function (fullPath) {
return PreferencesManager.get(TAB_SIZE, fullPath);
};

/**
* Sets indentation width.
* Affects any editors that share the same preference location.
* @param {number} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setSpaceUnits = function (value) {
PreferencesManager.set(SPACE_UNITS, value);
Editor.setSpaceUnits = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(SPACE_UNITS, value, options);
};

/** @type {number} Get indentation width */
Editor.getSpaceUnits = function () {
return PreferencesManager.get(SPACE_UNITS);
/**
* Get indentation width
* @param {string=} fullPath Path to file to get preference for
* @return {number}
*/
Editor.getSpaceUnits = function (fullPath) {
return PreferencesManager.get(SPACE_UNITS, fullPath);
};

/**
* Sets the auto close brackets.
* Affects any editors that share the same preference location.
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setCloseBrackets = function (value) {
PreferencesManager.set(CLOSE_BRACKETS, value);
Editor.setCloseBrackets = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(CLOSE_BRACKETS, value, options);
};

/** @type {boolean} Gets whether the current editor uses auto close brackets */
Editor.getCloseBrackets = function () {
return PreferencesManager.get(CLOSE_BRACKETS);
/**
* Gets whether the specified or current file uses auto close brackets
* @param {string=} fullPath Path to file to get preference for
* @return {boolean}
*/
Editor.getCloseBrackets = function (fullPath) {
return PreferencesManager.get(CLOSE_BRACKETS, fullPath);
};

/**
* Sets show line numbers option.
* Affects any editors that share the same preference location.
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setShowLineNumbers = function (value) {
PreferencesManager.set(SHOW_LINE_NUMBERS, value);
Editor.setShowLineNumbers = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(SHOW_LINE_NUMBERS, value, options);
};

/** @type {boolean} Returns true if show line numbers is enabled for the current editor */
Editor.getShowLineNumbers = function () {
return PreferencesManager.get(SHOW_LINE_NUMBERS);
/**
* Returns true if show line numbers is enabled for the specified or current file
* @param {string=} fullPath Path to file to get preference for
* @return {boolean}
*/
Editor.getShowLineNumbers = function (fullPath) {
return PreferencesManager.get(SHOW_LINE_NUMBERS, fullPath);
};

/**
* Sets show active line option.
* Affects any editors that share the same preference location.
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setShowActiveLine = function (value) {
PreferencesManager.set(STYLE_ACTIVE_LINE, value);
Editor.setShowActiveLine = function (value, fullPath) {
return PreferencesManager.set(STYLE_ACTIVE_LINE, value);
};

/** @type {boolean} Returns true if show active line is enabled for the current editor */
Editor.getShowActiveLine = function () {
return PreferencesManager.get(STYLE_ACTIVE_LINE);
/**
* Returns true if show active line is enabled for the specified or current file
* @param {string=} fullPath Path to file to get preference for
* @return {boolean}
*/
Editor.getShowActiveLine = function (fullPath) {
return PreferencesManager.get(STYLE_ACTIVE_LINE, fullPath);
};

/**
* Sets word wrap option.
* Affects any editors that share the same preference location.
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setWordWrap = function (value) {
PreferencesManager.set(WORD_WRAP, value);
Editor.setWordWrap = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(WORD_WRAP, value, options);
};

/** @type {boolean} Returns true if word wrap is enabled for the current editor */
Editor.getWordWrap = function () {
return PreferencesManager.get(WORD_WRAP);
/**
* Returns true if word wrap is enabled for the specified or current file
* @param {string=} fullPath Path to file to get preference for
* @return {boolean}
*/
Editor.getWordWrap = function (fullPath) {
return PreferencesManager.get(WORD_WRAP, fullPath);
};


// Set up listeners for preference changes
editorOptions.forEach(function (prefName) {
PreferencesManager.on("change", prefName, function () {
Expand Down
Loading

0 comments on commit c3411bb

Please sign in to comment.