multikey.nas: don't show empty ("reserved") entries
string.nas: scanf: detect %% correctly
This commit is contained in:
parent
8fcaaf4491
commit
fbd73ee7d3
2 changed files with 13 additions and 6 deletions
|
@ -49,6 +49,7 @@ var handle_key = func(key) {
|
||||||
cmd ~= chr(key);
|
cmd ~= chr(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var options = [];
|
||||||
var bindings = [];
|
var bindings = [];
|
||||||
var desc = __multikey._ = nil;
|
var desc = __multikey._ = nil;
|
||||||
if ((var node = find_entry(cmd, data, __multikey.arg = [])) != nil) {
|
if ((var node = find_entry(cmd, data, __multikey.arg = [])) != nil) {
|
||||||
|
@ -61,6 +62,9 @@ var handle_key = func(key) {
|
||||||
} elsif (node.getNode("exit") != nil) {
|
} elsif (node.getNode("exit") != nil) {
|
||||||
mode = 2;
|
mode = 2;
|
||||||
}
|
}
|
||||||
|
foreach (var c; node.getChildren("key"))
|
||||||
|
if (size(c.getChildren("binding")) or size(c.getChildren("key")))
|
||||||
|
append(options, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode and size(bindings)) {
|
if (mode and size(bindings)) {
|
||||||
|
@ -70,8 +74,7 @@ var handle_key = func(key) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
if (mode < 2)
|
if (mode < 2)
|
||||||
dialog.update(cmd, __multikey._ or desc,
|
dialog.update(cmd, __multikey._ or desc, menu ? options : []);
|
||||||
menu and node != nil ? node.getChildren("key") : []);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,13 +197,13 @@ var help = func {
|
||||||
continue;
|
continue;
|
||||||
if (string.isalnum(k[0][0]) and k[0][0] != curr) {
|
if (string.isalnum(k[0][0]) and k[0][0] != curr) {
|
||||||
curr = k[0][0];
|
curr = k[0][0];
|
||||||
var line = "-----------------------------------------------";
|
var line = "---------------------------------------------------";
|
||||||
print(debug._c("33", sprintf("\n-- %s %s", title, substr(line, size(title) + 2))));
|
print(debug._c("33", sprintf("\n-- %s %s", title, substr(line, size(title) + 2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s\t%s", colorize(k[0]), desc);
|
printf("%s\t%s", colorize(k[0]), desc);
|
||||||
}
|
}
|
||||||
print(debug._c("33", "\n-- Legend ---------------------------------------"));
|
print(debug._c("33", "\n-- Legend -------------------------------------------"));
|
||||||
printf("\t%s ... unsigned number", colorize("%u"));
|
printf("\t%s ... unsigned number", colorize("%u"));
|
||||||
printf("\t%s ... signed number", colorize("%d"));
|
printf("\t%s ... signed number", colorize("%d"));
|
||||||
printf("\t%s ... floating point number", colorize("%f"));
|
printf("\t%s ... floating point number", colorize("%f"));
|
||||||
|
|
|
@ -272,8 +272,12 @@ var scanf = func(test, format, result) {
|
||||||
f = format.getc();
|
f = format.getc();
|
||||||
if (f == nil)
|
if (f == nil)
|
||||||
die("scanf: trailing % in format");
|
die("scanf: trailing % in format");
|
||||||
if (f == `%` and str.getc() != `%`)
|
if (f == `%`) {
|
||||||
return 0;
|
if (str.getc() != `%`)
|
||||||
|
return 0;
|
||||||
|
success = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (isdigit(f)) {
|
if (isdigit(f)) {
|
||||||
var fnum = f - `0`;
|
var fnum = f - `0`;
|
||||||
|
|
Loading…
Reference in a new issue