* Moved duplicated initializers to the _InitObject() method.
* Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28127 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+215
-274
@@ -147,6 +147,213 @@ private:
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
TermView::TermView(BRect frame, int32 argc, const char** argv, int32 historySize)
|
||||||
|
: BView(frame, "termview", B_FOLLOW_ALL,
|
||||||
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED),
|
||||||
|
fTermRows(ROWS_DEFAULT),
|
||||||
|
fTermColumns(COLUMNS_DEFAULT),
|
||||||
|
fEncoding(M_UTF8),
|
||||||
|
fScrBufSize(historySize)
|
||||||
|
{
|
||||||
|
_InitObject(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TermView::TermView(int rows, int columns, int32 argc, const char** argv,
|
||||||
|
int32 historySize)
|
||||||
|
: BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL,
|
||||||
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED),
|
||||||
|
fTermRows(rows),
|
||||||
|
fTermColumns(columns),
|
||||||
|
fEncoding(M_UTF8),
|
||||||
|
fScrBufSize(historySize)
|
||||||
|
{
|
||||||
|
_InitObject(argc, argv);
|
||||||
|
SetTermSize(fTermRows, fTermColumns, true);
|
||||||
|
|
||||||
|
// TODO: Don't show the dragger, since replicant capabilities
|
||||||
|
// don't work very well ATM.
|
||||||
|
/*
|
||||||
|
BRect rect(0, 0, 16, 16);
|
||||||
|
rect.OffsetTo(Bounds().right - rect.Width(),
|
||||||
|
Bounds().bottom - rect.Height());
|
||||||
|
|
||||||
|
SetFlags(Flags() | B_DRAW_ON_CHILDREN | B_FOLLOW_ALL);
|
||||||
|
AddChild(new BDragger(rect, this,
|
||||||
|
B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW));*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TermView::TermView(BMessage* archive)
|
||||||
|
:
|
||||||
|
BView(archive),
|
||||||
|
fTermRows(ROWS_DEFAULT),
|
||||||
|
fTermColumns(COLUMNS_DEFAULT),
|
||||||
|
fEncoding(M_UTF8),
|
||||||
|
fScrBufSize(1000)
|
||||||
|
{
|
||||||
|
// We need this
|
||||||
|
SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED);
|
||||||
|
|
||||||
|
if (archive->FindInt32("encoding", (int32*)&fEncoding) < B_OK)
|
||||||
|
fEncoding = M_UTF8;
|
||||||
|
if (archive->FindInt32("columns", (int32*)&fTermColumns) < B_OK)
|
||||||
|
fTermColumns = COLUMNS_DEFAULT;
|
||||||
|
if (archive->FindInt32("rows", (int32*)&fTermRows) < B_OK)
|
||||||
|
fTermRows = ROWS_DEFAULT;
|
||||||
|
|
||||||
|
int32 argc = 0;
|
||||||
|
if (archive->HasInt32("argc"))
|
||||||
|
archive->FindInt32("argc", &argc);
|
||||||
|
|
||||||
|
const char **argv = new const char*[argc];
|
||||||
|
for (int32 i = 0; i < argc; i++) {
|
||||||
|
archive->FindString("argv", i, (const char**)&argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Retrieve colors, history size, etc. from archive
|
||||||
|
_InitObject(argc, argv);
|
||||||
|
|
||||||
|
delete[] argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Initializes the object for further use.
|
||||||
|
The members fTermRows, fTermColumns, fEncoding, and fScrBufSize must
|
||||||
|
already be initialized; they are not touched by this method.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
TermView::_InitObject(int32 argc, const char** argv)
|
||||||
|
{
|
||||||
|
fShell = NULL;
|
||||||
|
fWinchRunner = NULL;
|
||||||
|
fCursorBlinkRunner = NULL;
|
||||||
|
fAutoScrollRunner = NULL;
|
||||||
|
fResizeRunner = NULL;
|
||||||
|
fResizeView = NULL;
|
||||||
|
fCharClassifier = NULL;
|
||||||
|
fFontWidth = 0;
|
||||||
|
fFontHeight = 0;
|
||||||
|
fFontAscent = 0;
|
||||||
|
fFrameResized = false;
|
||||||
|
fLastActivityTime = 0;
|
||||||
|
fCursorState = 0;
|
||||||
|
fCursorHeight = 0;
|
||||||
|
fCursor = TermPos(0, 0);
|
||||||
|
fTextBuffer = NULL;
|
||||||
|
fVisibleTextBuffer = NULL;
|
||||||
|
fScrollBar = NULL;
|
||||||
|
fTextForeColor = kBlackColor;
|
||||||
|
fTextBackColor = kWhiteColor;
|
||||||
|
fCursorForeColor = kWhiteColor;
|
||||||
|
fCursorBackColor = kBlackColor;
|
||||||
|
fSelectForeColor = kWhiteColor;
|
||||||
|
fSelectBackColor = kBlackColor;
|
||||||
|
fScrollOffset = 0;
|
||||||
|
fLastSyncTime = 0;
|
||||||
|
fScrolledSinceLastSync = 0;
|
||||||
|
fSyncRunner = NULL;
|
||||||
|
fConsiderClockedSync = false;
|
||||||
|
fSelStart = TermPos(-1, -1);
|
||||||
|
fSelEnd = TermPos(-1, -1);
|
||||||
|
fMouseTracking = false;
|
||||||
|
fIMflag = false;
|
||||||
|
|
||||||
|
fTextBuffer = new(std::nothrow) TerminalBuffer;
|
||||||
|
if (fTextBuffer == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
fVisibleTextBuffer = new(std::nothrow) BasicTerminalBuffer;
|
||||||
|
if (fVisibleTextBuffer == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
// TODO: Make the special word chars user-settable!
|
||||||
|
fCharClassifier = new(std::nothrow) CharClassifier(
|
||||||
|
kDefaultSpecialWordChars);
|
||||||
|
if (fCharClassifier == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
status_t error = fTextBuffer->Init(fTermColumns, fTermRows, fScrBufSize);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
fTextBuffer->SetEncoding(fEncoding);
|
||||||
|
|
||||||
|
error = fVisibleTextBuffer->Init(fTermColumns, fTermRows + 2, 0);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
fShell = new (std::nothrow) Shell();
|
||||||
|
if (fShell == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
SetTermFont(be_fixed_font);
|
||||||
|
SetTermSize(fTermRows, fTermColumns, false);
|
||||||
|
//SetIMAware(false);
|
||||||
|
|
||||||
|
status_t status = fShell->Open(fTermRows, fTermColumns,
|
||||||
|
EncodingAsShortString(fEncoding), argc, argv);
|
||||||
|
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
status = _AttachShell(fShell);
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
SetLowColor(fTextBackColor);
|
||||||
|
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TermView::~TermView()
|
||||||
|
{
|
||||||
|
Shell* shell = fShell;
|
||||||
|
// _DetachShell sets fShell to NULL
|
||||||
|
|
||||||
|
_DetachShell();
|
||||||
|
|
||||||
|
delete fSyncRunner;
|
||||||
|
delete fAutoScrollRunner;
|
||||||
|
delete fCharClassifier;
|
||||||
|
delete fVisibleTextBuffer;
|
||||||
|
delete fTextBuffer;
|
||||||
|
delete shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
BArchivable *
|
||||||
|
TermView::Instantiate(BMessage* data)
|
||||||
|
{
|
||||||
|
if (validate_instantiation(data, "TermView"))
|
||||||
|
return new (std::nothrow) TermView(data);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TermView::Archive(BMessage* data, bool deep) const
|
||||||
|
{
|
||||||
|
status_t status = BView::Archive(data, deep);
|
||||||
|
if (status == B_OK)
|
||||||
|
status = data->AddString("add_on", TERM_SIGNATURE);
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (data->ReplaceString("class", "TermView") != B_OK)
|
||||||
|
data->AddString("class", "TermView");
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int32
|
inline int32
|
||||||
TermView::_LineAt(float y)
|
TermView::_LineAt(float y)
|
||||||
{
|
{
|
||||||
@@ -194,274 +401,6 @@ TermView::_InvalidateTextRect(int32 x1, int32 y1, int32 x2, int32 y2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TermView::TermView(BRect frame, int32 argc, const char **argv, int32 historySize)
|
|
||||||
: BView(frame, "termview", B_FOLLOW_ALL,
|
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED),
|
|
||||||
fShell(NULL),
|
|
||||||
fWinchRunner(NULL),
|
|
||||||
fCursorBlinkRunner(NULL),
|
|
||||||
fAutoScrollRunner(NULL),
|
|
||||||
fResizeRunner(NULL),
|
|
||||||
fResizeView(NULL),
|
|
||||||
fCharClassifier(NULL),
|
|
||||||
fFontWidth(0),
|
|
||||||
fFontHeight(0),
|
|
||||||
fFontAscent(0),
|
|
||||||
fFrameResized(false),
|
|
||||||
fLastActivityTime(0),
|
|
||||||
fCursorState(0),
|
|
||||||
fCursorHeight(0),
|
|
||||||
fCursor(0, 0),
|
|
||||||
fTermRows(ROWS_DEFAULT),
|
|
||||||
fTermColumns(COLUMNS_DEFAULT),
|
|
||||||
fEncoding(M_UTF8),
|
|
||||||
fTextBuffer(NULL),
|
|
||||||
fVisibleTextBuffer(NULL),
|
|
||||||
fScrollBar(NULL),
|
|
||||||
fTextForeColor(kBlackColor),
|
|
||||||
fTextBackColor(kWhiteColor),
|
|
||||||
fCursorForeColor(kWhiteColor),
|
|
||||||
fCursorBackColor(kBlackColor),
|
|
||||||
fSelectForeColor(kWhiteColor),
|
|
||||||
fSelectBackColor(kBlackColor),
|
|
||||||
fScrollOffset(0),
|
|
||||||
fScrBufSize(historySize),
|
|
||||||
fLastSyncTime(0),
|
|
||||||
fScrolledSinceLastSync(0),
|
|
||||||
fSyncRunner(NULL),
|
|
||||||
fConsiderClockedSync(false),
|
|
||||||
fSelStart(-1, -1),
|
|
||||||
fSelEnd(-1, -1),
|
|
||||||
fMouseTracking(false),
|
|
||||||
fIMflag(false)
|
|
||||||
{
|
|
||||||
_InitObject(argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TermView::TermView(int rows, int columns, int32 argc, const char **argv, int32 historySize)
|
|
||||||
: BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL,
|
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED),
|
|
||||||
fShell(NULL),
|
|
||||||
fWinchRunner(NULL),
|
|
||||||
fCursorBlinkRunner(NULL),
|
|
||||||
fAutoScrollRunner(NULL),
|
|
||||||
fResizeRunner(NULL),
|
|
||||||
fResizeView(NULL),
|
|
||||||
fCharClassifier(NULL),
|
|
||||||
fFontWidth(0),
|
|
||||||
fFontHeight(0),
|
|
||||||
fFontAscent(0),
|
|
||||||
fFrameResized(false),
|
|
||||||
fLastActivityTime(0),
|
|
||||||
fCursorState(0),
|
|
||||||
fCursorHeight(0),
|
|
||||||
fCursor(0, 0),
|
|
||||||
fTermRows(rows),
|
|
||||||
fTermColumns(columns),
|
|
||||||
fEncoding(M_UTF8),
|
|
||||||
fTextBuffer(NULL),
|
|
||||||
fVisibleTextBuffer(NULL),
|
|
||||||
fScrollBar(NULL),
|
|
||||||
fTextForeColor(kBlackColor),
|
|
||||||
fTextBackColor(kWhiteColor),
|
|
||||||
fCursorForeColor(kWhiteColor),
|
|
||||||
fCursorBackColor(kBlackColor),
|
|
||||||
fSelectForeColor(kWhiteColor),
|
|
||||||
fSelectBackColor(kBlackColor),
|
|
||||||
fScrollOffset(0),
|
|
||||||
fScrBufSize(historySize),
|
|
||||||
fLastSyncTime(0),
|
|
||||||
fScrolledSinceLastSync(0),
|
|
||||||
fSyncRunner(NULL),
|
|
||||||
fConsiderClockedSync(false),
|
|
||||||
fSelStart(-1, -1),
|
|
||||||
fSelEnd(-1, -1),
|
|
||||||
fMouseTracking(false),
|
|
||||||
fIMflag(false)
|
|
||||||
{
|
|
||||||
_InitObject(argc, argv);
|
|
||||||
SetTermSize(fTermRows, fTermColumns, true);
|
|
||||||
|
|
||||||
// TODO: Don't show the dragger, since replicant capabilities
|
|
||||||
// don't work very well ATM.
|
|
||||||
/*
|
|
||||||
BRect rect(0, 0, 16, 16);
|
|
||||||
rect.OffsetTo(Bounds().right - rect.Width(),
|
|
||||||
Bounds().bottom - rect.Height());
|
|
||||||
|
|
||||||
SetFlags(Flags() | B_DRAW_ON_CHILDREN | B_FOLLOW_ALL);
|
|
||||||
AddChild(new BDragger(rect, this,
|
|
||||||
B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW));*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TermView::TermView(BMessage *archive)
|
|
||||||
:
|
|
||||||
BView(archive),
|
|
||||||
fShell(NULL),
|
|
||||||
fWinchRunner(NULL),
|
|
||||||
fCursorBlinkRunner(NULL),
|
|
||||||
fAutoScrollRunner(NULL),
|
|
||||||
fResizeRunner(NULL),
|
|
||||||
fResizeView(NULL),
|
|
||||||
fCharClassifier(NULL),
|
|
||||||
fFontWidth(0),
|
|
||||||
fFontHeight(0),
|
|
||||||
fFontAscent(0),
|
|
||||||
fFrameResized(false),
|
|
||||||
fLastActivityTime(0),
|
|
||||||
fCursorState(0),
|
|
||||||
fCursorHeight(0),
|
|
||||||
fCursor(0, 0),
|
|
||||||
fTermRows(ROWS_DEFAULT),
|
|
||||||
fTermColumns(COLUMNS_DEFAULT),
|
|
||||||
fEncoding(M_UTF8),
|
|
||||||
fTextBuffer(NULL),
|
|
||||||
fVisibleTextBuffer(NULL),
|
|
||||||
fScrollBar(NULL),
|
|
||||||
fTextForeColor(kBlackColor),
|
|
||||||
fTextBackColor(kWhiteColor),
|
|
||||||
fCursorForeColor(kWhiteColor),
|
|
||||||
fCursorBackColor(kBlackColor),
|
|
||||||
fSelectForeColor(kWhiteColor),
|
|
||||||
fSelectBackColor(kBlackColor),
|
|
||||||
fScrBufSize(1000),
|
|
||||||
fLastSyncTime(0),
|
|
||||||
fScrolledSinceLastSync(0),
|
|
||||||
fSyncRunner(NULL),
|
|
||||||
fConsiderClockedSync(false),
|
|
||||||
fSelStart(-1, -1),
|
|
||||||
fSelEnd(-1, -1),
|
|
||||||
fMouseTracking(false),
|
|
||||||
fIMflag(false)
|
|
||||||
{
|
|
||||||
// We need this
|
|
||||||
SetFlags(Flags() | B_WILL_DRAW | B_PULSE_NEEDED);
|
|
||||||
|
|
||||||
if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK)
|
|
||||||
fEncoding = M_UTF8;
|
|
||||||
if (archive->FindInt32("columns", (int32 *)&fTermColumns) < B_OK)
|
|
||||||
fTermColumns = COLUMNS_DEFAULT;
|
|
||||||
if (archive->FindInt32("rows", (int32 *)&fTermRows) < B_OK)
|
|
||||||
fTermRows = ROWS_DEFAULT;
|
|
||||||
|
|
||||||
int32 argc = 0;
|
|
||||||
if (archive->HasInt32("argc"))
|
|
||||||
archive->FindInt32("argc", &argc);
|
|
||||||
|
|
||||||
const char **argv = new const char*[argc];
|
|
||||||
for (int32 i = 0; i < argc; i++) {
|
|
||||||
archive->FindString("argv", i, (const char **)&argv[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Retrieve colors, history size, etc. from archive
|
|
||||||
_InitObject(argc, argv);
|
|
||||||
|
|
||||||
delete[] argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TermView::_InitObject(int32 argc, const char **argv)
|
|
||||||
{
|
|
||||||
fTextBuffer = new(std::nothrow) TerminalBuffer;
|
|
||||||
if (fTextBuffer == NULL)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
fVisibleTextBuffer = new(std::nothrow) BasicTerminalBuffer;
|
|
||||||
if (fVisibleTextBuffer == NULL)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
// TODO: Make the special word chars user-settable!
|
|
||||||
fCharClassifier = new(std::nothrow) CharClassifier(
|
|
||||||
kDefaultSpecialWordChars);
|
|
||||||
if (fCharClassifier == NULL)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
status_t error = fTextBuffer->Init(fTermColumns, fTermRows, fScrBufSize);
|
|
||||||
if (error != B_OK)
|
|
||||||
return error;
|
|
||||||
fTextBuffer->SetEncoding(fEncoding);
|
|
||||||
|
|
||||||
error = fVisibleTextBuffer->Init(fTermColumns, fTermRows + 2, 0);
|
|
||||||
if (error != B_OK)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
fShell = new (std::nothrow) Shell();
|
|
||||||
if (fShell == NULL)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
SetTermFont(be_fixed_font);
|
|
||||||
SetTermSize(fTermRows, fTermColumns, false);
|
|
||||||
//SetIMAware(false);
|
|
||||||
|
|
||||||
status_t status = fShell->Open(fTermRows, fTermColumns,
|
|
||||||
EncodingAsShortString(fEncoding),
|
|
||||||
argc, argv);
|
|
||||||
|
|
||||||
if (status < B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
status = _AttachShell(fShell);
|
|
||||||
if (status < B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
|
|
||||||
SetLowColor(fTextBackColor);
|
|
||||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TermView::~TermView()
|
|
||||||
{
|
|
||||||
Shell *shell = fShell;
|
|
||||||
// _DetachShell sets fShell to NULL
|
|
||||||
|
|
||||||
_DetachShell();
|
|
||||||
|
|
||||||
delete fSyncRunner;
|
|
||||||
delete fAutoScrollRunner;
|
|
||||||
delete fCharClassifier;
|
|
||||||
delete fVisibleTextBuffer;
|
|
||||||
delete fTextBuffer;
|
|
||||||
delete shell;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* static */
|
|
||||||
BArchivable *
|
|
||||||
TermView::Instantiate(BMessage* data)
|
|
||||||
{
|
|
||||||
if (validate_instantiation(data, "TermView"))
|
|
||||||
return new (std::nothrow) TermView(data);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TermView::Archive(BMessage* data, bool deep) const
|
|
||||||
{
|
|
||||||
status_t status = BView::Archive(data, deep);
|
|
||||||
if (status == B_OK)
|
|
||||||
status = data->AddString("add_on", TERM_SIGNATURE);
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (data->ReplaceString("class", "TermView") != B_OK)
|
|
||||||
data->AddString("class", "TermView");
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::GetPreferredSize(float *width, float *height)
|
TermView::GetPreferredSize(float *width, float *height)
|
||||||
{
|
{
|
||||||
@@ -1602,13 +1541,15 @@ TermView::ScrollTo(BPoint where)
|
|||||||
|
|
||||||
|
|
||||||
BHandler*
|
BHandler*
|
||||||
TermView::ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier,
|
TermView::ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier,
|
||||||
int32 what, const char *property)
|
int32 what, const char* property)
|
||||||
{
|
{
|
||||||
BHandler *target = this;
|
BHandler* target = this;
|
||||||
BPropertyInfo propInfo(sPropList);
|
BPropertyInfo propInfo(sPropList);
|
||||||
if (propInfo.FindMatch(message, index, specifier, what, property) < B_OK)
|
if (propInfo.FindMatch(message, index, specifier, what, property) < B_OK) {
|
||||||
target = BView::ResolveSpecifier(message, index, specifier, what, property);
|
target = BView::ResolveSpecifier(message, index, specifier, what,
|
||||||
|
property);
|
||||||
|
}
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@@ -1616,7 +1557,7 @@ TermView::ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier,
|
|||||||
|
|
||||||
//! Gets dropped file full path and display it at cursor position.
|
//! Gets dropped file full path and display it at cursor position.
|
||||||
void
|
void
|
||||||
TermView::_DoFileDrop(entry_ref &ref)
|
TermView::_DoFileDrop(entry_ref& ref)
|
||||||
{
|
{
|
||||||
BEntry ent(&ref);
|
BEntry ent(&ref);
|
||||||
BPath path(&ent);
|
BPath path(&ent);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
* Stefano Ceccherini <stefano.ceccherini@gmail.com>
|
* Stefano Ceccherini <stefano.ceccherini@gmail.com>
|
||||||
* Kian Duffy, myob@users.sourceforge.net
|
* Kian Duffy, myob@users.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TERMVIEW_H
|
#ifndef TERMVIEW_H
|
||||||
#define TERMVIEW_H
|
#define TERMVIEW_H
|
||||||
|
|
||||||
@@ -32,25 +31,26 @@ class ResizeWindow;
|
|||||||
|
|
||||||
class TermView : public BView {
|
class TermView : public BView {
|
||||||
public:
|
public:
|
||||||
TermView(BRect frame, int32 argc, const char **argv, int32 historySize);
|
TermView(BRect frame, int32 argc, const char** argv,
|
||||||
TermView(int rows, int columns, int32 argc, const char **argv,
|
|
||||||
int32 historySize);
|
int32 historySize);
|
||||||
TermView(BMessage *archive);
|
TermView(int rows, int columns, int32 argc,
|
||||||
|
const char** argv, int32 historySize);
|
||||||
|
TermView(BMessage* archive);
|
||||||
~TermView();
|
~TermView();
|
||||||
|
|
||||||
static BArchivable* Instantiate(BMessage* data);
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||||
|
|
||||||
virtual void GetPreferredSize(float *width, float *height);
|
virtual void GetPreferredSize(float* _width, float* _height);
|
||||||
|
|
||||||
const char *TerminalName() const;
|
const char* TerminalName() const;
|
||||||
|
|
||||||
inline TerminalBuffer* TextBuffer() const { return fTextBuffer; }
|
inline TerminalBuffer* TextBuffer() const { return fTextBuffer; }
|
||||||
|
|
||||||
void GetTermFont(BFont *font) const;
|
void GetTermFont(BFont* font) const;
|
||||||
void SetTermFont(const BFont *font);
|
void SetTermFont(const BFont* font);
|
||||||
|
|
||||||
void GetFontSize(int *width, int *height);
|
void GetFontSize(int* width, int* height);
|
||||||
BRect SetTermSize(int rows, int cols, bool resize);
|
BRect SetTermSize(int rows, int cols, bool resize);
|
||||||
|
|
||||||
void SetTextColor(rgb_color fore, rgb_color back);
|
void SetTextColor(rgb_color fore, rgb_color back);
|
||||||
@@ -60,23 +60,24 @@ public:
|
|||||||
int Encoding() const;
|
int Encoding() const;
|
||||||
void SetEncoding(int encoding);
|
void SetEncoding(int encoding);
|
||||||
|
|
||||||
// void SetIMAware (bool);
|
//void SetIMAware(bool);
|
||||||
void SetScrollBar(BScrollBar *scrbar);
|
void SetScrollBar(BScrollBar* scrollBar);
|
||||||
BScrollBar *ScrollBar() const { return fScrollBar; };
|
BScrollBar* ScrollBar() const { return fScrollBar; };
|
||||||
|
|
||||||
virtual void SetTitle(const char *title);
|
virtual void SetTitle(const char* title);
|
||||||
virtual void NotifyQuit(int32 reason);
|
virtual void NotifyQuit(int32 reason);
|
||||||
|
|
||||||
// edit functions
|
// edit functions
|
||||||
void Copy(BClipboard *clipboard);
|
void Copy(BClipboard* clipboard);
|
||||||
void Paste(BClipboard *clipboard);
|
void Paste(BClipboard* clipboard);
|
||||||
void SelectAll();
|
void SelectAll();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
void GetFrameSize(float *width, float *height);
|
void GetFrameSize(float* width, float* height);
|
||||||
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
bool Find(const BString& str, bool forwardSearch,
|
||||||
void GetSelection(BString &str);
|
bool matchCase, bool matchWord);
|
||||||
|
void GetSelection(BString& string);
|
||||||
|
|
||||||
void CheckShellGone();
|
void CheckShellGone();
|
||||||
|
|
||||||
@@ -87,10 +88,11 @@ protected:
|
|||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
virtual void KeyDown(const char*, int32);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseMoved(BPoint, uint32, const BMessage *);
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
|
const BMessage* message);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
@@ -98,29 +100,31 @@ protected:
|
|||||||
|
|
||||||
virtual void ScrollTo(BPoint where);
|
virtual void ScrollTo(BPoint where);
|
||||||
|
|
||||||
virtual status_t GetSupportedSuites(BMessage *msg);
|
virtual status_t GetSupportedSuites(BMessage* msg);
|
||||||
virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index,
|
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
|
||||||
BMessage *specifier, int32 form,
|
BMessage* specifier, int32 form,
|
||||||
const char *property);
|
const char* property);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// point and text offset conversion
|
// point and text offset conversion
|
||||||
inline int32 _LineAt(float y);
|
inline int32 _LineAt(float y);
|
||||||
inline float _LineOffset(int32 index);
|
inline float _LineOffset(int32 index);
|
||||||
inline TermPos _ConvertToTerminal(const BPoint &p);
|
inline TermPos _ConvertToTerminal(const BPoint& point);
|
||||||
inline BPoint _ConvertFromTerminal(const TermPos &pos);
|
inline BPoint _ConvertFromTerminal(const TermPos& pos);
|
||||||
|
|
||||||
inline void _InvalidateTextRect(int32 x1, int32 y1, int32 x2, int32 y2);
|
inline void _InvalidateTextRect(int32 x1, int32 y1, int32 x2,
|
||||||
|
int32 y2);
|
||||||
|
|
||||||
status_t _InitObject(int32 argc, const char **argv);
|
status_t _InitObject(int32 argc, const char** argv);
|
||||||
|
|
||||||
status_t _AttachShell(Shell *shell);
|
status_t _AttachShell(Shell* shell);
|
||||||
void _DetachShell();
|
void _DetachShell();
|
||||||
|
|
||||||
void _AboutRequested();
|
void _AboutRequested();
|
||||||
|
|
||||||
void _DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
void _DrawLinePart(int32 x1, int32 y1, uint16 attr,
|
||||||
int32 width, bool mouse, bool cursor, BView *inView);
|
char* buffer, int32 width, bool mouse,
|
||||||
|
bool cursor, BView* inView);
|
||||||
void _DrawCursor();
|
void _DrawCursor();
|
||||||
void _InvalidateTextRange(TermPos start, TermPos end);
|
void _InvalidateTextRange(TermPos start, TermPos end);
|
||||||
|
|
||||||
@@ -148,15 +152,18 @@ private:
|
|||||||
// selection
|
// selection
|
||||||
void _Select(TermPos start, TermPos end, bool inclusive,
|
void _Select(TermPos start, TermPos end, bool inclusive,
|
||||||
bool setInitialSelection);
|
bool setInitialSelection);
|
||||||
void _ExtendSelection(TermPos, bool inclusive, bool useInitialSelection);
|
void _ExtendSelection(TermPos, bool inclusive,
|
||||||
|
bool useInitialSelection);
|
||||||
void _Deselect();
|
void _Deselect();
|
||||||
bool _HasSelection() const;
|
bool _HasSelection() const;
|
||||||
void _SelectWord(BPoint where, bool extend, bool useInitialSelection);
|
void _SelectWord(BPoint where, bool extend,
|
||||||
void _SelectLine(BPoint where, bool extend, bool useInitialSelection);
|
bool useInitialSelection);
|
||||||
|
void _SelectLine(BPoint where, bool extend,
|
||||||
|
bool useInitialSelection);
|
||||||
|
|
||||||
void _AutoScrollUpdate();
|
void _AutoScrollUpdate();
|
||||||
|
|
||||||
bool _CheckSelectedRegion(const TermPos &pos) const;
|
bool _CheckSelectedRegion(const TermPos& pos) const;
|
||||||
bool _CheckSelectedRegion(int32 row, int32 firstColumn,
|
bool _CheckSelectedRegion(int32 row, int32 firstColumn,
|
||||||
int32& lastColumn) const;
|
int32& lastColumn) const;
|
||||||
|
|
||||||
@@ -168,14 +175,14 @@ private:
|
|||||||
private:
|
private:
|
||||||
class CharClassifier;
|
class CharClassifier;
|
||||||
|
|
||||||
Shell *fShell;
|
Shell* fShell;
|
||||||
|
|
||||||
BMessageRunner *fWinchRunner;
|
BMessageRunner* fWinchRunner;
|
||||||
BMessageRunner *fCursorBlinkRunner;
|
BMessageRunner* fCursorBlinkRunner;
|
||||||
BMessageRunner *fAutoScrollRunner;
|
BMessageRunner* fAutoScrollRunner;
|
||||||
BMessageRunner *fResizeRunner;
|
BMessageRunner* fResizeRunner;
|
||||||
BStringView *fResizeView;
|
BStringView* fResizeView;
|
||||||
CharClassifier *fCharClassifier;
|
CharClassifier* fCharClassifier;
|
||||||
|
|
||||||
// Font and Width
|
// Font and Width
|
||||||
BFont fHalfFont;
|
BFont fHalfFont;
|
||||||
@@ -204,20 +211,23 @@ private:
|
|||||||
int fEncoding;
|
int fEncoding;
|
||||||
|
|
||||||
// Object pointer.
|
// Object pointer.
|
||||||
TerminalBuffer *fTextBuffer;
|
TerminalBuffer* fTextBuffer;
|
||||||
BasicTerminalBuffer *fVisibleTextBuffer;
|
BasicTerminalBuffer* fVisibleTextBuffer;
|
||||||
BScrollBar *fScrollBar;
|
BScrollBar* fScrollBar;
|
||||||
|
|
||||||
// Color and Attribute.
|
// Color and Attribute.
|
||||||
rgb_color fTextForeColor, fTextBackColor;
|
rgb_color fTextForeColor;
|
||||||
rgb_color fCursorForeColor, fCursorBackColor;
|
rgb_color fTextBackColor;
|
||||||
rgb_color fSelectForeColor, fSelectBackColor;
|
rgb_color fCursorForeColor;
|
||||||
|
rgb_color fCursorBackColor;
|
||||||
|
rgb_color fSelectForeColor;
|
||||||
|
rgb_color fSelectBackColor;
|
||||||
|
|
||||||
// Scroll Region
|
// Scroll Region
|
||||||
float fScrollOffset;
|
float fScrollOffset;
|
||||||
int32 fScrBufSize;
|
int32 fScrBufSize;
|
||||||
// TODO: That's the history capacity -- only needed until the text
|
// TODO: That's the history capacity -- only needed
|
||||||
// buffer is created.
|
// until the text buffer is created.
|
||||||
float fAutoScrollSpeed;
|
float fAutoScrollSpeed;
|
||||||
|
|
||||||
// redraw management
|
// redraw management
|
||||||
|
|||||||
Reference in New Issue
Block a user