Made all CodeConv methods static, since there was no point for them to
be nonstatic. Moved TermParse under Shell, Removed some parameters passing around from TermWindow/TermView/TermParse. Now TermParse threads are started when the shell is attached to a TermView. Might still be improved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21680 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -33,17 +33,8 @@ UTF8
|
|||||||
extern char gUTF8WidthTable[]; // defined in UTF8WidthTbl.c
|
extern char gUTF8WidthTable[]; // defined in UTF8WidthTbl.c
|
||||||
|
|
||||||
|
|
||||||
CodeConv::CodeConv()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CodeConv::~CodeConv()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! get font width in coding.
|
//! get font width in coding.
|
||||||
|
/* static */
|
||||||
int32
|
int32
|
||||||
CodeConv::UTF8GetFontWidth(const char *string)
|
CodeConv::UTF8GetFontWidth(const char *string)
|
||||||
{
|
{
|
||||||
@@ -61,6 +52,7 @@ CodeConv::UTF8GetFontWidth(const char *string)
|
|||||||
|
|
||||||
|
|
||||||
//! Convert internal coding from src coding.
|
//! Convert internal coding from src coding.
|
||||||
|
/* static */
|
||||||
int32
|
int32
|
||||||
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
|
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||||
{
|
{
|
||||||
@@ -92,6 +84,7 @@ CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int codi
|
|||||||
|
|
||||||
|
|
||||||
//! Convert internal coding to src coding.
|
//! Convert internal coding to src coding.
|
||||||
|
/* static */
|
||||||
int32
|
int32
|
||||||
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
|
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
|
||||||
{
|
{
|
||||||
@@ -131,6 +124,7 @@ CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
unsigned short
|
unsigned short
|
||||||
CodeConv::UTF8toUnicode(const char *utf8)
|
CodeConv::UTF8toUnicode(const char *utf8)
|
||||||
{
|
{
|
||||||
@@ -157,6 +151,7 @@ CodeConv::UTF8toUnicode(const char *utf8)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
void
|
void
|
||||||
CodeConv::euc_to_sjis(uchar *buf)
|
CodeConv::euc_to_sjis(uchar *buf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,23 +13,17 @@
|
|||||||
|
|
||||||
class CodeConv {
|
class CodeConv {
|
||||||
public:
|
public:
|
||||||
CodeConv();
|
static int32 UTF8GetFontWidth(const char *string);
|
||||||
~CodeConv();
|
|
||||||
|
|
||||||
int32 UTF8GetFontWidth(const char *string);
|
|
||||||
|
|
||||||
/* internal(UTF8) -> coding */
|
/* internal(UTF8) -> coding */
|
||||||
int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding);
|
static int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding);
|
||||||
|
|
||||||
/* coding -> internal(UTF8) */
|
/* coding -> internal(UTF8) */
|
||||||
int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding);
|
static int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void euc_to_sjis(uchar *buf);
|
static void euc_to_sjis(uchar *buf);
|
||||||
|
static unsigned short UTF8toUnicode(const char *utf8);
|
||||||
unsigned short UTF8toUnicode(const char *utf8);
|
|
||||||
|
|
||||||
int fNowCoding;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CODECONV_H */
|
#endif /* CODECONV_H */
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <new>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -48,6 +49,8 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
|
#include "TermParse.h"
|
||||||
|
#include "TermView.h"
|
||||||
#include "Shell.h"
|
#include "Shell.h"
|
||||||
#include "PrefHandler.h"
|
#include "PrefHandler.h"
|
||||||
|
|
||||||
@@ -108,7 +111,10 @@ static pid_t sShPid;
|
|||||||
|
|
||||||
|
|
||||||
Shell::Shell()
|
Shell::Shell()
|
||||||
:fFd(-1)
|
:
|
||||||
|
fFd(-1),
|
||||||
|
fTermParse(NULL),
|
||||||
|
fAttached(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,13 +131,25 @@ Shell::Open(int row, int col, const char *command, const char *coding)
|
|||||||
if (fFd >= 0)
|
if (fFd >= 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
return _Spawn(row, col, command, coding);
|
status_t status = _Spawn(row, col, command, coding);
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
fTermParse = new (std::nothrow) TermParse(fFd);
|
||||||
|
if (fTermParse == NULL) {
|
||||||
|
Close();
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Shell::Close()
|
Shell::Close()
|
||||||
{
|
{
|
||||||
|
delete fTermParse;
|
||||||
|
|
||||||
if (fFd >= 0) {
|
if (fFd >= 0) {
|
||||||
close(fFd);
|
close(fFd);
|
||||||
kill(-sShPid, SIGHUP);
|
kill(-sShPid, SIGHUP);
|
||||||
@@ -208,6 +226,30 @@ Shell::FD() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Shell::ViewAttached(TermView *view)
|
||||||
|
{
|
||||||
|
if (fAttached)
|
||||||
|
return;
|
||||||
|
|
||||||
|
status_t status = fTermParse->StartThreads(view);
|
||||||
|
if (status < B_OK) {
|
||||||
|
// TODO: What can we do here ?
|
||||||
|
fprintf(stderr, "Shell:ViewAttached():"
|
||||||
|
" cannot start parser threads: %s",
|
||||||
|
strerror(status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Shell::ViewDetached()
|
||||||
|
{
|
||||||
|
if (fAttached)
|
||||||
|
fTermParse->StopThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// private
|
// private
|
||||||
static status_t
|
static status_t
|
||||||
send_handshake_message(thread_id target, const handshake_t& handshake)
|
send_handshake_message(thread_id target, const handshake_t& handshake)
|
||||||
|
|||||||
@@ -81,10 +81,13 @@
|
|||||||
#define RDEL 0xFF
|
#define RDEL 0xFF
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Maybe merge TermParse and Shell classes ?
|
||||||
|
class TermParse;
|
||||||
|
class TermView;
|
||||||
class Shell {
|
class Shell {
|
||||||
public:
|
public:
|
||||||
Shell();
|
Shell();
|
||||||
~Shell();
|
virtual ~Shell();
|
||||||
|
|
||||||
status_t Open(int row, int col, const char *command, const char *coding);
|
status_t Open(int row, int col, const char *command, const char *coding);
|
||||||
void Close();
|
void Close();
|
||||||
@@ -102,8 +105,13 @@ public:
|
|||||||
|
|
||||||
int FD() const;
|
int FD() const;
|
||||||
|
|
||||||
|
virtual void ViewAttached(TermView *view);
|
||||||
|
virtual void ViewDetached();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fFd;
|
int fFd;
|
||||||
|
TermParse *fTermParse;
|
||||||
|
bool fAttached;
|
||||||
|
|
||||||
status_t _Spawn(int row, int col, const char *command, const char *coding);
|
status_t _Spawn(int row, int col, const char *command, const char *coding);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,11 +47,10 @@ extern int mbcstable[]; /* ESC $ */
|
|||||||
#define NPARAM 10 // Max parameters
|
#define NPARAM 10 // Max parameters
|
||||||
|
|
||||||
|
|
||||||
TermParse::TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj)
|
TermParse::TermParse(int fd)
|
||||||
:
|
:
|
||||||
fFd(fd),
|
fFd(fd),
|
||||||
fViewObj(inViewObj),
|
fViewObj(NULL),
|
||||||
fConvObj(inConvObj),
|
|
||||||
fParseThread(-1),
|
fParseThread(-1),
|
||||||
fParseSem(-1),
|
fParseSem(-1),
|
||||||
fReaderThread(-1),
|
fReaderThread(-1),
|
||||||
@@ -66,6 +65,33 @@ TermParse::TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj)
|
|||||||
|
|
||||||
|
|
||||||
TermParse::~TermParse()
|
TermParse::~TermParse()
|
||||||
|
{
|
||||||
|
StopThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TermParse::StartThreads(TermView *view)
|
||||||
|
{
|
||||||
|
fViewObj = view;
|
||||||
|
|
||||||
|
status_t status = InitPtyReader();
|
||||||
|
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
status = InitTermParse();
|
||||||
|
if (status < B_OK) {
|
||||||
|
//AbortPtyReader();
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TermParse::StopThreads()
|
||||||
{
|
{
|
||||||
fQuitting = true;
|
fQuitting = true;
|
||||||
|
|
||||||
@@ -78,22 +104,8 @@ TermParse::~TermParse()
|
|||||||
status_t dummy;
|
status_t dummy;
|
||||||
wait_for_thread(fReaderThread, &dummy);
|
wait_for_thread(fReaderThread, &dummy);
|
||||||
wait_for_thread(fParseThread, &dummy);
|
wait_for_thread(fParseThread, &dummy);
|
||||||
}
|
|
||||||
|
|
||||||
|
fViewObj = NULL;
|
||||||
status_t
|
|
||||||
TermParse::StartThreads()
|
|
||||||
{
|
|
||||||
status_t status = InitPtyReader();
|
|
||||||
|
|
||||||
if (status < B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
status = InitTermParse();
|
|
||||||
if (status < B_OK) {
|
|
||||||
//AbortPtyReader();
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -242,9 +254,6 @@ TermParse::EscParse()
|
|||||||
int cs96;
|
int cs96;
|
||||||
uchar curess = 0;
|
uchar curess = 0;
|
||||||
|
|
||||||
TermView *viewObj = fViewObj;
|
|
||||||
CodeConv *convObj = fConvObj;
|
|
||||||
|
|
||||||
uchar cbuf[4], dstbuf[4];
|
uchar cbuf[4], dstbuf[4];
|
||||||
uchar *ptr;
|
uchar *ptr;
|
||||||
|
|
||||||
@@ -305,7 +314,7 @@ TermParse::EscParse()
|
|||||||
cbuf[0] = c;
|
cbuf[0] = c;
|
||||||
cbuf[1] = '\0';
|
cbuf[1] = '\0';
|
||||||
width = HALF_WIDTH;
|
width = HALF_WIDTH;
|
||||||
viewObj->PutChar(cbuf, attr, width);
|
fViewObj->PutChar(cbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_PRINT_GR:
|
case CASE_PRINT_GR:
|
||||||
@@ -346,11 +355,11 @@ TermParse::EscParse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (now_coding != M_ISO_2022_JP)
|
if (now_coding != M_ISO_2022_JP)
|
||||||
convObj->ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding);
|
CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding);
|
||||||
else
|
else
|
||||||
convObj->ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP);
|
CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, M_EUC_JP);
|
||||||
|
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
fViewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_PRINT_CS96:
|
case CASE_PRINT_CS96:
|
||||||
@@ -359,33 +368,33 @@ TermParse::EscParse()
|
|||||||
cbuf[1] |= 0x80;
|
cbuf[1] |= 0x80;
|
||||||
cbuf[2] = 0;
|
cbuf[2] = 0;
|
||||||
width = 2;
|
width = 2;
|
||||||
convObj->ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP);
|
CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, M_EUC_JP);
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
fViewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_LF:
|
case CASE_LF:
|
||||||
viewObj->PutLF();
|
fViewObj->PutLF();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_CR:
|
case CASE_CR:
|
||||||
viewObj->PutCR();
|
fViewObj->PutCR();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_SJIS_KANA:
|
case CASE_SJIS_KANA:
|
||||||
cbuf[0] = (uchar)c;
|
cbuf[0] = (uchar)c;
|
||||||
cbuf[1] = '\0';
|
cbuf[1] = '\0';
|
||||||
convObj->ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding);
|
CodeConv::ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding);
|
||||||
width = 1;
|
width = 1;
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
fViewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_SJIS_INSTRING:
|
case CASE_SJIS_INSTRING:
|
||||||
cbuf[0] = (uchar)c;
|
cbuf[0] = (uchar)c;
|
||||||
GetReaderBuf(cbuf[1]);
|
GetReaderBuf(cbuf[1]);
|
||||||
cbuf[2] = '\0';
|
cbuf[2] = '\0';
|
||||||
convObj->ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding);
|
CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding);
|
||||||
width = 2;
|
width = 2;
|
||||||
viewObj->PutChar(dstbuf, attr, width);
|
fViewObj->PutChar(dstbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_UTF8_2BYTE:
|
case CASE_UTF8_2BYTE:
|
||||||
@@ -395,8 +404,8 @@ TermParse::EscParse()
|
|||||||
break;
|
break;
|
||||||
cbuf[1] = (uchar)c;
|
cbuf[1] = (uchar)c;
|
||||||
cbuf[2] = '\0';
|
cbuf[2] = '\0';
|
||||||
width = convObj->UTF8GetFontWidth((char*)cbuf);
|
width = CodeConv::UTF8GetFontWidth((char*)cbuf);
|
||||||
viewObj->PutChar(cbuf, attr, width);
|
fViewObj->PutChar(cbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_UTF8_3BYTE:
|
case CASE_UTF8_3BYTE:
|
||||||
@@ -411,8 +420,8 @@ TermParse::EscParse()
|
|||||||
break;
|
break;
|
||||||
cbuf[2] = c;
|
cbuf[2] = c;
|
||||||
cbuf[3] = '\0';
|
cbuf[3] = '\0';
|
||||||
width = convObj->UTF8GetFontWidth((char*)cbuf);
|
width = CodeConv::UTF8GetFontWidth((char*)cbuf);
|
||||||
viewObj->PutChar (cbuf, attr, width);
|
fViewObj->PutChar (cbuf, attr, width);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_MBCS:
|
case CASE_MBCS:
|
||||||
@@ -444,13 +453,13 @@ TermParse::EscParse()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_BS:
|
case CASE_BS:
|
||||||
viewObj->MoveCurLeft(1);
|
fViewObj->MoveCurLeft(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_TAB:
|
case CASE_TAB:
|
||||||
tmp = viewObj->GetCurX();
|
tmp = fViewObj->GetCurX();
|
||||||
tmp %= 8;
|
tmp %= 8;
|
||||||
viewObj->MoveCurRight(8 - tmp);
|
fViewObj->MoveCurRight(8 - tmp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_ESC:
|
case CASE_ESC:
|
||||||
@@ -510,7 +519,7 @@ TermParse::EscParse()
|
|||||||
/* ICH */
|
/* ICH */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->InsertSpace(row);
|
fViewObj->InsertSpace(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -518,7 +527,7 @@ TermParse::EscParse()
|
|||||||
/* CUU */
|
/* CUU */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->MoveCurUp(row);
|
fViewObj->MoveCurUp(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -526,7 +535,7 @@ TermParse::EscParse()
|
|||||||
/* CUD */
|
/* CUD */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->MoveCurDown(row);
|
fViewObj->MoveCurDown(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -534,7 +543,7 @@ TermParse::EscParse()
|
|||||||
/* CUF */
|
/* CUF */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->MoveCurRight(row);
|
fViewObj->MoveCurRight(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -542,7 +551,7 @@ TermParse::EscParse()
|
|||||||
/* CUB */
|
/* CUB */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->MoveCurLeft(row);
|
fViewObj->MoveCurLeft(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -553,7 +562,7 @@ TermParse::EscParse()
|
|||||||
if (nparam < 2 || (col = param[1]) < 1)
|
if (nparam < 2 || (col = param[1]) < 1)
|
||||||
col = 1;
|
col = 1;
|
||||||
|
|
||||||
viewObj->SetCurPos(col - 1, row - 1 );
|
fViewObj->SetCurPos(col - 1, row - 1 );
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -562,15 +571,15 @@ TermParse::EscParse()
|
|||||||
switch (param[0]) {
|
switch (param[0]) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
case 0:
|
case 0:
|
||||||
viewObj->EraseBelow();
|
fViewObj->EraseBelow();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
viewObj->SetCurPos(0, 0);
|
fViewObj->SetCurPos(0, 0);
|
||||||
viewObj->EraseBelow();
|
fViewObj->EraseBelow();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
@@ -578,7 +587,7 @@ TermParse::EscParse()
|
|||||||
|
|
||||||
case CASE_EL: // delete line
|
case CASE_EL: // delete line
|
||||||
/* EL */
|
/* EL */
|
||||||
viewObj->DeleteColumns();
|
fViewObj->DeleteColumns();
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -586,7 +595,7 @@ TermParse::EscParse()
|
|||||||
/* IL */
|
/* IL */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->PutNL(row);
|
fViewObj->PutNL(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -594,7 +603,7 @@ TermParse::EscParse()
|
|||||||
/* DL */
|
/* DL */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->DeleteLine(row);
|
fViewObj->DeleteLine(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -602,19 +611,19 @@ TermParse::EscParse()
|
|||||||
/* DCH */
|
/* DCH */
|
||||||
if ((row = param[0]) < 1)
|
if ((row = param[0]) < 1)
|
||||||
row = 1;
|
row = 1;
|
||||||
viewObj->DeleteChar(row);
|
fViewObj->DeleteChar(row);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_SET:
|
case CASE_SET:
|
||||||
/* SET */
|
/* SET */
|
||||||
viewObj->SetInsertMode(MODE_INSERT);
|
fViewObj->SetInsertMode(MODE_INSERT);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_RST:
|
case CASE_RST:
|
||||||
/* RST */
|
/* RST */
|
||||||
viewObj->SetInsertMode(MODE_OVER);
|
fViewObj->SetInsertMode(MODE_OVER);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -681,7 +690,7 @@ TermParse::EscParse()
|
|||||||
case CASE_CPR:
|
case CASE_CPR:
|
||||||
// Q & D hack by Y.Hayakawa ([email protected])
|
// Q & D hack by Y.Hayakawa ([email protected])
|
||||||
// 21-JUL-99
|
// 21-JUL-99
|
||||||
viewObj->DeviceStatusReport(param[0]);
|
fViewObj->DeviceStatusReport(param[0]);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -700,7 +709,7 @@ TermParse::EscParse()
|
|||||||
bot--;
|
bot--;
|
||||||
|
|
||||||
if (bot > top)
|
if (bot > top)
|
||||||
viewObj->SetScrollRegion(top, bot);
|
fViewObj->SetScrollRegion(top, bot);
|
||||||
|
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
@@ -737,13 +746,13 @@ TermParse::EscParse()
|
|||||||
|
|
||||||
case CASE_DECSC:
|
case CASE_DECSC:
|
||||||
/* DECSC */
|
/* DECSC */
|
||||||
viewObj->SaveCursor();
|
fViewObj->SaveCursor();
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASE_DECRC:
|
case CASE_DECRC:
|
||||||
/* DECRC */
|
/* DECRC */
|
||||||
viewObj->RestoreCursor();
|
fViewObj->RestoreCursor();
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -755,7 +764,7 @@ TermParse::EscParse()
|
|||||||
|
|
||||||
case CASE_RI:
|
case CASE_RI:
|
||||||
/* RI */
|
/* RI */
|
||||||
viewObj->ScrollRegion(-1, -1, SCRDOWN, 1);
|
fViewObj->ScrollRegion(-1, -1, SCRDOWN, 1);
|
||||||
parsestate = groundtable;
|
parsestate = groundtable;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -34,21 +34,20 @@
|
|||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
#include <Handler.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
|
|
||||||
|
|
||||||
class TermView;
|
|
||||||
class CodeConv;
|
|
||||||
|
|
||||||
//PtyReader buffer size.
|
//PtyReader buffer size.
|
||||||
#define READ_BUF_SIZE 2048
|
#define READ_BUF_SIZE 2048
|
||||||
|
|
||||||
|
class TermView;
|
||||||
class TermParse : public BHandler {
|
class TermParse : public BHandler {
|
||||||
public:
|
public:
|
||||||
TermParse(int fd, TermView *inViewObj, CodeConv *inConvObj);
|
TermParse(int fd);
|
||||||
~TermParse();
|
~TermParse();
|
||||||
|
|
||||||
status_t StartThreads();
|
status_t StartThreads(TermView *view);
|
||||||
|
status_t StopThreads();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Initialize TermParse and PtyReader thread.
|
// Initialize TermParse and PtyReader thread.
|
||||||
@@ -71,7 +70,6 @@ private:
|
|||||||
int fFd;
|
int fFd;
|
||||||
|
|
||||||
TermView *fViewObj;
|
TermView *fViewObj;
|
||||||
CodeConv *fConvObj;
|
|
||||||
|
|
||||||
thread_id fParseThread;
|
thread_id fParseThread;
|
||||||
sem_id fParseSem;
|
sem_id fParseSem;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const static rgb_color kTermColorTable[16] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TermView::TermView(BRect frame, CodeConv *inCodeConv)
|
TermView::TermView(BRect frame)
|
||||||
: BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
|
: BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||||
fShell(NULL),
|
fShell(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
@@ -85,7 +85,6 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv)
|
|||||||
fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)),
|
fTermColumns(PrefHandler::Default()->getInt32(PREF_COLS)),
|
||||||
fTop(0),
|
fTop(0),
|
||||||
fTextBuffer(new (nothrow) TermBuffer(fTermRows, fTermColumns)),
|
fTextBuffer(new (nothrow) TermBuffer(fTermRows, fTermColumns)),
|
||||||
fCodeConv(inCodeConv),
|
|
||||||
fScrollBar(NULL),
|
fScrollBar(NULL),
|
||||||
fScrTop(0),
|
fScrTop(0),
|
||||||
fScrBot(fTermRows - 1),
|
fScrBot(fTermRows - 1),
|
||||||
@@ -127,6 +126,7 @@ TermView::AttachShell(Shell *shell)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
fShell = shell;
|
fShell = shell;
|
||||||
|
fShell->ViewAttached(this);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -135,6 +135,7 @@ TermView::AttachShell(Shell *shell)
|
|||||||
void
|
void
|
||||||
TermView::DetachShell()
|
TermView::DetachShell()
|
||||||
{
|
{
|
||||||
|
fShell->ViewDetached();
|
||||||
fShell = NULL;
|
fShell = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,7 +1353,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
// input multibyte character
|
// input multibyte character
|
||||||
|
|
||||||
if (GetEncoding() != M_UTF8) {
|
if (GetEncoding() != M_UTF8) {
|
||||||
int cnum = fCodeConv->ConvertFromInternal(bytes, numBytes,
|
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes,
|
||||||
(char *)dstbuf, GetEncoding());
|
(char *)dstbuf, GetEncoding());
|
||||||
fShell->Write(dstbuf, cnum);
|
fShell->Write(dstbuf, cnum);
|
||||||
return;
|
return;
|
||||||
@@ -1600,7 +1601,7 @@ TermView::WritePTY(const uchar *text, int numBytes)
|
|||||||
{
|
{
|
||||||
if (GetEncoding() != 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 = CodeConv::ConvertFromInternal((char*)text, numBytes,
|
||||||
(char*)destBuffer, GetEncoding());
|
(char*)destBuffer, GetEncoding());
|
||||||
fShell->Write(destBuffer, numBytes);
|
fShell->Write(destBuffer, numBytes);
|
||||||
free(destBuffer);
|
free(destBuffer);
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ const unsigned char M_ADD_CURSOR [] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class TermBuffer;
|
class TermBuffer;
|
||||||
class CodeConv;
|
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BScrollBar;
|
class BScrollBar;
|
||||||
class BString;
|
class BString;
|
||||||
@@ -98,7 +97,7 @@ class Shell;
|
|||||||
|
|
||||||
class TermView : public BView {
|
class TermView : public BView {
|
||||||
public:
|
public:
|
||||||
TermView(BRect frame, CodeConv *inCodeConv);
|
TermView(BRect frame);
|
||||||
~TermView();
|
~TermView();
|
||||||
|
|
||||||
status_t AttachShell(Shell *shell);
|
status_t AttachShell(Shell *shell);
|
||||||
@@ -282,7 +281,6 @@ class TermView : public BView {
|
|||||||
// Object pointer.
|
// Object pointer.
|
||||||
|
|
||||||
TermBuffer *fTextBuffer;
|
TermBuffer *fTextBuffer;
|
||||||
CodeConv *fCodeConv;
|
|
||||||
BScrollBar *fScrollBar;
|
BScrollBar *fScrollBar;
|
||||||
|
|
||||||
// Offscreen Bitmap and View.
|
// Offscreen Bitmap and View.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "CodeConv.h"
|
#include "Coding.h"
|
||||||
#include "ColorWindow.h"
|
#include "ColorWindow.h"
|
||||||
#include "MenuUtil.h"
|
#include "MenuUtil.h"
|
||||||
#include "FindWindow.h"
|
#include "FindWindow.h"
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
||||||
: 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),
|
||||||
fShell(NULL),
|
fShell(NULL),
|
||||||
fTermParse(NULL),
|
|
||||||
fMenubar(NULL),
|
fMenubar(NULL),
|
||||||
fFilemenu(NULL),
|
fFilemenu(NULL),
|
||||||
fEditmenu(NULL),
|
fEditmenu(NULL),
|
||||||
@@ -64,7 +63,6 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
|||||||
fWindowSizeMenu(NULL),
|
fWindowSizeMenu(NULL),
|
||||||
fNewFontMenu(NULL),
|
fNewFontMenu(NULL),
|
||||||
fTermView(NULL),
|
fTermView(NULL),
|
||||||
fCodeConv(NULL),
|
|
||||||
fPrintSettings(NULL),
|
fPrintSettings(NULL),
|
||||||
fPrefWindow(NULL),
|
fPrefWindow(NULL),
|
||||||
fFindPanel(NULL),
|
fFindPanel(NULL),
|
||||||
@@ -106,8 +104,6 @@ TermWindow::~TermWindow()
|
|||||||
fTermView->DetachShell();
|
fTermView->DetachShell();
|
||||||
|
|
||||||
delete fShell;
|
delete fShell;
|
||||||
delete fTermParse;
|
|
||||||
delete fCodeConv;
|
|
||||||
if (fPrefWindow)
|
if (fPrefWindow)
|
||||||
fPrefWindow->PostMessage(B_QUIT_REQUESTED);
|
fPrefWindow->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
|
||||||
@@ -159,13 +155,11 @@ TermWindow::InitWindow()
|
|||||||
BRect textframe = Bounds();
|
BRect textframe = Bounds();
|
||||||
textframe.top = fMenubar->Bounds().bottom + 1.0;
|
textframe.top = fMenubar->Bounds().bottom + 1.0;
|
||||||
|
|
||||||
fCodeConv = new CodeConv();
|
fTermView = new TermView(textframe);
|
||||||
fTermView = new TermView(textframe, fCodeConv);
|
|
||||||
|
|
||||||
fTermView->AttachShell(fShell);
|
fTermView->AttachShell(fShell);
|
||||||
|
|
||||||
// Initialize TermView. (font, size and color)
|
// Initialize TermView. (font, size and color)
|
||||||
|
|
||||||
fTermView->SetTermFont(&halfFont, &fullFont);
|
fTermView->SetTermFont(&halfFont, &fullFont);
|
||||||
|
|
||||||
BRect rect = fTermView->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS),
|
BRect rect = fTermView->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS),
|
||||||
@@ -205,9 +199,6 @@ TermWindow::InitWindow()
|
|||||||
|
|
||||||
// Initialize TermParse
|
// Initialize TermParse
|
||||||
SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)));
|
SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)));
|
||||||
fTermParse = new TermParse(fShell->FD(), fTermView, fCodeConv);
|
|
||||||
if (fTermParse->StartThreads() < B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Initialize MessageRunner.
|
// Initialize MessageRunner.
|
||||||
fWindowUpdate = new BMessageRunner(BMessenger(this),
|
fWindowUpdate = new BMessageRunner(BMessenger(this),
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
class BMenu;
|
class BMenu;
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
class BMessageRunner;
|
class BMessageRunner;
|
||||||
class CodeConv;
|
|
||||||
class FindWindow;
|
class FindWindow;
|
||||||
class PrefWindow;
|
class PrefWindow;
|
||||||
class Shell;
|
class Shell;
|
||||||
@@ -79,7 +78,6 @@ private:
|
|||||||
*fWindowSizeMenu,
|
*fWindowSizeMenu,
|
||||||
*fNewFontMenu;
|
*fNewFontMenu;
|
||||||
TermView *fTermView;
|
TermView *fTermView;
|
||||||
CodeConv *fCodeConv;
|
|
||||||
BMessage *fPrintSettings;
|
BMessage *fPrintSettings;
|
||||||
PrefWindow *fPrefWindow;
|
PrefWindow *fPrefWindow;
|
||||||
FindWindow *fFindPanel;
|
FindWindow *fFindPanel;
|
||||||
|
|||||||
Reference in New Issue
Block a user