Skip to content

Commit

Permalink
Fixed Scintilla/SciMoz support
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Sep 21, 2014
1 parent cf4bbdc commit 738fafb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions content/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ addEventListener("keydown", function (evt) {
}, true);

addEventListener("keypress", function (evt) {
//dump("AVIM.onKeyPress -- code: " + String.fromCharCode(evt.which) + " #" + evt.which +
//dump("AVIM.onKeyPress -- isChrome: " + isChrome + "; code: " + String.fromCharCode(evt.which) + " #" + evt.which +
// "; target: " + evt.target.nodeName + "." + evt.target.className + "#" + evt.target.id +
// "; originalTarget: " + evt.originalTarget.nodeName + "." + evt.originalTarget.className + "#" + evt.originalTarget.id + "\n"); // debug
if (evt.ctrlKey || evt.metaKey || evt.altKey || checkCode(evt)) return;
Expand All @@ -786,7 +786,7 @@ addEventListener("keypress", function (evt) {
let scintilla = koView && koView.scintilla;
if (scintilla && scintilla.inputField &&
origTarget == scintilla.inputField.inputField) {
handleSciMoz(e);
handleSciMoz(evt);
return;
}

Expand Down
3 changes: 0 additions & 3 deletions content/kix.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ function Transferable(win) {
* Proxy for a Google Kix editor to pose as an ordinary HTML <textarea>.
*
* @param evt {object} The keyPress event.
* @param helpers {object} An object containing functions required by this
* subscript, to wit: applyKey() and
* lastWordInString().
*/
function KixProxy(evt) {
if (evt.keyCode == evt.DOM_VK_BACK_SPACE && !evt.shiftKey) {
Expand Down
13 changes: 7 additions & 6 deletions content/sciMoz.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ function getLine(scintilla, selId, lineNum) {
* Proxy for a SciMoz plugin object posing as an ordinary HTML <input> element.
*
* @param elt {object} The <xul:scintilla> tag.
* @param helpers {object} An object containing functions required by this
* subscript, to wit: applyKey() and
* lastWordInString().
* @param selId {number} The selection range number. By default, this
* parameter is 0 (for the main selection).
* @param lineNum {number} The line number of a line within a rectangular
Expand Down Expand Up @@ -188,15 +185,17 @@ function SciMozProxy(elt, selId, lineNum) {
}

context.lazyHandlers.sciMoz = function (evt) {
let elt = ko.views.manager.currentView.scimoz || evt.originalTarget;
let win = evt.originalTarget.ownerDocument.defaultView;
let elt = win.ko.views.manager.currentView.scimoz || evt.originalTarget;
// dump("AVIM.handleSciMoz -- target: " + elt + "; type: " + elt.type + "; code: " + evt.which + "\n"); // debug
// dump("xul:scintilla:\n" + [prop for (prop in elt)] + "\n"); // debug
// elt.setSelectionNStart(0, 8); // debug
// dump(">>> scimoz.getSelectionNStart: " + elt.selections ? elt.getSelectionNStart(0) : "" + "\n"); // debug

let anyChanged = false;
elt.beginUndoAction();
try {
elt.beginUndoAction();

// Fake a native textbox and keypress event for each selection.
let firstSel = 0;
let numSel = elt.selections;
Expand All @@ -220,7 +219,7 @@ context.lazyHandlers.sciMoz = function (evt) {
else proxy = new SciMozProxy(elt, i);
if (!proxy) continue;

let result = proxy.value && helpers.applyKey(proxy.value, evt);
let result = proxy.value && context.applyKey(proxy.value, evt);

if (result) {
if (result.value) proxy.value = result.value;
Expand All @@ -232,6 +231,8 @@ context.lazyHandlers.sciMoz = function (evt) {
}
catch (exc) {
// $if{Debug}
dump(">>> AVIM.handleSciMoz -- error on line " + (exc && exc.lineNumber) +
": " + exc + "\n" + (exc && exc.stack) + "\n");
throw exc;
// $endif{}
}
Expand Down

0 comments on commit 738fafb

Please sign in to comment.