Refactoring of 8-bit encodings support.
* Fixed issue introduced in hrev38139: restoring from the line drawing table was hard-coded to UTF8 Ground table. That is wrong: the table for currently configured encoding must be set back. Please look on using of _GuessGroundTable() for details; * Fixed issue introduced in hrev34894: the semantic of convert_xx_utf8 functions requires the destination length to be set equal to the target buffer size. Pre-hrev34894 usage of "homebrew" conversion functions was a bit different - destination length was set to 0. This made any converstions of input data useless and produce no visual results; * Private list of supported encodings (Encoding.cpp) was replaced by using BPrivate::BCharacterSetRoster functionality. That allows to use centralized info about encodings in unified with other applications (Mail & StyledEdit for example) way. Most of currently enumerated in UTF8.h encodings now available in Terminal. Note that UCS-2 and UTF-16 are temporary (???) excluded from the list of encodings supported by Terminal. * The B_UTF16_CONVERSION was added in system-wide UTF8.h declarations. This character set is available for enumerating by BCharacterSetRoster but not listed in public API. Looks like it was just missed; * Special note about "Text Encoding" entry in Preference File: So known "shortname" of encoding was used in the preferences file. For details look on the encodings list in previous version of Encoding.cpp. As result of migrating to BCharacterSet-provided resources this list was deleted and is not available anymore. Instead of it the IANA name of the character encoding targeted to be used for this purposes. Frankly speaking this part looks like not working at the moment. The value of text encoding is hardcoded to "UTF-8" now and is not affected by any operations in Terminal menu. Note that "shortname" for default encoding was "UTF8" but the saved value is "UTF-8" - and they are looking not dependent at all. So this change should not introduce any kind of backward incompatibility.
This commit is contained in:
parent
e11b156da9
commit
f37821851e
@ -39,6 +39,7 @@ enum {
|
||||
B_ISO15_CONVERSION,
|
||||
B_BIG5_CONVERSION, // Chinese Big5
|
||||
B_GBK_CONVERSION, // Chinese GB18030
|
||||
B_UTF16_CONVERSION // Unicode UTF-16
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "TermConst.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 int32 id; // encoding id
|
||||
};
|
||||
|
||||
/*
|
||||
* encoding_table ... use encoding menu, message, and preference keys.
|
||||
*/
|
||||
const static etable kEncodingTable[] = {
|
||||
{"UTF-8", "UTF8", M_UTF8},
|
||||
{"ISO-8859-1", "8859-1", B_ISO1_CONVERSION},
|
||||
{"ISO-8859-2", "8859-2", B_ISO2_CONVERSION},
|
||||
{"ISO-8859-3", "8859-3", B_ISO3_CONVERSION},
|
||||
{"ISO-8859-4", "8859-4", B_ISO4_CONVERSION},
|
||||
{"ISO-8859-5", "8859-5", B_ISO5_CONVERSION},
|
||||
{"ISO-8859-6", "8859-6", B_ISO6_CONVERSION},
|
||||
{"ISO-8859-7", "8859-7", B_ISO7_CONVERSION},
|
||||
{"ISO-8859-8", "8859-8", B_ISO8_CONVERSION},
|
||||
{"ISO-8859-9", "8859-9", B_ISO9_CONVERSION},
|
||||
{"ISO-8859-10", "8859-10", B_ISO10_CONVERSION},
|
||||
{"MacRoman", "MacRoman", B_MAC_ROMAN_CONVERSION},
|
||||
{"JIS", "JIS", B_JIS_CONVERSION},
|
||||
{"Shift-JIS", "SJIS", B_SJIS_CONVERSION},
|
||||
{"EUC-jp", "EUCJ", B_EUC_CONVERSION},
|
||||
{"EUC-kr", "EUCK", B_EUC_KR_CONVERSION},
|
||||
{"GB18030", "GB18030", B_GBK_CONVERSION},
|
||||
{"Big5", "Big5", B_BIG5_CONVERSION},
|
||||
|
||||
/* Not Implemented.
|
||||
{"EUC-tw", "EUCT", M_EUC_TW},
|
||||
{"ISO-2022-cn", "ISOC", M_ISO_2022_CN},
|
||||
{"ISO-2022-kr", "ISOK", M_ISO_2022_KR},
|
||||
*/
|
||||
|
||||
{NULL, NULL, 0},
|
||||
};
|
||||
|
||||
|
||||
|
||||
status_t
|
||||
get_next_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;
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net>
|
||||
* 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>
|
||||
|
||||
|
||||
status_t get_next_encoding(int i, int *id);
|
||||
|
||||
int EncodingID(const char *longname);
|
||||
const char * EncodingAsShortString(int id);
|
||||
const char * EncodingAsString(int id);
|
||||
|
||||
|
||||
#endif /* _CODING_H_ */
|
@ -5,6 +5,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] ;
|
||||
|
||||
UsePrivateHeaders libroot kernel shared system ;
|
||||
UsePrivateHeaders textencoding ;
|
||||
|
||||
Application Terminal :
|
||||
ActiveProcessInfo.cpp
|
||||
@ -12,7 +13,6 @@ Application Terminal :
|
||||
Arguments.cpp
|
||||
BasicTerminalBuffer.cpp
|
||||
Colors.cpp
|
||||
Encoding.cpp
|
||||
FindWindow.cpp
|
||||
Globals.cpp
|
||||
HistoryBuffer.cpp
|
||||
|
@ -8,9 +8,12 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "TermConst.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Directory.h>
|
||||
@ -24,10 +27,9 @@
|
||||
#include <NodeInfo.h>
|
||||
#include <Path.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "PrefHandler.h"
|
||||
#include "TermConst.h"
|
||||
|
||||
|
||||
/*
|
||||
* Startup preference settings.
|
||||
|
@ -33,6 +33,7 @@
|
||||
extern int gUTF8GroundTable[]; /* UTF8 Ground table */
|
||||
extern int gCS96GroundTable[]; /* CS96 Ground table */
|
||||
extern int gISO8859GroundTable[]; /* ISO8859 & EUC Ground table */
|
||||
extern int gWinCPGroundTable[]; /* Windows cp1252, cp1251, koi-8r */
|
||||
extern int gSJISGroundTable[]; /* Shift-JIS Ground table */
|
||||
|
||||
extern int gEscTable[]; /* ESC */
|
||||
@ -282,6 +283,7 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
|
||||
T(gUTF8GroundTable),
|
||||
T(gCS96GroundTable),
|
||||
T(gISO8859GroundTable),
|
||||
T(gWinCPGroundTable),
|
||||
T(gSJISGroundTable),
|
||||
T(gEscTable),
|
||||
T(gCsiTable),
|
||||
@ -308,6 +310,50 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
|
||||
}
|
||||
|
||||
|
||||
int *
|
||||
TermParse::_GuessGroundTable(int encoding)
|
||||
{
|
||||
switch (encoding) {
|
||||
case B_ISO1_CONVERSION:
|
||||
case B_ISO2_CONVERSION:
|
||||
case B_ISO3_CONVERSION:
|
||||
case B_ISO4_CONVERSION:
|
||||
case B_ISO5_CONVERSION:
|
||||
case B_ISO6_CONVERSION:
|
||||
case B_ISO7_CONVERSION:
|
||||
case B_ISO8_CONVERSION:
|
||||
case B_ISO9_CONVERSION:
|
||||
case B_ISO10_CONVERSION:
|
||||
case B_ISO13_CONVERSION:
|
||||
case B_ISO14_CONVERSION:
|
||||
case B_ISO15_CONVERSION:
|
||||
case B_EUC_CONVERSION:
|
||||
case B_EUC_KR_CONVERSION:
|
||||
case B_JIS_CONVERSION:
|
||||
case B_GBK_CONVERSION:
|
||||
case B_BIG5_CONVERSION:
|
||||
return gISO8859GroundTable;
|
||||
|
||||
case B_KOI8R_CONVERSION:
|
||||
case B_MS_WINDOWS_1251_CONVERSION:
|
||||
case B_MS_WINDOWS_CONVERSION:
|
||||
case B_MAC_ROMAN_CONVERSION:
|
||||
case B_MS_DOS_866_CONVERSION:
|
||||
case B_MS_DOS_CONVERSION:
|
||||
return gWinCPGroundTable;
|
||||
|
||||
case B_SJIS_CONVERSION:
|
||||
return gSJISGroundTable;
|
||||
|
||||
case M_UTF8:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return gUTF8GroundTable;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TermParse::EscParse()
|
||||
{
|
||||
@ -316,8 +362,8 @@ TermParse::EscParse()
|
||||
int cs96 = 0;
|
||||
uchar curess = 0;
|
||||
|
||||
char cbuf[4];
|
||||
char dstbuf[4];
|
||||
char cbuf[4] = { 0 };
|
||||
char dstbuf[4] = { 0 };
|
||||
char *ptr;
|
||||
|
||||
int currentEncoding = -1;
|
||||
@ -336,8 +382,8 @@ TermParse::EscParse()
|
||||
int *alternateParseTable = gUTF8GroundTable;
|
||||
bool shifted_in = false;
|
||||
|
||||
int32 srcLen;
|
||||
int32 dstLen;
|
||||
int32 srcLen = sizeof(cbuf);
|
||||
int32 dstLen = sizeof(dstbuf);
|
||||
long dummyState = 0;
|
||||
|
||||
int width = 1;
|
||||
@ -353,34 +399,7 @@ TermParse::EscParse()
|
||||
|
||||
if (currentEncoding != fBuffer->Encoding()) {
|
||||
// Change coding, change parse table.
|
||||
switch (fBuffer->Encoding()) {
|
||||
case B_ISO1_CONVERSION:
|
||||
case B_ISO2_CONVERSION:
|
||||
case B_ISO3_CONVERSION:
|
||||
case B_ISO4_CONVERSION:
|
||||
case B_ISO5_CONVERSION:
|
||||
case B_ISO6_CONVERSION:
|
||||
case B_ISO7_CONVERSION:
|
||||
case B_ISO8_CONVERSION:
|
||||
case B_ISO9_CONVERSION:
|
||||
case B_ISO10_CONVERSION:
|
||||
groundtable = gISO8859GroundTable;
|
||||
break;
|
||||
case B_SJIS_CONVERSION:
|
||||
groundtable = gSJISGroundTable;
|
||||
break;
|
||||
case B_EUC_CONVERSION:
|
||||
case B_EUC_KR_CONVERSION:
|
||||
case B_JIS_CONVERSION:
|
||||
case B_GBK_CONVERSION:
|
||||
case B_BIG5_CONVERSION:
|
||||
groundtable = gISO8859GroundTable;
|
||||
break;
|
||||
case M_UTF8:
|
||||
default:
|
||||
groundtable = gUTF8GroundTable;
|
||||
break;
|
||||
}
|
||||
groundtable = _GuessGroundTable(fBuffer->Encoding());
|
||||
parsestate = groundtable;
|
||||
currentEncoding = fBuffer->Encoding();
|
||||
}
|
||||
@ -433,6 +452,7 @@ TermParse::EscParse()
|
||||
}
|
||||
|
||||
srcLen = strlen(cbuf);
|
||||
dstLen = sizeof(dstbuf);
|
||||
if (currentEncoding != B_JIS_CONVERSION) {
|
||||
convert_to_utf8(currentEncoding, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
@ -450,7 +470,7 @@ TermParse::EscParse()
|
||||
cbuf[1] = c | 0x80;
|
||||
cbuf[2] = 0;
|
||||
srcLen = 2;
|
||||
dstLen = 0;
|
||||
dstLen = sizeof(dstbuf);
|
||||
convert_to_utf8(B_EUC_CONVERSION, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
|
||||
@ -512,7 +532,7 @@ TermParse::EscParse()
|
||||
cbuf[0] = c;
|
||||
cbuf[1] = '\0';
|
||||
srcLen = 1;
|
||||
dstLen = 0;
|
||||
dstLen = sizeof(dstbuf);
|
||||
convert_to_utf8(currentEncoding, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
|
||||
@ -524,7 +544,7 @@ TermParse::EscParse()
|
||||
cbuf[1] = c;
|
||||
cbuf[2] = '\0';
|
||||
srcLen = 2;
|
||||
dstLen = 0;
|
||||
dstLen = sizeof(dstbuf);
|
||||
convert_to_utf8(currentEncoding, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
|
||||
@ -571,7 +591,7 @@ TermParse::EscParse()
|
||||
{
|
||||
char page = _NextParseChar();
|
||||
|
||||
int* newTable = gUTF8GroundTable;
|
||||
int* newTable = _GuessGroundTable(currentEncoding);
|
||||
if (page == '0')
|
||||
newTable = gLineDrawTable;
|
||||
|
||||
|
@ -81,6 +81,7 @@ private:
|
||||
void _DecPrivateModeReset(int value);
|
||||
void _DecSaveCursor();
|
||||
void _DecRestoreCursor();
|
||||
int* _GuessGroundTable(int encoding);
|
||||
|
||||
int fFd;
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <Application.h>
|
||||
#include <Beep.h>
|
||||
#include <Catalog.h>
|
||||
#include <CharacterSet.h>
|
||||
#include <CharacterSetRoster.h>
|
||||
#include <Clipboard.h>
|
||||
#include <Debug.h>
|
||||
#include <Directory.h>
|
||||
@ -48,9 +50,9 @@
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
#include <UTF8.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "InlineInput.h"
|
||||
#include "Shell.h"
|
||||
#include "ShellParameters.h"
|
||||
@ -60,6 +62,8 @@
|
||||
#include "VTkeymap.h"
|
||||
|
||||
|
||||
using namespace BPrivate ; // BCharacterSet stuff
|
||||
|
||||
// defined in VTKeyTbl.c
|
||||
extern int function_keycode_table[];
|
||||
extern char *function_key_char_table[];
|
||||
@ -608,7 +612,10 @@ TermView::_InitObject(const ShellParameters& shellParameters)
|
||||
|
||||
// set the shell parameters' encoding
|
||||
ShellParameters modifiedShellParameters(shellParameters);
|
||||
modifiedShellParameters.SetEncoding(EncodingAsShortString(fEncoding));
|
||||
|
||||
const BCharacterSet* charset
|
||||
= BCharacterSetRoster::GetCharacterSetByConversionID(fEncoding);
|
||||
modifiedShellParameters.SetEncoding(!charset ? charset->GetName() : "UTF-8");
|
||||
|
||||
error = fShell->Open(fRows, fColumns, modifiedShellParameters);
|
||||
|
||||
@ -1552,7 +1559,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
if (numBytes > 1) {
|
||||
if (fEncoding != M_UTF8) {
|
||||
char destBuffer[16];
|
||||
int32 destLen;
|
||||
int32 destLen = sizeof(destBuffer);
|
||||
long state = 0;
|
||||
convert_from_utf8(fEncoding, bytes, &numBytes, destBuffer,
|
||||
&destLen, &state, '?');
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <CharacterSet.h>
|
||||
#include <CharacterSetRoster.h>
|
||||
#include <Clipboard.h>
|
||||
#include <Dragger.h>
|
||||
#include <File.h>
|
||||
@ -35,13 +37,13 @@
|
||||
#include <ScrollBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
#include <AutoLocker.h>
|
||||
|
||||
#include "ActiveProcessInfo.h"
|
||||
#include "Arguments.h"
|
||||
#include "AppearPrefView.h"
|
||||
#include "Encoding.h"
|
||||
#include "FindWindow.h"
|
||||
#include "Globals.h"
|
||||
#include "PrefWindow.h"
|
||||
@ -70,6 +72,7 @@ static const uint32 kTabTitleChanged = 'TTch';
|
||||
static const uint32 kWindowTitleChanged = 'WTch';
|
||||
static const uint32 kUpdateSwitchTerminalsMenuItem = 'Ustm';
|
||||
|
||||
using namespace BPrivate ; // BCharacterSet stuff
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
#define B_TRANSLATE_CONTEXT "Terminal TermWindow"
|
||||
@ -376,12 +379,20 @@ void
|
||||
TermWindow::MenusBeginning()
|
||||
{
|
||||
TermView* view = _ActiveTermView();
|
||||
|
||||
|
||||
// Syncronize Encode Menu Pop-up menu and Preference.
|
||||
BMenuItem* item = fEncodingMenu->FindItem(
|
||||
EncodingAsString(view->Encoding()));
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
const BCharacterSet* charset
|
||||
= BCharacterSetRoster::GetCharacterSetByConversionID(view->Encoding());
|
||||
if (charset != NULL) {
|
||||
BString name(charset->GetPrintName());
|
||||
const char* mime = charset->GetMIMEName();
|
||||
if (mime)
|
||||
name << " (" << mime << ")";
|
||||
|
||||
BMenuItem* item = fEncodingMenu->FindItem(name);
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
}
|
||||
|
||||
BFont font;
|
||||
view->GetTermFont(&font);
|
||||
@ -403,16 +414,27 @@ TermWindow::_MakeEncodingMenu()
|
||||
if (menu == NULL)
|
||||
return NULL;
|
||||
|
||||
int encoding;
|
||||
int i = 0;
|
||||
while (get_next_encoding(i, &encoding) == B_OK) {
|
||||
BCharacterSetRoster roster;
|
||||
BCharacterSet charset;
|
||||
while (roster.GetNextCharacterSet(&charset) == B_OK) {
|
||||
int encoding = M_UTF8;
|
||||
const char* mime = charset.GetMIMEName();
|
||||
if (mime == NULL || strcasecmp(mime, "UTF-8") != 0)
|
||||
encoding = charset.GetConversionID();
|
||||
|
||||
// filter out currently (???) not supported USC-2 and UTF-16
|
||||
if (encoding == B_UTF16_CONVERSION || encoding == B_UNICODE_CONVERSION)
|
||||
continue;
|
||||
|
||||
BString name(charset.GetPrintName());
|
||||
if (mime)
|
||||
name << " (" << mime << ")";
|
||||
|
||||
BMessage *message = new BMessage(MENU_ENCODING);
|
||||
if (message != NULL) {
|
||||
message->AddInt32("op", (int32)encoding);
|
||||
menu->AddItem(new BMenuItem(EncodingAsString(encoding),
|
||||
message));
|
||||
menu->AddItem(new BMenuItem(name, message));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
menu->SetRadioMode(true);
|
||||
@ -1135,8 +1157,12 @@ TermWindow::_AddTab(Arguments* args, const BString& currentDirectory)
|
||||
fTabView->AddTab(scrollView, tab);
|
||||
view->SetScrollBar(scrollView->ScrollBar(B_VERTICAL));
|
||||
view->SetMouseClipboard(gMouseClipboard);
|
||||
view->SetEncoding(EncodingID(
|
||||
PrefHandler::Default()->getString(PREF_TEXT_ENCODING)));
|
||||
|
||||
const BCharacterSet* charset
|
||||
= BCharacterSetRoster::FindCharacterSetByName(
|
||||
PrefHandler::Default()->getString(PREF_TEXT_ENCODING));
|
||||
if (charset != NULL)
|
||||
view->SetEncoding(charset->GetConversionID());
|
||||
|
||||
_SetTermColors(containerView);
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <Message.h>
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "TermConst.h"
|
||||
|
||||
|
||||
|
@ -1008,6 +1008,331 @@ CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
};
|
||||
|
||||
// #pragma mark WinCP table (Windows cp1252, cp1251, koi-8r etc.)
|
||||
int gWinCPGroundTable[] =
|
||||
{
|
||||
/* NUL SOH STX ETX */
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
/* EOT ENQ ACK BEL */
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_BELL,
|
||||
/* BS HT NL VT */
|
||||
CASE_BS,
|
||||
CASE_TAB,
|
||||
CASE_LF,
|
||||
CASE_LF, /*CASE_UP,*/
|
||||
/* NP CR SO SI */
|
||||
CASE_LF, /*CASE_IGNORE,*/
|
||||
CASE_CR,
|
||||
CASE_SO,
|
||||
CASE_SI,
|
||||
/* DLE DC1 DC2 DC3 */
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
/* DC4 NAK SYN ETB */
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
/* CAN EM SUB ESC */
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_ESC,
|
||||
/* FS GS RS US */
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
CASE_IGNORE,
|
||||
/* SP ! " # */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* $ % & ' */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* ( ) * + */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* , - . / */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* 0 1 2 3 */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* 4 5 6 7 */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* 8 9 : ; */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* < = > ? */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* @ A B C */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* D E F G */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* H I J K */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* L M N O */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* P Q R S */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* T U V W */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* X Y Z [ */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* \ ] ^ _ */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* ` a b c */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* d e f g */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* h i j k */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* l m n o */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* p q r s */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* t u v w */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* x y z { */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
/* | } ~ DEL */
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT,
|
||||
CASE_PRINT, //TODO???
|
||||
/* 0x80 0x81 0x82 0x83 */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x84 0x85 0x86 0x87 */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x88 0x89 0x8a 0x8b */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x8c 0x8d 0x8e 0x8f */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x90 0x91 0x92 0x93 */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x94 0x95 0x96 0x97 */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x99 0x99 0x9a 0x9b */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* 0x9c 0x9d 0x9e 0x9f */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* nobreakspace exclamdown cent sterling */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* currency yen brokenbar section */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* diaeresis copyright ordfeminine guillemotleft */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* notsign hyphen registered macron */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* degree plusminus twosuperior threesuperior */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* acute mu paragraph periodcentered */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* cedilla onesuperior masculine guillemotright */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* onequarter onehalf threequarters questiondown */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Agrave Aacute Acircumflex Atilde */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Adiaeresis Aring AE Ccedilla */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Egrave Eacute Ecircumflex Ediaeresis */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Igrave Iacute Icircumflex Idiaeresis */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Eth Ntilde Ograve Oacute */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Ocircumflex Otilde Odiaeresis multiply */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Ooblique Ugrave Uacute Ucircumflex */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* Udiaeresis Yacute Thorn ssharp */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* agrave aacute acircumflex atilde */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* adiaeresis aring ae ccedilla */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* egrave eacute ecircumflex ediaeresis */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* igrave iacute icircumflex idiaeresis */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* eth ntilde ograve oacute */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* ocircumflex otilde odiaeresis division */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* oslash ugrave uacute ucircumflex */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
/* udiaeresis yacute thorn ydiaeresis */
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
CASE_PRINT_GR,
|
||||
};
|
||||
|
||||
// #pragma mark ESC [ - CSI table
|
||||
int gCsiTable[] =
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user