Merge pull request #922 from ajaxorg/tmp

fix miscellaneous small bugs
This commit is contained in:
Mostafa Eweda 2012-09-11 11:27:20 -07:00
commit 994a0b3cc3
23 changed files with 94 additions and 43 deletions

View file

@ -25,7 +25,7 @@ var EventEmitter = require("../lib/event_emitter").EventEmitter;
var CommandManager = function(platform, commands) {
this.platform = platform;
this.commands = {};
this.commands = this.byName = {};
this.commmandKeyBinding = {};
this.addCommands(commands);

View file

@ -262,9 +262,8 @@
margin: 0 -12px 0 1px;
display: inline-block;
height: 100%;
width: 11px;
vertical-align: bottom;
vertical-align: top;
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat;

View file

@ -39,7 +39,6 @@ var useragent = require("./lib/useragent");
var TextInput = require("./keyboard/textinput").TextInput;
var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
var FoldHandler = require("./mouse/fold_handler").FoldHandler;
//var TouchHandler = require("./touch_handler").TouchHandler;
var KeyBinding = require("./keyboard/keybinding").KeyBinding;
var EditSession = require("./edit_session").EditSession;
var Search = require("./search").Search;
@ -74,12 +73,8 @@ var Editor = function(renderer, session) {
this.keyBinding = new KeyBinding(this);
// TODO detect touch event support
if (useragent.isIPad) {
//this.$mouseHandler = new TouchHandler(this);
} else {
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
}
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
this.$blockScrolling = 0;
this.$search = new Search().set({

View file

@ -212,7 +212,8 @@ exports.emacsKeys = {
"S-C-Home" : "selecttostart",
"S-C-End" : "selecttoend",
"C-l|M-s" : "centerselection",
"C-l" : "recenterTopBottom",
"M-s" : "centerselection",
"M-g": "gotoline",
"C-x C-p": "selectall",
@ -270,6 +271,20 @@ exports.emacsKeys = {
exports.handler.bindKeys(exports.emacsKeys);
exports.handler.addCommands({
recenterTopBottom: function(editor) {
var renderer = editor.renderer;
var pos = renderer.$cursorLayer.getPixelPosition();
var h = renderer.$size.scrollerHeight - renderer.lineHeight;
var scrollTop = renderer.scrollTop;
if (Math.abs(pos.top - scrollTop) < 2) {
scrollTop = pos.top - h;
} else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) {
scrollTop = pos.top;
} else {
scrollTop = pos.top - h * 0.5;
}
editor.session.setScrollTop(scrollTop);
},
selectRectangularRegion: function(editor) {
editor.multiSelect.toggleBlockSelection();
},
@ -323,7 +338,7 @@ exports.handler.addCommands({
},
killRegion: function(editor) {
exports.killRing.add(editor.getCopyText());
editor.cut();
editor.commands.byName.cut.exec(editor);
},
killRingSave: function(editor) {
exports.killRing.add(editor.getCopyText());

View file

@ -88,7 +88,9 @@ exports.handler = {
if (hashId == 1)
key = "ctrl-" + key;
if (data.state == "start") {
if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
return {command: coreCommands.stop};
} else if (data.state == "start") {
if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
hashId = -1;
key = data.inputChar;
@ -109,10 +111,7 @@ exports.handler = {
return {command: coreCommands.stop};
}
} else {
if (key == "esc" || key == "ctrl-[") {
data.state = "start";
return {command: coreCommands.stop};
} else if (key == "ctrl-w") {
if (key == "ctrl-w") {
return {command: "removewordleft"};
}
}

View file

@ -27,7 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
"use strict"
define(function(require, exports, module) {
@ -598,6 +598,25 @@ module.exports = {
return match;
}),
"{": new Motion(function(ed) {
var session = ed.session;
var row = session.selection.lead.row;
while(row > 0 && !/\S/.test(session.getLine(row)))
row--;
while(/\S/.test(session.getLine(row)))
row--;
return {column: 0, row: row};
}),
"}": new Motion(function(ed) {
var session = ed.session;
var l = session.getLength();
var row = session.selection.lead.row;
while(row < l && !/\S/.test(session.getLine(row)))
row++;
while(/\S/.test(session.getLine(row)))
row++;
return {column: 0, row: row};
}),
"ctrl-d": {
nav: function(editor, range, count, param) {
editor.selection.clearSelection();

View file

@ -148,6 +148,10 @@ var Cursor = function(parentEl) {
for (var i = selections.length; i--; ) {
sel = selections[i];
var pixelPos = this.getPixelPosition(sel.cursor, true);
if ((pixelPos.top > config.height + config.offset ||
pixelPos.top < -config.offset) && i > 1) {
continue;
}
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;

View file

@ -131,6 +131,7 @@ var Gutter = function(parentEl) {
html.push(
"<span class='ace_fold-widget ", c,
c == "start" && i == foldStart && i < fold.end.row ? " closed" : " open",
"' style='height:", config.lineHeight, "px",
"'></span>"
);
}

View file

@ -122,6 +122,9 @@ var Keys = (function() {
ret.enter = ret["return"];
ret.escape = ret.esc;
ret.del = ret["delete"];
// workaround for firefox bug
ret[173] = '-';
return ret;
})();

View file

@ -123,7 +123,7 @@ var ScrollBar = function(parent) {
* Sets the scroll top of the scroll bar.
*
**/
// TODO: on chrome 17+ after for small zoom levels after this function
// TODO: on chrome 17+ for small zoom levels after calling this function
// this.element.scrollTop != scrollTop which makes page to scroll up.
this.setScrollTop = function(scrollTop) {
this.element.scrollTop = scrollTop;

View file

@ -17,7 +17,8 @@
background: #e8e8e8;
}
.ace-chrome .ace_text-layer {
.ace-chrome .ace_scroller {
background-color: #FFFFFF;
}
.ace-chrome .ace_cursor {
@ -69,7 +70,7 @@
.ace-chrome .ace_variable.ace_parameter {
font-style:italic;
color:#FD971F;
color:#FD971F;
}
.ace-chrome .ace_line .ace_keyword.ace_operator {
color: rgb(104, 118, 135);
@ -103,7 +104,7 @@ color:#FD971F;
color: #0000A2;
}
.ace-chrome .ace_markup.ace_markupine {
.ace-chrome .ace_markup.ace_underline {
text-decoration:underline;
}
@ -155,11 +156,11 @@ color:#FD971F;
color: rgb(255, 0, 0)
}
.ace-chrome .ace_line .ace_string{
.ace-chrome .ace_line .ace_string {
color: #1A1AA6;
}
.ace-chrome .ace_entity.ace_other.ace_attribute-name{
.ace-chrome .ace_entity.ace_other.ace_attribute-name {
color: #994409;
}

View file

@ -22,6 +22,10 @@
background: #e8e8e8;
}
.ace-crimson-editor .ace_scroller {
background-color: #FFFFFF;
}
.ace-crimson-editor .ace_text-layer {
color: rgb(64, 64, 64);
}

View file

@ -16,6 +16,10 @@
background: #e8e8e8;
}
.ace-dreamweaver .ace_scroller {
background-color: #FFFFFF;
}
.ace-dreamweaver .ace_fold {
background-color: #757AD8;
}
@ -111,7 +115,7 @@
color: #00F;
}
.ace-dreamweaver .ace_markup.ace_markupine {
.ace-dreamweaver .ace_markup.ace_underline {
text-decoration:underline;
}

View file

@ -17,6 +17,10 @@
background: #ebebeb;
}
.ace-eclipse .ace_scroller {
background-color: #FFFFFF;
}
.ace-eclipse .ace_fold {
background-color: rgb(60, 76, 114);
}

View file

@ -117,7 +117,7 @@
border: 1px solid rgb(192, 192, 192);
}
.ace-github .ace_gutter_active_line{
.ace-github .ace_gutter_active_line {
background-color : rgba(0, 0, 0, 0.07);
}

View file

@ -125,7 +125,7 @@ color:#66D9EF;
color:#F92672;
}
.ace-monokai .ace_storage.ace_type, .ace-monokai .ace_support.ace_type{
.ace-monokai .ace_storage.ace_type, .ace-monokai .ace_support.ace_type {
font-style:italic;
color:#66D9EF;
}

View file

@ -20,7 +20,8 @@
background-color: #6B72E6;
}
.ace-tm .ace_text-layer {
.ace-tm .ace_scroller {
background-color: #FFFFFF;
}
.ace-tm .ace_cursor {
@ -111,7 +112,7 @@
color: #0000A2;
}
.ace-tm .ace_markup.ace_markupine {
.ace-tm .ace_markup.ace_underline {
text-decoration:underline;
}
@ -123,6 +124,14 @@
color:rgb(185, 6, 144);
}
.ace-tm .ace_meta.ace_tag {
color:rgb(0, 22, 142);
}
.ace-tm .ace_string.ace_regex {
color: rgb(255, 0, 0)
}
.ace-tm .ace_marker-layer .ace_selection {
background: rgb(181, 213, 255);
}
@ -156,14 +165,6 @@
border: 1px solid rgb(200, 200, 250);
}
.ace-tm .ace_meta.ace_tag {
color:rgb(0, 22, 142);
}
.ace-tm .ace_string.ace_regex {
color: rgb(255, 0, 0)
}
.ace-tm .ace_indent-guide {
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;
}

View file

@ -127,7 +127,7 @@ background-color:#8959A8;
color:#8959A8;
}
.ace-tomorrow .ace_storage.ace_type, .ace-tomorrow .ace_support.ace_type{
.ace-tomorrow .ace_storage.ace_type, .ace-tomorrow .ace_support.ace_type {
color:#8959A8;
}

View file

@ -127,7 +127,7 @@ background-color:#B798BF;
color:#B294BB;
}
.ace-tomorrow-night .ace_storage.ace_type, .ace-tomorrow-night .ace_support.ace_type{
.ace-tomorrow-night .ace_storage.ace_type, .ace-tomorrow-night .ace_support.ace_type {
color:#B294BB;
}

View file

@ -127,7 +127,7 @@ background-color:#EBBBFF;
color:#EBBBFF;
}
.ace-tomorrow-night-blue .ace_storage.ace_type, .ace-tomorrow-night-blue .ace_support.ace_type{
.ace-tomorrow-night-blue .ace_storage.ace_type, .ace-tomorrow-night-blue .ace_support.ace_type {
color:#EBBBFF;
}

View file

@ -127,7 +127,7 @@ background-color:#B798BF;
color:#C397D8;
}
.ace-tomorrow-night-bright .ace_storage.ace_type, .ace-tomorrow-night-bright .ace_support.ace_type{
.ace-tomorrow-night-bright .ace_storage.ace_type, .ace-tomorrow-night-bright .ace_support.ace_type {
color:#C397D8;
}

View file

@ -127,7 +127,7 @@ background-color:#CC99CC;
color:#CC99CC;
}
.ace-tomorrow-night-eighties .ace_storage.ace_type, .ace-tomorrow-night-eighties .ace_support.ace_type{
.ace-tomorrow-night-eighties .ace_storage.ace_type, .ace-tomorrow-night-eighties .ace_support.ace_type {
color:#CC99CC;
}

View file

@ -1038,9 +1038,11 @@ var VirtualRenderer = function(container, theme) {
cursor = {row: cursor, column: 0};
var pos = this.$cursorLayer.getPixelPosition(cursor);
var offset = pos.top - this.$size.scrollerHeight * (alignment || 0);
var h = this.$size.scrollerHeight - this.lineHeight;
var offset = pos.top - h * (alignment || 0);
this.session.setScrollTop(offset);
return offset;
};
this.STEPS = 8;