Merge pull request #1218 from danyaPostfactum/miscfixes

Miscellaneous fixes
This commit is contained in:
nightwing 2013-01-25 12:35:52 +04:00
commit 27a674cd3f
15 changed files with 94 additions and 39 deletions

View file

@ -476,7 +476,7 @@ var detectTextModules = function(input, source) {
input = input.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
input = input.replace(/\n\s+/g, "\n");
input = '"' + input.replace(/\n/g, '\\\n') + '"';
input = '"' + input.replace(/\r?\n/g, '\\\n') + '"';
textModules[module] = input;
return "";

View file

@ -356,6 +356,9 @@ bindCheckbox("enable_behaviours", function(checked) {
bindCheckbox("fade_fold_widgets", function(checked) {
env.editor.setFadeFoldWidgets(checked);
});
bindCheckbox("read_only", function(checked) {
env.editor.setReadOnly(checked);
});
var secondSession = null;
bindDropdown("split", function(value) {

View file

@ -67,7 +67,7 @@ var docs = {
"docs/AsciiDoc.asciidoc": "AsciiDoc",
"docs/javascript.js": "JavaScript",
"docs/clojure.clj": "Clojure",
"docs/coffeescript.coffee": "Coffeescript",
"docs/coffeescript.coffee": "CoffeeScript",
"docs/coldfusion.cfm": "ColdFusion",
"docs/cpp.cpp": "C/C++",
"docs/csharp.cs": "C#",

View file

@ -107,8 +107,10 @@
<option value="10px">10px</option>
<option value="11px">11px</option>
<option value="12px" selected="selected">12px</option>
<option value="13px">13px</option>
<option value="14px">14px</option>
<option value="16px">16px</option>
<option value="18px">18px</option>
<option value="20px">20px</option>
<option value="24px">24px</option>
</select>
@ -247,6 +249,14 @@
<input type="checkbox" id="highlight_token">
</td>
</tr>
<tr>
<td >
<label for="read_only">Read-only</label>
</td>
<td>
<input type="checkbox" id="read_only">
</td>
</tr>
</table>
</td></tr>
</table>

View file

@ -414,6 +414,16 @@ exports.commands = [{
bindKey: bindKey("Tab", "Tab"),
exec: function(editor) { editor.indent(); },
multiSelectAction: "forEach"
},{
name: "blockoutdent",
bindKey: bindKey("Ctrl-[", "Ctrl-["),
exec: function(editor) { editor.blockOutdent(); },
multiSelectAction: "forEach"
},{
name: "blockindent",
bindKey: bindKey("Ctrl-]", "Ctrl-]"),
exec: function(editor) { editor.blockIndent(); },
multiSelectAction: "forEach"
}, {
name: "insertstring",
exec: function(editor, str) { editor.insert(str); },

View file

@ -7,6 +7,8 @@
.ace_scroller {
position: absolute;
overflow: hidden;
top: 0;
bottom: 0;
}
.ace_content {
@ -20,8 +22,10 @@
.ace_gutter {
position: absolute;
overflow : hidden;
height: 100%;
width: auto;
top: 0;
bottom: 0;
left: 0;
cursor: default;
z-index: 4;
}
@ -66,6 +70,8 @@
overflow-x: hidden;
overflow-y: scroll;
right: 0;
top: 0;
bottom: 0;
}
.ace_scrollbar-inner {
@ -241,13 +247,17 @@
}
.ace_gutter-tooltip {
background-color: #FFFFD5;
background-color: #FFF;
background-image: -webkit-linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));
background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));
border: 1px solid gray;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
border-radius: 1px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
color: black;
display: inline-block;
max-width: 500px;
padding: 4px;
position: absolute;
position: fixed;
z-index: 300;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
@ -255,6 +265,10 @@
cursor: default;
white-space: pre-line;
word-wrap: break-word;
line-height: normal;
font-style: normal;
font-weight: normal;
letter-spacing: normal;
}
.ace_folding-enabled > .ace_gutter-cell {

View file

@ -1015,6 +1015,8 @@ var Editor = function(renderer, session) {
**/
this.setReadOnly = function(readOnly) {
this.$readOnly = readOnly;
this.textInput.setReadOnly(readOnly);
this.renderer.$cursorLayer.setBlinking(!readOnly);
};
/**
@ -1245,8 +1247,8 @@ var Editor = function(renderer, session) {
this.selection.setSelectionRange(originalRange);
};
/**
* Indents the current line.
/**
* Inserts an indentation into the current cursor position or indents the selected lines.
*
* @related EditSession.indentRows
**/
@ -1273,7 +1275,16 @@ var Editor = function(renderer, session) {
}
};
/**
/**
* Indents the current line.
* @related EditSession.indentRows
**/
this.blockIndent = function() {
var rows = this.$getSelectedRows();
this.session.indentRows(rows.first, rows.last, "\t");
};
/**
* Outdents the current line.
* @related EditSession.outdentRows
**/

View file

@ -355,11 +355,14 @@ var TextInput = function(parentNode, host) {
event.addListener(text, "keyup", onCompositionUpdate);
event.addListener(text, "compositionend", onCompositionEnd);
// CONTEXTMENU
this.getElement = function() {
return text;
};
this.setReadOnly = function(readOnly) {
text.readOnly = readOnly;
};
this.onContextMenu = function(e) {
if (!tempStyle)
tempStyle = text.style.cssText;

View file

@ -8,25 +8,25 @@
["keyword","function"],
["text"," "],
["identifier","nfact"],
["lparen","("],
["paren.lparen","("],
["variable","$n"],
["rparen",")"],
["paren.rparen",")"],
["text"," "],
["lparen","{"]
["paren.lparen","{"]
],[
"php-start",
["text"," "],
["keyword","if"],
["text"," "],
["lparen","("],
["paren.lparen","("],
["variable","$n"],
["text"," "],
["keyword.operator","=="],
["text"," "],
["constant.numeric","0"],
["rparen",")"],
["paren.rparen",")"],
["text"," "],
["lparen","{"]
["paren.lparen","{"]
],[
"php-start",
["text"," "],
@ -37,13 +37,13 @@
],[
"php-start",
["text"," "],
["rparen","}"]
["paren.rparen","}"]
],[
"php-start",
["text"," "],
["keyword","else"],
["text"," "],
["lparen","{"]
["paren.lparen","{"]
],[
"php-start",
["text"," "],
@ -54,21 +54,21 @@
["keyword.operator","*"],
["text"," "],
["identifier","nfact"],
["lparen","("],
["paren.lparen","("],
["variable","$n"],
["text"," "],
["keyword.operator","-"],
["text"," "],
["constant.numeric","1"],
["rparen",")"],
["paren.rparen",")"],
["text",";"]
],[
"php-start",
["text"," "],
["rparen","}"]
["paren.rparen","}"]
],[
"php-start",
["rparen","}"]
["paren.rparen","}"]
],[
"php-start"
],[
@ -86,11 +86,11 @@
["keyword.operator","="],
["text"," "],
["support.function","trim"],
["lparen","("],
["paren.lparen","("],
["support.function","fgets"],
["lparen","("],
["paren.lparen","("],
["constant.language","STDIN"],
["rparen","))"],
["paren.rparen","))"],
["text",";"]
],[
"php-start"
@ -112,9 +112,9 @@
["string","\" = \""],
["text"," . "],
["identifier","nfact"],
["lparen","("],
["paren.lparen","("],
["variable","$num"],
["rparen",")"],
["paren.rparen",")"],
["text"," . "],
["string","\""],
["constant.language.escape","\\n\\n"],

View file

@ -350,7 +350,7 @@ var CstyleBehaviour = function () {
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') {
if (rightChar == selected) {
range.end.column++;
return range;
}

View file

@ -978,10 +978,10 @@ var PhpLangHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

View file

@ -66,7 +66,6 @@ function GutterHandler(mouseHandler) {
function createTooltip() {
tooltip = dom.createElement("div");
tooltip.className = "ace_gutter-tooltip";
tooltip.style.maxWidth = "500px";
tooltip.style.display = "none";
editor.container.appendChild(tooltip);
}
@ -111,10 +110,10 @@ function GutterHandler(mouseHandler) {
function moveTooltip(e) {
var rect = editor.renderer.$gutter.getBoundingClientRect();
tooltip.style.left = e.x - rect.left + 15 + "px";
tooltip.style.left = e.x + 15 + "px";
if (e.y + 3 * editor.renderer.lineHeight + 15 < rect.bottom) {
tooltip.style.bottom = "";
tooltip.style.top = e.y - rect.top + 15 + "px";
tooltip.style.top = e.y + 15 + "px";
} else {
tooltip.style.top = "";
tooltip.style.bottom = rect.bottom - e.y + 5 + "px";

View file

@ -41,6 +41,8 @@ var DragdropHandler = function(mouseHandler) {
var mouseTarget = editor.container;
event.addListener(mouseTarget, "dragenter", function(e) {
if (editor.getReadOnly())
return;
counter++;
if (!dragSelectionMarker) {
range = editor.getSelectionRange();
@ -55,6 +57,8 @@ var DragdropHandler = function(mouseHandler) {
});
event.addListener(mouseTarget, "dragover", function(e) {
if (editor.getReadOnly())
return;
x = e.clientX;
y = e.clientY;
return event.preventDefault(e);
@ -67,10 +71,11 @@ var DragdropHandler = function(mouseHandler) {
};
event.addListener(mouseTarget, "dragleave", function(e) {
if (editor.getReadOnly())
return;
counter--;
if (counter > 0)
return;
console.log(e.type, counter,e.target);
clearInterval(timerId);
editor.session.removeMarker(dragSelectionMarker);
dragSelectionMarker = null;
@ -79,7 +84,8 @@ var DragdropHandler = function(mouseHandler) {
});
event.addListener(mouseTarget, "drop", function(e) {
console.log(e.type, counter,e.target);
if (editor.getReadOnly())
return;
counter = 0;
clearInterval(timerId);
editor.session.removeMarker(dragSelectionMarker);

View file

@ -1,6 +1,6 @@
.ace-monokai .ace_gutter {
background: #2f3129;
color: #f1f1f1
background: #2F3129;
color: #8F908A
}
.ace-monokai .ace_print-margin {
@ -56,7 +56,7 @@
}
.ace-monokai .ace_invisible {
color: #49483E
color: #52524d
}
.ace-monokai .ace_entity.ace_name.ace_tag,

View file

@ -306,7 +306,6 @@ var VirtualRenderer = function(container, theme) {
if (height && (force || size.height != height)) {
size.height = height;
this.scroller.style.height = height + "px";
size.scrollerHeight = this.scroller.clientHeight;
this.scrollBar.setHeight(size.scrollerHeight);