From 246ce973ec74e880006a4a98ba70770b45e9c3e8 Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 19 May 2008 17:31:57 +0000 Subject: [PATCH] save and reload up to 20 history entries --- Nasal/prop_key_handler.nas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Nasal/prop_key_handler.nas b/Nasal/prop_key_handler.nas index cd7baf42f..5c03e3709 100644 --- a/Nasal/prop_key_handler.nas +++ b/Nasal/prop_key_handler.nas @@ -288,3 +288,21 @@ var search = func(n, s) { } +_setlistener("/sim/signals/nasal-dir-initialized", func { + foreach (var p; props.globals.getNode("/sim/gui/prop-key-handler/history", 1).getChildren("entry")) + append(history, p.getValue()); +}); + + +_setlistener("/sim/signals/exit", func { + var max = props.initNode("/sim/gui/prop-key-handler/history-max-size", 20).getValue(); + if (size(history) > max) + history = subvec(history, size(history) - max); + forindex (var i; history) { + var p = props.globals.getNode("/sim/gui/prop-key-handler/history", 1).getChild("entry", i, 1); + p.setValue(history[i]); + p.setAttribute("userarchive", 1); + } +}); + +