📄 options.c
字号:
default: return -1; } } tOptionsCurr.eEncoding = eMappingFile2Encoding(szLeafname); DBG_DEC(tOptionsCurr.eEncoding); if (tOptionsCurr.eConversionType == conversion_ps && tOptionsCurr.eEncoding == encoding_utf_8) { werr(0, "The combination PostScript and UTF-8 is not supported"); return -1; } if (tOptionsCurr.eConversionType == conversion_pdf && tOptionsCurr.eEncoding == encoding_utf_8) { werr(0, "The combination PDF and UTF-8 is not supported"); return -1; } if (tOptionsCurr.eConversionType == conversion_pdf && tOptionsCurr.eEncoding == encoding_cyrillic) { werr(0, "The combination PDF and Cyrillic is not supported"); return -1; } if (tOptionsCurr.eConversionType == conversion_ps || tOptionsCurr.eConversionType == conversion_pdf) { /* PostScript or PDF mode */ if (tOptionsCurr.bUseLandscape) { /* Swap the page height and width */ iTmp = tOptionsCurr.iPageHeight; tOptionsCurr.iPageHeight = tOptionsCurr.iPageWidth; tOptionsCurr.iPageWidth = iTmp; } /* The paragraph break depends on the width of the paper */ tOptionsCurr.iParagraphBreak = iMilliPoints2Char( (long)tOptionsCurr.iPageWidth * 1000 - lDrawUnits2MilliPoints( PS_LEFT_MARGIN + PS_RIGHT_MARGIN)); DBG_DEC(tOptionsCurr.iParagraphBreak); } pCharacterMappingFile = pOpenCharacterMappingFile(szLeafname); if (pCharacterMappingFile != NULL) { bSuccess = bReadCharacterMappingTable(pCharacterMappingFile); vCloseCharacterMappingFile(pCharacterMappingFile); } else { bSuccess = FALSE; } return bSuccess ? optind : -1;#endif /* __riscos */} /* end of iReadOptions *//* * vGetOptions - get a copy of the current option values */voidvGetOptions(options_type *pOptions){ fail(pOptions == NULL); *pOptions = tOptionsCurr;} /* end of vGetOptions */#if defined(__riscos)/* * vWriteOptions - write the current options to the Options file */static voidvWriteOptions(void){ FILE *pFile; char *szOptionsFile; TRACE_MSG("vWriteOptions"); szOptionsFile = getenv("AntiWord$ChoicesSave"); if (szOptionsFile == NULL) { werr(0, "Warning: Name of the Choices file not found"); return; } if (!bMakeDirectory(szOptionsFile)) { werr(0, "Warning: I can't make a directory for the Choices file"); return; } pFile = fopen(szOptionsFile, "w"); if (pFile == NULL) { werr(0, "Warning: I can't write the Choices file"); return; } (void)fprintf(pFile, PARAGRAPH_BREAK"\n", tOptionsCurr.iParagraphBreak); (void)fprintf(pFile, AUTOFILETYPE"\n", tOptionsCurr.bAutofiletypeAllowed); (void)fprintf(pFile, USE_OUTLINEFONTS"\n", tOptionsCurr.eConversionType == conversion_text ? 0 : 1); (void)fprintf(pFile, SHOW_IMAGES"\n", tOptionsCurr.eImageLevel == level_no_images ? 0 : 1); (void)fprintf(pFile, HIDE_HIDDEN_TEXT"\n", tOptionsCurr.bHideHiddenText); (void)fprintf(pFile, SCALE_FACTOR_START"\n", tOptionsCurr.iScaleFactor); (void)fclose(pFile);} /* end of vWriteOptions *//* * vChoicesOpenAction - action to be taken when the Choices window opens */voidvChoicesOpenAction(window_handle tWindow){ TRACE_MSG("vChoicesOpenAction"); tOptionsTemp = tOptionsCurr; if (tOptionsTemp.iParagraphBreak == 0) { vUpdateRadioButton(tWindow, CHOICES_BREAK_BUTTON, FALSE); vUpdateRadioButton(tWindow, CHOICES_NO_BREAK_BUTTON, TRUE); vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE, DEFAULT_SCREEN_WIDTH); } else { vUpdateRadioButton(tWindow, CHOICES_BREAK_BUTTON, TRUE); vUpdateRadioButton(tWindow, CHOICES_NO_BREAK_BUTTON, FALSE); vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE, tOptionsTemp.iParagraphBreak); } vUpdateRadioButton(tWindow, CHOICES_AUTOFILETYPE_BUTTON, tOptionsTemp.bAutofiletypeAllowed); vUpdateRadioButton(tWindow, CHOICES_HIDDEN_TEXT_BUTTON, tOptionsTemp.bHideHiddenText); if (tOptionsTemp.eConversionType == conversion_draw) { vUpdateRadioButton(tWindow, CHOICES_WITH_IMAGES_BUTTON, tOptionsTemp.eImageLevel != level_no_images); vUpdateRadioButton(tWindow, CHOICES_NO_IMAGES_BUTTON, tOptionsTemp.eImageLevel == level_no_images); vUpdateRadioButton(tWindow, CHOICES_TEXTONLY_BUTTON, FALSE); } else { vUpdateRadioButton(tWindow, CHOICES_WITH_IMAGES_BUTTON, FALSE); vUpdateRadioButton(tWindow, CHOICES_NO_IMAGES_BUTTON, FALSE); vUpdateRadioButton(tWindow, CHOICES_TEXTONLY_BUTTON, TRUE); } vUpdateWriteableNumber(tWindow, CHOICES_SCALE_WRITEABLE, tOptionsTemp.iScaleFactor); TRACE_MSG("end of vChoicesOpenAction");} /* end of vChoicesOpenAction *//* * vDefaultButtonAction - action when the default button is clicked */static voidvDefaultButtonAction(window_handle tWindow){ TRACE_MSG("vDefaultButtonAction"); tOptionsTemp = tOptionsDefault; vUpdateRadioButton(tWindow, CHOICES_BREAK_BUTTON, TRUE); vUpdateRadioButton(tWindow, CHOICES_NO_BREAK_BUTTON, FALSE); vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE, tOptionsTemp.iParagraphBreak); vUpdateRadioButton(tWindow, CHOICES_AUTOFILETYPE_BUTTON, tOptionsTemp.bAutofiletypeAllowed); vUpdateRadioButton(tWindow, CHOICES_HIDDEN_TEXT_BUTTON, tOptionsTemp.bHideHiddenText); vUpdateRadioButton(tWindow, CHOICES_WITH_IMAGES_BUTTON, tOptionsTemp.eConversionType == conversion_draw && tOptionsTemp.eImageLevel != level_no_images); vUpdateRadioButton(tWindow, CHOICES_NO_IMAGES_BUTTON, tOptionsTemp.eConversionType == conversion_draw && tOptionsTemp.eImageLevel == level_no_images); vUpdateRadioButton(tWindow, CHOICES_TEXTONLY_BUTTON, tOptionsTemp.eConversionType == conversion_text); vUpdateWriteableNumber(tWindow, CHOICES_SCALE_WRITEABLE, tOptionsTemp.iScaleFactor);} /* end of vDefaultButtonAction *//* * vApplyButtonAction - action to be taken when the OK button is clicked */static voidvApplyButtonAction(void){ TRACE_MSG("vApplyButtonAction"); tOptionsCurr = tOptionsTemp;} /* end of vApplyButtonAction *//* * vSaveButtonAction - action to be taken when the save button is clicked */static voidvSaveButtonAction(void){ TRACE_MSG("vSaveButtonAction"); vApplyButtonAction(); vWriteOptions();} /* end of vSaveButtonAction *//* * vSetParagraphBreak - set the paragraph break to the given number */static voidvSetParagraphBreak(window_handle tWindow, int iNumber){ tOptionsTemp.iParagraphBreak = iNumber; if (tOptionsTemp.iParagraphBreak == 0) { return; } vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE, tOptionsTemp.iParagraphBreak);} /* end of vSetParagraphBreak *//* * vChangeParagraphBreak - change the paragraph break with the given number */static voidvChangeParagraphBreak(window_handle tWindow, int iNumber){ int iTmp; iTmp = tOptionsTemp.iParagraphBreak + iNumber; if (iTmp < MIN_SCREEN_WIDTH || iTmp > MAX_SCREEN_WIDTH) { /* Ignore */ return; } tOptionsTemp.iParagraphBreak = iTmp; vUpdateWriteableNumber(tWindow, CHOICES_BREAK_WRITEABLE, tOptionsTemp.iParagraphBreak);} /* end of vChangeParagraphBreak *//* * vChangeAutofiletype - invert the permission to autofiletype */static voidvChangeAutofiletype(window_handle tWindow){ tOptionsTemp.bAutofiletypeAllowed = !tOptionsTemp.bAutofiletypeAllowed; vUpdateRadioButton(tWindow, CHOICES_AUTOFILETYPE_BUTTON, tOptionsTemp.bAutofiletypeAllowed);} /* end of vChangeAutofiletype *//* * vChangeHiddenText - invert the hide/show hidden text */static voidvChangeHiddenText(window_handle tWindow){ tOptionsTemp.bHideHiddenText = !tOptionsTemp.bHideHiddenText; vUpdateRadioButton(tWindow, CHOICES_HIDDEN_TEXT_BUTTON, tOptionsTemp.bHideHiddenText);} /* end of vChangeHiddenText *//* * vUseFontsImages - use outline fonts, show images */static voidvUseFontsImages(BOOL bUseOutlineFonts, BOOL bShowImages){ tOptionsTemp.eConversionType = bUseOutlineFonts ? conversion_draw : conversion_text; tOptionsTemp.eImageLevel = bUseOutlineFonts && bShowImages ? level_default : level_no_images;} /* end of vUseFontsImages *//* * vSetScaleFactor - set the scale factor to the given number */static voidvSetScaleFactor(window_handle tWindow, int iNumber){ tOptionsTemp.iScaleFactor = iNumber; vUpdateWriteableNumber(tWindow, CHOICES_SCALE_WRITEABLE, tOptionsTemp.iScaleFactor);} /* end of vSetScaleFactor *//* * vChangeScaleFactor - change the scale factor with the given number */static voidvChangeScaleFactor(window_handle tWindow, int iNumber){ int iTmp; iTmp = tOptionsTemp.iScaleFactor + iNumber; if (iTmp < MIN_SCALE_FACTOR || iTmp > MAX_SCALE_FACTOR) { /* Ignore */ return; } tOptionsTemp.iScaleFactor = iTmp; vUpdateWriteableNumber(tWindow, CHOICES_SCALE_WRITEABLE, tOptionsTemp.iScaleFactor);} /* end of vChangeScaleFactor *//* * bChoicesMouseClick - handle a mouse click in the Choices window */BOOLbChoicesMouseClick(event_pollblock *pEvent, void *pvReference){ icon_handle tAction; mouse_block *pMouse; BOOL bCloseWindow; TRACE_MSG("bChoicesMouseClick"); fail(pEvent == NULL); fail(pEvent->type != event_CLICK); pMouse = &pEvent->data.mouse; if (!pMouse->button.data.select && !pMouse->button.data.adjust) { /* Not handled here */ DBG_HEX(pMouse->button.value); return FALSE; } /* Which action should be taken */ tAction = pMouse->icon; if (pMouse->button.data.adjust) { /* The adjust button reverses the direction */ switch (pMouse->icon) { case CHOICES_BREAK_UP_BUTTON: tAction = CHOICES_BREAK_DOWN_BUTTON; break; case CHOICES_BREAK_DOWN_BUTTON: tAction = CHOICES_BREAK_UP_BUTTON; break; case CHOICES_SCALE_UP_BUTTON: tAction = CHOICES_SCALE_DOWN_BUTTON; break; case CHOICES_SCALE_DOWN_BUTTON: tAction = CHOICES_SCALE_UP_BUTTON; break; default: break; } } /* Actions */ bCloseWindow = FALSE; switch (tAction) { case CHOICES_DEFAULT_BUTTON: vDefaultButtonAction(pMouse->window); break; case CHOICES_SAVE_BUTTON: vSaveButtonAction(); break; case CHOICES_CANCEL_BUTTON: bCloseWindow = TRUE; break; case CHOICES_APPLY_BUTTON: vApplyButtonAction(); bCloseWindow = TRUE; break; case CHOICES_BREAK_BUTTON: vSetParagraphBreak(pMouse->window, DEFAULT_SCREEN_WIDTH); break; case CHOICES_BREAK_UP_BUTTON: vChangeParagraphBreak(pMouse->window, 1); break; case CHOICES_BREAK_DOWN_BUTTON: vChangeParagraphBreak(pMouse->window, -1); break; case CHOICES_NO_BREAK_BUTTON: vSetParagraphBreak(pMouse->window, 0); break; case CHOICES_AUTOFILETYPE_BUTTON: vChangeAutofiletype(pMouse->window); break; case CHOICES_HIDDEN_TEXT_BUTTON: vChangeHiddenText(pMouse->window); break; case CHOICES_WITH_IMAGES_BUTTON: vUseFontsImages(TRUE, TRUE); break; case CHOICES_NO_IMAGES_BUTTON: vUseFontsImages(TRUE, FALSE); break; case CHOICES_TEXTONLY_BUTTON: vUseFontsImages(FALSE, FALSE); break; case CHOICES_SCALE_UP_BUTTON: vChangeScaleFactor(pMouse->window, 5); break; case CHOICES_SCALE_DOWN_BUTTON: vChangeScaleFactor(pMouse->window, -5); break; default: DBG_DEC(pMouse->icon); break; } if (bCloseWindow) { Error_CheckFatal(Wimp_CloseWindow(pMouse->window)); } return TRUE;} /* end of bChoicesMouseClick *//* * bChoicesKeyPressed - handle a key in the Choices window */BOOLbChoicesKeyPressed(event_pollblock *pEvent, void *pvReference){ icon_block tIcon; caret_block *pCaret; char *pcChar; int iNumber; DBG_MSG("bChoicesKeyPressed"); fail(pEvent == NULL); fail(pEvent->type != event_KEY); if (pEvent->data.key.code != '\r') { Error_CheckFatal(Wimp_ProcessKey(pEvent->data.key.code)); return TRUE; } pCaret = &pEvent->data.key.caret; Error_CheckFatal(Wimp_GetIconState(pCaret->window, pCaret->icon, &tIcon)); if (!tIcon.flags.data.text || !tIcon.flags.data.indirected) { werr(1, "Icon %d must be indirected text", (int)pCaret->icon); } iNumber = (int)strtol(tIcon.data.indirecttext.buffer, &pcChar, 10); switch(pCaret->icon) { case CHOICES_BREAK_WRITEABLE: if (*pcChar != '\0' && *pcChar != '\r') { DBG_DEC(*pcChar); iNumber = DEFAULT_SCREEN_WIDTH; } else if (iNumber < MIN_SCREEN_WIDTH) { iNumber = MIN_SCREEN_WIDTH; } else if (iNumber > MAX_SCREEN_WIDTH) { iNumber = MAX_SCREEN_WIDTH; } vSetParagraphBreak(pCaret->window, iNumber); break; case CHOICES_SCALE_WRITEABLE: if (*pcChar != '\0' && *pcChar != '\r') { DBG_DEC(*pcChar); iNumber = DEFAULT_SCALE_FACTOR; } else if (iNumber < MIN_SCALE_FACTOR) { iNumber = MIN_SCALE_FACTOR; } else if (iNumber > MAX_SCALE_FACTOR) { iNumber = MAX_SCALE_FACTOR; } vSetScaleFactor(pCaret->window, iNumber); break; default: DBG_DEC(pCaret->icon); break; } return TRUE;} /* end of bChoicesKeyPressed */#endif /* __riscos */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -