mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 02:07:58 +01:00
Better :yank formatting.
This commit is contained in:
@@ -496,7 +496,7 @@ const Buffer = Module("buffer", {
|
|||||||
*/
|
*/
|
||||||
focusAllowed: function (elem) {
|
focusAllowed: function (elem) {
|
||||||
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
||||||
return !options["strictfocus"] || elem.dactylFocusAllowed;
|
return !options["strictfocus"] || win.dactylFocusAllowed;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1013,9 +1013,7 @@ const Buffer = Module("buffer", {
|
|||||||
// at all correctly; if somehow the view-source stuff managed to
|
// at all correctly; if somehow the view-source stuff managed to
|
||||||
// execute script we'd be in big trouble here, I suspect.
|
// execute script we'd be in big trouble here, I suspect.
|
||||||
|
|
||||||
this.docShell = Cc["@mozilla.org/docshell;1"].createInstance(Ci.nsIBaseWindow)
|
this.docShell = services.create("docshell");
|
||||||
.QueryInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIWebPageDescriptor)
|
|
||||||
.QueryInterface(Ci.nsIWebProgress);
|
|
||||||
this.docShell.create();
|
this.docShell.create();
|
||||||
this.docShell.addProgressListener(this, this.docShell.NOTIFY_STATE_DOCUMENT);
|
this.docShell.addProgressListener(this, this.docShell.NOTIFY_STATE_DOCUMENT);
|
||||||
this.docShell.loadPage(descriptor, this.docShell.DISPLAY_AS_SOURCE);
|
this.docShell.loadPage(descriptor, this.docShell.DISPLAY_AS_SOURCE);
|
||||||
|
|||||||
@@ -1161,9 +1161,11 @@ const CommandLine = Module("commandline", {
|
|||||||
dactyl.registerObserver("echoLine", observe, true);
|
dactyl.registerObserver("echoLine", observe, true);
|
||||||
dactyl.registerObserver("echoMultiline", observe, true);
|
dactyl.registerObserver("echoMultiline", observe, true);
|
||||||
function observe(str, highlight, dom) {
|
function observe(str, highlight, dom) {
|
||||||
buffer.push(dom ? dom.textContent : str)
|
if (!observe.done)
|
||||||
|
buffer.push(dom ? util.domToString(dom) : str)
|
||||||
}
|
}
|
||||||
dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2)));
|
dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2)));
|
||||||
|
observe.done = true;
|
||||||
return buffer.join("\n");
|
return buffer.join("\n");
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -623,7 +623,11 @@ const Editor = Module("editor", {
|
|||||||
|
|
||||||
mappings.add([modes.INSERT],
|
mappings.add([modes.INSERT],
|
||||||
["<Tab>"], "Expand insert mode abbreviation",
|
["<Tab>"], "Expand insert mode abbreviation",
|
||||||
function () { editor.expandAbbreviation(modes.INSERT); document.commandDispatcher.advanceFocus(); });
|
function () {
|
||||||
|
util.dumpStack("\n\n\n<Tab>");
|
||||||
|
editor.expandAbbreviation(modes.INSERT);
|
||||||
|
document.commandDispatcher.advanceFocus();
|
||||||
|
});
|
||||||
|
|
||||||
mappings.add([modes.INSERT],
|
mappings.add([modes.INSERT],
|
||||||
["<C-]>", "<C-5>"], "Expand insert mode abbreviation",
|
["<C-]>", "<C-5>"], "Expand insert mode abbreviation",
|
||||||
|
|||||||
@@ -377,7 +377,6 @@ const Hints = Module("hints", {
|
|||||||
* Display the hints in pageHints that are still valid.
|
* Display the hints in pageHints that are still valid.
|
||||||
*/
|
*/
|
||||||
_showHints: function _showHints() {
|
_showHints: function _showHints() {
|
||||||
util.dumpStack();
|
|
||||||
let hintnum = 1;
|
let hintnum = 1;
|
||||||
let validHint = this._hintMatcher(this._hintString.toLowerCase());
|
let validHint = this._hintMatcher(this._hintString.toLowerCase());
|
||||||
let activeHint = this._hintNumber || 1;
|
let activeHint = this._hintNumber || 1;
|
||||||
@@ -451,7 +450,6 @@ const Hints = Module("hints", {
|
|||||||
* hint disappears.
|
* hint disappears.
|
||||||
*/
|
*/
|
||||||
_removeHints: function _removeHints(timeout, slight) {
|
_removeHints: function _removeHints(timeout, slight) {
|
||||||
util.dump("_removeHints", timeout, slight);
|
|
||||||
for (let [,{ doc: doc, start: start, end: end }] in Iterator(this._docs)) {
|
for (let [,{ doc: doc, start: start, end: end }] in Iterator(this._docs)) {
|
||||||
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
||||||
elem.parentNode.removeChild(elem);
|
elem.parentNode.removeChild(elem);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const Services = Module("Services", {
|
|||||||
this.services = {};
|
this.services = {};
|
||||||
|
|
||||||
this.add("annotation", "@mozilla.org/browser/annotation-service;1", Ci.nsIAnnotationService);
|
this.add("annotation", "@mozilla.org/browser/annotation-service;1", Ci.nsIAnnotationService);
|
||||||
|
this.add("appShell", "@mozilla.org/appshell/appShellService;1", Ci.nsIAppShellService);
|
||||||
this.add("appStartup", "@mozilla.org/toolkit/app-startup;1", Ci.nsIAppStartup);
|
this.add("appStartup", "@mozilla.org/toolkit/app-startup;1", Ci.nsIAppStartup);
|
||||||
this.add("autoCompleteSearch", "@mozilla.org/autocomplete/search;1?name=history", Ci.nsIAutoCompleteSearch);
|
this.add("autoCompleteSearch", "@mozilla.org/autocomplete/search;1?name=history", Ci.nsIAutoCompleteSearch);
|
||||||
this.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", Ci.nsINavBookmarksService);
|
this.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", Ci.nsINavBookmarksService);
|
||||||
@@ -54,6 +55,9 @@ const Services = Module("Services", {
|
|||||||
this.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
|
this.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
|
||||||
this.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
|
this.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
|
||||||
|
|
||||||
|
|
||||||
|
this.addClass("docshell", "@mozilla.org/docshell;1", [Ci.nsIBaseWindow, Ci.nsIWebNavigation,
|
||||||
|
Ci.nsIWebPageDescriptor, Ci.nsIWebProgress]);
|
||||||
this.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
|
this.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
|
||||||
this.addClass("file:", "@mozilla.org/network/protocol;1?name=file", Ci.nsIFileProtocolHandler);
|
this.addClass("file:", "@mozilla.org/network/protocol;1?name=file", Ci.nsIFileProtocolHandler);
|
||||||
this.addClass("find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
this.addClass("find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
|
|
||||||
this.addObserver(this);
|
this.addObserver(this);
|
||||||
this.overlays = {};
|
this.overlays = {};
|
||||||
|
|
||||||
|
let doc = services.get("appShell").hiddenDOMWindow.document;
|
||||||
|
this._div = this.xmlToDom(<div xmlns={XHTML}/>, doc);
|
||||||
|
doc.body.appendChild(this._div);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Only works for Pentadactyl
|
// FIXME: Only works for Pentadactyl
|
||||||
@@ -262,6 +266,17 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
dequote: function dequote(pattern, chars)
|
dequote: function dequote(pattern, chars)
|
||||||
pattern.replace(/\\(.)/, function (m0, m1) chars.indexOf(m1) >= 0 ? m1 : m0),
|
pattern.replace(/\\(.)/, function (m0, m1) chars.indexOf(m1) >= 0 ? m1 : m0),
|
||||||
|
|
||||||
|
domToString: function (node) {
|
||||||
|
this._div.appendChild(this._div.ownerDocument.importNode(node, true));
|
||||||
|
let sel = this._div.ownerDocument.defaultView.getSelection();
|
||||||
|
sel.removeAllRanges();
|
||||||
|
sel.selectAllChildren(this._div);
|
||||||
|
let res = sel.toString();
|
||||||
|
while (this._div.firstChild)
|
||||||
|
this._div.removeChild(this._div.firstChild);
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a message to the console. If <b>msg</b> is an object it is
|
* Prints a message to the console. If <b>msg</b> is an object it is
|
||||||
* pretty printed.
|
* pretty printed.
|
||||||
|
|||||||
Reference in New Issue
Block a user