/****************************** Module Header ******************************* * * Module Name: activatehighlight.e * * E wrapper routine to access the NEPMD library DLL. * Include of nepmdlib.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. * ****************************************************************************/ /* @@NepmdActivateHighlight@PROTOTYPE NepmdActivateHighlight( ActivateFlag, HighlightMode, HighlightOptions, Handle) @@NepmdActivateHighlight@CATEGORY@MODE @@NepmdActivateHighlight@SYNTAX This function activates or deactivates the keyword highlighting for the loaded file. On activating, mode files are checked for changes. When they were changed, the temporary standard EPM keyword file is rebuilt. @@NepmdActivateHighlight@PARM@ActivateFlag This parameter specifies wether the keyword highlighting should be activated or deactivated, Specifiy one of the following values: .pl compact tsize=5 - *0* or *OFF* = deactivate keyword highlighting - *1* or *ON* = activate keyword highlighting The default value is to activate keyword highlighting. When this flag is on, a rebuild of the keyword file can be forced by holding the *Ctrl key* down during execution. If highlighting for a mode doesn't work at all, the temporary epmkwds file in the *HiliteCacheDir* may contain bugs. Then hold the Ctrl key down while switching highlighting on to force a delete and rebuild. @@NepmdActivateHighlight@PARM@HighlightMode This optional parameter specifies the highlight mode to be used. If no highlight mode is specified, the highlight mode of the current file is used. Note that the highlight mode may differ from the mode. It can be set with the HighlightMode setting or the SetHighlightMode command. The default value is the current mode. @@NepmdActivateHighlight@PARM@HighlightOptions This optional parameter specifies options. Specifiy one of the following values: .pl compact tsize=5 - *N* = don't check the internal *EPM* highlight file for being outdated. The file is nevertheless newly generated, if it does not yet exist By default no options are used. @@NepmdActivateHighlight@PARM@Handle This optional parameter determines the handle obtained by a previous call to [.IDPNL_EFUNC_NEPMDOPENCONFIG]. Use *-3* or *HINI__NEPMDPROFILE* to automatically insert the value of the universal var *nepmd__hini*. That's the handle returned by the initial opening of NEPMD.INI. You may pass an *empty string* or *-9* to [.IDPNL_REGISTRY_IMPLICITOPEN implicitely open and close] the configuration repository before and after this call. @@NepmdActivateHighlight@RETURNS *NepmdActivateHighlight* returns nothing. This procedure sets the implicit universal var *rc*. rc is set to an [inf:cp2 "Errors" OS/2 error code] or to zero for no error. @@NepmdActivateHighlight@TESTCASE You can test this function from the *EPM* commandline by executing: .sl - *NepmdActivateHighlight* [.IDPNL_EFUNC_NEPMDACTIVATEHIGHLIGHT_PARM_ACTIVATEFLAG ActivateFlag] - or - *ActivateHighlight* [.IDPNL_EFUNC_NEPMDACTIVATEHIGHLIGHT_PARM_ACTIVATEFLAG ActivateFlag] Executing this command will (de)activate syntax highlighting according to the mode of the currently loaded file @@ */ ; --------------------------------------------------------------------------- ; Allow editor command to call function ; --------------------------------------------------------------------------- compile if NEPMD_LIB_TEST defc NepmdActivateHighlight, ActivateHighlight do i = 1 to 1 ActivateFlag = translate( word( arg( 1), 1)) if (ActivateFlag = '') then ActivateFlag = 'ON' endif HighlightMode = translate( word( arg( 1), 2)) NewStatus = 1 if (wordpos( ActivateFlag, 'ON 1') > 0) then NewStatus = 'activated' elseif (wordpos( ActivateFlag, 'OFF 0') > 0) then NewStatus = 'deactivated' else sayerror 'Wrong parameter "'ActivateFlag'" specified.' leave endif call NepmdActivateHighlight( ActivateFlag, HighlightMode, 0, NewStatus) if rc then sayerror 'Keyword highlighting could not be' NewStatus', rc = 'rc'.' else sayerror 'Keyword highlighting was' NewStatus 'successfully.' endif enddo compile endif ; --------------------------------------------------------------------------- ; Procedure: NepmdActivateHighlight ; --------------------------------------------------------------------------- ; E syntax: ; rc = NepmdActivateHighlight( ActivateFlag, ; Mode, ; HighlightOptions, ; Handle) ; ; --------------------------------------------------------------------------- ; C prototype: ; APIRET EXPENTRY NepmdQueryHighlightArgs( PSZ pszActivateFlag, ; PSZ pszHighlightMode, ; PSZ pszOptions, ; HCONFIG hconfig, ; PSZ pszBuffer, ; ULONG ulBuffLen); ; --------------------------------------------------------------------------- defproc NepmdActivateHighlight( ActivateFlag) universal nepmd_hini -- Get highlight mode of current file, if not specified HighlightMode = arg( 2) if HighlightMode = '' then HighlightMode = GetHighlightMode() endif HighlightOptions = arg( 3) -- Use zero as handle if none specified Handle = arg( 4) -- For -3, use the handle returned by the initial OpenConfig of NEPMD.INI. if Handle = HINI_NEPMDPROFILE then Handle = helperNepmdGetConfigHandle() elseif Handle = '' then Handle = -9 endif -- With Ctrl pressed and ActivateFlag = 1: Delete temp. file first to -- force a rebuild do once = 1 to 1 if not isadefproc( 'CtrlIsDown') then leave endif if not CtrlIsDown() then leave endif if not ActivateFlag then leave endif -- Delete file KeyPath = '\NEPMD\User\KeywordHighlighting\HiliteCacheDir' CacheDir = NepmdQueryConfigValue( nepmd_hini, KeyPath) CacheDir = ExpandEnvVars( CacheDir) CacheFilename = CacheDir'\'lowcase( HighlightMode) call DeleteFile( CacheFilename) enddo ActivateFlag = ActivateFlag\0 HighlightMode = HighlightMode\0 HighlightOptions = HighlightOptions\0 BuffLen = NEPMD_MAXLEN_ESTRING + 1 HighlightArgs = copies( \0, BuffLen) LibFile = helperNepmdGetlibfile() rc = dynalink32( LibFile, 'NepmdQueryHighlightArgs', address( ActivateFlag) || address( HighlightMode) || address( HighlightOptions) || atol( Handle) || address( HighlightArgs) || atol( BuffLen)) call helperNepmdCheckliberror( LibFile, rc) if not rc then HighlightArgs = makerexxstring( HighlightArgs) 'Highlight' HighlightArgs endif return