static void Config(void) { static const struct InitDialogItem PreDialogItems[] = { {DI_DOUBLEBOX ,3 ,1 ,50 ,10 ,0 ,MTitle}, {DI_TEXT ,5 ,2 ,0 ,0 ,0 ,MPathToViewer}, {DI_EDIT ,5 ,3 ,47 ,0 ,DIF_EDITEXPAND ,-1}, {DI_TEXT ,5 ,4 ,0 ,0 ,0 ,MOpenContents}, {DI_EDIT ,5 ,5 ,47 ,0 ,0 ,-1}, {DI_TEXT ,5 ,6 ,0 ,0 ,0 ,MKeywordSearch}, {DI_EDIT ,5 ,7 ,47 ,0 ,0 ,-1}, {DI_TEXT ,4 ,8 ,0 ,0 ,DIF_SEPARATOR ,-1}, {DI_BUTTON ,0 ,9 ,0 ,0 ,DIF_CENTERGROUP ,MOk}, {DI_BUTTON ,0 ,9 ,0 ,0 ,DIF_CENTERGROUP ,MCancel}, }; struct FarDialogItem DialogItems[sizeofa(PreDialogItems)]; InitDialogItems(PreDialogItems,DialogItems,sizeofa(PreDialogItems)); DialogItems[2].Focus = TRUE; lstrcpy(DialogItems[2].Data,PathToViewer); lstrcpy(DialogItems[4].Data,OpenContents); lstrcpy(DialogItems[6].Data,KeywordSearch); DialogItems[8].DefaultButton = 1; if (Info.Dialog(Info.ModuleNumber,-1,-1,54,12,NULL,(struct FarDialogItem *)&DialogItems,sizeofa(DialogItems)) != 8) return; lstrcpy(PathToViewer,DialogItems[2].Data); lstrcpy(OpenContents,DialogItems[4].Data); lstrcpy(KeywordSearch,DialogItems[6].Data); SetRegKey("PathToViewer",PathToViewer); SetRegKey("OpenContents",OpenContents); SetRegKey("KeywordSearch",KeywordSearch); }
static void Config(void) { static const struct InitDialogItem PreDialogItems[] = { {DI_DOUBLEBOX ,3 ,1 ,41 ,6 ,0 ,MTitle}, {DI_TEXT ,5 ,2 ,0 ,0 ,0 ,MShowIn}, {DI_COMBOBOX ,5 ,3 ,20 ,0 ,DIF_DROPDOWNLIST,-1}, {DI_COMBOBOX ,23 ,3 ,38 ,0 ,DIF_DROPDOWNLIST,-1}, {DI_TEXT ,4 ,4 ,0 ,0 ,DIF_SEPARATOR ,-1}, {DI_BUTTON ,0 ,5 ,0 ,0 ,DIF_CENTERGROUP ,MOk}, {DI_BUTTON ,0 ,5 ,0 ,0 ,DIF_CENTERGROUP ,MCancel}, }; struct FarDialogItem DialogItems[sizeofa(PreDialogItems)]; InitDialogItems(PreDialogItems,DialogItems,sizeofa(PreDialogItems)); DialogItems[2].Focus = TRUE; struct FarListItem li1[2]; memset(li1,0,sizeof(li1)); struct FarList fl1 = {2, li1}; li1[Modality].Flags=LIF_SELECTED; GetMsg(MNonModal,li1[0].Text); GetMsg(MModal,li1[1].Text); DialogItems[2].ListItems = &fl1; struct FarListItem li2[2]; memset(li2,0,sizeof(li2)); struct FarList fl2 = {2, li2}; li2[Visuality].Flags=LIF_SELECTED; GetMsg(MEditor,li2[0].Text); GetMsg(MViewer,li2[1].Text); DialogItems[3].ListItems = &fl2; DialogItems[5].DefaultButton = 1; if (Info.Dialog(Info.ModuleNumber,-1,-1,45,8,NULL,(struct FarDialogItem *)&DialogItems,sizeofa(DialogItems)) != 5) return; Modality = DialogItems[2].ListPos; Visuality = DialogItems[3].ListPos; SetRegKey("Modality",Modality); SetRegKey("Visuality",Visuality); }
int Config(void) { static const struct InitDialogItem PreDialogItems[] = { DI_DOUBLEBOX ,3 ,1 ,50 ,10 ,0 ,MTitle, DI_CHECKBOX ,5 ,2 ,0 ,0 ,0 ,MEditorAutoPos, DI_CHECKBOX ,5 ,3 ,0 ,0 ,0 ,MCmdAutoPos, DI_TEXT ,4 ,4 ,0 ,0 ,DIF_SEPARATOR ,-1, DI_CHECKBOX ,5 ,5 ,0 ,0 ,0 ,MCopyToClipboard, DI_TEXT ,4 ,6 ,0 ,0 ,DIF_SEPARATOR ,-1, DI_CHECKBOX ,5 ,7 ,0 ,0 ,0 ,MEncodeBeforeInsertion, DI_TEXT ,4 ,8 ,0 ,0 ,DIF_SEPARATOR ,-1, DI_BUTTON ,0 ,9 ,0 ,0 ,DIF_CENTERGROUP ,MOk, DI_BUTTON ,0 ,9 ,0 ,0 ,DIF_CENTERGROUP ,MCancel }; struct FarDialogItem DialogItems[sizeof(PreDialogItems)/sizeof(PreDialogItems[0])]; InitDialogItems(PreDialogItems,DialogItems,sizeof(PreDialogItems)/sizeof(PreDialogItems[0])); DialogItems[1].Focus = TRUE; DialogItems[8].DefaultButton = 1; DialogItems[1].Selected = EditorAutoPos; DialogItems[2].Selected = CmdAutoPos; DialogItems[4].Selected = CopyToClipboard; DialogItems[6].Selected = EncodeBeforeInsertion; if (Info.Dialog(Info.ModuleNumber,-1,-1,54,12,"Configure",(struct FarDialogItem *)&DialogItems,sizeof(PreDialogItems)/sizeof(PreDialogItems[0])) != 8) return FALSE; EditorAutoPos = DialogItems[1].Selected; CmdAutoPos = DialogItems[2].Selected; CopyToClipboard = DialogItems[4].Selected; EncodeBeforeInsertion = DialogItems[6].Selected; SetRegKey(®[REG_EDITORAUTOPOS],EditorAutoPos); SetRegKey(®[REG_CMDAUTOPOS],CmdAutoPos); SetRegKey(®[REG_COPYTOCLIPBOARD],CopyToClipboard); SetRegKey(®[REG_ENCODEBEFOREINSERTION],EncodeBeforeInsertion); return TRUE; }
Shortcuts::~Shortcuts() { for(size_t i = 0; i < KeyCount; i++) { FormatString strFolderShortcuts; strFolderShortcuts << FolderShortcutsKey << i; int index = 0; DeleteKeyTree(strFolderShortcuts); for(ShortcutItem* j = Items[i].First(); j; j = Items[i].Next(j), index++) { FormatString ValueName; ValueName << RecTypeName[PSCR_RT_SHORTCUT] << index; SetRegKey(strFolderShortcuts, ValueName, j->strFolder); ValueName.Clear(); if(!j->strPluginModule.IsEmpty()) { ValueName << RecTypeName[PSCR_RT_PLUGINMODULE] << index; SetRegKey(strFolderShortcuts, ValueName, j->strPluginModule); ValueName.Clear(); } if(!j->strPluginFile.IsEmpty()) { ValueName << RecTypeName[PSCR_RT_PLUGINFILE] << index; SetRegKey(strFolderShortcuts, ValueName, j->strPluginFile); ValueName.Clear(); } if(!j->strPluginData.IsEmpty()) { ValueName << RecTypeName[PSCR_RT_PLUGINDATA] << index; SetRegKey(strFolderShortcuts, ValueName, j->strPluginData); ValueName.Clear(); } } } }
// Каллбак для диалога редактирования имени кодовой страницы LONG_PTR WINAPI EditDialogProc(HANDLE hDlg, int Msg, int Param1, LONG_PTR Param2) { if (Msg==DN_CLOSE) { if (Param1==EDITCP_OK || Param1==EDITCP_RESET) { FARString strCodePageName; UINT CodePage = GetMenuItemCodePage(); FormatString strCodePage; strCodePage<<CodePage; if (Param1==EDITCP_OK) { wchar_t *CodePageName = strCodePageName.GetBuffer(SendDlgMessage(hDlg, DM_GETTEXTPTR, EDITCP_EDIT, 0)+1); SendDlgMessage(hDlg, DM_GETTEXTPTR, EDITCP_EDIT, (LONG_PTR)CodePageName); strCodePageName.ReleaseBuffer(); } // Если имя кодовой страницы пустое, то считаем, что имя не задано if (!strCodePageName.GetLength()) DeleteRegValue(NamesOfCodePagesKey, strCodePage); else SetRegKey(NamesOfCodePagesKey, strCodePage, strCodePageName); // Получаем информацию о кодовой странице CPINFOEX cpiex; if (GetCodePageInfo(CodePage, cpiex)) { // Формируем имя таблиц символов bool IsCodePageNameCustom = false; wchar_t *CodePageName = FormatCodePageName(CodePage, cpiex.CodePageName, sizeof(cpiex.CodePageName)/sizeof(wchar_t), IsCodePageNameCustom); // Формируем строку представления strCodePage.Clear(); FormatCodePageString(CodePage, CodePageName, strCodePage, IsCodePageNameCustom); // Обновляем имя кодовой страницы int Position = CodePages->GetSelectPos(); CodePages->DeleteItem(Position); MenuItemEx NewItem; NewItem.Clear(); NewItem.strName = strCodePage; NewItem.UserData = (char *)(UINT_PTR)CodePage; NewItem.UserDataSize = sizeof(UINT); CodePages->AddItem(&NewItem, Position); CodePages->SetSelectPos(Position, 1); } } } return DefDlgProc(hDlg, Msg, Param1, Param2); }
/* $ 03.08.2000 SVS ! Не срабатывал шаблон поиска файлов для под-юзеров */ void CopyGlobalSettings() { if (CheckRegKey(L"")) // при существующем - вываливаемся return; // такого извера нету - перенесем данные! SetRegRootKey(HKEY_LOCAL_MACHINE); CopyKeyTree(L"Software/Far2",Opt.strRegRoot,L"Software/Far2/Users\0"); SetRegRootKey(HKEY_CURRENT_USER); CopyKeyTree(L"Software/Far2",Opt.strRegRoot,L"Software/Far2/Users/Software/Far2/PluginsCache\0"); // "Вспомним" путь по шаблону!!! SetRegRootKey(HKEY_LOCAL_MACHINE); GetRegKey(L"System",L"TemplatePluginsPath",Opt.LoadPlug.strPersonalPluginsPath,L""); // удалим!!! DeleteRegKey(L"System"); // запишем новое значение! SetRegRootKey(HKEY_CURRENT_USER); SetRegKey(L"System",L"PersonalPluginsPath",Opt.LoadPlug.strPersonalPluginsPath); }
int WINAPI Configure(int ItemNumber) { PluginDialogBuilder Config(Info, MPlugIn, _T("Configuration")); FarDialogItem *p1, *p2; BOOL bShowInViewer = (Opt.WhereWork & 1) != 0; BOOL bShowInEditor = (Opt.WhereWork & 2) != 0; //BOOL bEnterWaitCompletion = (Opt.EnterFunction != 0); BOOL bUseElevation = (Opt.UseElevation != 0); BOOL bLowPriority = (Opt.RunLowPriority != 0); BOOL bForceMsiUse = (Opt.ForceMsiUse != 0); Config.AddCheckbox(MShowInEditor, &bShowInEditor); Config.AddCheckbox(MShowInViewer, &bShowInViewer); //Config.AddCheckbox(MEnterWaitCompletion, &bEnterWaitCompletion); Config.AddCheckbox(MUseElevation, &bUseElevation); Config.AddCheckbox(MLowPriority, &bUseElevation); Config.AddCheckbox(MForceMsiUse, &bForceMsiUse); Config.AddSeparator(); FarList AEnter, AShiftEnter; AEnter.ItemsNumber = AShiftEnter.ItemsNumber = 7; AEnter.Items = (FarListItem*)calloc(AEnter.ItemsNumber,sizeof(FarListItem)); AShiftEnter.Items = (FarListItem*)calloc(AEnter.ItemsNumber,sizeof(FarListItem)); for (int i = 0; i < AEnter.ItemsNumber; i++) { #ifdef FARAPI18 AEnter.Items[i].Text = GetMsg(MActionUninstallWait+i); AShiftEnter.Items[i].Text = AEnter.Items[i].Text; #else StringCchCopy(AEnter.Items[i].Text,ARRAYSIZE(AEnter.Items[i].Text),GetMsg(MActionUninstallWait+i)); StringCchCopy(AShiftEnter.Items[i].Text,ARRAYSIZE(AShiftEnter.Items[i].Text),AEnter.Items[i].Text); #endif } p1 = Config.AddText(MEnterAction); p2 = Config.AddComboBox(23, &AEnter, &Opt.EnterAction); Config.MoveItemAfter(p1,p2); p1 = Config.AddText(MShiftEnterAction); p2 = Config.AddComboBox(23, &AShiftEnter, &Opt.ShiftEnterAction); Config.MoveItemAfter(p1,p2); Config.AddOKCancel(MBtnOk, MBtnCancel); if (Config.ShowDialog()) { Opt.WhereWork = (bShowInViewer ? 1 : 0) | (bShowInEditor ? 2 : 0); //Opt.EnterFunction = bEnterWaitCompletion; Opt.UseElevation = bUseElevation; Opt.RunLowPriority = bLowPriority; Opt.ForceMsiUse = bForceMsiUse; SetRegKey(HKCU,_T(""),_T("WhereWork"),(DWORD) Opt.WhereWork); SetRegKey(HKCU,_T(""),_T("EnterAction"),(DWORD) Opt.EnterAction); SetRegKey(HKCU,_T(""),_T("ShiftEnterAction"),(DWORD) Opt.ShiftEnterAction); SetRegKey(HKCU,_T(""),_T("UseElevation"),(DWORD) Opt.UseElevation); SetRegKey(HKCU,_T(""),_T("RunLowPriority"),(DWORD) Opt.RunLowPriority); SetRegKey(HKCU,_T(""),_T("ForceMsiUse"),(DWORD) Opt.ForceMsiUse); } return FALSE; }
int wmain (int argc,wchar_t ** argv) { CAppData::stdfunc(); SetRegKey(argc,argv); if (!SetLanguageSpecifigHandles(argv[0])) return 1; CArrayFP<CDatabase*> aDatabases; WORD wCurrentThread=0; aDatabases.Add(CDatabase::FromDefaults(TRUE)); aDatabases[0]->SetNamePtr(alloccopy(L"DEFAULTX")); aDatabases[0]->SetThreadId(wCurrentThread); int i,helps=0; #ifndef WIN32 if (getenv("TZ")==NULL) fprintf(stderr,"Timezone is not set. Database may contain invalid file times.\nFor example type "SET TZ=GMT+1" for central european time.\n"); #endif for (i=1;i<argc;i++) { if (argv[i][0]=='-' || argv[i][0]=='/') { switch (argv[i][1]) { case L'X': if (argv[i][2]==L'\0') { if (i<argc-1) i++; // RegKeyName already set } break; case 'l': case 'L': if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0) wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName()); else if (argv[i][2]=='1') { aDatabases.GetLast()->AddLocalRoots(); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } else { CStringW* pStr; if (argv[i][2]==L'\0' && i+1<argc) pStr=new CStringW(argv[++i]); else pStr=new CStringW(argv[i]+2); if ((*pStr)[0]==L'\"') pStr->DelChar(0); if (pStr->LastChar()==L'\"') pStr->DelLastChar(); while (pStr->LastChar()==L'\\') pStr->DelLastChar(); if (pStr->GetLength()>1) { if ((*pStr)[1]==':' && pStr->GetLength()==2) aDatabases.GetLast()->AddRoot(pStr->GiveBuffer()); else if (FileSystem::IsDirectory(*pStr)) aDatabases.GetLast()->AddRoot(pStr->GiveBuffer()); else fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr); } else fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr); delete pStr; aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } break; case 'e': if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0) wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName()); else { CStringW* pStr; if (argv[i][2]=='\0' && i+1<argc) pStr=new CStringW(argv[++i]); else pStr=new CStringW(argv[i]+2); if ((*pStr)[0]==L'\"') pStr->DelChar(0); if (pStr->LastChar()==L'\"') pStr->DelLastChar(); while (pStr->LastChar()==L'\\') pStr->DelLastChar(); if (pStr->GetLength()>0) aDatabases.GetLast()->SetExcludedFiles(*pStr); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } break; case 'E': if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0) wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName()); else { CStringW* pStr; if (argv[i][2]=='\0' && i+1<argc) pStr=new CStringW(argv[++i]); else pStr=new CStringW(argv[i]+2); if ((*pStr)[0]==L'\"') pStr->DelChar(0); if (pStr->LastChar()==L'\"') pStr->DelLastChar(); while (pStr->LastChar()==L'\\') pStr->DelLastChar(); if (pStr->GetLength()>1) { if (!aDatabases.GetLast()->AddExcludedDirectory(*pStr)) fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr); } else fwprintf(stderr,ID2W(IDS_UPDATEDB32DIRECTORYISNOTVALID),(LPCWSTR)*pStr); delete pStr; aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } break; case 't': case 'T': if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0) wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName()); else if (argv[i][2]==L'c' || argv[i][2]==L'C') { if (argv[i][3]==L'\0') aDatabases.GetLast()->SetCreatorPtr(alloccopy(argv[++i])); else aDatabases.GetLast()->SetCreatorPtr(alloccopy(argv[i]+2)); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } else if (argv[i][2]==L'd' || argv[i][2]==L'D') { if (argv[i][3]==L'\0') aDatabases.GetLast()->SetDescriptionPtr(alloccopy(argv[++i])); else aDatabases.GetLast()->SetDescriptionPtr(alloccopy(argv[i]+2)); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } break; case 'i': case 'I': if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0) wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName()); else { aDatabases.GetLast()->SetFlag(CDatabase::flagIncrementalUpdate,TRUE); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } break; case 'c': case 'C': if (wcsncmp(aDatabases.GetLast()->GetName(),L"PARAMX",6)!=0 && wcsncmp(aDatabases.GetLast()->GetName(),L"DEFAULTX",8)!=0) wprintf(ID2W(IDS_UPDATEDB32CANNOTCHANGELOADED),aDatabases.GetLast()->GetName()); else if (argv[i][2]==L'A' || argv[i][2]==L'a') { aDatabases.GetLast()->SetFlag(CDatabase::flagAnsiCharset,TRUE); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } else if (argv[i][2]==L'U' || argv[i][2]==L'u') { aDatabases.GetLast()->SetFlag(CDatabase::flagAnsiCharset,FALSE); aDatabases.GetLast()->SetNamePtr(alloccopy(L"PARAMX")); } break; case 'N': case 'n': wCurrentThread++; break; case 'q': case 'Q': nQuiet=TRUE; break; case 'v': case 'V': printf("%s\n",szVersionStr); return 0; case 'd': { // Using database file CStringW sFile; if (argv[i][2]=='\0') sFile=argv[++i]; else sFile=(argv[i]+2); if (aDatabases.GetSize()==1 && wcscmp(aDatabases[0]->GetName(),L"DEFAULTX")==0) { aDatabases[0]->SetNamePtr(alloccopy(L"PARAMX")); aDatabases[0]->SetArchiveNamePtr(sFile.GiveBuffer()); } else { CDatabase* pDatabase=CDatabase::FromFile(sFile,(int)sFile.GetLength()); if (pDatabase!=NULL) { aDatabases.Add(pDatabase); pDatabase->SetNamePtr(alloccopy(L"PARAMX")); pDatabase->SetThreadId(wCurrentThread); } } } break; case 'D': { // Loading database 'name' from registry, cannot be changed CStringW sName; if (argv[i][2]=='\0') sName=argv[++i]; else sName=(argv[i]+2); if (CDatabase::FindByName(aDatabases,sName,(int)sName.GetLength())==NULL) { CDatabase* pDatabase=CDatabase::FromName(HKCU, CString(g_szRegKey)+"\\Databases",sName); if (pDatabase!=NULL) { pDatabase->SetFlag(CDatabase::flagGlobalUpdate); // Is only default loaded if (aDatabases.GetSize()==1 && wcscmp(aDatabases[0]->GetName(),L"DEFAULTX")==0) { delete aDatabases[0]; aDatabases[0]=pDatabase; } else { aDatabases.Add(pDatabase); pDatabase->SetThreadId(wCurrentThread); } } } } break; case 'h': case 'H': case '?': helps=1; break; default: helps=1; break; } } } if (helps==1) { #ifdef WIN32 fprintf(stdout,"%s\n",szVersionStr); #else fprintf(stdout,"%s\nusage updatedb",szVersionStr); #endif HRSRC hRc=FindResource(GetLanguageSpecificResourceHandle(),MAKEINTRESOURCE(IDR_UPDATEDBHELP),"HELPTEXT"); HGLOBAL hGlobal=LoadResource(GetLanguageSpecificResourceHandle(),hRc); LPCSTR pStr=(LPCSTR)LockResource(hGlobal); // Counting length int len; for (len=0;pStr[len]!='\0';len++) { if (pStr[len]=='E' && pStr[len+1]=='O' && pStr[len+2]=='F') break; } fwrite(pStr,1,len,stdout); FreeLibrary(GetLanguageSpecificResourceHandle()); return 1; } // Checking databases // First, check that there is database if (aDatabases.GetSize()==0) CDatabase::LoadFromRegistry(HKCU,CString(g_szRegKey)+"\\Databases",aDatabases); else if (aDatabases.GetSize()==1 && wcsncmp(aDatabases[0]->GetName(),L"DEFAULTX",8)==0) { aDatabases.RemoveAll(); CDatabase::LoadFromRegistry(HKCU,CString(g_szRegKey)+"\\Databases",aDatabases); // No registry values? if (aDatabases.GetSize()==0) { aDatabases.Add(CDatabase::FromDefaults(TRUE)); aDatabases[0]->SetNamePtr(alloccopy(L"DEFAULTX")); } } CDatabase::CheckValidNames(aDatabases); CDatabase::CheckDoubleNames(aDatabases); for (int i=0;i<aDatabases.GetSize();) { if (!aDatabases[i]->IsGloballyUpdated()) aDatabases.RemoveAt(i); else { if ((wcsncmp(aDatabases[i]->GetName(),L"PARAMX",6)==0 || wcsncmp(aDatabases[i]->GetName(),L"DEFAULTX",8)==0)) { BOOL bNameChanged=FALSE; if (aDatabases[i]->GetRoots()==0) { BOOL bFree; LPWSTR pFile=aDatabases[i]->GetResolvedArchiveName(bFree); CDatabaseInfo* pDatabaseInfo=CDatabaseInfo::GetFromFile(pFile); if (bFree) delete[] pFile; if (pDatabaseInfo!=NULL) { CDatabase* pDatabase; if (!pDatabaseInfo->sExtra2.IsEmpty()) pDatabase=CDatabase::FromExtraBlock(pDatabaseInfo->sExtra2); if (pDatabase==NULL && !pDatabaseInfo->sExtra1.IsEmpty()) pDatabase=CDatabase::FromExtraBlock(pDatabaseInfo->sExtra1); wprintf(ID2W(IDS_UPDATEDB32USINGEXISTINGSETTINGS), aDatabases[i]->GetArchiveName(),pDatabase->GetName()); pDatabase->SetArchiveType(aDatabases[i]->GetArchiveType()); pDatabase->SetArchiveName(aDatabases[i]->GetArchiveName()); delete aDatabases[i]; aDatabases[i]=pDatabase; delete pDatabaseInfo; bNameChanged=TRUE; } } if (!bNameChanged) { ULONG_PTR nFirst=LastCharIndex(aDatabases[i]->GetArchiveName(),L'\\')+1; int nLength=LastCharIndex(aDatabases[i]->GetArchiveName()+nFirst,L'.'); if (nLength==-1) nLength=istrlenw(aDatabases[i]->GetArchiveName()+nFirst); aDatabases[i]->SetNamePtr(alloccopy(aDatabases[i]->GetArchiveName()+nFirst,nLength)); } } i++; } } // Starting to update WORD dwTheads=CDatabase::CheckIDs(aDatabases); if (dwTheads==0) { FreeLibrary(GetLanguageSpecificResourceHandle()); return FALSE; } if (dwTheads==1) { CDatabaseUpdater Updater(aDatabases,aDatabases.GetSize(),UpdateProc); Updater.Update(FALSE); } else { WORD wThread; ppUpdaters=new CDatabaseUpdater*[dwTheads+1]; for (wThread=0;wThread<dwTheads;wThread++) { ppUpdaters[wThread]=new CDatabaseUpdater(aDatabases,aDatabases.GetSize(), UpdateProc,wThread,(DWORD)0); } ppUpdaters[dwTheads]=NULL; // Starting DWORD dwRunning=0; UpdateError ueCode; for (wThread=0;wThread<dwTheads;wThread++) { ueCode=ppUpdaters[wThread]->Update(TRUE); if (ueCode==ueSuccess) dwRunning++; else { delete ppUpdaters[wThread]; ppUpdaters[wThread]=UPDATER_EXITED(ueCode); } } if (dwRunning==0) delete ppUpdaters; else { while (ppUpdaters!=NULL) Sleep(100); } } FinishRegKey(); FreeLibrary(GetLanguageSpecificResourceHandle()); return 1; }
void FileList::SavePanelModes() { for (int I=0; I<10; I++) { string strColumnTitles, strColumnWidths; string strStatusColumnTitles, strStatusColumnWidths, strRegKey; strRegKey.Format(L"Panel\\ViewModes\\Mode%d",I); PanelViewSettings NewSettings=ViewSettingsArray[VIEW_0+I]; ViewSettingsToText(NewSettings.ColumnType,NewSettings.ColumnWidth,NewSettings.ColumnWidthType, NewSettings.ColumnCount,FALSE,strColumnTitles,strColumnWidths); ViewSettingsToText(NewSettings.StatusColumnType,NewSettings.StatusColumnWidth,NewSettings.StatusColumnWidthType, NewSettings.StatusColumnCount,TRUE,strStatusColumnTitles,strStatusColumnWidths); SetRegKey(strRegKey,L"Columns",strColumnTitles); SetRegKey(strRegKey,L"ColumnWidths",strColumnWidths); SetRegKey(strRegKey,L"StatusColumns",strStatusColumnTitles); SetRegKey(strRegKey,L"StatusColumnWidths",strStatusColumnWidths); SetRegKey(strRegKey,L"FullScreen",NewSettings.FullScreen); SetRegKey(strRegKey,L"AlignExtensions",NewSettings.AlignExtensions); SetRegKey(strRegKey,L"FolderAlignExtensions",NewSettings.FolderAlignExtensions); SetRegKey(strRegKey,L"FolderUpperCase",NewSettings.FolderUpperCase); SetRegKey(strRegKey,L"FileLowerCase",NewSettings.FileLowerCase); SetRegKey(strRegKey,L"FileUpperToLowerCase",NewSettings.FileUpperToLowerCase); SetRegKey(strRegKey,L"PreloadC0Data",NewSettings.PreloadC0Data); } }
long WINAPI MyDialog(HANDLE hDlg,int Msg,int Param1,long Param2) { static int POpenFrom; static unsigned char *Str; static int *Ret; static COORD coord; static int LastSelectedMenu; static struct FarMenuItem *MenuItems; static int TotalMenuItems; static int TargetTable; static struct CharTableSet cts; static struct TableStruct newtable; static struct FarDialogItem DlgASCII, DlgText, DlgEdit, DlgInfo; static CHAR_INFO VBufASCII[256]; static const unsigned char *InfoFormat; static BOOL EditMode; static int EditInsertMode; static char CharTxt[4]; static int CharTxtPos; static char example[MAX_PATH]; unsigned char Temp[51]; static int EditLen; static unsigned char EditText[512]; int tmplen; unsigned char tmptext[512]; char *Cmd; static struct EditorInfo ei; struct FarList *fl; struct EditorConvertText ect; struct EditorGetString egs; struct EditorSetString ess; struct EditorSetPosition esp; WORD Color; int i; switch (Msg) { case DN_INITDIALOG: EditMode = FALSE; EditLen = 0; POpenFrom = ((struct DialogData *)Param2)->OpenFrom; Str = ((struct DialogData *)Param2)->Str; Ret = ((struct DialogData *)Param2)->Ret; MenuItems = NULL; GetRegKey(®[REG_LASTCOORDX],(int *)&coord.X,0); GetRegKey(®[REG_LASTCOORDY],(int *)&coord.Y,0); for (i=0; GetCharTable(i,&cts) != -1; i++) { MenuItems=(struct FarMenuItem *)realloc(MenuItems,(i+1)*sizeof(struct FarMenuItem)); if (!MenuItems) { Warning(MMemoryError); Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); return FALSE; } lstrcpy(MenuItems[i].Text,cts.TableName); MenuItems[i].Checked = MenuItems[i].Selected = MenuItems[i].Separator = 0; } TotalMenuItems = i; MenuItems[LastSelectedMenu=0].Selected = 1; Info.SendDlgMessage(hDlg,DM_SETCURSORSIZE,3,MAKELONG(1,99)); InfoFormat = (const unsigned char *) GetMsg(MInfoFormat); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,3,(long)&DlgASCII); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,1,(long)&DlgText); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,5,(long)&DlgEdit); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,6,(long)&DlgInfo); Color = Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_DIALOGTEXT); Color |= Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_DIALOGBOX); SetVBufAttrib(VBufASCII,Color,256); SetVBufAttrib(DlgInfo.VBuf,Color,32); { struct FarDialogItem DlgDemo; char Demo[19*17+1]; char Space[18]; Info.SendDlgMessage(hDlg,DM_GETDLGITEM,11,(long)&DlgDemo); SetVBufAttrib(DlgDemo.VBuf,Color,19*17); FSF.sprintf(Space,"%17s"," "); lstrcpy(Demo," 0123456789ABCDEF"); for (i=0; i<256; i+=16) { char Hex[3]; FSF.sprintf(Hex,x2,i); lstrcat(Demo,Hex); lstrcat(Demo,Space); } Demo[19+3] = 32; for (i=1; i<256; i++) { Demo[19+i/16*19+i%16+3] = i; } SetVBufChars(DlgDemo.VBuf,(unsigned char *)Demo,19*17); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,11,(long)&DlgDemo); } Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,0); //Select DOS TargetTable = 0; //DOS if (POpenFrom == OPENF_EDITOR) { Info.EditorControl(ECTL_GETINFO,(void *)&ei); switch (ei.TableNum) { case -1: if (ei.AnsiMode == 1) { TargetTable = 1; //WIN Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,1); //select WIN } break; default: if (ei.TableNum < 0) break; TargetTable = ei.TableNum+2; FSF.sprintf(DlgText.Data,s32,MenuItems[ei.TableNum+2].Text); MenuItems[LastSelectedMenu].Selected = 0; MenuItems[LastSelectedMenu=(ei.TableNum+2)].Selected = 1; Info.CharTable(ei.TableNum,(char *)&cts,sizeof(struct CharTableSet)); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,1,(long)&DlgText); } if (EditorAutoPos) { egs.StringNumber = -1; Info.EditorControl(ECTL_GETSTRING,(void *)&egs); if (egs.StringLength > 0 && ei.CurPos < egs.StringLength) { i = egs.StringText[ei.CurPos]; coord.X = i%32; coord.Y = i/32; } } } if (CmdAutoPos && POpenFrom == OPENF_COMMANDLINE) { Info.Control(INVALID_HANDLE_VALUE,FCTL_GETCMDLINEPOS,(void *)&i); if (i < 1024) { Cmd = (char *)malloc(1024*sizeof(char)); if (!Cmd) { Warning(MMemoryError); Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); return FALSE; } Info.Control(INVALID_HANDLE_VALUE,FCTL_GETCMDLINE,(void *)Cmd); i = cts.EncodeTable[Cmd[i]]; coord.X = i%32; coord.Y = i/32; free(Cmd); } } if (POpenFrom == OPENF_MANUAL) { i = cts.EncodeTable[*Str]; coord.X = i%32; coord.Y = i/32; } Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,1); return TRUE; case DN_KEY: { long rParam2 = Param2; if (Param1==8) if (!(Param2==KEY_ESC || Param2==KEY_F10)) return FALSE; if ((Param2&KEY_CTRL)&&((Param2&0xFFL)>='a')&&((Param2&0xFFL)<='z')) rParam2&=~0x20L; switch (rParam2) { case KEY_LEFT: (coord.X>0)?--coord.X:((coord.Y>0)?(coord.X=31,--coord.Y):coord.X); break; case KEY_RIGHT: (coord.X<31)?++coord.X:((coord.Y<7)?(coord.X=0,++coord.Y):coord.X); break; case KEY_UP: if (coord.Y > 0) --coord.Y; break; case KEY_DOWN: if (coord.Y < 7) ++coord.Y; break; case KEY_HOME: coord.X = 0; break; case KEY_END: coord.X = 31; break; case KEY_PGUP: coord.Y = 0; break; case KEY_PGDN: coord.Y = 7; break; case KEY_CTRLHOME: coord.Y = coord.X = 0; break; case KEY_CTRLEND: coord.Y = 7; coord.X = 31; break; case KEY_ENTER: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_ENTER,0,0); return TRUE; case KEY_SHIFTF8: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,0,0); return TRUE; case KEY_F8: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,2,0); //exchange DOS/WIN return TRUE; case KEY_SHIFTENTER: case KEY_INS: case KEY_ADD: case KEY_SUBTRACT: if (!EditMode && Info.SendDlgMessage(hDlg,DMCM_SETEDIT,0,0)) { switch (Param2) { case KEY_ADD: (coord.X<31)?++coord.X:((coord.Y<7)?(coord.X=0,++coord.Y):coord.X); break; case KEY_SUBTRACT: (coord.X>0)?--coord.X:((coord.Y>0)?(coord.X=31,--coord.Y):coord.X); break; } break; } return TRUE; case KEY_DEL: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_DEL,0,0); return TRUE; case KEY_BS: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_BS,0,0); return TRUE; case KEY_CTRLINS: case KEY_CTRLC: if (!EditMode) { tmplen = EditLen; if (tmplen==0) { EditText[0] = coord.X+32*coord.Y; tmplen = 1; } EditText[tmplen] = 0; if (EncodeBeforeInsertion) { memcpy(tmptext,EditText,tmplen+1); Encode((char *)tmptext,tmplen,&cts,TargetTable); FSF.CopyToClipboard((const char *)tmptext); } else FSF.CopyToClipboard((const char *)EditText); } return TRUE; case KEY_ALTSHIFTF9: Info.SendDlgMessage(hDlg,DM_SHOWDIALOG,FALSE,0); Config(); Info.SendDlgMessage(hDlg,DM_SHOWDIALOG,TRUE,0); return TRUE; case KEY_F9: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,3,1); break; case KEY_SHIFTF9: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,3,-1); break; case KEY_CTRLI: Info.SendDlgMessage(hDlg,DMCM_SHOWTABLEINFO,0,0); return TRUE; case KEY_CTRLN: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,1,0); return TRUE; case KEY_CTRLE: if (!EditMode) { Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,0,0); } else { int xxx; const char *XXX; EditInsertMode = (EditInsertMode+1)%3; xxx=VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; switch (EditInsertMode) { case 0: XXX = x2; break; case 1: XXX = d3; break; case 2: XXX = c1; break; } FSF.sprintf(CharTxt,XXX,xxx); CharTxtPos = 0; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,9,(long)GetMsg(MEditModeHex+EditInsertMode)); } return TRUE; case KEY_CTRLX: if (EditMode) Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,0,1); return TRUE; case KEY_CTRLS: if (EditMode) Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,1,1); return TRUE; case KEY_CTRLL: if (EditMode) { static struct InitDialogItem InitItems[]= { {DI_DOUBLEBOX,3,1,57,4,0,MTitle}, {DI_TEXT,5,2,0,0,0,MEnterFileName}, {DI_EDIT,5,3,55,0,0,-1}, {DI_BUTTON,3,5,0,0,0,MOk}, }; struct FarDialogItem DialogItems[4]; InitDialogItems(InitItems,DialogItems,4); DialogItems[3].DefaultButton = 1; if (Info.Dialog(Info.ModuleNumber,-1,-1,60,6,NULL,DialogItems,4)!=3) break; FSF.Unquote(DialogItems[2].Data); lstrcpy(example,DialogItems[2].Data); LoadFile(example,hDlg,&newtable.cts); } return TRUE; case KEY_CTRLU: if (EditMode) { *example = '\0'; Info.SendDlgMessage(hDlg,DM_LISTDELETE,8,0); } return TRUE; default: if (EditMode) { BOOL ret=FALSE; if (Param2==KEY_ESC||Param2==KEY_F10) { if (Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,0,1)) { Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); } return TRUE; } switch (EditInsertMode) { case 0: //Hex if((Param2>='0' && Param2<='9') || (Param2>='a' && Param2<='f') || (Param2>='A' && Param2<='F')) { CharTxt[CharTxtPos++] = Param2; CharTxt[CharTxtPos] = '\0'; if (CharTxtPos>1) CharTxtPos=0; FSF.sscanf(CharTxt,"%X",&i); ret=TRUE; } break; case 1: //Decimal if((Param2>='0' && Param2<='9')) { CharTxt[CharTxtPos++] = Param2; CharTxt[CharTxtPos] = '\0'; FSF.sscanf(CharTxt,"%d",&i); if (i>255) { CharTxt[CharTxtPos=0] = Param2; CharTxt[++CharTxtPos] = '\0'; } if (CharTxtPos>2) CharTxtPos=0; ret=TRUE; } break; case 2: //Char if((Param2>31 && Param2<256)) { CharTxt[CharTxtPos++] = Param2; CharTxt[CharTxtPos] = '\0'; CharTxtPos=0; FSF.sscanf(CharTxt,"%c",&i); ret=TRUE; } } if (ret) { struct FarListPos lp; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); VBufASCII[coord.X+32*coord.Y].Char.AsciiChar = i; newtable.cts.DecodeTable[coord.X+32*coord.Y] = i; Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,8,(long)&lp); LoadFile(example,hDlg,&newtable.cts); Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,8,(long)&lp); CopyVBufSmart(DlgASCII.VBuf,VBufASCII,256); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,3,(long)&DlgASCII); Info.SendDlgMessage(hDlg,DMCM_REDRAW,0,1); return TRUE; } return FALSE; } else { if (Param2<256 && Param2>31) { coord.X = Param2%32; coord.Y = Param2/32; break; } return FALSE; } } if (EditMode) { int xxx; const char *XXX; xxx=VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; switch (EditInsertMode) { case 0: XXX = x2; break; case 1: XXX = d3; break; case 2: XXX = c1; } FSF.sprintf(CharTxt,XXX,xxx); CharTxtPos = 0; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); } Info.SendDlgMessage(hDlg,DMCM_REDRAW,0,1); return TRUE; } case DN_MOUSECLICK: switch (Param1) { case 3: coord = ((MOUSE_EVENT_RECORD *)Param2)->dwMousePosition; Info.SendDlgMessage(hDlg,DMCM_REDRAW,0,1); if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_SETEDIT,0,0); } else { if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) if (((MOUSE_EVENT_RECORD *)Param2)->dwEventFlags & DOUBLE_CLICK) Info.SendDlgMessage(hDlg,DMCM_ENTER,0,0); } return TRUE; case 1: if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,2,0); } else { if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,0,0); } } return TRUE; case 5: if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_BS,0,0); } else { if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_DEL,0,0); } } return TRUE; } return FALSE; case DMCM_REDRAW: if (Param1) { SetVBufChars(VBufASCII,cts.DecodeTable,256); CopyVBufSmart(DlgASCII.VBuf,VBufASCII,256); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,3,(long)&DlgASCII); } if (Param1 || Param2) { i = VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; FSF.sprintf((char *)Temp,(const char *)InfoFormat,(unsigned char)(i==0?32:i),(unsigned char)i,(unsigned char)i,(int)(coord.X+32*coord.Y),(int)(coord.X+32*coord.Y)); SetVBufChars(DlgInfo.VBuf,Temp,32); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,6,(long)&DlgInfo); Info.SendDlgMessage(hDlg,DM_SETCURSORPOS,3,(long)&coord); } return TRUE; case DMCM_SETEDIT: if (EditLen < 511) { i = VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; if (i == 0) { switch (POpenFrom) { case OPENF_EDITOR: case OPENF_VIEWER: case OPENF_MANUAL: DlgEdit.Data[EditLen] = 32; break; default: return FALSE; } } else DlgEdit.Data[EditLen] = (unsigned char) i; EditText[EditLen] = (unsigned char) (coord.X+32*coord.Y); DlgEdit.Data[++EditLen] = 0; Info.SendDlgMessage(hDlg,DM_SETDLGITEM,5,(long)&DlgEdit); return TRUE; } return FALSE; case DMCM_ENTER: if (EditLen==0) { i = VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; if (i == 0 && POpenFrom == OPENF_COMMANDLINE) { //MessageBeep(0); return FALSE; } else { EditText[0] = (unsigned char) (coord.X+32*coord.Y); EditLen = 1; } } EditText[EditLen] = 0; if (EncodeBeforeInsertion) if (TargetTable != LastSelectedMenu) Encode((char *)EditText,EditLen,&cts,TargetTable); if (CopyToClipboard) FSF.CopyToClipboard((const char *)EditText); switch (POpenFrom) { case OPENF_COMMANDLINE: Info.Control(INVALID_HANDLE_VALUE,FCTL_INSERTCMDLINE,(void *)EditText); break; case OPENF_EDITOR: egs.StringNumber = -1; Info.EditorControl(ECTL_GETSTRING,(void *)&egs); if (ei.CurPos > egs.StringLength) ess.StringText = (char *)malloc((egs.StringLength+EditLen+(ei.CurPos-egs.StringLength))*sizeof(char)); else ess.StringText = (char *)malloc((egs.StringLength+EditLen)*sizeof(char)); if (!ess.StringText) { Warning(MMemoryError); return FALSE; } if (ei.CurPos > egs.StringLength) { for (i=egs.StringLength; i<ei.CurPos; i++) ess.StringText[i] = cts.EncodeTable[32]; if (EncodeBeforeInsertion) Encode(&ess.StringText[egs.StringLength],ei.CurPos-egs.StringLength,&cts,TargetTable); memcpy(ess.StringText,egs.StringText,egs.StringLength); memcpy(ess.StringText+ei.CurPos,EditText,EditLen); ess.StringLength = EditLen + ei.CurPos; } else { memcpy(ess.StringText,egs.StringText,ei.CurPos); memcpy(ess.StringText+ei.CurPos,EditText,EditLen); memcpy(ess.StringText+ei.CurPos+EditLen,egs.StringText+ei.CurPos,egs.StringLength-ei.CurPos); ess.StringLength = EditLen + egs.StringLength; } ess.StringNumber = -1; ess.StringEOL = (char *)egs.StringEOL; Info.EditorControl(ECTL_SETSTRING,(void *)&ess); esp.CurPos = ei.CurPos + EditLen; esp.CurLine = esp.CurTabPos = esp.TopScreenLine = esp.LeftPos = esp.Overtype = -1; Info.EditorControl(ECTL_SETPOSITION,(void *)&esp); free(ess.StringText); break; case OPENF_VIEWER: break; case OPENF_MANUAL: { memcpy(Str,EditText,EditLen); *Ret=EditLen; } } Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); return TRUE; case DMCM_TABLESELECT: if (EditLen > 0) return FALSE; switch (Param1) { case 0: i = Info.Menu(Info.ModuleNumber,-1,-1,0,FMENU_WRAPMODE|FMENU_AUTOHIGHLIGHT,GetMsg(MTableSelect),NULL,NULL,NULL,NULL,MenuItems,TotalMenuItems); break; case 1: i = Param2; break; case 2: i = (LastSelectedMenu == 1 ? 0 : 1); break; case 3: i = LastSelectedMenu + Param2; if (i<0) i = TotalMenuItems-1; if (i >= TotalMenuItems) i = 0; break; } if (i!=-1) { FSF.sprintf(DlgText.Data,s32,MenuItems[i].Text); MenuItems[LastSelectedMenu].Selected = 0; MenuItems[LastSelectedMenu=i].Selected = 1; GetCharTable(i,&cts); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,1,(long)&DlgText); Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,0); return TRUE; } return FALSE; case DMCM_DEL: case DMCM_BS: if (EditLen > 0) { if (Msg == DMCM_DEL) EditLen=1; DlgEdit.Data[--EditLen] = 0; Info.SendDlgMessage(hDlg,DM_SETDLGITEM,5,(long)&DlgEdit); } return TRUE; case DMCM_SHOWTABLEINFO: { struct InitDialogItem InitItems[]= { {DI_DOUBLEBOX,3,1,57,8,0,MTitle}, {DI_TEXT,5,2,0,0,0,MTableName}, {DI_EDIT,5,3,55,0,0,-1}, {DI_TEXT,5,4,0,0,0,MStatusTableName}, {DI_EDIT,5,5,55,0,0,-1}, {DI_TEXT,5,6,0,0,0,MRFCCharset}, {DI_EDIT,5,7,55,0,0,-1}, {DI_BUTTON,3,9,0,0,0,MOk}, }; struct FarDialogItem DialogItems[8]; if (Param1||EditMode) InitItems[0].Data=MEnterTableInfo; InitDialogItems(InitItems,DialogItems,8); DialogItems[7].DefaultButton = 1; lstrcpy(DialogItems[2].Data,EditMode?newtable.cts.TableName:(Param1?"":cts.TableName)); if (!EditMode) { if (!Param1) { DialogItems[2].Flags|=DIF_READONLY; for (i=4; i<=6; i+=2) { DialogItems[i].Flags|=DIF_READONLY; lstrcpy(DialogItems[i].Data,GetMsg(MUnavailable)); } } } else { lstrcpy(DialogItems[4].Data,newtable.ShortName); lstrcpy(DialogItems[6].Data,newtable.RFCName); } if (Info.Dialog(Info.ModuleNumber,-1,-1,60,10,NULL,DialogItems,8)!=7) return FALSE; if (EditMode||Param1) { lstrcpyn(newtable.cts.TableName,DialogItems[2].Data,128); lstrcpyn(newtable.ShortName,DialogItems[4].Data,128); lstrcpyn(newtable.RFCName,DialogItems[6].Data,128); FSF.sprintf(DlgText.Data,s32,*(newtable.cts.TableName)?newtable.cts.TableName:newtable.ShortName); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,1,(long)&DlgText); } } return TRUE; case DMCM_EDITTABLE: if (Param2==0) { SMALL_RECT sr; COORD dcoord; if (Param1) { Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,0); newtable.cts=cts; *newtable.ShortName='\0'; *newtable.RFCName='\0'; Info.SendDlgMessage(hDlg,DMCM_SHOWTABLEINFO,1,0); } else { newtable.cts=cts; *newtable.ShortName='\0'; *newtable.RFCName='\0'; } dcoord.X = 61; dcoord.Y=25; Info.SendDlgMessage(hDlg,DM_RESIZEDIALOG,0,(long)&dcoord); sr.Left = 3; sr.Top=1; sr.Right=36; sr.Bottom=23; Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,(long)&sr); Info.SendDlgMessage(hDlg,DM_SHOWITEM,5,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,8,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,7,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,9,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,10,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,11,1); *example = '\0'; Info.SendDlgMessage(hDlg,DM_LISTDELETE,8,0); EditInsertMode = 0; i=VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; FSF.sprintf(CharTxt,x2,i); CharTxtPos = 0; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,9,(long)GetMsg(MEditModeHex+EditInsertMode)); Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,0); EditMode=TRUE; } else { if (Param1) { static struct InitDialogItem InitItems[]= { {DI_DOUBLEBOX,3,1,57,4,0,MTitle}, {DI_TEXT,5,2,0,0,0,MSaveToFile}, {DI_EDIT,5,3,55,0,0,-1}, {DI_BUTTON,3,5,0,0,0,MOk}, }; struct FarDialogItem DialogItems[4]; InitDialogItems(InitItems,DialogItems,4); DialogItems[3].DefaultButton = 1; lstrcpy(DialogItems[2].Data,*(newtable.cts.TableName)?newtable.cts.TableName:newtable.ShortName); lstrcat(DialogItems[2].Data,".reg"); if (Info.Dialog(Info.ModuleNumber,-1,-1,60,6,NULL,DialogItems,4)==3) { HANDLE fp; DWORD transfered; char buf[256]; FSF.Unquote(DialogItems[2].Data); fp = CreateFile(DialogItems[2].Data,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); if (fp==INVALID_HANDLE_VALUE) { Warning(MFileError); return FALSE; } lstrcpy(buf,"REGEDIT4\r\n[HKEY_CURRENT_USER\\Software\\Far\\CodeTables\\"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,*(newtable.ShortName)?newtable.ShortName:newtable.cts.TableName); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,"]\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); if (*(newtable.cts.TableName)&&*(newtable.ShortName)) { lstrcpy(buf,"\"TableName\"=\""); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,newtable.cts.TableName); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,"\"\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); } if (*(newtable.RFCName)) { lstrcpy(buf,"\"RFCCharset\"=\""); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,newtable.RFCName); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,"\"\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); } lstrcpy(buf,"\"Mapping\"=hex:\\\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); for (i=0; i<16; i++) { int j; *buf = '\0'; for (j=0; j<16; j++) { char hex[4]; FSF.sprintf(hex,"%02X,",newtable.cts.DecodeTable[i*16+j]); lstrcat(buf,hex); } if ((i*16+j)<255) lstrcat(buf,"\\"); else buf[lstrlen(buf)-1] = '\0'; lstrcat(buf,"\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); } CloseHandle(fp); } } else { SMALL_RECT sr; COORD coord; const char *Msg[2]; Msg[0] = GetMsg(MTitle); Msg[1] = GetMsg(MSureToExit); i = Info.Message(Info.ModuleNumber,FMSG_WARNING|FMSG_MB_YESNO,NULL,Msg,2,0); if (i==1 || i==-1) return FALSE; Info.SendDlgMessage(hDlg,DM_LISTDELETE,8,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,8,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,9,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,7,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,10,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,11,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,5,1); sr.Left = 3; sr.Top=1; sr.Right=36; sr.Bottom=15; Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,(long)&sr); coord.X = 40; coord.Y=17; Info.SendDlgMessage(hDlg,DM_RESIZEDIALOG,0,(long)&coord); Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,0); Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,0); EditMode=FALSE; } } return TRUE; case DN_CLOSE: if (MenuItems) free(MenuItems); SetRegKey(®[REG_LASTCOORDX],coord.X); SetRegKey(®[REG_LASTCOORDY],coord.Y); return TRUE; } return Info.DefDlgProc(hDlg,Msg,Param1,Param2); }
bool EditTypeRecord(int EditPos,int TotalRecords,bool NewRec) { bool Result=false; const int DlgX=76,DlgY=23; DialogDataEx EditDlgData[]= { DI_DOUBLEBOX,3, 1,DlgX-4,DlgY-2,0,0,MSG(MFileAssocTitle), DI_TEXT, 5, 2, 0, 2,0,0,MSG(MFileAssocMasks), DI_EDIT, 5, 3,DlgX-6, 3,(DWORD_PTR)L"Masks",DIF_FOCUS|DIF_HISTORY,L"", DI_TEXT, 5, 4, 0, 4,0,0,MSG(MFileAssocDescr), DI_EDIT, 5, 5,DlgX-6, 5,0,0,L"", DI_TEXT, 3, 6, 0, 6,0,DIF_SEPARATOR,L"", DI_CHECKBOX, 5, 7, 0, 7,1,0,MSG(MFileAssocExec), DI_EDIT, 9, 8,DlgX-6, 8,0,DIF_EDITPATH,L"", DI_CHECKBOX, 5, 9, 0, 9,1,0,MSG(MFileAssocAltExec), DI_EDIT, 9,10,DlgX-6,10,0,DIF_EDITPATH,L"", DI_CHECKBOX, 5,11, 0,11,1,0,MSG(MFileAssocView), DI_EDIT, 9,12,DlgX-6,12,0,DIF_EDITPATH,L"", DI_CHECKBOX, 5,13, 0,13,1,0,MSG(MFileAssocAltView), DI_EDIT, 9,14,DlgX-6,14,0,DIF_EDITPATH,L"", DI_CHECKBOX, 5,15, 0,15,1,0,MSG(MFileAssocEdit), DI_EDIT, 9,16,DlgX-6,16,0,DIF_EDITPATH,L"", DI_CHECKBOX, 5,17, 0,17,1,0,MSG(MFileAssocAltEdit), DI_EDIT, 9,18,DlgX-6,18,0,DIF_EDITPATH,L"", DI_TEXT, 3,DlgY-4, 0,DlgY-4,0,DIF_SEPARATOR,L"", DI_BUTTON, 0,DlgY-3, 0,DlgY-3,0,DIF_DEFAULT|DIF_CENTERGROUP,MSG(MOk), DI_BUTTON, 0,DlgY-3, 0,DlgY-3,0,DIF_CENTERGROUP,MSG(MCancel), }; MakeDialogItemsEx(EditDlgData,EditDlg); string strRegKey; strRegKey.Format(FTS.TypeFmt,EditPos); if (!NewRec) { GetRegKey(strRegKey,FTS.Mask,EditDlg[ETR_EDIT_MASKS].strData,L""); GetRegKey(strRegKey,FTS.Desc,EditDlg[ETR_EDIT_DESCR].strData,L""); GetRegKey(strRegKey,FTS.Execute,EditDlg[ETR_EDIT_EXEC].strData,L""); GetRegKey(strRegKey,FTS.AltExec,EditDlg[ETR_EDIT_ALTEXEC].strData,L""); GetRegKey(strRegKey,FTS.View,EditDlg[ETR_EDIT_VIEW].strData,L""); GetRegKey(strRegKey,FTS.AltView,EditDlg[ETR_EDIT_ALTVIEW].strData,L""); GetRegKey(strRegKey,FTS.Edit,EditDlg[ETR_EDIT_EDIT].strData,L""); GetRegKey(strRegKey,FTS.AltEdit,EditDlg[ETR_EDIT_ALTEDIT].strData,L""); DWORD State=GetRegKey(strRegKey,FTS.State,0xffffffff); for (int i=FILETYPE_EXEC,Item=ETR_COMBO_EXEC; i<=FILETYPE_ALTEDIT; i++,Item+=2) { if (!(State&(1<<i))) { EditDlg[Item].Selected=BSTATE_UNCHECKED; EditDlg[Item+1].Flags|=DIF_DISABLE; } } } Dialog Dlg(EditDlg,ARRAYSIZE(EditDlg),EditTypeRecordDlgProc); Dlg.SetHelp(FTS.HelpModify); Dlg.SetPosition(-1,-1,DlgX,DlgY); Dlg.Process(); if (Dlg.GetExitCode()==ETR_BUTTON_OK) { if (NewRec) { InsertKeyRecord(FTS.TypeFmt,EditPos,TotalRecords); } SetRegKey(strRegKey,FTS.Mask,EditDlg[ETR_EDIT_MASKS].strData); SetRegKey(strRegKey,FTS.Desc,EditDlg[ETR_EDIT_DESCR].strData); SetRegKey(strRegKey,FTS.Execute,EditDlg[ETR_EDIT_EXEC].strData); SetRegKey(strRegKey,FTS.AltExec,EditDlg[ETR_EDIT_ALTEXEC].strData); SetRegKey(strRegKey,FTS.View,EditDlg[ETR_EDIT_VIEW].strData); SetRegKey(strRegKey,FTS.AltView,EditDlg[ETR_EDIT_ALTVIEW].strData); SetRegKey(strRegKey,FTS.Edit,EditDlg[ETR_EDIT_EDIT].strData); SetRegKey(strRegKey,FTS.AltEdit,EditDlg[ETR_EDIT_ALTEDIT].strData); DWORD State=0; for (int i=FILETYPE_EXEC,Item=ETR_COMBO_EXEC; i<=FILETYPE_ALTEDIT; i++,Item+=2) { if (EditDlg[Item].Selected==BSTATE_CHECKED) { State|=(1<<i); } } SetRegKey(strRegKey,FTS.State,State); Result=true; } return Result; }
// Обработка добавления/удаления в/из список выбранных таблиц символов void ProcessSelected(bool select) { if (Opt.CPMenuMode && select) return; UINT itemPosition = CodePages->GetSelectPos(); UINT codePage = GetMenuItemCodePage(); if ((select && IsPositionFavorite(itemPosition)) || (!select && IsPositionNormal(itemPosition))) { // Преобразуем номер таблицы символов в строку FormatString strCPName; strCPName<<codePage; // Получаем текущее состояние флага в реестре int selectType = 0; GetRegKey(FavoriteCodePagesKey, strCPName, selectType, 0); // Удаляем/добавляем в ресестре информацию о выбранной кодовой странице if (select) SetRegKey(FavoriteCodePagesKey, strCPName, CPST_FAVORITE | (selectType & CPST_FIND ? CPST_FIND : 0)); else if (selectType & CPST_FIND) SetRegKey(FavoriteCodePagesKey, strCPName, CPST_FIND); else DeleteRegValue(FavoriteCodePagesKey, strCPName); // Создаём новый элемент меню MenuItemEx newItem; newItem.Clear(); newItem.strName = CodePages->GetItemPtr()->strName; newItem.UserData = (char *)(UINT_PTR)codePage; newItem.UserDataSize = sizeof(UINT); // Сохраняем позицию курсора int position=CodePages->GetSelectPos(); // Удаляем старый пункт меню CodePages->DeleteItem(CodePages->GetSelectPos()); // Добавляем пункт меню в новое место if (select) { // Добавляем разделитель, если выбранных кодовых страниц ещё не было // и после добавления останутся нормальные кодовые страницы if (!favoriteCodePages && normalCodePages>1) AddSeparator(MSG(MGetCodePageFavorites),CodePages->GetItemCount()-normalCodePages); // Ищем позицию, куда добавить элемент int newPosition = GetCodePageInsertPosition( codePage, CodePages->GetItemCount()-normalCodePages-favoriteCodePages, favoriteCodePages ); // Добавляем кодовою страницу в выбранные CodePages->AddItem(&newItem, newPosition); // Удаляем разделитель, если нет обыкновынных кодовых страниц if (normalCodePages==1) CodePages->DeleteItem(CodePages->GetItemCount()-1); // Изменяем счётчики нормальных и выбранных кодовых страниц favoriteCodePages++; normalCodePages--; position++; } else { // Удаляем разделитеь, если после удаления не останнется ни одной // выбранной таблицы символов if (favoriteCodePages==1 && normalCodePages>0) CodePages->DeleteItem(CodePages->GetItemCount()-normalCodePages-2); // Переносим элемент в нормальные таблицы, только если они показываются if (!Opt.CPMenuMode) { // Добавляем разделитель, если не было ни одной нормальной кодовой страницы if (!normalCodePages) AddSeparator(MSG(MGetCodePageOther)); // Добавляем кодовою страницу в нормальные CodePages->AddItem( &newItem, GetCodePageInsertPosition( codePage, CodePages->GetItemCount()-normalCodePages, normalCodePages ) ); normalCodePages++; } // Если в режиме скрытия нормальных таблиц мы удалили последнюю выбранную таблицу, то удаляем и разделитель else if (favoriteCodePages==1) CodePages->DeleteItem(CodePages->GetItemCount()-normalCodePages-1); favoriteCodePages--; if (position==CodePages->GetItemCount()-normalCodePages-1) position--; } // Устанавливаем позицию в меню CodePages->SetSelectPos(position>=CodePages->GetItemCount() ? CodePages->GetItemCount()-1 : position, 1); // Показываем меню if (Opt.CPMenuMode) CodePages->SetPosition(-1, -1, 0, 0); CodePages->Show(); } }
int MrRipper::ProcessKey(int Key, unsigned int ControlState) { switch (ControlState) { case (PKF_CONTROL|PKF_SHIFT): if (Key==VK_F3) ConvView = (Opt.DoConv)?FALSE:TRUE; return Key==VK_F4?TRUE:FALSE; break; case (PKF_SHIFT): if (Key == VK_F4){ AddDummy(); Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); return TRUE; } if (Key == VK_F3){ SplitFile(); Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); return TRUE; } if (Key == VK_F1){ Opt.UseLists = !Opt.UseLists; Free_shownfiles(); Free_copyfiles(); Free_dirs(); Free_dummyfiles(); FAT.ReInitFAT(); Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); SetRegKey(HKEY_CURRENT_USER,"",StrUseLists, Opt.UseLists); return TRUE; } if (Key == VK_F2){ SaveList(FALSE); return TRUE; } return (Key==VK_F5)|| (Key==VK_F6)|| (Key==VK_F7)|| (Key==VK_F8)?TRUE:FALSE; break; case (PKF_ALT): return (Key==VK_F6)?TRUE:FALSE; break; case (PKF_CONTROL): if (Key==VK_F9) { if (DefineRange(Opt.StartOffset, Opt.EndOffset)) { Opt.UserScanRange = TRUE; FAT.ReInitFAT(); Free_shownfiles(); Free_dirs(); Free_copyfiles(); Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); return TRUE; } } if (Key==VK_F8) { Opt.UserScanRange = FALSE; FAT.ReInitFAT(); Free_shownfiles(); Free_dirs(); Free_copyfiles(); Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); return TRUE; } if (Key==VK_F5) { FAT.ReInitFAT(); Free_shownfiles(); Free_copyfiles(); Free_dirs(); Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); return TRUE; } return (Key==VK_F11)?TRUE:FALSE; break; default: if (Key==VK_F3) ConvView = (Opt.DoConv)?TRUE:FALSE; if (Key==VK_F5) ConvView = Opt.DoConv; if (Key==VK_F6) { if (bPluginManager) return SavePlugins(); } if (Key==VK_F7){ if (!bPluginManager) { DelDup = !DelDup; Info.Control(INVALID_HANDLE_VALUE, FCTL_UPDATEPANEL, (void*)1); Info.Control(INVALID_HANDLE_VALUE, FCTL_REDRAWPANEL, NULL); return TRUE; } else { CreateSheme(); return TRUE; } } if (Key==VK_F8) if (bPluginManager) { LoadSheme(); return TRUE; } return (Key==VK_F4)?TRUE:FALSE; break; } return FALSE; }