home *** CD-ROM | disk | FTP | other *** search
- (*
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓·── ──·▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓│ │░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ Unit was conceived, designed and written ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ by Floor A.C. Naaijkens for ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ UltiHouse Software / The ECO Group. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ (C) MCMXCII by EUROCON PANATIONAL CORPORATION. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ All Rights Reserved for The ECO Group. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓│ │░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓·── ──·░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- *)
- {$V-,F+,O+}
- {$M 65520,0,65520}
- unit eco_edit;
- interface
- uses
-
- unit_scn,
-
- ttt_key, unit_key,
-
- bined, dos,
-
- ECO_utl, ECO_time, ECO_pasc,
-
- unit_ext, unit_fil,
- unit_str, unit_sup
-
- ;
-
- var
- exitcommand,
- hours, minutes,
- seconds, tics,
- year, month,
- day, errorcode : word;
- edfilesize : longint;
- st,filename : string;
- eddata : edcb;
-
-
- const
- windx1 = 2;
- windx2 = 79;
- windy1 = 2;
- windy2 = 24;
- editortimer : byte = 1;
- backupwait : byte = 5;
- makebackup : boolean = false;
- extension : string[3] = 'TXT';
- boxes: array[1..4,1..4,1..3] of char =
- (
- (('┌','┬','┐'), ('├','┼','┤'), ('└','┴','┘'), ('│','─','─')),
- (('╔','╦','╗'), ('╠','╬','╣'), ('╚','╩','╝'), ('║','═','═')),
- (('╓','╥','╖'), ('╟','╫','╢'), ('╙','╨','╜'), ('║','─','─')),
- (('╒','╤','╕'), ('╞','╪','╡'), ('╘','╧','╛'), ('│','═','═'))
- );
-
- exitcommands : array[0..24] of char =
- ( #2, { editor exit commands }
- #0, #59, #2, { 0 f1: help }
- #0, #17, #2, { 1 alt-w: save }
- #0, #68, #2, { 2 f10: size/shift }
- ^k, ^s, #2, { 3 redraw editor }
- #0, #30, #2, { 4 alt-a: accent chars }
- #0, #44, #2, { 5 alt-z: ascii chars }
- #0, #17, #2, { 6 alt-w: weird chars }
- #0, #48, #0 { 7 alt-b: box chars }
- );
-
-
- procedure call_editor;
-
-
- implementation
-
-
- procedure writeupstat(st: string);
- begin
- clearline(1,invf,invb);
- writeat(1,1,invf,invb,st)
- end;
-
-
- procedure writednstat(st: string);
- begin
- clearline(25,invf,invb);
- writeat(1,25,invf,invb,st)
- end;
-
-
- procedure initstatusline;
- var i: shortint;
- begin {initstatusline}
- writednstat(' f1help f2 f3 f4stat f5 '+
- 'f6 f7 f8 f9ascii f0menu');
- for i := 0 to 9 do attrib(i*8+2,25,i*8+3,25,8,15)
- end;
-
-
- procedure hidnstat;
- begin
- attrib(1,25,80,25,8,15)
- end;
-
-
- procedure initupstat;
- begin
- clearline(1,invf,invb); xy(2,1); colors(invf,invb); ECO_message;
- end;
-
-
- procedure initdnstat;
- var i: shortint;
- begin
- clearline(25,invf,invb); writeat(1,25,invf,invb,
- ' f1help f2 f3 f4stat f5 '+
- ' f6 f7 f8 f9ascii f0menu');
- for i := 0 to 9 do attrib(i*8+2,25,i*8+3,25,8,15)
- end;
-
-
- function yesanswer(prompt : string) : boolean;
- var ch : char;
- begin
- writednstat(prompt); repeat ch:=upcase(readkey) until ch in ['y', 'n'];
- yesanswer := ch='y';
- end;
-
-
- function choose_ascii_char: string;
- begin
- setchooseascii(58,4);
- mkwin(65,8,69,15,lc,black,1); delay(50); rmwin;
- mkwin(58,4,76,22,lightgray,blue,0);
- choose_ascii_char := chooseascii ;rmwin
- end;
-
-
-
- function choose_weird_char: string;
- var
- weird : shortint;
- toets : char;
- i : integer;
- begin
- mkwin(54,6,60,7,lc,black,1); delay(50); rmwin;
- mkwin(40,5,72,8,lc,black,2); weird := 1;
- writebetween(weird+40,72,5,hc,black,' Choose Weird Char ');
- for i := 1 to 31 do writeat(40+i,6,lc,black,chr(i));
- writeat(weird+40,7,lc+blink,black,''); offcursor;
- repeat
- toets := getkey;
- writeat(weird+40,7,lc,black,' ');
- if (toets=_left) or (toets=mleft) then weird := weird - 1;
- if weird<1 then weird := 31;
- if (toets=_right) or (toets=mright) then weird := weird + 1;
- if weird>31 then weird := 1;
- writeat(weird+40,7,lc+blink,black,'');
- until toets in [_esc, _enter, menter, mesc];
- rmwin;
- if toets in [menter,_enter] then
- choose_weird_char := chr(weird) else choose_weird_char := #00;
- oncursor
- end;
-
-
-
- function choose_accent_char: string;
- const
- accents: array [1..33] of char = (
- 'á','à','ä','â','å','æ','Æ','Å','Ä','ç','Ç',
- 'é','è','ë','ê','É','í','ì','ï','î','ñ','Ñ',
- 'ó','ò','ö','ô','Ö','ú','ù','ü','û','Ü','ÿ'
- );
- var
- accent : shortint;
- toets : char;
- i : integer;
- begin
- mkwin(55,6,60,7,lc,black,1); delay(50); rmwin;
- mkwin(40,5,74,8,lc,black,2); accent := 1;
- writebetween(40,74,5,hc,black,' Choose Accent Char ');
- for i := 1 to 33 do writeat(40+i,6,lc,black,accents[i]);
- writeat(accent+40,7,lc+blink,black,''); offcursor;
- repeat
- toets := getkey;
- writeat(accent+40,7,lc,black,' ');
- if toets in [mleft,_left] then accent := accent - 1;
- if accent<1 then accent := 33;
- if toets in [_right,mright] then accent := accent + 1;
- if accent>33 then accent := 1;
- writeat(accent+40,7,lc+blink,black,'');
- until toets in [_esc,_enter,menter,mesc];
- rmwin;
- if toets in [menter,_enter] then choose_accent_char := accents[accent]
- else choose_accent_char := #00;
- oncursor
- end;
-
-
- function choose_box_char: string;
- const
- boxpos: array[1..4,1..4,1..3] of record x,y: integer end = (
- (((x:27;y:7),(x:30;y:7),(x:33;y:7)),((x:27;y:9),(x:30;y:9),(x:33;y:9)),
- ((x:27;y:11),(x:30;y:11),(x:33;y:11)),((x:27;y:14),(x:30;y:14),(x:30;y:14))),
- (((x:40;y:7),(x:43;y:7),(x:46;y:7)),((x:40;y:9),(x:43;y:9),(x:46;y:9)),
- ((x:40;y:11),(x:43;y:11),(x:46;y:11)),((x:40;y:14),(x:43;y:14),(x:43;y:14))),
- (((x:53;y:7),(x:56;y:7),(x:59;y:7)),((x:53;y:9),(x:56;y:9),(x:59;y:9)),
- ((x:53;y:11),(x:56;y:11),(x:59;y:11)),((x:53;y:14),(x:56;y:14),(x:56;y:14))),
- (((x:66;y:7),(x:69;y:7),(x:72;y:7)),((x:66;y:9),(x:69;y:9),(x:72;y:9)),
- ((x:66;y:11),(x:69;y:11),(x:72;y:11)),((x:66;y:14),(x:69;y:14),(x:69;y:14)))
- );
-
- var
- j,a,b,c : integer;
- dk,toets : char;
- boxx,boxy,boxz : shortint;
-
- begin
- mkwin(47,7,52,13,lightgray,black,1); delay(50); rmwin;
- mkwin(24,5,75,15,lightgray,black,2); boxx:=1; boxy:=1; boxz:=1;
- writebetween(24,75,5,yellow,black,' box characters '); j:=0;
- for a:=1 to 4 do begin
- for b:=1 to 3 do
- for c:=1 to 3 do
- writeat(14+a*10+b*3+j,5+c*2,lightgray,black,boxes[a][c][b]);
- inc(j,3);
- end;
- j:=0;
- for a:=1 to 4 do begin
- for b:=1 to 2 do writeat(14+a*10+b*3+j,14,lightgray,black,boxes[a][4][b]);
- inc(j,3);
- end;
-
- repeat
-
- attrib(boxpos[boxx,boxy,boxz].x,boxpos[boxx,boxy,boxz].y,
- boxpos[boxx,boxy,boxz].x,boxpos[boxx,boxy,boxz].y,black+blink,7);
- toets:=getkey;
- attrib(boxpos[boxx,boxy,boxz].x,boxpos[boxx,boxy,boxz].y,
- boxpos[boxx,boxy,boxz].x,boxpos[boxx,boxy,boxz].y,lightgray,black);
-
- case toets of
- mleft,_left: begin
- if boxy<4 then begin
- if boxz>1 then dec(boxz) else begin boxz:=3; dec(boxx) end;
- end else if boxz>1 then dec(boxz) else begin boxz:=2; dec(boxx) end;
- if boxx<1 then boxx:=4
- end;
-
- mright,_right: begin
- if boxy<4 then begin
- if boxz<3 then inc(boxz) else begin boxz:=1; inc(boxx) end;
- end else if boxz<2 then inc(boxz) else begin boxz:=1; inc(boxx) end;
- if boxx>4 then boxx:=1
- end;
-
- mup,_up: if boxy>1 then dec(boxy) else boxy:=4;
-
- mdown,_down: if boxy<4 then inc(boxy) else boxy:=1
-
- end; {case}
-
- until toets in [_enter,_esc,menter,mesc];
-
- rmwin;
- if toets in [_enter,menter] then choose_box_char:=(boxes[boxx,boxy,boxz])
- else choose_box_char:=#00
- end; { box }
-
-
- procedure removebackup(bakname: string);
- var exitcode: word;
- begin
- if __existfil(bakname) then begin
- writednstat('Removing backup files...');
- __erasefil(bakname,exitcode); delaykey(1000);
- end;
- end;
-
-
- procedure show_overall_statistics(filename: string);
- var d: string;
- drivechar: char;
- const monostr: string[7] = ' Mode ';
- begin
- d := __timestr(hours,minutes,seconds,tics);
- writeat(18,13,lc,black,
- padright(int_to_str(hours),2,'0')+':'+
- padright(int_to_str(minutes),2,'0')+' '+
- __datestr(year,month,day));
- writeat(18,14,lightgray,black,int_to_str(memavail)+' Bytes free ram-memory.');
- writeat(18,15,lightgray,black,'DOS Version: '+
- int_to_str(_dosmajorver)+'.'+ int_to_str(_dosminorver));
- d := fexpand(filename); drivechar := d[1];
- writeat(18,16,lc,black,
- int_to_str(diskfree( ord(drivechar)-ord('A') + 1 ) ) +
- ' '+drivechar+':');
- writeat(18,17,lc,black,'Current directory:'); getdir(0, d);
- writeat(18,18,lc,black,__packfil(d,46));
- d := 'working on a ';
- case _pcmachine of
- _munknown: d:=d+'MS-DOS'; _mpc: d:=d+'PC';
- _mxt: d:=d+'XT'; _mpcjr: d:=d+'PCJR';
- _mat: d:=d+'AT'; _mat3x9: d:=d+'AT3X9';
- _mxt2: d:=d+'XT2'; _mxt286: d:=d+'XT286';
- _mcvt: d:=d+'CVT'; _mps2_25: d:=d+'PS2_25';
- _mps2_30: d:=d+'PS2_30'; _mps2_30_286: d:=d+'PS2_30_286';
- _mps2_50: d:=d+'PS2_50'; _mps2_60: d:=d+'PS2_60';
- _mps2_70: d:=d+'PS2_70'; _mps2_80: d:=d+'PS2_80'
- else d:=d+' Unknown model'
- end; { case }
- d := d + ' computer with';
- writeat(18,19,lc,black,d); d := 'a ';
- case _pcprocessor of
- _8088: d:=d+'8088'; _80c88: d:=d+'80C88';
- _8086: d:=d+'8086'; _80188: d:=d+'80188';
- _80186: d:=d+'80186'; _80286: d:=d+'80286';
- _80386: d:=d+'80386' else d:=d+'80486??'
- end; { case }
- d := d + ' processor and ';
- case _test8087 of
- 0: d := d + 'no co-processor.'; 1: d := d + 'a 8087 co-processor.';
- 2: d := d + 'a 80287 co-processor.'; 3: d := d + 'a 80387 co-processor.'
- else d := d + 'a 80487 extra processor?'
- end; { case }
- writeat(18,20,lc,black,d);
- d := 'Video: ';
- { if _monoadapter <> _absent then
- d := d + 'Monochrome-' +color_type[_monoadapter] + monostr;
- if _coloradapter <> _absent then
- d := d + 'Hercules-' +color_type[_coloradapter] + monostr;
- if _egaadapter <> _absent then
- d := d + 'CGA-' +color_type[_egaadapter] + monostr;
- if _hercadapter <> _absent then
- d := d + 'EGA-' +color_type[_hercadapter] + monostr;
- if _mcgaadapter <> _absent then
- d := d + 'VGA-' +color_type[_mcgaadapter] + monostr;
- if _vgaadapter <> _absent then
- d := d + 'MCGA-' +color_type[_vgaadapter] + monostr;
- } writeat(18,21,lc,black,d);
- end;
-
-
-
- procedure show_statistics(filename: string);
- var key: char;
- begin
- mkwin(38,8,42,15,lightgray,black,1); delay(50); rmwin;
- mkwin(15,3,65,23,yellow,black,1);
- writecenter(3,yellow,black,' View statistics ');
- writeat(18,5,lightgray,black,'Current file:');
- writeat(18,6,lightgray,black,__packfil(fexpand(filename),46));
- if eddata.status>0 then writeat(18,7,lightgray,black,'Modified.')
- else writeat(18,7,lightgray,black,'Not modified.');
- writeat(18,8,lightgray,black,
- int_to_str(eddata.bufsize)+' bytes total buffer size.');
- writeat(18,9,lightgray,black,
- int_to_str(eddata.eotext)+' bytes of text used.');
- writeat(18,10,lightgray,black,
- int_to_str(eddata.bufsize-eddata.eotext)+' bytes still available.');
- if eddata.blockstart<>eddata.blockend then
- writeat(18,11,lightgray,black,'Marked block of '+
- int_to_str(abs(eddata.blockend-eddata.blockstart))+' bytes.')
- else writeat(18,11,lightgray,black,'No marked block.');
- show_overall_statistics(filename); key:= getkey; rmwin;
- end;
-
-
- procedure checkreadfile(exitcode:word; fname:string);
- {-check the results of the file read}
- var f:file;
- begin
- if exitcode <> 0 then begin {couldn't read file}
- case exitcode of
- 1: begin {new file, assure valid file name}
- {$I-} assign(f, fname); rewrite(f);
- if ioresult <> 0 then begin
- close(f);
- writednstat(' illegal file name '+__packfil(fexpand(fname),38));
- end else begin
- close(f); erase(f); write('new file...'); delay(2000);
- write(^m); gotoxy(1, 1); exit;
- end;
- {$I+}end;
- 2: writednstat(' insufficient text buffer size.');
- else writednstat(' unknown read error.'); errorbeep;
- end; {case} hidnstat; delay(1500);
- end;
- end; {checkreadfile}
-
-
-
- procedure readfilefromdisc(var filnam:string);
- begin {filename must be expanded}
- filnam:= fexpand(filnam);
- if __isdrvfil(filnam[1],errorcode) then begin
- if (pos('*',filnam)=0) and (pos('?',filnam)=0) then
- if __existfil(filnam) then begin
- edfilesize:= file_size(filnam);
- writednstat(' sizing buffer attempt to:' +
- int_to_str(edfilesize)+' bytes out of available:' +
- int_to_str(eddata.bufsize)+' bytes.');
- delay(2000); resetbinaryeditor(eddata);
- if edfilesize>eddata.bufsize then begin
- writednstat(' fc cannot read ≥64k files.'); errorbeep;
- hidnstat; delay(3000); initstatusline; exit;
- end;
- writednstat(' reading ' +
- __packfil(filnam,50) + ' into file buffers.');
- exitcode := readfilebinaryeditor(eddata,filename); delay(1000);
- checkreadfile(exitcode,filenamebinaryeditor(eddata));
- if exitcode<2 then begin
- filename:= filnam; resetbinaryeditor(eddata);
- starttimer(editortimer)
- end else begin
- writednstat(' error! - memory adjusted, file not loaded...');
- hidnstat; errorbeep; delay(2000)
- end;
- end else begin
- writednstat(' file not found.');
- hidnstat ;errorbeep; delay(1000);
- if yesanswer(' Create a new file? (y/n) ') then begin
- filename:= filnam; exitcode:= readfilebinaryeditor(eddata,filename);
- starttimer(editortimer)
- end;
- end;
- end else begin
- case errorcode of
- 1: writednstat(' drive does not exist, reconsider!');
- 2: writednstat(' door of drive is open (360k)'+
- ' or no disc is mounted (720k)');
- 3: writednstat(' disc is not formatted!'+
- ' format first before use. (dos:format x:)');
- end; {case} errorbeep; hidnstat; delay(2500);
- end;
- end;
-
-
- procedure checksavefile(exitcode:word; filename:string);
- {-check the results of a file save}
- begin {checksavefile}
- if exitcode <> 0 then begin
- {couldn't save file}
- case exitcode of
- 1: writednstat(' unable to create output file '+__packfil(fexpand(filename),45));
- 2: writednstat(' error while writing output to '+__packfil(fexpand(filename),45));
- 3: writednstat(' unable to close output file '+__packfil(fexpand(filename),45));
- else writednstat(' unknown write error.');
- end; {case} hidnstat; errorbeep; delay(1500);
- end else starttimer(editortimer);
- end; {checksavefile}
-
-
- function exitbinaryeditor(var eddata:edcb; exitcommand:integer):boolean;
- {-handle an editor exit - save or abandon file}
- var
- exitcode : word;
- delfil :boolean;
-
-
- procedure modifywindow(var eddata:edcb);
- {-move or resize editor window interactively}
- var
- ch:char; { kbflag:word absolute $0040:$0017; }
- redraw, done, scroll:boolean; { lastkbflag:word; }
-
-
- procedure updatescreen(var eddata:edcb);
- {-update the screen after the window is resized}
- var junk:word;
- begin {updatescreen}
- {redraw the window box}
- restorescreen(1);
- writednstat(' '+#24#25#26#27+
- ' to move/resize window. <scrolllock> moves. <enter> accepts.' );
- with eddata do fbox(x1,y1,x2+2,y2+2,yellow,black,1);
- with eddata do writebetween(x1,x2+2,y1,yellow,black,'editor');
- if not(keypressed) then begin
- {force the editor to update the screen and return}
- junk:= usebinaryeditor(eddata, ^k^s); {^k^s is nul optie voor redraw}
- redraw:= false;
- with eddata do writebetween(x1,x2+2,y1,yellow,black,' editor ');
- end;
- end; {updatescreen}
-
- begin {modifywindow}
- with eddata do begin
- {show a prompt for resizing}
- writednstat(' '+#24#25#26#27+
- ' to move/resize window. <scrolllock> moves. <enter> accepts.');
- done:= false; redraw:= false;
- repeat {update the screen}
- if redraw then updatescreen(eddata);
- ch:=getkey; if scrollon then scroll:= true else scroll:= false;
- case ch of
- _left,mleft:
- if scroll then begin
- if x1 > 1 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- x1:= pred(x1); x2:= pred(x2); redraw:= true;
- end;
- end else if x2 > x1+30 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black, ' editor ');
- x2:= pred(x2); redraw:= true;
- end;
- mright,_right:
- if scroll then begin
- if x2 < 78 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- x1:= succ(x1); x2:= succ(x2); redraw:= true;
- end;
- end else if x2 < 78 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- x2:= succ(x2); redraw:= true;
- end;
- mup,_up:
- if scroll then begin
- if y1 > 2 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- y1:= pred(y1); y2:= pred(y2); redraw:= true;
- end;
- end else if y2 > y1+3 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- y2:= pred(y2); redraw:= true;
- end;
- mdown,_down: {down arrow}
- if scroll then begin
- if y2 < 22 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- y1:= succ(y1); y2:= succ(y2); redraw:= true;
- end;
- end else if y2 < 22 then begin
- fbox(x1,y1,x2+2,y2+2,yellow,black,0);
- writebetween(x1,x2+2,y1,yellow,black,' editor ');
- y2:= succ(y2); redraw:= true;
- end;
- end; {case}
- until ch in [menter,_enter]; initstatusline;
- end;
- end; {modifywindow}
-
- begin {exitbinaryeditor}
- exitbinaryeditor:= false; savecursor;
- case exitcommand of
- -1,0: exitbinaryeditor:= true;
- 1: begin
- if modifiedfilebinaryeditor(eddata) then begin
- writednstat(' Writing file buffers to disc...');
- exitcode:= savefilebinaryeditor(eddata,makebackup);
- checksavefile(exitcode,filenamebinaryeditor(eddata));
- removebackup(filename);
- end else errorbeep;
- end;
- 2: modifywindow(eddata);
- 3: ;{ do nothing at all! just force redrawal ^k^s }
- 4: st := __stuffkey(choose_accent_char);
- 5: st := __stuffkey(chr(16)+choose_ascii_char);
- 6: st := __stuffkey(chr(16)+choose_weird_char);
- 7: st := __stuffkey(choose_box_char);
- 8: show_statistics(filename);
- end; { case }
- if not(exitcommand in [6..9]) then __flushkey;
- loadcursor; initstatusline;
- end; {exitbinaryeditor}
-
-
-
- procedure call_editor;
- var st:string;
- begin
- mkwin(38,9,42,16,lightgray,black,1); delay(50); rmwin;
- initstatusline; oncursor;
- with eddata do fbox(x1,y1,x2+2,y2+2,yellow,black,1);
- with eddata do writebetween(x1,x2+2,y1,yellow,black,'[Editor]');
- __flushkey;
- repeat
- loadcursor; with eddata do box(x1,y1,x2+2,y2+2,yellow,black,1);
- with eddata do writebetween(x1,x2+2,y1,yellow,black,'[Editor]');
- exitcommand:= usebinaryeditor(eddata,''); savecursor
- until exitbinaryeditor(eddata,exitcommand); { stuffkey for exitcmd ? }
- end;
-
-
- procedure writefileonexit;
- begin
- if modifiedfilebinaryeditor(eddata)
- then if yesanswer(' File modified. Still want to save it? (y/n)') then begin
- writednstat(' Writing file buffers to disc...');
- exitcode := savefilebinaryeditor(eddata,makebackup);
- checksavefile(exitcode,filenamebinaryeditor(eddata));
- removebackup(filename);
- end else errorbeep;
- end;
-
-
- function createbackup(var eddata : edcb; bakname: string) : word;
- {
- -save the current file as backup, returning a status code
-
- status codes -
- 0 = successful save
- 1 = file creation error
- 2 = disk write error
- 3 = error closing file
- }
- var
- f : file;
- i, byteswritten : word;
-
- begin
- with eddata do
- begin
- assign(f, bakname); rewrite(f, 1);
- if ioresult <> 0
- then begin
- createbackup := 1; close(f);
- i := ioresult; {clear ioresult}
- exit;
- end;
- blockwrite(f, buffer^, succ(eotext), byteswritten);
- if (byteswritten <> succ(eotext)) or (ioresult <> 0)
- then begin
- createbackup := 2;
- close(f);
- exit;
- end;
- close(f);
- if ioresult <> 0
- then begin
- createbackup := 3;
- exit;
- end; {reset editor modified bit}
- status := 0; {success status}
- createbackup := 0;
- end;
- end;
-
-
- procedure writebackuptodisc;
- var
- dotpos : byte;
- bakname,
- newname : string;
- c : char;
- retcode : word;
-
- begin
- mkwin(10,9,70,17,highbkgdf,highbkgdb,1);
- writecenter(9,highbkgdf,highbkgdb,' backup file ');
- writecenter(12,highbkgdf,highbkgdb,' temporarily backing up the file buffers in file:');
- errorbeep; newname:= fexpand(filename);
- dotpos:= succ(length(newname));
- repeat dec(dotpos); c:= newname[dotpos] until (c = '.') or (c = '\') or (c = ':') or (dotpos = 0);
- if (dotpos = 0) or (c <> '.') then bakname:= newname+'.■B■'
- else bakname:= copy(newname, 1, dotpos)+'■B■';
- writecenter(14,highbkgdf,highbkgdb,__packfil(fexpand(bakname),56)); delay(2000);
- retcode:= createbackup(eddata,bakname); errorbeep;
- if retcode>0 then cleartext(15,9,65,17,highbkgdf,highbkgdb);
- case retcode of
- 1:writecenter(13,highbkgdf,highbkgdb,' Backup creation error');
- 2:writecenter(13,highbkgdf,highbkgdb,' Disk backup write error');
- 3:writecenter(13,highbkgdf,highbkgdb,' Error closing backup file.');
- end; { case }
- if retcode>0 then begin
- errorbeep; writednstat(' WATCH OUT! Inspect this phenomena immediately!');
- hidnstat; delay(3500)
- end; rmwin;
- end;
-
-
- {$F+}
- procedure editor_event_handler;
- var length:shortint;
- begin
- if str_to_int(copy(getlaptime(editortimer),4,2)) >= backupwait then begin
- writebackuptodisc; starttimer(editortimer); { restart count-down }
- end;
- end;
- {$F-}
-
-
-
- begin
- filename := fexpand('NOTES.TXT');
- exitcode := initbinaryeditor(
- eddata,maxfilesize,windx1,windy1,windx2,windy2,
- colorscreen and not(egavgasystem),
- edoptinsert+edoptindent,extension,exitcommands,@editor_event_handler);
- exitcode := readfilebinaryeditor(eddata,filename);
- {call_editor;}
- end.
-