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:
Stefano Ceccherini
2010-01-04 18:37:37 +00:00
parent 9f7a3e3406
commit 74d2e1599a
12 changed files with 691 additions and 9119 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ Arguments::Arguments()
fShellArguments(NULL), fShellArguments(NULL),
fTitle(NULL) fTitle(NULL)
{ {
const char *argv[] = { "/bin/sh", "--login" }; const char *argv[] = { "/bin/bash", "--login" };
_SetShellArguments(2, argv); _SetShellArguments(2, argv);
} }
@@ -13,7 +13,6 @@
#include <String.h> #include <String.h>
#include "CodeConv.h"
#include "TermConst.h" #include "TermConst.h"
#include "TerminalCharClassifier.h" #include "TerminalCharClassifier.h"
#include "TerminalLine.h" #include "TerminalLine.h"
@@ -550,8 +549,6 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
{ {
//debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n", //debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n",
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes); //(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) if ((int32)width == FULL_WIDTH)
attributes |= A_WIDTH; attributes |= A_WIDTH;
@@ -589,8 +586,6 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
void void
BasicTerminalBuffer::FillScreen(UTF8Char c, uint32 width, uint32 attributes) 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) if ((int32)width == FULL_WIDTH)
attributes |= A_WIDTH; attributes |= A_WIDTH;
-181
View File
@@ -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;
}
-31
View File
@@ -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 */
+1
View File
@@ -4,6 +4,7 @@
*/ */
#include "Encoding.h" #include "Encoding.h"
#include "TermConst.h"
#include <string.h> #include <string.h>
-1
View File
@@ -35,7 +35,6 @@
#include <SupportDefs.h> #include <SupportDefs.h>
#include <UTF8.h> #include <UTF8.h>
#define M_UTF8 (-1)
status_t get_next_encoding(int i, int *id); status_t get_next_encoding(int i, int *id);
-2
View File
@@ -8,7 +8,6 @@ Application Terminal :
AppearPrefView.cpp AppearPrefView.cpp
Arguments.cpp Arguments.cpp
BasicTerminalBuffer.cpp BasicTerminalBuffer.cpp
CodeConv.cpp
Encoding.cpp Encoding.cpp
FindWindow.cpp FindWindow.cpp
Globals.cpp Globals.cpp
@@ -25,7 +24,6 @@ Application Terminal :
TermScrollView.cpp TermScrollView.cpp
TermView.cpp TermView.cpp
TermWindow.cpp TermWindow.cpp
UTF8WidthTbl.c
VTKeyTbl.c VTKeyTbl.c
VTPrsTbl.c VTPrsTbl.c
: be tracker textencoding $(TARGET_LIBSUPC++) : be tracker textencoding $(TARGET_LIBSUPC++)
+2
View File
@@ -152,6 +152,8 @@ enum{
SCRDOWN SCRDOWN
}; };
#define M_UTF8 -1
#define TAB_WIDTH 8 #define TAB_WIDTH 8
#define MIN_COLS 10 #define MIN_COLS 10
+98 -77
View File
@@ -19,8 +19,8 @@
#include <Autolock.h> #include <Autolock.h>
#include <Beep.h> #include <Beep.h>
#include <Message.h> #include <Message.h>
#include <UTF8.h>
#include "CodeConv.h"
#include "TermConst.h" #include "TermConst.h"
#include "TerminalBuffer.h" #include "TerminalBuffer.h"
#include "VTparse.h" #include "VTparse.h"
@@ -47,19 +47,17 @@ extern int gMbcsTable[]; /* ESC $ */
//! Get char from pty reader buffer. //! Get char from pty reader buffer.
inline status_t inline uchar
TermParse::_NextParseChar(uchar &c) TermParse::_NextParseChar()
{ {
if (fParserBufferOffset >= fParserBufferSize) { if (fParserBufferOffset >= fParserBufferSize) {
// parser buffer empty // parser buffer empty
status_t error = _ReadParserBuffer(); status_t error = _ReadParserBuffer();
if (error != B_OK) if (error != B_OK)
return error; throw error;
} }
c = fParserBuffer[fParserBufferOffset++]; return fParserBuffer[fParserBufferOffset++];
return B_OK;
} }
@@ -95,13 +93,13 @@ TermParse::StartThreads(TerminalBuffer *buffer)
fQuitting = false; fQuitting = false;
fBuffer = buffer; fBuffer = buffer;
status_t status = InitPtyReader(); status_t status = _InitPtyReader();
if (status < B_OK) { if (status < B_OK) {
fBuffer = NULL; fBuffer = NULL;
return status; return status;
} }
status = InitTermParse(); status = _InitTermParse();
if (status < B_OK) { if (status < B_OK) {
StopPtyReader(); StopPtyReader();
fBuffer = NULL; fBuffer = NULL;
@@ -120,8 +118,8 @@ TermParse::StopThreads()
fQuitting = true; fQuitting = true;
StopPtyReader(); _StopPtyReader();
StopTermParse(); _StopTermParse();
fBuffer = NULL; fBuffer = NULL;
@@ -131,7 +129,7 @@ TermParse::StopThreads()
//! Initialize and spawn EscParse thread. //! Initialize and spawn EscParse thread.
status_t status_t
TermParse::InitTermParse() TermParse::_InitTermParse()
{ {
if (fParseThread >= 0) if (fParseThread >= 0)
return B_ERROR; // we might want to return B_OK instead ? return B_ERROR; // we might want to return B_OK instead ?
@@ -139,6 +137,9 @@ TermParse::InitTermParse()
fParseThread = spawn_thread(_escparse_thread, "EscParse", fParseThread = spawn_thread(_escparse_thread, "EscParse",
B_DISPLAY_PRIORITY, this); B_DISPLAY_PRIORITY, this);
if (fParseThread < 0)
return fParseThread;
resume_thread(fParseThread); resume_thread(fParseThread);
return B_OK; return B_OK;
@@ -147,7 +148,7 @@ TermParse::InitTermParse()
//! Initialize and spawn PtyReader thread. //! Initialize and spawn PtyReader thread.
status_t status_t
TermParse::InitPtyReader() TermParse::_InitPtyReader()
{ {
if (fReaderThread >= 0) if (fReaderThread >= 0)
return B_ERROR; // same as above return B_ERROR; // same as above
@@ -180,7 +181,7 @@ TermParse::InitPtyReader()
void void
TermParse::StopTermParse() TermParse::_StopTermParse()
{ {
if (fParseThread >= 0) { if (fParseThread >= 0) {
status_t dummy; status_t dummy;
@@ -191,7 +192,7 @@ TermParse::StopTermParse()
void void
TermParse::StopPtyReader() TermParse::_StopPtyReader()
{ {
if (fReaderSem >= 0) { if (fReaderSem >= 0) {
delete_sem(fReaderSem); delete_sem(fReaderSem);
@@ -287,13 +288,15 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
}; };
int i; int i;
fprintf(stderr, "groundtable: "); fprintf(stderr, "groundtable: ");
for (i = 0; tables[i].p; i++) for (i = 0; tables[i].p; i++) {
if (tables[i].p == groundtable) if (tables[i].p == groundtable)
fprintf(stderr, "%s\t", tables[i].name); fprintf(stderr, "%s\t", tables[i].name);
}
fprintf(stderr, "parsestate: "); fprintf(stderr, "parsestate: ");
for (i = 0; tables[i].p; i++) for (i = 0; tables[i].p; i++) {
if (tables[i].p == parsestate) if (tables[i].p == parsestate)
fprintf(stderr, "%s\t", tables[i].name); fprintf(stderr, "%s\t", tables[i].name);
}
fprintf(stderr, "char: 0x%02x (%d)\n", c, c); fprintf(stderr, "char: 0x%02x (%d)\n", c, c);
} }
@@ -301,23 +304,30 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
int32 int32
TermParse::EscParse() TermParse::EscParse()
{ {
int top, bot; int top;
int bottom;
int cs96 = 0; int cs96 = 0;
uchar curess = 0; uchar curess = 0;
char cbuf[4], dstbuf[4]; char cbuf[4];
char dstbuf[4];
char *ptr; char *ptr;
int now_coding = -1; int currentEncoding = -1;
int param[NPARAM]; int param[NPARAM];
int nparam = 1; int nparam = 1;
int row, col; int row;
int column;
/* default coding system is UTF8 */ /* default encoding system is UTF8 */
int *groundtable = gUTF8GroundTable; int *groundtable = gUTF8GroundTable;
int *parsestate = groundtable; int *parsestate = gUTF8GroundTable;
int32 srcLen;
int32 dstLen;
long dummyState = 0;
int width = 1; int width = 1;
BAutolock locker(fBuffer); BAutolock locker(fBuffer);
@@ -325,13 +335,12 @@ TermParse::EscParse()
fAttr = fSavedAttr = BACKCOLOR; fAttr = fSavedAttr = BACKCOLOR;
while (!fQuitting) { while (!fQuitting) {
uchar c; try {
if (_NextParseChar(c) < B_OK) uchar c = _NextParseChar();
break;
//DumpState(groundtable, parsestate, c); //DumpState(groundtable, parsestate, c);
if (now_coding != fBuffer->Encoding()) { if (currentEncoding != fBuffer->Encoding()) {
/* /*
* Change coding, change parse table. * Change coding, change parse table.
*/ */
@@ -364,7 +373,7 @@ TermParse::EscParse()
break; break;
} }
parsestate = groundtable; parsestate = groundtable;
now_coding = fBuffer->Encoding(); currentEncoding = fBuffer->Encoding();
} }
//debug_printf("TermParse: char: '%c' (%d), parse state: %d\n", c, c, parsestate[c]); //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 CASE_PRINT_GR:
/* case iso8859 gr character, or euc */ /* case iso8859 gr character, or euc */
ptr = cbuf; ptr = cbuf;
if (now_coding == B_EUC_CONVERSION if (currentEncoding == B_EUC_CONVERSION
|| now_coding == B_EUC_KR_CONVERSION || currentEncoding == B_EUC_KR_CONVERSION
|| now_coding == B_JIS_CONVERSION || currentEncoding == B_JIS_CONVERSION
|| now_coding == B_GBK_CONVERSION || currentEncoding == B_GBK_CONVERSION
|| now_coding == B_BIG5_CONVERSION) { || currentEncoding == B_BIG5_CONVERSION) {
switch (parsestate[curess]) { switch (parsestate[curess]) {
case CASE_SS2: /* JIS X 0201 */ case CASE_SS2: /* JIS X 0201 */
width = 1; width = 1;
@@ -394,7 +403,7 @@ TermParse::EscParse()
width = 1; width = 1;
*ptr++ = curess; *ptr++ = curess;
*ptr++ = c; *ptr++ = c;
_NextParseChar(c); c = _NextParseChar();
*ptr++ = c; *ptr++ = c;
*ptr = 0; *ptr = 0;
curess = 0; curess = 0;
@@ -403,7 +412,7 @@ TermParse::EscParse()
default: /* JIS X 0208 */ default: /* JIS X 0208 */
width = 2; width = 2;
*ptr++ = c; *ptr++ = c;
_NextParseChar(c); c = _NextParseChar();
*ptr++ = c; *ptr++ = c;
*ptr = 0; *ptr = 0;
break; break;
@@ -414,23 +423,28 @@ TermParse::EscParse()
*ptr = 0; *ptr = 0;
} }
if (now_coding != B_JIS_CONVERSION) { srcLen = strlen(cbuf);
CodeConv::ConvertToInternal(cbuf, -1, dstbuf, now_coding); if (currentEncoding != B_JIS_CONVERSION) {
convert_to_utf8(currentEncoding, cbuf, &srcLen,
dstbuf, &dstLen, &dummyState, '?');
} else { } else {
CodeConv::ConvertToInternal(cbuf, -1, dstbuf, convert_to_utf8(B_EUC_CONVERSION, cbuf, &srcLen,
B_EUC_CONVERSION); dstbuf, &dstLen, &dummyState, '?');
} }
fBuffer->InsertChar(dstbuf, 4, width, fAttr); fBuffer->InsertChar(dstbuf, dstLen, width, fAttr);
break; break;
case CASE_PRINT_CS96: case CASE_PRINT_CS96:
cbuf[0] = c | 0x80; cbuf[0] = c | 0x80;
_NextParseChar(c); c = _NextParseChar();
cbuf[1] = c | 0x80; cbuf[1] = c | 0x80;
cbuf[2] = 0; cbuf[2] = 0;
CodeConv::ConvertToInternal(cbuf, 2, dstbuf, B_EUC_CONVERSION); srcLen = 2;
fBuffer->InsertChar(dstbuf, 4, fAttr); dstLen = 0;
convert_to_utf8(B_EUC_CONVERSION, cbuf, &srcLen,
dstbuf, &dstLen, &dummyState, '?');
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
break; break;
case CASE_LF: case CASE_LF:
@@ -444,22 +458,28 @@ TermParse::EscParse()
case CASE_SJIS_KANA: case CASE_SJIS_KANA:
cbuf[0] = c; cbuf[0] = c;
cbuf[1] = '\0'; cbuf[1] = '\0';
CodeConv::ConvertToInternal(cbuf, 1, dstbuf, now_coding); srcLen = 1;
fBuffer->InsertChar(dstbuf, 4, fAttr); dstLen = 0;
convert_to_utf8(currentEncoding, cbuf, &srcLen,
dstbuf, &dstLen, &dummyState, '?');
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
break; break;
case CASE_SJIS_INSTRING: case CASE_SJIS_INSTRING:
cbuf[0] = c; cbuf[0] = c;
_NextParseChar(c); c = _NextParseChar();
cbuf[1] = c; cbuf[1] = c;
cbuf[2] = '\0'; cbuf[2] = '\0';
CodeConv::ConvertToInternal(cbuf, 2, dstbuf, now_coding); srcLen = 2;
fBuffer->InsertChar(dstbuf, 4, fAttr); dstLen = 0;
convert_to_utf8(currentEncoding, cbuf, &srcLen,
dstbuf, &dstLen, &dummyState, '?');
fBuffer->InsertChar(dstbuf, dstLen, fAttr);
break; break;
case CASE_UTF8_2BYTE: case CASE_UTF8_2BYTE:
cbuf[0] = c; cbuf[0] = c;
_NextParseChar(c); c = _NextParseChar();
if (groundtable[c] != CASE_UTF8_INSTRING) if (groundtable[c] != CASE_UTF8_INSTRING)
break; break;
cbuf[1] = c; cbuf[1] = c;
@@ -470,12 +490,12 @@ TermParse::EscParse()
case CASE_UTF8_3BYTE: case CASE_UTF8_3BYTE:
cbuf[0] = c; cbuf[0] = c;
_NextParseChar(c); c = _NextParseChar();
if (groundtable[c] != CASE_UTF8_INSTRING) if (groundtable[c] != CASE_UTF8_INSTRING)
break; break;
cbuf[1] = c; cbuf[1] = c;
_NextParseChar(c); c = _NextParseChar();
if (groundtable[c] != CASE_UTF8_INSTRING) if (groundtable[c] != CASE_UTF8_INSTRING)
break; break;
cbuf[2] = c; cbuf[2] = c;
@@ -497,8 +517,8 @@ TermParse::EscParse()
case CASE_SCS_STATE: case CASE_SCS_STATE:
{ {
cs96 = 0; cs96 = 0;
uchar dummy; _NextParseChar();
_NextParseChar(dummy); // skip next char
parsestate = groundtable; parsestate = groundtable;
break; break;
} }
@@ -616,10 +636,10 @@ TermParse::EscParse()
/* CUP | HVP */ /* CUP | HVP */
if ((row = param[0]) < 1) if ((row = param[0]) < 1)
row = 1; row = 1;
if (nparam < 2 || (col = param[1]) < 1) if (nparam < 2 || (column = param[1]) < 1)
col = 1; column = 1;
fBuffer->SetCursor(col - 1, row - 1 ); fBuffer->SetCursor(column - 1, row - 1 );
parsestate = groundtable; parsestate = groundtable;
break; break;
@@ -780,9 +800,10 @@ TermParse::EscParse()
case CASE_DA1: case CASE_DA1:
// DA - report device attributes // DA - report device attributes
if (param[0] < 1) if (param[0] < 1) {
// claim to be a VT102 // claim to be a VT102
write(fFd, "\033[?6c", 5); write(fFd, "\033[?6c", 5);
}
parsestate = groundtable; parsestate = groundtable;
break; break;
@@ -793,15 +814,15 @@ TermParse::EscParse()
top = 1; top = 1;
if (nparam < 2) if (nparam < 2)
bot = fBuffer->Height(); bottom = fBuffer->Height();
else else
bot = param[1]; bottom = param[1];
top--; top--;
bot--; bottom--;
if (bot > top) if (bottom > top)
fBuffer->SetScrollRegion(top, bot); fBuffer->SetScrollRegion(top, bottom);
parsestate = groundtable; parsestate = groundtable;
break; break;
@@ -894,24 +915,21 @@ TermParse::EscParse()
/* Operating System Command: ESC ] */ /* Operating System Command: ESC ] */
char string[512]; char string[512];
uint32 len = 0; uint32 len = 0;
uchar mode_char; uchar mode_char = _NextParseChar();
_NextParseChar(mode_char);
if (mode_char != '0' if (mode_char != '0'
&& mode_char != '1' && mode_char != '1'
&& mode_char != '2') { && mode_char != '2') {
parsestate = groundtable; parsestate = groundtable;
break; break;
} }
uchar current_char; uchar currentChar = _NextParseChar();
_NextParseChar(current_char); while ((currentChar = _NextParseChar()) != 0x7) {
while (_NextParseChar(current_char) == B_OK if (!isprint(currentChar & 0x7f)
&& current_char != 0x7) {
if (!isprint(current_char & 0x7f)
|| len+2 >= sizeof(string)) || len+2 >= sizeof(string))
break; break;
string[len++] = current_char; string[len++] = currentChar;
} }
if (current_char == 0x7) { if (currentChar == 0x7) {
string[len] = '\0'; string[len] = '\0';
switch (mode_char) { switch (mode_char) {
case '0': case '0':
@@ -971,11 +989,11 @@ TermParse::EscParse()
case CASE_HPA: // ESC [...G move cursor absolute horizontal case CASE_HPA: // ESC [...G move cursor absolute horizontal
/* HPA (CH) */ /* HPA (CH) */
if ((col = param[0]) < 1) if ((column = param[0]) < 1)
col = 1; column = 1;
// note beterm wants it 1-based unlike usual terminals // note beterm wants it 1-based unlike usual terminals
fBuffer->SetCursorX(col - 1); fBuffer->SetCursorX(column - 1);
parsestate = groundtable; parsestate = groundtable;
break; break;
@@ -995,15 +1013,18 @@ TermParse::EscParse()
case CASE_ECH: // erase characters case CASE_ECH: // erase characters
if ((col = param[0]) < 1) if ((column = param[0]) < 1)
col = 1; column = 1;
fBuffer->EraseChars(col); fBuffer->EraseChars(column);
parsestate = groundtable; parsestate = groundtable;
break; break;
default: default:
break; break;
} }
} catch (...) {
break;
}
} }
return B_OK; return B_OK;
+5 -5
View File
@@ -56,14 +56,14 @@ public:
status_t StopThreads(); status_t StopThreads();
private: private:
inline status_t _NextParseChar(uchar &c); inline uchar _NextParseChar();
// Initialize TermParse and PtyReader thread. // Initialize TermParse and PtyReader thread.
status_t InitTermParse(); status_t _InitTermParse();
status_t InitPtyReader(); status_t _InitPtyReader();
void StopTermParse(); void _StopTermParse();
void StopPtyReader(); void _StopPtyReader();
int32 EscParse(); int32 EscParse();
int32 PtyReader(); int32 PtyReader();
+12 -10
View File
@@ -48,7 +48,7 @@
#include <StringView.h> #include <StringView.h>
#include <Window.h> #include <Window.h>
#include "CodeConv.h" #include "Encoding.h"
#include "InlineInput.h" #include "InlineInput.h"
#include "Shell.h" #include "Shell.h"
#include "TermConst.h" #include "TermConst.h"
@@ -343,15 +343,15 @@ TermView::_InitObject(int32 argc, const char** argv)
SetTermFont(be_fixed_font); SetTermFont(be_fixed_font);
status_t status = fShell->Open(fRows, fColumns, error = fShell->Open(fRows, fColumns,
EncodingAsShortString(fEncoding), argc, argv); EncodingAsShortString(fEncoding), argc, argv);
if (status < B_OK) if (error < B_OK)
return status; return error;
status = _AttachShell(fShell); error = _AttachShell(fShell);
if (status < B_OK) if (error < B_OK)
return status; return error;
SetLowColor(fTextBackColor); SetLowColor(fTextBackColor);
SetViewColor(B_TRANSPARENT_32_BIT); SetViewColor(B_TRANSPARENT_32_BIT);
@@ -1243,10 +1243,12 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
if (numBytes > 1) { if (numBytes > 1) {
if (fEncoding != M_UTF8) { if (fEncoding != M_UTF8) {
char destBuffer[16]; char destBuffer[16];
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes, int32 destLen;
(char *)destBuffer, fEncoding); long state = 0;
convert_from_utf8(fEncoding, bytes, &numBytes, destBuffer,
&destLen, &state, '?');
_ScrollTo(0, true); _ScrollTo(0, true);
fShell->Write(destBuffer, cnum); fShell->Write(destBuffer, destLen);
return; return;
} }
File diff suppressed because it is too large Load Diff