?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  2. ;@                                                                            @
  3. ;@                               N o t e p a d                                @
  4. ;@                                                                            @
  5. ;@             (c) 2012-2014 by Prodatron / SymbiosiS (JЎrn Mika)             @
  6. ;@                                                                            @
  7. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  8.  
  9. ;Todo
  10. ;- find nach doc-ende von vorne anfangen bis curpos
  11. ;- commands 29-31 focus setzen!
  12.  
  13.  
  14. ;--- PROGRAM-ROUTINES ---------------------------------------------------------
  15. ;### PRGKEY -> Check key
  16. ;### PRGINF -> show info-box
  17. ;### PRGEND -> quit application
  18. ;### PRGPAR -> Search for command line parameter (textfile)
  19.  
  20. ;--- SUB-ROUTINES -------------------------------------------------------------
  21. ;### DIACNC -> Cancel dialogue
  22. ;### MSGGET -> check for message for application
  23. ;### CLCDEZ -> Converts byte into 2 decimal digits
  24. ;### CLCNUM -> Converts 16bit number into ASCII string (terminated by 0)
  25. ;### CLCR16 -> Converts string into 16bit number
  26.  
  27. ;--- CONFIG-ROUTINES ----------------------------------------------------------
  28. ;### CFGGET -> Generates config path
  29. ;### CFGLOD -> Loads config
  30. ;### CFGINI -> Initialize config
  31. ;### CFGFNT -> Loads font
  32. ;### CFGSAV -> Save config
  33. ;### CFGOPN -> Open config-dialogue
  34. ;### CFGCOL -> Updates colour preview
  35. ;### CFGOKY -> Close config-dialogue and save config
  36. ;### CFGWRP -> Switch between "wrap at window border" and "no wrap"
  37. ;### CFGBAR -> Switches the status bar on/off
  38.  
  39. ;--- FILE-ROUTINES ------------------------------------------------------------
  40. ;### FILMOD -> Ask for file-saving, if text has been modified
  41. ;### FILNEW -> New file
  42. ;### FILOPN -> Open file
  43. ;### FILSAS -> Save file as
  44. ;### FILSAV -> Save file
  45. ;### FILLOD -> load selected textfile
  46. ;### FILSTO -> save actual textfile
  47. ;### FILTIT -> Refreshes window title with filename
  48.  
  49. ;--- EDIT-ROUTINES ------------------------------------------------------------
  50. ;### EDTCHG -> Editor changed
  51. ;### EDTCUT -> Edit Cut
  52. ;### EDTCOP -> Edit Copy
  53. ;### EDTPAS -> Edit Paste
  54. ;### EDTSAL -> Edit Select All
  55. ;### EDTDEL -> Edit Delete
  56. ;### EDTGOT -> Edit Goto
  57. ;### EDTTIM -> Edit Date/Time
  58.  
  59. ;--- FIND- AND REPLACE-ROUTINES -----------------------------------------------
  60. ;### FNDFND -> Opens Find-Dialogue
  61. ;### FNDREP -> Opens Replace-Dialogue
  62. ;### FNDFOK -> Start Find
  63. ;### FNDROK -> Start Replace
  64. ;### FNDRDR -> Replace-Dialogue -> Replace
  65. ;### FNDRDA -> Replace-Dialogue -> Replace All
  66. ;### FNDRAL -> Start Replace all
  67. ;### FNDFNX -> Find next
  68. ;### FNDRPL -> Replaces text
  69. ;### FNDSEA -> Searches for text
  70. ;### FNDCAS -> Converts char into lcase, if case-flag is not set
  71. ;### FNDALN -> Checks, if word only + char is alphanumeric
  72. ;### FNDPLF -> Converts ^P into 13+10
  73. ;### FNDLFP -> Converts 13+10 into ^P
  74. ;### FNDGOT -> Goto
  75.  
  76. ;--- DOCUMENT-ROUTINES --------------------------------------------------------
  77. ;### DOCINI -> initialise loaded document
  78. ;### DOCNEW -> clears and initialise document
  79. ;### DOCRFS -> refresh document display
  80.  
  81.  
  82.  
  83. ;==============================================================================
  84. ;### CODE AREA ################################################################
  85. ;==============================================================================
  86.  
  87. ;### PRGPRZ -> Application process
  88. prgwin      db 0    ;main     window ID
  89. diawin      db 0    ;dialogue window ID
  90. windatsup   equ 51
  91.  
  92. prgprz  call prgpar
  93.         call cfglod
  94.         call cfgini
  95.         call SySystem_HLPINI
  96.  
  97.         ld a,(prgbnknum)
  98.         ld de,prgwindat
  99.         call SyDesktop_WINOPN
  100.         jp c,prgend             ;memory full -> quit process
  101.         ld (prgwin),a           ;window has been opened -> store ID
  102.  
  103.         ld a,(prgparf)
  104.         or a
  105.         call nz,fillod
  106.         call edtchg1
  107.  
  108. prgprz1 call msgget             ;*** check for messages
  109.         jr c,prgprz2
  110.         jr prgprz1
  111. prgprz0 rst #30
  112.         call msgget0
  113.         jr c,prgprz2
  114.         call edtchg0
  115.         jr prgprz1
  116. prgprz2 cp MSR_DSK_WCLICK       ;* window has been clicked?
  117.         jr nz,prgprz0
  118.         ld a,(diawin)
  119.         cp (iy+1)
  120.         ld a,(iy+2)
  121.         jr nz,prgprz3
  122.         cp DSK_ACT_CLOSE        ;* setup-close clicked
  123.         jp z,diacnc
  124. prgprz3 cp DSK_ACT_CLOSE        ;* main-close clicked
  125.         jr z,prgend0
  126.         cp DSK_ACT_MENU         ;* menu has been clicked
  127.         jr z,prgprz4
  128.         cp DSK_ACT_KEY          ;* key has been clicked
  129.         jr z,prgkey
  130.         cp DSK_ACT_CONTENT      ;* content clicked
  131.         jr nz,prgprz0
  132. prgprz4 ld l,(iy+8)
  133.         ld h,(iy+9)
  134.         ld a,l
  135.         or h
  136.         jr z,prgprz0
  137.         ld a,(iy+3)             ;A=click type (0/1/2=mouse left/right/double, 7=keyboard)
  138.         jp (hl)
  139.  
  140. ;### PRGKEY -> Check key
  141. prgkeya equ 8
  142. prgkeyt db "N"-64:dw filnew ;CTRL+N = New
  143.         db "O"-64:dw filopn ;CTRL+O = Open
  144.         db "S"-64:dw filsav ;CTRL+S = Save
  145.         db "F"-64:dw fndfnd ;CTRL+F = Find
  146.         db 143:dw fndfnx    ;F3     = Find next
  147.         db "R"-64:dw fndrep ;CTRL+R = Replace
  148.         db "G"-64:dw edtgot ;CTRL+G = Goto
  149.         db 145:dw edttim    ;F5     = Date/Time
  150.  
  151. prgkey  ld hl,prgkeyt
  152.         ld b,prgkeya
  153.         ld de,3
  154.         ld a,(iy+4)
  155. prgkey1 ld c,(hl)
  156.         cp c
  157.         jr z,prgkey2
  158.         add hl,de
  159.         djnz prgkey1
  160.         jp prgprz0
  161. prgkey2 inc hl
  162.         ld a,(hl)
  163.         inc hl
  164.         ld h,(hl)
  165.         ld l,a
  166.         ld a,7
  167.         jp (hl)
  168.  
  169. ;### PRGHLP -> show help
  170. prghlp  call SySystem_HLPOPN
  171.         jp prgprz0
  172.  
  173. ;### PRGINF -> show info-box
  174. prginf  ld hl,prgtxtinf         ;*** info box
  175.         ld b,1+128+64
  176. prginf1 call prginf0
  177.         jp prgprz0
  178. prginf0 ld a,(prgbnknum)
  179.         ld de,prgwindat
  180.         jp SySystem_SYSWRN
  181.  
  182. ;### PRGEND -> quit application
  183. prgend0 call filmod
  184.         jp c,prgprz0
  185. prgend  ld hl,(prgcodbeg+prgpstnum)
  186.         call SySystem_PRGEND
  187. prgend1 rst #30                     ;wait for death
  188.         jr prgend1
  189.  
  190. ;### PRGPAR -> Search for command line parameter (textfile)
  191. prgparf db 0                    ;flag, if command line parameter exists
  192.  
  193. prgpar  ld hl,(prgcodbeg)       ;search for command line parameter
  194.         ld de,prgcodbeg
  195.         dec h
  196.         add hl,de               ;HL=code area end=path
  197.         ld b,255
  198. prgpar1 ld a,(hl)
  199.         or a
  200.         ret z
  201.         cp 32
  202.         jr z,prgpar2
  203.         inc hl
  204.         djnz prgpar1
  205.         ret
  206. prgpar2 ld (hl),0
  207.         inc hl
  208.         ld de,docpth
  209.         ld bc,255
  210.         ld a,c
  211.         ld (prgparf),a
  212.         ldir
  213. prgpar3 ret
  214.  
  215.  
  216. ;==============================================================================
  217. ;### SUB-ROUTINES #############################################################
  218. ;==============================================================================
  219.  
  220. ;### DIACNC -> Cancel dialogue
  221. diacnc  ld a,(diawin)
  222.         call SyDesktop_WINCLS
  223.         jp prgprz0
  224.  
  225. ;### MSGGET -> check for message for application
  226. ;### Output     CF=0 -> no message, CF=1 -> IXH=sender, (AppMsgB)=message, A=(AppMsgB+0), IY=AppMsgB
  227. msgget  call msgget2            ;** sleep
  228.         rst #08
  229.         jr msgget1
  230. msgget0 call msgget2            ;** no sleep
  231.         rst #18                 ;get Message -> IXL=Status, IXH=sender ID
  232. msgget1 or a
  233.         db #dd:dec l
  234.         ret nz
  235.         ld iy,AppMsgB
  236.         ld a,(iy+0)
  237.         or a
  238.         jp z,prgend
  239.         scf
  240.         ret
  241. msgget2 ld a,(AppPrzN)
  242.         db #dd:ld l,a           ;IXL=our own process ID
  243.         db #dd:ld h,-1          ;IYL=sender ID (-1 = receive messages from any sender)
  244.         ld iy,AppMsgB           ;IY=Messagebuffer
  245.         ret
  246.  
  247. ;### CLCDEZ -> Converts byte into 2 decimal digits
  248. ;### Input      A=Value
  249. ;### Output     L=10-digit, H=1-digit
  250. ;### Destroyed  AF
  251. clcdez  ld l,0
  252. clcdez1 sub 10
  253.         jr c,clcdez2
  254.         inc l
  255.         jr clcdez1
  256. clcdez2 add "0"+10
  257.         ld h,a
  258.         ld a,"0"
  259.         add l
  260.         ld l,a
  261.         ret
  262.  
  263. ;### CLCNUM -> Converts 16bit number into ASCII string (terminated by 0)
  264. ;### Input      IX=value, IY=address, E=max digits
  265. ;### Output     (IY)=last digit
  266. ;### Destroyed  AF,BC,DE,HL,IX,IY
  267. clcnumt dw 1,10,100,1000,10000
  268. clcnum  ld d,0
  269.         ld b,e
  270.         dec e
  271.         push ix
  272.         pop hl
  273.         ld ix,clcnumt
  274.         add ix,de
  275.         add ix,de               ;IX=first divider
  276.         dec b
  277.         jr z,clcnum4
  278.         ld c,0
  279. clcnum1 ld e,(ix)
  280.         ld d,(ix+1)
  281.         dec ix
  282.         dec ix
  283.         ld a,"0"
  284.         or a
  285. clcnum2 sbc hl,de
  286.         jr c,clcnum5
  287.         inc c
  288.         inc a
  289.         jr clcnum2
  290. clcnum5 add hl,de
  291.         inc c
  292.         dec c
  293.         jr z,clcnum3
  294.         ld (iy+0),a
  295.         inc iy
  296. clcnum3 djnz clcnum1
  297. clcnum4 ld a,"0"
  298.         add l
  299.         ld (iy+0),a
  300.         ld (iy+1),0
  301.         ret
  302.  
  303. ;### CLCR16 -> Converts string into 16bit number
  304. ;### Input      IX=string, A=terminator, BC=min (>=0), DE=max (<=65534)
  305. ;### Output     IX=string behind terminator, HL=number, CF=1 -> invalid (too big/small, wrong chars/terminator)
  306. ;### Destroyed  AF,DE,IYL
  307. clcr16  ld hl,0
  308.         db #fd:ld l,a
  309. clcr161 ld a,(ix+0)
  310.         inc ix
  311.         db #fd:cp l
  312.         jr z,clcr163
  313.         sub "0"
  314.         ret c
  315.         cp 10
  316.         ccf
  317.         ret c
  318.         push bc
  319.         add hl,hl:jr c,clcr162
  320.         ld c,l
  321.         ld b,h
  322.         add hl,hl:jr c,clcr162
  323.         add hl,hl:jr c,clcr162
  324.         add hl,bc:jr c,clcr162
  325.         ld c,a
  326.         ld b,0
  327.         add hl,bc:ret c
  328.         pop bc
  329.         jr clcr161
  330. clcr162 pop bc
  331.         ret
  332. clcr163 sbc hl,bc
  333.         ret c
  334.         add hl,bc
  335.         inc de
  336.         sbc hl,de
  337.         ccf
  338.         ret c
  339.         add hl,de
  340.         or a
  341.         ret
  342.  
  343. SySystem_HLPFLG db 0    ;flag, if HLP-path is valid
  344. SySystem_HLPPTH db "%help.exe "
  345. SySystem_HLPPTH1 ds 128
  346. SySHInX db ".HLP",0
  347.  
  348. SySystem_HLPINI
  349.         ld hl,(prgcodbeg)
  350.         ld de,prgcodbeg
  351.         dec h
  352.         add hl,de                   ;HL = CodeEnd = Command line
  353.         ld de,SySystem_HLPPTH1
  354.         ld bc,0
  355.         db #dd:ld l,128
  356. SySHIn1 ld a,(hl)
  357.         or a
  358.         jr z,SySHIn3
  359.         cp " "
  360.         jr z,SySHIn3
  361.         cp "."
  362.         jr nz,SySHIn2
  363.         ld c,e
  364.         ld b,d
  365. SySHIn2 ld (de),a
  366.         inc hl
  367.         inc de
  368.         db #dd:dec l
  369.         ret z
  370.         jr SySHIn1
  371. SySHIn3 ld a,c
  372.         or b
  373.         ret z
  374.         ld e,c
  375.         ld d,b
  376.         ld hl,SySHInX
  377.         ld bc,5
  378.         ldir
  379.         ld a,1
  380.         ld (SySystem_HLPFLG),a
  381.         ret
  382.  
  383. SySystem_HLPOPN
  384.         ld a,(SySystem_HLPFLG)
  385.         or a
  386.         ret z
  387.         ld hl,SySystem_HLPPTH
  388.         ld a,(prgbnknum)
  389.         jp SySystem_PRGRUN
  390.  
  391.  
  392. ;==============================================================================
  393. ;### CONFIG-ROUTINES ##########################################################
  394. ;==============================================================================
  395.  
  396. cfgnam  db "notepad.dat",0
  397. cfgnam0
  398. cfgpth  dw 0
  399.  
  400. ;### CFGGET -> Generates config path
  401. cfgget  ld hl,(prgcodbeg)
  402.         ld de,prgcodbeg
  403.         dec h
  404.         add hl,de           ;HL = CodeEnd = path
  405.         ld (cfgpth),hl
  406.         ld e,l
  407.         ld d,h              ;DE=HL
  408.         ld b,255
  409. cfgget1 ld a,(hl)           ;search end of path
  410.         or a
  411.         jr z,cfgget2
  412.         inc hl
  413.         djnz cfgget1
  414.         jr cfgget4
  415.         ld a,255
  416.         sub b
  417.         jr z,cfgget4
  418.         ld b,a
  419. cfgget2 ld (hl),0
  420.         dec hl              ;search start of filename
  421.         call cfgget5
  422.         jr z,cfgget3
  423.         djnz cfgget2
  424.         jr cfgget4
  425. cfgget3 inc hl
  426.         ex de,hl
  427. cfgget4 ld hl,cfgnam        ;replace application filename with config filename
  428.         ld bc,cfgnam0-cfgnam
  429.         ldir
  430.         ret
  431. cfgget5 ld a,(hl)
  432.         cp "/"
  433.         ret z
  434.         cp "\\"
  435.         ret z
  436.         cp ":"
  437.         ret
  438.  
  439. ;### CFGLOD -> Loads config
  440. cfglod  call cfgget
  441.         ld hl,(cfgpth)
  442.         ld a,(prgbnknum)
  443.         db #dd:ld h,a
  444.         call SySystem_CallFunction
  445.         db MSC_SYS_SYSFIL
  446.         db FNC_FIL_FILOPN           ;open file
  447.         ret c
  448.         ld hl,cfgdat
  449.         ld bc,16+128
  450.         ld de,(prgbnknum)
  451.         push af
  452.         call SySystem_CallFunction
  453.         db MSC_SYS_SYSFIL
  454.         db FNC_FIL_FILINP           ;load configdata
  455.         pop af
  456.         call SySystem_CallFunction
  457.         db MSC_SYS_SYSFIL
  458.         db FNC_FIL_FILCLO           ;close file
  459.         ret
  460.  
  461. ;### CFGINI -> Initialize config
  462. cfgini  ld hl,prgwinmen4+2
  463.         ld de,cfgdatsta
  464.         ld a,(de)
  465.         add a
  466.         res 1,(hl)
  467.         or (hl)
  468.         ld (hl),a
  469.         and 2
  470.         call cfgbar1
  471.         jr nz,cfgini0
  472.         ld de,10
  473.         ld hl,(prgwindat+10)
  474.         add hl,de
  475.         ld (prgwindat+10),hl
  476. cfgini0 ld hl,(cfgdatpap)
  477.         ld a,h
  478.         add a:add a:add a:add a
  479.         add l
  480.         ld (txtmulobj+texdatcol),a
  481.         ld a,(cfgdattab)
  482.         ld (txtmulobj+texdattab),a
  483.         ld hl,txtmulobj+texdatfg2
  484.         res 0,(hl)
  485.         ld a,(cfgdatwrp)
  486.         cp 1
  487.         jr c,cfgini2
  488.         set 0,(hl)
  489.         ld hl,-1
  490.         jr nz,cfgini1
  491.         ld hl,(cfgdatwps)
  492. cfgini1 ld (txtmulobj+texdatxmx),hl
  493. cfgini2 ld a,(cfgfntnum)
  494.         inc a
  495.         ld (fntselobj),a
  496.         dec a
  497.         jr z,cfgfnt
  498.         db #fd:ld l,a
  499.         add a
  500.         ld l,a
  501.         ld h,0
  502.         ld de,cfgfntdat
  503.         add hl,de
  504.         ld ix,fntsellst+4
  505.         xor a
  506. cfgini3 ld (ix+2),l
  507.         ld (ix+3),h
  508.         ld de,4
  509.         add ix,de
  510.         ld bc,-1
  511.         cpir
  512.         db #fd:dec l
  513.         jr nz,cfgini3
  514.         call cfgwrp0
  515.         jr cfgfnt
  516.  
  517. ;### CFGFNT -> Loads font
  518. cfgfntl db -1   ;last loaded font
  519. cfgfnt  ld hl,txtmulobj+texdatflg
  520.         res 3,(hl)
  521.         ld a,(cfgdatfnt)
  522.         or a
  523.         ret z
  524.         ld hl,cfgfntl
  525.         cp (hl)
  526.         jr z,cfgfnt1
  527.         push af
  528.         ld hl,(cfgpth)
  529.         ld a,(prgbnknum)
  530.         db #dd:ld h,a
  531.         call SySystem_CallFunction
  532.         db MSC_SYS_SYSFIL
  533.         db FNC_FIL_FILOPN           ;open file
  534.         pop bc
  535.         ret c
  536.         push af
  537.         ld c,a
  538.         ld a,b
  539.         add a
  540.         ld l,a
  541.         ld h,0
  542.         ld de,cfgfntdat-2
  543.         add hl,de
  544.         ld a,(hl):db #dd:ld l,a
  545.         inc hl
  546.         ld a,(hl):db #dd:ld h,a
  547.         ld a,c
  548.         ld iy,0
  549.         ld c,0
  550.         call SySystem_CallFunction
  551.         db MSC_SYS_SYSFIL
  552.         db FNC_FIL_FILPOI           ;move to font data
  553.         pop bc
  554.         jr c,cfgfnt0
  555.         ld a,b
  556.         ld hl,txtbufmem
  557.         ld bc,txtbufmax+1
  558.         add hl,bc
  559.         ld (txtmulobj+texdatfnt),hl
  560.         ld bc,96*16+2
  561.         ld de,(prgbnknum)
  562.         push af
  563.         call SySystem_CallFunction
  564.         db MSC_SYS_SYSFIL
  565.         db FNC_FIL_FILINP           ;load font
  566.         pop bc
  567.         jr c,cfgfnt0
  568.         call cfgfnt1
  569.         ld a,(cfgdatfnt)
  570.         ld (cfgfntl),a
  571. cfgfnt0 ld a,b
  572.         call SySystem_CallFunction
  573.         db MSC_SYS_SYSFIL
  574.         db FNC_FIL_FILCLO           ;close file
  575.         ret
  576. cfgfnt1 ld hl,txtmulobj+texdatflg
  577.         set 3,(hl)
  578.         ret
  579.  
  580. ;### CFGSAV -> Save config
  581. cfgsav  ld hl,(cfgpth)      ;open config file
  582.         ld a,(prgbnknum)
  583.         db #dd:ld h,a
  584.         xor a
  585.         call SySystem_CallFunction
  586.         db MSC_SYS_SYSFIL
  587.         db FNC_FIL_FILOPN
  588.         ret c
  589.         ld de,(prgbnknum)   ;save config
  590.         ld hl,cfgdat
  591.         ld bc,16
  592.         push af
  593.         call SySystem_CallFunction
  594.         db MSC_SYS_SYSFIL
  595.         db FNC_FIL_FILOUT
  596.         pop af              ;close config file
  597.         call SySystem_CallFunction
  598.         db MSC_SYS_SYSFIL
  599.         db FNC_FIL_FILCLO
  600.         ret
  601.  
  602. ;### CFGOPN -> Open config-dialogue
  603. cfgopn  ld a,(cfgdatwrp)
  604.         ld (cfgwinwrp),a
  605.         ld ix,(cfgdatwps)
  606.         ld iy,cfgwinbuf1
  607.         ld e,4
  608.         call cfgopn1
  609.         ld ix,(cfgdattab)
  610.         db #dd:ld h,0
  611.         ld iy,cfgwinbuf2
  612.         ld e,2
  613.         call cfgopn1
  614.         ld bc,(fntselobj-1)
  615.         ld hl,fntsellst+1
  616.         ld de,4
  617. cfgopn2 res 7,(hl)
  618.         add hl,de
  619.         djnz cfgopn2
  620.         ld a,(cfgdatfnt)
  621.         ld (fntselobj+12),a
  622.         add a:add a
  623.         ld l,a
  624.         ld h,0
  625.         ld de,fntsellst+1
  626.         add hl,de
  627.         set 7,(hl)
  628.         ld a,(cfgdatpap)
  629.         ld (papselobj+12),a
  630.         ld c,a
  631.         ld a,(cfgdatpen)
  632.         ld (penselobj+12),a
  633.         call cfgcol0
  634.         ld de,cfgwindat
  635. cfgopn0 ld a,(prgbnknum)
  636.         call SyDesktop_WINOPN
  637.         jp c,prgprz0            ;memory full -> ignore
  638.         ld (diawin),a           ;window has been opened -> store ID
  639.         inc a
  640.         ld (prgwindat+windatsup),a
  641.         jp prgprz0
  642. cfgopn1 push iy
  643.         call clcnum
  644.         ex (sp),iy
  645.         pop hl
  646.         db #fd:ld e,l
  647.         db #fd:ld d,h
  648.         or a
  649.         sbc hl,de
  650.         inc l
  651.         ld (iy-6),l
  652.         ld (iy-10),l
  653.         ret
  654.  
  655. ;### CFGCOL -> Updates colour preview
  656. cfgcol  call cfgcol0
  657.         ld a,(diawin)
  658.         ld e,8
  659.         call SyDesktop_WINDIN
  660.         jp prgprz0
  661. cfgcol0 ld a,(penselobj+12)
  662.         add a:add a:add a:add a
  663.         ld hl,papselobj+12
  664.         add (hl)
  665.         ld (cfgwindsc8+2),a
  666.         ret
  667.  
  668. ;### CFGOKY -> Close config-dialogue and save config
  669. cfgoky  ld a,(cfgwinwrp)
  670.         ld (cfgdatwrp),a
  671.         ld ix,cfgwinbuf1
  672.         xor a
  673.         ld bc,50
  674.         ld de,9999
  675.         call clcr16
  676.         jr c,cfgoky1
  677.         ld (cfgdatwps),hl
  678. cfgoky1 ld ix,cfgwinbuf2
  679.         xor a
  680.         ld bc,1
  681.         ld de,99
  682.         call clcr16
  683.         jr c,cfgoky1
  684.         ld a,l
  685.         ld (cfgdattab),a
  686. cfgoky2 ld a,(fntselobj+12)
  687.         ld (cfgdatfnt),a
  688.         ld a,(papselobj+12)
  689.         ld (cfgdatpap),a
  690.         ld a,(penselobj+12)
  691.         ld (cfgdatpen),a
  692.         call cfgsav
  693.         call cfgini
  694.         call docrfs
  695.         jp diacnc
  696.  
  697. ;### CFGWRP -> Switch between "wrap at window border" and "no wrap"
  698. cfgwrp  ld a,(cfgdatwrp)
  699.         or a
  700.         ld a,2
  701.         jr z,cfgwrp2
  702.         xor a
  703. cfgwrp2 ld (cfgdatwrp),a
  704.         call cfgwrp0
  705.         call cfgini
  706.         call docrfs
  707.         jp prgprz0
  708. cfgwrp0 ld a,(cfgdatwrp)
  709.         or a
  710.         ld a,3
  711.         jr z,cfgwrp1
  712.         ld a,1
  713. cfgwrp1 ld (prgwinmen3+2),a
  714.         ret
  715.  
  716. ;### CFGBAR -> Switches the status bar on/off
  717. cfgbar  ld hl,prgwinmen4+2
  718.         ld de,cfgdatsta
  719.         ld a,(hl)               ;modify menu
  720.         xor 2
  721.         ld (hl),a
  722.         and 2
  723.         rra
  724.         ld (de),a
  725.         call cfgbar1
  726.         ld de,10
  727.         jr z,cfgbar2
  728.         call edtchg5
  729.         ld de,-10
  730. cfgbar2 ld hl,(prgwindat+10)
  731.         add hl,de
  732.         ld (prgwindat+10),hl
  733.         ld a,(prgwindat)
  734.         cp 2
  735.         ld a,(prgwin)
  736.         push af
  737.         call z,SyDesktop_WINMAX
  738.         pop af
  739.         call nz,SyDesktop_WINMID
  740.         jp prgprz0
  741. cfgbar1 ld hl,prgwindat+1
  742.         res 6,(hl)
  743.         ret z
  744.         set 6,(hl)
  745.         ret
  746.  
  747.  
  748. ;==============================================================================
  749. ;### FILE-ROUTINES ############################################################
  750. ;==============================================================================
  751.  
  752. ;### FILMOD -> Ask for file-saving, if text has been modified
  753. ;### Output     CF=0 ok, CF=1 cancel
  754. filmod  ld a,(txtmulobj+texdatflg)
  755.         rla
  756.         ret nc
  757.         ld hl,prgtxtsav
  758.         ld b,8*4+3+64
  759.         call prginf0
  760.         cp 1
  761.         ret c
  762.         sub 4
  763.         ret z
  764.         ccf
  765.         ret c
  766.         jp filsav0
  767.  
  768. ;### FILNEW -> New file
  769. filnew  call filmod
  770.         jp c,prgprz0
  771.         call docnew
  772.         call docrfs
  773.         jp prgprz0
  774.  
  775. ;### FILOPN -> Open file
  776. filopn  call filmod
  777.         jp c,prgprz0
  778.         xor a
  779.         call filopn0
  780.         or a
  781.         call z,fillod
  782.         jp prgprz0
  783. filopn0 ld hl,prgbnknum
  784.         add (hl)
  785.         ld hl,docmsk
  786.         ld c,8
  787.         ld ix,100
  788.         ld iy,5000
  789.         ld de,prgwindat
  790.         jp SySystem_SELOPN
  791.  
  792. ;### FILSAS -> Save file as
  793. filsas  call filsav1
  794.         call filtit
  795.         jp prgprz0
  796.  
  797. ;### FILSAV -> Save file
  798. filsav  call filsav0
  799.         jp prgprz0
  800. ;-> CF=1 cancel
  801. filsav0 ld a,(docpth)
  802.         or a
  803.         jr nz,filsav2
  804. filsav1 ld a,64
  805.         call filopn0
  806.         or a
  807.         scf
  808.         ret nz
  809. filsav2 call filsto
  810.         or a
  811.         ret
  812.  
  813. ;### FILLOD -> load selected textfile
  814. fillode dw prgtxterr1,prgtxterr2,prgtxterr3,prgtxterr4
  815.  
  816. fillod  ld hl,docpth
  817.         ld a,(prgbnknum)
  818.         db #dd:ld h,a
  819.         call SySystem_CallFunction
  820.         db MSC_SYS_SYSFIL
  821.         db FNC_FIL_FILOPN           ;open file
  822.         ld e,2      ;2=error while loading file
  823.         jr c,fillod5
  824.         push af
  825.         ld hl,txtbufmem
  826.         ld bc,txtbufmax
  827.         add hl,bc
  828.         ld (hl),0
  829.         sbc hl,bc
  830.         ld de,(prgbnknum)
  831.         call SySystem_CallFunction
  832.         db MSC_SYS_SYSFIL
  833.         db FNC_FIL_FILINP           ;load textdata
  834.         pop de
  835.         push bc
  836.         push af
  837.         ld a,d
  838.         call SySystem_CallFunction
  839.         db MSC_SYS_SYSFIL
  840.         db FNC_FIL_FILCLO           ;close file
  841.         pop af
  842.         pop bc
  843.         ld e,2      ;2=error while loading file
  844.         jr c,fillod3
  845.         ld hl,txtbufmem
  846.         add hl,bc
  847.         ld e,0      ;0=ok
  848.         ld (hl),e
  849.         jr nz,fillod1
  850.         inc e       ;1=memory full (only the first part of the file has been loaded)
  851. fillod1 push de         ;loading ok -> init text
  852.         call docini
  853.         call filtit
  854.         jr fillod4
  855. fillod3 push de         ;error while loading -> clear text
  856.         call docnew
  857. fillod4 call docrfs
  858.         pop de
  859. fillod5 inc e:dec e
  860.         ret z
  861.         ld l,e          ;show error message
  862.         ld h,0
  863.         add hl,hl
  864.         ld bc,fillode-2
  865.         add hl,bc
  866.         ld a,(hl)
  867.         inc hl
  868.         ld h,(hl)
  869.         ld l,a
  870.         ld b,1+64
  871.         call prginf0
  872.         jp prgprz0
  873.  
  874. ;### FILSTO -> save actual textfile
  875. filsto  ld hl,txtmulobj+texdatflg   ;reset modified-bit
  876.         res 7,(hl)
  877.         ld hl,docpth
  878.         ld a,(prgbnknum)
  879.         db #dd:ld h,a
  880.         xor a
  881.         call SySystem_CallFunction
  882.         db MSC_SYS_SYSFIL
  883.         db FNC_FIL_FILNEW           ;create file
  884.         ld e,3      ;3=error while writing file
  885.         jr c,fillod5
  886.         push af
  887.         ld hl,txtbufmem
  888.         ld bc,(txtmulobj+texdatlen)
  889.         add hl,bc
  890.         ld (hl),26
  891.         push hl
  892.         sbc hl,bc
  893.         inc bc
  894.         ld de,(prgbnknum)
  895.         call SySystem_CallFunction
  896.         db MSC_SYS_SYSFIL
  897.         db FNC_FIL_FILOUT           ;save textdata
  898.         pop hl
  899.         ld (hl),0
  900.         pop de
  901.         push af
  902.         ld a,d
  903.         call SySystem_CallFunction
  904.         db MSC_SYS_SYSFIL
  905.         db FNC_FIL_FILCLO           ;close file
  906.         pop af
  907.         ld e,3      ;3=error while writing file
  908.         jr c,fillod5
  909.         inc e       ;4=device full (only part of the text has been saved)
  910.         or a
  911.         jr nz,fillod5
  912.         ld e,a      ;0=ok
  913.         jr fillod5
  914.  
  915. ;### FILTIT -> Refreshes window title with filename
  916. filtitt db " - Notepad",0
  917.  
  918. filtit  ld hl,docpth
  919.         ld e,l:ld d,h
  920. filtit1 call cfgget5
  921.         inc hl
  922.         jr nz,filtit2
  923.         ld e,l:ld d,h
  924. filtit2 or a
  925.         jr nz,filtit1
  926.         dec hl
  927.         sbc hl,de
  928.         ld a,l
  929.         or a
  930.         ret z
  931.         cp 13
  932.         jr c,filtit3
  933.         ld a,12
  934. filtit3 ld c,a
  935.         ld b,0
  936.         ex de,hl
  937.         ld de,prgwintit
  938.         ldir
  939.         ld hl,filtitt
  940.         ld bc,11
  941.         ldir
  942.         ld a,(prgwin)
  943.         jp SyDesktop_WINTIT
  944.  
  945.  
  946. ;==============================================================================
  947. ;### EDIT-ROUTINES ############################################################
  948. ;==============================================================================
  949.  
  950. ;### EDTCHG -> Editor changed
  951. edtchgm db "Lin Col Siz Mrk "
  952. edtchgf db 0    ;flag, if changed
  953.  
  954. edtchg  ld a,1                  ;** Set Change-Flag
  955.         ld (edtchgf),a
  956.         jp prgprz0
  957.  
  958. edtchg0 ld hl,edtchgf           ;** Update only on change
  959.         bit 0,(hl)
  960.         ld (hl),0
  961.         ret z
  962. edtchg1 ld a,(prgwindat+1)      ;** Update only on view
  963.         bit 6,a
  964.         ret z
  965.         call edtchg5
  966.         ld a,(prgwin)
  967.         jp SyDesktop_WINSTA
  968. edtchg5 ld a,29                 ;** Update content
  969.         rst #20:dw jmp_keyput
  970.         rst #30
  971.         ld iy,prgwinsta
  972.         ld hl,edtchgm
  973.         ld ix,(txtmulobj+texdatmsg+2)
  974.         inc ix
  975.         call edtchg4
  976.         ld ix,(txtmulobj+texdatmsg+0)
  977.         inc ix
  978.         call edtchg4
  979.         ld ix,(txtmulobj+texdatlen)
  980.         call edtchg4
  981.         ld de,(txtmulobj+texdatmrk)
  982.         ld a,e:or d
  983.         jr z,edtchg3
  984.         bit 7,d
  985.         jr z,edtchg2
  986.         ld a,e:cpl:ld e,a
  987.         ld a,d:cpl:ld d,a
  988.         inc de
  989. edtchg2 push de:pop ix
  990.         call edtchg4
  991. edtchg3 ld (iy-2),0
  992.         ret
  993. edtchg4 push iy:pop de          ;add value
  994.         ld bc,4
  995.         add iy,bc
  996.         ldir
  997.         ld e,5
  998.         push hl
  999.         call clcnum
  1000.         pop hl
  1001.         inc iy:inc iy:inc iy
  1002.         ld (iy-2),","
  1003.         ld (iy-1)," "
  1004.         ret
  1005.  
  1006. ;### EDTCUT -> Edit Cut
  1007. edtcut  ld a,"X"-64
  1008. edtcut0 rst #20:dw jmp_keyput
  1009.         jp prgprz0
  1010.  
  1011. ;### EDTCOP -> Edit Copy
  1012. edtcop  ld a,"C"-64
  1013.         jr edtcut0
  1014.  
  1015. ;### EDTPAS -> Edit Paste
  1016. edtpas  ld a,"V"-64
  1017.         jr edtcut0
  1018.  
  1019. ;### EDTSAL -> Edit Select All
  1020. edtsal  ld a,"A"-64
  1021.         jr edtcut0
  1022.  
  1023. ;### EDTDEL -> Edit Delete
  1024. edtdel  ld a,8
  1025.         jr edtcut0
  1026.  
  1027. ;### EDTGOT -> Edit Goto
  1028. edtgot  ld hl,(gotdatoln+texdatlen)
  1029.         ld (gotdatoln+texdatmrk),hl
  1030.         ld hl,0
  1031.         ld (gotdatoln+texdatpos),hl
  1032.         ld a,3
  1033.         ld (gotwingrp+14),a
  1034.         ld de,gotwindat
  1035.         jp cfgopn0
  1036.  
  1037. ;### EDTTIM -> Edit Date/Time
  1038. edttims db "00:00:00 00.00.0000",0
  1039. edttim  ld hl,(txtmulobj+texdatmrk)
  1040.         ld a,l:or h
  1041.         jr z,edttim1
  1042.         ld a,8
  1043.         rst #20:dw jmp_keyput
  1044.         rst #30
  1045. edttim1 ld hl,(txtmulobj+texdatlen)     ;increase length
  1046.         ld de,19
  1047.         add hl,de
  1048.         ex de,hl
  1049.         ld hl,(txtmulobj+texdatmax)
  1050.         sbc hl,de
  1051.         jp c,fndral3
  1052.         ld (txtmulobj+texdatlen),de
  1053.         ld hl,txtmulobj+texdatflg
  1054.         set 7,(hl)
  1055.         ld hl,(txtmulobj+texdatpos)     ;insert data
  1056.         push hl
  1057.         push de
  1058.         ex de,hl
  1059.         sbc hl,de
  1060.         ld c,l:ld b,h
  1061.         inc bc
  1062.         pop de
  1063.         ld hl,txtbufmem
  1064.         add hl,de
  1065.         ex de,hl
  1066.         ld hl,-19
  1067.         add hl,de
  1068.         lddr
  1069.         inc de
  1070.         push de
  1071.         rst #20:dw #810c                ;generate time/date string
  1072.         push hl
  1073.         push de
  1074.         push bc
  1075.         call clcdez:ld (edttims+6),hl
  1076.         pop bc:push bc
  1077.         ld a,c
  1078.         call clcdez:ld (edttims+0),hl
  1079.         pop af
  1080.         call clcdez:ld (edttims+3),hl
  1081.         pop de:push de
  1082.         ld a,e
  1083.         call clcdez:ld (edttims+12),hl
  1084.         pop af
  1085.         call clcdez:ld (edttims+9),hl
  1086.         pop ix
  1087.         ld iy,edttims+15
  1088.         ld e,4
  1089.         call clcnum
  1090.         pop de
  1091.         ld hl,edttims                   ;copy time/date string
  1092.         ld bc,19
  1093.         push bc
  1094.         ldir
  1095.         pop bc
  1096.         pop hl
  1097.         add hl,bc
  1098.         ld (txtmulobj+texdatmsg+0),hl   ;update display
  1099.         ld hl,0
  1100.         ld (txtmulobj+texdatmrk),hl
  1101.         ld a,30
  1102.         rst #20:dw jmp_keyput
  1103.         jp prgprz0
  1104.  
  1105.  
  1106. ;==============================================================================
  1107. ;### FIND- AND REPLACE-ROUTINES ###############################################
  1108. ;==============================================================================
  1109.  
  1110. ;### FNDFND -> Opens Find-Dialogue
  1111. fndfnd  call fndfnd1
  1112.         ld de,fndwindat
  1113.         jp cfgopn0
  1114. fndfnd1 ld bc,(txtmulobj+texdatmrk)
  1115.         ld a,c:or b
  1116.         jr z,fndfnd5
  1117.         ld hl,(txtmulobj+texdatpos)
  1118.         bit 7,b
  1119.         jr z,fndfnd2
  1120.         add hl,bc
  1121.         ld a,c:cpl:ld c,a
  1122.         ld a,b:cpl:ld b,a
  1123.         inc bc
  1124. fndfnd2 ld a,b
  1125.         or a
  1126.         jr nz,fndfnd3
  1127.         ld a,c
  1128.         cp 32+1
  1129.         jr c,fndfnd4
  1130. fndfnd3 ld bc,32
  1131. fndfnd4 ld (fnddatofn+texdatlen),bc
  1132.         ld de,txtbufmem
  1133.         add hl,de
  1134.         ld de,fnddattfn
  1135.         ldir
  1136.         xor a
  1137.         ld (de),a
  1138. fndfnd5 ld hl,(fnddatofn+texdatlen)
  1139.         ld (fnddatofn+texdatmrk),hl
  1140.         ld hl,0
  1141.         ld (fnddatofn+texdatpos),hl
  1142.         ld a,3
  1143.         ld (fndwingrp+14),a
  1144.         ld (repwingrp+14),a
  1145.         ld hl,fnddattfn
  1146.         jp fndlfp
  1147.  
  1148. ;### FNDREP -> Opens Replace-Dialogue
  1149. fndrep  call fndfnd1
  1150.         ld hl,fnddattrp
  1151.         call fndlfp
  1152.         ld de,repwindat
  1153.         jp cfgopn0
  1154.  
  1155. ;### FNDFOK -> Start Find
  1156. fndfok  ld a,(diawin)
  1157.         call SyDesktop_WINCLS
  1158.         jp fndfnx
  1159.  
  1160. ;### FNDROK -> Start Replace
  1161. fndrok  call fndrok0
  1162.         ld hl,(txtmulobj+texdatpos)
  1163.         call fndsea
  1164.         jp c,fndfnx0
  1165. fndrok1 call fndfnx2
  1166.         rst #30
  1167.         ld de,rplwindat
  1168.         jp cfgopn0
  1169. fndrok0 ld a,(diawin)
  1170.         call SyDesktop_WINCLS
  1171.         ld hl,fnddattfn
  1172.         call fndplf
  1173.         ld hl,fnddattrp
  1174.         call fndplf
  1175.         rst #30         ;let the desktop-manager close the window first, before the text is modified
  1176.         ret
  1177.  
  1178. ;### FNDRDR -> Replace-Dialogue -> Replace
  1179. fndrdr  call fndrok0
  1180.         ld hl,(txtmulobj+texdatpos)
  1181.         ld de,(txtmulobj+texdatmrk)
  1182.         add hl,de
  1183.         push hl
  1184.         call fndrpl
  1185.         pop de
  1186.         jr c,fndral3
  1187.         ld hl,(fnddatorp+texdatlen)
  1188.         add hl,de
  1189.         ld (txtmulobj+texdatmsg+0),hl
  1190.         push hl
  1191.         ld hl,0
  1192.         ld (txtmulobj+texdatmrk),hl
  1193.         ld a,30
  1194.         rst #20:dw jmp_keyput
  1195.         rst #30
  1196.         pop hl
  1197.         call fndsea
  1198.         jr nc,fndrok1
  1199.         jp prgprz0
  1200.  
  1201. ;### FNDRDA -> Replace-Dialogue -> Replace All
  1202. fndrda  ld hl,(txtmulobj+texdatpos)
  1203.         ld de,(txtmulobj+texdatmrk)
  1204.         add hl,de
  1205.         ld (txtmulobj+texdatpos),hl
  1206.         ld hl,0
  1207.         ld (txtmulobj+texdatmrk),hl
  1208.         jr fndral
  1209.  
  1210. ;### FNDRAL -> Start Replace all
  1211. fndral  call fndrok0
  1212.         ld bc,0
  1213.         ld a,(fnddatall)
  1214.         dec a
  1215.         ld l,a:ld h,a
  1216.         jr z,fndral1
  1217. fndral0 ld hl,(txtmulobj+texdatpos)
  1218. fndral1 push bc
  1219.         call fndsea
  1220.         jr c,fndral2
  1221.         push hl
  1222.         call fndrpl
  1223.         pop hl
  1224.         pop bc
  1225.         jr c,fndral3
  1226.         inc bc
  1227.         ld de,(fnddatorp+texdatlen)
  1228.         add hl,de
  1229.         jr fndral1
  1230. fndral2 pop bc
  1231.         ld a,c:or b
  1232.         jr z,fndfnx0
  1233.         push bc:pop ix
  1234.         ld e,5
  1235.         ld iy,fndmsgtxt2b
  1236.         call clcnum
  1237.         push iy:pop de
  1238.         inc de
  1239.         ld hl,fndmsgtxt2c
  1240.         ld bc,8
  1241.         ldir
  1242.         call docrfs
  1243.         ld hl,prgtxtrep
  1244.         ld b,8*2+1+64+128
  1245.         jp prginf1
  1246. fndral3 ld hl,prgtxtmem
  1247.         ld b,8*3+1+64
  1248.         jp prginf1
  1249.  
  1250. ;### FNDFNX -> Find next
  1251. fndfnx  ld hl,fnddattfn
  1252.         call fndplf
  1253.         ld hl,(txtmulobj+texdatpos)
  1254.         call fndsea
  1255.         jr nc,fndfnx1
  1256. fndfnx0 ld hl,prgtxtfnd
  1257.         ld b,8*2+1+64
  1258.         jp prginf1
  1259. fndfnx1 call fndfnx2
  1260.         jp prgprz0
  1261. fndfnx2 ld de,(fnddatofn+texdatlen)
  1262.         add hl,de
  1263.         ld (txtmulobj+texdatmsg+0),hl
  1264.         ld a,e:cpl:ld e,a
  1265.         ld a,d:cpl:ld d,a
  1266.         inc de
  1267.         ld (txtmulobj+texdatmsg+2),de
  1268.         ld a,31
  1269.         rst #20:dw jmp_keyput
  1270.         ret
  1271.  
  1272. ;### FNDRPL -> Replaces text
  1273. ;### Input      HL=Offset, (fnddatofn+texdatlen)=old length, fnddattrp=new text, (fnddatorp+texdatlen)=new length
  1274. ;### Output     CF=0 ok, CF=1 memory full
  1275. fndrplo dw 0    ;offset
  1276. fndrpl  push hl
  1277.         ex de,hl
  1278.         ld hl,(fnddatofn+texdatlen)
  1279.         ld bc,(fnddatorp+texdatlen)
  1280.         or a
  1281.         sbc hl,bc
  1282.         push hl
  1283.         ld c,l:ld b,h
  1284.         ld hl,(txtmulobj+texdatlen)
  1285.         or a
  1286.         sbc hl,bc       ;hl=new length
  1287.         push hl
  1288.         ld bc,txtbufmax
  1289.         scf
  1290.         sbc hl,bc
  1291.         ccf
  1292.         pop hl
  1293.         pop bc          ;bc=lendif
  1294.         ret c           ;new length >= max+1 -> memory full
  1295.         ld (txtmulobj+texdatlen),hl
  1296.         ld a,c:or b
  1297.         jr z,fndrpl2
  1298.         push bc
  1299.         push hl
  1300.         ld a,b
  1301.         sbc hl,de
  1302.         ld bc,(fnddatorp+texdatlen)
  1303.         sbc hl,bc
  1304.         ld c,l:ld b,h
  1305.         inc bc          ;bc=copylength (newlen-new wordlength-offset+1)
  1306.         pop hl          ;hl=newlen
  1307.         rla
  1308.         jr nc,fndrpl1
  1309.         ld de,txtbufmem ;expand text -> copy backwards
  1310.         add hl,de       ;hl=last char+1
  1311.         pop de          ;de=dif
  1312.         push hl
  1313.         add hl,de       ;hl=last char+dif = source
  1314.         pop de          ;de=last char = destination
  1315.         lddr
  1316.         jr fndrpl2
  1317. fndrpl1 ld hl,(fnddatorp+texdatlen)
  1318.         add hl,de
  1319.         ld de,txtbufmem
  1320.         add hl,de
  1321.         ex de,hl        ;de=offset + new wordlength=destination
  1322.         pop hl
  1323.         add hl,de       ;hl=destination + dif=source
  1324.         ldir
  1325. fndrpl2 pop de
  1326.         ld hl,txtbufmem
  1327.         add hl,de
  1328.         ex de,hl
  1329.         ld hl,fnddattrp
  1330.         ld bc,(fnddatorp+texdatlen)
  1331.         ldir
  1332.         ld hl,txtmulobj+texdatflg
  1333.         set 7,(hl)      ;modified
  1334.         or a
  1335.         ret
  1336.  
  1337. ;### FNDSEA -> Searches for text
  1338. ;### Input      HL=Startoffset, fnddattfn=Text, (fnddatofn+texdatlen)=length, (fnddatcas)=Flag, if case sensitive
  1339. ;### Output     CF=0 ok (HL=offset), CF=1 nothing found
  1340. fndsea  ld de,(fnddatofn+texdatlen)
  1341.         ld a,e:or d
  1342.         scf
  1343.         ret z
  1344.         push hl
  1345.         add hl,de
  1346.         ex de,hl
  1347.         ld hl,(txtmulobj+texdatlen)
  1348.         scf
  1349.         sbc hl,de
  1350.         ld c,l:ld b,h
  1351.         pop hl
  1352.         ret c
  1353.         inc bc              ;bc=len
  1354.         ld de,txtbufmem
  1355.         add hl,de           ;hl=adr
  1356.         ld a,(fnddattfn)
  1357.         call fndcas
  1358.         ld e,a
  1359. fndsea1 ld a,(hl)       ;search for 1st char
  1360.         call fndcas
  1361.         cp e
  1362.         jr z,fndsea3
  1363. fndsea2 inc hl          ;next char
  1364.         dec bc
  1365.         ld a,c:or b
  1366.         jr nz,fndsea1
  1367.         scf
  1368.         ret
  1369. fndsea3 dec hl          ;1st char found
  1370.         ld a,(hl)
  1371.         inc hl
  1372.         call fndaln
  1373.         jr c,fndsea2
  1374.         push bc
  1375.         push de
  1376.         push hl
  1377.         ld bc,(fnddatofn+texdatlen)
  1378.         ld de,fnddattfn
  1379. fndsea4 inc hl          ;check remaining chars
  1380.         dec c
  1381.         jr z,fndsea6
  1382.         inc de
  1383.         ld a,(de)
  1384.         call fndcas
  1385.         ld b,a
  1386.         ld a,(hl)
  1387.         call fndcas
  1388.         cp b
  1389.         jr z,fndsea4
  1390. fndsea5 pop hl          ;not found, next char
  1391.         pop de
  1392.         pop bc
  1393.         jr fndsea2
  1394. fndsea6 ld a,(hl)       ;complete string found
  1395.         call fndaln
  1396.         jr c,fndsea5
  1397.         pop hl
  1398.         pop de
  1399.         pop bc
  1400.         ld de,txtbufmem
  1401.         or a
  1402.         sbc hl,de
  1403.         ret
  1404.  
  1405. ;### FNDCAS -> Converts char into lcase, if case-flag is not set
  1406. ;### Input      A=Char
  1407. ;### Output     A=Char
  1408. ;### Destroyed  F
  1409. fndcas  push hl
  1410.         ld hl,fnddatcas
  1411.         bit 0,(hl)
  1412.         pop hl
  1413.         ret nz
  1414.         cp "A"
  1415.         ret c
  1416.         cp "Z"+1
  1417.         ret nc
  1418.         add "a"-"A"
  1419.         ret
  1420.  
  1421. ;### FNDALN -> Checks, if word only + char is alphanumeric
  1422. ;### Input      A=Char
  1423. ;### Output     CF=1 word only + char is alphanumeric
  1424. ;### Destroyed  F
  1425. fndaln  or a
  1426.         push hl
  1427.         ld hl,fnddatwrd
  1428.         bit 0,(hl)
  1429.         pop hl
  1430.         ret z
  1431.         cp "_"
  1432.         scf
  1433.         ret z
  1434.         cp "0"
  1435.         ccf
  1436.         ret nc
  1437.         cp "9"+1
  1438.         ret c
  1439.         cp "A"
  1440.         ccf
  1441.         ret nc
  1442.         cp "Z"+1
  1443.         ret c
  1444.         cp "a"
  1445.         ccf
  1446.         ret nc
  1447.         cp "z"+1
  1448.         ret
  1449.  
  1450. ;### FNDPLF -> Converts ^P into 13+10
  1451. ;### Input      HL=String
  1452. ;### Destroyed  AF,BC,DE,HL
  1453. fndplf  ld bc,13*256+10
  1454.         ld de,"^"*256+"P"
  1455.         jr fndlfp0
  1456.  
  1457. ;### FNDLFP -> Converts 13+10 into ^P
  1458. ;### Input      HL=String
  1459. ;### Destroyed  AF,BC,DE,HL
  1460. fndlfp  ld de,13*256+10
  1461.         ld bc,"^"*256+"P"
  1462. fndlfp0 ld a,(hl)
  1463. fndlfp1 or a
  1464.         ret z
  1465.         inc hl
  1466.         cp d
  1467.         jr nz,fndlfp0
  1468.         ld a,(hl)
  1469.         cp e
  1470.         jr nz,fndlfp1
  1471.         dec hl
  1472.         ld (hl),b
  1473.         inc hl
  1474.         ld (hl),c
  1475.         inc hl
  1476.         jr fndlfp0
  1477.  
  1478. ;### FNDGOT -> Goto
  1479. fndgot  ld a,(diawin)           ;close dialogue
  1480.         call SyDesktop_WINCLS
  1481.         ld ix,gotdattln         ;convert line
  1482.         xor a
  1483.         ld bc,1
  1484.         ld de,9999
  1485.         call clcr16
  1486.         jr nc,fndgot2
  1487. fndgot1 ld hl,prgtxtnum
  1488.         ld b,8*3+1+64
  1489.         jp prginf1
  1490. fndgot2 push hl
  1491.         ld ix,gotdattcl         ;convert column
  1492.         xor a
  1493.         ld bc,1
  1494.         ld de,16383
  1495.         call clcr16
  1496.         pop bc
  1497.         jr c,fndgot1
  1498.         push hl                 ;limit max-line
  1499.         ld hl,(txtmulobj+texdatlnt)
  1500.         sbc hl,bc
  1501.         jr nc,fndgot3
  1502.         add hl,bc
  1503.         ld c,l:ld b,h
  1504. fndgot3 ld ix,txtmulobj+texdatlln
  1505.         ld hl,0                 ;goto line
  1506. fndgot4 dec bc
  1507.         ld a,c:or b
  1508.         jr z,fndgot5
  1509.         ld e,(ix+0)
  1510.         ld d,(ix+1)
  1511.         res 7,d
  1512.         add hl,de
  1513.         inc ix
  1514.         inc ix
  1515.         jr fndgot4
  1516. fndgot5 ex de,hl
  1517.         pop hl                  ;limit max-column
  1518.         ld c,(ix+0)
  1519.         ld b,(ix+1)
  1520.         inc bc
  1521.         bit 7,b
  1522.         res 7,b
  1523.         jr z,fndgot6
  1524.         dec bc:dec bc
  1525. fndgot6 sbc hl,bc
  1526.         jr nc,fndgot7
  1527.         add hl,bc
  1528.         ld c,l:ld b,h
  1529. fndgot7 dec bc
  1530.         ex de,hl
  1531.         add hl,bc
  1532.         ld (txtmulobj+texdatmsg+0),hl
  1533.         ld hl,0
  1534.         ld (txtmulobj+texdatmsg+2),hl
  1535.         ld a,31
  1536.         rst #20:dw jmp_keyput   ;set cursor
  1537.         jp prgprz0
  1538.  
  1539.  
  1540. ;==============================================================================
  1541. ;### DOCUMENT-ROUTINES ########################################################
  1542. ;==============================================================================
  1543.  
  1544. texdatadr       equ 0           ;Zeiger auf Text
  1545. texdatbeg       equ 2           ;erstes angezeigtes Zeichen (nur singleline)
  1546. texdatpos       equ 4           ;Cursorposition im Gesamttext
  1547. texdatmrk       equ 6           ;0/Anzahl markierter Zeichen [neg->Cursor=Ende Markierung]
  1548. texdatlen       equ 8           ;Textlфnge
  1549. texdatmax       equ 10          ;maximal zulфssige Textlфnge (1-16383; exklusive 0-Terminator)
  1550. texdatflg       equ 12          ;Flags (Bit0=Pa▀wort [nur singleline], Bit1=ReadOnly, Bit2=AltColor, Bit3=AltFont [nur multiline])
  1551. ;** extended 16c/altfont
  1552. texdatcol       equ 13          ;4bit txtpap, 4bit txtpen
  1553. texdatrhm       equ 14          ;4bit rahmen1, 4bit rahmen2
  1554. texdatfnt       equ 15          ;Adresse des alternativen Fonts
  1555. texdatrs1       equ 17          ;*reserved 1byte*
  1556. ;** ab hier nur Multiline
  1557. texdatlnt       equ 18          ;aktuelle Anzahl Zeilen
  1558. texdatxmx       equ 20          ;maximale Zeilenbreite in Pixeln bei Wordwrap-Pos-Vorgabe (-1=unbegrenzt)
  1559. texdatymx       equ 22          ;maximale Anzahl Zeilen (*2 bytes ab texdatlln!)
  1560. texdatxwn       equ 24          ;win x len ohne slider f№r bisherige formatierung (winx<>aktx -> Neuformatierung notwendig, durch -8 erzwingen)
  1561. texdatywn       equ 26          ;win y len ohne slider
  1562.  
  1563. texdatzgr       equ 28          ;pointer auf diesen datensatz (ab texdatadr)
  1564. texdatxfl       equ 30          ;full x len (=Lфnge der lфngsten Textzeile in Pixel)
  1565. texdatyfl       equ 32          ;full y len (=Anzahl aller Textzeilen * 8)
  1566. texdatxof       equ 34          ;offset x   (=texdatbeg)
  1567. texdatyof       equ 36          ;offset y
  1568. texdatfg2       equ 38          ;Flags (Bit0=WordWrap-Position vorgegeben [dann Xslider], Bit1=1)
  1569. texdattab       equ 39          ;Tabstop GrЎ▀e (1-255; 0=kein Tabstop) ##!!##
  1570.  
  1571. texdatmsg       equ 40          ;Message-Buffer (in POS, MRK, out CXP, CYP)
  1572. texdatrs2       equ 44          ;*reserved 4byte*
  1573. texdatlln       equ 48          ;Zeilen-Lфngentabelle (bit15=cr+lf am ende vorhanden)
  1574.  
  1575. ;### DOCINI -> initialise loaded document
  1576. docini  ld hl,txtmulobj+texdatflg   ;reset modified-bit
  1577.         res 7,(hl)
  1578.         ld hl,txtbufmem             ;search for EOF (0 or 26 [CPC])
  1579.         ld bc,txtbufmax
  1580.         push hl
  1581.         xor a                       ;search for 0
  1582.         cpir
  1583.         ex (sp),hl
  1584.         ld bc,txtbufmax
  1585.         ld a,26                     ;search for 26 (EOF)
  1586.         cpir
  1587.         pop de
  1588.         or a
  1589.         sbc hl,de
  1590.         jr nc,docini1
  1591.         add hl,de
  1592.         ex de,hl
  1593. docini1 ex de,hl
  1594.         dec hl
  1595.         xor a
  1596.         ld (hl),a
  1597.         ld bc,txtbufmem
  1598.         sbc hl,bc                   ;hl=textlength (=min(found(0),found(26))
  1599.         ld (txtmulobj+texdatlen),hl
  1600. docini2 ld a,l
  1601.         or h
  1602.         jr z,docnew1
  1603.         ld a,(bc)
  1604.         cp 10
  1605.         jr z,docini4
  1606.         cp 13
  1607.         jr z,docini4
  1608.         cp 32
  1609.         jr c,docini3
  1610.         cp 128
  1611.         jr c,docini4
  1612. docini3 ld a,"?"
  1613.         ld (bc),a
  1614. docini4 inc bc
  1615.         dec hl
  1616.         jr docini2
  1617.  
  1618. ;### DOCNEW -> clears and initialise document
  1619. docnew  ld hl,txtmulobj+texdatflg   ;reset modified-bit
  1620.         res 7,(hl)
  1621.         xor a
  1622.         ld (txtbufmem),a
  1623.         ld l,a:ld h,a
  1624.         ld (txtmulobj+texdatlen),hl
  1625. docnew1 ld (txtmulobj+texdatpos),hl
  1626.         ld (txtmulobj+texdatmrk),hl
  1627.         ld (txtmulobj+texdatxof),hl
  1628.         ld (txtmulobj+texdatyof),hl
  1629.         ret
  1630.  
  1631. ;### DOCRFS -> refresh document display
  1632. docrfs  call edtchg1
  1633.         ld hl,-8
  1634.         ld (txtmulobj+texdatxwn),hl
  1635.         ld a,(prgwin)
  1636.         ld e,1
  1637.         jp SyDesktop_WINDIN
  1638.  
  1639.  
  1640. ;==============================================================================
  1641. ;### DATA AREA ################################################################
  1642. ;==============================================================================
  1643.  
  1644. prgdatbeg
  1645.  
  1646. txtbufmem db 0
  1647. ;!!!last label in data-area!!!
  1648.  
  1649. ;==============================================================================
  1650. ;### TRANSFER AREA ############################################################
  1651. ;==============================================================================
  1652.  
  1653. prgtrnbeg
  1654. ;### PRGPRZS -> Stack for application process
  1655.         ds 128
  1656. prgstk  ds 6*2
  1657.         dw prgprz
  1658. AppPrzN db 0
  1659. AppMsgB ds 14
  1660.  
  1661. prgicn16c db 12,24,24:dw $+7:dw $+4,12*24:db 5
  1662.         db #88,#88,#88,#88,#DD,#8D,#D8,#DD,#8D,#D8,#DD,#88,#88,#88,#88,#8D,#8D,#D8,#DD,#8D,#D8,#DD,#8D,#D8,#88,#88,#88,#54,#D4,#4D,#44,#D4,#4D,#44,#D4,#77,#88,#88,#88,#54,#44,#44,#44,#44,#44,#44,#44,#77
  1663.         db #88,#88,#85,#44,#44,#44,#44,#44,#44,#44,#45,#17,#88,#88,#85,#44,#44,#44,#44,#44,#44,#44,#45,#17,#88,#88,#54,#44,#FF,#FF,#FF,#FF,#F4,#44,#50,#17,#88,#88,#54,#44,#44,#44,#44,#44,#44,#44,#51,#17
  1664.         db #88,#85,#44,#45,#55,#55,#55,#55,#44,#45,#00,#17,#88,#85,#44,#44,#44,#44,#44,#44,#44,#45,#00,#17,#88,#54,#44,#55,#55,#55,#55,#54,#44,#51,#11,#17,#88,#54,#44,#44,#44,#44,#44,#44,#44,#50,#06,#17
  1665.         db #85,#44,#44,#44,#44,#44,#44,#44,#45,#00,#06,#17,#85,#44,#44,#44,#44,#44,#44,#44,#45,#11,#11,#17,#54,#44,#44,#44,#44,#44,#44,#44,#50,#00,#66,#17,#54,#44,#44,#44,#44,#44,#44,#44,#50,#00,#66,#17
  1666.         db #85,#55,#55,#55,#55,#55,#55,#55,#11,#11,#11,#17,#88,#88,#88,#70,#00,#00,#00,#00,#00,#06,#66,#17,#88,#88,#88,#70,#00,#00,#00,#00,#00,#06,#66,#17,#88,#88,#88,#71,#11,#11,#11,#11,#11,#11,#11,#17
  1667.         db #88,#88,#88,#70,#00,#00,#00,#00,#00,#66,#66,#17,#88,#88,#88,#76,#66,#66,#66,#66,#66,#66,#61,#17,#88,#88,#88,#87,#11,#11,#11,#11,#11,#11,#11,#78,#88,#88,#88,#88,#77,#77,#77,#77,#77,#77,#77,#88
  1668.  
  1669. docmsk  db "TXT",0
  1670. docpth  ds 256
  1671.  
  1672. ;### STRINGS ##################################################################
  1673.  
  1674. prgwintit   db "untitled - Notepad",0:ds 12-8
  1675. prgwinsta   ds 4*11
  1676.  
  1677. prgtxtinf1  db "Notepad for SymbOS",0
  1678. prgtxtinf2  db " Version 1.2 (Build 141019pdt)",0
  1679. prgtxtinf3  db " Copyright <c> 2014 SymbiosiS"
  1680. prgtxtinf0  db 0
  1681.  
  1682. prgtxterra  db "Textbuffer full. Only a part of",0
  1683. prgtxterrb  db "the document has been loaded.",0
  1684. prgtxterrc  db "Error while loading file!",0
  1685. prgtxterrd  db "Error while saving file!",0
  1686. prgtxterre  db "Device full. Only a part of",0
  1687. prgtxterrf  db "the document has been saved.",0
  1688.  
  1689. prgtxtsav1  db "Save changes?",0
  1690.  
  1691. prgtxtoky   db "Ok",0
  1692. prgtxtcnc   db "Cancel",0
  1693. prgtxtfnx   db "Find next",0
  1694. prgtxtfrp   db "Replace",0
  1695. prgtxtfra   db "Replace all",0
  1696.  
  1697. ;### FIND AND REPLACE #########################################################
  1698.  
  1699. fndwintit   db "Find",0
  1700. repwintit   db "Replace",0
  1701. gotwintit   db "Go to",0
  1702.  
  1703. fndwintxt1  db "Find what",0
  1704. fndwintxt2  db "Replace with",0
  1705. fndwintxt3  db "Match case",0
  1706. fndwintxt4  db "Whole word only",0
  1707. fndwintxt5  db "Entire document",0
  1708. fndwintxt6  db "Line",0
  1709. fndwintxt7  db "Column",0
  1710.  
  1711. fnddattfn   ds 33
  1712. fnddattrp   ds 33
  1713. gotdattln   db "1":ds 4
  1714. gotdattcl   db "1":ds 5
  1715.  
  1716. fndmsgtxt1  db "Text not found!",0
  1717. fndmsgtxt2a db "Replaced "
  1718. fndmsgtxt2b ds 8+5
  1719. fndmsgtxt2c db " times.",0
  1720. fndmsgtxt3a db "Textbuffer full. Couldn't",0
  1721. fndmsgtxt3b db "replace one or more entries.",0
  1722. fndmsgtxt4  db "Invalid number",0
  1723.  
  1724. ;### CONFIG ###################################################################
  1725.  
  1726. fnttxtdef   db "Default",0
  1727.  
  1728. coltxt00    db "00",0
  1729. coltxt01    db "01",0
  1730. coltxt02    db "02",0
  1731. coltxt03    db "03",0
  1732. coltxt04    db "04",0
  1733. coltxt05    db "05",0
  1734. coltxt06    db "06",0
  1735. coltxt07    db "07",0
  1736. coltxt08    db "08",0
  1737. coltxt09    db "09",0
  1738. coltxt10    db "10",0
  1739. coltxt11    db "11",0
  1740. coltxt12    db "12",0
  1741. coltxt13    db "13",0
  1742. coltxt14    db "14",0
  1743. coltxt15    db "15",0
  1744.  
  1745. cfgwintit   db "Settings",0
  1746. cfgwintxt0  db "Font type",0
  1747. cfgwintxt1  db "Font colour",0
  1748. cfgwintxt2  db "Options",0
  1749. cfgwintxt3  db "Word wrap at window border",0
  1750. cfgwintxt4  db "Word wrap at",0
  1751. cfgwintxt5  db "px",0
  1752. cfgwintxt6  db "No word wrap",0
  1753. cfgwintxt7  db "Tabstop width",0
  1754. cfgwintxt8  db "chars",0
  1755. cfgwintxt9  db "Pen",0
  1756. cfgwintxta  db "Paper",0
  1757. cfgwintxtb  db "Preview",0
  1758.  
  1759. ;### MENU #####################################################################
  1760.  
  1761. prgwinmentx1 db "File",0
  1762. prgwinmen1tx1 db "New",0
  1763. prgwinmen1tx2 db "Open...",0
  1764. prgwinmen1tx3 db "Save",0
  1765. prgwinmen1tx4 db "Save As...",0
  1766. prgwinmen1tx5 db "Exit",0
  1767.  
  1768. prgwinmentx2 db "Edit",0
  1769. prgwinmen2tx1 db "Cut",0
  1770. prgwinmen2tx2 db "Copy",0
  1771. prgwinmen2tx3 db "Paste",0
  1772. prgwinmen2tx4 db "Delete",0
  1773. prgwinmen2tx5 db "Find...",0
  1774. prgwinmen2tx6 db "Find Again",0
  1775. prgwinmen2tx7 db "Replace...",0
  1776. prgwinmen2tx8 db "Go To...",0
  1777. prgwinmen2tx9 db "Select All",0
  1778. prgwinmen2txa db "Time/Date",0
  1779.  
  1780. prgwinmentx3 db "Format",0
  1781. prgwinmen3tx1 db "Auto word wrap",0
  1782. prgwinmen3tx2 db "Settings...",0
  1783.  
  1784. prgwinmentx4 db "View",0
  1785. prgwinmen4tx1 db "Status bar",0
  1786.  
  1787. prgwinmentx5 db "?",0
  1788. prgwinmen5tx1 db "Index",0
  1789. prgwinmen5tx2 db "About Notepad...",0
  1790.  
  1791. ;### ALERT BOXES ##############################################################
  1792.  
  1793. prgtxtinf  dw prgtxtinf1,4*1+2,prgtxtinf2,4*1+2,prgtxtinf3,4*1+2,prgicnbig
  1794.  
  1795. prgtxterr1  dw prgtxterra,4*1+2,prgtxterrb,4*1+2,prgtxtinf0,4*1+2
  1796. prgtxterr2  dw prgtxterrc,4*1+2,prgtxtinf0,4*1+2,prgtxtinf0,4*1+2
  1797. prgtxterr3  dw prgtxterrd,4*1+2,prgtxtinf0,4*1+2,prgtxtinf0,4*1+2
  1798. prgtxterr4  dw prgtxterre,4*1+2,prgtxterrf,4*1+2,prgtxtinf0,4*1+2
  1799.  
  1800. prgtxtsav   dw prgtxtsav1,4*1+2,prgtxtinf0,4*1+2,prgtxtinf0,4*1+2
  1801.  
  1802. prgtxtfnd   dw fndmsgtxt1,4*1+2,prgtxtinf0,4*1+2,prgtxtinf0,4*1+2
  1803. prgtxtrep   dw fndmsgtxt2a,4*1+2,prgtxtinf0,4*1+2,prgtxtinf0,4*1+2,prgicnbig
  1804. prgtxtmem   dw fndmsgtxt3a,4*1+2,fndmsgtxt3b,4*1+2,prgtxtinf0,4*1+2
  1805. prgtxtnum   dw fndmsgtxt4,4*1+2,prgtxtinf0,4*1+2,prgtxtinf0,4*1+2
  1806.  
  1807. ;### CONFIG WINDOW ############################################################
  1808.  
  1809. cfgwindat   dw #1401,4+16,079,024,160,138,0,0,160,138,160,138,160,138,0,cfgwintit,0,0,cfgwingrp,0,0:ds 136+14
  1810. cfgwingrp   db 20,0:dw cfgwinobj,0,0,256*20+19,0,0,0
  1811. cfgwinobj
  1812.             dw     00,         0,2,          0,0,1000,1000,0        ;00=Hintergrund
  1813.             dw     00,255*256+ 3,cfgwindsc0, 00, 01, 80,59,0        ;01=Frame       "Font type"
  1814.             dw     00,255*256+41,fntselobj,  08, 10, 64,42,0        ;02=Font-List
  1815.             dw     00,255*256+ 3,cfgwindsc1, 80, 01, 80,59,0        ;03=Frame       "Font colour"
  1816.             dw     00,255*256+ 1,cfgwindsc6, 88, 12, 32, 8,0        ;04=Description "Pen"
  1817.             dw cfgcol,255*256+42,penselobj, 120, 11, 32,10,0        ;05=Pen-List
  1818.             dw     00,255*256+ 1,cfgwindsc7, 88, 24, 32, 8,0        ;06=Description "Paper"
  1819.             dw cfgcol,255*256+42,papselobj, 120, 23, 32,10,0        ;07=Paper-List
  1820.             dw     00,255*256+ 1,cfgwindsc8, 92, 40, 56, 8,0        ;08=Description "Preview"
  1821.             dw     00,255*256+ 3,cfgwindsc2, 00, 60,160,63,0        ;09=Frame       "Options"
  1822.             dw     00,255*256+18,cfgwinrad0, 08, 70,120, 8,0        ;10=Radiobox    "Word wrap at window border"
  1823.             dw     00,255*256+18,cfgwinrad1, 08, 81, 64, 8,0        ;11=Radiobox    "Word wrap at"
  1824.             dw     00,255*256+32,cfgwininp1, 73, 79, 26,12,0        ;12=Input       "Word wrap at"
  1825.             dw     00,255*256+ 1,cfgwindsc4,101, 81, 32, 8,0        ;13=Description "px"
  1826.             dw     00,255*256+18,cfgwinrad2, 08, 92, 64, 8,0        ;14=Radiobox    "No word wrap"
  1827.             dw     00,255*256+ 1,cfgwindsc3, 08,106, 32, 8,0        ;15=Description "Tab stop width"
  1828.             dw     00,255*256+32,cfgwininp2, 68,104, 16,12,0        ;16=Input       "Tab stop width"
  1829.             dw     00,255*256+ 1,cfgwindsc5, 86,106, 32, 8,0        ;17=Description "chars"
  1830.             dw cfgoky,255*256+16,prgtxtoky,  59,123, 48,12,0        ;18="Ok"    -Button
  1831.             dw diacnc,255*256+16,prgtxtcnc, 109,123, 48,12,0        ;19="Cancel"-Button
  1832.  
  1833.  
  1834. fntselobj   dw 8,0,fntsellst,0,1,fntselrow,0,1
  1835. fntselrow   dw 0,56,0,0
  1836. fntsellst   dw 00,fnttxtdef
  1837.             dw 01,fnttxtdef, 02,fnttxtdef, 03,fnttxtdef, 04,fnttxtdef, 05,fnttxtdef, 06,fnttxtdef, 07,fnttxtdef, 08,fnttxtdef
  1838.             dw 09,fnttxtdef, 10,fnttxtdef, 11,fnttxtdef, 12,fnttxtdef, 13,fnttxtdef, 14,fnttxtdef, 15,fnttxtdef, 16,fnttxtdef
  1839.  
  1840. penselobj   dw 16,0,pensellst,0,1,penselrow,0,1
  1841. penselrow   dw 0,56,0,0
  1842. pensellst   dw 00,coltxt00, 01,coltxt01, 02,coltxt02, 03,coltxt03, 04,coltxt04, 05,coltxt05, 06,coltxt06, 07,coltxt07
  1843.             dw 08,coltxt08, 09,coltxt09, 10,coltxt10, 11,coltxt11, 12,coltxt12, 13,coltxt13, 14,coltxt14, 15,coltxt15
  1844.  
  1845. papselobj   dw 16,0,papsellst,0,1,papselrow,0,1
  1846. papselrow   dw 0,56,0,0
  1847. papsellst   dw 00,coltxt00, 01,coltxt01, 02,coltxt02, 03,coltxt03, 04,coltxt04, 05,coltxt05, 06,coltxt06, 07,coltxt07
  1848.             dw 08,coltxt08, 09,coltxt09, 10,coltxt10, 11,coltxt11, 12,coltxt12, 13,coltxt13, 14,coltxt14, 15,coltxt15
  1849.  
  1850. cfgwindsc0  dw cfgwintxt0,2+4
  1851. cfgwindsc1  dw cfgwintxt1,2+4
  1852. cfgwindsc2  dw cfgwintxt2,2+4
  1853. cfgwindsc3  dw cfgwintxt7,2+4
  1854. cfgwindsc4  dw cfgwintxt5,2+4
  1855. cfgwindsc5  dw cfgwintxt8,2+4
  1856. cfgwindsc6  dw cfgwintxt9,2+4
  1857. cfgwindsc7  dw cfgwintxta,2+4
  1858. cfgwindsc8  dw cfgwintxtb,256*194+16
  1859.  
  1860. cfgwininp1  dw cfgwinbuf1,0,0,0,0,4,0
  1861. cfgwinbuf1  ds 5
  1862. cfgwininp2  dw cfgwinbuf2,0,0,0,0,2,0
  1863. cfgwinbuf2  ds 3
  1864.  
  1865. cfgwinwrp   db 0
  1866. cfgwinradb  dw -1,-1
  1867. cfgwinrad0  dw cfgwinwrp,cfgwintxt3,256*0+2+4,cfgwinradb
  1868. cfgwinrad1  dw cfgwinwrp,cfgwintxt4,256*1+2+4,cfgwinradb
  1869. cfgwinrad2  dw cfgwinwrp,cfgwintxt6,256*2+2+4,cfgwinradb
  1870.  
  1871. cfgdat
  1872. cfgdatpap   db 0    ;paper
  1873. cfgdatpen   db 1    ;pen
  1874. cfgdatfnt   db 0    ;font
  1875. cfgdatwrp   db 0    ;0=autowordwrap, 1=wordwrap at position x, 2=no wordwrap
  1876. cfgdatwps   dw 200  ;wordwrap-position (pixels)
  1877. cfgdattab   db 8    ;tabstop-position (chars)
  1878. cfgdatsta   db 1    ;flag, if statusbar
  1879.             ds 16-8
  1880.  
  1881. cfgfntnum   db 0    ;number of fonts
  1882. cfgfntdat   ds 127  ;font information (offset table, names)
  1883.  
  1884. ;### GOTO #####################################################################
  1885.  
  1886. gotwindat   dw #1401,4+16,090,060,120,34,0,0,120,34,120,34,120,34,0,gotwintit,0,0,gotwingrp,0,0:ds 136+14
  1887. gotwingrp   db 07,0:dw gotwinobj,0,0,256*07+06,0,0,3
  1888. gotwinobj
  1889.             dw     00,         0,2,          0,0,1000,1000,0        ;00=Hintergrund
  1890.             dw     00,255*256+ 1,gotwindsc1, 04, 06, 34, 8,0        ;01=Description "Line"
  1891.             dw     00,255*256+32,gotdatoln,  38, 04, 32,12,0        ;02=Input       "Line"
  1892.             dw     00,255*256+ 1,gotwindsc2, 04, 20, 34, 8,0        ;03=Description "Column"
  1893.             dw     00,255*256+32,gotdatocl,  38, 18, 32,12,0        ;04=Input       "Column"
  1894.             dw fndgot,255*256+16,prgtxtoky,  76, 04, 40,12,0        ;05="Ok"        -Button
  1895.             dw diacnc,255*256+16,prgtxtcnc,  76, 18, 40,12,0        ;06="Cancel"    -Button
  1896.  
  1897. gotwindsc1  dw fndwintxt6,2+4
  1898. gotwindsc2  dw fndwintxt7,2+4
  1899. gotdatoln   dw gotdattln,0,1,0,1,4,0
  1900. gotdatocl   dw gotdattcl,0,1,0,1,5,0
  1901.  
  1902. ;### FIND AND REPLACE #########################################################
  1903.  
  1904. fndwindat   dw #1401,4+16,060,060,240,46,0,0,240,46,240,46,240,46,0,fndwintit,0,0,fndwingrp,0,0:ds 136+14
  1905. fndwingrp   db 07,0:dw fndwinobj,0,0,256*07+06,0,0,3
  1906. fndwinobj
  1907.             dw     00,         0,2,          0,0,1000,1000,0        ;00=Hintergrund
  1908.             dw     00,255*256+ 1,fndwindsc1, 04, 06, 40, 8,0        ;01=Description "Find what"
  1909.             dw     00,255*256+32,fnddatofn,  60, 04,114,12,0        ;02=Input       "Find what"
  1910.             dw     00,255*256+17,fndwinchk1, 04, 24, 80, 8,0        ;03=Checkbox    "Match case"
  1911.             dw     00,255*256+17,fndwinchk2, 04, 34, 80, 8,0        ;04=Checkbox    "Whole word only"
  1912.             dw fndfok,255*256+16,prgtxtfnx, 182, 04, 54,12,0        ;05="Find next" -Button
  1913.             dw diacnc,255*256+16,prgtxtcnc, 182, 20, 54,12,0        ;06="Cancel"    -Button
  1914.  
  1915. repwindat   dw #1401,4+16,060,060,240,70,0,0,240,70,240,70,240,70,0,repwintit,0,0,repwingrp,0,0:ds 136+14
  1916. repwingrp   db 11,0:dw repwinobj,0,0,256*11+09,0,0,3
  1917. repwinobj
  1918.             dw     00,         0,2,          0,0,1000,1000,0        ;00=Hintergrund
  1919.             dw     00,255*256+ 1,fndwindsc1, 04, 06, 40, 8,0        ;01=Description  "Find what"
  1920.             dw     00,255*256+32,fnddatofn,  60, 04,114,12,0        ;02=Input        "Find what"
  1921.             dw     00,255*256+ 1,fndwindsc2, 04, 20, 40, 8,0        ;03=Description  "Replace with"
  1922.             dw     00,255*256+32,fnddatorp,  60, 18,114,12,0        ;04=Input        "Replace with"
  1923.             dw     00,255*256+17,fndwinchk1, 04, 38, 80, 8,0        ;05=Checkbox     "Match case"
  1924.             dw     00,255*256+17,fndwinchk2, 04, 48, 80, 8,0        ;06=Checkbox     "Whole word only"
  1925.             dw     00,255*256+17,fndwinchk3, 04, 58, 80, 8,0        ;07=Checkbox     "Entire document"
  1926.             dw fndrok,255*256+16,prgtxtfnx, 182, 04, 54,12,0        ;08="Find next"  -Button
  1927.             dw fndral,255*256+16,prgtxtfra, 182, 20, 54,12,0        ;09="Replace all"-Button
  1928.             dw diacnc,255*256+16,prgtxtcnc, 182, 36, 54,12,0        ;10="Cancel"     -Button
  1929.  
  1930. rplwindat   dw #1401,4+16,060,060,226,24,0,0,226,24,226,24,226,24,0,repwintit,0,0,rplwingrp,0,0:ds 136+14
  1931. rplwingrp   db 5,0:dw rplwinobj,0,0,256*5+3,0,0,2
  1932. rplwinobj
  1933.             dw     00,         0,2,          0,0,1000,1000,0        ;00=Hintergrund
  1934.             dw fndrok,255*256+16,prgtxtfnx,   2, 6, 54,12,0         ;01="Find next"  -Button
  1935.             dw fndrdr,255*256+16,prgtxtfrp,  58, 6, 54,12,0         ;02="Replace"    -Button
  1936.             dw fndrda,255*256+16,prgtxtfra, 114, 6, 54,12,0         ;03="Replace all"-Button
  1937.             dw diacnc,255*256+16,prgtxtcnc, 170, 6, 54,12,0         ;04="Cancel"     -Button
  1938.  
  1939. fndwindsc1  dw fndwintxt1,2+4
  1940. fndwindsc2  dw fndwintxt2,2+4
  1941.  
  1942. fndwinchk1  dw fnddatcas,fndwintxt3,2+4
  1943. fndwinchk2  dw fnddatwrd,fndwintxt4,2+4
  1944. fndwinchk3  dw fnddatall,fndwintxt5,2+4
  1945.  
  1946. fnddatofn   dw fnddattfn,0,0,0,0,32,0
  1947. fnddatorp   dw fnddattrp,0,0,0,0,32,0
  1948. fnddatcas   db 0    ;flag, if case-sensitive
  1949. fnddatwrd   db 0    ;flag, if whole word only
  1950. fnddatall   db 0    ;flag, if entire document
  1951.  
  1952. ;### MAIN WINDOW ##############################################################
  1953.  
  1954. prgwindat   dw #7701,3,50,20,200,106,0,0,200,106,100,50,1000,1000,prgicnsml,prgwintit
  1955. prgwindat0  dw prgwinsta,prgwinmen,prgwingrp,0,0:ds 136+14
  1956.  
  1957. prgwinmen  dw  5, 1+4,prgwinmentx1,prgwinmen1,0, 1+4,prgwinmentx2,prgwinmen2,0, 1+4,prgwinmentx3,prgwinmen3,0, 1+4,prgwinmentx4,prgwinmen4,0, 1+4,prgwinmentx5,prgwinmen5,0
  1958. prgwinmen1 dw  6, 1,prgwinmen1tx1,filnew,0, 1,prgwinmen1tx2,filopn,0, 1,prgwinmen1tx3,filsav,0, 1,prgwinmen1tx4,filsas,0, 1+8,0,0,0, 1,prgwinmen1tx5,prgend0,0
  1959. prgwinmen2 dw 12, 1,prgwinmen2tx1,edtcut,0, 1,prgwinmen2tx2,edtcop,0, 1,prgwinmen2tx3,edtpas,0, 1,prgwinmen2tx4,edtdel,0, 1+8,0,0,0,                1,prgwinmen2tx5,fndfnd,0
  1960.            dw     1,prgwinmen2tx6,fndfnx,0, 1,prgwinmen2tx7,fndrep,0, 1,prgwinmen2tx8,edtgot,0, 1+8,0,0,0,                1,prgwinmen2tx9,edtsal,0, 1,prgwinmen2txa,edttim,0
  1961. prgwinmen3 dw  2, 1,prgwinmen3tx1,cfgwrp,0, 1,prgwinmen3tx2,cfgopn,0
  1962. prgwinmen4 dw  1, 1,prgwinmen4tx1,cfgbar,0
  1963. prgwinmen5 dw  3, 1,prgwinmen5tx1,prghlp,0, 1+8,0,0,0, 1,prgwinmen5tx2,prginf,0
  1964.  
  1965. prgwingrp   db 2,0:dw prgwinobj,prgwinclc,0,256*0+0,0,0,2
  1966. prgwinobj
  1967.             dw     00,255*256+00,8         ,0,0,0,0,0   ;00=Background
  1968.             dw edtchg,255*256+33,txtmulobj ,0,0,0,0,0   ;01=Editor
  1969.  
  1970. prgwinclc
  1971.             dw   0,      0,  0,  0,1000,      0,1000,      0    ;Background
  1972.             dw   1,      0,  1,  0,  -2,256*1+1, -2,256*1+1     ;Editor
  1973.  
  1974. txtmulobj   dw txtbufmem    ;texdatadr       equ 0           ;Zeiger auf Text
  1975.             dw 0            ;texdatbeg       equ 2           ;erstes angezeigtes Zeichen (nur singleline)
  1976.             dw 0            ;texdatpos       equ 4           ;Cursorposition im Gesamttext
  1977.             dw 0            ;texdatmrk       equ 6           ;0/Anzahl markierter Zeichen [neg->Cursor=Ende Markierung]
  1978.             dw 0            ;texdatlen       equ 8           ;Textlфnge
  1979.             dw txtbufmax    ;texdatmax       equ 10          ;maximal zulфssige Textlфnge (1-16383; exklusive 0-Terminator)
  1980.             db 4            ;texdatflg       equ 12          ;Flags (Bit0=Pa▀wort [nur singleline], Bit1=ReadOnly, Bit2=AltColor, Bit3=AltFont [nur multiline], Bit7=Text has been modified)
  1981.                             ;;** extended 16c/altfont
  1982.             db 0+16         ;texdatcol       equ 13          ;4bit txtpap, 4bit txtpen
  1983.             db 0            ;texdatrhm       equ 14          ;4bit rahmen1, 4bit rahmen2 (nur singleline)
  1984.             dw 0            ;texdatfnt       equ 15          ;Adresse des alternativen Fonts
  1985.             ds 1            ;texdatrs1       equ 17          ;*reserved 2byte*
  1986.                             ;;** ab hier nur Multiline
  1987.             dw 0            ;texdatlnt       equ 18          ;aktuelle Anzahl Zeilen
  1988.             dw -1           ;texdatxmx       equ 20          ;maximale Zeilenbreite in Pixeln bei Wordwrap-Pos-Vorgabe (-1=unbegrenzt)
  1989.             dw txtlinmax    ;texdatymx       equ 22          ;maximale Anzahl Zeilen (*2 bytes ab texdatlln!)
  1990.             dw -8           ;texdatxwn       equ 24          ;win y len ohne slider f№r bisherige formatierung (winx<>aktx -> Neuformatierung notwendig, durch -8 erzwingen)
  1991.             dw 0            ;texdatywn       equ 26          ;win y len ohne slider
  1992.                             ;
  1993.             dw txtmulobj    ;texdatzgr       equ 28          ;pointer auf diesen datensatz
  1994.             dw 120          ;texdatxfl       equ 30          ;full x len (=Lфnge der lфngsten Textzeile in Pixel)
  1995.             dw 80           ;texdatyfl       equ 32          ;full y len (=Anzahl aller Textzeilen * 8)
  1996.             dw 0            ;texdatxof       equ 34          ;offset x
  1997.             dw 0            ;texdatyof       equ 36          ;offset y
  1998.             db 1+2          ;texdatfg2       equ 38          ;Flags (Bit0=kein Auto-WordWrap [dann Xslider], Bit1=1)
  1999.             db 0            ;texdattab       equ 39          ;Tabstop GrЎ▀e (1-255; 0=kein Tabstop)
  2000.                             ;
  2001.             ds 4            ;texdatmsg       equ 40          ;Message-Buffer (in POS, MRK, out CXP, CYP)
  2002.             ds 4            ;texdatrs2       equ 44          ;*reserved 4byte*
  2003.             db 0            ;texdatlln       equ 48          ;Zeilen-Lфngentabelle (bit15=cr+lf am ende vorhanden, wird mitgezфhlt)
  2004. ;!!!last line in transfer-area!!!
  2005.  
  2006. prgtrnend
  2007.