Add 'Soft Wrap' and 'Show Print Margin' option to bookmarklet settings

This commit is contained in:
Julian Viereck 2011-02-15 18:43:03 +08:00 • committed by Fabian Jakobs
commit 36a3d23623
2 changed files with 47 additions and 6 deletions

View file

@ -252,7 +252,9 @@ window.__ace_shadowed__.transformTextarea = function(element) {
background: "rgba(0, 0, 0, 0.6)", background: "rgba(0, 0, 0, 0.6)",
zIndex: 100, zIndex: 100,
color: "white", color: "white",
display: "none" display: "none",
overflow: "auto",
fontSize: "14px"
}); });
container.appendChild(settingDiv); container.appendChild(settingDiv);
@ -328,6 +330,34 @@ function setupApi(editor, editorDiv, settingDiv, ace, options) {
case "fontSize": case "fontSize":
editorDiv.style.fontSize = value; editorDiv.style.fontSize = value;
break; break;
case "softWrap":
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "40":
session.setUseWrapMode(true);
session.setWrapLimitRange(40, 40);
renderer.setPrintMarginColumn(40);
break;
case "80":
session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
}
break;
case "showPrintMargin":
renderer.setShowPrintMargin(toBool(value));
break
} }
options[key] = value; options[key] = value;
@ -359,7 +389,9 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
mode: "Mode:", mode: "Mode:",
gutter: "Display Gutter:", gutter: "Display Gutter:",
theme: "Theme:", theme: "Theme:",
fontSize: "Font Size:" fontSize: "Font Size:",
softWrap: "Soft Wrap:",
showPrintMargin: "Show Print Margin:"
} }
var optionValues = { var optionValues = {
@ -395,7 +427,14 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
"12px": "12px", "12px": "12px",
"14px": "14px", "14px": "14px",
"16px": "16px" "16px": "16px"
} },
softWrap: {
off: "Off",
40: "40",
80: "80",
free: "Free"
},
showPrintMargin: BOOL
} }
var table = []; var table = [];
@ -453,7 +492,9 @@ window.__ace_shadowed__.options = {
mode: "text", mode: "text",
theme: "textmate", theme: "textmate",
gutter: "false", gutter: "false",
fontSize: "12px" fontSize: "12px",
softWrap: "off",
showPrintMargin: "false"
} }
})() })()

View file

@ -59,12 +59,12 @@ function inject() {
}, false); }, false);
} }
}); });
} }
inject();
var textAce; var textAce;
inject();
setTimeout(function() { setTimeout(function() {
var t = document.querySelector("textarea"); var t = document.querySelector("textarea");
var ace = window.__ace_shadowed__; var ace = window.__ace_shadowed__;