/****************************** Module Header ******************************* * * Module Name: get.e * * Copyright (c) Netlabs EPM Distribution Project 2002 * * $Id$ * * =========================================================================== * * This file is part of the Netlabs EPM Distribution package and is free * software. You can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * Netlabs EPM Distribution. This library is distributed in the hope that it * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * ****************************************************************************/ compile if not defined( SMALL) EA_comment 'This defines the GET command; it can be linked, or executed directly.' define INCLUDING_FILE = 'GET.E' include 'stdconst.e' const tryinclude 'mycnf.e' const compile if not defined( NLS_LANGUAGE) NLS_LANGUAGE = 'ENGLISH' compile endif include NLS_LANGUAGE'.e' defmain -- External modules always start execution at DEFMAIN. 'Get' arg( 1) compile endif ; --------------------------------------------------------------------------- defc Get universal default_edit_options get_file = strip( arg( 1)) if get_file = '' then sayerror NO_FILENAME__MSG 'GET' return endif if pos( argsep, get_file) then sayerror INVALID_OPTION__MSG return endif call Parse_Filename( get_file, .filename) getfileid fileid s_last = .last display -1 call NextCmdAltersText() 'xcom e /q /d' get_file editrc = rc getfileid gfileid if editrc = -282 | not .last then -- -282 = sayerror('New file') 'xcom q' display 1 if editrc = -282 then sayerror FILE_NOT_FOUND__MSG': 'get_file else sayerror FILE_IS_EMPTY__MSG': 'get_file endif return endif if editrc & editrc <> -278 then -- -278 sayerror('Lines truncated') then display 1 sayerror editrc return endif call psave_mark( save_mark) if not .levelofattributesupport then 'loadattributes' endif get_file_attrib = .levelofattributesupport -- Mark src file top mark_line bottom -- Remove EOF LastLineStr = textline( .last) LastLineLen = length( strip( LastLineStr, 'T')) if rightstr( LastLineStr, 1) = \26 then -- Ends with EOF? .col = LastLineLen 'DeleteChar' .modify = 0 endif mark_line -- Copy mark activatefile fileid rc = 0 call pcopy_mark() copy_rc = rc -- Test for memory too full for copy_mark. -- Quit src file activatefile gfileid 'xcom q' parse value save_mark with s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt if fileid = s_mkfileid then -- May have to move the mark. diff = fileid.last - s_last -- (Adjustment for difference in size) if fileid.line < s_firstline then s_firstline = s_firstline + diff; endif if fileid.line < s_lastline then s_lastline = s_lastline + diff; endif endif call prestore_mark( s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt) activatefile fileid if get_file_attrib // 2 then call Attribute_On( 1) -- Colors flag endif if get_file_attrib bitand 4 then call Attribute_On( 4) -- Mixed fonts flag endif if get_file_attrib bitand 8 then call Attribute_On( 8) -- "Save attributes" flag endif display 1 if copy_rc then sayerror NOT_2_COPIES__MSG get_file endif ; refresh ; call repaint_window()