mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
merge m-c to fx-team
This commit is contained in:
commit
c409d78680
@ -568,6 +568,7 @@ DebuggerUI.prototype = {
|
|||||||
let dbg = this.getDebugger(this.aWindow.gBrowser.selectedTab);
|
let dbg = this.getDebugger(this.aWindow.gBrowser.selectedTab);
|
||||||
dbg.debuggerWindow.SourceScripts.setEditorMode(aSourceUrl, aContentType);
|
dbg.debuggerWindow.SourceScripts.setEditorMode(aSourceUrl, aContentType);
|
||||||
dbg.editor.setText(aSourceText);
|
dbg.editor.setText(aSourceText);
|
||||||
|
dbg.editor.resetUndo();
|
||||||
let doc = dbg.frame.contentDocument;
|
let doc = dbg.frame.contentDocument;
|
||||||
let scripts = doc.getElementById("scripts");
|
let scripts = doc.getElementById("scripts");
|
||||||
let elt = scripts.getElementsByAttribute("value", aSourceUrl)[0];
|
let elt = scripts.getElementsByAttribute("value", aSourceUrl)[0];
|
||||||
|
@ -615,6 +615,7 @@ var SourceScripts = {
|
|||||||
window.editor.setText(aScript.text);
|
window.editor.setText(aScript.text);
|
||||||
window.updateEditorBreakpoints();
|
window.updateEditorBreakpoints();
|
||||||
}
|
}
|
||||||
|
window.editor.resetUndo();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,10 +45,29 @@
|
|||||||
<!ENTITY % debuggerDTD SYSTEM "chrome://browser/locale/devtools/debugger.dtd" >
|
<!ENTITY % debuggerDTD SYSTEM "chrome://browser/locale/devtools/debugger.dtd" >
|
||||||
%debuggerDTD;
|
%debuggerDTD;
|
||||||
]>
|
]>
|
||||||
|
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
|
||||||
|
<?xul-overlay href="chrome://browser/content/source-editor-overlay.xul"?>
|
||||||
<xul:window xmlns="http://www.w3.org/1999/xhtml"
|
<xul:window xmlns="http://www.w3.org/1999/xhtml"
|
||||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
<xul:script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||||
<xul:script type="text/javascript" src="debugger.js"/>
|
<xul:script type="text/javascript" src="debugger.js"/>
|
||||||
<xul:script type="text/javascript" src="debugger-view.js"/>
|
<xul:script type="text/javascript" src="debugger-view.js"/>
|
||||||
|
<xul:popupset id="debugger-popups">
|
||||||
|
<xul:menupopup id="sourceEditorContextMenu"
|
||||||
|
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||||
|
<xul:menuitem id="se-cMenu-copy"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-selectAll"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-find"/>
|
||||||
|
<xul:menuitem id="se-cMenu-findAgain"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-gotoLine"/>
|
||||||
|
</xul:menupopup>
|
||||||
|
</xul:popupset>
|
||||||
|
<xul:commandset id="editMenuCommands"/>
|
||||||
|
<xul:commandset id="sourceEditorCommands"/>
|
||||||
|
<xul:keyset id="sourceEditorKeys"/>
|
||||||
|
|
||||||
<div id="body" class="vbox flex">
|
<div id="body" class="vbox flex">
|
||||||
<xul:toolbar id="dbg-toolbar">
|
<xul:toolbar id="dbg-toolbar">
|
||||||
|
@ -74,6 +74,7 @@ _BROWSER_TEST_FILES = \
|
|||||||
browser_dbg_select-line.js \
|
browser_dbg_select-line.js \
|
||||||
browser_dbg_clean-exit.js \
|
browser_dbg_clean-exit.js \
|
||||||
browser_dbg_bug723069_editor-breakpoints.js \
|
browser_dbg_bug723069_editor-breakpoints.js \
|
||||||
|
browser_dbg_bug731394_editor-contextmenu.js \
|
||||||
head.js \
|
head.js \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bug 731394: test the debugger source editor default context menu.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
|
||||||
|
|
||||||
|
let gPane = null;
|
||||||
|
let gTab = null;
|
||||||
|
let gDebuggee = null;
|
||||||
|
let gDebugger = null;
|
||||||
|
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
let tempScope = {};
|
||||||
|
Cu.import("resource:///modules/source-editor.jsm", tempScope);
|
||||||
|
let SourceEditor = tempScope.SourceEditor;
|
||||||
|
|
||||||
|
let contextMenu = null;
|
||||||
|
|
||||||
|
debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
|
||||||
|
gTab = aTab;
|
||||||
|
gDebuggee = aDebuggee;
|
||||||
|
gPane = aPane;
|
||||||
|
gDebugger = gPane.debuggerWindow;
|
||||||
|
|
||||||
|
gPane.activeThread.addOneTimeListener("scriptsadded", function() {
|
||||||
|
Services.tm.currentThread.dispatch({ run: onScriptsAdded }, 0);
|
||||||
|
});
|
||||||
|
gDebuggee.firstCall();
|
||||||
|
});
|
||||||
|
|
||||||
|
function onScriptsAdded()
|
||||||
|
{
|
||||||
|
let scripts = gDebugger.DebuggerView.Scripts._scripts;
|
||||||
|
|
||||||
|
is(gDebugger.StackFrames.activeThread.state, "paused",
|
||||||
|
"Should only be getting stack frames while paused.");
|
||||||
|
|
||||||
|
is(scripts.itemCount, 2, "Found the expected number of scripts.");
|
||||||
|
|
||||||
|
let editor = gDebugger.editor;
|
||||||
|
|
||||||
|
isnot(editor.getText().indexOf("debugger"), -1,
|
||||||
|
"The correct script was loaded initially.");
|
||||||
|
|
||||||
|
contextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
|
||||||
|
ok(contextMenu, "source editor context menupopup");
|
||||||
|
ok(editor.readOnly, "editor is read only");
|
||||||
|
|
||||||
|
editor.focus();
|
||||||
|
editor.setSelection(0, 10);
|
||||||
|
|
||||||
|
contextMenu.addEventListener("popupshown", function onPopupShown() {
|
||||||
|
contextMenu.removeEventListener("popupshown", onPopupShown, false);
|
||||||
|
executeSoon(testContextMenu);
|
||||||
|
}, false);
|
||||||
|
contextMenu.openPopup(editor.editorElement, "overlap", 0, 0, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testContextMenu()
|
||||||
|
{
|
||||||
|
let document = gDebugger.document;
|
||||||
|
|
||||||
|
ok(document.getElementById("editMenuCommands"),
|
||||||
|
"#editMenuCommands found");
|
||||||
|
ok(!document.getElementById("editMenuKeys"),
|
||||||
|
"#editMenuKeys not found");
|
||||||
|
ok(document.getElementById("sourceEditorCommands"),
|
||||||
|
"#sourceEditorCommands found");
|
||||||
|
ok(document.getElementById("sourceEditorKeys"),
|
||||||
|
"#sourceEditorKeys found");
|
||||||
|
|
||||||
|
// Map command ids to their expected disabled state.
|
||||||
|
let commands = {"se-cmd-undo": true, "se-cmd-redo": true,
|
||||||
|
"se-cmd-cut": true, "se-cmd-paste": true,
|
||||||
|
"se-cmd-delete": true, "cmd_findAgain": true,
|
||||||
|
"cmd_findPrevious": true, "cmd_find": false,
|
||||||
|
"cmd_gotoLine": false, "cmd_copy": false,
|
||||||
|
"se-cmd-selectAll": false};
|
||||||
|
for (let id in commands) {
|
||||||
|
let element = document.getElementById(id);
|
||||||
|
is(element.hasAttribute("disabled"), commands[id],
|
||||||
|
id + " hasAttribute('disabled') check");
|
||||||
|
}
|
||||||
|
|
||||||
|
executeSoon(function() {
|
||||||
|
contextMenu.hidePopup();
|
||||||
|
gDebugger.StackFrames.activeThread.resume(finish);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
removeTab(gTab);
|
||||||
|
gPane = null;
|
||||||
|
gTab = null;
|
||||||
|
gDebuggee = null;
|
||||||
|
gDebugger = null;
|
||||||
|
});
|
||||||
|
}
|
@ -10,7 +10,7 @@ browser.jar:
|
|||||||
content/browser/devtools/cssruleview.xul (styleinspector/cssruleview.xul)
|
content/browser/devtools/cssruleview.xul (styleinspector/cssruleview.xul)
|
||||||
content/browser/devtools/styleinspector.css (styleinspector/styleinspector.css)
|
content/browser/devtools/styleinspector.css (styleinspector/styleinspector.css)
|
||||||
content/browser/orion.js (sourceeditor/orion/orion.js)
|
content/browser/orion.js (sourceeditor/orion/orion.js)
|
||||||
content/browser/source-editor-overlay.xul (sourceeditor/source-editor-overlay.xul)
|
* content/browser/source-editor-overlay.xul (sourceeditor/source-editor-overlay.xul)
|
||||||
* content/browser/debugger.xul (debugger/debugger.xul)
|
* content/browser/debugger.xul (debugger/debugger.xul)
|
||||||
content/browser/debugger.css (debugger/debugger.css)
|
content/browser/debugger.css (debugger/debugger.css)
|
||||||
content/browser/debugger.js (debugger/debugger.js)
|
content/browser/debugger.js (debugger/debugger.js)
|
||||||
|
@ -111,21 +111,6 @@
|
|||||||
modifiers="accel"/>
|
modifiers="accel"/>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<key id="key_cut"
|
|
||||||
key="&cutCmd.key;"
|
|
||||||
modifiers="accel"/>
|
|
||||||
|
|
||||||
<key id="key_copy"
|
|
||||||
key="©Cmd.key;"
|
|
||||||
modifiers="accel"/>
|
|
||||||
<key id="key_paste"
|
|
||||||
key="&pasteCmd.key;"
|
|
||||||
modifiers="accel"/>
|
|
||||||
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>
|
|
||||||
<key id="key_undo" key="&undoCmd.key;" modifiers="accel"
|
|
||||||
command="se-cmd-undo"/>
|
|
||||||
<key id="key_redo" key="&undoCmd.key;" modifiers="accel,shift"
|
|
||||||
command="se-cmd-redo"/>
|
|
||||||
<key id="sp-key-run"
|
<key id="sp-key-run"
|
||||||
key="&run.key;"
|
key="&run.key;"
|
||||||
command="sp-cmd-run"
|
command="sp-cmd-run"
|
||||||
@ -146,28 +131,6 @@
|
|||||||
key="&webConsoleCmd.commandkey;"
|
key="&webConsoleCmd.commandkey;"
|
||||||
command="sp-cmd-webConsole"
|
command="sp-cmd-webConsole"
|
||||||
modifiers="accel,shift"/>
|
modifiers="accel,shift"/>
|
||||||
<key id="key_find"
|
|
||||||
key="&findCmd.key;"
|
|
||||||
command="cmd_find"
|
|
||||||
modifiers="accel"/>
|
|
||||||
#ifdef XP_MACOSX
|
|
||||||
<key id="key_findAgain"
|
|
||||||
key="&findAgainCmd.key;"
|
|
||||||
command="cmd_findAgain"
|
|
||||||
modifiers="accel"/>
|
|
||||||
<key id="key_findPrevious"
|
|
||||||
key="&findPreviousCmd.key;"
|
|
||||||
command="cmd_findPrevious"
|
|
||||||
modifiers="accel,shift"/>
|
|
||||||
#else
|
|
||||||
<key id="key_findAgain"
|
|
||||||
keycode="VK_F3"
|
|
||||||
command="cmd_findAgain"/>
|
|
||||||
<key id="key_findPrevious"
|
|
||||||
keycode="VK_F3"
|
|
||||||
command="cmd_findPrevious"
|
|
||||||
modifiers="shift"/>
|
|
||||||
#endif
|
|
||||||
<key id="key_openHelp"
|
<key id="key_openHelp"
|
||||||
keycode="VK_F1"
|
keycode="VK_F1"
|
||||||
command="sp-cmd-documentationLink"/>
|
command="sp-cmd-documentationLink"/>
|
||||||
@ -219,56 +182,20 @@
|
|||||||
<menu id="sp-edit-menu" label="&editMenu.label;"
|
<menu id="sp-edit-menu" label="&editMenu.label;"
|
||||||
accesskey="&editMenu.accesskey;">
|
accesskey="&editMenu.accesskey;">
|
||||||
<menupopup id="sp-menu_editpopup"
|
<menupopup id="sp-menu_editpopup"
|
||||||
onpopupshowing="goUpdateGlobalEditMenuItems()">
|
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||||
<menuitem id="sp-menu-undo"
|
<menuitem id="se-menu-undo"/>
|
||||||
label="&undoCmd.label;"
|
<menuitem id="se-menu-redo"/>
|
||||||
key="key_undo"
|
|
||||||
accesskey="&undoCmd.accesskey;"
|
|
||||||
command="se-cmd-undo"/>
|
|
||||||
<menuitem id="sp-menu-redo"
|
|
||||||
label="&redoCmd.label;"
|
|
||||||
key="key_redo"
|
|
||||||
accesskey="&redoCmd.accesskey;"
|
|
||||||
command="se-cmd-redo"/>
|
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="sp-menu-cut"
|
<menuitem id="se-menu-cut"/>
|
||||||
label="&cutCmd.label;"
|
<menuitem id="se-menu-copy"/>
|
||||||
key="key_cut"
|
<menuitem id="se-menu-paste"/>
|
||||||
accesskey="&cutCmd.accesskey;"
|
|
||||||
command="cmd_cut"/>
|
|
||||||
<menuitem id="sp-menu-copy"
|
|
||||||
label="©Cmd.label;"
|
|
||||||
key="key_copy"
|
|
||||||
accesskey="©Cmd.accesskey;"
|
|
||||||
command="cmd_copy"/>
|
|
||||||
<menuitem id="sp-menu-paste"
|
|
||||||
label="&pasteCmd.label;"
|
|
||||||
key="key_paste"
|
|
||||||
accesskey="&pasteCmd.accesskey;"
|
|
||||||
command="cmd_paste"/>
|
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="sp-menu-selectAll"
|
<menuitem id="se-menu-selectAll"/>
|
||||||
label="&selectAllCmd.label;"
|
|
||||||
key="key_selectAll"
|
|
||||||
accesskey="&selectAllCmd.accesskey;"
|
|
||||||
command="cmd_selectAll"/>
|
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="sp-menu-find"
|
<menuitem id="se-menu-find"/>
|
||||||
label="&findCmd.label;"
|
<menuitem id="se-menu-findAgain"/>
|
||||||
accesskey="&findCmd.accesskey;"
|
|
||||||
key="key_find"
|
|
||||||
command="cmd_find"/>
|
|
||||||
<menuitem id="sp-menu-findAgain"
|
|
||||||
label="&findAgainCmd.label;"
|
|
||||||
accesskey="&findAgainCmd.accesskey;"
|
|
||||||
key="key_findAgain"
|
|
||||||
command="cmd_findAgain"/>
|
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="sp-menu-gotoLine"
|
<menuitem id="se-menu-gotoLine"/>
|
||||||
label="&gotoLineCmd.label;"
|
|
||||||
accesskey="&gotoLineCmd.accesskey;"
|
|
||||||
key="key_gotoLine"
|
|
||||||
command="cmd_gotoLine"/>
|
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
@ -338,13 +265,13 @@
|
|||||||
|
|
||||||
<popupset id="scratchpad-popups">
|
<popupset id="scratchpad-popups">
|
||||||
<menupopup id="scratchpad-text-popup"
|
<menupopup id="scratchpad-text-popup"
|
||||||
onpopupshowing="goUpdateGlobalEditMenuItems()">
|
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||||
<menuitem id="menu_cut"/>
|
<menuitem id="se-cMenu-cut"/>
|
||||||
<menuitem id="menu_copy"/>
|
<menuitem id="se-cMenu-copy"/>
|
||||||
<menuitem id="menu_paste"/>
|
<menuitem id="se-cMenu-paste"/>
|
||||||
<menuitem id="menu_delete"/>
|
<menuitem id="se-cMenu-delete"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="menu_selectAll"/>
|
<menuitem id="se-cMenu-selectAll"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="sp-text-run"
|
<menuitem id="sp-text-run"
|
||||||
label="&run.label;"
|
label="&run.label;"
|
||||||
@ -370,7 +297,7 @@
|
|||||||
</popupset>
|
</popupset>
|
||||||
|
|
||||||
<notificationbox id="scratchpad-notificationbox" flex="1">
|
<notificationbox id="scratchpad-notificationbox" flex="1">
|
||||||
<hbox id="scratchpad-editor" flex="1" context="scratchpad-text-popup" />
|
<hbox id="scratchpad-editor" flex="1"/>
|
||||||
</notificationbox>
|
</notificationbox>
|
||||||
|
|
||||||
</window>
|
</window>
|
||||||
|
@ -27,7 +27,7 @@ function runTests()
|
|||||||
let doc = gScratchpadWindow.document;
|
let doc = gScratchpadWindow.document;
|
||||||
let winUtils = gScratchpadWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
let winUtils = gScratchpadWindow.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||||
getInterface(Ci.nsIDOMWindowUtils);
|
getInterface(Ci.nsIDOMWindowUtils);
|
||||||
let OS = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
|
let OS = Services.appinfo.OS;
|
||||||
|
|
||||||
info("will test the Edit menu");
|
info("will test the Edit menu");
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ function runTests()
|
|||||||
|
|
||||||
let menuPopup = editMenu.menupopup;
|
let menuPopup = editMenu.menupopup;
|
||||||
ok(menuPopup, "the Edit menupopup");
|
ok(menuPopup, "the Edit menupopup");
|
||||||
let cutItem = doc.getElementById("sp-menu-cut");
|
let cutItem = doc.getElementById("se-menu-cut");
|
||||||
ok(cutItem, "the Cut menuitem");
|
ok(cutItem, "the Cut menuitem");
|
||||||
let pasteItem = doc.getElementById("sp-menu-paste");
|
let pasteItem = doc.getElementById("se-menu-paste");
|
||||||
ok(pasteItem, "the Paste menuitem");
|
ok(pasteItem, "the Paste menuitem");
|
||||||
|
|
||||||
let anchor = doc.documentElement;
|
let anchor = doc.documentElement;
|
||||||
@ -174,9 +174,9 @@ function runTests()
|
|||||||
|
|
||||||
menuPopup = doc.getElementById("scratchpad-text-popup");
|
menuPopup = doc.getElementById("scratchpad-text-popup");
|
||||||
ok(menuPopup, "the context menupopup");
|
ok(menuPopup, "the context menupopup");
|
||||||
cutItem = doc.getElementById("menu_cut");
|
cutItem = doc.getElementById("se-cMenu-cut");
|
||||||
ok(cutItem, "the Cut menuitem");
|
ok(cutItem, "the Cut menuitem");
|
||||||
pasteItem = doc.getElementById("menu_paste");
|
pasteItem = doc.getElementById("se-cMenu-paste");
|
||||||
ok(pasteItem, "the Paste menuitem");
|
ok(pasteItem, "the Paste menuitem");
|
||||||
|
|
||||||
sp.setText("bug 699130: hello world! (context menu)");
|
sp.setText("bug 699130: hello world! (context menu)");
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
* Kenny Heaton <kennyheaton@gmail.com>
|
* Kenny Heaton <kennyheaton@gmail.com>
|
||||||
* Spyros Livathinos <livathinos.spyros@gmail.com>
|
* Spyros Livathinos <livathinos.spyros@gmail.com>
|
||||||
* Allen Eubank <adeubank@gmail.com>
|
* Allen Eubank <adeubank@gmail.com>
|
||||||
|
* Girish Sharma <scrapmachines@gmail.com>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
@ -63,6 +64,14 @@ const ORION_IFRAME = "data:text/html;charset=utf8,<!DOCTYPE html>" +
|
|||||||
|
|
||||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum allowed vertical offset for the line index when you call
|
||||||
|
* SourceEditor.setCaretPosition().
|
||||||
|
*
|
||||||
|
* @type number
|
||||||
|
*/
|
||||||
|
const VERTICAL_OFFSET = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The primary selection update delay. On Linux, the X11 primary selection is
|
* The primary selection update delay. On Linux, the X11 primary selection is
|
||||||
* updated to hold the currently selected text.
|
* updated to hold the currently selected text.
|
||||||
@ -109,6 +118,10 @@ const ORION_ANNOTATION_TYPES = {
|
|||||||
* Default key bindings in the Orion editor.
|
* Default key bindings in the Orion editor.
|
||||||
*/
|
*/
|
||||||
const DEFAULT_KEYBINDINGS = [
|
const DEFAULT_KEYBINDINGS = [
|
||||||
|
{
|
||||||
|
action: "enter",
|
||||||
|
code: Ci.nsIDOMKeyEvent.DOM_VK_ENTER,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
action: "undo",
|
action: "undo",
|
||||||
code: Ci.nsIDOMKeyEvent.DOM_VK_Z,
|
code: Ci.nsIDOMKeyEvent.DOM_VK_Z,
|
||||||
@ -465,6 +478,10 @@ SourceEditor.prototype = {
|
|||||||
*/
|
*/
|
||||||
_doTab: function SE__doTab()
|
_doTab: function SE__doTab()
|
||||||
{
|
{
|
||||||
|
if (this.readOnly) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let indent = "\t";
|
let indent = "\t";
|
||||||
let selection = this.getSelection();
|
let selection = this.getSelection();
|
||||||
let model = this._model;
|
let model = this._model;
|
||||||
@ -515,6 +532,10 @@ SourceEditor.prototype = {
|
|||||||
*/
|
*/
|
||||||
_doUnindentLines: function SE__doUnindentLines()
|
_doUnindentLines: function SE__doUnindentLines()
|
||||||
{
|
{
|
||||||
|
if (this.readOnly) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let indent = "\t";
|
let indent = "\t";
|
||||||
|
|
||||||
let selection = this.getSelection();
|
let selection = this.getSelection();
|
||||||
@ -569,6 +590,10 @@ SourceEditor.prototype = {
|
|||||||
*/
|
*/
|
||||||
_doEnter: function SE__doEnter()
|
_doEnter: function SE__doEnter()
|
||||||
{
|
{
|
||||||
|
if (this.readOnly) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let selection = this.getSelection();
|
let selection = this.getSelection();
|
||||||
if (selection.start != selection.end) {
|
if (selection.start != selection.end) {
|
||||||
return false;
|
return false;
|
||||||
@ -1309,10 +1334,56 @@ SourceEditor.prototype = {
|
|||||||
* The new caret line location. Line numbers start from 0.
|
* The new caret line location. Line numbers start from 0.
|
||||||
* @param number [aColumn=0]
|
* @param number [aColumn=0]
|
||||||
* Optional. The new caret column location. Columns start from 0.
|
* Optional. The new caret column location. Columns start from 0.
|
||||||
|
* @param number [aAlign=0]
|
||||||
|
* Optional. Position of the line with respect to viewport.
|
||||||
|
* Allowed values are:
|
||||||
|
* SourceEditor.VERTICAL_ALIGN.TOP target line at top of view.
|
||||||
|
* SourceEditor.VERTICAL_ALIGN.CENTER target line at center of view.
|
||||||
|
* SourceEditor.VERTICAL_ALIGN.BOTTOM target line at bottom of view.
|
||||||
*/
|
*/
|
||||||
setCaretPosition: function SE_setCaretPosition(aLine, aColumn)
|
setCaretPosition: function SE_setCaretPosition(aLine, aColumn, aAlign)
|
||||||
{
|
{
|
||||||
this.setCaretOffset(this._model.getLineStart(aLine) + (aColumn || 0));
|
let editorHeight = this._view.getClientArea().height;
|
||||||
|
let lineHeight = this._view.getLineHeight();
|
||||||
|
let linesVisible = Math.floor(editorHeight/lineHeight);
|
||||||
|
let halfVisible = Math.round(linesVisible/2);
|
||||||
|
let firstVisible = this.getTopIndex();
|
||||||
|
let lastVisible = this._view.getBottomIndex();
|
||||||
|
let caretOffset = this._model.getLineStart(aLine) + (aColumn || 0);
|
||||||
|
|
||||||
|
this._view.setSelection(caretOffset, caretOffset, false);
|
||||||
|
|
||||||
|
// If the target line is in view, skip the vertical alignment part.
|
||||||
|
if (aLine <= lastVisible && aLine >= firstVisible) {
|
||||||
|
this._view.showSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting the offset so that the line always falls in the upper half
|
||||||
|
// of visible lines (lower half for BOTTOM aligned).
|
||||||
|
// VERTICAL_OFFSET is the maximum allowed value.
|
||||||
|
let offset = Math.min(halfVisible, VERTICAL_OFFSET);
|
||||||
|
|
||||||
|
let topIndex;
|
||||||
|
switch (aAlign) {
|
||||||
|
case this.VERTICAL_ALIGN.CENTER:
|
||||||
|
topIndex = Math.max(aLine - halfVisible, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case this.VERTICAL_ALIGN.BOTTOM:
|
||||||
|
topIndex = Math.max(aLine - linesVisible + offset, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // this.VERTICAL_ALIGN.TOP.
|
||||||
|
topIndex = Math.max(aLine - offset, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Bringing down the topIndex to total lines in the editor if exceeding.
|
||||||
|
topIndex = Math.min(topIndex, this.getLineCount());
|
||||||
|
this.setTopIndex(topIndex);
|
||||||
|
|
||||||
|
let location = this._view.getLocationAtOffset(caretOffset);
|
||||||
|
this._view.setHorizontalPixel(location.x);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,80 +35,203 @@
|
|||||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
-
|
-
|
||||||
- ***** END LICENSE BLOCK ***** -->
|
- ***** END LICENSE BLOCK ***** -->
|
||||||
<!DOCTYPE overlay SYSTEM "chrome://browser/locale/devtools/sourceeditor.dtd">
|
<!DOCTYPE overlay [
|
||||||
|
<!ENTITY % editMenuStrings SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
|
||||||
|
%editMenuStrings;
|
||||||
|
<!ENTITY % sourceEditorStrings SYSTEM "chrome://browser/locale/devtools/sourceeditor.dtd">
|
||||||
|
%sourceEditorStrings;
|
||||||
|
]>
|
||||||
<overlay id="sourceEditorOverlay"
|
<overlay id="sourceEditorOverlay"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
|
||||||
<!-- This Source Editor overlay requires the editMenuOverlay.xul to be loaded.
|
<!-- This Source Editor overlay requires the editMenuOverlay.xul to be loaded.
|
||||||
The globalOverlay.js script is also required in the XUL document where
|
The globalOverlay.js script is also required in the XUL document where
|
||||||
the source-editor-overlay.xul is loaded. -->
|
the source-editor-overlay.xul is loaded. Do not use #editMenuKeys to
|
||||||
|
avoid conflicts! -->
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
function goUpdateSourceEditorMenuItems()
|
||||||
|
{
|
||||||
|
goUpdateGlobalEditMenuItems();
|
||||||
|
let commands = ['se-cmd-undo', 'se-cmd-redo', 'se-cmd-cut', 'se-cmd-paste',
|
||||||
|
'se-cmd-delete'];
|
||||||
|
commands.forEach(goUpdateCommand);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<commandset id="sourceEditorCommands">
|
<commandset id="sourceEditorCommands">
|
||||||
<command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
|
<command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
|
||||||
<command id="cmd_findAgain" oncommand="goDoCommand('cmd_findAgain')" disabled="true"/>
|
<command id="cmd_findAgain" oncommand="goDoCommand('cmd_findAgain')" disabled="true"/>
|
||||||
<command id="cmd_findPrevious" oncommand="goDoCommand('cmd_findPrevious')" disabled="true"/>
|
<command id="cmd_findPrevious" oncommand="goDoCommand('cmd_findPrevious')" disabled="true"/>
|
||||||
<command id="cmd_gotoLine" oncommand="goDoCommand('cmd_gotoLine')"/>
|
<command id="cmd_gotoLine" oncommand="goDoCommand('cmd_gotoLine')"/>
|
||||||
|
<command id="se-cmd-selectAll" oncommand="goDoCommand('se-cmd-selectAll')"/>
|
||||||
|
<command id="se-cmd-cut" oncommand="goDoCommand('se-cmd-cut')" disabled="true"/>
|
||||||
|
<command id="se-cmd-paste" oncommand="goDoCommand('se-cmd-paste')" disabled="true"/>
|
||||||
|
<command id="se-cmd-delete" oncommand="goDoCommand('se-cmd-delete')" disabled="true"/>
|
||||||
<command id="se-cmd-undo" oncommand="goDoCommand('se-cmd-undo')" disabled="true"/>
|
<command id="se-cmd-undo" oncommand="goDoCommand('se-cmd-undo')" disabled="true"/>
|
||||||
<command id="se-cmd-redo" oncommand="goDoCommand('se-cmd-redo')" disabled="true"/>
|
<command id="se-cmd-redo" oncommand="goDoCommand('se-cmd-redo')" disabled="true"/>
|
||||||
</commandset>
|
</commandset>
|
||||||
|
|
||||||
<keyset id="sourceEditorKeys">
|
<keyset id="sourceEditorKeys">
|
||||||
|
<!-- Do not use both #sourceEditorKeys and #editMenuKeys in the same
|
||||||
|
document to avoid conflicts! -->
|
||||||
|
<key id="key_undo"
|
||||||
|
key="&undoCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="se-cmd-undo"/>
|
||||||
|
#ifdef XP_UNIX
|
||||||
|
<key id="key_redo"
|
||||||
|
key="&undoCmd.key;"
|
||||||
|
modifiers="accel,shift"
|
||||||
|
command="se-cmd-redo"/>
|
||||||
|
#else
|
||||||
|
<key id="key_redo"
|
||||||
|
key="&redoCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="se-cmd-redo"/>
|
||||||
|
#endif
|
||||||
|
<key id="key_cut"
|
||||||
|
key="&cutCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="se-cmd-cut"/>
|
||||||
|
<key id="key_copy"
|
||||||
|
key="©Cmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="cmd_copy"/>
|
||||||
|
<key id="key_paste"
|
||||||
|
key="&pasteCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="se-cmd-paste"/>
|
||||||
<key id="key_gotoLine"
|
<key id="key_gotoLine"
|
||||||
key="&gotoLineCmd.key;"
|
key="&gotoLineCmd.key;"
|
||||||
command="cmd_gotoLine"
|
command="cmd_gotoLine"
|
||||||
modifiers="accel"/>
|
modifiers="accel"/>
|
||||||
|
<key id="key_delete"
|
||||||
|
keycode="VK_DELETE"
|
||||||
|
command="se-cmd-delete"/>
|
||||||
|
<key id="key_selectAll"
|
||||||
|
key="&selectAllCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="se-cmd-selectAll"/>
|
||||||
|
<key id="key_find"
|
||||||
|
key="&findCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="cmd_find"/>
|
||||||
|
<key id="key_findAgain"
|
||||||
|
key="&findAgainCmd.key;"
|
||||||
|
modifiers="accel"
|
||||||
|
command="cmd_findAgain"/>
|
||||||
|
<key id="key_findPrevious"
|
||||||
|
key="&findAgainCmd.key;"
|
||||||
|
modifiers="shift,accel"
|
||||||
|
command="cmd_findPrevious"/>
|
||||||
|
<key id="key_findAgain2"
|
||||||
|
keycode="&findAgainCmd.key2;"
|
||||||
|
command="cmd_findAgain"/>
|
||||||
|
<key id="key_findPrevious2"
|
||||||
|
keycode="&findAgainCmd.key2;"
|
||||||
|
modifiers="shift"
|
||||||
|
command="cmd_findPrevious"/>
|
||||||
</keyset>
|
</keyset>
|
||||||
|
|
||||||
<menupopup id="sourceEditorContextMenu"
|
<!-- Items for the Edit menu -->
|
||||||
onpopupshowing="goUpdateGlobalEditMenuItems()">
|
|
||||||
<menuitem id="se-menu-undo"
|
<menuitem id="se-menu-undo"
|
||||||
label="&undoCmd.label;"
|
label="&undoCmd.label;"
|
||||||
key="key_undo"
|
key="key_undo"
|
||||||
accesskey="&undoCmd.accesskey;"
|
accesskey="&undoCmd.accesskey;"
|
||||||
command="se-cmd-undo"/>
|
command="se-cmd-undo"/>
|
||||||
<menuseparator/>
|
<menuitem id="se-menu-redo"
|
||||||
<menuitem id="se-menu-cut"
|
label="&redoCmd.label;"
|
||||||
label="&cutCmd.label;"
|
key="key_redo"
|
||||||
key="key_cut"
|
accesskey="&redoCmd.accesskey;"
|
||||||
accesskey="&cutCmd.accesskey;"
|
command="se-cmd-redo"/>
|
||||||
command="cmd_cut"/>
|
<menuitem id="se-menu-cut"
|
||||||
<menuitem id="se-menu-copy"
|
label="&cutCmd.label;"
|
||||||
label="©Cmd.label;"
|
key="key_cut"
|
||||||
key="key_copy"
|
accesskey="&cutCmd.accesskey;"
|
||||||
accesskey="©Cmd.accesskey;"
|
command="se-cmd-cut"/>
|
||||||
command="cmd_copy"/>
|
<menuitem id="se-menu-copy"
|
||||||
<menuitem id="se-menu-paste"
|
label="©Cmd.label;"
|
||||||
label="&pasteCmd.label;"
|
key="key_copy"
|
||||||
key="key_paste"
|
accesskey="©Cmd.accesskey;"
|
||||||
accesskey="&pasteCmd.accesskey;"
|
command="cmd_copy"/>
|
||||||
command="cmd_paste"/>
|
<menuitem id="se-menu-paste"
|
||||||
<menuitem id="se-menu-delete"
|
label="&pasteCmd.label;"
|
||||||
label="&deleteCmd.label;"
|
key="key_paste"
|
||||||
key="key_delete"
|
accesskey="&pasteCmd.accesskey;"
|
||||||
accesskey="&deleteCmd.accesskey;"
|
command="se-cmd-paste"/>
|
||||||
command="cmd_delete"/>
|
<menuitem id="se-menu-delete"
|
||||||
<menuseparator/>
|
label="&deleteCmd.label;"
|
||||||
<menuitem id="se-menu-selectAll"
|
key="key_delete"
|
||||||
label="&selectAllCmd.label;"
|
accesskey="&deleteCmd.accesskey;"
|
||||||
key="key_selectAll"
|
command="se-cmd-delete"/>
|
||||||
accesskey="&selectAllCmd.accesskey;"
|
<menuitem id="se-menu-selectAll"
|
||||||
command="cmd_selectAll"/>
|
label="&selectAllCmd.label;"
|
||||||
<menuseparator/>
|
key="key_selectAll"
|
||||||
<menuitem id="se-menu-find"
|
accesskey="&selectAllCmd.accesskey;"
|
||||||
label="&findCmd.label;"
|
command="se-cmd-selectAll"/>
|
||||||
accesskey="&findCmd.accesskey;"
|
<menuitem id="se-menu-find"
|
||||||
key="key_find"
|
label="&findCmd.label;"
|
||||||
command="cmd_find"/>
|
accesskey="&findCmd.accesskey;"
|
||||||
<menuitem id="se-menu-findAgain"
|
key="key_find"
|
||||||
label="&findAgainCmd.label;"
|
command="cmd_find"/>
|
||||||
accesskey="&findAgainCmd.accesskey;"
|
<menuitem id="se-menu-findAgain"
|
||||||
key="key_findAgain"
|
label="&findAgainCmd.label;"
|
||||||
command="cmd_findAgain"/>
|
accesskey="&findAgainCmd.accesskey;"
|
||||||
<menuseparator/>
|
key="key_findAgain"
|
||||||
<menuitem id="se-menu-gotoLine"
|
command="cmd_findAgain"/>
|
||||||
label="&gotoLineCmd.label;"
|
<menuitem id="se-menu-gotoLine"
|
||||||
accesskey="&gotoLineCmd.accesskey;"
|
label="&gotoLineCmd.label;"
|
||||||
key="key_gotoLine"
|
accesskey="&gotoLineCmd.accesskey;"
|
||||||
command="cmd_gotoLine"/>
|
key="key_gotoLine"
|
||||||
</menupopup>
|
command="cmd_gotoLine"/>
|
||||||
|
|
||||||
|
<!-- Items for context menus -->
|
||||||
|
|
||||||
|
<menuitem id="se-cMenu-undo"
|
||||||
|
label="&undoCmd.label;"
|
||||||
|
key="key_undo"
|
||||||
|
accesskey="&undoCmd.accesskey;"
|
||||||
|
command="se-cmd-undo"/>
|
||||||
|
<menuitem id="se-cMenu-cut"
|
||||||
|
label="&cutCmd.label;"
|
||||||
|
key="key_cut"
|
||||||
|
accesskey="&cutCmd.accesskey;"
|
||||||
|
command="se-cmd-cut"/>
|
||||||
|
<menuitem id="se-cMenu-copy"
|
||||||
|
label="©Cmd.label;"
|
||||||
|
key="key_copy"
|
||||||
|
accesskey="©Cmd.accesskey;"
|
||||||
|
command="cmd_copy"/>
|
||||||
|
<menuitem id="se-cMenu-paste"
|
||||||
|
label="&pasteCmd.label;"
|
||||||
|
key="key_paste"
|
||||||
|
accesskey="&pasteCmd.accesskey;"
|
||||||
|
command="se-cmd-paste"/>
|
||||||
|
<menuitem id="se-cMenu-delete"
|
||||||
|
label="&deleteCmd.label;"
|
||||||
|
key="key_delete"
|
||||||
|
accesskey="&deleteCmd.accesskey;"
|
||||||
|
command="se-cmd-delete"/>
|
||||||
|
<menuitem id="se-cMenu-selectAll"
|
||||||
|
label="&selectAllCmd.label;"
|
||||||
|
key="key_selectAll"
|
||||||
|
accesskey="&selectAllCmd.accesskey;"
|
||||||
|
command="se-cmd-selectAll"/>
|
||||||
|
<menuitem id="se-cMenu-find"
|
||||||
|
label="&findCmd.label;"
|
||||||
|
accesskey="&findCmd.accesskey;"
|
||||||
|
key="key_find"
|
||||||
|
command="cmd_find"/>
|
||||||
|
<menuitem id="se-cMenu-findAgain"
|
||||||
|
label="&findAgainCmd.label;"
|
||||||
|
accesskey="&findAgainCmd.accesskey;"
|
||||||
|
key="key_findAgain"
|
||||||
|
command="cmd_findAgain"/>
|
||||||
|
<menuitem id="se-cMenu-gotoLine"
|
||||||
|
label="&gotoLineCmd.label;"
|
||||||
|
accesskey="&gotoLineCmd.accesskey;"
|
||||||
|
key="key_gotoLine"
|
||||||
|
command="cmd_gotoLine"/>
|
||||||
</overlay>
|
</overlay>
|
||||||
|
@ -253,6 +253,10 @@ SourceEditorController.prototype = {
|
|||||||
case "cmd_gotoLine":
|
case "cmd_gotoLine":
|
||||||
case "se-cmd-undo":
|
case "se-cmd-undo":
|
||||||
case "se-cmd-redo":
|
case "se-cmd-redo":
|
||||||
|
case "se-cmd-cut":
|
||||||
|
case "se-cmd-paste":
|
||||||
|
case "se-cmd-delete":
|
||||||
|
case "se-cmd-selectAll":
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -278,6 +282,7 @@ SourceEditorController.prototype = {
|
|||||||
switch (aCommand) {
|
switch (aCommand) {
|
||||||
case "cmd_find":
|
case "cmd_find":
|
||||||
case "cmd_gotoLine":
|
case "cmd_gotoLine":
|
||||||
|
case "se-cmd-selectAll":
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
case "cmd_findAgain":
|
case "cmd_findAgain":
|
||||||
@ -290,6 +295,19 @@ SourceEditorController.prototype = {
|
|||||||
case "se-cmd-redo":
|
case "se-cmd-redo":
|
||||||
result = this._editor.canRedo();
|
result = this._editor.canRedo();
|
||||||
break;
|
break;
|
||||||
|
case "se-cmd-cut":
|
||||||
|
case "se-cmd-delete": {
|
||||||
|
let selection = this._editor.getSelection();
|
||||||
|
result = selection.start != selection.end && !this._editor.readOnly;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "se-cmd-paste": {
|
||||||
|
let window = this._editor._view._frameWindow;
|
||||||
|
let controller = window.controllers.getControllerForCommand("cmd_paste");
|
||||||
|
result = !this._editor.readOnly &&
|
||||||
|
controller.isCommandEnabled("cmd_paste");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
@ -320,12 +338,26 @@ SourceEditorController.prototype = {
|
|||||||
case "cmd_gotoLine":
|
case "cmd_gotoLine":
|
||||||
this._editor.ui.gotoLine();
|
this._editor.ui.gotoLine();
|
||||||
break;
|
break;
|
||||||
|
case "se-cmd-selectAll":
|
||||||
|
this._editor._view.invokeAction("selectAll");
|
||||||
|
break;
|
||||||
case "se-cmd-undo":
|
case "se-cmd-undo":
|
||||||
this._editor.undo();
|
this._editor.undo();
|
||||||
break;
|
break;
|
||||||
case "se-cmd-redo":
|
case "se-cmd-redo":
|
||||||
this._editor.redo();
|
this._editor.redo();
|
||||||
break;
|
break;
|
||||||
|
case "se-cmd-cut":
|
||||||
|
this._editor.ui._ownerWindow.goDoCommand("cmd_cut");
|
||||||
|
break;
|
||||||
|
case "se-cmd-paste":
|
||||||
|
this._editor.ui._ownerWindow.goDoCommand("cmd_paste");
|
||||||
|
break;
|
||||||
|
case "se-cmd-delete": {
|
||||||
|
let selection = this._editor.getSelection();
|
||||||
|
this._editor.setText("", selection.start, selection.end);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -312,6 +312,16 @@ SourceEditor.EVENTS = {
|
|||||||
DIRTY_CHANGED: "DirtyChanged",
|
DIRTY_CHANGED: "DirtyChanged",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allowed vertical alignment options for the line index
|
||||||
|
* when you call SourceEditor.setCaretPosition().
|
||||||
|
*/
|
||||||
|
SourceEditor.VERTICAL_ALIGN = {
|
||||||
|
TOP: 0,
|
||||||
|
CENTER: 1,
|
||||||
|
BOTTOM: 2,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend a destination object with properties from a source object.
|
* Extend a destination object with properties from a source object.
|
||||||
*
|
*
|
||||||
@ -336,6 +346,7 @@ extend(SourceEditor.prototype, {
|
|||||||
MODES: SourceEditor.MODES,
|
MODES: SourceEditor.MODES,
|
||||||
THEMES: SourceEditor.THEMES,
|
THEMES: SourceEditor.THEMES,
|
||||||
DEFAULTS: SourceEditor.DEFAULTS,
|
DEFAULTS: SourceEditor.DEFAULTS,
|
||||||
|
VERTICAL_ALIGN: SourceEditor.VERTICAL_ALIGN,
|
||||||
|
|
||||||
_lastFind: null,
|
_lastFind: null,
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ _BROWSER_TEST_FILES = \
|
|||||||
browser_bug712982_line_ruler_click.js \
|
browser_bug712982_line_ruler_click.js \
|
||||||
browser_bug725618_moveLines_shortcut.js \
|
browser_bug725618_moveLines_shortcut.js \
|
||||||
browser_bug700893_dirty_state.js \
|
browser_bug700893_dirty_state.js \
|
||||||
|
browser_bug729480_line_vertical_align.js \
|
||||||
head.js \
|
head.js \
|
||||||
|
|
||||||
libs:: $(_BROWSER_TEST_FILES)
|
libs:: $(_BROWSER_TEST_FILES)
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
/* vim: set ts=2 et sw=2 tw=80: */
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
let tempScope = {};
|
||||||
|
Cu.import("resource:///modules/source-editor.jsm", tempScope);
|
||||||
|
let SourceEditor = tempScope.SourceEditor;
|
||||||
|
|
||||||
|
let testWin;
|
||||||
|
let editor;
|
||||||
|
const VERTICAL_OFFSET = 3;
|
||||||
|
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
const windowUrl = "data:application/vnd.mozilla.xul+xml,<?xml version='1.0'?>" +
|
||||||
|
"<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
|
||||||
|
" title='test for bug 729480 - allow setCaretPosition align the target line" +
|
||||||
|
" vertically in view according to a third argument'" +
|
||||||
|
" width='300' height='300'><box flex='1'/></window>";
|
||||||
|
const windowFeatures = "chrome,titlebar,toolbar,centerscreen,dialog=no";
|
||||||
|
|
||||||
|
testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
|
||||||
|
testWin.addEventListener("load", function onWindowLoad() {
|
||||||
|
testWin.removeEventListener("load", onWindowLoad, false);
|
||||||
|
waitForFocus(initEditor, testWin);
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initEditor()
|
||||||
|
{
|
||||||
|
let box = testWin.document.querySelector("box");
|
||||||
|
|
||||||
|
editor = new SourceEditor();
|
||||||
|
editor.init(box, {showLineNumbers: true}, editorLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
function editorLoaded()
|
||||||
|
{
|
||||||
|
editor.focus();
|
||||||
|
|
||||||
|
// setting 3 pages of lines containing the line number.
|
||||||
|
let view = editor._view;
|
||||||
|
|
||||||
|
let lineHeight = view.getLineHeight();
|
||||||
|
let editorHeight = view.getClientArea().height;
|
||||||
|
let linesPerPage = Math.floor(editorHeight / lineHeight);
|
||||||
|
let totalLines = 3 * linesPerPage;
|
||||||
|
|
||||||
|
let text = "";
|
||||||
|
for (let i = 0; i < totalLines; i++) {
|
||||||
|
text += "Line " + i + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.setText(text);
|
||||||
|
editor.setCaretOffset(0);
|
||||||
|
|
||||||
|
let offset = Math.min(Math.round(linesPerPage/2), VERTICAL_OFFSET);
|
||||||
|
// Building the iterator array.
|
||||||
|
// [line, alignment, topIndex_check]
|
||||||
|
let iterateOn = [
|
||||||
|
[0, "TOP", 0],
|
||||||
|
[25, "TOP", 25 - offset],
|
||||||
|
// Case when the target line is already in view.
|
||||||
|
[27, "TOP", 25 - offset],
|
||||||
|
[0, "BOTTOM", 0],
|
||||||
|
[5, "BOTTOM", 0],
|
||||||
|
[38, "BOTTOM", 38 - linesPerPage + offset],
|
||||||
|
[0, "CENTER", 0],
|
||||||
|
[4, "CENTER", 0],
|
||||||
|
[34, "CENTER", 34 - Math.round(linesPerPage/2)]
|
||||||
|
];
|
||||||
|
|
||||||
|
function testEnd() {
|
||||||
|
editor.destroy();
|
||||||
|
testWin.close();
|
||||||
|
testWin = editor = null;
|
||||||
|
waitForFocus(finish, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testPosition(pos) {
|
||||||
|
is(editor.getTopIndex(), iterateOn[pos][2], "scroll is correct for test #" + pos);
|
||||||
|
iterator(++pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
function iterator(i) {
|
||||||
|
if (i == iterateOn.length) {
|
||||||
|
testEnd();
|
||||||
|
} else {
|
||||||
|
editor.setCaretPosition(iterateOn[i][0], 0,
|
||||||
|
editor.VERTICAL_ALIGN[iterateOn[i][1]]);
|
||||||
|
executeSoon(testPosition.bind(this, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iterator(0);
|
||||||
|
}
|
@ -201,11 +201,21 @@ function editorLoaded()
|
|||||||
editor.setText("foobar");
|
editor.setText("foobar");
|
||||||
is(editor.getText(), "foobar", "editor allows programmatic changes (setText)");
|
is(editor.getText(), "foobar", "editor allows programmatic changes (setText)");
|
||||||
|
|
||||||
|
EventUtils.synthesizeKey("VK_RETURN", {}, testWin);
|
||||||
|
is(editor.getText(), "foobar", "Enter key does nothing");
|
||||||
|
|
||||||
|
EventUtils.synthesizeKey("VK_TAB", {}, testWin);
|
||||||
|
is(editor.getText(), "foobar", "Tab does nothing");
|
||||||
|
|
||||||
|
editor.setText(" foobar");
|
||||||
|
EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}, testWin);
|
||||||
|
is(editor.getText(), " foobar", "Shift+Tab does nothing");
|
||||||
|
|
||||||
editor.readOnly = false;
|
editor.readOnly = false;
|
||||||
|
|
||||||
editor.setCaretOffset(editor.getCharCount());
|
editor.setCaretOffset(editor.getCharCount());
|
||||||
EventUtils.synthesizeKey("-", {}, testWin);
|
EventUtils.synthesizeKey("-", {}, testWin);
|
||||||
is(editor.getText(), "foobar-", "editor is now editable again");
|
is(editor.getText(), " foobar-", "editor is now editable again");
|
||||||
|
|
||||||
// Test the Selection event.
|
// Test the Selection event.
|
||||||
|
|
||||||
|
@ -57,7 +57,22 @@
|
|||||||
<xul:script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
<xul:script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||||
|
|
||||||
<xul:popupset id="style-editor-popups">
|
<xul:popupset id="style-editor-popups">
|
||||||
<xul:menupopup id="sourceEditorContextMenu"/>
|
<xul:menupopup id="sourceEditorContextMenu"
|
||||||
|
onpopupshowing="goUpdateSourceEditorMenuItems()">
|
||||||
|
<xul:menuitem id="se-cMenu-undo"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-cut"/>
|
||||||
|
<xul:menuitem id="se-cMenu-copy"/>
|
||||||
|
<xul:menuitem id="se-cMenu-paste"/>
|
||||||
|
<xul:menuitem id="se-cMenu-delete"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-selectAll"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-find"/>
|
||||||
|
<xul:menuitem id="se-cMenu-findAgain"/>
|
||||||
|
<xul:menuseparator/>
|
||||||
|
<xul:menuitem id="se-cMenu-gotoLine"/>
|
||||||
|
</xul:menupopup>
|
||||||
</xul:popupset>
|
</xul:popupset>
|
||||||
|
|
||||||
<xul:commandset id="editMenuCommands"/>
|
<xul:commandset id="editMenuCommands"/>
|
||||||
@ -66,7 +81,6 @@
|
|||||||
<xul:command id="style-editor-cmd-close" oncommand="window.close();"/>
|
<xul:command id="style-editor-cmd-close" oncommand="window.close();"/>
|
||||||
</xul:commandset>
|
</xul:commandset>
|
||||||
|
|
||||||
<xul:keyset id="editMenuKeys"/>
|
|
||||||
<xul:keyset id="sourceEditorKeys"/>
|
<xul:keyset id="sourceEditorKeys"/>
|
||||||
<xul:keyset id="style-editor-keyset">
|
<xul:keyset id="style-editor-keyset">
|
||||||
<xul:key id="style-editor-key-close"
|
<xul:key id="style-editor-key-close"
|
||||||
|
@ -43,50 +43,6 @@
|
|||||||
<!ENTITY editMenu.label "Edit">
|
<!ENTITY editMenu.label "Edit">
|
||||||
<!ENTITY editMenu.accesskey "E">
|
<!ENTITY editMenu.accesskey "E">
|
||||||
|
|
||||||
<!ENTITY undoCmd.label "Undo">
|
|
||||||
<!ENTITY undoCmd.key "Z">
|
|
||||||
<!ENTITY undoCmd.accesskey "U">
|
|
||||||
|
|
||||||
<!ENTITY redoCmd.label "Redo">
|
|
||||||
<!ENTITY redoCmd.key "Y">
|
|
||||||
<!ENTITY redoCmd.accesskey "R">
|
|
||||||
|
|
||||||
<!ENTITY cutCmd.label "Cut">
|
|
||||||
<!ENTITY cutCmd.key "X">
|
|
||||||
<!ENTITY cutCmd.accesskey "t">
|
|
||||||
|
|
||||||
<!ENTITY copyCmd.label "Copy">
|
|
||||||
<!ENTITY copyCmd.key "C">
|
|
||||||
<!ENTITY copyCmd.accesskey "C">
|
|
||||||
|
|
||||||
<!ENTITY pasteCmd.label "Paste">
|
|
||||||
<!ENTITY pasteCmd.key "V">
|
|
||||||
<!ENTITY pasteCmd.accesskey "P">
|
|
||||||
|
|
||||||
<!ENTITY selectAllCmd.label "Select All">
|
|
||||||
<!ENTITY selectAllCmd.key "A">
|
|
||||||
<!ENTITY selectAllCmd.accesskey "A">
|
|
||||||
|
|
||||||
<!ENTITY findCmd.label "Find…">
|
|
||||||
<!ENTITY findCmd.key "F">
|
|
||||||
<!ENTITY findCmd.accesskey "F">
|
|
||||||
|
|
||||||
<!ENTITY findAgainCmd.label "Find Again…">
|
|
||||||
<!-- LOCALIZATION NOTE (findAgainCmd.key): This key is used only on Macs.
|
|
||||||
- Windows and Linux builds use the F3 key which is not localizable on purpose.
|
|
||||||
-->
|
|
||||||
<!ENTITY findAgainCmd.key "G">
|
|
||||||
<!ENTITY findAgainCmd.accesskey "g">
|
|
||||||
<!-- LOCALIZATION NOTE (findPreviousCmd.key): This key is used only on Macs.
|
|
||||||
- Windows and Linux builds use the Shift-F3 key which is not localizable on
|
|
||||||
- purpose.
|
|
||||||
-->
|
|
||||||
<!ENTITY findPreviousCmd.key "G">
|
|
||||||
|
|
||||||
<!ENTITY gotoLineCmd.label "Jump to line…">
|
|
||||||
<!ENTITY gotoLineCmd.key "J">
|
|
||||||
<!ENTITY gotoLineCmd.accesskey "J">
|
|
||||||
|
|
||||||
<!ENTITY run.label "Run">
|
<!ENTITY run.label "Run">
|
||||||
<!ENTITY run.accesskey "R">
|
<!ENTITY run.accesskey "R">
|
||||||
<!ENTITY run.key "r">
|
<!ENTITY run.key "r">
|
||||||
|
@ -10,23 +10,6 @@
|
|||||||
- A good criteria is the language in which you'd find the best
|
- A good criteria is the language in which you'd find the best
|
||||||
- documentation on web development on the web. -->
|
- documentation on web development on the web. -->
|
||||||
|
|
||||||
<!ENTITY undoCmd.label "Undo">
|
|
||||||
<!ENTITY undoCmd.accesskey "U">
|
|
||||||
<!ENTITY cutCmd.label "Cut">
|
|
||||||
<!ENTITY cutCmd.accesskey "t">
|
|
||||||
<!ENTITY copyCmd.label "Copy">
|
|
||||||
<!ENTITY copyCmd.accesskey "C">
|
|
||||||
<!ENTITY pasteCmd.label "Paste">
|
|
||||||
<!ENTITY pasteCmd.accesskey "P">
|
|
||||||
<!ENTITY deleteCmd.label "Delete">
|
|
||||||
<!ENTITY deleteCmd.accesskey "D">
|
|
||||||
<!ENTITY selectAllCmd.label "Select All">
|
|
||||||
<!ENTITY selectAllCmd.accesskey "A">
|
|
||||||
<!ENTITY findCmd.label "Find…">
|
|
||||||
<!ENTITY findCmd.accesskey "F">
|
|
||||||
<!ENTITY findAgainCmd.label "Find Again…">
|
|
||||||
<!ENTITY findAgainCmd.accesskey "g">
|
|
||||||
<!ENTITY gotoLineCmd.label "Jump to line…">
|
<!ENTITY gotoLineCmd.label "Jump to line…">
|
||||||
<!ENTITY gotoLineCmd.key "J">
|
<!ENTITY gotoLineCmd.key "J">
|
||||||
<!ENTITY gotoLineCmd.accesskey "J">
|
<!ENTITY gotoLineCmd.accesskey "J">
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@
|
|||||||
|
|
||||||
.ruleview-rule-source {
|
.ruleview-rule-source {
|
||||||
background-color: -moz-dialog;
|
background-color: -moz-dialog;
|
||||||
color: #0091ff;
|
color: -moz-dialogText;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@
|
|||||||
|
|
||||||
.ruleview-rule-source {
|
.ruleview-rule-source {
|
||||||
background-color: -moz-dialog;
|
background-color: -moz-dialog;
|
||||||
color: #0091ff;
|
color: -moz-dialogText;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@
|
|||||||
|
|
||||||
.ruleview-rule-source {
|
.ruleview-rule-source {
|
||||||
background-color: -moz-dialog;
|
background-color: -moz-dialog;
|
||||||
color: #0091ff;
|
color: -moz-dialogText;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user