Skip to content

Commit

Permalink
1. 0003325: Detect external file editing and post back to plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
zg0 committed Oct 10, 2016
1 parent 0fbe1b2 commit a4bde5b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
1 change: 1 addition & 0 deletions far/CONTRIBUTORS
Expand Up @@ -104,6 +104,7 @@ Victor Istomin
Vlad Lozynskyi
Kate Fedorova
Mauro72
dimfish

And special thanks to all of our community members!
You are not less important than the people mentioned here.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
zg 10.10.2016 16:33:04 +0200 - build 4818

1. 0003325: Detect external file editing and post back to plugin.

drkns 10.10.2016 02:27:15 +0200 - build 4817

1. Уточнение 4816.
Expand Down
47 changes: 37 additions & 10 deletions far/filelist.cpp
Expand Up @@ -1885,19 +1885,27 @@ int FileList::ProcessKey(const Manager::Key& Key)
/* $ 02.08.2001 IS обработаем ассоциации для alt-f4 */
BOOL Processed=FALSE;

if ((LocalKey==KEY_ALTF4 || LocalKey==KEY_RALTF4) &&
ProcessLocalFileTypes(strFileName,strShortFileName,FILETYPE_ALTEDIT,
PluginMode))
Processed=TRUE;
else if (LocalKey==KEY_F4 &&
ProcessLocalFileTypes(strFileName,strShortFileName,FILETYPE_EDIT,
PluginMode))
Processed=TRUE;
FILETIME tmpWriteTimeBefore, tmpWriteTimeAfter, tmpChangeTimeBefore, tmpChangeTimeAfter;
os::GetFileTimeSimple(strFileName, nullptr, nullptr, &tmpWriteTimeBefore, &tmpChangeTimeBefore);

if (LocalKey == KEY_ALTF4 || LocalKey == KEY_RALTF4 || LocalKey == KEY_F4)
{
if (ProcessLocalFileTypes(strFileName, strShortFileName, (LocalKey == KEY_F4)?FILETYPE_EDIT:FILETYPE_ALTEDIT, PluginMode))
{
os::GetFileTimeSimple(strFileName, nullptr, nullptr, &tmpWriteTimeAfter, &tmpChangeTimeAfter);
UploadFile = tmpWriteTimeAfter != tmpWriteTimeBefore || tmpChangeTimeAfter != tmpChangeTimeBefore;
Processed = TRUE;
}
}

if (!Processed || LocalKey==KEY_CTRLSHIFTF4 || LocalKey==KEY_RCTRLSHIFTF4)
{
if (EnableExternal)
ProcessExternal(Global->Opt->strExternalEditor,strFileName,strShortFileName,PluginMode);
{
ProcessExternal(Global->Opt->strExternalEditor, strFileName, strShortFileName, PluginMode);
os::GetFileTimeSimple(strFileName, nullptr, nullptr, &tmpWriteTimeAfter, &tmpChangeTimeAfter);
UploadFile = tmpWriteTimeAfter != tmpWriteTimeBefore || tmpChangeTimeAfter != tmpChangeTimeBefore;
}
else if (PluginMode)
{
RefreshedPanel = Global->WindowManager->GetCurrentWindow()->GetType() != windowtype_editor;
Expand Down Expand Up @@ -2606,6 +2614,7 @@ void FileList::ProcessEnter(bool EnableExec,bool SeparateWindow,bool EnableAssoc
plugin_panel* OpenedPlugin = nullptr;
const auto PluginMode = m_PanelMode == panel_mode::PLUGIN_PANEL && !Global->CtrlObject->Plugins->UseFarCommand(m_hPlugin, PLUGIN_FARGETFILE);
SCOPE_EXIT{ if (PluginMode && (!OpenedPlugin || OpenedPlugin == PANEL_STOP)) DeleteFileWithFolder(strFileName); };
FILETIME tmpWriteTimeBefore, tmpWriteTimeAfter, tmpChangeTimeBefore, tmpChangeTimeAfter;

if (PluginMode)
{
Expand All @@ -2617,10 +2626,11 @@ void FileList::ProcessEnter(bool EnableExec,bool SeparateWindow,bool EnableAssoc
PluginPanelItemHolder PanelItem;
FileListToPluginItem(CurItem, PanelItem);

if (!Global->CtrlObject->Plugins->GetFile(m_hPlugin, &PanelItem.Item, strTempDir, strFileName, OPM_SILENT | OPM_VIEW))
if (!Global->CtrlObject->Plugins->GetFile(m_hPlugin, &PanelItem.Item, strTempDir, strFileName, OPM_EDIT))
return;

strShortFileName = ConvertNameToShort(strFileName);
os::GetFileTimeSimple(strFileName, nullptr, nullptr, &tmpWriteTimeBefore, &tmpChangeTimeBefore);
}


Expand Down Expand Up @@ -2665,6 +2675,23 @@ void FileList::ProcessEnter(bool EnableExec,bool SeparateWindow,bool EnableAssoc

OpenFilePlugin(strFileName, TRUE, Type);
}

if (PluginMode && (!OpenedPlugin || OpenedPlugin == PANEL_STOP))
{
if (os::GetFileTimeSimple(strFileName, nullptr, nullptr, &tmpWriteTimeAfter, &tmpChangeTimeAfter))
{
if (tmpWriteTimeAfter != tmpWriteTimeBefore || tmpChangeTimeAfter != tmpChangeTimeBefore)
{
PluginPanelItemHolder PanelItem;
if (FileNameToPluginItem(strFileName, PanelItem))
{
int PutCode = Global->CtrlObject->Plugins->PutFiles(m_hPlugin, &PanelItem.Item, 1, false, OPM_EDIT);
if (PutCode == 1 || PutCode == 2)
SetPluginModified();
}
}
}
}
}
}

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

0 comments on commit a4bde5b

Please sign in to comment.