Add editor.html dropdown Soft Wrap

This commit is contained in:
Julian Viereck 2011-01-28 19:33:48 +08:00 • committed by Fabian Jakobs
commit e6e01a3ed1
4 changed files with 41 additions and 16 deletions

View file

@ -150,7 +150,11 @@ exports.launch = function(env) {
modeEl.value = "text"; modeEl.value = "text";
} }
wrapModeEl.checked = doc.getUseWrapMode() ? "checked" : ""; if (!doc.getUseWrapMode()) {
wrapModeEl.value = "off";
} else {
wrapModeEl.value = doc.getWrapLimit();
}
env.editor.focus(); env.editor.focus();
}); });
@ -170,6 +174,27 @@ exports.launch = function(env) {
document.getElementById("editor").style["font-size"] = value; document.getElementById("editor").style["font-size"] = value;
}); });
bindDropdown("soft_wrap", function(value) {
var session = env.editor.getSession();
var renderer = env.editor.renderer;
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "40":
session.setUseWrapMode(true);
session.setWrapLimit(40);
renderer.setPrintMarginColumn(40);
break;
case "80":
session.setUseWrapMode(true);
session.setWrapLimit(80);
renderer.setPrintMarginColumn(80);
break;
}
});
bindCheckbox("select_style", function(checked) { bindCheckbox("select_style", function(checked) {
env.editor.setSelectionStyle(checked ? "line" : "text"); env.editor.setSelectionStyle(checked ? "line" : "text");
}); });
@ -190,10 +215,6 @@ exports.launch = function(env) {
env.editor.renderer.setShowPrintMargin(checked); env.editor.renderer.setShowPrintMargin(checked);
}); });
bindCheckbox("soft_wrap", function(checked) {
env.editor.getSession().setUseWrapMode(checked);
});
function bindCheckbox(id, callback) { function bindCheckbox(id, callback) {
var el = document.getElementById(id); var el = document.getElementById(id);
var onCheck = function() { var onCheck = function() {

View file

@ -74,7 +74,6 @@
<option value="php">PHP</option> <option value="php">PHP</option>
</select> </select>
</td> </td>
<td align="right"> <td align="right">
<label for="keybinding">Key Binding:</label> <label for="keybinding">Key Binding:</label>
<select id="keybinding" size="1"> <select id="keybinding" size="1">
@ -84,6 +83,14 @@
<option value="custom">Custom</option> <option value="custom">Custom</option>
</select> </select>
</td> </td>
<td align="right">
<label for="soft_wrap">Soft Wrap:</label>
<select id="soft_wrap" size="1">
<option value="off">Off</option>
<option value="40">40 Chars</option>
<option value="80">80 Chars</option>
</select>
</td>
<td align="right"> <td align="right">
<label for="show_gutter">Show Gutter</label> <label for="show_gutter">Show Gutter</label>
<input type="checkbox" id="show_gutter" checked> <input type="checkbox" id="show_gutter" checked>
@ -92,10 +99,6 @@
<label for="show_print_margin">Show Print Margin</label> <label for="show_print_margin">Show Print Margin</label>
<input type="checkbox" id="show_print_margin" checked> <input type="checkbox" id="show_print_margin" checked>
</td> </td>
<td align="right">
<label for="soft_wrap">Soft Wrap</label>
<input type="checkbox" id="soft_wrap">
</td>
</tr> </tr>
</table> </table>

View file

@ -656,6 +656,7 @@ var EditSession = function(text, mode) {
if (wrapLimit != this.$wrapLimit) { if (wrapLimit != this.$wrapLimit) {
this.$wrapLimit = wrapLimit; this.$wrapLimit = wrapLimit;
this.$updateWrapData(0, this.getLength() - 1); this.$updateWrapData(0, this.getLength() - 1);
this._dispatchEvent("changeWrapMode");
} }
}; };