/****************************** Module Header ******************************* * * Module Name: config.e * * Copyright (c) Netlabs EPM Distribution Project 2004 * * $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. * ****************************************************************************/ ; Configuration and ini file definitions. ; ; The 1st part of initialization is done in INIT.E by setting universal ; vars to values of consts and defining definit. definit is called before ; defmain at linking of EPM.EX. initconfig is called by defmain. ; ; Thats's the 2nd part of initialization. It concerns with settings queried ; from EPM.INI and with definitions for the settings dialog. It defines ; following commands (among others): ; ; InitConfig Read values from ini and change configuration of ; current EPM window. This overwrites values previously ; initialized to values of consts, if their ini entries ; are present. Called by defmain. ; ; RenderConfig Send values to config dialog, either ; - default values defined by consts or ; - values read from ini or ; - current values. ; Called by configdlg at its startup. ; ; SetConfig Change configuration of current EPM window according ; to the changes by the user. Called by configdlg at its ; closing. ; ; While some universals are set at definit, defc initconfig is called at ; defmain. It's quite important for performance and stability, at which time ; during startup all the init stuff is processed. This applies not only to ; getting values from the ini, but also to the creation of menu and making ; the window visible. ; Configuration changes, that must be written to the ini, can be made by ; o settings dialog ; o menu items ; o drag and drop from color and font palettes ; o additional commands ; Instead of using EPM.INI, only NEPMD.INI is used now. ; In order to always process all those ways equal, it's sometimes tricky to ; move settings to NEPMD.INI. E.g. for the color and font settings special ; commands are called after a color or font change, except for the toolbar. ; ; So every setting can be moved to NEPMD.INI, except the following (so far): ; o initial setup of toolbar after its startup (but can be changed ; afterwards) ; o position of EPM window and others ; o list of toolbar names used by the standard config dialog ; o toolbar setup string (aka toolbar template), saved by the standard ; config dialog (dialog will be replaced sometime) ; o toolbar im- and export, made by the standard config dialog (dialog ; will be replaced sometime) ; o toolbar font changed via font palette ; o toolbar color changed via color palette (not important) ; All these issues can be handled by changing the entry for OS2.INI -> EPM ; -> EPMIniPath before EPM's startup or opening the config dialog ; and resetting it after the action, because the path for EPM.INI is read ; only once at EPM's startup, excluding for ConfigDlg! ; The entry for UCMenu -> ConfigInfo changes to some strange values after ; a font is dropped on the toolbar. ; Before: ; 832328.Helv1677721616777216 ; After: ; 270401576262612.System VIO1355361413553614 ; 27040157626269.WarpSans1355361413553614 ; The color values are: ; 16777216 = 0x1000000 (means default color?) ; 13553614 = 0xCECFCE (CE = 205, CF = 206) ; light gray = 204-204-204, values above are probably just not precise. ; Syntax: ; \1 style \1 cx \1 cy \1 font \1 color \1 itemcolor \1 ; Removed consts: ; INCLUDE_MENU_SUPPORT, INCLUDE_STD_MENUS, WANT_DYNAMIC_PROMPTS, ; BLOCK_ACTIONBAR_ACCELERATORS, WANT_STACK_CMDS, RING_OPTIONAL, ; WANT_STREAM_MODE, WANT_TOOLBAR, SPELL_SUPPORT, WANT_APPLICATION_INI_FILE, ; ENHANCED_ENTER_KEYS, WANT_LONGNAMES, WANT_PROFILE TOGGLE_ESCAPE, ; TOGGLE_TAB, DYNAMIC_CURSOR_STYLE, WANT_BITMAP_BACKGROUND, INITIAL_TOOLBAR ; WPS_SUPPORT, ENTER_ACTION, C_ENTER_ACTION, SUPPORT_USER_EXITS, ; CHECK_FOR_LEXAM. ; Remaining consts: ; HOST_SUPPORT ; my_CURSORDIMENSIONS, my_SAVEPATH, ; Remaining standard ini keys (now moved to NEPMD.INI): ; (i) means: internally defined, by non-available C code. ; Todo: All other keys should be moved to NEPMD's RegContainer. ; EPM -> AUTOSAVE ; AUTOSPATH ; CommandBox (i) ; CUA_ACCEL ; DEFAULTSWP (i) ; MARGINS ; MsgBox (i) ; OpenBox (i) ; OPT2FLAGS ; OPTFLAGS ; RING ; STACK ; TABS ; ERESDLGS -> * (i) ; UCMenu -> ConfigInfo (i) ; UCMenu_Templates -> * (i) ; ; OPTFLAGS: ; Bit Setting ; for value = 1 for value = 0 ; --- ---------------- ------------------- ; 1 status bar on status bar off ; 2 msgline on msgline off ; 3 vscrollbar on vscrollbar off ; 4 hscrollbar on hscrollbar off ; 5 fileicon on fileicon off unused in EPM 6 (icon beside system menu icon) ; 6 rotbuttons on rotbuttons off ; 7 info at top info at bottom pos of status + msg lines ; 8 CUA marking advanced marking ; 9 menuprompt on menuprompt off menu hints on msg line ; 10 stream mode line mode ; 11 longnames on longnames off show .LONGNAME EA instead of file name in titletext ; 12 REXX profile on REXX profile off ; 13 escapekey on escapekey off ESC opens cmdbox ; 14 tabkey on tabkey off 1 = TAB inserts tab char ; 15 bgbitmap on bgbitmap off ; 16 toolbar on toolbar off ; 17 dropstyle import dropstyle edit action for dropped file icon ; 18 ?extra stuff on ?extra stuff off ? ; ; OPT2FLAGS: ; Bit Setting ; for value = 1 for value = 0 ; --- ---------------- ------------------- ; 1 I-beam pointer arrow pointer 1 = (vEPM_POINTER=2) ; 2 underline cursor bar cursor 1 = (cursordimensions = '-128.3 -128.-64') ; --------------------------------------------------------------------------- ; Provide some consts, for the case a user really wants to change this: const compile if not defined( CONFIGDLG_START_WITH_CURRENT_FILE_SETTINGS) -- 0 => start with settings from EPM.INI CONFIGDLG_START_WITH_CURRENT_FILE_SETTINGS = 0 -- previous standard would have been 1 compile endif compile if not defined( CONFIGDLG_CHANGE_FILE_SETTINGS) CONFIGDLG_CHANGE_FILE_SETTINGS = 'REFRESHDEFAULT' -- previous standard would have been 1 compile endif compile if not defined( CONFIGDLG_ASK_REFLOW) CONFIGDLG_ASK_REFLOW = 0 -- previous standard would have been 1 compile endif ; --------------------------------------------------------------------------- /* 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � What's it called: configdlg � � Syntax: configdlg � � � � What does it do : ask EPM.EXE to pop up its internal configuration dialog. � � This is done by posting a EPM_POPCONFIGDLG message to � � the EPM Book window. � � � � (All EPM_EDIT_xxx messages are defined in the ETOOLKT � � PACKAGE available on PCTOOLS.) � � � � Who and when : Jerry C. 7/20/89 � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 */ defc ConfigDlg args = arg( 1) wp = wordpos( 'SYS', upcase( args)) -- SYS not used by EPM. Used by Epm class? if wp then args = delword( args, wp, 1) msgid = 5147 -- EPM_POPSYSCONFIGDLG else msgid = 5129 -- EPM_POPCONFIGDLG endif omit = 0 omit = omit + 4 -- omit Paths page (outdated) omit = omit + 8 -- omit Autosave page (outdated) omit = omit + 32 -- omit Keys page (outdated) --omit = 512 if IsNum( args) then omit = args endif -- omit: from 0 to 1023 -- 0: show all pages -- 1: without page 1 Margins -- 2: without page 2 Colors -- 4: without page 3 Paths -- 8: without page 4 Autosave -- 16: without page 5 Fonts -- 32: without page 6 Keys -- 64: without page 7 Window -- 128: without page 8 Misc. -- 256: without page 9 Toolbar style -- 512: without page 10 Toolbar call windowmessage( 0, getpminfo( APP_HANDLE), msgid, omit, -- 0 = Omit no pages 0) ; --------------------------------------------------------------------------- /* 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � What's it called: renderconfig � � Syntax: renderconfig reply_window_hwnd page fsend_default � � � � What does it do : Upon the request of a external window, send configuration� � information in the form of special WM_COMMAND messages � � to the window handle specified in parameter one. � � � � The second parameter is the page number of the config � � dialog which is requesting the information; this tells � � us the range of information desired. (Each page only � � gets sent the information for that page, when the page � � is activated. Better performance than sending every- � � thing when the dialog is initialized.) � � � � The third parameter is a flag, as follows: � � 0 -> send value from .ini file � � 1 -> send default value (ignoring .ini) � � 2 -> send current value (5.60 & above, only) � � � � The fuction is used by EPM to fill in the EPM CONFIG � � dialog box. � � � � Who and when : Jerry C. & LAM 7/20/89 � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 */ defc RenderConfig universal app_hini universal vdefault_tabs universal vdefault_margins universal vdefault_autosave universal default_font universal vmessagecolor universal vstatuscolor universal statfont universal msgfont universal bm_filename universal bitmap_present universal toolbar_loaded universal stream_mode universal show_longnames universal rexx_profile universal cua_marking_switch -- for compatbility universal cua_menu_accel universal vepm_pointer universal cursordimensions parse arg hndle page fsend_default . -- Usually fsend_default is = 2 at this point -------------------------------------------------------------------------- -- Overwrite fsend_default to open the settings dialog with standard -- settings (from EPM.INI), not with settings of the current file. -- In standard EPM defc SetConfig (called when the dialog is closed) -- compares these settings with the current file's settings. If different, -- the settings for the current file are changed, what is not intended -- now. -- Therefore in defc SetConfig the update of current file's margins and -- tabs is diabled now. -- The settings notebook will change only default or global settings now. compile if CONFIGDLG_START_WITH_CURRENT_FILE_SETTINGS = 0 -- new default fsend_default = 0 compile elseif CONFIGDLG_START_WITH_CURRENT_FILE_SETTINGS = 1 fsend_default = 2 compile endif -- else use submitted flag (normally = 2) -- Notebook control ---------------------------------------------- help_panel = 5300 + page -- Tabs and margins are on the first notebook page. if page = 1 then --------------------- Page 1 is tabs ------------- -- Page 1 is not compatible with the config via the Preferences menu, -- but is used to configure margins with old menus. if fsend_default = 2 then tempstr = .tabs else KeyPath = '\NEPMD\User\Tabs' tempstr = QueryConfigKey( KeyPath) endif call Send_Config_Data( hndle, tempstr, 3, help_panel) tempstr = 0 call Send_Config_Data( hndle, tempstr, 19, help_panel) elseif page = 2 then ----------------- Page 2 is margins ---------- if fsend_default = 2 then -- 2: Use current values tempstr = .margins else -- 0|1: Use values from .ini file or default values KeyPath = '\NEPMD\User\Margins' tempstr = QueryConfigKey( KeyPath) endif call Send_Config_Data( hndle, tempstr, 1, 5301) elseif page = 3 then ----------------- Page 3 is colors ----------- if fsend_default = 2 then -- 2: Use current values tempstr = .textcolor .markcolor vstatuscolor vmessagecolor else if fsend_default then -- 1: Use default values tempstr = '' else -- 0: Use values from .ini file KeyPath = '\NEPMD\User\Colors' textcol = ColorNameToNum( QueryConfigKey( KeyPath'\Text')) markcol = ColorNameToNum( QueryConfigKey( KeyPath'\Mark')) statuscol = ColorNameToNum( QueryConfigKey( KeyPath'\Status')) messagecol = ColorNameToNum( QueryConfigKey( KeyPath'\Message')) tempstr = textcol markcol statuscol messagecol endif if tempstr = '' | tempstr = 1 then tempstr = TEXTCOLOR MARKCOLOR STATUSCOLOR MESSAGECOLOR endif endif parse value tempstr with ttextcolor tmarkcolor tstatuscolor tmessagecolor . call Send_Config_Data( hndle, ttextcolor, 4, help_panel) call Send_Config_Data( hndle, tmarkcolor, 5, help_panel) call Send_Config_Data( hndle, tstatuscolor, 6, help_panel) call Send_Config_Data( hndle, tmessagecolor, 7, help_panel) elseif page = 4 then ----------------- Page 4 is paths ------------ -- Page 4 is not compatible with the config via the Preferences menu. elseif page = 5 then ----------------- Page 5 is autosave --------- if fsend_default = 2 then -- 2: Use current values tempstr = .autosave else -- 0|1: Use values from .ini file or default values tempstr = GetAutoSaveNum() endif call Send_Config_Data( hndle, tempstr, 2, help_panel) call Send_Config_Data( hndle, strip( GetBackupDir(), 't', '\')'\', 9, help_panel) elseif page = 6 then ----------------- Page 6 is fonts ------------ ----------------- Text fontid = word( default_font 0 .font, fsend_default + 1) call Send_Config_Data( hndle, queryfont( fontid)'.'Trunc( .textcolor // 16)'.'.textcolor % 16, 24, help_panel) ----------------- Status -- All fonts are saved now as psize'.'facename['.'attr], like OS/2 font specs if not fsend_default then -- 0: Use values from .ini file KeyPath = '\NEPMD\User\Fonts\Status' tempstr = QueryConfigKey( KeyPath) elseif fsend_default = 1 then -- 1: Use default values tempstr = queryfont( 0) else -- 2: Use current values tempstr = statfont endif tempstr = ConvertToEFont( tempstr) call Send_Config_Data( hndle, tempstr'.'Trunc( vstatuscolor // 16)'.'vstatuscolor % 16, 25, help_panel) ----------------- Message if not fsend_default then -- 0: Use values from .ini file KeyPath = '\NEPMD\User\Fonts\Message' tempstr = QueryConfigKey( KeyPath) elseif fsend_default = 1 then -- 1: Use default values tempstr = queryfont( 0) else -- 2: Use current values tempstr = msgfont endif tempstr = ConvertToEFont( tempstr) call Send_Config_Data( hndle, tempstr'.'Trunc( vmessagecolor // 16)'.'vmessagecolor % 16, 26, help_panel) elseif page = 7 then ----------------- Page 7 is enter keys ------- -- Page 7 is not compatible with the configuration via STDKEYS.E or MYKEYS.E. elseif page = 8 then ----------------- Page 8 is Frame controls --- tempstr = '1111010' -- StatWnd, MsgWnd, hscroll, vscroll, infoattop, bgbitmap, drop if not fsend_default then -- 0: Use values from .ini file statflg = 1 msgflg = 1 hscrollflg = 1 vscrollflg = 1 KeyPath = '\NEPMD\User\Appearance\InfoLine\AtTop' infoattopflg = QueryConfigKey( KeyPath) KeyPath = '\NEPMD\User\Appearance\BackgroundBitmap' new_bitmap = QueryConfigKey( KeyPath) KeyPath = '\NEPMD\User\FileDropAction' drop_style = (QueryConfigKey( KeyPath) = 'import') tempstr = statflg || msgflg || hscrollflg || vscrollflg || infoattopflg || new_bitmap || drop_style elseif fsend_default = 2 then -- 2: Use current values statflg = QueryFrameControl( 1) msgflg = QueryFrameControl( 2) hscrollflg = QueryFrameControl( 16) vscrollflg = QueryFrameControl( 8) infoattopflg = QueryFrameControl( 32) new_bitmap = bitmap_present drop_style = QueryFrameControl( 8192) tempstr = statflg || msgflg || hscrollflg || vscrollflg || infoattopflg || new_bitmap || drop_style endif call Send_Config_Data( hndle, tempstr, 15, help_panel) KeyPath = '\NEPMD\User\Appearance\BackgroundBitmap\Filename' call Send_Config_Data( hndle, QueryConfigKey( KeyPath), 16, help_panel) elseif page = 9 then ----------------- Page 9 is Misc. ------------ -- dialog has longnames and profile bits exchanged, compared to OPTFLAGS tempstr = '0000100' -- CUA marking, stream mode, Rexx profile, longnames, I-beam pointer, underline cursor, menu accelerators if not fsend_default then -- 0: Use values from .ini file -- For compatibilty markflg = (QueryMarkingMode() = 'C') KeyPath = '\NEPMD\User\StreamMode' streamflg = QueryConfigKey( KeyPath, 1) KeyPath = '\NEPMD\User\RexxProfile' profile = QueryConfigKey( KeyPath, 1) KeyPath = '\NEPMD\User\Appearance\InfoLine\Longname' longnames = QueryConfigKey( KeyPath, 1) KeyPath = '\NEPMD\User\Appearance\PointerStyle' pointer_style = QueryConfigKey( KeyPath, 2) - 1 KeyPath = '\NEPMD\User\Appearance\CursorStyle' cursor_shape = QueryConfigKey( KeyPath, 1) - 1 KeyPath = '\NEPMD\User\SpecialKeys\Alt\BlockAltLetter' menu_accel = not QueryConfigKey( KeyPath, 0) tempstr = markflg || streamflg || profile || longnames || pointer_style || cursor_shape || menu_accel elseif fsend_default = 2 then -- 2: Use current values tempstr = cua_marking_switch || stream_mode || rexx_profile || show_longnames || (vepm_pointer = 2) || (cursordimensions = '-128.3 -128.-64') || cua_menu_accel endif call Send_Config_Data( hndle, tempstr, 18, help_panel) elseif page = 12 then ---------------- Page 12 is Toolbar config -- if fsend_default = 1 -- 1: Use default values then tempstr = '' else -- 0|2: Use values from .ini file or current values tempstr = queryprofile( app_hini, 'UCMenu', 'ConfigInfo') endif if tempstr = '' then --tempstr = \1'8'\1'32'\1'32'\1'8.Helv'\1'16777216'\1'16777216'\1 -- internal default if no entry in EPM.INI tempstr = \1'120'\1'32'\1'32'\1'9.WarpSans'\1'16777216'\1'16777216'\1 -- internal default if no entry in EPM.INI endif call Send_Config_Data( hndle, tempstr, 22, help_panel) elseif page = 13 then ---------------- Page 13 is Toolbar name & on/off active_toolbar = toolbar_loaded if active_toolbar = \1 then active_toolbar = '' endif send_toolbar = active_toolbar -- current setting if fsend_default then if fsend_default = 1 then -- 1: Use default values send_toolbar = '' -- standard setting endif else next = GetDefaultToolbar() if next > '' then send_toolbar = next -- default setting from ini endif endif call Send_Config_Data( hndle, send_toolbar, 20, help_panel) call Send_Config_Data( hndle, QueryFrameControl( EFRAMEF_TOOLBAR), 21, help_panel) -- The list of toolbars and all the button actions on this page are not configurable -- with E commands. endif -- page = 1 ; --------------------------------------------------------------------------- defproc Send_Config_Data( hndle, strng, i, help_panel) strng = strng\0 -- null terminate (asciiz) call windowmessage( 1, hndle, 32, -- WM_COMMAND - 0x0020 MpFrom2Short( help_panel, i), ltoa( offset( strng) || selector( strng), 10)) ; --------------------------------------------------------------------------- /* 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � What's it called: setconfig � � Syntax: setconfig configid newvalue � � � � What does it do : The function is called by the EPM CONFIG dialog box to � � return values set by the user. � � � � � � Who and when : Jerry C. & LAM 7/20/89 � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 */ defc SetConfig universal app_hini universal appname universal vdefault_tabs universal vdefault_margins universal vdefault_autosave universal vmessagecolor universal vstatuscolor universal bm_filename universal bitmap_present universal toolbar_loaded universal stream_mode universal default_stream_mode universal show_longnames universal rexx_profile universal cua_marking_switch -- for compatbility universal cua_menu_accel universal vepm_pointer ChangeFileSettings = CONFIGDLG_CHANGE_FILE_SETTINGS -- standard was 1 AskReflow = CONFIGDLG_ASK_REFLOW --dprintf( 'SETCONFIG', arg( 1)) parse value arg( 1) with configid perm newcmd if configid = 1 then if ChangeFileSettings = 1 then -- change current file's setting if .margins <> newcmd then .margins = newcmd 'PostMe RefreshInfoLine MARGINS' if AskReflow then 'PostMe Maybe_Reflow_All' endif endif elseif ChangeFileSettings = 'REFRESHDEFAULT' then -- change setting of all files in 'RingRefreshSetting DEFAULT SetMargins 'newcmd -- the ring with default settings endif if perm then KeyPath = '\NEPMD\User\Margins' call WriteConfigKey( KeyPath, newcmd) endif vdefault_margins = newcmd 'AtEvent AfterStartup RefreshInfoLine MARGINS' elseif configid = 2 then if perm then KeyPath = '\NEPMD\User\AutoSave\Number' call WriteConfigKey( KeyPath, newcmd) endif .autosave = newcmd vdefault_autosave = newcmd elseif configid = 3 then if ChangeFileSettings = 1 then -- change current file's setting if .tabs <> newcmd then .tabs = newcmd 'PostMe RefreshInfoLine TABS' endif elseif ChangeFileSettings = 'REFRESHDEFAULT' then -- change setting of all files in 'RingRefreshSetting DEFAULT SetTabs 'newcmd -- the ring with default settings endif if perm then KeyPath = '\NEPMD\User\Tabs' call WriteConfigKey( KeyPath, newcmd) endif vdefault_tabs = newcmd 'AtEvent AfterStartup RefreshInfoLine TABS' elseif configid = 4 & newcmd <> .textcolor then .textcolor = newcmd if perm then 'SaveColor TEXT' endif elseif configid = 5 & newcmd <> .markcolor then .markcolor = newcmd if perm then 'SaveColor MARK' endif elseif configid = 6 & newcmd <> vstatuscolor then vstatuscolor = newcmd 'SetStatusline' if perm then 'SaveColor STATUS' endif elseif configid = 7 & newcmd <> vmessagecolor then vmessagecolor = newcmd 'SetMessageline' if perm then 'SaveColor MESSAGE' endif elseif configid = 9 then elseif configid = 10 then elseif configid = 11 then elseif configid = 12 then elseif configid = 15 then parse value newcmd with statflg 2 msgflg 3 hscrollflg 4 vscrollflg 5 infoattopflg 6 new_bitmap 7 drop_style 8 'ToggleFrame 1' statflg 'ToggleFrame 2' msgflg 'ToggleFrame 8' vscrollflg 'ToggleFrame 16' hscrollflg 'ToggleFrame 32' infoattopflg 'ToggleFrame 8192' drop_style if bitmap_present <> new_bitmap then 'Toggle_Bitmap' -- always permanent if bitmap_present then bm_filename = '' -- Will be reset; want to ensure it's reloaded. endif endif if perm then KeyPath = '\NEPMD\User\Appearance\InfoLine\Status' call WriteConfigKey( KeyPath, statflg) KeyPath = '\NEPMD\User\Appearance\InfoLine\Message' call WriteConfigKey( KeyPath, msgflg) -- Removed permanent disabling of scroll bars KeyPath = '\NEPMD\User\Appearance\InfoLine\AtTop' call WriteConfigKey( KeyPath, infoattopflg) KeyPath = '\NEPMD\User\FileDropAction' call WriteConfigKey( KeyPath, word( 'edit import', drop_style + 1)) endif elseif configid = 16 then if bm_filename <> newcmd then if bitmap_present then if bm_filename = '' then -- Need to turn off & back on to get default bitmap 'Toggle_Bitmap' 'Toggle_Bitmap' else 'Load_Dt_Bitmap' newcmd endif endif endif if perm then KeyPath = '\NEPMD\User\Appearance\BackgroundBitmap\Filename' call WriteConfigKey( KeyPath, bm_filename) endif elseif configid = 18 then parse value newcmd with markflg 2 streamflg 3 profile 4 longnames 5 pointer_style 6 cursor_shape 7 menu_accel 8 vepm_pointer = 1 + pointer_style mouse_setpointer vepm_pointer 'CursorStyle' (cursor_shape + 1) if markflg <> cua_marking_switch then 'CUA_Mark_Toggle' 'PostMe RefreshInfoline MARKINGMODE' -- postme required? CUA_mark_toggle sets infoline already! endif if streamflg <> default_stream_mode then if ChangeFileSettings = 1 then -- change current file's setting 'Stream_Toggle' -- old definition stream_mode = streamflg 'PostMe RefreshInfoline STREAMMODE' elseif ChangeFileSettings = 'REFRESHDEFAULT' then next = GetAVar( fid'.streammode') -- query file setting if next = 'DEFAULT' | next = '' then -- unset if tabkey was not changed by any modeexecute 'Stream_Toggle' stream_mode = streamflg 'PostMe RefreshInfoLine STREAMMODE' endif endif default_stream_mode = streamflg endif if longnames <> '' then show_longnames = longnames endif if profile <> '' then rexx_profile = profile endif if cua_menu_accel <> menu_accel then 'Accel_Toggle' endif if perm then KeyPath = '\NEPMD\User\Mark\AdvancedMarking' WriteConfigKey( KeyPath, not markflg) KeyPath = '\NEPMD\User\StreamMode' WriteConfigKey( KeyPath, streamflg) KeyPath = '\NEPMD\User\Appearance\InfoLine\Longname' WriteConfigKey( KeyPath, longnames) KeyPath = '\NEPMD\User\RexxProfile' WriteConfigKey( KeyPath, profile) KeyPath = '\NEPMD\User\Appearance\InfoLine\Longname' WriteConfigKey( KeyPath, longnames) KeyPath = '\NEPMD\User\Appearance\PointerStyle' WriteConfigKey( KeyPath, pointer_style + 1) KeyPath = '\NEPMD\User\Appearance\CursorStyle' WriteConfigKey( KeyPath, cursor_shape + 1) KeyPath = '\NEPMD\User\SpecialKeys\Alt\BlockAltLetter' WriteConfigKey( KeyPath, not menu_accel) endif elseif configid = 19 then elseif configid = 20 then -- Toolbar name if newcmd = '' then -- Null string; use compiled-in toolbar if toolbar_loaded <> \1 then --'loaddefaulttoolbar' 'LoadStandardToolbar' endif elseif newcmd <> toolbar_loaded then call windowmessage( 0, getpminfo( EPMINFO_EDITFRAME), 5916, app_hini, Put_In_Buffer( newcmd)) toolbar_loaded = newcmd endif if perm then call SetDefaultToolbar() endif elseif configid = 21 then -- Toolbar enabled if newcmd <> QueryFrameControl( EFRAMEF_TOOLBAR) then 'ToggleFrame' EFRAMEF_TOOLBAR newcmd endif if perm then KeyPath = '\NEPMD\User\Toolbar' call WriteConfigKey( KeyPath, newcmd) endif elseif configid = 22 then -- Toolbar style call windowmessage( 0, getpminfo( EPMINFO_EDITFRAME), 5921, Put_In_Buffer( newcmd), 0) if perm then call setprofile( app_hini, 'UCMenu', 'ConfigInfo', newcmd) endif elseif configid = 0 then ; This doesn't work. "SetConfig 0" is always executed when the dialog is ; closed, after all other SetConfig calls and always just with "0" as ; parameter, without perm. ; if perm then ; 'SaveColor' ; endif --dprintf( 'setconfig', 'configid = 0') ; In standard EPM the font was always saved: ; call setprofile( app_hini, appname, INI_STUFF, ; .textcolor .markcolor vstatuscolor vmessagecolor) 'SaveFont' endif ; --------------------------------------------------------------------------- /* 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � What's it called: initconfig � � � � What does it do : Set universal variables according to the values � � previously saved in the EPM.INI file. � � � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 */ ; The menu defs like togglecontrol, toggleframe, ... must be already defined ; before initconfig is executed. defc InitConfig universal nepmd_hini universal currenthlpfiles universal shell_index universal rexx_profile universal vdefault_tabs universal vdefault_margins universal vdefault_autosave universal cua_marking_switch -- for compatibilty universal stream_mode universal default_stream_mode universal cursoreverywhere universal join_after_wrap -- = joinafterwrap universal twospaces -- = two_spaces universal expand_on universal matchtab_on universal stay universal default_edit_options universal default_search_options universal default_save_options universal vepm_pointer universal ring_enabled universal show_longnames universal menu_prompt universal cua_menu_accel universal stack_cmds universal toolbar_present universal bitmap_present universal bm_filename universal vdesktopcolor universal vmessagecolor universal vstatuscolor universal vmodifiedstatuscolor universal vreadonlystatuscolor universal default_font -- a number (= .font), not a font spec universal msgfont universal statfont universal addenda_filename universal dictionary_filename universal header_width compile if HOST_SUPPORT universal hostcopy compile endif compile if (HOST_SUPPORT = 'EMUL' | HOST_SUPPORT = 'E3EMUL') and not defined( my_SAVEPATH) universal savepath compile endif --dprintf( 'InitConfig called') compile if HOST_SUPPORT compile if defined( my_hostcopy) hostcopy = my_hostcopy compile else hostcopy = 'almcopy' -- Default for OS/2 is the OS/2 version of ALMCOPY. compile endif -- Could be mytecopy, e78copy, bondcopy, cp78copy, almcopy, etc. -- Add options if necessary (e.g., 'mytecopy /nowsf') compile endif -- Init obsolete universal var for compatibility compile if (HOST_SUPPORT = 'EMUL' | HOST_SUPPORT = 'E3EMUL') and not defined( my_SAVEPATH) savepath = strip( GetBackupDir(), 't', '\')'\' compile endif KeyPath = '\NEPMD\User\Spellcheck\Language' ActiveNum = NepmdQueryConfigValue( nepmd_hini, KeyPath'\Selected') if ActiveNum <> '' then Dict = NepmdQueryConfigValue( nepmd_hini, KeyPath'\'ActiveNum'\Dictionary') Add = NepmdQueryConfigValue( nepmd_hini, KeyPath'\'ActiveNum'\Addenda') endif dictionary_filename = Dict addenda_filename = Add shell_index = 0 -- Add additional help files. AddToHelp calls HM_SET_HELP_LIBRARY_NAME -- and closes all help panels in an existing help viewer associated with -- EPM. So execute AddToHelp only if no other window is open. if QueryMoreEpmWindows() then currenthlpfiles = 'epm.hlp etkucms.hlp reflow.hlp tree.hlp' else currenthlpfiles = 'epm.hlp' 'AddToHelp etkucms.hlp reflow.hlp tree.hlp' endif -- o We need this e.g. for to use otherkeys. -- o This should probably be moved to KEYS.E. 'ToggleControl 26 0' -- Turn off internal support for cursor keys. -- stay = 1: After a change, restore the cursor to the start pos. stay = 0 KeyPath = '\NEPMD\User\Margins' next = QueryConfigKey( KeyPath) .margins = next vdefault_margins = next next = GetAutoSaveNum() .autosave = next vdefault_autosave = next KeyPath = '\NEPMD\User\Tabs' next = QueryConfigKey( KeyPath) .tabs = next vdefault_tabs = next KeyPath = '\NEPMD\User\Appearance\InfoLine\Status' statflg = QueryConfigKey( KeyPath, 1) 'ToggleFrame 1' statflg KeyPath = '\NEPMD\User\Appearance\InfoLine\Message' msgflg = QueryConfigKey( KeyPath, 1) 'ToggleFrame 2' msgflg vscrollflg = 1 -- enable vertical scrollbar 'ToggleFrame 8' vscrollflg hscrollflg = 1 -- enable horizontal scrollbar 'ToggleFrame 16' hscrollflg -- Ensure that ring is always on. That can't be disabled in EPM. What can -- only be disabled are the rotate buttons and menu items. This won't make -- sense, because via drag'n'drop it's always possible to add multiple -- files to the ring. ring_enabled = 1 -- always activate this 'ToggleFrame 4' 1 -- enable rotate buttons KeyPath = '\NEPMD\User\Appearance\InfoLine\AtTop' infoattopflg = QueryConfigKey( KeyPath, 0) 'ToggleFrame 32' infoattopflg KeyPath = '\NEPMD\User\FileDropAction' drop_style = (QueryConfigKey( KeyPath) = 'import') 'ToggleFrame 8192' drop_style -- For compatibility cua_marking_switch = (QueryMarkingMode() <> 'A') KeyPath = '\NEPMD\User\Appearance\InfoLine\Message\MenuHints' menu_prompt = QueryConfigKey( KeyPath, 1) KeyPath = '\NEPMD\User\StreamMode' default_stream_mode = QueryConfigKey( KeyPath, 1) stream_mode = default_stream_mode 'togglecontrol 24' stream_mode KeyPath = '\NEPMD\User\Appearance\InfoLine\Longname' longnames = QueryConfigKey( KeyPath, 1) show_longnames = 1 if longnames <> '' then show_longnames = longnames endif KeyPath = '\NEPMD\User\RexxProfile' profile = QueryConfigKey( KeyPath, 1) rexx_profile = 1 if profile <> '' then rexx_profile = profile endif KeyPath = '\NEPMD\User\Appearance\BackgroundBitmap' bitmap_present = QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\Appearance\BackgroundBitmap\Filename' bm_filename = QueryConfigKey( KeyPath) if bitmap_present & bm_filename <> '' then 'Load_Dt_Bitmap' bm_filename endif KeyPath = '\NEPMD\User\Appearance\PointerStyle' vepm_pointer = QueryConfigKey( KeyPath, 2) KeyPath = '\NEPMD\User\Appearance\CursorStyle' 'CursorStyle' QueryConfigKey( KeyPath, 1) -- Maybe correct ini entry, returned value not used Setup = GetToolbarSetup() KeyPath = '\NEPMD\User\Toolbar' toolbar_present = QueryConfigKey( KeyPath, 1) if toolbar_present then 'ReloadToolbar' endif stack_cmds = 1 -- always activate this KeyPath = '\NEPMD\User\SpecialKeys\Alt\BlockAltLetter' cua_menu_accel = not QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\Mode\TEXT\Reflow\TwoSpaces' twospaces = QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\Edit\DefaultOptions' default_edit_options = QueryConfigKey( KeyPath) KeyPath = '\NEPMD\User\Save\DefaultOptions' default_save_options = QueryConfigKey( KeyPath) default_search_options = GetDefaultSearchOptions() KeyPath = '\NEPMD\User\SyntaxExpansion' expand_on = QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\SpecialKeys\Tab\MatchWordsAbove' matchtab_on = QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\SpecialKeys\Tab\ShowTabs' on = QueryConfigKey( KeyPath, 1) call tabglyph( on) KeyPath = '\NEPMD\User\Format\Reflow\JoinAfterWrap' join_after_wrap = QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\CursorPos\CursorEverywhere' cursoreverywhere = QueryConfigKey( KeyPath, 0) KeyPath = '\NEPMD\User\Format\HeaderWidth' header_width = QueryConfigKey( KeyPath) KeyPath = '\NEPMD\User\Colors' -- The 2nd arg of QueryConfigKey is a fallback value. It is applied when -- a key doesn't exist in NEPMD.INI and when it doesn't have a default -- value defined in RegDefaults. .textcolor = ColorNameToNum( QueryConfigKey( KeyPath'\Text', BLACK+WHITEB)) .markcolor = ColorNameToNum( QueryConfigKey( KeyPath'\Mark', BLUE+LIGHT_GRAYB)) vdesktopcolor = ColorNameToNum( QueryConfigKey( KeyPath'\Background', BLACK+LIGHT_GRAYB)) vmessagecolor = ColorNameToNum( QueryConfigKey( KeyPath'\Message', LIGHT_RED+WHITEB)) vstatuscolor = ColorNameToNum( QueryConfigKey( KeyPath'\Status', BLACK+LIGHT_GRAYB)) vmodifiedstatuscolor = ColorNameToNum( QueryConfigKey( KeyPath'\ModifiedStatus', MAGENTA+LIGHT_GRAYB)) vreadonlystatuscolor = ColorNameToNum( QueryConfigKey( KeyPath'\ReadOnlyStatus', LIGHT_BLUE+LIGHT_GRAYB)) call windowmessage( 0, getpminfo( EPMINFO_EDITCLIENT), -- post 5497, -- EPM_EDIT_SETDTCOLOR vdesktopcolor, 0) 'SetMessageline' -- update the color --'SetStatusline' -- update the color, not required, done by RefreshStatusLine KeyPath = '\NEPMD\User\Fonts' -- The 2nd arg of QueryConfigKey is a fallback value. It is applied when -- a key doesn't exist in NEPMD.INI and when it doesn't have a default -- value defined in RegDefaults. next = QueryConfigKey( KeyPath'\Text', '12.System VIO') next = ConvertToEFont( next) parse value next with fontname'.'fontsize'.'fontsel .font = registerfont( fontname, fontsize, fontsel) default_font = .font -- All fonts are saved now as psize'.'facename['.'attr], like OS/2 font specs msgfont = QueryConfigKey( KeyPath'\Message', '10.Helv') parse value ConvertToEFont( msgfont) with fontname'.'fontsize'.'fontsel --parse value msgfont with fontname'.'fontsize'.'fontsel 'SetStatFace' getpminfo( EPMINFO_EDITMSGHWND) fontname 'SetStatPtsize' getpminfo( EPMINFO_EDITMSGHWND) fontsize statfont = QueryConfigKey( KeyPath'\Status', '10.System Proportional Non-ISO') parse value ConvertToEFont( statfont) with fontname'.'fontsize'.'fontsel 'SetStatFace' getpminfo( EPMINFO_EDITSTATUSHWND) fontname 'SetStatPtsize' getpminfo( EPMINFO_EDITSTATUSHWND) fontsize -- Apply all defined pseudo mode DEFAULT settings. This inits universals -- used by mode settings. 'ApplyDefaultModeSettings' -- Init 'std' keyset 'InitStdKeyset' -- Accelerator keys must be defined before the menu, because the key defs -- are required to append them to the menu item texts. --dprintf( 'Calling LoadAccel by InitConfig, defined in CONFIG.E') 'LoadAccel' 'LoadDefaultMenu' -- Ensure that config key is reset SetCheckModifyRestart( '0') ; --------------------------------------------------------------------------- ; Executed by ToggleFrame with 'OptOnly' parm, the old Preferences dialog, by ; the menu item "Options -> Save options" of stdmenu and two times by the ; Tags dialog on Refresh with 'OptOnly' as arg, which doesn't make sense. defc SaveOptions universal rexx_profile universal show_longnames universal stream_mode universal vepm_pointer universal cursordimensions universal cua_menu_accel universal bm_filename --dprintf( 'SaveOptions: arg( 1) = 'arg( 1)) KeyPath = '\NEPMD\User\Appearance\InfoLine\Status' call WriteConfigKey( KeyPath, QueryFrameControl( 1)) KeyPath = '\NEPMD\User\Appearance\InfoLine\Message' call WriteConfigKey( KeyPath, QueryFrameControl( 2)) -- Removed permanent disabling of scroll bars KeyPath = '\NEPMD\User\Appearance\InfoLine\AtTop' call WriteConfigKey( KeyPath, QueryFrameControl( 32)) KeyPath = '\NEPMD\User\FileDropAction' call WriteConfigKey( KeyPath, word( 'edit import', QueryFrameControl( 8192) + 1)) -- Advanced/CUA marking is now always permanent KeyPath = '\NEPMD\User\StreamMode' WriteConfigKey( KeyPath, stream_mode) KeyPath = '\NEPMD\User\Appearance\InfoLine\Longname' WriteConfigKey( KeyPath, show_longnames) KeyPath = '\NEPMD\User\RexxProfile' WriteConfigKey( KeyPath, rexx_profile) KeyPath = '\NEPMD\User\Appearance\InfoLine\Longname' WriteConfigKey( KeyPath, show_longnames) KeyPath = '\NEPMD\User\Appearance\PointerStyle' WriteConfigKey( KeyPath, (vepm_pointer = 2) + 1) KeyPath = '\NEPMD\User\Appearance\CursorStyle' WriteConfigKey( KeyPath, (cursordimensions = '-128.3 -128.-64') + 1) KeyPath = '\NEPMD\User\Toolbar' on = QueryFrameControl( EFRAMEF_TOOLBAR) call WriteConfigKey( KeyPath, on) if arg( 1) = 'OptOnly' then return endif KeyPath = '\NEPMD\User\SpecialKeys\Alt\BlockAltLetter' WriteConfigKey( KeyPath, not cua_menu_accel) 'SaveFont EDIT' 'SaveFont MSG' 'SaveFont STAT' KeyPath = '\NEPMD\User\Appearance\BackgroundBitmap\Filename' call WriteConfigKey( KeyPath, bm_filename) call SaveApp() ; --------------------------------------------------------------------------- ; Internally called when a font is dropped on a window, after SetPresParam. ; Then the standard args are 'EDIT' | 'MSG' | 'STAT'. They are replaced ; with words of KeyList. If no word of KeyList is specified as arg, then all ; fonts are saved. ; Called as well by the config dialog on close, if the "Save settings" ; checkbox was checked. /* 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � What's it called: savefont � � � � What does it do : save fonts in the ini file � � Who&when : GLS 09/16/93 � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 */ defc SaveFont universal msgfont universal statfont universal default_font --dprintf( 'SaveFont', 'arg( 1) = ['arg( 1)']') -- arg( 1) = 'EDIT' | 'MSG' | 'STAT' KeyList = 'Text Message Status' -- Font specs have spaces. Therefore they are separated with \1 ValList = ConvertToOs2Font( queryfont( .font))''\1''msgfont''\1''statfont''\1 args = upcase( arg( 1)) -- Replace EDIT, MSG, STAT new = '' do w = 1 to words( args) next = word( args, w) if next = 'EDIT' then new = new 'TEXT' elseif next = 'MSG' then new = new 'MESSAGE' elseif next = 'STAT' then new = new 'STATUS' else wp2 = wordpos( next, upcase( KeyList)) if wp2 then new = new next endif endif enddo args = strip( new) if args = '' then args = upcase( KeyList) endif KeyPath = '\NEPMD\User\Fonts' rest = args do w = 1 to words( args) next = word( args, w) wp = wordpos( next, upcase( KeyList)) if wp then Key = word( KeyList, wp) rest = ValList do i = 1 to wp parse value rest with Val \1 rest enddo WriteConfigKey( KeyPath'\'Key, Val) --dprintf( 'SAVEFONT', KeyPath'\'word( KeyList, wp)' = 'Val) -- Set default_font to take change immediately for the next loaded files if Key = 'Text' then default_font = .font endif endif enddo ; --------------------------------------------------------------------------- ; Internally called when a color is dropped on a window, after SetPresParam. ; Then the standard args are 'EDIT' | 'MSG' | 'STAT'. They are not precise ; enough and any occurence of it causes now ignoration of that call. ; They are replaced by calls of SaveColor from SetPresParam. If no word of ; KeyList is specified as arg, then all colors are saved. /* 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커 � What's it called: savecolor � � � � What does it do : save color in the ini file � � Who&when : GLS 09/16/93 � 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸 */ defc SaveColor universal vdesktopcolor universal vmessagecolor universal vstatuscolor universal vmodifiedstatuscolor universal vreadonlystatuscolor --dprintf( 'SAVECOLOR', 'arg( 1) = ['arg( 1)']') IgnoreList = 'EDIT MSG STAT' KeyList = 'Text Mark Background Message Status ModifiedStatus ReadOnlyStatus' ValList = .textcolor .markcolor vdesktopcolor vmessagecolor vstatuscolor || ' 'vmodifiedstatuscolor vreadonlystatuscolor args = upcase( arg( 1)) -- Ignore EDIT, MSG, STAT (and unknown words), since they are not precise enough new = '' do w = 1 to words( args) next = word( args, w) wp1 = wordpos( next, IgnoreList) if wp1 then return -- don't process this, since SetPresParam calls SaveColor itself endif wp2 = wordpos( next, upcase( KeyList)) if wp2 then new = new next endif enddo args = strip( new) -- Default args if no words of KeyList specified if args = '' then args = upcase( KeyList) endif KeyPath = '\NEPMD\User\Colors' rest = args do w = 1 to words( args) next = word( args, w) wp = wordpos( next, upcase( KeyList)) if wp then Key = word( KeyList, wp) Val = ColorNumToName( word( ValList, wp)) WriteConfigKey( KeyPath'\'Key, Val) --dprintf( 'SAVECOLOR', KeyPath'\'Key' = 'Val) endif enddo ; --------------------------------------------------------------------------- ; Syntax: Tabs [| | default | 0] defc Tabs universal vdefault_tabs KeyPath = '\NEPMD\User\Tabs' DefaultVal = QueryConfigKey( KeyPath) -- Parse args Args = strip( arg( 1)) if upcase( Args) = 'DEFAULT' or Args = '0' then Args = DefaultVal elseif not IsNum( Args) then Args = '' endif if Args = '' then -- Open entrybox Title = 'Configure default tabs' Text = 'Enter a single number for a fixed tab interval, or a list of explicit tab positions (default: 'DefaultVal'):' KeyPath = '\NEPMD\User\Tabs' IniValue = QueryConfigKey( KeyPath) DefaultButton = 1 parse value EntryBox( Title, '/~Set/~Reset/'CANCEL__MSG, -- max. 4 buttons IniValue, '', 260, atoi( DefaultButton) || atoi( 0000) || -- help id GethWndC( APP_HANDLE) || Text) with Button 2 NewValue \0 NewValue = strip( NewValue) if Button = \1 then -- Set 'Tabs' NewValue elseif Button = \2 then -- Reset 'Tabs 'DefaultVal endif else NewTabs = Args -- Set value vdefault_tabs = NewTabs .tabs = NewTabs KeyPath = '\NEPMD\User\Tabs' call WriteConfigKey( KeyPath, NewTabs) 'AtEvent AfterStartup RefreshInfoLine TABS' if isadefproc( 'MenuText_tabs') then MenuText_tabs() endif endif ; --------------------------------------------------------------------------- ; This changes the .tabs field var for current file only. defc LocalTabs .tabs = arg( 1) 'RefreshInfoLine TABS' ; --------------------------------------------------------------------------- ; Syntax: ma [[] [] | default | 0] defc Margins, Ma universal vdefault_margins KeyPath = '\NEPMD\User\Margins' DefaultVal = QueryConfigKey( KeyPath) -- Parse args Args = strip( arg( 1)) if upcase( Args) = 'DEFAULT' or Args = '0' then Args = DefaultVal endif if Args = '' then -- Open entrybox Title = 'Configure margins' Text = 'Enter leftma rightma parma (default: 'DefaultVal'):' KeyPath = '\NEPMD\User\Margins' IniValue = QueryConfigKey( KeyPath) DefaultButton = 1 parse value EntryBox( Title, '/~Set/~Reset/'CANCEL__MSG, -- max. 4 buttons IniValue, '', 260, atoi( DefaultButton) || atoi( 0000) || -- help id GethWndC( APP_HANDLE) || Text) with Button 2 NewValue \0 NewValue = strip( NewValue) if Button = \1 then -- Set 'Margins' NewValue elseif Button = \2 then -- Reset 'Margins 'DefaultVal endif else -- Assemble value parse value Args with leftm rightm parm . if rightm = '' then -- If only 1 arg specified rightm = Args leftm = 1 endif if parm = '' then -- If parmargin not specified parm = leftm endif NewMargins = leftm rightm parm -- Set value vdefault_margins = NewMargins .margins = NewMargins KeyPath = '\NEPMD\User\Margins' call WriteConfigKey( KeyPath, NewMargins) 'AtEvent AfterStartup RefreshInfoLine MARGINS' if isadefproc( 'MenuText_margins') then MenuText_margins() endif endif ; --------------------------------------------------------------------------- defproc GetCuaMark getfileid fid on = (GetAVar( fid'.cuamark') = 1) return on ; --------------------------------------------------------------------------- defproc GetStreamMode getfileid fid on = (GetAVar( fid'.streammode') = 1) return on ; --------------------------------------------------------------------------- defproc GetExpand getfileid fid on = (GetAVar( fid'.expand') = 1) return on ; --------------------------------------------------------------------------- defproc GetMatchtab getfileid fid on = (GetAVar( fid'.matchtab') = 1) return on ; --------------------------------------------------------------------------- ; NEPMD config macros ; --------------------------------------------------------------------------- ; --------------------------------------------------------------------------- ; Returns a full filename of the netlabs or user tree. An existing user file ; overrides a netlabs file. If both are not found, the user filename is ; returned. defproc GetUserNetlabsFile( Name, SubPath) OutFilename = '' NetlabsDir = Get_Env( 'NEPMD_ROOTDIR')'\netlabs' UserDir = Get_Env( 'NEPMD_USERDIR') if SubPath <> '' then -- Ensure that SubPath has a trailing backslash SubPath = strip( SubPath, 'B', '\')'\' endif NetlabsFile = NetlabsDir'\'SubPath''Name UserFile = UserDir'\'SubPath''Name if Exist( UserFile) then OutFilename = UserFile elseif Exist( NetlabsFile) then OutFilename = NetlabsFile else OutFilename = UserFile endif return OutFilename ; --------------------------------------------------------------------------- defproc AddOptionalPrefix( Str, Prefix) NewStr = Str if leftstr( Str, length( Prefix)) <> Prefix then NewStr = Prefix''Str endif return NewStr ; --------------------------------------------------------------------------- defproc DeleteConfigTree( KeyPath) -- A trailing backslash may be specified to delete only subkeys fDeleteSubOnly = 0 if rightstr( KeyPath, 1) = '\' then fDeleteSubOnly = 1 -- Strip trailing '\' KeyPath = leftstr( KeyPath, length( KeyPath) - 1) endif KeyPath = AddOptionalPrefix( KeyPath, '\NEPMD') --dprintf( 'KeyPath = 'KeyPath) call DeleteNextConfigKey( KeyPath, '', fDeleteSubOnly) return defc DeleteConfigTree universal numcfgkeys numcfgkeys = 0 parse arg Args wp = wordpos( 'QUIET', upcase( Args)) fQuiet = (wp > 0) if wp then Args = delword( Args, wp, 1) endif KeyPath = Args call DeleteConfigTree( KeyPath) if not fQuiet then 'SayError' numcfgkeys 'key(s) deleted.' endif ; --------------------------------------------------------------------------- defproc DeleteNextConfigKey( KeyPath) universal nepmd_hini universal numcfgkeys if numcfgkeys = '' then numcfgkeys = 0 endif -- Compare with previous KeyPath to avoid inifinite recursion LastKeyPath = arg( 2) if KeyPath = LastKeyPath then rc = 13 -- ERROR_INVALID_DATA 'SayError DeleteNextConfigKey: Error: infinite recursion for: 'KeyPath return endif fDeleteSubOnly = (arg( 3) = 1) if not fDeleteSubOnly then -- Delete key, don't query default values -- This doesn't find empty values nor empty zero-terminated values. Val = queryprofile( nepmd_hini, 'RegKeys', KeyPath) if Val <> '' then numcfgkeys = numcfgkeys + 1 --dprintf( ' DeleteNextConfigKey: Key found: 'KeyPath' = 'strip( leftstr( translate( Val, '.', \1), 80))) endif -- This finds also empty values or empty zero-terminated values. call DeleteConfigKey( KeyPath) endif fDeleteSubOnly = 0 -- Delete subkeys and subcontainers ContainerList = queryprofile( nepmd_hini, 'RegContainer', KeyPath) Rest = ContainerList do while Rest <> '' parse value Rest with NextKey \0 Rest --dprintf( 'KeyPath\NextKey = 'KeyPath'\'NextKey) -- Process NextKey (recursive call) call DeleteNextConfigKey( KeyPath'\'NextKey, KeyPath, fDeleteSubOnly) -- Don't stop here on error to delete the rest --if rc then -- leave --endif enddo return ; A recursive call of NepmdGetNextConfigKey would require different NextKey ; vars for each iteration. In E, there exists no way to specify a var name ; by concatenated strings. ; --------------------------------------------------------------------------- defproc RenameConfigTree( OldKeyPath, NewKeyPath) OldKeyPath = AddOptionalPrefix( OldKeyPath, '\NEPMD') NewKeyPath = AddOptionalPrefix( NewKeyPath, '\NEPMD') --dprintf( 'OldKeyPath = 'OldKeyPath', NewKeyPath = 'NewKeyPath) call RenameNextConfigKey( OldKeyPath, NewKeyPath) return defc RenameConfigTree universal numcfgkeys numcfgkeys = 0 parse arg OldKeyPath NewKeyPath call RenameConfigTree( OldKeyPath, NewKeyPath) 'SayError' numcfgkeys 'key(s) renamed.' ; --------------------------------------------------------------------------- ; If OldKeyPath exists and NewKeyPath doesn't: rename them. ; If both exist: delete OldKeyPath. defproc RenameDeleteConfigTree( OldKeyPath, NewKeyPath) universal nepmd_hini OldKeyPath = AddOptionalPrefix( OldKeyPath, '\NEPMD') NewKeyPath = AddOptionalPrefix( NewKeyPath, '\NEPMD') if strip( queryprofile( nepmd_hini, 'RegContainer', OldKeyPath), 'B', \0) then if strip( queryprofile( nepmd_hini, 'RegContainer', NewKeyPath), 'B', \0) then call DeleteConfigTree( OldKeyPath) else call RenameConfigTree( OldKeyPath, NewKeyPath) endif endif return defc RenameDeleteConfigTree universal numcfgkeys numcfgkeys = 0 parse arg OldKeyPath NewKeyPath call RenameDeleteConfigTree( OldKeyPath, NewKeyPath) 'SayError' numcfgkeys 'key(s) renamed or deleted.' ; --------------------------------------------------------------------------- defproc RenameNextConfigKey( OldKeyPath, NewKeyPath) universal nepmd_hini universal numcfgkeys if numcfgkeys = '' then numcfgkeys = 0 endif -- Compare with previous KeyPath to avoid inifinite recursion LastKeyPath = arg( 3) if OldKeyPath = LastKeyPath then rc = 13 -- ERROR_INVALID_DATA sayerror 'RenameNextConfigKey: Error: infinte recursion for: 'OldKeyPath return endif -- Rename key, don't query default values. -- This doesn't find empty values nor empty zero-terminated values. Val = queryprofile( nepmd_hini, 'RegKeys', OldKeyPath) if Val <> '' then --dprintf( ' RenameNextConfigKey: Key found: 'OldKeyPath' = 'strip( leftstr( translate( Val, '.', \1), 80))) call WriteConfigKey( NewKeyPath, Val) numcfgkeys = numcfgkeys + 1 endif -- This finds also empty values or empty zero-terminated values. call DeleteConfigKey( OldKeyPath) -- Rename subkeys and subcontainers ContainerList = queryprofile( nepmd_hini, 'RegContainer', OldKeyPath) Rest = ContainerList do while Rest <> '' parse value Rest with NextKey \0 Rest --dprintf( 'OldKeyPath\NextKey = 'OldKeyPath'\'NextKey) -- Process NextKey (recursive call) call RenameNextConfigKey( OldKeyPath'\'NextKey, NewKeyPath'\'NextKey, OldKeyPath) if rc then leave endif enddo return ; A recursive call of NepmdGetNextConfigKey would require different NextKey ; vars for each iteration. In E, there exists no way to specify a var name ; by concatenated strings. ; --------------------------------------------------------------------------- ; Syntax: ExportConfig ExportFilename Filter fIncludeRegDefaults ; ExportConfig "ExportFilename" "Filter1 Filter2" fIncludeRegDefaults ; Don't forget to specify 1 as 3rd word if RegDefaults should be exported. defc ExportConfig ExportFilename = '' ListOfFilters = '' fIncludeRegDefaults = 0 fIncludeSpecified = 0 -- Parse args parse arg rest a = 0 do forever rest = strip( rest) if rest = '' then leave endif a = a + 1 -- Handle double quotes if leftstr( rest, 1 = '"') then parse value rest with '"'next'"' rest else parse value rest with next rest next = strip( next) endif if a = 1 then ExportFilename = next elseif a = 2 then ListOfFilters = next elseif a = 3 then fIncludeRegDefaults = next fIncludeSpecified = 1 else leave endif enddo do once = 1 to 1 if fIncludeSpecified then -- Flag already specified as 3rd arg leave endif -- Determine flag from filename lp1 = lastpos( '\', ExportFilename) Name = substr( ExportFilename, lp1 + 1) lp2 = lastpos( '.', Name) if lp2 then Basename = leftstr( Name, Max( 0, lp2 - 1)) else Basename = Name endif CheckName = lowcase( Basename) if pos( 'default', CheckName) then fIncludeRegDefaults = 1 leave endif p = pos( '_', CheckName) if p then Prefix = leftstr( CheckName, Max( 0, p - 1)) else Prefix = Basename endif if pos( 'd', Prefix) then fIncludeRegDefaults = 1 leave endif enddo call ExportConfig( ExportFilename, ListOfFilters, fIncludeRegDefaults) defproc ExportConfig( ExportFilename, ListOfFilters) universal numcfgkeys -- Also used by ExportNextUserConfigKey do once = 1 to 1 numcfgkeys = 0 fIncludeRegDefaults = (arg( 3) = 1) -- Build CfgFile, maybe prepended by path and appended by date and extension lp1 = lastpos( '\', ExportFileName) Name = substr( ExportFilename, lp1 + 1) lp2 = lastpos( '.', Name) parse value DateTime() with Date Time if lp1 then if lp2 then CfgFile = ExportFilename else CfgFile = ExportFilename'_'Date'.cfg' endif else UserDir = Get_Env( 'NEPMD_USERDIR') if lp2 then CfgFile = UserDir'\bin\'ExportFilename else CfgFile = UserDir'\bin\'ExportFilename'_'Date'.cfg' endif endif -- Check if CfgFile is already loaded getfileid cfgfid, CfgFile if cfgfid <> '' then -- Quit CfgFile getfileid fid activatefile cfgfid .modify = 0 'xcom q' if fid <> cfgfid then activatefile fid endif endif -- Use a virtual name first to disable datetime check Filename = '.export' -- Determine template fModeTemplate = 1 do w = 1 to words( ListOfFilters) KeyPath = word( ListOfFilters, w) if not pos( '\NEPMD\User\Mode', KeyPath) then fModeTemplate = 0 leave endif enddo if fModeTemplate then TemplateName = 'modecfg.tpl' else TemplateName = 'exportcfg.tpl' endif TemplateFile = GetUserNetlabsFile( TemplateName, 'install') -- Build VarStr VarStr = 'CFG_NAME='GetFileSpec( 'N', CfgFile) || ' CFG_FILTERS="'ListOfFilters'"' || ' DATETIME="'DateTime()'"' -- Create file CreateFileFromTemplate( Filename, TemplateFile, VarStr) if rc then leave endif -- Use parts from ExportConfig2. Maybe add ExportConfigWriteVars. do w = 1 to words( ListOfFilters) KeyPath = word( ListOfFilters, w) insertline KeyPath" = DELETE:" enddo insertline "" -- Save first key line, actually the empty line. New lines are inserted -- above of it. FirstKeyLine = .last -- RegDefaults Handle = HINI_NEPMDPROFILE ProfileApp = 'RegDefaults' PrevSubPath = '' if fIncludeRegDefaults then do w = 1 to words( ListOfFilters) KeyPath = word( ListOfFilters, w) -- Find all default keys Filter = KeyPath DefKeyPath = '' do while NepmdGetNextProfileKey( Handle, ProfileApp, Filter, DefKeyPath) -- Query value (user or default) Val = QueryConfigKey( DefKeyPath) -- Enquote Val if it has leading or trailing spaces if length( Val) <> length( strip( Val)) then Val = '"'Val'"' endif PrevSubPath = MaybeInsertLine( DefKeyPath, PrevSubPath) numcfgkeys = numcfgkeys + 1 call WriteKeyPathValLine( DefKeyPath, Val) enddo enddo endif -- RegKeys do w = 1 to words( ListOfFilters) KeyPath = word( ListOfFilters, w) call ExportNextUserConfigKey( KeyPath) enddo .line = FirstKeyLine 'CenterLine' .col = 1 .filename = CfgFile -- defload for the new file should be completed and all keys should be -- added here before showing the SaveAs dialog or saving the file. -- Therefore use another defc and 2x PostMe. 'PostMe PostMe ExportConfig2' enddo return ; --------------------------------------------------------------------------- defc ExportConfig2 universal numcfgkeys 'SayError' numcfgkeys 'key(s) exported.' if numcfgkeys > 0 then if Exist( .filename) then -- SaveAs_Dlg: arg1 = 0 => omit overlay dialog if file exists 'SaveAs_Dlg 0' else 'Save' endif else .modify = 0 'Quit' endif ; --------------------------------------------------------------------------- ; Parse %% and %%. For %%: Search for = in ; VarStr. If not found, keep %%. Expand %% to %. Expand env vars ; and boot drive. defproc ExportConfigExpandVars( LineStr, VarStr) p1 = 0 p2 = 0 startp = 1 startp2 = startp do forever -- parse is not used here, because if only 1 % char is present, it -- would assign all the rest to EnvVar. if not p1 then p1 = pos( '%', LineStr, startp) --dprintf( 'p1 = 'p1' = pos( %, 'LineStr', 'startp')') if p1 = 0 then leave endif startp = p1 + 1 startp2 = startp endif if not p2 then p2 = pos( '%', LineStr, startp2) --dprintf( 'p2 = 'p2' = pos( %, 'LineStr', 'startp')') if p2 = 0 then leave endif startp2 = p2 + 1 endif LeftPart = substr( LineStr, 1, p1 - 1) VarName = substr( LineStr, p1 + 1, p2 - p1 - 1) RightPart = substr( LineStr, p2 + 1) if VarName = '' then -- Replace %% with % LineStr = LeftPart'%'RightPart startp = p1 + 1 p1 = 0 p2 = 0 iterate endif p3 = pos( upcase( VarName)'=', upcase( VarStr)) if p3 then -- VarName found in VarStr -- Note: Positional parsing doesn't work with (var)s. p4 = p3 + length( VarName'=') rest = substr( VarStr, p4) if leftstr( rest, 1) = '"' then parse value rest with '"'ThisVal'"' else parse value rest with ThisVal . endif LineStr = LeftPart''ThisVal''RightPart startp = p1 + length( ThisVal) p1 = 0 p2 = 0 iterate else -- VarName not found in VarStr ThisVal = Get_Env( VarName) if ThisVal = '' then -- Keep %VarStr% startp = p2 + 1 p1 = 0 p2 = 0 iterate else -- Replace with env var value LineStr = LeftPart''ThisVal''RightPart startp = p1 + length( ThisVal) p1 = 0 p2 = 0 iterate endif endif enddo -- forever -- Replace ?: with boot drive do while pos( '?:', LineStr) > 0 parse value LineStr with LeftPart'?:'RightPart BootDrive = NepmdQuerySysInfo( 'BOOTDRIVE') LineStr = LeftPart''BootDrive''RightPart enddo return LineStr ; --------------------------------------------------------------------------- defproc CreateFileFromTemplate( Filename, TemplateFilename) VarStr = arg( 3) do once = 1 to 1 display -1 -- Disable screen refresh -- Load template 'xcom Edit /d 'EnquoteFileSpec( TemplateFilename) if rc then display 1 leave endif .modify = 0 .autosave = 0 -- Delete the .LONGNAME EA, because name changes call Delete_Ea( '.LONGNAME') -- Delete the EPM.POS EA call Delete_Ea( 'EPM.POS') -- Use a virtual name first to disable datetime check .filename = Filename top .col = 1 -- Get first comment char(s), separated by a space getline LineStr FirstWord = strip( word( LineStr, 1)) 'RemoveNextHeader 'FirstWord bot insertline "" -- Expand vars passed as arg( 3) and env vars do l = 1 to .last getline LineStr, l ExpandedLineStr = ExportConfigExpandVars( LineStr, VarStr) if LineStr <> ExpandedLineStr then replaceline ExpandedLineStr, l .modify = 0 endif enddo display 1 'DiscardChanges' rc = 0 enddo return ; --------------------------------------------------------------------------- ; Remove next comment block from a buffer, starting at cursor line. ; Optional arg is a line comment char or '\*' (for \* ... *\ comments). defc RemoveNextHeader universal infolinerefresh saved_autosave = .autosave .autosave = 0 saved_modify = .modify call NextCmdAltersText() infolinerefresh = 0 cComment = 0 fHeader = 0 CommentChars = strip( arg( 1)) if CommentChars = '' then -- Check comment char on current line LineCommentChars = '; : # %' CommentChars = '' getline LineStr ch1 = leftstr( LineStr, 1) ch2 = leftstr( LineStr, 2) wp = wordpos( ch1, LineCommentChars) if ch2 = '/*' then CommentChars = '/* */' fHeader = 1 elseif wp > 0 then CommentChars = word( LineCommentChars, wp) fHeader = 1 endif endif do l = .line to .last getline LineStr if words( CommentChars) = 2 then w1 = word( CommentChars, 1) w2 = word( CommentChars, 2) if leftstr( LineStr, length( w1)) = w1 then cComment = cComment + 1 fHeader = 1 elseif rightstr( LineStr, length( w2)) = w2 & cComment > 0 then cComment = cComment - 1 endif elseif words( CommentChars) = 1 then if leftstr( LineStr, 1) = CommentChars then cComment = 1 fHeader = 1 else leave endif else leave endif if fHeader then deleteline if .line = .last then leave endif if cComment = 0 then leave endif else if .line = .last then leave endif '+1' iterate endif if not fHeader then leave endif enddo -- Remove following empty line if .last > 0 then getline LineStr if strip( LineStr) = '' then deleteline endif endif infolinerefresh = 1 .autosave = saved_autosave if .modify > saved_modify then .modify = saved_modify + 1 endif ; --------------------------------------------------------------------------- const -- More specific paths must come first, e.g. -- \NEPMD\User\ProgramObjects\Assocs\ before \NEPMD\User\ProgramObjects\ INSERT_EMPTY_LINE_LIST = '\NEPMD\User\Encoding\' || ' \NEPMD\User\ProgramObjects\Assocs\ \NEPMD\User\ProgramObjects\' || ' \NEPMD\User\Colors\Highlighting\ \NEPMD\User\CodingStyle\' || ' \NEPMD\User\Mode\ \NEPMD\User\Spellcheck\Language\' || ' \NEPMD\User\Tags\' defproc MaybeInsertLine( KeyPath, PrevSubPath) universal numcfgkeys SubPath = '' do e = 1 to words( INSERT_EMPTY_LINE_LIST) ExcludePath = word( INSERT_EMPTY_LINE_LIST, e) ExcludeLen = length( ExcludePath) if abbrev( KeyPath, ExcludePath) then -- SubPath is rest after ExcludePath SubPath = substr( KeyPath, length( strip( ExcludePath, 'T', '\')) + 1) --Ensure that SubPath contains at least one sublevel if not pos( '\', strip( SubPath, 'L', '\')) then lp = lastpos( '\', strip( ExcludePath, 'T', '\')) SubPath = substr( KeyPath, lp) endif leave endif enddo if SubPath = '' then -- Use default value: Get SubPath from the 3rd segment on numbsl = 0 rest = KeyPath do while rest <> '' PrevRest = rest parse value rest with '\'next'\'-1 rest if next then numbsl = numbsl + 1 endif if numbsl >= 2 then -- SubPath is 3rd level SubPath = rest --Ensure that SubPath contains at least one sublevel if not pos( '\', strip( SubPath, 'L', '\')) then SubPath = PrevRest endif leave endif enddo endif parse value SubPath with '\'FirstSegment'\' parse value FirstSegment with FirstSegment':' parse value PrevSubPath with '\'PrevFirstSegment'\' parse value PrevFirstSegment with PrevFirstSegment':' if FirstSegment <> PrevFirstSegment then if numcfgkeys > 0 then insertline "" endif endif PrevSubPath = SubPath return PrevSubPath ; --------------------------------------------------------------------------- ; Formats Val with aligned color values if it's a color key. Returns no ; value if Val is not a color value. defproc FormatRgbColor( KeyPath, Val) fValIsRGBColor = 0 OutVal = '' do once = 1 to 1 if words( Val) <> 3 then leave endif parse value Val with Val1 Val2 Val3 . Val1 = strip( Val1) Val2 = strip( Val2) Val3 = strip( Val3) if not IsNum( Val1) then leave elseif not IsNum( Val2) then leave elseif not IsNum( Val3) then leave elseif not pos( '\Colors\', KeyPath) then leave endif fValIsRGBColor = 1 if fValIsRGBColor then OutVal = rightstr( Val1, 3)' 'rightstr( Val2, 3)' 'rightstr( Val3, 3) endif enddo return OutVal ; --------------------------------------------------------------------------- ; For a KeyPath in RegKeys all user-specified key = value pairs are queried. ; Default values are excluded. For writing entries, WriteKeyPathValLine is ; called. defproc ExportNextUserConfigKey( KeyPath) universal nepmd_hini universal numcfgkeys --dprintf( 'ExportNextUserConfigKey( 'KeyPath')') rc = 0 -- Compare with previous KeyPath to avoid infinite recursion LastKeyPath = arg( 2) if KeyPath = LastKeyPath then rc = 13 -- ERROR_INVALID_DATA 'SayError ExportNextUserConfigKey: Error: infinite recursion for: 'KeyPath return endif MainKeyPath = arg( 3) if MainKeyPath = '' then MainKeyPath = KeyPath PrevSubPath = '' endif do once = 1 to 1 -- Query key value, delete keys with default values -- This doesn't find empty values nor empty zero-terminated values. DefaultVal = queryprofile( nepmd_hini, 'RegDefaults', KeyPath) Val = queryprofile( nepmd_hini, 'RegKeys', KeyPath) if Val = '' then -- Val is also empty if KeyPath is a subkey. leave endif if Val = DefaultVal then -- Cleanup same values as default -- Query value to get proper rc. CheckVal = NepmdQueryConfigValue( nepmd_hini, KeyPath) --dprintf( 'NepmdQueryConfigValue( nepmd_hini, 'KeyPath'), rc = 'rc) if rc then -- Ignore errors rc = 0 else call DeleteConfigKey( KeyPath) --dprintf( 'NepmdDeleteConfigValue( 'KeyPath'), rc = 'rc) -- Ignore errors rc = 0 endif leave endif -- Check if KeyPath already exists in export file fFoundInCheckFile = 0 do l = 1 to .last getline CheckLineStr, l parse value CheckLineStr with CheckKey '=' CheckVal CheckKey = strip( CheckKey) CheckVal = strip( CheckVal) if KeyPath = CheckKey then if upcase( CheckVal) <> 'DELETE:' then fFoundInCheckFile = 1 leave endif endif enddo if fFoundInCheckFile then leave endif PrevSubPath = MaybeInsertLine( KeyPath, PrevSubPath) numcfgkeys = numcfgkeys + 1 --dprintf( ' Key found: 'KeyPath' = 'strip( leftstr( translate( Val, '.', \0), 100))) call WriteKeyPathValLine( KeyPath, Val) enddo -- Query subkeys and subcontainers KeyPath = strip( KeyPath, 'T', '\') ContainerList = queryprofile( nepmd_hini, 'RegContainer', KeyPath) --dprintf( ' KeyPath = 'KeyPath', ContainerList = 'translate( ContainerList, '.', \0)) Rest = ContainerList do while Rest <> '' parse value Rest with NextKey \0 Rest -- Process NextKey (recursive call) call ExportNextUserConfigKey( KeyPath'\'NextKey, KeyPath, MainKeyPath) if rc then leave endif enddo return ; --------------------------------------------------------------------------- ; Writes a key = val line to current file, above the current line. defproc WriteKeyPathValLine( KeyPath, Val) MaxLineLen = 500 -- max. 1600 IndentLen = length( KeyPath) + 3 if IndentLen <= 53 then IndentLen = 53 elseif IndentLen <= 65 then IndentLen = 65 elseif IndentLen <= 77 then IndentLen = 77 endif MaxValLen = MaxLineLen - IndentLen ValLineNum = 1 fEnquote = 0 -- Make color values better readable: add indent ColorVal = FormatRgbColor( KeyPath, Val) if ColorVal <> '' then Val = ColorVal else NullPos = pos( \0, Val) if NullPos then fEnquote = 1 elseif length( Val) > MaxValLen then fEnquote = 1 elseif length( Val) > length( strip( Val)) then fEnquote = 1 endif endif if fEnquote then Rest = Val do while length( Rest) -- Escape null chars NullPos = pos( \0, Rest) if NullPos then EscapeRest = Rest Rest = '' do while length( EscapeRest) NullPos = pos( \0, EscapeRest) if NullPos then EscapeNext = leftstr( EscapeRest, NullPos - 1) EscapeRest = substr( EscapeRest, NullPos + 1) if EscapeNext <> '' then Rest = Rest'"'EscapeNext'"\0' else Rest = Rest'\0' endif else EscapeNext = EscapeRest EscapeRest = '' Rest = Rest'"'EscapeNext'"' endif enddo endif if length( Rest) > MaxValLen - 2 then -- Break long lines Val = leftstr( Rest, MaxValLen - 2) Rest = substr( Rest, MaxValLen - 2 + 1) -- Avoid leading quote of Rest that belongs to Val if leftstr( Rest, 1) = '"' & leftstr( Val, 1) = '"' then Val = Val'"' Rest = substr( Rest, 2) endif -- Avoid trailing quote of Val that belongs to Rest if rightstr( Val, 3) = '\0"' & leftstr( Rest, 1) <> '"' then Val = leftstr( Val, length( Val) - 1) Rest = '"'Rest endif -- Avoid to split '\0' if rightstr( Val, 1) = '\' & leftstr( Rest, 1) = '0' then Val = leftstr( Val, length( Val) - 1) Rest = '\0'substr( Rest, 2) endif else Val = Rest Rest = '' endif -- Enquote if not enquoted above if leftstr( Val, 1) <> '"' & leftstr( Val, 2) <> '\0' then Val = '"'Val endif if rightstr( Val, 1) <> '"' & rightstr( Val, 2) <> '\0' then Val = Val'"' endif -- Write Val WriteNextKeyPathValLine( ValLineNum, KeyPath, IndentLen, Val) ValLineNum = ValLineNum + 1 enddo else -- fEnquote -- Write Val WriteNextKeyPathValLine( ValLineNum, KeyPath, IndentLen, Val) endif return ; --------------------------------------------------------------------------- defproc WriteNextKeyPathValLine( ValLineNum, KeyPath, IndentLen, Val) if ValLineNum = 1 then LineStr = leftstr( KeyPath, IndentLen - 3)' = 'Val else LineStr = copies( ' ', IndentLen - 4)'+++ 'Val endif --dprintf( LineStr) insertline LineStr return ; --------------------------------------------------------------------------- defproc ImportUserConfig( UserConfigFile) universal nepmd_hini call NepmdImportUserConfig( nepmd_hini, UserConfigFile) call CreateCodingStyleNameIndex() return defc ImportUserConfig UserConfigFile = arg( 1) if UserConfigFile = '' then 'SelectUserConfig' elseif not Exist( UserConfigFile) then 'SelectUserConfig' else fNepmdConfig = CheckNepmdUserConfig( UserConfigFile) if fNepmdConfig then call ImportUserConfig( UserConfigFile) if rc then 'SayError Configuration file "'UserConfigFile'" could not be imported, rc = 'rc'.' else 'SayError Configuration file "'UserConfigFile'" imported successfully.' endif else 'SayError Error: "'UserConfigFile'" is not an importable file.' endif endif ; --------------------------------------------------------------------------- defproc CheckNepmdUserConfig( UserConfigFile) RetVal = 0 getfileid startfid display -1 do once = 1 to 1 'xcom e /d' UserConfigFile if rc then leave endif getfileid checkfid .visible = 0 FirstLineStr = '' do l = 1 to .last LineStr = strip( textline( l)) -- Ignore comments if leftstr( LineStr, 1) = ';' then iterate -- Ignore empty lines elseif LineStr = '' then iterate endif FirstLineStr = LineStr leave enddo if leftstr( FirstLineStr, 1) = '[' then RetVal = 0 elseif leftstr( FirstLineStr, 7) <> '\NEPMD\' then RetVal = 0 else -- Not a section and starts with '\NEPMD\' RetVal = 1 endif getfileid fid if fid = checkfid then 'Quit' endif pActivateFile( startfid) enddo display 1 return RetVal ; --------------------------------------------------------------------------- defc SelectUserConfig Title = 'Select a user configuration file to import' Cmd = 'ImportUserConfig' FileMask = Get_Env( 'NEPMD_USERDIR')'\bin\*.cfg' 'FileDlg' Title', 'Cmd', 'FileMask ; --------------------------------------------------------------------------- defc DeleteUserSettings if AskOkCancel( 'Delete all user settings?'\n\n || 'Be sure to have them exported before.') then 'DeleteConfigTree \NEPMD\User' endif ; --------------------------------------------------------------------------- defproc QueryConfigKey( KeyPath) universal nepmd_hini if leftstr( KeyPath, 1) <> '\' then --dprintf( 'Error: Unexpected KeyPath arg "'KeyPath'" in QueryConfigKey.') 'SayError Error: Unexpected KeyPath arg "'KeyPath'" in QueryConfigKey.' 'ErrorMsgBox Error in QueryConfigKey,' || 'Unexpected KeyPath arg "'KeyPath'".' return endif KeyPath = AddOptionalPrefix( KeyPath, '\NEPMD') DefaultVal = arg( 2) next = NepmdQueryConfigValue( nepmd_hini, KeyPath) if not rc & next <> '' then return next else return DefaultVal endif defc QueryConfigKey parse arg KeyPath 'SayError' KeyPath' = 'QueryConfigKey( KeyPath)'.' ; --------------------------------------------------------------------------- defproc WriteConfigKey( KeyPath, Val) universal nepmd_hini if leftstr( KeyPath, 1) <> '\' then --dprintf( 'Error: Unexpected KeyPath arg "'KeyPath'" in WriteConfigKey, Val = "'Val'".') 'SayError Error: Unexpected KeyPath arg "'KeyPath'" in WriteConfigKey, Val = "'Val'".' 'ErrorMsgBox Error in WriteConfigKey,' || 'Unexpected KeyPath arg "'KeyPath'", Val = "'Val'".' return endif KeyPath = AddOptionalPrefix( KeyPath, '\NEPMD') -- Compare with old and default value. If equal, don't save. OldVal = NepmdQueryConfigValue( nepmd_hini, KeyPath) DefaultVal = queryprofile( nepmd_hini, 'RegDefaults', KeyPath) if Val = OldVal then -- nop elseif Val = DefaultVal then call NepmdDeleteConfigValue( nepmd_hini, KeyPath) else call NepmdWriteConfigValue( nepmd_hini, KeyPath, Val) endif return defc WriteConfigKey universal nepmd_hini parse arg Args wp = wordpos( 'QUIET', upcase( Args)) fQuiet = (wp > 0) if wp then Args = delword( Args, wp, 1) endif parse value Args with KeyPath Val if not fQuiet then OldVal = NepmdQueryConfigValue( nepmd_hini, KeyPath) DefaultVal = queryprofile( nepmd_hini, 'RegDefaults', KeyPath) endif call WriteConfigKey( KeyPath, Val) if not fQuiet then NewVal = queryprofile( nepmd_hini, 'RegKeys', KeyPath) if NewVal <> OldVal then 'SayError' Val' written to 'KeyPath'.' elseif Val = DefaultVal then 'SayError' Val' not written to 'KeyPath', equal to default value.' elseif Val = OldVal then 'SayError' Val' not written to 'KeyPath', equal to old value.' else 'SayError' Val' not written to 'KeyPath', other reason.' endif endif ; --------------------------------------------------------------------------- defproc DeleteConfigKey( KeyPath) universal nepmd_hini KeyPath = AddOptionalPrefix( KeyPath, '\NEPMD') call NepmdDeleteConfigValue( nepmd_hini, KeyPath) return defc DeleteConfigKey universal nepmd_hini parse arg Args wp = wordpos( 'QUIET', upcase( Args)) fQuiet = (wp > 0) if wp then Args = delword( Args, wp, 1) endif KeyPath = Args if not fQuiet then PrevVal = queryprofile( nepmd_hini, 'RegKeys', KeyPath) endif -- DeleteConfigKey ensures that also RegContainer is cleaned call DeleteConfigKey( KeyPath) if not fQuiet then NewVal = queryprofile( nepmd_hini, 'RegKeys', KeyPath) if PrevVal = '' then 'SayError' KeyPath' not found.' elseif NewVal = '' then 'SayError' KeyPath' deleted.' else 'SayError' KeyPath' not deleted.' endif endif ; --------------------------------------------------------------------------- defc DeleteRegDefaults universal nepmd_hini call setprofile( nepmd_hini, 'RegDefaults', '', '') 'SayError DeleteRegDefaults: rc = 'rc ; --------------------------------------------------------------------------- defproc QueryModeKey( Mode, Key) universal nepmd_hini PathPrefix = '\NEPMD\User\Mode' Mode = upcase( Mode) parse value Mode with Mode ':' Ext if Mode = '' then Mode = GetMode() endif Key = SettingCase( Key) -- This corrects the case for all load and select settings KeyPath = PathPrefix'\'Mode'\'Key if Ext <> '' then KeyPath = PathPrefix'\'Mode':'Ext'\'Key endif -- Query DEFAULT pseudo mode DefaultKeyPath = PathPrefix'\DEFAULT\'Key DefaultValue = QueryConfigKey( DefaultKeyPath) -- Use specifed optional value as fallback if DefaultValue = '' then DefaultValue = arg( 3) endif -- Query config key next = QueryConfigKey( KeyPath) SavedVal = queryprofile( nepmd_hini, 'RegKeys', KeyPath) if not rc & (next <> '' | SavedVal = 'NONE:') then return next else return DefaultValue endif ; --------------------------------------------------------------------------- defproc WriteModeKey( Mode, Key, Val) PathPrefix = '\NEPMD\User\Mode' Mode = upcase( Mode) parse value Mode with Mode ':' Ext if Mode = '' then Mode = GetMode() endif Key = SettingCase( Key) -- This corrects the case for all load and select settings KeyPath = PathPrefix'\'Mode'\'Key if Ext <> '' then KeyPath = PathPrefix'\'Mode':'Ext'\'Key endif if Val = '' then Val = 'NONE:' endif WriteConfigKey( KeyPath, Val) return ; --------------------------------------------------------------------------- defproc DeleteModeKey( Mode, Key) PathPrefix = '\NEPMD\User\Mode' Mode = upcase( Mode) parse value Mode with Mode ':' Ext if Mode = '' then Mode = GetMode() endif Key = SettingCase( Key) -- This corrects the case for all load and select settings KeyPath = PathPrefix'\'Mode'\'Key if Ext <> '' then KeyPath = PathPrefix'\'Mode':'Ext'\'Key endif DeleteConfigKey( KeyPath) return ; --------------------------------------------------------------------------- defproc GetExpandModes ExpandModeList = '' ModeList = NepmdQueryModeList() do w = 1 to words( ModeList) ThisMode = word( ModeList, w) if isadefproc( ThisMode'FirstExpansion') then if ExpandModeList <> '' then ExpandModeList = ExpandModeList' ' endif ExpandModeList = ExpandModeList''ThisMode endif enddo return ExpandModeList ; --------------------------------------------------------------------------- defproc GetCodingStyleModes CSModeList = '' UserKeyPath = '\NEPMD\User\CodingStyle' Handle = HINI_NEPMDPROFILE -- Find all user coding styles KeyPath = UserKeyPath SearchOption = 'C' NextNum = '' do while NepmdGetNextConfigKey( Handle, KeyPath, SearchOption, NextNum) if not IsNum( NextNum) then iterate endif -- Query modes NextModes = QueryConfigKey( KeyPath'\'NextNum'\Modes') if NextModes <> '' then -- Append to CSModeList if CSModeList <> '' then CSModeList = CSModeList' ' endif CSModeList = CSModeList''NextModes endif enddo -- Find all default coding styles ProfileApp = 'RegDefaults' Filter = UserKeyPath NextKeyPath = '' do while NepmdGetNextProfileKey( Handle, ProfileApp, Filter, NextKeyPath) parse value NextKeyPath with (UserKeyPath)'\'NextNum'\'NextKey if not IsNum( NextNum) then iterate endif if NextKey <> 'Modes' then iterate endif -- Query modes NextModes = NepmdQueryConfigValue( Handle, NextKeyPath) if NextModes <> '' then -- Append to CSModeList if CSModeList <> '' then CSModeList = CSModeList' ' endif CSModeList = CSModeList''NextModes endif enddo -- Sort CSMModeList in the same order as mode list returned by -- NepmdQueryModeList SavedCSModeList = upcase( CSModeList) CSModeList = '' ModeList = NepmdQueryModeList() do w = 1 to words( ModeList) ThisMode = word( ModeList, w) if wordpos( ThisMode, SavedCSModeList) then -- Append to CSModeList if CSModeList <> '' then CSModeList = CSModeList' ' endif CSModeList = CSModeList''ThisMode endif enddo return CSModeList ; --------------------------------------------------------------------------- defproc QueryCodingStyleKey( CodingStyle, Key) do once = 1 to 1 Val = '' -- Query coding style name if CodingStyle = '' then CodingStyle = GetCodingStyle() endif if CodingStyle = '' then leave endif -- Query coding style number -- This is written on import, because keys present in RegDefaults only -- don't support to query available ones. This is different from user -- keys of RegKeys, where RegContainer is written additionally. KeyPath = '\NEPMD\Var\CodingStyle\'lowcase( CodingStyle)'\Number' CodingStyleNum = QueryConfigKey( KeyPath) if CodingStyleNum = '' then leave endif -- Query coding style key KeyPath = '\NEPMD\User\CodingStyle\'CodingStyleNum'\'Key Val = QueryConfigKey( KeyPath) enddo return Val ; --------------------------------------------------------------------------- defproc WriteCodingStyleKey( CodingStyle, Key, Val) do once = 1 to 1 -- Query coding style name if CodingStyle = '' then CodingStyle = GetCodingStyle() endif if CodingStyle = '' then leave endif -- Query coding style number -- This is written on import, because keys present in RegDefaults only -- don't support to query available ones. This is different from user -- keys of RegKeys, where RegContainer is written additionally. KeyPath = '\NEPMD\Var\CodingStyle\'lowcase( CodingStyle)'\Number' CodingStyleNum = QueryConfigKey( KeyPath) if CodingStyleNum = '' then leave endif -- Write coding style key KeyPath = '\NEPMD\User\CodingStyle\'CodingStyleNum'\'Key call WriteConfigKey( KeyPath, Val) enddo return ; --------------------------------------------------------------------------- defproc QueryModeExpandKey( ExpandMode, Key) do once = 1 to 1 Val = '' if ExpandMode = '' then ExpandMode = GetExpandMode() endif if ExpandMode = '' then leave endif DefaultVal = arg( 3) fOverride = (QueryModeKey( ExpandMode, 'Expand\Override'Key) = 1) Val = '' if not fOverride then Val = QueryCodingStyleKey( '', Key) endif if Val = '' then Val = QueryModeKey( ExpandMode, 'Expand\'Key) endif if Val = '' then if DefaultVal <> '' then Val = QueryModeKey( ExpandMode, 'Expand\'Key, DefaultVal) endif endif enddo return Val ; --------------------------------------------------------------------------- defproc WriteModeExpandKey( ExpandMode, Key, Val) do once = 1 to 1 if ExpandMode = '' then ExpandMode = GetExpandMode() endif if ExpandMode = '' then leave endif call WriteModeKey( ExpandMode, 'Expand\'Key, Val) enddo return ; --------------------------------------------------------------------------- defproc DeleteModeExpandKey( ExpandMode, Key) do once = 1 to 1 if ExpandMode = '' then ExpandMode = GetExpandMode() endif if ExpandMode = '' then leave endif call DeleteModeKey( ExpandMode, 'Expand\'Key) enddo return ; --------------------------------------------------------------------------- defproc QueryModeFindDefKey( Mode, Key) DefaultVal = arg( 3) Val = QueryModeKey( Mode, 'FindDef\'Key) if Val = '' then if DefaultVal <> '' then Val = QueryModeKey( Mode, 'FindDef\'Key, DefaultVal) endif endif return Val ; --------------------------------------------------------------------------- defproc WriteModeFindDefKey( Mode, Key, Val) call WriteModeKey( Mode, 'FindDef\'Key, Val) return ; --------------------------------------------------------------------------- ; For debugging: remove all mode keys from NEPMD.INI. defc DelAllModeKeys call DeleteConfigTree( '\NEPMD\User\Mode') 'SayError Settings for all modes deleted.' ; --------------------------------------------------------------------------- defproc FileChanged( Fullname) universal nepmd_hini do once = 1 to 1 fChanged = 0 if not Exist( Fullname) then fChanged = 1 endif KeyPath = arg( 2) if KeyPath = '' then KeyPath = '\NEPMD\Var\FileChanged' endif -- Search Fullname in config and get DateTimeSize ThisFilename = '' ThisDateTimeSize = '' ThisKeyPath1 = '' ThisKeyPath2 = '' SearchOption = 'C' NextNum = '' do while NepmdGetNextConfigKey( nepmd_hini, KeyPath, SearchOption, NextNum) ThisFilename = QueryConfigKey( KeyPath'\'NextNum'\Filename') if lowcase( ThisFilename) = lowcase( Fullname) then ThisKeyPath1 = KeyPath'\'NextNum'\Filename' ThisKeyPath2 = KeyPath'\'NextNum'\DateTimeSize' ThisDateTimeSize = QueryConfigKey( ThisKeyPath2) leave endif enddo if ThisDateTimeSize = '' then leave endif -- Get DateTimeSize of current file FileDateTimeSize = NepmdQueryPathInfo( Fullname, 'MTIME') || ' 'NepmdQueryPathInfo( Fullname, 'SIZE') -- Compare if FileDateTimeSize <> ThisDateTimeSize then fChanged = 1 WriteConfigKey( ThisKeyPath1, Fullname) WriteConfigKey( ThisKeyPath2, FileDateTimeSize) endif enddo return fChanged ; --------------------------------------------------------------------------- defproc IsExFileInternal( ExFile) RootDir = Get_Env( 'NEPMD_ROOTDIR') UserDir = Get_Env( 'NEPMD_USERDIR') ExFileName = lowcase( GetFileSpec( 'N', ExFile)) if ExFileName = 'mystuff.ex' then fInternal = 1 elseif Exist( RootDir'\netlabs\ex\'ExFilename) then fInternal = 1 elseif Exist( UserDir'\autolink\'ExFilename) then fInternal = 1 elseif EFileFoundInListFile( ExFile, GetUserNetlabsFile( 'exfiles.lst', 'ex')) then fInternal = 1 elseif EFileFoundInListFile( ExFile, GetUserNetlabsFile( 'actions.lst', 'ex')) then fInternal = 1 elseif EFileFoundInListFile( ExFile, 'macroadd.lst') then fInternal = 1 elseif EFileFoundInListFile( ExFile, 'autolink.lst') then fInternal = 1 else fInternal = 0 endif return fInternal ; --------------------------------------------------------------------------- ; EFile may be an .e name or a basename or a fully-qualified filename. ; Instead of .e also an .ex name can be used. defproc EFileFoundInListFile( EFile, ListFile) do once = 1 to 1 fFound = 0 NepmdUserDir = Get_Env( 'NEPMD_USERDIR') NepmdRootDir = Get_Env( 'NEPMD_ROOTDIR') ListFile = lowcase( GetFileSpec( 'N', ListFile)) if ListFile = 'macroadd.lst' then Fullname = NepmdUserDir'\ex\'ListFile elseif ListFile = 'autolink.lst' then Fullname = NepmdUserDir'\autolink\'ListFile elseif wordpos( ListFile, 'exfiles.lst actions.lst') then Fullname = GetUserNetlabsFile( ListFile, 'ex') else 'SayError Unknown ListFile "'ListFile'" specified.' endif if not Exist( Fullname) then leave endif KeyPath = '\NEPMD\Var\ListFile\'ListFile EntriesKeyPath = KeyPath'\Entries' -- Check if saved entries in config are up-to-date. -- If not, then resan ListFile and renew entries in config do once2 = 1 to 1 -- Get FileDateTimeSize from config KeyPath1 = KeyPath'\DateTimeSize' SavedDateTimeSize = QueryConfigKey( KeyPath1) -- Get DateTimeSize of current file FileDateTimeSize = NepmdQueryPathInfo( Fullname, 'MTIME') || ' 'NepmdQueryPathInfo( Fullname, 'SIZE') -- Compare if FileDateTimeSize = SavedDateTimeSize then leave endif -- Read ListFile and write entries to config display -2 getfileid startfid -- Load ListFile 'xcom e /d' Fullname if rc <> 0 then leave endif getfileid listfid .visible = 0 -- Delete old entries DeleteConfigTree( EntriesKeyPath) -- Read lines f = 0 do l = 1 to .last LineStr = textline( l) StrippedLineStr = strip( LineStr) -- Ignore comments, lines starting with ';' at column 1 are comments if substr( LineStr, 1, 1) = ';' then iterate -- Ignore empty lines elseif StrippedLineStr = '' then iterate endif EFile = StrippedLineStr -- Either a basename or a full .e filename EFile = StripQuotesFileSpec( EFile) -- Write entry to config f = f + 1 WriteConfigKey( EntriesKeyPath'\'f, EFile) enddo -- l -- Quit ListFile activatefile listfid .modify = 0 'xcom q' pActivateFile( startfid) display 2 -- Save DateTimeSize for next comparison WriteConfigKey( KeyPath1, FileDateTimeSize) enddo -- once2 -- Search EFile in config entries -- Allow for extension 'ex' instaed of 'e' if lowcase( GetFileSpec( 'E', EFile)) = 'ex' then EFile = ChangeExt( EFile, 'e') endif EFilename = lowcase( GetFileSpec( 'N', EFile)) EFileBasename = lowcase( GetFileSpec( 'B', EFile)) SearchOption = 'K' NextNum = '' do while NepmdGetNextConfigKey( -3, EntriesKeyPath, SearchOption, NextNum) if not IsNum( NextNum) then iterate endif NextEntry = QueryConfigKey( EntriesKeyPath'\'NextNum) NextEntryName = lowcase( GetFileSpec( 'N', NextEntry)) if EFilename = NextEntryName | EFileBasename = NextEntryName then fFound = 1 leave endif enddo enddo -- once return fFound ; --------------------------------------------------------------------------- defproc DeleteObsoleteCsKeys CodingStyleModes = 'C JAVA REXX' NumDeleted = 0 do w = 1 to words( CodingStyleModes) ThisMode = word( CodingStyleModes, w) ModeKeyPath = '\NEPMD\User\Mode\'ThisMode Handle = -3 SearchOptions = 'K' NextKey = '' FoundKeys = '' -- Deletion requires to query the keys first do while NepmdGetNextConfigKey( Handle, ModeKeyPath, SearchOptions, NextKey) FoundKeys = FoundKeys''NextKey''\0 enddo RestKeys = FoundKeys do while RestKeys parse value RestKeys with NextKey \0 RestKeys Val = QueryModeKey( ThisMode, NextKey) if rightstr( Val, 5) == ' (cs)' | Val = '' then DeleteModeKey( ThisMode, NextKey) NumDeleted = NumDeleted + 1 endif enddo enddo return NumDeleted ; --------------------------------------------------------------------------- defc DeleteObsoleteCsKeys NumDeleted = DeleteObsoleteCsKeys() 'SayError 'NumDeleted' key(s) deleted.' ; --------------------------------------------------------------------------- defc RenameSpellcheckKeys universal nepmd_hini KeyPathPrefix = '\NEPMD\User\Spellcheck\Language' NameList = queryprofile( nepmd_hini, 'RegContainer', KeyPathPrefix) SelectedName = QueryConfigKey( '\NEPMD\User\Spellcheck\SelectedLanguage') SelectedVal = QueryConfigKey( KeyPathPrefix'\Selected') SelectedNum = 1 -- default value OrderVal = QueryConfigKey( KeyPathPrefix'\Order') OrderString = OrderVal rest = NameList fConverted = 0 n = 0 do forever if rest = '' then leave endif parse value rest with next \0 rest if next = '' then iterate -- Check if already converted and ignore new key names elseif IsNum( next) | next = 'Order' | next = 'Selected' then iterate endif n = n + 1 -- Find the next free key number KeyNum = n -- default value c = 0 do forever c = c + 1 if not wordpos( c, OrderString) then KeyNum = c OrderString = strip( OrderString KeyNum) leave endif enddo -- Rename tree from name to num and add Name key NameVal = next OldKeyPath = KeyPathPrefix'\'NameVal NewKeyPath = KeyPathPrefix'\'KeyNum if strip( queryprofile( nepmd_hini, 'RegContainer', OldKeyPath), 'B', \0) then if strip( queryprofile( nepmd_hini, 'RegContainer', NewKeyPath), 'B', \0) then call DeleteConfigTree( OldKeyPath) else call RenameConfigTree( OldKeyPath, NewKeyPath) fConverted = 1 call WriteConfigKey( NewKeyPath'\Name', NameVal) endif endif if NameVal = SelectedName then SelectedNum = KeyNum endif enddo if fConverted then -- Add/change Order key if OrderString <> OrderVal then call WriteConfigKey( KeyPathPrefix'\Order', OrderString) endif -- Add/change Selected key if SelectedNum <> SelectedVal then call WriteConfigKey( KeyPathPrefix'\Selected', SelectedNum) endif endif -- Delete old SelectedLanguage key call DeleteConfigKey( '\NEPMD\User\Spellcheck\SelectedLanguage') ; --------------------------------------------------------------------------- defc RenameMouseStyleKey universal nepmd_hini OldKeyPath = '\NEPMD\User\Mark\MouseStyle' NewKeyPath = '\NEPMD\User\Mark\DefaultMouseMark' if strip( queryprofile( nepmd_hini, 'RegContainer', OldKeyPath), 'B', \0) then if strip( queryprofile( nepmd_hini, 'RegContainer', NewKeyPath), 'B', \0) then call DeleteConfigTree( OldKeyPath) else -- Rename the value MouseStyle = queryprofile( nepmd_hini, 'RegKeys', OldKeyPath) if MouseStyle <> '' then Val = 'C' if MouseStyle <> 2 then Val = 'B' endif call setprofile( nepmd_hini, 'RegKeys', OldKeyPath, Val) endif -- Rename the key call RenameConfigTree( OldKeyPath, NewKeyPath) endif endif ; --------------------------------------------------------------------------- ; This command collects config key changes in the NEPMD config repository ; of NEPMD.INI from version 1.00 on. It's exectued once after install by ; main2 of MAIN.E, if JustInstalled = 1. It can also be executed manually ; and multiple times. defc CleanUpConfigKeys universal numcfgkeys universal nepmd_hini numcfgkeys = 0 call DeleteConfigTree( '\NEPMD\User\GrepVersion') call DeleteConfigTree( '\NEPMD\User\LastStuff') call DeleteConfigTree( '\NEPMD\User\Mark\MouseStyle') call DeleteConfigTree( '\NEPMD\User\Mark\AdvancedMarking') call DeleteConfigTree( '\NEPMD\User\Mark\CuaMarking') call DeleteConfigTree( '\NEPMD\User\Mouse\Mark\Workaround') call DeleteConfigTree( '\NEPMD\User\Mouse\Url\Browser') call DeleteConfigTree( '\NEPMD\User\Reflow\Margins1') call DeleteConfigTree( '\NEPMD\User\Reflow\Margins\1') call DeleteConfigTree( '\NEPMD\User\Search\LastFindDefButton') call DeleteConfigTree( '\NEPMD\User\Search\LastSearchArgs') call DeleteConfigTree( '\NEPMD\User\Search\LastChangeArgs') call DeleteConfigTree( '\NEPMD\User\Search\AddSearchChangeOptions') call DeleteConfigTree( '\NEPMD\User\Search\Files') call DeleteConfigTree( '\NEPMD\User\Shell\Start\Quiet') call DeleteConfigTree( '\NEPMD\User\Tools\Grep\Version') call DeleteConfigTree( '\NEPMD\User\Tools\md5') call DeleteConfigTree( '\NEPMD\Var\Mode') call DeleteConfigTree( '\NEPMD\Var\Search\LastFindDefButton') call DeleteConfigTree( '\NEPMD\Var\Search\LastSearchDialogOptions') call DeleteConfigTree( '\NEPMD\Var\Search\LastSearchArgs') call DeleteConfigTree( '\NEPMD\Var\Search\AddSearchChangeOptions') call DeleteConfigTree( '\NEPMD\Var\CodingStyles') NumDeleted = DeleteObsoleteCsKeys() numcfgkeys = numcfgkeys + NumDeleted SavedNum = numcfgkeys -- Don't count the following: call DeleteConfigTree( '\NEPMD\System\ExFiles') call DeleteConfigTree( '\NEPMD\Var\ExFiles') call DeleteConfigTree( '\NEPMD\Var\VersionCheck\CheckDateTime') -- Ensure that VersionCheck is newly executed after install call setprofile( nepmd_hini, 'Install', 'UserCfgJustImported', '') numcfgkeys = SavedNum -- If OldKeyPath exists and NewKeyPath doesn't: rename, if both exist: delete OldKeyPath call RenameDeleteConfigTree( '\NEPMD\User\History\Edit', '\NEPMD\Var\History\Edit') call RenameDeleteConfigTree( '\NEPMD\User\History\Load', '\NEPMD\Var\History\Load') call RenameDeleteConfigTree( '\NEPMD\User\History\Save', '\NEPMD\Var\History\Save') 'ConvertHistory' call RenameDeleteConfigTree( '\NEPMD\User\Balance', '\NEPMD\User\SpecialKeys\MatchFindOpening') call RenameDeleteConfigTree( '\NEPMD\User\CursorPos\ScrollAfterLocate', '\NEPMD\User\CursorPos\ScrollAfterSearch') call RenameDeleteConfigTree( '\NEPMD\User\InfoLine\Sep', '\NEPMD\User\Appearance\InfoLine\Sep') call RenameDeleteConfigTree( '\NEPMD\User\InfoLine\StatusFields', '\NEPMD\User\Appearance\InfoLine\Status\Template') call RenameDeleteConfigTree( '\NEPMD\User\InfoLine\TitleFields', '\NEPMD\User\Appearance\InfoLine\Title\Template') call RenameDeleteConfigTree( '\NEPMD\User\Keys\AccelKeys\BlockLeftAltKey', '\NEPMD\User\SpecialKeys\Alt\BlockLeftAlt') call RenameDeleteConfigTree( '\NEPMD\User\Keys\AccelKeys\BlockRightAltKey', '\NEPMD\User\SpecialKeys\Alt\BlockRightAlt') call RenameDeleteConfigTree( '\NEPMD\User\Keys\AddKeyDefs\List', '\NEPMD\User\Keysets\AddKeyDefs\List') call RenameDeleteConfigTree( '\NEPMD\User\Keys\AddKeyDefs\Selected', '\NEPMD\User\Keysets\AddKeyDefs\Selected') call RenameDeleteConfigTree( '\NEPMD\User\Keys\Tab\MatchTab', '\NEPMD\User\SpecialKeys\Tab\MatchWordsAbove') call RenameDeleteConfigTree( '\NEPMD\User\Keys\Tab\TabGlyph', '\NEPMD\User\SpecialKeys\Tab\ShowTabs') call RenameDeleteConfigTree( '\NEPMD\User\Mark\ShiftMarkExtends', '\NEPMD\User\Mark\ShiftMarkAlwaysExtends') call RenameDeleteConfigTree( '\NEPMD\User\MatchChars', '\NEPMD\User\SpecialKeys\MatchInsertPair') call RenameDeleteConfigTree( '\NEPMD\User\Reflow\Margins2', '\NEPMD\User\Reflow\Margins\2') call RenameDeleteConfigTree( '\NEPMD\User\Reflow\MarginsItem', '\NEPMD\User\Reflow\Margins\Selected') call RenameDeleteConfigTree( '\NEPMD\User\SavedRings', '\NEPMD\Var\SavedRings') call RenameDeleteConfigTree( '\NEPMD\User\Scroll\AfterLocate', '\NEPMD\User\CursorPos\ScrollAfterSearch') call RenameDeleteConfigTree( '\NEPMD\User\Scroll\CursorEverywhere', '\NEPMD\User\CursorPos\CursorEverywhere') call RenameDeleteConfigTree( '\NEPMD\User\Scroll\KeepCursorOnScreen', '\NEPMD\User\CursorPos\KeepCursorOnScreen') call DeleteConfigTree( '\NEPMD\User\Format\Reflow\KeepIndented') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\TwoSpaces', '\NEPMD\User\Mode\TEXT\Reflow\TwoSpaces') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\Margins\Selected', '\NEPMD\User\Mode\TEXT\Reflow\Margins\Selected') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\Margins\2', '\NEPMD\User\Mode\TEXT\Reflow\Margins\2') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\ReflowLists', '\NEPMD\User\Mode\TEXT\Reflow\Mail\Lists') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\ListBulletWords', '\NEPMD\User\Mode\TEXT\Reflow\Mail\Lists\BulletWords') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\ListAddNumberWords', '\NEPMD\User\Mode\TEXT\Reflow\Mail\Lists\NumericSepWords') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\ListNumberAppendWords', '\NEPMD\User\Mode\TEXT\Reflow\Mail\Lists\NumericEndWords') call RenameDeleteConfigTree( '\NEPMD\User\Format\Reflow\MailFixFalseReplyLevels', '\NEPMD\User\Mode\TEXT\Reflow\Mail\FixFalseReplyLevels') 'RenameSpellCheckKeys' 'RenameMouseStyleKey' if numcfgkeys > 0 then 'SayError Updated old config keys in NEPMD.INI:' numcfgkeys 'key(s) converted.' endif