/****************************** Module Header ******************************* * * Module Name: enter.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. * ****************************************************************************/ ; --------------------------------------------------------------------- ; Syntax: ; Newline (normally used) ; NewLine newline_key ; newline_key = newline | enter plus combinations ; with s_, a_ or c_ as single prefix ; NewLine number (for compatibility) ; number = 1 ... 8 ; Newline Cmd ; NewLine SplitCfg,ColCfg,fCmd,Cmd defc Newline, Enter universal stream_mode universal curkey call NextCmdAltersText( 'N') if IsAShell() | upcase( leftstr( .filename, 8)) = '.DOS DIR' then call DirProcessDirectoryOfLine() if not rc then return endif endif KeyString = arg( 1) if KeyString = 'newline' | KeyString = 'enter' | rightstr( KeyString, length( '_newline')) = '_newline' | rightstr( KeyString, length( '_enter')) = '_enter' | KeyString = '' then if KeyString = '' then parse value curkey with KeyString \1 . endif -- Query line and split config, query cursor column config KeyPath = '\NEPMD\User\SpecialKeys' if stream_mode then KeyPath = KeyPath'\Stream' else KeyPath = KeyPath'\Line' endif KeyPath = KeyPath'\'KeyString next = QueryConfigKey( KeyPath) if next = '' then next = 'Split,KeepIndent' endif parse value next with SplitCfg','ColCfg','fCmd','Cmd if fCmd <> 1 then fCmd = 0 endif if fCmd then Cmd return endif elseif IsNum( arg( 1)) then -- Compatibility with original EPM if stream_mode | arg( 1) = '6' then SplitCfg = 'Split' ColCfg = 'KeepIndent' --ColCfg = 'NoIndent' elseif arg( 1) = '1' | arg( 1) = '3' then SplitCfg = 'Add' ColCfg = 'KeepCol' elseif arg( 1) = '9' then SplitCfg = 'Add' ColCfg = 'NoIndent' elseif arg( 1) = '2' then SplitCfg = 'NoAdd' ColCfg = 'KeepCol' elseif arg( 1) = '4' | arg( 1) = '5' then SplitCfg = 'AddIns' ColCfg = 'KeepCol' elseif arg( 1) = '7' then SplitCfg = 'Add' ColCfg = 'Margins' elseif arg( 1) = '8' then SplitCfg = 'Add' ColCfg = 'ParMargin' endif elseif IsADefc( subword( arg( 1), 1, 1)) then arg( 1) return else parse value arg( 1) with SplitCfg','ColCfg','fCmd','Cmd if fCmd <> 1 then fCmd = 0 endif if fCmd then Cmd return endif endif do once = 1 to 1 UpSplitCfg = upcase( SplitCfg) UpColCfg = upcase( ColCfg) -- o split splits the line at cursor positition and keeps the cursor there. -- The new line is not indented. -- o splitlines() splits the line, copies the indent (spaces and tabs) of -- the start line for the new line and places the cursor on the startline, -- after the indent. PrevCol = .col PrevLine = .line PrevLast = .last PrevNonBlank = GetFirstNonBlank( PrevLine) -- Split line, insert line, add indent, set cursor line if not PrevLine then insert elseif UpSplitCfg = 'SPLIT' | (UpSplitCfg = 'SPLITINS' & insert_state()) then fMarkDeleted = ReplaceMark() if fMarkDeleted & not insert_state() then -- Delete the character, to emulate replacing the -- marked character with a newline deletechar endif if PrevCol <= PrevNonBlank then split if UpColCfg = 'KEEPINDENT' then UpColCfg = 'NOINDENT' endif else if UpColCfg = 'KEEPINDENT' | UpColCfg = 'KEEPCOL' then -- Split and copy indent call SplitLines() else -- Split without indent split endif endif down elseif UpSplitCfg = 'ADD' | (UpSplitCfg = 'ADDINS' & insert_state()) then insert elseif UpSplitCfg = 'NOADD' | (UpSplitCfg = 'SPLITINS' & not insert_state()) | (UpSplitCfg = 'ADDINS' & not insert_state()) then down endif -- Set cursor col col = .col if UpColCfg = 'MARGINS' then parse value .margins with leftcol . paracol . if textline( PrevLine) = '' or not PrevLine then col = paracol else if PrevNonBlank = paracol then col = leftcol else col = PrevNonBlank endif endif elseif UpColCfg = 'PARMARGIN' then parse value .margins with leftcol . paracol . col = paracol elseif PrevLine = 0 then col = 1 elseif UpColCfg = 'KEEPINDENT' then col = PrevNonBlank elseif UpColCfg = 'KEEPCOL' then col = PrevCol elseif UpColCfg = 'NOINDENT' then col = 1 endif -- Insert spaces instead of just placing the cursor -- Process the only if a new line was added. -- For KEEPINDENT and KEEPCOL, splitlines()) has already copied -- the indent from the line above, so don't process it then. if .last > PrevLast & UpColCfg <> 'KEEPINDENT' & UpColCfg <> 'KEEPCOL' then .col = 1 do c = 1 to col - 1 keyin ' ' enddo endif -- Place the cursor to col .col = col -- Move attributes at split position call MoveAttr( PrevLine, PrevCol, .line, .col) enddo ; --------------------------------------------------------------------- defproc GetFirstNonBlank if arg( 1) <> '' then LineNum = arg( 1) else LineNum = .line endif if LineNum = 0 then FirstNonBlank = 1 else FirstNonBlank = Max( 1, verify( textline( LineNum), ' '\t)) endif return FirstNonBlank ; --------------------------------------------------------------------- /* ; Unused defproc EInsert_Line insert up getline line parse value pMargins() with leftcol . paracol . if line = '' or not .line then .col = paracol else call pFirst_NonBlank() if .col = paracol then .col = leftcol endif endif down */