Removed a goto, style changes, patch by Vasilis Kaoutsis. Thank you!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20179 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2006, Haiku, Inc.
|
* Copyright 2001-2007, Haiku, Inc.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* Distributed under the terms of the MIT license.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Kian Duffy <[email protected]>
|
* Kian Duffy, [email protected]
|
||||||
|
* Y.Hayakawa, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -802,7 +803,7 @@ TermView::ViewThread(void *data)
|
|||||||
BRect r(pos.x1 * width, pos.y1 * height,
|
BRect r(pos.x1 * width, pos.y1 * height,
|
||||||
(pos.x2 + 1) * width -1,(pos.y2 + 1) * height -1);
|
(pos.x2 + 1) * width -1,(pos.y2 + 1) * height -1);
|
||||||
|
|
||||||
if(theObj->LockLooper()) {
|
if (theObj->LockLooper()) {
|
||||||
theObj->Invalidate(r);
|
theObj->Invalidate(r);
|
||||||
theObj->UnlockLooper();
|
theObj->UnlockLooper();
|
||||||
}
|
}
|
||||||
@@ -857,23 +858,23 @@ TermView::MouseTracking(void *data)
|
|||||||
|
|
||||||
while(!theObj->fQuitting) {
|
while(!theObj->fQuitting) {
|
||||||
|
|
||||||
if(1) {
|
if (1) {
|
||||||
#ifdef CHANGE_CURSOR_IMAGE
|
#ifdef CHANGE_CURSOR_IMAGE
|
||||||
if(!has_data(find_thread(NULL))) {
|
if (!has_data(find_thread(NULL))) {
|
||||||
BRect r;
|
BRect r;
|
||||||
|
|
||||||
if(theObj->fSelected
|
if (theObj->fSelected
|
||||||
&& ( gTermPref->getInt32(PREF_DRAGN_COPY)
|
&& ( gTermPref->getInt32(PREF_DRAGN_COPY)
|
||||||
|| modifiers() & B_CONTROL_KEY)) {
|
|| modifiers() & B_CONTROL_KEY)) {
|
||||||
|
|
||||||
if(theObj->LockLooper()) {
|
if (theObj->LockLooper()) {
|
||||||
theObj->GetMouse(&stpoint, &button);
|
theObj->GetMouse(&stpoint, &button);
|
||||||
r = theObj->Bounds();
|
r = theObj->Bounds();
|
||||||
theObj->UnlockLooper();
|
theObj->UnlockLooper();
|
||||||
}
|
}
|
||||||
if(r.Contains(stpoint)) {
|
if (r.Contains(stpoint)) {
|
||||||
CurPos tmppos = theObj->BPointToCurPos(stpoint);
|
CurPos tmppos = theObj->BPointToCurPos(stpoint);
|
||||||
if(theObj->fSelStart > theObj->fSelEnd) {
|
if (theObj->fSelStart > theObj->fSelEnd) {
|
||||||
stpos = theObj->fSelEnd;
|
stpos = theObj->fSelEnd;
|
||||||
edpos = theObj->fSelStart;
|
edpos = theObj->fSelStart;
|
||||||
} else {
|
} else {
|
||||||
@@ -881,7 +882,7 @@ TermView::MouseTracking(void *data)
|
|||||||
edpos = theObj->fSelEnd;
|
edpos = theObj->fSelEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tmppos > stpos && tmppos < edpos)
|
if (tmppos > stpos && tmppos < edpos)
|
||||||
be_app->SetCursor(M_ADD_CURSOR);
|
be_app->SetCursor(M_ADD_CURSOR);
|
||||||
else
|
else
|
||||||
be_app->SetCursor(B_HAND_CURSOR);
|
be_app->SetCursor(B_HAND_CURSOR);
|
||||||
@@ -894,7 +895,7 @@ TermView::MouseTracking(void *data)
|
|||||||
code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint));
|
code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(code != MOUSE_THR_CODE)
|
if (code != MOUSE_THR_CODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
selected = theObj->fSelected;
|
selected = theObj->fSelected;
|
||||||
@@ -906,7 +907,7 @@ TermView::MouseTracking(void *data)
|
|||||||
|
|
||||||
snooze(40 * 1000);
|
snooze(40 * 1000);
|
||||||
|
|
||||||
if(theObj->LockLooper()) {
|
if (theObj->LockLooper()) {
|
||||||
theObj->GetMouse(&edpoint, &button);
|
theObj->GetMouse(&edpoint, &button);
|
||||||
theObj->UnlockLooper();
|
theObj->UnlockLooper();
|
||||||
}
|
}
|
||||||
@@ -915,51 +916,51 @@ TermView::MouseTracking(void *data)
|
|||||||
if (edpos.y < 0)
|
if (edpos.y < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(stpoint == edpoint) {
|
if (stpoint == edpoint) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if(!selected) {
|
if (!selected) {
|
||||||
theObj->Select(stpos, edpos);
|
theObj->Select(stpos, edpos);
|
||||||
selected = true;
|
selected = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Align cursor point to text.
|
// Align cursor point to text.
|
||||||
if(stpos == edpos)
|
if (stpos == edpos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(edpos > stpos) {
|
if (edpos > stpos) {
|
||||||
edpoint.x -= theObj->fFontWidth / 2;
|
edpoint.x -= theObj->fFontWidth / 2;
|
||||||
edpos = theObj->BPointToCurPos(edpoint);
|
edpos = theObj->BPointToCurPos(edpoint);
|
||||||
//edpos.x--;
|
//edpos.x--;
|
||||||
if(edpos.x < 0)
|
if (edpos.x < 0)
|
||||||
edpos.x = 0;
|
edpos.x = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(edpos < stpos) {
|
if (edpos < stpos) {
|
||||||
edpoint.x += theObj->fFontWidth / 2;
|
edpoint.x += theObj->fFontWidth / 2;
|
||||||
edpos = theObj->BPointToCurPos(edpoint);
|
edpos = theObj->BPointToCurPos(edpoint);
|
||||||
//edpos.x++;
|
//edpos.x++;
|
||||||
if(edpos.x > theObj->fTermColumns)
|
if (edpos.x > theObj->fTermColumns)
|
||||||
edpos.x = theObj->fTermColumns;
|
edpos.x = theObj->fTermColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll check
|
// Scroll check
|
||||||
if(theObj->LockLooper()) {
|
if (theObj->LockLooper()) {
|
||||||
|
|
||||||
// Get now scroll point
|
// Get now scroll point
|
||||||
theObj->fScrollBar->GetRange(&scr_start, &scr_end);
|
theObj->fScrollBar->GetRange(&scr_start, &scr_end);
|
||||||
scr_pos = theObj->fScrollBar->Value();
|
scr_pos = theObj->fScrollBar->Value();
|
||||||
|
|
||||||
if(edpoint.y < theObj->Bounds().LeftTop().y )
|
if (edpoint.y < theObj->Bounds().LeftTop().y )
|
||||||
|
|
||||||
// mouse point left of window
|
// mouse point left of window
|
||||||
if(scr_pos != scr_start)
|
if (scr_pos != scr_start)
|
||||||
theObj->ScrollTo(0, edpoint.y);
|
theObj->ScrollTo(0, edpoint.y);
|
||||||
|
|
||||||
if(edpoint.y > theObj->Bounds().LeftBottom().y) {
|
if (edpoint.y > theObj->Bounds().LeftBottom().y) {
|
||||||
|
|
||||||
// mouse point left of window
|
// mouse point left of window
|
||||||
if(scr_pos != scr_end)
|
if (scr_pos != scr_end)
|
||||||
theObj->ScrollTo(0, edpoint.y);
|
theObj->ScrollTo(0, edpoint.y);
|
||||||
}
|
}
|
||||||
theObj->UnlockLooper();
|
theObj->UnlockLooper();
|
||||||
@@ -1128,10 +1129,7 @@ TermView::UpdateSIGWINCH()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Device Status.
|
//! Device Status.
|
||||||
Q & D hack by Y.Hayakawa([email protected])
|
|
||||||
21-JUL-99
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
TermView::DeviceStatusReport(int n)
|
TermView::DeviceStatusReport(int n)
|
||||||
{
|
{
|
||||||
@@ -1320,7 +1318,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
// send signal to shell process group.
|
// send signal to shell process group.
|
||||||
tcgetattr(gPfd, &tio);
|
tcgetattr(gPfd, &tio);
|
||||||
if (*bytes == tio.c_cc[VINTR]) {
|
if (*bytes == tio.c_cc[VINTR]) {
|
||||||
if(tio.c_lflag & ISIG)
|
if (tio.c_lflag & ISIG)
|
||||||
kill(-sh_pid, SIGINT);
|
kill(-sh_pid, SIGINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1547,7 +1545,7 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
// {
|
// {
|
||||||
// int32 op;
|
// int32 op;
|
||||||
// msg->FindInt32("be:opcode", &op);
|
// msg->FindInt32("be:opcode", &op);
|
||||||
// switch(op){
|
// switch (op){
|
||||||
// case B_INPUT_METHOD_STARTED:
|
// case B_INPUT_METHOD_STARTED:
|
||||||
//DoIMStart(msg);
|
//DoIMStart(msg);
|
||||||
// break;
|
// break;
|
||||||
@@ -1610,7 +1608,7 @@ TermView::DoCopy()
|
|||||||
// Deselecting the current selection is not the behavior that
|
// Deselecting the current selection is not the behavior that
|
||||||
// R5's Terminal app displays. We want to mimic the behavior, so we will
|
// R5's Terminal app displays. We want to mimic the behavior, so we will
|
||||||
// no longer do the deselection
|
// no longer do the deselection
|
||||||
// if(!fMouseTracking)
|
// if (!fMouseTracking)
|
||||||
// DeSelect();
|
// DeSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1651,7 +1649,7 @@ TermView::DoSelectAll(void)
|
|||||||
start.x = 0;
|
start.x = 0;
|
||||||
end.x = fTermColumns -1;
|
end.x = fTermColumns -1;
|
||||||
|
|
||||||
if(start_pos > 0)
|
if (start_pos > 0)
|
||||||
start.y = start_pos;
|
start.y = start_pos;
|
||||||
else
|
else
|
||||||
start.y = 0;
|
start.y = 0;
|
||||||
@@ -1671,7 +1669,7 @@ TermView::DoClearAll(void)
|
|||||||
fTop = 0;
|
fTop = 0;
|
||||||
ScrollTo(0, 0);
|
ScrollTo(0, 0);
|
||||||
|
|
||||||
if(LockLooper()) {
|
if (LockLooper()) {
|
||||||
SetHighColor(fTextBackColor);
|
SetHighColor(fTextBackColor);
|
||||||
|
|
||||||
FillRect(Bounds());
|
FillRect(Bounds());
|
||||||
@@ -1701,7 +1699,7 @@ TermView::SubstMetaChar(const char *p, char *q)
|
|||||||
char *mp = metachar;
|
char *mp = metachar;
|
||||||
for(int i = 0; i < 22; i++){
|
for(int i = 0; i < 22; i++){
|
||||||
|
|
||||||
if(*p == *mp++) {
|
if (*p == *mp++) {
|
||||||
*q++ = '\\';
|
*q++ = '\\';
|
||||||
num_char++;
|
num_char++;
|
||||||
break;
|
break;
|
||||||
@@ -1879,7 +1877,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
if (clicks == 0)
|
if (clicks == 0)
|
||||||
clicks = 3;
|
clicks = 3;
|
||||||
|
|
||||||
switch(clicks) {
|
switch (clicks) {
|
||||||
case 1:
|
case 1:
|
||||||
fMouseTracking = true;
|
fMouseTracking = true;
|
||||||
send_data(fMouseThread, MOUSE_THR_CODE, (void *)&where, sizeof(BPoint));
|
send_data(fMouseThread, MOUSE_THR_CODE, (void *)&where, sizeof(BPoint));
|
||||||
@@ -1897,7 +1895,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sub menu(coding popup menu)
|
// Sub menu(coding popup menu)
|
||||||
if(buttons == mSubMenuButton){
|
if (buttons == mSubMenuButton){
|
||||||
ConvertToScreen(&where);
|
ConvertToScreen(&where);
|
||||||
SetupPop();
|
SetupPop();
|
||||||
fPopMenu->Go(where, true);
|
fPopMenu->Go(where, true);
|
||||||
@@ -1911,10 +1909,10 @@ TermView::MouseDown(BPoint where)
|
|||||||
void
|
void
|
||||||
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *)
|
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *)
|
||||||
{
|
{
|
||||||
if(fMouseImage && Window()->IsActive()) {
|
if (fMouseImage && Window()->IsActive()) {
|
||||||
if(transit == B_ENTERED_VIEW)
|
if (transit == B_ENTERED_VIEW)
|
||||||
be_app->SetCursor(B_I_BEAM_CURSOR);
|
be_app->SetCursor(B_I_BEAM_CURSOR);
|
||||||
if(transit == B_EXITED_VIEW)
|
if (transit == B_EXITED_VIEW)
|
||||||
be_app->SetCursor(B_HAND_CURSOR);
|
be_app->SetCursor(B_HAND_CURSOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1927,19 +1925,19 @@ TermView::Select(CurPos start, CurPos end)
|
|||||||
uchar buf[4];
|
uchar buf[4];
|
||||||
ushort attr;
|
ushort attr;
|
||||||
|
|
||||||
if(start.x < 0)
|
if (start.x < 0)
|
||||||
start.x = 0;
|
start.x = 0;
|
||||||
if(end.x >= fTermColumns)
|
if (end.x >= fTermColumns)
|
||||||
end.x = fTermColumns - 1;
|
end.x = fTermColumns - 1;
|
||||||
|
|
||||||
if(fTextBuffer->GetChar(start.y, start.x, buf, &attr) == IN_STRING) {
|
if (fTextBuffer->GetChar(start.y, start.x, buf, &attr) == IN_STRING) {
|
||||||
start.x--;
|
start.x--;
|
||||||
if(start.x < 0) start.x = 0;
|
if (start.x < 0) start.x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fTextBuffer->GetChar(end.y, end.x, buf, &attr) == IN_STRING) {
|
if (fTextBuffer->GetChar(end.y, end.x, buf, &attr) == IN_STRING) {
|
||||||
end.x++;
|
end.x++;
|
||||||
if(end.x >= fTermColumns) end.x = fTermColumns;
|
if (end.x >= fTermColumns) end.x = fTermColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSelStart = start;
|
fSelStart = start;
|
||||||
@@ -1958,14 +1956,14 @@ TermView::AddSelectRegion(CurPos pos)
|
|||||||
ushort attr;
|
ushort attr;
|
||||||
CurPos start, end, inPos;
|
CurPos start, end, inPos;
|
||||||
|
|
||||||
if(!fSelected)
|
if (!fSelected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// error check, and if mouse point to a plase full width character,
|
// error check, and if mouse point to a plase full width character,
|
||||||
// select point decliment.
|
// select point decliment.
|
||||||
if(pos.x >= fTermColumns)
|
if (pos.x >= fTermColumns)
|
||||||
pos.x = fTermColumns - 1;
|
pos.x = fTermColumns - 1;
|
||||||
else if(pos.x < 0)
|
else if (pos.x < 0)
|
||||||
pos.x = 0;
|
pos.x = 0;
|
||||||
|
|
||||||
if (pos.y < 0)
|
if (pos.y < 0)
|
||||||
@@ -1973,7 +1971,7 @@ TermView::AddSelectRegion(CurPos pos)
|
|||||||
|
|
||||||
if (fTextBuffer->GetChar(pos.y, pos.x, buf, &attr) == IN_STRING) {
|
if (fTextBuffer->GetChar(pos.y, pos.x, buf, &attr) == IN_STRING) {
|
||||||
pos.x++;
|
pos.x++;
|
||||||
if(pos.x >= fTermColumns)
|
if (pos.x >= fTermColumns)
|
||||||
pos.x = fTermColumns - 1;
|
pos.x = fTermColumns - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2052,10 +2050,10 @@ TermView::ResizeSelectRegion(CurPos pos)
|
|||||||
|
|
||||||
pos.x++;
|
pos.x++;
|
||||||
|
|
||||||
if(pos == inPos)
|
if (pos == inPos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(pos.x >= fTermColumns)
|
if (pos.x >= fTermColumns)
|
||||||
pos.x = fTermColumns - 1;
|
pos.x = fTermColumns - 1;
|
||||||
}
|
}
|
||||||
fSelEnd = pos;
|
fSelEnd = pos;
|
||||||
@@ -2305,18 +2303,16 @@ TermView::GetSelection(BString &str)
|
|||||||
inline void
|
inline void
|
||||||
TermView::SendDataToDrawEngine(int x1, int y1, int x2, int y2)
|
TermView::SendDataToDrawEngine(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
// TODO: remove the goto
|
|
||||||
|
|
||||||
sem_info info;
|
sem_info info;
|
||||||
|
|
||||||
retry:
|
for (;;) {
|
||||||
|
get_sem_info(fDrawRectSem, &info);
|
||||||
|
|
||||||
get_sem_info(fDrawRectSem, &info);
|
if ((RECT_BUF_SIZE - info.count) < 2) {
|
||||||
|
snooze(10 * 1000);
|
||||||
if((RECT_BUF_SIZE - info.count) < 2) {
|
continue;
|
||||||
|
} else
|
||||||
snooze(10 * 1000);
|
break;
|
||||||
goto retry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fDrawRectBuffer[fDrawRect_p].x1 = x1;
|
fDrawRectBuffer[fDrawRect_p].x1 = x1;
|
||||||
|
|||||||
Reference in New Issue
Block a user