Skip to content

Commit

Permalink
more 4723: ignore on ShiftEnter & RunAs support
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Jun 23, 2016
1 parent e049326 commit 050e43c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
drkns 24.06.2016 01:39:45 +0200 - build 4724

1. Продолжение 4723 - исключение для ShiftEnter и поддержка run as.

drkns 24.06.2016 01:15:01 +0200 - build 4723

1. Очень экспериментальная фича: встроенные ассоциации распространяются на комстроку.
Expand Down
32 changes: 20 additions & 12 deletions far/execute.cpp
Expand Up @@ -659,6 +659,9 @@ void Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio
string strNewCmdStr;
string strNewCmdPar;

// Info.NewWindow may be changed later
const auto IgnoreInternalAssociations = Info.NewWindow;

if (Info.SourceMode == execute_info::source_mode::known)
{
strNewCmdStr = Info.Command;
Expand Down Expand Up @@ -773,22 +776,27 @@ void Execute(execute_info& Info, bool FolderRun, bool Silent, const std::functio
}
else
{
auto FoundModuleNameShort = FoundModuleName;
ConvertNameToShort(FoundModuleNameShort, FoundModuleNameShort);
const auto LastX = WhereX(), LastY = WhereY();
if (ProcessLocalFileTypes(FoundModuleName, FoundModuleNameShort, FILETYPE_EXEC, Info.WaitMode == execute_info::wait_mode::wait_finish, false, [&](execute_info& AssocInfo)
if (!IgnoreInternalAssociations)
{
GotoXY(LastX, LastY);
if (!strNewCmdPar.empty())
auto FoundModuleNameShort = FoundModuleName;
ConvertNameToShort(FoundModuleNameShort, FoundModuleNameShort);
const auto LastX = WhereX(), LastY = WhereY();
if (ProcessLocalFileTypes(FoundModuleName, FoundModuleNameShort, FILETYPE_EXEC, Info.WaitMode == execute_info::wait_mode::wait_finish, false, Info.RunAs, [&](execute_info& AssocInfo)
{
AssocInfo.Command.append(L" ").append(strNewCmdPar);
GotoXY(LastX, LastY);

if (!strNewCmdPar.empty())
{
AssocInfo.Command.append(L" ").append(strNewCmdPar);
}

Execute(AssocInfo, FolderRun, Silent, ConsoleActivator);
}))
{
return;
}
Execute(AssocInfo, FolderRun, Silent, ConsoleActivator);
}))
{
return;
GotoXY(LastX, LastY);
}
GotoXY(LastX, LastY);

if (GetImageType(FoundModuleName, ImageType) || GetAssociatedImageType(FoundModuleName, ImageType) || GetImageTypeFallback(ImageType))
{
Expand Down
2 changes: 1 addition & 1 deletion far/filelist.cpp
Expand Up @@ -2651,7 +2651,7 @@ void FileList::ProcessEnter(bool EnableExec,bool SeparateWindow,bool EnableAssoc
if (!SetCurPath())
return;

if (!SeparateWindow && ProcessLocalFileTypes(strFileName, strShortFileName, FILETYPE_EXEC, PluginMode))
if (!SeparateWindow && ProcessLocalFileTypes(strFileName, strShortFileName, FILETYPE_EXEC, PluginMode, true, RunAs))
return;

const auto IsItExecutable = IsExecutable(strFileName);
Expand Down
3 changes: 2 additions & 1 deletion far/filetype.cpp
Expand Up @@ -89,7 +89,7 @@ size_t GetDescriptionWidth()
- Убрал непонятный мне запрет на использование маски файлов типа "*.*"
(был когда-то, вроде, такой баг-репорт)
*/
bool ProcessLocalFileTypes(const string& Name, const string& ShortName, FILETYPE_MODE Mode, bool AlwaysWaitFinish, bool AddToHistory, const std::function<void(execute_info&)>& Launcher)
bool ProcessLocalFileTypes(const string& Name, const string& ShortName, FILETYPE_MODE Mode, bool AlwaysWaitFinish, bool AddToHistory, bool RunAs, const std::function<void(execute_info&)>& Launcher)
{
string strCommand, strDescription, strMask;
{
Expand Down Expand Up @@ -192,6 +192,7 @@ bool ProcessLocalFileTypes(const string& Name, const string& ShortName, FILETYPE
execute_info Info;
Info.Command = strCommand;
Info.WaitMode = AlwaysWaitFinish? execute_info::wait_mode::wait_finish : ListFileUsed? execute_info::wait_mode::wait_idle : execute_info::wait_mode::no_wait;
Info.RunAs = RunAs;

Launcher? Launcher(Info) : Global->CtrlObject->CmdLine()->ExecString(Info);

Expand Down
2 changes: 1 addition & 1 deletion far/filetype.hpp
Expand Up @@ -53,7 +53,7 @@ enum FILETYPE_MODE
*/
bool GetFiletypeOpenMode(int keyPressed, FILETYPE_MODE& mode, bool& shouldForceInternal);

bool ProcessLocalFileTypes(const string& Name, const string& ShortName, FILETYPE_MODE Mode, bool AlwaysWaitFinish, bool AddToHistory = true, const std::function<void(struct execute_info&)>& Launcher = nullptr);
bool ProcessLocalFileTypes(const string& Name, const string& ShortName, FILETYPE_MODE Mode, bool AlwaysWaitFinish, bool AddToHistory = true, bool RunAs = false, const std::function<void(struct execute_info&)>& Launcher = nullptr);
void ProcessExternal(const string& Command, const string& Name, const string& ShortName, bool AlwaysWaitFinish);
void EditFileTypes();

Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4723)m4_dnl
m4_define(BUILD,4724)m4_dnl

0 comments on commit 050e43c

Please sign in to comment.