1 /*--------------------------------------------------------------------
2 nxeditor
3 FILE NAME:file.c
4 Programed by : I.Neva
5 R & D ADVANCED SYSTEMS. IMAGING PRODUCTS.
6 1992.06.01
7
8 Copyright (c) 1998,1999,2000 SASAKI Shunsuke.
9 All rights reserved.
10 --------------------------------------------------------------------*/
11 #include "ed.h"
12 #include <sys/stat.h>
13 #include <sys/file.h>
14
15
FileStartInit(bool f)16 void FileStartInit(bool f) // !! list clear flag
17 {
18 edbuf[CurrentFileNo].cf = FALSE;
19 BlockInit();
20
21 // cursor
22 csrle.cx=0;
23 csrle.lx=0;
24 csrle.sx=0;
25 csrle.dsize=GetColWidth()-NumWidth;
26 csrle.size=MAXEDITLINE;
27 csr_fix();
28
29 csrse.cy=GetMinRow();
30 csrse.ly=GetTopNumber();
31 csrse.gf=FALSE;
32 csrse.bytes=0;
33
34 if (f)
35 lists_clear();
36
37 csrse.ed=GetTop()->next;
38 }
39
edbuf_init()40 void edbuf_init()
41 {
42 int i;
43
44 for (i=0; i<MAX_edbuf; i++)
45 {
46 *edbuf[i].path='\0';
47 edbuf[i].pm=FALSE;
48 }
49
50 for (CurrentFileNo= MAX_edfiles
51 ; CurrentFileNo< MAX_edbuf; ++CurrentFileNo)
52 FileStartInit(FALSE);
53 }
54
55
56 #ifndef LOCK_SH
57 #define LOCK_SH 1
58 #define LOCK_EX 2
59 #define LOCK_NB 4
60 #define LOCK_UN 8
61 #endif
62
edbuf_lock(bool func (FILE *,const char *),const char * fn)63 bool edbuf_lock(bool func(FILE *, const char*), const char *fn)
64 {
65 char buf[LN_path+1];
66 FILE *fp;
67 int i, a;
68 bool f;
69
70 sysinfo_path(buf, "ne_lock");
71 fp=fopen(buf, "r+");
72 if (fp==NULL)
73 {
74 fp=fopen(buf, "w+");
75 if (fp==NULL)
76 {
77 inkey_wait("lock �ե����뤬 open ����ޤ���");
78 return TRUE;
79 }
80 }
81
82 for (i=0;;++i)
83 {
84 a=flock(fileno(fp), LOCK_EX | LOCK_NB);
85 if (a==0)
86 break;
87 if (i>=10)
88 {
89 fclose(fp);
90 inkey_wait("lock �ե����뤬 lock ����Ƥ��ޤ���");
91 return TRUE;
92 }
93 }
94
95 f=func(fp, fn);
96
97 flock(fileno(fp), LOCK_UN);
98 fclose(fp);
99 return f;
100 }
101
102
edbuf_rm_func(FILE * fp,const char * fn)103 bool edbuf_rm_func(FILE *fp, const char *fn)
104 {
105 char buf[LN_path+1];
106 char *p ,*q;
107 long n;
108
109 p=NULL;
110 n=0;
111 while(fgets(buf, LN_path, fp))
112 {
113 if (*buf!='\0' && buf[strlen(buf)-1]=='\n')
114 buf[strlen(buf)-1]='\0';
115
116 if (strcmp(fn, buf)==0)
117 continue;
118
119 n+=strlen(buf)+1;
120 q=(char *)mem_alloc(n+1);
121 if (p==NULL)
122 sprintf(q, "%s\n",buf); else
123 sprintf(q, "%s%s\n", p, buf);
124 free(p);
125 p=q;
126 }
127
128 rewind(fp);
129 if (n>0)
130 {
131 fputs(p, fp);
132 fflush(fp);
133 }
134 ftruncate(fileno(fp), n);
135
136 return n>0;
137 }
138
edbuf_rm(int n)139 void edbuf_rm(int n)
140 {
141 char buf[LN_path+1];
142
143 if (!edbuf_lock(edbuf_rm_func, edbuf[n].path))
144 {
145 sysinfo_path(buf, "ne_lock");
146 unlink(buf);
147 }
148 *edbuf[n].path = '\0';
149 }
150
151
152
edbuf_add_func(FILE * fp,const char * fn)153 bool edbuf_add_func(FILE *fp, const char *fn)
154 {
155 char buf[LN_path+1];
156
157 while(fgets(buf, LN_path, fp))
158 {
159 if (*buf!='\0' && buf[strlen(buf)-1]=='\n')
160 buf[strlen(buf)-1]='\0';
161
162 if (strcmp(fn, buf)==0)
163 return FALSE;
164 }
165
166 fprintf(fp, "%s\n", fn);
167 return TRUE;
168 }
169
edbuf_add(const char * fn)170 bool edbuf_add(const char *fn)
171 {
172 int i;
173
174 for (i=0; i<MAX_edfiles; i++)
175 {
176 if (*edbuf[i].path=='\0')
177 break;
178 }
179
180 if (i>=MAX_edfiles)
181 {
182 inkey_wait(DONT_OPEN_MORE_FILE_MSG);
183 return FALSE;
184 }
185
186 if (!edbuf_lock(edbuf_add_func, fn))
187 {
188 inkey_wait("���˥����ץ�Ƥ��ޤ���");
189 return FALSE;
190 }
191
192 strcpy(edbuf[i].path, fn);
193 BackFileNo=CurrentFileNo;
194 CurrentFileNo=i;
195 return TRUE;
196 }
197
edbuf_mv(int n,const char * fn)198 bool edbuf_mv(int n, const char *fn)
199 {
200 edbuf_lock(edbuf_rm_func, edbuf[n].path);
201 if (!edbuf_lock(edbuf_add_func, fn))
202 {
203 inkey_wait("���˥����ץ�Ƥ��ޤ���");
204 if (!edbuf_lock(edbuf_add_func, edbuf[n].path))
205 inkey_wait("���ե�����⥪���ץ�Ƥ��ޤ���");
206 return FALSE;
207 }
208
209 strcpy(edbuf[n].path, fn);
210 return TRUE;
211 }
212
213
214
215
216
CheckFileAccess(const char * fn)217 bool CheckFileAccess(const char *fn)
218 {
219 struct stat sbuf;
220 bool f;
221
222 if (fn!=NULL && strcmp(fn, edbuf[CurrentFileNo].path)!=0)
223 return FALSE;
224
225 if (edbuf[CurrentFileNo].ct != -1)
226 {
227 f=stat(edbuf[CurrentFileNo].path, &sbuf);
228 if (f!=-1 && sbuf.st_ctime != edbuf[CurrentFileNo].ct)
229 return TRUE;
230 }
231 return FALSE;
232 }
233
file_change(int n)234 bool file_change(int n)
235 {
236 /* 2000/03/08 by Mia fix
237 edbuf[n].path=='\0' cannot be true.
238 */
239 if (n<0 || n>MAX_edfiles || *edbuf[n].path=='\0')
240 return FALSE;
241
242 BackFileNo = CurrentFileNo;
243 CurrentFileNo = n;
244 if (CheckFileAccess(NULL))
245 system_msg(TARGET_FILE_CHANGED_MSG);
246 return TRUE;
247 }
248
249
SetFileChangeFlag()250 void SetFileChangeFlag()
251 {
252 edbuf[CurrentFileNo].cf = TRUE;
253 }
254
ResetFileChangeFlag()255 void ResetFileChangeFlag()
256 {
257 edbuf[CurrentFileNo].cf = FALSE;
258 }
259
CheckFileOpened(const char * fn)260 int CheckFileOpened(const char *fn)
261 {
262 int i;
263
264 for (i=0 ;i<MAX_edfiles; i++)
265 {
266 if (*edbuf[i].path=='\0')
267 continue;
268
269 if (strcmp(edbuf[i].path, fn) == 0)
270 return i;
271 }
272 return -1;
273 }
274
275
276
277
FindOutNextFile(int no)278 int FindOutNextFile(int no)
279 {
280 int i;
281
282 for (i=no; i<MAX_edfiles; i++)
283 {
284 if (*edbuf[i].path != '\0' && i != CurrentFileNo)
285 return i;
286 }
287 for (i=0; i<no; i++)
288 {
289 if (*edbuf[i].path != '\0' && i != CurrentFileNo)
290 return i;
291 }
292 return -1;
293 }
294
GetBackFile(int n)295 int GetBackFile(int n)
296 {
297 int i;
298
299 if (BackFileNo!=n && *edbuf[BackFileNo].path != '\0')
300 return BackFileNo;
301 return FindOutNextFile(n);
302 }
303
304
305
306
307
308
309
310
311
filesave_proc(const char * s,FILE * fp)312 void filesave_proc(const char *s,FILE *fp)
313 {
314 bool f;
315 char buf[MAXEDITLINE+1];
316 char f_buf[MAXEDITLINE+1];
317 char *rm_table[]={"\n","\r\n","\r"};
318
319 if (s==NULL)
320 return;
321 strjncpy(buf, s, MAXEDITLINE);
322 if (*s=='\0'|| s[strlen(s)-1]!='\n')
323 f=FALSE; else
324 {
325 buf[strlen(s)-1]='\0';
326 f=TRUE;
327 }
328
329 fputs(kanji_fromeuc(f_buf,MAXEDITLINE,buf,edbuf[CurrentFileNo].kc) ,fp);
330 if (f)
331 fputs(rm_table[edbuf[CurrentFileNo].rm] ,fp);
332
333 // kanji_fputs(s,fp,edbuf[CurrentFileNo].kc,edbuf[CurrentFileNo].rm);
334 }
335
filesave(char * filename,bool f)336 int filesave(char *filename,bool f)
337 {
338 FILE *fp;
339 int res;
340
341 /* 2000.03.08 by Mia fix
342 If strlen(filename) == LN_path,
343 strcat(backpath, ".bak") may fail.
344 This should be fixed although a pathological case.
345 */
346 char backpath[LN_path+4+1];
347 char buffer[MAXEDITLINE+1];
348
349
350 if (!f)
351 {
352 if (!edbuf[CurrentFileNo].cf)
353 return TRUE;
354
355 term_bell();
356 res = keysel_yneq(THIS_FILE_CHANGED_MSG);
357
358 if (res==ESCAPE)
359 return FALSE;
360 if (!res)
361 return TRUE;
362 }
363
364 if (access(filename, F_OK) == 0 && access(filename, W_OK) == -1)
365 {
366 CrtDrawAll();
367 inkey_wait(DONT_WRITE_FILE_MSG);
368 return FALSE;
369 }
370
371
372 if (CheckFileAccess(filename))
373 {
374 term_bell();
375 res = keysel_yneq(SAVE_FILE_CHANGED_MSG);
376
377 if (res==ESCAPE|| !res)
378 return FALSE;
379 }
380
381
382 if (sysinfo.backupf && access(filename, F_OK)==0)
383 {
384 strcpy(backpath,filename);
385 strcat(backpath,".bak");
386 unlink(backpath);
387 rename(filename, backpath);
388 }
389
390 fp=fopen(filename,"w");
391 if (fp==NULL)
392 {
393 CrtDrawAll();
394 inkey_wait(DONT_WRITE_FILE_MSG);
395 return FALSE;
396 }
397
398 sprintf(buffer, "%s %s .. ", SAVEING_MSG, filename);
399 lists_proc(filesave_proc,fp,GetTopNumber(),GetLastNumber());
400 fclose(fp);
401 ResetFileChangeFlag();
402
403 sprintf(buffer, "%s %s .. ", SAVESUCCESS_MSG, filename);
404 system_msg(buffer);
405
406 return TRUE;
407 }
408
409
file_open_proc(char * s,kinfo_t * kip)410 void *file_open_proc(char *s,kinfo_t *kip)
411 {
412 char buf[MAXEDITLINE+1];
413 bool f;
414
415 f=file_gets(buf, MAXEDITLINE, kip->fp, &kip->n_cr, &kip->n_lf);
416 kanji_toeuc(s, MAXEDITLINE, buf, kip->kc==KC_sjis, &kip->jm);
417 //fprintf(stderr,"[%s]%d\n",s,f);
418 return f!=-1?kip:NULL;
419 }
420
file_new_proc(char * s,void * vp)421 void *file_new_proc(char *s,void *vp)
422 {
423 *s='\0';
424 return NULL;
425 }
426
427
fileopen(char * filename)428 int fileopen(char *filename)
429 {
430 FILE *fp;
431 char buf[MAXEDITLINE+1];
432 struct stat sbuf;
433 kinfo_t ki;
434 int n,nx;
435 bool sf;
436
437 sf=stat(filename, &sbuf);
438 if (!sf&& (sbuf.st_mode&S_IFMT)!= S_IFREG)
439 return FALSE; /* �쥮��顼�ե�����ǤϤʤ���*/
440
441 fp=fopen(filename,"r");
442 if (fp==NULL)
443 {
444 if (access(filename,F_OK)==-1) /* �����ե����� */
445 {
446 lists_add(file_new_proc,"");
447 edbuf[CurrentFileNo].ct = -1;
448
449 sprintf(buf, "%s [ %s ]", NEWFILE_MSG, filename);
450 system_msg(buf);
451 csr_lenew();
452 return TRUE;
453 }
454 if (access(filename, R_OK) == -1)
455 inkey_wait(PERMISSION_MSG); else
456 inkey_wait("�����ʥ��顼");
457 return FALSE;
458 }
459
460 edbuf[CurrentFileNo].ct= sf? sbuf.st_ctime: -1;
461 sprintf(buf,"%s %s ",READING_MSG,filename);
462 system_msg(buf);
463
464
465 edbuf[CurrentFileNo].kc=file_knjchk(fp);
466 rewind(fp);
467
468 ki.fp=fp;
469 ki.kc=edbuf[CurrentFileNo].kc;
470 ki.n_cr=0;
471 ki.n_lf=0;
472 ki.jm=JM_ank;
473 lists_add(file_open_proc,&ki);
474
475
476 /* CR/LF�⡼�ɤγ��� */
477 n=max(ki.n_cr,ki.n_lf);
478 if (n==0)
479 edbuf[CurrentFileNo].rm=0; else
480 {
481 nx=n>10? 10:1;
482
483 if (n/nx>ki.n_cr)
484 edbuf[CurrentFileNo].rm=RM_lf; else
485 edbuf[CurrentFileNo].rm=n/nx>ki.n_lf?RM_cr:RM_crlf;
486 }
487
488 csr_lenew();
489 /* SetPermissionFlg(filename);*/
490
491 RefreshMessage();
492
493 return TRUE;
494 }
495
file_insert(char * filename)496 bool file_insert(char *filename)
497 {
498 FILE *fp;
499 kinfo_t ki;
500
501
502 fp=fopen(filename,"r");
503 if (fp==NULL)
504 return FALSE;
505
506 system_msg(WAITING_MSG);
507
508 ki.kc=file_knjchk(fp);
509 ki.fp=fp;
510 ki.n_cr=0;
511 ki.n_lf=0;
512 ki.jm=JM_ank;
513 rewind(fp);
514
515 lists_add(file_open_proc,&ki);
516
517 csr_lenew();
518 /* SetPermissionFlg(filename);*/
519 return TRUE;
520 }
521
RenameFile(int current_no,const char * s)522 bool RenameFile(int current_no,const char *s)
523 {
524 int i;
525 char fn[MAXEDITLINE+1];
526 struct stat sbuf;
527
528 if (s!=NULL&& *s!='\0')
529 strcpy(fn,s); else
530 {
531 strcpy(fn,edbuf[current_no].path);
532 if (HisGets(fn, RENAME_MSG, FOPEN_SYSTEM) == NULL)
533 return FALSE;
534 if (*fn=='\0')
535 return FALSE;
536 }
537 reg_pf(NULL, fn,FALSE);
538
539 for (i=0; i<MAX_edfiles; i++)
540 {
541 if (*edbuf[i].path=='\0')
542 continue;
543
544 if (strcmp(edbuf[i].path, fn) == 0)
545 {
546 if (!keysel_ynq(THIS_FILE_OPENED_MSG))
547 return FALSE;
548 break;
549 }
550 }
551
552 if (access(fn, F_OK)!=-1&& !keysel_ynq(FILE_EXIST_MSG))
553 return FALSE;
554
555 if (edbuf_mv(current_no, fn))
556 return FALSE;
557
558 SetFileChangeFlag();
559 edbuf[current_no].ct= stat(edbuf[current_no].path,&sbuf)==-1?
560 -1: sbuf.st_ctime;
561 return TRUE;
562 }
563
564
FileOpenOp(const char * path)565 bool FileOpenOp(const char *path)
566 {
567 int n;
568 char pf[LN_path+1];
569
570 if (*path=='\0')
571 return FALSE;
572 strcpy(pf,path);
573 reg_pf(NULL, pf,FALSE);
574
575 n=CheckFileOpened(pf);
576 if (n!=-1)
577 {
578 /* 2000/03/08 by Mia upd
579 Do not call file_change
580 when requested file has been already opened and is current file
581 so that BackFileNo not be changed.
582 */
583 file_change(n);
584 return FALSE;
585 }
586
587 if (!edbuf_add(pf))
588 return FALSE;
589
590 FileStartInit(TRUE); //!!?? �ʤ������ˤ��줬ɬ�ס�
591
592 if (fileopen(edbuf[CurrentFileNo].path))
593 return TRUE;
594
595 edbuf_rm(CurrentFileNo);
596 lists_clear();
597 CurrentFileNo=BackFileNo;
598
599 return FALSE;
600 }
601
602
603
604 /*-----------------------------------------------------------------------------
605 ESC-O handler.
606
607 2000/03/11 by Mia upd
608 hack up filer support.
609 */
op_file_open()610 SHELL bool op_file_open() /* ^[O */
611 {
612 char fname[LN_path+1];
613
614 *fname='\0';
615 if (HisGets(fname, OPEN_MSG, FOPEN_SYSTEM)==NULL)
616 return FALSE;
617
618 fname[LN_path] = '\0';
619 if (need_filer( fname ))
620 eff_filer(fname);
621
622 if (*fname=='\0')
623 {
624 CrtDrawAll();
625 return FALSE;
626 }
627
628 // system_msg(WAITING_MSG);
629 return FileOpenOp(fname);
630 }
631
op_file_insert()632 SHELL bool op_file_insert() /* ^[I */
633 {
634 char fname[MAXEDITLINE+1];
635
636 *fname='\0';
637 if (HisGets(fname, INS_MSG, FOPEN_SYSTEM)==NULL)
638 return FALSE;
639
640 fname[LN_path] = '\0';
641 if (need_filer( fname ))
642 eff_filer(fname);
643
644 if (*fname=='\0')
645 {
646 CrtDrawAll();
647 return FALSE;
648 }
649
650 // system_msg(WAITING_MSG);
651 file_insert(fname);
652 SetFileChangeFlag();
653 return TRUE;
654 }
655
656
657
op_file_save()658 SHELL void op_file_save() /* ^[S */
659 {
660 struct stat sbuf;
661 int cTime;
662 char fn[LN_path+1];
663
664 csr_leupdate();
665
666 // if (!RenameFile(CurrentFileNo, NULL))
667 // return;
668 strcpy(fn,edbuf[CurrentFileNo].path);
669 if (HisGets(fn, RENAME_MSG, FOPEN_SYSTEM) == NULL)
670 return;
671 if (*fn=='\0')
672 return;
673
674 if (!filesave(fn,TRUE))
675 return;
676
677 if (strcmp(fn,edbuf[CurrentFileNo].path)==0)
678 {
679 cTime= stat(edbuf[CurrentFileNo].path, &sbuf);
680 edbuf[CurrentFileNo].ct = cTime==-1?-1:sbuf.st_ctime;
681 }
682 }
683
op_file_profile()684 SHELL void op_file_profile() /* ^[W */
685 {
686 csr_leupdate();
687 profile_write();
688
689 system_msg(SAVE_PROFILE_MSG);
690 }
691
fileclose(int n)692 bool fileclose(int n)
693 {
694 int m;
695
696 csr_leupdate();
697
698
699 m=CurrentFileNo;
700 CurrentFileNo=n;
701
702 if (edbuf[n].cf &&!filesave(edbuf[n].path,FALSE))
703 return FALSE;
704
705 // CrtDrawAll();
706 edbuf_rm(n);
707 lists_clear();
708
709 CurrentFileNo=m;
710
711 return TRUE;
712 }
713
op_file_close()714 SHELL bool op_file_close() /* ^[C */
715 {
716 int n;
717
718 if (!fileclose(CurrentFileNo))
719 return FALSE;
720
721 if (!file_change(BackFileNo))
722 {
723 n=FindOutNextFile(CurrentFileNo);
724 if (n==-1 || !file_change(n))
725 ne_fin();
726 }
727 BackFileNo = FindOutNextFile(CurrentFileNo);
728 }
729
op_file_aclose()730 SHELL void op_file_aclose()
731 {
732 int i;
733
734 for (i=0; i<MAX_edfiles; i++)
735 {
736 if (*edbuf[i].path == '\0')
737 continue;
738 CurrentFileNo=i;
739 CrtDrawAll();
740 if (!fileclose(i))
741 return;
742 }
743 ne_fin();
744 }
745
op_file_quit()746 SHELL void op_file_quit()
747 {
748 int i;
749
750 op_file_profile();
751
752 for (i=0; i<MAX_edfiles; i++)
753 {
754 if (*edbuf[i].path == '\0')
755 continue;
756 CurrentFileNo=i;
757 edbuf_rm(i);
758 lists_clear();
759 }
760 ne_fin();
761 }
762
763
op_file_undo()764 void op_file_undo() /* �Խ�undo */
765 {
766 long lineOffset;
767 char pf[LN_path+1];
768 bool res;
769
770 csr_leupdate();
771
772 if (!edbuf[CurrentFileNo].cf)
773 return;
774 term_bell();
775 res=keysel_yneq(ARE_YOU_SURE_MSG);
776 if (res==ESCAPE|| !res)
777 return;
778
779 strcpy(pf, edbuf[CurrentFileNo].path);
780 lineOffset = GetLineOffset();
781
782 FileStartInit(TRUE);
783
784 if (!fileopen(pf))
785 {
786 edbuf_rm(CurrentFileNo);
787 lists_clear();
788 CurrentFileNo=BackFileNo;
789
790 system_msg(TARGET_FILE_PERM_MSG);
791 }
792
793
794 csr_setly(lineOffset);
795 }
796
797 static int file_menu_res = 0;
op_menu_file()798 void op_menu_file()
799 {
800 int res;
801
802 res=menu_vselect(-1, -1, 10, MENU_OPEN_MSG, MENU_CLOSE_MSG, MENU_SAVE_MSG
803 ,MENU_SAVEAS_MSG,MENU_CLOSE_AF_MSG,MENU_SAVE_PROFILE_MSG
804 ,MENU_RENAME_MSG,MENU_REFRESH_CF_MSG,MENU_ESCAPE_SHELL_MSG,
805 MENU_INSERT_OUTPUT_MSG);
806
807 switch(res) {
808 case 0:
809 op_file_open();
810 break;
811 case 1:
812 op_file_close();
813 break;
814 case 2:
815 op_file_save();
816 break;
817 case 3:
818 // �ե�����̾����ꤷ��save��
819 break;
820 case 4:
821 op_file_aclose();
822 break;
823 case 5:
824 op_file_profile();
825 break;
826 case 6:
827 RenameFile(CurrentFileNo, NULL);
828 break;
829 case 7:
830 op_file_undo();
831 break;
832 case 8:
833 op_misc_exec("");
834 break;
835 /* exec and get stdout/stderr */
836 case 9 :
837 op_misc_insert_output( ) ;
838 break ;
839
840 default: //!!
841 return;
842 }
843 file_menu_res = res;
844 }
845
op_file_copen()846 SHELL void op_file_copen()
847 {
848 int n,m;
849
850 n=CurrentFileNo;
851 if (!op_file_open())
852 return;
853
854 m=CurrentFileNo;
855 CurrentFileNo=n;
856 CrtDrawAll();
857
858 if (op_file_close() &&CurrentFileNo!=m)
859 {
860 CurrentFileNo=m;
861 CrtDrawAll();
862 }
863 }
864
op_file_toggle()865 void op_file_toggle()
866 {
867 int tmpNo;
868
869 if ((tmpNo = GetBackFile(CurrentFileNo)) != -1)
870 file_change(tmpNo);
871 }
872
873 char tmpbuff[MAX_edbuf][MAXLINESTR+1];
874 /*void file_select_proc(int a,mitem_t *mip,void *vp)
875 {
876 strcpy(mip->str,tmpbuff[a]);
877 }
878 }
879 */
880
SelectFileMenu()881 int SelectFileMenu()
882 {
883 int i,j;
884 int m;
885 int res;
886 menu_t menu;
887
888 for (i = 0, j = 0, m = 0; i < MAX_edfiles; i++)
889 {
890 if (*edbuf[i].path=='\0')
891 continue;
892 if (i < CurrentFileNo)
893 m++;
894 sprintf(tmpbuff[j],"%-.*s %1s ",GetColWidth()-6,edbuf[i].path
895 ,(edbuf[i].cf ? "*":""));
896 j++;
897 }
898
899 menu_iteminit(&menu);
900 menu_itemmakelists(&menu, MAXLINESTR+1, j, (char *)tmpbuff);
901
902 res=menu_select(&menu);
903
904 CrtDrawAll();
905
906 return res==-1? -1:res;
907 }
908
op_file_select()909 void op_file_select()
910 {
911 int i;
912 int j;
913 int file_no;
914
915 if ((file_no = SelectFileMenu()) != -1)
916 {
917 for (i=j=0; i<MAX_edfiles; i++)
918 {
919 if (*edbuf[i].path != '\0')
920 {
921 if (j== file_no)
922 break;
923 j++;
924 }
925 }
926 file_change(i);
927 }
928 }
929
op_file_rename()930 SHELL void op_file_rename()
931 {
932 RenameFile(CurrentFileNo,NULL);
933 }
934