mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 08:07:59 +01:00
Pass line/column numbers to the editor for rich text editors too.
This commit is contained in:
@@ -15,7 +15,8 @@ SED := $(shell if [ "xoo" = x$$(echo foo | sed -E 's/f(o)/\1/' 2>/dev/null) ]; \
|
|||||||
PKGCONFIG ?= pkg-config
|
PKGCONFIG ?= pkg-config
|
||||||
GECKO_SDK_PATH := $(shell $(PKGCONFIG) --libs libxul | $(SED) 's,([^-]|-[^L])*-L([^ ]+)/lib.*,\2,')
|
GECKO_SDK_PATH := $(shell $(PKGCONFIG) --libs libxul | $(SED) 's,([^-]|-[^L])*-L([^ ]+)/lib.*,\2,')
|
||||||
|
|
||||||
CXX ?= c++ -o
|
CXX ?= c++
|
||||||
|
CPP = $(CXX) -o
|
||||||
LINK ?= c++
|
LINK ?= c++
|
||||||
|
|
||||||
MKDEP ?= $(CXX) -M
|
MKDEP ?= $(CXX) -M
|
||||||
|
|||||||
@@ -9,6 +9,13 @@
|
|||||||
em:description="Binary utilities for dactyl add-ons"
|
em:description="Binary utilities for dactyl add-ons"
|
||||||
em:unpack="true">
|
em:unpack="true">
|
||||||
|
|
||||||
|
<em:targetApplication>
|
||||||
|
<Description
|
||||||
|
em:id="toolkit@mozilla.org"
|
||||||
|
em:minVersion="4.0"
|
||||||
|
em:maxVersion="9.*"/>
|
||||||
|
</em:targetApplication>
|
||||||
|
|
||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description
|
<Description
|
||||||
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
|
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ $(XPTDIR)%.xpt: %.idl
|
|||||||
_CPPFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(DEFINES)
|
_CPPFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(DEFINES)
|
||||||
|
|
||||||
$(OBJDIR)%.o: %.cpp Makefile
|
$(OBJDIR)%.o: %.cpp Makefile
|
||||||
$(CXX)$@ -c $(_CPPFLAGS) $<
|
$(CPP)$@ -c $(_CPPFLAGS) $<
|
||||||
|
|
||||||
.depend: $(CPPSRCS) Makefile
|
.depend: $(CPPSRCS) Makefile
|
||||||
$(MKDEP) $(_CPPFLAGS) $(CPPSRCS) | $(SED) 's;^[^ ];$(OBJDIR)&;' >.depend
|
$(MKDEP) $(_CPPFLAGS) $(CPPSRCS) | $(SED) 's;^[^ ];$(OBJDIR)&;' >.depend
|
||||||
|
|||||||
@@ -796,7 +796,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (obj instanceof Option) {
|
else if (obj instanceof Option) {
|
||||||
tag = spec = function (name) <>'{name}'</>;
|
spec = function () template.map(obj.names, tag, " ");
|
||||||
|
tag = function (name) <>'{name}'</>;
|
||||||
link = function (opt, name) <o>{name}</o>;
|
link = function (opt, name) <o>{name}</o>;
|
||||||
args = { value: "", values: [] };
|
args = { value: "", values: [] };
|
||||||
}
|
}
|
||||||
@@ -819,9 +820,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
res.* += <>
|
res.* += <>
|
||||||
<item>
|
<item>
|
||||||
<tags>{template.map(obj.names.slice().reverse(), tag, " ")}</tags>
|
<tags>{template.map(obj.names.slice().reverse(), tag, " ")}</tags>
|
||||||
<spec>{(obj instanceof Option)
|
<spec>{let (name = (obj.specs || obj.names)[0])
|
||||||
? template.map(obj.names.slice(), spec, " ")
|
|
||||||
: let (name = (obj.specs || obj.names)[0])
|
|
||||||
spec(template.highlightRegexp(tag(name),
|
spec(template.highlightRegexp(tag(name),
|
||||||
/\[(.*?)\]/g,
|
/\[(.*?)\]/g,
|
||||||
function (m, n0) <oa>{n0}</oa>),
|
function (m, n0) <oa>{n0}</oa>),
|
||||||
|
|||||||
@@ -204,17 +204,33 @@ var Editor = Module("editor", {
|
|||||||
|
|
||||||
if (textBox) {
|
if (textBox) {
|
||||||
var text = textBox.value;
|
var text = textBox.value;
|
||||||
let pre = text.substr(0, textBox.selectionStart);
|
var pre = text.substr(0, textBox.selectionStart);
|
||||||
line = 1 + pre.replace(/[^\n]/g, "").length;
|
|
||||||
column = 1 + pre.replace(/[^]*\n/, "").length;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var editor_ = window.GetCurrentEditor ? GetCurrentEditor()
|
var editor_ = window.GetCurrentEditor ? GetCurrentEditor()
|
||||||
: Editor.getEditor(document.commandDispatcher.focusedWindow);
|
: Editor.getEditor(document.commandDispatcher.focusedWindow);
|
||||||
dactyl.assert(editor_);
|
dactyl.assert(editor_);
|
||||||
text = Array.map(editor_.rootElement.childNodes, function (e) DOM.stringify(e, true)).join("");
|
text = Array.map(editor_.rootElement.childNodes, function (e) DOM.stringify(e, true)).join("");
|
||||||
|
|
||||||
|
util.dump(editor_.selection);
|
||||||
|
|
||||||
|
if (!editor_.selection.rangeCount)
|
||||||
|
var sel = "";
|
||||||
|
else {
|
||||||
|
let range = RangeFind.nodeContents(editor_.rootElement);
|
||||||
|
let end = editor_.selection.getRangeAt(0);
|
||||||
|
range.setEnd(end.startContainer, end.startOffset);
|
||||||
|
pre = DOM.stringify(range, true);
|
||||||
|
if (range.startContainer instanceof Text)
|
||||||
|
pre = pre.replace(/^(?:<[^>"]+>)+/, "");
|
||||||
|
if (range.endContainer instanceof Text)
|
||||||
|
pre = pre.replace(/(?:<\/[^>"]+>)+$/, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line = 1 + pre.replace(/[^\n]/g, "").length;
|
||||||
|
column = 1 + pre.replace(/[^]*\n/, "").length;
|
||||||
|
|
||||||
let origGroup = textBox && textBox.getAttributeNS(NS, "highlight") || "";
|
let origGroup = textBox && textBox.getAttributeNS(NS, "highlight") || "";
|
||||||
let cleanup = util.yieldable(function cleanup(error) {
|
let cleanup = util.yieldable(function cleanup(error) {
|
||||||
if (timer)
|
if (timer)
|
||||||
|
|||||||
Reference in New Issue
Block a user