Quick fix to prevent the terminal from crashing in case it got a message

with mouse coordinates outside the window (yeah, it has been written
that bad).
Need to rewrite the whole mouse handling, though...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15152 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-25 16:20:32 +00:00
parent 39b345c7b6
commit 498cd44c3a
2 changed files with 23 additions and 17 deletions

View File

@ -96,17 +96,18 @@ TermBuffer::TermBuffer(int rows, int cols)
mRowSize = rows; mRowSize = rows;
mRowOffset = 0; mRowOffset = 0;
//buffer_size = ARRAY_SIZE; //buffer_size = ARRAY_SIZE;
buffer_size = gTermPref->getInt32 (PREF_HISTORY_SIZE); buffer_size = gTermPref->getInt32 (PREF_HISTORY_SIZE);
// Allocate buffer // Allocate buffer
mBase = (term_buffer**) malloc (sizeof (term_buffer*) * buffer_size); mBase = (term_buffer**) malloc (sizeof (term_buffer*) * buffer_size);
for(int i = 0; i < buffer_size; i++) for (int i = 0; i < buffer_size; i++)
mBase[i] = (term_buffer *) calloc (mColSize + 1, sizeof (term_buffer)); mBase[i] = (term_buffer *) calloc (mColSize + 1, sizeof (term_buffer));
} }
TermBuffer::~TermBuffer() TermBuffer::~TermBuffer()
{ {
for(int i = 0; i < buffer_size; i++) for(int i = 0; i < buffer_size; i++)
@ -115,26 +116,29 @@ TermBuffer::~TermBuffer()
free(mBase); free(mBase);
} }
// Gets a character from TermBuffer
//! Gets a character from TermBuffer
int int
TermBuffer::GetChar (int row, int col, uchar *buf, ushort *attr) TermBuffer::GetChar(int row, int col, uchar *buf, ushort *attr)
{ {
term_buffer *ptr; if (row < 0 || col < 0)
return -1;
ptr = (mBase[row % buffer_size] + col);
term_buffer *ptr = (mBase[row % buffer_size] + col);
if (ptr->status == A_CHAR) if (ptr->status == A_CHAR)
memcpy (buf, (char *)(ptr->code), 4); memcpy(buf, (char *)(ptr->code), 4);
*attr = ptr->attr; *attr = ptr->attr;
return ptr->status; return ptr->status;
} }
// Get a string (length = num) from given position.
//! Get a string (length = num) from given position.
int int
TermBuffer::GetString (int row, int col, int num, uchar *buf, TermBuffer::GetString(int row, int col, int num, uchar *buf,
ushort *attr) ushort *attr)
{ {
int count = 0, all_count = 0; int count = 0, all_count = 0;
term_buffer *ptr; term_buffer *ptr;

View File

@ -904,7 +904,9 @@ TermView::MouseTracking(void *data)
} }
edpos = theObj->BPointToCurPos(edpoint); edpos = theObj->BPointToCurPos(edpoint);
if (edpos.y < 0)
continue;
if(stpoint == edpoint) { if(stpoint == edpoint) {
continue; continue;
} else { } else {