commit a0376226ae05e1e9a3f0e053d55ad3d47e4ee444
parent 05922e579e1c0cde4b0df75e000cc9144d09fac3
Author: Alexander Burger <abu@software-lab.de>
Date: Sat, 26 Nov 2011 21:10:37 +0100
Changed GUI '+Hint' system
Diffstat:
11 files changed, 253 insertions(+), 151 deletions(-)
diff --git a/CHANGES b/CHANGES
@@ -1,4 +1,5 @@
* XXdec11 picoLisp-3.0.9
+ Changed GUI '+Hint' system
Calculated message passing (64-bit)
Improved "tags" file handling
IPv6 support
diff --git a/app/cusu.l b/app/cusu.l
@@ -1,4 +1,4 @@
-# 05nov09abu
+# 26nov11abu
# (c) Software Lab. Alexander Burger
(must "Customer/Supplier" Customer)
@@ -18,9 +18,9 @@
(<grid> 3
,"Number" NIL (gui '(+E/R +NumField) '(nr : home obj) 10)
,"Salutation"
- (gui '(+Hint) ,"Salutation"
+ (gui '(+Choice) ,"Salutation"
'(mapcar '((This) (cons (: nm) This)) (collect 'nm '+Sal)) )
- (gui '(+Hint2 +E/R +Obj +TextField) '(sal : home obj) '(nm +Sal) 20)
+ (gui '(+E/R +Obj +TextField) '(sal : home obj) '(nm +Sal) 20)
,"Name" NIL (gui '(+E/R +Cue +TextField) '(nm : home obj) ,"Name" 40)
,"Name 2" NIL (gui '(+E/R +TextField) '(nm2 : home obj) 40) ) )
(,"Address"
diff --git a/doc/app.html b/doc/app.html
@@ -1456,6 +1456,7 @@ href="refD.html#dep">dep</a></code> ("dependencies") function:
<pre><code>
: (dep '+gui)
++gui
+JsField
+Button
+UpButton
@@ -1463,12 +1464,13 @@ href="refD.html#dep">dep</a></code> ("dependencies") function:
+DstButton
+ClrButton
+ChoButton
- +Hint
+ +Choice
+GoButton
+BubbleButton
+DelRowButton
+ShowButton
+DnButton
+ +Img
+field
+Checkbox
+TextField
diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar
Binary files differ.
diff --git a/lib.css b/lib.css
@@ -1,4 +1,4 @@
-/* 18nov11abu
+/* 24nov11abu
* (c) Software Lab. Alexander Burger
*/
@@ -207,3 +207,18 @@ a:hover {
margin: 1ex 5em 1ex 1em;
border: dashed thin;
}
+
+/* Hints */
+.hint {
+ font-size: small;
+ background-color: #707070;
+}
+
+.hints {
+ font-size: small;
+ color: black;
+ padding-left: 3px;
+ padding-top: 3px;
+ border: 1px solid;
+ background-color: white;
+}
diff --git a/lib/form.js b/lib/form.js
@@ -1,9 +1,10 @@
-/* 29oct11abu
+/* 26nov11abu
* (c) Software Lab. Alexander Burger
*/
var FormReq = false;
var HintReq = false;
+var Hint, Hints, Beg, End;
try {
FormReq = new XMLHttpRequest();
@@ -20,7 +21,8 @@ var Key, InBtn, Auto, Drop;
function inBtn(flg) {InBtn = flg;}
function formKey(event) {
- Key = event.keyCode;
+ if ((Key = event.keyCode) == 27 && Hint)
+ Hint.style.visibility = "hidden";
return true;
}
@@ -59,6 +61,13 @@ function dropLoad(event) {
Drop = null;
}
+function hasElement(form, name) {
+ for (var i = 0; i < form.elements.length; ++i)
+ if (form.elements[i].name == name)
+ return true;
+ return false;
+}
+
/*** Form submit ***/
function doPost(form) {
for (var i = 0; ; ++i) {
@@ -71,21 +80,21 @@ function doPost(form) {
}
function post(form, file) {
- var i, j, url, data;
+ var i;
- if (!FormReq)
+ if (!FormReq || !hasElement(form,"*Get") || (i = form.action.indexOf("~")) <= 0)
return true;
if (FormReq.readyState > 0 && FormReq.readyState < 4) {
Queue.push(form);
return false;
}
form.style.cursor = "wait";
- url = form.action.split("~");
- try {FormReq.open("POST", url[0] + "~!jsForm?" + url[1]);}
+ try {FormReq.open("POST", form.action.substr(0,i) + "~!jsForm?" + form.action.substr(i+1));}
catch (e) {return true;}
-
FormReq.onreadystatechange = function() {
if (FormReq.readyState == 4 && FormReq.status == 200) {
+ var i, j;
+
if (FormReq.responseText == "T") {
Queue.length = 0;
form.submit();
@@ -225,9 +234,8 @@ function post(form, file) {
post(Queue.shift(), null);
}
}
-
- data = "";
- for (i = 0; i < Btn.length;)
+ var data = "";
+ for (var i = 0; i < Btn.length;)
if (Btn[i].form != form)
++i;
else {
@@ -274,28 +282,82 @@ function post(form, file) {
return false;
}
-
/*** Hints ***/
-var Hint, Pos;
-
function doHint(field) {
- var i, url, data;
+ if (HintReq) {
+ if (!Hint) {
+ Hint = document.createElement("div");
+ Hint.setAttribute("class", "hint");
+ Hint.style.visibility = "hidden";
+ Hint.style.position = "absolute";
+ Hints = document.createElement("div");
+ Hints.setAttribute("class", "hints");
+ Hints.style.position = "relative";
+ Hints.style.top = "-2px";
+ Hints.style.left = "-3px";
+ Hint.appendChild(Hints);
+ }
+ field.parentNode.appendChild(Hint);
+ var top = field.offsetHeight + 2;
+ var left = 3;
+ for (var obj = field; obj.id != "main" && obj.id != "menu"; obj = obj.offsetParent) {
+ top += obj.offsetTop;
+ left += obj.offsetLeft;
+ }
+ Hint.style.top = top + "px";
+ Hint.style.left = left + "px";
+ }
+}
+
+function hintKey(field, event, tok, coy) {
+ var i, data;
- Hint = null;
+ if (event.keyCode == 9 || event.keyCode == 27)
+ return false;
if (!HintReq)
return true;
if (HintReq.readyState > 0 && HintReq.readyState < 4)
return false;
- if ((i = field.id.lastIndexOf("-")) < 0)
+ if (tok) {
+ for (Beg = field.selectionStart; Beg > 0 && !field.value.charAt(Beg-1).match(/\s/); --Beg);
+ End = field.selectionEnd;
+ }
+ else {
+ Beg = 0;
+ End = field.value.length;
+ }
+ if ((coy || Beg == End) && event.keyCode != 45) { // INS
+ Hint.style.visibility = "hidden";
return true;
- url = field.form.action.split("~");
- try {HintReq.open("POST", url[0] + "~!jsHint?" + field.id.substr(i+1));}
+ }
+ try {
+ HintReq.open("POST",
+ ((i = field.form.action.indexOf("~")) <= 0? "" :
+ field.form.action.substr(0, i+1) ) +
+ ((i = field.id.lastIndexOf("-")) < 0? "!jsHint?$" + field.id :
+ "!jsHint?+" + field.id.substr(i+1) ) +
+ "&" + encodeURIComponent(field.value.substring(Beg, End)) );
+ }
catch (e) {return true;}
HintReq.onreadystatechange = function() {
if (HintReq.readyState == 4 && HintReq.status == 200) {
- Hint = HintReq.responseText.split("&");
- for (i = 0; i < Hint.length; ++i)
- Hint[i] = decodeURIComponent(Hint[i]);
+ var i, n, lst, str;
+
+ if ((str = HintReq.responseText).length == 0)
+ Hint.style.visibility = "hidden";
+ else {
+ lst = str.split("&");
+ while (Hints.hasChildNodes())
+ Hints.removeChild(Hints.firstChild);
+ for (i = 0, n = 7; i < lst.length; ++i) {
+ addHint(field, str = decodeURIComponent(lst[i]));
+ if (str.length > n)
+ n = str.length;
+ }
+ Hints.style.width = n + 3 + "ex";
+ Hint.style.width = n + 4 + "ex";
+ Hint.style.visibility = "visible";
+ }
}
}
for (i = 0; i < field.form.elements.length; ++i) {
@@ -308,75 +370,33 @@ function doHint(field) {
}
try {HintReq.send(data);}
catch (e) {HintReq.abort();}
- Pos = -1;
return true;
}
-function hintKey(field, event, coy) {
- var beg = field.selectionStart;
- var end = field.selectionEnd;
- var i;
-
- if (Hint.length > 0) {
- if (event.keyCode == 19) { // Pause/Break
- if (beg != end)
- return true;
- for (Pos = beg; Pos > 0 && !field.value.charAt(Pos-1).match(/\s/); --Pos);
- if ((i = findHint(field.value.substring(Pos, beg))) < 0)
- Pos = -1;
- else
- setHint(field, beg, end, i);
- return false;
- }
- if (event.keyCode == 38 || event.keyCode == 40) { // Up or Down
- if (beg == end)
- return true;
- if ((i = findHint(field.value.substring(Pos, end))) >= 0)
- setHint(field, beg, end, nextHint(field.value.substring(Pos, beg), i, event.keyCode==38? -1 : +1));
- return false;
- }
- if (!coy) {
- if (Pos < 0)
- for (Pos = beg; Pos > 0 && !field.value.charAt(Pos-1).match(/\s/); --Pos);
- if ((i = findHint(field.value.substring(Pos, beg) + String.fromCharCode(event.charCode || event.keyCode))) < 0)
- Pos = -1;
- else {
- setHint(field, beg+1, end, i);
- return false;
- }
- }
+function addHint(field, str) {
+ var item = document.createElement("div");
+ item.appendChild(document.createTextNode(str));
+ item.onmouseover = function() {
+ this.style.background = "black";
+ this.style.color= "white";
+ field.onchange = false;
}
- return true;
-}
-
-function findHint(str) {
- var len = str.length;
-
- for (var i = 0; i < Hint.length; ++i)
- if (Hint[i].substr(0,len) == str)
- return i;
- return -1;
-}
-
-function nextHint(str, i, n) {
- var len = str.length;
-
- do {
- if (n < 0) {
- if ((i += n) < 0)
- i = Hint.length - 1;
- }
- else {
- if ((i += n) >= Hint.length)
- i = 0;
- }
- } while (Hint[i].substr(0,len) != str);
- return i;
-}
-
-function setHint(field, beg, end, i) {
- field.value = field.value.substr(0,Pos) + Hint[i] + field.value.substring(end, field.value.length);
- field.setSelectionRange(beg, Pos+Hint[i].length);
- field.onblur = function() {fldChg(field)};
- field.onchange = false;
+ item.onmouseout = function() {
+ this.style.background = "white";
+ this.style.color= "black";
+ field.onchange = function() {
+ return fldChg(field)
+ };
+ }
+ item.onclick = function () {
+ Hint.style.visibility = "hidden";
+ field.value = field.value.substr(0,Beg) + item.firstChild.nodeValue + field.value.substr(End);
+ post(field.form, null);
+ field.setSelectionRange(Beg + item.firstChild.nodeValue.length, field.value.length);
+ field.focus();
+ field.onchange = function() {
+ return fldChg(field)
+ };
+ }
+ Hints.appendChild(item);
}
diff --git a/lib/form.l b/lib/form.l
@@ -1,4 +1,4 @@
-# 21nov11abu
+# 26nov11abu
# (c) Software Lab. Alexander Burger
# *PRG *Top *Gui *Btn *Get *Got *Form *Evt *Lock *Spans
@@ -466,7 +466,7 @@
(<span> *Style "@") ) ) ) )
-(class +Hint +ChoButton)
+(class +Choice +ChoButton)
# ttl hint
(dm T (Ttl Exe)
@@ -486,6 +486,13 @@
(cancelButton) ) ) )
+(class +Tok)
+
+(dm T @
+ (=: tok T)
+ (pass extra) )
+
+
(class +Coy)
(dm T @
@@ -493,56 +500,75 @@
(pass extra) )
-(class +Hint0)
-# coy
+(class +hint)
+# tok coy
(dm show> ("Var")
- (<style>
+ (<js>
(list
+ '("autocomplete" . "off")
'("onfocus" . "doHint(this)")
(cons
- "onkeypress"
- (pack "return hintKey(this,event" (and (: coy) ",true") ")")) )
+ "onkeyup"
+ (pack
+ "return hintKey(this,event"
+ (if2 (: tok) (: coy) ",true,true" ",true" ",false,true")
+ ")" ) ) )
(extra "Var") ) )
-(de jsHint (Ix)
+(de jsHint (I Str)
(httpHead "text/plain; charset=utf-8")
(ht:Out *Chunked
- (let? Lst (get "*Lst" (- "*Cnt" (format *Get)))
- (let? L
- (try 'hint>
- (get
- (if (gt0 (format *Form))
- (get Lst @)
- (get Lst 1 (+ (length (car Lst)) (format *Form)) 1) )
- 'gui
- (format Ix) ) )
- (prin
- (ht:Fmt
- (if (atom (car L))
- (car L)
- (caar L) ) ) )
- (for X (cdr L)
- (prin '&
- (ht:Fmt (if (atom X) X (car X))) ) ) ) ) ) )
-
-
-(class +Hint1 +Hint0)
+ (let? L
+ (if (sym? I)
+ ((; I hint) Str)
+ (let? Lst (get "*Lst" (- "*Cnt" (format *Get)))
+ (try 'hint>
+ (get
+ (if (gt0 (format *Form))
+ (get Lst @)
+ (get Lst 1 (+ (length (car Lst)) (format *Form)) 1) )
+ 'gui
+ I )
+ Str ) ) )
+ (prin
+ (ht:Fmt
+ (if (atom (car L))
+ (car L)
+ (caar L) ) ) )
+ (for X (cdr L)
+ (prin '&
+ (ht:Fmt (if (atom X) X (car X))) ) ) ) ) )
+
+
+(class +Hint +hint)
+# hint
+
+(dm T (Fun . @)
+ (=: hint Fun)
+ (pass extra) )
+
+(dm hint> (Str)
+ ((: hint) Str) )
+
+
+(class +Hint1 +hint)
# hint
(dm T (Exe . @)
(=: hint Exe)
(pass extra) )
-(dm hint> ()
- (eval (: hint)) )
+(dm hint> (Str)
+ (extract '((S) (pre? Str S))
+ (eval (: hint)) ) )
-(class +Hint2 +Hint0)
+(class +Hint2 +hint)
-(dm hint> ()
- (with (field -1)
- (eval (: hint)) ) )
+(dm hint> (Str)
+ (extract '((X) (pre? Str (if (atom X) X (car X))))
+ (with (field -1) (eval (: hint))) ) )
(class +Txt)
@@ -653,7 +679,7 @@
(pass super (pack "<" Str ">")) )
(dm show> ("Var")
- (<style>
+ (<js>
(let V (eval (: cue))
(list
(cons "onclick" (pack "if (this.value=='" V "') this.value=''"))
@@ -1007,7 +1033,7 @@
(pass extra) )
(dm show> ("Var")
- (<style>
+ (<js>
(quote
("ondragenter" . "doDrag(event)")
("ondragover" . "doDrag(event)")
@@ -1967,7 +1993,7 @@
(T (extra "Var")) ) )
-(class +Obj +obj)
+(class +Obj +hint +obj)
# objVar objTyp objHook
# ([T|msg] (var . typ) [hook] [T] ..)
@@ -1980,12 +2006,23 @@
(pass extra
(if (nT (next))
(arg)
- (cons NIL (hint> This)) ) ) )
+ (cons NIL
+ (if (: objHook)
+ (collect (: objVar) (last (: objTyp)) (eval @) NIL T (: objVar))
+ (collect (: objVar) (last (: objTyp)) NIL T (: objVar)) ) ) ) ) )
-(dm hint> ()
- (if (: objHook)
- (collect (: objVar) (last (: objTyp)) (eval @) NIL T (: objVar))
- (collect (: objVar) (last (: objTyp)) NIL T (: objVar)) ) )
+(dm hint> (Str)
+ (make
+ (for
+ (Q
+ (goal
+ (cons
+ (list 'db (: objVar) (last (: objTyp)) (: objHook) Str '@@) ) )
+ (prove Q) )
+ (let V (get (asoq '@@ @) -1 (: objVar))
+ (unless (member V (made))
+ (link V) ) )
+ (T (nth (made) 24)) ) ) )
(dm txt> (Obj)
(if (ext? Obj)
diff --git a/lib/http.l b/lib/http.l
@@ -1,4 +1,4 @@
-# 08sep11abu
+# 26nov11abu
# (c) Software Lab. Alexander Burger
# *Home *Gate *Host *Port *Port1 *Port% *Http1 *Chunked
@@ -157,6 +157,7 @@
(_htHead)
(cond
(*MPartLim (_htMultipart))
+ ((=0 *ContLen))
((if *ContLen (ht:Read @) (line))
(for L (split @ '&)
(when (cdr (setq L (split L "=")))
diff --git a/lib/xhtml.l b/lib/xhtml.l
@@ -1,10 +1,11 @@
-# 22nov11abu
+# 26nov11abu
# (c) Software Lab. Alexander Burger
-# *JS *Style *Menu *Tab *ID
+# *JS "*JS" *Style *Menu *Tab *ID
(mapc allow '(*Menu *Tab *ID))
(setq *Menu 0 *Tab 1)
+(off "*JS")
(de htPrin (Prg Ofs)
(default Ofs 1)
@@ -13,6 +14,12 @@
(ht:Prin (eval X Ofs))
(eval X Ofs) ) ) )
+(de htJs ()
+ (for X "*JS"
+ (prin " " (car X) "=\"")
+ (ht:Prin (cdr X))
+ (prin "\"") ) )
+
(de htStyle (Attr)
(cond
((atom Attr)
@@ -51,6 +58,9 @@
(de <tag> (Nm Attr . Prg)
(tag Nm Attr 2 Prg) )
+(de <js> ("*JS" . "Prg")
+ (run "Prg") )
+
(de style (X Prg)
(let *Style
(nond
@@ -511,7 +521,7 @@
(prin
"<form enctype=\"multipart/form-data\" action=\""
(sesId Url)
- (and *JS "\" onkeypress=\"formKey(event)\" onsubmit=\"return doPost(this)")
+ (and *JS "\" onkeydown=\"formKey(event)\" onsubmit=\"return doPost(this)")
"\" method=\"post\">" )
(tag 'fieldset Attr 2 Prg)
(prinl "</form>") )
@@ -541,7 +551,9 @@
(prin (- N) "\" style=\"text-align: right;\"")
(prin N "\"") )
(and Max (prin " maxlength=\"" Max "\""))
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "field")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") )
@@ -560,7 +572,9 @@
(ht:Prin (htmlVal "Var"))
(prin "\" size=\"" N "\"")
(and Max (prin " maxlength=\"" Max "\""))
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "passwd")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") )
@@ -571,7 +585,9 @@
(prin " value=\"")
(ht:Prin (htmlVal "Var"))
(prin "\" size=\"" N "\"")
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "upload")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") )
@@ -580,7 +596,9 @@
(prin "<textarea ")
(htmlVar "Var")
(prin " cols=\"" Cols "\" rows=\"" Rows "\" wrap=\"off\"")
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "area")
(and Flg (prin " disabled=\"disabled\""))
(prin '>)
@@ -590,7 +608,9 @@
(de <select> (Lst "Var" Flg)
(prin "<select ")
(htmlVar "Var")
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "select")
(prin '>)
(for "X" Lst
@@ -614,7 +634,9 @@
(prin "<input type=\"checkbox\" ")
(htmlVar "Var")
(prin " value=\"T\"" (and Val " checked=\"checked\""))
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "check")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") ) )
@@ -625,7 +647,9 @@
(prin " value=\"")
(ht:Prin Val)
(prin "\"" (and (= Val (htmlVal "Var")) " checked=\"checked\""))
- (and *JS (prin " onchange=\"return fldChg(this)\""))
+ (when *JS
+ (prin " onchange=\"return fldChg(this)\"")
+ (htJs) )
(dfltCss "radio")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") )
@@ -638,7 +662,8 @@
(prin "\"")
(when *JS
(prin " onmousedown=\"inBtn(1)\" onblur=\"inBtn(0)\"")
- (and JS (prin " onclick=\"return doBtn(this)\"")) )
+ (and JS (prin " onclick=\"return doBtn(this)\""))
+ (htJs) )
(dfltCss "submit")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") )
@@ -649,7 +674,8 @@
(prin " src=\"" (sesId Src) "\"")
(when *JS
(prin " onmousedown=\"inBtn(1)\" onblur=\"inBtn(0)\"")
- (and JS (prin " onclick=\"return doBtn(this)\"")) )
+ (and JS (prin " onclick=\"return doBtn(this)\""))
+ (htJs) )
(dfltCss "image")
(and Flg (prin " disabled=\"disabled\""))
(prinl "/>") )
diff --git a/src/vers.h b/src/vers.h
@@ -1 +1 @@
-static byte Version[4] = {3,0,8,8};
+static byte Version[4] = {3,0,8,9};
diff --git a/src64/version.l b/src64/version.l
@@ -1,6 +1,6 @@
-# 14nov11abu
+# 26nov11abu
# (c) Software Lab. Alexander Burger
-(de *Version 3 0 8 8)
+(de *Version 3 0 8 9)
# vi:et:ts=3:sw=3