View Issue Details

IDProjectCategoryView StatusLast Update
0002529WishesPlugins APIpublic2014-06-15 07:15
Reporterfml2 Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.0 
Summary0002529: Добавить в Plugin API возможность удалять записи из истории команд
DescriptionВ настоящий момент (сборка 3722) плагиновский АПИ (и его обертка для луа) позволяет считывать историю команд, но не позволяет удалять записи из нее.

Мне в моем макросе (см. http://forum.farmanager.com/viewtopic.php?f=4&t=8289#p114422) такая возможность очень бы пригодилась.

Поэтому запрос/пожелание: добавить в АПИ плагинов (ведь этот АПИ -- основа основ) возможность удалять записи из истории команд. А потом добавить такую возможность для макросов, написанных на Луа (если после добавления в АПИ эта возможность в Луа не появляется автоматически).
TagsNo tags attached.
Build

Activities

fml2

2013-12-13 23:14

reporter   bugnote:0011598

Last edited: 2013-12-13 23:34

Правильно ли я понимаю, что первым шагом должно быть добавление поля "id" в структуру "FarSettingsHistory" (из plugin.hpp) и его корректное заполнение в функции "FarSettings::FillHistory" (plugsettings.cpp)

А потом уже передавать его в структуру Луа (в plugins/luamacro/luafar/service.c)?

Но это приведет к тому, что каждый пункт в меню истории будет "весить" на 8 байт больше, так? Это было бы приемлемо?

fml2

2013-12-24 19:44

reporter  

IdInHistoryItems.diff (1,262 bytes)   
Index: plugin.hpp
===================================================================
--- plugin.hpp	(revision 11273)
+++ plugin.hpp	(working copy)
@@ -1970,6 +1970,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugsettings.cpp
===================================================================
--- plugsettings.cpp	(revision 11273)
+++ plugsettings.cpp	(working copy)
@@ -204,6 +204,16 @@
 	Array->Items.emplace_back(Item);
 }
 
+static void AddItem(FarSettingsHistoryItems* Array, FarSettingsHistory& Item, const string& Name, const string& Param, const GUID& Guid, const string& File, unsigned __int64 Id)
+{
+	Item.Name=AddString(Name);
+	Item.Param=AddString(Param);
+	Item.PluginId=Guid;
+	Item.File=AddString(File);
+	Item.Id=Id;
+	Array->Items.emplace_back(Item);
+}
+
 int PluginSettings::Enum(FarSettingsEnum& Enum)
 {
 	int result=FALSE;
@@ -463,7 +473,7 @@
 			item.Lock=HLock;
 			GUID Guid;
 			if(strGuid.empty()||!StrToGuid(strGuid,Guid)) Guid=FarGuid;
-			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile);
+			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile,id);
 		}
 	}
 	if (!m_Enum.back()->Items.empty())
IdInHistoryItems.diff (1,262 bytes)   

fml2

2013-12-24 19:45

reporter  

IdInHistoryItems_LuaFar.diff (652 bytes)   
Index: luamacro/luafar/service.c
===================================================================
--- luamacro/luafar/service.c	(revision 11273)
+++ luamacro/luafar/service.c	(working copy)
@@ -5373,7 +5373,7 @@
 			if(udata->IsFarSettings)
 			{
 				const struct FarSettingsHistory *fsh = fse.Value.Histories + i;
-				lua_createtable(L, 0, 6);
+				lua_createtable(L, 0, 7);
 
 				if(fsh->Name) PutWStrToTable(L, "Name", fsh->Name, -1);
 
@@ -5386,6 +5386,7 @@
 				pushFileTime(L, &fsh->Time);
 				lua_setfield(L, -2, "Time");
 				PutBoolToTable(L, "Lock", fsh->Lock);
+				PutNumToTable(L, "Id", (double)fsh->Id);
 			}
 			else
 			{

fml2

2013-12-24 19:47

reporter   bugnote:0011602

Создал два патча (для Far и для LuaFar). Цель -- возвращать Id для каждой записи истории при вызове settings:Enum. Это является предварительным шагом к тому, чтобы сделать возможным удаление записей из истории (команд, каталогов, ...) из макросов, написанных на Lua.

Но опробовать патчи я не смог, т.к. не знаю, как собирать LuaFar. Может, кто-нибудь поможет?

fml2

2013-12-24 21:00

reporter  

IdInHistoryItems_LuaFar_2.diff (1,000 bytes)   
Index: common/unicode/plugin.hpp
===================================================================
--- common/unicode/plugin.hpp	(revision 11273)
+++ common/unicode/plugin.hpp	(working copy)
@@ -1812,6 +1812,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: luamacro/luafar/service.c
===================================================================
--- luamacro/luafar/service.c	(revision 11273)
+++ luamacro/luafar/service.c	(working copy)
@@ -5373,7 +5373,7 @@
 			if(udata->IsFarSettings)
 			{
 				const struct FarSettingsHistory *fsh = fse.Value.Histories + i;
-				lua_createtable(L, 0, 6);
+				lua_createtable(L, 0, 7);
 
 				if(fsh->Name) PutWStrToTable(L, "Name", fsh->Name, -1);
 
@@ -5386,6 +5386,7 @@
 				pushFileTime(L, &fsh->Time);
 				lua_setfield(L, -2, "Time");
 				PutBoolToTable(L, "Lock", fsh->Lock);
+				PutNumToTable(L, "Id", (double)fsh->Id);
 			}
 			else
 			{
IdInHistoryItems_LuaFar_2.diff (1,000 bytes)   

fml2

2013-12-24 21:07

reporter   bugnote:0011603

Загрузил исправленный патч для LuaFar: нужно было подправить common/plugin.hpp.

fml2

2013-12-24 21:26

reporter  

IdInHistoryItems_Combined.diff (2,367 bytes)   
Index: plugins/common/unicode/plugin.hpp
===================================================================
--- plugins/common/unicode/plugin.hpp	(revision 11273)
+++ plugins/common/unicode/plugin.hpp	(working copy)
@@ -1812,6 +1812,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/luafar/service.c
===================================================================
--- plugins/luamacro/luafar/service.c	(revision 11273)
+++ plugins/luamacro/luafar/service.c	(working copy)
@@ -5373,7 +5373,7 @@
 			if(udata->IsFarSettings)
 			{
 				const struct FarSettingsHistory *fsh = fse.Value.Histories + i;
-				lua_createtable(L, 0, 6);
+				lua_createtable(L, 0, 7);
 
 				if(fsh->Name) PutWStrToTable(L, "Name", fsh->Name, -1);
 
@@ -5386,6 +5386,7 @@
 				pushFileTime(L, &fsh->Time);
 				lua_setfield(L, -2, "Time");
 				PutBoolToTable(L, "Lock", fsh->Lock);
+				PutNumToTable(L, "Id", (double)fsh->Id);
 			}
 			else
 			{
Index: unicode_far/plugin.hpp
===================================================================
--- unicode_far/plugin.hpp	(revision 11273)
+++ unicode_far/plugin.hpp	(working copy)
@@ -1970,6 +1970,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: unicode_far/plugsettings.cpp
===================================================================
--- unicode_far/plugsettings.cpp	(revision 11273)
+++ unicode_far/plugsettings.cpp	(working copy)
@@ -204,6 +204,16 @@
 	Array->Items.emplace_back(Item);
 }
 
+static void AddItem(FarSettingsHistoryItems* Array, FarSettingsHistory& Item, const string& Name, const string& Param, const GUID& Guid, const string& File, unsigned __int64 Id)
+{
+	Item.Name=AddString(Name);
+	Item.Param=AddString(Param);
+	Item.PluginId=Guid;
+	Item.File=AddString(File);
+	Item.Id=Id;
+	Array->Items.emplace_back(Item);
+}
+
 int PluginSettings::Enum(FarSettingsEnum& Enum)
 {
 	int result=FALSE;
@@ -463,7 +473,7 @@
 			item.Lock=HLock;
 			GUID Guid;
 			if(strGuid.empty()||!StrToGuid(strGuid,Guid)) Guid=FarGuid;
-			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile);
+			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile,id);
 		}
 	}
 	if (!m_Enum.back()->Items.empty())
IdInHistoryItems_Combined.diff (2,367 bytes)   

fml2

2013-12-24 21:27

reporter   bugnote:0011604

Добавил объединенный патч (Far + LuaFar), так легче его применять.

fml2

2013-12-24 22:50

reporter  

IdInHistoryItems_Combined_2.diff (2,728 bytes)   
Index: plugins/common/unicode/plugin.hpp
===================================================================
--- plugins/common/unicode/plugin.hpp	(revision 11273)
+++ plugins/common/unicode/plugin.hpp	(working copy)
@@ -1812,6 +1812,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/farapi.lua
===================================================================
--- plugins/luamacro/farapi.lua	(revision 11273)
+++ plugins/luamacro/farapi.lua	(working copy)
@@ -1780,6 +1780,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/luafar/service.c
===================================================================
--- plugins/luamacro/luafar/service.c	(revision 11273)
+++ plugins/luamacro/luafar/service.c	(working copy)
@@ -5373,7 +5373,7 @@
 			if(udata->IsFarSettings)
 			{
 				const struct FarSettingsHistory *fsh = fse.Value.Histories + i;
-				lua_createtable(L, 0, 6);
+				lua_createtable(L, 0, 7);
 
 				if(fsh->Name) PutWStrToTable(L, "Name", fsh->Name, -1);
 
@@ -5386,6 +5386,7 @@
 				pushFileTime(L, &fsh->Time);
 				lua_setfield(L, -2, "Time");
 				PutBoolToTable(L, "Lock", fsh->Lock);
+				PutNumToTable(L, "Id", (double)fsh->Id);
 			}
 			else
 			{
Index: unicode_far/plugin.hpp
===================================================================
--- unicode_far/plugin.hpp	(revision 11273)
+++ unicode_far/plugin.hpp	(working copy)
@@ -1970,6 +1970,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: unicode_far/plugsettings.cpp
===================================================================
--- unicode_far/plugsettings.cpp	(revision 11273)
+++ unicode_far/plugsettings.cpp	(working copy)
@@ -204,6 +204,16 @@
 	Array->Items.emplace_back(Item);
 }
 
+static void AddItem(FarSettingsHistoryItems* Array, FarSettingsHistory& Item, const string& Name, const string& Param, const GUID& Guid, const string& File, unsigned __int64 Id)
+{
+	Item.Name=AddString(Name);
+	Item.Param=AddString(Param);
+	Item.PluginId=Guid;
+	Item.File=AddString(File);
+	Item.Id=Id;
+	Array->Items.emplace_back(Item);
+}
+
 int PluginSettings::Enum(FarSettingsEnum& Enum)
 {
 	int result=FALSE;
@@ -463,7 +473,7 @@
 			item.Lock=HLock;
 			GUID Guid;
 			if(strGuid.empty()||!StrToGuid(strGuid,Guid)) Guid=FarGuid;
-			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile);
+			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile,id);
 		}
 	}
 	if (!m_Enum.back()->Items.empty())

fml2

2013-12-24 22:51

reporter   bugnote:0011605

Добавил http://bugs.farmanager.com/file_download.php?file_id=1155&type=bug с подправленным файлом farapi.lua (хотя я и не знаю, зачем этот файл нужен и где он используется).

fml2

2013-12-25 10:49

reporter  

IdInHistoryItems_Combined_3.diff (2,665 bytes)   
Index: enc/enc_lua/luafar_manual.tsi
===================================================================
--- enc/enc_lua/luafar_manual.tsi	(revision 11273)
+++ enc/enc_lua/luafar_manual.tsi	(working copy)
@@ -6385,6 +6385,7 @@
 #_        File:     string
 #_        Time:     number (number of milliseconds elapsed since January 1, 1601)
 #_        Lock:     boolean
+#_        Id:       number (ID of the entry in the history DB; is only filled for history items -- commands, folders etc.)
 #_
 #_**Far API used:**
 #_  SettingsControl
Index: plugins/common/unicode/plugin.hpp
===================================================================
--- plugins/common/unicode/plugin.hpp	(revision 11273)
+++ plugins/common/unicode/plugin.hpp	(working copy)
@@ -1812,6 +1812,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/farapi.lua
===================================================================
--- plugins/luamacro/farapi.lua	(revision 11273)
+++ plugins/luamacro/farapi.lua	(working copy)
@@ -1780,6 +1780,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/luafar/service.c
===================================================================
--- plugins/luamacro/luafar/service.c	(revision 11273)
+++ plugins/luamacro/luafar/service.c	(working copy)
@@ -5373,7 +5373,7 @@
 			if(udata->IsFarSettings)
 			{
 				const struct FarSettingsHistory *fsh = fse.Value.Histories + i;
-				lua_createtable(L, 0, 6);
+				lua_createtable(L, 0, 7);
 
 				if(fsh->Name) PutWStrToTable(L, "Name", fsh->Name, -1);
 
@@ -5386,6 +5386,7 @@
 				pushFileTime(L, &fsh->Time);
 				lua_setfield(L, -2, "Time");
 				PutBoolToTable(L, "Lock", fsh->Lock);
+				PutNumToTable(L, "Id", (double)fsh->Id);
 			}
 			else
 			{
Index: unicode_far/plugin.hpp
===================================================================
--- unicode_far/plugin.hpp	(revision 11273)
+++ unicode_far/plugin.hpp	(working copy)
@@ -1970,6 +1970,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: unicode_far/plugsettings.cpp
===================================================================
--- unicode_far/plugsettings.cpp	(revision 11273)
+++ unicode_far/plugsettings.cpp	(working copy)
@@ -463,6 +463,7 @@
 			item.Lock=HLock;
 			GUID Guid;
 			if(strGuid.empty()||!StrToGuid(strGuid,Guid)) Guid=FarGuid;
+			item.Id=id;
 			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile);
 		}
 	}

fml2

2013-12-25 10:50

reporter   bugnote:0011606

Подправил LuaFar_Manual: http://bugs.farmanager.com/file_download.php?file_id=1156&type=bug

vskirdin

2013-12-25 11:35

administrator   bugnote:0011607

И оно работает? (я не про Lua, а про АПИ)
Или последняя редакция патча решает только вот этот вопрос: "является предварительным шагом к тому, чтобы сделать возможным"?
Если да, то может сделаете полноценный патч? (а то сабж помпезно обозван, а фактически...)

fml2

2013-12-25 12:16

reporter   bugnote:0011608

Пока только предварительный шаг, как и объявлено. Но, наедюсь, все двигается в правильном направлении.

fml2

2013-12-25 21:39

reporter  

IdInHistoryItems_Combined_4.diff (8,270 bytes)   
Index: enc/enc_lua/luafar_manual.tsi
===================================================================
--- enc/enc_lua/luafar_manual.tsi	(revision 11273)
+++ enc/enc_lua/luafar_manual.tsi	(working copy)
@@ -6233,6 +6233,7 @@
 #_* [`Get`](420.html)
 #_* [`OpenSubkey`](442.html)
 #_* [`Set`](421.html)
+#_* [`DeleteHistoryItem`](554.html)
 #_
 </article>
 </node>
@@ -6385,6 +6386,7 @@
 #_        File:     string
 #_        Time:     number (number of milliseconds elapsed since January 1, 1601)
 #_        Lock:     boolean
+#_        Id:       number (ID of the entry in the history DB; is only filled for history items -- commands, folders etc.)
 #_
 #_**Far API used:**
 #_  SettingsControl
@@ -6507,6 +6509,33 @@
 </article>
 </node>
 <node>
+id=554
+lv=2
+dt=Text
+nm=obj:DeleteHistoryItem
+ctime=3507637642
+mtime=3576228671
+<article>
+Removes an item from the history. If the item is locked it is not removed.
+#_result = obj:DeleteHistoryItem (HistoryType, ItemId)
+#_
+#_**Parameters:**
+#_  HistoryType: string, one of "FSSF_HISTORY_CMD", "FSSF_HISTORY_FOLDER", "FSSF_HISTORY_VIEW" or "FSSF_HISTORY_EDIT"
+#_  ItemId:      number. The ID can be retrieved via a call to 'Enum.'
+#_
+#_**Returns:**
+#_  result: boolean true if the item has been really deleted, false otherwise
+#_
+#_**Far API used:**
+#_  SettingsControl
+#_
+#_@@@
+#_
+</article>
+</node>
+
+
+<node>
 id=82
 lv=1
 dt=Text
Index: plugins/common/unicode/plugin.hpp
===================================================================
--- plugins/common/unicode/plugin.hpp	(revision 11273)
+++ plugins/common/unicode/plugin.hpp	(working copy)
@@ -1724,6 +1724,7 @@
 	SCTL_DELETE                     = 5,
 	SCTL_CREATESUBKEY               = 6,
 	SCTL_OPENSUBKEY                 = 7,
+	SCTL_DELETE_HISTORY_ITEM        = 8, // Param1 is the history type (see FSSF_HISTORY_xyz), Param2 is a pointer to the ID of the item to delete
 };
 
 enum FARSETTINGSTYPES
@@ -1812,6 +1813,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/farapi.lua
===================================================================
--- plugins/luamacro/farapi.lua	(revision 11273)
+++ plugins/luamacro/farapi.lua	(working copy)
@@ -1692,6 +1692,7 @@
 	SCTL_DELETE                     = 5,
 	SCTL_CREATESUBKEY               = 6,
 	SCTL_OPENSUBKEY                 = 7,
+	SCTL_DELETE_HISTORY_ITEM        = 8, // Param1 is the history type (see FSSF_HISTORY_xyz), Param2 is a pointer to the ID of the item to delete
 };
 
 enum FARSETTINGSTYPES
@@ -1780,6 +1781,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: plugins/luamacro/luafar/service.c
===================================================================
--- plugins/luamacro/luafar/service.c	(revision 11273)
+++ plugins/luamacro/luafar/service.c	(working copy)
@@ -5343,6 +5343,17 @@
 	return 1;
 }
 
+static int Settings_deletehistoryitem(lua_State *L)
+{
+	FarSettingsUdata* udata = CheckSettings(L, 1);
+	int historyType = (int)check_env_flag(L, 2);
+	unsigned __int64 itemId = (unsigned __int64)luaL_checkinteger(L,3);
+	int deleted = GetPluginData(L)->Info->SettingsControl(udata->Handle, SCTL_DELETE_HISTORY_ITEM, historyType, &itemId);
+	lua_pushinteger(L, deleted);
+
+	return 1;
+}
+
 static int Settings_enum(lua_State *L)
 {
 	struct FarSettingsEnum fse;
@@ -5373,7 +5384,7 @@
 			if(udata->IsFarSettings)
 			{
 				const struct FarSettingsHistory *fsh = fse.Value.Histories + i;
-				lua_createtable(L, 0, 6);
+				lua_createtable(L, 0, 7);
 
 				if(fsh->Name) PutWStrToTable(L, "Name", fsh->Name, -1);
 
@@ -5386,6 +5397,7 @@
 				pushFileTime(L, &fsh->Time);
 				lua_setfield(L, -2, "Time");
 				PutBoolToTable(L, "Lock", fsh->Lock);
+				PutNumToTable(L, "Id", (double)fsh->Id);
 			}
 			else
 			{
@@ -5518,6 +5530,7 @@
 	{"Set",                 Settings_set},
 	{"CreateSubkey",        Settings_createsubkey},
 	{"OpenSubkey",          Settings_opensubkey},
+	{"DeleteHistoryItem",   Settings_deletehistoryitem},
 	{NULL, NULL},
 };
 
Index: unicode_far/plugapi.cpp
===================================================================
--- unicode_far/plugapi.cpp	(revision 11273)
+++ unicode_far/plugapi.cpp	(working copy)
@@ -2387,6 +2387,8 @@
 		case SCTL_CREATESUBKEY:
 		case SCTL_OPENSUBKEY:
 			return CheckStructSize((const FarSettingsValue*)Param2)?settings->SubKey(*(const FarSettingsValue*)Param2, Command==SCTL_CREATESUBKEY):0;
+		case SCTL_DELETE_HISTORY_ITEM:
+			return (unsigned __int64*)Param2 ? settings->DeleteHistoryItem((int)Param1, *(unsigned __int64*)Param2) : FALSE;
 	}
 
 	return FALSE;
Index: unicode_far/plugin.hpp
===================================================================
--- unicode_far/plugin.hpp	(revision 11273)
+++ unicode_far/plugin.hpp	(working copy)
@@ -1876,6 +1876,7 @@
 	SCTL_DELETE                     = 5,
 	SCTL_CREATESUBKEY               = 6,
 	SCTL_OPENSUBKEY                 = 7,
+	SCTL_DELETE_HISTORY_ITEM        = 8, // Param1 is the history type (see FSSF_HISTORY_xyz), Param2 is a pointer to the ID of the item to delete
 };
 
 enum FARSETTINGSTYPES
@@ -1970,6 +1971,7 @@
 	const wchar_t* File;
 	FILETIME Time;
 	BOOL Lock;
+	unsigned __int64 Id;
 };
 
 struct FarSettingsEnum
Index: unicode_far/plugsettings.cpp
===================================================================
--- unicode_far/plugsettings.cpp	(revision 11273)
+++ unicode_far/plugsettings.cpp	(working copy)
@@ -295,6 +295,11 @@
 	return result;
 }
 
+int PluginSettings::DeleteHistoryItem(int HistoryType, unsigned __int64 itemId)
+{
+	return FALSE;
+}
+
 int FarSettings::Set(const FarSettingsItem& Item)
 {
 	return FALSE;
@@ -444,6 +449,37 @@
 	return Save? Global->Db->HistoryCfg().get() : Global->Db->HistoryCfgMem().get();
 }
 
+static History* getHistory(FARSETTINGS_SUBFOLDERS HistoryType)
+{
+	History *result;
+	switch(HistoryType)
+	{
+		case FSSF_HISTORY_CMD:
+			result = Global->CtrlObject->CmdHistory;
+			break;
+		case FSSF_HISTORY_FOLDER:
+			result = Global->CtrlObject->FolderHistory;
+			break;
+		case FSSF_HISTORY_VIEW:
+		case FSSF_HISTORY_EDIT:
+			result = Global->CtrlObject->ViewHistory;
+			break;
+		default:
+			result = nullptr;
+			break;
+	}
+	return result;
+}
+
+int FarSettings::DeleteHistoryItem(int HistoryType, unsigned __int64 itemId)
+{
+	History *history = getHistory((FARSETTINGS_SUBFOLDERS)HistoryType);
+	if (!history)
+		return FALSE;
+	
+	return history->DeleteIfUnlocked(itemId);
+}
+
 int FarSettings::FillHistory(int Type,const string& HistoryName,FarSettingsEnum& Enum,HistoryFilter Filter)
 {
 	m_Enum.emplace_back(std::make_unique<FarSettingsHistoryItems>());
@@ -463,6 +499,7 @@
 			item.Lock=HLock;
 			GUID Guid;
 			if(strGuid.empty()||!StrToGuid(strGuid,Guid)) Guid=FarGuid;
+			item.Id=id;
 			AddItem(m_Enum.back().get(),item,strName,strData,Guid,strFile);
 		}
 	}
Index: unicode_far/plugsettings.hpp
===================================================================
--- unicode_far/plugsettings.hpp	(revision 11273)
+++ unicode_far/plugsettings.hpp	(working copy)
@@ -50,6 +50,8 @@
 		virtual int Enum(FarSettingsEnum& Enum)=0;
 		virtual int Delete(const FarSettingsValue& Value)=0;
 		virtual int SubKey(const FarSettingsValue& Value, bool bCreate)=0;
+		// Deletes the history item if it is not locked. Returns TRUE if the item was really deleted and FALSE otherwise.
+		virtual int DeleteHistoryItem(int HistoryType, unsigned __int64 itemId)=0;
 };
 
 class FarSettingsNameItems
@@ -80,6 +82,7 @@
 		int Enum(FarSettingsEnum& Enum);
 		int Delete(const FarSettingsValue& Value);
 		int SubKey(const FarSettingsValue& Value, bool bCreate);
+		int DeleteHistoryItem(int HistoryType, unsigned __int64 itemId);
 };
 
 class FarSettingsHistoryItems
@@ -110,4 +113,5 @@
 		int Enum(FarSettingsEnum& Enum);
 		int Delete(const FarSettingsValue& Value);
 		int SubKey(const FarSettingsValue& Value, bool bCreate);
+		int DeleteHistoryItem(int HistoryType, unsigned __int64 itemId);
 };

fml2

2013-12-25 21:41

reporter   bugnote:0011609

Last edited: 2013-12-25 21:51

Загрузил патч, в котором работает все: и возврат ID для записей истории (результат вызова "Enum"), и удаление записей из истории.

АПИ сделан так, что удалить можно только записи из истории (команд/папок/просмотра), а не любые произвольные настройки Фара.

Патч: http://bugs.farmanager.com/file_download.php?file_id=1157&type=bug

Пример вызова в LuaFar:

local settings = far.CreateSettings("far")
local deleted = settings:DeleteHistoryItem("FSSF_HISTORY_CMD", 164)

fml2

2013-12-28 13:00

reporter   bugnote:0011612

Last edited: 2013-12-28 13:02

Ввиду того, что патч ломает двоиную совместимость плагиновского АПИ, а также того, что реализация этого совместимым образом возможна, но сопряжена с довольно объемными и не очень "красивыми" выкрутасами, работу над фичей прекращаю.

Обсуждение см. здесь: http://forum.farmanager.com/viewtopic.php?f=57&t=8378

Issue History

Date Modified Username Field Change
2013-11-25 18:15 fml2 New Issue
2013-12-13 23:14 fml2 Note Added: 0011598
2013-12-13 23:34 fml2 Note Edited: 0011598
2013-12-24 19:44 fml2 File Added: IdInHistoryItems.diff
2013-12-24 19:45 fml2 File Added: IdInHistoryItems_LuaFar.diff
2013-12-24 19:47 fml2 Note Added: 0011602
2013-12-24 21:00 fml2 File Added: IdInHistoryItems_LuaFar_2.diff
2013-12-24 21:07 fml2 Note Added: 0011603
2013-12-24 21:26 fml2 File Added: IdInHistoryItems_Combined.diff
2013-12-24 21:27 fml2 Note Added: 0011604
2013-12-24 22:50 fml2 File Added: IdInHistoryItems_Combined_2.diff
2013-12-24 22:51 fml2 Note Added: 0011605
2013-12-25 10:49 fml2 File Added: IdInHistoryItems_Combined_3.diff
2013-12-25 10:50 fml2 Note Added: 0011606
2013-12-25 11:35 vskirdin Note Added: 0011607
2013-12-25 12:16 fml2 Note Added: 0011608
2013-12-25 21:39 fml2 File Added: IdInHistoryItems_Combined_4.diff
2013-12-25 21:41 fml2 Note Added: 0011609
2013-12-25 21:51 fml2 Note Edited: 0011609
2013-12-25 21:51 fml2 Note Edited: 0011609
2013-12-28 13:00 fml2 Note Added: 0011612
2013-12-28 13:02 fml2 Note Edited: 0011612