Moved all TermView initializing code into TermView itself. Before you
couldn't just rely on its constructor to fully initialize the object, since the code was scattered around, mostly into TermWindow. Added a commented out TermWindow constructor which only creates and adds a TermView object to the view hierarchy, which now works. Removed weird TermWindowActivate method, use WindowActivated instead. TermApp can now keep a pointer to a BWindow instead of TermWindow, since it doesn't do anything special with it. TermView::SetTermFont() now can filter the font attributes (it uses B_FIXED_SPACING, I'm not sure it's needed but it doesn't hurt). Usual cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21698 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -25,8 +25,6 @@
|
|||||||
#include "TTextControl.h"
|
#include "TTextControl.h"
|
||||||
|
|
||||||
|
|
||||||
extern PrefHandler *PrefHandler::Default();
|
|
||||||
|
|
||||||
|
|
||||||
ShellPrefView::ShellPrefView(BRect frame, const char *name,
|
ShellPrefView::ShellPrefView(BRect frame, const char *name,
|
||||||
TermWindow *window)
|
TermWindow *window)
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ TermApp::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ACTIVATE_TERM:
|
case MSG_ACTIVATE_TERM:
|
||||||
fTermWindow->TermWinActivate();
|
fTermWindow->Activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_TERM_IS_MINIMIZE:
|
case MSG_TERM_IS_MINIMIZE:
|
||||||
|
|||||||
@@ -35,11 +35,8 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class TermWindow;
|
|
||||||
class TermParse;
|
|
||||||
class BRect;
|
class BRect;
|
||||||
|
class BWindow;
|
||||||
class TermApp : public BApplication {
|
class TermApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
TermApp();
|
TermApp();
|
||||||
@@ -71,7 +68,7 @@ class TermApp : public BApplication {
|
|||||||
BString fWindowTitle;
|
BString fWindowTitle;
|
||||||
int32 fWindowNumber;
|
int32 fWindowNumber;
|
||||||
|
|
||||||
TermWindow* fTermWindow;
|
BWindow* fTermWindow;
|
||||||
BRect fTermFrame;
|
BRect fTermFrame;
|
||||||
BString fCommandLine;
|
BString fCommandLine;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ const uint32 MENU_SHOW_COLOR = 'Mcol';
|
|||||||
|
|
||||||
const uint32 M_GET_DEVICE_NUM = 'Mgdn';
|
const uint32 M_GET_DEVICE_NUM = 'Mgdn';
|
||||||
|
|
||||||
// Message Runner
|
|
||||||
const uint32 MSGRUN_WINDOW = 'Rwin';
|
|
||||||
|
|
||||||
// Preference Message
|
// Preference Message
|
||||||
const ulong PSET__COLS = 'pcol';
|
const ulong PSET__COLS = 'pcol';
|
||||||
|
|||||||
@@ -17,18 +17,19 @@
|
|||||||
#include "PrefHandler.h"
|
#include "PrefHandler.h"
|
||||||
#include "PrefView.h"
|
#include "PrefView.h"
|
||||||
#include "Shell.h"
|
#include "Shell.h"
|
||||||
#include "TermApp.h"
|
|
||||||
#include "TermBuffer.h"
|
#include "TermBuffer.h"
|
||||||
#include "TermConst.h"
|
#include "TermConst.h"
|
||||||
#include "TermParse.h"
|
#include "TermParse.h"
|
||||||
#include "TermWindow.h"
|
|
||||||
#include "VTkeymap.h"
|
#include "VTkeymap.h"
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Beep.h>
|
#include <Beep.h>
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Input.h>
|
#include <Input.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <MessageRunner.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
@@ -107,6 +108,9 @@ const unsigned char M_ADD_CURSOR[] = {
|
|||||||
|
|
||||||
#define MOUSE_THR_CODE 'mtcd'
|
#define MOUSE_THR_CODE 'mtcd'
|
||||||
|
|
||||||
|
const static uint32 kUpdateSigWinch = 'Rwin';
|
||||||
|
|
||||||
|
|
||||||
TermView::TermView(BRect frame, const char *command)
|
TermView::TermView(BRect frame, const char *command)
|
||||||
: BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED),
|
: BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED),
|
||||||
fShell(NULL),
|
fShell(NULL),
|
||||||
@@ -152,12 +156,15 @@ TermView::TermView(BRect frame, const char *command)
|
|||||||
SetMouseCursor();
|
SetMouseCursor();
|
||||||
|
|
||||||
SetTermFont(be_plain_font, be_plain_font);
|
SetTermFont(be_plain_font, be_plain_font);
|
||||||
|
SetTermColor();
|
||||||
|
|
||||||
//SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE));
|
//SetIMAware(PrefHandler::Default()->getInt32(PREF_IM_AWARE));
|
||||||
|
|
||||||
// Get encoding name (setenv TTYPE in spawn_shell functions)
|
const char *encoding = PrefHandler::Default()->getString(PREF_TEXT_ENCODING);
|
||||||
const char *encoding = longname2shortname(PrefHandler::Default()->getString(PREF_TEXT_ENCODING));
|
SetEncoding(longname2id(encoding));
|
||||||
|
|
||||||
fShell = new Shell();
|
fShell = new Shell();
|
||||||
status_t status = fShell->Open(fTermRows, fTermColumns, command, encoding);
|
status_t status = fShell->Open(fTermRows, fTermColumns, command, longname2shortname(encoding));
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
throw status;
|
throw status;
|
||||||
|
|
||||||
@@ -165,6 +172,8 @@ TermView::TermView(BRect frame, const char *command)
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
throw status;
|
throw status;
|
||||||
|
|
||||||
|
SetTermSize(fTermColumns, fTermRows, false);
|
||||||
|
|
||||||
_InitMouseThread();
|
_InitMouseThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +190,16 @@ TermView::~TermView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::GetPreferredSize(float *width, float *height)
|
||||||
|
{
|
||||||
|
if (width)
|
||||||
|
*width = fTermColumns * fFontWidth;
|
||||||
|
if (height)
|
||||||
|
*height = fTermRows * fFontHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TermView::AttachShell(Shell *shell)
|
TermView::AttachShell(Shell *shell)
|
||||||
{
|
{
|
||||||
@@ -240,7 +259,7 @@ TermView::SetTermSize(int rows, int cols, bool resize)
|
|||||||
if (resize)
|
if (resize)
|
||||||
ResizeTo(fTermColumns * fFontWidth - 1, fTermRows * fFontHeight -1);
|
ResizeTo(fTermColumns * fFontWidth - 1, fTermRows * fFontHeight -1);
|
||||||
|
|
||||||
Invalidate(Frame());
|
Invalidate();
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
@@ -283,6 +302,9 @@ TermView::SetTermFont(const BFont *halfFont, const BFont *fullFont)
|
|||||||
fHalfFont = halfFont;
|
fHalfFont = halfFont;
|
||||||
fFullFont = fullFont;
|
fFullFont = fullFont;
|
||||||
|
|
||||||
|
_FixFontAttributes(fHalfFont);
|
||||||
|
_FixFontAttributes(fFullFont);
|
||||||
|
|
||||||
// calculate half font's max width
|
// calculate half font's max width
|
||||||
// Not Bounding, check only A-Z(For case of fHalfFont is KanjiFont. )
|
// Not Bounding, check only A-Z(For case of fHalfFont is KanjiFont. )
|
||||||
for (int c = 0x20 ; c <= 0x7e; c++){
|
for (int c = 0x20 ; c <= 0x7e; c++){
|
||||||
@@ -929,8 +951,7 @@ TermView::MouseTracking(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scroll check
|
// Scroll check
|
||||||
if (theObj->LockLooper()) {
|
if (theObj->fScrollBar != NULL && 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();
|
||||||
@@ -1039,10 +1060,11 @@ TermView::DrawLines(int x1, int y1, ushort attr, uchar *buf,
|
|||||||
void
|
void
|
||||||
TermView::ResizeScrBarRange()
|
TermView::ResizeScrBarRange()
|
||||||
{
|
{
|
||||||
float viewheight, start_pos;
|
if (fScrollBar == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
viewheight = fTermRows * fFontHeight;
|
float viewheight = fTermRows * fFontHeight;
|
||||||
start_pos = fTop -(fScrBufSize - fTermRows *2) * fFontHeight;
|
float start_pos = fTop -(fScrBufSize - fTermRows *2) * fFontHeight;
|
||||||
|
|
||||||
if (start_pos > 0) {
|
if (start_pos > 0) {
|
||||||
fScrollBar->SetRange(start_pos, viewheight + fTop - fFontHeight);
|
fScrollBar->SetRange(start_pos, viewheight + fTop - fFontHeight);
|
||||||
@@ -1153,12 +1175,24 @@ TermView::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
SetFont(&fHalfFont);
|
SetFont(&fHalfFont);
|
||||||
MakeFocus(true);
|
MakeFocus(true);
|
||||||
fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows);
|
if (fScrollBar)
|
||||||
|
fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows);
|
||||||
|
|
||||||
|
BMessage message(kUpdateSigWinch);
|
||||||
|
fWinchRunner = new (std::nothrow) BMessageRunner(BMessenger(this), &message, 500000);
|
||||||
|
|
||||||
Window()->SetPulseRate(1000000);
|
Window()->SetPulseRate(1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TermView::DetachedFromWindow()
|
||||||
|
{
|
||||||
|
delete fWinchRunner;
|
||||||
|
fWinchRunner = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::Pulse()
|
TermView::Pulse()
|
||||||
{
|
{
|
||||||
@@ -1293,11 +1327,7 @@ TermView::WindowActivated(bool active)
|
|||||||
void
|
void
|
||||||
TermView::KeyDown(const char *bytes, int32 numBytes)
|
TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||||
{
|
{
|
||||||
char c;
|
|
||||||
struct termios tio;
|
|
||||||
int32 key, mod;
|
int32 key, mod;
|
||||||
|
|
||||||
uchar dstbuf[1024];
|
|
||||||
Looper()->CurrentMessage()->FindInt32("modifiers", &mod);
|
Looper()->CurrentMessage()->FindInt32("modifiers", &mod);
|
||||||
Looper()->CurrentMessage()->FindInt32("key", &key);
|
Looper()->CurrentMessage()->FindInt32("key", &key);
|
||||||
|
|
||||||
@@ -1306,6 +1336,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
|
|
||||||
// If bytes[0] equal intr charactor,
|
// If bytes[0] equal intr charactor,
|
||||||
// send signal to shell process group.
|
// send signal to shell process group.
|
||||||
|
struct termios tio;
|
||||||
fShell->GetAttr(tio);
|
fShell->GetAttr(tio);
|
||||||
if (*bytes == tio.c_cc[VINTR]) {
|
if (*bytes == tio.c_cc[VINTR]) {
|
||||||
if (tio.c_lflag & ISIG)
|
if (tio.c_lflag & ISIG)
|
||||||
@@ -1315,31 +1346,19 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
// Terminal changes RET, ENTER, F1...F12, and ARROW key code.
|
// Terminal changes RET, ENTER, F1...F12, and ARROW key code.
|
||||||
|
|
||||||
if (numBytes == 1) {
|
if (numBytes == 1) {
|
||||||
|
|
||||||
switch (*bytes) {
|
switch (*bytes) {
|
||||||
case B_RETURN:
|
case B_RETURN:
|
||||||
c = 0x0d;
|
{
|
||||||
if (key == RETURN_KEY || key == ENTER_KEY) {
|
char c = 0x0d;
|
||||||
fShell->Write(&c, 1);
|
fShell->Write(&c, 1);
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
fShell->Write(bytes, numBytes);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
if (key == LEFT_ARROW_KEY) {
|
fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1);
|
||||||
fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
if (key == RIGHT_ARROW_KEY) {
|
fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1);
|
||||||
fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
@@ -1351,10 +1370,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == UP_ARROW_KEY) {
|
fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1);
|
||||||
fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_DOWN_ARROW:
|
case B_DOWN_ARROW:
|
||||||
@@ -1364,24 +1380,15 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == DOWN_ARROW_KEY) {
|
fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1);
|
||||||
fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_INSERT:
|
case B_INSERT:
|
||||||
if (key == INSERT_KEY) {
|
fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1);
|
||||||
fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_HOME:
|
case B_HOME:
|
||||||
if (key == HOME_KEY) {
|
fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1);
|
||||||
fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PAGE_UP:
|
case B_PAGE_UP:
|
||||||
@@ -1393,10 +1400,7 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == PAGE_UP_KEY) {
|
fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1);
|
||||||
fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PAGE_DOWN:
|
case B_PAGE_DOWN:
|
||||||
@@ -1406,21 +1410,15 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == PAGE_DOWN_KEY) {
|
fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1);
|
||||||
fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_END:
|
case B_END:
|
||||||
if (key == END_KEY) {
|
fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE)-1);
|
||||||
fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE)-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_FUNCTION_KEY:
|
case B_FUNCTION_KEY:
|
||||||
for (c = 0; c < 12; c++) {
|
for (int32 c = 0; c < 12; c++) {
|
||||||
if (key == function_keycode_table[c]) {
|
if (key == function_keycode_table[c]) {
|
||||||
fShell->Write(function_key_char_table[c], 5);
|
fShell->Write(function_key_char_table[c], 5);
|
||||||
return;
|
return;
|
||||||
@@ -1429,33 +1427,31 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
fShell->Write(bytes, numBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// input multibyte character
|
// input multibyte character
|
||||||
|
|
||||||
if (GetEncoding() != M_UTF8) {
|
if (GetEncoding() != M_UTF8) {
|
||||||
|
uchar dstbuf[1024];
|
||||||
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes,
|
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes,
|
||||||
(char *)dstbuf, GetEncoding());
|
(char *)dstbuf, GetEncoding());
|
||||||
fShell->Write(dstbuf, cnum);
|
fShell->Write(dstbuf, cnum);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fShell->Write(bytes, numBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::FrameResized(float width, float height)
|
TermView::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
const int cols =((int)width + 1) / fFontWidth;
|
const int cols = ((int)width + 1) / fFontWidth;
|
||||||
const int rows =((int)height + 1) / fFontHeight;
|
const int rows = ((int)height + 1) / fFontHeight;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if (rows < fCurPos.y + 1) {
|
if (rows < fCurPos.y + 1) {
|
||||||
fTop +=(fCurPos.y + 1 - rows) * fFontHeight;
|
fTop += (fCurPos.y + 1 - rows) * fFontHeight;
|
||||||
offset = fCurPos.y + 1 - rows;
|
offset = fCurPos.y + 1 - rows;
|
||||||
fCurPos.y = rows - 1;
|
fCurPos.y = rows - 1;
|
||||||
}
|
}
|
||||||
@@ -1464,6 +1460,9 @@ TermView::FrameResized(float width, float height)
|
|||||||
fTermColumns = cols;
|
fTermColumns = cols;
|
||||||
|
|
||||||
fFrameResized = true;
|
fFrameResized = true;
|
||||||
|
|
||||||
|
// TODO: Fix this
|
||||||
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1550,6 +1549,9 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
case kUpdateSigWinch:
|
||||||
|
UpdateSIGWINCH();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
@@ -1667,8 +1669,10 @@ TermView::DoClearAll(void)
|
|||||||
// reset cursor pos
|
// reset cursor pos
|
||||||
SetCurPos(0, 0);
|
SetCurPos(0, 0);
|
||||||
|
|
||||||
fScrollBar->SetRange(0, 0);
|
if (fScrollBar) {
|
||||||
fScrollBar->SetProportion(1);
|
fScrollBar->SetRange(0, 0);
|
||||||
|
fScrollBar->SetProportion(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2223,3 +2227,12 @@ TermView::Redraw(int x1, int y1, int x2, int y2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void
|
||||||
|
TermView::_FixFontAttributes(BFont &font)
|
||||||
|
{
|
||||||
|
font.SetSpacing(B_FIXED_SPACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#define CUROFF 0
|
#define CUROFF 0
|
||||||
#define CURON 1
|
#define CURON 1
|
||||||
|
|
||||||
|
class BMessageRunner;
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BScrollBar;
|
class BScrollBar;
|
||||||
class BString;
|
class BString;
|
||||||
@@ -54,6 +55,8 @@ public:
|
|||||||
TermView(BRect frame, const char *command);
|
TermView(BRect frame, const char *command);
|
||||||
~TermView();
|
~TermView();
|
||||||
|
|
||||||
|
virtual void GetPreferredSize(float *width, float *height);
|
||||||
|
|
||||||
status_t AttachShell(Shell *shell);
|
status_t AttachShell(Shell *shell);
|
||||||
void DetachShell();
|
void DetachShell();
|
||||||
|
|
||||||
@@ -61,8 +64,10 @@ public:
|
|||||||
|
|
||||||
void SetTermFont(const BFont *halfFont, const BFont *fullFont);
|
void SetTermFont(const BFont *halfFont, const BFont *fullFont);
|
||||||
void GetFontSize(int *width, int *height);
|
void GetFontSize(int *width, int *height);
|
||||||
|
|
||||||
BRect SetTermSize(int rows, int cols, bool flag);
|
BRect SetTermSize(int rows, int cols, bool flag);
|
||||||
void SetTermColor();
|
void SetTermColor();
|
||||||
|
|
||||||
void SetMouseCursor();
|
void SetMouseCursor();
|
||||||
// void SetIMAware (bool);
|
// void SetIMAware (bool);
|
||||||
void SetScrollBar(BScrollBar *scrbar);
|
void SetScrollBar(BScrollBar *scrbar);
|
||||||
@@ -124,6 +129,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
virtual void DetachedFromWindow();
|
||||||
virtual void Pulse();
|
virtual void Pulse();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
@@ -180,8 +186,12 @@ private:
|
|||||||
bool CheckSelectedRegion(const CurPos &pos);
|
bool CheckSelectedRegion(const CurPos &pos);
|
||||||
inline void Redraw(int, int, int, int);
|
inline void Redraw(int, int, int, int);
|
||||||
|
|
||||||
|
static void _FixFontAttributes(BFont &font);
|
||||||
|
|
||||||
Shell *fShell;
|
Shell *fShell;
|
||||||
|
|
||||||
|
BMessageRunner *fWinchRunner;
|
||||||
|
|
||||||
// Font and Width
|
// Font and Width
|
||||||
BFont fHalfFont;
|
BFont fHalfFont;
|
||||||
BFont fFullFont;
|
BFont fFullFont;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <MessageRunner.h>
|
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
#include <PropertyInfo.h>
|
#include <PropertyInfo.h>
|
||||||
@@ -52,6 +51,16 @@
|
|||||||
|
|
||||||
const static float kViewOffset = 3;
|
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)
|
||||||
|
{
|
||||||
|
fTermView = new TermView(Bounds(), command);
|
||||||
|
AddChild(fTermView);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
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),
|
||||||
@@ -67,7 +76,6 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
|||||||
fPrintSettings(NULL),
|
fPrintSettings(NULL),
|
||||||
fPrefWindow(NULL),
|
fPrefWindow(NULL),
|
||||||
fFindPanel(NULL),
|
fFindPanel(NULL),
|
||||||
fWindowUpdate(NULL),
|
|
||||||
fSavedFrame(0, 0, -1, -1),
|
fSavedFrame(0, 0, -1, -1),
|
||||||
fFindString(""),
|
fFindString(""),
|
||||||
fFindForwardMenuItem(NULL),
|
fFindForwardMenuItem(NULL),
|
||||||
@@ -79,7 +87,7 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command)
|
|||||||
{
|
{
|
||||||
_InitWindow(command);
|
_InitWindow(command);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TermWindow::~TermWindow()
|
TermWindow::~TermWindow()
|
||||||
{
|
{
|
||||||
@@ -92,8 +100,6 @@ TermWindow::~TermWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrefHandler::DeleteDefault();
|
PrefHandler::DeleteDefault();
|
||||||
|
|
||||||
delete fWindowUpdate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +123,6 @@ TermWindow::_InitWindow(const char *command)
|
|||||||
if (size < 6.0f)
|
if (size < 6.0f)
|
||||||
size = 6.0f;
|
size = 6.0f;
|
||||||
halfFont.SetSize(size);
|
halfFont.SetSize(size);
|
||||||
halfFont.SetSpacing(B_FIXED_SPACING);
|
|
||||||
|
|
||||||
family = PrefHandler::Default()->getString(PREF_FULL_FONT_FAMILY);
|
family = PrefHandler::Default()->getString(PREF_FULL_FONT_FAMILY);
|
||||||
|
|
||||||
@@ -147,8 +152,6 @@ TermWindow::_InitWindow(const char *command)
|
|||||||
SetSizeLimits(MIN_COLS * width, MAX_COLS * width,
|
SetSizeLimits(MIN_COLS * width, MAX_COLS * width,
|
||||||
MIN_COLS * height, MAX_COLS * height);
|
MIN_COLS * height, MAX_COLS * height);
|
||||||
|
|
||||||
fTermView->SetTermColor();
|
|
||||||
|
|
||||||
// Add offset to baseview.
|
// Add offset to baseview.
|
||||||
rect.InsetBy(-kViewOffset, -kViewOffset);
|
rect.InsetBy(-kViewOffset, -kViewOffset);
|
||||||
|
|
||||||
@@ -173,13 +176,6 @@ TermWindow::_InitWindow(const char *command)
|
|||||||
AddChild(fTermView);
|
AddChild(fTermView);
|
||||||
|
|
||||||
fEditmenu->SetTargetForItems(fTermView);
|
fEditmenu->SetTargetForItems(fTermView);
|
||||||
|
|
||||||
// Initialize TermParse
|
|
||||||
SetEncoding(longname2id(PrefHandler::Default()->getString(PREF_TEXT_ENCODING)));
|
|
||||||
|
|
||||||
// Initialize MessageRunner.
|
|
||||||
fWindowUpdate = new BMessageRunner(BMessenger(this),
|
|
||||||
new BMessage (MSGRUN_WINDOW), 500000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -429,7 +425,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
PrefHandler::Default()->getInt32 (PREF_COLS), 0);
|
PrefHandler::Default()->getInt32 (PREF_COLS), 0);
|
||||||
|
|
||||||
ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH + kViewOffset * 2,
|
ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH + kViewOffset * 2,
|
||||||
r.Height()+fMenubar->Bounds().Height() + kViewOffset *2);
|
r.Height()+fMenubar->Bounds().Height() + kViewOffset *2);
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
if (PrefHandler::GetDefaultPath(path) == B_OK)
|
if (PrefHandler::GetDefaultPath(path) == B_OK)
|
||||||
@@ -468,36 +464,31 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
case EIGHTYTWENTYFOUR: {
|
case EIGHTYTWENTYFOUR: {
|
||||||
PrefHandler::Default()->setString(PREF_COLS, "80");
|
PrefHandler::Default()->setString(PREF_COLS, "80");
|
||||||
PrefHandler::Default()->setString(PREF_ROWS, "24");
|
PrefHandler::Default()->setString(PREF_ROWS, "24");
|
||||||
this->PostMessage (MSG_ROWS_CHANGED);
|
PostMessage (MSG_COLS_CHANGED);
|
||||||
this->PostMessage (MSG_COLS_CHANGED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EIGHTYTWENTYFIVE: {
|
case EIGHTYTWENTYFIVE: {
|
||||||
PrefHandler::Default()->setString(PREF_COLS, "80");
|
PrefHandler::Default()->setString(PREF_COLS, "80");
|
||||||
PrefHandler::Default()->setString(PREF_ROWS, "25");
|
PrefHandler::Default()->setString(PREF_ROWS, "25");
|
||||||
this->PostMessage (MSG_ROWS_CHANGED);
|
PostMessage (MSG_COLS_CHANGED);
|
||||||
this->PostMessage (MSG_COLS_CHANGED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EIGHTYFORTY: {
|
case EIGHTYFORTY: {
|
||||||
PrefHandler::Default()->setString(PREF_COLS, "80");
|
PrefHandler::Default()->setString(PREF_COLS, "80");
|
||||||
PrefHandler::Default()->setString(PREF_ROWS, "40");
|
PrefHandler::Default()->setString(PREF_ROWS, "40");
|
||||||
this->PostMessage (MSG_ROWS_CHANGED);
|
PostMessage (MSG_COLS_CHANGED);
|
||||||
this->PostMessage (MSG_COLS_CHANGED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ONETHREETWOTWENTYFOUR: {
|
case ONETHREETWOTWENTYFOUR: {
|
||||||
PrefHandler::Default()->setString(PREF_COLS, "132");
|
PrefHandler::Default()->setString(PREF_COLS, "132");
|
||||||
PrefHandler::Default()->setString(PREF_ROWS, "24");
|
PrefHandler::Default()->setString(PREF_ROWS, "24");
|
||||||
this->PostMessage (MSG_ROWS_CHANGED);
|
PostMessage (MSG_COLS_CHANGED);
|
||||||
this->PostMessage (MSG_COLS_CHANGED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ONETHREETWOTWENTYFIVE: {
|
case ONETHREETWOTWENTYFIVE: {
|
||||||
PrefHandler::Default()->setString(PREF_COLS, "132");
|
PrefHandler::Default()->setString(PREF_COLS, "132");
|
||||||
PrefHandler::Default()->setString(PREF_ROWS, "25");
|
PrefHandler::Default()->setString(PREF_ROWS, "25");
|
||||||
this->PostMessage (MSG_ROWS_CHANGED);
|
PostMessage (MSG_COLS_CHANGED);
|
||||||
this->PostMessage (MSG_COLS_CHANGED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FULLSCREEN: {
|
case FULLSCREEN: {
|
||||||
@@ -549,10 +540,7 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
_DoPrint();
|
_DoPrint();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSGRUN_WINDOW: {
|
|
||||||
fTermView->UpdateSIGWINCH();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_ABOUT_REQUESTED: {
|
case B_ABOUT_REQUESTED: {
|
||||||
be_app->PostMessage(B_ABOUT_REQUESTED);
|
be_app->PostMessage(B_ABOUT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
@@ -563,14 +551,18 @@ TermWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// WindowActivated (bool)
|
|
||||||
// Dispatch Mesasge.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
void
|
void
|
||||||
TermWindow::WindowActivated(bool)
|
TermWindow::WindowActivated(bool)
|
||||||
{
|
{
|
||||||
|
#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
|
||||||
|
if (focus_follows_mouse()) {
|
||||||
|
BPoint aMouseLoc = Frame().LeftTop();
|
||||||
|
set_mouse_position(int32(aMouseLoc.x + 16), int32(aMouseLoc.y + 2));
|
||||||
|
be_app->SetCursor(B_HAND_CURSOR);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -582,21 +574,6 @@ TermWindow::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TermWindow::TermWinActivate()
|
|
||||||
{
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
|
|
||||||
if (focus_follows_mouse()) {
|
|
||||||
BPoint aMouseLoc = Frame().LeftTop();
|
|
||||||
set_mouse_position(int32(aMouseLoc.x + 16), int32(aMouseLoc.y + 2));
|
|
||||||
be_app->SetCursor(B_HAND_CURSOR);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TermWindow::GetSupportedSuites(BMessage *msg)
|
TermWindow::GetSupportedSuites(BMessage *msg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
class BMenu;
|
class BMenu;
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
class BMessageRunner;
|
|
||||||
class FindWindow;
|
class FindWindow;
|
||||||
class PrefWindow;
|
class PrefWindow;
|
||||||
class TermView;
|
class TermView;
|
||||||
@@ -46,8 +45,6 @@ public:
|
|||||||
TermWindow(BRect frame, const char* title, const char *command);
|
TermWindow(BRect frame, const char* title, const char *command);
|
||||||
virtual ~TermWindow();
|
virtual ~TermWindow();
|
||||||
|
|
||||||
void TermWinActivate();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void WindowActivated(bool);
|
virtual void WindowActivated(bool);
|
||||||
@@ -77,7 +74,6 @@ private:
|
|||||||
BMessage *fPrintSettings;
|
BMessage *fPrintSettings;
|
||||||
PrefWindow *fPrefWindow;
|
PrefWindow *fPrefWindow;
|
||||||
FindWindow *fFindPanel;
|
FindWindow *fFindPanel;
|
||||||
BMessageRunner *fWindowUpdate;
|
|
||||||
BRect fSavedFrame;
|
BRect fSavedFrame;
|
||||||
window_look fSavedLook;
|
window_look fSavedLook;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user