/****************************** 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 cua_marking_switch universal stream_mode universal curkey 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 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 if cua_marking_switch then if not process_mark_like_cua() and -- There was no mark not insert_state() then -- & we're in replace mode delete_char -- Delete the character, to emulate replacing the endif -- marked character with a newline. 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 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 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 */