/* Anchor Editor - juil.98 - par Sylvain Huet */ /* add localisation (must define "loc" function) - may 2001 - by macfly */ struct AnchEdit= [chAnchor:Chn,winAnchor:ObjWin,nameAnchor:ObjText, llAnchor:ObjList,plAnchor:ObjList,alAnchor:ObjList, endAnchor:fun [S [S r1]] I, listlAnchor:[S r1],listpAnchor:[S r1],listaAnchor:[S r1] ]mkAnchor;; fun updatel2(s,l)= _ADDlist l 1000 s;; fun updatel(l,ls)= _RSTlist l; apply_on_list ls @updatel2 l;; fun addlisti(l,i,a)= if l==nil || i<=0 then a::l else let l->[b n] in b::addlisti n i-1 a;; fun remlisti(l,i)= if l==nil then nil else let l->[a n] in if i<=0 then n else a::remlisti n i-1;; fun _selectl(x,b,i,sel)= let _GETlist b.alAnchor ->[j _] in let nth_list b.listlAnchor i -> s in (set b.listaAnchor=addlisti b.listaAnchor if j==nil || j<0 then 1000 else j+1 s; updatel b.alAnchor b.listaAnchor);; fun _selectp(x,b,i,sel)= let _GETlist b.alAnchor ->[j _] in let nth_list b.listpAnchor i -> s in (set b.listaAnchor=addlisti b.listaAnchor if j==nil || j<0 then 1000 else j+1 s; updatel b.alAnchor b.listaAnchor);; fun _selecta(x,b,i,sel)= set b.listaAnchor=remlisti b.listaAnchor i; updatel b.alAnchor b.listaAnchor;; fun _ok(x,b)= let _GETtext b.nameAnchor->s in (_DSwindow b.winAnchor; exec b.endAnchor with [s tl b.listaAnchor]);; fun _cancel(x,b)= _DSwindow b.winAnchor; exec b.endAnchor with [nil nil];; fun _destroy(x,b)= exec b.endAnchor with [nil nil];; fun iniAnchor(ch,father,title,end,listl,listp,lista,name)= let _CRwindow ch father nil nil 320 425 WN_MENU+WN_MINBOX title -> win in let _CRtext ch win 5 5 50 20 ET_BORDER strcat loc "NAME" " : " -> nt in let _CReditLine ch win 60 5 100 20 ET_DOWN+ET_AHSCROLL name -> nme in let _CRtext ch win 5 30 150 20 ET_BORDER loc "LINKS" -> lt in let _CRlist ch win 5 55 150 155 LB_DOWN+LB_VSCROLL -> ll in let _CRtext ch win 5 215 150 20 ET_BORDER loc "POSITIONS" -> pt in let _CRlist ch win 5 240 150 155 LB_DOWN+LB_VSCROLL -> pl in let _CRtext ch win 165 30 150 20 ET_BORDER loc "ANCHORS" -> at in let _CRlist ch win 165 55 150 340 LB_DOWN+LB_VSCROLL -> al in let _CRbutton ch win 5 400 45 20 0 loc "OK" -> ok in let _CRbutton ch win 55 400 45 20 0 loc "CANCEL" -> cancel in let mkAnchor [ch win nme ll pl al end listl listp ">>start"::lista] -> b in (_CBwinDestroy win @_destroy b; _CBlistDclick ll @_selectl b; _CBlistDclick pl @_selectp b; _CBlistDclick al @_selecta b; _CBbutton ok @_ok b; _CBbutton cancel @_cancel b; updatel ll b.listlAnchor; updatel pl b.listpAnchor; updatel al b.listaAnchor; b );; fun main()= iniAnchor _channel nil "toto" nil "aa"::"bb"::nil "11"::"222"::"333"::nil "222"::nil "abc";;