Attach/DetachShell are now private. Added a new TermView constructor

which only specifies the rows and columns, view size is automatically 
calculated, and used it in TermWindow. Added a TermView::SetTitle() 
method, thus TermParse doesn't call Window() anymore. Some cleanups, 
scrollbar was off by one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21808 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-08-03 09:59:30 +00:00
parent efd2184922
commit 2b87a97ac6
8 changed files with 189 additions and 150 deletions
+12 -9
View File
@@ -232,14 +232,18 @@ Shell::Signal(int signal)
status_t status_t
Shell::GetAttr(struct termios &attr) Shell::GetAttr(struct termios &attr)
{ {
return tcgetattr(fFd, &attr); if (tcgetattr(fFd, &attr) < 0)
return errno;
return B_OK;
} }
status_t status_t
Shell::SetAttr(struct termios &attr) Shell::SetAttr(struct termios &attr)
{ {
return tcsetattr(fFd, TCSANOW, &attr); if (tcsetattr(fFd, TCSANOW, &attr) < 0)
return errno;
return B_OK;
} }
@@ -378,13 +382,6 @@ Shell::_Spawn(int row, int col, const char *command, const char *encoding)
exit(1); exit(1);
} }
struct termios tio;
/* get tty termios (not necessary).
* TODO: so why are we doing it ?
*/
tcgetattr(slave, &tio);
/* set signal default */ /* set signal default */
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
signal(SIGHUP, SIG_DFL); signal(SIGHUP, SIG_DFL);
@@ -393,6 +390,12 @@ Shell::_Spawn(int row, int col, const char *command, const char *encoding)
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);
signal(SIGTTOU, SIG_DFL); signal(SIGTTOU, SIG_DFL);
struct termios tio;
/* get tty termios (not necessary).
* TODO: so why are we doing it ?
*/
tcgetattr(slave, &tio);
/* /*
* Set Terminal interface. * Set Terminal interface.
*/ */
+1 -1
View File
@@ -20,7 +20,7 @@ SmartTabView::SmartTabView(BRect frame, const char *name, button_width width,
{ {
// See BTabView::_InitObject() to see why we are doing this // See BTabView::_InitObject() to see why we are doing this
ContainerView()->MoveBy(-3, -TabHeight() - 3); ContainerView()->MoveBy(-3, -TabHeight() - 3);
ContainerView()->ResizeBy(9, TabHeight() + 9); ContainerView()->ResizeBy(10, TabHeight() + 9);
} }
+1 -2
View File
@@ -19,7 +19,6 @@
#include <Beep.h> #include <Beep.h>
#include <Message.h> #include <Message.h>
#include <Window.h>
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@@ -851,7 +850,7 @@ TermParse::EscParse()
switch (mode_char) { switch (mode_char) {
case '0': case '0':
case '2': case '2':
fView->Window()->SetTitle(string); fView->SetTitle(string);
break; break;
case '1': case '1':
break; break;
+147 -90
View File
@@ -19,7 +19,6 @@
#include "TermConst.h" #include "TermConst.h"
#include "VTkeymap.h" #include "VTkeymap.h"
#include <Application.h>
#include <Alert.h> #include <Alert.h>
#include <Beep.h> #include <Beep.h>
#include <Clipboard.h> #include <Clipboard.h>
@@ -107,12 +106,31 @@ const unsigned char M_ADD_CURSOR[] = {
#define ROWS_DEFAULT 25 #define ROWS_DEFAULT 25
#define COLUMNS_DEFAULT 80 #define COLUMNS_DEFAULT 80
static property_info sPropList[] = {
{ "encoding",
{B_GET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0},
"get terminal encoding"},
{ "encoding",
{B_SET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0},
"set terminal encoding"},
{ "tty",
{B_GET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0},
"get tty name."},
{ 0 }
};
const static uint32 kUpdateSigWinch = 'Rwin'; const static uint32 kUpdateSigWinch = 'Rwin';
const static rgb_color kBlackColor = { 0, 0, 0, 255 }; const static rgb_color kBlackColor = { 0, 0, 0, 255 };
const static rgb_color kWhiteColor = { 255, 255, 255, 255 }; const static rgb_color kWhiteColor = { 255, 255, 255, 255 };
TermView::TermView(BRect frame, const char *command, int32 historySize) TermView::TermView(BRect frame, const char *command, int32 historySize)
: 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),
@@ -161,6 +179,55 @@ TermView::TermView(BRect frame, const char *command, int32 historySize)
} }
TermView::TermView(int rows, int columns, const char *command, int32 historySize)
: BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED),
fShell(NULL),
fFontWidth(0),
fFontHeight(0),
fFontAscent(0),
fUpdateFlag(false),
fInsertModeFlag(MODE_OVER),
fScrollUpCount(0),
fScrollBarRange(0),
fFrameResized(false),
fLastCursorTime(0),
fCursorDrawFlag(CURON),
fCursorStatus(CURON),
fCursorBlinkingFlag(CURON),
fCursorRedrawFlag(CURON),
fCursorHeight(0),
fCurPos(0, 0),
fCurStack(0, 0),
fBufferStartPos(-1),
fTermRows(rows),
fTermColumns(columns),
fEncoding(M_UTF8),
fTop(0),
fTextBuffer(NULL),
fScrollBar(NULL),
fTextForeColor(kBlackColor),
fTextBackColor(kWhiteColor),
fCursorForeColor(kWhiteColor),
fCursorBackColor(kBlackColor),
fSelectForeColor(kWhiteColor),
fSelectBackColor(kBlackColor),
fScrTop(0),
fScrBot(fTermRows - 1),
fScrBufSize(historySize),
fScrRegionSet(0),
fPreviousMousePoint(0, 0),
fSelStart(-1, -1),
fSelEnd(-1, -1),
fMouseTracking(false),
fMouseThread(-1),
fQuitting(false),
fIMflag(false)
{
_InitObject(command);
SetTermSize(fTermRows, fTermColumns, true);
}
TermView::TermView(BMessage *archive) TermView::TermView(BMessage *archive)
: :
BView(archive), BView(archive),
@@ -236,10 +303,11 @@ TermView::_InitObject(const char *command)
status_t status = fShell->Open(fTermRows, fTermColumns, status_t status = fShell->Open(fTermRows, fTermColumns,
command, longname2shortname(id2longname(fEncoding))); command, longname2shortname(id2longname(fEncoding)));
if (status < B_OK) if (status < B_OK)
return status; return status;
status = AttachShell(fShell); status = _AttachShell(fShell);
if (status < B_OK) if (status < B_OK)
return status; return status;
@@ -254,7 +322,7 @@ TermView::_InitObject(const char *command)
TermView::~TermView() TermView::~TermView()
{ {
DetachShell(); _DetachShell();
delete fTextBuffer; delete fTextBuffer;
delete fShell; delete fShell;
@@ -302,27 +370,6 @@ TermView::GetPreferredSize(float *width, float *height)
} }
status_t
TermView::AttachShell(Shell *shell)
{
if (shell == NULL)
return B_BAD_VALUE;
fShell = shell;
fShell->ViewAttached(this);
return B_OK;
}
void
TermView::DetachShell()
{
fShell->ViewDetached();
fShell = NULL;
}
const char * const char *
TermView::TerminalName() const TermView::TerminalName() const
{ {
@@ -467,6 +514,16 @@ TermView::SetScrollBar(BScrollBar *scrollBar)
} }
void
TermView::SetTitle(const char *title)
{
// TODO: Do something different in case we're a replicant,
// or in case we are inside a BTabView ?
if (Window())
Window()->SetTitle(title);
}
//! Print one character //! Print one character
void void
TermView::PutChar(uchar *string, ushort attr, int width) TermView::PutChar(uchar *string, ushort attr, int width)
@@ -949,6 +1006,27 @@ TermView::ScrollAtCursor()
} }
status_t
TermView::_AttachShell(Shell *shell)
{
if (shell == NULL)
return B_BAD_VALUE;
fShell = shell;
fShell->ViewAttached(this);
return B_OK;
}
void
TermView::_DetachShell()
{
fShell->ViewDetached();
fShell = NULL;
}
status_t status_t
TermView::_InitMouseThread() TermView::_InitMouseThread()
{ {
@@ -1007,9 +1085,9 @@ TermView::_MouseTracking()
} }
if (tmppos > stpos && tmppos < edpos) if (tmppos > stpos && tmppos < edpos)
be_app->SetCursor(M_ADD_CURSOR); SetViewCursor(M_ADD_CURSOR);
else else
be_app->SetCursor(B_HAND_CURSOR); SetViewCursor(B_HAND_CURSOR);
} }
} }
snooze(50 * 1000); snooze(50 * 1000);
@@ -1442,13 +1520,18 @@ TermView::WindowActivated(bool active)
void void
TermView::KeyDown(const char *bytes, int32 numBytes) TermView::KeyDown(const char *bytes, int32 numBytes)
{ {
int32 key, mod;
Looper()->CurrentMessage()->FindInt32("modifiers", &mod);
Looper()->CurrentMessage()->FindInt32("key", &key);
if (fIMflag) if (fIMflag)
return; return;
int32 key, mod, rawChar;
BMessage *currentMessage = Looper()->CurrentMessage();
if (currentMessage == NULL)
return;
currentMessage->FindInt32("modifiers", &mod);
currentMessage->FindInt32("key", &key);
currentMessage->FindInt32("raw_char", &rawChar);
// If bytes[0] equal intr character, // If bytes[0] equal intr character,
// send signal to shell process group. // send signal to shell process group.
struct termios tio; struct termios tio;
@@ -1458,6 +1541,8 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
fShell->Signal(SIGINT); fShell->Signal(SIGINT);
} }
printf("rawKey: %c\n", (char)rawChar);
// Terminal filters RET, ENTER, F1...F12, and ARROW key code. // Terminal filters RET, ENTER, F1...F12, and ARROW key code.
// TODO: Cleanup // TODO: Cleanup
if (numBytes == 1) { if (numBytes == 1) {
@@ -1673,12 +1758,13 @@ TermView::MessageReceived(BMessage *msg)
_DoSelectAll(); _DoSelectAll();
break; break;
case B_SET_PROPERTY: { case B_SET_PROPERTY:
{
int32 i; int32 i;
int32 encodingID; int32 encodingID;
BMessage spe; BMessage specifier;
msg->GetCurrentSpecifier(&i, &spe); msg->GetCurrentSpecifier(&i, &specifier);
if (!strcmp("encoding", spe.FindString("property", i))){ if (!strcmp("encoding", specifier.FindString("property", i))){
msg->FindInt32 ("data", &encodingID); msg->FindInt32 ("data", &encodingID);
SetEncoding(encodingID); SetEncoding(encodingID);
msg->SendReply(B_REPLY); msg->SendReply(B_REPLY);
@@ -1688,16 +1774,16 @@ TermView::MessageReceived(BMessage *msg)
break; break;
} }
case B_GET_PROPERTY: { case B_GET_PROPERTY:
{
int32 i; int32 i;
BMessage spe; BMessage specifier;
msg->GetCurrentSpecifier(&i, &spe); msg->GetCurrentSpecifier(&i, &specifier);
if (!strcmp("encoding", spe.FindString("property", i))){ if (!strcmp("encoding", specifier.FindString("property", i))){
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
reply.AddInt32("result", Encoding()); reply.AddInt32("result", Encoding());
msg->SendReply(&reply); msg->SendReply(&reply);
} } else if (!strcmp("tty", specifier.FindString("property", i))) {
else if (!strcmp("tty", spe.FindString("property", i))) {
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
reply.AddString("result", TerminalName()); reply.AddString("result", TerminalName());
msg->SendReply(&reply); msg->SendReply(&reply);
@@ -1748,40 +1834,23 @@ TermView::MessageReceived(BMessage *msg)
status_t status_t
TermView::GetSupportedSuites(BMessage *message) TermView::GetSupportedSuites(BMessage *message)
{ {
static property_info propList[] = { BPropertyInfo propInfo(sPropList);
{ "encoding",
{B_GET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0},
"get muterminal encoding"},
{ "encoding",
{B_SET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0},
"set muterminal encoding"},
{ "tty",
{B_GET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0},
"get tty_name."},
{ 0 }
};
message->AddString("suites", "suite/vnd.naan-termview"); message->AddString("suites", "suite/vnd.naan-termview");
BPropertyInfo propInfo(propList);
message->AddFlat("messages", &propInfo); message->AddFlat("messages", &propInfo);
return BView::GetSupportedSuites(message); return BView::GetSupportedSuites(message);
} }
BHandler* BHandler*
TermView::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, TermView::ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier,
int32 form, const char *property) int32 what, const char *property)
{ {
if (((strcmp(property, "encode") == 0) BHandler *target = this;
&& ((msg->what == B_SET_PROPERTY) || (msg->what == B_GET_PROPERTY))) BPropertyInfo propInfo(sPropList);
|| ((strcmp(property, "tty") == 0) && (msg->what == B_GET_PROPERTY))) if (propInfo.FindMatch(message, index, specifier, what, property) < B_OK)
return this; target = BView::ResolveSpecifier(message, index, specifier, what, property);
return BView::ResolveSpecifier(msg, index, specifier, form, property); return target;
} }
@@ -2058,14 +2127,13 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
void void
TermView::_Select(CurPos start, CurPos end) TermView::_Select(CurPos start, CurPos end)
{ {
uchar buf[4];
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;
uchar buf[4];
ushort attr;
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) if (start.x < 0)
@@ -2090,10 +2158,6 @@ TermView::_Select(CurPos start, CurPos end)
void void
TermView::_AddSelectRegion(CurPos pos) TermView::_AddSelectRegion(CurPos pos)
{ {
uchar buf[4];
ushort attr;
CurPos start, end, inPos;
if (!_HasSelection()) if (!_HasSelection())
return; return;
@@ -2107,14 +2171,17 @@ TermView::_AddSelectRegion(CurPos pos)
if (pos.y < 0) if (pos.y < 0)
pos.y = 0; pos.y = 0;
uchar buf[4];
ushort attr;
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;
} }
start = fSelStart; CurPos start = fSelStart;
end = fSelEnd; CurPos end = fSelEnd;
CurPos inPos;
// Mouse point is same as selected line. // Mouse point is same as selected line.
if (pos.y == fSelStart.y && pos.y == fSelEnd.y) { if (pos.y == fSelStart.y && pos.y == fSelEnd.y) {
@@ -2169,11 +2236,7 @@ TermView::_AddSelectRegion(CurPos pos)
void void
TermView::_ResizeSelectRegion(CurPos pos) TermView::_ResizeSelectRegion(CurPos pos)
{ {
CurPos inPos; CurPos inPos = fSelEnd;
uchar buf[4];
ushort attr;
inPos = fSelEnd;
// 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.
@@ -2185,8 +2248,9 @@ TermView::_ResizeSelectRegion(CurPos pos)
if (pos.y < 0) if (pos.y < 0)
pos.y = 0; pos.y = 0;
uchar buf[4];
ushort attr;
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 == inPos) if (pos == inPos)
@@ -2206,15 +2270,13 @@ TermView::_ResizeSelectRegion(CurPos pos)
void void
TermView::_DeSelect(void) TermView::_DeSelect(void)
{ {
CurPos start, end;
if (!_HasSelection()) if (!_HasSelection())
return; return;
fTextBuffer->DeSelect(); fTextBuffer->DeSelect();
start = fSelStart; CurPos start = fSelStart;
end = fSelEnd; CurPos end = fSelEnd;
fSelStart.Set(-1, -1); fSelStart.Set(-1, -1);
fSelEnd.Set(-1, -1); fSelEnd.Set(-1, -1);
@@ -2241,19 +2303,13 @@ TermView::_SelectWord(BPoint where, int mod)
fTextBuffer->Select(start, end); fTextBuffer->Select(start, end);
if (mod & B_SHIFT_KEY) { if (mod & B_SHIFT_KEY) {
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)
@@ -2441,6 +2497,7 @@ TermView::Find(const BString &str, bool forwardSearch, bool matchCase, bool matc
return true; return true;
} }
//! Get the selected text and copy to str //! Get the selected text and copy to str
void void
TermView::GetSelection(BString &str) TermView::GetSelection(BString &str)
+8 -4
View File
@@ -33,22 +33,21 @@ class TermBuffer;
class TermView : public BView { class TermView : public BView {
public: public:
TermView(BRect frame, const char *command = NULL, int32 historySize = 1000); TermView(BRect frame, const char *command = NULL, int32 historySize = 1000);
TermView(int rows, int columns, const char *command = NULL, int32 historySize = 1000);
TermView(BMessage *archive); 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);
status_t AttachShell(Shell *shell); virtual void GetPreferredSize(float *width, float *height);
void DetachShell();
const char *TerminalName() const; const char *TerminalName() const;
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 resize);
void SetTextColor(rgb_color fore, rgb_color back); void SetTextColor(rgb_color fore, rgb_color back);
void SetSelectColor(rgb_color fore, rgb_color back); void SetSelectColor(rgb_color fore, rgb_color back);
void SetCursorColor(rgb_color fore, rgb_color back); void SetCursorColor(rgb_color fore, rgb_color back);
@@ -60,6 +59,8 @@ public:
void SetScrollBar(BScrollBar *scrbar); void SetScrollBar(BScrollBar *scrbar);
BScrollBar *ScrollBar() const { return fScrollBar; }; BScrollBar *ScrollBar() const { return fScrollBar; };
void SetTitle(const char *title);
// Output Charactor // Output Charactor
void PutChar(uchar *string, ushort attr, int width); void PutChar(uchar *string, ushort attr, int width);
void PutCR(void); void PutCR(void);
@@ -135,6 +136,9 @@ private:
status_t _InitObject(const char *command); status_t _InitObject(const char *command);
status_t _InitMouseThread(void); status_t _InitMouseThread(void);
status_t _AttachShell(Shell *shell);
void _DetachShell();
void _AboutRequested(); void _AboutRequested();
void _DrawLines(int , int, ushort, uchar *, int, int, int, BView *); void _DrawLines(int , int, ushort, uchar *, int, int, int, BView *);
+9 -31
View File
@@ -33,8 +33,6 @@
#include <ScrollBar.h> #include <ScrollBar.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <String.h> #include <String.h>
#include <TextControl.h>
#include <WindowScreen.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -60,9 +58,7 @@ TermWindow::TermWindow(BRect frame, const char* title, const char *command)
fEditmenu(NULL), fEditmenu(NULL),
fEncodingmenu(NULL), fEncodingmenu(NULL),
fHelpmenu(NULL), fHelpmenu(NULL),
fFontMenu(NULL),
fWindowSizeMenu(NULL), fWindowSizeMenu(NULL),
fNewFontMenu(NULL),
fPrintSettings(NULL), fPrintSettings(NULL),
fPrefWindow(NULL), fPrefWindow(NULL),
fFindPanel(NULL), fFindPanel(NULL),
@@ -181,28 +177,11 @@ TermWindow::_SetupMenu()
fWindowSizeMenu->AddItem(new BMenuItem("132x25", new BMessage(ONETHREETWOTWENTYFIVE))); fWindowSizeMenu->AddItem(new BMenuItem("132x25", new BMessage(ONETHREETWOTWENTYFIVE)));
fWindowSizeMenu->AddItem(new BMenuItem("Fullscreen", new BMessage(FULLSCREEN), B_ENTER)); fWindowSizeMenu->AddItem(new BMenuItem("Fullscreen", new BMessage(FULLSCREEN), B_ENTER));
// Considering we have this in the preferences window, this menu is not
// needed and should not be shown if we are to not confuse the user
/* fNewFontMenu = new BMenu("Font");
fNewFontMenu->SetRadioMode(true);
int32 numFamilies1 = count_font_families();
for ( int32 i = 0; i < numFamilies1; i++ ) {
font_family family;
uint32 flags;
if ( get_font_family(i, &family, &flags) == B_OK ) {
fNewFontMenu->AddItem(item = new BMenuItem(family, new BMessage(MSG_FONT_CHANGED)));
// if (0 ==i) item->SetMarked(true);
}
}
fNewFontMenu->FindItem (PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
*/
fEncodingmenu = new BMenu("Font Encoding"); fEncodingmenu = new BMenu("Font Encoding");
fEncodingmenu->SetRadioMode(true); fEncodingmenu->SetRadioMode(true);
MakeEncodingMenu(fEncodingmenu, true); MakeEncodingMenu(fEncodingmenu, true);
fHelpmenu->AddItem(fWindowSizeMenu); fHelpmenu->AddItem(fWindowSizeMenu);
fHelpmenu->AddItem(fEncodingmenu); fHelpmenu->AddItem(fEncodingmenu);
// fHelpmenu->AddItem(fNewFontMenu);
fHelpmenu->AddSeparatorItem(); fHelpmenu->AddSeparatorItem();
fHelpmenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(MENU_PREF_OPEN))); fHelpmenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(MENU_PREF_OPEN)));
fHelpmenu->AddSeparatorItem(); fHelpmenu->AddSeparatorItem();
@@ -427,7 +406,6 @@ TermWindow::MessageReceived(BMessage *message)
break; break;
} }
case MSG_FONT_CHANGED: { case MSG_FONT_CHANGED: {
PrefHandler::Default()->setString (PREF_HALF_FONT_FAMILY, fNewFontMenu->FindMarked()->Label());
PostMessage(MSG_HALF_FONT_CHANGED); PostMessage(MSG_HALF_FONT_CHANGED);
break; break;
} }
@@ -473,6 +451,9 @@ TermWindow::WindowActivated(bool activated)
bool bool
TermWindow::QuitRequested() TermWindow::QuitRequested()
{ {
// TODO: Intercept the B_QUIT_REQUESTED message
// sent by the TermView, and only close one tab if there
// are multiple ones ? Or handle the case inside TermView itself ?
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return true; return true;
} }
@@ -577,7 +558,9 @@ TermWindow::_NewTab(const char *command)
fullFont.SetSpacing(B_FIXED_SPACING); fullFont.SetSpacing(B_FIXED_SPACING);
// Make Terminal text view. // Make Terminal text view.
TermView *view = new TermView(BRect(0, 0, 10, 10), command); TermView *view = new TermView(PrefHandler::Default()->getInt32(PREF_ROWS),
PrefHandler::Default()->getInt32(PREF_COLS),
command);
BScrollView *scrollView = new BScrollView("scrollView", view, B_FOLLOW_ALL, BScrollView *scrollView = new BScrollView("scrollView", view, B_FOLLOW_ALL,
B_WILL_DRAW|B_FRAME_EVENTS, false, true); B_WILL_DRAW|B_FRAME_EVENTS, false, true);
@@ -592,10 +575,6 @@ TermWindow::_NewTab(const char *command)
_SetTermColors(); _SetTermColors();
BRect rect = view->SetTermSize(PrefHandler::Default()->getInt32(PREF_ROWS),
PrefHandler::Default()->getInt32(PREF_COLS), false);
// If it's the first time we're called, setup the window // If it's the first time we're called, setup the window
if (fTabView->CountTabs() == 1) { if (fTabView->CountTabs() == 1) {
int width, height; int width, height;
@@ -603,12 +582,11 @@ TermWindow::_NewTab(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);
// Add offset to baseview. float fWidth, fHeight;
rect.InsetBy(-kViewOffset, -kViewOffset); view->GetPreferredSize(&fWidth, &fHeight);
// Resize Window // Resize Window
ResizeTo(rect.Width()+ B_V_SCROLL_BAR_WIDTH, ResizeTo(fWidth + B_V_SCROLL_BAR_WIDTH, fHeight + fMenubar->Bounds().Height());
rect.Height() + fMenubar->Bounds().Height());
// TODO: If I don't do this, the view won't show up. // TODO: If I don't do this, the view won't show up.
// Bug in BTabView or in my code ? // Bug in BTabView or in my code ?
+1 -3
View File
@@ -69,9 +69,7 @@ private:
*fEditmenu, *fEditmenu,
*fEncodingmenu, *fEncodingmenu,
*fHelpmenu, *fHelpmenu,
*fFontMenu, *fWindowSizeMenu;
*fWindowSizeMenu,
*fNewFontMenu;
BMessage *fPrintSettings; BMessage *fPrintSettings;
PrefWindow *fPrefWindow; PrefWindow *fPrefWindow;