@@ -6,6 +6,7 @@ import { onInit } from "./init";
66
77const STORAGE_NAME = `terminal-config` ;
88const boolean = [ "true" , "false" ] ,
9+ temps = { } ,
910 boolTransform = ( a ) => a === `true` ,
1011 intTransform = ( a ) => parseInt ( a ) ;
1112
@@ -66,7 +67,8 @@ let config =
6667onInit ( ( ) => locale . setLocale ( config . language ) ) ;
6768
6869export function get ( key ) {
69- return typeof config [ key ] === "undefined" ? null : config [ key ] ;
70+ return typeof temps [ key ] !== "undefined" ? temps [ key ]
71+ : typeof config [ key ] === "undefined" ? null : config [ key ] ;
7072}
7173
7274/**
@@ -81,7 +83,7 @@ function onUpdate (updated) {
8183}
8284
8385/**
84- *
86+ * Set the configuration option.
8587 * @param {string } key
8688 * @param {* } value
8789 * @param {boolean } localOnly - Updates only the local values.
@@ -110,6 +112,18 @@ export function set (key, value, localOnly = false) {
110112 return "" ;
111113}
112114
115+ /**
116+ * Sets the option only for the current session.
117+ * @param {string } key
118+ * @param {* } value
119+ */
120+ export function setTemp ( key , value ) {
121+ if ( ! metadata . hasOwnProperty ( key )
122+ || ( metadata [ key ] . values && metadata [ key ] . values . indexOf ( value ) === - 1 ) )
123+ return ;
124+ temps [ key ] = metadata [ key ] . transform ? metadata [ key ] . transform ( value ) : value ;
125+ }
126+
113127export function reset ( ) {
114128 for ( let p in config ) {
115129 if ( metadata [ p ] && ! metadata [ p ] . global )
0 commit comments