history.js (1941B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 APPEND_TO_HISTORY, 9 CLEAR_HISTORY, 10 HISTORY_LOADED, 11 UPDATE_HISTORY_POSITION, 12 REVERSE_SEARCH_INPUT_CHANGE, 13 REVERSE_SEARCH_BACK, 14 REVERSE_SEARCH_NEXT, 15 } = require("resource://devtools/client/webconsole/constants.js"); 16 17 /** 18 * Append a new value in the history of executed expressions, 19 * or overwrite the most recent entry. The most recent entry may 20 * contain the last edited input value that was not evaluated yet. 21 */ 22 function appendToHistory(expression) { 23 return { 24 type: APPEND_TO_HISTORY, 25 expression, 26 }; 27 } 28 29 /** 30 * Clear the console history altogether. Note that this will not affect 31 * other consoles that are already opened (since they have their own copy), 32 * but it will reset the array for all newly-opened consoles. 33 */ 34 function clearHistory() { 35 return { 36 type: CLEAR_HISTORY, 37 }; 38 } 39 40 /** 41 * Fired when the console history from previous Firefox sessions is loaded. 42 */ 43 function historyLoaded(entries) { 44 return { 45 type: HISTORY_LOADED, 46 entries, 47 }; 48 } 49 50 /** 51 * Update place-holder position in the history list. 52 */ 53 function updateHistoryPosition(direction, expression) { 54 return { 55 type: UPDATE_HISTORY_POSITION, 56 direction, 57 expression, 58 }; 59 } 60 61 function reverseSearchInputChange(value) { 62 return { 63 type: REVERSE_SEARCH_INPUT_CHANGE, 64 value, 65 }; 66 } 67 68 function showReverseSearchNext({ access } = {}) { 69 return { 70 type: REVERSE_SEARCH_NEXT, 71 access, 72 }; 73 } 74 75 function showReverseSearchBack({ access } = {}) { 76 return { 77 type: REVERSE_SEARCH_BACK, 78 access, 79 }; 80 } 81 82 module.exports = { 83 appendToHistory, 84 clearHistory, 85 historyLoaded, 86 updateHistoryPosition, 87 reverseSearchInputChange, 88 showReverseSearchNext, 89 showReverseSearchBack, 90 };