diff --git a/mozilla/extensions/venkman/resources/content/file-utils.js b/mozilla/extensions/venkman/resources/content/file-utils.js index ea70d4a6c58..86d9c7f5df4 100644 --- a/mozilla/extensions/venkman/resources/content/file-utils.js +++ b/mozilla/extensions/venkman/resources/content/file-utils.js @@ -220,7 +220,25 @@ function LocalFile(file, mode, perms, tmp) if (typeof perms == "undefined") perms = 0666 & ~futils.umask; - + + if (typeof mode == "string") + { + switch (mode) + { + case ">": + mode = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE; + break; + case ">>": + mode = MODE_WRONLY | MODE_CREATE | MODE_APPEND; + break; + case "<": + mode = MODE_RDONLY; + break; + default: + throw "Invalid mode ``" + mode + "''"; + } + } + if (typeof file == "string") { this.localFile = classes[LOCALFILE_CTRID].createInstance(nsILocalFile); diff --git a/mozilla/extensions/venkman/resources/content/pref-manager.js b/mozilla/extensions/venkman/resources/content/pref-manager.js index 4f2008b2922..26b351afb9b 100644 --- a/mozilla/extensions/venkman/resources/content/pref-manager.js +++ b/mozilla/extensions/venkman/resources/content/pref-manager.js @@ -203,12 +203,11 @@ function pm_addpref (prefName, defaultValue) } return value; - } + }; + + if (!arrayContains(prefManager.prefNames, prefName)) + prefManager.prefNames.push(prefName); - if (prefName in prefManager) - return; - - prefManager.prefNames.push(prefName); prefManager.prefNames.sort(); prefManager.prefs.__defineGetter__(prefName, prefGetter); prefManager.prefs.__defineSetter__(prefName, prefSetter); diff --git a/mozilla/extensions/venkman/resources/content/tree-utils.js b/mozilla/extensions/venkman/resources/content/tree-utils.js index 3e981c1dfec..7e1a919840b 100644 --- a/mozilla/extensions/venkman/resources/content/tree-utils.js +++ b/mozilla/extensions/venkman/resources/content/tree-utils.js @@ -1183,7 +1183,6 @@ function xtv_thaw () delete this.changeStart; delete this.changeAmount; - } XULTreeView.prototype.saveBranchState = @@ -1502,6 +1501,88 @@ function xtv_pactcell (action) { } +XULTreeView.prototype.onRouteFocus = +function xtv_rfocus (event) +{ + if (this.tree && this.tree.treeBody) + this.tree.treeBody.setAttribute("focused", true) + + if ("onFocus" in this) + this.onFocus(event); +} + +XULTreeView.prototype.onRouteBlur = +function xtv_rblur (event) +{ + if (this.tree && this.tree.treeBody) + this.tree.treeBody.removeAttribute("focused"); + + if ("onBlur" in this) + this.onBlur(event); +} + +XULTreeView.prototype.onRouteDblClick = +function xtv_rdblclick (event) +{ + if (!("onRowCommand" in this) || event.target.localName != "treechildren") + return; + + var rowIndex = this.tree.selection.currentIndex; + if (rowIndex == -1 || rowIndex > this.rowCount) + return; + var rec = this.childData.locateChildByVisualRow(rowIndex); + if (!rec) + { + ASSERT (0, "bogus row index " + rowIndex); + return; + } + + this.onRowCommand(rec, event); +} + +XULTreeView.prototype.onRouteKeyPress = +function xtv_rkeypress (event) +{ + var rec; + + if ("onRowCommand" in this && (event.keyCode == 13 || event.charCode == 32)) + { + if (!this.selection) + return; + + var rowIndex = this.tree.selection.currentIndex; + if (rowIndex == -1 || rowIndex > this.rowCount) + return; + rec = this.childData.locateChildByVisualRow(rowIndex); + if (!rec) + { + ASSERT (0, "bogus row index " + rowIndex); + return; + } + + this.onRowCommand(rec, event); + } + else if ("onKeyPress" in this) + { + var rowIndex = this.tree.selection.currentIndex; + if (rowIndex != -1 && rowIndex < this.rowCount) + { + var rec = this.childData.locateChildByVisualRow(rowIndex); + if (!rec) + { + ASSERT (0, "bogus row index " + rowIndex); + return; + } + } + else + { + rec = null; + } + + this.onKeyPress(rec, event); + } +} + /*******************************************************************************/ function xtv_formatRecord (rec, indent) diff --git a/mozilla/extensions/venkman/resources/content/venkman-bindings.xml b/mozilla/extensions/venkman/resources/content/venkman-bindings.xml index ee556de0402..df45b0bac41 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-bindings.xml +++ b/mozilla/extensions/venkman/resources/content/venkman-bindings.xml @@ -82,7 +82,7 @@ - + diff --git a/mozilla/extensions/venkman/resources/content/venkman-commands.js b/mozilla/extensions/venkman/resources/content/venkman-commands.js index 1cc1491dc4b..06857328ed3 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-commands.js +++ b/mozilla/extensions/venkman/resources/content/venkman-commands.js @@ -47,6 +47,7 @@ function initCommands() ["about-mozilla", cmdAboutMozilla, 0], ["break", cmdBreak, CMD_CONSOLE], ["break-props", cmdBreakProps, CMD_CONSOLE], + ["change-value", cmdChangeValue, 0], ["chrome-filter", cmdChromeFilter, CMD_CONSOLE], ["clear", cmdClear, CMD_CONSOLE], ["clear-all", cmdClearAll, CMD_CONSOLE], @@ -104,16 +105,19 @@ function initCommands() ["propsd", cmdProps, CMD_CONSOLE], ["quit", cmdQuit, CMD_CONSOLE], ["restore-layout", cmdRestoreLayout, CMD_CONSOLE], + ["restore-settings", cmdRestoreSettings, CMD_CONSOLE], ["release-notes", cmdReleaseNotes, 0], ["run-to", cmdRunTo, CMD_NEED_STACK], + ["save-breakpoints", cmdSaveBreakpoints, CMD_CONSOLE], ["save-layout", cmdSaveLayout, CMD_CONSOLE], ["save-profile", cmdSaveProfile, CMD_CONSOLE], + ["save-settings", cmdSaveSettings, CMD_CONSOLE], ["scan-source", cmdScanSource, 0], ["scope", cmdScope, CMD_CONSOLE | CMD_NEED_STACK], ["this-expr", cmdThisExpr, CMD_CONSOLE], ["toggle-float", cmdToggleFloat, CMD_CONSOLE], - ["toggle-save-layout", cmdToggleSaveLayout, 0], ["toggle-view", cmdToggleView, CMD_CONSOLE], + ["toggle-pref", cmdTogglePref, CMD_CONSOLE], ["startup-init", cmdStartupInit, CMD_CONSOLE], ["step", cmdStep, CMD_CONSOLE | CMD_NEED_STACK], ["stop", cmdStop, CMD_CONSOLE | CMD_NO_STACK], @@ -130,6 +134,8 @@ function initCommands() ["toggle-ias", "startup-init toggle", 0], ["toggle-pprint", "pprint toggle", 0], ["toggle-profile", "profile toggle", 0], + ["toggle-save-layout", "toggle-pref saveLayoutOnExit", 0], + ["toggle-save-settings", "toggle-pref saveSettingsOnExit", 0], ["em-cycle", "emode cycle", 0], ["em-ignore", "emode ignore", 0], ["em-trace", "emode trace", 0], @@ -253,16 +259,24 @@ function cmdBreak (e) } else { - var fbreak = getFutureBreakpoint(url, e.lineNumber); + var props = e.properties; + var fbreak; + if (e.parent) + fbreak = e.parent; + else + fbreak = getFutureBreakpoint(url, e.lineNumber); if (!fbreak) { dispatch ("fbreak", { isInteractive: e.isInteractive, urlPattern: url, - lineNumber: e.lineNumber }); + lineNumber: e.lineNumber, + props: props}); fbreak = getFutureBreakpoint(url, e.lineNumber); + props = null; // hard breakpoint properties will be inherited } - console.scriptManagers[url].setBreakpoint (e.lineNumber, fbreak); + console.scriptManagers[url].setBreakpoint (e.lineNumber, fbreak, + props); feedback (e, getMsg(MSN_BP_CREATED, [url, e.lineNumber])); } } @@ -288,6 +302,60 @@ function cmdBreakProps (e) "chrome,extrachrome,menubar,resizable", e.breakWrapper); } +function cmdChangeValue(e) +{ + var obj = e.parentValue.getWrappedValue(); + + if (!e.newValue) + { + var ok; + + var current = obj[e.propertyName]; + if (typeof current == "string") + current = current.quote(); + else if (typeof current == "object") + current = ""; + else + current = String(current); + + while (!ok) + { + + var expr = prompt(getMsg(MSN_ENTER_EXPRESSION, e.propertyName), + current); + if (expr == null || expr == "") + return; + + try + { + if ("frames" in console) + { + e.newValue = evalInTargetScope(expr, true); + e.newValue = e.newValue.getWrappedValue(); + } + else + { + var parent = e.parentValue.jsParent.getWrappedValue(); + e.newValue = eval(expr, parent); + } + ok = true; + } + catch(ex) + { + if (ex instanceof jsdIValue) + alert (String(ex.getWrappedValue)); + else + alert (String(ex)); + + current = expr; + } + } + } + + obj[e.propertyName] = e.newValue; + dispatch ("hook-eval-done"); +} + function cmdChromeFilter (e) { const FLAGS = SCRIPT_NODEBUG | SCRIPT_NOPROFILE; @@ -721,11 +789,13 @@ function cmdFBreak(e) if (i == 0) display (MSG_NO_FBREAKS_SET); - return; + return null; } else { - if (setFutureBreakpoint (e.urlPattern, e.lineNumber)) + var fbreak = setFutureBreakpoint (e.urlPattern, e.lineNumber, + e.properties); + if (fbreak) { feedback (e, getMsg(MSN_FBP_CREATED, [e.urlPattern, e.lineNumber])); } @@ -734,6 +804,7 @@ function cmdFBreak(e) feedback (e, getMsg(MSN_FBP_EXISTS, [e.urlPattern, e.lineNumber]), MT_ERROR); } + return fbreak; } } @@ -1015,7 +1086,11 @@ function cmdFrame (e) e.frameIndex = getCurrentFrameIndex(); } - dispatch ("find-frame", { frameIndex: e.frameIndex }); + if (!("isInteractive" in e)) + e.isInteractive = false; + + dispatch ("find-frame", { frameIndex: e.frameIndex, + isInteractive: e.isInteractive }); return true; } @@ -1080,7 +1155,7 @@ function cmdLoadd (e) var rv = rvStr = console._loader.loadSubScript(e.url, obj); if (typeof rv == "function") rvStr = MSG_TYPE_FUNCTION; - display(getMsg(MSN_SUBSCRIPT_LOADED, [e.url, rvStr]), MT_INFO); + feedback(e, getMsg(MSN_SUBSCRIPT_LOADED, [e.url, rvStr]), MT_INFO); return rv; } catch (ex) @@ -1321,6 +1396,23 @@ function cmdRestoreLayout (e) console.viewManager.reconstituteVURLs (layout.split (/\s*;\s*/)); } +function cmdRestoreSettings(e) +{ + if (!e.settingsFile || e.settingsFile == "?") + { + var rv = pickOpen(MSG_OPEN_FILE, "*.js"); + if (rv.reason == PICK_CANCEL) + return; + e.settingsFile = getURLSpecFromFile(rv.file); + } + else if (e.settingsFile.indexOf("file:") != 0) + { + e.settingsFile = getURLSpecFromFile(e.settingsFile); + } + + dispatch("loadd", { url: e.settingsFile }); +} + function cmdReleaseNotes (e) { openTopWin(MSG_RELEASE_URL); @@ -1337,7 +1429,90 @@ function cmdRunTo (e) dispatch ("cont"); } -function cmdSaveLayout (e) +function cmdSaveBreakpoints(e) +{ + var needClose = false; + var file = e.settingsFile; + + if (!file || file == "?") + { + var rv = pickSaveAs(MSG_SAVE_FILE, "*.js"); + if (rv.reason == PICK_CANCEL) + return; + e.settingsFile = file = fopen(rv.file, ">"); + needClose = true; + } + else if (typeof file == "string") + { + e.settingsFile = file = fopen(file, ">"); + needClose = true; + } + + var fbp, bp; + var params; + + file.write ("\n//Breakpoint settings start...\n"); + + for (i in console.fbreaks) + { + var wroteVar; + + fbp = console.fbreaks[i]; + params = { + urlPattern: fbp.url, + lineNumber: fbp.lineNumber, + properties: fbp.getProperties() + }; + + if (keys(fbp.childrenBP).length) + { + if (!wroteVar) + { + file.write ("var fbreak;\n\n"); + wroteVar = true; + } + file.write("fbreak = "); + } + + file.write("dispatch('fbreak', " + params.toSource() + ");\n\n"); + + for (i in fbp.childrenBP) + { + bp = fbp.childrenBP[i]; + + file.write("dispatch('break', {" + + "urlPattern:" + bp.url.quote() + ", " + + "lineNumber:" + bp.lineNumber + ", " + + "parent:fbreak, " + + "properties:" + bp.getProperties().toSource() + + "});\n"); + }; + + file.write("\n"); + } + + for (i in console.breaks) + { + bp = console.breaks[i]; + if (!bp.parentBP) + { + params = { + urlPattern: bp.url, + lineNumber: bp.lineNumber, + properties: bp.getProperties() + }; + + file.write("dispatch('break', " + params.toSource() + ");\n"); + } + } + + file.write (MSG_BREAKPOINTS_RESTORED.quote() + ";\n"); + + if (needClose) + file.close(); +} + +function cmdSaveLayout(e) { if (!e.name) { @@ -1393,7 +1568,7 @@ function cmdSaveProfile (e) e.targetFile = rv.file; } - var file = fopen (e.targetFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE); + var file = fopen (e.targetFile, ">"); var templateName; var ary = file.localFile.path.match(/\.([^.]+)$/); @@ -1451,6 +1626,28 @@ function cmdSaveProfile (e) return file.localFile; } +function cmdSaveSettings(e) +{ + if (!e.settingsFile || e.settingsFile == "?") + { + var rv = pickSaveAs(MSG_SAVE_FILE, "*.js"); + if (rv.reason == PICK_CANCEL) + return; + e.settingsFile = fopen(rv.file, ">"); + } + else if (typeof e.settingsFile == "string") + { + e.settingsFile = fopen(e.settingsFile, ">"); + } + + dispatch ("save-breakpoints", { settingsFile: e.settingsFile }); + dispatch ("save-watches", { settingsFile: e.settingsFile }); + + e.settingsFile.write("\n" + MSG_SETTINGS_RESTORED.quote() + ";\n"); + + e.settingsFile.close(); +} + function cmdScanSource (e) { e.scriptInstance.scanForMetaComments(); @@ -1516,10 +1713,21 @@ function cmdToggleSomething (e) function cmdSetEvalObj (e) { - if (e.jsdValue instanceof jsdIStackFrame) - console.currentEvalObject = e.jsdValue; - else - console.currentEvalObject = e.jsdValue.getWrappedValue(); + if (!(e.jsdValue instanceof jsdIStackFrame)) + { + e.jsdValue = e.jsdValue.getWrappedValue(); + } + + if (e.jsdValue == console.currentEvalObject) + { + var frame = getCurrentFrame(); + if (frame) + e.jsdValue = frame; + else + e.jsdValue = console; + } + + console.currentEvalObject = e.jsdValue; } function cmdSetScriptFlag (e) @@ -1747,11 +1955,12 @@ function cmdToggleFloat (e) dispatch ("move-view", { viewId: e.viewId, locationUrl: locationUrl }); } -function cmdToggleSaveLayout (e) +function cmdTogglePref (e) { - var state = !console.prefs["saveLayoutOnExit"]; - console.prefs["saveLayoutOnExit"] = state; - feedback (e, getMsg (MSN_SAVE_LAYOUT, state ? MSG_VAL_ON : MSG_VAL_OFF)); + var state = !console.prefs[e.prefName]; + console.prefs[e.prefName] = state; + feedback (e, getMsg (MSN_FMT_PREFVALUE, + [e.prefName, state ? MSG_VAL_ON : MSG_VAL_OFF])); } function cmdToggleView (e) diff --git a/mozilla/extensions/venkman/resources/content/venkman-debugger.js b/mozilla/extensions/venkman/resources/content/venkman-debugger.js index a1ab5c6ad2a..5d871ee6163 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-debugger.js +++ b/mozilla/extensions/venkman/resources/content/venkman-debugger.js @@ -501,12 +501,12 @@ function smgr_hasbp (line) } ScriptManager.prototype.setBreakpoint = -function smgr_break (line, parentBP) +function smgr_break (line, parentBP, props) { var found = false; for (var i in this.instances) - found |= this.instances[i].setBreakpoint(line, parentBP); + found |= this.instances[i].setBreakpoint(line, parentBP, props); return found; } @@ -683,6 +683,9 @@ function si_linemap() { if (!this._lineMapInited) { + if (this.topLevel && this.topLevel.jsdScript.isValid) + this.topLevel.addToLineMap(this._lineMap); + for (var i in this.functions) { if (this.functions[i].jsdScript.isValid) @@ -754,21 +757,22 @@ function si_getbp (line) } ScriptInstance.prototype.setBreakpoint = -function si_setbp (line, parentBP) +function si_setbp (line, parentBP, props) { function setBP (scriptWrapper) { - var jsdScript = scriptWrapper.jsdScript; - if (!jsdScript.isValid) + if (!scriptWrapper.jsdScript.isValid) return false; + var jsdScript = scriptWrapper.jsdScript; + if (line >= jsdScript.baseLineNumber && line <= jsdScript.baseLineNumber + jsdScript.lineExtent && - jsdScript.isLineExecutable (line, PCMAP_SOURCETEXT)) + (jsdScript.isLineExecutable (line, PCMAP_SOURCETEXT) || + jsdScript.baseLineNumber == line)) { - scriptWrapper.setBreakpoint(jsdScript.lineToPc(line, - PCMAP_SOURCETEXT), - parentBP); + var pc = jsdScript.lineToPc(line, PCMAP_SOURCETEXT); + scriptWrapper.setBreakpoint(pc, parentBP, props); return true; } return false; @@ -975,7 +979,7 @@ function sw_hasbp (pc) } ScriptWrapper.prototype.setBreakpoint = -function sw_setbp (pc, parentBP) +function sw_setbp (pc, parentBP, props) { var key = this.jsdScript.tag + ":" + pc; @@ -985,6 +989,9 @@ function sw_setbp (pc, parentBP) return null; var brk = new BreakInstance (parentBP, this, pc); + if (props) + brk.setProperties(props); + console.breaks[key] = brk; this.breaks[key] = brk; @@ -1139,6 +1146,39 @@ function bi_getURL () "&enabled=" + this.enabled); } +BreakInstance.prototype.getProperties = +function bi_getprops() +{ + var rv = new Object(); + + rv.enabled = this._enabled; + if ("_conditionEnabled" in this) + rv.conditionEnabled = this._conditionEnabled; + if ("_condition" in this) + rv.condition = this._condition; + if ("_passExceptions" in this) + rv.passExceptions = this._passExceptions; + if ("_logResult" in this) + rv.logResult = this._logResult; + if ("_resultAction" in this) + rv.resultAction = this._resultAction; + + return rv; +} + +BreakInstance.prototype.setProperties = +function bi_setprops(obj) +{ + for (var p in obj) + { + if (p.search(/pc|url|lineNumber/) == -1) + this[p] = obj[p]; + } + + if ("propsWindow" in this) + this.propsWindow.populateFromBreakpoint(); +} + BreakInstance.prototype.clearBreakpoint = function bi_clear() { @@ -1264,7 +1304,7 @@ function FutureBreakpoint (url, lineNumber) this.url = url; this.lineNumber = lineNumber; this.enabled = true; - this.childrenBP = new Object; + this.childrenBP = new Object(); this.conditionEnabled = false; this.condition = ""; this.passExceptions = false; @@ -1285,6 +1325,34 @@ function fb_getURL () "&enabled=" + this.enabled); } + +FutureBreakpoint.prototype.getProperties = +function fb_getprops() +{ + var rv = new Object(); + + rv.conditionEnabled = this.conditionEnabled; + rv.condition = this.condition; + rv.passExceptions = this.passExceptions; + rv.logResult = this.logResult; + rv.resultAction = this.resultAction; + + return rv; +} + +FutureBreakpoint.prototype.setProperties = +function fb_setprops(obj) +{ + for (var p in obj) + { + if (p.search(/url|lineNumber|childrenBP/) == -1) + this[p] = obj[p]; + } + + if ("propsWindow" in this) + this.propsWindow.populateFromBreakpoint(); +} + FutureBreakpoint.prototype.clearFutureBreakpoint = function fb_clear () { @@ -1413,7 +1481,8 @@ function debugTrap (frame, type, rv) [rv.value.stringValue, formatFrame(frame)]), MT_ETRACE); if (rv.value.jsClassName == "Error") - display (formatProperty(rv.value.getProperty("message"))); + display (formatProperty(rv.value.getProperty("message")), + MT_EVAL_OUT); if (console.throwMode != TMODE_BREAK) return jsdIExecutionHook.RETURN_CONTINUE_THROW; @@ -1736,7 +1805,7 @@ function displayProperties (v) var p = new Object(); v.getProperties (p, {}); - for (var i in p.value) display(formatProperty (p.value[i])); + for (var i in p.value) display(formatProperty (p.value[i]), MT_EVAL_OUT); } function displaySourceContext (sourceText, line, contextLines) @@ -1793,7 +1862,7 @@ function displayFrame (jsdFrame, idx, showHeader, sourceContext) if (typeof sourceContext == "undefined") sourceContext = null; - display(getMsg(MSN_FMT_FRAME_LINE, [idx, formatFrame(jsdFrame)])); + display(getMsg(MSN_FMT_FRAME_LINE, [idx, formatFrame(jsdFrame)]), MT_OUTPUT); if (!jsdFrame.isNative && sourceContext != null) { @@ -1826,7 +1895,7 @@ function getFutureBreakpoint (urlPattern, lineNumber) return null; } -function setFutureBreakpoint (urlPattern, lineNumber) +function setFutureBreakpoint (urlPattern, lineNumber, props) { var key = urlPattern + "#" + lineNumber; @@ -1848,6 +1917,8 @@ function setFutureBreakpoint (urlPattern, lineNumber) } var fbreak = new FutureBreakpoint (urlPattern, lineNumber); + if (props) + fbreak.setProperties(props); console.fbreaks[key] = fbreak; dispatch ("hook-fbreak-set", { fbreak: fbreak }); diff --git a/mozilla/extensions/venkman/resources/content/venkman-floater.js b/mozilla/extensions/venkman/resources/content/venkman-floater.js index e4239bdb267..c5da2bafe79 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-floater.js +++ b/mozilla/extensions/venkman/resources/content/venkman-floater.js @@ -91,8 +91,11 @@ function updateTitle() for (v in containedViews) ary.push(containedViews[v].caption); - document.title = getMsg(opener.MSN_FLOATER_TITLE, - ary.join(opener.MSG_COMMASP)); + var views = ary.join(opener.MSG_COMMASP); + if (views == "") + views = opener.MSG_VAL_NONE; + + document.title = getMsg(opener.MSN_FLOATER_TITLE, views); } diff --git a/mozilla/extensions/venkman/resources/content/venkman-menus.js b/mozilla/extensions/venkman/resources/content/venkman-menus.js index 049e9d5060e..b08c7cf8740 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-menus.js +++ b/mozilla/extensions/venkman/resources/content/venkman-menus.js @@ -84,11 +84,20 @@ function initMenus() [ ["open-url"], ["find-file"], - ["-"], + ["close-source-tab", + {enabledif: "console.views.source2.currentContent && " + + "console.views.source2.sourceTabList.length"}], ["close"], + ["-"], ["save-source-tab", { enabledif: "console.views.source2.canSave()" }], ["save-profile"], ["-"], + ["save-settings"], + ["restore-settings"], + ["toggle-save-settings", + {type: "checkbox", + checkedif: "console.prefs['saveSettingsOnExit']"}], + ["-"], [navigator.platform.search(/win/i) == -1 ? "quit" : "exit"] ] }; diff --git a/mozilla/extensions/venkman/resources/content/venkman-msg.js b/mozilla/extensions/venkman/resources/content/venkman-msg.js index 34874017772..fb57a5d85ac 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-msg.js +++ b/mozilla/extensions/venkman/resources/content/venkman-msg.js @@ -104,7 +104,7 @@ function getMsgFrom (bundle, msgName, params, deflt) if (params && params instanceof Array) rv = bundle.formatStringFromName (msgName, params, params.length); - else if (params) + else if (params || params == 0) rv = bundle.formatStringFromName (msgName, [params], 1); else rv = bundle.GetStringFromName (msgName); @@ -139,16 +139,17 @@ const MT_HELLO = "HELLO"; const MT_HELP = "HELP"; const MT_WARN = "WARN"; const MT_INFO = "INFO"; -const MT_SOURCE = "SOURCE"; -const MT_STEP = "STEP"; +const MT_OUTPUT = "#OUTPUT"; +const MT_SOURCE = "#SOURCE"; +const MT_STEP = "#STEP"; const MT_STOP = "STOP"; -const MT_ETRACE = "ETRACE"; -const MT_LOG = "LOG"; +const MT_ETRACE = "#ETRACE"; +const MT_LOG = "#LOG"; const MT_USAGE = "USAGE"; -const MT_EVAL_IN = "EVAL-IN"; -const MT_EVAL_OUT = "EVAL-OUT"; -const MT_FEVAL_IN = "FEVAL-IN"; -const MT_FEVAL_OUT = "FEVAL-OUT"; +const MT_EVAL_IN = "#EVAL-IN"; +const MT_EVAL_OUT = "#EVAL-OUT"; +const MT_FEVAL_IN = "#FEVAL-IN"; +const MT_FEVAL_OUT = "#FEVAL-OUT"; /* these messages might be needed to report an exception at startup, before * initMsgs() has been called. */ diff --git a/mozilla/extensions/venkman/resources/content/venkman-output-base.css b/mozilla/extensions/venkman/resources/content/venkman-output-base.css index bd142c7973a..947f6c0b11e 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-output-base.css +++ b/mozilla/extensions/venkman/resources/content/venkman-output-base.css @@ -50,10 +50,13 @@ a.venkman-link:hover { .msg { /* .msg = a single message in the */ width: 100%; /* output window */ font: 11pt lucida, sans-serif; - font-family: monospace; white-space: -moz-pre-wrap; } +.msg[monospace] { + font-family: monospace; +} + .msg-data[msg-type="USAGE"] { font-weight: bold; font-style: italic; diff --git a/mozilla/extensions/venkman/resources/content/venkman-prefs.js b/mozilla/extensions/venkman/resources/content/venkman-prefs.js index a551f672933..bb3542bf955 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-prefs.js +++ b/mozilla/extensions/venkman/resources/content/venkman-prefs.js @@ -35,25 +35,30 @@ function initPrefs() { + var dir = getSpecialDirectory("ProfD"); + dir.append("venkman-settings.js"); + var defaultSettingsFile = dir.path; console.prefManager = new PrefManager("extensions.venkman."); console.prefs = console.prefManager.prefs; var prefs = [ - ["maxStringLength", 100], - ["startupCount", 0], ["enableChromeFilter", true], - ["tabWidth", 4], - ["initialScripts", ""], - ["prettyprint", false], ["guessContext", 5], ["guessPattern", "(\\w+)\\s*[:=]\\s*$"], - ["permitStartupHit", true], - ["statusDuration", 5 * 1000], - ["menubarInFloaters", navigator.platform.indexOf ("Mac") != -1], + ["initialScripts", ""], ["lastErrorMode", "ignore"], - ["lastThrowMode", "ignore"] + ["lastThrowMode", "ignore"], + ["maxStringLength", 4000], + ["menubarInFloaters", navigator.platform.indexOf ("Mac") != -1], + ["permitStartupHit", true], + ["prettyprint", false], + ["saveSettingsOnExit", false], + ["settingsFile", defaultSettingsFile], + ["startupCount", 0], + ["statusDuration", 5 * 1000], + ["tabWidth", 4] ]; console.prefManager.addPrefs(prefs); diff --git a/mozilla/extensions/venkman/resources/content/venkman-records.js b/mozilla/extensions/venkman/resources/content/venkman-records.js index b1b58e681e1..4946befa506 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-records.js +++ b/mozilla/extensions/venkman/resources/content/venkman-records.js @@ -611,9 +611,13 @@ function vr_refresh () } catch (ex) { + /* dd ("caught exception refreshing " + this.displayName); - dd (dumpObjectTree(ex)); - + if (typeof ex == "object") + dd (dumpObjectTree(ex)); + else + dd(ex); + */ if (!(ex instanceof jsdIValue)) ex = console.jsds.wrapValue(ex); diff --git a/mozilla/extensions/venkman/resources/content/venkman-static.js b/mozilla/extensions/venkman/resources/content/venkman-static.js index d1a9b7107ab..4d92a174c0b 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-static.js +++ b/mozilla/extensions/venkman/resources/content/venkman-static.js @@ -33,8 +33,8 @@ * */ -const __vnk_version = "0.9.48"; -const __vnk_requiredLocale = "0.9.47+"; +const __vnk_version = "0.9.57"; +const __vnk_requiredLocale = "0.9.51+"; var __vnk_versionSuffix = ""; const __vnk_counter_url = @@ -282,6 +282,8 @@ function dispatchCommand (command, e, flags) dd (getMsg(MSN_ERR_INTERNAL_HOOK, h)); } + dd ("Caught exception calling " + + (isBefore ? "before" : "after") + " hook " + h); dd (formatException(ex)); if (typeof ex == "object" && "stack" in ex) dd (ex.stack); @@ -553,18 +555,13 @@ function init() for (i = 0; i < startupMsgs.length; ++i) display (startupMsgs[i][0], startupMsgs[i][1]); - + display (getMsg(MSN_TIP1_HELP, console.prefs["sessionView.requireSlash"] ? "/" : "")); display (MSG_TIP2_HELP); if (console.prefs["sessionView.requireSlash"]) display (MSG_TIP3_HELP); - //if (console.prefs["sessionView.requireSlash"]) - // display (MSG_SLASH_REQUIRED, MT_ATTENTION); - //dispatch ("commands"); - //dispatch ("help"); - dispatch ("pprint", { toggle: console.prefs["prettyprint"] }); if (MSG_LOCALE_VERSION != __vnk_requiredLocale) @@ -575,6 +572,13 @@ function init() } console.initialized = true; + + if (console.prefs["saveSettingsOnExit"]) + { + dispatch ("restore-settings", + {settingsFile: console.prefs["settingsFile"]}); + } + dispatch ("hook-venkman-started"); dd ("}"); @@ -585,6 +589,12 @@ function destroy () if (console.prefs["saveLayoutOnExit"]) dispatch ("save-layout default"); + if (console.prefs["saveSettingsOnExit"]) + { + dispatch ("save-settings", + {settingsFile: console.prefs["settingsFile"]}); + } + delete console.currentEvalObject; delete console.jsdConsole; @@ -629,14 +639,16 @@ function fetchLaunchCount() { var ary = String(r.responseText).match(/(\d+)/); if (ary) + { display (getMsg(MSN_LAUNCH_COUNT, [console.prefs["startupCount"], ary[1]])); + } }; var r = new XMLHttpRequest(); r.onload = onLoad; r.open ("GET", - __vnk_counter_url + "?local=" + console.prefs["startupCount"] + + __vnk_counter_url + "?local=" + console.prefs["startupCount"] + "&version=" + __vnk_version); r.send (null); } @@ -649,7 +661,6 @@ function con_ua () { return ("Venkman " + __vnk_version + __vnk_versionSuffix + " [Mozilla " + ary[1] + "/" + ary[2] + "]"); - } return ("Venkman " + __vnk_version + __vnk_versionSuffix + " [" + diff --git a/mozilla/extensions/venkman/resources/content/venkman-utils.js b/mozilla/extensions/venkman/resources/content/venkman-utils.js index eebc2a6c858..1d4a0835f5d 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-utils.js +++ b/mozilla/extensions/venkman/resources/content/venkman-utils.js @@ -32,6 +32,8 @@ const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor; const nsIWebNavigation = Components.interfaces.nsIWebNavigation; const nsIDocShellTreeItem = Components.interfaces.nsIDocShellTreeItem; +var utils = new Object(); + if (typeof document == "undefined") /* in xpcshell */ { dumpln = print; @@ -330,15 +332,69 @@ function insertHyphenatedWord (longWord, containerTag) function insertLink (matchText, containerTag) { var href; + var linkText; - if (matchText.indexOf ("://") == -1 && matchText.indexOf("x-jsd") != 0) - href = "http://" + matchText; + var trailing; + ary = matchText.match(/([.,]+)$/); + if (ary) + { + linkText = RegExp.leftContext; + trailing = ary[1]; + } else - href = matchText; - + { + linkText = matchText; + } + + var ary = linkText.match (/^(\w[\w-]+):/); + if (ary) + { + if (!("schemes" in utils)) + { + var pfx = "@mozilla.org/network/protocol;1?name="; + var len = pfx.length + + utils.schemes = new Object(); + for (var c in Components.classes) + { + if (c.indexOf(pfx) == 0) + utils.schemes[c.substr(len)] = true; + } + } + + if (!(ary[1] in utils.schemes)) + { + insertHyphenatedWord(matchText, containerTag); + return; + } + + href = linkText; + } + else + { + href = "http://" + linkText; + } + var anchor = htmlVA (null, href, ""); - insertHyphenatedWord(matchText, anchor); - containerTag.appendChild (anchor); + insertHyphenatedWord (linkText, anchor); + containerTag.appendChild (anchor); + if (trailing) + insertHyphenatedWord (trailing, containerTag); + +} + +function insertQuote (matchText, containerTag, msgtype) +{ + if (msgtype[0] == "#") + { + containerTag.appendChild(document.createTextNode(matchText)); + return; + } + + if (matchText == "``") + containerTag.appendChild(document.createTextNode("\u201c")); + else + containerTag.appendChild(document.createTextNode("\u201d")); } /* length should be an even number >= 6 */ @@ -531,6 +587,20 @@ function getBaseWindowFromWindow (win) return rv; } +function getSpecialDirectory(name) +{ + if (!("directoryService" in utils)) + { + const DS_CTR = "@mozilla.org/file/directory_service;1"; + const nsIProperties = Components.interfaces.nsIProperties; + + utils.directoryService = + Components.classes[DS_CTR].getService(nsIProperties); + } + + return utils.directoryService.get(name, Components.interfaces.nsIFile); +} + function getPathFromURL (url) { var ary = url.match(/^(.*\/)([^\/?#]+)(\?|#|$)/); @@ -559,13 +629,6 @@ function getURLSpecFromFile (file) const nsIIOService = Components.interfaces.nsIIOService; const nsILocalFile = Components.interfaces.nsILocalFile; - /* bug 166792 added this interface in Sept. 2002, but we need to work on - * older versions too. */ - var nsIFileProtocolHandler; - if ("nsIFileProtocolHandler" in Components.interfaces) - nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler; - else - nsIFileProtocolHandler = null; if (typeof file == "string") { @@ -576,9 +639,12 @@ function getURLSpecFromFile (file) } var service = Components.classes[IOS_CTRID].getService(nsIIOService); - if (!nsIFileProtocolHandler) + /* In sept 2002, bug 166792 moved this method to the nsIFileProtocolHandler + * interface, but we need to support older versions too. */ + if ("getURLSpecFromFile" in service) return service.getURLSpecFromFile(file); + var nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler; var fileHandler = service.getProtocolHandler("file"); fileHandler = fileHandler.QueryInterface(nsIFileProtocolHandler); return fileHandler.getURLSpecFromFile(file); diff --git a/mozilla/extensions/venkman/resources/content/venkman-views.js b/mozilla/extensions/venkman/resources/content/venkman-views.js index a93bcc4ea80..e66f3931a7c 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-views.js +++ b/mozilla/extensions/venkman/resources/content/venkman-views.js @@ -98,6 +98,11 @@ function destroyViews() */ function syncTreeView (treeContent, treeView, cb) { + function ondblclick(event) { treeView.onRouteDblClick(event); }; + function onkeypress(event) { treeView.onRouteKeyPress(event); }; + function onfocus(event) { treeView.onRouteFocus(event); }; + function onblur(event) { treeView.onRouteBlur(event); }; + function tryAgain() { if ("treeBoxObject" in treeContent) @@ -119,6 +124,7 @@ function syncTreeView (treeContent, treeView, cb) treeContent.treeBoxObject.view = treeView; if (treeContent.treeBoxObject.selection) treeContent.treeBoxObject.selection.tree = treeContent.treeBoxObject; + } catch (ex) { @@ -126,6 +132,23 @@ function syncTreeView (treeContent, treeView, cb) return; } + if (!treeContent._listenersInstalled) + { + try + { + treeContent.addEventListener("dblclick", ondblclick, false); + treeContent.addEventListener("keypress", onkeypress, false); + treeContent.addEventListener("focus", onfocus, false); + treeContent.addEventListener("blur", onblur, false); + } + catch (ex) + { + dd ("caught exception setting listeners: " + ex); + } + + treeContent._listenersInstalled = true; + } + if (typeof cb == "function") cb(); } @@ -334,6 +357,9 @@ function bv_init () ["clear-all"], ["fclear-all"], ["-"], + ["save-breakpoints"], + ["restore-settings"], + ["-"], ["break-props"] ] }; @@ -357,24 +383,24 @@ function bv_hide() syncTreeView (getChildById(this.currentContent, "break-tree"), null); } -console.views.breaks.onDblClick = -function bv_sel (e) +console.views.breaks.onRowCommand = +function bv_rowcommand (rec) { - if (e.target.localName != "treechildren") - return; + if (rec instanceof BPRecord) + dispatch ("find-bp", {breakpoint: rec.breakWrapper}); +} - var rowIndex = this.tree.selection.currentIndex; - if (rowIndex == -1 || rowIndex > this.rowCount) - return; - var row = this.childData.locateChildByVisualRow(rowIndex); - if (!row) +console.views.breaks.onKeyPress = +function bv_keypress(rec, e) +{ + if (e.keyCode == 46) { - ASSERT (0, "bogus row index " + rowIndex); - return; + cx = this.getContext({}); + if ("hasBreak" in cx) + dispatch ("clear-break", cx); + if ("hasFBreak" in cx) + dispatch ("clear-fbreak", cx); } - - if (row instanceof BPRecord) - dispatch ("find-bp", {breakpoint: row.breakWrapper}); } console.views.breaks.getContext = @@ -462,6 +488,9 @@ function lv_init () getContext: this.getContext, items: [ + ["change-value", {enabledif: "cx.parentValue"}], + ["watch-expr"], + ["-"], ["set-eval-obj", {type: "checkbox", checkedif: "has('jsdValue') && " + "cx.jsdValue.getWrappedValue() == " + @@ -668,10 +697,15 @@ function lv_hide () syncTreeView (getChildById(this.currentContent, "locals-tree"), null); } -console.views.locals.onDblClick = -function lv_dblclick () +console.views.locals.onRowCommand = +function lv_rowcommand(rec) { - //dd ("locals double click"); + if (this.isContainerEmpty(rec.childIndex) && "value" in rec.parentRecord) + { + dispatch ("change-value", + {parentValue: rec.parentRecord.value, + propertyName: rec.displayName}); + } } console.views.locals.getCellProperties = @@ -696,6 +730,8 @@ function lv_cellprops (index, colID, properties) console.views.locals.getContext = function lv_getcx(cx) { + var locals = console.views.locals; + cx.jsdValueList = new Array(); function recordContextGetter (cx, rec, i) @@ -703,6 +739,24 @@ function lv_getcx(cx) if (i == 0) { cx.jsdValue = rec.value; + cx.expression = rec.displayName; + + if ("value" in rec.parentRecord) + { + cx.parentValue = rec.parentRecord.value; + var cur = rec.parentRecord; + while (cur != locals.childData && + cur != locals.scopeRecord) + { + cx.expression = cur.displayName + "." + cx.expression; + cur = cur.parentRecord; + } + } + else + { + cx.parentValue = null; + } + cx.propertyName = rec.displayName; } else { @@ -1130,32 +1184,14 @@ function scv_hide () syncTreeView (getChildById(this.currentContent, "scripts-tree"), null); } -console.views.scripts.onDblClick = -function scv_dblclick (e) +console.views.scripts.onRowCommand = +function scv_rowcommand (rec) { - if (e.target.localName != "treechildren") - return; - - var scriptsView = console.views.scripts; - var rowIndex = scriptsView.tree.selection.currentIndex; - - if (rowIndex == -1) - return; - - if (rowIndex == -1 || rowIndex > scriptsView.rowCount) - { - //dd ("row out of bounds"); - return; - } - - var row = scriptsView.childData.locateChildByVisualRow(rowIndex); - ASSERT (row, "bogus row"); - - if (row instanceof ScriptRecord) - dispatch ("find-script", { scriptWrapper: row.scriptWrapper }); - else if (row instanceof ScriptInstanceRecord) + if (rec instanceof ScriptRecord) + dispatch ("find-script", { scriptWrapper: rec.scriptWrapper }); + else if (rec instanceof ScriptInstanceRecord) dispatch ("find-sourcetext", - { sourceText: row.scriptInstance.sourceText }); + { sourceText: rec.scriptInstance.sourceText }); } console.views.scripts.onClick = @@ -1335,7 +1371,7 @@ function ss_init () ["sessionView.outputWindow", "chrome://venkman/content/venkman-output-window.html?$css"], ["sessionView.currentCSS", - "chrome://venkman/skin/venkman-output-default.css"], + "chrome://venkman/skin/venkman-output-dark.css"], ["sessionView.defaultCSS", "chrome://venkman/skin/venkman-output-default.css"], ["sessionView.darkCSS", @@ -1403,6 +1439,7 @@ function ss_init () this.munger = new CMunger(); this.munger.enabled = true; + this.munger.addRule ("quote", /(``|'')/, insertQuote); this.munger.addRule ("link", /((\w+):\/\/[^<>()\'\"\s:]+|www(\.[^.<>()\'\"\s:]+){2,}|x-jsd:help[\w&\?%]*)/, insertLink); @@ -1509,7 +1546,19 @@ console.views.session.hooks["hook-session-display"] = function ss_hookDisplay (e) { var message = e.message; - var msgtype = ("msgtype" in e) ? e.msgtype : MT_INFO; + var msgtype = (e.msgtype) ? e.msgtype : MT_INFO; + var monospace; + var mtname; + + if (msgtype[0] == "#") + { + monospace = true; + mtname = msgtype.substr(1); + } + else + { + mtname = msgtype; + } function setAttribs (obj, c, attrs) { @@ -1519,7 +1568,9 @@ function ss_hookDisplay (e) obj.setAttribute (a, attrs[a]); } obj.setAttribute("class", c); - obj.setAttribute("msg-type", msgtype); + obj.setAttribute("msg-type", mtname); + if (monospace) + obj.setAttribute("monospace", "true"); } var msgRow = htmlTR("msg"); @@ -1528,7 +1579,7 @@ function ss_hookDisplay (e) var msgData = htmlTD(); setAttribs(msgData, "msg-data"); if (typeof message == "string") - msgData.appendChild(console.views.session.stringToDOM(message)); + msgData.appendChild(console.views.session.stringToDOM(message, msgtype)); else msgData.appendChild(message); @@ -1664,14 +1715,14 @@ function ss_hide () } console.views.session.stringToDOM = -function ss_stringToDOM (message) +function ss_stringToDOM (message, msgtype) { var ary = message.split ("\n"); var span = htmlSpan(); for (var l in ary) { - this.munger.munge(ary[l], span); + this.munger.munge(ary[l], span, msgtype); span.appendChild (htmlBR()); } @@ -2009,17 +2060,11 @@ function skv_hide() syncTreeView (getChildById(this.currentContent, "stack-tree"), null); } -console.views.stack.onDblClick = -function skv_select (e) +console.views.stack.onRowCommand = +function skv_rowcommand (rec) { - if (e.target.localName != "treechildren") - return; - - var rowIndex = console.views.stack.tree.selection.currentIndex; + var rowIndex = rec.childIndex; - if (rowIndex == -1) - return; - if (rowIndex >= 0 && rowIndex < console.frames.length) dispatch ("frame", { frameIndex: rowIndex }); } @@ -2096,7 +2141,14 @@ console.views.source2.viewId = VIEW_SOURCE2; console.views.source2.init = function ss_init () { - console.prefManager.addPref ("source2View.maxTabs", 5); + var prefs = + [ + ["source2View.maxTabs", 5], + ["source2View.showCloseButton", true], + ["source2View.middleClickClose", false] + ]; + + console.prefManager.addPrefs(prefs); this.cmdary = [ @@ -2709,16 +2761,16 @@ function s2v_syncframe (iframe) { if ("contentDocument" in iframe && "webProgress" in iframe) { + var listener = console.views.source2.progressListener; + iframe.addProgressListener (listener, WINDOW); + iframe.loadURI (iframe.getAttribute ("targetSrc")); + if (iframe.hasAttribute ("raiseOnSync")) { var i = this.getIndexOfDOMWindow (iframe.webProgress.DOMWindow); this.showTab(i); iframe.removeAttribute ("raiseOnSync"); } - - var listener = console.views.source2.progressListener; - iframe.addProgressListener (listener, WINDOW); - iframe.loadURI (iframe.getAttribute ("targetSrc")); } else { @@ -2727,11 +2779,11 @@ function s2v_syncframe (iframe) } catch (ex) { - // dd ("caught exception showing session view, will try again later."); - // dd (dumpObjectTree(ex)); + dd ("caught exception showing session view, will try again later."); + dd (ex); + dd (dumpObjectTree(ex)); setTimeout (tryAgain, 500); } - } console.views.source2.syncOutputDeck = @@ -2776,6 +2828,7 @@ function s2v_cleardeck () bloke.setAttribute ("id", "source2-bloke"); bloke.setAttribute ("hidden", "true"); this.tabs.appendChild (bloke); + bloke.selected = true; } } @@ -2785,26 +2838,52 @@ function s2v_createframe (sourceTab, index, raiseFlag) if (!ASSERT(this.deck, "we're deckless")) return null; - if (this.tabs.childNodes.length == 1) - { - var bloke = getChildById (this.tabs, "source2-bloke"); - if (bloke) - this.tabs.removeChild(bloke); - } + var bloke = getChildById (this.tabs, "source2-bloke"); + if (bloke) + this.tabs.removeChild(bloke); var document = this.currentContent.ownerDocument; - var tab = document.createElement ("tab"); + var tab = document.createElement ("tab"); + tab.selected = false; tab.setAttribute ("class", "source2-tab"); tab.setAttribute ("context", "context:source2"); - tab.setAttribute ("crop", "center"); + tab.setAttribute ("align", "center"); tab.setAttribute ("flex", "1"); - tab.setAttribute ("label", sourceTab.sourceText.shortName); + tab.setAttribute("onclick", + "console.views.source2.onTabClick(event)"); + + var tabicon = document.createElement("image"); + tabicon.setAttribute("class", "tab-icon"); + tab.appendChild(tabicon); + var label = document.createElement("label"); + tab.label = label; + label.setAttribute("value", sourceTab.sourceText.shortName); + label.setAttribute("crop", "center"); + label.setAttribute("flex", "1"); + tab.appendChild(label); + tab.appendChild(document.createElement("spacer")); + if (console.prefs["source2View.showCloseButton"]) + { + var closeButton = document.createElement("image"); + closeButton.setAttribute("class", "tab-close-button"); + closeButton.setAttribute("onclick", + "console.views.source2.onCloseButton(event)"); + tab.appendChild(closeButton); + } if (index < this.tabs.childNodes.length) this.tabs.insertBefore (tab, this.tabs.childNodes[index]); else this.tabs.appendChild (tab); + + if (!this.tabs.firstChild.hasAttribute("first-tab")) + { + this.tabs.firstChild.setAttribute("first-tab", "true"); + if (this.tabs.firstChild.nextSibling) + this.tabs.firstChild.nextSibling.removeAttribute("first-tab"); + } + sourceTab.tab = tab; var tabPanel = document.createElement("tabpanel"); @@ -2849,7 +2928,7 @@ function s2v_loadsource (sourceText, index) { return null; } - sourceTab.tab.setAttribute("label", sourceText.shortName); + sourceTab.tab.label.setAttribute("value", sourceText.shortName); sourceTab.iframe.setAttribute("targetSrc", sourceText.jsdURL); sourceTab.iframe.setAttribute("raiseOnSync", "true"); this.syncOutputFrame(sourceTab.iframe); @@ -2894,6 +2973,30 @@ function s2v_addsource (sourceText) return this.loadSourceTextAtIndex (sourceText, index); } +console.views.source2.onCloseButton = +function s2v_onclose(e) +{ + var index = this.getIndexOfTab(e.target.parentNode); + this.removeSourceTabAtIndex(index); + e.preventBubble() +} + +console.views.source2.onTabClick = +function s2v_ontab(e) +{ + var tab; + if (e.target.localName == "tab") + tab = e.target; + else + tab = e.target.parentNode; + + var index = this.getIndexOfTab(tab); + if (e.which == 2 && console.prefs["source2View.middleClickClose"]) + this.removeSourceTabAtIndex(index); + else + this.showTab(index); +} + console.views.source2.removeSourceText = function s2v_removetext (sourceText) { @@ -2923,6 +3026,8 @@ function s2v_removeindex (index) lastIndex = this.sourceTabList.length - 1; if (lastIndex >= 0) this.showTab(lastIndex); + if (index == 0 && this.tabs.firstChild) + this.tabs.firstChild.setAttribute("first-tab", "true"); } else if (this.lastSelectedTab > this.sourceTabList.length) { @@ -2994,6 +3099,7 @@ function s2v_getindex (window) { if (child.firstChild.webProgress.DOMWindow == window) return i; + ++i; child = child.nextSibling; } @@ -3016,7 +3122,32 @@ function s2v_showtab (index) { //dd ("show tab " + index); if (this.tabs) - this.tabs.selectedItem = this.tabs.childNodes[index]; + { + for (var i = 0; i < this.tabs.childNodes.length; ++i) + { + var tab = this.tabs.childNodes[i]; + tab.selected = false; + tab.removeAttribute("selected"); + tab.removeAttribute("beforeselected"); + tab.removeAttribute("afterselected"); + } + + tab = this.tabs.childNodes[index]; + tab.selected = true; + tab.setAttribute("selected", "true"); + if (tab.previousSibling) + tab.previousSibling.setAttribute("beforeselected", "true"); + if (tab.nextSibling) + tab.nextSibling.setAttribute("afterselected", "true"); + + this.tabs.selectedItem = tab; + if (!ASSERT(index <= (this.deck.childNodes.length - 1) && index >= 0, + "index ``" + index + "'' out of range")) + { + return; + } + this.deck.selectedIndex = index; + } else this.lastSelectedTab = index; } @@ -3210,16 +3341,16 @@ function s2v_show () source2View.onShow(); }; - var version; - var help; + //var version; + //var help; try { this.tabs = getChildById (this.currentContent, "source2-tabs"); this.deck = getChildById (this.currentContent, "source2-deck"); //this.bloke = getChildById (this.currentContent, "source2-bloke"); - version = getChildById (this.currentContent, "source2-version-label"); - help = getChildById (this.currentContent, "source2-help-label"); + //version = getChildById (this.currentContent, "source2-version-label"); + //help = getChildById (this.currentContent, "source2-help-label"); } catch (ex) { @@ -3233,8 +3364,8 @@ function s2v_show () return; } - version.setAttribute ("value", console.userAgent); - help.setAttribute ("value", MSG_SOURCE2_HELP); + //version.setAttribute ("value", console.userAgent); + //help.setAttribute ("value", MSG_SOURCE2_HELP); this.syncOutputDeck(); initContextMenu(this.currentContent.ownerDocument, "context:source2"); } @@ -3242,7 +3373,8 @@ function s2v_show () console.views.source2.onHide = function s2v_hide () { - this.lastSelectedTab = this.tabs.selectedIndex; + if (this.sourceTabList.length > 0) + this.lastSelectedTab = this.tabs.selectedIndex; this.clearOutputDeck(); this.deck = null; this.tabs = null; @@ -3825,6 +3957,7 @@ function wv_init() ["watch-expr", cmdWatchExpr, CMD_CONSOLE], ["watch-exprd", cmdWatchExpr, CMD_CONSOLE], ["remove-watch", cmdUnwatch, CMD_CONSOLE], + ["save-watches", cmdSaveWatches, CMD_CONSOLE], ["watch-property", cmdWatchProperty, 0], ]; @@ -3832,6 +3965,8 @@ function wv_init() getContext: this.getContext, items: [ + ["change-value", {enabledif: "cx.parentValue"}], + ["-"], ["watch-expr"], ["remove-watch"], ["set-eval-obj", {type: "checkbox", @@ -3855,8 +3990,10 @@ function wv_init() checkedif: "ValueRecord.prototype.showFunctions"}], ["toggle-ecmas", {type: "checkbox", - checkedif: "ValueRecord.prototype.showECMAProps"}] - + checkedif: "ValueRecord.prototype.showECMAProps"}], + ["-"], + ["save-watches"], + ["restore-settings"] ] }; @@ -3929,6 +4066,11 @@ function wv_getcx(cx) if (i == 0) { cx.jsdValue = rec.value; + if ("value" in rec.parentRecord) + cx.parentValue = rec.parentRecord.value; + else + cx.parentValue = null; + cx.propertyName = rec.displayName; if (rec.parentRecord == console.views.watches.childData) cx.index = rec.childIndex; } @@ -3964,10 +4106,26 @@ function wv_refresh() this.tree.invalidate(); } -console.views.watches.onDblClick = -function wv_dblclick () +console.views.watches.onRowCommand = +function wv_rowcommand(rec) { - //dd ("watches double click"); + if ("value" in rec.parentRecord) + { + dispatch ("change-value", + {parentValue: rec.parentRecord.value, + propertyName: rec.displayName}); + } +} + +console.views.watches.onKeyPress = +function wv_keypress(rec, e) +{ + if (e.keyCode == 46) + { + var cx = this.getContext({}); + if ("index" in cx) + dispatch ("remove-watch", cx); + } } function cmdUnwatch (e) @@ -4003,10 +4161,16 @@ function cmdWatchExpr (e) if (!e.expression) { - if (e.isInteractive) + if ("isInteractive" in e && e.isInteractive) { - var watchData = console.views.watches.childData; + var watchData = console.views.watches.childData.childData; var len = watchData.length; + if (len == 0) + { + display (getMsg(MSG_NO_WATCHES_SET)); + return null; + } + display (getMsg(MSN_WATCH_HEADER, len)); for (var i = 0; i < len; ++i) { @@ -4038,25 +4202,12 @@ function cmdWatchExpr (e) return null; } - if (console.currentEvalObject instanceof jsdIStackFrame) - { - refresher = function () { - if ("frames" in console) - { - this.value = - evalInTargetScope(e.expression, true); - } - }; - } - else - { - var evalObject = console.currentEvalObject; - refresher = function () { - rv = console.doEval.apply(evalObject, - [e.expression, parent]); - this.value = console.jsds.wrapValue(rv); - }; - } + refresher = function () { + if ("frames" in console) + this.value = evalInTargetScope(e.expression, true); + else + throw MSG_VAL_NA; + }; } else { @@ -4089,6 +4240,40 @@ function cmdWatchProperty (e) return rec; } +function cmdSaveWatches(e) +{ + var needClose = false; + var file = e.settingsFile; + + if (!file || file == "?") + { + rv = pickSaveAs(MSG_SAVE_FILE, "*.js"); + if (rv.reason == PICK_CANCEL) + return; + e.settingsFile = file = fopen(rv.file, ">"); + needClose = true; + } + else if (typeof file == "string") + { + e.settingsFile = file = fopen(file, ">"); + needClose = true; + } + + file.write ("\n//Watch settings start...\n"); + + var watchData = console.views.watches.childData.childData; + var len = watchData.length; + for (var i = 0; i < len; ++i) + { + file.write("dispatch('watch-expr " + watchData[i].displayName + "');\n"); + } + + file.write ("\n" + MSG_WATCHES_RESTORED.quote() + ";\n"); + + if (needClose) + file.close(); +} + /******************************************************************************* * Windows View *******************************************************************************/ @@ -4186,25 +4371,11 @@ function winv_cellprops (index, colID, properties) return; } -console.views.windows.onDblClick = -function winv_dblclick (e) +console.views.windows.onRowCommand = +function winv_rowcommand (rec) { - if (e.target.localName != "treechildren") - return; - - var rowIndex = this.tree.selection.currentIndex; - if (rowIndex == -1 || rowIndex > this.rowCount) - return; - var row = this.childData.locateChildByVisualRow(rowIndex); - if (!row) - { - ASSERT (0, "bogus row index " + rowIndex); - return; - } - - if ("url" in row) - dispatch ("find-url", { url: row.url }); - + if ("url" in rec) + dispatch ("find-url", { url: rec.url }); } console.views.windows.getContext = diff --git a/mozilla/extensions/venkman/resources/content/venkman-views.xul b/mozilla/extensions/venkman/resources/content/venkman-views.xul index 9b8acc2672a..08163477d98 100644 --- a/mozilla/extensions/venkman/resources/content/venkman-views.xul +++ b/mozilla/extensions/venkman/resources/content/venkman-views.xul @@ -49,7 +49,6 @@ @@ -72,7 +71,6 @@ @@ -119,7 +117,6 @@ oninput="console.views.scripts.onSearchInput(event);"/> @@ -143,10 +140,6 @@ - -