/****************************** Module Header ******************************* * * Module Name: stdcmds.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. * ****************************************************************************/ ; ; STDCMDS.E Alphabetized by command name. ; ; --------------------------------------------------------------------------- ; Executes a 'change' command for specified hex chars at cursor position. ; Searches a hex char, specified as e.g. 0d or 0D as first word. ; Replaces it with another hex char, e.g. 0a or 0A, specified as second word. ; As optional third word, following words are allowed: *, M*, *M or a number. ; If a number, the 'change' command is executed that number of times or ; submitted to the 'change' command as search options. defc Alter parse value upcase( arg( 1)) with c1 c2 cnt . if length( c1) <> 1 then if length( c1) <> 2 | verify( c1, HEXCHARS) then 'SayError Alter: 'sayerrortext( -328) -- 'Invalid first parameter.' endif c1 = chr( ( pos( leftstr( c1, 1), HEXCHARS) - 1) * 16 + pos( rightstr( c1, 1), HEXCHARS) - 1) endif if length( c2) <> 1 then if length( c2) <> 2 | verify( c2, HEXCHARS) then 'SayError Alter: 'sayerrortext( -329) -- 'Invalid second parameter.' endif c2 = chr( ( pos( leftstr( c2, 1), HEXCHARS) - 1) * 16 + pos( rightstr( c2, 1), HEXCHARS) - 1) endif delim = substr( HEXCHARS, verify( HEXCHARS, c1''c2), 1) -- Pick first char. not in c1''c2 change_cmd = 'c' delim''c1''delim''c2''delim call NextCmdAltersText() if cnt = '' then change_cmd elseif cnt = '*' | cnt = 'M*' | cnt = '*M' then change_cmd cnt elseif IsNum( cnt) then do i = 1 to cnt change_cmd enddo else 'SayError Alter: 'sayerrortext( -330) -- 'Invalid third parameter' endif ; --------------------------------------------------------------------------- defc App, Append -- With linking, PUT can be an external module. call NextCmdAltersText() 'Put' arg( 1) -- Collect the names; the module is named PUT.EX. ; --------------------------------------------------------------------------- defc Asc parse arg i '=' . if i = '' then getline line i = substr( line, .col, 1) endif 'SayError Asc 'i' = 'asc( i)'' ; --------------------------------------------------------------------------- ; autoshell off/on/0/1 ; ; specifies whether E should automatically pass internally-unresolved commands ; to DOS. Autoshell is an internal command; this DEFC is a simple front end ; to allow the user to type off/on/0/1. It calls the internal command via ; 'xcom autoshell'. ; ; Users who have very long path-search times might prefer to execute ; "autoshell 0" somewhere in their start-up sequence. defc AutoShell uparg = upcase( arg( 1)) if uparg = ON__MSG or uparg = 1 then .autoshell = 1 elseif uparg = OFF__MSG or uparg = '0' then .autoshell = 0 else 'SayError AutoShell = '.autoshell endif ; --------------------------------------------------------------------------- defc Bottom, Bot bottom ; --------------------------------------------------------------------------- defc Chr parse arg i '=' . 'SayError Chr 'i' = 'chr( i)'' ; --------------------------------------------------------------------------- -- TODO: Move to STDCTRL.E defc Close hwnd = strip( arg( 1)) if hwnd = '' then hwnd = getpminfo( EPMINFO_EDITCLIENT) endif call windowmessage( 0, hwnd, 41, -- WM_CLOSE 0, 0) ; --------------------------------------------------------------------------- -- TODO: Move to STDCTRL.E defc Cursor_Style, CursorStyle universal cursordimensions NewStyle = arg( 1) if not wordpos( NewStyle, '1 2 3') then NewStyle = '' endif if NewStyle = 1 then -- Vertical bar KeyPath = '\NEPMD\User\Appearance\CursorWidth' CursorWidth = QueryConfigKey( KeyPath, 2) CursorDimen = '-128.-128 'CursorWidth'.-128' -- '-128.-128 2.-128' elseif NewStyle = 2 then -- Underline cursor CursorDimen = '-128.-64 -128.3' elseif NewStyle = 3 then -- Special KeyPath = '\NEPMD\User\Appearance\CursorSpecialDimensions' CursorDimen = QueryConfigKey( KeyPath) else CursorDimen = arg( 1) endif -- Save style number if NewStyle <> '' then KeyPath = '\NEPMD\User\Appearance\CursorStyle' call WriteConfigKey( KeyPath, NewStyle) endif -- Check value parse value CursorDimen with w1 '.' w2 w3 '.' w4 junk if IsNum( w1) & IsNum( w2) & IsNum( w3) & IsNum( w4) & junk = '' then -- Set universal cursordimensions = CursorDimen -- Save special dimensions if Style = 3 KeyPath = '\NEPMD\User\Appearance\CursorStyle' Style = QueryConfigKey( KeyPath) if Style = 3 then KeyPath = '\NEPMD\User\Appearance\CursorSpecialDimensions' call WriteConfigKey( KeyPath, CursorDimen) endif else if NewStyle = 3 then -- Special -- Saved CursorDimen not valid: Set Style = 3 only, -- keep current dimensions --'CursorStyle' cursordimensions -- not required else -- Open commandline to enter new value 'CommandLine CursorStyle' cursordimensions return endif endif -- Apply new value call Fixup_Cursor() if isadefc( 'MenuInit_Miscellaneous') then 'MenuInit_Miscellaneous' endif ; --------------------------------------------------------------------------- -- TODO: Move to STDCTRL.E ; Sets the width of the bar cursor (style 1). defc CursorWidth KeyPath = '\NEPMD\User\Appearance\CursorWidth' CursorWidth = QueryConfigKey( KeyPath, 2) NewCursorWidth = arg( 1) if IsNum( NewCursorWidth) then call WriteConfigKey( KeyPath, NewCursorWidth) else 'CommandLine CursorWidth' CursorWidth return endif -- Apply new value 'CursorStyle 1' if isadefc( 'MenuInit_Miscellaneous') then 'MenuInit_Miscellaneous' endif ; --------------------------------------------------------------------------- -- TODO: Move to STDCTRL.E, together with SetMousePointer of MOUSE.E defc PointerStyle universal vepm_pointer NewStyle = arg( 1) KeyPath = '\NEPMD\User\Appearance\PointerStyle' Style = QueryConfigKey( KeyPath, 2) if wordpos( NewStyle, '1 2') then call WriteConfigKey( KeyPath, NewStyle) else 'CommandLine PointerStyle' vepm_pointer return endif -- Apply value vepm_pointer = NewStyle mouse_setpointer vepm_pointer if isadefc( 'MenuInit_Miscellaneous') then 'MenuInit_Miscellaneous' endif ; --------------------------------------------------------------------------- ; This command is the same function that has been attached to the key ; Alt-equal. Moved here as a separate command to make key binding more ; flexible. And to allow execution without a key binding. In EPM, no ; getkey() prompt. Cancel at first error. defc DoLines do once = 1 to 1 getfileid fid getmark markfirstline, marklastline, markfirstcol, marklastcol, markfid firstline = .line lastline = .line if fid <> markfid then -- nop elseif marktype() <> 'LINE' then -- nop elseif markfirstline <> marklastline | markfirstline <> .line then k = WinMessageBox( 'Dolines', EX_ALL__MSG, MB_YESNOCANCEL + MB_QUERY + MB_DEFBUTTON1 + MB_MOVEABLE) if k = MBID_YES then firstline = markfirstline lastline = marklastline elseif k = MBID_NO then -- nop else leave endif else -- nop endif if firstline < 1 then leave endif Mode = GetMode() call NextCmdAltersText() do linenum = firstline to lastline getline LineStr, linenum LineStr = strip( LineStr) -- For REXX or E files, strip quotes or double quotes if wordpos( Mode, 'REXX E') > 0 then if leftstr( LineStr, 1) = "'" & rightstr( LineStr, 1) = "'" then LineStr = substr( LineStr, 2, length( LineStr) - 2) elseif leftstr( LineStr, 1) = '"' & rightstr( LineStr, 1) = '"' then LineStr = substr( LineStr, 2, length( LineStr) - 2) endif endif -- Strip first and last word if it looks like a comment char. -- This allows for specifying an executable E command within a comment. -- It could be extended to strip mode-dependent comment chars plus '*'. firstwrd = word( LineStr, 1) if wordpos( firstwrd, '\''* (* // * ; # % --') then LineStr = subword( LineStr, 2) endif numwrds = words( LineStr) lastwrd = word( LineStr, numwrds) if wordpos( lastwrd, '*''\ *)') then LineStr = subword( LineStr, 1, numwrds - 1) endif -- Execute LineStr enddo enddo ; --------------------------------------------------------------------------- ; jbl 1/12/89: The syntax of ECHO is revised to be like browse(). It's ; a function so a macro can test its current value. defc Echo uparg = upcase( arg( 1)) if uparg = ON__MSG or uparg = 1 then call echo( 1) elseif uparg = OFF__MSG or uparg = '0' then call echo( 0) elseif IsNum( uparg) then call echo( uparg) else if echo() < 2 then 'SayError' ECHO_IS__MSG word( OFF__MSG ON__MSG, echo() + 1) else 'SayError' ECHO_IS__MSG echo() endif endif ; --------------------------------------------------------------------------- defc Expand universal expand_on uparg = upcase( arg( 1)) if uparg = ON__MSG then expand_on = 1 elseif uparg = OFF__MSG then expand_on = 0 elseif uparg = '' then 'SayError Expand = 'word( OFF__MSG ON__MSG, expand_on + 1) else 'SayError' INVALID_ARG__MSG ON_OFF__MSG')' stop endif ; --------------------------------------------------------------------------- ; Changed to allow for multiple chars and added option to fill left-aligned, ; with padded spaces. ; 'Fill ' won't fill with a space. The trailing space after the command ; is always removed. But entering a space in the entry box works. ; Note: 'Fill ; ' would include the trailing space. defc Fill, FillMark pFill_Mark( arg( 1)) ; --------------------------------------------------------------------------- defc Flow parse arg l r p . if l = '' then parse value '1 73 1' with l r p elseif r = '' then r = l l = 1 p = 1 elseif p = '' then p = l endif oldmarg = .margins .margins = l r p if .margins = l r p then call NextCmdAltersText() call pSave_Mark( save_mark) call Text_Reflow() call pRestore_Mark( save_mark) else 'SayError Flow: Invalid argument.' endif .margins = oldmarg ; --------------------------------------------------------------------------- defc GoTo parse arg line col line = strip( line) col = strip( col) do once = 1 to 1 if line > .last then leave endif call pSave_Pos( savedpos) line if col <> '' then .col = col endif call pSave_Pos( lpos) -- This proc is often used for newly-loaded files. It opens the file -- without a dialog in the way. Therefore better center the found -- line. call ScrollAfterSearch( savedpos, lpos, '', '', 'C C') 'PostMe HighlightCursor' -- PostMe required enddo ; --------------------------------------------------------------------------- defc GoToHili parse arg line col len . line = strip( line) col = strip( col) len = strip( len) do once = 1 to 1 if line > .last then leave endif call pSave_Pos( savedpos) line if col <> '' then .col = col endif call pSave_Pos( lpos) -- This proc is often used for newly-loaded files. It opens the file -- without a dialog in the way. Therefore better center the found -- line. call ScrollAfterSearch( savedpos, lpos, len, '', 'C C') if len <> '' then 'PostMe HighlightMatch' line col len -- PostMe required endif enddo ; --------------------------------------------------------------------------- defc GoToLineStr parse arg line Str line = strip( line) Str = strip( Str) do once = 1 to 1 if line > .last then leave endif call pSave_Pos( savedpos) .line = line .col = 1 lrc = '' if Str <> '' then display -2 getsearch savedsearch Mode = GetMode() fCaseSensitive = QueryModeKey( Mode, 'CaseSensitive') if fCaseSensitive = 0 then CaseOpt = 'c' -- ignore else CaseOpt = 'e' -- exact endif 'xcom l '\1''Str''\1'w+fa'CaseOpt line = .line -- Must be queried directly after 'xcom l', otherwise -- it may return wrong data. col = getpminfo( EPMINFO_SEARCHPOS) len = getpminfo( EPMINFO_LSLENGTH) setsearch savedsearch display 2 lrc = rc endif call pSave_Pos( lpos) if lrc = 0 then -- This proc is often used for newly-loaded files. It opens the file -- without a dialog in the way. Therefore better center the found -- line. call ScrollAfterSearch( savedpos, lpos, len, '', 'C C') 'PostMe HighlightMatch' line col len -- PostMe required endif enddo ; --------------------------------------------------------------------------- -- Uses findfile statement to search EPATH for the helpfile. -- Its syntax: findfile destfilename, searchfilename [, envpathvar] [, ['P']] defc Help HelpFile = HELPFILENAME -- 4.02: search EPATH/DPATH for the help file. New 'D' option on findfile. findfile DestFilename, HelpFile, '', 'D' if rc then -- If not there, search the HELP path findfile DestFilename, HelpFile, 'HELP' endif if rc then -- If all that fails, try the standard path findfile DestFilename, HelpFile, 'PATH' if rc then 'SayError' FILE_NOT_FOUND__MSG':' HelpFile return '' endif endif 'OpenHelp' DestFilename ; --------------------------------------------------------------------------- ; Like Key, but a command instead of a key must be specified. ; Syntax: DoCmd [IFDEFINED] [] [] ; 'IFDEFINED' must be the first word. When specified, no error ; msg is given when is not defined. ; can be specified to run multiple times. ; If = 'RC', then is run until an error occurs. ; 'IFDEFINED' and 'RC' are not case-sensitive. defc DoCmd, DoCommand args = strip( arg( 1)) if args = '' then return endif fIfDefined = 0 if upcase( word( args, 1)) = 'IFDEFINED' then fIfDefined = 1 args = strip( subword( args, 2)) endif parse value args with Num Cmd Num = strip( Num) Cmd = strip( Cmd) if upcase( Num) = 'RC' then til_rc = 1 else til_rc = 0 if not IsNum( Num) then Num = 1 Cmd = strip( args) endif endif if fIfDefined then fDefined = IsADefC( word( Cmd, 1)) if not fDefined then return endif endif call NextCmdAltersText() if til_rc then do forever Cmd if rc then leave endif end else for i = 1 to Num Cmd endfor endif ; --------------------------------------------------------------------------- defc LongNames universal show_longnames uparg = upcase( arg( 1)) if uparg = ON__MSG or uparg = 1 then show_longnames = 1 elseif uparg = OFF__MSG or uparg = 0 then show_longnames = 0 else 'SayError' LONGNAMES_IS__MSG word( OFF__MSG ON__MSG, show_longnames + 1) endif ; --------------------------------------------------------------------------- defc LowerCase call NextCmdAltersText() call pLowerCase() ; --------------------------------------------------------------------------- defc MatchTab universal matchtab_on uparg = upcase( arg( 1)) if uparg = ON__MSG then matchtab_on = 1 elseif uparg = OFF__MSG then matchtab_on = 0 elseif uparg = '' then 'SayError MatchTab = 'word( OFF__MSG ON__MSG, matchtab_on + 1) else 'SayError MatchTab:' INVALID_ARG__MSG ON_OFF__MSG')' stop endif ; --------------------------------------------------------------------------- ; MultiCommand, or Many Commands - lets you enter many commands on a line, ; like XEDIT's SET LINEND, but you specify the delimiter as part of the ; command so there's never a conflict. Example, using ';' as delimiter: ; mc ; top; c /begin/{/ *; top; c/end/}/ *; top defc Mc parse value strip( arg( 1), 'L') with delim 2 rest do while rest <> '' parse value rest with cmd (delim) rest cmd enddo ; --------------------------------------------------------------------------- ; ScollToTop: Make current line topmost on screen. defc NewTop, ScrollToTop l = .line -- Must disable KeepCursorOnScreen - strange. KeyPath = '\NEPMD\User\CursorPos\KeepCursorOnScreen' Enabled = QueryConfigKey( KeyPath) if Enabled then WriteConfigKey( KeyPath, 0) endif .cursory = 1 l if Enabled then -- Re-enable it WriteConfigKey( KeyPath, 1) endif 'PostMe HighlightCursor' ; --------------------------------------------------------------------------- defc RestorePos saved_pos = strip( arg( 1)) if saved_pos <> '' then call pRestore_Pos( saved_pos) endif ; --------------------------------------------------------------------------- defc ShowPos call pSave_Pos( SavedPos) dprintf( 'Current pos: 'SavedPos) ; --------------------------------------------------------------------------- defc NextView getfileid fid vid = .currentview_of_file next = .nextview_of_file if vid = next then 'SayError' ONLY_VIEW__MSG else activatefile next endif ; --------------------------------------------------------------------------- ; Opens the 'Quick Reference'. arg( 1) = full filename of e.g. epmhelp.qhl. ; See defc Help. defc OpenHelp compile if 0 rectangle = atol( 4)''atol( 75)''atol( 632)''atol( 351) filename = arg( 1)\0 exfile = 'help.ex'\0 topoffile = HELP_TOP__MSG\0 botoffile = HELP_BOT__MSG\0 rethwnd = '1234' params = atol( getpminfo( EPMINFO_HAB)) || -- application anchor block atol( getpminfo( EPMINFO_PARENTCLIENT)) || -- handle to parent of edit window atol( getpminfo( EPMINFO_OWNERCLIENT)) || -- handle to owner of edit window address( rectangle) || -- positioning of edit window address( filename) || -- file to be edited atol( 0) || -- handle to editor pointer icon. atol( 0) || -- handle to mark pointer icon. atol( 0) || -- editor ICON. atol( 12) || -- internal editor options atol( 203) || -- PM standard window styles (FCF_xxxx) atoi( 1) || -- TRUE = LARGE FONT, FALSE = SMALL FONT address( exfile) || -- pre-compiled macro code file (EPM.EX) address( topoffile) || -- top and bottom of file markers address( botoffile) || atoi( 0) || -- unique window id specified for edit window atol( 0) || -- environment variable to search for .ex atoi( 0) -- reserved for future use. call dynalinkc( E_DLL, '_EPM_EDITWINDOWCREATE', address( params) || address( rethwnd)) compile else -- send EPM icon window a help message. It will take care of -- the correct setting up of the help window. -- call windowmessage( 0, getpminfo( APP_HANDLE), 5132, -- EPM_POPHELPBROWSER Put_In_Buffer( arg( 1)), 1) -- Tell EPM to free the buffer. compile endif ; --------------------------------------------------------------------------- defc PageBreak -- I put a form feed character there for the dual purpose of somewhat -- supporting page breaks in raw mode and to allow the attributes to be -- placed at column 2 rather than column 1. My selection of a chr( 12) may -- actually mean that all page breaks need to be stripped after one is done -- printing because they may render the file invalid. (For example, I don't -- know if C allows a free FORMFEED character.) insertline chr( 12) up -- I place the attributes at column 2 rather than column 1 below, because if -- they are at column 1, line mark operations will not move them with the line. insert_attribute 6, 0, 1, 0, /*col:*/ 2, .line insert_attribute 6, 0, 0, 0, /*col:*/ 2, .line call Attribute_On( 8) -- "Save attributes" flag ; --------------------------------------------------------------------------- compile if 0 -- EPM32 -- LAM: Doesn't seem worth the code space... defc PrevView getfileid fid vid = .currentview_of_file next = .nextview_of_file if vid = next then 'SayError' ONLY_VIEW__MSG else do forever nextnext = next.nextview_of_file if nextnext = vid then leave endif next = nextnext enddo activatefile next endif compile endif ; --------------------------------------------------------------------------- ; Print just the marked area, if there is one. Defaults to printing on LPT1. ; Optional argument specifies printer. defc Print -- Save the users current file to the printer/ parse arg prt ':' -- Optional printer name if not prt then prt = Default_Printer() -- Default endif prtnum = Check_For_Printer( prt) if prtnum then if not Printer_Ready( prtnum) then 'SayError' PRINTER_NOT_READY__MSG stop endif elseif substr( prt, 1, 2) <> '\\' then -- Assume \\hostname\prt is correct. 'SayError' BAD_PRINT_ARG__MSG stop endif if marktype() then getmark firstline, lastline, firstcol, lastcol, markfileid getfileid fileid if fileid <> markfileid then 'SayError' OTHER_FILE_MARKED__MSG UNMARK_OR_EDIT__MSG markfileid.filename stop endif mt = marktype() 'xcom E /n' -- Create a temporary no-name file. if rc = -282 then -- sayerror( 'New file') if marktype() = 'LINE' then deleteline endif elseif rc then stop endif getfileid tempofid call pCopy_Mark() if rc then stop endif call pSet_Mark( firstline, lastline, firstcol, lastcol, mt, markfileid) activatefile tempofid 'SayError' PRINTING_MARK__MSG else 'SayError' PRINTING__MSG .filename endif 'xcom Save /s /ne /q' prt -- /NE means No EOF (for Laserjet driver) if marktype() then .modify = 0 'xcom Quit' endif sayerror 0 -- clear 'printing' message ; --------------------------------------------------------------------------- defc ProcessBreak -- executed if Ctrl+Break was pressed universal vepm_pointer universal dictionary_loaded mouse_setpointer vepm_pointer -- Reset mouse pointer call ShowWindow( 'ON') -- Make sure that the window is displayed if dictionary_loaded then call Drop_Dictionary() endif if IsAShell() then 'Shell_Break' else sayerror MACRO_HALTED__MSG endif ; --------------------------------------------------------------------------- defc Profile universal rexx_profile uparg = upcase( arg( 1)) if uparg = ON__MSG or uparg = 1 then rexx_profile = 1 elseif uparg = OFF__MSG or uparg = 0 then rexx_profile = 0 else 'SayError Profile' word( OFF__MSG ON__MSG, rexx_profile + 1) endif ; --------------------------------------------------------------------------- defc PopMark universal mark_stack parse value mark_stack with savemark '/' mark_stack call pRestore_Mark( savemark) ; --------------------------------------------------------------------------- defc PopPos universal position_stack parse value position_stack with fid saveposition '/' position_stack if fid = '' then 'SayError' STACK_EMPTY__MSG return endif display -2 rc = 0 activatefile fid display 2 if rc then 'SayError' FILE_GONE__MSG return endif call pRestore_Pos( saveposition) ; --------------------------------------------------------------------------- defc PushMark universal mark_stack call CheckMark() call pSave_Mark( savemark) -- Note - this does an UNMARK call pRestore_Mark( savemark) if length( mark_stack) + length( savemark) + 1 >= MAXCOL then 'SayError' STACK_FULL__MSG return endif mark_stack = savemark'/'mark_stack ; --------------------------------------------------------------------------- defc SwapMark universal mark_stack call CheckMark() call pSave_Mark( savemark) 'PopMark' if length( mark_stack) + length( savemark) + 1 >= MAXCOL then 'SayError' STACK_FULL__MSG return endif mark_stack = savemark'/'mark_stack ; --------------------------------------------------------------------------- defc PushPos universal position_stack call pSave_Pos( saveposition) getfileid fid if length( position_stack) + length( saveposition fid) + 1 >= MAXCOL then 'SayError' STACK_FULL__MSG return endif position_stack = fid saveposition'/'position_stack ; --------------------------------------------------------------------------- defc SwapPos universal position_stack call pSave_Pos( saveposition) getfileid fid 'PopPos' if length( position_stack) + length( saveposition fid) + 1 >= MAXCOL then 'SayError' STACK_FULL__MSG return endif position_stack = fid saveposition'/'position_stack ; --------------------------------------------------------------------------- defc Qs, quietshell, quiet_shell quietshell arg( 1) ; --------------------------------------------------------------------------- defc Rc arg( 1) sayerror 'rc = 'rc'' ; --------------------------------------------------------------------------- defc Stay universal stay uparg = upcase( arg( 1)) if uparg = '' then 'SayError Stay = 'word( OFF__MSG ON__MSG, stay + 1) elseif uparg = '1' | uparg = ON__MSG then stay = 1 elseif uparg = '0' | uparg = OFF__MSG then stay = 0 else 'SayError' INVALID_ARG__MSG ON_OFF__MSG')' endif ; --------------------------------------------------------------------------- defc StripTBlanksFromLines, Strip parse arg FirstLine LastLine . if FirstLine = '' then FirstLine = 1 endif if LastLine = '' then LastLine = .last endif call NextCmdAltersText() n = 0 do Line = FirstLine to LastLine -- Determine LineStr before calling SearchReplaceLine getline LineStr, Line if length( LineStr) = 0 then iterate endif -- Remove trailing whitespace -- Running SearchReplaceLine on every line with extended grep is -- slow. Therefore avoid the call if possible. rcx = 1 if rightstr( LineStr, 1) == ' ' | rightstr( LineStr, 1) == \9 then rcx = SearchReplaceLine( ':w$', '', 1, 'x', Line, 1) endif -- Count changes if rcx = 0 then n = n + 1 endif enddo 'SayHint 'n' lines stripped.' ; --------------------------------------------------------------------------- defc TabGlyph uparg = upcase( arg( 1)) if uparg = ON__MSG or uparg = 1 then call tabglyph( 1) elseif uparg = OFF__MSG or uparg = '0' then call tabglyph( 0) elseif uparg = '' or uparg = '?' then cb = tabglyph() -- query current state 'SayError' TABGLYPH_IS__MSG word( OFF__MSG ON__MSG, cb + 1) else 'SayError' INVALID_ARG__MSG ON_OFF__MSG'/?)' endif ; --------------------------------------------------------------------------- defc TimeStamp --universal countryinfo parse value GetDateTime() with Hour24 Minutes Seconds . Day MonthNum Year0 Year1 . call NextCmdAltersText() --parse value countryinfo with 22 datesep 23 24 timesep 25 datesep = '-' -- ISO timesep = ':' -- ISO keyin rightstr( Year0 + 256 * Year1, 4, 0)''datesep''rightstr( monthnum, 2, 0)''datesep''rightstr( Day, 2, 0)' ' || rightstr( hour24, 2)''timesep''rightstr( Minutes, 2, '0')''timesep''rightstr( Seconds, 2, '0')' ' ; --------------------------------------------------------------------------- defc Top top ; --------------------------------------------------------------------------- defc UpperCase call NextCmdAltersText() call pUpperCase() ; --------------------------------------------------------------------------- defc Ver 'SayError 'EDITOR_VER__MSG ver( 0) ; --------------------------------------------------------------------------- ; Hint for char mark: If cursor is on col 1 of the last marked line, then ; this means that the marked area includes the line break of the line above. ; getmark returns lastcol = 0 then. defc ShowMark getfileid curfid -- marktype() returns only CHAR, BLOCK or LINE, not CHARG and not BLOCKG. mt = marktype() getmark firstline, lastline, firstcol, lastcol, markfid Next = 'getmark : firstline lastline firstcol lastcol = 'firstline lastline firstcol lastcol || ', markfid curfid = 'markfid curfid', marktype = 'mt 'SayHint' Next dprintf( Next) -- lastcol is 1 more here. The 'g' variants don't include the attributes -- at negative offset for the following col. getmarkg firstline, lastline, firstcol, lastcol, markfid Next = 'getmarkg: firstline lastline firstcol lastcol = 'firstline lastline firstcol lastcol || ', markfid curfid = 'markfid curfid', marktype = 'mt 'SayHint' Next dprintf( Next)