]> git.lyx.org Git - lyx.git/blobdiff - src/tex-accent.C
Small formatting and comment cleanup.
[lyx.git] / src / tex-accent.C
index 75535215a6a0c569b597f18acdb945aba2b36bbf..63e6185cb59c958a595298d7897f696c8981dcae 100644 (file)
@@ -1,10 +1,25 @@
+/**
+ * \file tex-accent.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #include <config.h>
 
-#include <cstdlib>
 #include "tex-accent.h"
-#include "commandtags.h"
-#include "LString.h"
-#include "support/lstrings.h"
+#include "support/convert.h"
+
+#include <string>
+
+
+namespace lyx {
+
+using std::string;
 
 /* the names used by TeX and XWindows for deadkeys/accents are not the same
    so here follows a table to clearify the differences. Please correct this
    |------------------|------------------|------------------|--------------|
    |      TeX         |     XWindows     |   \bind/LFUN     | used by intl |
    |------------------|------------------|------------------|--------------|
-   |    grave         |    grave         |LFUN_GRAVE        | grave
-   |    acute         |    acute         |LFUN_ACUTE        | acute
-   |    circumflex    |    circumflex    |LFUN_CIRCUMFLEX   | circumflex
-   | umlaut/dieresis  |    diaeresis     |LFUN_UMLAUT       | umlaut
-   |    tilde         |    tilde         |LFUN_TILDE        | tilde
-   |    macron        |    maron         |LFUN_MACRON       | macron
-   |    dot           |    abovedot      |LFUN_DOT          | dot
-   |    cedilla       |    cedilla       |LFUN_CEDILLA      | cedilla
-   |    underdot      |                  |LFUN_UNDERDOT     | underdot
-   |    underbar      |                  |LFUN_UNDERBAR     | underbar
-   |    hácek         |    caron         |LFUN_CARON        | caron
-   |    breve         |    breve         |LFUN_BREVE        | breve
-   |    tie           |                  |LFUN_TIE          | tie
-   | Hungarian umlaut |    doubleacute   |LFUN_HUNG_UMLAUT  | hungarian umlaut
-   |    circle        |    abovering     |LFUN_CIRCLE       | circle
+   |    grave         |    grave         |LFUN_ACCENT_GRAVE        | grave
+   |    acute         |    acute         |LFUN_ACCENT_ACUTE        | acute
+   |    circumflex    |    circumflex    |LFUN_ACCENT_CIRCUMFLEX   | circumflex
+   | umlaut/dieresis  |    diaeresis     |LFUN_ACCENT_UMLAUT       | umlaut
+   |    tilde         |    tilde         |LFUN_ACCENT_TILDE        | tilde
+   |    macron        |    maron         |LFUN_ACCENT_MACRON       | macron
+   |    dot           |    abovedot      |LFUN_ACCENT_DOT          | dot
+   |    cedilla       |    cedilla       |LFUN_ACCENT_CEDILLA      | cedilla
+   |    underdot      |                  |LFUN_ACCENT_UNDERDOT     | underdot
+   |    underbar      |                  |LFUN_ACCENT_UNDERBAR     | underbar
+   |    hácek         |    caron         |LFUN_ACCENT_CARON        | caron
+   |    breve         |    breve         |LFUN_ACCENT_BREVE        | breve
+   |    tie           |                  |LFUN_ACCENT_TIE          | tie
+   | Hungarian umlaut |    doubleacute   |LFUN_ACCENT_HUNGARIAN_UMLAUT  | hungarian umlaut
+   |    circle        |    abovering     |LFUN_ACCENT_CIRCLE       | circle
    |                  |    ogonek        |                  |
    |                  |    iota          |                  |
    |                  |    voiced_sound  |                  |
    |                  | semivoiced_sound |                  |
-   |                  |                  |LFUN_SPECIAL_CARON| special caron
+   |                  |                  |LFUN_ACCENT_SPECIAL_CARON| special caron
    */
 // I am not sure how some of the XWindows names coresponds to the TeX ones.
 
-//static
-tex_accent_struct lyx_accent_table[18] ={
-       { (tex_accent)0, "", "", "",(kb_action)0},
-       {TEX_ACUTE,      "\\'",  " AEIOUYaeiouySZszRLCNrlcn","acute",   LFUN_ACUTE},
-       {TEX_GRAVE,      "\\`",  " aeiouAEIOU",           "grave",    LFUN_GRAVE},
-       {TEX_MACRON,     "\\=",  " EeAIOUaiou",           "macron",    LFUN_MACRON},
-       {TEX_TILDE,      "\\~",  " ANOanoIiUu",           "tilde",    LFUN_TILDE},
-       {TEX_UNDERBAR,   "\\b", " ",                     "underbar", LFUN_UNDERBAR},
-       {TEX_CEDILLA,    "\\c", " CcSsTtRLGrlgNKnk",     "cedilla",    LFUN_CEDILLA},
-       {TEX_UNDERDOT,   "\\d", " ",                     "underdot", LFUN_UNDERDOT},
-       {TEX_CIRCUMFLEX, "\\^",  " AEIOUaeiouHJhjCGScgs", "circumflex",  LFUN_CIRCUMFLEX},
-       {TEX_CIRCLE,     "\\r", " AaUu",                 "circle",  LFUN_CIRCLE},
-       {TEX_TIE,        "\\t", " ",                     "tie",    LFUN_TIE},
-       {TEX_BREVE,      "\\u", " AaGgUu",               "breve",    LFUN_BREVE},
-       {TEX_CARON,      "\\v", " LSTZlstzCEDNRcednr",   "caron",    LFUN_CARON},
-//  {TEX_SPECIAL_CARON, "\\q", "","ooo",  LFUN_SPECIAL_CARON},
-       {TEX_HUNGUML,    "\\H", " OUou",                 "hugarian_umlaut",    LFUN_HUNG_UMLAUT},
-       {TEX_UMLAUT,     "\\\"", " AEIOUaeiouy",          "umlaut",    LFUN_UMLAUT},
-       {TEX_DOT,        "\\.",  " ZzICGicgEe",           "dot",    LFUN_DOT},
-       {TEX_OGONEK,     "\\k",  " AaEe",                 "ogonek",    LFUN_OGONEK},
-       { (tex_accent)0, "", "", "",(kb_action)0}};
-        
+tex_accent_struct lyx_accent_table[18] = {
+       { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)},
+       {TEX_ACUTE,      "\\'",  /*" AEIOUYaeiouySZszRLCNrlcn",*/ "acute",   LFUN_ACCENT_ACUTE},
+       {TEX_GRAVE,      "\\`",  /*" aeiouAEIOU",*/           "grave",    LFUN_ACCENT_GRAVE},
+       {TEX_MACRON,     "\\=",  /*" EeAIOUaiou",*/           "macron",    LFUN_ACCENT_MACRON},
+       {TEX_TILDE,      "\\~",  /*" ANOanoIiUu",*/           "tilde",    LFUN_ACCENT_TILDE},
+       {TEX_UNDERBAR,   "\\b", /*" ",*/                     "underbar", LFUN_ACCENT_UNDERBAR},
+       {TEX_CEDILLA,    "\\c", /*" CcSsTtRLGrlgNKnk",*/     "cedilla",    LFUN_ACCENT_CEDILLA},
+       {TEX_UNDERDOT,   "\\d", /*" ",*/                     "underdot", LFUN_ACCENT_UNDERDOT},
+       {TEX_CIRCUMFLEX, "\\^",  /*" AEIOUaeiouHJhjCGScgs",*/ "circumflex",  LFUN_ACCENT_CIRCUMFLEX},
+       {TEX_CIRCLE,     "\\r", /*" AaUu",*/                 "circle",  LFUN_ACCENT_CIRCLE},
+       {TEX_TIE,        "\\t", /*" ",*/                     "tie",    LFUN_ACCENT_TIE},
+       {TEX_BREVE,      "\\u", /*" AaGgUu",*/               "breve",    LFUN_ACCENT_BREVE},
+       {TEX_CARON,      "\\v", /*" LSTZlstzCEDNRcednr",*/   "caron",    LFUN_ACCENT_CARON},
+//  {TEX_SPECIAL_CARON, "\\q", "", "ooo",  LFUN_ACCENT_SPECIAL_CARON},
+       {TEX_HUNGUML,    "\\H", /*" OUou",*/                 "hugarian_umlaut",    LFUN_ACCENT_HUNGARIAN_UMLAUT},
+       {TEX_UMLAUT,     "\\\"", /*" AEIOUaeiouy",*/          "umlaut",    LFUN_ACCENT_UMLAUT},
+       {TEX_DOT,        "\\.",  /*" ZzICGicgEe",*/           "dot",    LFUN_ACCENT_DOT},
+       {TEX_OGONEK,     "\\k",  /*" AaEe",*/                 "ogonek",    LFUN_ACCENT_OGONEK},
+       { static_cast<tex_accent>(0), "", /*"",*/ "", static_cast<kb_action>(0)}};
+
 
 tex_accent_struct get_accent(kb_action action)
 {
-       int i=0;
-       while (i<=TEX_MAX_ACCENT){
+       int i = 0;
+       while (i <= TEX_MAX_ACCENT) {
                if (lyx_accent_table[i].action == action)
                        return lyx_accent_table[i];
-               i++;
+               ++i;
        }
-       struct tex_accent_struct temp = { (tex_accent)0, 0, 0,
-                                         0,(kb_action)0};
+       struct tex_accent_struct temp = { static_cast<tex_accent>(0), 0,
+                                         0, static_cast<kb_action>(0)};
        return temp;
 }
 
-string DoAccent(const string& s,tex_accent accent)
+
+string const DoAccent(string const & s, tex_accent accent)
 {
        string res;
-       
-       res+=lyx_accent_table[accent].cmd;
-       res+='{';
-       if (s=="i" || s=="j") {
-               res+='\\';
+
+       res += lyx_accent_table[accent].cmd;
+       res += '{';
+       if (s == "i" || s == "j") {
+               res += '\\';
        }
-       res+=s;
-       res+='}';
+       res += s;
+       res += '}';
        return res;
 }
 
-string DoAccent(char c,tex_accent accent)
+
+string const DoAccent(char c, tex_accent accent)
 {
-       return DoAccent(tostr(c),accent);
+       return DoAccent(convert<string>(c), accent);
 }
 
+
+} // namespace lyx