Don't use exceptions in TermView constructor, as it would cause problems
with instantiation. Note that if an error occurs in the constructor, we're pretty much screwed. Made some TermView functions private. Some small cleanup, and some WIP code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21742 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,4 +32,39 @@ SmartTabView::Select(int32 index)
|
||||
view->ResizeTo(Bounds().Width(), Bounds().Height());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
SmartTabView::AddTab(BView *target, BTab *tab)
|
||||
{
|
||||
if (target == NULL)
|
||||
return;
|
||||
|
||||
if (CountTabs() == 1) {
|
||||
|
||||
}
|
||||
AddTab(target, tab);
|
||||
}
|
||||
|
||||
|
||||
BTab *
|
||||
SmartTabView::RemoveTab(int32 index)
|
||||
{
|
||||
BTab *oldTab = RemoveTab(index);
|
||||
if (CountTabs() == 1) {
|
||||
|
||||
}
|
||||
return oldTab;
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
SmartTabView::DrawTabs()
|
||||
{
|
||||
//if (CountTabs() > 1)
|
||||
return BTabView::DrawTabs();
|
||||
//return BRect(0, 0, -1, -1);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ public:
|
||||
B_WILL_DRAW | B_NAVIGABLE_JUMP |
|
||||
B_FRAME_EVENTS | B_NAVIGABLE);
|
||||
virtual ~SmartTabView();
|
||||
virtual void Select(int32 tab);
|
||||
virtual void Select(int32 tab);
|
||||
/*
|
||||
virtual void AddTab(BView *target, BTab *tab = NULL);
|
||||
virtual BTab* RemoveTab(int32 index);
|
||||
virtual BRect DrawTabs();*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ TermParse::EscParse()
|
||||
cbuf[2] = c;
|
||||
cbuf[3] = '\0';
|
||||
width = CodeConv::UTF8GetFontWidth((char*)cbuf);
|
||||
fView->PutChar (cbuf, attr, width);
|
||||
fView->PutChar(cbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_MBCS:
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
|
||||
#include <new>
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
// defined VTKeyTbl.c
|
||||
extern int function_keycode_table[];
|
||||
extern char *function_key_char_table[];
|
||||
@@ -209,6 +207,7 @@ TermView::TermView(BMessage *archive)
|
||||
fQuitting(false),
|
||||
fIMflag(false)
|
||||
{
|
||||
printf("TermView(BMessage *)\n");
|
||||
if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK)
|
||||
fEncoding = M_UTF8;
|
||||
if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK)
|
||||
@@ -217,32 +216,38 @@ TermView::TermView(BMessage *archive)
|
||||
fTermRows = 25;
|
||||
|
||||
// TODO: Retrieve command, colors, history size, etc. from archive
|
||||
_InitObject(NULL);
|
||||
printf("_InitObject() returned %s\n", strerror(_InitObject(NULL)));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
status_t
|
||||
TermView::_InitObject(const char *command)
|
||||
{
|
||||
fTextBuffer = new TermBuffer(fTermRows, fTermColumns, fScrBufSize);
|
||||
|
||||
SetTermFont(be_fixed_font, be_fixed_font);
|
||||
|
||||
//SetIMAware(false);
|
||||
|
||||
fShell = new Shell();
|
||||
fTextBuffer = new (std::nothrow) TermBuffer(fTermRows, fTermColumns, fScrBufSize);
|
||||
if (fTextBuffer == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
fShell = new (std::nothrow) Shell();
|
||||
if (fShell == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
status_t status = fShell->Open(fTermRows, fTermColumns,
|
||||
command, longname2shortname(id2longname(fEncoding)));
|
||||
if (status < B_OK)
|
||||
throw status;
|
||||
return status;
|
||||
|
||||
status = AttachShell(fShell);
|
||||
if (status < B_OK)
|
||||
throw status;
|
||||
return status;
|
||||
|
||||
SetTermSize(fTermRows, fTermColumns, false);
|
||||
//SetIMAware(false);
|
||||
|
||||
_InitMouseThread();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,8 +267,11 @@ TermView::~TermView()
|
||||
BArchivable *
|
||||
TermView::Instantiate(BMessage* data)
|
||||
{
|
||||
printf("TermView::Instantiate()\n");
|
||||
if (validate_instantiation(data, "TermView"))
|
||||
return new TermView(data);
|
||||
return new (std::nothrow) TermView(data);
|
||||
|
||||
printf("Returned NULL\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -271,17 +279,15 @@ TermView::Instantiate(BMessage* data)
|
||||
status_t
|
||||
TermView::Archive(BMessage* data, bool deep) const
|
||||
{
|
||||
printf("TermView::Archive()\n");
|
||||
status_t status = BView::Archive(data, deep);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
status = data->AddInt32("encoding", (int32)fEncoding);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
status = data->AddInt32("columns", (int32)fTermColumns);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
status = data->AddInt32("rows", (int32)fTermRows);
|
||||
|
||||
if (status == B_OK)
|
||||
status = data->AddInt32("encoding", (int32)fEncoding);
|
||||
if (status == B_OK)
|
||||
status = data->AddInt32("columns", (int32)fTermColumns);
|
||||
if (status == B_OK)
|
||||
status = data->AddInt32("rows", (int32)fTermRows);
|
||||
printf("Archive() returned %s\n", strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1438,7 +1444,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
if (fIMflag)
|
||||
return;
|
||||
|
||||
// If bytes[0] equal intr charactor,
|
||||
// If bytes[0] equal intr character,
|
||||
// send signal to shell process group.
|
||||
struct termios tio;
|
||||
fShell->GetAttr(tio);
|
||||
@@ -1448,9 +1454,8 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
}
|
||||
|
||||
// Terminal changes RET, ENTER, F1...F12, and ARROW key code.
|
||||
|
||||
if (numBytes == 1) {
|
||||
switch (*bytes) {
|
||||
switch (bytes[0]) {
|
||||
case B_RETURN:
|
||||
{
|
||||
char c = 0x0d;
|
||||
@@ -1537,10 +1542,11 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
} else {
|
||||
// input multibyte character
|
||||
if (fEncoding != M_UTF8) {
|
||||
uchar dstbuf[1024];
|
||||
uchar destBuffer[1024];
|
||||
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes,
|
||||
(char *)dstbuf, fEncoding);
|
||||
fShell->Write(dstbuf, cnum);
|
||||
(char *)destBuffer, fEncoding);
|
||||
fShell->Write(destBuffer, cnum);
|
||||
destBuffer[cnum] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,7 @@ public:
|
||||
void PutNL(int num);
|
||||
void SetInsertMode(int flag);
|
||||
void InsertSpace(int num);
|
||||
int TermDraw(const CurPos &start, const CurPos &end);
|
||||
int TermDrawRegion(CurPos start, CurPos end);
|
||||
int TermDrawSelectedRegion(CurPos start, CurPos end);
|
||||
|
||||
// Delete Charactor
|
||||
void EraseBelow();
|
||||
void DeleteChar(int num);
|
||||
@@ -131,12 +129,16 @@ protected:
|
||||
const char *property);
|
||||
|
||||
private:
|
||||
void _InitObject(const char *command);
|
||||
status_t _InitObject(const char *command);
|
||||
|
||||
static int32 MouseTracking(void *);
|
||||
|
||||
status_t _InitMouseThread(void);
|
||||
void DrawLines(int , int, ushort, uchar *, int, int, int, BView *);
|
||||
int TermDraw(const CurPos &start, const CurPos &end);
|
||||
int TermDrawRegion(CurPos start, CurPos end);
|
||||
int TermDrawSelectedRegion(CurPos start, CurPos end);
|
||||
|
||||
void DoPrint(BRect updateRect);
|
||||
void ResizeScrBarRange (void);
|
||||
void DoFileDrop(entry_ref &ref);
|
||||
@@ -147,7 +149,7 @@ private:
|
||||
void DoSelectAll();
|
||||
void DoClearAll();
|
||||
|
||||
void WritePTY (const uchar *text, int num_byteses);
|
||||
void WritePTY(const uchar *text, int num_byteses);
|
||||
|
||||
// Comunicate Input Method
|
||||
// void DoIMStart (BMessage* message);
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
const static float kViewOffset = 3;
|
||||
|
||||
#if 0
|
||||
/*
|
||||
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
||||
:
|
||||
BWindow(frame, title, B_DOCUMENT_WINDOW, B_CURRENT_WORKSPACE|B_QUIT_ON_WINDOW_CLOSE),
|
||||
@@ -76,13 +76,22 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
||||
fMatchCase(false),
|
||||
fMatchWord(false)
|
||||
{
|
||||
|
||||
fTabView = new SmartTabView(Bounds(), "Tab view");
|
||||
AddChild(fTabView);
|
||||
|
||||
_NewTab(command);
|
||||
_NewTab(NULL);
|
||||
|
||||
BView *view = new TermView(Bounds());
|
||||
AddChild(view);
|
||||
BRect draggerFrame(0, 0, 16, 16);
|
||||
draggerFrame.OffsetTo(Bounds().RightBottom() - BPoint(16, 16));
|
||||
BDragger *dragger = new BDragger(draggerFrame, view, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||
|
||||
view->AddChild(dragger);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
||||
|
||||
Reference in New Issue
Block a user