[haiku-commits] r34175 - haiku/trunk/src/apps/terminal

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Nov 2009 17:13:56 +0100 (CET)

Author: jackburton
Date: 2009-11-21 17:13:56 +0100 (Sat, 21 Nov 2009)
New Revision: 34175
Changeset: http://dev.haiku-os.org/changeset/34175/haiku

Added:
   haiku/trunk/src/apps/terminal/Encoding.cpp
   haiku/trunk/src/apps/terminal/Encoding.h
Removed:
   haiku/trunk/src/apps/terminal/Coding.cpp
   haiku/trunk/src/apps/terminal/Coding.h
Modified:
   haiku/trunk/src/apps/terminal/CodeConv.h
   haiku/trunk/src/apps/terminal/Jamfile
   haiku/trunk/src/apps/terminal/PrefHandler.cpp
   haiku/trunk/src/apps/terminal/TermWindow.cpp
   haiku/trunk/src/apps/terminal/TerminalBuffer.cpp
Log:
Renamed "Coding" to "Encoding" and adjusted other files accordingly


Modified: haiku/trunk/src/apps/terminal/CodeConv.h
===================================================================
--- haiku/trunk/src/apps/terminal/CodeConv.h    2009-11-21 16:08:24 UTC (rev 
34174)
+++ haiku/trunk/src/apps/terminal/CodeConv.h    2009-11-21 16:13:56 UTC (rev 
34175)
@@ -9,8 +9,9 @@
 
 
 #include <SupportDefs.h>
-#include "Coding.h"
 
+#include "Encoding.h"
+
 class CodeConv {
        public:
                static int32 UTF8GetFontWidth(const char *string);

Copied: haiku/trunk/src/apps/terminal/Encoding.cpp (from rev 34170, 
haiku/trunk/src/apps/terminal/Coding.cpp)
===================================================================
--- haiku/trunk/src/apps/terminal/Encoding.cpp                          (rev 0)
+++ haiku/trunk/src/apps/terminal/Encoding.cpp  2009-11-21 16:13:56 UTC (rev 
34175)
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2003-2009 Haiku, Inc.
+ * Distributed under the terms of the MIT license.
+ */
+
+#include "Encoding.h"
+
+#include <string.h>
+
+
+struct etable {
+       const char *name;       // long name for menu item.
+       const char *shortname;  // short name (use for command-line etc.)
+       const char shortcut;    // short cut key code
+       const int32 id;         // encoding id 
+};
+
+/*
+ * encoding_table ... use encoding menu, message, and preference keys.
+ */
+const static etable kEncodingTable[] = {
+       {"UTF-8", "UTF8", 'U', M_UTF8},
+       {"ISO-8859-1", "8859-1", '1', B_ISO1_CONVERSION},
+       {"ISO-8859-2", "8859-2", '2', B_ISO2_CONVERSION},
+       {"ISO-8859-3", "8859-3", '3', B_ISO3_CONVERSION},
+       {"ISO-8859-4", "8859-4", '4', B_ISO4_CONVERSION},
+       {"ISO-8859-5", "8859-5", '5', B_ISO5_CONVERSION},
+       {"ISO-8859-6", "8859-6", '6', B_ISO6_CONVERSION},
+       {"ISO-8859-7", "8859-7", '7', B_ISO7_CONVERSION},
+       {"ISO-8859-8", "8859-8", '8', B_ISO8_CONVERSION},
+       {"ISO-8859-9", "8859-9", '9', B_ISO9_CONVERSION},
+       {"ISO-8859-10", "8859-10", '0', B_ISO10_CONVERSION},
+       {"MacRoman", "MacRoman", 'M',  B_MAC_ROMAN_CONVERSION},
+       {"JIS", "JIS", 'J', B_JIS_CONVERSION},
+       {"Shift-JIS", "SJIS", 'S', B_SJIS_CONVERSION},
+       {"EUC-jp", "EUCJ", 'E', B_EUC_CONVERSION},
+       {"EUC-kr", "EUCK", 'K', B_EUC_KR_CONVERSION},
+       {"GB18030", "GB18030", 0, B_GBK_CONVERSION},
+       {"Big5", "Big5", 'B', B_BIG5_CONVERSION},
+
+       /* Not Implemented.
+       {"EUC-tw", "EUCT", "T", M_EUC_TW},
+       {"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN},
+       {"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR},
+       */  
+
+       {NULL, NULL, 0, 0},
+};
+
+
+
+status_t
+get_nth_encoding(int i, int *id)
+{
+       if (id == NULL)
+               return B_BAD_VALUE;
+       
+       if (i < 0 || i >= (int)(sizeof(kEncodingTable) / sizeof(etable)) - 1)
+               return B_BAD_INDEX;
+
+       *id = kEncodingTable[i].id;
+       
+       return B_OK;
+}
+
+
+int
+EncodingID(const char *longname)
+{
+       int id = M_UTF8;
+       const etable *s = kEncodingTable;
+       
+       for (int i = 0; s->name; s++, i++) {
+               if (!strcmp(s->name, longname)) {
+                       id = s->id;
+                       break;
+               }
+       }
+       return id;
+}
+
+
+const char *
+EncodingAsShortString(int id)
+{
+       const etable *p = kEncodingTable;
+       while (p->name) {
+               if (id == p->id)
+                       return p->shortname;
+               p++;
+       }
+
+       return kEncodingTable[0].shortname;
+}
+
+
+const char *
+EncodingAsString(int id)
+{
+       const etable *p = kEncodingTable;
+       while (p->name) {
+               if (id == p->id)
+                       return p->name;
+               p++;
+       }
+
+       return kEncodingTable[0].name;
+}
+
+
+const char
+id2shortcut(int id)
+{
+       const etable *p = kEncodingTable;
+       while (p->name) {
+               if (id == p->id)
+                       return p->shortcut;
+               p++;
+       }
+       return kEncodingTable[0].shortcut;
+}
+

Copied: haiku/trunk/src/apps/terminal/Encoding.h (from rev 34170, 
haiku/trunk/src/apps/terminal/Coding.h)
===================================================================
--- haiku/trunk/src/apps/terminal/Encoding.h                            (rev 0)
+++ haiku/trunk/src/apps/terminal/Encoding.h    2009-11-21 16:13:56 UTC (rev 
34175)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003-4 Kian Duffy <myob@xxxxxxxxxxxxxxxxxxxxx>
+ * Copyright (c) 2004 Daniel Furrer <assimil8or@xxxxxxxxxxxxxxxxxxxxx>
+ * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files or portions
+ * thereof (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ *  * Redistributions in binary form must reproduce the above copyright notice
+ *    in the  binary, as well as this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided with
+ *    the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#ifndef _ENCODING__H_
+#define _ENCODING__H_
+
+#include <SupportDefs.h>
+#include <UTF8.h>
+
+#define M_UTF8 (-1)
+
+status_t       get_nth_encoding(int i, int *id);
+
+int                    EncodingID(const char *longname);
+const char *   EncodingAsShortString(int id);
+const char *   EncodingAsString(int id);
+const char             id2shortcut(int id);
+
+
+#endif /* _CODING_H_ */

Modified: haiku/trunk/src/apps/terminal/Jamfile
===================================================================
--- haiku/trunk/src/apps/terminal/Jamfile       2009-11-21 16:08:24 UTC (rev 
34174)
+++ haiku/trunk/src/apps/terminal/Jamfile       2009-11-21 16:13:56 UTC (rev 
34175)
@@ -9,7 +9,7 @@
        Arguments.cpp
        BasicTerminalBuffer.cpp
        CodeConv.cpp
-       Coding.cpp
+       Encoding.cpp
        FindWindow.cpp
        Globals.cpp
        HistoryBuffer.cpp

Modified: haiku/trunk/src/apps/terminal/PrefHandler.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/PrefHandler.cpp       2009-11-21 16:08:24 UTC 
(rev 34174)
+++ haiku/trunk/src/apps/terminal/PrefHandler.cpp       2009-11-21 16:13:56 UTC 
(rev 34175)
@@ -8,7 +8,7 @@
  */
 
 
-#include "Coding.h"
+#include "Encoding.h"
 #include "PrefHandler.h"
 #include "TermConst.h"
 

Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermWindow.cpp        2009-11-21 16:08:24 UTC 
(rev 34174)
+++ haiku/trunk/src/apps/terminal/TermWindow.cpp        2009-11-21 16:13:56 UTC 
(rev 34175)
@@ -30,7 +30,7 @@
 
 #include "Arguments.h"
 #include "AppearPrefView.h"
-#include "Coding.h"
+#include "Encoding.h"
 #include "FindWindow.h"
 #include "PrefWindow.h"
 #include "PrefHandler.h"

Modified: haiku/trunk/src/apps/terminal/TerminalBuffer.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TerminalBuffer.cpp    2009-11-21 16:08:24 UTC 
(rev 34174)
+++ haiku/trunk/src/apps/terminal/TerminalBuffer.cpp    2009-11-21 16:13:56 UTC 
(rev 34175)
@@ -9,7 +9,7 @@
 
 #include <Message.h>
 
-#include "Coding.h"
+#include "Encoding.h"
 #include "TermConst.h"
 
 


Other related posts:

  • » [haiku-commits] r34175 - haiku/trunk/src/apps/terminal - stefano . ceccherini