From d298c78715af5117e102263fec6a98cb5c51b00b Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Wed, 25 Mar 2015 09:35:10 +0000 Subject: [PATCH 01/11] integration of code-folding extension into brackets --- .../default/CodeFolding/DefaultSettings.js | 19 + src/extensions/default/CodeFolding/Prefs.js | 73 ++++ .../default/CodeFolding/SettingsDialog.js | 68 ++++ .../CodeFolding/foldhelpers/foldcode.js | 217 ++++++++++++ .../CodeFolding/foldhelpers/foldgutter.js | 267 ++++++++++++++ .../CodeFolding/foldhelpers/indentFold.js | 62 ++++ .../CodeFolding/foldhelpers/latex-fold.js | 57 +++ .../CodeFolding/foldhelpers/region-fold.js | 60 ++++ .../htmlTemplates/settings-dialog.html | 65 ++++ src/extensions/default/CodeFolding/main.js | 329 ++++++++++++++++++ src/extensions/default/CodeFolding/main.less | 54 +++ .../default/CodeFolding/nls/de/strings.js | 34 ++ .../default/CodeFolding/nls/es/strings.js | 34 ++ .../default/CodeFolding/nls/fi/strings.js | 57 +++ .../default/CodeFolding/nls/fr/strings.js | 54 +++ .../default/CodeFolding/nls/gl/strings.js | 34 ++ .../default/CodeFolding/nls/it/strings.js | 34 ++ .../default/CodeFolding/nls/ja/strings.js | 55 +++ .../default/CodeFolding/nls/nl/strings.js | 57 +++ .../default/CodeFolding/nls/pt-BR/strings.js | 55 +++ .../default/CodeFolding/nls/root/strings.js | 57 +++ .../default/CodeFolding/nls/ru/strings.js | 57 +++ .../default/CodeFolding/nls/strings.js | 51 +++ src/extensions/default/CodeFolding/strings.js | 38 ++ 24 files changed, 1888 insertions(+) create mode 100644 src/extensions/default/CodeFolding/DefaultSettings.js create mode 100644 src/extensions/default/CodeFolding/Prefs.js create mode 100644 src/extensions/default/CodeFolding/SettingsDialog.js create mode 100644 src/extensions/default/CodeFolding/foldhelpers/foldcode.js create mode 100644 src/extensions/default/CodeFolding/foldhelpers/foldgutter.js create mode 100644 src/extensions/default/CodeFolding/foldhelpers/indentFold.js create mode 100644 src/extensions/default/CodeFolding/foldhelpers/latex-fold.js create mode 100644 src/extensions/default/CodeFolding/foldhelpers/region-fold.js create mode 100644 src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html create mode 100644 src/extensions/default/CodeFolding/main.js create mode 100644 src/extensions/default/CodeFolding/main.less create mode 100644 src/extensions/default/CodeFolding/nls/de/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/es/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/fi/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/fr/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/gl/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/it/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/ja/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/nl/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/pt-BR/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/root/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/ru/strings.js create mode 100644 src/extensions/default/CodeFolding/nls/strings.js create mode 100644 src/extensions/default/CodeFolding/strings.js diff --git a/src/extensions/default/CodeFolding/DefaultSettings.js b/src/extensions/default/CodeFolding/DefaultSettings.js new file mode 100644 index 00000000000..10200605ee8 --- /dev/null +++ b/src/extensions/default/CodeFolding/DefaultSettings.js @@ -0,0 +1,19 @@ +/** + * JSON values for default settings + * @author Patrick Oladimeji + * @date 8/23/14 15:45:35 PM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, require, brackets, window */ +define(function (require, exports, module) { + "use strict"; + + module.exports = { + minFoldSize: 2, + saveFoldStates: true, + alwaysUseIndentFold: true, + enableRegionFolding: true, + fadeFoldButtons: false, + maxFoldLevel: 2 // this value is only used when fold all is called + }; +}); \ No newline at end of file diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js new file mode 100644 index 00000000000..b4dbb1f6643 --- /dev/null +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -0,0 +1,73 @@ +/** + * Wrapper around brackets pref system to ensure preferences are stored in in one single object instead of using multiple keys. + * This is to make it easy for the user who edits their preferences file to easily manage the potentially numerous lines of preferences generated by the persisting code-folding state. + * @author Patrick Oladimeji + * @date 3/22/14 20:39:53 PM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, brackets*/ +define(function (require, exports, module) { + "use strict"; + var PreferencesManager = brackets.getModule("preferences/PreferencesManager"), + _prefs = PreferencesManager.getExtensionPrefs("code-folding"), + stateManager = PreferencesManager.stateManager.getPrefixedSystem("code-folding"), + DefaultSettings = require("DefaultSettings"), + store = {}, + settings = {}, + folds = "folds"; + + function simplify(folds) { + if (!folds) { return folds; } + var res = {}, range; + Object.keys(folds).map(function (line) { + range = folds[line]; + res[line] = Array.isArray(range) ? range : [[range.from.line, range.from.ch], [range.to.line, range.to.ch]]; + }); + return res; + } + + function inflate(folds) { + if (!folds) { return folds; } + //transform the folds into objects with from and to properties + var ranges = {}, obj; + Object.keys(folds).forEach(function (line) { + obj = folds[line]; + ranges[line] = {from: {line: obj[0][0], ch: obj[0][1]}, to: {line: obj[1][0], ch: obj[1][1]}}; + }); + + return ranges; + } + + module.exports = { + get: function (id) { + store = (stateManager.get(folds) || {}); + return inflate(store[id]); + }, + set: function (id, value) { + store[id] = simplify(value); + stateManager.set(folds, store); + stateManager.save(); + }, + getSetting: function (key) { + settings = (stateManager.get("settings") || DefaultSettings); + return settings[key]; + }, + setSetting: function (key, value) { + settings[key] = value; + stateManager.set("settings", settings); + stateManager.save(); + }, + getAllSettings: function () { + var res = {}, self = this; + Object.keys(DefaultSettings).forEach(function (key) { + res[key] = self.getSetting(key); + }); + return res; + }, + clearAllFolds: function () { + stateManager.set(folds, {}); + stateManager.save(); + } + }; + +}); diff --git a/src/extensions/default/CodeFolding/SettingsDialog.js b/src/extensions/default/CodeFolding/SettingsDialog.js new file mode 100644 index 00000000000..aebb340b94a --- /dev/null +++ b/src/extensions/default/CodeFolding/SettingsDialog.js @@ -0,0 +1,68 @@ +/** + * Configure and change settings for the code folding extension + * @author Patrick Oladimeji + * @date 8/23/14 12:32:46 PM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, require, brackets, Mustache, $ */ +define(function (require, exports, module) { + "use strict"; + var Dialogs = brackets.getModule("widgets/Dialogs"), + DefaultSettings = require("DefaultSettings"), + Strings = require("i18n!nls/strings"), + CommandManager = brackets.getModule("command/CommandManager"), + settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), + preferences = require("Prefs"); + + function setFormValues(prefs) { + $("#min-fold-size").val(prefs.minFoldSize || 2); + $("#max-fold-level").val(prefs.maxFoldLevel || 2); + $("#save-fold-states").prop("checked", prefs.saveFoldStates); + $("#always-use-indent-fold").prop("checked", prefs.alwaysUseIndentFold); + $("#enable-region-folding").prop("checked", prefs.enableRegionFolding); + $("#fade-fold-buttons").prop("checked", prefs.fadeFoldButtons); + } + + function restoreDefaults() { + setFormValues(DefaultSettings); + } + + function showDialog(cb) { + var template = Mustache.render(settingsTemplate, Strings); + var dialog = Dialogs.showModalDialogUsingTemplate(template); + var useShortcuts; + setFormValues(preferences.getAllSettings()); + + dialog.done(function (buttonId) { + if (buttonId === "ok") { + var $dialog = dialog.getElement(); + var minFoldSize = $("#min-fold-size", $dialog).val(); + var maxFoldLevel = $("#max-fold-level", $dialog).val(); + preferences.setSetting("minFoldSize", isNaN(minFoldSize) || +minFoldSize === 0 ? + +preferences.getSetting("minFoldSize") : +minFoldSize); + preferences.setSetting("saveFoldStates", $("#save-fold-states", $dialog).prop("checked")); + preferences.setSetting("maxFoldLevel", isNaN(maxFoldLevel) || +maxFoldLevel === 0 ? + +preferences.getSetting("maxFoldLevel") : +maxFoldLevel); + preferences.setSetting("alwaysUseIndentFold", $("#always-use-indent-fold", $dialog).prop("checked")); + preferences.setSetting("enableRegionFolding", $("#enable-region-folding", $dialog).prop("checked")); + preferences.setSetting("fadeFoldButtons", $("#fade-fold-buttons", $dialog).prop("checked")); + if (cb && typeof cb === "function") { + cb(); + } + } + }); + } + + function bindListeners() { + $("button[data-button-id='defaults']").on("click", function (e) { + e.stopPropagation(); + restoreDefaults(); + }); + } + + bindListeners(); + + module.exports = { + show: showDialog + }; +}); \ No newline at end of file diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js new file mode 100644 index 00000000000..f7b1abcb39b --- /dev/null +++ b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js @@ -0,0 +1,217 @@ +/** + * Based on http://codemirror.net/addon/fold/foldcode.js + * @author Patrick Oladimeji + * @date 10/28/13 8:41:46 AM + * @last modified 20 April 2014 + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, brackets, document*/ +define(function (require, exports, module) { + "use strict"; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + prefs = require("Prefs"); + + module.exports = function () { + function doFold(cm, pos, options, force) { + force = force || "fold"; + if (typeof pos === "number") { + pos = CodeMirror.Pos(pos, 0); + } + var finder = (options && options.rangeFinder) || CodeMirror.fold.auto; + var minSize = (options && options.minFoldSize) || prefs.getSetting("minFoldSize"); + + function getRange(allowFolded) { + var range = options && options.range ? options.range : finder(cm, pos); + if (!range || range.to.line - range.from.line < minSize) { + return null; + } + var marks = cm.findMarksAt(range.from), + i; + for (i = 0; i < marks.length; ++i) { + if (marks[i].__isFold && force !== "fold") { + if (!allowFolded) { + return null; + } + range.cleared = true; + marks[i].clear(); + } + } + //check for overlapping folds + var lastMark, foldMarks; + if (marks && marks.length) { + foldMarks = marks.filter(function (d) { return d.__isFold; }); + if (foldMarks && foldMarks.length) { + lastMark = foldMarks[foldMarks.length - 1].find(); + if (lastMark && range.from.line <= lastMark.to.line && lastMark.to.line < range.to.line) { + return null; + } + } + } + return range; + } + + function makeWidget() { + var widget = document.createElement("span"); + widget.className = "CodeMirror-foldmarker"; + return widget; + } + + var range = getRange(true); + if (options && options.scanUp) { + while (!range && pos.line > cm.firstLine()) { + pos = CodeMirror.Pos(pos.line - 1, 0); + range = getRange(false); + } + } + if (!range || range.cleared || force === "unfold" || range.to.line - range.from.line < minSize) { + if (range) { range.cleared = false; } + return; + } + + var myWidget = makeWidget(); + var myRange = cm.markText(range.from, range.to, { + replacedWith: myWidget, + clearOnEnter: true, + __isFold: true + }); + CodeMirror.on(myWidget, "mousedown", function () { + myRange.clear(); + }); + myRange.on("clear", function (from, to) { + delete cm._lineFolds[from.line]; + CodeMirror.signal(cm, "unfold", cm, from, to); + }); + + if (force === "fold") { + delete range.cleared; + cm._lineFolds[pos.line] = range; + } else { + delete cm._lineFolds[pos.line]; + } + CodeMirror.signal(cm, force, cm, range.from, range.to); + return range; + } + + CodeMirror.defineExtension("foldCode", function (pos, options, force) { + return doFold(this, pos, options, force); + }); + + //define an unfoldCode extension to quickly unfold folded code + CodeMirror.defineExtension("unfoldCode", function (pos, options) { + return doFold(this, pos, options, "unfold"); + }); + + CodeMirror.registerHelper("fold", "combine", function () { + var funcs = Array.prototype.slice.call(arguments, 0); + return function (cm, start) { + var i; + for (i = 0; i < funcs.length; ++i) { + var found = funcs[i] && funcs[i](cm, start); + if (found) { + return found; + } + } + }; + }); + + CodeMirror.defineExtension("isFolded", function (line) { + return this._lineFolds[line]; + }); + /** + Checks the validity of the ranges passed in the parameter and returns the foldranges + that are still valid in the current document + @param {object} folds the dictionary of lines in the current document that should be folded + @returns {object} valid folds found in those passed in parameter + */ + CodeMirror.defineExtension("getValidFolds", function (folds) { + var keys, rf = CodeMirror.fold.auto, cm = this, result = {}; + if (folds && (keys = Object.keys(folds)).length) { + var i, range, cachedRange; + keys.forEach(function (lineNumber) { + lineNumber = +lineNumber; + if (lineNumber >= cm.firstLine() && lineNumber <= cm.lastLine()) { + range = rf(cm, CodeMirror.Pos(lineNumber)); + cachedRange = folds[lineNumber]; + if (range && cachedRange && range.from.line === cachedRange.from.line && + range.to.line === cachedRange.to.line) { + cm.foldCode(lineNumber, {range: folds[lineNumber]}, "fold"); + result[lineNumber] = folds[lineNumber]; + } + } + }); + } + return result; + }); + + CodeMirror.commands.toggleFold = function (cm) { + cm.foldCode(cm.getCursor()); + }; + CodeMirror.commands.fold = function (cm, options, force) { + cm.foldCode(cm.getCursor(), options, "fold"); + }; + CodeMirror.commands.unfold = function (cm, options, force) { + cm.foldCode(cm.getCursor(), options, "unfold"); + }; + CodeMirror.commands.foldAll = function (cm) { + cm.operation(function () { + var i, e; + for (i = cm.firstLine(), e = cm.lastLine(); i <= e; i++) { + cm.foldCode(CodeMirror.Pos(i, 0), null, "fold"); + } + }); + }; + /** + Folds the specified range. The descendants of any fold regions within the range are also folded up to + a level set globally in the codeFolding preferences + */ + CodeMirror.commands.foldToLevel = function (cm, start, end) { + var rf = CodeMirror.fold.auto, level = prefs.getSetting("maxFoldLevel"); + function foldLevel(n, from, to) { + if (n > 0) { + var i = from, e, range; + while (i < to) { + range = rf(cm, CodeMirror.Pos(i, 0)); + if (range) { + //call fold level for the range just folded + foldLevel(n - 1, range.from.line + 1, range.to.line - 1); + cm.foldCode(CodeMirror.Pos(i, 0), null, "fold"); + i = range.to.line + 1; + } else { + i++; + } + } + } + } + cm.operation(function () { + start = start === undefined ? cm.firstLine() : start; + end = end || cm.lastLine(); + foldLevel(level, start, end); + }); + }; + + CodeMirror.commands.unfoldAll = function (cm, from, to) { + from = from || cm.firstLine(); + to = to || cm.lastLine(); + cm.operation(function () { + var i, e; + for (i = from, e = to; i <= e; i++) { + if (cm.isFolded(i)) { cm.unfoldCode(i, {range: cm._lineFolds[i]}); } + } + }); + }; + + CodeMirror.registerHelper("fold", "auto", function (cm, start) { + var helpers = cm.getHelpers(start, "fold"), i, cur; + //ensure mode helper is loaded if there is one + var mode = cm.getMode().name; + var modeHelper = CodeMirror.fold[mode]; + if (modeHelper && helpers.indexOf(modeHelper) < 0) { + helpers.push(modeHelper); + } + for (i = 0; i < helpers.length; i++) { + cur = helpers[i](cm, start); + if (cur) { return cur; } + } + }); + }; +}); \ No newline at end of file diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js new file mode 100644 index 00000000000..973095d0b77 --- /dev/null +++ b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js @@ -0,0 +1,267 @@ +/** + * Based on http://codemirror.net/addon/fold/foldgutter.js + Modulised by: + * @author Patrick Oladimeji + * @date 10/24/13 10:14:01 AM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, brackets, document, clearTimeout, setTimeout, $*/ +define(function (require, exports, module) { + "use strict"; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); + var prefs = require("Prefs"); + + module.exports = function () { + function State(options) { + this.options = options; + this.from = this.to = 0; + } + + function parseOptions(opts) { + if (opts === true) { opts = {}; } + if (!opts.gutter) { opts.gutter = "CodeMirror-foldgutter"; } + if (!opts.indicatorOpen) { opts.indicatorOpen = "CodeMirror-foldgutter-open"; } + if (!opts.indicatorFolded) { opts.indicatorFolded = "CodeMirror-foldgutter-folded"; } + return opts; + } + + function marker(spec) { + if (typeof spec === "string") { + var elt = document.createElement("div"); + elt.className = spec; + return elt; + } else { + return spec.cloneNode(true); + } + } + + /** + Updates the gutter markers for the specified range + @param cm the codemirror object + @param {Number} from the starting line for the update + @param {Number} to the ending line for the update + */ + function updateFoldInfo(cm, from, to) { + var minFoldSize = prefs.getSetting("minFoldSize") || 2; + var opts = cm.state.foldGutter.options; + var fade = prefs.getSetting("fadeFoldButtons"); + var gutter = $(cm.getGutterElement()); + var i = from; + var isFold = function (m) { + return m.__isFold; + }, clear = function (m) {return m.clear(); }; + + /** + helper function to check if the given line is in a folded region in the editor. + @param {Number} line the + @return {from: {ch: Number, line: Number}, to: {ch: Number, line: Number}} the range that hides the specified line or undefine if the line is not hidden + */ + function _isCurrentlyFolded(line) { + var keys = Object.keys(cm._lineFolds), i = 0, r; + while (i < keys.length) { + r = cm._lineFolds[keys[i]]; + if (r.from.line < line && r.to.line >= line) { + return r; + } + i++; + } + } + + /** + This case is needed when unfolding a region that does not cause the viewport to change. + For instance in a file with about 15 lines, if some code regions are folded and unfolded, the + viewport change event isnt fired by codeMirror. The setTimeout is a workaround to trigger the + gutter update after the viewport has been drawn. + */ + if (i === to) { + setTimeout(function () { + var vp = cm.getViewport(); + updateFoldInfo(cm, vp.from, vp.to); + }, 200); + } + + while (i < to) { + var sr = _isCurrentlyFolded(i),//surrounding range for the current line if one exists + range; + var mark = marker("CodeMirror-foldgutter-blank"); + var pos = CodeMirror.Pos(i), + func = opts.rangeFinder || CodeMirror.fold.auto; + //dont look inside collapsed ranges + if (sr) { + i = sr.to.line + 1; + } else { + range = cm._lineFolds[i] || (func && func(cm, pos)); + if (!fade || (fade && gutter.is(":hover"))) { + if (cm.isFolded(i)) { + //expand fold if invalid + if (range) { + mark = marker(opts.indicatorFolded); + } else { + cm.findMarksAt(pos).filter(isFold) + .forEach(clear); + } + } else { + if (range && range.to.line - range.from.line >= minFoldSize) { + mark = marker(opts.indicatorOpen); + } + } + } + cm.setGutterMarker(i, opts.gutter, mark); + i++; + } + } + } + + function clearGutter(cm) { + var opts = cm.state.foldGutter.options; + cm.clearGutter(opts.gutter); + var blank = marker("CodeMirror-foldgutter-blank"); + var vp = cm.getViewport(); + cm.operation(function () { + cm.eachLine(vp.from, vp.to, function (line) { + cm.setGutterMarker(line.lineNo(), opts.gutter, blank); + }); + }); + } + + function updateInViewport(cm, from, to) { + var vp = cm.getViewport(), state = cm.state.foldGutter; + from = !isNaN(from) ? from : vp.from; + to = !isNaN(to) ? to : vp.to; + + if (!state) { return; } + cm.operation(function () { + updateFoldInfo(cm, from, to); + }); + state.from = from; + state.to = to; + } + + function updateFoldsCache(cm, from, linesDiff) { + var range; + var minFoldSize = prefs.getSetting("minFoldSize") || 2; + + if (linesDiff === 0 && cm._lineFolds) { + var opts = cm.state.foldGutter.options; + var rf = opts.rangeFinder || CodeMirror.fold.auto; + range = rf(cm, CodeMirror.Pos(from)); + + if (range && range.from.line - range.to.line >= minFoldSize) { + cm._lineFolds[from] = range; + } else { + delete cm._lineFolds[from]; + } + } else if (cm._lineFolds) { + var newFolds = {}; + Object.keys(cm._lineFolds).forEach(function (line) { + line = +line; + if (line < from) { + newFolds[line] = cm._lineFolds[line]; + } else { + range = cm._lineFolds[line]; + range.from.line = range.from.line + linesDiff; + range.to.line = range.to.line + linesDiff; + newFolds[line + linesDiff] = range; + + } + }); + cm._lineFolds = newFolds; + } + } + + function onChange(cm, changeObj) { + if (changeObj.origin === "setValue") {//text content has changed outside of brackets + var folds = cm.getValidFolds(cm._lineFolds); + cm._lineFolds = folds; + Object.keys(folds).forEach(function (line) { + cm.foldCode(+line); + }); + } else { + var state = cm.state.foldGutter; + var lineChanges = changeObj.text.length - changeObj.removed.length; + //update the lineFolds cache + updateFoldsCache(cm, changeObj.from.line, lineChanges); + if (lineChanges !== 0) { + if (lineChanges > 0) { + updateFoldInfo(cm, changeObj.from.line + lineChanges, changeObj.from.line + lineChanges + 1); + } + } + state.from = changeObj.from.line; + state.to = 0; + clearTimeout(state.changeUpdate); + state.changeUpdate = setTimeout(function () { + updateInViewport(cm); + }, prefs.getSetting("foldOnChangeTimeSpan") || 600); + } + } + + function onViewportChange(cm) { + var state = cm.state.foldGutter; + clearTimeout(state.changeUpdate); + state.changeUpdate = setTimeout(function () { + var vp = cm.getViewport(); + if (state.from === state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { + updateInViewport(cm); + } else { + cm.operation(function () { + if (vp.from < state.from) { + updateFoldInfo(cm, vp.from, state.from); + state.from = vp.from; + } + if (vp.to > state.to) { + updateFoldInfo(cm, state.to, vp.to); + state.to = vp.to; + } else { + updateFoldInfo(cm, vp.from, vp.to); + state.to = vp.to; + state.from = vp.from; + } + }); + } + }, prefs.getSetting("updateViewportTimeSpan") || 400); + } + + function onFold(cm, from, to) { + var state = cm.state.foldGutter, line = from.line; + if (line >= state.from && line < state.to) { + updateFoldInfo(cm, line, line + 1); + } + } + + function onUnFold(cm, from, to) { + var state = cm.state.foldGutter, line = from.line; + var vp = cm.getViewport(); + if (line >= state.from && line < state.to) { + updateFoldInfo(cm, line, Math.min(vp.to, to.line)); + } + } + + CodeMirror.defineOption("foldGutter", false, function (cm, val, old) { + if (old && old !== CodeMirror.Init) { + cm.clearGutter(cm.state.foldGutter.options.gutter); + cm.state.foldGutter = null; + cm.off("gutterClick", old.onGutterClick); + cm.off("change", onChange); + cm.off("viewportChange", onViewportChange); + cm.off("fold", onFold); + cm.off("unfold", onUnFold); + cm.off("swapDoc", updateInViewport); + } + if (val) { + cm.state.foldGutter = new State(parseOptions(val)); + updateInViewport(cm); + cm.on("gutterClick", val.onGutterClick); + cm.on("change", onChange); + cm.on("viewportChange", onViewportChange); + cm.on("fold", onFold); + cm.on("unfold", onUnFold); + cm.on("swapDoc", updateInViewport); + } + }); + + return { + clearGutter: clearGutter, + updateInViewport: updateInViewport + }; + }; +}); diff --git a/src/extensions/default/CodeFolding/foldhelpers/indentFold.js b/src/extensions/default/CodeFolding/foldhelpers/indentFold.js new file mode 100644 index 00000000000..db4e059c10c --- /dev/null +++ b/src/extensions/default/CodeFolding/foldhelpers/indentFold.js @@ -0,0 +1,62 @@ +/** + * Fold range finder based on line indentations. Ignores blank lines and commented lines + * @author Patrick Oladimeji + * @date 12/27/13 21:54:41 PM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, brackets*/ + +define(function (require, exports, module) { + "use strict"; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); + var cols = CodeMirror.countColumn, pos = CodeMirror.Pos; + + function lastNonEmptyLineNumber(cm) { + var lc = cm.lastLine(), line = cm.getLine(lc); + while (lc > 0 && line.trim().length === 0) { + lc--; + line = cm.getLine(lc); + } + return lc; + } + + module.exports = function (cm, start) { + var lineText = cm.getLine(start.line), tabSize = cm.getOption("tabSize"); + + var lineIndent = cols(lineText, null, tabSize), collapsible = false, lineCount = cm.lineCount(); + var token = cm.getTokenAt(pos(start.line, lineIndent + 1)); + //no folding for blank lines or commented lines + if (lineText.trim().length === 0 || (token && token.type === "comment")) { + return; + } + var i, indent, currentLine; + for (i = start.line + 1; i < lineCount; i++) { + currentLine = cm.getLine(i); + indent = cols(currentLine, null, tabSize); + + token = cm.getTokenAt(pos(i, indent + 1)); + //only fold for non blank lines or non commented lines + if (currentLine.trim().length !== 0 && (token && token.type !== "comment")) { + if (!collapsible) { + if (indent > lineIndent) { + collapsible = true; + } + } else { + if (indent <= lineIndent) { + return {from: pos(start.line, lineText.length), + to: pos(i - 1, cm.getLine(i - 1).length)}; + } + } + + if (indent === lineIndent || indent < lineIndent) { + return; + } + } + } + //use last nonempty line as the end of the folding region if there is no explicit end to this indent + if (collapsible) { + i = lastNonEmptyLineNumber(cm); + return {from: pos(start.line, lineText.length), to: pos(i, cm.getLine(i).length)}; + } + }; +}); diff --git a/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js b/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js new file mode 100644 index 00000000000..1fc65df7481 --- /dev/null +++ b/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js @@ -0,0 +1,57 @@ +/** + * Fold latex code regions + * @author Patrick Oladimeji + * @date 11/29/13 10:56:52 AM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, brackets, CodeMirror*/ +define(function (require, exports, module) { + "use strict"; + + brackets.getModule(["thirdparty/CodeMirror2/addon/fold/brace-fold"]); + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); + + module.exports = function (cm, start) { + var line = start.line, lineText = cm.getLine(line); + var startRegex = /^([\\](?:section|subsection|subsubsection|begin)\*?\s*\{)([\w\s\d\(\)\,\.\?]+)\}/; + ///fixme the matches for subsection and subsubections are wrong + function findClose(match, context) { + function find(regex) { + var i, lineText, lastLine = cm.lastLine(); + for (i = line + 1; i < lastLine; i++) { + lineText = cm.getLine(i); + var endTag = regex.exec(lineText); + if (endTag) { return {line: i, ch: endTag.index}; } + } + return {line: i + 1, ch: 0}; + } + + var regex, pos; + if (match.indexOf("\\begin") === 0) { //look for \end{context} + regex = new RegExp("\\end\\s*\\{" + context + "\\}"); + } else { + if (match.indexOf("\\subsection") === 0) { + regex = /^([\\](?:subsection|section)\*?\s*\{)([\w\s\d\(\)\,\.\?]+)\}/; + } else if (match.indexOf("\\subsubsection") === 0) { + regex = /^([\\](?:subsubsection|subsection|section)\*?\s*\{)([\w\s\d\(\)\,\.\?]+)\}/; + } else if (match.indexOf("\\section") === 0) { + regex = /^([\\](?:section|bibliography|biblipgraphystyle)\*?\s*\{)([\w\s\d\(\)\,\.\?]+)\}/; + } + } + pos = find(regex); + if (pos) { + pos.line = pos.line - 1; + } + return pos; + } + + var matches = startRegex.exec(lineText); + + if (!matches) { return CodeMirror.fold.brace(cm, start); } + //find the close tag depending on the match + var end = findClose(matches[1], matches[2]); + if (!end) { return null; } + return {from: CodeMirror.Pos(line, matches.index + matches[0].length), + to: CodeMirror.Pos(end.line, end.ch)}; + }; +}); diff --git a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js new file mode 100644 index 00000000000..a0c7d8eff75 --- /dev/null +++ b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js @@ -0,0 +1,60 @@ +// Function copied from brace-fold.js addon in CodeMirror Library with minor altering. +// CodeMirror 4.1.1, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +/*jshint eqnull:true, unused:true, undef: true*/ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, eqeq:true */ +/*global define, brackets*/ +define(function (require, exports, module) { + "use strict"; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + startRegion = /\W+region/i, + endRegion = /\W+endregion/i, + space = /\s/; + + module.exports = function (cm, start) { + var line = start.line, i, j; + var startCh = 0, stack = [], token; + var lastLine = cm.lastLine(), end, endCh, nextOpen, nextClose; + //no need to fold on single line files + if (line === lastLine) { return; } + + for (i = line; i <= lastLine; ++i) { + var text = cm.getLine(i), pos = startCh; + for (j = pos; j < text.length; true) { + //skip all blank lines at begining of test + if (space.test(text[j])) { + j++; + } else { + token = cm.getTokenAt(CodeMirror.Pos(i, j + 1)); + if (token) { + if (token.string.length && token.type === "comment") { + nextOpen = token.string.toLowerCase().match(startRegion) ? token.end : -1; + nextClose = token.string.toLowerCase().match(endRegion) ? token.start : -1; + if (nextOpen > -1) { + stack.push(nextOpen); + } + if (nextClose > -1) { + if (stack.length === 1) { + endCh = nextClose; + end = i; + return {from: CodeMirror.Pos(line, stack[0]), + to: CodeMirror.Pos(end, endCh)}; + } + stack.pop(); + } + } else { + break; //break out of loop if the first non-space character is not a comment + } + } + j = token ? token.end + 1 : text.length; + } + } + + if (stack.length === 0) { break; } + } + if (end == null || (line == end && endCh == startCh)) { return; } + return {from: CodeMirror.Pos(line, stack[0]), + to: CodeMirror.Pos(end, endCh)}; + }; + +}); diff --git a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html new file mode 100644 index 00000000000..fcb7d52c0b6 --- /dev/null +++ b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html @@ -0,0 +1,65 @@ + \ No newline at end of file diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js new file mode 100644 index 00000000000..594a4a39dda --- /dev/null +++ b/src/extensions/default/CodeFolding/main.js @@ -0,0 +1,329 @@ +/* +* Copyright (c) 2013 Patrick Oladimeji. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*/ +/** + * Code folding extension for brackets + * @author Patrick Oladimeji + * @date 10/24/13 9:35:26 AM + */ +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define, d3, require, $, brackets, window, MouseEvent */ + +require.config({ + paths: { + "text" : "lib/text", + "i18n" : "lib/i18n" + }, + locale: brackets.getLocale() +}); + +define(function (require, exports, module) { + "use strict"; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); + var Strings = require("strings"); + var CommandManager = brackets.getModule("command/CommandManager"), + DocumentManager = brackets.getModule("document/DocumentManager"), + EditorManager = brackets.getModule("editor/EditorManager"), + ProjectManager = brackets.getModule("project/ProjectManager"), + KeyBindingManager = brackets.getModule("command/KeyBindingManager"), + ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), + Menus = brackets.getModule("command/Menus"), + _prefs = require("./Prefs"), + CODE_FOLD_EXT = "javascript.code.folding", + COLLAPSE_ALL = "codefolding.collapse.all", + COLLAPSE = "codefolding.collapse", + EXPAND = "codefolding.expand", + EXPAND_ALL = "codefolding.expand.all", + CODE_FOLDING_SETTINGS = "codefolding.settings", + gutterName = "CodeMirror-foldgutter", + COLLAPSE_CUSTOM_REGIONS = "codefolding.collapse.customregions", + SettingsDialog = require("SettingsDialog"); + + ExtensionUtils.loadStyleSheet(module, "main.less"); + + //load code mirror addons + brackets.getModule(["thirdparty/CodeMirror2/addon/fold/brace-fold"]); + brackets.getModule(["thirdparty/CodeMirror2/addon/fold/comment-fold"]); + brackets.getModule(["thirdparty/CodeMirror2/addon/fold/markdown-fold"]); + + //still using slightly modified versions of the foldcode.js and foldgutter.js since we + //need to modify the gutter click handler to take care of some collapse and expand features + //e.g. collapsing all children when 'alt' key is pressed + require("foldhelpers/foldcode")(); + var foldGutter = require("foldhelpers/foldgutter")(); + + var indentFold = require("foldhelpers/indentFold"), + latexFold = require("foldhelpers/latex-fold"), + regionFold = require("foldhelpers/region-fold"); + + //register a global fold helper based on indentation folds + CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { + return _prefs.getSetting("alwaysUseIndentFold"); + }, indentFold); + + CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { + return _prefs.getSetting("enableRegionFolding"); + }, regionFold); + + CodeMirror.registerHelper("fold", "stex", latexFold); + CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); + CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); + + /** gets the folded regions in the editor. + * @returns a map containing {linenumber: {from, to}} + */ + function getLineFoldsInEditor(editor) { + var cm = editor._codeMirror, i, folds = {}; + if (cm) { + var marks = cm.getAllMarks(); + marks.filter(function (m) {return m.__isFold; }) + .forEach(function (mark) { + var range = mark.find(); + if (range) { + folds[range.from.line] = range; + } + }); + } + return folds; + } + + /** + Restores the linefolds in the editor using values fetched from the preference store + Checks the document to ensure that changes have not been made (e.g., in a different editor) + to invalidate the saved line folds. + @param {Editor} editor the editor whose saved line folds should be restored + */ + function restoreLineFolds(editor) { + var saveFolds = _prefs.getSetting("saveFoldStates"); + var rf = CodeMirror.fold.auto; + if (editor && saveFolds) { + var cm = editor._codeMirror, foldFunc; + if (!cm) {return; } + var path = editor.document.file.fullPath, keys; + var folds = cm._lineFolds || _prefs.get(path), vp = cm.getViewport(); + cm._lineFolds = cm.getValidFolds(folds); + _prefs.set(path, cm._lineFolds); + Object.keys(cm._lineFolds).forEach(function (line) { + cm.foldCode(+line); + }); + } + } + + /**Saves the line folds in the editor using the preference storage**/ + function saveLineFolds(editor) { + var saveFolds = _prefs.getSetting("saveFoldStates"); + if (!editor || !saveFolds) { return; } + var folds = editor._codeMirror._lineFolds || {}; + var path = editor.document.file.fullPath; + if (Object.keys(folds).length) { + _prefs.set(path, folds); + } else { + _prefs.set(path, undefined); + } + } + + function onGutterClick(cm, line, gutter, event) { + var opts = cm.state.foldGutter.options, pos = CodeMirror.Pos(line); + if (gutter !== opts.gutter) { return; } + var editor = EditorManager.getActiveEditor(), range, i; + var _lineFolds = cm._lineFolds; + if (cm.isFolded(line)) { + if (event.altKey) {//unfold code including children + range = _lineFolds[line]; + CodeMirror.commands.unfoldAll(cm, range.from.line, range.to.line); + } else { + cm.unfoldCode(line, {range: _lineFolds[line]}); + } + } else { + if (event.altKey) { + var rf = CodeMirror.fold.auto; + range = rf(cm, pos); + if (range) { + CodeMirror.commands.foldToLevel(cm, range.from.line, range.to.line); + } + } else { + cm.foldCode(line); + } + } + } + + /** + Collapses all custom regions defined in the current editor + */ + function collapseCustomRegions() { + var editor = EditorManager.getFocusedEditor(); + if (editor) { + var cm = editor._codeMirror, i = cm.firstLine(); + while (i < cm.lastLine()) { + var range = cm.foldCode(i, {rangeFinder: regionFold}); + if (range) { + i = range.to.line; + } else { + i++; + } + } + } + } + + /** + Collapses the code region nearest the current cursor position. + Nearest is found by searching from the current line and moving up the document until an + opening code-folding region is found. + */ + function collapseCurrent() { + var editor = EditorManager.getFocusedEditor(); + if (editor) { + var cm = editor._codeMirror; + var cursor = editor.getCursorPos(), i; + //move cursor up until a collapsible line is found + for (i = cursor.line; i >= 0; i--) { + if (cm.foldCode(i)) { + editor.setCursorPos(i); + return; + } + } + } + } + /** + Expands the code region at the current cursor position. + */ + function expandCurrent() { + var editor = EditorManager.getFocusedEditor(); + if (editor) { + var cursor = editor.getCursorPos(), cm = editor._codeMirror; + cm.unfoldCode(cursor.line); + } + } + /** + Collapses all foldable regions in the current document. Folding is done up to a level 'n' + which is defined in the preferences. Levels refer to fold heirarchies e.g., for the following + code fragment, the function is level 1, the if statement is level 2 and the forEach is level 3 + + function sample() { + if (debug) { + logMessages.forEach(function (m) { + console.debug(m); + }); + } + } + */ + function collapseAll() { + var editor = EditorManager.getFocusedEditor(); + if (editor && editor._codeMirror) { + var i, cm = editor._codeMirror, range; + CodeMirror.commands.foldToLevel(cm); + } + } + /** + Expands all folded regions in the current document + */ + function expandAll() { + var editor = EditorManager.getFocusedEditor(); + if (editor && editor._codeMirror) { + var i, cm = editor._codeMirror; + CodeMirror.commands.unfoldAll(cm); + } + } + + function registerHandlers(editor) { + var cm = editor._codeMirror; + if (cm) { + var path = editor.document.file.fullPath, _lineFolds = _prefs.get(path); + _lineFolds = _lineFolds || {}; + cm._lineFolds = _lineFolds; + var gutters = cm.getOption("gutters").slice(0); + var lnIndex = gutters.indexOf("CodeMirror-linenumbers"); + gutters.splice(lnIndex + 1, 0, gutterName); + cm.setOption("gutters", gutters); + cm.setOption("foldGutter", {onGutterClick: onGutterClick}); + + $(cm.getGutterElement()).on({ + mouseenter: function () { + if (_prefs.getSetting("fadeFoldButtons")) { + foldGutter.updateInViewport(cm); + } + }, + mouseleave: function () { + if (_prefs.getSetting("fadeFoldButtons")) { + foldGutter.clearGutter(cm); + } + } + }); + } + } + + function onActiveEditorChanged(event, current, previous) { + if (current && current._codeMirror.getOption("gutters").indexOf(gutterName) === -1) { + registerHandlers(current); + restoreLineFolds(current); + } + if (previous) { saveLineFolds(previous); } + } + + function saveBeforeClose() { + saveLineFolds(EditorManager.getCurrentFullEditor()); + } + + function showSettingsDialog() { + SettingsDialog.show(function () { + var editor = EditorManager.getCurrentFullEditor(); + if (editor) { + var cm = editor._codeMirror; + if (_prefs.getSetting("fadeFoldButtons")) { + foldGutter.clearGutter(cm); + } else { + foldGutter.updateInViewport(cm); + } + } + }); + } + + $(EditorManager).on("activeEditorChange", onActiveEditorChanged); + $(DocumentManager).on("documentRefreshed", function (event, doc) { + //restore the folds for this document + restoreLineFolds(doc._masterEditor); + }); + + $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); + + CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, showSettingsDialog); + CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); + CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); + + CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); + + CommandManager.register(Strings.COLLAPSE_CURRENT, COLLAPSE, collapseCurrent); + CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); + + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); + + KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-C"); + KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-X"); + KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); + KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); +}); \ No newline at end of file diff --git a/src/extensions/default/CodeFolding/main.less b/src/extensions/default/CodeFolding/main.less new file mode 100644 index 00000000000..1cf7c57a685 --- /dev/null +++ b/src/extensions/default/CodeFolding/main.less @@ -0,0 +1,54 @@ +@font-size: 1.2em; +@color: #aaa; + +.CodeMirror-foldgutter { + &-open:after { + content: "\25bc"; + font-size: @font-size; + color: @color; + } + &-folded:after { + content: "\25b6"; + font-size: @font-size; + color: @color; + } +} + +.CodeMirror-foldgutter, +.CodeMirror-foldgutter-open, +.CodeMirror-foldgutter-folded, +.CodeMirror-foldgutter-blank { + width: @font-size; + cursor: default; + line-height: 100%; +} + +.CodeMirror-gutter-elt { + height: 100% !important; +} + +.CodeMirror-foldmarker { + padding-right: 5px; + padding-left: 5px; + margin-right: 3px; + margin-left: 3px; + border-radius: 3px; + cursor: pointer; + border: 1px solid lighten(@color, 10%); + color: darken(@color, 20%); + background-color: lighten(@color, 20%); + + &:after { + content: "\2194"; + } +} + +#code-folding-settings-dialog { + label { + width: 40%; + padding-right: 10px; + } + input[type=number] { + width: 40px; + } +} \ No newline at end of file diff --git a/src/extensions/default/CodeFolding/nls/de/strings.js b/src/extensions/default/CodeFolding/nls/de/strings.js new file mode 100644 index 00000000000..c912c12ffa9 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/de/strings.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// German Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CollapseAll" : "Alle Abschnitte Zuklappen", + "ExpandAll" : "Alle Abschnitte Aufklappen", + "CollapseCurrent" : "Abschnitt Zuklappen", + "ExpandCurrent" : "Abschnitt Aufklappen", +}); diff --git a/src/extensions/default/CodeFolding/nls/es/strings.js b/src/extensions/default/CodeFolding/nls/es/strings.js new file mode 100644 index 00000000000..46d9cf02ec2 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/es/strings.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Spanish Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CollapseAll" : "Contraer Todo", + "ExpandAll" : "Expandir Todo", + "CollapseCurrent" : "Contraer Sección", + "ExpandCurrent" : "Expandir Sección", +}); diff --git a/src/extensions/default/CodeFolding/nls/fi/strings.js b/src/extensions/default/CodeFolding/nls/fi/strings.js new file mode 100644 index 00000000000..228821523d0 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/fi/strings.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Finnish Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "Koodin laskostuksen asetukset", + "COLLAPSE_ALL" : "Pienennä kaikki", + "EXPAND_ALL" : "Laajenna kaikki", + "COLLAPSE_CURRENT" : "Pienennä nykyinen", + "EXPAND_CURRENT" : "Laajenna nykyinen", + "COLLAPSE_CUSTOM_REGIONS" : "Pienennä mukautetut alueet", + + // Form variables region + "MIN_FOLD_SIZE" : "Pienin laskostuksen koko", + "MIN_FOLD_SIZE_HELP" : "Pienin sallittu laskostettavan alueen rivimäärä", + "ENABLE_REGION_FOLDING" : "Ota mukautetun alueen laskostus käyttöön", + "SAVE_FOLD_STATES" : "Tallenna laskosten tilat", + "SAVE_FOLD_STATES_HELP" : "Tallenna laskosten tilat levylle, kun editori suljetaan ja palauta ne, kun editori avataan uudelleen", + "ALWAYS_USE_INDENT_FOLD" : "Käytä aina sisennyslaskostusta", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Käytä aina sisennyksen tasoa laskostuksen ohjenuorana", + "FADE_FOLD_BUTTONS" : "Häivytä laskostuspainikkeet", + "FADE_FOLD_BUTTONS_HELP" : "Piilottaa laskostuspainikkeet, ellei osoitin ole sivumarginaalin päällä", + "MAX_FOLD_LEVEL" : "Suurin sallittu sisäkkäisten laskosten määrä", + "MAX_FOLD_LEVEL_HELP" : "Käytetään rajoittamaan sisäkkäisten laskosten määrää etsittäessä ja pienennettäessä, kun käytetään Näytä -> Pienennä kaikki \u2011komentoa tai kun Alt-näppäintä pidetään alhaalla pienennettäessä. Pitäisi parantaa suurten tiedostojen suorituskykyä.", + "BUTTON_SAVE" : "Tallenna", + "BUTTON_DEFAULTS" : "Palauta oletukset", + "BUTTON_CANCEL" : "Peruuta", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "Haluatko ladata Bracketsin uudelleen ottaaksesi uudet asetukset käyttöön? Sinua pyydetään tallentamaan muutokset tallentamattomiin dokumentteihin.", + "RELOAD_BRACKETS" : "Lataa Brackets uudelleen", + "BUTTON_RELOAD" : "Lataa uudelleen" +}); diff --git a/src/extensions/default/CodeFolding/nls/fr/strings.js b/src/extensions/default/CodeFolding/nls/fr/strings.js new file mode 100644 index 00000000000..b305a4ea8fa --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/fr/strings.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// French Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "Paramètres Code Folding", + "COLLAPSE_ALL" : "Tout réduire", + "EXPAND_ALL" : "Tout développer", + "COLLAPSE_CURRENT" : "Réduire", + "EXPAND_CURRENT" : "Développer", + + // Form variables region + "MIN_FOLD_SIZE" : "Taille de repli minimale", + "MIN_FOLD_SIZE_HELP" : "Nombre de lignes minimal pour proposer un repli", + "ENABLE_REGION_FOLDING" : "Activer le repli personnalisé de zone", + "SAVE_FOLD_STATES" : "Enregistrer l'état des replis", + "SAVE_FOLD_STATES_HELP" : "Enregistre l'état des replis sur le disque quand l'éditeur est fermé et les rétablit à sa réouverture", + "ALWAYS_USE_INDENT_FOLD" : "Toujours utiliser l'indentation du replis", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Toujours utiliser le niveau d'indentation comme norme de replis", + "USE_KEYBOARD_SHORTCUTS" : "Utiliser les raccourcis clavier", + "REMAP_KEYBOARD_SHORTCUTS" : "Redéfinir les raccourcis clavier", + "BUTTON_SAVE" : "Enregistrer", + "BUTTON_DEFAULTS" : "Réinitialiser", + "BUTTON_CANCEL" : "Annuler", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "Souhaitez-vous recharger Brackets pour appliquer les nouveaux paramètres ? Il vous sera demandé de sauvegarder les changements sur les documents ouverts.", + "RELOAD_BRACKETS" : "Recharger Brackets", + "BUTTON_RELOAD" : "Recharger" +}); diff --git a/src/extensions/default/CodeFolding/nls/gl/strings.js b/src/extensions/default/CodeFolding/nls/gl/strings.js new file mode 100644 index 00000000000..16b28d327ab --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/gl/strings.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Galician Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CollapseAll" : "Contraer Todo", + "ExpandAll" : "Expandir Todo", + "CollapseCurrent" : "Contraer Sección", + "ExpandCurrent" : "Expandir Sección", +}); diff --git a/src/extensions/default/CodeFolding/nls/it/strings.js b/src/extensions/default/CodeFolding/nls/it/strings.js new file mode 100644 index 00000000000..144a8051c28 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/it/strings.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Italian Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CollapseAll" : "Collassa tutto", + "ExpandAll" : "Espandi tutto", + "CollapseCurrent" : "Collassa", + "ExpandCurrent" : "Espandi", +}); diff --git a/src/extensions/default/CodeFolding/nls/ja/strings.js b/src/extensions/default/CodeFolding/nls/ja/strings.js new file mode 100644 index 00000000000..4220ba4f89d --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/ja/strings.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Japanese Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "折りたたみの設定", + "COLLAPSE_ALL" : "すべて折りたたむ", + "EXPAND_ALL" : "すべて展開", + "COLLAPSE_CURRENT" : "現在のグループを折りたたむ", + "EXPAND_CURRENT" : "現在のグループを展開", + "COLLAPSE_CUSTOM_REGIONS" : "カスタム領域を折りたたむ", + + // Form variables region + "MIN_FOLD_SIZE" : "折りたたみビューを表示する行数の最小値", + "MIN_FOLD_SIZE_HELP" : "Minimum number of lines to allow in a fold range", + "ENABLE_REGION_FOLDING" : "カスタム領域の折りたたみを有効にする", + "SAVE_FOLD_STATES" : "折りたたみ状態を保存する", + "SAVE_FOLD_STATES_HELP" : "Save fold states to disk when editor is closed and restore the folds when reopened", + "ALWAYS_USE_INDENT_FOLD" : "常にインデントの折りたたみを使用する", + "ALWAYS_USE_INDENT_FOLD_HELP" : "折りたたみのガイドラインとして常にインデント レベルを使用します", + //"USE_KEYBOARD_SHORTCUTS": "Use keyboard shortcuts", + //"REMAP_KEYBOARD_SHORTCUTS": "Remap keyboard shortcuts", + "BUTTON_SAVE" : "保存", + "BUTTON_DEFAULTS" : "既定の設定に戻す", + "BUTTON_CANCEL" : "キャンセル", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "新しい設定を有効にするには、Brackets を再読み込みする必要があります。未保存のドキュメントを、保存または破棄を確認するメッセージが表示されます。", + "RELOAD_BRACKETS" : "Brackets の再読み込み", + "BUTTON_RELOAD" : "再読み込み" +}); diff --git a/src/extensions/default/CodeFolding/nls/nl/strings.js b/src/extensions/default/CodeFolding/nls/nl/strings.js new file mode 100644 index 00000000000..b48db8b7fca --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/nl/strings.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Dutch translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "Code Folding instellingen", + "COLLAPSE_ALL" : "Alles inklappen", + "EXPAND_ALL" : "Alles uitklappen", + "COLLAPSE_CURRENT" : "Huidige inklappen", + "EXPAND_CURRENT" : "Huidige uitklappen", + "COLLAPSE_CUSTOM_REGIONS" : "Aangepaste regio's inklappen", + + // Form variables region + "MIN_FOLD_SIZE" : "Minimale vouwgrootte", + "MIN_FOLD_SIZE_HELP" : "Minimaal aantal regels om toe te staan in een vouwreeks", + "ENABLE_REGION_FOLDING" : "Aangepaste regio's inschakelen", + "SAVE_FOLD_STATES" : "Vouwstatus bewaren", + "SAVE_FOLD_STATES_HELP" : "Vouwstatus bewaren op schijf als editor gesloten wordt en herstellen wanneer opnieuw geopend", + "ALWAYS_USE_INDENT_FOLD" : "Altijd vouwindentatie gebruiken", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Altijd het indentatieniveau als vouwrichtlijn gebruiken", + "FADE_FOLD_BUTTONS" : "Vouwknoppen vervagen", + "FADE_FOLD_BUTTONS_HELP" : "Verberg de vouwknoppen, behalve als de muis over de goot hangt", + //"USE_KEYBOARD_SHORTCUTS" : "Gebruik toetsenbordshortcuts", + //"REMAP_KEYBOARD_SHORTCUTS" : "Aanpassen toetsenbordshortcuts", + "BUTTON_SAVE" : "Opslaan", + "BUTTON_DEFAULTS" : "Herstel standaarden", + "BUTTON_CANCEL" : "Annuleren", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "Wil je Brackets herstarten om de nieuwe instelingen toe te passen? Je zal gevraagd worden om wijzigingen in nog niet opgeslagen documenten op te slaan.", + "RELOAD_BRACKETS" : "Herstart Brackets", + "BUTTON_RELOAD" : "Herstart" +}); diff --git a/src/extensions/default/CodeFolding/nls/pt-BR/strings.js b/src/extensions/default/CodeFolding/nls/pt-BR/strings.js new file mode 100644 index 00000000000..b48d6017e5a --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/pt-BR/strings.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Spanish Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "Opções de Dobramento", + "COLLAPSE_ALL" : "Dobrar Tudo", + "EXPAND_ALL" : "Expandir Tudo", + "COLLAPSE_CURRENT" : "Dobrar Posição Atual", + "EXPAND_CURRENT" : "Expandir Posição Atual", + "COLLAPSE_CUSTOM_REGIONS" : "Dobrar Regiões Personalizadas", + + // Form variables region + "MIN_FOLD_SIZE" : "Tamanha Mínimo", + "MIN_FOLD_SIZE_HELP" : "Número Mínimo de linhas necessário para o dobramento", + "ENABLE_REGION_FOLDING" : "Regiões Personalizadas de Dobramento", + "SAVE_FOLD_STATES" : "Salvar Dobramentos", + "SAVE_FOLD_STATES_HELP" : "Salva o estado atual das dobras quando o editor é fechado e as restaura quando aberto", + "ALWAYS_USE_INDENT_FOLD" : "Sempre Usar Dobramento por Indentação", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Usa a Indentação como guia para o Dobramento", + "FADE_FOLD_BUTTONS" : "Ocultar os botões de Dobramento", + "FADE_FOLD_BUTTONS_HELP" : "Oculta os botões quando o cursor não está sobre eles", + "BUTTON_SAVE" : "Salvar", + "BUTTON_DEFAULTS" : "Restaurar Opções", + "BUTTON_CANCEL" : "Cancelar", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "Deseja reiniciar o Brackets para aplicar as novas configurações? Haverá a possibilidade de salvar os arquivos editados.", + "RELOAD_BRACKETS" : "Reiniciar Brackets", + "BUTTON_RELOAD" : "Recarregar" +}); diff --git a/src/extensions/default/CodeFolding/nls/root/strings.js b/src/extensions/default/CodeFolding/nls/root/strings.js new file mode 100644 index 00000000000..27a40e05b20 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/root/strings.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// English - root strings + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "Code Folding Settings", + "COLLAPSE_ALL" : "Collapse All", + "EXPAND_ALL" : "Expand All", + "COLLAPSE_CURRENT" : "Collapse Current", + "EXPAND_CURRENT" : "Expand Current", + "COLLAPSE_CUSTOM_REGIONS" : "Collapse Custom Regions", + + // Form variables region + "MIN_FOLD_SIZE" : "Minimum fold size", + "MIN_FOLD_SIZE_HELP" : "Minimum number of lines to allow in a fold range", + "ENABLE_REGION_FOLDING" : "Enable custom region folding", + "SAVE_FOLD_STATES" : "Save fold states", + "SAVE_FOLD_STATES_HELP" : "Save fold states to disk when editor is closed and restore the folds when reopened", + "ALWAYS_USE_INDENT_FOLD" : "Always use indent fold", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Always use level of indentation as a folding guideline", + "FADE_FOLD_BUTTONS" : "Fade fold buttons", + "FADE_FOLD_BUTTONS_HELP" : "Hides the fold buttons unless the mouse is over the gutter", + "MAX_FOLD_LEVEL" : "Maximum number of nested folds", + "MAX_FOLD_LEVEL_HELP" : "Used to limit the number of nested folds to find and collapse when View -> Collapse All is called or Alt is held down when collapsing. Should improve performance for large files.", + "BUTTON_SAVE" : "Save", + "BUTTON_DEFAULTS" : "Restore defaults", + "BUTTON_CANCEL" : "Cancel", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "Would you like to reload Brackets to apply the new settings? You will be prompted to save changes on unsaved documents.", + "RELOAD_BRACKETS" : "Reload Brackets", + "BUTTON_RELOAD" : "Reload" +}); diff --git a/src/extensions/default/CodeFolding/nls/ru/strings.js b/src/extensions/default/CodeFolding/nls/ru/strings.js new file mode 100644 index 00000000000..064a7c30a97 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/ru/strings.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +// Russian Translation + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define({ + "CODE_FOLDING_SETTINGS" : "Настройки Code Folding", + "COLLAPSE_ALL" : "Свернуть все", + "EXPAND_ALL" : "Развернуть все", + "COLLAPSE_CURRENT" : "Свернуть текущий", + "EXPAND_CURRENT" : "Развернуть текущий", + "COLLAPSE_CUSTOM_REGIONS" : "Свернуть текущий region", + + // Form variables region + "MIN_FOLD_SIZE" : "Минимальный размер сворачивания", + "MIN_FOLD_SIZE_HELP" : "Минимальное число строк для сворачивания", + "ENABLE_REGION_FOLDING" : "Включить сворачивание для region`ов", + "SAVE_FOLD_STATES" : "Сохранять состояние", + "SAVE_FOLD_STATES_HELP" : "Сохранить состояние свёрнутых/развёрнутых блоков на диск при закрытии редактора и восстановить при повторном открытии", + "ALWAYS_USE_INDENT_FOLD" : "Всегда использовать вложеность", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Всегда использовать уровень вложенности в качестве ориентира", + "FADE_FOLD_BUTTONS" : "Скрывать кнопки для фолдинга", + "FADE_FOLD_BUTTONS_HELP" : "Отображать кнопки для фолдинга только при наведении", + "MAX_FOLD_LEVEL" : "Максимальное число вложенных сворачиваний", + "MAX_FOLD_LEVEL_HELP" : "Используется для ограничения числа вложенных сворачиваний, чтобы свернуть воспользуйтесь Вид-> Свернуть Все или зажмите Alt во время сворачивания. Это улучшит производительность для больших файлов.", + "BUTTON_SAVE" : "Сохранить", + "BUTTON_DEFAULTS" : "Востановить значения по умолчанию", + "BUTTON_CANCEL" : "Отмена", + + // Endregion + "CONFIRM_RELOAD_BRACKETS" : "Вы хотите перезагрузить Brackets, чтобы применить новые параметры? Вам будет предложено сохранить все изменения.", + "RELOAD_BRACKETS" : "Перегрузить Brackets", + "BUTTON_RELOAD" : "Перегрузить" +}); diff --git a/src/extensions/default/CodeFolding/nls/strings.js b/src/extensions/default/CodeFolding/nls/strings.js new file mode 100644 index 00000000000..830bae493c6 --- /dev/null +++ b/src/extensions/default/CodeFolding/nls/strings.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +define(function (require, exports, module) { + + 'use strict'; + + // Code that needs to display user strings should call require("strings") to load + // strings.js. This file will dynamically load strings.js for the specified by bracketes.locale. + // + // Translations for other locales should be placed in nls/>/strings.js + // Localization is provided via the i18n plugin. + // All other bundles for languages need to add a prefix to the exports below so i18n can find them. + // TODO: dynamically populate the local prefix list below? + module.exports = { + root: true, + "de": true, + "es": true, + "fi": true, + "fr": true, + "gl": true, + "it": true, + "ja": true, + "nl": true, + "ru": true + }; +}); + diff --git a/src/extensions/default/CodeFolding/strings.js b/src/extensions/default/CodeFolding/strings.js new file mode 100644 index 00000000000..56386bab4e8 --- /dev/null +++ b/src/extensions/default/CodeFolding/strings.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +/** + * This file provides the interface to user visible strings in Brackets. Code that needs + * to display strings should should load this module by calling var Strings = require("strings"). + * The i18n plugin will dynamically load the strings for the right locale and populate + * the exports variable. See src\nls\strings.js for the master file of English strings. + */ +define(function (require, exports, module) { + "use strict"; + + module.exports = require("i18n!nls/strings"); + +}); \ No newline at end of file From a69a289360d0ded75f6da4514b3d23e71ab74224 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Wed, 25 Mar 2015 15:47:34 +0000 Subject: [PATCH 02/11] JSHint error fixes --- .../default/CodeFolding/DefaultSettings.js | 2 +- src/extensions/default/CodeFolding/Prefs.js | 1 - .../default/CodeFolding/SettingsDialog.js | 8 ++--- .../CodeFolding/foldhelpers/foldcode.js | 4 +-- .../CodeFolding/foldhelpers/foldgutter.js | 12 +++---- .../CodeFolding/foldhelpers/latex-fold.js | 2 +- .../CodeFolding/foldhelpers/region-fold.js | 2 +- src/extensions/default/CodeFolding/main.js | 34 ++++--------------- 8 files changed, 21 insertions(+), 44 deletions(-) diff --git a/src/extensions/default/CodeFolding/DefaultSettings.js b/src/extensions/default/CodeFolding/DefaultSettings.js index 10200605ee8..a4da6844ef8 100644 --- a/src/extensions/default/CodeFolding/DefaultSettings.js +++ b/src/extensions/default/CodeFolding/DefaultSettings.js @@ -4,7 +4,7 @@ * @date 8/23/14 15:45:35 PM */ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define, require, brackets, window */ +/*global define*/ define(function (require, exports, module) { "use strict"; diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index b4dbb1f6643..1a7a5892378 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -9,7 +9,6 @@ define(function (require, exports, module) { "use strict"; var PreferencesManager = brackets.getModule("preferences/PreferencesManager"), - _prefs = PreferencesManager.getExtensionPrefs("code-folding"), stateManager = PreferencesManager.stateManager.getPrefixedSystem("code-folding"), DefaultSettings = require("DefaultSettings"), store = {}, diff --git a/src/extensions/default/CodeFolding/SettingsDialog.js b/src/extensions/default/CodeFolding/SettingsDialog.js index aebb340b94a..3d18a46280e 100644 --- a/src/extensions/default/CodeFolding/SettingsDialog.js +++ b/src/extensions/default/CodeFolding/SettingsDialog.js @@ -4,13 +4,12 @@ * @date 8/23/14 12:32:46 PM */ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define, require, brackets, Mustache, $ */ +/*global define, brackets, Mustache, $ */ define(function (require, exports, module) { "use strict"; var Dialogs = brackets.getModule("widgets/Dialogs"), DefaultSettings = require("DefaultSettings"), Strings = require("i18n!nls/strings"), - CommandManager = brackets.getModule("command/CommandManager"), settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), preferences = require("Prefs"); @@ -30,7 +29,6 @@ define(function (require, exports, module) { function showDialog(cb) { var template = Mustache.render(settingsTemplate, Strings); var dialog = Dialogs.showModalDialogUsingTemplate(template); - var useShortcuts; setFormValues(preferences.getAllSettings()); dialog.done(function (buttonId) { @@ -39,10 +37,10 @@ define(function (require, exports, module) { var minFoldSize = $("#min-fold-size", $dialog).val(); var maxFoldLevel = $("#max-fold-level", $dialog).val(); preferences.setSetting("minFoldSize", isNaN(minFoldSize) || +minFoldSize === 0 ? - +preferences.getSetting("minFoldSize") : +minFoldSize); + +preferences.getSetting("minFoldSize") : +minFoldSize); preferences.setSetting("saveFoldStates", $("#save-fold-states", $dialog).prop("checked")); preferences.setSetting("maxFoldLevel", isNaN(maxFoldLevel) || +maxFoldLevel === 0 ? - +preferences.getSetting("maxFoldLevel") : +maxFoldLevel); + +preferences.getSetting("maxFoldLevel") : +maxFoldLevel); preferences.setSetting("alwaysUseIndentFold", $("#always-use-indent-fold", $dialog).prop("checked")); preferences.setSetting("enableRegionFolding", $("#enable-region-folding", $dialog).prop("checked")); preferences.setSetting("fadeFoldButtons", $("#fade-fold-buttons", $dialog).prop("checked")); diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js index f7b1abcb39b..51ba8e39fbb 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js @@ -126,7 +126,7 @@ define(function (require, exports, module) { CodeMirror.defineExtension("getValidFolds", function (folds) { var keys, rf = CodeMirror.fold.auto, cm = this, result = {}; if (folds && (keys = Object.keys(folds)).length) { - var i, range, cachedRange; + var range, cachedRange; keys.forEach(function (lineNumber) { lineNumber = +lineNumber; if (lineNumber >= cm.firstLine() && lineNumber <= cm.lastLine()) { @@ -168,7 +168,7 @@ define(function (require, exports, module) { var rf = CodeMirror.fold.auto, level = prefs.getSetting("maxFoldLevel"); function foldLevel(n, from, to) { if (n > 0) { - var i = from, e, range; + var i = from, range; while (i < to) { range = rf(cm, CodeMirror.Pos(i, 0)); if (range) { diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js index 973095d0b77..5bda7d82949 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js @@ -5,7 +5,7 @@ * @date 10/24/13 10:14:01 AM */ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define, brackets, document, clearTimeout, setTimeout, $*/ +/*global define, brackets, document, window, $*/ define(function (require, exports, module) { "use strict"; var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); @@ -74,7 +74,7 @@ define(function (require, exports, module) { gutter update after the viewport has been drawn. */ if (i === to) { - setTimeout(function () { + window.setTimeout(function () { var vp = cm.getViewport(); updateFoldInfo(cm, vp.from, vp.to); }, 200); @@ -188,8 +188,8 @@ define(function (require, exports, module) { } state.from = changeObj.from.line; state.to = 0; - clearTimeout(state.changeUpdate); - state.changeUpdate = setTimeout(function () { + window.clearTimeout(state.changeUpdate); + state.changeUpdate = window.setTimeout(function () { updateInViewport(cm); }, prefs.getSetting("foldOnChangeTimeSpan") || 600); } @@ -197,8 +197,8 @@ define(function (require, exports, module) { function onViewportChange(cm) { var state = cm.state.foldGutter; - clearTimeout(state.changeUpdate); - state.changeUpdate = setTimeout(function () { + window.clearTimeout(state.changeUpdate); + state.changeUpdate = window.setTimeout(function () { var vp = cm.getViewport(); if (state.from === state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { updateInViewport(cm); diff --git a/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js b/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js index 1fc65df7481..d9c08a5aee7 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js @@ -4,7 +4,7 @@ * @date 11/29/13 10:56:52 AM */ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define, brackets, CodeMirror*/ +/*global define, brackets */ define(function (require, exports, module) { "use strict"; diff --git a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js index a0c7d8eff75..071287914b8 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js @@ -38,7 +38,7 @@ define(function (require, exports, module) { endCh = nextClose; end = i; return {from: CodeMirror.Pos(line, stack[0]), - to: CodeMirror.Pos(end, endCh)}; + to: CodeMirror.Pos(end, endCh)}; } stack.pop(); } diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index 594a4a39dda..3f8dd0b9e09 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -26,7 +26,7 @@ * @date 10/24/13 9:35:26 AM */ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define, d3, require, $, brackets, window, MouseEvent */ +/*global define, require, $, brackets*/ require.config({ paths: { @@ -48,7 +48,6 @@ define(function (require, exports, module) { ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), Menus = brackets.getModule("command/Menus"), _prefs = require("./Prefs"), - CODE_FOLD_EXT = "javascript.code.folding", COLLAPSE_ALL = "codefolding.collapse.all", COLLAPSE = "codefolding.collapse", EXPAND = "codefolding.expand", @@ -87,24 +86,6 @@ define(function (require, exports, module) { CodeMirror.registerHelper("fold", "stex", latexFold); CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); - - /** gets the folded regions in the editor. - * @returns a map containing {linenumber: {from, to}} - */ - function getLineFoldsInEditor(editor) { - var cm = editor._codeMirror, i, folds = {}; - if (cm) { - var marks = cm.getAllMarks(); - marks.filter(function (m) {return m.__isFold; }) - .forEach(function (mark) { - var range = mark.find(); - if (range) { - folds[range.from.line] = range; - } - }); - } - return folds; - } /** Restores the linefolds in the editor using values fetched from the preference store @@ -114,12 +95,11 @@ define(function (require, exports, module) { */ function restoreLineFolds(editor) { var saveFolds = _prefs.getSetting("saveFoldStates"); - var rf = CodeMirror.fold.auto; if (editor && saveFolds) { - var cm = editor._codeMirror, foldFunc; + var cm = editor._codeMirror; if (!cm) {return; } - var path = editor.document.file.fullPath, keys; - var folds = cm._lineFolds || _prefs.get(path), vp = cm.getViewport(); + var path = editor.document.file.fullPath; + var folds = cm._lineFolds || _prefs.get(path); cm._lineFolds = cm.getValidFolds(folds); _prefs.set(path, cm._lineFolds); Object.keys(cm._lineFolds).forEach(function (line) { @@ -144,7 +124,7 @@ define(function (require, exports, module) { function onGutterClick(cm, line, gutter, event) { var opts = cm.state.foldGutter.options, pos = CodeMirror.Pos(line); if (gutter !== opts.gutter) { return; } - var editor = EditorManager.getActiveEditor(), range, i; + var range; var _lineFolds = cm._lineFolds; if (cm.isFolded(line)) { if (event.altKey) {//unfold code including children @@ -229,7 +209,7 @@ define(function (require, exports, module) { function collapseAll() { var editor = EditorManager.getFocusedEditor(); if (editor && editor._codeMirror) { - var i, cm = editor._codeMirror, range; + var cm = editor._codeMirror; CodeMirror.commands.foldToLevel(cm); } } @@ -239,7 +219,7 @@ define(function (require, exports, module) { function expandAll() { var editor = EditorManager.getFocusedEditor(); if (editor && editor._codeMirror) { - var i, cm = editor._codeMirror; + var cm = editor._codeMirror; CodeMirror.commands.unfoldAll(cm); } } From 1fb62d1ee77425812775344f27440b1175f54e66 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Sun, 29 Mar 2015 02:40:32 +0100 Subject: [PATCH 03/11] Refactored extension to use brackets style exports properties. Added some api documentation for functions. --- .../default/CodeFolding/DefaultSettings.js | 20 +- src/extensions/default/CodeFolding/Prefs.js | 138 ++++-- .../default/CodeFolding/SettingsDialog.js | 99 ++-- .../CodeFolding/foldhelpers/foldcode.js | 191 ++++---- .../CodeFolding/foldhelpers/foldgutter.js | 453 ++++++++++-------- .../CodeFolding/foldhelpers/indentFold.js | 16 +- .../CodeFolding/foldhelpers/latex-fold.js | 12 +- .../CodeFolding/foldhelpers/region-fold.js | 80 ++-- src/extensions/default/CodeFolding/main.js | 201 ++++---- 9 files changed, 666 insertions(+), 544 deletions(-) diff --git a/src/extensions/default/CodeFolding/DefaultSettings.js b/src/extensions/default/CodeFolding/DefaultSettings.js index a4da6844ef8..aa54d20113b 100644 --- a/src/extensions/default/CodeFolding/DefaultSettings.js +++ b/src/extensions/default/CodeFolding/DefaultSettings.js @@ -6,14 +6,14 @@ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ /*global define*/ define(function (require, exports, module) { - "use strict"; - - module.exports = { - minFoldSize: 2, - saveFoldStates: true, - alwaysUseIndentFold: true, - enableRegionFolding: true, - fadeFoldButtons: false, + "use strict"; + + module.exports = { + minFoldSize: 2, + saveFoldStates: true, + alwaysUseIndentFold: true, + enableRegionFolding: true, + fadeFoldButtons: false, maxFoldLevel: 2 // this value is only used when fold all is called - }; -}); \ No newline at end of file + }; +}); diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index 1a7a5892378..4cb7712f8fd 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -1,5 +1,5 @@ /** - * Wrapper around brackets pref system to ensure preferences are stored in in one single object instead of using multiple keys. + * Wrapper around brackets pref system to ensure preferences are stored in in one single object instead of using multiple keys. * This is to make it easy for the user who edits their preferences file to easily manage the potentially numerous lines of preferences generated by the persisting code-folding state. * @author Patrick Oladimeji * @date 3/22/14 20:39:53 PM @@ -10,63 +10,117 @@ define(function (require, exports, module) { "use strict"; var PreferencesManager = brackets.getModule("preferences/PreferencesManager"), stateManager = PreferencesManager.stateManager.getPrefixedSystem("code-folding"), - DefaultSettings = require("DefaultSettings"), + DefaultSettings = require("DefaultSettings"), store = {}, - settings = {}, - folds = "folds"; - + settings = {}, + foldsKey = "folds"; + /** + Simplifies the fold ranges into an array of pairs of numbers. + @param {!{number: {from: {ch, line}, to: {ch, line}} folds the raw fold ranges indexed by line numbers + @returns {number: Array>} an object whose keys are line numbers and the values are array + of two 2-element arrays. First array contains [from.line, from.ch] and the second contains [to.line, to.ch] + */ function simplify(folds) { - if (!folds) { return folds; } + if (!folds) { + return folds; + } var res = {}, range; - Object.keys(folds).map(function (line) { + Object.keys(folds).forEach(function (line) { range = folds[line]; res[line] = Array.isArray(range) ? range : [[range.from.line, range.from.ch], [range.to.line, range.to.ch]]; }); return res; } - + /** + Inflates the fold ranges stored as simplified numeric arrays. The inflation converts the data into + objects whose keys are line numbers and whose values are objects in the format {from: {line, ch}, to: {line, ch}}. + @param {number: Array>} folds the simplified fold ranges + @returns {number: {from: {line, ch}, to: {line, ch}}} + */ function inflate(folds) { - if (!folds) { return folds; } + if (!folds) { + return folds; + } //transform the folds into objects with from and to properties var ranges = {}, obj; Object.keys(folds).forEach(function (line) { obj = folds[line]; ranges[line] = {from: {line: obj[0][0], ch: obj[0][1]}, to: {line: obj[1][0], ch: obj[1][1]}}; }); - + return ranges; } - - module.exports = { - get: function (id) { - store = (stateManager.get(folds) || {}); - return inflate(store[id]); - }, - set: function (id, value) { - store[id] = simplify(value); - stateManager.set(folds, store); - stateManager.save(); - }, - getSetting: function (key) { - settings = (stateManager.get("settings") || DefaultSettings); - return settings[key]; - }, - setSetting: function (key, value) { - settings[key] = value; - stateManager.set("settings", settings); - stateManager.save(); - }, - getAllSettings: function () { - var res = {}, self = this; - Object.keys(DefaultSettings).forEach(function (key) { - res[key] = self.getSetting(key); - }); - return res; - }, - clearAllFolds: function () { - stateManager.set(folds, {}); - stateManager.save(); - } - }; + + /** + Gets the line folds saved for the specified path. + @param {string} path the document path + @returns {number: {from: {line, ch}, to: {line, ch}}} the line folds for the document at the specified path + */ + function get(path) { + store = (stateManager.get(foldsKey) || {}); + return inflate(store[path]); + } + + /** + Saves the line folds specified + */ + function set(path, folds) { + store[path] = simplify(folds); + stateManager.set(foldsKey, store); + stateManager.save(); + } + + /** + Get the code folding setting with the specified key from the store + @param {!string} key The key for the setting to retrieve + @returns {string} the setting with the specified key + */ + function getSetting(key) { + settings = (stateManager.get("settings") || DefaultSettings); + return settings[key]; + } + + /** + Save the code folding setting with the specified key using the specified value + @param {!string} key + @param {!string} value + */ + function setSetting(key, value) { + settings[key] = value; + stateManager.set("settings", settings); + stateManager.save(); + } + + /** + Gets all the values for code folding settings. + @returns {object} all settings saved in the preferences. + */ + function getAllSettings() { + var res = {}; + Object.keys(DefaultSettings).forEach(function (key) { + res[key] = getSetting(key); + }); + return res; + } + + /** + Clears all the saved line folds for all documents. + */ + function clearAllFolds() { + stateManager.set(foldsKey, {}); + stateManager.save(); + } + + module.exports.get = get; + + module.exports.set = set; + + module.exports.getSetting = getSetting; + + module.exports.setSetting = setSetting; + + module.exports.getAllSettings = getAllSettings; + + module.exports.clearAllFolds = clearAllFolds; }); diff --git a/src/extensions/default/CodeFolding/SettingsDialog.js b/src/extensions/default/CodeFolding/SettingsDialog.js index 3d18a46280e..7512dcae50c 100644 --- a/src/extensions/default/CodeFolding/SettingsDialog.js +++ b/src/extensions/default/CodeFolding/SettingsDialog.js @@ -7,60 +7,63 @@ /*global define, brackets, Mustache, $ */ define(function (require, exports, module) { "use strict"; - var Dialogs = brackets.getModule("widgets/Dialogs"), - DefaultSettings = require("DefaultSettings"), - Strings = require("i18n!nls/strings"), - settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), - preferences = require("Prefs"); - - function setFormValues(prefs) { - $("#min-fold-size").val(prefs.minFoldSize || 2); + var Dialogs = brackets.getModule("widgets/Dialogs"), + DefaultSettings = require("DefaultSettings"), + Strings = require("i18n!nls/strings"), + settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), + preferences = require("Prefs"); + + function setFormValues(prefs) { + $("#min-fold-size").val(prefs.minFoldSize || 2); $("#max-fold-level").val(prefs.maxFoldLevel || 2); - $("#save-fold-states").prop("checked", prefs.saveFoldStates); - $("#always-use-indent-fold").prop("checked", prefs.alwaysUseIndentFold); - $("#enable-region-folding").prop("checked", prefs.enableRegionFolding); - $("#fade-fold-buttons").prop("checked", prefs.fadeFoldButtons); - } - - function restoreDefaults() { - setFormValues(DefaultSettings); - } - - function showDialog(cb) { - var template = Mustache.render(settingsTemplate, Strings); - var dialog = Dialogs.showModalDialogUsingTemplate(template); - setFormValues(preferences.getAllSettings()); - + $("#save-fold-states").prop("checked", prefs.saveFoldStates); + $("#always-use-indent-fold").prop("checked", prefs.alwaysUseIndentFold); + $("#enable-region-folding").prop("checked", prefs.enableRegionFolding); + $("#fade-fold-buttons").prop("checked", prefs.fadeFoldButtons); + } + + function restoreDefaults() { + setFormValues(DefaultSettings); + } + + /** + Shows the preferences dialog + @param {function} cb a callback function to invoke when the dialog has been accepted or dismised + */ + function showDialog(cb) { + var template = Mustache.render(settingsTemplate, Strings); + var dialog = Dialogs.showModalDialogUsingTemplate(template); + setFormValues(preferences.getAllSettings()); + dialog.done(function (buttonId) { - if (buttonId === "ok") { - var $dialog = dialog.getElement(); - var minFoldSize = $("#min-fold-size", $dialog).val(); + if (buttonId === "ok") { + var $dialog = dialog.getElement(); + var minFoldSize = $("#min-fold-size", $dialog).val(); var maxFoldLevel = $("#max-fold-level", $dialog).val(); - preferences.setSetting("minFoldSize", isNaN(minFoldSize) || +minFoldSize === 0 ? + preferences.setSetting("minFoldSize", isNaN(minFoldSize) || +minFoldSize === 0 ? +preferences.getSetting("minFoldSize") : +minFoldSize); - preferences.setSetting("saveFoldStates", $("#save-fold-states", $dialog).prop("checked")); - preferences.setSetting("maxFoldLevel", isNaN(maxFoldLevel) || +maxFoldLevel === 0 ? + preferences.setSetting("saveFoldStates", $("#save-fold-states", $dialog).prop("checked")); + preferences.setSetting("maxFoldLevel", isNaN(maxFoldLevel) || +maxFoldLevel === 0 ? +preferences.getSetting("maxFoldLevel") : +maxFoldLevel); preferences.setSetting("alwaysUseIndentFold", $("#always-use-indent-fold", $dialog).prop("checked")); - preferences.setSetting("enableRegionFolding", $("#enable-region-folding", $dialog).prop("checked")); - preferences.setSetting("fadeFoldButtons", $("#fade-fold-buttons", $dialog).prop("checked")); - if (cb && typeof cb === "function") { - cb(); - } - } - }); - } - - function bindListeners() { - $("button[data-button-id='defaults']").on("click", function (e) { + preferences.setSetting("enableRegionFolding", $("#enable-region-folding", $dialog).prop("checked")); + preferences.setSetting("fadeFoldButtons", $("#fade-fold-buttons", $dialog).prop("checked")); + } + + if (cb && typeof cb === "function") { + cb(); + } + }); + } + + function bindListeners() { + $("button[data-button-id='defaults']").on("click", function (e) { e.stopPropagation(); restoreDefaults(); }); - } - - bindListeners(); - - module.exports = { - show: showDialog - }; -}); \ No newline at end of file + } + + bindListeners(); + + exports.show = showDialog; +}); diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js index 51ba8e39fbb..a565f28884e 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js @@ -8,95 +8,101 @@ /*global define, brackets, document*/ define(function (require, exports, module) { "use strict"; - var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), - prefs = require("Prefs"); + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + prefs = require("Prefs"); - module.exports = function () { - function doFold(cm, pos, options, force) { - force = force || "fold"; - if (typeof pos === "number") { - pos = CodeMirror.Pos(pos, 0); - } - var finder = (options && options.rangeFinder) || CodeMirror.fold.auto; - var minSize = (options && options.minFoldSize) || prefs.getSetting("minFoldSize"); + function doFold(cm, pos, options, force) { + options = options || {}; + force = force || "fold"; + if (typeof pos === "number") { + pos = CodeMirror.Pos(pos, 0); + } + var finder = options.rangeFinder || CodeMirror.fold.auto; + var minSize = options.minFoldSize || prefs.getSetting("minFoldSize"); - function getRange(allowFolded) { - var range = options && options.range ? options.range : finder(cm, pos); - if (!range || range.to.line - range.from.line < minSize) { - return null; - } - var marks = cm.findMarksAt(range.from), - i; - for (i = 0; i < marks.length; ++i) { - if (marks[i].__isFold && force !== "fold") { - if (!allowFolded) { - return null; - } - range.cleared = true; - marks[i].clear(); + function getRange(allowFolded) { + var range = options.range || finder(cm, pos); + if (!range || range.to.line - range.from.line < minSize) { + return null; + } + var marks = cm.findMarksAt(range.from), + i, + lastMark, + foldMarks; + for (i = 0; i < marks.length; ++i) { + if (marks[i].__isFold && force !== "fold") { + if (!allowFolded) { + return null; } + range.cleared = true; + marks[i].clear(); } - //check for overlapping folds - var lastMark, foldMarks; - if (marks && marks.length) { - foldMarks = marks.filter(function (d) { return d.__isFold; }); - if (foldMarks && foldMarks.length) { - lastMark = foldMarks[foldMarks.length - 1].find(); - if (lastMark && range.from.line <= lastMark.to.line && lastMark.to.line < range.to.line) { - return null; - } + } + //check for overlapping folds + if (marks && marks.length) { + foldMarks = marks.filter(function (d) { + return d.__isFold; + }); + if (foldMarks && foldMarks.length) { + lastMark = foldMarks[foldMarks.length - 1].find(); + if (lastMark && range.from.line <= lastMark.to.line && lastMark.to.line < range.to.line) { + return null; } } - return range; } + return range; + } - function makeWidget() { - var widget = document.createElement("span"); - widget.className = "CodeMirror-foldmarker"; - return widget; - } + function makeWidget() { + var widget = document.createElement("span"); + widget.className = "CodeMirror-foldmarker"; + return widget; + } - var range = getRange(true); - if (options && options.scanUp) { - while (!range && pos.line > cm.firstLine()) { - pos = CodeMirror.Pos(pos.line - 1, 0); - range = getRange(false); - } - } - if (!range || range.cleared || force === "unfold" || range.to.line - range.from.line < minSize) { - if (range) { range.cleared = false; } - return; + var range = getRange(true); + if (options.scanUp) { + while (!range && pos.line > cm.firstLine()) { + pos = CodeMirror.Pos(pos.line - 1, 0); + range = getRange(false); } + } + if (!range || range.cleared || force === "unfold" || range.to.line - range.from.line < minSize) { + if (range) { range.cleared = false; } + return; + } - var myWidget = makeWidget(); - var myRange = cm.markText(range.from, range.to, { - replacedWith: myWidget, - clearOnEnter: true, - __isFold: true - }); - CodeMirror.on(myWidget, "mousedown", function () { - myRange.clear(); - }); - myRange.on("clear", function (from, to) { - delete cm._lineFolds[from.line]; - CodeMirror.signal(cm, "unfold", cm, from, to); - }); - - if (force === "fold") { - delete range.cleared; - cm._lineFolds[pos.line] = range; - } else { - delete cm._lineFolds[pos.line]; - } - CodeMirror.signal(cm, force, cm, range.from, range.to); - return range; + var myWidget = makeWidget(); + var myRange = cm.markText(range.from, range.to, { + replacedWith: myWidget, + clearOnEnter: true, + __isFold: true + }); + CodeMirror.on(myWidget, "mousedown", function () { + myRange.clear(); + }); + myRange.on("clear", function (from, to) { + delete cm._lineFolds[from.line]; + CodeMirror.signal(cm, "unfold", cm, from, to); + }); + + if (force === "fold") { + delete range.cleared; + cm._lineFolds[pos.line] = range; + } else { + delete cm._lineFolds[pos.line]; } + CodeMirror.signal(cm, force, cm, range.from, range.to); + return range; + } + /** + Initialises extensions and helpers on the CodeMirror object + */ + function init() { CodeMirror.defineExtension("foldCode", function (pos, options, force) { return doFold(this, pos, options, force); }); - //define an unfoldCode extension to quickly unfold folded code CodeMirror.defineExtension("unfoldCode", function (pos, options) { return doFold(this, pos, options, "unfold"); }); @@ -152,6 +158,7 @@ define(function (require, exports, module) { CodeMirror.commands.unfold = function (cm, options, force) { cm.foldCode(cm.getCursor(), options, "unfold"); }; + CodeMirror.commands.foldAll = function (cm) { cm.operation(function () { var i, e; @@ -160,6 +167,17 @@ define(function (require, exports, module) { } }); }; + + CodeMirror.commands.unfoldAll = function (cm, from, to) { + from = from || cm.firstLine(); + to = to || cm.lastLine(); + cm.operation(function () { + var i, e; + for (i = from, e = to; i <= e; i++) { + if (cm.isFolded(i)) { cm.unfoldCode(i, {range: cm._lineFolds[i]}); } + } + }); + }; /** Folds the specified range. The descendants of any fold regions within the range are also folded up to a level set globally in the codeFolding preferences @@ -188,30 +206,21 @@ define(function (require, exports, module) { foldLevel(level, start, end); }); }; - - CodeMirror.commands.unfoldAll = function (cm, from, to) { - from = from || cm.firstLine(); - to = to || cm.lastLine(); - cm.operation(function () { - var i, e; - for (i = from, e = to; i <= e; i++) { - if (cm.isFolded(i)) { cm.unfoldCode(i, {range: cm._lineFolds[i]}); } - } - }); - }; CodeMirror.registerHelper("fold", "auto", function (cm, start) { var helpers = cm.getHelpers(start, "fold"), i, cur; - //ensure mode helper is loaded if there is one - var mode = cm.getMode().name; - var modeHelper = CodeMirror.fold[mode]; - if (modeHelper && helpers.indexOf(modeHelper) < 0) { - helpers.push(modeHelper); - } + //ensure mode helper is loaded if there is one + var mode = cm.getMode().name; + var modeHelper = CodeMirror.fold[mode]; + if (modeHelper && helpers.indexOf(modeHelper) < 0) { + helpers.push(modeHelper); + } for (i = 0; i < helpers.length; i++) { cur = helpers[i](cm, start); if (cur) { return cur; } } }); - }; -}); \ No newline at end of file + } + + exports.init = init; +}); diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js index 5bda7d82949..0fd13cc46cb 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js @@ -1,6 +1,5 @@ /** * Based on http://codemirror.net/addon/fold/foldgutter.js - Modulised by: * @author Patrick Oladimeji * @date 10/24/13 10:14:01 AM */ @@ -8,234 +7,275 @@ /*global define, brackets, document, window, $*/ define(function (require, exports, module) { "use strict"; - var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); - var prefs = require("Prefs"); - - module.exports = function () { - function State(options) { - this.options = options; - this.from = this.to = 0; - } - - function parseOptions(opts) { - if (opts === true) { opts = {}; } - if (!opts.gutter) { opts.gutter = "CodeMirror-foldgutter"; } - if (!opts.indicatorOpen) { opts.indicatorOpen = "CodeMirror-foldgutter-open"; } - if (!opts.indicatorFolded) { opts.indicatorFolded = "CodeMirror-foldgutter-folded"; } - return opts; - } - - function marker(spec) { - if (typeof spec === "string") { - var elt = document.createElement("div"); - elt.className = spec; - return elt; - } else { - return spec.cloneNode(true); - } - } - + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + prefs = require("Prefs"); + + function State(options) { + this.options = options; + this.from = this.to = 0; + } + + function parseOptions(opts) { + if (opts === true) { opts = {}; } + if (!opts.gutter) { opts.gutter = "CodeMirror-foldgutter"; } + if (!opts.indicatorOpen) { opts.indicatorOpen = "CodeMirror-foldgutter-open"; } + if (!opts.indicatorFolded) { opts.indicatorFolded = "CodeMirror-foldgutter-folded"; } + return opts; + } + + /** + Utility for creating fold markers in fold gutter + @param {string} spec the className for the marker + @returns {HTMLElement} + */ + function marker(spec) { + var elt = document.createElement("div"); + elt.className = spec; + return elt; + } + + /** + Updates the gutter markers for the specified range + @param {!CodeMirror} cm the CodeMirror instance for the active editor + @param {!number} from the starting line for the update + @param {!number} to the ending line for the update + */ + function updateFoldInfo(cm, from, to) { + var minFoldSize = prefs.getSetting("minFoldSize") || 2; + var opts = cm.state.foldGutter.options; + var fade = prefs.getSetting("fadeFoldButtons"); + var gutter = $(cm.getGutterElement()); + var i = from; + var isFold = function (m) { + return m.__isFold; + }, clear = function (m) {return m.clear(); }; + /** - Updates the gutter markers for the specified range - @param cm the codemirror object - @param {Number} from the starting line for the update - @param {Number} to the ending line for the update + helper function to check if the given line is in a folded region in the editor. + @param {Number} line the + @return {from: {ch: Number, line: Number}, to: {ch: Number, line: Number}} the range that hides the specified line or undefine if the line is not hidden */ - function updateFoldInfo(cm, from, to) { - var minFoldSize = prefs.getSetting("minFoldSize") || 2; - var opts = cm.state.foldGutter.options; - var fade = prefs.getSetting("fadeFoldButtons"); - var gutter = $(cm.getGutterElement()); - var i = from; - var isFold = function (m) { - return m.__isFold; - }, clear = function (m) {return m.clear(); }; - - /** - helper function to check if the given line is in a folded region in the editor. - @param {Number} line the - @return {from: {ch: Number, line: Number}, to: {ch: Number, line: Number}} the range that hides the specified line or undefine if the line is not hidden - */ - function _isCurrentlyFolded(line) { - var keys = Object.keys(cm._lineFolds), i = 0, r; - while (i < keys.length) { - r = cm._lineFolds[keys[i]]; - if (r.from.line < line && r.to.line >= line) { - return r; - } - i++; + function _isCurrentlyFolded(line) { + var keys = Object.keys(cm._lineFolds), i = 0, r; + while (i < keys.length) { + r = cm._lineFolds[keys[i]]; + if (r.from.line < line && r.to.line >= line) { + return r; } + i++; } - - /** - This case is needed when unfolding a region that does not cause the viewport to change. - For instance in a file with about 15 lines, if some code regions are folded and unfolded, the - viewport change event isnt fired by codeMirror. The setTimeout is a workaround to trigger the - gutter update after the viewport has been drawn. - */ - if (i === to) { - window.setTimeout(function () { - var vp = cm.getViewport(); - updateFoldInfo(cm, vp.from, vp.to); - }, 200); - } - - while (i < to) { - var sr = _isCurrentlyFolded(i),//surrounding range for the current line if one exists - range; - var mark = marker("CodeMirror-foldgutter-blank"); - var pos = CodeMirror.Pos(i), - func = opts.rangeFinder || CodeMirror.fold.auto; - //dont look inside collapsed ranges - if (sr) { - i = sr.to.line + 1; - } else { - range = cm._lineFolds[i] || (func && func(cm, pos)); - if (!fade || (fade && gutter.is(":hover"))) { - if (cm.isFolded(i)) { - //expand fold if invalid - if (range) { - mark = marker(opts.indicatorFolded); - } else { - cm.findMarksAt(pos).filter(isFold) - .forEach(clear); - } + } + + /** + This case is needed when unfolding a region that does not cause the viewport to change. + For instance in a file with about 15 lines, if some code regions are folded and unfolded, the + viewport change event isnt fired by codeMirror. The setTimeout is a workaround to trigger the + gutter update after the viewport has been drawn. + */ + if (i === to) { + window.setTimeout(function () { + var vp = cm.getViewport(); + updateFoldInfo(cm, vp.from, vp.to); + }, 200); + } + + while (i < to) { + var sr = _isCurrentlyFolded(i),//surrounding range for the current line if one exists + range; + var mark = marker("CodeMirror-foldgutter-blank"); + var pos = CodeMirror.Pos(i), + func = opts.rangeFinder || CodeMirror.fold.auto; + //dont look inside collapsed ranges + if (sr) { + i = sr.to.line + 1; + } else { + range = cm._lineFolds[i] || (func && func(cm, pos)); + if (!fade || (fade && gutter.is(":hover"))) { + if (cm.isFolded(i)) { + //expand fold if invalid + if (range) { + mark = marker(opts.indicatorFolded); } else { - if (range && range.to.line - range.from.line >= minFoldSize) { - mark = marker(opts.indicatorOpen); - } + cm.findMarksAt(pos).filter(isFold) + .forEach(clear); + } + } else { + if (range && range.to.line - range.from.line >= minFoldSize) { + mark = marker(opts.indicatorOpen); } } - cm.setGutterMarker(i, opts.gutter, mark); - i++; } + cm.setGutterMarker(i, opts.gutter, mark); + i++; } } - - function clearGutter(cm) { - var opts = cm.state.foldGutter.options; - cm.clearGutter(opts.gutter); - var blank = marker("CodeMirror-foldgutter-blank"); - var vp = cm.getViewport(); - cm.operation(function () { - cm.eachLine(vp.from, vp.to, function (line) { - cm.setGutterMarker(line.lineNo(), opts.gutter, blank); - }); - }); - } + } - function updateInViewport(cm, from, to) { - var vp = cm.getViewport(), state = cm.state.foldGutter; - from = !isNaN(from) ? from : vp.from; - to = !isNaN(to) ? to : vp.to; - - if (!state) { return; } - cm.operation(function () { - updateFoldInfo(cm, from, to); + function updateInViewport(cm, from, to) { + var vp = cm.getViewport(), state = cm.state.foldGutter; + from = !isNaN(from) ? from : vp.from; + to = !isNaN(to) ? to : vp.to; + + if (!state) { return; } + cm.operation(function () { + updateFoldInfo(cm, from, to); + }); + state.from = from; + state.to = to; + } + + /** + Clears the code folding gutter + @param {!CodeMirror} cm the CodeMirror instance for the active editor + */ + function clearGutter(cm) { + var opts = cm.state.foldGutter.options; + cm.clearGutter(opts.gutter); + var blank = marker("CodeMirror-foldgutter-blank"); + var vp = cm.getViewport(); + cm.operation(function () { + cm.eachLine(vp.from, vp.to, function (line) { + cm.setGutterMarker(line.lineNo(), opts.gutter, blank); }); - state.from = from; - state.to = to; - } - - function updateFoldsCache(cm, from, linesDiff) { - var range; - var minFoldSize = prefs.getSetting("minFoldSize") || 2; + }); + } - if (linesDiff === 0 && cm._lineFolds) { - var opts = cm.state.foldGutter.options; + /** + Updates the line folds cache usually when the document changes. + @param {!CodeMirror} cm the CodeMirror instance for the active editor + @param {!number} from the line number designating the start position of the change + @param {!number} linesDiff a number to show how many lines where removed or added to the document + */ + function updateFoldsCache(cm, from, linesDiff) { + var range; + var minFoldSize = prefs.getSetting("minFoldSize") || 2; + var foldedLines = Object.keys(cm._lineFolds).map(function (d) { + return +d; + }); + if (linesDiff === 0) { + if (foldedLines.indexOf(from) > -1) { + var opts = cm.state.foldGutter.options || {}; var rf = opts.rangeFinder || CodeMirror.fold.auto; range = rf(cm, CodeMirror.Pos(from)); - - if (range && range.from.line - range.to.line >= minFoldSize) { + + if (range && range.to.line - range.from.line >= minFoldSize) { cm._lineFolds[from] = range; } else { delete cm._lineFolds[from]; } - } else if (cm._lineFolds) { - var newFolds = {}; - Object.keys(cm._lineFolds).forEach(function (line) { - line = +line; - if (line < from) { - newFolds[line] = cm._lineFolds[line]; - } else { - range = cm._lineFolds[line]; - range.from.line = range.from.line + linesDiff; - range.to.line = range.to.line + linesDiff; - newFolds[line + linesDiff] = range; - - } - }); - cm._lineFolds = newFolds; } - } - - function onChange(cm, changeObj) { - if (changeObj.origin === "setValue") {//text content has changed outside of brackets - var folds = cm.getValidFolds(cm._lineFolds); - cm._lineFolds = folds; - Object.keys(folds).forEach(function (line) { - cm.foldCode(+line); - }); - } else { - var state = cm.state.foldGutter; - var lineChanges = changeObj.text.length - changeObj.removed.length; - //update the lineFolds cache - updateFoldsCache(cm, changeObj.from.line, lineChanges); - if (lineChanges !== 0) { - if (lineChanges > 0) { - updateFoldInfo(cm, changeObj.from.line + lineChanges, changeObj.from.line + lineChanges + 1); - } + } else if (foldedLines.length) { + var newFolds = {}; + foldedLines.forEach(function (line) { + range = cm._lineFolds[line]; + if (line < from || linesDiff === 0) { + newFolds[line] = range; + } else { + range.from.line = range.from.line + linesDiff; + range.to.line = range.to.line + linesDiff; + newFolds[line + linesDiff] = range; + } - state.from = changeObj.from.line; - state.to = 0; - window.clearTimeout(state.changeUpdate); - state.changeUpdate = window.setTimeout(function () { - updateInViewport(cm); - }, prefs.getSetting("foldOnChangeTimeSpan") || 600); - } + }); + cm._lineFolds = newFolds; } - - function onViewportChange(cm) { + } + + /** + Triggered when the content of the document changes. When the entire content of the document + is changed - e.g., changes made from a different editor, the same lineFolds are kept only if + they are still valid in the context of the new document content. + + @param {!CodeMirror} cm the CodeMirror instance for the active editor + @param {!{origin:string, from: {ch:number, line:number}, to: {ch: number, line: number}, + removed: string[], text: string[]}} changeObj detailed information about the change that occurred in the document + */ + function onChange(cm, changeObj) { + if (changeObj.origin === "setValue") {//text content has changed outside of brackets + var folds = cm.getValidFolds(cm._lineFolds); + cm._lineFolds = folds; + Object.keys(folds).forEach(function (line) { + cm.foldCode(+line); + }); + } else { var state = cm.state.foldGutter; + var lineChanges = changeObj.text.length - changeObj.removed.length; + //update the lineFolds cache + updateFoldsCache(cm, changeObj.from.line, lineChanges); + if (lineChanges !== 0) { + updateFoldInfo(cm, changeObj.from.line + lineChanges, changeObj.from.line + lineChanges + 1); + } + state.from = changeObj.from.line; + state.to = 0; window.clearTimeout(state.changeUpdate); state.changeUpdate = window.setTimeout(function () { - var vp = cm.getViewport(); - if (state.from === state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { - updateInViewport(cm); - } else { - cm.operation(function () { - if (vp.from < state.from) { - updateFoldInfo(cm, vp.from, state.from); - state.from = vp.from; - } - if (vp.to > state.to) { - updateFoldInfo(cm, state.to, vp.to); - state.to = vp.to; - } else { - updateFoldInfo(cm, vp.from, vp.to); - state.to = vp.to; - state.from = vp.from; - } - }); - } - }, prefs.getSetting("updateViewportTimeSpan") || 400); - } - - function onFold(cm, from, to) { - var state = cm.state.foldGutter, line = from.line; - if (line >= state.from && line < state.to) { - updateFoldInfo(cm, line, line + 1); - } + updateInViewport(cm); + }, prefs.getSetting("foldOnChangeTimeSpan") || 600); } - - function onUnFold(cm, from, to) { - var state = cm.state.foldGutter, line = from.line; + } + + /** + Triggered on viewport changes e.g., user scrolls or resizes the viewport. + @param {!CodeMirror} cm the CodeMirror instance for the active editor + */ + function onViewportChange(cm) { + var state = cm.state.foldGutter; + window.clearTimeout(state.changeUpdate); + state.changeUpdate = window.setTimeout(function () { var vp = cm.getViewport(); - if (line >= state.from && line < state.to) { - updateFoldInfo(cm, line, Math.min(vp.to, to.line)); + if (state.from === state.to || vp.from - state.to > 20 || state.from - vp.to > 20) { + updateInViewport(cm); + } else { + cm.operation(function () { + if (vp.from < state.from) { + updateFoldInfo(cm, vp.from, state.from); + state.from = vp.from; + } + if (vp.to > state.to) { + updateFoldInfo(cm, state.to, vp.to); + state.to = vp.to; + } else { + updateFoldInfo(cm, vp.from, vp.to); + state.to = vp.to; + state.from = vp.from; + } + }); } + }, prefs.getSetting("updateViewportTimeSpan") || 400); + } + + /** + Triggered when a code segment is folded. + @param {!CodeMirror} cm the CodeMirror instance for the active editor + @param {!{line:number, ch:number}} from the ch and line position that designates the start of the region + @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region + */ + function onFold(cm, from, to) { + var state = cm.state.foldGutter, line = from.line; + if (line >= state.from && line < state.to) { + updateFoldInfo(cm, line, line + 1); + } + } + + /** + Triggered when a folded code segment is unfolded. + @param {!CodeMirror} cm the CodeMirror instance for the active editor + @param {!{line:number, ch:number}} from the ch and line position that designates the start of the region + @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region + */ + function onUnFold(cm, from, to) { + var state = cm.state.foldGutter, line = from.line; + var vp = cm.getViewport(); + if (line >= state.from && line < state.to) { + updateFoldInfo(cm, line, Math.min(vp.to, to.line)); } - + } + + /** + Initialises the fold gutter and registers event handlers for changes to document, viewport + and user interactions. + */ + function init() { CodeMirror.defineOption("foldGutter", false, function (cm, val, old) { if (old && old !== CodeMirror.Init) { cm.clearGutter(cm.state.foldGutter.options.gutter); @@ -258,10 +298,11 @@ define(function (require, exports, module) { cm.on("swapDoc", updateInViewport); } }); - - return { - clearGutter: clearGutter, - updateInViewport: updateInViewport - }; - }; + } + + exports.init = init; + exports.clearGutter = clearGutter; + + exports.updateInViewport = updateInViewport; + }); diff --git a/src/extensions/default/CodeFolding/foldhelpers/indentFold.js b/src/extensions/default/CodeFolding/foldhelpers/indentFold.js index db4e059c10c..9eb8ee7dd3d 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/indentFold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/indentFold.js @@ -10,7 +10,7 @@ define(function (require, exports, module) { "use strict"; var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); var cols = CodeMirror.countColumn, pos = CodeMirror.Pos; - + function lastNonEmptyLineNumber(cm) { var lc = cm.lastLine(), line = cm.getLine(lc); while (lc > 0 && line.trim().length === 0) { @@ -19,10 +19,10 @@ define(function (require, exports, module) { } return lc; } - - module.exports = function (cm, start) { + + function indentFold(cm, start) { var lineText = cm.getLine(start.line), tabSize = cm.getOption("tabSize"); - + var lineIndent = cols(lineText, null, tabSize), collapsible = false, lineCount = cm.lineCount(); var token = cm.getTokenAt(pos(start.line, lineIndent + 1)); //no folding for blank lines or commented lines @@ -33,7 +33,7 @@ define(function (require, exports, module) { for (i = start.line + 1; i < lineCount; i++) { currentLine = cm.getLine(i); indent = cols(currentLine, null, tabSize); - + token = cm.getTokenAt(pos(i, indent + 1)); //only fold for non blank lines or non commented lines if (currentLine.trim().length !== 0 && (token && token.type !== "comment")) { @@ -47,7 +47,7 @@ define(function (require, exports, module) { to: pos(i - 1, cm.getLine(i - 1).length)}; } } - + if (indent === lineIndent || indent < lineIndent) { return; } @@ -58,5 +58,7 @@ define(function (require, exports, module) { i = lastNonEmptyLineNumber(cm); return {from: pos(start.line, lineText.length), to: pos(i, cm.getLine(i).length)}; } - }; + } + + module.exports = indentFold; }); diff --git a/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js b/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js index d9c08a5aee7..30dfc8298db 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/latex-fold.js @@ -11,7 +11,7 @@ define(function (require, exports, module) { brackets.getModule(["thirdparty/CodeMirror2/addon/fold/brace-fold"]); var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); - module.exports = function (cm, start) { + function latexFold(cm, start) { var line = start.line, lineText = cm.getLine(line); var startRegex = /^([\\](?:section|subsection|subsubsection|begin)\*?\s*\{)([\w\s\d\(\)\,\.\?]+)\}/; ///fixme the matches for subsection and subsubections are wrong @@ -25,7 +25,7 @@ define(function (require, exports, module) { } return {line: i + 1, ch: 0}; } - + var regex, pos; if (match.indexOf("\\begin") === 0) { //look for \end{context} regex = new RegExp("\\end\\s*\\{" + context + "\\}"); @@ -44,14 +44,16 @@ define(function (require, exports, module) { } return pos; } - + var matches = startRegex.exec(lineText); - + if (!matches) { return CodeMirror.fold.brace(cm, start); } //find the close tag depending on the match var end = findClose(matches[1], matches[2]); if (!end) { return null; } return {from: CodeMirror.Pos(line, matches.index + matches[0].length), to: CodeMirror.Pos(end.line, end.ch)}; - }; + } + + module.exports = latexFold; }); diff --git a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js index 071287914b8..5810d28afc6 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js @@ -1,7 +1,6 @@ -// Function copied from brace-fold.js addon in CodeMirror Library with minor altering. +// Function based on brace-fold.js addon in CodeMirror Library with minor altering. // CodeMirror 4.1.1, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: http://codemirror.net/LICENSE -/*jshint eqnull:true, unused:true, undef: true*/ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, eqeq:true */ /*global define, brackets*/ define(function (require, exports, module) { @@ -9,52 +8,59 @@ define(function (require, exports, module) { var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), startRegion = /\W+region/i, endRegion = /\W+endregion/i, - space = /\s/; - - module.exports = function (cm, start) { + space = /\s/; + + function regionFold(cm, start) { var line = start.line, i, j; var startCh = 0, stack = [], token; var lastLine = cm.lastLine(), end, endCh, nextOpen, nextClose; - //no need to fold on single line files - if (line === lastLine) { return; } + //no need to fold on single line files + if (line === lastLine) { + return; + } for (i = line; i <= lastLine; ++i) { var text = cm.getLine(i), pos = startCh; for (j = pos; j < text.length; true) { - //skip all blank lines at begining of test - if (space.test(text[j])) { - j++; - } else { - token = cm.getTokenAt(CodeMirror.Pos(i, j + 1)); - if (token) { - if (token.string.length && token.type === "comment") { - nextOpen = token.string.toLowerCase().match(startRegion) ? token.end : -1; - nextClose = token.string.toLowerCase().match(endRegion) ? token.start : -1; - if (nextOpen > -1) { - stack.push(nextOpen); - } - if (nextClose > -1) { - if (stack.length === 1) { - endCh = nextClose; - end = i; - return {from: CodeMirror.Pos(line, stack[0]), + //skip all blank lines at begining of text + if (space.test(text[j])) { + j++; + } else { + token = cm.getTokenAt(CodeMirror.Pos(i, j + 1)); + if (token) { + if (token.string.length && token.type === "comment") { + nextOpen = token.string.toLowerCase().match(startRegion) ? token.end : -1; + nextClose = token.string.toLowerCase().match(endRegion) ? token.start : -1; + if (nextOpen > -1) { + stack.push(nextOpen); + } + if (nextClose > -1) { + if (stack.length === 1) { + endCh = nextClose; + end = i; + return {from: CodeMirror.Pos(line, stack[0]), to: CodeMirror.Pos(end, endCh)}; - } - stack.pop(); - } - } else { - break; //break out of loop if the first non-space character is not a comment - } - } - j = token ? token.end + 1 : text.length; - } + } + stack.pop(); + } + } else { + break; //break out of loop if the first non-space character is not a comment + } + } + j = token ? token.end + 1 : text.length; + } } - - if (stack.length === 0) { break; } + + if (stack.length === 0) { + break; + } + } + if (end === null || end === undefined || (line == end && endCh == startCh)) { + return; } - if (end == null || (line == end && endCh == startCh)) { return; } return {from: CodeMirror.Pos(line, stack[0]), to: CodeMirror.Pos(end, endCh)}; - }; + } + module.exports = regionFold; }); diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index 3f8dd0b9e09..d836d9d8326 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -46,55 +46,44 @@ define(function (require, exports, module) { ProjectManager = brackets.getModule("project/ProjectManager"), KeyBindingManager = brackets.getModule("command/KeyBindingManager"), ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), - Menus = brackets.getModule("command/Menus"), + Menus = brackets.getModule("command/Menus"), _prefs = require("./Prefs"), COLLAPSE_ALL = "codefolding.collapse.all", COLLAPSE = "codefolding.collapse", EXPAND = "codefolding.expand", EXPAND_ALL = "codefolding.expand.all", - CODE_FOLDING_SETTINGS = "codefolding.settings", + CODE_FOLDING_SETTINGS = "codefolding.settings", gutterName = "CodeMirror-foldgutter", - COLLAPSE_CUSTOM_REGIONS = "codefolding.collapse.customregions", - SettingsDialog = require("SettingsDialog"); - + COLLAPSE_CUSTOM_REGIONS = "codefolding.collapse.customregions", + SettingsDialog = require("SettingsDialog"); + ExtensionUtils.loadStyleSheet(module, "main.less"); //load code mirror addons brackets.getModule(["thirdparty/CodeMirror2/addon/fold/brace-fold"]); brackets.getModule(["thirdparty/CodeMirror2/addon/fold/comment-fold"]); brackets.getModule(["thirdparty/CodeMirror2/addon/fold/markdown-fold"]); - + //still using slightly modified versions of the foldcode.js and foldgutter.js since we //need to modify the gutter click handler to take care of some collapse and expand features //e.g. collapsing all children when 'alt' key is pressed - require("foldhelpers/foldcode")(); - var foldGutter = require("foldhelpers/foldgutter")(); + var foldGutter = require("foldhelpers/foldgutter"), + foldCode = require("foldhelpers/foldcode"); var indentFold = require("foldhelpers/indentFold"), latexFold = require("foldhelpers/latex-fold"), regionFold = require("foldhelpers/region-fold"); - //register a global fold helper based on indentation folds - CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { - return _prefs.getSetting("alwaysUseIndentFold"); - }, indentFold); - - CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { - return _prefs.getSetting("enableRegionFolding"); - }, regionFold); - - CodeMirror.registerHelper("fold", "stex", latexFold); - CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); - CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); - - /** + + + /** Restores the linefolds in the editor using values fetched from the preference store Checks the document to ensure that changes have not been made (e.g., in a different editor) to invalidate the saved line folds. @param {Editor} editor the editor whose saved line folds should be restored */ function restoreLineFolds(editor) { - var saveFolds = _prefs.getSetting("saveFoldStates"); + var saveFolds = _prefs.getSetting("saveFoldStates"); if (editor && saveFolds) { var cm = editor._codeMirror; if (!cm) {return; } @@ -107,20 +96,20 @@ define(function (require, exports, module) { }); } } - + /**Saves the line folds in the editor using the preference storage**/ function saveLineFolds(editor) { - var saveFolds = _prefs.getSetting("saveFoldStates"); + var saveFolds = _prefs.getSetting("saveFoldStates"); if (!editor || !saveFolds) { return; } - var folds = editor._codeMirror._lineFolds || {}; - var path = editor.document.file.fullPath; - if (Object.keys(folds).length) { - _prefs.set(path, folds); - } else { - _prefs.set(path, undefined); - } + var folds = editor._codeMirror._lineFolds || {}; + var path = editor.document.file.fullPath; + if (Object.keys(folds).length) { + _prefs.set(path, folds); + } else { + _prefs.set(path, undefined); + } } - + function onGutterClick(cm, line, gutter, event) { var opts = cm.state.foldGutter.options, pos = CodeMirror.Pos(line); if (gutter !== opts.gutter) { return; } @@ -145,30 +134,30 @@ define(function (require, exports, module) { } } } - - /** - Collapses all custom regions defined in the current editor - */ - function collapseCustomRegions() { - var editor = EditorManager.getFocusedEditor(); - if (editor) { - var cm = editor._codeMirror, i = cm.firstLine(); - while (i < cm.lastLine()) { - var range = cm.foldCode(i, {rangeFinder: regionFold}); - if (range) { - i = range.to.line; - } else { - i++; - } - } - } - } - + /** - Collapses the code region nearest the current cursor position. - Nearest is found by searching from the current line and moving up the document until an - opening code-folding region is found. - */ + Collapses all custom regions defined in the current editor + */ + function collapseCustomRegions() { + var editor = EditorManager.getFocusedEditor(); + if (editor) { + var cm = editor._codeMirror, i = cm.firstLine(); + while (i < cm.lastLine()) { + var range = cm.foldCode(i, {rangeFinder: regionFold}); + if (range) { + i = range.to.line; + } else { + i++; + } + } + } + } + + /** + Collapses the code region nearest the current cursor position. + Nearest is found by searching from the current line and moving up the document until an + opening code-folding region is found. + */ function collapseCurrent() { var editor = EditorManager.getFocusedEditor(); if (editor) { @@ -183,9 +172,9 @@ define(function (require, exports, module) { } } } - /** - Expands the code region at the current cursor position. - */ + /** + Expands the code region at the current cursor position. + */ function expandCurrent() { var editor = EditorManager.getFocusedEditor(); if (editor) { @@ -194,10 +183,10 @@ define(function (require, exports, module) { } } /** - Collapses all foldable regions in the current document. Folding is done up to a level 'n' - which is defined in the preferences. Levels refer to fold heirarchies e.g., for the following + Collapses all foldable regions in the current document. Folding is done up to a level 'n' + which is defined in the preferences. Levels refer to fold heirarchies e.g., for the following code fragment, the function is level 1, the if statement is level 2 and the forEach is level 3 - + function sample() { if (debug) { logMessages.forEach(function (m) { @@ -223,11 +212,11 @@ define(function (require, exports, module) { CodeMirror.commands.unfoldAll(cm); } } - - function registerHandlers(editor) { - var cm = editor._codeMirror; - if (cm) { - var path = editor.document.file.fullPath, _lineFolds = _prefs.get(path); + + function registerHandlers(editor) { + var cm = editor._codeMirror; + if (cm) { + var path = editor.document.file.fullPath, _lineFolds = _prefs.get(path); _lineFolds = _lineFolds || {}; cm._lineFolds = _lineFolds; var gutters = cm.getOption("gutters").slice(0); @@ -235,7 +224,7 @@ define(function (require, exports, module) { gutters.splice(lnIndex + 1, 0, gutterName); cm.setOption("gutters", gutters); cm.setOption("foldGutter", {onGutterClick: onGutterClick}); - + $(cm.getGutterElement()).on({ mouseenter: function () { if (_prefs.getSetting("fadeFoldButtons")) { @@ -248,23 +237,25 @@ define(function (require, exports, module) { } } }); - } - } - + } + } + function onActiveEditorChanged(event, current, previous) { - if (current && current._codeMirror.getOption("gutters").indexOf(gutterName) === -1) { - registerHandlers(current); - restoreLineFolds(current); - } - if (previous) { saveLineFolds(previous); } + if (current && current._codeMirror.getOption("gutters").indexOf(gutterName) === -1) { + registerHandlers(current); + restoreLineFolds(current); + } + if (previous) { + saveLineFolds(previous); + } } - + function saveBeforeClose() { - saveLineFolds(EditorManager.getCurrentFullEditor()); - } - - function showSettingsDialog() { - SettingsDialog.show(function () { + saveLineFolds(EditorManager.getCurrentFullEditor()); + } + + function showSettingsDialog() { + SettingsDialog.show(function () { var editor = EditorManager.getCurrentFullEditor(); if (editor) { var cm = editor._codeMirror; @@ -275,35 +266,49 @@ define(function (require, exports, module) { } } }); - } - + } + + foldCode.init(); + foldGutter.init(); + //register a global fold helper based on indentation folds + CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { + return _prefs.getSetting("alwaysUseIndentFold"); + }, indentFold); + + CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { + return _prefs.getSetting("enableRegionFolding"); + }, regionFold); + + CodeMirror.registerHelper("fold", "stex", latexFold); + CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); + CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); + $(EditorManager).on("activeEditorChange", onActiveEditorChanged); $(DocumentManager).on("documentRefreshed", function (event, doc) { - //restore the folds for this document restoreLineFolds(doc._masterEditor); }); - + $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); - + CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, showSettingsDialog); CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); - - CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); + + CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); CommandManager.register(Strings.COLLAPSE_CURRENT, COLLAPSE, collapseCurrent); CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); - - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); + + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-C"); KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-X"); KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); -}); \ No newline at end of file +}); From 4d4029ad92d3825c47b79f2c5df97d3dc83a094a Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Sun, 29 Mar 2015 15:42:10 +0100 Subject: [PATCH 04/11] Moved preferences to brackets.json --- src/extensions/default/CodeFolding/Prefs.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index 4cb7712f8fd..9494d897da2 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -9,7 +9,7 @@ define(function (require, exports, module) { "use strict"; var PreferencesManager = brackets.getModule("preferences/PreferencesManager"), - stateManager = PreferencesManager.stateManager.getPrefixedSystem("code-folding"), + prefs = PreferencesManager.getExtensionPrefs("code-folding"), DefaultSettings = require("DefaultSettings"), store = {}, settings = {}, @@ -57,7 +57,7 @@ define(function (require, exports, module) { @returns {number: {from: {line, ch}, to: {line, ch}}} the line folds for the document at the specified path */ function get(path) { - store = (stateManager.get(foldsKey) || {}); + store = (prefs.get(foldsKey) || {}); return inflate(store[path]); } @@ -66,8 +66,7 @@ define(function (require, exports, module) { */ function set(path, folds) { store[path] = simplify(folds); - stateManager.set(foldsKey, store); - stateManager.save(); + prefs.set(foldsKey, store); } /** @@ -76,7 +75,7 @@ define(function (require, exports, module) { @returns {string} the setting with the specified key */ function getSetting(key) { - settings = (stateManager.get("settings") || DefaultSettings); + settings = (prefs.get("settings") || DefaultSettings); return settings[key]; } @@ -87,8 +86,7 @@ define(function (require, exports, module) { */ function setSetting(key, value) { settings[key] = value; - stateManager.set("settings", settings); - stateManager.save(); + prefs.set("settings", settings); } /** @@ -107,8 +105,7 @@ define(function (require, exports, module) { Clears all the saved line folds for all documents. */ function clearAllFolds() { - stateManager.set(foldsKey, {}); - stateManager.save(); + prefs.set(foldsKey, {}); } module.exports.get = get; From d9fcb1a2ad37585566a5372ec9fc7375a04f348f Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Sun, 29 Mar 2015 19:07:46 +0100 Subject: [PATCH 05/11] Added support for disabling the extension from the preferences dialog. --- .../default/CodeFolding/DefaultSettings.js | 1 + .../default/CodeFolding/SettingsDialog.js | 48 +++++--- .../htmlTemplates/reload-dialog.html | 12 ++ .../htmlTemplates/settings-dialog.html | 107 ++++++++++-------- src/extensions/default/CodeFolding/main.js | 107 ++++++++++-------- .../default/CodeFolding/nls/root/strings.js | 25 ++-- 6 files changed, 177 insertions(+), 123 deletions(-) create mode 100644 src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html diff --git a/src/extensions/default/CodeFolding/DefaultSettings.js b/src/extensions/default/CodeFolding/DefaultSettings.js index aa54d20113b..3ba8b8b63a6 100644 --- a/src/extensions/default/CodeFolding/DefaultSettings.js +++ b/src/extensions/default/CodeFolding/DefaultSettings.js @@ -9,6 +9,7 @@ define(function (require, exports, module) { "use strict"; module.exports = { + enabled: true, minFoldSize: 2, saveFoldStates: true, alwaysUseIndentFold: true, diff --git a/src/extensions/default/CodeFolding/SettingsDialog.js b/src/extensions/default/CodeFolding/SettingsDialog.js index 7512dcae50c..7e69efbb6bb 100644 --- a/src/extensions/default/CodeFolding/SettingsDialog.js +++ b/src/extensions/default/CodeFolding/SettingsDialog.js @@ -10,10 +10,14 @@ define(function (require, exports, module) { var Dialogs = brackets.getModule("widgets/Dialogs"), DefaultSettings = require("DefaultSettings"), Strings = require("i18n!nls/strings"), + CommandManager = brackets.getModule("command/CommandManager"), settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), + reloadTemplate = require("text!htmlTemplates/reload-dialog.html"), preferences = require("Prefs"); function setFormValues(prefs) { + prefs.enabled = prefs.enabled === undefined ? true : prefs.enabled; + $("#enable-code-folding").prop("checked", prefs.enabled); $("#min-fold-size").val(prefs.minFoldSize || 2); $("#max-fold-level").val(prefs.maxFoldLevel || 2); $("#save-fold-states").prop("checked", prefs.saveFoldStates); @@ -33,13 +37,34 @@ define(function (require, exports, module) { function showDialog(cb) { var template = Mustache.render(settingsTemplate, Strings); var dialog = Dialogs.showModalDialogUsingTemplate(template); + var $dialog = dialog.getElement(); setFormValues(preferences.getAllSettings()); + $("button[data-button-id='defaults']", $dialog).on("click", function (e) { + e.stopPropagation(); + restoreDefaults(); + }); + + $("#enable-code-folding", $dialog).change(function () { + var enabled = $("#enable-code-folding").prop("checked"); + var settingsElements = $("#min-fold-size, #max-fold-level, #save-fold-states," + + "#always-use-indent-fold, #enable-region-folding, #fade-fold-buttons"); + if (enabled) { + settingsElements.removeAttr("disabled"); + settingsElements.removeClass("disabled"); + } else { + settingsElements.attr("disabled", true); + settingsElements.addClass("diabled"); + } + }); + dialog.done(function (buttonId) { if (buttonId === "ok") { - var $dialog = dialog.getElement(); var minFoldSize = $("#min-fold-size", $dialog).val(); var maxFoldLevel = $("#max-fold-level", $dialog).val(); + var enabled = $("#enable-code-folding", $dialog).prop("checked"); + + preferences.setSetting("enabled", enabled); preferences.setSetting("minFoldSize", isNaN(minFoldSize) || +minFoldSize === 0 ? +preferences.getSetting("minFoldSize") : +minFoldSize); preferences.setSetting("saveFoldStates", $("#save-fold-states", $dialog).prop("checked")); @@ -48,22 +73,19 @@ define(function (require, exports, module) { preferences.setSetting("alwaysUseIndentFold", $("#always-use-indent-fold", $dialog).prop("checked")); preferences.setSetting("enableRegionFolding", $("#enable-region-folding", $dialog).prop("checked")); preferences.setSetting("fadeFoldButtons", $("#fade-fold-buttons", $dialog).prop("checked")); - } - if (cb && typeof cb === "function") { - cb(); - } - }); - } + //show reload prompt + template = Mustache.render(reloadTemplate, Strings); + var reloadDialog = Dialogs.showModalDialogUsingTemplate(template); + reloadDialog.done(function (buttonId) { + if (buttonId === "ok") { + CommandManager.execute("debug.refreshWindow"); + } + }); - function bindListeners() { - $("button[data-button-id='defaults']").on("click", function (e) { - e.stopPropagation(); - restoreDefaults(); + } }); } - bindListeners(); - exports.show = showDialog; }); diff --git a/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html new file mode 100644 index 00000000000..27dc0fc7e9f --- /dev/null +++ b/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html @@ -0,0 +1,12 @@ + diff --git a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html index fcb7d52c0b6..f8fbd5cb0d6 100644 --- a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html +++ b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html @@ -3,58 +3,65 @@

{{CODE_FOLDING_SETTINGS}}

- \ No newline at end of file + diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index d836d9d8326..b80c31f4722 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -74,8 +74,6 @@ define(function (require, exports, module) { latexFold = require("foldhelpers/latex-fold"), regionFold = require("foldhelpers/region-fold"); - - /** Restores the linefolds in the editor using values fetched from the preference store Checks the document to ensure that changes have not been made (e.g., in a different editor) @@ -254,8 +252,57 @@ define(function (require, exports, module) { saveLineFolds(EditorManager.getCurrentFullEditor()); } - function showSettingsDialog() { - SettingsDialog.show(function () { + /** + Initialise the extension + */ + function init() { + if ([undefined, true].indexOf(_prefs.getSetting("enabled")) > -1) { + foldCode.init(); + foldGutter.init(); + //register a global fold helper based on indentation folds + CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { + return _prefs.getSetting("alwaysUseIndentFold"); + }, indentFold); + + CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { + return _prefs.getSetting("enableRegionFolding"); + }, regionFold); + + CodeMirror.registerHelper("fold", "stex", latexFold); + CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); + CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); + + $(EditorManager).on("activeEditorChange", onActiveEditorChanged); + $(DocumentManager).on("documentRefreshed", function (event, doc) { + restoreLineFolds(doc._masterEditor); + }); + + $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); + + CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, function () { + SettingsDialog.show(); + }); + CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); + CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); + + CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); + + CommandManager.register(Strings.COLLAPSE_CURRENT, COLLAPSE, collapseCurrent); + CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); + + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); + + KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-C"); + KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-X"); + KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); + KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); + var editor = EditorManager.getCurrentFullEditor(); if (editor) { var cm = editor._codeMirror; @@ -265,50 +312,14 @@ define(function (require, exports, module) { foldGutter.updateInViewport(cm); } } - }); + } else { + CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, function () { + SettingsDialog.show(); + }); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); + } } - foldCode.init(); - foldGutter.init(); - //register a global fold helper based on indentation folds - CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { - return _prefs.getSetting("alwaysUseIndentFold"); - }, indentFold); - - CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { - return _prefs.getSetting("enableRegionFolding"); - }, regionFold); - - CodeMirror.registerHelper("fold", "stex", latexFold); - CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); - CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); - - $(EditorManager).on("activeEditorChange", onActiveEditorChanged); - $(DocumentManager).on("documentRefreshed", function (event, doc) { - restoreLineFolds(doc._masterEditor); - }); - - $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); - - CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, showSettingsDialog); - CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); - CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); - - CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); - - CommandManager.register(Strings.COLLAPSE_CURRENT, COLLAPSE, collapseCurrent); - CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); - - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); - - KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-C"); - KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-X"); - KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); - KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); + init(); }); diff --git a/src/extensions/default/CodeFolding/nls/root/strings.js b/src/extensions/default/CodeFolding/nls/root/strings.js index 27a40e05b20..2527eeb9f1e 100644 --- a/src/extensions/default/CodeFolding/nls/root/strings.js +++ b/src/extensions/default/CodeFolding/nls/root/strings.js @@ -1,24 +1,24 @@ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * */ // English - root strings @@ -27,6 +27,7 @@ /*global define */ define({ + "ENABLE_CODE_FOLDING" : "Enable code folding", "CODE_FOLDING_SETTINGS" : "Code Folding Settings", "COLLAPSE_ALL" : "Collapse All", "EXPAND_ALL" : "Expand All", From 81cb981799c3c5081cab418cdb6269ba1e6ea4f6 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Sun, 29 Mar 2015 23:07:26 +0100 Subject: [PATCH 06/11] Merged english translation strings into nls/root/strings.js --- .../default/CodeFolding/SettingsDialog.js | 2 +- .../htmlTemplates/reload-dialog.html | 4 +-- .../htmlTemplates/settings-dialog.html | 6 ++-- src/extensions/default/CodeFolding/main.js | 2 +- .../default/CodeFolding/nls/fi/strings.js | 30 +++++++++---------- .../default/CodeFolding/nls/fr/strings.js | 30 +++++++++---------- .../default/CodeFolding/nls/ja/strings.js | 30 +++++++++---------- .../default/CodeFolding/nls/nl/strings.js | 6 ++-- .../default/CodeFolding/nls/pt-BR/strings.js | 6 ++-- .../default/CodeFolding/nls/root/strings.js | 6 ++-- src/nls/root/strings.js | 26 +++++++++++++++- 11 files changed, 80 insertions(+), 68 deletions(-) diff --git a/src/extensions/default/CodeFolding/SettingsDialog.js b/src/extensions/default/CodeFolding/SettingsDialog.js index 7e69efbb6bb..da8d98bfd37 100644 --- a/src/extensions/default/CodeFolding/SettingsDialog.js +++ b/src/extensions/default/CodeFolding/SettingsDialog.js @@ -9,7 +9,7 @@ define(function (require, exports, module) { "use strict"; var Dialogs = brackets.getModule("widgets/Dialogs"), DefaultSettings = require("DefaultSettings"), - Strings = require("i18n!nls/strings"), + Strings = brackets.getModule("strings"), CommandManager = brackets.getModule("command/CommandManager"), settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), reloadTemplate = require("text!htmlTemplates/reload-dialog.html"), diff --git a/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html index 27dc0fc7e9f..78ef71b81b0 100644 --- a/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html +++ b/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html @@ -6,7 +6,7 @@

{{RELOAD_BRACKETS}}

diff --git a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html index f8fbd5cb0d6..62ae8f1764e 100644 --- a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html +++ b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html @@ -65,8 +65,8 @@

{{CODE_FOLDING_SETTINGS}}

diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index b80c31f4722..5159a65d743 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -39,7 +39,7 @@ require.config({ define(function (require, exports, module) { "use strict"; var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); - var Strings = require("strings"); + var Strings = brackets.getModule("strings"); var CommandManager = brackets.getModule("command/CommandManager"), DocumentManager = brackets.getModule("document/DocumentManager"), EditorManager = brackets.getModule("editor/EditorManager"), diff --git a/src/extensions/default/CodeFolding/nls/fi/strings.js b/src/extensions/default/CodeFolding/nls/fi/strings.js index 228821523d0..90dcca3be21 100644 --- a/src/extensions/default/CodeFolding/nls/fi/strings.js +++ b/src/extensions/default/CodeFolding/nls/fi/strings.js @@ -1,24 +1,24 @@ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * */ // Finnish Translation @@ -46,12 +46,10 @@ define({ "FADE_FOLD_BUTTONS_HELP" : "Piilottaa laskostuspainikkeet, ellei osoitin ole sivumarginaalin päällä", "MAX_FOLD_LEVEL" : "Suurin sallittu sisäkkäisten laskosten määrä", "MAX_FOLD_LEVEL_HELP" : "Käytetään rajoittamaan sisäkkäisten laskosten määrää etsittäessä ja pienennettäessä, kun käytetään Näytä -> Pienennä kaikki \u2011komentoa tai kun Alt-näppäintä pidetään alhaalla pienennettäessä. Pitäisi parantaa suurten tiedostojen suorituskykyä.", - "BUTTON_SAVE" : "Tallenna", - "BUTTON_DEFAULTS" : "Palauta oletukset", - "BUTTON_CANCEL" : "Peruuta", + "RESTORE_DEFAULTS" : "Palauta oletukset", // Endregion "CONFIRM_RELOAD_BRACKETS" : "Haluatko ladata Bracketsin uudelleen ottaaksesi uudet asetukset käyttöön? Sinua pyydetään tallentamaan muutokset tallentamattomiin dokumentteihin.", "RELOAD_BRACKETS" : "Lataa Brackets uudelleen", - "BUTTON_RELOAD" : "Lataa uudelleen" + "RELOAD" : "Lataa uudelleen" }); diff --git a/src/extensions/default/CodeFolding/nls/fr/strings.js b/src/extensions/default/CodeFolding/nls/fr/strings.js index b305a4ea8fa..35dd7ff283c 100644 --- a/src/extensions/default/CodeFolding/nls/fr/strings.js +++ b/src/extensions/default/CodeFolding/nls/fr/strings.js @@ -1,24 +1,24 @@ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * */ // French Translation @@ -43,12 +43,10 @@ define({ "ALWAYS_USE_INDENT_FOLD_HELP" : "Toujours utiliser le niveau d'indentation comme norme de replis", "USE_KEYBOARD_SHORTCUTS" : "Utiliser les raccourcis clavier", "REMAP_KEYBOARD_SHORTCUTS" : "Redéfinir les raccourcis clavier", - "BUTTON_SAVE" : "Enregistrer", - "BUTTON_DEFAULTS" : "Réinitialiser", - "BUTTON_CANCEL" : "Annuler", + "RESTORE_DEFAULTS" : "Réinitialiser", // Endregion "CONFIRM_RELOAD_BRACKETS" : "Souhaitez-vous recharger Brackets pour appliquer les nouveaux paramètres ? Il vous sera demandé de sauvegarder les changements sur les documents ouverts.", "RELOAD_BRACKETS" : "Recharger Brackets", - "BUTTON_RELOAD" : "Recharger" + "RELOAD" : "Recharger" }); diff --git a/src/extensions/default/CodeFolding/nls/ja/strings.js b/src/extensions/default/CodeFolding/nls/ja/strings.js index 4220ba4f89d..2dd7ac21ce0 100644 --- a/src/extensions/default/CodeFolding/nls/ja/strings.js +++ b/src/extensions/default/CodeFolding/nls/ja/strings.js @@ -1,24 +1,24 @@ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * */ // Japanese Translation @@ -44,12 +44,10 @@ define({ "ALWAYS_USE_INDENT_FOLD_HELP" : "折りたたみのガイドラインとして常にインデント レベルを使用します", //"USE_KEYBOARD_SHORTCUTS": "Use keyboard shortcuts", //"REMAP_KEYBOARD_SHORTCUTS": "Remap keyboard shortcuts", - "BUTTON_SAVE" : "保存", - "BUTTON_DEFAULTS" : "既定の設定に戻す", - "BUTTON_CANCEL" : "キャンセル", + "RESTORE_DEFAULTS" : "既定の設定に戻す", // Endregion "CONFIRM_RELOAD_BRACKETS" : "新しい設定を有効にするには、Brackets を再読み込みする必要があります。未保存のドキュメントを、保存または破棄を確認するメッセージが表示されます。", "RELOAD_BRACKETS" : "Brackets の再読み込み", - "BUTTON_RELOAD" : "再読み込み" + "RELOAD" : "再読み込み" }); diff --git a/src/extensions/default/CodeFolding/nls/nl/strings.js b/src/extensions/default/CodeFolding/nls/nl/strings.js index b48db8b7fca..d32e1ca827a 100644 --- a/src/extensions/default/CodeFolding/nls/nl/strings.js +++ b/src/extensions/default/CodeFolding/nls/nl/strings.js @@ -46,12 +46,10 @@ define({ "FADE_FOLD_BUTTONS_HELP" : "Verberg de vouwknoppen, behalve als de muis over de goot hangt", //"USE_KEYBOARD_SHORTCUTS" : "Gebruik toetsenbordshortcuts", //"REMAP_KEYBOARD_SHORTCUTS" : "Aanpassen toetsenbordshortcuts", - "BUTTON_SAVE" : "Opslaan", - "BUTTON_DEFAULTS" : "Herstel standaarden", - "BUTTON_CANCEL" : "Annuleren", + "RESTORE_DEFAULTS" : "Herstel standaarden", // Endregion "CONFIRM_RELOAD_BRACKETS" : "Wil je Brackets herstarten om de nieuwe instelingen toe te passen? Je zal gevraagd worden om wijzigingen in nog niet opgeslagen documenten op te slaan.", "RELOAD_BRACKETS" : "Herstart Brackets", - "BUTTON_RELOAD" : "Herstart" + "RELOAD" : "Herstart" }); diff --git a/src/extensions/default/CodeFolding/nls/pt-BR/strings.js b/src/extensions/default/CodeFolding/nls/pt-BR/strings.js index b48d6017e5a..b9865323266 100644 --- a/src/extensions/default/CodeFolding/nls/pt-BR/strings.js +++ b/src/extensions/default/CodeFolding/nls/pt-BR/strings.js @@ -44,12 +44,10 @@ define({ "ALWAYS_USE_INDENT_FOLD_HELP" : "Usa a Indentação como guia para o Dobramento", "FADE_FOLD_BUTTONS" : "Ocultar os botões de Dobramento", "FADE_FOLD_BUTTONS_HELP" : "Oculta os botões quando o cursor não está sobre eles", - "BUTTON_SAVE" : "Salvar", - "BUTTON_DEFAULTS" : "Restaurar Opções", - "BUTTON_CANCEL" : "Cancelar", + "RESTORE_DEFAULTS" : "Restaurar Opções", // Endregion "CONFIRM_RELOAD_BRACKETS" : "Deseja reiniciar o Brackets para aplicar as novas configurações? Haverá a possibilidade de salvar os arquivos editados.", "RELOAD_BRACKETS" : "Reiniciar Brackets", - "BUTTON_RELOAD" : "Recarregar" + "RELOAD" : "Recarregar" }); diff --git a/src/extensions/default/CodeFolding/nls/root/strings.js b/src/extensions/default/CodeFolding/nls/root/strings.js index 2527eeb9f1e..097976760af 100644 --- a/src/extensions/default/CodeFolding/nls/root/strings.js +++ b/src/extensions/default/CodeFolding/nls/root/strings.js @@ -47,12 +47,10 @@ define({ "FADE_FOLD_BUTTONS_HELP" : "Hides the fold buttons unless the mouse is over the gutter", "MAX_FOLD_LEVEL" : "Maximum number of nested folds", "MAX_FOLD_LEVEL_HELP" : "Used to limit the number of nested folds to find and collapse when View -> Collapse All is called or Alt is held down when collapsing. Should improve performance for large files.", - "BUTTON_SAVE" : "Save", - "BUTTON_DEFAULTS" : "Restore defaults", - "BUTTON_CANCEL" : "Cancel", + "RESTORE_DEFAULTS" : "Restore defaults", // Endregion "CONFIRM_RELOAD_BRACKETS" : "Would you like to reload Brackets to apply the new settings? You will be prompted to save changes on unsaved documents.", "RELOAD_BRACKETS" : "Reload Brackets", - "BUTTON_RELOAD" : "Reload" + "RELOAD" : "Reload" }); diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index e91c326e9fd..763e25fd8a7 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -622,5 +622,29 @@ define({ "CMD_TOGGLE_RECENT_PROJECTS" : "Recent Projects", // extensions/default/WebPlatformDocs - "DOCS_MORE_LINK" : "Read more" + "DOCS_MORE_LINK" : "Read more", + + //extensions/default/CodeFolding + "ENABLE_CODE_FOLDING" : "Enable code folding", + "CODE_FOLDING_SETTINGS" : "Code Folding Settings", + "COLLAPSE_ALL" : "Collapse All", + "EXPAND_ALL" : "Expand All", + "COLLAPSE_CURRENT" : "Collapse Current", + "EXPAND_CURRENT" : "Expand Current", + "COLLAPSE_CUSTOM_REGIONS" : "Collapse Custom Regions", + "MIN_FOLD_SIZE" : "Minimum fold size", + "MIN_FOLD_SIZE_HELP" : "Minimum number of lines to allow in a fold range", + "ENABLE_REGION_FOLDING" : "Enable custom region folding", + "SAVE_FOLD_STATES" : "Save fold states", + "SAVE_FOLD_STATES_HELP" : "Save fold states to disk when editor is closed and restore the folds when reopened", + "ALWAYS_USE_INDENT_FOLD" : "Always use indent fold", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Always use level of indentation as a folding guideline", + "FADE_FOLD_BUTTONS" : "Fade fold buttons", + "FADE_FOLD_BUTTONS_HELP" : "Hides the fold buttons unless the mouse is over the gutter", + "MAX_FOLD_LEVEL" : "Maximum number of nested folds", + "MAX_FOLD_LEVEL_HELP" : "Used to limit the number of nested folds to find and collapse when View -> Collapse All is called or Alt is held down when collapsing. Should improve performance for large files.", + "RESTORE_DEFAULTS" : "Restore defaults", + "CONFIRM_RELOAD_BRACKETS" : "Would you like to reload Brackets to apply the new settings? You will be prompted to save changes on unsaved documents.", + "RELOAD_BRACKETS" : "Reload {APP_NAME}", + "RELOAD" : "Reload" }); From f4c7091b63e58c5dc4de263d00ee9950ba7a9a8d Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Mon, 30 Mar 2015 10:38:52 +0100 Subject: [PATCH 07/11] Merged language strings for fi, nl, pt-br, ru --- src/extensions/default/CodeFolding/Prefs.js | 4 +- src/nls/fi/strings.js | 25 ++++- src/nls/nl/strings.js | 67 ++++++++----- src/nls/pt-br/strings.js | 59 +++++++---- src/nls/ru/strings.js | 103 ++++++++++++-------- 5 files changed, 174 insertions(+), 84 deletions(-) diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index 9494d897da2..7aa48b1cfcc 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -22,7 +22,7 @@ define(function (require, exports, module) { */ function simplify(folds) { if (!folds) { - return folds; + return; } var res = {}, range; Object.keys(folds).forEach(function (line) { @@ -39,7 +39,7 @@ define(function (require, exports, module) { */ function inflate(folds) { if (!folds) { - return folds; + return; } //transform the folds into objects with from and to properties var ranges = {}, obj; diff --git a/src/nls/fi/strings.js b/src/nls/fi/strings.js index 8db8c23b69a..cadea280ee7 100644 --- a/src/nls/fi/strings.js +++ b/src/nls/fi/strings.js @@ -624,7 +624,30 @@ define({ "CMD_TOGGLE_RECENT_PROJECTS" : "Viimeisimmät projektit", // extensions/default/WebPlatformDocs - "DOCS_MORE_LINK" : "Lue lisää" + "DOCS_MORE_LINK" : "Lue lisää", + + //extensions/default/CodeFolding + "CODE_FOLDING_SETTINGS" : "Koodin laskostuksen asetukset", + "COLLAPSE_ALL" : "Pienennä kaikki", + "EXPAND_ALL" : "Laajenna kaikki", + "COLLAPSE_CURRENT" : "Pienennä nykyinen", + "EXPAND_CURRENT" : "Laajenna nykyinen", + "COLLAPSE_CUSTOM_REGIONS" : "Pienennä mukautetut alueet", + "MIN_FOLD_SIZE" : "Pienin laskostuksen koko", + "MIN_FOLD_SIZE_HELP" : "Pienin sallittu laskostettavan alueen rivimäärä", + "ENABLE_REGION_FOLDING" : "Ota mukautetun alueen laskostus käyttöön", + "SAVE_FOLD_STATES" : "Tallenna laskosten tilat", + "SAVE_FOLD_STATES_HELP" : "Tallenna laskosten tilat levylle, kun editori suljetaan ja palauta ne, kun editori avataan uudelleen", + "ALWAYS_USE_INDENT_FOLD" : "Käytä aina sisennyslaskostusta", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Käytä aina sisennyksen tasoa laskostuksen ohjenuorana", + "FADE_FOLD_BUTTONS" : "Häivytä laskostuspainikkeet", + "FADE_FOLD_BUTTONS_HELP" : "Piilottaa laskostuspainikkeet, ellei osoitin ole sivumarginaalin päällä", + "MAX_FOLD_LEVEL" : "Suurin sallittu sisäkkäisten laskosten määrä", + "MAX_FOLD_LEVEL_HELP" : "Käytetään rajoittamaan sisäkkäisten laskosten määrää etsittäessä ja pienennettäessä, kun käytetään Näytä -> Pienennä kaikki \u2011komentoa tai kun Alt-näppäintä pidetään alhaalla pienennettäessä. Pitäisi parantaa suurten tiedostojen suorituskykyä.", + "RESTORE_DEFAULTS" : "Palauta oletukset", + "CONFIRM_RELOAD_BRACKETS" : "Haluatko ladata Bracketsin uudelleen ottaaksesi uudet asetukset käyttöön? Sinua pyydetään tallentamaan muutokset tallentamattomiin dokumentteihin.", + "RELOAD_BRACKETS" : "Lataa Brackets uudelleen", + "RELOAD" : "Lataa uudelleen" }); /* Last translated for eef9c68a1fdff372b9ea6352cacb5e2506e55be9 */ diff --git a/src/nls/nl/strings.js b/src/nls/nl/strings.js index c261a379bf1..f7301c33ac7 100644 --- a/src/nls/nl/strings.js +++ b/src/nls/nl/strings.js @@ -25,7 +25,7 @@ /*global define */ define({ - + /** * Errors */ @@ -76,7 +76,7 @@ define({ "ERROR_LAUNCHING_BROWSER_TITLE" : "Probleem bij het starten in de browser", "ERROR_CANT_FIND_CHROME" : "De Google Chrome browser kon niet gevonden worden. Zorg ervoor dat deze geïnstalleerd is.", "ERROR_LAUNCHING_BROWSER" : "Er is een fout opgetreden bij het starten van de browser. (error {0})", - + "LIVE_DEVELOPMENT_ERROR_TITLE" : "Probleem met Live Voorbeeld", "LIVE_DEVELOPMENT_RELAUNCH_TITLE" : "Bezig met verbinden met de browser", "LIVE_DEVELOPMENT_ERROR_MESSAGE" : "Om met Live Voorbeeld te verbinden, moet Chrome opnieuw gestart worden met debugging op afstand ingeschakeld.

Wil je Chrome herstarten en debugging op afstand inschakelen?", @@ -87,7 +87,7 @@ define({ "LIVE_DEVELOPMENT_INFO_TITLE" : "Welkom bij Live Voorbeeld!", "LIVE_DEVELOPMENT_INFO_MESSAGE" : "Live Voorbeeld verbindt {APP_NAME} met je browser. Het toont een voorbeeld van je HTML bestand in de browser, vervolgens updatet het voorbeeld onmiddelijk bij het wijzigen van je code.

In deze vroege versie van {APP_NAME}, werkt Live Voorbeeld enkel met Google Chrome en updatet live bij het wijzigen van CSS of HTML bestanden. Wijzigingen aan JavaScript bestanden worden automatisch herladen wanneer je bewaart.

(Je zal dit bericht slechts eenmaal zien.)", "LIVE_DEVELOPMENT_TROUBLESHOOTING" : "Voor meer informatie zie, see Oplossen van Live Ontwikkeling verbindingsproblemen.", - + "LIVE_DEV_STATUS_TIP_NOT_CONNECTED" : "Live Voorbeeld", "LIVE_DEV_STATUS_TIP_PROGRESS1" : "Live Voorbeeld: Bezig met verbinden\u2026", "LIVE_DEV_STATUS_TIP_PROGRESS2" : "Live Voorbeeld: Initialiseren\u2026", @@ -99,7 +99,7 @@ define({ "LIVE_DEV_DETACHED_TARGET_CLOSED" : "Live Voorbeeld is geannuleerd omdat de pagina gesloten werd in de browser", "LIVE_DEV_NAVIGATED_AWAY" : "Live Voorbeeld is geannuleerd omdat de browser navigeerde naar een pagina die geen deel uit maakt van het huidige project", "LIVE_DEV_CLOSED_UNKNOWN_REASON" : "Live Voorbeeld is geannuleerd om een onbekende reden ({0})", - + "SAVE_CLOSE_TITLE" : "Opslaan van wijzigingen", "SAVE_CLOSE_MESSAGE" : "Wil je de wijzigingen opslaan die je maakte in het document {0}?", "SAVE_CLOSE_MULTI_MESSAGE" : "Wil je je wijzigingen van de volgende bestanden opslaan?", @@ -109,7 +109,7 @@ define({ "FILE_DELETED_TITLE" : "Bestand Verwijderd", "EXT_MODIFIED_MESSAGE" : "{0} is gewijzigd op de schijf, maar heeft ook onbewaarde wijzigingen in {APP_NAME}.

Welke versie wil je behouden?", "EXT_DELETED_MESSAGE" : "{0} is verwijderd op de schijf, maar heeft onbewaarde wijzigingen in {APP_NAME}.

Wil je je wijzigingen behouden?", - + // Find, Replace, Find in Files "SEARCH_REGEXP_INFO" : "Gebruik de /re/ syntax voor een regexp zoekopdracht", "FIND_RESULT_COUNT" : "{0} resultaten", @@ -121,7 +121,7 @@ define({ "BUTTON_REPLACE_ALL" : "Alle\u2026", "BUTTON_STOP" : "Stop", "BUTTON_REPLACE" : "Vervang", - + "BUTTON_NEXT" : "\u25B6", "BUTTON_PREV" : "\u25C0", "BUTTON_NEXT_HINT" : "Volgende overeenkomst", @@ -167,7 +167,7 @@ define({ "KEYBOARD_CTRL" : "Ctrl", "KEYBOARD_SHIFT" : "Shift", "KEYBOARD_SPACE" : "Space", - + /** * StatusBar strings */ @@ -193,8 +193,8 @@ define({ "LINT_DISABLED" : "Linting is uitgeschakeld", "NO_LINT_AVAILABLE" : "Er is geen linter beschikbaar voor {0}", "NOTHING_TO_LINT" : "Niets om te linten", - - + + /** * Command Name Constants */ @@ -250,7 +250,7 @@ define({ "CMD_OPEN_LINE_BELOW" : "Open regel beneden", "CMD_TOGGLE_CLOSE_BRACKETS" : "Automatisch accolades sluiten", "CMD_SHOW_CODE_HINTS" : "Toon code hints", - + // View menu commands "VIEW_MENU" : "Beeld", "CMD_HIDE_SIDEBAR" : "Verberg zijbalk", @@ -284,7 +284,7 @@ define({ "CMD_PREV_DOC" : "Vorig document", "CMD_SHOW_IN_TREE" : "Toon in bestandsboom", "CMD_SHOW_IN_OS" : "Toon in besturingssysteem", - + // Help menu commands "HELP_MENU" : "Help", "CMD_CHECK_FOR_UPDATE" : "Controleer op updates", @@ -328,7 +328,7 @@ define({ "BASEURL_ERROR_HASH_DISALLOWED" : "De start URL kan geen hashes bevatten zoals \"{0}\".", "BASEURL_ERROR_INVALID_CHAR" : "Speciale karakters zoals '{0}' moeten %-geëncodeerd zijn.", "BASEURL_ERROR_UNKNOWN_ERROR" : "Onbekende fout bij het parsen van de begin URL", - + // Extension Management strings "INSTALL" : "Installeren", "UPDATE" : "Update", @@ -405,14 +405,14 @@ define({ "EXTENSIONS_INSTALLED_TITLE" : "Geïnstalleerd", "EXTENSIONS_AVAILABLE_TITLE" : "Beschikbaar", "EXTENSIONS_UPDATES_TITLE" : "Updates", - + /** * Unit names */ "UNIT_PIXELS" : "pixels", - - + + // extensions/default/DebugCommands "DEBUG_MENU" : "Debug", "CMD_SHOW_DEV_TOOLS" : "Tools weergeven voor ontwikkelaars", @@ -424,13 +424,13 @@ define({ "CMD_ENABLE_NODE_DEBUGGER" : "Schakel Node Debugger in", "CMD_LOG_NODE_STATE" : "Log Node Status naar Console", "CMD_RESTART_NODE" : "Herstart Node", - + "LANGUAGE_TITLE" : "Wijzig taal", "LANGUAGE_MESSAGE" : "Taal:", "LANGUAGE_SUBMIT" : "{APP_NAME} opnieuw laden", "LANGUAGE_CANCEL" : "Annuleren", "LANGUAGE_SYSTEM_DEFAULT" : "Systeem voorkeuren", - + // extensions/default/InlineColorEditor "COLOR_EDITOR_CURRENT_COLOR_SWATCH_TIP" : "Huidige kleur", "COLOR_EDITOR_ORIGINAL_COLOR_SWATCH_TIP" : "Originele kleur", @@ -439,22 +439,43 @@ define({ "COLOR_EDITOR_HSLA_BUTTON_TIP" : "HSLa formaat", "COLOR_EDITOR_USED_COLOR_TIP_SINGULAR" : "{0} ({1} keer gebruikt)", "COLOR_EDITOR_USED_COLOR_TIP_PLURAL" : "{0} ({1} keer gebruikt)", - + // extensions/default/JavaScriptCodeHints "CMD_JUMPTO_DEFINITION" : "Ga naar definitie", "CMD_SHOW_PARAMETER_HINT" : "Toon parameter Hint", "NO_ARGUMENTS" : "", - + // extensions/default/JSLint "JSLINT_NAME" : "JSLint", - + // extensions/default/QuickView "CMD_ENABLE_QUICK_VIEW" : "Snel bekijken bij muis over", - + // extensions/default/RecentProjects "CMD_TOGGLE_RECENT_PROJECTS" : "Recente projecten", - + // extensions/default/WebPlatformDocs - "DOCS_MORE_LINK" : "Lees meer" + "DOCS_MORE_LINK" : "Lees meer", + + //extensions/default/CodeFolding + "CODE_FOLDING_SETTINGS" : "Code Folding instellingen", + "COLLAPSE_ALL" : "Alles inklappen", + "EXPAND_ALL" : "Alles uitklappen", + "COLLAPSE_CURRENT" : "Huidige inklappen", + "EXPAND_CURRENT" : "Huidige uitklappen", + "COLLAPSE_CUSTOM_REGIONS" : "Aangepaste regio's inklappen", + "MIN_FOLD_SIZE" : "Minimale vouwgrootte", + "MIN_FOLD_SIZE_HELP" : "Minimaal aantal regels om toe te staan in een vouwreeks", + "ENABLE_REGION_FOLDING" : "Aangepaste regio's inschakelen", + "SAVE_FOLD_STATES" : "Vouwstatus bewaren", + "SAVE_FOLD_STATES_HELP" : "Vouwstatus bewaren op schijf als editor gesloten wordt en herstellen wanneer opnieuw geopend", + "ALWAYS_USE_INDENT_FOLD" : "Altijd vouwindentatie gebruiken", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Altijd het indentatieniveau als vouwrichtlijn gebruiken", + "FADE_FOLD_BUTTONS" : "Vouwknoppen vervagen", + "FADE_FOLD_BUTTONS_HELP" : "Verberg de vouwknoppen, behalve als de muis over de goot hangt", + "RESTORE_DEFAULTS" : "Herstel standaarden", + "CONFIRM_RELOAD_BRACKETS" : "Wil je Brackets herstarten om de nieuwe instelingen toe te passen? Je zal gevraagd worden om wijzigingen in nog niet opgeslagen documenten op te slaan.", + "RELOAD_BRACKETS" : "Herstart Brackets", + "RELOAD" : "Herstart" }); /* Last translated for 752856d58d2e9dde14e1af6be615bb7080727b7a */ diff --git a/src/nls/pt-br/strings.js b/src/nls/pt-br/strings.js index 2a5a0db3fa1..b5bda3a6b48 100644 --- a/src/nls/pt-br/strings.js +++ b/src/nls/pt-br/strings.js @@ -25,7 +25,7 @@ /*global define */ define({ - + /** * Errors */ @@ -48,7 +48,7 @@ define({ "FILENAMES_LEDE" : "Nomes de arquivos", "FILENAME" : "Nome de arquivo", "DIRECTORY_NAME" : "Nome de diretório", - + // Project error strings "ERROR_LOADING_PROJECT" : "Erro ao carregar o projeto", @@ -199,7 +199,7 @@ define({ "ERROR_FETCHING_UPDATE_INFO_TITLE" : "Erro ao receber informações de atualização", "ERROR_FETCHING_UPDATE_INFO_MSG" : "Houve um problema ao obter informações sobre a última atualização do servidor. Por favor, certifique-se de estar conectado à Internet e tente novamente.", - + // File exclusion filters "NEW_FILE_FILTER" : "Adicionar filtro\u2026", "CLEAR_FILE_FILTER" : "Limpar filtro de arquivos", @@ -225,7 +225,7 @@ define({ // Quick Docs "ERROR_QUICK_DOCS_PROVIDER_NOT_FOUND" : "Quick Docs não disponível para a posição atual do cursor", - + /** * ProjectManager */ @@ -294,8 +294,8 @@ define({ "NOTHING_TO_LINT" : "Nada para analisar", "LINTER_TIMED_OUT" : "{0} expirou após esperar durante {1} ms", "LINTER_FAILED" : "{0} terminou com o erro: {1}", - - + + /** * Command Name Constants */ @@ -319,7 +319,7 @@ define({ "CMD_FILE_SAVE_ALL" : "Salvar todos", "CMD_FILE_SAVE_AS" : "Salvar como\u2026", "CMD_LIVE_FILE_PREVIEW" : "Live Preview", - "CMD_TOGGLE_LIVE_PREVIEW_MB_MODE" : "Habilitar Live Preview experimental", + "CMD_TOGGLE_LIVE_PREVIEW_MB_MODE" : "Habilitar Live Preview experimental", "CMD_RELOAD_LIVE_PREVIEW" : "Forçar recarregamento do Live Preview", "CMD_PROJECT_SETTINGS" : "Configurações do projeto\u2026", "CMD_FILE_RENAME" : "Renomear", @@ -454,17 +454,17 @@ define({ "BASEURL_ERROR_INVALID_CHAR" : "Caracteres especiais como '{0}' devem ser codificados para URL encoding.", "BASEURL_ERROR_UNKNOWN_ERROR" : "Erro desconhecido ao parsear URL base", "EMPTY_VIEW_HEADER" : "Abra um arquivo enquanto este painel possui o foco", - + // Strings for themes-settings.html and themes-general.html "CURRENT_THEME" : "Tema atual", "USE_THEME_SCROLLBARS" : "Usar barra de rolagens do tema", "FONT_SIZE" : "Tamanho da fonte", "FONT_FAMILY" : "Família da fonte", "THEMES_SETTINGS" : "Configurações de temas", - + // CSS Quick Edit "BUTTON_NEW_RULE" : "Nova regra", - + // Extension Management strings "INSTALL" : "Instalar", "UPDATE" : "Atualizar", @@ -555,7 +555,7 @@ define({ "EXTENSIONS_AVAILABLE_TITLE" : "Disponíveis", "EXTENSIONS_THEMES_TITLE" : "Temas", "EXTENSIONS_UPDATES_TITLE" : "Atualizações", - + "INLINE_EDITOR_NO_MATCHES" : "Nenhum resultado.", "INLINE_EDITOR_HIDDEN_MATCHES" : "Todas as correspondências foram ocultadas. Expanda os arquivos listados na direita para ver os resultados.", "CSS_QUICK_EDIT_NO_MATCHES" : "Nenhuma regra CSS corresponde à sua seleção.
Clique em \"Nova regra\" para criar uma.", @@ -585,13 +585,13 @@ define({ "CMD_RESTART_NODE" : "Reiniciar Node", "CMD_SHOW_ERRORS_IN_STATUS_BAR" : "Mostrar erros na barra de status", "CMD_OPEN_BRACKETS_SOURCE" : "Abrir local do Brackets", - + "LANGUAGE_TITLE" : "Alterar idioma", "LANGUAGE_MESSAGE" : "Idioma:", "LANGUAGE_SUBMIT" : "Reiniciar {APP_NAME}", "LANGUAGE_CANCEL" : "Cancelar", "LANGUAGE_SYSTEM_DEFAULT" : "Padrão do sistema", - + // extensions/default/InlineTimingFunctionEditor "INLINE_TIMING_EDITOR_TIME" : "Tempo", "INLINE_TIMING_EDITOR_PROGRESSION" : "Progresso", @@ -607,24 +607,45 @@ define({ "COLOR_EDITOR_HSLA_BUTTON_TIP" : "Formato HSLa", "COLOR_EDITOR_USED_COLOR_TIP_SINGULAR" : "{0} (usada {1} vez)", "COLOR_EDITOR_USED_COLOR_TIP_PLURAL" : "{0} (usada {1} vezes)", - + // extensions/default/JavaScriptCodeHints "CMD_JUMPTO_DEFINITION" : "Pular para definição", "CMD_SHOW_PARAMETER_HINT" : "Mostrar dicas de parâmetro", "NO_ARGUMENTS" : "", "DETECTED_EXCLUSION_TITLE" : "Problema de inferência de arquivo JavaScript", "DETECTED_EXCLUSION_INFO" : "Brackets enfrentou um problema ao processar: {0}.

Este arquivo não será mais processado para dicas de código, definições ou edição rápida. Para reverter, abra .brackets.json em seu projeto e edite jscodehints.detectedExclusions.

Este provavelmente é um bug do Brackets. Se você pode fornecer uma cópia deste arquivo, por favor registre um bug com um link para o arquivo mencionado aqui.", - + // extensions/default/JSLint "JSLINT_NAME" : "JSLint", - + // extensions/default/QuickView "CMD_ENABLE_QUICK_VIEW" : "Quick View ao passar o mouse", - + // extensions/default/RecentProjects "CMD_TOGGLE_RECENT_PROJECTS" : "Projetos Recentes", - + // extensions/default/WebPlatformDocs - "DOCS_MORE_LINK" : "Leia mais" + "DOCS_MORE_LINK" : "Leia mais", + + //extensions/default/CodeFolding + "CODE_FOLDING_SETTINGS" : "Opções de Dobramento", + "COLLAPSE_ALL" : "Dobrar Tudo", + "EXPAND_ALL" : "Expandir Tudo", + "COLLAPSE_CURRENT" : "Dobrar Posição Atual", + "EXPAND_CURRENT" : "Expandir Posição Atual", + "COLLAPSE_CUSTOM_REGIONS" : "Dobrar Regiões Personalizadas", + "MIN_FOLD_SIZE" : "Tamanha Mínimo", + "MIN_FOLD_SIZE_HELP" : "Número Mínimo de linhas necessário para o dobramento", + "ENABLE_REGION_FOLDING" : "Regiões Personalizadas de Dobramento", + "SAVE_FOLD_STATES" : "Salvar Dobramentos", + "SAVE_FOLD_STATES_HELP" : "Salva o estado atual das dobras quando o editor é fechado e as restaura quando aberto", + "ALWAYS_USE_INDENT_FOLD" : "Sempre Usar Dobramento por Indentação", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Usa a Indentação como guia para o Dobramento", + "FADE_FOLD_BUTTONS" : "Ocultar os botões de Dobramento", + "FADE_FOLD_BUTTONS_HELP" : "Oculta os botões quando o cursor não está sobre eles", + "RESTORE_DEFAULTS" : "Restaurar Opções", + "CONFIRM_RELOAD_BRACKETS" : "Deseja reiniciar o Brackets para aplicar as novas configurações? Haverá a possibilidade de salvar os arquivos editados.", + "RELOAD_BRACKETS" : "Reiniciar Brackets", + "RELOAD" : "Recarregar" }); /* Last translated for 0b949dd02b87866d54f38631715a4353a8f927e5 */ diff --git a/src/nls/ru/strings.js b/src/nls/ru/strings.js index d2f62e1d7e3..ccd262b585b 100644 --- a/src/nls/ru/strings.js +++ b/src/nls/ru/strings.js @@ -1,31 +1,31 @@ /* * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * */ /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ /*global define */ define({ - + /** * Errors */ @@ -86,7 +86,7 @@ define({ "ERROR_LAUNCHING_BROWSER_TITLE" : "Ошибка запуска браузера.", "ERROR_CANT_FIND_CHROME" : "Браузер Google Chrome не найден. Пожалуйста, убедитесь, что он установлен.", "ERROR_LAUNCHING_BROWSER" : "Произошла ошибка при запуске браузера. (ошибка {0})", - + "LIVE_DEVELOPMENT_ERROR_TITLE" : "Ошибка функции Live Preview", "LIVE_DEVELOPMENT_RELAUNCH_TITLE" : "Соединение с браузером", "LIVE_DEVELOPMENT_ERROR_MESSAGE" : "Функция Live Preview требует перезапуска Chrome с включенной функцией удаленной отладки.

Перезапустить Chrome с удаленной отладкой?", @@ -97,19 +97,19 @@ define({ "LIVE_DEVELOPMENT_INFO_TITLE" : "Добро пожаловать в Live Preview!", "LIVE_DEVELOPMENT_INFO_MESSAGE" : "Live Preview, функция синхронного предпросмотра, подключает браузер к среде разработки {APP_NAME}. Эта функция загружает HTML файл для предварительного просмотра в браузере и мгновенно отображает все изменения при редактировании кода.

В данной версии {APP_NAME}, функция Live Preview пока что работает только с Google Chrome и обновления в реальном времени отображаются только при редактировании CSS или HTML файлов. Изменения в JavaScript файлах автоматически перезагружают страницу при сохранении.

(Это сообщение будет показано только один раз.)", "LIVE_DEVELOPMENT_TROUBLESHOOTING" : "Для дополнительной информации, смотрите Поиск и устранение неисправностей ошибок подключения Live Preview.", - + "LIVE_DEV_STATUS_TIP_NOT_CONNECTED" : "Live Preview", "LIVE_DEV_STATUS_TIP_PROGRESS1" : "Live Preview: Подключение\u2026", "LIVE_DEV_STATUS_TIP_PROGRESS2" : "Live Preview: Инициализация\u2026", "LIVE_DEV_STATUS_TIP_CONNECTED" : "Отсоединить Live Preview", "LIVE_DEV_STATUS_TIP_OUT_OF_SYNC" : "Live Preview (Для отображения изменений сохраните их)", "LIVE_DEV_STATUS_TIP_SYNC_ERROR" : "Live Preview (Не обновляется из-за синтаксической ошибки)", - + "LIVE_DEV_DETACHED_REPLACED_WITH_DEVTOOLS" : "Функция Live Preview была отключена при открытии инструментов разработки в браузере", "LIVE_DEV_DETACHED_TARGET_CLOSED" : "Функция Live Preview была отключена при закрытии страницы в браузере", "LIVE_DEV_NAVIGATED_AWAY" : "Функция Live Preview была отключена при переходе на страницу не принадлежащую проекту", "LIVE_DEV_CLOSED_UNKNOWN_REASON" : "Функция Live Preview была отменена по неизвестной причине ({0})", - + "SAVE_CLOSE_TITLE" : "Сохранить изменения", "SAVE_CLOSE_MESSAGE" : "Вы хотите сохранить изменения, которые вы сделали в документе {0}?", "SAVE_CLOSE_MULTI_MESSAGE" : "Вы хотите сохранить изменения для следующих файлов?", @@ -120,7 +120,7 @@ define({ "EXT_MODIFIED_WARNING" : "{0} был изменен на диске.

Вы хотите сохранить ваши изменения и перезаписать внешние?", "EXT_MODIFIED_MESSAGE" : "{0} был изменен на диске, но также имеются несохраненные изменения в {APP_NAME}.

Какую версию вы хотите оставить?", "EXT_DELETED_MESSAGE" : "{0} был удален на диске, но имеются несохраненные изменения в {APP_NAME}.

Вы хотите оставить ваши изменения?", - + // Generic dialog/button labels "DONE" : "Готово", "OK" : "ОК", @@ -132,7 +132,7 @@ define({ "DELETE" : "Удалить", "BUTTON_YES" : "Да", "BUTTON_NO" : "Нет", - + // Find, Replace, Find in Files "FIND_RESULT_COUNT" : "{0} результатов", "FIND_RESULT_COUNT_SINGLE" : "1 результат", @@ -164,7 +164,7 @@ define({ "FIND_REPLACE_TITLE_WITH" : "на", "FIND_TITLE_LABEL" : "Найдено", "FIND_TITLE_SUMMARY" : "— {0} {1} {2} в {3}", - + // Find in Files "FIND_IN_FILES_TITLE_PART1" : "\"", "FIND_IN_FILES_TITLE_PART2" : "\" найдено", @@ -185,7 +185,7 @@ define({ "REPLACE_IN_FILES_ERRORS" : "Данные файлы не были изменены, т.к. они изменились после поиска или не могут быть записаны.", "ERROR_FETCHING_UPDATE_INFO_TITLE" : "Ошибка при получении информации об обновлениях", "ERROR_FETCHING_UPDATE_INFO_MSG" : "Ошибка при получении информации о последних обновлениях с сервера. Пожалуйста, убедитесь, что вы подключены к интернету и попробуйте снова. ", - + // File exclusion filters "NEW_FILE_FILTER" : "Новый фильтр\u2026", "CLEAR_FILE_FILTER" : "Не исключать файлы", @@ -227,7 +227,7 @@ define({ "KEYBOARD_CTRL" : "Ctrl", "KEYBOARD_SHIFT" : "Shift", "KEYBOARD_SPACE" : "Space", - + /** * StatusBar strings */ @@ -260,8 +260,8 @@ define({ "NOTHING_TO_LINT" : "Не подлежит статическому анализу", "LINTER_TIMED_OUT" : "{0} превысил время ожидания {1} мс", "LINTER_FAILED" : "{0} завершил исполнение с ошибкой: {1}", - - + + /** * Command Name Constants */ @@ -336,7 +336,7 @@ define({ "CMD_REPLACE_IN_FILES" : "Заменить в файлах", "CMD_REPLACE_IN_SELECTED" : "Заменить в выделенном файле/директории", "CMD_REPLACE_IN_SUBTREE" : "Заменить в\u2026", - + // View menu commands "VIEW_MENU" : "Вид", "CMD_HIDE_SIDEBAR" : "Скрыть боковую панель", @@ -373,7 +373,7 @@ define({ "CMD_SHOW_IN_EXPLORER" : "Показать в Проводнике", "CMD_SHOW_IN_FINDER" : "Показать в Finder", "CMD_SHOW_IN_OS" : "Показать в операционной системе", - + // Help menu commands "HELP_MENU" : "Помощь", "CMD_CHECK_FOR_UPDATE" : "Проверить наличие обновлений", @@ -415,10 +415,10 @@ define({ "BASEURL_ERROR_HASH_DISALLOWED" : "Базовый URL не может содержать такие хеши как \"{0}\".", "BASEURL_ERROR_INVALID_CHAR" : "Специальные символы как '{0}' должны быть %-экранированы.", "BASEURL_ERROR_UNKNOWN_ERROR" : "Неизвестная ошибка при синтаксическом разборе основного URL", - + // CSS Quick Edit "BUTTON_NEW_RULE" : "Новое правило", - + // Extension Management strings "INSTALL" : "Установить", "UPDATE" : "Обновить", @@ -499,14 +499,14 @@ define({ "EXTENSIONS_INSTALLED_TITLE" : "Установленные", "EXTENSIONS_AVAILABLE_TITLE" : "Доступные", "EXTENSIONS_UPDATES_TITLE" : "Обновления", - + "INLINE_EDITOR_NO_MATCHES" : "Совпадений не найдено.", "CSS_QUICK_EDIT_NO_MATCHES" : "Существующих правил CSS соответвующих выделенному тексту не определено.
Выберите \"Новое правило\" чтобы создать новое.", "CSS_QUICK_EDIT_NO_STYLESHEETS" : "Ваш проект не содержит таблиц стилей (stylesheets).
Создайте его чтобы добавить правила CSS.", // Custom Viewers "IMAGE_VIEWER_LARGEST_ICON" : "наибольший размер", - + /** * Unit names */ @@ -527,20 +527,20 @@ define({ "CMD_LOG_NODE_STATE" : "Отображать состояние node в консоли", "CMD_RESTART_NODE" : "Перезапустить node", "CMD_SHOW_ERRORS_IN_STATUS_BAR" : "Показывать ошибки в строке состояния", - + "LANGUAGE_TITLE" : "Изменить язык", "LANGUAGE_MESSAGE" : "Пожалуйста, выберите желаемый язык из списка ниже:", "LANGUAGE_SUBMIT" : "Перезагрузить {APP_NAME}", "LANGUAGE_CANCEL" : "Отмена", "LANGUAGE_SYSTEM_DEFAULT" : "По умолчанию", - + // extensions/default/InlineTimingFunctionEditor "INLINE_TIMING_EDITOR_TIME" : "Время", "INLINE_TIMING_EDITOR_PROGRESSION" : "Прогресс", "BEZIER_EDITOR_INFO" : " Передвинуть выделенную точку
Shift Передвинуться на десять единиц
Tab Переключиться между точками", "STEPS_EDITOR_INFO" : " Увеличить или уменьшить шаги
'Начало' или 'Конец'", "INLINE_TIMING_EDITOR_INVALID" : "Старое значение {0} некорректно, отображаемая функция была заменена на {1}. Документ будет обновлен с первой правкой.", - + // extensions/default/InlineColorEditor "COLOR_EDITOR_CURRENT_COLOR_SWATCH_TIP" : "Текущий цвет", "COLOR_EDITOR_ORIGINAL_COLOR_SWATCH_TIP" : "Оригинальный цвет", @@ -549,21 +549,46 @@ define({ "COLOR_EDITOR_HSLA_BUTTON_TIP" : "HSLa формат", "COLOR_EDITOR_USED_COLOR_TIP_SINGULAR" : "{0} (Использовано {1} раз)", "COLOR_EDITOR_USED_COLOR_TIP_PLURAL" : "{0} (Использовано {1} раза)", - + // extensions/default/JavaScriptCodeHints "CMD_JUMPTO_DEFINITION" : "Перейти к определению", "CMD_SHOW_PARAMETER_HINT" : "Показывать подсказки по аргументам функции", "NO_ARGUMENTS" : "<нет аргументов>", - + // extensions/default/JSLint "JSLINT_NAME" : "JSLint", - + // extensions/default/QuickView "CMD_ENABLE_QUICK_VIEW" : "Быстрый просмотр при наведении", - + // extensions/default/RecentProjects "CMD_TOGGLE_RECENT_PROJECTS" : "Предыдущие проекты", - + // extensions/default/WebPlatformDocs - "DOCS_MORE_LINK" : "Подробнее\u2026" + "DOCS_MORE_LINK" : "Подробнее\u2026", + + //extensions/default/CodeFolding + "CODE_FOLDING_SETTINGS" : "Настройки Code Folding", + "COLLAPSE_ALL" : "Свернуть все", + "EXPAND_ALL" : "Развернуть все", + "COLLAPSE_CURRENT" : "Свернуть текущий", + "EXPAND_CURRENT" : "Развернуть текущий", + "COLLAPSE_CUSTOM_REGIONS" : "Свернуть текущий region", + "MIN_FOLD_SIZE" : "Минимальный размер сворачивания", + "MIN_FOLD_SIZE_HELP" : "Минимальное число строк для сворачивания", + "ENABLE_REGION_FOLDING" : "Включить сворачивание для region`ов", + "SAVE_FOLD_STATES" : "Сохранять состояние", + "SAVE_FOLD_STATES_HELP" : "Сохранить состояние свёрнутых/развёрнутых блоков на диск при закрытии редактора и восстановить при повторном открытии", + "ALWAYS_USE_INDENT_FOLD" : "Всегда использовать вложеность", + "ALWAYS_USE_INDENT_FOLD_HELP" : "Всегда использовать уровень вложенности в качестве ориентира", + "FADE_FOLD_BUTTONS" : "Скрывать кнопки для фолдинга", + "FADE_FOLD_BUTTONS_HELP" : "Отображать кнопки для фолдинга только при наведении", + "MAX_FOLD_LEVEL" : "Максимальное число вложенных сворачиваний", + "MAX_FOLD_LEVEL_HELP" : "Используется для ограничения числа вложенных сворачиваний, чтобы свернуть воспользуйтесь Вид-> Свернуть Все или зажмите Alt во время сворачивания. Это улучшит производительность для больших файлов.", + "BUTTON_SAVE" : "Сохранить", + "BUTTON_DEFAULTS" : "Востановить значения по умолчанию", + "BUTTON_CANCEL" : "Отмена", + "CONFIRM_RELOAD_BRACKETS" : "Вы хотите перезагрузить Brackets, чтобы применить новые параметры? Вам будет предложено сохранить все изменения.", + "RELOAD_BRACKETS" : "Перегрузить Brackets", + "BUTTON_RELOAD" : "Перегрузить" }); From b341c370b96e84b75f47cc3f6d719410e6b4d616 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Tue, 31 Mar 2015 22:30:10 +0100 Subject: [PATCH 08/11] Removed htmltemplates related to dialog boxes for code-folding settings. Updated shortcut to Ctrl+Alt+[ and Ctrl+Alt+] for expand and collapse --- .../default/CodeFolding/DefaultSettings.js | 20 ---- src/extensions/default/CodeFolding/Prefs.js | 44 +++++---- .../default/CodeFolding/SettingsDialog.js | 91 ------------------- .../htmlTemplates/reload-dialog.html | 12 --- .../htmlTemplates/settings-dialog.html | 72 --------------- src/extensions/default/CodeFolding/main.js | 18 +--- .../default/CodeFolding/nls/de/strings.js | 34 ------- .../default/CodeFolding/nls/es/strings.js | 34 ------- .../default/CodeFolding/nls/fi/strings.js | 55 ----------- .../default/CodeFolding/nls/fr/strings.js | 52 ----------- .../default/CodeFolding/nls/gl/strings.js | 34 ------- .../default/CodeFolding/nls/it/strings.js | 34 ------- .../default/CodeFolding/nls/ja/strings.js | 53 ----------- .../default/CodeFolding/nls/nl/strings.js | 55 ----------- .../default/CodeFolding/nls/pt-BR/strings.js | 53 ----------- .../default/CodeFolding/nls/root/strings.js | 56 ------------ .../default/CodeFolding/nls/ru/strings.js | 57 ------------ .../default/CodeFolding/nls/strings.js | 51 ----------- src/nls/fi/strings.js | 7 +- src/nls/nl/strings.js | 7 +- src/nls/pt-br/strings.js | 7 +- src/nls/root/strings.js | 7 +- src/nls/ru/strings.js | 13 +-- 23 files changed, 34 insertions(+), 832 deletions(-) delete mode 100644 src/extensions/default/CodeFolding/DefaultSettings.js delete mode 100644 src/extensions/default/CodeFolding/SettingsDialog.js delete mode 100644 src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html delete mode 100644 src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html delete mode 100644 src/extensions/default/CodeFolding/nls/de/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/es/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/fi/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/fr/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/gl/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/it/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/ja/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/nl/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/pt-BR/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/root/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/ru/strings.js delete mode 100644 src/extensions/default/CodeFolding/nls/strings.js diff --git a/src/extensions/default/CodeFolding/DefaultSettings.js b/src/extensions/default/CodeFolding/DefaultSettings.js deleted file mode 100644 index 3ba8b8b63a6..00000000000 --- a/src/extensions/default/CodeFolding/DefaultSettings.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * JSON values for default settings - * @author Patrick Oladimeji - * @date 8/23/14 15:45:35 PM - */ -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define*/ -define(function (require, exports, module) { - "use strict"; - - module.exports = { - enabled: true, - minFoldSize: 2, - saveFoldStates: true, - alwaysUseIndentFold: true, - enableRegionFolding: true, - fadeFoldButtons: false, - maxFoldLevel: 2 // this value is only used when fold all is called - }; -}); diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index 7aa48b1cfcc..b69aa21e8cc 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -9,11 +9,28 @@ define(function (require, exports, module) { "use strict"; var PreferencesManager = brackets.getModule("preferences/PreferencesManager"), - prefs = PreferencesManager.getExtensionPrefs("code-folding"), - DefaultSettings = require("DefaultSettings"), - store = {}, - settings = {}, - foldsKey = "folds"; + prefs = PreferencesManager.getExtensionPrefs("code-folding"), + strings = brackets.getModule("strings"), + store = {}, + foldsKey = "folds"; + + //default preference values + prefs.definePreference("enabled", "boolean", true, + {name: strings.ENABLE_CODE_FOLDING, description: strings.ENABLE_CODE_FOLDING}); + prefs.definePreference("minFoldSize", "number", 2, + {name: strings.MIN_FOLD_SIZE, description: strings.MIN_FOLD_SIZE_HELP}); + prefs.definePreference("saveFoldStates", "boolean", true, + {name: strings.SAVE_FOLD_STATES, description: strings.SAVE_FOLD_STATES_HELP}); + prefs.definePreference("alwaysUseIndentFold", "boolean", true, + {name: strings.ALWAYS_USE_INDENT_FOLD, description: strings.ALWAYS_USE_INDENT_FOLD_HELP}); + prefs.definePreference("enableRegionFolding", "boolean", true, + {name: strings.ENABLE_REGION_FOLDING, description: strings.ENABLE_REGION_FOLDING}); + prefs.definePreference("fadeFoldButtons", "boolean", false, + {name: strings.FADE_FOLD_BUTTONS, description: strings.FADE_FOLD_BUTTONS_HELP}); + prefs.definePreference("maxFoldLevel", "number", 2, + {name: strings.MAX_FOLD_LEVEL, description: strings.MAX_FOLD_LEVEL_HELP}); + prefs.definePreference("folds", "object", {}); + /** Simplifies the fold ranges into an array of pairs of numbers. @param {!{number: {from: {ch, line}, to: {ch, line}} folds the raw fold ranges indexed by line numbers @@ -75,18 +92,7 @@ define(function (require, exports, module) { @returns {string} the setting with the specified key */ function getSetting(key) { - settings = (prefs.get("settings") || DefaultSettings); - return settings[key]; - } - - /** - Save the code folding setting with the specified key using the specified value - @param {!string} key - @param {!string} value - */ - function setSetting(key, value) { - settings[key] = value; - prefs.set("settings", settings); + return prefs.get(key, PreferencesManager.CURRENT_PROJECT); } /** @@ -95,7 +101,7 @@ define(function (require, exports, module) { */ function getAllSettings() { var res = {}; - Object.keys(DefaultSettings).forEach(function (key) { + prefs.getKeys().forEach(function (key) { res[key] = getSetting(key); }); return res; @@ -114,8 +120,6 @@ define(function (require, exports, module) { module.exports.getSetting = getSetting; - module.exports.setSetting = setSetting; - module.exports.getAllSettings = getAllSettings; module.exports.clearAllFolds = clearAllFolds; diff --git a/src/extensions/default/CodeFolding/SettingsDialog.js b/src/extensions/default/CodeFolding/SettingsDialog.js deleted file mode 100644 index da8d98bfd37..00000000000 --- a/src/extensions/default/CodeFolding/SettingsDialog.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Configure and change settings for the code folding extension - * @author Patrick Oladimeji - * @date 8/23/14 12:32:46 PM - */ -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define, brackets, Mustache, $ */ -define(function (require, exports, module) { - "use strict"; - var Dialogs = brackets.getModule("widgets/Dialogs"), - DefaultSettings = require("DefaultSettings"), - Strings = brackets.getModule("strings"), - CommandManager = brackets.getModule("command/CommandManager"), - settingsTemplate = require("text!htmlTemplates/settings-dialog.html"), - reloadTemplate = require("text!htmlTemplates/reload-dialog.html"), - preferences = require("Prefs"); - - function setFormValues(prefs) { - prefs.enabled = prefs.enabled === undefined ? true : prefs.enabled; - $("#enable-code-folding").prop("checked", prefs.enabled); - $("#min-fold-size").val(prefs.minFoldSize || 2); - $("#max-fold-level").val(prefs.maxFoldLevel || 2); - $("#save-fold-states").prop("checked", prefs.saveFoldStates); - $("#always-use-indent-fold").prop("checked", prefs.alwaysUseIndentFold); - $("#enable-region-folding").prop("checked", prefs.enableRegionFolding); - $("#fade-fold-buttons").prop("checked", prefs.fadeFoldButtons); - } - - function restoreDefaults() { - setFormValues(DefaultSettings); - } - - /** - Shows the preferences dialog - @param {function} cb a callback function to invoke when the dialog has been accepted or dismised - */ - function showDialog(cb) { - var template = Mustache.render(settingsTemplate, Strings); - var dialog = Dialogs.showModalDialogUsingTemplate(template); - var $dialog = dialog.getElement(); - setFormValues(preferences.getAllSettings()); - - $("button[data-button-id='defaults']", $dialog).on("click", function (e) { - e.stopPropagation(); - restoreDefaults(); - }); - - $("#enable-code-folding", $dialog).change(function () { - var enabled = $("#enable-code-folding").prop("checked"); - var settingsElements = $("#min-fold-size, #max-fold-level, #save-fold-states," + - "#always-use-indent-fold, #enable-region-folding, #fade-fold-buttons"); - if (enabled) { - settingsElements.removeAttr("disabled"); - settingsElements.removeClass("disabled"); - } else { - settingsElements.attr("disabled", true); - settingsElements.addClass("diabled"); - } - }); - - dialog.done(function (buttonId) { - if (buttonId === "ok") { - var minFoldSize = $("#min-fold-size", $dialog).val(); - var maxFoldLevel = $("#max-fold-level", $dialog).val(); - var enabled = $("#enable-code-folding", $dialog).prop("checked"); - - preferences.setSetting("enabled", enabled); - preferences.setSetting("minFoldSize", isNaN(minFoldSize) || +minFoldSize === 0 ? - +preferences.getSetting("minFoldSize") : +minFoldSize); - preferences.setSetting("saveFoldStates", $("#save-fold-states", $dialog).prop("checked")); - preferences.setSetting("maxFoldLevel", isNaN(maxFoldLevel) || +maxFoldLevel === 0 ? - +preferences.getSetting("maxFoldLevel") : +maxFoldLevel); - preferences.setSetting("alwaysUseIndentFold", $("#always-use-indent-fold", $dialog).prop("checked")); - preferences.setSetting("enableRegionFolding", $("#enable-region-folding", $dialog).prop("checked")); - preferences.setSetting("fadeFoldButtons", $("#fade-fold-buttons", $dialog).prop("checked")); - - //show reload prompt - template = Mustache.render(reloadTemplate, Strings); - var reloadDialog = Dialogs.showModalDialogUsingTemplate(template); - reloadDialog.done(function (buttonId) { - if (buttonId === "ok") { - CommandManager.execute("debug.refreshWindow"); - } - }); - - } - }); - } - - exports.show = showDialog; -}); diff --git a/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html deleted file mode 100644 index 78ef71b81b0..00000000000 --- a/src/extensions/default/CodeFolding/htmlTemplates/reload-dialog.html +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html b/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html deleted file mode 100644 index 62ae8f1764e..00000000000 --- a/src/extensions/default/CodeFolding/htmlTemplates/settings-dialog.html +++ /dev/null @@ -1,72 +0,0 @@ - diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index 5159a65d743..8a36c9a0871 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -52,10 +52,8 @@ define(function (require, exports, module) { COLLAPSE = "codefolding.collapse", EXPAND = "codefolding.expand", EXPAND_ALL = "codefolding.expand.all", - CODE_FOLDING_SETTINGS = "codefolding.settings", gutterName = "CodeMirror-foldgutter", - COLLAPSE_CUSTOM_REGIONS = "codefolding.collapse.customregions", - SettingsDialog = require("SettingsDialog"); + COLLAPSE_CUSTOM_REGIONS = "codefolding.collapse.customregions"; ExtensionUtils.loadStyleSheet(module, "main.less"); @@ -279,9 +277,6 @@ define(function (require, exports, module) { $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); - CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, function () { - SettingsDialog.show(); - }); CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); @@ -291,15 +286,14 @@ define(function (require, exports, module) { CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); - KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-C"); - KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-X"); + KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-["); + KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-]"); KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); @@ -312,12 +306,6 @@ define(function (require, exports, module) { foldGutter.updateInViewport(cm); } } - } else { - CommandManager.register(Strings.CODE_FOLDING_SETTINGS + "...", CODE_FOLDING_SETTINGS, function () { - SettingsDialog.show(); - }); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CODE_FOLDING_SETTINGS); } } diff --git a/src/extensions/default/CodeFolding/nls/de/strings.js b/src/extensions/default/CodeFolding/nls/de/strings.js deleted file mode 100644 index c912c12ffa9..00000000000 --- a/src/extensions/default/CodeFolding/nls/de/strings.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// German Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CollapseAll" : "Alle Abschnitte Zuklappen", - "ExpandAll" : "Alle Abschnitte Aufklappen", - "CollapseCurrent" : "Abschnitt Zuklappen", - "ExpandCurrent" : "Abschnitt Aufklappen", -}); diff --git a/src/extensions/default/CodeFolding/nls/es/strings.js b/src/extensions/default/CodeFolding/nls/es/strings.js deleted file mode 100644 index 46d9cf02ec2..00000000000 --- a/src/extensions/default/CodeFolding/nls/es/strings.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Spanish Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CollapseAll" : "Contraer Todo", - "ExpandAll" : "Expandir Todo", - "CollapseCurrent" : "Contraer Sección", - "ExpandCurrent" : "Expandir Sección", -}); diff --git a/src/extensions/default/CodeFolding/nls/fi/strings.js b/src/extensions/default/CodeFolding/nls/fi/strings.js deleted file mode 100644 index 90dcca3be21..00000000000 --- a/src/extensions/default/CodeFolding/nls/fi/strings.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Finnish Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CODE_FOLDING_SETTINGS" : "Koodin laskostuksen asetukset", - "COLLAPSE_ALL" : "Pienennä kaikki", - "EXPAND_ALL" : "Laajenna kaikki", - "COLLAPSE_CURRENT" : "Pienennä nykyinen", - "EXPAND_CURRENT" : "Laajenna nykyinen", - "COLLAPSE_CUSTOM_REGIONS" : "Pienennä mukautetut alueet", - - // Form variables region - "MIN_FOLD_SIZE" : "Pienin laskostuksen koko", - "MIN_FOLD_SIZE_HELP" : "Pienin sallittu laskostettavan alueen rivimäärä", - "ENABLE_REGION_FOLDING" : "Ota mukautetun alueen laskostus käyttöön", - "SAVE_FOLD_STATES" : "Tallenna laskosten tilat", - "SAVE_FOLD_STATES_HELP" : "Tallenna laskosten tilat levylle, kun editori suljetaan ja palauta ne, kun editori avataan uudelleen", - "ALWAYS_USE_INDENT_FOLD" : "Käytä aina sisennyslaskostusta", - "ALWAYS_USE_INDENT_FOLD_HELP" : "Käytä aina sisennyksen tasoa laskostuksen ohjenuorana", - "FADE_FOLD_BUTTONS" : "Häivytä laskostuspainikkeet", - "FADE_FOLD_BUTTONS_HELP" : "Piilottaa laskostuspainikkeet, ellei osoitin ole sivumarginaalin päällä", - "MAX_FOLD_LEVEL" : "Suurin sallittu sisäkkäisten laskosten määrä", - "MAX_FOLD_LEVEL_HELP" : "Käytetään rajoittamaan sisäkkäisten laskosten määrää etsittäessä ja pienennettäessä, kun käytetään Näytä -> Pienennä kaikki \u2011komentoa tai kun Alt-näppäintä pidetään alhaalla pienennettäessä. Pitäisi parantaa suurten tiedostojen suorituskykyä.", - "RESTORE_DEFAULTS" : "Palauta oletukset", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "Haluatko ladata Bracketsin uudelleen ottaaksesi uudet asetukset käyttöön? Sinua pyydetään tallentamaan muutokset tallentamattomiin dokumentteihin.", - "RELOAD_BRACKETS" : "Lataa Brackets uudelleen", - "RELOAD" : "Lataa uudelleen" -}); diff --git a/src/extensions/default/CodeFolding/nls/fr/strings.js b/src/extensions/default/CodeFolding/nls/fr/strings.js deleted file mode 100644 index 35dd7ff283c..00000000000 --- a/src/extensions/default/CodeFolding/nls/fr/strings.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// French Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CODE_FOLDING_SETTINGS" : "Paramètres Code Folding", - "COLLAPSE_ALL" : "Tout réduire", - "EXPAND_ALL" : "Tout développer", - "COLLAPSE_CURRENT" : "Réduire", - "EXPAND_CURRENT" : "Développer", - - // Form variables region - "MIN_FOLD_SIZE" : "Taille de repli minimale", - "MIN_FOLD_SIZE_HELP" : "Nombre de lignes minimal pour proposer un repli", - "ENABLE_REGION_FOLDING" : "Activer le repli personnalisé de zone", - "SAVE_FOLD_STATES" : "Enregistrer l'état des replis", - "SAVE_FOLD_STATES_HELP" : "Enregistre l'état des replis sur le disque quand l'éditeur est fermé et les rétablit à sa réouverture", - "ALWAYS_USE_INDENT_FOLD" : "Toujours utiliser l'indentation du replis", - "ALWAYS_USE_INDENT_FOLD_HELP" : "Toujours utiliser le niveau d'indentation comme norme de replis", - "USE_KEYBOARD_SHORTCUTS" : "Utiliser les raccourcis clavier", - "REMAP_KEYBOARD_SHORTCUTS" : "Redéfinir les raccourcis clavier", - "RESTORE_DEFAULTS" : "Réinitialiser", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "Souhaitez-vous recharger Brackets pour appliquer les nouveaux paramètres ? Il vous sera demandé de sauvegarder les changements sur les documents ouverts.", - "RELOAD_BRACKETS" : "Recharger Brackets", - "RELOAD" : "Recharger" -}); diff --git a/src/extensions/default/CodeFolding/nls/gl/strings.js b/src/extensions/default/CodeFolding/nls/gl/strings.js deleted file mode 100644 index 16b28d327ab..00000000000 --- a/src/extensions/default/CodeFolding/nls/gl/strings.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Galician Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CollapseAll" : "Contraer Todo", - "ExpandAll" : "Expandir Todo", - "CollapseCurrent" : "Contraer Sección", - "ExpandCurrent" : "Expandir Sección", -}); diff --git a/src/extensions/default/CodeFolding/nls/it/strings.js b/src/extensions/default/CodeFolding/nls/it/strings.js deleted file mode 100644 index 144a8051c28..00000000000 --- a/src/extensions/default/CodeFolding/nls/it/strings.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Italian Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CollapseAll" : "Collassa tutto", - "ExpandAll" : "Espandi tutto", - "CollapseCurrent" : "Collassa", - "ExpandCurrent" : "Espandi", -}); diff --git a/src/extensions/default/CodeFolding/nls/ja/strings.js b/src/extensions/default/CodeFolding/nls/ja/strings.js deleted file mode 100644 index 2dd7ac21ce0..00000000000 --- a/src/extensions/default/CodeFolding/nls/ja/strings.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Japanese Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CODE_FOLDING_SETTINGS" : "折りたたみの設定", - "COLLAPSE_ALL" : "すべて折りたたむ", - "EXPAND_ALL" : "すべて展開", - "COLLAPSE_CURRENT" : "現在のグループを折りたたむ", - "EXPAND_CURRENT" : "現在のグループを展開", - "COLLAPSE_CUSTOM_REGIONS" : "カスタム領域を折りたたむ", - - // Form variables region - "MIN_FOLD_SIZE" : "折りたたみビューを表示する行数の最小値", - "MIN_FOLD_SIZE_HELP" : "Minimum number of lines to allow in a fold range", - "ENABLE_REGION_FOLDING" : "カスタム領域の折りたたみを有効にする", - "SAVE_FOLD_STATES" : "折りたたみ状態を保存する", - "SAVE_FOLD_STATES_HELP" : "Save fold states to disk when editor is closed and restore the folds when reopened", - "ALWAYS_USE_INDENT_FOLD" : "常にインデントの折りたたみを使用する", - "ALWAYS_USE_INDENT_FOLD_HELP" : "折りたたみのガイドラインとして常にインデント レベルを使用します", - //"USE_KEYBOARD_SHORTCUTS": "Use keyboard shortcuts", - //"REMAP_KEYBOARD_SHORTCUTS": "Remap keyboard shortcuts", - "RESTORE_DEFAULTS" : "既定の設定に戻す", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "新しい設定を有効にするには、Brackets を再読み込みする必要があります。未保存のドキュメントを、保存または破棄を確認するメッセージが表示されます。", - "RELOAD_BRACKETS" : "Brackets の再読み込み", - "RELOAD" : "再読み込み" -}); diff --git a/src/extensions/default/CodeFolding/nls/nl/strings.js b/src/extensions/default/CodeFolding/nls/nl/strings.js deleted file mode 100644 index d32e1ca827a..00000000000 --- a/src/extensions/default/CodeFolding/nls/nl/strings.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Dutch translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CODE_FOLDING_SETTINGS" : "Code Folding instellingen", - "COLLAPSE_ALL" : "Alles inklappen", - "EXPAND_ALL" : "Alles uitklappen", - "COLLAPSE_CURRENT" : "Huidige inklappen", - "EXPAND_CURRENT" : "Huidige uitklappen", - "COLLAPSE_CUSTOM_REGIONS" : "Aangepaste regio's inklappen", - - // Form variables region - "MIN_FOLD_SIZE" : "Minimale vouwgrootte", - "MIN_FOLD_SIZE_HELP" : "Minimaal aantal regels om toe te staan in een vouwreeks", - "ENABLE_REGION_FOLDING" : "Aangepaste regio's inschakelen", - "SAVE_FOLD_STATES" : "Vouwstatus bewaren", - "SAVE_FOLD_STATES_HELP" : "Vouwstatus bewaren op schijf als editor gesloten wordt en herstellen wanneer opnieuw geopend", - "ALWAYS_USE_INDENT_FOLD" : "Altijd vouwindentatie gebruiken", - "ALWAYS_USE_INDENT_FOLD_HELP" : "Altijd het indentatieniveau als vouwrichtlijn gebruiken", - "FADE_FOLD_BUTTONS" : "Vouwknoppen vervagen", - "FADE_FOLD_BUTTONS_HELP" : "Verberg de vouwknoppen, behalve als de muis over de goot hangt", - //"USE_KEYBOARD_SHORTCUTS" : "Gebruik toetsenbordshortcuts", - //"REMAP_KEYBOARD_SHORTCUTS" : "Aanpassen toetsenbordshortcuts", - "RESTORE_DEFAULTS" : "Herstel standaarden", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "Wil je Brackets herstarten om de nieuwe instelingen toe te passen? Je zal gevraagd worden om wijzigingen in nog niet opgeslagen documenten op te slaan.", - "RELOAD_BRACKETS" : "Herstart Brackets", - "RELOAD" : "Herstart" -}); diff --git a/src/extensions/default/CodeFolding/nls/pt-BR/strings.js b/src/extensions/default/CodeFolding/nls/pt-BR/strings.js deleted file mode 100644 index b9865323266..00000000000 --- a/src/extensions/default/CodeFolding/nls/pt-BR/strings.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Spanish Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CODE_FOLDING_SETTINGS" : "Opções de Dobramento", - "COLLAPSE_ALL" : "Dobrar Tudo", - "EXPAND_ALL" : "Expandir Tudo", - "COLLAPSE_CURRENT" : "Dobrar Posição Atual", - "EXPAND_CURRENT" : "Expandir Posição Atual", - "COLLAPSE_CUSTOM_REGIONS" : "Dobrar Regiões Personalizadas", - - // Form variables region - "MIN_FOLD_SIZE" : "Tamanha Mínimo", - "MIN_FOLD_SIZE_HELP" : "Número Mínimo de linhas necessário para o dobramento", - "ENABLE_REGION_FOLDING" : "Regiões Personalizadas de Dobramento", - "SAVE_FOLD_STATES" : "Salvar Dobramentos", - "SAVE_FOLD_STATES_HELP" : "Salva o estado atual das dobras quando o editor é fechado e as restaura quando aberto", - "ALWAYS_USE_INDENT_FOLD" : "Sempre Usar Dobramento por Indentação", - "ALWAYS_USE_INDENT_FOLD_HELP" : "Usa a Indentação como guia para o Dobramento", - "FADE_FOLD_BUTTONS" : "Ocultar os botões de Dobramento", - "FADE_FOLD_BUTTONS_HELP" : "Oculta os botões quando o cursor não está sobre eles", - "RESTORE_DEFAULTS" : "Restaurar Opções", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "Deseja reiniciar o Brackets para aplicar as novas configurações? Haverá a possibilidade de salvar os arquivos editados.", - "RELOAD_BRACKETS" : "Reiniciar Brackets", - "RELOAD" : "Recarregar" -}); diff --git a/src/extensions/default/CodeFolding/nls/root/strings.js b/src/extensions/default/CodeFolding/nls/root/strings.js deleted file mode 100644 index 097976760af..00000000000 --- a/src/extensions/default/CodeFolding/nls/root/strings.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// English - root strings - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "ENABLE_CODE_FOLDING" : "Enable code folding", - "CODE_FOLDING_SETTINGS" : "Code Folding Settings", - "COLLAPSE_ALL" : "Collapse All", - "EXPAND_ALL" : "Expand All", - "COLLAPSE_CURRENT" : "Collapse Current", - "EXPAND_CURRENT" : "Expand Current", - "COLLAPSE_CUSTOM_REGIONS" : "Collapse Custom Regions", - - // Form variables region - "MIN_FOLD_SIZE" : "Minimum fold size", - "MIN_FOLD_SIZE_HELP" : "Minimum number of lines to allow in a fold range", - "ENABLE_REGION_FOLDING" : "Enable custom region folding", - "SAVE_FOLD_STATES" : "Save fold states", - "SAVE_FOLD_STATES_HELP" : "Save fold states to disk when editor is closed and restore the folds when reopened", - "ALWAYS_USE_INDENT_FOLD" : "Always use indent fold", - "ALWAYS_USE_INDENT_FOLD_HELP" : "Always use level of indentation as a folding guideline", - "FADE_FOLD_BUTTONS" : "Fade fold buttons", - "FADE_FOLD_BUTTONS_HELP" : "Hides the fold buttons unless the mouse is over the gutter", - "MAX_FOLD_LEVEL" : "Maximum number of nested folds", - "MAX_FOLD_LEVEL_HELP" : "Used to limit the number of nested folds to find and collapse when View -> Collapse All is called or Alt is held down when collapsing. Should improve performance for large files.", - "RESTORE_DEFAULTS" : "Restore defaults", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "Would you like to reload Brackets to apply the new settings? You will be prompted to save changes on unsaved documents.", - "RELOAD_BRACKETS" : "Reload Brackets", - "RELOAD" : "Reload" -}); diff --git a/src/extensions/default/CodeFolding/nls/ru/strings.js b/src/extensions/default/CodeFolding/nls/ru/strings.js deleted file mode 100644 index 064a7c30a97..00000000000 --- a/src/extensions/default/CodeFolding/nls/ru/strings.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -// Russian Translation - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define({ - "CODE_FOLDING_SETTINGS" : "Настройки Code Folding", - "COLLAPSE_ALL" : "Свернуть все", - "EXPAND_ALL" : "Развернуть все", - "COLLAPSE_CURRENT" : "Свернуть текущий", - "EXPAND_CURRENT" : "Развернуть текущий", - "COLLAPSE_CUSTOM_REGIONS" : "Свернуть текущий region", - - // Form variables region - "MIN_FOLD_SIZE" : "Минимальный размер сворачивания", - "MIN_FOLD_SIZE_HELP" : "Минимальное число строк для сворачивания", - "ENABLE_REGION_FOLDING" : "Включить сворачивание для region`ов", - "SAVE_FOLD_STATES" : "Сохранять состояние", - "SAVE_FOLD_STATES_HELP" : "Сохранить состояние свёрнутых/развёрнутых блоков на диск при закрытии редактора и восстановить при повторном открытии", - "ALWAYS_USE_INDENT_FOLD" : "Всегда использовать вложеность", - "ALWAYS_USE_INDENT_FOLD_HELP" : "Всегда использовать уровень вложенности в качестве ориентира", - "FADE_FOLD_BUTTONS" : "Скрывать кнопки для фолдинга", - "FADE_FOLD_BUTTONS_HELP" : "Отображать кнопки для фолдинга только при наведении", - "MAX_FOLD_LEVEL" : "Максимальное число вложенных сворачиваний", - "MAX_FOLD_LEVEL_HELP" : "Используется для ограничения числа вложенных сворачиваний, чтобы свернуть воспользуйтесь Вид-> Свернуть Все или зажмите Alt во время сворачивания. Это улучшит производительность для больших файлов.", - "BUTTON_SAVE" : "Сохранить", - "BUTTON_DEFAULTS" : "Востановить значения по умолчанию", - "BUTTON_CANCEL" : "Отмена", - - // Endregion - "CONFIRM_RELOAD_BRACKETS" : "Вы хотите перезагрузить Brackets, чтобы применить новые параметры? Вам будет предложено сохранить все изменения.", - "RELOAD_BRACKETS" : "Перегрузить Brackets", - "BUTTON_RELOAD" : "Перегрузить" -}); diff --git a/src/extensions/default/CodeFolding/nls/strings.js b/src/extensions/default/CodeFolding/nls/strings.js deleted file mode 100644 index 830bae493c6..00000000000 --- a/src/extensions/default/CodeFolding/nls/strings.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -define(function (require, exports, module) { - - 'use strict'; - - // Code that needs to display user strings should call require("strings") to load - // strings.js. This file will dynamically load strings.js for the specified by bracketes.locale. - // - // Translations for other locales should be placed in nls/>/strings.js - // Localization is provided via the i18n plugin. - // All other bundles for languages need to add a prefix to the exports below so i18n can find them. - // TODO: dynamically populate the local prefix list below? - module.exports = { - root: true, - "de": true, - "es": true, - "fi": true, - "fr": true, - "gl": true, - "it": true, - "ja": true, - "nl": true, - "ru": true - }; -}); - diff --git a/src/nls/fi/strings.js b/src/nls/fi/strings.js index cadea280ee7..64c86611097 100644 --- a/src/nls/fi/strings.js +++ b/src/nls/fi/strings.js @@ -627,7 +627,6 @@ define({ "DOCS_MORE_LINK" : "Lue lisää", //extensions/default/CodeFolding - "CODE_FOLDING_SETTINGS" : "Koodin laskostuksen asetukset", "COLLAPSE_ALL" : "Pienennä kaikki", "EXPAND_ALL" : "Laajenna kaikki", "COLLAPSE_CURRENT" : "Pienennä nykyinen", @@ -643,11 +642,7 @@ define({ "FADE_FOLD_BUTTONS" : "Häivytä laskostuspainikkeet", "FADE_FOLD_BUTTONS_HELP" : "Piilottaa laskostuspainikkeet, ellei osoitin ole sivumarginaalin päällä", "MAX_FOLD_LEVEL" : "Suurin sallittu sisäkkäisten laskosten määrä", - "MAX_FOLD_LEVEL_HELP" : "Käytetään rajoittamaan sisäkkäisten laskosten määrää etsittäessä ja pienennettäessä, kun käytetään Näytä -> Pienennä kaikki \u2011komentoa tai kun Alt-näppäintä pidetään alhaalla pienennettäessä. Pitäisi parantaa suurten tiedostojen suorituskykyä.", - "RESTORE_DEFAULTS" : "Palauta oletukset", - "CONFIRM_RELOAD_BRACKETS" : "Haluatko ladata Bracketsin uudelleen ottaaksesi uudet asetukset käyttöön? Sinua pyydetään tallentamaan muutokset tallentamattomiin dokumentteihin.", - "RELOAD_BRACKETS" : "Lataa Brackets uudelleen", - "RELOAD" : "Lataa uudelleen" + "MAX_FOLD_LEVEL_HELP" : "Käytetään rajoittamaan sisäkkäisten laskosten määrää etsittäessä ja pienennettäessä, kun käytetään Näytä -> Pienennä kaikki \u2011komentoa tai kun Alt-näppäintä pidetään alhaalla pienennettäessä. Pitäisi parantaa suurten tiedostojen suorituskykyä." }); /* Last translated for eef9c68a1fdff372b9ea6352cacb5e2506e55be9 */ diff --git a/src/nls/nl/strings.js b/src/nls/nl/strings.js index f7301c33ac7..e6386e300d9 100644 --- a/src/nls/nl/strings.js +++ b/src/nls/nl/strings.js @@ -458,7 +458,6 @@ define({ "DOCS_MORE_LINK" : "Lees meer", //extensions/default/CodeFolding - "CODE_FOLDING_SETTINGS" : "Code Folding instellingen", "COLLAPSE_ALL" : "Alles inklappen", "EXPAND_ALL" : "Alles uitklappen", "COLLAPSE_CURRENT" : "Huidige inklappen", @@ -472,10 +471,6 @@ define({ "ALWAYS_USE_INDENT_FOLD" : "Altijd vouwindentatie gebruiken", "ALWAYS_USE_INDENT_FOLD_HELP" : "Altijd het indentatieniveau als vouwrichtlijn gebruiken", "FADE_FOLD_BUTTONS" : "Vouwknoppen vervagen", - "FADE_FOLD_BUTTONS_HELP" : "Verberg de vouwknoppen, behalve als de muis over de goot hangt", - "RESTORE_DEFAULTS" : "Herstel standaarden", - "CONFIRM_RELOAD_BRACKETS" : "Wil je Brackets herstarten om de nieuwe instelingen toe te passen? Je zal gevraagd worden om wijzigingen in nog niet opgeslagen documenten op te slaan.", - "RELOAD_BRACKETS" : "Herstart Brackets", - "RELOAD" : "Herstart" + "FADE_FOLD_BUTTONS_HELP" : "Verberg de vouwknoppen, behalve als de muis over de goot hangt" }); /* Last translated for 752856d58d2e9dde14e1af6be615bb7080727b7a */ diff --git a/src/nls/pt-br/strings.js b/src/nls/pt-br/strings.js index b5bda3a6b48..bc14db2eb81 100644 --- a/src/nls/pt-br/strings.js +++ b/src/nls/pt-br/strings.js @@ -628,7 +628,6 @@ define({ "DOCS_MORE_LINK" : "Leia mais", //extensions/default/CodeFolding - "CODE_FOLDING_SETTINGS" : "Opções de Dobramento", "COLLAPSE_ALL" : "Dobrar Tudo", "EXPAND_ALL" : "Expandir Tudo", "COLLAPSE_CURRENT" : "Dobrar Posição Atual", @@ -642,10 +641,6 @@ define({ "ALWAYS_USE_INDENT_FOLD" : "Sempre Usar Dobramento por Indentação", "ALWAYS_USE_INDENT_FOLD_HELP" : "Usa a Indentação como guia para o Dobramento", "FADE_FOLD_BUTTONS" : "Ocultar os botões de Dobramento", - "FADE_FOLD_BUTTONS_HELP" : "Oculta os botões quando o cursor não está sobre eles", - "RESTORE_DEFAULTS" : "Restaurar Opções", - "CONFIRM_RELOAD_BRACKETS" : "Deseja reiniciar o Brackets para aplicar as novas configurações? Haverá a possibilidade de salvar os arquivos editados.", - "RELOAD_BRACKETS" : "Reiniciar Brackets", - "RELOAD" : "Recarregar" + "FADE_FOLD_BUTTONS_HELP" : "Oculta os botões quando o cursor não está sobre eles" }); /* Last translated for 0b949dd02b87866d54f38631715a4353a8f927e5 */ diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 763e25fd8a7..19115dcd7b0 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -626,7 +626,6 @@ define({ //extensions/default/CodeFolding "ENABLE_CODE_FOLDING" : "Enable code folding", - "CODE_FOLDING_SETTINGS" : "Code Folding Settings", "COLLAPSE_ALL" : "Collapse All", "EXPAND_ALL" : "Expand All", "COLLAPSE_CURRENT" : "Collapse Current", @@ -642,9 +641,5 @@ define({ "FADE_FOLD_BUTTONS" : "Fade fold buttons", "FADE_FOLD_BUTTONS_HELP" : "Hides the fold buttons unless the mouse is over the gutter", "MAX_FOLD_LEVEL" : "Maximum number of nested folds", - "MAX_FOLD_LEVEL_HELP" : "Used to limit the number of nested folds to find and collapse when View -> Collapse All is called or Alt is held down when collapsing. Should improve performance for large files.", - "RESTORE_DEFAULTS" : "Restore defaults", - "CONFIRM_RELOAD_BRACKETS" : "Would you like to reload Brackets to apply the new settings? You will be prompted to save changes on unsaved documents.", - "RELOAD_BRACKETS" : "Reload {APP_NAME}", - "RELOAD" : "Reload" + "MAX_FOLD_LEVEL_HELP" : "Used to limit the number of nested folds to find and collapse when View -> Collapse All is called or Alt is held down when collapsing. Should improve performance for large files." }); diff --git a/src/nls/ru/strings.js b/src/nls/ru/strings.js index ccd262b585b..b5caf354d77 100644 --- a/src/nls/ru/strings.js +++ b/src/nls/ru/strings.js @@ -164,7 +164,7 @@ define({ "FIND_REPLACE_TITLE_WITH" : "на", "FIND_TITLE_LABEL" : "Найдено", "FIND_TITLE_SUMMARY" : "— {0} {1} {2} в {3}", - + // Find in Files "FIND_IN_FILES_TITLE_PART1" : "\"", "FIND_IN_FILES_TITLE_PART2" : "\" найдено", @@ -336,7 +336,7 @@ define({ "CMD_REPLACE_IN_FILES" : "Заменить в файлах", "CMD_REPLACE_IN_SELECTED" : "Заменить в выделенном файле/директории", "CMD_REPLACE_IN_SUBTREE" : "Заменить в\u2026", - + // View menu commands "VIEW_MENU" : "Вид", "CMD_HIDE_SIDEBAR" : "Скрыть боковую панель", @@ -568,7 +568,6 @@ define({ "DOCS_MORE_LINK" : "Подробнее\u2026", //extensions/default/CodeFolding - "CODE_FOLDING_SETTINGS" : "Настройки Code Folding", "COLLAPSE_ALL" : "Свернуть все", "EXPAND_ALL" : "Развернуть все", "COLLAPSE_CURRENT" : "Свернуть текущий", @@ -584,11 +583,5 @@ define({ "FADE_FOLD_BUTTONS" : "Скрывать кнопки для фолдинга", "FADE_FOLD_BUTTONS_HELP" : "Отображать кнопки для фолдинга только при наведении", "MAX_FOLD_LEVEL" : "Максимальное число вложенных сворачиваний", - "MAX_FOLD_LEVEL_HELP" : "Используется для ограничения числа вложенных сворачиваний, чтобы свернуть воспользуйтесь Вид-> Свернуть Все или зажмите Alt во время сворачивания. Это улучшит производительность для больших файлов.", - "BUTTON_SAVE" : "Сохранить", - "BUTTON_DEFAULTS" : "Востановить значения по умолчанию", - "BUTTON_CANCEL" : "Отмена", - "CONFIRM_RELOAD_BRACKETS" : "Вы хотите перезагрузить Brackets, чтобы применить новые параметры? Вам будет предложено сохранить все изменения.", - "RELOAD_BRACKETS" : "Перегрузить Brackets", - "BUTTON_RELOAD" : "Перегрузить" + "MAX_FOLD_LEVEL_HELP" : "Используется для ограничения числа вложенных сворачиваний, чтобы свернуть воспользуйтесь Вид-> Свернуть Все или зажмите Alt во время сворачивания. Это улучшит производительность для больших файлов." }); From d3866438f166a80cdd0cd3ea5cac8b9b6fc04cf6 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Wed, 1 Apr 2015 22:34:55 +0100 Subject: [PATCH 09/11] updated to fix preferences so that fold gutter is correctly rendered when projects are changed. --- src/extensions/default/CodeFolding/Prefs.js | 3 +- .../CodeFolding/foldhelpers/foldgutter.js | 2 +- src/extensions/default/CodeFolding/main.js | 38 ++++++++++++------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index b69aa21e8cc..81d64e3248a 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -48,6 +48,7 @@ define(function (require, exports, module) { }); return res; } + /** Inflates the fold ranges stored as simplified numeric arrays. The inflation converts the data into objects whose keys are line numbers and whose values are objects in the format {from: {line, ch}, to: {line, ch}}. @@ -92,7 +93,7 @@ define(function (require, exports, module) { @returns {string} the setting with the specified key */ function getSetting(key) { - return prefs.get(key, PreferencesManager.CURRENT_PROJECT); + return prefs.get(key); } /** diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js index 0fd13cc46cb..4ddfa1c70de 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js @@ -300,9 +300,9 @@ define(function (require, exports, module) { }); } + exports.init = init; exports.clearGutter = clearGutter; - exports.updateInViewport = updateInViewport; }); diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index 8a36c9a0871..9f20b1af647 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -38,9 +38,10 @@ require.config({ define(function (require, exports, module) { "use strict"; - var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); - var Strings = brackets.getModule("strings"); - var CommandManager = brackets.getModule("command/CommandManager"), + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + Strings = brackets.getModule("strings"), + AppInit = brackets.getModule("utils/AppInit"), + CommandManager = brackets.getModule("command/CommandManager"), DocumentManager = brackets.getModule("document/DocumentManager"), EditorManager = brackets.getModule("editor/EditorManager"), ProjectManager = brackets.getModule("project/ProjectManager"), @@ -93,7 +94,9 @@ define(function (require, exports, module) { } } - /**Saves the line folds in the editor using the preference storage**/ + /** + Saves the line folds in the editor using the preference storage + **/ function saveLineFolds(editor) { var saveFolds = _prefs.getSetting("saveFoldStates"); if (!editor || !saveFolds) { return; } @@ -168,6 +171,7 @@ define(function (require, exports, module) { } } } + /** Expands the code region at the current cursor position. */ @@ -178,6 +182,7 @@ define(function (require, exports, module) { cm.unfoldCode(cursor.line); } } + /** Collapses all foldable regions in the current document. Folding is done up to a level 'n' which is defined in the preferences. Levels refer to fold heirarchies e.g., for the following @@ -198,6 +203,7 @@ define(function (require, exports, module) { CodeMirror.commands.foldToLevel(cm); } } + /** Expands all folded regions in the current document */ @@ -209,7 +215,7 @@ define(function (require, exports, module) { } } - function registerHandlers(editor) { + function createGutter(editor) { var cm = editor._codeMirror; if (cm) { var path = editor.document.file.fullPath, _lineFolds = _prefs.get(path); @@ -237,12 +243,14 @@ define(function (require, exports, module) { } function onActiveEditorChanged(event, current, previous) { - if (current && current._codeMirror.getOption("gutters").indexOf(gutterName) === -1) { - registerHandlers(current); - restoreLineFolds(current); - } - if (previous) { - saveLineFolds(previous); + if (_prefs.getSetting("enabled")) { + if (current && current._codeMirror.getOption("gutters").indexOf(gutterName) === -1) { + createGutter(current); + restoreLineFolds(current); + } + if (previous) { + saveLineFolds(previous); + } } } @@ -254,7 +262,7 @@ define(function (require, exports, module) { Initialise the extension */ function init() { - if ([undefined, true].indexOf(_prefs.getSetting("enabled")) > -1) { + if (_prefs.getSetting("enabled")) { foldCode.init(); foldGutter.init(); //register a global fold helper based on indentation folds @@ -272,7 +280,9 @@ define(function (require, exports, module) { $(EditorManager).on("activeEditorChange", onActiveEditorChanged); $(DocumentManager).on("documentRefreshed", function (event, doc) { - restoreLineFolds(doc._masterEditor); + if (_prefs.getSetting("enabled")) { + restoreLineFolds(doc._masterEditor); + } }); $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); @@ -309,5 +319,5 @@ define(function (require, exports, module) { } } - init(); + AppInit.appReady(init); }); From 88261fc5a40a6329fa9c16519d14dbe8b908e108 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Fri, 3 Apr 2015 22:59:48 +0100 Subject: [PATCH 10/11] added package.json removed deprecated warnings on event handlers --- src/extensions/default/CodeFolding/Prefs.js | 14 -------------- src/extensions/default/CodeFolding/main.js | 13 ++++++++----- .../default/CodeFolding/package.json | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 src/extensions/default/CodeFolding/package.json diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index 81d64e3248a..102733937ea 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -96,18 +96,6 @@ define(function (require, exports, module) { return prefs.get(key); } - /** - Gets all the values for code folding settings. - @returns {object} all settings saved in the preferences. - */ - function getAllSettings() { - var res = {}; - prefs.getKeys().forEach(function (key) { - res[key] = getSetting(key); - }); - return res; - } - /** Clears all the saved line folds for all documents. */ @@ -121,8 +109,6 @@ define(function (require, exports, module) { module.exports.getSetting = getSetting; - module.exports.getAllSettings = getAllSettings; - module.exports.clearAllFolds = clearAllFolds; }); diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index 9f20b1af647..773529fec84 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -48,7 +48,7 @@ define(function (require, exports, module) { KeyBindingManager = brackets.getModule("command/KeyBindingManager"), ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), Menus = brackets.getModule("command/Menus"), - _prefs = require("./Prefs"), + _prefs = require("Prefs"), COLLAPSE_ALL = "codefolding.collapse.all", COLLAPSE = "codefolding.collapse", EXPAND = "codefolding.expand", @@ -262,7 +262,7 @@ define(function (require, exports, module) { Initialise the extension */ function init() { - if (_prefs.getSetting("enabled")) { + if (!CodeMirror.fold.combine && _prefs.getSetting("enabled")) { foldCode.init(); foldGutter.init(); //register a global fold helper based on indentation folds @@ -278,14 +278,17 @@ define(function (require, exports, module) { CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); - $(EditorManager).on("activeEditorChange", onActiveEditorChanged); - $(DocumentManager).on("documentRefreshed", function (event, doc) { + EditorManager.on("activeEditorChange", onActiveEditorChanged); + DocumentManager.on("documentRefreshed", function (event, doc) { if (_prefs.getSetting("enabled")) { restoreLineFolds(doc._masterEditor); } }); - $(ProjectManager).on("beforeProjectClose beforeAppClose", saveBeforeClose); + ProjectManager.on("beforeProjectClose beforeAppClose", saveBeforeClose); + ProjectManager.on("projectOpen projectReferesh", function () { + init(); + }); CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); diff --git a/src/extensions/default/CodeFolding/package.json b/src/extensions/default/CodeFolding/package.json new file mode 100644 index 00000000000..15fc26b84db --- /dev/null +++ b/src/extensions/default/CodeFolding/package.json @@ -0,0 +1,19 @@ +{ + "title": "Code Folding", + "name": "code-folding", + "version": "0.3.3", + "author": "Patrick Oladimeji ", + "description": "Brackets extension that provides simple code folding for files edited in brackets. Supports brace folding, tag folding, indent folding and multi-line comment folding", + "homepage": "https://github.com/thehogfather/brackets-code-folding", + "keywords": ["code folding", "code collapsing"], + "categories": ["formatting", "general", "editing", "visual"], + "i18n": ["en", "de", "it", "es", "gl", "fr", "ru", "jp", "fi", "nl", "pt-br"], + "engines": { + "brackets": ">=0.38.0" + }, + "contributors": [ + {"name": "Patrick Oladimeji", "email": "thehogfather@dustygem.co.uk", "url": "https://github.com/thehogfather"}, + {"name": "Daniel Glazman", "email": "daniel@glazman.org"} + ], + "license": "MIT" +} From a3661700657fdd93c04487970abe12d0ee436169 Mon Sep 17 00:00:00 2001 From: Patrick Oladimeji Date: Mon, 6 Apr 2015 16:11:54 +0100 Subject: [PATCH 11/11] updated JSDocs and general code clean up. --- src/extensions/default/CodeFolding/Prefs.js | 54 ++-- .../CodeFolding/foldhelpers/foldcode.js | 116 ++++--- .../CodeFolding/foldhelpers/foldgutter.js | 114 +++---- .../CodeFolding/foldhelpers/indentFold.js | 5 +- .../CodeFolding/foldhelpers/region-fold.js | 8 +- src/extensions/default/CodeFolding/main.js | 294 ++++++++++-------- 6 files changed, 336 insertions(+), 255 deletions(-) diff --git a/src/extensions/default/CodeFolding/Prefs.js b/src/extensions/default/CodeFolding/Prefs.js index 102733937ea..d04cd893e99 100644 --- a/src/extensions/default/CodeFolding/Prefs.js +++ b/src/extensions/default/CodeFolding/Prefs.js @@ -32,11 +32,11 @@ define(function (require, exports, module) { prefs.definePreference("folds", "object", {}); /** - Simplifies the fold ranges into an array of pairs of numbers. - @param {!{number: {from: {ch, line}, to: {ch, line}} folds the raw fold ranges indexed by line numbers - @returns {number: Array>} an object whose keys are line numbers and the values are array - of two 2-element arrays. First array contains [from.line, from.ch] and the second contains [to.line, to.ch] - */ + * Simplifies the fold ranges into an array of pairs of numbers. + * @param {!Object} folds the raw fold ranges indexed by line numbers + * @return {Object} an object whose keys are line numbers and the values are array + * of two 2-element arrays. First array contains [from.line, from.ch] and the second contains [to.line, to.ch] + */ function simplify(folds) { if (!folds) { return; @@ -50,11 +50,11 @@ define(function (require, exports, module) { } /** - Inflates the fold ranges stored as simplified numeric arrays. The inflation converts the data into - objects whose keys are line numbers and whose values are objects in the format {from: {line, ch}, to: {line, ch}}. - @param {number: Array>} folds the simplified fold ranges - @returns {number: {from: {line, ch}, to: {line, ch}}} - */ + * Inflates the fold ranges stored as simplified numeric arrays. The inflation converts the data into + * objects whose keys are line numbers and whose values are objects in the format {from: {line, ch}, to: {line, ch}}. + * @param {Object} folds the simplified fold ranges + * @return {Object} the converted fold ranges + */ function inflate(folds) { if (!folds) { return; @@ -70,42 +70,44 @@ define(function (require, exports, module) { } /** - Gets the line folds saved for the specified path. - @param {string} path the document path - @returns {number: {from: {line, ch}, to: {line, ch}}} the line folds for the document at the specified path - */ - function get(path) { + * Gets the line folds saved for the specified path. + * @param {string} path the document path + * @return {Object} the line folds for the document at the specified path + */ + function getFolds(path) { store = (prefs.get(foldsKey) || {}); return inflate(store[path]); } /** - Saves the line folds specified - */ - function set(path, folds) { + * Saves the line folds for the specified path + * @param {!string} path the path to the document + * @param {Object} folds the fold ranges to save for the current document + */ + function setFolds(path, folds) { store[path] = simplify(folds); prefs.set(foldsKey, store); } /** - Get the code folding setting with the specified key from the store - @param {!string} key The key for the setting to retrieve - @returns {string} the setting with the specified key - */ + * Get the code folding setting with the specified key from the store + * @param {!string} key The key for the setting to retrieve + * @return {string} the setting with the specified key + */ function getSetting(key) { return prefs.get(key); } /** - Clears all the saved line folds for all documents. - */ + * Clears all the saved line folds for all documents. + */ function clearAllFolds() { prefs.set(foldsKey, {}); } - module.exports.get = get; + module.exports.getFolds = getFolds; - module.exports.set = set; + module.exports.setFolds = setFolds; module.exports.getSetting = getSetting; diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js index a565f28884e..3354d24dab3 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldcode.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldcode.js @@ -11,14 +11,22 @@ define(function (require, exports, module) { var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), prefs = require("Prefs"); + /** + * Performs the folding and unfolding of code regions. + * @param {CodeMirror} cm the CodeMirror instance + * @param {number| Object} pos + */ function doFold(cm, pos, options, force) { options = options || {}; force = force || "fold"; if (typeof pos === "number") { pos = CodeMirror.Pos(pos, 0); } - var finder = options.rangeFinder || CodeMirror.fold.auto; - var minSize = options.minFoldSize || prefs.getSetting("minFoldSize"); + var finder = options.rangeFinder || CodeMirror.fold.auto, + minSize = options.minFoldSize || prefs.getSetting("minFoldSize"), + range, + widget, + textRange; function getRange(allowFolded) { var range = options.range || finder(cm, pos); @@ -59,7 +67,7 @@ define(function (require, exports, module) { return widget; } - var range = getRange(true); + range = getRange(true); if (options.scanUp) { while (!range && pos.line > cm.firstLine()) { pos = CodeMirror.Pos(pos.line - 1, 0); @@ -71,16 +79,18 @@ define(function (require, exports, module) { return; } - var myWidget = makeWidget(); - var myRange = cm.markText(range.from, range.to, { - replacedWith: myWidget, + widget = makeWidget(); + textRange = cm.markText(range.from, range.to, { + replacedWith: widget, clearOnEnter: true, __isFold: true }); - CodeMirror.on(myWidget, "mousedown", function () { - myRange.clear(); + + CodeMirror.on(widget, "mousedown", function () { + textRange.clear(); }); - myRange.on("clear", function (from, to) { + + textRange.on("clear", function (from, to) { delete cm._lineFolds[from.line]; CodeMirror.signal(cm, "unfold", cm, from, to); }); @@ -91,6 +101,7 @@ define(function (require, exports, module) { } else { delete cm._lineFolds[pos.line]; } + CodeMirror.signal(cm, force, cm, range.from, range.to); return range; } @@ -107,32 +118,19 @@ define(function (require, exports, module) { return doFold(this, pos, options, "unfold"); }); - CodeMirror.registerHelper("fold", "combine", function () { - var funcs = Array.prototype.slice.call(arguments, 0); - return function (cm, start) { - var i; - for (i = 0; i < funcs.length; ++i) { - var found = funcs[i] && funcs[i](cm, start); - if (found) { - return found; - } - } - }; - }); - CodeMirror.defineExtension("isFolded", function (line) { return this._lineFolds[line]; }); + /** - Checks the validity of the ranges passed in the parameter and returns the foldranges - that are still valid in the current document - @param {object} folds the dictionary of lines in the current document that should be folded - @returns {object} valid folds found in those passed in parameter - */ + * Checks the validity of the ranges passed in the parameter and returns the foldranges + * that are still valid in the current document + * @param {object} folds the dictionary of lines in the current document that should be folded + * @returns {object} valid folds found in those passed in parameter + */ CodeMirror.defineExtension("getValidFolds", function (folds) { - var keys, rf = CodeMirror.fold.auto, cm = this, result = {}; + var keys, rf = CodeMirror.fold.auto, cm = this, result = {}, range, cachedRange; if (folds && (keys = Object.keys(folds)).length) { - var range, cachedRange; keys.forEach(function (lineNumber) { lineNumber = +lineNumber; if (lineNumber >= cm.firstLine() && lineNumber <= cm.lastLine()) { @@ -149,16 +147,28 @@ define(function (require, exports, module) { return result; }); - CodeMirror.commands.toggleFold = function (cm) { - cm.foldCode(cm.getCursor()); - }; - CodeMirror.commands.fold = function (cm, options, force) { + /** + * Utility function to fold the region at the current cursor position in a document + * @param {CodeMirror} cm the CodeMirror instance + * @param {?options} options extra options to pass to the fold function + */ + CodeMirror.commands.fold = function (cm, options) { cm.foldCode(cm.getCursor(), options, "fold"); }; - CodeMirror.commands.unfold = function (cm, options, force) { + + /** + * Utility function to unfold the region at the current cursor position in a document + * @param {CodeMirror} cm the CodeMirror instance + * @param {?options} options extra options to pass to the fold function + */ + CodeMirror.commands.unfold = function (cm, options) { cm.foldCode(cm.getCursor(), options, "unfold"); }; + /** + * Utility function to fold all foldable regions in a document + * @param {CodeMirror} cm the CodeMirror instance + */ CodeMirror.commands.foldAll = function (cm) { cm.operation(function () { var i, e; @@ -168,6 +178,12 @@ define(function (require, exports, module) { }); }; + /** + * Utility function to unfold all folded regions in a document + * @param {CodeMirror} cm the CodeMirror instance + * @param {?number} from the line number for the beginning of the region to unfold + * @param {?number} to the line number for the end of the region to unfold + */ CodeMirror.commands.unfoldAll = function (cm, from, to) { from = from || cm.firstLine(); to = to || cm.lastLine(); @@ -178,10 +194,14 @@ define(function (require, exports, module) { } }); }; + /** - Folds the specified range. The descendants of any fold regions within the range are also folded up to - a level set globally in the codeFolding preferences - */ + * Folds the specified range. The descendants of any fold regions within the range are also folded up to + * a level set globally in the `maxFoldLevel' preferences + * @param {CodeMirror} cm the CodeMirror instance + * @param {?number} start the line number for the beginning of the region to fold + * @param {?number} end the line number for the end of the region to fold + */ CodeMirror.commands.foldToLevel = function (cm, start, end) { var rf = CodeMirror.fold.auto, level = prefs.getSetting("maxFoldLevel"); function foldLevel(n, from, to) { @@ -207,6 +227,28 @@ define(function (require, exports, module) { }); }; + /** + * Helper to combine an array of fold range finders into one + */ + CodeMirror.registerHelper("fold", "combine", function () { + var funcs = Array.prototype.slice.call(arguments, 0); + return function (cm, start) { + var i; + for (i = 0; i < funcs.length; ++i) { + var found = funcs[i] && funcs[i](cm, start); + if (found) { + return found; + } + } + }; + }); + + /** + * Creates a helper which returns the appropriate fold function based on the mode of the current position in + * a document. + * @param {CodeMirror} cm the CodeMirror instance + * @param {number} start the current position in the document + */ CodeMirror.registerHelper("fold", "auto", function (cm, start) { var helpers = cm.getHelpers(start, "fold"), i, cur; //ensure mode helper is loaded if there is one diff --git a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js index 4ddfa1c70de..56575b44576 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js +++ b/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js @@ -24,10 +24,10 @@ define(function (require, exports, module) { } /** - Utility for creating fold markers in fold gutter - @param {string} spec the className for the marker - @returns {HTMLElement} - */ + * Utility for creating fold markers in fold gutter + * @param {string} spec the className for the marker + * @return {HTMLElement} a htmlelement representing the fold marker + */ function marker(spec) { var elt = document.createElement("div"); elt.className = spec; @@ -35,32 +35,38 @@ define(function (require, exports, module) { } /** - Updates the gutter markers for the specified range - @param {!CodeMirror} cm the CodeMirror instance for the active editor - @param {!number} from the starting line for the update - @param {!number} to the ending line for the update - */ + * Updates the gutter markers for the specified range + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + * @param {!number} from the starting line for the update + * @param {!number} to the ending line for the update + */ function updateFoldInfo(cm, from, to) { var minFoldSize = prefs.getSetting("minFoldSize") || 2; var opts = cm.state.foldGutter.options; var fade = prefs.getSetting("fadeFoldButtons"); var gutter = $(cm.getGutterElement()); var i = from; - var isFold = function (m) { + + function isFold(m) { return m.__isFold; - }, clear = function (m) {return m.clear(); }; + } + + function clear(m) { + return m.clear(); + } /** - helper function to check if the given line is in a folded region in the editor. - @param {Number} line the - @return {from: {ch: Number, line: Number}, to: {ch: Number, line: Number}} the range that hides the specified line or undefine if the line is not hidden - */ + * @private + * helper function to check if the given line is in a folded region in the editor. + * @param {number} line the + * @return {Object} the range that hides the specified line or undefine if the line is not hidden + */ function _isCurrentlyFolded(line) { - var keys = Object.keys(cm._lineFolds), i = 0, r; + var keys = Object.keys(cm._lineFolds), i = 0, range; while (i < keys.length) { - r = cm._lineFolds[keys[i]]; - if (r.from.line < line && r.to.line >= line) { - return r; + range = cm._lineFolds[keys[i]]; + if (range.from.line < line && range.to.line >= line) { + return range; } i++; } @@ -111,10 +117,16 @@ define(function (require, exports, module) { } } + /** + * Updates the fold infor in the viewport for the specifiec range + * @param {CodeMirror} cm the instance of the CodeMirror object + * @param {?number} from the starting line number for the update + * @param {?number} to the end line number for the update + */ function updateInViewport(cm, from, to) { var vp = cm.getViewport(), state = cm.state.foldGutter; - from = !isNaN(from) ? from : vp.from; - to = !isNaN(to) ? to : vp.to; + from = isNaN(from) ? vp.from : from; + to = isNaN(to) ? vp.to : to; if (!state) { return; } cm.operation(function () { @@ -125,9 +137,9 @@ define(function (require, exports, module) { } /** - Clears the code folding gutter - @param {!CodeMirror} cm the CodeMirror instance for the active editor - */ + * Clears the code folding gutter + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + */ function clearGutter(cm) { var opts = cm.state.foldGutter.options; cm.clearGutter(opts.gutter); @@ -141,11 +153,11 @@ define(function (require, exports, module) { } /** - Updates the line folds cache usually when the document changes. - @param {!CodeMirror} cm the CodeMirror instance for the active editor - @param {!number} from the line number designating the start position of the change - @param {!number} linesDiff a number to show how many lines where removed or added to the document - */ + * Updates the line folds cache usually when the document changes. + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + * @param {!number} from the line number designating the start position of the change + * @param {!number} linesDiff a number to show how many lines where removed or added to the document + */ function updateFoldsCache(cm, from, linesDiff) { var range; var minFoldSize = prefs.getSetting("minFoldSize") || 2; @@ -182,14 +194,12 @@ define(function (require, exports, module) { } /** - Triggered when the content of the document changes. When the entire content of the document - is changed - e.g., changes made from a different editor, the same lineFolds are kept only if - they are still valid in the context of the new document content. - - @param {!CodeMirror} cm the CodeMirror instance for the active editor - @param {!{origin:string, from: {ch:number, line:number}, to: {ch: number, line: number}, - removed: string[], text: string[]}} changeObj detailed information about the change that occurred in the document - */ + * Triggered when the content of the document changes. When the entire content of the document + * is changed - e.g., changes made from a different editor, the same lineFolds are kept only if + * they are still valid in the context of the new document content. + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + * @param {!Object} changeObj detailed information about the change that occurred in the document + */ function onChange(cm, changeObj) { if (changeObj.origin === "setValue") {//text content has changed outside of brackets var folds = cm.getValidFolds(cm._lineFolds); @@ -215,9 +225,9 @@ define(function (require, exports, module) { } /** - Triggered on viewport changes e.g., user scrolls or resizes the viewport. - @param {!CodeMirror} cm the CodeMirror instance for the active editor - */ + * Triggered on viewport changes e.g., user scrolls or resizes the viewport. + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + */ function onViewportChange(cm) { var state = cm.state.foldGutter; window.clearTimeout(state.changeUpdate); @@ -245,11 +255,11 @@ define(function (require, exports, module) { } /** - Triggered when a code segment is folded. - @param {!CodeMirror} cm the CodeMirror instance for the active editor - @param {!{line:number, ch:number}} from the ch and line position that designates the start of the region - @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region - */ + * Triggered when a code segment is folded. + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + * @param {!Object} from the ch and line position that designates the start of the region + * @param {!Object} to the ch and line position that designates the end of the region + */ function onFold(cm, from, to) { var state = cm.state.foldGutter, line = from.line; if (line >= state.from && line < state.to) { @@ -258,10 +268,10 @@ define(function (require, exports, module) { } /** - Triggered when a folded code segment is unfolded. - @param {!CodeMirror} cm the CodeMirror instance for the active editor - @param {!{line:number, ch:number}} from the ch and line position that designates the start of the region - @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region + * Triggered when a folded code segment is unfolded. + * @param {!CodeMirror} cm the CodeMirror instance for the active editor + * @param {!{line:number, ch:number}} from the ch and line position that designates the start of the region + * @param {!{line:number, ch:number}} to the ch and line position that designates the end of the region */ function onUnFold(cm, from, to) { var state = cm.state.foldGutter, line = from.line; @@ -272,9 +282,9 @@ define(function (require, exports, module) { } /** - Initialises the fold gutter and registers event handlers for changes to document, viewport - and user interactions. - */ + * Initialises the fold gutter and registers event handlers for changes to document, viewport + * and user interactions. + */ function init() { CodeMirror.defineOption("foldGutter", false, function (cm, val, old) { if (old && old !== CodeMirror.Init) { diff --git a/src/extensions/default/CodeFolding/foldhelpers/indentFold.js b/src/extensions/default/CodeFolding/foldhelpers/indentFold.js index 9eb8ee7dd3d..a2c233f7ad2 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/indentFold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/indentFold.js @@ -8,8 +8,9 @@ define(function (require, exports, module) { "use strict"; - var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"); - var cols = CodeMirror.countColumn, pos = CodeMirror.Pos; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + cols = CodeMirror.countColumn, + pos = CodeMirror.Pos; function lastNonEmptyLineNumber(cm) { var lc = cm.lastLine(), line = cm.getLine(lc); diff --git a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js index 5810d28afc6..b282e85dab4 100644 --- a/src/extensions/default/CodeFolding/foldhelpers/region-fold.js +++ b/src/extensions/default/CodeFolding/foldhelpers/region-fold.js @@ -5,10 +5,10 @@ /*global define, brackets*/ define(function (require, exports, module) { "use strict"; - var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), - startRegion = /\W+region/i, - endRegion = /\W+endregion/i, - space = /\s/; + var CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"), + startRegion = /\W+region/i, + endRegion = /\W+endregion/i, + space = /\s/; function regionFold(cm, start) { var line = start.line, i, j; diff --git a/src/extensions/default/CodeFolding/main.js b/src/extensions/default/CodeFolding/main.js index 773529fec84..cd077733ef2 100644 --- a/src/extensions/default/CodeFolding/main.js +++ b/src/extensions/default/CodeFolding/main.js @@ -48,7 +48,7 @@ define(function (require, exports, module) { KeyBindingManager = brackets.getModule("command/KeyBindingManager"), ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), Menus = brackets.getModule("command/Menus"), - _prefs = require("Prefs"), + prefs = require("Prefs"), COLLAPSE_ALL = "codefolding.collapse.all", COLLAPSE = "codefolding.collapse", EXPAND = "codefolding.expand", @@ -67,48 +67,57 @@ define(function (require, exports, module) { //need to modify the gutter click handler to take care of some collapse and expand features //e.g. collapsing all children when 'alt' key is pressed var foldGutter = require("foldhelpers/foldgutter"), - foldCode = require("foldhelpers/foldcode"); - - var indentFold = require("foldhelpers/indentFold"), + foldCode = require("foldhelpers/foldcode"), + indentFold = require("foldhelpers/indentFold"), latexFold = require("foldhelpers/latex-fold"), regionFold = require("foldhelpers/region-fold"); /** - Restores the linefolds in the editor using values fetched from the preference store - Checks the document to ensure that changes have not been made (e.g., in a different editor) - to invalidate the saved line folds. - @param {Editor} editor the editor whose saved line folds should be restored - */ + * Restores the linefolds in the editor using values fetched from the preference store + * Checks the document to ensure that changes have not been made (e.g., in a different editor) + * to invalidate the saved line folds. + * @param {Editor} editor the editor whose saved line folds should be restored + */ function restoreLineFolds(editor) { - var saveFolds = _prefs.getSetting("saveFoldStates"); - if (editor && saveFolds) { - var cm = editor._codeMirror; - if (!cm) {return; } - var path = editor.document.file.fullPath; - var folds = cm._lineFolds || _prefs.get(path); - cm._lineFolds = cm.getValidFolds(folds); - _prefs.set(path, cm._lineFolds); - Object.keys(cm._lineFolds).forEach(function (line) { - cm.foldCode(+line); - }); - } + var saveFolds = prefs.getSetting("saveFoldStates"); + if (!editor || !saveFolds) { return; } + + var cm = editor._codeMirror; + if (!cm) {return; } + var path = editor.document.file.fullPath; + var folds = cm._lineFolds || prefs.getFolds(path); + cm._lineFolds = cm.getValidFolds(folds); + prefs.setFolds(path, cm._lineFolds); + Object.keys(cm._lineFolds).forEach(function (line) { + cm.foldCode(+line); + }); } /** - Saves the line folds in the editor using the preference storage - **/ + * Saves the line folds in the editor using the preference storage + * @param {Editor} editor the editor whose line folds should be saved + */ function saveLineFolds(editor) { - var saveFolds = _prefs.getSetting("saveFoldStates"); + var saveFolds = prefs.getSetting("saveFoldStates"); if (!editor || !saveFolds) { return; } var folds = editor._codeMirror._lineFolds || {}; var path = editor.document.file.fullPath; if (Object.keys(folds).length) { - _prefs.set(path, folds); + prefs.setFolds(path, folds); } else { - _prefs.set(path, undefined); + prefs.setFolds(path, undefined); } } + /** + * Event handler for gutter click. Manages folding and unfolding code regions. If the Alt key + * is pressed while clicking the fold gutter, child code fragments are also folded/unfolded + * up to a level defined in the `maxFoldLevel' preference. + * @param {object} cm the codeMirror object + * @param {number} line the line number for the clicked gutter + * @param {string} gutter the name of the gutter element clicked + * @param {object} event the underlying dom event triggered for the gutter click + */ function onGutterClick(cm, line, gutter, event) { var opts = cm.state.foldGutter.options, pos = CodeMirror.Pos(line); if (gutter !== opts.gutter) { return; } @@ -135,46 +144,48 @@ define(function (require, exports, module) { } /** - Collapses all custom regions defined in the current editor - */ + * Collapses all custom regions defined in the current editor + */ function collapseCustomRegions() { var editor = EditorManager.getFocusedEditor(); - if (editor) { - var cm = editor._codeMirror, i = cm.firstLine(); - while (i < cm.lastLine()) { - var range = cm.foldCode(i, {rangeFinder: regionFold}); - if (range) { - i = range.to.line; - } else { - i++; - } + if (!editor) { + return; + } + var cm = editor._codeMirror, i = cm.firstLine(); + while (i < cm.lastLine()) { + var range = cm.foldCode(i, {rangeFinder: regionFold}); + if (range) { + i = range.to.line; + } else { + i++; } } } /** - Collapses the code region nearest the current cursor position. - Nearest is found by searching from the current line and moving up the document until an - opening code-folding region is found. - */ + * Collapses the code region nearest the current cursor position. + * Nearest is found by searching from the current line and moving up the document until an + * opening code-folding region is found. + */ function collapseCurrent() { var editor = EditorManager.getFocusedEditor(); - if (editor) { - var cm = editor._codeMirror; - var cursor = editor.getCursorPos(), i; - //move cursor up until a collapsible line is found - for (i = cursor.line; i >= 0; i--) { - if (cm.foldCode(i)) { - editor.setCursorPos(i); - return; - } + if (!editor) { + return; + } + var cm = editor._codeMirror; + var cursor = editor.getCursorPos(), i; + //move cursor up until a collapsible line is found + for (i = cursor.line; i >= 0; i--) { + if (cm.foldCode(i)) { + editor.setCursorPos(i); + return; } } } /** - Expands the code region at the current cursor position. - */ + * Expands the code region at the current cursor position. + */ function expandCurrent() { var editor = EditorManager.getFocusedEditor(); if (editor) { @@ -184,18 +195,18 @@ define(function (require, exports, module) { } /** - Collapses all foldable regions in the current document. Folding is done up to a level 'n' - which is defined in the preferences. Levels refer to fold heirarchies e.g., for the following - code fragment, the function is level 1, the if statement is level 2 and the forEach is level 3 - - function sample() { - if (debug) { - logMessages.forEach(function (m) { - console.debug(m); - }); - } - } - */ + * Collapses all foldable regions in the current document. Folding is done up to a level 'n' + * which is defined in the `maxFoldLevel preference. Levels refer to fold heirarchies e.g., for the following + * code fragment, the function is level 1, the if statement is level 2 and the forEach is level 3 + * + * function sample() { + * if (debug) { + * logMessages.forEach(function (m) { + * console.debug(m); + * }); + * } + * } + */ function collapseAll() { var editor = EditorManager.getFocusedEditor(); if (editor && editor._codeMirror) { @@ -205,8 +216,8 @@ define(function (require, exports, module) { } /** - Expands all folded regions in the current document - */ + * Expands all folded regions in the current document + */ function expandAll() { var editor = EditorManager.getFocusedEditor(); if (editor && editor._codeMirror) { @@ -215,35 +226,46 @@ define(function (require, exports, module) { } } + /** + * Initialises and creates the code-folding gutter. + * @param {Editor} editor the editor on which to initialise the fold gutter + */ function createGutter(editor) { var cm = editor._codeMirror; - if (cm) { - var path = editor.document.file.fullPath, _lineFolds = _prefs.get(path); - _lineFolds = _lineFolds || {}; - cm._lineFolds = _lineFolds; - var gutters = cm.getOption("gutters").slice(0); - var lnIndex = gutters.indexOf("CodeMirror-linenumbers"); - gutters.splice(lnIndex + 1, 0, gutterName); - cm.setOption("gutters", gutters); - cm.setOption("foldGutter", {onGutterClick: onGutterClick}); + if (!cm) { + return; + } + var path = editor.document.file.fullPath, _lineFolds = prefs.getFolds(path); + _lineFolds = _lineFolds || {}; + cm._lineFolds = _lineFolds; + var gutters = cm.getOption("gutters").slice(0); + var lnIndex = gutters.indexOf("CodeMirror-linenumbers"); + gutters.splice(lnIndex + 1, 0, gutterName); + cm.setOption("gutters", gutters); + cm.setOption("foldGutter", {onGutterClick: onGutterClick}); - $(cm.getGutterElement()).on({ - mouseenter: function () { - if (_prefs.getSetting("fadeFoldButtons")) { - foldGutter.updateInViewport(cm); - } - }, - mouseleave: function () { - if (_prefs.getSetting("fadeFoldButtons")) { - foldGutter.clearGutter(cm); - } + $(cm.getGutterElement()).on({ + mouseenter: function () { + if (prefs.getSetting("fadeFoldButtons")) { + foldGutter.updateInViewport(cm); } - }); - } + }, + mouseleave: function () { + if (prefs.getSetting("fadeFoldButtons")) { + foldGutter.clearGutter(cm); + } + } + }); } + /** + * Event handler to initialise fold-gutter and restores/saves line folds in editors whenever the active editor changes + * @param {object} event the event object + * @param {Editor} current the current editor + * @param {Editor} previous the previous editor + */ function onActiveEditorChanged(event, current, previous) { - if (_prefs.getSetting("enabled")) { + if (prefs.getSetting("enabled")) { if (current && current._codeMirror.getOption("gutters").indexOf(gutterName) === -1) { createGutter(current); restoreLineFolds(current); @@ -254,6 +276,9 @@ define(function (require, exports, module) { } } + /** + * Saves the line folds in the current full editor before it is closed. + */ function saveBeforeClose() { saveLineFolds(EditorManager.getCurrentFullEditor()); } @@ -262,62 +287,63 @@ define(function (require, exports, module) { Initialise the extension */ function init() { - if (!CodeMirror.fold.combine && _prefs.getSetting("enabled")) { - foldCode.init(); - foldGutter.init(); - //register a global fold helper based on indentation folds - CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { - return _prefs.getSetting("alwaysUseIndentFold"); - }, indentFold); + if (CodeMirror.fold.combine || !prefs.getSetting("enabled")) { + return; + } + foldCode.init(); + foldGutter.init(); + //register a global fold helper based on indentation folds + CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) { + return prefs.getSetting("alwaysUseIndentFold"); + }, indentFold); - CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { - return _prefs.getSetting("enableRegionFolding"); - }, regionFold); + CodeMirror.registerGlobalHelper("fold", "region", function (mode, cm) { + return prefs.getSetting("enableRegionFolding"); + }, regionFold); - CodeMirror.registerHelper("fold", "stex", latexFold); - CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); - CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); + CodeMirror.registerHelper("fold", "stex", latexFold); + CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace); + CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace); - EditorManager.on("activeEditorChange", onActiveEditorChanged); - DocumentManager.on("documentRefreshed", function (event, doc) { - if (_prefs.getSetting("enabled")) { - restoreLineFolds(doc._masterEditor); - } - }); + EditorManager.on("activeEditorChange", onActiveEditorChanged); + DocumentManager.on("documentRefreshed", function (event, doc) { + if (prefs.getSetting("enabled")) { + restoreLineFolds(doc._masterEditor); + } + }); - ProjectManager.on("beforeProjectClose beforeAppClose", saveBeforeClose); - ProjectManager.on("projectOpen projectReferesh", function () { - init(); - }); + ProjectManager.on("beforeProjectClose beforeAppClose", saveBeforeClose); + ProjectManager.on("projectOpen projectReferesh", function () { + init(); + }); - CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); - CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); + CommandManager.register(Strings.COLLAPSE_ALL, COLLAPSE_ALL, collapseAll); + CommandManager.register(Strings.EXPAND_ALL, EXPAND_ALL, expandAll); - CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); + CommandManager.register(Strings.COLLAPSE_CUSTOM_REGIONS, COLLAPSE_CUSTOM_REGIONS, collapseCustomRegions); - CommandManager.register(Strings.COLLAPSE_CURRENT, COLLAPSE, collapseCurrent); - CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); + CommandManager.register(Strings.COLLAPSE_CURRENT, COLLAPSE, collapseCurrent); + CommandManager.register(Strings.EXPAND_CURRENT, EXPAND, expandCurrent); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); - Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuDivider(); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(EXPAND_ALL); + Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(COLLAPSE_CUSTOM_REGIONS); - KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-["); - KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-]"); - KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); - KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); + KeyBindingManager.addBinding(COLLAPSE, "Ctrl-Alt-["); + KeyBindingManager.addBinding(EXPAND, "Ctrl-Alt-]"); + KeyBindingManager.addBinding(COLLAPSE_ALL, "Alt-1"); + KeyBindingManager.addBinding(EXPAND_ALL, "Shift-Alt-1"); - var editor = EditorManager.getCurrentFullEditor(); - if (editor) { - var cm = editor._codeMirror; - if (_prefs.getSetting("fadeFoldButtons")) { - foldGutter.clearGutter(cm); - } else { - foldGutter.updateInViewport(cm); - } + var editor = EditorManager.getCurrentFullEditor(); + if (editor) { + var cm = editor._codeMirror; + if (prefs.getSetting("fadeFoldButtons")) { + foldGutter.clearGutter(cm); + } else { + foldGutter.updateInViewport(cm); } } }