Ignore:
Timestamp:
Jan 29, 2019, 7:18:48 PM (6 years ago)
Author:
Andreas Schnellbacher
Message:
  • Renamed select hooks and commands to filesloaded and fileswitched.
  • Cosmetic changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/netlabs/macros/edit.e

    r3430 r3434  
    7676defproc PreLoadFile( FileSpec, Options)
    7777   universal filestoload
    78    universal filestoloadmax  -- still used for 'xcom e' and afterload
     78   universal filestoloadmax  -- still used for 'xcom e' and ProcessFilesLoaded
    7979   if filestoload = '' then
    8080      filestoload = 0
     
    132132      -- GetMode doesn't work here, because it tries to write the fid'.mode'
    133133      -- 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.
    135135      -- We should better determine the mode here, save it in a array var with the
    136136      -- .filename as identifier, and replace the identifier with the fileid later
     
    300300      endif
    301301
    302       Codepage = upcase(Codepage)
     302      Codepage = upcase( Codepage)
    303303      if Codepage = 'CP1004' then
    304304         Codepage = 'latin-1'
     
    379379; ---------------------------------------------------------------------------
    380380;compile if LINK_HOST_SUPPORT & (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL')
    381 ; compile if not defined(MVS)
     381; compile if not defined( MVS)
    382382;    MVS = 0
    383383; compile endif
    384 ; compile if not defined(E3MVS)
     384; compile if not defined( E3MVS)
    385385;    E3MVS = 0
    386386; compile endif
    387 ; compile if not defined(HOST_LT_REQUIRED)
     387; compile if not defined( HOST_LT_REQUIRED)
    388388;    HOST_LT_REQUIRED = 0
    389389; compile endif
     
    498498defc e, ed, Edit, epm
    499499   universal default_edit_options
    500    universal CurEditCmd
     500   universal cureditcmd
    501501   universal firstloadedfid  -- first file for this edit cmd, set here
    502502   universal firstinringfid  -- first file in the ring, set by defmain
     
    515515      -- Set current edit cmd to let other commands differ between several ways
    516516      -- 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.
    519520      -- This is currently used for RestorePos and RingSavePos.
    520       if CurEditCmd = '' then
    521          CurEditCmd = 'EDIT'
     521      if cureditcmd = '' then
     522         cureditcmd = 'EDIT'
    522523      endif
    523524
     
    545546      error_reading = ''
    546547      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 letter
    551       --  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
    553554
    554555      fParseCmd = 1
     
    569570
    570571         if ch = "'" & fParseCmd then
    571             parse value rest with (ch) cmd (ch) rest
     572            parse value rest with (ch) Cmd (ch) rest
    572573            do while substr( rest, 1, 1) = ch & pos( ch, rest, 2)
    573574               parse value rest with (ch) p (ch) rest
    574                cmd = cmd''ch''p
     575               Cmd = Cmd''ch''p
    575576            enddo
    576             CurEditCmd = cmd  -- set universal var to determine later in LOAD.E if pos shall be restored from EA
    577             cmd
     577            CurEditCmd = Cmd  -- set universal var to determine later in LOAD.E if pos shall be restored from EA
     578            Cmd
    578579
    579580         elseif ch = '/' then       -- Option
     
    642643
    643644; Todo: rewrite that horrible message stuff:
    644             if rc = -3 then        -- sayerror('Path not found')
     645            if rc = -3 then        -- sayerror( 'Path not found')
    645646               bad_paths = bad_paths', 'FileSpec
    646             elseif rc = -2 then    -- sayerror('File not found')
     647            elseif rc = -2 then    -- sayerror( 'File not found')
    647648               not_found = not_found', 'FileSpec
    648             elseif rc = -282 then  -- sayerror('New file')
     649            elseif rc = -282 then  -- sayerror( 'New file')
    649650               new_files = new_files', 'FileSpec
    650651               new_files_loaded = new_files_loaded + 1
    651             elseif rc = -278 then  --sayerror('Lines truncated') <-- never happens for EPM 6
     652            elseif rc = -278 then  --sayerror( 'Lines truncated') <-- never happens for EPM 6
    652653               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
    655658                  nextfile
    656659               enddo
    657660               truncated = truncated', '.filename
    658661               .modify = 0
    659             elseif rc = -5 then  -- sayerror('Access denied')
     662            elseif rc = -5 then  -- sayerror( 'Access denied')
    660663               access_denied = access_denied', 'FileSpec
    661             elseif rc = -15 then  -- sayerror('Invalid drive')
     664            elseif rc = -15 then  -- sayerror( 'Invalid drive')
    662665               invalid_drive = invalid_drive', 'FileSpec
    663             elseif rc = -286 then  -- sayerror('Error reading file')
     666            elseif rc = -286 then  -- sayerror( 'Error reading file')
    664667               error_reading = error_reading', 'FileSpec
    665             elseif rc = -284 then  -- sayerror('Error opening file')
     668            elseif rc = -284 then  -- sayerror( 'Error opening file')
    666669               error_opening = error_opening', 'FileSpec
    667670            endif  -- rc=-3
    668671            --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')
    673676                  then
    674677                  -- If rc = 0, then set first_file_loaded:
     
    681684
    682685      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
    684691         multiple_errors = (new_files || bad_paths || not_found || truncated ||
    685692                            access_denied || error_reading || error_opening ||
     
    692699                            error_reading || error_opening || invalid_drive)
    693700
    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
    696707      else
    697708         multiple_errors = 0
    698709      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
    705729      if multiple_errors then
    706          messageNwait( MULTIPLE_ERRORS__MSG)
     730         MessageNWait( MULTIPLE_ERRORS__MSG)
    707731      endif
    708732
     
    711735      if first_file_loaded <> '' then
    712736
    713          -- activatefile is now executed in ProcessAfterLoad with postme.
     737         -- activatefile is now executed in ProcessFilesLoaded with postme.
    714738         -- This finally works properly. With activatefile here the ring would get messed.
    715739         --activatefile first_file_loaded
    716          -- Set fid for ProcessAfterLoad:
     740         -- Set fid for ProcessFilesLoaded:
    717741         firstloadedfid = first_file_loaded
    718742
     
    723747      endif
    724748
    725       if upcase( CurEditCmd) <> 'RESTORERING' then
     749      if upcase( cureditcmd) <> 'RESTORERING' then
    726750         'AtStartup AddToHistory EDIT' args
    727751      endif
     
    738762defc o, Open
    739763   fname = strip( arg( 1))                  -- Remove excess spaces
    740    call parse_filename( fname, .filename)   -- Resolve '=', if any
     764   call Parse_Filename( fname, .filename)   -- Resolve '=', if any
    741765
    742766   call windowmessage( 0, getpminfo( APP_HANDLE),
    743767                       5386,                   -- EPM_EDIT_NEWFILE
    744                        put_in_buffer( fname),
     768                       Put_In_Buffer( fname),
    745769                       1)                      -- Tell EPM to free the buffer.
    746770
     
    759783   parse arg Filename Pathname Rest
    760784   if Pathname = '' | Pathname = '.' then
    761       if filetype( Filename) = 'CMD' then
     785      if FileType( Filename) = 'CMD' then
    762786         PathnameList = 'PATH'
    763787      else
     
    769793   do w = 1 to words( PathnameList)
    770794      Pathname = word( PathnameList, w)
    771       call parse_filename( Filename,
     795      call Parse_Filename( Filename,
    772796                           substr( .filename, lastpos( '\', .filename) + 1))
    773797      findfile Newfile, Filename, Pathname  -- find Filename in Pathname env var
     
    784808; ---------------------------------------------------------------------------
    785809defc op, OPath, OpenPath
    786    "Open 'ep "arg(1)"'"
     810   "Open 'ep "arg( 1)"'"
    787811
    788812; ---------------------------------------------------------------------------
     
    816840      epmdir = directory()
    817841
    818       call psave_pos( savedpos)
     842      call pSave_Pos( savedpos)
    819843      getsearch oldsearch
    820844      -- search (reverse) in command shell buffer for the prompt and
     
    827851         call ShellParsePromptLine( CurDir, Cmd)
    828852      endif
    829       ShellCmd = 'shell'
     853      ShellCmd = 'Shell'
    830854      if CurDir <> '' then
    831855         ShellCmd = ShellCmd 'cdd' CurDir
    832856      endif
    833857      setsearch oldsearch
    834       call prestore_pos( savedpos)
     858      call pRestore_Pos( savedpos)
    835859
    836860      fn = "'mc +cd "epmdir"+"shellcmd"'"
     
    858882   endif
    859883
    860    postmc = ''
     884   PostMcArg = ''
    861885   if fn <> '' then
    862       call psave_pos( savedpos)
     886      call pSave_Pos( savedpos)
    863887      -- add arg for 'mc'
    864       postmc = postmc';restorepos 'savedpos
     888      PostMcArg = ';RestorePos 'savedpos
    865889   endif
    866890   -- Valid EPM commandline options are always regnized, even when they
     
    868892   if GetMode() = 'BIN' then
    869893      -- prepend 'binedit'
    870       fn = "'binedit "fn"'"
    871    endif
    872    if postmc > '' then
    873       "Open" fn "'postme mc "postmc"'"
     894      fn = "'BinEdit "fn"'"
     895   endif
     896   if PostMcArg > '' then
     897      "Open" fn "'PostMe mc "PostMcArg"'"
    874898   else
    875899      'Open' fn
     
    893917   'HookAdd loadonce matchtab off'
    894918   'HookAdd loadonce mode bin noea'
    895    'e /t /64 /bin "'arg(1)'"'    -- options should go before filename                    <-- Todo: parse options and filename
     919   'e /t /64 /bin "'arg( 1)'"'    -- options should go before filename                    <-- Todo: parse options and filename
    896920                                 -- /64 doesn't work if run from a program object.
    897921   'postme AvoidSaveOptions /e /s /t /o /l'
     
    950974
    951975; ---------------------------------------------------------------------------
    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.
    953977; 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.
    955979; For association with *.ex (type: EX file) and *.e:
    956980;    Program object:
     
    12561280;      Works now with temp files (starting with '.') as well.
    12571281;      Always returns 0.
    1258 defproc parse_filename( var filename)
     1282defproc Parse_Filename( var filename)
    12591283
    12601284   sourcefile = strip( arg( 2))
     
    12751299         parse value rest with "'"wrd"'" rest
    12761300         -- parse wrd again without the quotes (wrd may contain multiple wrds)
    1277          call parse_filename( wrd, sourcefile)
     1301         call Parse_Filename( wrd, sourcefile)
    12781302         resolved = resolved" '"wrd"'"
    12791303      elseif leftstr( rest, 1) = '"' then
     
    12811305         parse value rest with '"'wrd'"' rest
    12821306         -- wrd is ready to resolve '='
    1283          call parse_filename2( wrd, sourcefile)
     1307         call Parse_Filename2( wrd, sourcefile)
    12841308         resolved = resolved' "'wrd'"'
    12851309      else
     
    12871311         parse value rest with wrd rest
    12881312         -- wrd is ready to resolve '='
    1289          call parse_filename2( wrd, sourcefile)
     1313         call Parse_Filename2( wrd, sourcefile)
    12901314         resolved = resolved' 'wrd
    12911315      endif
     
    12971321; ---------------------------------------------------------------------------
    12981322; Resolve '=', '%' and ?: in a single word or word with spaces
    1299 defproc parse_filename2( var wrd, sourcefile)
     1323defproc Parse_Filename2( var wrd, sourcefile)
    13001324
    13011325   -- Parse sourcefile
     
    13741398
    13751399   -- Get specified dir
    1376    StartDir = arg(2)
     1400   StartDir = arg( 2)
    13771401
    13781402   -- Translate '/' to '\' if local masks specified
     
    14561480; Wrong: [Does *not* assume all options are specified before filenames.]
    14571481; Options must be specified before filename.
    1458 defproc parse_leading_options( var rest, var options)
     1482defproc Parse_Leading_Options( var rest, var options)
    14591483   options = ''
    14601484   loop
     
    14741498; path or the fileid, which will be replaced by the corresponding part of the
    14751499; previous file (initially, the current filename).
    1476 defproc parse_file_n_opts( argstr)
     1500defproc Parse_File_N_Opts( argstr)
    14771501   prev_filename = .filename
    14781502   output = ''
     
    14861510      endif
    14871511      if substr( filename, 1, 1) <> '/' then
    1488          call parse_filename( filename, prev_filename)
     1512         call Parse_Filename( filename, prev_filename)
    14891513         prev_filename = filename
    14901514      endif
     
    14971521; source file is modified.
    14981522; We can just execute 'get' to achieve the same result.
    1499 defc insert_text_file
     1523defc Insert_Text_File
    15001524   'get 'arg( 1)
    15011525
Note: See TracChangeset for help on using the changeset viewer.