Merge branch 'master' of github.com:thomaswilburn/Caret
This commit is contained in:
commit
a94aa183f5
4 changed files with 38 additions and 17 deletions
|
@ -1,6 +1,21 @@
|
|||
/*
|
||||
|
||||
All settings for Caret are stored in JSON-formatted files. If you open one of
|
||||
these files from the menu, then save it, it'll be dropped into Chrome's
|
||||
synchronized storage, which means that (theoretically) all your computers will
|
||||
get a copy.
|
||||
|
||||
Unfortunately, it's not (yet) feasible to merge configuration the way that
|
||||
Sublime does, which means that this won't behave exactly like you may expect.
|
||||
If new options are introduced, you'll need to copy your settings to a new
|
||||
file, reset Caret's config to the defaults from the menu, then copy your
|
||||
configuration changes back over. Sorry about that. I'm working on it.
|
||||
|
||||
*/
|
||||
{
|
||||
"defaultTheme": "chrome",
|
||||
"defaultTheme": "chrome", //AKA "Native"
|
||||
"indentation": 2,
|
||||
"wordWrap": true,
|
||||
"wrapLimit": 100
|
||||
"fontFamily": "", //WARNING: only fixed-width fonts are currently supported
|
||||
"fontSize": 13
|
||||
}
|
|
@ -24,7 +24,7 @@ define(["file", "command", "settings!ace,user", "dom2"], function(File, command,
|
|||
var displayText = "";
|
||||
if (!selection.inMultiSelectMode) {
|
||||
var cursor = selection.getCursor();
|
||||
displayText = cursor.row + ":" + cursor.column;
|
||||
displayText = (cursor.row + 1) + ":" + (cursor.column + 1);
|
||||
cursorPosition.innerHTML = displayText;
|
||||
}
|
||||
});
|
||||
|
@ -47,7 +47,9 @@ define(["file", "command", "settings!ace,user", "dom2"], function(File, command,
|
|||
userConfig = Settings.get("user");
|
||||
themes.value = userConfig.defaultTheme;
|
||||
editor.setTheme("ace/theme/" + themes.value);
|
||||
}
|
||||
editor.container.style.fontSize = userConfig.fontSize ? userConfig.fontSize + "px" : null;
|
||||
editor.container.style.fontFamily = userConfig.fontFamily || null;
|
||||
};
|
||||
|
||||
command.on("init:startup", init);
|
||||
command.on("init:restart", reset);
|
||||
|
|
|
@ -157,6 +157,7 @@ define([
|
|||
}
|
||||
augmentTab(session, file);
|
||||
session.raise();
|
||||
return session;
|
||||
};
|
||||
|
||||
var removeTab = function(index) {
|
||||
|
@ -300,9 +301,10 @@ define([
|
|||
|
||||
command.on("session:open-settings-file", function(name) {
|
||||
Settings.load(name, function() {
|
||||
var data = JSON.stringify(Settings.get(name), null, 2);
|
||||
var data = Settings.getAsString(name);
|
||||
var file = Settings.getAsFile(name);
|
||||
addTab(data, file);
|
||||
//since we allow comments, it's a good idea to tweak the display to JS mode
|
||||
addTab(data, file).setMode("ace/mode/javascript");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -38,11 +38,16 @@ define(["command"], function(command) {
|
|||
|
||||
var Settings = {
|
||||
get: function(name) {
|
||||
if (!name) {
|
||||
return local;
|
||||
}
|
||||
name = name + ".json";
|
||||
return local[name];
|
||||
try {
|
||||
return JSON.parse(local[name].replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ""));
|
||||
} catch (e) {
|
||||
return JSON.parse(defaults[name].replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ""));
|
||||
}
|
||||
},
|
||||
getAsString: function(name) {
|
||||
name = name + ".json";
|
||||
return local[name] || defaults[name];
|
||||
},
|
||||
getAsFile: function(name) {
|
||||
return new SyncFile(name + ".json");
|
||||
|
@ -54,15 +59,11 @@ define(["command"], function(command) {
|
|||
}
|
||||
|
||||
var onload = function() {
|
||||
var raw = this.responseText.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, "");
|
||||
defaults[name] = JSON.parse(raw);
|
||||
var raw = this.responseText.replace();
|
||||
defaults[name] = raw;
|
||||
chrome.storage.sync.get(name, function(data) {
|
||||
if (data[name]) {
|
||||
try {
|
||||
local[name] = JSON.parse(data[name]);
|
||||
} catch (e) {
|
||||
local[name] = defaults[name];
|
||||
}
|
||||
local[name] = data[name];
|
||||
} else {
|
||||
local[name] = defaults[name];
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ define(["command"], function(command) {
|
|||
key += ".json";
|
||||
local[key] = defaults[key];
|
||||
chrome.storage.sync.remove(key);
|
||||
command.fire("init:restart");
|
||||
});
|
||||
|
||||
command.on("settings:change-local", function() {
|
||||
|
|
Loading…
Reference in a new issue