Guest User

The_Muh

a guest
Jul 16th, 2009
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.50 KB | None | 0 0
  1. '--------------Credits--------------'
  2. ' MuhEdit, version 0.9.11-2
  3. ' Programming and idea by The_Muh.
  4. '-----------------------------------'
  5. '
  6. function byte_2_x(B as ulongint) as string
  7. dim KiB as ulongint
  8. dim MiB as ulongint
  9. dim biggest as string
  10. dim stamp as string
  11.  
  12. if B >= 1024 then
  13. KiB = int(B / 1024)
  14. B -= KiB * 1024
  15. Biggest = "KiB"
  16. end if
  17. if KiB >= 1024 then
  18. MiB = int(KiB / 1024)
  19. KiB -= MiB * 1024
  20. Biggest = "MiB"
  21. end if
  22.  
  23. select case biggest
  24. case "KiB":
  25. stamp = Kib & " KiB, " & B & " Byte"
  26. case "MiB":
  27. stamp = Mib & "MiB, " & KiB & " KiB"
  28. end select
  29. return stamp
  30. end function
  31.  
  32. type file_type
  33. title as string
  34. flag as integer
  35. end type
  36.  
  37.  
  38. 'declares:
  39. declare function search() as integer
  40. declare sub correct_cur()
  41. declare sub laden(seite as string)
  42. declare sub speichern(file as string = "")
  43. declare sub text(ByVal wahl As Integer, title as string = "")
  44. declare sub anzeige(anzeigetext() as string, X as integer, Y as integer)
  45. declare function new_file() as string
  46. declare function conv(key as string) as string
  47. declare function directory() as string
  48. declare function gen_row(number as integer, biggest as integer) as string
  49. declare function eingabe(ByVal frage As String ,vorgabe As String, X as integer,Y as integer, title as string = "") as string
  50. declare function Max(array() as string) as integer
  51. declare Function str_replace(ByVal V_Data As String, ByVal V_Expression As String, ByVal V_ReplaceBy As String) As String
  52.  
  53. 'variablen:
  54. dim d as string
  55. dim as string Li, Re
  56. dim as integer ascL, ascR
  57. dim shared as string tZeile()
  58. dim shared as string seite
  59. dim shared as integer zeile=3, spalte=1
  60. dim as integer mzeile, mspalte, buttons, wheel, wheel_old, mdummy
  61. dim i as integer
  62. dim L as integer
  63. Dim as integer einf = 1
  64. dim shared dirs as string
  65. dim rest as string
  66. dim shared a as integer
  67. dim shared b as integer
  68. dim shared pot_spalte as integer = 1
  69. dim clip as integer
  70. dim shared ba as integer = 0
  71. 'Options-varis:
  72. dim shared row_num as integer = 1
  73. dim shared all_rows as integer = 0
  74. dim shared hoehe as integer = 60
  75. dim shared breite as integer = 65
  76. REDIM tzeile(1) AS STRING
  77.  
  78. 'makros:#macro datei(fl, endung)
  79. #macro datei(fl, endung)
  80. K = DIR("*."& endung ,fl + &H04 + &H01)
  81. do
  82. if len(k) > 0 and k <> "." and k <> ".." then
  83. redim preserve files(i)
  84. files(i).title = K
  85. files(i).flag = fl
  86. i += 1
  87. end if
  88. K = DIR("")
  89. LOOP until LEN(K) = 0
  90. #endmacro
  91.  
  92. #macro blubb()
  93. dim key as string
  94. dim sh as integer
  95. c = 0
  96. do
  97. cls
  98. locate 1, 1 : PRINT "MuhEdit Filebrowser";
  99. locate 2, 1 : Print String(breite, asc("_"));
  100. locate hoehe,1 :Print "Switch between File / Directory = F2 or F4 ";
  101. text(5)
  102. for sh = lbound(files) to (hoehe -5) 'text anzeigen...
  103. if SH + A <= ubound(files) then
  104. locate sh+3,1
  105. if sh = c then
  106. if files(sh+a).flag = &h10 then
  107. print "X) /"& files(sh+A).title;
  108. else
  109. print "X) "& files(sh+A).title;
  110. end if
  111. else
  112. if files(sh+a).flag = &h10 then
  113. print " ) /"& files(sh+A).title;
  114. else
  115. print " ) "& files(sh+A).title;
  116. end if
  117. end if
  118. else
  119. exit for
  120. end if
  121. next sh
  122. do : sleep 1 : key = inkey : loop until key <> ""
  123. select case asc(right(key,1))
  124. case 60, 62
  125. if flag = &h10 then
  126. flag = &h00
  127. else
  128. flag = &h10
  129. end if
  130. exit do
  131. case 73
  132. if A > 0 then
  133. A -= 1
  134. end if
  135. case 81
  136. if c + a < ubound(files) then A += 1
  137. case 72 'oben
  138. if c > 0 then c -= 1
  139. if A > 0 and c = 0 then a -= 1
  140. case 80 'unten
  141. if c < (hoehe -5) and c < ubound(files) then
  142. c += 1
  143. else
  144. if c + a < ubound(files) then A += 1
  145. end if
  146. end select
  147. select case asc(left(key,1))
  148. case 27
  149. if flag = &h10 then
  150. weiter = 0
  151. else
  152. C = -1
  153. weiter = 0
  154. end if
  155. exit do
  156. case 13
  157. if files(c).flag = &h10 then
  158. if c = 0 then
  159. dirs = ".."
  160. else
  161. dirs = files(c).title
  162. end if
  163. chdir(dirs)
  164. else
  165. seite = files(c).title
  166. weiter = 0
  167. end if
  168. exit do
  169. end select
  170. loop
  171. #endmacro
  172.  
  173. 'subs und funktionen:
  174. sub angleichen()
  175. if ubound(tzeile) < zeile + A then redim preserve tzeile(zeile + A) as string
  176. end sub
  177.  
  178. function gen_row(number as integer, biggest as integer) as string
  179. dim l_num as integer
  180. dim l_big as integer
  181. dim row as string
  182.  
  183. l_num = len(str(number))
  184. l_big = len(str(biggest))
  185.  
  186. row = string( (l_big - l_num), " ") & str(number) & "|"
  187. return row
  188. end function
  189.  
  190. sub anzeige(anzeigetext() as string, X as integer,Y as integer)
  191. for sh as integer = 3 to (hoehe - 2) 'text anzeigen...
  192. if SH + X <= ubound(anzeigetext) then
  193. locate sh, 1
  194. if row_num = 1 then
  195. if ubound(anzeigetext) < hoehe -2 and all_rows = 1 then
  196. ba = len(gen_row(0,hoehe -2))
  197. print gen_row(sh + x -2, hoehe -2) & mid(anzeigetext(sh+X),Y+1,breite- ba)
  198. else
  199. ba = len(gen_row(0,ubound(anzeigetext)))
  200. print gen_row(sh + x -2, ubound(anzeigetext)) & mid(anzeigetext(sh+X),Y+1,breite -ba)
  201. shell "echo "& len(mid(anzeigetext(sh+X),1+Y,breite)) &" , "& breite
  202. end if
  203. else
  204. print mid(anzeigetext(sh+X),Y +1,breite)
  205. end if
  206. else
  207. exit for
  208. end if
  209. next sh
  210. if ubound(anzeigetext) < hoehe -2 and row_num = 1 and all_rows = 1 then
  211. for i as integer = ubound(anzeigetext) +1 to hoehe -2
  212. print gen_row(i -2, hoehe -2)
  213. next
  214. end if
  215. end sub
  216.  
  217. function conv(key as string) as string
  218. dim con as string
  219. dim ascl as integer
  220. ascL = asc(left(key,1))
  221. select case ascL
  222. 'case 167 : con = chr(245) '§
  223. case 228 : con = chr(132) 'ä
  224. case 196 : con = chr(142)
  225. case 246 : con = chr(148) 'ö
  226. case 214 : con = chr(153)
  227. case 252 : con = chr(129) 'ü
  228. case 220 : con = chr(154)
  229. case 223 : con = chr(225) '�&#159;
  230. case else: con = chr(ascl)
  231. end select
  232. return con
  233. end function
  234.  
  235. sub correct_curs()
  236. angleichen()
  237. if len(tzeile(zeile + A)) >= pot_spalte and len(tzeile(zeile + a)) > 1 then
  238. spalte = pot_spalte
  239. end if
  240. if len(tzeile(zeile + A)) < pot_spalte then
  241. spalte = len(tzeile(zeile + A)) + 1
  242. if len(tzeile(zeile + A)) = 0 then spalte = 1
  243. end if
  244. if spalte + ba > breite then
  245. B = spalte - (breite + ba)
  246. spalte -= B
  247. else
  248. b = 0
  249. end if
  250. end sub
  251.  
  252. sub counter()
  253. dim code as integer
  254. dim blank as integer
  255. dim i as integer
  256. for i = 1 to ubound(tzeile)-1
  257. if len(ltrim(tzeile(i))) = 0 or len(ltrim(tzeile(i),chr(9))) = 0 then blank += 1
  258. if len(ltrim(tzeile(i),chr(9))) <> 0 and len(ltrim(tzeile(i))) <> 0 then code += 1
  259. next i
  260.  
  261. locate 8,1
  262. print "Textlines: "& code' - blank
  263. print "Blanklines: "& blank
  264. print ""
  265. print "Gesamt: "& code + blank
  266. end sub
  267.  
  268. function directory() as string
  269. dim dirs as string
  270. dim files() as file_type
  271. dim as integer i = 1
  272. dim c as integer
  273. dim K as string
  274. dim A as integer
  275. dim key as string
  276. dim flag as integer
  277. dim weiter as integer
  278. weiter = 1
  279. Locate 4,1
  280. files(0).title = ".."
  281. do
  282. redim preserve files(2)
  283. i = 1
  284. files(0).flag = &h10
  285. datei(&h10,"*")
  286. datei(&h00,"txt")
  287. datei(&h00,"*ml")
  288. datei(&h00,"bas")
  289.  
  290. blubb()
  291. if c > ubound(files) then continue do
  292. loop until weiter = 0
  293. if files(c).flag = &h00 then
  294. a = 0
  295. b = 0
  296. laden(seite)
  297. end if
  298. locate 1,1
  299. return curdir
  300. end function
  301.  
  302. function eingabe(ByVal frage As String ,vorgabe As String, X as integer,Y as integer, title as string = "") as string
  303. dim zeichen as string
  304. dim zeichenkette as string
  305. dim L as integer
  306. dim Li as string
  307. dim Re as string
  308. dim ascR as integer
  309. dim ascL as integer
  310. dim einf as integer
  311. dim spalte as integer
  312. dim rest as string
  313. einf = 1
  314. zeichenkette = vorgabe
  315. locate x, 1
  316. print frage & Zeichenkette;
  317. spalte = len(zeichenkette) +1
  318. y = len(frage) +1
  319. do
  320. text(2)
  321. text(6, title)
  322. locate x,1: print frage;
  323. locate x,len(frage) + 1: print Zeichenkette;
  324. DRAW STRING ((y + spalte-2)*8 , (x-1)*8), "_" 'Cursor anzeigen
  325. do : sleep 1 : zeichen = inkey : loop while zeichen = ""
  326.  
  327. Li = mid(zeichen, 1,1)
  328. Re = mid(zeichen, 2.1)
  329. ascL = asc(Li)
  330. ascR = asc(Re)
  331.  
  332. L = len(zeichenkette)
  333. select case ascR
  334. case 82 'testen ob "einf" gedr�ckt wurde
  335. if einf = 1 then 'der umschalter
  336. einf = 0
  337. else
  338. einf = 1
  339. end if
  340. case 75: 'links
  341. if spalte > 1 then spalte -= 1
  342. case 77: 'rechts
  343. if spalte < L then spalte += 1
  344. end select
  345.  
  346. if ascL <> 255 then
  347. select case ascL
  348. case 8 'backspace
  349. if L > spalte then
  350. zeichenkette = left(zeichenkette,spalte-2) + right(zeichenkette,L -(spalte-1))
  351. else
  352. zeichenkette=left(zeichenkette,len(zeichenkette)-1)
  353. end if
  354.  
  355. if spalte <> 1 then spalte -= 1
  356. pot_spalte = spalte
  357. case 13 'enter
  358. return zeichenkette
  359. locate 3,1
  360. exit function
  361. case 27
  362. return vorgabe
  363. locate 3,1
  364. exit function
  365. case 127 'entf
  366. if L >= spalte then
  367. zeichenkette = left(zeichenkette,spalte-1) + right(zeichenkette,L -(spalte))
  368. end if
  369. case else
  370. if L >= spalte then
  371. if einf = 0 then
  372. MID(zeichenkette, spalte, 1) = zeichen
  373. else
  374. zeichenkette = left(zeichenkette, spalte-1) + zeichen + right(zeichenkette, (L - spalte +1) )
  375. end if
  376. else
  377. zeichenkette = zeichenkette + zeichen
  378. end if
  379. spalte += 1
  380. end select
  381. end if
  382. loop until zeichen = chr(13)
  383. end function
  384.  
  385. sub info()
  386. cls
  387. text(1)
  388. dim array as integer
  389. dim zeilen as integer
  390. dim zeichen as integer
  391. dim filesize as integer
  392.  
  393. OPEN seite FOR BINARY AS #1
  394. filesize = LOF(1)
  395. CLOSE #1
  396.  
  397. array = ubound(tzeile)
  398. for i1 as integer = 1 to array
  399. if len(tzeile(i1)) > 0 then
  400. zeilen += 1
  401. end if
  402. next i1
  403.  
  404. for i2 as integer = 1 to array
  405. zeichen += len(tzeile(i2))
  406. next
  407.  
  408.  
  409. locate 3,1:print "Filename: "& seite;
  410. locate 4,1:print "Letters: "& zeichen;
  411. locate 5,1:print "Filesize: "& byte_2_x(filesize)
  412. end sub
  413.  
  414.  
  415. sub laden(filename as string)
  416. dim as integer i = 2
  417. dim dummy as string
  418. redim tzeile(1) as string
  419. OPEN filename FOR INPUT AS #1
  420. while not EOF(1)
  421. i += 1
  422. REDIM Preserve tzeile(i) AS STRING
  423. line INPUT #1, dummy
  424. tzeile(i) = rtrim(str_replace(dummy, chr(9), " "))
  425. wend
  426. CLOSE #1
  427. redim preserve tzeile(max(tzeile())) 'leere zeilen am ende der datei "abschneiden"
  428. end sub
  429.  
  430. function max(array() as string) as integer
  431. dim m as integer
  432. for i as integer = 3 to ubound(array)
  433. if len(ltrim(array(i))) <> 0 then
  434. m = i
  435. end if
  436. next
  437. return m
  438. end function
  439.  
  440. function new_file() as string
  441. dim filename as string
  442. dim key as string
  443. cls
  444. text (6,"Create a new File")
  445. if seite <> "" then
  446. locate hoehe, 1 : print "Save old file? (J/N)";
  447. do : sleep 1 : key = inkey: loop until key <> ""
  448. if lcase(key) = "j" then
  449. speichern(seite)
  450. end if
  451. end if
  452.  
  453. filename = eingabe("New Filename: ", "new.txt", hoehe, 1, "Create a new File")
  454. if DIR(filename, &h27) <> "" then
  455. locate hoehe, 1 : print "File already exists, overwrite? (J/N)";
  456. do : sleep 1 : key = inkey: loop until lcase(key) = "j" or lcase(key) = "n"
  457. if lcase(key) = "j" then
  458. open filename for output as #1
  459. close #1
  460. redim tzeile(0)
  461. elseif lcase(key) = "n" then
  462. exit function
  463. end if
  464. elseif len(filename) <> 0 then
  465. open filename for output as #1
  466. close #1
  467. redim tzeile(0)
  468. end if
  469. return filename
  470. end function
  471.  
  472. Function str_replace(ByVal V_Data As String, ByVal V_Expression As String, ByVal V_ReplaceBy As String) As String
  473. Dim X As Long
  474. Dim SL As Long
  475. Dim D as String
  476. D = V_Data
  477. SL = Len(V_Expression)
  478. X = 0
  479. Do
  480. X = X + 1
  481. If X > Len(D) - SL + 1 Then Exit Do
  482. If Mid(D, X, SL) = V_Expression Then
  483. D = Mid(D, 1, X - 1) & V_ReplaceBy & Mid(D, X + SL)
  484. X = X - (SL - 1)
  485. If X < 0 then X = 0
  486. End If
  487. Loop
  488. Return D
  489. End Function
  490.  
  491. sub replace()
  492. cls
  493. dim keyword as string
  494. dim positionX(1 to 46) as integer
  495. dim positionY(1 to 46) as integer
  496. dim repl as string
  497. dim hit as integer
  498.  
  499. locate 1,1 : print "Search";
  500. locate 2, 1 : Print String(breite , asc("_"));
  501. text 5
  502. keyword = eingabe("Keyword:","",hoehe,1)
  503. repl = eingabe("Replace with:","",hoehe,1)
  504. locate 3,1
  505. for i as integer = 1 to ubound(tzeile)
  506. hit = instr(tzeile(i),keyword)
  507. if hit > 0 then
  508. tzeile(i) = left(tzeile(i),hit-1) + repl + right(tzeile(i), len(tzeile(i)) - hit -len(keyword) +1 )
  509. end if
  510. next
  511. end sub
  512.  
  513. function search() as integer
  514.  
  515. dim keyword as string
  516. dim key as string
  517. dim suchpos as integer
  518. dim as integer hit = -1
  519. locate 1,1 :Print String(breite , asc(" "));
  520. locate 1,1 : print "MuhEdit - Search";
  521. locate 2, 1 : Print String(breite, asc("_"));
  522. text 5
  523. keyword = eingabe("Keyword:","",hoehe,1)
  524. suchpos = spalte +B
  525. do
  526. for i as integer = zeile + A +hit to ubound(tzeile)
  527. do
  528. hit = instr(suchpos+1,lcase(tzeile(i)),lcase(keyword))
  529. if hit > 0 then
  530. zeile = i
  531. if zeile >= hoehe then
  532. A = (zeile - hoehe) +4
  533. zeile = zeile - A
  534. end if
  535. pot_spalte = hit
  536. correct_curs
  537. exit for
  538. end if
  539. suchpos = hit + len(keyword) -1
  540. loop until hit = 0
  541. suchpos = 0
  542. next
  543. cls
  544. locate 1,1 :Print String(breite , asc(" "));
  545. locate 1,1 : print "Search";
  546. locate 2, 1 : Print String(breite, asc("_"));
  547.  
  548. anzeige(tzeile(),A, B)
  549. text 5
  550. if hit = 0 then
  551. print "Last result in File, start new?";
  552. else
  553. print "Continue search?";
  554. end if
  555. print " Y/N";
  556. do : sleep 1 : key = inkey : loop until key <> ""
  557. if lcase(key) = "y" or key = chr(13) then
  558. if hit = 0 then
  559. zeile = 3
  560. A = 0
  561. hit = 0
  562. end if
  563. else
  564. exit do
  565. end if
  566. loop
  567. return 0
  568. end function
  569.  
  570.  
  571. sub speichern(file as string = "")
  572. cls
  573. dim x as integer
  574. dim as integer i = 3
  575. dim K as string
  576. dim filename() as string
  577. dim dummy as string
  578. text (6,"MuhEdit Saver")
  579. if file = "" then
  580. redim filename(i)
  581. anzeige(filename(), 0, 0)
  582. if len(seite) > 0 then
  583. seite = eingabe("Filename:",seite,hoehe,1)
  584. else
  585. seite = eingabe("Filename:","example.txt",hoehe,1)
  586. end if
  587. else
  588. 'print file
  589. seite = file
  590. end if
  591.  
  592. OPEN seite FOR OUTPUT AS #1
  593. For x = 3 to max(tzeile())
  594. dummy = str_replace(tzeile(x), " ", chr(9))
  595. PRINT #1, rtrim(dummy)
  596. next
  597. CLOSE #1
  598. if file = "" then text(3) : getkey
  599. end sub
  600.  
  601. sub text(ByVal wahl As Integer, title as string = "")
  602. select case wahl
  603. case 1
  604. locate 1, 1 : PRINT "Load = F2 / Save = F3 / Directory = F4 / Quit = ESC";
  605. locate 2, 1 : Print String(breite , asc("_"));
  606. Locate (hoehe-1),1 : Print String(breite , asc("_"));
  607. Locate (hoehe),1 : Print String(breite , asc(" "));
  608. Locate (hoehe),1 : Print "File: "& right(seite,30) &" / Line: "& Zeile + A - 2 &" / Row:"& spalte+b;
  609. case 2
  610. locate (hoehe ), 1 : Print String(breite, asc(" "));
  611. case 3
  612. locate (hoehe), 1 : Print String(breite, asc(" "));
  613. Locate (hoehe), 1 : Print "Accepted";
  614. locate 3,1
  615. case 4
  616. locate (hoehe), 1 : Print String(breite, asc(" "));
  617. Locate (hoehe), 1 : Print "False";
  618. locate 3,1
  619. case 5
  620. Locate (hoehe-1),1 : Print String(breite, asc("_"));
  621. case 6
  622. locate 1, 1 : PRINT title;
  623. locate 2, 1 : Print String(breite, asc("_"));
  624. Locate (hoehe-1),1 : Print String(breite, asc("_"));
  625. Locate (hoehe),1 : Print String(breite, asc(" "));
  626. case else
  627. exit sub
  628. end select
  629. end sub
  630.  
  631.  
  632.  
  633. '------------------Aufruf-flags auswerten------------------'
  634. dim s as integer
  635. if command(1) = "-S" then
  636. hoehe = HIWORD(WIDTH)
  637. breite = LOWORD(WIDTH)
  638.  
  639. if command(2) <> "" then
  640. seite = command(2)
  641. laden(seite)
  642. end if
  643. CLS
  644. elseif command(1) <> "-S" then
  645. seite = command(1)
  646. laden(seite)
  647. screenres breite*8, hoehe * 8
  648. COLOR 0, 15
  649. CLS
  650. end if
  651. '------------------------hauptprogramm----------------------'
  652. dirs = curdir
  653. locate 3, 0
  654. DO
  655. '------ verwaltung + anzeige ------'
  656. angleichen()
  657. L = len(tzeile(zeile + A))
  658. anzeige(tzeile(), A, B)
  659. text 1
  660. locate zeile ,spalte,1
  661. DRAW STRING ((spalte-1 + ba)*8 , (zeile -1)*8), "_", 'Cursor anzeigen
  662. '------ Eingabe ------':
  663. do : sleep 1 'auf eingabe warten
  664. d = inkey
  665. getmouse mspalte, mzeile,wheel,buttons
  666. if mzeile = -1 and mspalte = -1 then continue do
  667. mzeile = (mzeile+4) / 8
  668. mspalte = (mspalte+4) / 8 - BA
  669. if mspalte <= 0 then mspalte = 1
  670. if buttons = 1 and mzeile <= (hoehe - 2) and mzeile > 2 then
  671. if mzeile < 3 then mzeile = 3
  672.  
  673. if mzeile + a > ubound(tzeile) then
  674. mzeile = ubound(tzeile) -a
  675. if mzeile > hoehe then
  676. a = int(mzeile - hoehe)
  677. mzeile -= a
  678. end if
  679. end if
  680.  
  681. while buttons <> 0
  682. getmouse mspalte, mzeile,wheel,buttons
  683. if mzeile = -1 and mspalte = -1 then continue while
  684. mzeile = (mzeile+4) / 8
  685. mspalte = (mspalte+4) / 8 - BA
  686. if mzeile < 3 then mzeile = 3
  687.  
  688. if mzeile > ubound(tzeile) then
  689. mzeile = ubound(tzeile)
  690. if mzeile > hoehe then
  691. a = int(mzeile - hoehe)
  692. mzeile -= a
  693. end if
  694. end if
  695.  
  696. if mzeile <= ubound(tzeile) and mzeile > 2 then
  697. if zeile <> mzeile or spalte <> mspalte then
  698. DRAW STRING ((spalte-1 + ba)*8 , (zeile -1)*8), "_",15
  699. end if
  700. zeile = mzeile
  701. spalte = mspalte
  702.  
  703. 'Begin Mouse-Check Code
  704. if ubound(tZeile) < zeile + A then
  705. if ubound(tzeile) > hoehe -4 then
  706. A = (ubound(tzeile) - hoehe +2)
  707. zeile = (ubound(tzeile) - A)
  708. else
  709. zeile = (ubound(tzeile))
  710. end if
  711. end if
  712. if zeile > hoehe -2 then zeile = hoehe -2
  713.  
  714. tZeile(zeile + A) = rtrim(tZeile(zeile + A))
  715. if mspalte > len(tZeile(zeile + A)) then
  716. spalte = len(tZeile(zeile + A)) + 1
  717. else
  718. spalte = mspalte
  719. end if
  720. if row_num = 1 then
  721. dim foo as string = str(ubound(tzeile)) & " "
  722. end if
  723. 'End Mouse-Check Code
  724. pot_spalte = spalte
  725. correct_curs
  726. DRAW STRING ((spalte-1 + ba)*8 , (zeile -1)*8), "_", 'Cursor anzeigen
  727.  
  728. d = ""
  729. anzeige(tzeile(),A,B)
  730. end if
  731. wend
  732. exit do
  733. end if
  734. 'mausrad-code:
  735. mdummy = wheel - wheel_old
  736. if mdummy > 0 then 'hoch
  737. if A-3 > 0 then
  738. A -= 3
  739. else
  740. A = 0
  741. end if
  742. end if
  743. if mdummy < 0 and ubound(tzeile) > hoehe then 'runter
  744. if zeile + A +3 <= ubound(tzeile) then
  745. A += 3
  746. else
  747. A = ubound(tzeile) - zeile
  748. end if
  749. if zeile + A + (hoehe - 4 - zeile)+3 > ubound(tzeile) then
  750. dim dummy as integer = zeile + A + (hoehe - 2 - zeile) - ubound(tzeile)
  751.  
  752. A = A - dummy
  753. end if
  754. end if
  755. wheel_old = wheel
  756. if mdummy <> 0 then exit do
  757. 'set_mark()
  758. 'ende Mausrad-code
  759. loop until d<>""
  760. if mdummy <> 0 then cls : correct_curs :continue do
  761. locate zeile ,spalte,1
  762. if d = "" then continue do
  763. Re = mid(d, 2.1)
  764. ascR = asc(Re)
  765. if command(1) <> "-S" then D = conv(D)
  766. Li = mid(d, 1,1)
  767. ascL = asc(Li)
  768.  
  769.  
  770. '------ Verarbeitung teil 1 ------':
  771. SELECT CASE ascR
  772. case 72 'oben
  773. if zeile > 3 then
  774. zeile -= 1
  775. else
  776. if A > 0 then A -= 1
  777. end if
  778. if zeile <> 2 then
  779. correct_curs
  780. end if
  781. case 80 'unten
  782. if zeile + a < ubound(tzeile) then
  783. if zeile < (hoehe - 2) then
  784. zeile += 1
  785. else
  786. A += 1
  787. end if
  788. correct_curs
  789. end if
  790. case 75 'links
  791. if spalte > 1 then 'nicht am zeilenanfang
  792. spalte-=1
  793. pot_spalte = spalte + b
  794. else 'am zeilenanfang
  795. if zeile > 3 and zeile < (hoehe - 2) then
  796. if B = 0 then
  797. zeile -= 1
  798. pot_spalte = len(tzeile(zeile +A)) +1
  799. if spalte > breite then
  800. B = pot_spalte - breite
  801. pot_spalte -= B
  802. end if
  803. correct_curs
  804. else
  805. B -= 1
  806. end if
  807. elseif zeile = 3 or zeile = (hoehe-2) then
  808. if B > 0 then
  809. B -= 1
  810. elseif B = 0 then
  811. if zeile = hoehe-2 then
  812. zeile -= 1
  813. else
  814. if A > 0 then A -= 1
  815. end if
  816. end if
  817. end if
  818. end if
  819. case 77 'rechts
  820. if spalte + b < L + 2 and spalte + b < L +1 orelse zeile + a < ubound(tzeile) then
  821. if spalte < breite then
  822. spalte += 1
  823. pot_spalte = spalte + b
  824. elseif spalte = hoehe then
  825. b += 1
  826. end if
  827. end if
  828. if spalte + b >= l +2 then
  829. spalte = 1
  830. B = 0
  831. if zeile < (hoehe - 2) then
  832. zeile += 1
  833. else
  834. A += 1
  835. end if
  836. end if
  837. case 107 'das X oben
  838. exit do
  839. case 59 'F1
  840. tzeile(zeile + a) = left(tzeile(zeile + a), spalte + b)
  841. correct_curs
  842. case 63 'F5, hohe und breite
  843. if command(1) <> "-S" then
  844. CLS
  845. text(1)
  846. locate 3,1 : print "The width must be 55 or higher"
  847. locate 4,1 : print "The Heigth must be 20 or higher"
  848. locate 5,1 : Input "Heigth: ", Hoehe
  849. Locate 6,1 : Input "Width: ", Breite
  850. if breite < 65 then breite = 65
  851. if hoehe < 40 then hoehe = 40
  852. screenres breite *8, hoehe * 8
  853. if zeile > hoehe then
  854. A += zeile-hoehe+2
  855. zeile = 3
  856. end if
  857. COLOR 0, 15
  858. end if
  859. case 64 'f6 (dateiinfo)
  860. info()
  861. counter()
  862. getkey
  863. case 65 'F7 Zeilennummern
  864. if row_num = 1 then
  865. row_num = 0
  866. ba = 0
  867. else
  868. row_num = 1
  869. end if
  870. case 66 'F8 Alle/nicht alle zeilennummern
  871. if row_num = 1 then
  872. if all_rows = 1 then
  873. all_rows = 0
  874. else
  875. all_rows = 1
  876. end if
  877. end if
  878. case 61 'seite speichern(F3)
  879. speichern()
  880. text(1)
  881. case 60 'Laden (F2)
  882. dirs = directory()
  883. spalte =1
  884. zeile = 3
  885. case 82 'einf�gen
  886. if einf = 1 then
  887. einf = 0
  888. else
  889. einf = 1
  890. end if
  891. case 73 'bild hoch
  892. if A-2 > 0 then
  893. A -= 3
  894. else
  895. A = 0
  896. end if
  897. correct_curs
  898. case 81 'bild runter
  899. if ubound(tzeile) > (zeile + A)+2 then
  900. a += 3
  901. else
  902. A = ubound(tzeile) - zeile
  903. end if
  904. correct_curs
  905. case 71 'Pos1
  906. pot_spalte = 1
  907. b = 0
  908. correct_curs
  909. case 79 'Ende
  910. pot_spalte = len(tzeile(zeile +A)) +1
  911. if spalte > breite then
  912. B = pot_spalte - breite
  913. pot_spalte -= B
  914. end if
  915. correct_curs
  916. #ifndef __fb_linux__
  917. case 83 'entf
  918. if L >= spalte + B then
  919. tzeile(zeile+A) = left(tzeile(zeile+A),B + spalte-1) + right(tzeile(zeile+A),L -(spalte+B))
  920. elseif L < spalte + B then
  921. redim preserve tzeile(ubound(tzeile) + 1)
  922. rest = tzeile(zeile + a +1)
  923. tzeile(zeile +a ) = tzeile(zeile + a) + rest
  924. for x as integer = zeile + a +1 TO max(tzeile())
  925. tzeile(x) = tzeile(x+1)
  926. next
  927. redim preserve tzeile(ubound(tzeile) -1)
  928. end if
  929. #endif
  930. end select
  931. '------ Verarbeitung teil 2 ------':
  932. if ascL <> 255 then
  933. select case ascL
  934. case 6
  935. search()
  936. if zeile > 46 then
  937. A = zeile - 46
  938. zeile -= A
  939. end if
  940. case 8 'backspace
  941. if spalte > 1 then 'nicht am zeilenanfang
  942. if B = 0 then
  943. spalte-=1
  944. else
  945. b -= 1
  946. end if
  947. locate zeile,spalte
  948. L = len(tzeile(zeile +A))
  949. if L >= spalte+B then
  950. tzeile(zeile+A) = left(tzeile(zeile+A),B + spalte-1) + right(tzeile(zeile+A),L -(spalte+B))
  951. else
  952. tzeile(zeile +A)=left(tzeile(zeile +A),len(tzeile(zeile +A))-1)
  953. end if
  954. else 'am zeilenanfang
  955. if zeile + A <= max(tzeile()) and zeile + A > 3 then
  956. spalte = len(tzeile(zeile +A -1)) +1
  957. redim preserve tzeile(ubound(tzeile) + 1)
  958. rest = tzeile(zeile + A)
  959. tzeile(zeile + A -1) = tzeile(zeile + A -1) + rest
  960. for x as integer = (zeile + A) TO max(tzeile())
  961. tzeile(x) = tzeile(x+1)
  962. next
  963. redim preserve tzeile(ubound(tzeile) -1)
  964. zeile -= 1
  965. end if
  966. if zeile +a > max(tzeile()) and zeile > 3 then
  967. zeile -= 1
  968. spalte = len(rtrim(tzeile(zeile + A)))+1
  969. end if
  970. if zeile = 3 and a > 0 then
  971. if A > 0 then A -= 1
  972. spalte = len(rtrim(tzeile(zeile+a)))+1
  973. end if
  974. pot_spalte = spalte
  975. end if
  976. case 13 'enter
  977. if L >= (spalte + b) and zeile >= 3 then
  978. redim preserve tzeile(ubound(tzeile) + 1)
  979. for x as integer = ubound(tzeile) to (zeile +a +1) step -1
  980. tzeile(x) = tzeile(x-1)
  981. next
  982.  
  983. rest = right(tzeile(zeile +A), (L - (spalte + B))+1)
  984. tzeile(zeile+A) = left(tzeile(zeile+A), (Spalte +B) -1)
  985. tzeile(Zeile+A+1) = rest
  986. elseif zeile + a < max(tzeile()) and Len(ltrim(tzeile(zeile))) = 0 then
  987. redim preserve tzeile(ubound(tzeile) + 1)
  988. for x as integer = ubound(tzeile) to (zeile + a +1) step -1
  989. tzeile(x) = tzeile(x-1)
  990. next
  991. end if
  992. if zeile < (hoehe - 2) then
  993. zeile += 1
  994. spalte = 1
  995. B = 0
  996. else
  997. spalte = 1
  998. B = 0
  999. A += 1
  1000. end if
  1001. pot_spalte = spalte
  1002. case 14
  1003. seite = new_file
  1004. cls
  1005. #IFdef __fb_linux__
  1006. case 127 'ENTF
  1007. if L >= spalte + a then
  1008. tzeile(zeile+A) = left(tzeile(zeile+A),B + spalte-1) + right(tzeile(zeile+A),L -(spalte+B))
  1009. elseif L < spalte + a then
  1010. redim preserve tzeile(ubound(tzeile) + 1)
  1011. rest = tzeile(zeile + a +1)
  1012. tzeile(zeile + a) = tzeile(zeile +a) + rest
  1013. for x as integer = zeile+a+1 TO max(tzeile())
  1014. tzeile(x) = tzeile(x+1)
  1015. next
  1016. redim preserve tzeile(ubound(tzeile) -1)
  1017. end if
  1018. if zeile + a > max(tzeile()) and L = 0 and zeile > 3 then
  1019. zeile -= 1
  1020. redim preserve tzeile(zeile + A)
  1021. end if
  1022. #endif
  1023.  
  1024. '-----------------------------'
  1025. case 18
  1026. replace()
  1027. case 19
  1028. speichern()
  1029. text(1)
  1030. case 27 'escape
  1031. exit do
  1032. case 32 to 127,9,245, 132,142,148,153,129,154,225
  1033. if ascL = 9 then
  1034. D = string(4, " ")
  1035. end if
  1036.  
  1037. L = len(tzeile(zeile +A))
  1038. if L >= spalte + B then
  1039. if einf = 0 then
  1040. MID(tzeile(zeile + A), spalte +B 1) = d
  1041. else
  1042. tzeile(zeile +A) = left(tzeile(zeile +A), spalte +B-1 -ba) + d + right(tzeile(zeile +A), (L - spalte -B +1))
  1043. end if
  1044. else
  1045. tzeile(zeile +A) = tzeile(zeile +A) + d
  1046. end if
  1047.  
  1048. if spalte = breite then
  1049. b += 1
  1050. else
  1051. spalte += 1
  1052. end if
  1053.  
  1054. if ascL = 9 then
  1055. if spalte <= breite -4 then
  1056. spalte += len(D) -1
  1057. else
  1058. B += len(D) -1 - (breite - spalte)
  1059. end if
  1060. end if
  1061. pot_spalte = spalte + b
  1062. end select
  1063. end if
  1064. cls
  1065. loop
  1066. end
  1067.  
Advertisement
Add Comment
Please, Sign In to add comment