Big refactoring. Got rid of some global variables by putting code in
global functions (at least for now), removed useless globals, restyled the code. Not yet done. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21557 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -61,10 +61,6 @@ CodeConv::UTF8GetFontWidth(const char *string)
|
|||||||
int32
|
int32
|
||||||
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
|
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||||
{
|
{
|
||||||
int32 dstlen = 0;
|
|
||||||
long state = 0;
|
|
||||||
int theCoding;
|
|
||||||
|
|
||||||
if (srclen == -1)
|
if (srclen == -1)
|
||||||
srclen = strlen(src);
|
srclen = strlen(src);
|
||||||
|
|
||||||
@@ -74,11 +70,10 @@ CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int codi
|
|||||||
return srclen;
|
return srclen;
|
||||||
}
|
}
|
||||||
|
|
||||||
theCoding = coding_translation_table[coding];
|
int theCoding = coding_translation_table[coding];
|
||||||
|
|
||||||
|
|
||||||
dstlen = srclen * 256;
|
|
||||||
|
|
||||||
|
int32 dstlen = srclen * 256;
|
||||||
|
long state = 0;
|
||||||
convert_from_utf8(theCoding, (char *)src, &srclen,
|
convert_from_utf8(theCoding, (char *)src, &srclen,
|
||||||
(char *)dst, &dstlen, &state, '?');
|
(char *)dst, &dstlen, &state, '?');
|
||||||
|
|
||||||
@@ -97,10 +92,6 @@ CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int codi
|
|||||||
int32
|
int32
|
||||||
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
|
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||||
{
|
{
|
||||||
int32 dstlen = 4;
|
|
||||||
long state = 0;
|
|
||||||
int theCoding;
|
|
||||||
|
|
||||||
if (srclen == -1)
|
if (srclen == -1)
|
||||||
srclen = strlen(src);
|
srclen = strlen(src);
|
||||||
|
|
||||||
@@ -126,8 +117,9 @@ CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
theCoding = coding_translation_table[coding];
|
int theCoding = coding_translation_table[coding];
|
||||||
|
int32 dstlen = 4;
|
||||||
|
long state = 0;
|
||||||
convert_to_utf8(theCoding, (char *)src, &srclen,
|
convert_to_utf8(theCoding, (char *)src, &srclen,
|
||||||
(char *)dst, &dstlen, &state, '?');
|
(char *)dst, &dstlen, &state, '?');
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
#include "Coding.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 uint32 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', M_ISO_8859_1},
|
||||||
|
{"ISO-8859-2", "8859-2", '2', M_ISO_8859_2},
|
||||||
|
{"ISO-8859-3", "8859-3", '3', M_ISO_8859_3},
|
||||||
|
{"ISO-8859-4", "8859-4", '4', M_ISO_8859_4},
|
||||||
|
{"ISO-8859-5", "8859-5", '5', M_ISO_8859_5},
|
||||||
|
{"ISO-8859-6", "8859-6", '6', M_ISO_8859_6},
|
||||||
|
{"ISO-8859-7", "8859-7", '7', M_ISO_8859_7},
|
||||||
|
{"ISO-8859-8", "8859-8", '8', M_ISO_8859_8},
|
||||||
|
{"ISO-8859-9", "8859-9", '9', M_ISO_8859_9},
|
||||||
|
{"ISO-8859-10", "8859-10", '0', M_ISO_8859_10},
|
||||||
|
{"MacRoman", "MacRoman",'M', M_MAC_ROMAN},
|
||||||
|
{"JIS", "JIS", 'J', M_ISO_2022_JP},
|
||||||
|
{"Shift-JIS", "SJIS", 'S', M_SJIS},
|
||||||
|
{"EUC-jp", "EUCJ", 'E', M_EUC_JP},
|
||||||
|
{"EUC-kr", "EUCK", 'K', M_EUC_KR},
|
||||||
|
|
||||||
|
/* Not Implement.
|
||||||
|
{"EUC-tw", "EUCT", "T", M_EUC_TW},
|
||||||
|
{"Big5", "Big5", 'B', M_BIG5},
|
||||||
|
{"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN},
|
||||||
|
{"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR},
|
||||||
|
*/
|
||||||
|
|
||||||
|
{NULL, NULL, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int sCurrentEncoding = M_UTF8;
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
get_nth_encoding(int i, int *id)
|
||||||
|
{
|
||||||
|
if (id == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
if (i < 0 || i >= sizeof(kEncodingTable) / sizeof(etable))
|
||||||
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
|
*id = kEncodingTable[i].id;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
longname2id(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 *
|
||||||
|
longname2shortname(const char *longname)
|
||||||
|
{
|
||||||
|
const char *shortName = NULL;
|
||||||
|
|
||||||
|
const etable *p = kEncodingTable;
|
||||||
|
while (p->name) {
|
||||||
|
if (!strcmp(p->name, longname)) {
|
||||||
|
shortName = p->shortname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shortName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
id2longname(int id)
|
||||||
|
{
|
||||||
|
return kEncodingTable[id].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char
|
||||||
|
id2shortcut(int id)
|
||||||
|
{
|
||||||
|
return kEncodingTable[id].shortcut;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SetEncoding(int encoding)
|
||||||
|
{
|
||||||
|
sCurrentEncoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
GetEncoding()
|
||||||
|
{
|
||||||
|
return sCurrentEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -82,45 +82,16 @@ const uint32 coding_translation_table[] = {
|
|||||||
B_EUC_KR_CONVERSION /* EUC Korean */
|
B_EUC_KR_CONVERSION /* EUC Korean */
|
||||||
};
|
};
|
||||||
|
|
||||||
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 uint32 op; // encodeing opcode
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
status_t get_nth_encoding(int i, int *op);
|
||||||
* encoding_table ... use encoding menu, message, and preference keys.
|
|
||||||
*/
|
|
||||||
const etable encoding_table[]=
|
|
||||||
{
|
|
||||||
{"UTF-8", "UTF8", 'U', M_UTF8},
|
|
||||||
{"ISO-8859-1", "8859-1", '1', M_ISO_8859_1},
|
|
||||||
{"ISO-8859-2", "8859-2", '2', M_ISO_8859_2},
|
|
||||||
{"ISO-8859-3", "8859-3", '3', M_ISO_8859_3},
|
|
||||||
{"ISO-8859-4", "8859-4", '4', M_ISO_8859_4},
|
|
||||||
{"ISO-8859-5", "8859-5", '5', M_ISO_8859_5},
|
|
||||||
{"ISO-8859-6", "8859-6", '6', M_ISO_8859_6},
|
|
||||||
{"ISO-8859-7", "8859-7", '7', M_ISO_8859_7},
|
|
||||||
{"ISO-8859-8", "8859-8", '8', M_ISO_8859_8},
|
|
||||||
{"ISO-8859-9", "8859-9", '9', M_ISO_8859_9},
|
|
||||||
{"ISO-8859-10", "8859-10", '0', M_ISO_8859_10},
|
|
||||||
{"MacRoman", "MacRoman",'M', M_MAC_ROMAN},
|
|
||||||
{"JIS", "JIS", 'J', M_ISO_2022_JP},
|
|
||||||
{"Shift-JIS", "SJIS", 'S', M_SJIS},
|
|
||||||
{"EUC-jp", "EUCJ", 'E', M_EUC_JP},
|
|
||||||
{"EUC-kr", "EUCK", 'K', M_EUC_KR},
|
|
||||||
|
|
||||||
/* Not Implement.
|
int longname2id(const char *longname);
|
||||||
{"EUC-tw", "EUCT", "T", M_EUC_TW},
|
const char * longname2shortname(const char *longname);
|
||||||
{"Big5", "Big5", 'B', M_BIG5},
|
const char * id2longname(int op);
|
||||||
{"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN},
|
const char id2shortcut(int op);
|
||||||
{"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR},
|
|
||||||
*/
|
|
||||||
|
|
||||||
{NULL, NULL, 0, 0},
|
void SetEncoding(int encoding);
|
||||||
};
|
int GetEncoding();
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODING_H_ */
|
#endif /* _CODING_H_ */
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] ;
|
|||||||
Application Terminal :
|
Application Terminal :
|
||||||
AppearPrefView.cpp
|
AppearPrefView.cpp
|
||||||
CodeConv.cpp
|
CodeConv.cpp
|
||||||
|
Coding.cpp
|
||||||
CurPos.cpp
|
CurPos.cpp
|
||||||
FindWindow.cpp
|
FindWindow.cpp
|
||||||
MenuUtil.cpp
|
MenuUtil.cpp
|
||||||
|
|||||||
@@ -40,44 +40,24 @@ MakeMenu(ulong msg, const char **items, const char *defaultItemName)
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
longname2op(const char *longname)
|
|
||||||
{
|
|
||||||
int op = M_UTF8;
|
|
||||||
const etable *s = encoding_table;
|
|
||||||
|
|
||||||
for (int i = 0; s->name; s++, i++) {
|
|
||||||
if (!strcmp(s->name, longname)) {
|
|
||||||
op = s->op;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
op2longname(int op)
|
|
||||||
{
|
|
||||||
return encoding_table[op].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MakeEncodingMenu(BMenu *eMenu, int coding, bool flag)
|
MakeEncodingMenu(BMenu *eMenu, int marked, bool flag)
|
||||||
{
|
{
|
||||||
const etable *e = encoding_table;
|
int encoding;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (e->name) {
|
while (get_nth_encoding(i, &encoding) == B_OK) {
|
||||||
BMessage *msg = new BMessage(MENU_ENCODING);
|
BMessage *msg = new BMessage(MENU_ENCODING);
|
||||||
msg->AddInt32("op", (int32)e->op);
|
msg->AddInt32("op", (int32)encoding);
|
||||||
if (flag)
|
if (flag)
|
||||||
eMenu->AddItem(new BMenuItem(e->name, msg, e->shortcut));
|
eMenu->AddItem(new BMenuItem(id2longname(encoding), msg, id2shortcut(encoding)));
|
||||||
else
|
else
|
||||||
eMenu->AddItem(new BMenuItem(e->name, msg));
|
eMenu->AddItem(new BMenuItem(id2longname(encoding), msg));
|
||||||
|
|
||||||
if (i == coding)
|
if (i == marked)
|
||||||
eMenu->ItemAt(i)->SetMarked(true);
|
eMenu->ItemAt(i)->SetMarked(true);
|
||||||
|
|
||||||
e++;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
@@ -22,13 +19,10 @@ class PrefHandler;
|
|||||||
|
|
||||||
BPopUpMenu * MakeMenu(ulong msg, const char **items,
|
BPopUpMenu * MakeMenu(ulong msg, const char **items,
|
||||||
const char *defaultItemName);
|
const char *defaultItemName);
|
||||||
int longname2op(const char *longname);
|
|
||||||
const char * op2longname(int op);
|
|
||||||
void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag);
|
void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag);
|
||||||
void LoadLocaleFile (PrefHandler *);
|
void LoadLocaleFile (PrefHandler *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ PrefHandler::_LoadFromFile(const char* path)
|
|||||||
setRGB(PREF_CURSOR_FORE_COLOR, prefs.curfg);
|
setRGB(PREF_CURSOR_FORE_COLOR, prefs.curfg);
|
||||||
setRGB(PREF_SELECT_BACK_COLOR, prefs.selbg);
|
setRGB(PREF_SELECT_BACK_COLOR, prefs.selbg);
|
||||||
setRGB(PREF_SELECT_FORE_COLOR, prefs.selfg);
|
setRGB(PREF_SELECT_FORE_COLOR, prefs.selfg);
|
||||||
setString(PREF_TEXT_ENCODING, encoding_table[prefs.encoding].name);
|
setString(PREF_TEXT_ENCODING, id2longname(prefs.encoding));
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,19 +62,23 @@ PrefView::PrefView (BRect frame, const char *name)
|
|||||||
fLabel.SetTo(name);
|
fLabel.SetTo(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// ~PrefView ()
|
// ~PrefView ()
|
||||||
// Destructor.
|
// Destructor.
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
PrefView::~PrefView()
|
PrefView::~PrefView()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
PrefView::ViewLabel (void) const
|
PrefView::ViewLabel (void) const
|
||||||
{
|
{
|
||||||
return fLabel.String();
|
return fLabel.String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// CanApply()
|
// CanApply()
|
||||||
// Determines whether view can respont Apply command or not.
|
// Determines whether view can respont Apply command or not.
|
||||||
@@ -85,14 +89,14 @@ PrefView::CanApply ()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrefView::MessageReceived(BMessage* msg)
|
PrefView::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
BControl *control;
|
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case MSG_TEXT_MODIFIED: {
|
case MSG_TEXT_MODIFIED: {
|
||||||
TTextControl* textControl;
|
TTextControl* textControl;
|
||||||
|
BControl *control;
|
||||||
if (msg->FindPointer("source", (void**)&control) >= B_OK
|
if (msg->FindPointer("source", (void**)&control) >= B_OK
|
||||||
&& (textControl = dynamic_cast<TTextControl*>(control))) {
|
&& (textControl = dynamic_cast<TTextControl*>(control))) {
|
||||||
textControl->ModifiedText(true);
|
textControl->ModifiedText(true);
|
||||||
@@ -106,8 +110,6 @@ PrefView::MessageReceived(BMessage* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// SetupBColorControl
|
// SetupBColorControl
|
||||||
// Make BColorControl.
|
// Make BColorControl.
|
||||||
@@ -115,9 +117,7 @@ PrefView::MessageReceived(BMessage* msg)
|
|||||||
BColorControl *
|
BColorControl *
|
||||||
PrefView::SetupBColorControl(BPoint p, color_control_layout layout, float cell_size, ulong msg)
|
PrefView::SetupBColorControl(BPoint p, color_control_layout layout, float cell_size, ulong msg)
|
||||||
{
|
{
|
||||||
BColorControl *col;
|
BColorControl *col = new BColorControl( p, layout, cell_size, "", new BMessage(msg));
|
||||||
|
|
||||||
col = new BColorControl( p, layout, cell_size, "", new BMessage(msg));
|
|
||||||
AddChild(col);
|
AddChild(col);
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
PrefHandler *gTermPref;
|
PrefHandler *gTermPref;
|
||||||
extern char gWindowName[];
|
|
||||||
|
|
||||||
bool gUsageRequested = false;
|
bool gUsageRequested = false;
|
||||||
bool gGeometryRequested = false;
|
bool gGeometryRequested = false;
|
||||||
@@ -336,18 +335,6 @@ TermApp::RefsReceived(BMessage* message)
|
|||||||
status_t
|
status_t
|
||||||
TermApp::_MakeTermWindow(BRect &frame)
|
TermApp::_MakeTermWindow(BRect &frame)
|
||||||
{
|
{
|
||||||
const char *encoding = gTermPref->getString(PREF_TEXT_ENCODING);
|
|
||||||
|
|
||||||
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
|
||||||
const etable *p = encoding_table;
|
|
||||||
while (p->name) {
|
|
||||||
if (!strcmp(p->name, encoding)) {
|
|
||||||
encoding = p->shortname;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *command = NULL;
|
const char *command = NULL;
|
||||||
if (CommandLine.Length() > 0)
|
if (CommandLine.Length() > 0)
|
||||||
command = CommandLine.String();
|
command = CommandLine.String();
|
||||||
@@ -362,6 +349,8 @@ TermApp::_MakeTermWindow(BRect &frame)
|
|||||||
if (cols < MIN_COLS)
|
if (cols < MIN_COLS)
|
||||||
gTermPref->setInt32(PREF_COLS, cols = MIN_COLS);
|
gTermPref->setInt32(PREF_COLS, cols = MIN_COLS);
|
||||||
|
|
||||||
|
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
||||||
|
const char *encoding = longname2shortname(gTermPref->getString(PREF_TEXT_ENCODING));
|
||||||
int pfd = spawn_shell(rows, cols, command, encoding);
|
int pfd = spawn_shell(rows, cols, command, encoding);
|
||||||
if (pfd < 0)
|
if (pfd < 0)
|
||||||
return pfd;
|
return pfd;
|
||||||
|
|||||||
@@ -36,9 +36,6 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
extern int gPfd;
|
|
||||||
extern char *ptyname;
|
|
||||||
|
|
||||||
class TermWindow;
|
class TermWindow;
|
||||||
class TermParse;
|
class TermParse;
|
||||||
class BRect;
|
class BRect;
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ extern int eigtable[]; /* ESC ignore table */
|
|||||||
extern int mbcstable[]; /* ESC $ */
|
extern int mbcstable[]; /* ESC $ */
|
||||||
|
|
||||||
|
|
||||||
// MuTerminal coding system (global varriable)
|
|
||||||
int gNowCoding = M_UTF8;
|
|
||||||
|
|
||||||
#define DEFAULT -1
|
#define DEFAULT -1
|
||||||
#define NPARAM 10 // Max parameters
|
#define NPARAM 10 // Max parameters
|
||||||
@@ -271,11 +269,11 @@ TermParse::EscParse()
|
|||||||
if (GetReaderBuf(c) < B_OK)
|
if (GetReaderBuf(c) < B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (now_coding != gNowCoding) {
|
if (now_coding != GetEncoding()) {
|
||||||
/*
|
/*
|
||||||
* Change coding, change parse table.
|
* Change coding, change parse table.
|
||||||
*/
|
*/
|
||||||
switch (gNowCoding) {
|
switch (GetEncoding()) {
|
||||||
case M_UTF8:
|
case M_UTF8:
|
||||||
groundtable = utf8_groundtable;
|
groundtable = utf8_groundtable;
|
||||||
break;
|
break;
|
||||||
@@ -301,7 +299,7 @@ TermParse::EscParse()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
now_coding = gNowCoding;
|
now_coding = GetEncoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (parsestate[c]) {
|
switch (parsestate[c]) {
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ using std::nothrow;
|
|||||||
extern int function_keycode_table[];
|
extern int function_keycode_table[];
|
||||||
extern char *function_key_char_table[];
|
extern char *function_key_char_table[];
|
||||||
|
|
||||||
extern int gNowCoding; // defined in TermParse.cpp
|
|
||||||
extern PrefHandler *gTermPref; // Global Preference Handler
|
extern PrefHandler *gTermPref; // Global Preference Handler
|
||||||
|
|
||||||
const static rgb_color kTermColorTable[16] = {
|
const static rgb_color kTermColorTable[16] = {
|
||||||
@@ -1339,9 +1338,9 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
} else {
|
} else {
|
||||||
// input multibyte character
|
// input multibyte character
|
||||||
|
|
||||||
if (gNowCoding != M_UTF8) {
|
if (GetEncoding() != M_UTF8) {
|
||||||
int cnum = fCodeConv->ConvertFromInternal(bytes, numBytes,
|
int cnum = fCodeConv->ConvertFromInternal(bytes, numBytes,
|
||||||
(char *)dstbuf, gNowCoding);
|
(char *)dstbuf, GetEncoding());
|
||||||
write(fTerminalFd, dstbuf, cnum);
|
write(fTerminalFd, dstbuf, cnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1586,10 +1585,10 @@ TermView::DoClearAll(void)
|
|||||||
void
|
void
|
||||||
TermView::WritePTY(const uchar *text, int numBytes)
|
TermView::WritePTY(const uchar *text, int numBytes)
|
||||||
{
|
{
|
||||||
if (gNowCoding != M_UTF8) {
|
if (GetEncoding() != M_UTF8) {
|
||||||
uchar *destBuffer = (uchar *)malloc(numBytes * 3);
|
uchar *destBuffer = (uchar *)malloc(numBytes * 3);
|
||||||
numBytes = fCodeConv->ConvertFromInternal((char*)text, numBytes,
|
numBytes = fCodeConv->ConvertFromInternal((char*)text, numBytes,
|
||||||
(char*)destBuffer, gNowCoding);
|
(char*)destBuffer, GetEncoding());
|
||||||
write(fTerminalFd, destBuffer, numBytes);
|
write(fTerminalFd, destBuffer, numBytes);
|
||||||
free(destBuffer);
|
free(destBuffer);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -53,10 +53,6 @@ extern PrefHandler *gTermPref;
|
|||||||
//#define GPL_FILE "/gpl.html"
|
//#define GPL_FILE "/gpl.html"
|
||||||
//#define CHLP_FILE "file:///boot/beos/documentation/Shell%20Tools/index.html"
|
//#define CHLP_FILE "file:///boot/beos/documentation/Shell%20Tools/index.html"
|
||||||
|
|
||||||
extern int gNowCoding; /* defined TermParce.cpp */
|
|
||||||
|
|
||||||
void SetCoding(int);
|
|
||||||
|
|
||||||
|
|
||||||
TermWindow::TermWindow(BRect frame, const char* title, int fd)
|
TermWindow::TermWindow(BRect frame, const char* title, int fd)
|
||||||
: BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE),
|
: BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE),
|
||||||
@@ -180,7 +176,7 @@ TermWindow::InitWindow(void)
|
|||||||
fEditmenu->SetTargetForItems(fTermView);
|
fEditmenu->SetTargetForItems(fTermView);
|
||||||
|
|
||||||
// Initialize TermParse
|
// Initialize TermParse
|
||||||
gNowCoding = longname2op(gTermPref->getString(PREF_TEXT_ENCODING));
|
SetEncoding(longname2id(gTermPref->getString(PREF_TEXT_ENCODING)));
|
||||||
fTermParse = new TermParse(fPfd, this, fTermView, fCodeConv);
|
fTermParse = new TermParse(fPfd, this, fTermView, fCodeConv);
|
||||||
if (fTermParse->StartThreads() < B_OK)
|
if (fTermParse->StartThreads() < B_OK)
|
||||||
return;
|
return;
|
||||||
@@ -203,7 +199,7 @@ void
|
|||||||
TermWindow::MenusBeginning(void)
|
TermWindow::MenusBeginning(void)
|
||||||
{
|
{
|
||||||
// Syncronize Encode Menu Pop-up menu and Preference.
|
// Syncronize Encode Menu Pop-up menu and Preference.
|
||||||
(fEncodingmenu->FindItem(op2longname(gNowCoding)))->SetMarked(true);
|
(fEncodingmenu->FindItem(id2longname(GetEncoding())))->SetMarked(true);
|
||||||
BWindow::MenusBeginning();
|
BWindow::MenusBeginning();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +273,7 @@ TermWindow::SetupMenu(void)
|
|||||||
|
|
||||||
fEncodingmenu = new BMenu("Font Encoding");
|
fEncodingmenu = new BMenu("Font Encoding");
|
||||||
fEncodingmenu->SetRadioMode(true);
|
fEncodingmenu->SetRadioMode(true);
|
||||||
MakeEncodingMenu(fEncodingmenu, gNowCoding, true);
|
MakeEncodingMenu(fEncodingmenu, GetEncoding(), true);
|
||||||
fHelpmenu->AddItem(fWindowSizeMenu);
|
fHelpmenu->AddItem(fWindowSizeMenu);
|
||||||
fHelpmenu->AddItem(fEncodingmenu);
|
fHelpmenu->AddItem(fEncodingmenu);
|
||||||
// fHelpmenu->AddItem(fNewFontMenu);
|
// fHelpmenu->AddItem(fNewFontMenu);
|
||||||
@@ -398,8 +394,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
case MENU_ENCODING: {
|
case MENU_ENCODING: {
|
||||||
message->FindInt32 ("op", &coding_id);
|
message->FindInt32 ("op", &coding_id);
|
||||||
gNowCoding = coding_id;
|
SetEncoding(coding_id);
|
||||||
SetCoding(coding_id);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Extended B_SET_PROPERTY. Dispatch this message,
|
// Extended B_SET_PROPERTY. Dispatch this message,
|
||||||
@@ -410,8 +405,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
message->GetCurrentSpecifier(&i, &spe);
|
message->GetCurrentSpecifier(&i, &spe);
|
||||||
if (!strcmp("encode", spe.FindString("property", i))){
|
if (!strcmp("encode", spe.FindString("property", i))){
|
||||||
message->FindInt32 ("data", &coding_id);
|
message->FindInt32 ("data", &coding_id);
|
||||||
gNowCoding = coding_id;
|
SetEncoding (coding_id);
|
||||||
SetCoding (coding_id);
|
|
||||||
|
|
||||||
message->SendReply(B_REPLY);
|
message->SendReply(B_REPLY);
|
||||||
} else {
|
} else {
|
||||||
@@ -427,7 +421,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
message->GetCurrentSpecifier(&i, &spe);
|
message->GetCurrentSpecifier(&i, &spe);
|
||||||
if (!strcmp("encode", spe.FindString("property", i))){
|
if (!strcmp("encode", spe.FindString("property", i))){
|
||||||
BMessage reply(B_REPLY);
|
BMessage reply(B_REPLY);
|
||||||
reply.AddInt32("result", gNowCoding);
|
reply.AddInt32("result", GetEncoding());
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
}
|
}
|
||||||
else if (!strcmp("tty", spe.FindString("property", i))) {
|
else if (!strcmp("tty", spe.FindString("property", i))) {
|
||||||
@@ -664,20 +658,6 @@ TermWindow::ResolveSpecifier(BMessage *msg, int32 index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// SetCoding
|
|
||||||
// Set coding utility functions.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
|
||||||
SetCoding(int coding)
|
|
||||||
{
|
|
||||||
const etable *p = encoding_table;
|
|
||||||
p += coding;
|
|
||||||
|
|
||||||
gNowCoding = coding;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TermWindow::DoPageSetup()
|
TermWindow::DoPageSetup()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class FindWindow;
|
|||||||
|
|
||||||
class TermWindow : public BWindow {
|
class TermWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
TermWindow(BRect frame, const char* title, int gPfd);
|
TermWindow(BRect frame, const char* title, int fd);
|
||||||
virtual ~TermWindow();
|
virtual ~TermWindow();
|
||||||
|
|
||||||
void TermWinActivate();
|
void TermWinActivate();
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "TermApp.h"
|
#include "TermApp.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user