Skip to content

Modify the configuration redirection mode #1086

@Mapaler

Description

@Mapaler

The extension of #1069 (comment)

Can we refer to the approach of Total Commander in this regard, using redirection to split the ini?

This allows for the separation of roaming configuration and local configuration.

It can also be used to control which configurations remain consistent and which ones differ in a multi-user environment.

For example, the following excerpt

[Layout]
BreadCrumbBar=1
CmdLine=1
CurDir=1
DirectoryTabs=1
DriveBar1=1
DriveBar2=1
DriveBarFlat=1
DriveCombo=0
HistoryHotlistButtons=1
InterfaceFlat=1
KeyButtons=1
StatusBar=1
TabHeader=1
XPthemeBg=1
[Associations]
RedirectSection=%COMMANDER_PATH%\User\User.ini
[Command line history]
RedirectSection=%COMMANDER_PATH%\User\History.ini
[SplitPerFile]
RedirectSection=%COMMANDER_PATH%\User\History.ini
[SyncOptions]
RedirectSection=%COMMANDER_PATH%\User\User.ini
[USER]
RedirectSection=%COMMANDER_PATH%\User\User.ini

If there is a RedirectSection value encountered during the section, redirect to another ini file.

Some pseudocode

function ReadIni(filePath, section, key) {
	let redirectPath = Win32ApiGetIni(filePath, section, "RedirectSection");
	if (redirectPath) {
		// recursion
		return ReadIni(ResolvePath(redirectPath), section, key);
	} else {
		return Win32ApiGetIni(filePath, section, key);
	}
}

function Win32ApiGetIni(filePath, section, key) {
	let retVal = "";
	GetPrivateProfileString(filePath, section, "", retVal, 0xFF, key);
	return retVal;
}
function ResolvePath(filePath) {
	let resolveedPath = filePath;
	resolveedPath = resolveedPath.replace("%COMMANDER_PATH%", thisApp.exePath);
	resolveedPath = Win32ApiGetFullPathName(resolveedPath);
	return filePath;
}

The initial INI file can be redirected according to the following priority:
  1. If.\Notepad4.ini exists, the application runs directly in portable mode.
  2. Per-user configuration (customizable by the individual user):
[HKEY_CURRENT_USER\SOFTWARE\zufuliu\Notepad4]
IniFileName=%AppData%\zufuliu\Notepad4\Notepad4.ini
  1. System-wide default configuration (set by the administrator):
[HKEY_LOCAL_MACHINE\SOFTWARE\zufuliu\Notepad4]
IniFileName= %ProgramData%\zufuliu\Notepad4\Notepad4.ini

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions