Invoke the shell using /bin/bash instead of /bin/sh.
Use convert_to/from_utf8() directly instead of the homebrewn proxy methods. Removed CodeConv from the repository. Remove UTF8WidthTbl.c from the repository, since it's not used anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -19,7 +19,7 @@ Arguments::Arguments()
|
||||
fShellArguments(NULL),
|
||||
fTitle(NULL)
|
||||
{
|
||||
const char *argv[] = { "/bin/sh", "--login" };
|
||||
const char *argv[] = { "/bin/bash", "--login" };
|
||||
|
||||
_SetShellArguments(2, argv);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include "CodeConv.h"
|
||||
#include "TermConst.h"
|
||||
#include "TerminalCharClassifier.h"
|
||||
#include "TerminalLine.h"
|
||||
@@ -550,8 +549,6 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
|
||||
{
|
||||
//debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n",
|
||||
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
|
||||
// TODO: Check if this method can be removed completely
|
||||
//int width = CodeConv::UTF8GetFontWidth(c.bytes);
|
||||
if ((int32)width == FULL_WIDTH)
|
||||
attributes |= A_WIDTH;
|
||||
|
||||
@@ -589,8 +586,6 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
|
||||
void
|
||||
BasicTerminalBuffer::FillScreen(UTF8Char c, uint32 width, uint32 attributes)
|
||||
{
|
||||
// TODO: Check if this method can be removed completely
|
||||
//int width = CodeConv::UTF8GetFontWidth(c.bytes);
|
||||
if ((int32)width == FULL_WIDTH)
|
||||
attributes |= A_WIDTH;
|
||||
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2007, Haiku, Inc.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
MuTerminal Code Conversion class (MC3).
|
||||
|
||||
version 1.1 Internal coding system is UTF8.
|
||||
|
||||
Code conversion member functions are convert character code and calc
|
||||
font width.
|
||||
|
||||
Available coding systems.
|
||||
|
||||
ISO-8859-1 ... 10
|
||||
Shift JIS
|
||||
EUC-jp
|
||||
UTF8
|
||||
|
||||
************************************************************************/
|
||||
|
||||
#include <UTF8.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "CodeConv.h"
|
||||
|
||||
#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80)
|
||||
|
||||
|
||||
extern char gUTF8WidthTable[]; // defined in UTF8WidthTbl.c
|
||||
|
||||
|
||||
//! get font width in coding.
|
||||
/* static */
|
||||
int32
|
||||
CodeConv::UTF8GetFontWidth(const char *string)
|
||||
{
|
||||
ushort unicode = UTF8toUnicode(string);
|
||||
uchar width = gUTF8WidthTable[unicode >> 3];
|
||||
ushort offset = unicode & 0x07;
|
||||
|
||||
uchar point = 0x80 >> offset;
|
||||
|
||||
return (width & point) > 0 ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
//! Convert internal coding from src coding.
|
||||
/* static */
|
||||
int32
|
||||
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||
{
|
||||
if (srclen == -1)
|
||||
srclen = strlen(src);
|
||||
|
||||
if (coding == M_UTF8) {
|
||||
memcpy(dst, src, srclen);
|
||||
dst[srclen] = '\0';
|
||||
return srclen;
|
||||
}
|
||||
|
||||
int32 dstlen = srclen * 256;
|
||||
long state = 0;
|
||||
convert_from_utf8(coding, (char *)src, &srclen,
|
||||
(char *)dst, &dstlen, &state, '?');
|
||||
|
||||
// TODO: Apart from this particular case, looks like we could use the
|
||||
// system api for code conversion... check if this (which looks a lot like a workaround)
|
||||
// applies to haiku, and if not, get rid of this class and just use the system api directly.
|
||||
if (coding == B_EUC_CONVERSION && state != 0) {
|
||||
const char *end_of_jis = "\033(B";
|
||||
strncpy((char *)dst + dstlen, end_of_jis, 3);
|
||||
dstlen += 3;
|
||||
}
|
||||
|
||||
dst[dstlen] = '\0';
|
||||
return dstlen;
|
||||
}
|
||||
|
||||
|
||||
//! Convert internal coding to src coding.
|
||||
/* static */
|
||||
int32
|
||||
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||
{
|
||||
if (srclen == -1)
|
||||
srclen = strlen(src);
|
||||
|
||||
if (coding == M_UTF8) {
|
||||
memcpy(dst, src, srclen);
|
||||
dst[srclen] = '\0';
|
||||
return srclen;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifndef __INTEL__
|
||||
if (coding = M_EUC_JP) {
|
||||
uchar buf[2];
|
||||
memcpy (buf, src, 2);
|
||||
euc_to_sjis (buf);
|
||||
srclen = 2;
|
||||
convert_to_utf8 (B_SJIS_CONVERSION, (char*) buf, &srclen,
|
||||
(char *)dst, &dstlen,
|
||||
&state, '?');
|
||||
dst[dstlen] = '\0';
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32 dstlen = 4;
|
||||
long state = 0;
|
||||
convert_to_utf8(coding, (char *)src, &srclen,
|
||||
(char *)dst, &dstlen, &state, '?');
|
||||
|
||||
dst[dstlen] = '\0';
|
||||
return dstlen;
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
unsigned short
|
||||
CodeConv::UTF8toUnicode(const char *utf8)
|
||||
{
|
||||
uchar tmp;
|
||||
unsigned short unicode = 0x0000;
|
||||
|
||||
tmp = *utf8 & 0xe0;
|
||||
|
||||
if (tmp < 0x80) {
|
||||
unicode = (unsigned short)*utf8;
|
||||
} else if (tmp < 0xe0) {
|
||||
unicode = (unsigned short)*utf8++ & 0x1f;
|
||||
unicode = unicode << 6;
|
||||
unicode = unicode | ((unsigned short)*utf8 & 0x3f);
|
||||
} else if (tmp < 0xf0) {
|
||||
unicode = (unsigned short)*utf8++ & 0x0f;
|
||||
unicode = unicode << 6;
|
||||
unicode = unicode | ((unsigned short)*utf8++ & 0x3f);
|
||||
unicode = unicode << 6;
|
||||
unicode = unicode | ((unsigned short)*utf8 & 0x3f);
|
||||
}
|
||||
|
||||
return unicode;
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
void
|
||||
CodeConv::euc_to_sjis(uchar *buf)
|
||||
{
|
||||
int gl, gr;
|
||||
int p;
|
||||
int c1, c2;
|
||||
|
||||
gl = *buf & 0x7F;
|
||||
gr = *(buf + 1) & 0x7F;
|
||||
gl -= 0x21;
|
||||
gr -= 0x21;
|
||||
|
||||
p = gl * 94 + gr;
|
||||
|
||||
c1 = p / 188;
|
||||
c2 = p % 188;
|
||||
|
||||
if (c1 >= 31)
|
||||
c1 = c1 - 31 + 0xE0;
|
||||
else
|
||||
c1 += 0x81;
|
||||
|
||||
if (c2 >= 63)
|
||||
c2 = c2 - 63 + 0x80;
|
||||
else
|
||||
c2 += 0x40;
|
||||
|
||||
*buf++ = c1;
|
||||
*buf = c2;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef CODECONV_H
|
||||
#define CODECONV_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include "Encoding.h"
|
||||
|
||||
class CodeConv {
|
||||
public:
|
||||
static int32 UTF8GetFontWidth(const char *string);
|
||||
|
||||
/* internal(UTF8) -> coding */
|
||||
static int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding);
|
||||
|
||||
/* coding -> internal(UTF8) */
|
||||
static int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding);
|
||||
|
||||
private:
|
||||
static void euc_to_sjis(uchar *buf);
|
||||
static unsigned short UTF8toUnicode(const char *utf8);
|
||||
};
|
||||
|
||||
|
||||
#endif /* CODECONV_H */
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "TermConst.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <SupportDefs.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
#define M_UTF8 (-1)
|
||||
|
||||
status_t get_next_encoding(int i, int *id);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ Application Terminal :
|
||||
AppearPrefView.cpp
|
||||
Arguments.cpp
|
||||
BasicTerminalBuffer.cpp
|
||||
CodeConv.cpp
|
||||
Encoding.cpp
|
||||
FindWindow.cpp
|
||||
Globals.cpp
|
||||
@@ -25,7 +24,6 @@ Application Terminal :
|
||||
TermScrollView.cpp
|
||||
TermView.cpp
|
||||
TermWindow.cpp
|
||||
UTF8WidthTbl.c
|
||||
VTKeyTbl.c
|
||||
VTPrsTbl.c
|
||||
: be tracker textencoding $(TARGET_LIBSUPC++)
|
||||
|
||||
@@ -152,6 +152,8 @@ enum{
|
||||
SCRDOWN
|
||||
};
|
||||
|
||||
#define M_UTF8 -1
|
||||
|
||||
#define TAB_WIDTH 8
|
||||
|
||||
#define MIN_COLS 10
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#include <Autolock.h>
|
||||
#include <Beep.h>
|
||||
#include <Message.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
#include "CodeConv.h"
|
||||
#include "TermConst.h"
|
||||
#include "TerminalBuffer.h"
|
||||
#include "VTparse.h"
|
||||
@@ -47,19 +47,17 @@ extern int gMbcsTable[]; /* ESC $ */
|
||||
|
||||
|
||||
//! Get char from pty reader buffer.
|
||||
inline status_t
|
||||
TermParse::_NextParseChar(uchar &c)
|
||||
inline uchar
|
||||
TermParse::_NextParseChar()
|
||||
{
|
||||
if (fParserBufferOffset >= fParserBufferSize) {
|
||||
// parser buffer empty
|
||||
status_t error = _ReadParserBuffer();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
throw error;
|
||||
}
|
||||
|
||||
c = fParserBuffer[fParserBufferOffset++];
|
||||
|
||||
return B_OK;
|
||||
return fParserBuffer[fParserBufferOffset++];
|
||||
}
|
||||
|
||||
|
||||
@@ -95,13 +93,13 @@ TermParse::StartThreads(TerminalBuffer *buffer)
|
||||
fQuitting = false;
|
||||
fBuffer = buffer;
|
||||
|
||||
status_t status = InitPtyReader();
|
||||
status_t status = _InitPtyReader();
|
||||
if (status < B_OK) {
|
||||
fBuffer = NULL;
|
||||
return status;
|
||||
}
|
||||
|
||||
status = InitTermParse();
|
||||
status = _InitTermParse();
|
||||
if (status < B_OK) {
|
||||
StopPtyReader();
|
||||
fBuffer = NULL;
|
||||
@@ -120,8 +118,8 @@ TermParse::StopThreads()
|
||||
|
||||
fQuitting = true;
|
||||
|
||||
StopPtyReader();
|
||||
StopTermParse();
|
||||
_StopPtyReader();
|
||||
_StopTermParse();
|
||||
|
||||
fBuffer = NULL;
|
||||
|
||||
@@ -131,7 +129,7 @@ TermParse::StopThreads()
|
||||
|
||||
//! Initialize and spawn EscParse thread.
|
||||
status_t
|
||||
TermParse::InitTermParse()
|
||||
TermParse::_InitTermParse()
|
||||
{
|
||||
if (fParseThread >= 0)
|
||||
return B_ERROR; // we might want to return B_OK instead ?
|
||||
@@ -139,6 +137,9 @@ TermParse::InitTermParse()
|
||||
fParseThread = spawn_thread(_escparse_thread, "EscParse",
|
||||
B_DISPLAY_PRIORITY, this);
|
||||
|
||||
if (fParseThread < 0)
|
||||
return fParseThread;
|
||||
|
||||
resume_thread(fParseThread);
|
||||
|
||||
return B_OK;
|
||||
@@ -147,7 +148,7 @@ TermParse::InitTermParse()
|
||||
|
||||
//! Initialize and spawn PtyReader thread.
|
||||
status_t
|
||||
TermParse::InitPtyReader()
|
||||
TermParse::_InitPtyReader()
|
||||
{
|
||||
if (fReaderThread >= 0)
|
||||
return B_ERROR; // same as above
|
||||
@@ -180,7 +181,7 @@ TermParse::InitPtyReader()
|
||||
|
||||
|
||||
void
|
||||
TermParse::StopTermParse()
|
||||
TermParse::_StopTermParse()
|
||||
{
|
||||
if (fParseThread >= 0) {
|
||||
status_t dummy;
|
||||
@@ -191,7 +192,7 @@ TermParse::StopTermParse()
|
||||
|
||||
|
||||
void
|
||||
TermParse::StopPtyReader()
|
||||
TermParse::_StopPtyReader()
|
||||
{
|
||||
if (fReaderSem >= 0) {
|
||||
delete_sem(fReaderSem);
|
||||
@@ -287,13 +288,15 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
|
||||
};
|
||||
int i;
|
||||
fprintf(stderr, "groundtable: ");
|
||||
for (i = 0; tables[i].p; i++)
|
||||
for (i = 0; tables[i].p; i++) {
|
||||
if (tables[i].p == groundtable)
|
||||
fprintf(stderr, "%s\t", tables[i].name);
|
||||
}
|
||||
fprintf(stderr, "parsestate: ");
|
||||
for (i = 0; tables[i].p; i++)
|
||||
for (i = 0; tables[i].p; i++) {
|
||||
if (tables[i].p == parsestate)
|
||||
fprintf(stderr, "%s\t", tables[i].name);
|
||||
}
|
||||
fprintf(stderr, "char: 0x%02x (%d)\n", c, c);
|
||||
}
|
||||
|
||||
@@ -301,23 +304,30 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
|
||||
int32
|
||||
TermParse::EscParse()
|
||||
{
|
||||
int top, bot;
|
||||
int top;
|
||||
int bottom;
|
||||
int cs96 = 0;
|
||||
uchar curess = 0;
|
||||
|
||||
char cbuf[4], dstbuf[4];
|
||||
char cbuf[4];
|
||||
char dstbuf[4];
|
||||
char *ptr;
|
||||
|
||||
int now_coding = -1;
|
||||
int currentEncoding = -1;
|
||||
|
||||
int param[NPARAM];
|
||||
int nparam = 1;
|
||||
|
||||
int row, col;
|
||||
int row;
|
||||
int column;
|
||||
|
||||
/* default coding system is UTF8 */
|
||||
/* default encoding system is UTF8 */
|
||||
int *groundtable = gUTF8GroundTable;
|
||||
int *parsestate = groundtable;
|
||||
int *parsestate = gUTF8GroundTable;
|
||||
|
||||
int32 srcLen;
|
||||
int32 dstLen;
|
||||
long dummyState = 0;
|
||||
|
||||
int width = 1;
|
||||
BAutolock locker(fBuffer);
|
||||
@@ -325,13 +335,12 @@ TermParse::EscParse()
|
||||
fAttr = fSavedAttr = BACKCOLOR;
|
||||
|
||||
while (!fQuitting) {
|
||||
uchar c;
|
||||
if (_NextParseChar(c) < B_OK)
|
||||
break;
|
||||
try {
|
||||
uchar c = _NextParseChar();
|
||||
|
||||
//DumpState(groundtable, parsestate, c);
|
||||
|
||||
if (now_coding != fBuffer->Encoding()) {
|
||||
if (currentEncoding != fBuffer->Encoding()) {
|
||||
/*
|
||||
* Change coding, change parse table.
|
||||
*/
|
||||
@@ -364,7 +373,7 @@ TermParse::EscParse()
|
||||
break;
|
||||
}
|
||||
parsestate = groundtable;
|
||||
now_coding = fBuffer->Encoding();
|
||||
currentEncoding = fBuffer->Encoding();
|
||||
}
|
||||
|
||||
//debug_printf("TermParse: char: '%c' (%d), parse state: %d\n", c, c, parsestate[c]);
|
||||
@@ -376,11 +385,11 @@ TermParse::EscParse()
|
||||
case CASE_PRINT_GR:
|
||||
/* case iso8859 gr character, or euc */
|
||||
ptr = cbuf;
|
||||
if (now_coding == B_EUC_CONVERSION
|
||||
|| now_coding == B_EUC_KR_CONVERSION
|
||||
|| now_coding == B_JIS_CONVERSION
|
||||
|| now_coding == B_GBK_CONVERSION
|
||||
|| now_coding == B_BIG5_CONVERSION) {
|
||||
if (currentEncoding == B_EUC_CONVERSION
|
||||
|| currentEncoding == B_EUC_KR_CONVERSION
|
||||
|| currentEncoding == B_JIS_CONVERSION
|
||||
|| currentEncoding == B_GBK_CONVERSION
|
||||
|| currentEncoding == B_BIG5_CONVERSION) {
|
||||
switch (parsestate[curess]) {
|
||||
case CASE_SS2: /* JIS X 0201 */
|
||||
width = 1;
|
||||
@@ -394,7 +403,7 @@ TermParse::EscParse()
|
||||
width = 1;
|
||||
*ptr++ = curess;
|
||||
*ptr++ = c;
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
*ptr++ = c;
|
||||
*ptr = 0;
|
||||
curess = 0;
|
||||
@@ -403,7 +412,7 @@ TermParse::EscParse()
|
||||
default: /* JIS X 0208 */
|
||||
width = 2;
|
||||
*ptr++ = c;
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
*ptr++ = c;
|
||||
*ptr = 0;
|
||||
break;
|
||||
@@ -414,23 +423,28 @@ TermParse::EscParse()
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
if (now_coding != B_JIS_CONVERSION) {
|
||||
CodeConv::ConvertToInternal(cbuf, -1, dstbuf, now_coding);
|
||||
srcLen = strlen(cbuf);
|
||||
if (currentEncoding != B_JIS_CONVERSION) {
|
||||
convert_to_utf8(currentEncoding, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
} else {
|
||||
CodeConv::ConvertToInternal(cbuf, -1, dstbuf,
|
||||
B_EUC_CONVERSION);
|
||||
convert_to_utf8(B_EUC_CONVERSION, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
}
|
||||
|
||||
fBuffer->InsertChar(dstbuf, 4, width, fAttr);
|
||||
fBuffer->InsertChar(dstbuf, dstLen, width, fAttr);
|
||||
break;
|
||||
|
||||
case CASE_PRINT_CS96:
|
||||
cbuf[0] = c | 0x80;
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
cbuf[1] = c | 0x80;
|
||||
cbuf[2] = 0;
|
||||
CodeConv::ConvertToInternal(cbuf, 2, dstbuf, B_EUC_CONVERSION);
|
||||
fBuffer->InsertChar(dstbuf, 4, fAttr);
|
||||
srcLen = 2;
|
||||
dstLen = 0;
|
||||
convert_to_utf8(B_EUC_CONVERSION, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
|
||||
break;
|
||||
|
||||
case CASE_LF:
|
||||
@@ -444,22 +458,28 @@ TermParse::EscParse()
|
||||
case CASE_SJIS_KANA:
|
||||
cbuf[0] = c;
|
||||
cbuf[1] = '\0';
|
||||
CodeConv::ConvertToInternal(cbuf, 1, dstbuf, now_coding);
|
||||
fBuffer->InsertChar(dstbuf, 4, fAttr);
|
||||
srcLen = 1;
|
||||
dstLen = 0;
|
||||
convert_to_utf8(currentEncoding, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
|
||||
break;
|
||||
|
||||
case CASE_SJIS_INSTRING:
|
||||
cbuf[0] = c;
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
cbuf[1] = c;
|
||||
cbuf[2] = '\0';
|
||||
CodeConv::ConvertToInternal(cbuf, 2, dstbuf, now_coding);
|
||||
fBuffer->InsertChar(dstbuf, 4, fAttr);
|
||||
srcLen = 2;
|
||||
dstLen = 0;
|
||||
convert_to_utf8(currentEncoding, cbuf, &srcLen,
|
||||
dstbuf, &dstLen, &dummyState, '?');
|
||||
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
|
||||
break;
|
||||
|
||||
case CASE_UTF8_2BYTE:
|
||||
cbuf[0] = c;
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[1] = c;
|
||||
@@ -470,12 +490,12 @@ TermParse::EscParse()
|
||||
|
||||
case CASE_UTF8_3BYTE:
|
||||
cbuf[0] = c;
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[1] = c;
|
||||
|
||||
_NextParseChar(c);
|
||||
c = _NextParseChar();
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[2] = c;
|
||||
@@ -497,8 +517,8 @@ TermParse::EscParse()
|
||||
case CASE_SCS_STATE:
|
||||
{
|
||||
cs96 = 0;
|
||||
uchar dummy;
|
||||
_NextParseChar(dummy);
|
||||
_NextParseChar();
|
||||
// skip next char
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
}
|
||||
@@ -616,10 +636,10 @@ TermParse::EscParse()
|
||||
/* CUP | HVP */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
if (nparam < 2 || (col = param[1]) < 1)
|
||||
col = 1;
|
||||
if (nparam < 2 || (column = param[1]) < 1)
|
||||
column = 1;
|
||||
|
||||
fBuffer->SetCursor(col - 1, row - 1 );
|
||||
fBuffer->SetCursor(column - 1, row - 1 );
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -780,9 +800,10 @@ TermParse::EscParse()
|
||||
|
||||
case CASE_DA1:
|
||||
// DA - report device attributes
|
||||
if (param[0] < 1)
|
||||
if (param[0] < 1) {
|
||||
// claim to be a VT102
|
||||
write(fFd, "\033[?6c", 5);
|
||||
}
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -793,15 +814,15 @@ TermParse::EscParse()
|
||||
top = 1;
|
||||
|
||||
if (nparam < 2)
|
||||
bot = fBuffer->Height();
|
||||
bottom = fBuffer->Height();
|
||||
else
|
||||
bot = param[1];
|
||||
bottom = param[1];
|
||||
|
||||
top--;
|
||||
bot--;
|
||||
bottom--;
|
||||
|
||||
if (bot > top)
|
||||
fBuffer->SetScrollRegion(top, bot);
|
||||
if (bottom > top)
|
||||
fBuffer->SetScrollRegion(top, bottom);
|
||||
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
@@ -894,24 +915,21 @@ TermParse::EscParse()
|
||||
/* Operating System Command: ESC ] */
|
||||
char string[512];
|
||||
uint32 len = 0;
|
||||
uchar mode_char;
|
||||
_NextParseChar(mode_char);
|
||||
uchar mode_char = _NextParseChar();
|
||||
if (mode_char != '0'
|
||||
&& mode_char != '1'
|
||||
&& mode_char != '2') {
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
}
|
||||
uchar current_char;
|
||||
_NextParseChar(current_char);
|
||||
while (_NextParseChar(current_char) == B_OK
|
||||
&& current_char != 0x7) {
|
||||
if (!isprint(current_char & 0x7f)
|
||||
uchar currentChar = _NextParseChar();
|
||||
while ((currentChar = _NextParseChar()) != 0x7) {
|
||||
if (!isprint(currentChar & 0x7f)
|
||||
|| len+2 >= sizeof(string))
|
||||
break;
|
||||
string[len++] = current_char;
|
||||
string[len++] = currentChar;
|
||||
}
|
||||
if (current_char == 0x7) {
|
||||
if (currentChar == 0x7) {
|
||||
string[len] = '\0';
|
||||
switch (mode_char) {
|
||||
case '0':
|
||||
@@ -971,11 +989,11 @@ TermParse::EscParse()
|
||||
|
||||
case CASE_HPA: // ESC [...G move cursor absolute horizontal
|
||||
/* HPA (CH) */
|
||||
if ((col = param[0]) < 1)
|
||||
col = 1;
|
||||
if ((column = param[0]) < 1)
|
||||
column = 1;
|
||||
|
||||
// note beterm wants it 1-based unlike usual terminals
|
||||
fBuffer->SetCursorX(col - 1);
|
||||
fBuffer->SetCursorX(column - 1);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -995,15 +1013,18 @@ TermParse::EscParse()
|
||||
|
||||
|
||||
case CASE_ECH: // erase characters
|
||||
if ((col = param[0]) < 1)
|
||||
col = 1;
|
||||
fBuffer->EraseChars(col);
|
||||
if ((column = param[0]) < 1)
|
||||
column = 1;
|
||||
fBuffer->EraseChars(column);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (...) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
|
||||
@@ -56,14 +56,14 @@ public:
|
||||
status_t StopThreads();
|
||||
|
||||
private:
|
||||
inline status_t _NextParseChar(uchar &c);
|
||||
inline uchar _NextParseChar();
|
||||
|
||||
// Initialize TermParse and PtyReader thread.
|
||||
status_t InitTermParse();
|
||||
status_t InitPtyReader();
|
||||
status_t _InitTermParse();
|
||||
status_t _InitPtyReader();
|
||||
|
||||
void StopTermParse();
|
||||
void StopPtyReader();
|
||||
void _StopTermParse();
|
||||
void _StopPtyReader();
|
||||
|
||||
int32 EscParse();
|
||||
int32 PtyReader();
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <StringView.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "CodeConv.h"
|
||||
#include "Encoding.h"
|
||||
#include "InlineInput.h"
|
||||
#include "Shell.h"
|
||||
#include "TermConst.h"
|
||||
@@ -343,15 +343,15 @@ TermView::_InitObject(int32 argc, const char** argv)
|
||||
|
||||
SetTermFont(be_fixed_font);
|
||||
|
||||
status_t status = fShell->Open(fRows, fColumns,
|
||||
error = fShell->Open(fRows, fColumns,
|
||||
EncodingAsShortString(fEncoding), argc, argv);
|
||||
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
if (error < B_OK)
|
||||
return error;
|
||||
|
||||
status = _AttachShell(fShell);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
error = _AttachShell(fShell);
|
||||
if (error < B_OK)
|
||||
return error;
|
||||
|
||||
SetLowColor(fTextBackColor);
|
||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
@@ -1243,10 +1243,12 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
if (numBytes > 1) {
|
||||
if (fEncoding != M_UTF8) {
|
||||
char destBuffer[16];
|
||||
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes,
|
||||
(char *)destBuffer, fEncoding);
|
||||
int32 destLen;
|
||||
long state = 0;
|
||||
convert_from_utf8(fEncoding, bytes, &numBytes, destBuffer,
|
||||
&destLen, &state, '?');
|
||||
_ScrollTo(0, true);
|
||||
fShell->Write(destBuffer, cnum);
|
||||
fShell->Write(destBuffer, destLen);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user