View Issue Details

IDProjectCategoryView StatusLast Update
0002226Wishes_Commonpublic2013-02-03 00:33
ReporterDAtaMan Assigned Tovskirdin  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Version3.0 
Fixed in Version3.0 
Summary0002226: Транслитерация в фильтрах меню
DescriptionХотелось бы, чтобы Xlat работал бы и в фильтрах меню
Additional InformationПатч приложен
TagsNo tags attached.
Build3031

Activities

DAtaMan

2012-12-17 09:28

reporter  

VMenuXlat.diff (7,211 bytes)   
Index: vmenu.cpp
===================================================================
--- vmenu.cpp	(revision 9188)
+++ vmenu.cpp	(working copy)
@@ -58,6 +58,7 @@
 #include "pathmix.hpp"
 #include "cmdline.hpp"
 #include "FarGuid.hpp"
+#include "xlat.hpp"
 
 VMenu::VMenu(const wchar_t *Title,       // ��������� ���
              MenuDataEx *Data, // ����� ���
@@ -663,11 +664,12 @@
 	SetSelectPos(&pos);
 }
 
-void VMenu::FilterStringUpdated(bool bLonger)
+void VMenu::FilterStringUpdated()
 {
 	int PrevSeparator = -1, PrevGroup = -1;
 	int UpperVisible = -1, LowerVisible = -2;
 	bool bBottomMode = false;
+	string strName;
 
 	if (SelectPos > 0)
 	{
@@ -679,40 +681,44 @@
 			bBottomMode = true;
 	}
 
-	if (bLonger)
-	{
-		//������ ������ ���������
+	MenuItemEx *CurItem=nullptr;
+	ItemHiddenCount=0;
+
 		for (int i=0; i < ItemCount; i++)
 		{
-			// ��� ����� ��������� ����� �� �����������
-			if (ItemIsVisible(Item[i]->Flags))
+			CurItem=Item[i];
+			CurItem->Flags &= ~LIF_HIDDEN;
+			strName=CurItem->strName;
+			if (CurItem->Flags & LIF_SEPARATOR)
 			{
-				if (Item[i]->Flags & LIF_SEPARATOR)
+						// � �������� ������ ��� ������� ����, ���������� ����� ������� - �� �����
+						if (PrevSeparator != -1)
+						{
+							Item[PrevSeparator]->Flags |= LIF_HIDDEN;
+							ItemHiddenCount++;
+						}
+				if (strName.IsEmpty() && PrevGroup == -1)
 				{
-					// � �������� ������ ��� ������� ����, ���������� ����� ������� - �� �����
-					if (PrevSeparator != -1)
-					{
-						Item[PrevSeparator]->Flags |= LIF_HIDDEN;
-						ItemHiddenCount++;
-					}
-					if (Item[i]->strName.IsEmpty() && PrevGroup == -1)
-					{
-						Item[i]->Flags |= LIF_HIDDEN;
-						ItemHiddenCount++;
-						PrevSeparator = -1;
-					}
-					else
-					{
-						PrevSeparator = i;
-					}
+					CurItem->Flags |= LIF_HIDDEN;
+					ItemHiddenCount++;
+					PrevSeparator = -1;
 				}
-				else if (!StrStrI(Item[i]->strName, strFilter))
+				else
 				{
-					Item[i]->Flags |= LIF_HIDDEN;
+					PrevSeparator = i;
+				}
+			}
+			else
+			{
+				RemoveExternalSpaces(strName);
+				RemoveChar(strName,L'&',TRUE);
+				if(!StrStrI(strName, strFilter))
+				{
+					CurItem->Flags |= LIF_HIDDEN;
 					ItemHiddenCount++;
 					if (SelectPos == i)
 					{
-						Item[i]->Flags &= ~LIF_SELECTED;
+						CurItem->Flags &= ~LIF_SELECTED;
 						SelectPos = -1;
 						LowerVisible = -1;
 					}
@@ -722,15 +728,15 @@
 					PrevGroup = i;
 					if (LowerVisible == -2)
 					{
-						if (ItemCanHaveFocus(Item[i]->Flags))
+						if (ItemCanHaveFocus(CurItem->Flags))
 							UpperVisible = i;
 					}
 					else if (LowerVisible == -1)
 					{
-						if (ItemCanHaveFocus(Item[i]->Flags))
-							LowerVisible = i;
+					if (ItemCanHaveFocus(CurItem->Flags))
+						LowerVisible = i;
 					}
-					// ���� ���������� - ������� ������
+						// ���� ���������� - ������� ������
 					if (PrevSeparator != -1)
 						PrevSeparator = -1;
 				}
@@ -742,52 +748,8 @@
 			Item[PrevSeparator]->Flags |= LIF_HIDDEN;
 			ItemHiddenCount++;
 		}
-	}
-	else
-	{
-		//������ ������ ����������
-		for (int i=0; i < ItemCount; i++)
-		{
-			if (!ItemIsVisible(Item[i]->Flags))
-			{
-				if (Item[i]->Flags & LIF_SEPARATOR)
-				{
-					PrevSeparator = i;
-				}
-				else if (StrStrI(Item[i]->strName, strFilter))
-				{
-					Item[i]->Flags &= ~LIF_HIDDEN;
-					ItemHiddenCount--;
-				}
-			}
 
-			if (ItemIsVisible(Item[i]->Flags))
-			{
-				if (Item[i]->Flags & LIF_SEPARATOR)
-				{
-					PrevGroup = -1;
-					if ((PrevSeparator != -1))
-						PrevSeparator = -1;
-				}
-				else
-				{
-					if (PrevSeparator != -1)
-					{
-						if (!Item[PrevSeparator]->strName.IsEmpty() || PrevGroup != -1)
-						{
-							// ���������� ����� ����� ������ ������� �� ����
-							Item[PrevSeparator]->Flags &= ~LIF_HIDDEN;
-							ItemHiddenCount--;
-						}
-						PrevSeparator = -1;
-					}
-					PrevGroup = i;
-				}
-			}
-		}
-
 		FilterUpdateHeight();
-	}
 
 	if (GetShowItemCount()>0)
 	{
@@ -1135,7 +1097,7 @@
 					strFilter.Clear();
 					if (vParam!=nullptr)
 						AddToFilter(((string *)vParam)->CPtr());
-					FilterStringUpdated(true);
+					FilterStringUpdated();
 					bFilterLocked = prevLocked;
 					DisplayObject();
 					*(string *)vParam = oldFilter;
@@ -1215,7 +1177,7 @@
 		strFilter += (wchar_t)Key;
 	}
 
-	FilterStringUpdated(Key!=KEY_BS);
+	FilterStringUpdated();
 	DisplayObject();
 
 	return TRUE;
@@ -1240,7 +1202,7 @@
 			if (strFilter.IsEmpty())
 				RestoreFilteredItems();
 			else
-				FilterStringUpdated(true);
+				FilterStringUpdated();
 
 			DisplayObject();
 
@@ -1256,7 +1218,7 @@
 	{
 		if ((Key!=KEY_F1 && Key!=KEY_SHIFTF1 && Key!=KEY_F10 && Key!=KEY_ESC && Key!=KEY_ALTF9 && Key!=KEY_RALTF9))
 		{
-			if (!bFilterEnabled || (bFilterEnabled && Key!=KEY_BS && Key!=KEY_CTRLALTF && Key!=KEY_RCTRLRALTF && Key!=KEY_CTRLRALTF && Key!=KEY_RCTRLALTF))
+			if (!bFilterEnabled || (bFilterEnabled && Key!=KEY_BS && Key!=KEY_CTRLALTF && Key!=KEY_RCTRLRALTF && Key!=KEY_CTRLRALTF && Key!=KEY_RCTRLALTF && Key!=KEY_OP_XLAT))
 			{
 				Modal::ExitCode = -1;
 				return FALSE;
@@ -1480,7 +1442,7 @@
 					if (strFilter.IsEmpty())
 						RestoreFilteredItems();
 					else
-						FilterStringUpdated(true);
+						FilterStringUpdated();
 
 					DisplayObject();
 				}
@@ -1501,6 +1463,34 @@
 				break;
 			}
 		}
+		case KEY_OP_XLAT:
+		{
+			if (bFilterEnabled && !bFilterLocked)
+			{
+				const wchar_t *FilterString=strFilter;
+				int start=StrLength(FilterString);
+				bool DoXlat=TRUE;
+
+				if (IsWordDiv(Global->Opt->XLat.strWordDivForXlat,FilterString[start]))
+				{
+					if (start) start--;
+					DoXlat=(!IsWordDiv(Global->Opt->XLat.strWordDivForXlat,FilterString[start]));
+				}
+
+				if (DoXlat)
+				{
+					while (start>=0 && !IsWordDiv(Global->Opt->XLat.strWordDivForXlat,FilterString[start]))
+						start--;
+
+					start++;
+					::Xlat((wchar_t *) FilterString,start,StrLength(FilterString),Global->Opt->XLat.Flags);
+					SetFilterString(FilterString);
+					FilterStringUpdated();
+					DisplayObject();
+				}
+			}
+			break;
+		}
 		case KEY_TAB:
 		case KEY_SHIFTTAB:
 		default:
@@ -1969,7 +1959,7 @@
 		{
 			RestoreFilteredItems();
 			if (!strFilter.IsEmpty())
-				FilterStringUpdated(true);
+				FilterStringUpdated();
 		}
 		ClearFlags(VMENU_REFILTERREQUIRED);
 	}
Index: vmenu.hpp
===================================================================
--- vmenu.hpp	(revision 9188)
+++ vmenu.hpp	(working copy)
@@ -327,7 +327,7 @@
 		int  FindItem(const FarListFind *FindItem);
 		int  FindItem(int StartIndex,const wchar_t *Pattern,UINT64 Flags=0);
 		void RestoreFilteredItems();
-		void FilterStringUpdated(bool bLonger);
+		void FilterStringUpdated();
 		void FilterUpdateHeight(bool bShrink=false);
 		void SetFilterEnabled(bool bEnabled) { bFilterEnabled=bEnabled; };
 		void SetFilterLocked(bool bLocked) { bFilterEnabled=bLocked; };
VMenuXlat.diff (7,211 bytes)   

vskirdin

2012-12-18 07:35

administrator   bugnote:0009888

build 3031

DAtaMan

2012-12-18 09:06

reporter   bugnote:0009891

Ок, спасибо.

Issue History

Date Modified Username Field Change
2012-12-17 09:27 DAtaMan New Issue
2012-12-17 09:28 DAtaMan File Added: VMenuXlat.diff
2012-12-17 13:31 vskirdin Assigned To => vskirdin
2012-12-17 13:31 vskirdin Status new => assigned
2012-12-18 07:35 vskirdin Note Added: 0009888
2012-12-18 07:35 vskirdin Status assigned => feedback
2012-12-18 09:06 DAtaMan Note Added: 0009891
2012-12-18 09:06 DAtaMan Status feedback => assigned
2012-12-18 09:06 DAtaMan Status assigned => resolved
2012-12-19 07:05 vskirdin Build => 3031
2012-12-19 07:05 vskirdin Status resolved => closed
2012-12-19 07:05 vskirdin Resolution open => fixed
2012-12-19 07:05 vskirdin Fixed in Version => 3.0
2013-02-03 00:33 alexy Severity minor => feature