1
0
Fork 0

apply/store editfield values on Clear/Print/Execute/leave

This commit is contained in:
mfranz 2007-03-29 14:53:40 +00:00
parent 88b81056e1
commit d10d5980ca

View file

@ -43,6 +43,10 @@
<command>dialog-apply</command> <command>dialog-apply</command>
<object-name>editfield</object-name> <object-name>editfield</object-name>
</binding> </binding>
<binding>
<command>nasal</command>
<script>select(active)</script>
</binding>
</textbox> </textbox>
<group> <group>
@ -110,8 +114,8 @@
</button> </button>
<button> <button>
<legend>Print</legend> <legend>Dump</legend>
<key>Ctrl-p</key> <key>Ctrl-d</key>
<equal>true</equal> <equal>true</equal>
<binding> <binding>
<command>dialog-apply</command> <command>dialog-apply</command>
@ -144,16 +148,18 @@
var kbdctrl = props.globals.getNode("/devices/status/keyboard/ctrl", 1); var kbdctrl = props.globals.getNode("/devices/status/keyboard/ctrl", 1);
var printf = func { print(call(sprintf, arg)) } var printf = func { print(call(sprintf, arg)) }
var edit = dlg.getNode("edit", 1); var edit = dlg.getNode("edit", 1);
if (!contains(globals, "__nasal_console_locals")) { if (!contains(globals, "__nasal_console")) {
globals["__nasal_console_locals"] = {}; globals["__nasal_console"] = {};
} }
var locals = globals["__nasal_console_locals"]; var locals = globals["__nasal_console"];
var numtabs = size(dlg.getChildren("code")); var numtabs = size(dlg.getChildren("code"));
if (!numtabs) { if (!numtabs) {
numtabs = 10; numtabs = 10;
} }
var dump = func { var dump = func {
gui.dialog_apply("nasal-console", "editfield");
select(active);
rule = "--------------------------------------------------------------------------------"; rule = "--------------------------------------------------------------------------------";
print(rule ~ "\n"); print(rule ~ "\n");
print(edit.getValue()); print(edit.getValue());
@ -162,6 +168,7 @@
var clear = func { var clear = func {
edit.setValue(""); edit.setValue("");
select(active);
} }
var execute = func(what = nil) { var execute = func(what = nil) {
@ -201,7 +208,6 @@
foreach (var c; dlg.getChildren("tab-down")) { foreach (var c; dlg.getChildren("tab-down")) {
c.setBoolValue(c.getIndex() == active); c.setBoolValue(c.getIndex() == active);
} }
# animate tab buttons
dlg.getNode("active").setIntValue(active = which); dlg.getNode("active").setIntValue(active = which);
edit.setValue(dlg.getChild("code", active).getValue()); edit.setValue(dlg.getChild("code", active).getValue());
} }
@ -215,8 +221,8 @@
~ " tab ... leave edit mode (visible text cursor)\n" ~ " tab ... leave edit mode (visible text cursor)\n"
~ " return ... execute active code\n" ~ " return ... execute active code\n"
~ " ctrl-c ... clear input field\n" ~ " ctrl-c ... clear input field\n"
~ " ctrl-p ... print input field contents to terminal\n" ~ " ctrl-d ... dump input field contents to terminal\n"
~ " escape ... close dialog\n\n" ~ " esc ... close dialog\n\n"
~ "Ctrl-click on tab buttons executes code without switching to the tab.\n" ~ "Ctrl-click on tab buttons executes code without switching to the tab.\n"
~ "Add more &lt;code> properties in ~/.fgfs/autosave.xml for more tab buttons."); ~ "Add more &lt;code> properties in ~/.fgfs/autosave.xml for more tab buttons.");
} }