Added a TermView::NotifyQuit() method, used in TermParse, so it doesn't
mess with be_app anymore. Renamed TermView private methods to have an underscore prefix. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21743 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Beep.h>
|
#include <Beep.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
@@ -150,7 +149,8 @@ TermParse::PtyReader()
|
|||||||
uchar buf[READ_BUF_SIZE];
|
uchar buf[READ_BUF_SIZE];
|
||||||
int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition));
|
int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fBufferPosition));
|
||||||
if (nread <= 0) {
|
if (nread <= 0) {
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
// TODO: errno ? (Jerome ?) :)
|
||||||
|
fView->NotifyQuit(nread);
|
||||||
exit_thread(B_ERROR);
|
exit_thread(B_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+159
-141
@@ -14,7 +14,6 @@
|
|||||||
#include "TermView.h"
|
#include "TermView.h"
|
||||||
|
|
||||||
#include "CodeConv.h"
|
#include "CodeConv.h"
|
||||||
#include "PrefView.h"
|
|
||||||
#include "Shell.h"
|
#include "Shell.h"
|
||||||
#include "TermBuffer.h"
|
#include "TermBuffer.h"
|
||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
@@ -545,7 +544,7 @@ TermView::InsertSpace(int num)
|
|||||||
UpdateLine();
|
UpdateLine();
|
||||||
|
|
||||||
fTextBuffer->InsertSpace(fCurPos, num);
|
fTextBuffer->InsertSpace(fCurPos, num);
|
||||||
TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
_TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -560,14 +559,14 @@ TermView::SetInsertMode(int flag)
|
|||||||
|
|
||||||
//! Draw region
|
//! Draw region
|
||||||
inline int
|
inline int
|
||||||
TermView::TermDraw(const CurPos &start, const CurPos &end)
|
TermView::_TermDraw(const CurPos &start, const CurPos &end)
|
||||||
{
|
{
|
||||||
int x1 = start.x;
|
int x1 = start.x;
|
||||||
int y1 = start.y;
|
int y1 = start.y;
|
||||||
int x2 = end.x;
|
int x2 = end.x;
|
||||||
int y2 = end.y;
|
int y2 = end.y;
|
||||||
|
|
||||||
Redraw(x1, y1 + fTop / fFontHeight,
|
_Redraw(x1, y1 + fTop / fFontHeight,
|
||||||
x2, y2 + fTop / fFontHeight);
|
x2, y2 + fTop / fFontHeight);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -576,7 +575,7 @@ TermView::TermDraw(const CurPos &start, const CurPos &end)
|
|||||||
|
|
||||||
//! Draw region
|
//! Draw region
|
||||||
int
|
int
|
||||||
TermView::TermDrawSelectedRegion(CurPos start, CurPos end)
|
TermView::_TermDrawSelectedRegion(CurPos start, CurPos end)
|
||||||
{
|
{
|
||||||
CurPos inPos;
|
CurPos inPos;
|
||||||
|
|
||||||
@@ -587,14 +586,14 @@ TermView::TermDrawSelectedRegion(CurPos start, CurPos end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (start.y == end.y) {
|
if (start.y == end.y) {
|
||||||
Redraw(start.x, start.y, end.x, end.y);
|
_Redraw(start.x, start.y, end.x, end.y);
|
||||||
} else {
|
} else {
|
||||||
Redraw(start.x, start.y, fTermColumns, start.y);
|
_Redraw(start.x, start.y, fTermColumns, start.y);
|
||||||
|
|
||||||
if (end.y - start.y > 0)
|
if (end.y - start.y > 0)
|
||||||
Redraw(0, start.y + 1, fTermColumns, end.y - 1);
|
_Redraw(0, start.y + 1, fTermColumns, end.y - 1);
|
||||||
|
|
||||||
Redraw(0, end.y, end.x, end.y);
|
_Redraw(0, end.y, end.x, end.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -603,7 +602,7 @@ TermView::TermDrawSelectedRegion(CurPos start, CurPos end)
|
|||||||
|
|
||||||
//! Draw region
|
//! Draw region
|
||||||
int
|
int
|
||||||
TermView::TermDrawRegion(CurPos start, CurPos end)
|
TermView::_TermDrawRegion(CurPos start, CurPos end)
|
||||||
{
|
{
|
||||||
CurPos inPos;
|
CurPos inPos;
|
||||||
int top = fTop / fFontHeight;
|
int top = fTop / fFontHeight;
|
||||||
@@ -618,14 +617,14 @@ TermView::TermDrawRegion(CurPos start, CurPos end)
|
|||||||
end.y += top;
|
end.y += top;
|
||||||
|
|
||||||
if (start.y == end.y) {
|
if (start.y == end.y) {
|
||||||
Redraw(start.x, start.y, end.x, end.y);
|
_Redraw(start.x, start.y, end.x, end.y);
|
||||||
} else {
|
} else {
|
||||||
Redraw(start.x, start.y, fTermColumns - 1, start.y);
|
_Redraw(start.x, start.y, fTermColumns - 1, start.y);
|
||||||
|
|
||||||
if (end.y - start.y > 0) {
|
if (end.y - start.y > 0) {
|
||||||
Redraw(0, start.y + 1, fTermColumns - 1, end.y - 1);
|
_Redraw(0, start.y + 1, fTermColumns - 1, end.y - 1);
|
||||||
}
|
}
|
||||||
Redraw(0, end.y, end.x, end.y);
|
_Redraw(0, end.y, end.x, end.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -639,9 +638,9 @@ TermView::EraseBelow()
|
|||||||
UpdateLine();
|
UpdateLine();
|
||||||
|
|
||||||
fTextBuffer->EraseBelow(fCurPos);
|
fTextBuffer->EraseBelow(fCurPos);
|
||||||
TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
_TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
||||||
if (fCurPos.y != fTermRows - 1)
|
if (fCurPos.y != fTermRows - 1)
|
||||||
TermDraw(CurPos(0, fCurPos.y + 1), CurPos(fTermColumns - 1, fTermRows - 1));
|
_TermDraw(CurPos(0, fCurPos.y + 1), CurPos(fTermColumns - 1, fTermRows - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -652,7 +651,7 @@ TermView::DeleteChar(int num)
|
|||||||
UpdateLine();
|
UpdateLine();
|
||||||
|
|
||||||
fTextBuffer->DeleteChar(fCurPos, num);
|
fTextBuffer->DeleteChar(fCurPos, num);
|
||||||
TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
_TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -663,7 +662,7 @@ TermView::DeleteColumns()
|
|||||||
UpdateLine();
|
UpdateLine();
|
||||||
|
|
||||||
fTextBuffer->DeleteChar(fCurPos, fTermColumns - fCurPos.x);
|
fTextBuffer->DeleteChar(fCurPos, fTermColumns - fCurPos.x);
|
||||||
TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
_TermDraw(fCurPos, CurPos(fTermColumns - 1, fCurPos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -817,7 +816,7 @@ TermView::DrawCursor()
|
|||||||
ushort attr;
|
ushort attr;
|
||||||
|
|
||||||
int top = fTop / fFontHeight;
|
int top = fTop / fFontHeight;
|
||||||
bool m_flag = CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + fTop / fFontHeight));
|
bool m_flag = _CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + fTop / fFontHeight));
|
||||||
if (fTextBuffer->GetChar(fCurPos.y + top, fCurPos.x, buf, &attr) == A_CHAR) {
|
if (fTextBuffer->GetChar(fCurPos.y + top, fCurPos.x, buf, &attr) == A_CHAR) {
|
||||||
int width;
|
int width;
|
||||||
if (IS_WIDTH(attr))
|
if (IS_WIDTH(attr))
|
||||||
@@ -825,7 +824,7 @@ TermView::DrawCursor()
|
|||||||
else
|
else
|
||||||
width = 1;
|
width = 1;
|
||||||
|
|
||||||
DrawLines(fCurPos.x * fFontWidth,
|
_DrawLines(fCurPos.x * fFontWidth,
|
||||||
fCurPos.y * fFontHeight + fTop,
|
fCurPos.y * fFontHeight + fTop,
|
||||||
attr, buf, width, m_flag, true, this);
|
attr, buf, width, m_flag, true, this);
|
||||||
} else {
|
} else {
|
||||||
@@ -848,7 +847,7 @@ TermView::BlinkCursor()
|
|||||||
&& fCursorBlinkingFlag == CURON
|
&& fCursorBlinkingFlag == CURON
|
||||||
&& Window()->IsActive()) {
|
&& Window()->IsActive()) {
|
||||||
if (fCursorStatus == CURON)
|
if (fCursorStatus == CURON)
|
||||||
TermDraw(fCurPos, fCurPos);
|
_TermDraw(fCurPos, fCurPos);
|
||||||
else
|
else
|
||||||
DrawCursor();
|
DrawCursor();
|
||||||
|
|
||||||
@@ -864,7 +863,7 @@ TermView::SetCurDraw(bool flag)
|
|||||||
{
|
{
|
||||||
if (flag == CUROFF) {
|
if (flag == CUROFF) {
|
||||||
if (fCursorStatus == CURON)
|
if (fCursorStatus == CURON)
|
||||||
TermDraw(fCurPos, fCurPos);
|
_TermDraw(fCurPos, fCurPos);
|
||||||
|
|
||||||
fCursorStatus = CUROFF;
|
fCursorStatus = CUROFF;
|
||||||
fCursorDrawFlag = CUROFF;
|
fCursorDrawFlag = CUROFF;
|
||||||
@@ -909,7 +908,7 @@ TermView::ScrollRegion(int top, int bot, int dir, int num)
|
|||||||
bot = fScrBot;
|
bot = fScrBot;
|
||||||
|
|
||||||
fTextBuffer->ScrollRegion(top, bot , dir ,num);
|
fTextBuffer->ScrollRegion(top, bot , dir ,num);
|
||||||
TermDraw(CurPos(0, top), CurPos(fTermColumns - 1, bot));
|
_TermDraw(CurPos(0, top), CurPos(fTermColumns - 1, bot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -941,7 +940,7 @@ void
|
|||||||
TermView::ScrollAtCursor()
|
TermView::ScrollAtCursor()
|
||||||
{
|
{
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
ResizeScrBarRange();
|
_ResizeScrBarRange();
|
||||||
fScrollUpCount = 0;
|
fScrollUpCount = 0;
|
||||||
ScrollTo(0, fTop);
|
ScrollTo(0, fTop);
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
@@ -954,7 +953,7 @@ TermView::_InitMouseThread()
|
|||||||
{
|
{
|
||||||
// spawn Mouse Tracking thread.
|
// spawn Mouse Tracking thread.
|
||||||
if (fMouseThread < 0) {
|
if (fMouseThread < 0) {
|
||||||
fMouseThread = spawn_thread(MouseTracking, "MouseTracking",
|
fMouseThread = spawn_thread(_MouseTrackingEntryFunction, "MouseTracking",
|
||||||
B_NORMAL_PRIORITY,this);
|
B_NORMAL_PRIORITY,this);
|
||||||
} else
|
} else
|
||||||
return B_BAD_THREAD_ID;
|
return B_BAD_THREAD_ID;
|
||||||
@@ -963,9 +962,17 @@ TermView::_InitMouseThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
int32
|
||||||
|
TermView::_MouseTrackingEntryFunction(void *data)
|
||||||
|
{
|
||||||
|
return static_cast<TermView *>(data)->_MouseTracking();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Thread for tracking mouse.
|
//! Thread for tracking mouse.
|
||||||
int32
|
int32
|
||||||
TermView::MouseTracking(void *data)
|
TermView::_MouseTracking()
|
||||||
{
|
{
|
||||||
int32 code, selected = false;
|
int32 code, selected = false;
|
||||||
uint32 button;
|
uint32 button;
|
||||||
@@ -974,31 +981,28 @@ TermView::MouseTracking(void *data)
|
|||||||
BPoint stpoint, edpoint;
|
BPoint stpoint, edpoint;
|
||||||
float scr_start, scr_end, scr_pos;
|
float scr_start, scr_end, scr_pos;
|
||||||
|
|
||||||
TermView *theObj =(TermView *)data;
|
while(!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->HasSelection()
|
if (_HasSelection()
|
||||||
&& (modifiers() & B_CONTROL_KEY)) {
|
&& (modifiers() & B_CONTROL_KEY)) {
|
||||||
|
|
||||||
if (theObj->LockLooper()) {
|
if (LockLooper()) {
|
||||||
theObj->GetMouse(&stpoint, &button);
|
GetMouse(&stpoint, &button);
|
||||||
r = theObj->Bounds();
|
r = Bounds();
|
||||||
theObj->UnlockLooper();
|
UnlockLooper();
|
||||||
}
|
}
|
||||||
if (r.Contains(stpoint)) {
|
if (r.Contains(stpoint)) {
|
||||||
CurPos tmppos = theObj->BPointToCurPos(stpoint);
|
CurPos tmppos = _BPointToCurPos(stpoint);
|
||||||
if (theObj->fSelStart > theObj->fSelEnd) {
|
if (fSelStart > fSelEnd) {
|
||||||
stpos = theObj->fSelEnd;
|
stpos = fSelEnd;
|
||||||
edpos = theObj->fSelStart;
|
edpos = fSelStart;
|
||||||
} else {
|
} else {
|
||||||
stpos = theObj->fSelStart;
|
stpos = fSelStart;
|
||||||
edpos = theObj->fSelEnd;
|
edpos = fSelEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmppos > stpos && tmppos < edpos)
|
if (tmppos > stpos && tmppos < edpos)
|
||||||
@@ -1017,21 +1021,21 @@ TermView::MouseTracking(void *data)
|
|||||||
if (code != MOUSE_THR_CODE)
|
if (code != MOUSE_THR_CODE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
selected = theObj->HasSelection();
|
selected = _HasSelection();
|
||||||
edpoint.Set(-1, -1);
|
edpoint.Set(-1, -1);
|
||||||
|
|
||||||
stpos = theObj->BPointToCurPos(stpoint);
|
stpos = _BPointToCurPos(stpoint);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
snooze(40 * 1000);
|
snooze(40 * 1000);
|
||||||
|
|
||||||
if (theObj->LockLooper()) {
|
if (LockLooper()) {
|
||||||
theObj->GetMouse(&edpoint, &button);
|
GetMouse(&edpoint, &button);
|
||||||
theObj->UnlockLooper();
|
UnlockLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
edpos = theObj->BPointToCurPos(edpoint);
|
edpos = _BPointToCurPos(edpoint);
|
||||||
if (edpos.y < 0)
|
if (edpos.y < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1039,7 +1043,7 @@ TermView::MouseTracking(void *data)
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
theObj->Select(stpos, edpos);
|
_Select(stpos, edpos);
|
||||||
selected = true;
|
selected = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -1048,56 +1052,55 @@ TermView::MouseTracking(void *data)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (edpos > stpos) {
|
if (edpos > stpos) {
|
||||||
edpoint.x -= theObj->fFontWidth / 2;
|
edpoint.x -= fFontWidth / 2;
|
||||||
edpos = theObj->BPointToCurPos(edpoint);
|
edpos = _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 += fFontWidth / 2;
|
||||||
edpos = theObj->BPointToCurPos(edpoint);
|
edpos = _BPointToCurPos(edpoint);
|
||||||
//edpos.x++;
|
//edpos.x++;
|
||||||
if (edpos.x > theObj->fTermColumns)
|
if (edpos.x > fTermColumns)
|
||||||
edpos.x = theObj->fTermColumns;
|
edpos.x = fTermColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll check
|
// Scroll check
|
||||||
if (theObj->fScrollBar != NULL && theObj->LockLooper()) {
|
if (fScrollBar != NULL && LockLooper()) {
|
||||||
// Get now scroll point
|
// Get now scroll point
|
||||||
theObj->fScrollBar->GetRange(&scr_start, &scr_end);
|
fScrollBar->GetRange(&scr_start, &scr_end);
|
||||||
scr_pos = theObj->fScrollBar->Value();
|
scr_pos = fScrollBar->Value();
|
||||||
|
|
||||||
if (edpoint.y < theObj->Bounds().LeftTop().y )
|
if (edpoint.y < 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);
|
ScrollTo(0, edpoint.y);
|
||||||
|
|
||||||
if (edpoint.y > theObj->Bounds().LeftBottom().y) {
|
if (edpoint.y > 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);
|
ScrollTo(0, edpoint.y);
|
||||||
}
|
}
|
||||||
theObj->UnlockLooper();
|
UnlockLooper();
|
||||||
}
|
}
|
||||||
theObj->ResizeSelectRegion(edpos);
|
_ResizeSelectRegion(edpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(button);
|
} while(button);
|
||||||
theObj->fMouseTracking = false;
|
fMouseTracking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_thread(B_OK);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Draw character on offscreen bitmap.
|
//! Draw character on offscreen bitmap.
|
||||||
void
|
void
|
||||||
TermView::DrawLines(int x1, int y1, ushort attr, uchar *buf,
|
TermView::_DrawLines(int x1, int y1, ushort attr, uchar *buf,
|
||||||
int width, int mouse, int cursor, BView *inView)
|
int width, int mouse, int cursor, BView *inView)
|
||||||
{
|
{
|
||||||
int x2, y2;
|
int x2, y2;
|
||||||
@@ -1171,7 +1174,7 @@ TermView::DrawLines(int x1, int y1, ushort attr, uchar *buf,
|
|||||||
|
|
||||||
//! Resize scroll bar range and knob size.
|
//! Resize scroll bar range and knob size.
|
||||||
void
|
void
|
||||||
TermView::ResizeScrBarRange()
|
TermView::_ResizeScrBarRange()
|
||||||
{
|
{
|
||||||
if (fScrollBar == NULL)
|
if (fScrollBar == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -1198,7 +1201,7 @@ TermView::ScrollScreen()
|
|||||||
|
|
||||||
if (fScrollUpCount > fTermRows ) {
|
if (fScrollUpCount > fTermRows ) {
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
ResizeScrBarRange();
|
_ResizeScrBarRange();
|
||||||
fScrollBarRange += fScrollUpCount;
|
fScrollBarRange += fScrollUpCount;
|
||||||
fScrollUpCount = 0;
|
fScrollUpCount = 0;
|
||||||
ScrollTo(0, fTop);
|
ScrollTo(0, fTop);
|
||||||
@@ -1214,7 +1217,7 @@ TermView::ScrollScreenDraw()
|
|||||||
{
|
{
|
||||||
if (fScrollUpCount){
|
if (fScrollUpCount){
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
ResizeScrBarRange();
|
_ResizeScrBarRange();
|
||||||
|
|
||||||
fScrollBarRange += fScrollUpCount;
|
fScrollBarRange += fScrollUpCount;
|
||||||
fScrollUpCount = 0;
|
fScrollUpCount = 0;
|
||||||
@@ -1230,10 +1233,10 @@ void
|
|||||||
TermView::_UpdateSIGWINCH()
|
TermView::_UpdateSIGWINCH()
|
||||||
{
|
{
|
||||||
if (fFrameResized) {
|
if (fFrameResized) {
|
||||||
if (HasSelection())
|
if (_HasSelection())
|
||||||
TermDrawSelectedRegion(fSelStart, fSelEnd);
|
_TermDrawSelectedRegion(fSelStart, fSelEnd);
|
||||||
ScrollTo(0, fTop);
|
ScrollTo(0, fTop);
|
||||||
ResizeScrBarRange();
|
_ResizeScrBarRange();
|
||||||
|
|
||||||
fShell->UpdateWindowSize(fTermRows, fTermColumns);
|
fShell->UpdateWindowSize(fTermRows, fTermColumns);
|
||||||
|
|
||||||
@@ -1272,10 +1275,10 @@ TermView::UpdateLine()
|
|||||||
{
|
{
|
||||||
if (fUpdateFlag == true) {
|
if (fUpdateFlag == true) {
|
||||||
if (fInsertModeFlag == MODE_INSERT) {
|
if (fInsertModeFlag == MODE_INSERT) {
|
||||||
TermDraw(CurPos(fBufferStartPos, fCurPos.y),
|
_TermDraw(CurPos(fBufferStartPos, fCurPos.y),
|
||||||
CurPos(fTermColumns - 1, fCurPos.y));
|
CurPos(fTermColumns - 1, fCurPos.y));
|
||||||
} else {
|
} else {
|
||||||
TermDraw(CurPos(fBufferStartPos, fCurPos.y),
|
_TermDraw(CurPos(fBufferStartPos, fCurPos.y),
|
||||||
CurPos(fCurPos.x - 1, fCurPos.y));
|
CurPos(fCurPos.x - 1, fCurPos.y));
|
||||||
}
|
}
|
||||||
fUpdateFlag = false;
|
fUpdateFlag = false;
|
||||||
@@ -1318,7 +1321,7 @@ void
|
|||||||
TermView::Draw(BRect updateRect)
|
TermView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
if (IsPrinting()) {
|
if (IsPrinting()) {
|
||||||
DoPrint(updateRect);
|
_DoPrint(updateRect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,7 +1353,7 @@ TermView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
for (i = k; i <= x2;) {
|
for (i = k; i <= x2;) {
|
||||||
count = fTextBuffer->GetString(j, i, x2, buf, &attr);
|
count = fTextBuffer->GetString(j, i, x2, buf, &attr);
|
||||||
m_flag = CheckSelectedRegion(CurPos(i, j));
|
m_flag = _CheckSelectedRegion(CurPos(i, j));
|
||||||
|
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
if (m_flag) {
|
if (m_flag) {
|
||||||
@@ -1366,7 +1369,7 @@ TermView::Draw(BRect updateRect)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawLines(fFontWidth * i, fFontHeight * j,
|
_DrawLines(fFontWidth * i, fFontHeight * j,
|
||||||
attr, buf, count, m_flag, false, this);
|
attr, buf, count, m_flag, false, this);
|
||||||
i += count;
|
i += count;
|
||||||
if (i >= fTermColumns)
|
if (i >= fTermColumns)
|
||||||
@@ -1382,7 +1385,7 @@ TermView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::DoPrint(BRect updateRect)
|
TermView::_DoPrint(BRect updateRect)
|
||||||
{
|
{
|
||||||
ushort attr;
|
ushort attr;
|
||||||
uchar buf[256];
|
uchar buf[256];
|
||||||
@@ -1417,7 +1420,7 @@ TermView::DoPrint(BRect updateRect)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawLines(fFontWidth * i, fFontHeight * j,
|
_DrawLines(fFontWidth * i, fFontHeight * j,
|
||||||
attr, buf, count, false, false, this);
|
attr, buf, count, false, false, this);
|
||||||
i += count;
|
i += count;
|
||||||
}
|
}
|
||||||
@@ -1587,11 +1590,11 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
{
|
{
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
if (msg->FindRef("refs", i++, &ref) == B_OK) {
|
if (msg->FindRef("refs", i++, &ref) == B_OK) {
|
||||||
DoFileDrop(ref);
|
_DoFileDrop(ref);
|
||||||
|
|
||||||
while (msg->FindRef("refs", i++, &ref) == B_OK) {
|
while (msg->FindRef("refs", i++, &ref) == B_OK) {
|
||||||
WritePTY((const uchar*)" ", 1);
|
_WritePTY((const uchar*)" ", 1);
|
||||||
DoFileDrop(ref);
|
_DoFileDrop(ref);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(msg);
|
||||||
@@ -1610,25 +1613,25 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
if (sts != B_OK)
|
if (sts != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
WritePTY((uchar *)text, numBytes);
|
_WritePTY((uchar *)text, numBytes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_COPY:
|
case B_COPY:
|
||||||
DoCopy();
|
_DoCopy();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PASTE:
|
case B_PASTE:
|
||||||
{
|
{
|
||||||
int32 code;
|
int32 code;
|
||||||
if (msg->FindInt32("index", &code) == B_OK)
|
if (msg->FindInt32("index", &code) == B_OK)
|
||||||
DoPaste();
|
_DoPaste();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_SELECT_ALL:
|
case B_SELECT_ALL:
|
||||||
DoSelectAll();
|
_DoSelectAll();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_SET_PROPERTY: {
|
case B_SET_PROPERTY: {
|
||||||
@@ -1666,7 +1669,7 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case MENU_CLEAR_ALL:
|
case MENU_CLEAR_ALL:
|
||||||
DoClearAll();
|
_DoClearAll();
|
||||||
fShell->Write(ctrl_l, 1);
|
fShell->Write(ctrl_l, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1745,22 +1748,22 @@ TermView::ResolveSpecifier(BMessage *msg, 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);
|
||||||
BString string(path.Path());
|
BString string(path.Path());
|
||||||
|
|
||||||
string.CharacterEscape(" ~`#$&*()\\|[]{};'\"<>?!",'\\');
|
string.CharacterEscape(" ~`#$&*()\\|[]{};'\"<>?!",'\\');
|
||||||
WritePTY((const uchar *)string.String(), string.Length());
|
_WritePTY((const uchar *)string.String(), string.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Copy selected text to Clipboard.
|
//! Copy selected text to Clipboard.
|
||||||
void
|
void
|
||||||
TermView::DoCopy()
|
TermView::_DoCopy()
|
||||||
{
|
{
|
||||||
if (!HasSelection())
|
if (!_HasSelection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BString copyStr;
|
BString copyStr;
|
||||||
@@ -1782,13 +1785,13 @@ TermView::DoCopy()
|
|||||||
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Paste clipboard text at cursor position.
|
//! Paste clipboard text at cursor position.
|
||||||
void
|
void
|
||||||
TermView::DoPaste()
|
TermView::_DoPaste()
|
||||||
{
|
{
|
||||||
if (be_clipboard->Lock()) {
|
if (be_clipboard->Lock()) {
|
||||||
BMessage *clipMsg = be_clipboard->Data();
|
BMessage *clipMsg = be_clipboard->Data();
|
||||||
@@ -1798,7 +1801,7 @@ TermView::DoPaste()
|
|||||||
(const void **)&text, &numBytes) == B_OK ) {
|
(const void **)&text, &numBytes) == B_OK ) {
|
||||||
// Clipboard text doesn't attached EOF?
|
// Clipboard text doesn't attached EOF?
|
||||||
text[numBytes] = '\0';
|
text[numBytes] = '\0';
|
||||||
WritePTY((uchar *)text, numBytes);
|
_WritePTY((uchar *)text, numBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
@@ -1808,7 +1811,7 @@ TermView::DoPaste()
|
|||||||
|
|
||||||
//! Select all displayed text and text /in buffer.
|
//! Select all displayed text and text /in buffer.
|
||||||
void
|
void
|
||||||
TermView::DoSelectAll(void)
|
TermView::_DoSelectAll(void)
|
||||||
{
|
{
|
||||||
CurPos start, end;
|
CurPos start, end;
|
||||||
int screen_top;
|
int screen_top;
|
||||||
@@ -1829,14 +1832,14 @@ TermView::DoSelectAll(void)
|
|||||||
|
|
||||||
end.y = fCurPos.y + screen_top;
|
end.y = fCurPos.y + screen_top;
|
||||||
|
|
||||||
Select(start, end);
|
_Select(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear display and text buffer, then moves Cursorr at home position.
|
// Clear display and text buffer, then moves Cursorr at home position.
|
||||||
void
|
void
|
||||||
TermView::DoClearAll(void)
|
TermView::_DoClearAll(void)
|
||||||
{
|
{
|
||||||
DeSelect();
|
_DeSelect();
|
||||||
fTextBuffer->Clear();
|
fTextBuffer->Clear();
|
||||||
|
|
||||||
fTop = 0;
|
fTop = 0;
|
||||||
@@ -1864,7 +1867,7 @@ TermView::DoClearAll(void)
|
|||||||
encoding to UTF8 before writing PTY.
|
encoding to UTF8 before writing PTY.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TermView::WritePTY(const uchar *text, int numBytes)
|
TermView::_WritePTY(const uchar *text, int numBytes)
|
||||||
{
|
{
|
||||||
if (fEncoding != M_UTF8) {
|
if (fEncoding != M_UTF8) {
|
||||||
uchar *destBuffer = (uchar *)malloc(numBytes * 3);
|
uchar *destBuffer = (uchar *)malloc(numBytes * 3);
|
||||||
@@ -1886,14 +1889,14 @@ TermView::MouseDown(BPoint where)
|
|||||||
|
|
||||||
// paste button
|
// paste button
|
||||||
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
|
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
|
||||||
if (HasSelection()) {
|
if (_HasSelection()) {
|
||||||
// copy text from region
|
// copy text from region
|
||||||
BString copy;
|
BString copy;
|
||||||
fTextBuffer->GetStringFromRegion(copy, fSelStart, fSelEnd);
|
fTextBuffer->GetStringFromRegion(copy, fSelStart, fSelEnd);
|
||||||
WritePTY((uchar *)copy.String(), copy.Length());
|
_WritePTY((uchar *)copy.String(), copy.Length());
|
||||||
} else {
|
} else {
|
||||||
// copy text from clipboard.
|
// copy text from clipboard.
|
||||||
DoPaste();
|
_DoPaste();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1904,7 +1907,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
Window()->CurrentMessage()->FindInt32("modifiers", &mod);
|
Window()->CurrentMessage()->FindInt32("modifiers", &mod);
|
||||||
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
|
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
|
||||||
|
|
||||||
if (HasSelection()) {
|
if (_HasSelection()) {
|
||||||
CurPos inPos, stPos, edPos;
|
CurPos inPos, stPos, edPos;
|
||||||
if (fSelStart < fSelEnd) {
|
if (fSelStart < fSelEnd) {
|
||||||
stPos = fSelStart;
|
stPos = fSelStart;
|
||||||
@@ -1914,7 +1917,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
edPos = fSelStart;
|
edPos = fSelStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
inPos = BPointToCurPos(where);
|
inPos = _BPointToCurPos(where);
|
||||||
|
|
||||||
// If mouse pointer is avove selected Region, start Drag'n Copy.
|
// If mouse pointer is avove selected Region, start Drag'n Copy.
|
||||||
if (inPos > stPos && inPos < edPos) {
|
if (inPos > stPos && inPos < edPos) {
|
||||||
@@ -1925,7 +1928,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
GetMouse(&p, &bt);
|
GetMouse(&p, &bt);
|
||||||
|
|
||||||
if (bt == 0) {
|
if (bt == 0) {
|
||||||
DeSelect();
|
_DeSelect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1940,8 +1943,8 @@ TermView::MouseDown(BPoint where)
|
|||||||
BMessage msg(B_MIME_TYPE);
|
BMessage msg(B_MIME_TYPE);
|
||||||
msg.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length());
|
msg.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length());
|
||||||
|
|
||||||
BPoint st = CurPosToBPoint(stPos);
|
BPoint st = _CurPosToBPoint(stPos);
|
||||||
BPoint ed = CurPosToBPoint(edPos);
|
BPoint ed = _CurPosToBPoint(edPos);
|
||||||
BRect r;
|
BRect r;
|
||||||
|
|
||||||
if (stPos.y == edPos.y) {
|
if (stPos.y == edPos.y) {
|
||||||
@@ -1970,9 +1973,9 @@ TermView::MouseDown(BPoint where)
|
|||||||
fPreviousMousePoint = where;
|
fPreviousMousePoint = where;
|
||||||
|
|
||||||
if (mod & B_SHIFT_KEY)
|
if (mod & B_SHIFT_KEY)
|
||||||
AddSelectRegion(BPointToCurPos(where));
|
_AddSelectRegion(_BPointToCurPos(where));
|
||||||
else
|
else
|
||||||
DeSelect();
|
_DeSelect();
|
||||||
|
|
||||||
|
|
||||||
// If clicks larger than 3, reset mouse click counter.
|
// If clicks larger than 3, reset mouse click counter.
|
||||||
@@ -1987,11 +1990,11 @@ TermView::MouseDown(BPoint where)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
SelectWord(where, mod);
|
_SelectWord(where, mod);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
SelectLine(where, mod);
|
_SelectLine(where, mod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -2009,7 +2012,7 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
|||||||
|
|
||||||
// Select a range of text
|
// Select a range of text
|
||||||
void
|
void
|
||||||
TermView::Select(CurPos start, CurPos end)
|
TermView::_Select(CurPos start, CurPos end)
|
||||||
{
|
{
|
||||||
uchar buf[4];
|
uchar buf[4];
|
||||||
ushort attr;
|
ushort attr;
|
||||||
@@ -2035,18 +2038,19 @@ TermView::Select(CurPos start, CurPos end)
|
|||||||
fSelEnd = end;
|
fSelEnd = end;
|
||||||
|
|
||||||
fTextBuffer->Select(fSelStart, fSelEnd);
|
fTextBuffer->Select(fSelStart, fSelEnd);
|
||||||
TermDrawSelectedRegion(fSelStart, fSelEnd);
|
_TermDrawSelectedRegion(fSelStart, fSelEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add select region(shift + mouse click)
|
// Add select region(shift + mouse click)
|
||||||
void
|
void
|
||||||
TermView::AddSelectRegion(CurPos pos)
|
TermView::_AddSelectRegion(CurPos pos)
|
||||||
{
|
{
|
||||||
uchar buf[4];
|
uchar buf[4];
|
||||||
ushort attr;
|
ushort attr;
|
||||||
CurPos start, end, inPos;
|
CurPos start, end, inPos;
|
||||||
|
|
||||||
if (!HasSelection())
|
if (!_HasSelection())
|
||||||
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,
|
||||||
@@ -2113,12 +2117,13 @@ TermView::AddSelectRegion(CurPos pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fTextBuffer->Select(fSelStart, fSelEnd);
|
fTextBuffer->Select(fSelStart, fSelEnd);
|
||||||
TermDrawSelectedRegion(inPos, fSelEnd);
|
_TermDrawSelectedRegion(inPos, fSelEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Resize select region (mouse drag)
|
// Resize select region (mouse drag)
|
||||||
void
|
void
|
||||||
TermView::ResizeSelectRegion(CurPos pos)
|
TermView::_ResizeSelectRegion(CurPos pos)
|
||||||
{
|
{
|
||||||
CurPos inPos;
|
CurPos inPos;
|
||||||
uchar buf[4];
|
uchar buf[4];
|
||||||
@@ -2149,17 +2154,17 @@ TermView::ResizeSelectRegion(CurPos pos)
|
|||||||
fSelEnd = pos;
|
fSelEnd = pos;
|
||||||
|
|
||||||
fTextBuffer->Select(fSelStart, pos);
|
fTextBuffer->Select(fSelStart, pos);
|
||||||
TermDrawSelectedRegion(inPos, pos);
|
_TermDrawSelectedRegion(inPos, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DeSelect a range of text
|
// DeSelect a range of text
|
||||||
void
|
void
|
||||||
TermView::DeSelect(void)
|
TermView::_DeSelect(void)
|
||||||
{
|
{
|
||||||
CurPos start, end;
|
CurPos start, end;
|
||||||
|
|
||||||
if (!HasSelection())
|
if (!_HasSelection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fTextBuffer->DeSelect();
|
fTextBuffer->DeSelect();
|
||||||
@@ -2170,24 +2175,24 @@ TermView::DeSelect(void)
|
|||||||
fSelStart.Set(-1, -1);
|
fSelStart.Set(-1, -1);
|
||||||
fSelEnd.Set(-1, -1);
|
fSelEnd.Set(-1, -1);
|
||||||
|
|
||||||
TermDrawSelectedRegion(start, end);
|
_TermDrawSelectedRegion(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TermView::HasSelection() const
|
TermView::_HasSelection() const
|
||||||
{
|
{
|
||||||
return fSelStart != fSelEnd;
|
return fSelStart != fSelEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::SelectWord(BPoint where, int mod)
|
TermView::_SelectWord(BPoint where, int mod)
|
||||||
{
|
{
|
||||||
CurPos start, end, pos;
|
CurPos start, end, pos;
|
||||||
bool flag;
|
bool flag;
|
||||||
|
|
||||||
pos = BPointToCurPos(where);
|
pos = _BPointToCurPos(where);
|
||||||
flag = fTextBuffer->FindWord(pos, &start, &end);
|
flag = fTextBuffer->FindWord(pos, &start, &end);
|
||||||
fTextBuffer->Select(start, end);
|
fTextBuffer->Select(start, end);
|
||||||
|
|
||||||
@@ -2196,28 +2201,29 @@ TermView::SelectWord(BPoint where, int mod)
|
|||||||
if (flag) {
|
if (flag) {
|
||||||
|
|
||||||
if (start < fSelStart)
|
if (start < fSelStart)
|
||||||
AddSelectRegion(start);
|
_AddSelectRegion(start);
|
||||||
else if (end > fSelEnd)
|
else if (end > fSelEnd)
|
||||||
AddSelectRegion(end);
|
_AddSelectRegion(end);
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
AddSelectRegion(pos);
|
_AddSelectRegion(pos);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DeSelect();
|
_DeSelect();
|
||||||
if (flag)
|
if (flag)
|
||||||
Select(start, end);
|
_Select(start, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::SelectLine(BPoint where, int mod)
|
TermView::_SelectLine(BPoint where, int mod)
|
||||||
{
|
{
|
||||||
CurPos start, end, pos;
|
CurPos start, end, pos;
|
||||||
|
|
||||||
pos = BPointToCurPos(where);
|
pos = _BPointToCurPos(where);
|
||||||
|
|
||||||
if (mod & B_SHIFT_KEY) {
|
if (mod & B_SHIFT_KEY) {
|
||||||
|
|
||||||
@@ -2225,32 +2231,35 @@ TermView::SelectLine(BPoint where, int mod)
|
|||||||
end = CurPos(fTermColumns - 1, pos.y);
|
end = CurPos(fTermColumns - 1, pos.y);
|
||||||
|
|
||||||
if (start < fSelStart)
|
if (start < fSelStart)
|
||||||
AddSelectRegion(start);
|
_AddSelectRegion(start);
|
||||||
else if (end > fSelEnd)
|
else if (end > fSelEnd)
|
||||||
AddSelectRegion(end);
|
_AddSelectRegion(end);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DeSelect();
|
_DeSelect();
|
||||||
Select(CurPos(0, pos.y), CurPos(fTermColumns - 1, pos.y));
|
_Select(CurPos(0, pos.y), CurPos(fTermColumns - 1, pos.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert View visible area corrdination to cursor position.
|
// Convert View visible area corrdination to cursor position.
|
||||||
CurPos
|
CurPos
|
||||||
TermView::BPointToCurPos(const BPoint &p)
|
TermView::_BPointToCurPos(const BPoint &p)
|
||||||
{
|
{
|
||||||
return CurPos(p.x / fFontWidth, p.y / fFontHeight);
|
return CurPos(p.x / fFontWidth, p.y / fFontHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert cursor position to view coordination.
|
// Convert cursor position to view coordination.
|
||||||
BPoint
|
BPoint
|
||||||
TermView::CurPosToBPoint(const CurPos &pos)
|
TermView::_CurPosToBPoint(const CurPos &pos)
|
||||||
{
|
{
|
||||||
return BPoint(fFontWidth * pos.x, pos.y * fFontHeight + fTop);
|
return BPoint(fFontWidth * pos.x, pos.y * fFontHeight + fTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TermView::CheckSelectedRegion(const CurPos &pos)
|
TermView::_CheckSelectedRegion(const CurPos &pos)
|
||||||
{
|
{
|
||||||
CurPos start, end;
|
CurPos start, end;
|
||||||
|
|
||||||
@@ -2292,6 +2301,7 @@ TermView::GetFrameSize(float *width, float *height)
|
|||||||
*height = fTop + fTermRows * fFontHeight;
|
*height = fTop + fTermRows * fFontHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sets terninal rows and cols.
|
// Sets terninal rows and cols.
|
||||||
void
|
void
|
||||||
TermView::GetFontInfo(int *width, int *height)
|
TermView::GetFontInfo(int *width, int *height)
|
||||||
@@ -2300,6 +2310,7 @@ TermView::GetFontInfo(int *width, int *height)
|
|||||||
*height = fFontHeight;
|
*height = fFontHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Find a string, and select it if found
|
// Find a string, and select it if found
|
||||||
bool
|
bool
|
||||||
TermView::Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord)
|
TermView::Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord)
|
||||||
@@ -2380,8 +2391,8 @@ TermView::Find(const BString &str, bool forwardSearch, bool matchCase, bool matc
|
|||||||
selectionend.y = (result + str.Length() - 1) / fTermColumns;
|
selectionend.y = (result + str.Length() - 1) / fTermColumns;
|
||||||
selectionend.x = (result + str.Length() - 1) % fTermColumns;
|
selectionend.x = (result + str.Length() - 1) % fTermColumns;
|
||||||
//Update the contents of the view
|
//Update the contents of the view
|
||||||
DeSelect();
|
_DeSelect();
|
||||||
Select(selectionstart, selectionend);
|
_Select(selectionstart, selectionend);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2395,9 +2406,16 @@ TermView::GetSelection(BString &str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::NotifyQuit(int32 reason)
|
||||||
|
{
|
||||||
|
// TODO: If we are a replicant, we can't just quit the BWindow, no?.
|
||||||
|
Window()->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
TermView::Redraw(int x1, int y1, int x2, int y2)
|
TermView::_Redraw(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
BRect rect(x1 * fFontWidth, y1 * fFontHeight,
|
BRect rect(x1 * fFontWidth, y1 * fFontHeight,
|
||||||
(x2 + 1) * fFontWidth -1, (y2 + 1) * fFontHeight -1);
|
(x2 + 1) * fFontWidth -1, (y2 + 1) * fFontHeight -1);
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ public:
|
|||||||
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
||||||
void GetSelection(BString &str);
|
void GetSelection(BString &str);
|
||||||
|
|
||||||
|
void NotifyQuit(int32 reason);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
@@ -130,59 +132,59 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _InitObject(const char *command);
|
status_t _InitObject(const char *command);
|
||||||
|
|
||||||
static int32 MouseTracking(void *);
|
|
||||||
|
|
||||||
status_t _InitMouseThread(void);
|
status_t _InitMouseThread(void);
|
||||||
void DrawLines(int , int, ushort, uchar *, int, int, int, BView *);
|
void _DrawLines(int , int, ushort, uchar *, int, int, int, BView *);
|
||||||
int TermDraw(const CurPos &start, const CurPos &end);
|
int _TermDraw(const CurPos &start, const CurPos &end);
|
||||||
int TermDrawRegion(CurPos start, CurPos end);
|
int _TermDrawRegion(CurPos start, CurPos end);
|
||||||
int TermDrawSelectedRegion(CurPos start, CurPos end);
|
int _TermDrawSelectedRegion(CurPos start, CurPos end);
|
||||||
|
|
||||||
void DoPrint(BRect updateRect);
|
void _DoPrint(BRect updateRect);
|
||||||
void ResizeScrBarRange (void);
|
void _ResizeScrBarRange (void);
|
||||||
void DoFileDrop(entry_ref &ref);
|
void _DoFileDrop(entry_ref &ref);
|
||||||
|
|
||||||
// edit menu function.
|
// edit menu function.
|
||||||
void DoCopy();
|
void _DoCopy();
|
||||||
void DoPaste();
|
void _DoPaste();
|
||||||
void DoSelectAll();
|
void _DoSelectAll();
|
||||||
void DoClearAll();
|
void _DoClearAll();
|
||||||
|
|
||||||
void WritePTY(const uchar *text, int num_byteses);
|
void _WritePTY(const uchar *text, int num_byteses);
|
||||||
|
|
||||||
// Comunicate Input Method
|
// Comunicate Input Method
|
||||||
// void DoIMStart (BMessage* message);
|
// void _DoIMStart (BMessage* message);
|
||||||
// void DoIMStop (BMessage* message);
|
// void _DoIMStop (BMessage* message);
|
||||||
// void DoIMChange (BMessage* message);
|
// void _DoIMChange (BMessage* message);
|
||||||
// void DoIMLocation (BMessage* message);
|
// void _DoIMLocation (BMessage* message);
|
||||||
// void DoIMConfirm (void);
|
// void _DoIMConfirm (void);
|
||||||
void ConfirmString (const char *, int32);
|
void _ConfirmString (const char *, int32);
|
||||||
int32 GetCharFromUTF8String (const char *, char *);
|
int32 _GetCharFromUTF8String (const char *, char *);
|
||||||
int32 GetWidthFromUTF8String (const char *);
|
int32 _GetWidthFromUTF8String (const char *);
|
||||||
|
|
||||||
// Mouse select
|
// Mouse select
|
||||||
void Select(CurPos start, CurPos end);
|
void _Select(CurPos start, CurPos end);
|
||||||
void AddSelectRegion(CurPos);
|
void _AddSelectRegion(CurPos);
|
||||||
void ResizeSelectRegion(CurPos);
|
void _ResizeSelectRegion(CurPos);
|
||||||
|
|
||||||
void DeSelect();
|
void _DeSelect();
|
||||||
bool HasSelection() const;
|
bool _HasSelection() const;
|
||||||
|
|
||||||
// select word function
|
// select word function
|
||||||
void SelectWord(BPoint where, int mod);
|
void _SelectWord(BPoint where, int mod);
|
||||||
void SelectLine(BPoint where, int mod);
|
void _SelectLine(BPoint where, int mod);
|
||||||
|
|
||||||
// point and text offset conversion.
|
// point and text offset conversion.
|
||||||
CurPos BPointToCurPos(const BPoint &p);
|
CurPos _BPointToCurPos(const BPoint &p);
|
||||||
BPoint CurPosToBPoint(const CurPos &pos);
|
BPoint _CurPosToBPoint(const CurPos &pos);
|
||||||
|
|
||||||
bool CheckSelectedRegion(const CurPos &pos);
|
bool _CheckSelectedRegion(const CurPos &pos);
|
||||||
inline void Redraw(int, int, int, int);
|
inline void _Redraw(int, int, int, int);
|
||||||
|
|
||||||
void _UpdateSIGWINCH();
|
void _UpdateSIGWINCH();
|
||||||
static void _FixFontAttributes(BFont &font);
|
static void _FixFontAttributes(BFont &font);
|
||||||
|
|
||||||
|
static int32 _MouseTrackingEntryFunction(void *);
|
||||||
|
int32 _MouseTracking();
|
||||||
|
|
||||||
Shell *fShell;
|
Shell *fShell;
|
||||||
|
|
||||||
BMessageRunner *fWinchRunner;
|
BMessageRunner *fWinchRunner;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
const static float kViewOffset = 3;
|
const static float kViewOffset = 3;
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
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),
|
||||||
@@ -82,16 +82,17 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
|||||||
|
|
||||||
_NewTab(command);
|
_NewTab(command);
|
||||||
_NewTab(NULL);
|
_NewTab(NULL);
|
||||||
|
fTabView->Select(0);
|
||||||
|
/*
|
||||||
BView *view = new TermView(Bounds());
|
BView *view = new TermView(Bounds());
|
||||||
AddChild(view);
|
AddChild(view);
|
||||||
BRect draggerFrame(0, 0, 16, 16);
|
BRect _WritePTYdraggerFrame(0, 0, 16, 16);
|
||||||
draggerFrame.OffsetTo(Bounds().RightBottom() - BPoint(16, 16));
|
draggerFrame.OffsetTo(Bounds().RightBottom() - BPoint(16, 16));
|
||||||
BDragger *dragger = new BDragger(draggerFrame, view, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
BDragger *dragger = new BDragger(draggerFrame, view, B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||||
|
|
||||||
view->AddChild(dragger);
|
view->AddChild(dragger);*/
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
|
|
||||||
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
||||||
|
|||||||
Reference in New Issue
Block a user