Compare commits

...
5 changed files with 470 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ add_custom_target(check-files-quick-view
DEPENDS KSwitcherFiles
VERBATIM)
target_include_directories(KSwitcherFiles PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/build/terminal-deps/sdk/build/native/include")
target_link_libraries(KSwitcherFiles PRIVATE user32 gdi32 comctl32 shell32 comdlg32 advapi32 ole32 uuid wininet netapi32 mpr KSwitcherFilesImage libssh2::libssh2)
target_link_libraries(KSwitcherFiles PRIVATE user32 gdi32 comctl32 shell32 comdlg32 advapi32 ole32 uuid wininet netapi32 mpr userenv KSwitcherFilesImage libssh2::libssh2)
if(MSVC)
target_compile_options(KSwitcherFiles PRIVATE /utf-8)
else()
+9
View File
@@ -786,6 +786,15 @@ Warning і початковий фокус на No.
**commit.gpgSign** і налаштований засіб підписування. Git hooks для
цих операцій Files вимкнено. Для комітів із hooks або інтерактивним
підписуванням використовуй Git у терміналі.
- **F9 → Commands → Environment Variables** показує області **User**,
**System** і **Process**, джерело, сире та розгорнуте значення.
Process показує середовище поточного процесу Files лише для читання.
**Edit** зберігає тип реєстрового значення. **Copy to User** і
**Copy to System** переносять сире значення та його тип і запитують
підтвердження, якщо визначення існує. Якщо значення змінилося після
відкриття діалогу або Windows відмовила в доступі, Files показує причину.
Запущені сеанси PowerShell зберігають своє середовище. Після зміни
перезапусти Files, щоб вбудований PowerShell успадкував нові значення.
- Короткі червоні повідомлення використовують звичайний текст без смуги прокрутки. Висота діалогу залежить від кількості рядків повідомлення.
- Для однорядкових полів Far використовуй спільний компонент `FAR_EDIT` і спільну підготовку та палітру діалогів. Компонент використовує нативний Win32 Edit без рамки й центрує текст вертикально. Його використовують Search, Copy/Rename, Title/Path і пошук в історії. Кольори Text і Popup background діють на всі ці поля, зокрема на поле Copy лише для читання. У відповідних розділах Options → Colors зміни видно на зразку поля. Existing files у Copy є списком без редагування. Поля та редагований список Windows Options мають системне оформлення.
- Для позиціонування роздільника використовуй невидимий маркер, якщо межу не задає інший елемент секції. Спільний обробник малює лінію.
+36
View File
@@ -635,3 +635,39 @@ BEGIN
CONTROL "&Commit", IDOK, "Button", BS_OWNERDRAW | WS_TABSTOP, 125, 193, 80, 17
CONTROL "&Cancel", IDCANCEL, "Button", BS_OWNERDRAW | WS_TABSTOP, 215, 193, 80, 17
END
127 DIALOGEX 0, 0, 458, 224
STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN
CAPTION "Environment Variables"
FONT 10, "Consolas"
BEGIN
LTEXT "&Scope", 610, 16, 16, 58, 13
COMBOBOX 611, 77, 15, 120, 75, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | WS_TABSTOP
LTEXT "", 613, 16, 34, 426, 13, SS_PATHELLIPSIS | SS_NOPREFIX
LISTBOX 612, 16, 50, 172, 119, LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_TABSTOP
LTEXT "", 614, 197, 50, 245, 13, SS_ENDELLIPSIS | SS_NOPREFIX
LTEXT "Ra&w value", 620, 197, 66, 245, 13
EDITTEXT 615, 197, 80, 245, 30, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY
LTEXT "E&xpanded value", 621, 197, 115, 245, 13
EDITTEXT 616, 197, 129, 245, 39, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY
LTEXT "", 617, 16, 174, 426, 24, SS_NOPREFIX
LTEXT "", 618, 10, 199, 1, 1, NOT WS_VISIBLE
CONTROL "&Edit", 622, "Button", BS_OWNERDRAW | WS_TABSTOP, 27, 204, 59, 15
CONTROL "Copy to &User", 623, "Button", BS_OWNERDRAW | WS_TABSTOP, 89, 204, 89, 15
CONTROL "Cop&y to System", 624, "Button", BS_OWNERDRAW | WS_TABSTOP, 181, 204, 100, 15
CONTROL "&Refresh", 625, "Button", BS_OWNERDRAW | WS_TABSTOP, 285, 204, 66, 15
CONTROL "&Close", IDOK, "Button", BS_OWNERDRAW | WS_TABSTOP, 354, 204, 65, 15
END
128 DIALOGEX 0, 0, 366, 122
STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN
CAPTION "Edit environment definition"
FONT 10, "Consolas"
BEGIN
LTEXT "", 630, 16, 16, 334, 13, SS_ENDELLIPSIS | SS_NOPREFIX
LTEXT "Ra&w value", 631, 16, 33, 334, 13
EDITTEXT 632, 16, 47, 334, 42, ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN
LTEXT "", 633, 10, 94, 1, 1, NOT WS_VISIBLE
CONTROL "&Save", IDOK, "Button", BS_OWNERDRAW | WS_TABSTOP, 102, 100, 78, 16
CONTROL "&Cancel", IDCANCEL, "Button", BS_OWNERDRAW | WS_TABSTOP, 186, 100, 78, 16
END
+418
View File
@@ -0,0 +1,418 @@
enum class EnvironmentScope { user, system, process };
constexpr wchar_t userEnvironmentPath[]=L"Environment";
constexpr wchar_t systemEnvironmentPath[]=L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
constexpr unsigned environmentValueLimit=32767;
const wchar_t *environmentScopeName(EnvironmentScope scope)
{
switch(scope)
{
case EnvironmentScope::user: return L"User";
case EnvironmentScope::system: return L"System";
case EnvironmentScope::process: return L"Process";
}
return L"";
}
std::wstring environmentSource(EnvironmentScope scope)
{
if(scope==EnvironmentScope::process) return L"Current KSwitcher.Files process";
return scope==EnvironmentScope::user?L"HKCU\\"+std::wstring(userEnvironmentPath):
L"HKLM\\"+std::wstring(systemEnvironmentPath);
}
struct EnvironmentKey
{
HKEY value{};
explicit EnvironmentKey(EnvironmentScope scope,bool write=false)
{
const bool user=scope==EnvironmentScope::user;
const auto root=user?HKEY_CURRENT_USER:HKEY_LOCAL_MACHINE;
const auto path=user?userEnvironmentPath:systemEnvironmentPath;
const auto access=KEY_QUERY_VALUE|(write?KEY_SET_VALUE:0);
const auto result=user && write?
RegCreateKeyExW(root,path,0,nullptr,0,access,nullptr,&value,nullptr):
RegOpenKeyExW(root,path,0,access,&value);
if(result!=ERROR_SUCCESS && (result!=ERROR_FILE_NOT_FOUND || !user || write))
throw std::system_error(result,std::system_category(),"Open the environment registry key");
}
EnvironmentKey(const EnvironmentKey &)=delete;
~EnvironmentKey(){if(value) RegCloseKey(value);}
};
struct EnvironmentValue
{
DWORD type{};
std::wstring text;
bool supported{};
bool operator==(const EnvironmentValue &) const = default;
};
struct EnvironmentVariable
{
std::wstring name;
EnvironmentValue value;
};
std::optional<EnvironmentValue> readEnvironmentValue(HKEY key,const std::wstring &name)
{
if(!key) return {};
DWORD size{},type{};
auto result=RegQueryValueExW(key,name.c_str(),nullptr,&type,nullptr,&size);
if(result==ERROR_FILE_NOT_FOUND) return {};
if(result!=ERROR_SUCCESS) throw std::system_error(result,std::system_category(),"Read the environment definition");
for(int attempt=0;attempt<4;++attempt)
{
if(type!=REG_SZ && type!=REG_EXPAND_SZ) return EnvironmentValue{type,{},false};
if(size%sizeof(wchar_t) || size>2*(environmentValueLimit+1))
return EnvironmentValue{type,{},false};
std::wstring text(size/sizeof(wchar_t)+1,L'\0');
result=RegQueryValueExW(key,name.c_str(),nullptr,&type,reinterpret_cast<BYTE*>(text.data()),&size);
if(result==ERROR_FILE_NOT_FOUND) return {};
if(result==ERROR_MORE_DATA) continue;
if(result!=ERROR_SUCCESS) throw std::system_error(result,std::system_category(),"Read the environment definition");
if((type!=REG_SZ && type!=REG_EXPAND_SZ) || size%sizeof(wchar_t))
return EnvironmentValue{type,{},false};
text.resize(size/sizeof(wchar_t));
while(!text.empty() && text.back()==L'\0') text.pop_back();
if(text.find(L'\0')!=text.npos) return EnvironmentValue{type,{},false};
return EnvironmentValue{type,std::move(text),true};
}
throw std::runtime_error("The environment definition changed while Windows was reading it.");
}
std::vector<EnvironmentVariable> readEnvironmentScope(EnvironmentScope scope)
{
std::vector<EnvironmentVariable> entries;
if(scope==EnvironmentScope::process)
{
const auto block=GetEnvironmentStringsW();
if(!block) throw std::system_error(GetLastError(),std::system_category(),"Read the current process environment");
const std::unique_ptr<wchar_t,decltype(&FreeEnvironmentStringsW)> owned(block,FreeEnvironmentStringsW);
for(auto offset=block;*offset;)
{
const std::wstring_view line=offset;
const auto equals=line.find(L'=');
if(equals!=line.npos && equals>0)
entries.push_back({std::wstring(line.substr(0,equals)),{REG_SZ,std::wstring(line.substr(equals+1)),true}});
offset+=line.size()+1;
}
}
else
{
const EnvironmentKey key(scope);
if(!key.value) return {};
std::vector<wchar_t> name(16384);
for(DWORD index=0;;++index)
{
DWORD length=static_cast<DWORD>(name.size());
const auto result=RegEnumValueW(key.value,index,name.data(),&length,nullptr,nullptr,nullptr,nullptr);
if(result==ERROR_NO_MORE_ITEMS) break;
if(result!=ERROR_SUCCESS) throw std::system_error(result,std::system_category(),"List environment definitions");
if(!length) continue;
std::wstring label(name.data(),length);
if(label.find(L'=')!=label.npos) continue;
if(auto value=readEnvironmentValue(key.value,label);value && value->supported)
entries.push_back({std::move(label),std::move(*value)});
}
}
std::sort(entries.begin(),entries.end(),[](const auto &left,const auto &right) {
return CompareStringOrdinal(left.name.c_str(),-1,right.name.c_str(),-1,TRUE)==CSTR_LESS_THAN;
});
return entries;
}
std::wstring expandedEnvironmentValue(EnvironmentScope scope,const EnvironmentValue &value)
{
if(value.type!=REG_EXPAND_SZ) return value.text;
Handle token{};
if(scope==EnvironmentScope::user &&
!OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY|TOKEN_IMPERSONATE|TOKEN_DUPLICATE,&token.value))
throw std::system_error(GetLastError(),std::system_category(),"Open the current user's environment");
std::wstring expanded(environmentValueLimit+1,L'\0');
if(!ExpandEnvironmentStringsForUserW(token.value,value.text.c_str(),expanded.data(),static_cast<DWORD>(expanded.size())))
throw std::system_error(GetLastError(),std::system_category(),"Expand the environment definition");
expanded.resize(wcslen(expanded.c_str()));
return expanded;
}
void writeEnvironmentValue(EnvironmentScope scope,const std::wstring &name,const EnvironmentValue &replacement,
const std::optional<EnvironmentValue> &expected)
{
if(scope==EnvironmentScope::process) throw std::runtime_error("The current process environment is read-only here.");
if(replacement.text.size()>environmentValueLimit) throw std::runtime_error("The value exceeds the Windows environment limit.");
const EnvironmentKey key(scope,true);
if(readEnvironmentValue(key.value,name)!=expected)
throw std::runtime_error("Windows changed this definition while it was open. Reload and review the current value.");
if(expected==replacement) return;
const auto bytes=static_cast<DWORD>((replacement.text.size()+1)*sizeof(wchar_t));
const auto result=RegSetValueExW(key.value,name.c_str(),0,replacement.type,
reinterpret_cast<const BYTE*>(replacement.text.c_str()),bytes);
if(result!=ERROR_SUCCESS) throw std::system_error(result,std::system_category(),"Save the environment definition");
try
{
std::thread([] {
DWORD_PTR reply{};
SendMessageTimeoutW(HWND_BROADCAST,WM_SETTINGCHANGE,0,reinterpret_cast<LPARAM>(L"Environment"),
SMTO_ABORTIFHUNG,250,&reply);
}).detach();
}
catch(const std::exception &) {}
}
const wchar_t *environmentValueType(const EnvironmentValue &value)
{
return value.type==REG_EXPAND_SZ?L"REG_EXPAND_SZ":L"REG_SZ";
}
struct EnvironmentEdit
{
EnvironmentScope scope;
EnvironmentVariable original;
std::wstring replacement;
};
INT_PTR CALLBACK environmentEditDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
{
constexpr int label=630,body=632,footer=633;
if(message==WM_INITDIALOG)
{
const auto &editor=*reinterpret_cast<const EnvironmentEdit *>(lp);
SetWindowLongPtrW(dialog,DWLP_USER,lp);
prepareTextDialog(dialog);
layoutDialogContent(dialog,label);
const auto title=editor.original.name+L" · "+environmentScopeName(editor.scope)+L" · "+
environmentValueType(editor.original.value);
SetDlgItemTextW(dialog,label,title.c_str());
SendDlgItemMessageW(dialog,body,EM_SETLIMITTEXT,environmentValueLimit,0);
SetDlgItemTextW(dialog,body,editor.original.value.text.c_str());
layoutDialogButtons(dialog,footer,{IDOK,IDCANCEL});
SendMessageW(dialog,DM_SETDEFID,IDOK,0);
SetFocus(GetDlgItem(dialog,body));
return FALSE;
}
if(message==WM_COMMAND && LOWORD(wp)==IDOK)
{
auto &editor=*reinterpret_cast<EnvironmentEdit *>(GetWindowLongPtrW(dialog,DWLP_USER));
editor.replacement=dialogFieldText(GetDlgItem(dialog,body));
FilesModalDialog::finish(dialog,IDOK);
return TRUE;
}
if(message==WM_CLOSE || (message==WM_COMMAND && LOWORD(wp)==IDCANCEL))
{
FilesModalDialog::finish(dialog,IDCANCEL);
return TRUE;
}
return paintCopyDialog(dialog,message,wp,lp,L" Edit environment definition ",false,{footer});
}
constexpr int envScope=611,envList=612,envSource=613,envSelected=614,envRaw=615,envExpanded=616,
envStatus=617,envFooter=618,envEdit=622,envCopyUser=623,envCopySystem=624,envRefresh=625;
struct EnvironmentPanel
{
EnvironmentScope scope=EnvironmentScope::user;
std::vector<EnvironmentVariable> entries;
std::wstring readFailure,notice;
};
std::wstring environmentErrorText(const std::exception &error)
{
if(const auto *system=dynamic_cast<const std::system_error *>(&error)) return fileError(*system);
return ks::wide(error.what());
}
const EnvironmentVariable *selectedEnvironmentVariable(HWND dialog,const EnvironmentPanel &panel)
{
const auto row=SendDlgItemMessageW(dialog,envList,LB_GETCURSEL,0,0);
if(row<0) return nullptr;
const auto index=SendDlgItemMessageW(dialog,envList,LB_GETITEMDATA,row,0);
return index>=0 && static_cast<size_t>(index)<panel.entries.size()?&panel.entries[index]:nullptr;
}
void setEnvironmentDetails(HWND dialog,const EnvironmentPanel &panel)
{
const auto *entry=selectedEnvironmentVariable(dialog,panel);
const bool registry=panel.scope!=EnvironmentScope::process;
SetDlgItemTextW(dialog,envSource,environmentSource(panel.scope).c_str());
SetDlgItemTextW(dialog,envSelected,entry?(entry->name+L" · "+
(registry?environmentValueType(entry->value):L"Read-only")).c_str():L"");
SetDlgItemTextW(dialog,envRaw,entry?entry->value.text.c_str():L"");
std::wstring expanded;
if(entry)
{
try {expanded=expandedEnvironmentValue(panel.scope,entry->value);}
catch(const std::exception &error) {expanded=L"Unavailable · "+environmentErrorText(error);}
}
SetDlgItemTextW(dialog,envExpanded,expanded.c_str());
EnableWindow(GetDlgItem(dialog,envEdit),entry && registry);
EnableWindow(GetDlgItem(dialog,envCopyUser),entry && panel.scope!=EnvironmentScope::user);
EnableWindow(GetDlgItem(dialog,envCopySystem),entry && panel.scope!=EnvironmentScope::system);
const auto status=!panel.readFailure.empty()?panel.readFailure:!panel.notice.empty()?panel.notice:
!entry?std::wstring(L"No environment variables in this scope."):
registry?L"Existing PowerShell sessions keep their environment. Restart Files for embedded PowerShell.":
L"These values belong to the running Files process.";
SetDlgItemTextW(dialog,envStatus,status.c_str());
}
void reloadEnvironmentPanel(HWND dialog,EnvironmentPanel &panel,const std::wstring &preferred={})
{
panel.readFailure.clear();
try {panel.entries=readEnvironmentScope(panel.scope);}
catch(const std::exception &error)
{
panel.entries.clear();
panel.readFailure=environmentErrorText(error);
}
const auto list=GetDlgItem(dialog,envList);
SendMessageW(list,WM_SETREDRAW,FALSE,0);
SendMessageW(list,LB_RESETCONTENT,0,0);
LRESULT selected=0;
for(size_t index=0;index<panel.entries.size();++index)
{
const auto &name=panel.entries[index].name;
const auto row=SendMessageW(list,LB_ADDSTRING,0,reinterpret_cast<LPARAM>(name.c_str()));
if(row<0) continue;
SendMessageW(list,LB_SETITEMDATA,row,index);
if(CompareStringOrdinal(name.c_str(),-1,preferred.c_str(),-1,TRUE)==CSTR_EQUAL) selected=row;
}
if(!panel.entries.empty()) SendMessageW(list,LB_SETCURSEL,selected,0);
SendMessageW(list,WM_SETREDRAW,TRUE,0);
InvalidateRect(list,nullptr,TRUE);
setEnvironmentDetails(dialog,panel);
}
void saveEnvironmentDefinition(HWND dialog,EnvironmentPanel &panel,const EnvironmentVariable &entry,
std::optional<EnvironmentScope> copyTo={})
{
try
{
if(copyTo)
{
const EnvironmentKey key(*copyTo);
const auto previous=readEnvironmentValue(key.value,entry.name);
if(previous && !previous->supported)
throw std::runtime_error("The destination already has a registry value of an unsupported type.");
const auto question=previous?L"Replace "+entry.name+L" in "+environmentScopeName(*copyTo)+L"?":
L"Copy "+entry.name+L" to "+environmentScopeName(*copyTo)+L"?";
if(showFilesNotice(dialog,question.c_str(),L"Copy environment definition",
{.confirm=true,.tone=previous?FilesNoticeTone::warning:FilesNoticeTone::dialog})!=IDYES) return;
if(panel.scope!=EnvironmentScope::process)
{
const EnvironmentKey source(panel.scope);
if(readEnvironmentValue(source.value,entry.name)!=entry.value)
throw std::runtime_error("The source definition changed. Reload and review it before copying.");
}
writeEnvironmentValue(*copyTo,entry.name,entry.value,previous);
panel.scope=*copyTo;
SendDlgItemMessageW(dialog,envScope,CB_SETCURSEL,static_cast<WPARAM>(panel.scope),0);
}
else
{
if(panel.scope==EnvironmentScope::process) return;
EnvironmentEdit editor{panel.scope,entry};
if(FilesModalDialog::run(GetModuleHandleW(nullptr),MAKEINTRESOURCEW(128),dialog,environmentEditDialog,
reinterpret_cast<LPARAM>(&editor))!=IDOK || editor.replacement==entry.value.text) return;
writeEnvironmentValue(panel.scope,entry.name,{entry.value.type,editor.replacement,true},entry.value);
}
panel.notice=L"Saved. Restart Files for embedded PowerShell to inherit the new value.";
}
catch(const std::exception &error)
{
panel.notice.clear();
const auto details=environmentErrorText(error);
showFilesNotice(dialog,details.c_str(),L"Could not save environment definition",{.tone=FilesNoticeTone::warning});
}
reloadEnvironmentPanel(dialog,panel,entry.name);
}
INT_PTR CALLBACK environmentPanelDialog(HWND dialog,UINT message,WPARAM wp,LPARAM lp)
{
if(message==WM_INITDIALOG)
{
auto &panel=*reinterpret_cast<EnvironmentPanel *>(lp);
SetWindowLongPtrW(dialog,DWLP_USER,lp);
prepareTextDialog(dialog);
layoutDialogContent(dialog,610);
const auto scope=GetDlgItem(dialog,envScope);
for(const auto item:{EnvironmentScope::user,EnvironmentScope::system,EnvironmentScope::process})
SendMessageW(scope,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(environmentScopeName(item)));
SendMessageW(scope,CB_SETCURSEL,0,0);
installFarCombo(scope,GetDlgItem(dialog,610));
const auto list=GetDlgItem(dialog,envList);
const auto bounds=dialogControlBounds(dialog,envList);
SetWindowPos(list,nullptr,0,0,std::max(1L,bounds.right-bounds.left-scrollBarWidth(list)),
bounds.bottom-bounds.top,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
installScrollBar(list,dialog);
layoutDialogButtons(dialog,envFooter,{envEdit,envCopyUser,envCopySystem,envRefresh,IDOK});
SendMessageW(dialog,DM_SETDEFID,IDOK,0);
reloadEnvironmentPanel(dialog,panel);
SetFocus(scope);
return FALSE;
}
auto *panel=reinterpret_cast<EnvironmentPanel *>(GetWindowLongPtrW(dialog,DWLP_USER));
if(!panel) return FALSE;
if(message==WM_DRAWITEM && wp==envScope)
{
drawFarComboRow(*reinterpret_cast<const DRAWITEMSTRUCT *>(lp));
return TRUE;
}
if(message==WM_CTLCOLORLISTBOX && reinterpret_cast<HWND>(lp)!=GetDlgItem(dialog,envList))
{
const auto dc=reinterpret_cast<HDC>(wp);
SetTextColor(dc,colors[Text]);
SetBkColor(dc,colors[Dialog]);
return reinterpret_cast<INT_PTR>(teal);
}
if(message==WM_COMMAND)
{
const auto id=LOWORD(wp),notification=HIWORD(wp);
if(id==envScope && (notification==CBN_SELENDOK ||
(notification==CBN_SELCHANGE && !SendDlgItemMessageW(dialog,envScope,CB_GETDROPPEDSTATE,0,0))))
{
const auto scope=SendDlgItemMessageW(dialog,envScope,CB_GETCURSEL,0,0);
if(scope>=0 && scope<=static_cast<LRESULT>(EnvironmentScope::process) &&
static_cast<EnvironmentScope>(scope)!=panel->scope)
{
const auto *entry=selectedEnvironmentVariable(dialog,*panel);
const auto selected=entry?entry->name:std::wstring{};
panel->scope=static_cast<EnvironmentScope>(scope);
reloadEnvironmentPanel(dialog,*panel,selected);
}
return TRUE;
}
if(id==envRefresh || (id==envList && notification==LBN_SELCHANGE))
{
if(id==envRefresh)
{
const auto *entry=selectedEnvironmentVariable(dialog,*panel);
const auto name=entry?entry->name:std::wstring{};
reloadEnvironmentPanel(dialog,*panel,name);
}
else setEnvironmentDetails(dialog,*panel);
return TRUE;
}
if(id==envEdit || id==envCopyUser || id==envCopySystem)
{
if(const auto *entry=selectedEnvironmentVariable(dialog,*panel))
saveEnvironmentDefinition(dialog,*panel,EnvironmentVariable(*entry),id==envEdit?std::nullopt:
std::optional(id==envCopyUser?EnvironmentScope::user:EnvironmentScope::system));
return TRUE;
}
if(id==IDOK || id==IDCANCEL)
{
FilesModalDialog::finish(dialog,IDCANCEL);
return TRUE;
}
}
if(message==WM_CLOSE) {FilesModalDialog::finish(dialog,IDCANCEL);return TRUE;}
return paintCopyDialog(dialog,message,wp,lp,L" Environment Variables ",false,{envFooter},false,GetDlgItem(dialog,envList));
}
void showEnvironmentPanel(HWND owner)
{
EnvironmentPanel panel;
FilesModalDialog::run(GetModuleHandleW(nullptr),MAKEINTRESOURCEW(127),owner,environmentPanelDialog,
reinterpret_cast<LPARAM>(&panel));
}
+6 -1
View File
@@ -11,6 +11,7 @@
#include <sddl.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <userenv.h>
#include <cmath>
#include <numbers>
#include <algorithm>
@@ -3848,6 +3849,7 @@ void showPanelLockProcesses(HWND owner,Panel &panel);
void showProcesses(HWND owner,std::vector<fs::path> paths={});
bool gitChangesAvailable(const Panel &panel);
void openGitChanges(HWND owner,const Panel &panel);
void showEnvironmentPanel(HWND owner);
bool selectablePickerRow(LRESULT row)
{
@@ -3897,6 +3899,7 @@ void selectDrive()
else if(menuIndex==2 && row==14) ks::files::showAllViewerBookmarks(owner,textWindowDialogs());
else if(menuIndex==2 && row==15) showProcesses(owner);
else if(menuIndex==2 && row==16) openGitChanges(owner,panels[active]);
else if(menuIndex==2 && row==17) showEnvironmentPanel(owner);
else if(menuIndex==1 && row==4) createArchive(owner,panels[active]);
else if(menuIndex==1 && row==5) showPanelItemProperties(owner,panels[active]);
else if(menuIndex==1 && row==6) showPanelLockProcesses(owner,panels[active]);
@@ -7904,6 +7907,7 @@ bool loadFilesPreferences(HWND window)
#include "files_options.inl"
#include "files_panel_columns_dialog.inl"
#include "files_space_analyzer.inl"
#include "files_environment.inl"
void openMenu(HWND window, int index)
{
@@ -7958,7 +7962,7 @@ void openMenu(HWND window, int index)
L"Hibernate remote PC",L"Update remote KSwitcher",L"Compare files\t"+comparisonShortcutLabel(),
L"Find files\tAlt+F7",quickViewWindow?L"Close Quick View\tCtrl+Q":L"Quick View\tCtrl+Q",
L"Copy full path\tCtrl+Shift+C",L"Space Analyzer",L"View as hex\tShift+F3",L"Viewer bookmarks…",L"Processes…",
L"Git Changes…"};
L"Git Changes…",L"Environment Variables…"};
}
const auto &panel=panels[active];
const bool remoteResults=remoteSearchResults(panel);
@@ -7986,6 +7990,7 @@ void openMenu(HWND window, int index)
commandActions={0,3,11,-1,1,13,14,2,4,5,8};
if(!terminalVisible) commandActions.push_back(15);
if(gitChangesAvailable(panel)) commandActions.push_back(16);
if(!terminalVisible) commandActions.push_back(17);
if(!terminalVisible && canFindFiles(panels[active])) commandActions.insert(commandActions.begin()+1,9);
if(!terminalVisible && !panels[active].peer && !panels[active].ftp)
commandActions.insert(commandActions.begin()+2,12);