int DrawInit(void) { int iError; iError = DisplayInit(); if (iError) { printf("DisplayInit error!\n"); return -1; } iError = FontsInit(); if (iError) { printf("FontsInit error!\n"); return -1; } iError = EncodingInit(); if (iError) { printf("EncodingInit error!\n"); return -1; } return 0; }
GTextInfo *GetEncodingTypes(void) { GTextInfo *ti; int i, cnt; Encoding *item; EncodingInit(); cnt = 0; for ( item=enclist; item!=NULL ; item=item->next ) if ( !item->hidden ) ++cnt; i = cnt + sizeof(encodingtypes)/sizeof(encodingtypes[0]); ti = gcalloc(i+1,sizeof(GTextInfo)); memcpy(ti,encodingtypes,sizeof(encodingtypes)-sizeof(encodingtypes[0])); for ( i=0; i<sizeof(encodingtypes)/sizeof(encodingtypes[0])-1; ++i ) { ti[i].text = (unichar_t *) copy((char *) ti[i].text); } if ( cnt!=0 ) { ti[i++].line = true; for ( item=enclist; item!=NULL ; item=item->next ) if ( !item->hidden ) { ti[i].text = uc_copy(item->enc_name); ti[i++].userdata = (void *) item->enc_name; } } return( ti ); }
GMenuItem *GetEncodingMenu(void (*func)(GWindow,GMenuItem *,GEvent *), Encoding *current) { GMenuItem *mi; int i, cnt; Encoding *item; EncodingInit(); cnt = 0; for ( item=enclist; item!=NULL ; item=item->next ) if ( !item->hidden ) ++cnt; i = cnt+1; i += sizeof(encodingtypes)/sizeof(encodingtypes[0]); mi = gcalloc(i+1,sizeof(GMenuItem)); for ( i=0; i<sizeof(encodingtypes)/sizeof(encodingtypes[0])-1; ++i ) { mi[i].ti = encodingtypes[i]; if ( !mi[i].ti.line ) { mi[i].ti.text = utf82u_copy((char *) (mi[i].ti.text)); mi[i].ti.checkable = true; if ( strmatch(mi[i].ti.userdata,current->enc_name)==0 || (current->iconv_name!=NULL && strmatch(mi[i].ti.userdata,current->iconv_name)==0)) mi[i].ti.checked = true; } mi[i].ti.text_is_1byte = false; mi[i].ti.fg = mi[i].ti.bg = COLOR_DEFAULT; mi[i].invoke = func; } if ( cnt!=0 ) { mi[i].ti.fg = mi[i].ti.bg = COLOR_DEFAULT; mi[i++].ti.line = true; for ( item=enclist; item!=NULL ; item=item->next ) if ( !item->hidden ) { mi[i].ti.text = utf82u_copy(item->enc_name); mi[i].ti.userdata = (void *) item->enc_name; mi[i].ti.fg = mi[i].ti.bg = COLOR_DEFAULT; mi[i].ti.checkable = true; if ( item==current ) mi[i].ti.checked = true; mi[i++].invoke = func; } } return( mi ); }
int main(int argc, char *argv[]) { int iError; struct PageIdetify tPageIdetify; struct PageOpr *ptMainPageOpr; iError = PrintDeviceInit(); if(iError){ DebugPrint("Print device init error\n"); goto error_exit; } DebugPrint("\nSupported print device\n"); ShowPrintOpr(); if(argc != 2){ DebugPrint(DEBUG_ERR"exe <fontfile>\n"); return -1; } iError = EncodingInit(); if(iError){ DebugPrint("Encoding init error\n"); goto error_exit; } DebugPrint("\nSupported encoding\n"); ShowEncodingOpr(); iError = FontInit(); if(iError){ DebugPrint("Font init error\n"); goto error_exit; } DebugPrint("\nSupported font\n"); ShowFontOpr(); iError = SetFontsDetail("freetype", argv[1], 20); if(iError){ DebugPrint("This font can't be support. check the file format or file size\n"); goto error_exit; } iError = DisplayInit(); if(iError){ DebugPrint("Display init error\n"); goto error_exit; } DebugPrint("\nSupported display device\n"); ShowDisOpr(); SelectAndInitDefaultDisOpr("fb"); if(iError){ DebugPrint("Init default display opration error\n"); goto error_exit; } iError = InputDeviceInit(); AllInputFdInit(); if(iError){ DebugPrint("Input device init error\n"); goto error_exit; } DebugPrint("\nSupported input device\n"); ShowInputOpr(); iError = PicFmtInit(); if(iError){ DebugPrint("Picture format init error\n"); goto error_exit; } DebugPrint("\nSupported picture format\n"); ShowPicFmtParser(); iError = AllocVideoMem(5); if(iError){ DebugPrint("Alloc video memory error\n"); goto error_exit; } iError = MusicParserInit(); if(iError){ DebugPrint("MusicParser init error\n"); goto error_exit; } DebugPrint("\nSupported music\n"); ShowMusicParser(); iError = PagesInit(); if(iError){ DebugPrint("Page init error\n"); goto error_exit; } DebugPrint("\nCreated pages\n"); ShowPageOpr(); ptMainPageOpr = GetPageOpr("main"); if(NULL == ptMainPageOpr){ DebugPrint("GetPageOpr error\n"); goto error_exit; } ptMainPageOpr->RunPage(&tPageIdetify); FreeAllVideoMem(); FreeDirAndFileIcons(); PrintDeviceExit(); exit: return 0; error_exit: return -1; }
/* ./show_file [-s Size] [-f freetype_font_file] [-h HZK] <text_file> */ int main(int argc, char **argv) { int iError; unsigned int dwFontSize = 16; char acHzkFile[128]; char acFreetypeFile[128]; char acTextFile[128]; char cOpr; acHzkFile[0] = '\0'; acFreetypeFile[0] = '\0'; acTextFile[0] = '\0'; while ((iError = getopt(argc, argv, "s:f:h:")) != -1) { /*СЎПо*/ switch(iError) { case 's': { dwFontSize = strtoul(optarg, NULL, 0); break; } case 'f': { strncpy(acFreetypeFile, optarg, 128); acFreetypeFile[127] = '\0'; break; } case 'h': { strncpy(acHzkFile, optarg, 128); acHzkFile[127] = '\0'; break; } default: { printf("Usage: %s [-s Size] [-f font_file] [-h HZK] <text_file>\n", argv[0]); return -1; break; } } } if (optind >= argc) { printf("Usage: %s [-s Size] [-f font_file] [-h HZK] <text_file>\n", argv[0]); return -1; } strncpy(acTextFile, argv[optind], 128); acTextFile[127] = '\0'; iError = DisplayInit(); if (iError) { DBG_PRINTF("DisplayInit error!\n"); return -1; } iError = FontsInit(); if (iError) { DBG_PRINTF("FontsInit error!\n"); return -1; } iError = EncodingInit(); if (iError) { DBG_PRINTF("EncodingInit error!\n"); return -1; } iError = OpenTextFile(acTextFile); if (iError) { DBG_PRINTF("OpenTextFile error!\n"); return -1; } iError = SetTextDetail(acHzkFile, acFreetypeFile, dwFontSize); if (iError) { DBG_PRINTF("SetTextDetail error!\n"); return -1; } iError = SelectAndInitDisplay("fb"); if (iError) { DBG_PRINTF("SelectAndInitDisplay error!\n"); return -1; } iError = ShowNextPage(); if (iError) { DBG_PRINTF("Error to show first page\n"); return -1; } while (1) { printf("Enter 'n' to show next page, 'u' to show previous page, 'q' to exit: "); do { cOpr = getchar(); } while ((cOpr != 'n') && (cOpr != 'u') && (cOpr != 'q')); if (cOpr == 'n') { ShowNextPage(); } else if (cOpr == 'u') { ShowPrePage(); } else { return 0; } } return 0; }
/* ./show_file [-s Size] [-f freetype_font_file] [-h HZK] <text_file> */ int main(int argc, char **argv) { int iError; unsigned int dwFontSize = 16; char acHzkFile[128]; char acFreetypeFile[128]; char acTextFile[128]; char acDisplay[128]; char cOpr; int bList = 0; T_InputEvent tInputEvent; acHzkFile[0] = '\0'; acFreetypeFile[0] = '\0'; acTextFile[0] = '\0'; strcpy(acDisplay, "fb"); while ((iError = getopt(argc, argv, "ls:f:h:d:")) != -1) { switch(iError) { case 'l': { bList = 1; break; } case 's': { dwFontSize = strtoul(optarg, NULL, 0); break; } case 'f': { strncpy(acFreetypeFile, optarg, 128); acFreetypeFile[127] = '\0'; break; } case 'h': { strncpy(acHzkFile, optarg, 128); acHzkFile[127] = '\0'; break; } case 'd': { strncpy(acDisplay, optarg, 128); acDisplay[127] = '\0'; break; } default: { printf("Usage: %s [-s Size] [-d display] [-f font_file] [-h HZK] <text_file>\n", argv[0]); printf("Usage: %s -l\n", argv[0]); return -1; break; } } } if (!bList && (optind >= argc)) { printf("Usage: %s [-s Size] [-d display] [-f font_file] [-h HZK] <text_file>\n", argv[0]); printf("Usage: %s -l\n", argv[0]); return -1; } iError = DisplayInit(); if (iError) { printf("DisplayInit error!\n"); return -1; } iError = FontsInit(); if (iError) { printf("FontsInit error!\n"); return -1; } iError = EncodingInit(); if (iError) { printf("EncodingInit error!\n"); return -1; } iError = InputInit(); if (iError) { printf("InputInit error!\n"); return -1; } if (bList) { printf("supported display:\n"); ShowDispOpr(); printf("supported font:\n"); ShowFontOpr(); printf("supported encoding:\n"); ShowEncodingOpr(); printf("supported input:\n"); ShowInputOpr(); return 0; } strncpy(acTextFile, argv[optind], 128); acTextFile[127] = '\0'; iError = OpenTextFile(acTextFile); if (iError) { printf("OpenTextFile error!\n"); return -1; } iError = SetTextDetail(acHzkFile, acFreetypeFile, dwFontSize); if (iError) { printf("SetTextDetail error!\n"); return -1; } DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); iError = SelectAndInitDisplay(acDisplay); if (iError) { printf("SelectAndInitDisplay error!\n"); return -1; } iError = AllInputDevicesInit(); if (iError) { DBG_PRINTF("Error AllInputDevicesInit\n"); return -1; } DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); iError = ShowNextPage(); DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); if (iError) { printf("Error to show first page\n"); return -1; } printf("Enter 'n' to show next page, 'u' to show previous page, 'q' to exit: "); while (1) { if (0 == GetInputEvent(&tInputEvent)) { if (tInputEvent.iVal == INPUT_VALUE_DOWN) { ShowNextPage(); } else if (tInputEvent.iVal == INPUT_VALUE_UP) { ShowPrePage(); } else if (tInputEvent.iVal == INPUT_VALUE_EXIT) { return 0; } } } return 0; }