home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / tex-accent.C < prev    next >
C/C++ Source or Header  |  1998-04-23  |  4KB  |  94 lines

  1. #include <config.h>
  2.  
  3. #include <stdlib.h>
  4. #include "tex-accent.h"
  5. #include "commandtags.h"
  6. #include "LString.h"
  7.  
  8. /* the names used by TeX and XWindows for deadkeys/accents are not the same
  9.    so here follows a table to clearify the differences. Please correct this
  10.    if I got it wrong
  11.  
  12.    |------------------|------------------|------------------|--------------|
  13.    |      TeX         |     XWindows     |   \bind/LFUN     | used by intl |
  14.    |------------------|------------------|------------------|--------------|
  15.    |    grave         |    grave         |LFUN_GRAVE        | grave
  16.    |    acute         |    acute         |LFUN_ACUTE        | acute
  17.    |    circumflex    |    circumflex    |LFUN_CIRCUMFLEX   | circumflex
  18.    | umlaut/dieresis  |    diaeresis     |LFUN_UMLAUT       | umlaut
  19.    |    tilde         |    tilde         |LFUN_TILDE        | tilde
  20.    |    macron        |    maron         |LFUN_MACRON       | macron
  21.    |    dot           |    abovedot      |LFUN_DOT          | dot
  22.    |    cedilla       |    cedilla       |LFUN_CEDILLA      | cedilla
  23.    |    underdot      |                  |LFUN_UNDERDOT     | underdot
  24.    |    underbar      |                  |LFUN_UNDERBAR     | underbar
  25.    |    hßcek         |    caron         |LFUN_CARON        | caron
  26.    |    breve         |    breve         |LFUN_BREVE        | breve
  27.    |    tie           |                  |LFUN_TIE          | tie
  28.    | Hungarian umlaut |    doubleacute   |LFUN_HUNG_UMLAUT  | hungarian umlaut
  29.    |    circle        |    abovering     |LFUN_CIRCLE       | circle
  30.    |                  |    ogonek        |                  |
  31.    |                  |    iota          |                  |
  32.    |                  |    voiced_sound  |                  |
  33.    |                  | semivoiced_sound |                  |
  34.    |                  |                  |LFUN_SPECIAL_CARON| special caron
  35.    */
  36. // I am not sure how some of the XWindows names coresponds to the TeX ones.
  37.  
  38. //static
  39. tex_accent_struct lyx_accent_table[18] ={
  40.     { (tex_accent)0, "", "", "",(kb_action)0},
  41.     {TEX_ACUTE,      "\\'",  " AEIOUYaeiouySZszRLCNrlcn","acute",   LFUN_ACUTE},
  42.     {TEX_GRAVE,      "\\`",  " aeiouAEIOU",           "grave",    LFUN_GRAVE},
  43.     {TEX_MACRON,     "\\=",  " EeAIOUaiou",           "macron",    LFUN_MACRON},
  44.     {TEX_TILDE,      "\\~",  " ANOanoIiUu",           "tilde",    LFUN_TILDE},
  45.     {TEX_UNDERBAR,   "\\b", " ",                     "underbar", LFUN_UNDERBAR},
  46.     {TEX_CEDILLA,    "\\c", " CcSsTtRLGrlgNKnk",     "cedilla",    LFUN_CEDILLA},
  47.     {TEX_UNDERDOT,   "\\d", " ",                     "underdot", LFUN_UNDERDOT},
  48.     {TEX_CIRCUMFLEX, "\\^",  " AEIOUaeiouHJhjCGScgs", "circumflex",  LFUN_CIRCUMFLEX},
  49.     {TEX_CIRCLE,     "\\r", " AaUu",                 "circle",  LFUN_CIRCLE},
  50.     {TEX_TIE,        "\\t", " ",                     "tie",    LFUN_TIE},
  51.     {TEX_BREVE,      "\\u", " AaGgUu",               "breve",    LFUN_BREVE},
  52.     {TEX_CARON,      "\\v", " LSTZlstzCEDNRcednr",   "caron",    LFUN_CARON},
  53. //  {TEX_SPECIAL_CARON, "\\q", "","ooo",  LFUN_SPECIAL_CARON},
  54.     {TEX_HUNGUML,    "\\H", " OUou",                 "hugarian_umlaut",    LFUN_HUNG_UMLAUT},
  55.     {TEX_UMLAUT,     "\\\"", " AEIOUaeiouy",          "umlaut",    LFUN_UMLAUT},
  56.     {TEX_DOT,        "\\.",  " ZzICGicgEe",           "dot",    LFUN_DOT},
  57.     {TEX_OGONEK,     "\\k",  " AaEe",                 "ogonek",    LFUN_OGONEK},
  58.     { (tex_accent)0, "", "", "",(kb_action)0}};
  59.         
  60.  
  61. tex_accent_struct get_accent(kb_action action)
  62. {
  63.     int i=0;
  64.     while (i<=TEX_MAX_ACCENT){
  65.         if (lyx_accent_table[i].action == action)
  66.             return lyx_accent_table[i];
  67.         i++;
  68.     }
  69.     struct tex_accent_struct temp = { (tex_accent)0, NULL, NULL,
  70.                       NULL,(kb_action)0};
  71.     return temp;
  72. }
  73.  
  74. LString DoAccent(const LString& s,tex_accent accent)
  75. {
  76.     LString res;
  77.     
  78.     res+=lyx_accent_table[accent].cmd;
  79.     res+='{';
  80.     if (s=="i" || s=="j") {
  81.         res+='\\';
  82.     }
  83.     res+=s;
  84.     res+='}';
  85.     return res;
  86. }
  87.  
  88. LString DoAccent(char c,tex_accent accent)
  89. {
  90.     LString tmp; tmp += c;
  91.     return DoAccent(tmp,accent);
  92. }
  93.  
  94.