Listing keymaps (local/english names,...)

9 posts / 0 new
Last post
jabirulo
jabirulo's picture
Offline
Last seen: 6 days 1 hour ago
Joined: 2013-05-30 00:53
Listing keymaps (local/english names,...)
Hi just build a little tool (to add such functionality to KeymapSwitcher.docky) that list KEYMAPS: files and outputs: filename / english name / local name / charset With some local names that as you can see below uses a different charset and thus show its local name odd (ex Bulgarian -> ±êÛÓÐàáÚØ) How to make it readable (alas shown in Locale/Input prefs)? TIA .. KEYMAP:bg_ISO-8859-5 Bulgarian ISO-8859-5 / ±êÛÓÐàáÚØ ISO-8859-5 / 8 KEYMAP:bih_qwerty_ISO-8859-2 Bosnian (USA) QWERTY ISO-8859-2 / Bosnian QWERTY / 5 KEYMAP:br Brazilian (EUA) / Brasileiro (EUA) / 4 KEYMAP:br_2 Brazilian (EUA) modified / Brasileiro (EUA) mod. / 4 KEYMAP:br_abnt2 Brazilian (ABNT2) / Brasileiro (ABNT2) / 4 KEYMAP:br_abnt2_ISO-8859-15 Brazilian (ABNT2) ISO-8859-15 / Brasileiro (ABNT2 €) / 111 KEYMAP:by_ISO-8859-5 Belarusian ISO-8859-5 / ±ÕÛÐàãáÚö ISO-8859-5 / 8 ..
gazelle
gazelle's picture
Offline
Last seen: 4 years 8 months ago
Joined: 2011-04-13 12:52
Something like that: ;/*
Something like that:
  1. ;/* CharsetTest, execute me to compile me
  2. gcc -o CharsetTest CharsetTest.c -Wall -Werror -lauto
  3. quit
  4. */
  5.  
  6. #include <intuition/intuition.h>
  7. #include <graphics/text.h>
  8. #include <graphics/rpattr.h>
  9. #include <proto/exec.h>
  10. #include <proto/dos.h>
  11. #include <proto/intuition.h>
  12. #include <proto/graphics.h>
  13. #include <proto/diskfont.h>
  14.  
  15. #include "stdlib.h" /* for exit() */
  16. #include "string.h" /* for strlen() */
  17.  
  18. struct Window *Window = NULL;
  19. struct TextFont *tfISO5 = NULL;
  20.  
  21. void CloseAll(void)
  22. {
  23. if (tfISO5) IGraphics->CloseFont(tfISO5);
  24. if (Window) IIntuition->CloseWindow(Window);
  25. }
  26.  
  27. void Fail(char *failString)
  28. {
  29. IDOS->Printf("%s\n", failString);
  30. CloseAll();
  31. exit(FALSE);
  32. }
  33.  
  34. void OpenWindow(void)
  35. {
  36. static char WindowTitle[] = "Charset Test";
  37.  
  38. if (!(Window = IIntuition->OpenWindowTags(NULL,
  39. WA_Title, WindowTitle,
  40. WA_Width, 300,
  41. WA_Height, 100,
  42. WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET,
  43. WA_IDCMP, IDCMP_CLOSEWINDOW)))
  44. Fail("could not open window");
  45. }
  46.  
  47. void CharsetTest(void)
  48. {
  49. char testStringSYS[] = "Test System Charset: ±êÛÓÐàáÚØ";
  50. char testStringISO5[] = "Test ISO-8859-5: ±êÛÓÐàáÚØ";
  51. WORD x, y;
  52. struct RastPort *rp = Window->RPort;
  53. struct TextFont *tfSYS = NULL;
  54. struct TTextAttr ttaISO5;
  55. struct TagItem ti[2];
  56.  
  57. /* get system font and try other charset */
  58. IGraphics->GetRPAttrs(rp, RPTAG_Font, &tfSYS, TAG_DONE);
  59. ttaISO5.tta_Name = tfSYS->tf_Message.mn_Node.ln_Name;
  60. ttaISO5.tta_YSize = tfSYS->tf_YSize;
  61. ttaISO5.tta_Style = tfSYS->tf_Style | FSF_TAGGED;
  62. ttaISO5.tta_Flags = tfSYS->tf_Flags;
  63. ttaISO5.tta_Tags = ti;
  64. ti[0].ti_Tag = TA_CharSet;
  65. ti[0].ti_Data = 8; // ISO-8859-5
  66. ti[1].ti_Tag = TAG_DONE;
  67.  
  68. if (!(tfISO5 = IDiskfont->OpenDiskFont((struct TextAttr *)&ttaISO5)))
  69. Fail("could not open font in ISO-8859-5");
  70.  
  71. IGraphics->SetAPen(rp, 1);
  72.  
  73. x = Window->BorderLeft + 10;
  74. y = Window->BorderTop + 10 + rp->TxBaseline + 2;
  75.  
  76. /* render font in system charset */
  77. IGraphics->Move(rp, x, y);
  78. IGraphics->Text(rp, testStringSYS, strlen(testStringSYS));
  79.  
  80. /* render font in ISO-8859-5 */
  81. y += rp->TxHeight + 2;
  82. IGraphics->SetFont(rp, tfISO5);
  83. IGraphics->Move(rp, x, y);
  84. IGraphics->Text(rp, testStringISO5, strlen(testStringISO5));
  85.  
  86. }
  87.  
  88. int main(void)
  89. {
  90. BOOL done;
  91. struct IntuiMessage *imsg;
  92.  
  93. OpenWindow();
  94. CharsetTest();
  95.  
  96. done = FALSE;
  97. while (!done)
  98. {
  99. imsg = (struct IntuiMessage *) IExec->GetMsg(Window->UserPort);
  100. if (!imsg)
  101. {
  102. IExec->Wait(1 << Window->UserPort->mp_SigBit);
  103. continue;
  104. }
  105.  
  106. if (imsg)
  107. {
  108. switch (imsg->Class)
  109. {
  110. case IDCMP_CLOSEWINDOW:
  111. done = TRUE;
  112. break;
  113. }
  114. IExec->ReplyMsg((struct Message *) imsg);
  115. }
  116. }
  117.  
  118. CloseAll();
  119.  
  120. return 0;
  121. }
jabirulo
jabirulo's picture
Offline
Last seen: 6 days 1 hour ago
Joined: 2013-05-30 00:53
YES, THX!!! Will try to add
YES, THX!!! Will try to add such code to KMS (if you don't mind) so some local keymaps shows correct.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
gazelle
gazelle's picture
Offline
Last seen: 4 years 8 months ago
Joined: 2011-04-13 12:52
Sure, take what you need,
Sure, take what you need, that's why I posted the code.
jabirulo
jabirulo's picture
Offline
Last seen: 6 days 1 hour ago
Joined: 2013-05-30 00:53
Hi, I manage to show local
Hi, I manage to show local strings in their charset in a listbrowser (THX gazelle!!!) -First I load charset fonts:
  1. struct TextAttr *font = screen->Font;
  2. struct FontISO
  3. {
  4. struct TextFont *tf;
  5. struct TTextAttr tta;
  6. struct TagItem ti[2];
  7. } fiso[3];
  8.  
  9. fiso[1].tta.tta_Name = font->ta_Name;
  10. fiso[1].tta.tta_YSize = font->ta_YSize;
  11. fiso[1].tta.tta_Style = font->ta_Style | FSF_TAGGED;
  12. fiso[1].tta.tta_Flags = font->ta_Flags;
  13. fiso[1].tta.tta_Tags = fiso[1].ti;
  14. fiso[1].ti[0].ti_Tag = TA_CharSet;
  15. fiso[1].ti[0].ti_Data = 5; // 5=ISO_8859-2
  16. fiso[1].ti[1].ti_Tag = TAG_DONE;
  17. fiso[1].tf = IDiskfont->OpenDiskFont((struct TextAttr *)&fiso[1].tta);
  18. if(!fiso[1].tf) IDOS->Printf("Can't open font in ISO-8859-2 charset\n");
  19. ...
-Using label image to create an image object with the local string (KM_desc):
  1. Object *imagen1;
  2. imagen1 = IIntuition->NewObject(NULL, "label.image", LABEL_DisposeImage,TRUE,
  3. IA_Font,dd->fiso[1].tta, //LABEL_Underscore,0,
  4. LABEL_Text,KM_desc, TAG_END);
-Add to the listbrowser such "image":
  1. ...
  2. node = IListBrowser->AllocListBrowserNode(TOTALCOLUMNS,
  3. LBNA_Column,0, LBNCA_CopyText,TRUE,
  4. LBNCA_Text,dat->Name,
  5. LBNA_Column,1, LBNCA_Image,imagen1,
  6. TAG_DONE);
  7.  
  8. IExec->AddTail(&listbrowser_list, node);
  9. ...
And they show correct, the problem is when I resize/(un)iconify/click_on_entry it gets UNDERLINED!!! IMAGE(http://jabirulo.site90.com/temp/window_grab.jpg) Any idea what (tag,...) am I missing/doing wrong? TIA EDIT1: I started/cloned source and added code bit by bit and now entries are shown correctly (not underlined), will investigate it further what did I wrong.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
salass00
salass00's picture
Offline
Last seen: 2 months 3 days ago
Joined: 2011-02-03 11:27
There is an ampersand ('&')
There is an ampersand ('&') missing here:
  1. Object *imagen1;
  2. imagen1 = IIntuition->NewObject(NULL, "label.image", LABEL_DisposeImage,TRUE,
  3. IA_Font,dd->fiso[1].tta, //LABEL_Underscore,0,
  4. LABEL_Text,KM_desc, TAG_END);
Instead of "IA_Font,dd->fiso[1].tta," you should have "IA_Font,&dd->fiso[1].tta,".
salass00
salass00's picture
Offline
Last seen: 2 months 3 days ago
Joined: 2011-02-03 11:27
Double post.
Double post.
jabirulo
jabirulo's picture
Offline
Last seen: 6 days 1 hour ago
Joined: 2013-05-30 00:53
Oooops, you're right. THX.
Oooops, you're right. THX.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
jabirulo
jabirulo's picture
Offline
Last seen: 6 days 1 hour ago
Joined: 2013-05-30 00:53
BTW if font is already loaded
BTW if font is already loaded in memory, can I get rid off (reloading it)
  1. ..
  2. dd->fiso[1].tf = IDiskfont->OpenDiskFont((struct TextAttr *)&dd->fiso[1].tta);
  3. if(!dd->fiso[1].tf) IDOS->Printf("Can't open font in ISO-8859-2 charset\n");
  4. ..
  5. IGraphics->CloseFont(dd->fiso[0].tf);
  6. ..
lines? As 'IA_Font' tag only "needs" 'struct TTextAttr' (and 'struct TagItem'). Did some test and seems I don't need OpendDiskFont()/CloseFont(). Right? TIA
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Log in or register to post comments