FAR-SVN [commit]: unicode_far: r7857 - trunk/unicode_far

0 views
Skip to first unread message

s...@farmanager.com

unread,
Apr 11, 2012, 10:43:51 AM4/11/12
to farco...@googlegroups.com
Author: zg
Date: Wed Apr 11 16:43:50 2012
New Revision: 7857

Log:
1. 0002004: Не сохраняется история команд в пределах сеанса.

2. gcc warning.


Modified:
trunk/unicode_far/changelog
trunk/unicode_far/configdb.cpp
trunk/unicode_far/configdb.hpp
trunk/unicode_far/dialog.cpp
trunk/unicode_far/history.cpp
trunk/unicode_far/history.hpp
trunk/unicode_far/pathmix.cpp
trunk/unicode_far/plugsettings.cpp
trunk/unicode_far/vbuild.m4

Modified: trunk/unicode_far/changelog
==============================================================================
--- trunk/unicode_far/changelog (original)
+++ trunk/unicode_far/changelog Wed Apr 11 16:43:50 2012
@@ -1,3 +1,9 @@
+zg 11.04.2012 17:38:32 +0200 - build 2603
+
+1. 0002004: пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ.
+
+2. gcc warning.
+
w17 11.04.2012 15:39:21 +0400 - build 2602

1. пїЅпїЅпїЅпїЅпїЅ 2599.2

Modified: trunk/unicode_far/configdb.cpp
==============================================================================
--- trunk/unicode_far/configdb.cpp (original)
+++ trunk/unicode_far/configdb.cpp Wed Apr 11 16:43:50 2012
@@ -58,6 +58,7 @@
PluginsCacheConfig *PlCacheCfg;
PluginsHotkeysConfig *PlHotkeyCfg;
HistoryConfig *HistoryCfg;
+HistoryConfig *HistoryCfgMem;
MacroConfig *MacroCfg;

int IntToHex(int h)
@@ -2493,6 +2494,14 @@

};

+class HistoryConfigMemoryDb: public HistoryConfigDb {
+public:
+ HistoryConfigMemoryDb()
+ {
+ Initialize(L":memory:", true);
+ }
+};
+
class MacroConfigDb: public MacroConfig, public SQLiteDb {
SQLiteStmt stmtConstsEnum;
SQLiteStmt stmtGetConstValue;
@@ -2535,7 +2544,7 @@
"CREATE TABLE IF NOT EXISTS key_macros(area TEXT NOT NULL, key TEXT NOT NULL, flags TEXT, sequence TEXT, description TEXT, PRIMARY KEY (area, key));"
)
) return false;
-
+
if (
InitStmt(stmtConstsEnum, L"SELECT name, value, type FROM constants ORDER BY name;") &&
InitStmt(stmtGetConstValue, L"SELECT value, type FROM constants WHERE name=?1;") &&
@@ -3009,7 +3018,7 @@
const wchar_t* pname = nullptr;
int rc = pDb->InitStatus(pname, err_report);
if ( rc > 0 )
- {
+ {
if ( err_report )
{
Console.Write(L"problem\r\n ", 11);
@@ -3034,6 +3043,7 @@
NEW_DB(PlCacheCfg, PluginsCacheConfigDb)
NEW_DB(PlHotkeyCfg, PluginsHotkeysConfigDb)
NEW_DB(HistoryCfg, HistoryConfigDb)
+ NEW_DB(HistoryCfgMem, HistoryConfigMemoryDb)
NEW_DB(MacroCfg, MacroConfigDb)
}

@@ -3041,6 +3051,7 @@
{
nProblem = 0;
delete MacroCfg;
+ delete HistoryCfgMem;
delete HistoryCfg;
delete PlHotkeyCfg;
delete PlCacheCfg;

Modified: trunk/unicode_far/configdb.hpp
==============================================================================
--- trunk/unicode_far/configdb.hpp (original)
+++ trunk/unicode_far/configdb.hpp Wed Apr 11 16:43:50 2012
@@ -266,6 +266,7 @@
extern PluginsCacheConfig *PlCacheCfg;
extern PluginsHotkeysConfig *PlHotkeyCfg;
extern HistoryConfig *HistoryCfg;
+extern HistoryConfig *HistoryCfgMem;
extern MacroConfig *MacroCfg;

void InitDb(bool err_report=false);

Modified: trunk/unicode_far/dialog.cpp
==============================================================================
--- trunk/unicode_far/dialog.cpp (original)
+++ trunk/unicode_far/dialog.cpp Wed Apr 11 16:43:50 2012
@@ -987,16 +987,21 @@

if (strData.IsEmpty())
{
- History::ReadLastItem(CurItem->strHistory, strData);
+ DlgEdit *EditPtr;

- if (MsgIndex != -1)
+ if ((EditPtr = (DlgEdit *)(CurItem->ObjPtr)) )
{
- // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ DM_SETHISTORY => пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ
- // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ
- FarDialogItemData IData={sizeof(FarDialogItemData)};
- IData.PtrData=const_cast<wchar_t*>(strData.CPtr());
- IData.PtrLength=strData.GetLength();
- SendDlgMessage(this,DM_SETTEXT,MsgIndex,&IData);
+ EditPtr->GetHistory()->ReadLastItem(CurItem->strHistory, strData);
+
+ if (MsgIndex != -1)
+ {
+ // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ DM_SETHISTORY => пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ
+ // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ
+ FarDialogItemData IData={sizeof(FarDialogItemData)};
+ IData.PtrData=const_cast<wchar_t*>(strData.CPtr());
+ IData.PtrLength=strData.GetLength();
+ SendDlgMessage(this,DM_SETTEXT,MsgIndex,&IData);
+ }
}
}
}

Modified: trunk/unicode_far/history.cpp
==============================================================================
--- trunk/unicode_far/history.cpp (original)
+++ trunk/unicode_far/history.cpp Wed Apr 11 16:43:50 2012
@@ -90,7 +90,7 @@
*/
void History::AddToHistory(const wchar_t *Str, int Type, const GUID* Guid, const wchar_t *File, const wchar_t *Data, bool SaveForbid)
{
- if (!EnableAdd || !*EnableSave || SaveForbid)
+ if (!EnableAdd || SaveForbid)
return;

if (CtrlObject->Macro.IsExecuting() && CtrlObject->Macro.IsHistoryDisable((int)TypeHistory))
@@ -103,7 +103,7 @@
string strName(Str),strGuid,strFile(File),strData(Data);
if(Guid) strGuid=GuidToStr(*Guid);

- HistoryCfg->BeginTransaction();
+ HistoryCfgRef()->BeginTransaction();

if (RemoveDups) // пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ?
{
@@ -113,7 +113,7 @@
bool HLock;
unsigned __int64 id;
unsigned __int64 Time;
- while (HistoryCfg->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData))
+ while (HistoryCfgRef()->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData))
{
if (EqualType(Type,HType))
{
@@ -122,24 +122,24 @@
if (!StrCmpFn(strName,strHName)&&!StrCmpFn(strGuid,strHGuid)&&!StrCmpFn(strFile,strHFile)&&!StrCmpFn(strData,strHData))
{
Lock = Lock || HLock;
- HistoryCfg->Delete(id);
+ HistoryCfgRef()->Delete(id);
break;
}
}
}
}

- HistoryCfg->Add(TypeHistory, strHistoryName, strName, Type, Lock, strGuid, strFile, strData);
+ HistoryCfgRef()->Add(TypeHistory, strHistoryName, strName, Type, Lock, strGuid, strFile, strData);

ResetPosition();

- HistoryCfg->EndTransaction();
+ HistoryCfgRef()->EndTransaction();
}

bool History::ReadLastItem(const wchar_t *HistoryName, string &strStr)
{
strStr.Clear();
- return HistoryCfg->GetNewest(HISTORYTYPE_DIALOG, HistoryName, strStr);
+ return HistoryCfgRef()->GetNewest(HISTORYTYPE_DIALOG, HistoryName, strStr);
}

const wchar_t *History::GetTitle(int Type)
@@ -204,7 +204,7 @@
bool Done=false;
bool SetUpMenuPos=false;

- if (TypeHistory == HISTORYTYPE_DIALOG && !HistoryCfg->Count(TypeHistory,strHistoryName))
+ if (TypeHistory == HISTORYTYPE_DIALOG && !HistoryCfgRef()->Count(TypeHistory,strHistoryName))
return 0;

while (!Done)
@@ -224,7 +224,7 @@
SYSTEMTIME st;
GetLocalTime(&st);
int LastDay=0, LastMonth = 0, LastYear = 0;
- while (HistoryCfg->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData,TypeHistory==HISTORYTYPE_DIALOG))
+ while (HistoryCfgRef()->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData,TypeHistory==HISTORYTYPE_DIALOG))
{
string strRecord;

@@ -359,7 +359,7 @@
{
bool ModifiedHistory=false;

- HistoryCfg->BeginTransaction();
+ HistoryCfgRef()->BeginTransaction();

DWORD index=0;
string strHName,strHGuid,strHFile,strHData;
@@ -367,7 +367,7 @@
bool HLock;
unsigned __int64 id;
unsigned __int64 Time;
- while (HistoryCfg->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData))
+ while (HistoryCfgRef()->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData))
{
if (HLock) // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ
continue;
@@ -385,12 +385,12 @@

if(kill)
{
- HistoryCfg->Delete(id);
+ HistoryCfgRef()->Delete(id);
ModifiedHistory=true;
}
}

- HistoryCfg->EndTransaction();
+ HistoryCfgRef()->EndTransaction();

if (ModifiedHistory) // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ
{
@@ -455,7 +455,7 @@
if (CurrentRecord)
{
string strName;
- if (HistoryCfg->Get(CurrentRecord, strName))
+ if (HistoryCfgRef()->Get(CurrentRecord, strName))
CopyToClipboard(strName);
}

@@ -467,7 +467,7 @@
{
if (CurrentRecord)
{
- HistoryCfg->FlipLock(CurrentRecord);
+ HistoryCfgRef()->FlipLock(CurrentRecord);
HistoryMenu.Hide();
ResetPosition();
HistoryMenu.Modal::SetExitCode(Pos.SelectPos);
@@ -481,10 +481,10 @@
case KEY_SHIFTNUMDEL:
case KEY_SHIFTDEL:
{
- if (CurrentRecord && !HistoryCfg->IsLocked(CurrentRecord))
+ if (CurrentRecord && !HistoryCfgRef()->IsLocked(CurrentRecord))
{
HistoryMenu.Hide();
- HistoryCfg->Delete(CurrentRecord);
+ HistoryCfgRef()->Delete(CurrentRecord);
ResetPosition();
HistoryMenu.Modal::SetExitCode(Pos.SelectPos);
HistoryMenu.SetUpdateRequired(TRUE);
@@ -506,7 +506,7 @@
MSG(MHistoryClear),
MSG(MClear),MSG(MCancel)))))
{
- HistoryCfg->DeleteAllUnlocked(TypeHistory,strHistoryName);
+ HistoryCfgRef()->DeleteAllUnlocked(TypeHistory,strHistoryName);

ResetPosition();
HistoryMenu.Hide();
@@ -537,7 +537,7 @@
return -1;


- if (!HistoryCfg->Get(SelectedRecord, strSelectedRecordName, &SelectedRecordType, strSelectedRecordGuid, strSelectedRecordFile, strSelectedRecordData))
+ if (!HistoryCfgRef()->Get(SelectedRecord, strSelectedRecordName, &SelectedRecordType, strSelectedRecordGuid, strSelectedRecordFile, strSelectedRecordData))
return -1;

//BUGUBUG: eliminate those magic numbers!
@@ -599,13 +599,13 @@

void History::GetPrev(string &strStr)
{
- CurrentItem = HistoryCfg->GetPrev(TypeHistory, strHistoryName, CurrentItem, strStr);
+ CurrentItem = HistoryCfgRef()->GetPrev(TypeHistory, strHistoryName, CurrentItem, strStr);
}


void History::GetNext(string &strStr)
{
- CurrentItem = HistoryCfg->GetNext(TypeHistory, strHistoryName, CurrentItem, strStr);
+ CurrentItem = HistoryCfgRef()->GetNext(TypeHistory, strHistoryName, CurrentItem, strStr);
}


@@ -623,14 +623,14 @@

int i=0;
string strName;
- unsigned __int64 HistoryItem=HistoryCfg->CyclicGetPrev(TypeHistory, strHistoryName, CurrentItem, strName);
+ unsigned __int64 HistoryItem=HistoryCfgRef()->CyclicGetPrev(TypeHistory, strHistoryName, CurrentItem, strName);
while (HistoryItem != CurrentItem)
{
if (!HistoryItem)
{
if (++i > 1) //infinite loop
break;
- HistoryItem = HistoryCfg->CyclicGetPrev(TypeHistory, strHistoryName, HistoryItem, strName);
+ HistoryItem = HistoryCfgRef()->CyclicGetPrev(TypeHistory, strHistoryName, HistoryItem, strName);
continue;
}

@@ -645,7 +645,7 @@
return true;
}

- HistoryItem = HistoryCfg->CyclicGetPrev(TypeHistory, strHistoryName, HistoryItem, strName);
+ HistoryItem = HistoryCfgRef()->CyclicGetPrev(TypeHistory, strHistoryName, HistoryItem, strName);
}

return false;
@@ -660,7 +660,7 @@
bool HLock;
unsigned __int64 id;
unsigned __int64 Time;
- while (HistoryCfg->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData,true))
+ while (HistoryCfgRef()->Enum(index++,TypeHistory,strHistoryName,&id,strHName,&HType,&HLock,&Time,strHGuid,strHFile,strHData,true))
{
if (!StrCmpNI(Str,strHName,Length))
{
@@ -685,9 +685,9 @@
bool History::DeleteIfUnlocked(unsigned __int64 id)
{
bool b = false;
- if (id && !HistoryCfg->IsLocked(id))
+ if (id && !HistoryCfgRef()->IsLocked(id))
{
- if (HistoryCfg->Delete(id))
+ if (HistoryCfgRef()->Delete(id))
{
b = true;
ResetPosition();
@@ -707,3 +707,8 @@
{
return Type1 == Type2 || (TypeHistory == HISTORYTYPE_VIEW && ((Type1 == 4 && Type2 == 1) || (Type1 == 1 && Type2 == 4)))?true:false;
}
+
+HistoryConfig* History::HistoryCfgRef(void)
+{
+ return (*EnableSave)?HistoryCfg:HistoryCfgMem;
+}

Modified: trunk/unicode_far/history.hpp
==============================================================================
--- trunk/unicode_far/history.hpp (original)
+++ trunk/unicode_far/history.hpp Wed Apr 11 16:43:50 2012
@@ -33,6 +33,8 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

+#include "configdb.hpp"
+
class Dialog;
class VMenu;

@@ -54,12 +56,11 @@
size_t HistoryCount;
const int *EnableSave;
unsigned __int64 CurrentItem;
-
private:
bool EqualType(int Type1, int Type2);
const wchar_t *GetTitle(int Type);
int ProcessMenu(string &strStr, GUID* Guid, string *File, string *Data, const wchar_t *Title, VMenu &HistoryMenu, int Height, int &Type, Dialog *Dlg);
-
+ HistoryConfig* HistoryCfgRef(void);
public:
History(enumHISTORYTYPE TypeHistory, const wchar_t *HistoryName, size_t HistoryCount, const int *EnableSave, bool SaveType);
~History();
@@ -74,7 +75,7 @@
void SetAddMode(bool EnableAdd, int RemoveDups, bool KeepSelectedPos);
void ResetPosition() { CurrentItem = 0; }
bool DeleteIfUnlocked(unsigned __int64 id);
+ bool ReadLastItem(const wchar_t *HistoryName, string &strStr);

- static bool ReadLastItem(const wchar_t *HistoryName, string &strStr);
static void CompactHistory();
};

Modified: trunk/unicode_far/pathmix.cpp
==============================================================================
--- trunk/unicode_far/pathmix.cpp (original)
+++ trunk/unicode_far/pathmix.cpp Wed Apr 11 16:43:50 2012
@@ -78,7 +78,7 @@
static bool REInit = false;
if(!REInit)
{
- int Result = 0;
+ int Result;
Result = PathTypes[0].re.Compile(L"/(^.\\:)/", OP_PERLSTYLE|OP_OPTIMIZE|OP_IGNORECASE); // x:<whatever>
assert(Result);
Result = PathTypes[1].re.Compile(L"/(^\\\\{2}[\\?\\.]\\\\.\\:)(?:[\\\\\\/]|$)/", OP_PERLSTYLE|OP_OPTIMIZE|OP_IGNORECASE); // \\?\x: or \\?\x:\ or \\?\x:\<whatever>

Modified: trunk/unicode_far/plugsettings.cpp
==============================================================================
--- trunk/unicode_far/plugsettings.cpp (original)
+++ trunk/unicode_far/plugsettings.cpp Wed Apr 11 16:43:50 2012
@@ -428,6 +428,27 @@
return result+FSSF_COUNT;
}

+static HistoryConfig* HistoryRef(int Type)
+{
+ int Save=true;
+ switch(Type)
+ {
+ case HISTORYTYPE_CMD:
+ Save=Opt.SaveHistory;
+ break;
+ case HISTORYTYPE_FOLDER:
+ Save=Opt.SaveFoldersHistory;
+ break;
+ case HISTORYTYPE_VIEW:
+ Save=Opt.SaveViewHistory;
+ break;
+ case HISTORYTYPE_DIALOG:
+ Save=Opt.Dialogs.EditHistory;
+ break;
+ }
+ return Save?HistoryCfg:HistoryCfgMem;
+}
+
int FarSettings::FillHistory(int Type,const string& HistoryName,FarSettingsEnum& Enum,HistoryFilter Filter)
{
Vector<FarSettingsHistory>& array=*m_Enum.addItem();
@@ -439,7 +460,7 @@
int HType;
bool HLock;
unsigned __int64 Time;
- while(HistoryCfg->Enum(Index++,Type,HistoryName,&id,strName,&HType,&HLock,&Time,strGuid,strFile,strData,false))
+ while(HistoryRef(Type)->Enum(Index++,Type,HistoryName,&id,strName,&HType,&HLock,&Time,strGuid,strFile,strData,false))
{
if(Filter(HType))
{

Modified: trunk/unicode_far/vbuild.m4
==============================================================================
--- trunk/unicode_far/vbuild.m4 (original)
+++ trunk/unicode_far/vbuild.m4 Wed Apr 11 16:43:50 2012
@@ -1 +1 @@
-m4_define(BUILD,2602)m4_dnl
+m4_define(BUILD,2603)m4_dnl

Reply all
Reply to author
Forward
0 new messages