Merge pull request #1502 from ajaxorg/scrolling_issues
fix several small issues on mac
This commit is contained in:
commit
65713e974b
4 changed files with 69 additions and 12 deletions
|
|
@ -80,6 +80,39 @@ exports.handler = {
|
||||||
data.lastEvent = "keypress";
|
data.lastEvent = "keypress";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// on mac, with some keyboard layouts (e.g swedish) ^ starts composition, we don't need it in normal mode
|
||||||
|
updateMacCompositionHandlers: function(editor, enable) {
|
||||||
|
var onCompositionUpdateOverride = function(text) {
|
||||||
|
if (util.currentMode !== "insert") {
|
||||||
|
var el = this.textInput.getElement();
|
||||||
|
el.blur();
|
||||||
|
el.focus();
|
||||||
|
el.value = text;
|
||||||
|
} else {
|
||||||
|
this.onCompositionUpdateOrig(text);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var onCompositionStartOverride = function(text) {
|
||||||
|
if (util.currentMode === "insert") {
|
||||||
|
this.onCompositionStartOrig(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (enable) {
|
||||||
|
if (!editor.onCompositionUpdateOrig) {
|
||||||
|
editor.onCompositionUpdateOrig = editor.onCompositionUpdate;
|
||||||
|
editor.onCompositionUpdate = onCompositionUpdateOverride;
|
||||||
|
editor.onCompositionStartOrig = editor.onCompositionStart;
|
||||||
|
editor.onCompositionStart = onCompositionStartOverride;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (editor.onCompositionUpdateOrig) {
|
||||||
|
editor.onCompositionUpdate = editor.onCompositionUpdateOrig;
|
||||||
|
editor.onCompositionUpdateOrig = null;
|
||||||
|
editor.onCompositionStart = editor.onCompositionStartOrig;
|
||||||
|
editor.onCompositionStartOrig = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleKeyboard: function(data, hashId, key, keyCode, e) {
|
handleKeyboard: function(data, hashId, key, keyCode, e) {
|
||||||
// ignore command keys (shift, ctrl etc.)
|
// ignore command keys (shift, ctrl etc.)
|
||||||
|
|
@ -132,12 +165,15 @@ exports.handler = {
|
||||||
if (util.currentMode !== "insert")
|
if (util.currentMode !== "insert")
|
||||||
cmds.coreCommands.stop.exec(editor);
|
cmds.coreCommands.stop.exec(editor);
|
||||||
editor.$vimModeHandler = this;
|
editor.$vimModeHandler = this;
|
||||||
|
|
||||||
|
this.updateMacCompositionHandlers(editor, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
detach: function(editor) {
|
detach: function(editor) {
|
||||||
editor.removeListener("click", exports.onCursorMove);
|
editor.removeListener("click", exports.onCursorMove);
|
||||||
util.noMode(editor);
|
util.noMode(editor);
|
||||||
util.currentMode = "normal";
|
util.currentMode = "normal";
|
||||||
|
this.updateMacCompositionHandlers(editor, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: cmds.actions,
|
actions: cmds.actions,
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,18 @@ var actions = exports.actions = {
|
||||||
case "b":
|
case "b":
|
||||||
editor.renderer.alignCursor(null, 1);
|
editor.renderer.alignCursor(null, 1);
|
||||||
break;
|
break;
|
||||||
|
case "c":
|
||||||
|
editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
|
||||||
|
break;
|
||||||
|
case "o":
|
||||||
|
editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
|
||||||
|
break;
|
||||||
|
case "C":
|
||||||
|
editor.session.foldAll();
|
||||||
|
break;
|
||||||
|
case "O":
|
||||||
|
editor.session.unfold();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -141,9 +141,9 @@ else {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.addMouseWheelListener = function(el, callback) {
|
exports.addMouseWheelListener = function(el, callback) {
|
||||||
var factor = 8;
|
if ("onmousewheel" in el) {
|
||||||
var listener = function(e) {
|
var factor = 8;
|
||||||
if (e.wheelDelta !== undefined) {
|
exports.addListener(el, "mousewheel", function(e) {
|
||||||
if (e.wheelDeltaX !== undefined) {
|
if (e.wheelDeltaX !== undefined) {
|
||||||
e.wheelX = -e.wheelDeltaX / factor;
|
e.wheelX = -e.wheelDeltaX / factor;
|
||||||
e.wheelY = -e.wheelDeltaY / factor;
|
e.wheelY = -e.wheelDeltaY / factor;
|
||||||
|
|
@ -151,8 +151,16 @@ exports.addMouseWheelListener = function(el, callback) {
|
||||||
e.wheelX = 0;
|
e.wheelX = 0;
|
||||||
e.wheelY = -e.wheelDelta / factor;
|
e.wheelY = -e.wheelDelta / factor;
|
||||||
}
|
}
|
||||||
}
|
callback(e);
|
||||||
else {
|
});
|
||||||
|
} else if ("onwheel" in el) {
|
||||||
|
exports.addListener(el, "wheel", function(e) {
|
||||||
|
e.wheelX = (e.deltaX || 0) * 5;
|
||||||
|
e.wheelY = (e.deltaY || 0) * 5;
|
||||||
|
callback(e);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
exports.addListener(el, "DOMMouseScroll", function(e) {
|
||||||
if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
|
if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
|
||||||
e.wheelX = (e.detail || 0) * 5;
|
e.wheelX = (e.detail || 0) * 5;
|
||||||
e.wheelY = 0;
|
e.wheelY = 0;
|
||||||
|
|
@ -160,11 +168,9 @@ exports.addMouseWheelListener = function(el, callback) {
|
||||||
e.wheelX = 0;
|
e.wheelX = 0;
|
||||||
e.wheelY = (e.detail || 0) * 5;
|
e.wheelY = (e.detail || 0) * 5;
|
||||||
}
|
}
|
||||||
}
|
callback(e);
|
||||||
callback(e);
|
});
|
||||||
};
|
}
|
||||||
exports.addListener(el, "DOMMouseScroll", listener);
|
|
||||||
exports.addListener(el, "mousewheel", listener);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
|
exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
|
||||||
|
|
|
||||||
|
|
@ -727,7 +727,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
changes & this.CHANGE_SIZE ||
|
changes & this.CHANGE_SIZE ||
|
||||||
changes & this.CHANGE_TEXT ||
|
changes & this.CHANGE_TEXT ||
|
||||||
changes & this.CHANGE_LINES ||
|
changes & this.CHANGE_LINES ||
|
||||||
changes & this.CHANGE_SCROLL
|
changes & this.CHANGE_SCROLL ||
|
||||||
|
changes & this.CHANGE_H_SCROLL
|
||||||
)
|
)
|
||||||
this.$computeLayerConfig();
|
this.$computeLayerConfig();
|
||||||
|
|
||||||
|
|
@ -1269,7 +1270,9 @@ var VirtualRenderer = function(container, theme) {
|
||||||
if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
|
if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
|
||||||
- this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
|
- this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
|
||||||
return true;
|
return true;
|
||||||
// todo: handle horizontal scrolling
|
// todo: better handle horizontal scrolling
|
||||||
|
if (deltaX)
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pixelToScreenCoordinates = function(x, y) {
|
this.pixelToScreenCoordinates = function(x, y) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue