Index: viewer.hpp
===================================================================
--- viewer.hpp	(revision 5887)
+++ viewer.hpp	(working copy)
@@ -163,7 +163,11 @@
 		bool m_bQuickView;
 
 		UINT DefCodePage;
+
 		int vgetc_ready;
+		__int64 EOF_Pos;
+		int update_check_period;
+		DWORD last_update_check;
 
 	private:
 		virtual void DisplayObject();
Index: viewer.cpp
===================================================================
--- viewer.cpp	(revision 5887)
+++ viewer.cpp	(working copy)
@@ -128,6 +128,7 @@
 	bVE_READ_Sent = false;
 	Signature = false;
 	vgetc_ready = -1;
+   EOF_Pos = -1;
 }
 
 
@@ -376,6 +377,23 @@
 	   пора легализироваться */
 	CtrlObject->Plugins.ProcessViewerEvent(VE_READ,nullptr);
 	bVE_READ_Sent = true;
+
+	last_update_check = GetTickCount();
+	string strRoot;
+	GetPathRoot(strFullFileName, strRoot);
+	int DriveType = FAR_GetDriveType(strRoot);
+	if (IsDriveTypeCDROM(DriveType))
+		DriveType = DRIVE_CDROM;
+	switch (DriveType) //??? make it configurable
+	{
+		case DRIVE_REMOVABLE: update_check_period = -1;   break; // flash drive or floppy: never
+		case DRIVE_FIXED:     update_check_period = +1;   break; // hard disk: 1msec
+		case DRIVE_REMOTE:    update_check_period = 1000; break; // network drive: 1sec
+		case DRIVE_CDROM:     update_check_period = -1;   break; // cd/dvd: never
+		case DRIVE_RAMDISK:   update_check_period = +1;   break; // ramdrive: 1msec
+		default:              update_check_period = -1;   break; // unknown: never
+	}
+
 	return TRUE;
 }
 
@@ -454,7 +472,11 @@
 	if (!SelectSize)
 		SelectPos=FilePos;
 
-	switch (nMode)
+   __int64 last_filepos = -1;
+   bool eof_mode = EOF_Pos >= 0 && nMode == SHOW_RELOAD;
+   do {
+   
+   switch (nMode)
 	{
 		case SHOW_HEX:
 			CtrlObject->Plugins.CurViewer = this; //HostFileViewer;
@@ -473,6 +495,13 @@
 				ReadString(Strings[I],-1,MAX_VIEWLINEB);
 			}
 
+         if (eof_mode)
+         {
+            last_filepos = vtell();
+            eof_mode = last_filepos < EOF_Pos;
+            if (eof_mode)
+               nMode = SHOW_DOWN;
+         }
 			break;
 		case SHOW_UP:
 
@@ -506,8 +535,20 @@
 			ReadString(Strings[Y2-Y1],-1,MAX_VIEWLINEB);
 			Strings[Y2-Y1]->nFilePos = vtell();
 			ReadString(Strings[Y2-Y1],-1,MAX_VIEWLINEB);
+
+         if (eof_mode)
+         {
+            __int64 fpos = vtell();
+            if (fpos >= EOF_Pos || fpos <= last_filepos)
+            {
+               eof_mode = false; nMode = SHOW_RELOAD;
+            }
+            else
+               last_filepos = fpos;
+         }
 			break;
 	}
+   } while ( eof_mode );
 
 	if (nMode != SHOW_HEX)
 	{
@@ -676,7 +717,7 @@
 
 					if (!X)
 					{
-						*OutStr=0;
+						*OutStr = L'\0';
 						break;
 					}
 
@@ -721,7 +762,7 @@
 
 			if (!nr)
 			{
-				*OutStr=0;
+				*OutStr = L'\0';
 			}
 			else
 			{
@@ -816,7 +857,7 @@
 
 					if (!X)
 					{
-						*OutStr=0;
+						*OutStr = L'\0';
 						break;
 					}
 
@@ -1269,42 +1310,39 @@
 		}
 		case KEY_IDLE:
 		{
-			if (ViewFile.Opened())
+			if (ViewFile.Opened() && update_check_period >= 0)
 			{
-				string strRoot;
-				GetPathRoot(strFullFileName, strRoot);
-				int DriveType=FAR_GetDriveType(strRoot);
+				DWORD now_ticks = GetTickCount();
+				if ((int)(now_ticks - last_update_check) < update_check_period)
+					return TRUE;
+				last_update_check = now_ticks;
 
-				if (DriveType!=DRIVE_REMOVABLE && !IsDriveTypeCDROM(DriveType))
-				{
-					FAR_FIND_DATA_EX NewViewFindData;
+				FAR_FIND_DATA_EX NewViewFindData;
+				if (!apiGetFindDataEx(strFullFileName, NewViewFindData))
+					return TRUE;
 
-					if (!apiGetFindDataEx(strFullFileName, NewViewFindData))
-						return TRUE;
+				ViewFile.FlushBuffers();
+				vseek(0,SEEK_END);
+				__int64 CurFileSize=vtell();
 
-					ViewFile.FlushBuffers();
-					vseek(0,SEEK_END);
-					__int64 CurFileSize=vtell();
+				if (ViewFindData.ftLastWriteTime.dwLowDateTime!=NewViewFindData.ftLastWriteTime.dwLowDateTime
+				 || ViewFindData.ftLastWriteTime.dwHighDateTime!=NewViewFindData.ftLastWriteTime.dwHighDateTime
+				 || CurFileSize!=FileSize)
+				{
+					ViewFindData=NewViewFindData;
+					FileSize=CurFileSize;
 
-					if (ViewFindData.ftLastWriteTime.dwLowDateTime!=NewViewFindData.ftLastWriteTime.dwLowDateTime ||
-					        ViewFindData.ftLastWriteTime.dwHighDateTime!=NewViewFindData.ftLastWriteTime.dwHighDateTime ||
-					        CurFileSize!=FileSize)
+					if (FilePos>FileSize)
+						ProcessKey(KEY_CTRLEND);
+					else
 					{
-						ViewFindData=NewViewFindData;
-						FileSize=CurFileSize;
+						__int64 PrevLastPage=LastPage;
+						Show();
 
-						if (FilePos>FileSize)
+						if (PrevLastPage && !LastPage)
+						{
 							ProcessKey(KEY_CTRLEND);
-						else
-						{
-							__int64 PrevLastPage=LastPage;
-							Show();
-
-							if (PrevLastPage && !LastPage)
-							{
-								ProcessKey(KEY_CTRLEND);
-								LastPage=TRUE;
-							}
+							LastPage=TRUE;
 						}
 					}
 				}
@@ -1796,6 +1834,8 @@
 				}
 
 				FilePos=vtell();
+            if (!VM.Hex && VM.Wrap && VM.WordWrap)
+               EOF_Pos = FilePos; //!!! hack to adjust possible incorrect last page show
 
 				/*
 				        {
@@ -1826,6 +1866,7 @@
 				        }
 				*/
 				Show();
+            EOF_Pos = -1;
 //        LastSelPos=FilePos;
 			}
 
