mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:27:58 +01:00
Store node XPath in marks.
This commit is contained in:
@@ -49,15 +49,27 @@ var Marks = Module("marks", {
|
|||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
|
|
||||||
let position = buffer.scrollPosition;
|
let position = buffer.scrollPosition;
|
||||||
|
let path = util.generateXPath(buffer.findScrollable(0, position.x));
|
||||||
|
|
||||||
if (Marks.isURLMark(mark)) {
|
if (Marks.isURLMark(mark)) {
|
||||||
let res = this._urlMarks.set(mark, { location: doc.documentURI, offset: position, tab: Cu.getWeakReference(tabs.getTab()), timestamp: Date.now()*1000 });
|
let res = this._urlMarks.set(mark, {
|
||||||
|
location: doc.documentURI,
|
||||||
|
offset: position,
|
||||||
|
xpath: path,
|
||||||
|
tab: Cu.getWeakReference(tabs.getTab()),
|
||||||
|
timestamp: Date.now()*1000
|
||||||
|
});
|
||||||
if (!silent)
|
if (!silent)
|
||||||
dactyl.log(_("mark.addURL", Marks.markToString(mark, res)), 5);
|
dactyl.log(_("mark.addURL", Marks.markToString(mark, res)), 5);
|
||||||
}
|
}
|
||||||
else if (Marks.isLocalMark(mark)) {
|
else if (Marks.isLocalMark(mark)) {
|
||||||
let marks = this._localMarks.get(doc.documentURI, {});
|
let marks = this._localMarks.get(doc.documentURI, {});
|
||||||
marks[mark] = { location: doc.documentURI, offset: position, timestamp: Date.now()*1000 };
|
marks[mark] = {
|
||||||
|
location: doc.documentURI,
|
||||||
|
offset: position,
|
||||||
|
xpath: path,
|
||||||
|
timestamp: Date.now()*1000
|
||||||
|
};
|
||||||
this._localMarks.changed();
|
this._localMarks.changed();
|
||||||
if (!silent)
|
if (!silent)
|
||||||
dactyl.log(_("mark.addLocal", Marks.markToString(mark, marks[mark])), 5);
|
dactyl.log(_("mark.addLocal", Marks.markToString(mark, marks[mark])), 5);
|
||||||
@@ -155,10 +167,19 @@ var Marks = Module("marks", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_scrollTo: function _scrollTo(mark) {
|
_scrollTo: function _scrollTo(mark) {
|
||||||
|
if (!mark.xpath)
|
||||||
|
var node = buffer.findScrollable(0, (mark.offset || mark.position).x)
|
||||||
|
else
|
||||||
|
for (node in util.evaluateXPath(mark.xpath, buffer.focusedFrame.document))
|
||||||
|
;
|
||||||
|
|
||||||
|
util.assert(node);
|
||||||
|
util.scrollIntoView(node, true);
|
||||||
|
|
||||||
if (mark.position)
|
if (mark.position)
|
||||||
buffer.scrollToPercent(mark.position.x * 100, mark.position.y * 100);
|
Buffer.scrollToPercent(node, mark.position.x * 100, mark.position.y * 100);
|
||||||
else if (mark.offset)
|
else if (mark.offset)
|
||||||
buffer.scrollToPosition(mark.offset.x, mark.offset.y);
|
Buffer.scrollToPosition(node, mark.offset.x, mark.offset.y);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -71,7 +71,9 @@
|
|||||||
editing input fields with i_<C-i>. See :h 'editor'. [b4]
|
editing input fields with i_<C-i>. See :h 'editor'. [b4]
|
||||||
• Improved [macro-string] support, including automatic elision
|
• Improved [macro-string] support, including automatic elision
|
||||||
of optional elements, and array subscripts. [b4][b7]
|
of optional elements, and array subscripts. [b4][b7]
|
||||||
• Marks are now stored as line and column ordinals rather than percentages. [b8]
|
• Improvements to marks:
|
||||||
|
- Marks are now stored as line and column ordinals rather than percentages. [b8]
|
||||||
|
- Marks now store the marked element and ensure its visibility when followed. [b8]
|
||||||
• Mapping changes:
|
• Mapping changes:
|
||||||
- It's now possible to map keys in many more modes, including
|
- It's now possible to map keys in many more modes, including
|
||||||
Hint, Multi-line Output, and Menu. [b4]
|
Hint, Multi-line Output, and Menu. [b4]
|
||||||
|
|||||||
Reference in New Issue
Block a user