Changeset 3434 for trunk/src/netlabs/macros/edit.e
- Timestamp:
- Jan 29, 2019, 7:18:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/netlabs/macros/edit.e ¶
r3430 r3434 76 76 defproc PreLoadFile( FileSpec, Options) 77 77 universal filestoload 78 universal filestoloadmax -- still used for 'xcom e' and afterload78 universal filestoloadmax -- still used for 'xcom e' and ProcessFilesLoaded 79 79 if filestoload = '' then 80 80 filestoload = 0 … … 132 132 -- GetMode doesn't work here, because it tries to write the fid'.mode' 133 133 -- array var. At this time the file is not loaded, so the fileid is not set. 134 -- But calling NepmdQueryDefaultMode( Filename) would work.134 -- But calling NepmdQueryDefaultMode( Filename) would work. 135 135 -- We should better determine the mode here, save it in a array var with the 136 136 -- .filename as identifier, and replace the identifier with the fileid later … … 300 300 endif 301 301 302 Codepage = upcase( Codepage)302 Codepage = upcase( Codepage) 303 303 if Codepage = 'CP1004' then 304 304 Codepage = 'latin-1' … … 379 379 ; --------------------------------------------------------------------------- 380 380 ;compile if LINK_HOST_SUPPORT & (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') 381 ; compile if not defined( MVS)381 ; compile if not defined( MVS) 382 382 ; MVS = 0 383 383 ; compile endif 384 ; compile if not defined( E3MVS)384 ; compile if not defined( E3MVS) 385 385 ; E3MVS = 0 386 386 ; compile endif 387 ; compile if not defined( HOST_LT_REQUIRED)387 ; compile if not defined( HOST_LT_REQUIRED) 388 388 ; HOST_LT_REQUIRED = 0 389 389 ; compile endif … … 498 498 defc e, ed, Edit, epm 499 499 universal default_edit_options 500 universal CurEditCmd500 universal cureditcmd 501 501 universal firstloadedfid -- first file for this edit cmd, set here 502 502 universal firstinringfid -- first file in the ring, set by defmain … … 515 515 -- Set current edit cmd to let other commands differ between several ways 516 516 -- of file loading. 517 -- Other commands, that execute 'Edit', can set this universal var before 518 -- and then it will not be overwritten by 'Edit'. Afterload will reset it. 517 -- Other commands that execute 'Edit', can set this universal var before 518 -- and then it will not be overwritten by 'Edit'. ProcessFilesLoaded 519 -- will reset it. 519 520 -- This is currently used for RestorePos and RingSavePos. 520 if CurEditCmd = '' then521 CurEditCmd = 'EDIT'521 if cureditcmd = '' then 522 cureditcmd = 'EDIT' 522 523 endif 523 524 … … 545 546 error_reading = '' 546 547 error_opening = '' 547 -- bad_paths --> Non-existing path specified.548 -- truncated --> File contained lines longer than 255 characters.549 -- access_denied --> If user tried to edit a subdirectory.550 -- invalid_drive --> No such drive letter551 -- error_reading --> Bad disk(ette).552 -- error_opening --> Path contained invalid name.548 -- bad_paths --> non-existing path specified 549 -- truncated --> file contained lines longer than 255 characters (EPM 5 only) 550 -- access_denied --> if user tried to edit a subdirectory 551 -- invalid_drive --> no such drive letter 552 -- error_reading --> bad disk(ette) 553 -- error_opening --> path contained invalid name 553 554 554 555 fParseCmd = 1 … … 569 570 570 571 if ch = "'" & fParseCmd then 571 parse value rest with (ch) cmd (ch) rest572 parse value rest with (ch) Cmd (ch) rest 572 573 do while substr( rest, 1, 1) = ch & pos( ch, rest, 2) 573 574 parse value rest with (ch) p (ch) rest 574 cmd = cmd''ch''p575 Cmd = Cmd''ch''p 575 576 enddo 576 CurEditCmd = cmd -- set universal var to determine later in LOAD.E if pos shall be restored from EA577 cmd577 CurEditCmd = Cmd -- set universal var to determine later in LOAD.E if pos shall be restored from EA 578 Cmd 578 579 579 580 elseif ch = '/' then -- Option … … 642 643 643 644 ; Todo: rewrite that horrible message stuff: 644 if rc = -3 then -- sayerror( 'Path not found')645 if rc = -3 then -- sayerror( 'Path not found') 645 646 bad_paths = bad_paths', 'FileSpec 646 elseif rc = -2 then -- sayerror( 'File not found')647 elseif rc = -2 then -- sayerror( 'File not found') 647 648 not_found = not_found', 'FileSpec 648 elseif rc = -282 then -- sayerror( 'New file')649 elseif rc = -282 then -- sayerror( 'New file') 649 650 new_files = new_files', 'FileSpec 650 651 new_files_loaded = new_files_loaded + 1 651 elseif rc = -278 then --sayerror( 'Lines truncated') <-- never happens for EPM 6652 elseif rc = -278 then --sayerror( 'Lines truncated') <-- never happens for EPM 6 652 653 getfileid truncid 653 do i = 1 to filesinring(1) -- Provide an upper limit; prevent looping forever 654 if .modify then leave; endif -- Need to do this if wildcards were specified. 654 do i = 1 to filesinring( 1) -- Provide an upper limit; prevent looping forever 655 if .modify then -- Need to do this if wildcards were specified. 656 leave 657 endif 655 658 nextfile 656 659 enddo 657 660 truncated = truncated', '.filename 658 661 .modify = 0 659 elseif rc = -5 then -- sayerror( 'Access denied')662 elseif rc = -5 then -- sayerror( 'Access denied') 660 663 access_denied = access_denied', 'FileSpec 661 elseif rc = -15 then -- sayerror( 'Invalid drive')664 elseif rc = -15 then -- sayerror( 'Invalid drive') 662 665 invalid_drive = invalid_drive', 'FileSpec 663 elseif rc = -286 then -- sayerror( 'Error reading file')666 elseif rc = -286 then -- sayerror( 'Error reading file') 664 667 error_reading = error_reading', 'FileSpec 665 elseif rc = -284 then -- sayerror( 'Error opening file')668 elseif rc = -284 then -- sayerror( 'Error opening file') 666 669 error_opening = error_opening', 'FileSpec 667 670 endif -- rc=-3 668 671 --if first_file_loaded = '' then -- useless: forever empty at this point 669 if rc <> -3 & -- sayerror( 'Path not found')670 rc <> -2 & -- sayerror( 'File not found')671 rc <> -5 & -- sayerror( 'Access denied')672 rc <> -15 -- sayerror( 'Invalid drive')672 if rc <> -3 & -- sayerror( 'Path not found') 673 rc <> -2 & -- sayerror( 'File not found') 674 rc <> -5 & -- sayerror( 'Access denied') 675 rc <> -15 -- sayerror( 'Invalid drive') 673 676 then 674 677 -- If rc = 0, then set first_file_loaded: … … 681 684 682 685 if files_loaded > 1 then -- If only one file, leave E3's message 683 if new_files_loaded > 1 then p = 'New files:'; else p = 'New file:'; endif 686 if new_files_loaded > 1 then 687 p = 'New files:' 688 else 689 p = 'New file:' 690 endif 684 691 multiple_errors = (new_files || bad_paths || not_found || truncated || 685 692 access_denied || error_reading || error_opening || … … 692 699 error_reading || error_opening || invalid_drive) 693 700 694 if new_files then sayerror NEW_FILE__MSG substr(new_files,2); endif 695 if not_found then sayerror FILE_NOT_FOUND__MSG':' substr(not_found,2); endif 701 if new_files then 702 sayerror NEW_FILE__MSG substr( new_files, 2) 703 endif 704 if not_found then 705 sayerror FILE_NOT_FOUND__MSG':' substr( not_found, 2) 706 endif 696 707 else 697 708 multiple_errors = 0 698 709 endif 699 if bad_paths then sayerror BAD_PATH__MSG':' substr(bad_paths,2); endif 700 if truncated then sayerror LINES_TRUNCATED__MSG':' substr(truncated,2); endif 701 if access_denied then sayerror ACCESS_DENIED__MSG':' substr(access_denied,2); endif 702 if invalid_drive then sayerror INVALID_DRIVE__MSG':' substr(invalid_drive,2); endif 703 if error_reading then sayerror ERROR_READING__MSG':' substr(error_reading,2); endif -- __MSGs were 704 if error_opening then sayerror ERROR_OPENING__MSG':' substr(error_opening,2); endif -- exchanged 710 if bad_paths then 711 sayerror BAD_PATH__MSG':' substr( bad_paths, 2) 712 endif 713 if truncated then 714 sayerror LINES_TRUNCATED__MSG':' substr( truncated, 2) 715 endif 716 if access_denied then 717 sayerror ACCESS_DENIED__MSG':' substr( access_denied, 2) 718 endif 719 if invalid_drive then 720 sayerror INVALID_DRIVE__MSG':' substr( invalid_drive, 2) 721 endif 722 if error_reading then 723 sayerror ERROR_READING__MSG':' substr( error_reading, 2) 724 endif 725 if error_opening then 726 sayerror ERROR_OPENING__MSG':' substr( error_opening, 2) 727 endif 728 705 729 if multiple_errors then 706 messageNwait( MULTIPLE_ERRORS__MSG)730 MessageNWait( MULTIPLE_ERRORS__MSG) 707 731 endif 708 732 … … 711 735 if first_file_loaded <> '' then 712 736 713 -- activatefile is now executed in Process AfterLoad with postme.737 -- activatefile is now executed in ProcessFilesLoaded with postme. 714 738 -- This finally works properly. With activatefile here the ring would get messed. 715 739 --activatefile first_file_loaded 716 -- Set fid for Process AfterLoad:740 -- Set fid for ProcessFilesLoaded: 717 741 firstloadedfid = first_file_loaded 718 742 … … 723 747 endif 724 748 725 if upcase( CurEditCmd) <> 'RESTORERING' then749 if upcase( cureditcmd) <> 'RESTORERING' then 726 750 'AtStartup AddToHistory EDIT' args 727 751 endif … … 738 762 defc o, Open 739 763 fname = strip( arg( 1)) -- Remove excess spaces 740 call parse_filename( fname, .filename) -- Resolve '=', if any764 call Parse_Filename( fname, .filename) -- Resolve '=', if any 741 765 742 766 call windowmessage( 0, getpminfo( APP_HANDLE), 743 767 5386, -- EPM_EDIT_NEWFILE 744 put_in_buffer( fname),768 Put_In_Buffer( fname), 745 769 1) -- Tell EPM to free the buffer. 746 770 … … 759 783 parse arg Filename Pathname Rest 760 784 if Pathname = '' | Pathname = '.' then 761 if filetype( Filename) = 'CMD' then785 if FileType( Filename) = 'CMD' then 762 786 PathnameList = 'PATH' 763 787 else … … 769 793 do w = 1 to words( PathnameList) 770 794 Pathname = word( PathnameList, w) 771 call parse_filename( Filename,795 call Parse_Filename( Filename, 772 796 substr( .filename, lastpos( '\', .filename) + 1)) 773 797 findfile Newfile, Filename, Pathname -- find Filename in Pathname env var … … 784 808 ; --------------------------------------------------------------------------- 785 809 defc op, OPath, OpenPath 786 "Open 'ep "arg( 1)"'"810 "Open 'ep "arg( 1)"'" 787 811 788 812 ; --------------------------------------------------------------------------- … … 816 840 epmdir = directory() 817 841 818 call p save_pos( savedpos)842 call pSave_Pos( savedpos) 819 843 getsearch oldsearch 820 844 -- search (reverse) in command shell buffer for the prompt and … … 827 851 call ShellParsePromptLine( CurDir, Cmd) 828 852 endif 829 ShellCmd = ' shell'853 ShellCmd = 'Shell' 830 854 if CurDir <> '' then 831 855 ShellCmd = ShellCmd 'cdd' CurDir 832 856 endif 833 857 setsearch oldsearch 834 call p restore_pos( savedpos)858 call pRestore_Pos( savedpos) 835 859 836 860 fn = "'mc +cd "epmdir"+"shellcmd"'" … … 858 882 endif 859 883 860 postmc= ''884 PostMcArg = '' 861 885 if fn <> '' then 862 call p save_pos( savedpos)886 call pSave_Pos( savedpos) 863 887 -- add arg for 'mc' 864 postmc = postmc';restorepos 'savedpos888 PostMcArg = ';RestorePos 'savedpos 865 889 endif 866 890 -- Valid EPM commandline options are always regnized, even when they … … 868 892 if GetMode() = 'BIN' then 869 893 -- prepend 'binedit' 870 fn = "' binedit "fn"'"871 endif 872 if postmc> '' then873 "Open" fn "' postme mc "postmc"'"894 fn = "'BinEdit "fn"'" 895 endif 896 if PostMcArg > '' then 897 "Open" fn "'PostMe mc "PostMcArg"'" 874 898 else 875 899 'Open' fn … … 893 917 'HookAdd loadonce matchtab off' 894 918 'HookAdd loadonce mode bin noea' 895 'e /t /64 /bin "'arg( 1)'"' -- options should go before filename <-- Todo: parse options and filename919 'e /t /64 /bin "'arg( 1)'"' -- options should go before filename <-- Todo: parse options and filename 896 920 -- /64 doesn't work if run from a program object. 897 921 'postme AvoidSaveOptions /e /s /t /o /l' … … 950 974 951 975 ; --------------------------------------------------------------------------- 952 ; Finds EPM macro files <basename>.e in Dir of arg( 1) and EPMMACROPATH.976 ; Finds EPM macro files <basename>.e in Dir of arg( 1) and EPMMACROPATH. 953 977 ; Opens listbox to select one file if multiple found. 954 ; <basename> is parsed from arg( 1), so arg(1) may have any extension.978 ; <basename> is parsed from arg( 1), so arg( 1) may have any extension. 955 979 ; For association with *.ex (type: EX file) and *.e: 956 980 ; Program object: … … 1256 1280 ; Works now with temp files (starting with '.') as well. 1257 1281 ; Always returns 0. 1258 defproc parse_filename( var filename)1282 defproc Parse_Filename( var filename) 1259 1283 1260 1284 sourcefile = strip( arg( 2)) … … 1275 1299 parse value rest with "'"wrd"'" rest 1276 1300 -- parse wrd again without the quotes (wrd may contain multiple wrds) 1277 call parse_filename( wrd, sourcefile)1301 call Parse_Filename( wrd, sourcefile) 1278 1302 resolved = resolved" '"wrd"'" 1279 1303 elseif leftstr( rest, 1) = '"' then … … 1281 1305 parse value rest with '"'wrd'"' rest 1282 1306 -- wrd is ready to resolve '=' 1283 call parse_filename2( wrd, sourcefile)1307 call Parse_Filename2( wrd, sourcefile) 1284 1308 resolved = resolved' "'wrd'"' 1285 1309 else … … 1287 1311 parse value rest with wrd rest 1288 1312 -- wrd is ready to resolve '=' 1289 call parse_filename2( wrd, sourcefile)1313 call Parse_Filename2( wrd, sourcefile) 1290 1314 resolved = resolved' 'wrd 1291 1315 endif … … 1297 1321 ; --------------------------------------------------------------------------- 1298 1322 ; Resolve '=', '%' and ?: in a single word or word with spaces 1299 defproc parse_filename2( var wrd, sourcefile)1323 defproc Parse_Filename2( var wrd, sourcefile) 1300 1324 1301 1325 -- Parse sourcefile … … 1374 1398 1375 1399 -- Get specified dir 1376 StartDir = arg( 2)1400 StartDir = arg( 2) 1377 1401 1378 1402 -- Translate '/' to '\' if local masks specified … … 1456 1480 ; Wrong: [Does *not* assume all options are specified before filenames.] 1457 1481 ; Options must be specified before filename. 1458 defproc parse_leading_options( var rest, var options)1482 defproc Parse_Leading_Options( var rest, var options) 1459 1483 options = '' 1460 1484 loop … … 1474 1498 ; path or the fileid, which will be replaced by the corresponding part of the 1475 1499 ; previous file (initially, the current filename). 1476 defproc parse_file_n_opts( argstr)1500 defproc Parse_File_N_Opts( argstr) 1477 1501 prev_filename = .filename 1478 1502 output = '' … … 1486 1510 endif 1487 1511 if substr( filename, 1, 1) <> '/' then 1488 call parse_filename( filename, prev_filename)1512 call Parse_Filename( filename, prev_filename) 1489 1513 prev_filename = filename 1490 1514 endif … … 1497 1521 ; source file is modified. 1498 1522 ; We can just execute 'get' to achieve the same result. 1499 defc insert_text_file1523 defc Insert_Text_File 1500 1524 'get 'arg( 1) 1501 1525
Note:
See TracChangeset
for help on using the changeset viewer.