diff options
| author | ruki <[email protected]> | 2017-05-10 20:59:21 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-05-10 20:59:21 +0800 |
| commit | 966876f494902efecb1ea475bade16cd96fe160c (patch) | |
| tree | 1f91f27feead302448faed74adc3b214275fe08a /xmake | |
| parent | 194980341bd177815feb13a529892519138b9cb0 (diff) | |
| parent | da6e4cce0e4c1736db0898d53c16ac8ca0441846 (diff) | |
Merge pull request #84 from TitanSnow/replhistory
replhistory
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua b/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua index 5e24ec832..6ffb6b4f1 100644 --- a/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua +++ b/xmake/core/sandbox/modules/import/core/sandbox/sandbox.lua @@ -28,6 +28,7 @@ local sandbox_core_sandbox = sandbox_core_sandbox or {} -- load modules local sandbox = require("sandbox/sandbox") local raise = require("sandbox/modules/raise") +local history = require("project/history") -- enter interactive mode function sandbox_core_sandbox.interactive() @@ -47,8 +48,34 @@ function sandbox_core_sandbox.interactive() -- bind sandbox environment -- setfenv(0, instance._PUBLIC) + local enable_readline = os.versioninfo().features.readline + local replhistory + if enable_readline then + -- clear history + readline.clear_history() + + -- load history + replhistory = history.load("replhistory") or {} + for _, ln in ipairs(replhistory) do + readline.add_history(ln) + end + end + -- enter interactive mode with this new sandbox sandbox.interactive(instance._PUBLIC) + + if enable_readline then + -- save to history + local entries = readline.history_list() + if #entries > #replhistory then + for i = #replhistory+1, #entries do + history.save("replhistory", entries[i].line) + end + end + + -- clear history + readline.clear_history() + end end -- return module |
