📄 globalparams.cc
字号:
if (tokens->getLength() != 5) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } tok = (GString *)tokens->get(2); if (!tok->cmp("H")) { wMode = 0; } else if (!tok->cmp("V")) { wMode = 1; } else { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } param = new PSFontParam(((GString *)tokens->get(1))->copy(), wMode, ((GString *)tokens->get(3))->copy(), ((GString *)tokens->get(4))->copy()); fontList->append(param);}void GlobalParams::parseTextEncoding(GList *tokens, GString *fileName, int line) { if (tokens->getLength() != 2) { error(-1, "Bad 'textEncoding' config file command (%s:%d)", fileName->getCString(), line); return; } delete textEncoding; textEncoding = ((GString *)tokens->get(1))->copy();}void GlobalParams::parseTextEOL(GList *tokens, GString *fileName, int line) { GString *tok; if (tokens->getLength() != 2) { error(-1, "Bad 'textEOL' config file command (%s:%d)", fileName->getCString(), line); return; } tok = (GString *)tokens->get(1); if (!tok->cmp("unix")) { textEOL = eolUnix; } else if (!tok->cmp("dos")) { textEOL = eolDOS; } else if (!tok->cmp("mac")) { textEOL = eolMac; } else { error(-1, "Bad 'textEOL' config file command (%s:%d)", fileName->getCString(), line); }}void GlobalParams::parseFontDir(GList *tokens, GString *fileName, int line) { if (tokens->getLength() != 2) { error(-1, "Bad 'fontDir' config file command (%s:%d)", fileName->getCString(), line); return; } fontDirs->append(((GString *)tokens->get(1))->copy());}void GlobalParams::parseInitialZoom(GList *tokens, GString *fileName, int line) { if (tokens->getLength() != 2) { error(-1, "Bad 'initialZoom' config file command (%s:%d)", fileName->getCString(), line); return; } delete initialZoom; initialZoom = ((GString *)tokens->get(1))->copy();}void GlobalParams::parseScreenType(GList *tokens, GString *fileName, int line) { GString *tok; if (tokens->getLength() != 2) { error(-1, "Bad 'screenType' config file command (%s:%d)", fileName->getCString(), line); return; } tok = (GString *)tokens->get(1); if (!tok->cmp("dispersed")) { screenType = screenDispersed; } else if (!tok->cmp("clustered")) { screenType = screenClustered; } else if (!tok->cmp("stochasticClustered")) { screenType = screenStochasticClustered; } else { error(-1, "Bad 'screenType' config file command (%s:%d)", fileName->getCString(), line); }}void GlobalParams::parseBind(GList *tokens, GString *fileName, int line) { KeyBinding *binding; GList *cmds; int code, mods, context, i; if (tokens->getLength() < 4) { error(-1, "Bad 'bind' config file command (%s:%d)", fileName->getCString(), line); return; } if (!parseKey((GString *)tokens->get(1), (GString *)tokens->get(2), &code, &mods, &context, "bind", tokens, fileName, line)) { return; } for (i = 0; i < keyBindings->getLength(); ++i) { binding = (KeyBinding *)keyBindings->get(i); if (binding->code == code && binding->mods == mods && binding->context == context) { delete (KeyBinding *)keyBindings->del(i); break; } } cmds = new GList(); for (i = 3; i < tokens->getLength(); ++i) { cmds->append(((GString *)tokens->get(i))->copy()); } keyBindings->append(new KeyBinding(code, mods, context, cmds));}void GlobalParams::parseUnbind(GList *tokens, GString *fileName, int line) { KeyBinding *binding; int code, mods, context, i; if (tokens->getLength() != 3) { error(-1, "Bad 'unbind' config file command (%s:%d)", fileName->getCString(), line); return; } if (!parseKey((GString *)tokens->get(1), (GString *)tokens->get(2), &code, &mods, &context, "unbind", tokens, fileName, line)) { return; } for (i = 0; i < keyBindings->getLength(); ++i) { binding = (KeyBinding *)keyBindings->get(i); if (binding->code == code && binding->mods == mods && binding->context == context) { delete (KeyBinding *)keyBindings->del(i); break; } }}GBool GlobalParams::parseKey(GString *modKeyStr, GString *contextStr, int *code, int *mods, int *context, char *cmdName, GList *tokens, GString *fileName, int line) { char *p0; *mods = xpdfKeyModNone; p0 = modKeyStr->getCString(); while (1) { if (!strncmp(p0, "shift-", 6)) { *mods |= xpdfKeyModShift; p0 += 6; } else if (!strncmp(p0, "ctrl-", 5)) { *mods |= xpdfKeyModCtrl; p0 += 5; } else if (!strncmp(p0, "alt-", 4)) { *mods |= xpdfKeyModAlt; p0 += 4; } else { break; } } if (!strcmp(p0, "space")) { *code = ' '; } else if (!strcmp(p0, "tab")) { *code = xpdfKeyCodeTab; } else if (!strcmp(p0, "return")) { *code = xpdfKeyCodeReturn; } else if (!strcmp(p0, "enter")) { *code = xpdfKeyCodeEnter; } else if (!strcmp(p0, "backspace")) { *code = xpdfKeyCodeBackspace; } else if (!strcmp(p0, "insert")) { *code = xpdfKeyCodeInsert; } else if (!strcmp(p0, "delete")) { *code = xpdfKeyCodeDelete; } else if (!strcmp(p0, "home")) { *code = xpdfKeyCodeHome; } else if (!strcmp(p0, "end")) { *code = xpdfKeyCodeEnd; } else if (!strcmp(p0, "pgup")) { *code = xpdfKeyCodePgUp; } else if (!strcmp(p0, "pgdn")) { *code = xpdfKeyCodePgDn; } else if (!strcmp(p0, "left")) { *code = xpdfKeyCodeLeft; } else if (!strcmp(p0, "right")) { *code = xpdfKeyCodeRight; } else if (!strcmp(p0, "up")) { *code = xpdfKeyCodeUp; } else if (!strcmp(p0, "down")) { *code = xpdfKeyCodeDown; } else if (p0[0] == 'f' && p0[1] >= '1' && p0[1] <= '9' && !p0[2]) { *code = xpdfKeyCodeF1 + (p0[1] - '1'); } else if (p0[0] == 'f' && ((p0[1] >= '1' && p0[1] <= '2' && p0[2] >= '0' && p0[2] <= '9') || (p0[1] == '3' && p0[2] >= '0' && p0[2] <= '5')) && !p0[3]) { *code = xpdfKeyCodeF1 + 10 * (p0[1] - '0') + (p0[2] - '0') - 1; } else if (!strncmp(p0, "mousePress", 10) && p0[10] >= '1' && p0[10] <= '7' && !p0[11]) { *code = xpdfKeyCodeMousePress1 + (p0[10] - '1'); } else if (!strncmp(p0, "mouseRelease", 12) && p0[12] >= '1' && p0[12] <= '7' && !p0[13]) { *code = xpdfKeyCodeMouseRelease1 + (p0[12] - '1'); } else if (*p0 >= 0x20 && *p0 <= 0x7e && !p0[1]) { *code = (int)*p0; } else { error(-1, "Bad key/modifier in '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return gFalse; } p0 = contextStr->getCString(); if (!strcmp(p0, "any")) { *context = xpdfKeyContextAny; } else { *context = xpdfKeyContextAny; while (1) { if (!strncmp(p0, "fullScreen", 10)) { *context |= xpdfKeyContextFullScreen; p0 += 10; } else if (!strncmp(p0, "window", 6)) { *context |= xpdfKeyContextWindow; p0 += 6; } else if (!strncmp(p0, "continuous", 10)) { *context |= xpdfKeyContextContinuous; p0 += 10; } else if (!strncmp(p0, "singlePage", 10)) { *context |= xpdfKeyContextSinglePage; p0 += 10; } else if (!strncmp(p0, "overLink", 8)) { *context |= xpdfKeyContextOverLink; p0 += 8; } else if (!strncmp(p0, "offLink", 7)) { *context |= xpdfKeyContextOffLink; p0 += 7; } else if (!strncmp(p0, "outline", 7)) { *context |= xpdfKeyContextOutline; p0 += 7; } else if (!strncmp(p0, "mainWin", 7)) { *context |= xpdfKeyContextMainWin; p0 += 7; } else if (!strncmp(p0, "scrLockOn", 9)) { *context |= xpdfKeyContextScrLockOn; p0 += 9; } else if (!strncmp(p0, "scrLockOff", 10)) { *context |= xpdfKeyContextScrLockOff; p0 += 10; } else { error(-1, "Bad context in '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return gFalse; } if (!*p0) { break; } if (*p0 != ',') { error(-1, "Bad context in '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return gFalse; } ++p0; } } return gTrue;}void GlobalParams::parseCommand(char *cmdName, GString **val, GList *tokens, GString *fileName, int line) { if (tokens->getLength() != 2) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } if (*val) { delete *val; } *val = ((GString *)tokens->get(1))->copy();}void GlobalParams::parseYesNo(char *cmdName, GBool *flag, GList *tokens, GString *fileName, int line) { GString *tok; if (tokens->getLength() != 2) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } tok = (GString *)tokens->get(1); if (!parseYesNo2(tok->getCString(), flag)) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); }}GBool GlobalParams::parseYesNo2(char *token, GBool *flag) { if (!strcmp(token, "yes")) { *flag = gTrue; } else if (!strcmp(token, "no")) { *flag = gFalse; } else { return gFalse; } return gTrue;}void GlobalParams::parseInteger(char *cmdName, int *val, GList *tokens, GString *fileName, int line) { GString *tok; int i; if (tokens->getLength() != 2) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } tok = (GString *)tokens->get(1); if (tok->getLength() == 0) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } if (tok->getChar(0) == '-') { i = 1; } else { i = 0; } for (; i < tok->getLength(); ++i) { if (tok->getChar(i) < '0' || tok->getChar(i) > '9') { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } } *val = atoi(tok->getCString());}void GlobalParams::parseFloat(char *cmdName, double *val, GList *tokens, GString *fileName, int line) { GString *tok; int i; if (tokens->getLength() != 2) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } tok = (GString *)tokens->get(1); if (tok->getLength() == 0) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } if (tok->getChar(0) == '-') { i = 1; } else { i = 0; } for (; i < tok->getLength(); ++i) { if (!((tok->getChar(i) >= '0' && tok->getChar(i) <= '9') || tok->getChar(i) == '.')) { error(-1, "Bad '%s' config file command (%s:%d)", cmdName, fileName->getCString(), line); return; } } *val = atof(tok->getCString());}GlobalParams::~GlobalParams() { GHashIter *iter; GString *key; GList *list; freeBuiltinFontTables(); delete macRomanReverseMap; delete baseDir; delete nameToUnicode; deleteGHash(cidToUnicodes, GString); deleteGHash(unicodeToUnicodes, GString); deleteGHash(residentUnicodeMaps, UnicodeMap); deleteGHash(unicodeMaps, GString); deleteGList(toUnicodeDirs, GString); deleteGHash(displayFonts, DisplayFontParam); deleteGHash(displayCIDFonts, DisplayFontParam); deleteGHash(displayNamedCIDFonts, DisplayFontParam);#ifdef WIN32 if (winFontList) { delete winFontList; }#endif if (psFile) { delete psFile; } deleteGHash(psFonts, PSFontParam); deleteGList(psNamedFonts16, PSFontParam); deleteGList(psFonts16, PSFontParam); delete textEncoding; deleteGList(fontDirs, GString); delete initialZoom; if (urlCommand) { delete urlCommand; } if (movieCommand) { delete movieCommand; } deleteGList(keyBindings, KeyBinding); cMapDirs->startIter(&iter); while (cMapDirs->getNext(&iter, &key, (void **)&list)) { deleteGList(list, GString); } delete cMapDirs; delete cidToUnicodeCache; delete unicodeToUnicodeCache; delete unicodeMapCache; delete cMapCache;#ifdef ENABLE_PLUGINS delete securityHandlers; deleteGList(plugins, Plugin);#endif#if MULTITHREADED gDestroyMutex(&mutex); gDestroyMutex(&unicodeMapCacheMutex); gDestroyMutex(&cMapCacheMutex);#endif}//------------------------------------------------------------------------void GlobalParams::setBaseDir(char *dir) { delete baseDir; baseDir = new GString(dir);}void GlobalParams::setupBaseFonts(char *dir) { GString *fontName; GString *fileName;#ifdef WIN32 HMODULE shell32Lib; BOOL (__stdcall *SHGetSpecialFolderPathFunc)(HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate); char winFontDir[MAX_PATH];#endif FILE *f; DisplayFontParamKind kind; DisplayFontParam *dfp; int i, j;#ifdef WIN32 // SHGetSpecialFolderPath isn't available in older versions of // shell32.dll (Win95 and WinNT4), so do a dynamic load winFontDir[0] = '\0'; if ((shell32Lib = LoadLibrary("shell32.dll"))) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -