home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / s / semtex / !SemTeX / Source (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1994-12-18  |  27.9 KB  |  1,255 lines

  1.  ><SemTeX$Dir>.!RunImage
  2.  This application is FreeWare. (c) 1994 Dick Alstein
  3. Appl$="SemTeX"
  4. #ApplVersion$="1.00 (17-Dec-94)"
  5. error
  6. quit%=
  7.     5mask%=(1<<0)+(1<<4)+(1<<5)+(1<<7)+(1<<11)+(1<<12)
  8.  "Wimp_Poll",mask%,blk% 
  9.  reason%
  10.  reason% 
  11.        
  12.  blk%!0=controlwin% 
  13. 4        
  14. control_openpane(blk%!28,blk%!4,blk%!8)
  15.          blk%!28=controlpane%
  16.       
  17. $      
  18.  "Wimp_OpenWindow",,blk%
  19.        
  20.  blk%!0=controlwin% 
  21. 4        
  22. control_openpane(blk%!28,blk%!4,blk%!8)
  23.       
  24. "    
  25.  3 : 
  26. closewindow(blk%!0)
  27. ?    
  28.  6 : 
  29. mouseclick(blk%!0,blk%!4,blk%!8,blk%!12,blk%!16)
  30.      
  31.  7 : 
  32. startsavedialogue
  33. *    
  34.  8 : 
  35.  "Wimp_ProcessKey",blk%!24
  36.  9 : 
  37. menuselect(blk%)
  38. 1    
  39.  17,18 : 
  40. receive(blk%!4,blk%!8,blk%!16)
  41. 1    
  42.  19 : 
  43. receiveack(blk%!4,blk%!8,blk%!16)
  44.  quit%
  45. msg_exit
  46.  "Wimp_CloseDown"
  47.  errblk% &100
  48.  msglist% 64
  49. msglist%!0=3
  50. msglist%!4=5
  51. msglist%!8=&502
  52. msglist%!12=&400C1
  53. msglist%!16=2
  54. msglist%!20=4
  55. msglist%!24=10
  56. msglist%!28=0
  57.  "Wimp_Initialise",300,&4B534154,Appl$,msglist% 
  58.  osversion%,thistask%
  59. error
  60.  scrapblk% &100
  61.  scrapblk2% &100
  62.  blk% &700
  63. indsize%=&400
  64.  indir% indsize%
  65. indirend%=indir%+indsize%
  66.  ptrinfo% 24
  67. 7&ApplDir$=
  68. readvarval("SemTeX$Dir")
  69. msg_init
  70. scrapblk%!0=-1
  71. :!scrapblk%!4=0 : scrapblk%!8=0
  72. ;%scrapblk%!12=68 : scrapblk%!16=68
  73. scrapblk%!20=&7000301A
  74. $(scrapblk%+24)="!semtex"
  75.  "Wimp_CreateIcon",,scrapblk% 
  76.  baricon%
  77.  "Wimp_OpenTemplate",,ApplDir$+".Templates"
  78. @"infowin%=
  79. loadtemplate("Info")
  80. A%$(blk%!(92+7*32+20))=ApplVersion$
  81. B%savewin%=
  82. loadtemplate("SaveBox")
  83. C savefname%=blk%!(92+0*32+20)
  84. D(choiceswin%=
  85. loadtemplate("Choices")
  86.  actionstr%(4)
  87. F#actionstr%(1)=blk%!(92+6*32+20)
  88. G#actionstr%(2)=blk%!(92+9*32+20)
  89. H$actionstr%(3)=blk%!(92+12*32+20)
  90. I$actionstr%(4)=blk%!(92+15*32+20)
  91. J(controlwin%=
  92. loadtemplate("Control")
  93. K-controlpane%=
  94. loadtemplate("ControlPane")
  95. cpane_width%=blk%!12-blk%!4
  96. M cpane_height%=blk%!16-blk%!8
  97. N(convertwin%=
  98. loadtemplate("Convert")
  99. O#convertfname%=blk%!(92+0*32+20)
  100. P$convertsprite%=blk%!(92+1*32+20)
  101. Q%convertremtxt1%=blk%!(92+3*32+20)
  102. R%convertremtxt2%=blk%!(92+4*32+20)
  103.  "Wimp_CloseTemplate"
  104. readscreenvars
  105. nrofactions%=5
  106.  action$(nrofactions%),action%(4)
  107. action$(1)="Ignore"
  108. action$(2)="Open Control"
  109. action$(3)="Edit"
  110. action$(4)="Run LaTeX"
  111. action$(5)="Run TeX"
  112. initmenus
  113. ]-historysize%=
  114. msg_lookup0("LIST_SIZE"))
  115.  historysize%<1 
  116. complain(
  117. msg_lookup0("IVLS"))
  118.   historysize%=16
  119.  docs% 256*historysize%
  120.  doc%(historysize%)
  121. scrapblk%!0=controlwin%
  122. scrapblk%!4=0
  123.  "Wimp_GetIconState",,scrapblk%
  124. g control_line_x%=scrapblk%!16
  125. h#control_line_y%=-(scrapblk%!12)
  126. i control_line_f%=scrapblk%!24
  127. j control_line_v%=scrapblk%!32
  128.  "Wimp_DeleteIcon",,scrapblk%
  129.  i%=1 
  130.  historysize%
  131.   doc%(i%)=docs%+256*(i%-1)
  132.   $(doc%(i%))=""
  133. nrofdocs%=0
  134. currentdoc%=0
  135. control_setextent
  136. convertfnsize%=32
  137.  convertfn$(convertfnsize%)
  138. nrofconvertfns%=0
  139. choices_load
  140. choices_set
  141. choices_read
  142.  i%,j%
  143.  i%=1 
  144.  j%=1 
  145.  nrofactions%
  146. ~8    
  147.  $(actionstr%(i%))=action$(j%) 
  148.  action%(i%)=j%
  149. choices_set
  150.  i%=1 
  151. ,  $(actionstr%(i%))=action$(action%(i%))
  152. redrawicon(choiceswin%,3+3*i%)
  153. choices_default
  154. action%(1)=3
  155. action%(2)=3
  156. action%(3)=2
  157. action%(4)=2
  158. choices_load
  159.  (ApplDir$+".Choices")
  160.  f%=0 
  161. choices_default
  162.  #f% : 
  163. error : 
  164. choices_default : 
  165. #f%,action%(1),action%(2),action%(3),action%(4)
  166. choices_save
  167.  (ApplDir$+".Choices")
  168.  f%<>0 
  169.  #f% : 
  170. error : 
  171. #f%,action%(1),action%(2),action%(3),action%(4)
  172. closewindow(handle%)
  173. scrapblk%!0=handle%
  174.  "Wimp_CloseWindow",,scrapblk%
  175.  handle%=controlwin% 
  176.   scrapblk%!0=controlpane%
  177.  "Wimp_CloseWindow",,scrapblk%
  178. complain(text$)
  179.  dummy%
  180. dummy%=
  181. errbox(text$,16)
  182. control_open
  183.  dx%,dy%,offs%
  184. scrapblk%!0=controlwin%
  185.  "Wimp_GetWindowState",,scrapblk%
  186.  (scrapblk%!16-scrapblk%!8)>control_extent% 
  187. .  scrapblk%!16=scrapblk%!8+control_extent%
  188.     dx%=0
  189.     dy%=0
  190.  open window 'on top of' iconbar icon (if not already open)
  191.  ((scrapblk%!32 
  192.  (1<<16))=0) 
  193.  "Wimp_GetPointerInfo",,ptrinfo%
  194. 3  dx%=ptrinfo%!0-(scrapblk%!12+scrapblk%!4) 
  195.   dy%=96-scrapblk%!8
  196. scrapblk%!4=scrapblk%!4+dx%
  197. scrapblk%!8=scrapblk%!8+dy%
  198. !scrapblk%!12=scrapblk%!12+dx%
  199. !scrapblk%!16=scrapblk%!16+dy%
  200.  ensure that selected line is visible
  201.  nrofdocs%>0 
  202. *  offs%=-(control_line_y%*currentdoc%)
  203.  scrapblk%!24 < (offs%+control_line_y%) 
  204. *    scrapblk%!24=offs%+control_line_y%
  205.  scrapblk%!24-(scrapblk%!16-scrapblk%!8-cpane_height%) > offs% 
  206. C    scrapblk%!24=offs%+(scrapblk%!16-scrapblk%!8-cpane_height%)
  207. scrapblk%!28=-1
  208. control_openpane(scrapblk%!28,scrapblk%!4,scrapblk%!8)
  209. scrapblk%!28=controlpane%
  210.  "Wimp_OpenWindow",,scrapblk%
  211. control_openpane(scrapblk%!28,scrapblk%!4,scrapblk%!8)
  212. control_openpane(behind%,pxmin%,pymin%)
  213.  dx%,dy%
  214. scrapblk2%!0=controlpane%
  215.  "Wimp_GetWindowState",,scrapblk2%
  216.     dx%=0
  217.     dy%=0
  218. scrapblk2%!4=pxmin%+dx%
  219. scrapblk2%!8=pymin%+dy%
  220. )scrapblk2%!12=pxmin%+cpane_width%+dx%
  221. *scrapblk2%!16=pymin%+cpane_height%+dy%
  222. scrapblk2%!28=behind%
  223.  "Wimp_OpenWindow",,scrapblk2%
  224. control_add(file$)
  225.  nrofdocs%>0 
  226. selecticon(controlwin%,currentdoc%-1,0)
  227.  (i%<nrofdocs%) 
  228.  ($doc%(i%)<>file$)
  229.   i%+=1
  230.  $doc%(i%)=file$ 
  231.   currentdoc%=i%
  232.  nrofdocs%<historysize% 
  233. !    
  234.  create new icon in list
  235.     nrofdocs%+=1
  236.     i%=nrofdocs%
  237.     scrapblk%!0=controlwin%
  238.     scrapblk%!4=0
  239. )    scrapblk%!8=-(control_line_y%*i%)
  240. $    scrapblk%!12=control_line_x%
  241. .    scrapblk%!16=-(control_line_y%*(i%-1))
  242. $    scrapblk%!20=control_line_f%
  243.     scrapblk%!24=doc%(i%)
  244. $    scrapblk%!28=control_line_v%
  245.     scrapblk%!32=256
  246. '    
  247.  "Wimp_CreateIcon",,scrapblk%
  248. control_setextent
  249.  shift lines in history
  250.  i%>1
  251.     $doc%(i%)=$doc%(i%-1)
  252. %    
  253. redrawicon(controlwin%,i%-1)
  254.     i%-=1
  255.   $doc%(1)=file$
  256.   currentdoc%=1
  257. redrawicon(controlwin%,0)
  258. selecticon(controlwin%,currentdoc%-1,1)
  259. control_remove(nr%)
  260.  shift lines in history
  261. i%=nr%
  262.  i%<nrofdocs%
  263.   $doc%(i%)=$doc%(i%+1)
  264. redrawicon(controlwin%,i%-1)
  265.   i%+=1
  266.  (currentdoc%>nr%) 
  267.  (currentdoc%=nrofdocs%) 
  268. selecticon(controlwin%,currentdoc%-1,0)
  269.   currentdoc%-=1
  270. selecticon(controlwin%,currentdoc%-1,1)
  271. $doc%(nrofdocs%)=""
  272. redrawicon(controlwin%,nrofdocs%-1)
  273. scrapblk%!0=controlwin%
  274. scrapblk%!4=nrofdocs%-1
  275.  "Wimp_DeleteIcon",,scrapblk%
  276. nrofdocs%-=1
  277. control_setextent
  278. control_setextent
  279. l%=nrofdocs%
  280.  l%<5 
  281.  l%=5
  282. scrapblk2%!0=0
  283. +4scrapblk2%!4=-(control_line_y%*l%)-cpane_height%
  284. , scrapblk2%!8=control_line_x%
  285. scrapblk2%!12=0
  286.  "Wimp_SetExtent",controlwin%,scrapblk2%
  287. /!control_extent%=-scrapblk2%!4
  288.  check if visible area is not beyond new work area
  289. scrapblk%!0=controlwin%
  290.  "Wimp_GetWindowState",,scrapblk%
  291.  (scrapblk%!32 
  292.  (1<<16)) 
  293.  (scrapblk%!16-scrapblk%!8)>control_extent% 
  294. 50    scrapblk%!8=scrapblk%!16-control_extent%
  295. 6'    
  296.  "Wimp_OpenWindow",,scrapblk%
  297. 7?    
  298. control_openpane(scrapblk%!28,scrapblk%!4,scrapblk%!8)
  299. convert(todir$)
  300.  opts$,name$,leaf$,ext$,s%,cmd$
  301. opts$=
  302. msg_lookup0("COPT")
  303.  converttype% 
  304. A*    
  305.  convert "FILE/EXT" to "file.ext"
  306.  (nrofconvertfns%>0)
  307. C+      name$=convertfn$(nrofconvertfns%)
  308. D)      leaf$=
  309. leafname(
  310. locase(name$))
  311.       s%=
  312. leaf$,"/")
  313.       ext$=
  314. leaf$,s%+1)
  315.       leaf$=
  316. leaf$,s%-1)
  317. HB      
  318.  "OS_File",8,todir$+"."+leaf$ : 
  319.  make sure dir exists
  320. I       cmd$="Copy "+name$+" "
  321. J3      cmd$+=todir$+"."+leaf$+"."+ext$+" "+opts$
  322. K"      
  323.  "Wimp_StartTask",cmd$
  324.       nrofconvertfns%-=1
  325. M        
  326. O+    
  327.  convert "file.ext" to "FILE/EXT" 
  328.  (nrofconvertfns%>0)
  329. Q+      name$=convertfn$(nrofconvertfns%)
  330.       ext$=
  331. leafname(name$)
  332. S,      
  333.  truncate to 8 chars (=DOS style)
  334. T/      leaf$=
  335. leafname(
  336. dirname(name$)),8) 
  337. U       cmd$="Copy "+name$+" "
  338. V3      cmd$+=todir$+"."+leaf$+"/"+ext$+" "+opts$
  339. W"      
  340.  "Wimp_StartTask",cmd$
  341.       nrofconvertfns%-=1
  342. Y        
  343. convert_add(dir$,leaf$)
  344.  o%,r%
  345.  nrofconvertfns%=convertfnsize% 
  346. complain(
  347. msg_lookup1("TMFC",
  348. (convertfnsize%)))
  349.  converttype% 
  350.       nrofconvertfns%+=1
  351. e4      convertfn$(nrofconvertfns%)=dir$+"."+leaf$
  352. f'      $(convertsprite%)="directory"
  353.       
  354.  leaf$="*" 
  355. i(        
  356.  add all files in directory
  357.         o%=0
  358.         
  359. lD          
  360.  "OS_GBPB",10,dir$,scrapblk%,1,o%,256,"*" 
  361.  ,,,r%,o%
  362. m4          
  363.  (r%>0) 
  364.  ((scrapblk%!16 
  365.  1) <> 0) 
  366. n"            nrofconvertfns%+=1
  367. oG            convertfn$(nrofconvertfns%)=dir$+"."+
  368. str(scrapblk%+20)
  369.           
  370. q8        
  371.  (o%=-1) 
  372.  (nrofconvertfns%=convertfnsize%)
  373.         
  374.  o%<>-1 
  375. s?          
  376. complain(
  377. msg_lookup1("TMFC",
  378. (convertfnsize%)))
  379.         
  380.       
  381.         nrofconvertfns%+=1
  382. w6        convertfn$(nrofconvertfns%)=dir$+"."+leaf$
  383.       
  384. y&      $(convertsprite%)="file_xxx"
  385.  nrofconvertfns%=1 
  386. |!    $(convertfname%)="1 file"
  387. ~4    $(convertfname%)=
  388. (nrofconvertfns%)+" files"
  389. shadeicon(convertwin%,1,0)
  390. redrawicon(convertwin%,0)
  391.  converttype%=1 
  392. *    $(convertremtxt1%)="From: FOO/TEX"
  393. (    $(convertremtxt2%)="To: foo.tex"
  394. *    $(convertremtxt1%)="From: foo.tex"
  395. (    $(convertremtxt2%)="To: foo/tex"
  396. redrawicon(convertwin%,3)
  397. redrawicon(convertwin%,4)
  398. convert_open
  399. nrofconvertfns%=0
  400. converttype%=0
  401. $(convertfname%)=""
  402.  $(convertsprite%)="file_xxx"
  403. $(convertremtxt1%)=""
  404. $(convertremtxt2%)=""
  405. redrawicon(convertwin%,0)
  406. shadeicon(convertwin%,1,1)
  407. redrawicon(convertwin%,3)
  408. redrawicon(convertwin%,4)
  409. openwindow(convertwin%,2)
  410. direxists(d$)
  411.  found%
  412.  "OS_File",17,d$ 
  413.  found%
  414. =(found% 
  415.  2)<>0
  416. dirname(F$)
  417.  p%,q%
  418. F$,".",p%)
  419.  q% > 0 
  420.  p%=q%+1
  421.  q%=0
  422. F$,p%-2)
  423. editfile(file$,type%,addtohist%)
  424. fileexists(file$) 
  425.  broadcast Message_DataOpen
  426.   scrapblk%!0=256
  427.   scrapblk%!12=0
  428.   scrapblk%!16=5
  429.   scrapblk%!20=-1
  430.   scrapblk%!28=-1
  431.   scrapblk%!32=-1
  432.   scrapblk%!36=0
  433.   scrapblk%!40=type%
  434.   $(scrapblk%+44)=file$+
  435.  "Wimp_SendMessage",18,scrapblk%,0
  436.  addtohist% 
  437. control_add(file$)
  438. errbox(err$,boxes%)
  439. errblk%!0=0
  440. $(errblk%+4)=err$+
  441.  "Wimp_ReportError",errblk%,boxes%,Appl$ 
  442.  ,click%
  443. =(click%=1)
  444. error
  445.  "Wimp_CloseDown" : 
  446. errbox(
  447. $+" (line "+
  448. )+")",3) 
  449.  "Wimp_CloseDown"
  450. fileexists(f$)
  451.  found%
  452.  "OS_File",17,f$ 
  453.  found%
  454. =(found% 
  455.  1)<>0
  456. iconselected(window%,icon%)
  457. scrapblk%!0=window%
  458. scrapblk%!4=icon%
  459.  "Wimp_GetIconState",,scrapblk%
  460. #=((scrapblk%!24) 
  461.  (1<<21)) > 0
  462. initmenus
  463.  "MenuUtil_Initialise",010,0
  464.  "MenuUtil_New",,Appl$ 
  465.  mainmenu%
  466.  "MenuUtil_Add",mainmenu%,"Info" 
  467.  item_info%
  468.  "MenuUtil_Add",mainmenu%,"Choices..." 
  469.  item_choices%
  470.  "MenuUtil_Add",mainmenu%,"Create" 
  471.  item_create%
  472.  "MenuUtil_Add",mainmenu%,"Convert..." 
  473.  item_convert%
  474.  "MenuUtil_Add",mainmenu%,"Quit" 
  475.  item_quit%
  476.  "MenuUtil_SubMenu",item_info%,infowin%
  477.  "MenuUtil_SubMenu",item_create%,savewin%
  478.  "MenuUtil_New",,"Action" 
  479.  actionmenu%
  480.  i%=1 
  481.  nrofactions%
  482.  "MenuUtil_Add",actionmenu%,action$(i%)
  483.  "MenuUtil_New",,"Document" 
  484.  docmenu%
  485.  "MenuUtil_Add",docmenu%,"Remove" 
  486.  item_deldoc%
  487. leafname(f$)
  488.  p%,q%
  489.   p%=q%+1
  490.   q%=
  491. f$,".",p%)
  492.  q%=0
  493. f$,p%)
  494. loadtemplate(name$)
  495.  handle%
  496.  "Wimp_CloseTemplate" : 
  497. error
  498.  "Wimp_LoadTemplate",,blk%+4,indir%,indirend%,-1,name$,0 
  499.  ,,indir%
  500.  "Wimp_CreateWindow",,blk%+4 
  501.  handle%
  502. =handle%
  503. locase(s$)
  504.  i%=1 
  505.   a%=
  506. s$,i%,1))
  507.  (a%>=65)
  508. (a%<=90) 
  509. s$,i%,1)=
  510. (a%+32)
  511. menuselect(selection%)
  512.  adjust%,selinfo%,itemnr%,item%,item$,parentitem%
  513.  p%,q%
  514.  "MenuUtil_Decode",lastmenu%,selection% 
  515.  ,adjust%,selinfo%
  516. itemnr%=selinfo%!0
  517. item%=selinfo%!8
  518. item$=
  519. str(selinfo%!12)
  520. parentitem%=selinfo%!24
  521.  lastmenu% 
  522.  mainmenu%
  523.  item% 
  524.       
  525.  item_choices%
  526.         
  527. choices_set
  528. &        
  529. openwindow(choiceswin%,1)
  530.       
  531.  item_convert%
  532.         
  533. convert_open
  534.       
  535.  item_quit%
  536.         quit%=
  537.         
  538.  actionmenu%
  539. 3    $(actionstr%((lastmenu_icon%-4) 
  540.  3))=item$
  541. 1    
  542. redrawicon(choiceswin%,lastmenu_icon%-1)
  543.  docmenu%
  544. :    
  545.  adjust% 
  546.  adjust%=(nrofdocs%>(lastmenu_icon%+1))
  547. )    
  548. control_remove(lastmenu_icon%+1)
  549.  adjust% 
  550. showmenu(0,0,0)
  551. mouseclick(xpos%,ypos%,button%,wndw%,icon%)
  552.  dir$,x%,y%
  553.  wndw% 
  554.  button% 
  555.       
  556. '+        
  557. showmenu(mainmenu%,icon%,blk%)
  558.       
  559. )%        
  560. closewindow(controlwin%)
  561.       
  562.         
  563. control_open
  564. ,        
  565.  savewin%
  566.  icon% 
  567. /.      
  568.  1 : 
  569. startsavedrag(savewin%,icon%)
  570. 0        
  571.  convertwin%
  572.  icon% 
  573.       
  574. 4C        
  575.  nrofconvertfns%>0 
  576. startsavedrag(convertwin%,icon%)
  577. 5        
  578.  choiceswin%
  579.  (button% 
  580.       
  581.  icon% 
  582.         
  583.           
  584. choices_read
  585. ;'          
  586.  icon%=0 
  587. choices_save
  588. <'          
  589. closewindow(choiceswin%)
  590.         
  591. >'          
  592. closewindow(choiceswin%)
  593.         
  594.  7,10,13,16
  595. @K          
  596.  change click coords, so menu opens to the right of the icon
  597. A%          scrapblk%!0=choiceswin%
  598. B1          
  599.  "Wimp_GetWindowState",,scrapblk%
  600.           x%=scrapblk%!4
  601.           y%=scrapblk%!16
  602.           scrapblk%!4=icon%
  603. F/          
  604.  "Wimp_GetIconState",,scrapblk%
  605.           x%+=scrapblk%!16
  606.           y%+=scrapblk%!20
  607.           blk%!0=x%+64
  608.           blk%!4=y%
  609. K/          
  610. showmenu(actionmenu%,icon%,blk%)
  611.       
  612. M        
  613.  controlpane%
  614. O)    
  615.  (nrofdocs%>0) 
  616.  (button% 
  617. P.      dir$=
  618. parentname($doc%(currentdoc%))
  619.       
  620.  icon% 
  621.         
  622. S2          
  623. editfile($doc%(currentdoc%),&FFF,0)
  624.         
  625. U+          
  626. runlatex($doc%(currentdoc%))
  627.         
  628. W)          
  629. runtex($doc%(currentdoc%))
  630.         
  631. Y,          
  632. runbibtex($doc%(currentdoc%))
  633.         
  634. [%          
  635.  "Filer_OpenDir "+dir$
  636.         
  637.           
  638. tidydir(dir$)
  639.         
  640. _*          
  641. fileexists(dir$+".dvi") 
  642. `-            
  643. editfile(dir$+".dvi",&CE4,0)
  644.           
  645.             
  646.           
  647.         
  648. e+          
  649. rundvips($doc%(currentdoc%))
  650.       
  651.       
  652.  (button% 
  653. h%        
  654. closewindow(controlwin%)
  655.       
  656. j        
  657.  controlwin%
  658.  click on line in list
  659. m&    
  660.  (button% 
  661.  (icon%>=0) 
  662.       
  663.  -1) 
  664. o         
  665.  click (Shift-Menu)
  666. p$        
  667. control_remove(icon%+1)
  668.       
  669.         blk%!4=blk%!4+22
  670. s*        
  671. showmenu(docmenu%,icon%,blk%)
  672.       
  673. u        
  674.  (button% 
  675.  5*256) 
  676. w"      
  677.  currentdoc%<>icon%+1 
  678. x#        
  679.  click (Select/Adjust)
  680. y4        
  681. selecticon(controlwin%,currentdoc%-1,0)
  682.         currentdoc%=icon%+1
  683. {4        
  684. selecticon(controlwin%,currentdoc%-1,1)
  685.       
  686. }        
  687.  (button% 
  688. (      
  689.  double-click (Select/Adjyst)
  690. '      
  691. selecticon(controlpane%,0,1)
  692. .      
  693. editfile($doc%(currentdoc%),&FFF,0)
  694. '      
  695. selecticon(controlpane%,0,0)
  696. 1      
  697.  button%=1 
  698. closewindow(controlwin%)
  699.         
  700. msg_init
  701.  fname$,flags%,size%,buf%
  702. fname$=ApplDir$+".Messages"
  703.  "MessageTrans_FileInfo",,fname$ 
  704.  flags%,,size%
  705.  flags% 
  706.   buf%=0
  707.  buf% size%
  708.  msgdesc% 17+
  709. (fname$)
  710. $(msgdesc%+16)=fname$
  711.  "MessageTrans_OpenFile",msgdesc%,msgdesc%+16,buf%
  712. msg_exit
  713.  "MessageTrans_CloseFile",msgdesc%
  714. msgdesc%=0
  715. msg_lookup0(token$)
  716.  result%
  717.  "MessageTrans_Lookup",msgdesc%,token$,0 
  718.  ,,result%
  719. str(result%)
  720. msg_lookup1(token$,param$)
  721.  result%
  722.  "MessageTrans_Lookup",msgdesc%,token$,scrapblk%,&100,param$ 
  723.  ,,result%
  724. str(result%)
  725. msg_lookup2(token$,param1$,param2$)
  726.  result%
  727.  "MessageTrans_Lookup",msgdesc%,token$,scrapblk%,&100,param1$,param2$ 
  728.  ,,result%
  729. str(result%)
  730. openwindow(handle%,pos%)
  731.  dx%,dy%
  732. scrapblk%!0=handle%
  733.  "Wimp_GetWindowState",,scrapblk%
  734.     dx%=0
  735.     dy%=0
  736.  pos% 
  737.  0 : 
  738.  open 'as is'
  739.  1 : 
  740.  centered on screen if not open
  741. (    
  742.  ((scrapblk%!32 
  743.  (1<<16))=0) 
  744. /      
  745.  center window to screen if not open
  746. >      dx%=screensize_x% 
  747.  2-(scrapblk%!12+scrapblk%!4) 
  748. >      dy%=screensize_y% 
  749.  2-(scrapblk%!16+scrapblk%!8) 
  750.         
  751.  2 : 
  752.  open window 'on top of' iconbar icon (if not already open)
  753. (    
  754.  ((scrapblk%!32 
  755.  (1<<16))=0) 
  756. ,      
  757.  "Wimp_GetPointerInfo",,ptrinfo%
  758. 7      dx%=ptrinfo%!0-(scrapblk%!12+scrapblk%!4) 
  759.       dy%=96-scrapblk%!8
  760.         
  761. scrapblk%!4=scrapblk%!4+dx%
  762. scrapblk%!8=scrapblk%!8+dy%
  763. !scrapblk%!12=scrapblk%!12+dx%
  764. !scrapblk%!16=scrapblk%!16+dy%
  765. scrapblk%!28=-1
  766.  "Wimp_OpenWindow",,scrapblk%
  767. parentname(f$)
  768.  p%,q%
  769.   p%=q%+1
  770.   q%=
  771. f$,".",p%)
  772.  q%=0
  773. f$,p%-2)
  774. readscreenvars
  775.  xeig%,yeig%,xpixels%,ypixels%
  776.  "OS_ReadModeVariable",-1,4 
  777.  ,,xeig%
  778.  "OS_ReadModeVariable",-1,5 
  779.  ,,yeig%
  780.  "OS_ReadModeVariable",-1,11 
  781.  ,,xpixels%
  782.  "OS_ReadModeVariable",-1,12 
  783.  ,,ypixels%
  784. Escreensize_x%=(xpixels%+1)*(1<<xeig%) : 
  785.  screen size in OS units
  786. )screensize_y%=(ypixels%+1)*(1<<yeig%)
  787. readvarval(var$)
  788.  len%
  789.  "OS_ReadVarVal",var$,scrapblk2%,256,0 
  790.  ,,len%
  791. scrapblk2%?len%=13
  792. =$(scrapblk2%)
  793. receive(sender%,ref%,code%)
  794.  icon%,window%,name$,type%,size%
  795.  leaf$,inputtype%,act%,time%,buttons%,b%,l%,cmd$,hlp$
  796.  sender%<>thistask% 
  797.  code% 
  798.       quit%=
  799. "      
  800.  "Wimp_CreateMenu",,-1
  801.       name$=
  802. str(blk%+44)
  803.       
  804.  savefromwin% 
  805.         
  806.  savewin%
  807. "          
  808.  "OS_File",8,name$
  809. /          
  810.  "OS_File",11,name$+".tex",&FFF
  811. ,          
  812. editfile(name$+".tex",&FFF,1)
  813.         
  814.  convertwin%
  815. '          
  816. convert(
  817. dirname(name$))
  818. '          
  819. closewindow(convertwin%)
  820.       
  821.       window%=blk%!20
  822.       icon%=blk%!24
  823.       name$=
  824. str(blk%+44)
  825.       type%=blk%!40
  826.       inputtype%=0
  827.       
  828.  type% 
  829.         
  830.  &1000
  831. #          leaf$=
  832. scandir(name$)
  833.           
  834. (leaf$)>0 
  835.             
  836.  window% 
  837.               
  838.  convertwin%
  839. '                
  840.  converttype%<>1 
  841. $                  converttype%=2
  842. "                  inputtype%=2
  843.                   leaf$="*"
  844.                 
  845.                   
  846.                 
  847.               
  848.                  inputtype%=1
  849.             
  850.           
  851.         
  852.           
  853.  type%<&1000 
  854. &            leaf$=
  855. leafname(name$)
  856. %            name$=
  857. dirname(name$)
  858.             
  859.  window% 
  860. /              
  861.  -2,controlwin%,controlpane%
  862. '                
  863. locase(leaf$) 
  864. /                  
  865.  "tex","sty","bib","bst"
  866. $                    inputtype%=1
  867.                 
  868.               
  869.  convertwin%
  870. %                
  871. leaf$,"/")>0 
  872. )                  
  873.  converttype%<>2 
  874. &                    converttype%=1
  875. $                    inputtype%=2
  876.                   
  877.                     
  878.                   
  879.                 
  880. )                  
  881.  converttype%<>1 
  882. &                    converttype%=2
  883. $                    inputtype%=2
  884.                   
  885.                     
  886.                   
  887.                 
  888.             
  889.           
  890.       
  891.       
  892.  inputtype% 
  893.         
  894. )!          
  895.  load new document
  896.           act%=0
  897.           
  898.  code% 
  899.             
  900.               
  901.  window% 
  902.                 
  903. /4                  act%=3 : 
  904.  drop dir on iconbar
  905. 0.                
  906.  controlwin%,controlpane%
  907. 1;                  act%=4 : 
  908.  drop dir on control window
  909.               
  910.             
  911.               
  912.  -1) 
  913. 5+                act%=2 : 
  914.  shift-dclick
  915.               
  916. 7D                
  917.  see if mouse button is released within 0.2 sec
  918.                 time%=
  919.                 
  920. :0                  
  921.  "OS_Mouse" 
  922.  ,,buttons%
  923. ;3                
  924. -time%)>20) 
  925.  (buttons%=0)
  926. <0                
  927.  if so, then ignore message
  928. ="                
  929.  buttons%=0 
  930.                   act%=0
  931.                 
  932. @,                  act%=1 : 
  933.  dclick+hold
  934.                 
  935.               
  936.           
  937.           
  938.  act%>0 
  939. E$            
  940.  action%(act%)<>1 
  941.               blk%!12=ref%
  942.               blk%!16=4
  943. H7              
  944.  "Wimp_SendMessage",17,blk%,sender%
  945.             
  946. J"            
  947.  action%(act%) 
  948.               
  949. L1                
  950. control_add(name$+"."+leaf$)
  951. M!                
  952. control_open
  953. N9              
  954.  3 : 
  955. editfile(name$+"."+leaf$,&FFF,1)
  956. O2              
  957.  4 : 
  958. runlatex(name$+"."+leaf$)
  959.             
  960.           
  961.         
  962.           
  963.  name conversion
  964. T'          
  965. convert_add(name$,leaf$)
  966.       
  967.       
  968.  desktop save
  969.       file%=blk%!20
  970. Y"      cmd$="Run "+ApplDir$+
  971. Z+      
  972.  "OS_GBPB",2,file%,cmd$,
  973. (cmd$)
  974.  &502
  975. \*      
  976.  request from !Help application
  977.       hlp$=""
  978.       icon%=blk%!36
  979.       
  980.  blk%!32 
  981.         
  982. a1          hlp$=
  983. msg_lookup1("HLP_IBAR",Appl$)
  984.         
  985.  controlpane%
  986.           
  987.  icon%>=0 
  988. d7            hlp$=
  989. msg_lookup0("HLP_CPANE"+
  990. (icon%))
  991.           
  992.         
  993.  controlwin%
  994. g+          hlp$=
  995. msg_lookup0("HLP_CTRL")
  996.         
  997.  savewin%
  998. i-          hlp$=
  999. msg_lookup0("HLP_CREATE")
  1000.         
  1001.  convertwin%
  1002. k+          hlp$=
  1003. msg_lookup0("HLP_CONV")
  1004. l#          
  1005.  nrofconvertfns%=0 
  1006. m/            hlp$+=
  1007. msg_lookup0("HLP_CONV0")
  1008.           
  1009. o/            hlp$+=
  1010. msg_lookup0("HLP_CONV1")
  1011.           
  1012.       
  1013.       
  1014.  hlp$<>"" 
  1015.         blk%!0=256
  1016.         blk%!12=ref%
  1017.         blk%!16=&503
  1018.         $(blk%+20)=hlp$
  1019. w1        
  1020.  "Wimp_SendMessage",17,blk%,sender%
  1021.       
  1022.  &400C1
  1023.       
  1024. readscreenvars
  1025. receiveack(sender%,ref%,code%)
  1026.  var$,flags%
  1027.  sender%=thistask% 
  1028.  code% 
  1029. A      
  1030.  Message_DataOpen returns unacknowledged -> run editor
  1031.       
  1032.  blk%!40 
  1033. 8        
  1034.  &CE4           : var$="Alias$@RunType_CE4"
  1035. 8        
  1036.  &FFF,&2A7,&2A8 : var$="Alias$@RunType_FFF"
  1037.       
  1038. C      
  1039.  "XOS_ReadVarVal",var$,scrapblk%,&100,0,3 
  1040.  ,,l%;flags%
  1041.       
  1042.  (flags% 
  1043.  1)=0 
  1044. M        
  1045.  "OS_SubstituteArgs",
  1046. str(blk%+44),scrapblk2%,&100,scrapblk%,l%
  1047. *        
  1048.  "Wimp_StartTask",scrapblk2%
  1049.       
  1050. redrawicon(window%,icon%)
  1051. scrapblk%!0=window%
  1052. scrapblk%!4=icon%
  1053. scrapblk%!8=0
  1054. scrapblk%!12=0
  1055.  "Wimp_SetIconState",,scrapblk%
  1056. removefile(fn$)
  1057. fileexists(fn$) 
  1058.  "Wimp_StartTask","Delete "+fn$
  1059. runbibtex(file$)
  1060.  dir$,leaf$,p%,i%,t$
  1061. dir$=
  1062. parentname(file$)
  1063. leaf$=
  1064. leafname(file$)
  1065. fileexists(dir$+".aux") 
  1066. \    
  1067.  "MessageTrans_EnumerateTokens",msgdesc%,"RUN_BIBTEX*",scrapblk%,256,i% 
  1068.  ,,p%,,i%
  1069.  p%<>0 
  1070. .      t$=
  1071. msg_lookup2(
  1072. str(p%),dir$,leaf$)
  1073.        
  1074.  "Wimp_StartTask",t$
  1075.         
  1076.  p%=0
  1077. rundvips(file$)
  1078.  dir$,leaf$,p%,i%,t$
  1079. dir$=
  1080. parentname(file$)
  1081. leaf$=
  1082. leafname(file$)
  1083. fileexists(dir$+".dvi") 
  1084. [    
  1085.  "MessageTrans_EnumerateTokens",msgdesc%,"RUN_DVIPS*",scrapblk%,256,i% 
  1086.  ,,p%,,i%
  1087.  p%<>0 
  1088. .      t$=
  1089. msg_lookup2(
  1090. str(p%),dir$,leaf$)
  1091.        
  1092.  "Wimp_StartTask",t$
  1093.         
  1094.  p%=0
  1095. runlatex(file$)
  1096.  dir$,leaf$,p%,i%,t$
  1097. dir$=
  1098. parentname(file$)
  1099. leaf$=
  1100. leafname(file$)
  1101. locase(leaf$)="tex" 
  1102. [    
  1103.  "MessageTrans_EnumerateTokens",msgdesc%,"RUN_LATEX*",scrapblk%,256,i% 
  1104.  ,,p%,,i%
  1105.  p%<>0 
  1106. .      t$=
  1107. msg_lookup2(
  1108. str(p%),dir$,leaf$)
  1109.        
  1110.  "Wimp_StartTask",t$
  1111.         
  1112.  p%=0
  1113. runtex(file$)
  1114.  dir$,leaf$,p%,i%,t$
  1115. dir$=
  1116. parentname(file$)
  1117. leaf$=
  1118. leafname(file$)
  1119. locase(leaf$)="tex" 
  1120. Y    
  1121.  "MessageTrans_EnumerateTokens",msgdesc%,"RUN_TEX*",scrapblk%,256,i% 
  1122.  ,,p%,,i%
  1123.  p%<>0 
  1124. .      t$=
  1125. msg_lookup2(
  1126. str(p%),dir$,leaf$)
  1127.        
  1128.  "Wimp_StartTask",t$
  1129.         
  1130.  p%=0
  1131.  check directory for file of correct name+type
  1132. scandir(dir$)
  1133.  leaf$,read%,offs%,found%
  1134. found%=
  1135.  "OS_GBPB",10,dir$,scrapblk%,1,offs%,256,"*" 
  1136.  ,,,read%,offs%
  1137.  (read%>0) 
  1138.  ((scrapblk%!16 
  1139.  1) <> 0) 
  1140.      leaf$=
  1141. str(scrapblk%+20)
  1142. locase(leaf$) 
  1143. #      
  1144.  "tex","sty","bib","bst"
  1145. *        
  1146.  ((scrapblk%!0)>>8) 
  1147.  &FFF 
  1148. .          
  1149.  &FFF,&2A7,&2A8,&FE4 : found%=
  1150.         
  1151.         
  1152.  (offs%=-1) 
  1153.  (found%)
  1154.  found% 
  1155.  leaf$=""
  1156. =leaf$
  1157. selecticon(window%,icon%,flag%)
  1158.  oldflag%
  1159. scrapblk%!0=window%
  1160. scrapblk%!4=icon%
  1161.  "Wimp_GetIconState",,scrapblk%
  1162. %oldflag%=(scrapblk%!24) 
  1163.  (1<<21)
  1164.  flag% 
  1165.   scrapblk%!8=1<<21
  1166.   scrapblk%!8=0
  1167. scrapblk%!12=1<<21
  1168.  oldflag%<>scrapblk%!8 
  1169.  only set when changing
  1170.  "Wimp_SetIconState",,scrapblk%
  1171. shadeicon(window%,icon%,f%)
  1172. scrapblk%!0=window%
  1173. scrapblk%!4=icon%
  1174.   scrapblk%!8=(1<<22)
  1175.   scrapblk%!8=0
  1176. scrapblk%!12=1<<22
  1177.  "Wimp_SetIconState",,scrapblk%
  1178. showmenu(menu%,icon%,blkptr%)
  1179.  menu%<>0 
  1180.   lastmenu%=menu%
  1181.   lastmenu_icon%=icon%
  1182.  lastmenu%=mainmenu% 
  1183. (  $(savefname%)=
  1184. msg_lookup0("NDOC")
  1185.  "MenuUtil_Show",menu%,blkptr%
  1186. startsavedialogue
  1187.  dragasprite% 
  1188.  "DragASprite_Stop"
  1189. blk%!0=256
  1190. blk%!12=0
  1191. ""blk%!16=1 : 
  1192.  Message_DataSave
  1193.  "Wimp_GetPointerInfo",,ptrinfo%
  1194. blk%!20=ptrinfo%!12
  1195. blk%!24=ptrinfo%!16
  1196. blk%!28=ptrinfo%!0
  1197. blk%!32=ptrinfo%!4
  1198. blk%!36=0
  1199.  savefromwin% 
  1200.  savewin%
  1201.     blk%!40=&1000
  1202. ,.    $(blk%+44)=
  1203. leafname($(savefname%))+
  1204.  convertwin%
  1205.     blk%!40=&1000
  1206. /.    $(blk%+44)=
  1207. leafname(convertfn$(1))+
  1208. 2        
  1209.  "Wimp_SendMessage",17,blk%,ptrinfo%!12,ptrinfo%!16
  1210. startsavedrag(window%,icon%)
  1211.  b%,win0x%,win0y%
  1212. scrapblk%!0=window%
  1213.  "Wimp_GetWindowState",,scrapblk%
  1214. ;#win0x%=scrapblk%!4-scrapblk%!20
  1215. <$win0y%=scrapblk%!16-scrapblk%!24
  1216. scrapblk%!0=window%
  1217. scrapblk%!4=icon%
  1218.  "Wimp_GetIconState",,scrapblk%
  1219. blk%!4=5
  1220. blk%!8=scrapblk%!8+win0x%
  1221. blk%!12=scrapblk%!12+win0y%
  1222. blk%!16=scrapblk%!16+win0x%
  1223. blk%!20=scrapblk%!20+win0y%
  1224.  "Wimp_GetPointerInfo",,ptrinfo%
  1225. blk%!24=blk%!8-ptrinfo%!0
  1226. blk%!28=blk%!12-ptrinfo%!4
  1227. H,blk%!32=screensize_x%+blk%!16-ptrinfo%!0
  1228. I,blk%!36=screensize_y%+blk%!20-ptrinfo%!4
  1229.  "OS_Byte",161,&1C 
  1230.  ,,b%
  1231. dragasprite%=(b% 
  1232.  2)<>0
  1233.  dragasprite% 
  1234.  "DragASprite_Start",&A1,1,$(scrapblk%!28),blk%+8,blk%+24
  1235.  "Wimp_DragBox",1,blk%
  1236. savefromwin%=window%
  1237. str(s%)
  1238.  i%,n$
  1239.  (s%?i%>=32) 
  1240.  (i%<255)
  1241.   n$+=
  1242. (s%?i%)
  1243.   i%+=1
  1244. tidydir(dir$)
  1245.  p%,i%,t$
  1246.  "MessageTrans_EnumerateTokens",msgdesc%,"TIDY_EXT*",scrapblk%,256,i% 
  1247.  ,,p%,,i%
  1248.  p%<>0 
  1249. b!    t$=
  1250. msg_lookup0(
  1251. str(p%))
  1252. c     
  1253. removefile(dir$+"."+t$)
  1254.  p%=0
  1255.