* Rewrote terminal ID code to use a temporary file - this fixes bug #1174.

* Tried to fix the usual deadlock on quit, but suspending the thread (to
  interrupt read()) doesn't have the expected outcome (might be a kernel
  bug).
* Removed superfluous MENU_FILE_QUIT and send a B_QUIT_REQUESTED instead.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20816 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-04-25 17:00:51 +00:00
parent a1a9e858a2
commit 7f1085115e
7 changed files with 249 additions and 283 deletions

View File

@ -1,38 +1,42 @@
/*
* Copyright 2001-2007, Haiku.
* Copyright (c) 2003-2004 Kian Duffy <myob@users.sourceforge.net>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed unter the terms of the MIT license.
*/
#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <malloc.h>
#include <storage/Path.h>
#include <NodeInfo.h>
#include <Roster.h>
#include "TermApp.h"
#include "CodeConv.h"
#include "PrefHandler.h"
#include "spawn.h"
#include "TermBuffer.h"
#include "TermWindow.h"
#include "TermConst.h"
#include <Alert.h>
#include <NodeInfo.h>
#include <Path.h>
#include <Roster.h>
#include <Screen.h>
#include <String.h>
#include <TextView.h>
#include "TermApp.h"
#include "TermBuffer.h"
#include "TermWindow.h"
#include "TermConst.h"
#include "spawn.h"
#include "PrefHandler.h"
#include "CodeConv.h"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
// Preference temporary
extern PrefHandler *gTermPref;
extern char gWindowName[];
bool usage_requested = false;
bool geometry_requested = false;
bool color_requested = false;
bool gUsageRequested = false;
bool gGeometryRequested = false;
bool gColorRequested = false;
struct standard_args {
char *name;
@ -71,23 +75,22 @@ const ulong MSG_TERM_IS_MINIMIZE = 'mtim';
TermApp::TermApp()
: BApplication(TERM_SIGNATURE)
: BApplication(TERM_SIGNATURE),
fStartFullscreen(false),
fWindowNumber(-1),
fTermWindow(NULL)
{
fWindowNumber = FindTerminalId();
fWindowTitle = "Terminal";
_RegisterTerminal();
char title[256];
snprintf(title, sizeof(title), "Terminal %d", fWindowNumber);
fWindowTitle = title;
fStartFullscreen = false;
if (fWindowNumber > 0)
fWindowTitle << " " << fWindowNumber;
int i = fWindowNumber / 16;
int j = fWindowNumber % 16;
int k = (j * 16) + (i * 64) + 50;
int l = (j * 16) + 50;
int k =(j * 16) + (i * 64) + 50;
int l =(j * 16) + 50;
fTermWindow = NULL;
fAboutPanel = NULL;
fTermFrame.Set(k, l, k + 50, k + 50);
gTermPref = new PrefHandler();
@ -96,7 +99,6 @@ TermApp::TermApp()
TermApp::~TermApp()
{
// delete gTermPref;
}
@ -104,10 +106,10 @@ void
TermApp::ReadyToRun()
{
// Prevent opeing window when option -h is given.
if (usage_requested)
if (gUsageRequested)
return;
status_t status = MakeTermWindow(fTermFrame);
status_t status = _MakeTermWindow(fTermFrame);
// failed spawn, print stdout and open alert panel
if (status < B_OK) {
@ -118,7 +120,6 @@ TermApp::ReadyToRun()
return;
}
// using BScreen::Frame isn't enough
if (fStartFullscreen)
BMessenger(fTermWindow).SendMessage(FULLSCREEN);
@ -128,11 +129,13 @@ TermApp::ReadyToRun()
void
TermApp::Quit()
{
if (!usage_requested){
if (!gUsageRequested){
int status;
kill(-sh_pid, SIGHUP);
wait(&status);
_UnregisterTerminal();
}
delete gTermPref;
@ -166,7 +169,7 @@ TermApp::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case MENU_SWITCH_TERM:
SwitchTerm();
_SwitchTerm();
break;
case MSG_ACTIVATE_TERM:
@ -204,8 +207,8 @@ TermApp::ArgvReceived(int32 argc, char **argv)
// Print usage
if (argmatch(argv, argc, "-help", "--help", 3, NULL, &skip_args)) {
Usage(argv[0]);
usage_requested = true;
_Usage(argv[0]);
gUsageRequested = true;
PostMessage(B_QUIT_REQUESTED);
}
@ -230,14 +233,14 @@ TermApp::ArgvReceived(int32 argc, char **argv)
|| width >= 256 || height >= 256 || xpos >= 2048 || ypos >= 2048) {
fprintf(stderr, "%s: invalid geometry format or value.\n", argv[0]);
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
usage_requested = true;
gUsageRequested = true;
PostMessage(B_QUIT_REQUESTED);
}
gTermPref->setInt32(PREF_COLS, width);
gTermPref->setInt32(PREF_ROWS, height);
fTermFrame.Set(xpos, ypos, xpos + 50, ypos + 50);
geometry_requested = true;
gGeometryRequested = true;
}
#if 0
@ -248,7 +251,7 @@ TermApp::ArgvReceived(int32 argc, char **argv)
status_t status = inFile.SetTo("/etc/rgb.txt", B_READ_ONLY);
if (status != B_OK) {
fprintf(stderr, "%s: Can't open /etc/rgb.txt file.\n", argv[0]);
usage_requested = true;
gUsageRequested = true;
PostMessage(B_QUIT_REQUESTED);
}
@ -278,7 +281,7 @@ TermApp::ArgvReceived(int32 argc, char **argv)
if (*argv[skip_args] == '-') {
fprintf(stderr, "%s: invalid option `%s'\n", argv[0], argv[skip_args]);
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
usage_requested = true;
gUsageRequested = true;
PostMessage(B_QUIT_REQUESTED);
}
@ -290,25 +293,9 @@ TermApp::ArgvReceived(int32 argc, char **argv)
}
}
//void
//TermApp::AboutRequested(void)
//{
// if(fAboutPanel) {
// fAboutPanel->Activate();
// }
// else {
// BRect rect(0, 0, 350 - 1, 170 - 1);
// rect.OffsetTo(fTermWindow->Frame().LeftTop());
// rect.OffsetBy(100, 100);
// fAboutPanel = new AboutDlg(rect, this);
// fAboutPanel->Show();
// }
//}
void
TermApp::RefsReceived(BMessage *message)
TermApp::RefsReceived(BMessage* message)
{
// Works Only Launced by Double-Click file, or Drags file to App.
if (!IsLaunching())
@ -345,7 +332,7 @@ TermApp::RefsReceived(BMessage *message)
status_t
TermApp::MakeTermWindow(BRect &frame)
TermApp::_MakeTermWindow(BRect &frame)
{
const char *encoding = gTermPref->getString(PREF_TEXT_ENCODING);
@ -385,10 +372,9 @@ TermApp::MakeTermWindow(BRect &frame)
void
TermApp::ActivateTermWindow(team_id id)
TermApp::_ActivateTermWindow(team_id id)
{
BMessenger app(TERM_SIGNATURE, id);
if (app.IsTargetLocal())
fTermWindow->Activate();
else
@ -397,7 +383,7 @@ TermApp::ActivateTermWindow(team_id id)
void
TermApp::SwitchTerm()
TermApp::_SwitchTerm()
{
team_id myId = be_app->Team(); // My id
BList teams;
@ -418,73 +404,98 @@ TermApp::SwitchTerm()
do {
if (--i < 0)
i = numTerms - 1;
} while (IsMinimize(reinterpret_cast<team_id>(teams.ItemAt(i))));
} while (_IsMinimized(reinterpret_cast<team_id>(teams.ItemAt(i))));
// Activate switched terminal.
ActivateTermWindow(reinterpret_cast<team_id>(teams.ItemAt(i)));
_ActivateTermWindow(reinterpret_cast<team_id>(teams.ItemAt(i)));
}
bool
TermApp::IsMinimize(team_id id)
TermApp::_IsMinimized(team_id id)
{
BMessenger app(TERM_SIGNATURE, id);
if (app.IsTargetLocal())
return fTermWindow->IsMinimized();
BMessage reply;
bool hidden;
if (app.SendMessage(MSG_TERM_IS_MINIMIZE, &reply) != B_OK)
return true;
bool hidden;
reply.FindBool("result", &hidden);
return hidden;
}
int32
TermApp::FindTerminalId()
void
TermApp::_UpdateRegistration(bool set)
{
BList teams;
be_roster->GetAppList(TERM_SIGNATURE, &teams);
int32 count = teams.CountItems();
int32 numbers[count];
thread_info info;
get_thread_info(find_thread(NULL), &info);
for (int32 i=0; i<count; i++) {
numbers[i] = 0;
team_id id = (team_id)teams.ItemAt(i);
if (id == info.team)
continue;
BMessage msg(B_GET_PROPERTY);
BMessage reply;
msg.AddSpecifier("Title");
msg.AddSpecifier("Window", (int32)0);
if (BMessenger(TERM_SIGNATURE, id).SendMessage(&msg, &reply) != B_OK)
continue;
BString title;
if (reply.FindString("result", &title)!=B_OK)
continue;
sscanf(title.String(), "Terminal %ld", &numbers[i]);
if (set)
fWindowNumber = -1;
else if (fWindowNumber < 0)
return;
int fd = open("/tmp/terminal_ids", O_RDWR | O_CREAT);
if (fd < 0)
return;
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_CUR;
lock.l_start = 0;
lock.l_len = -1;
fcntl(fd, F_SETLKW, &lock);
uint8 windows[256];
ssize_t length = read_pos(fd, 0, windows, sizeof(windows));
if (length < 0) {
close(fd);
return;
}
for (int32 i=1; i<count; i++) {
bool found = false;
for (int32 j=0; j<count; j++) {
if (i == numbers[j]) {
found = true;
if (length > (ssize_t)sizeof(windows))
length = sizeof(windows);
if (set) {
int32 i;
for (i = 0; i < length; i++) {
if (!windows[i]) {
windows[i] = true;
fWindowNumber = i + 1;
break;
}
}
if (!found)
return i;
if (i == length) {
if (length >= (ssize_t)sizeof(windows)) {
close(fd);
return;
}
windows[length] = true;
length++;
fWindowNumber = length;
}
} else {
// update information and write it back
windows[fWindowNumber - 1] = false;
}
return count;
write_pos(fd, 0, windows, length);
close(fd);
}
void
TermApp::_UnregisterTerminal()
{
_UpdateRegistration(false);
}
void
TermApp::_RegisterTerminal()
{
_UpdateRegistration(true);
}
@ -510,35 +521,32 @@ TermApp::FindTerminalId()
// be_roster->ActivateApp(be_roster->TeamFor(B_NETPOSITIVE_APP_SIGNATURE));
//}
#define PR(a) fprintf(stderr, a)
// Display usage to stderr
void
TermApp::Usage(char *name)
TermApp::_Usage(char *name)
{
fprintf(stderr, "\n");
fprintf(stderr, "Haiku Terminal\n");
fprintf(stderr, "Copyright 2004 Haiku, Inc.\n");
fprintf(stderr, "Parts Copyright(C) 1999 Kazuho Okui and Takashi Murai.\n");
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s [OPTION] [SHELL]\n", name);
PR(" -p, --preference load preference file\n");
PR(" -t, --title set window title\n");
PR(" -geom, --geometry set window geometry\n");
PR(" An example of geometry is \"80x25+100+100\"\n");
fprintf(stderr, "Haiku Terminal\n"
"Copyright 2001-2007 Haiku, Inc.\n"
"Copyright(C) 1999 Kazuho Okui and Takashi Murai.\n"
"\n"
"Usage: %s [OPTION] [SHELL]\n", name);
fprintf(stderr, " -p, --preference load preference file\n"
" -t, --title set window title\n"
" -geom, --geometry set window geometry\n"
" An example of geometry is \"80x25+100+100\"\n");
#if 0
PR(" -fg, --text-fore-color set window foreground color\n");
PR(" -bg, --text-back-color set window background color\n");
PR(" -curfg, --cursor-fore-color set cursor foreground color\n");
PR(" -curbg, --cursor-back-color set cursor background color\n");
PR(" -selfg, --select-fore-color set selection area foreground color\n");
PR(" -selbg, --select-back-color set selection area background color\n");
PR(" Examples of color are \"#FF00FF\" and \"purple\"\n");
fprintf(stderr, " -fg, --text-fore-color set window foreground color\n"
" -bg, --text-back-color set window background color\n"
" -curfg, --cursor-fore-color set cursor foreground color\n"
" -curbg, --cursor-back-color set cursor background color\n"
" -selfg, --select-fore-color set selection area foreground color\n"
" -selbg, --select-back-color set selection area background color\n"
" Examples of color are \"#FF00FF\" and \"purple\"\n");
#endif
PR("\n");
}
int
text_to_rgb(char *name, rgb_color *color, char *buffer)
{

View File

@ -1,4 +1,5 @@
/*
* Copyright 2001-2007, Haiku.
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
@ -27,13 +28,14 @@
* THE SOFTWARE.
*
*/
#ifndef TERM_APP_H
#define TERM_APP_H
#ifndef TERMAPP_H
#define TERMAPP_H
#include <app/Application.h>
#include <Application.h>
#include <String.h>
extern int gPfd;
extern char *ptyname;
@ -42,51 +44,41 @@ class TermParse;
class BRect;
class AboutDlg;
class TermApp : public BApplication
{
public:
TermApp();
~TermApp();
class TermApp : public BApplication {
public:
TermApp();
virtual ~TermApp();
private:
/*
* Hook functions
*/
void ReadyToRun();
void Quit();
void AboutRequested();
void MessageReceived(BMessage* msg);
void RefsReceived(BMessage *message);
void ArgvReceived(int32 argc, char **argv);
protected:
void ReadyToRun();
void Quit();
void AboutRequested();
void MessageReceived(BMessage* message);
void RefsReceived(BMessage* message);
void ArgvReceived(int32 argc, char** argv);
/*
* Public Member functions.
*/
status_t MakeTermWindow (BRect &frame);
void SwitchTerm(void);
void ActivateTermWindow(team_id id);
private:
status_t _MakeTermWindow(BRect& frame);
void _SwitchTerm();
void _ActivateTermWindow(team_id id);
bool _IsMinimized(team_id id);
void _UpdateRegistration(bool set);
void _UnregisterTerminal();
void _RegisterTerminal();
void Usage(char *name);
private:
bool IsMinimize (team_id);
int32 FindTerminalId();
void _Usage(char *name);
int fRows, fCols, fXpos, fYpos;
bool fStartFullscreen;
BString fWindowTitle;
int fWindowNumber;
rgb_color fFg, fBg, fCurFg, fCurBg, fSelFg, fSelbg;
rgb_color fImfg, fImbg, fImSel;
TermWindow *fTermWindow;
TermParse *fTermParse;
BRect fTermFrame;
AboutDlg *fAboutPanel;
BString CommandLine;
port_id fRegistrationPort;
int32 fRows, fCols, fXpos, fYpos;
bool fStartFullscreen;
BString fWindowTitle;
int32 fWindowNumber;
rgb_color fFg, fBg, fCurFg, fCurBg, fSelFg, fSelbg;
rgb_color fImfg, fImbg, fImSel;
TermWindow* fTermWindow;
TermParse* fTermParse;
BRect fTermFrame;
BString CommandLine;
};
#endif
#endif // TERM_APP_H

View File

@ -44,7 +44,6 @@
const uint32 MENU_SWITCH_TERM = 'MSWT';
const uint32 MENU_NEW_TERM = 'MNTE';
const uint32 MENU_PREF_OPEN = 'MPre';
const uint32 MENU_FILE_QUIT = 'MFqu';
const uint32 MENU_CLEAR_ALL = 'MCAl';
const uint32 MENU_HELP = 'Mhlp';
const uint32 MENU_COMMAND_HELP = 'Mchp';

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2005, Haiku, Inc.
* Copyright 2001-2007, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* Distributed under the terms of the MIT license.
@ -48,10 +48,9 @@ int gNowCoding = M_UTF8;
#define DEFAULT -1
#define NPARAM 10 // Max parameters
/*
* Constructor and Destructor.
*/
TermParse::TermParse(int fd, TermWindow *inWinObj, TermView *inViewObj, CodeConv *inConvObj)
TermParse::TermParse(int fd, TermWindow *inWinObj, TermView *inViewObj,
CodeConv *inConvObj)
:
fFd(fd),
fViewObj(inViewObj),
@ -77,6 +76,9 @@ TermParse::~TermParse()
delete_sem(fReaderSem);
delete_sem(fReaderLocker);
//suspend_thread(fReaderThread);
// TODO: interrupt read() - doesn't work for whatever reason
status_t dummy;
wait_for_thread(fReaderThread, &dummy);
wait_for_thread(fParseThread, &dummy);
@ -101,10 +103,7 @@ TermParse::StartThreads()
}
/////////////////////////////////////////////////////////////////////////////
// PtyReader ... Get character from pty device.
//
/////////////////////////////////////////////////////////////////////////////
//! Get data from pty device.
int32
TermParse::PtyReader()
{
@ -120,18 +119,20 @@ TermParse::PtyReader()
if (status < B_OK)
return status;
}
// Read PTY
uchar buf[READ_BUF_SIZE];
int nread = read(fFd, buf, READ_BUF_SIZE - (read_p - fParser_p));
if (nread <= 0) {
be_app->PostMessage(B_QUIT_REQUESTED);
exit_thread(B_ERROR);
}
int left = READ_BUF_SIZE - (read_p % READ_BUF_SIZE);
int mod = read_p % READ_BUF_SIZE;
// Copy read string to PtyBuffer.
if (nread <= 0) {
be_app->PostMessage(B_QUIT_REQUESTED);
exit_thread(B_ERROR);
}
// Copy read string to PtyBuffer.
int left = READ_BUF_SIZE - (read_p % READ_BUF_SIZE);
int mod = read_p % READ_BUF_SIZE;
if (nread >= left) {
memcpy(fReadBuf + mod, buf, left);
memcpy(fReadBuf, buf + left, nread - left);
@ -139,21 +140,17 @@ TermParse::PtyReader()
memcpy(fReadBuf + mod, buf, nread);
read_p += nread;
// Release semaphore. Number of semaphore counter is nread.
release_sem_etc(fReaderSem, nread, 0);
release_sem_etc(fReaderSem, nread, 0);
}
fReaderThread = -1;
exit_thread(B_OK);
return B_OK;
}
///////////////////////////////////////////////////////////////////////////
// GetReaderBuf ... Get char pty reader buffer.
//
///////////////////////////////////////////////////////////////////////////
//! Get char from pty reader buffer.
status_t
TermParse::GetReaderBuf(uchar &c)
{
@ -163,15 +160,15 @@ TermParse::GetReaderBuf(uchar &c)
} while (status == B_INTERRUPTED);
if (status == B_TIMED_OUT) {
fViewObj->ScrollAtCursor();
fViewObj->UpdateLine();
fViewObj->ScrollAtCursor();
fViewObj->UpdateLine();
// Reset cursor blinking time and turn on cursor blinking.
fCursorUpdate->SetInterval (1000000);
fViewObj->SetCurDraw (CURON);
fCursorUpdate->SetInterval (1000000);
fViewObj->SetCurDraw (CURON);
// wait new input from pty.
do {
// wait new input from pty.
do {
status = acquire_sem(fReaderSem);
} while (status == B_INTERRUPTED);
if (status < B_OK)
@ -185,39 +182,34 @@ TermParse::GetReaderBuf(uchar &c)
fParser_p++;
// If PtyReader thread locked, decrement counter and unlock thread.
if (fLockFlag != 0) {
if (--fLockFlag == 0)
release_sem(fReaderLocker);
}
if (--fLockFlag == 0)
release_sem(fReaderLocker);
}
fViewObj->SetCurDraw(CUROFF);
return B_OK;
}
///////////////////////////////////////////////////////////////////////////
// InitTermParse ... Initialize and spawn EscParse thread.
//
///////////////////////////////////////////////////////////////////////////
//! Initialize and spawn EscParse thread.
status_t
TermParse::InitTermParse()
{
if (fParseThread >= 0)
return B_ERROR; // we might want to return B_OK instead ?
BMessage cursor(MSGRUN_CURSOR);
fCursorUpdate = new BMessageRunner(BMessenger(fViewObj),
new BMessage(MSGRUN_CURSOR), 1000000);
fParseThread = spawn_thread(_escparse_thread, "EscParse", B_DISPLAY_PRIORITY, this);
&cursor, 1000000);
fParseThread = spawn_thread(_escparse_thread, "EscParse",
B_DISPLAY_PRIORITY, this);
return resume_thread(fParseThread);
}
///////////////////////////////////////////////////////////////////////////
// InitPtyReader ... Initialize and spawn PtyReader thread.
//
///////////////////////////////////////////////////////////////////////////
//! Initialize and spawn PtyReader thread.
thread_id
TermParse::InitPtyReader()
{
@ -234,13 +226,14 @@ TermParse::InitPtyReader()
return fReaderLocker;
}
fReaderThread = spawn_thread(_ptyreader_thread, "PtyReader", B_NORMAL_PRIORITY, this);
fReaderThread = spawn_thread(_ptyreader_thread, "PtyReader",
B_NORMAL_PRIORITY, this);
if (fReaderThread < 0) {
delete_sem(fReaderSem);
delete_sem(fReaderLocker);
return fReaderThread;
}
return resume_thread(fReaderThread);
}
@ -869,16 +862,14 @@ TermParse::EscParse()
}
/* static */
int32
/*static*/ int32
TermParse::_ptyreader_thread(void *data)
{
return reinterpret_cast<TermParse *>(data)->PtyReader();
}
/* static */
int32
/*static*/ int32
TermParse::_escparse_thread(void *data)
{
return reinterpret_cast<TermParse *>(data)->EscParse();

View File

@ -27,14 +27,15 @@
* THE SOFTWARE.
*
*/
#ifndef TERMPARSE_H
#define TERMPARSE_H
#include "TermConst.h"
#include <OS.h>
#include <MessageRunner.h>
#include "TermConst.h"
class TermView;
class CodeConv;

View File

@ -228,9 +228,9 @@ TermWindow::SetupMenu(void)
fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("About Terminal...", new BMessage(B_ABOUT_REQUESTED)));
fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("Quit", new BMessage(MENU_FILE_QUIT), 'Q'));
fFilemenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
fMenubar->AddItem(fFilemenu);
// Make Edit Menu.
fEditmenu = new BMenu ("Edit");
fEditmenu->AddItem (new BMenuItem ("Copy", new BMessage (B_COPY),'C'));
@ -246,10 +246,9 @@ TermWindow::SetupMenu(void)
fFindForwardMenuItem = new BMenuItem ("Find Forward", new BMessage (MENU_FIND_FORWARD), ']');
fEditmenu->AddItem (fFindForwardMenuItem);
fFindForwardMenuItem->SetEnabled(false);
fMenubar->AddItem (fEditmenu);
// Make Help Menu.
fHelpmenu = new BMenu("Settings");
fWindowSizeMenu = new BMenu("Window Size");
@ -259,7 +258,7 @@ TermWindow::SetupMenu(void)
fWindowSizeMenu->AddItem(new BMenuItem("132x24", new BMessage(ONETHREETWOTWENTYFOUR)));
fWindowSizeMenu->AddItem(new BMenuItem("132x25", new BMessage(ONETHREETWOTWENTYFIVE)));
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");
@ -369,8 +368,8 @@ TermWindow::MessageReceived(BMessage *message)
fFindForwardMenuItem->SetEnabled(false);
break;
}
//Enable the menu items Find Forward and Find Backward
// Enable the menu items Find Forward and Find Backward
fFindBackwardMenuItem->SetEnabled(true);
fFindForwardMenuItem->SetEnabled(true);
break;
@ -393,14 +392,10 @@ TermWindow::MessageReceived(BMessage *message)
}
break;
}
case MSG_FIND_CLOSED: {
case MSG_FIND_CLOSED:
fFindPanel = NULL;
break;
}
case MENU_FILE_QUIT: {
be_app->PostMessage(B_QUIT_REQUESTED);
break;
}
case MENU_ENCODING: {
message->FindInt32 ("op", &coding_id);
gNowCoding = coding_id;
@ -600,35 +595,16 @@ TermWindow::WindowActivated (bool )
}
////////////////////////////////////////////////////////////////////////////
// Quit (void)
// Quit Application.
////////////////////////////////////////////////////////////////////////////
//void
//TermWindow::colRequested() {
// colWindow *colW=new colWindow("Colours for Terminal");
// colW->Show();
// }
void
TermWindow::Quit()
{
BWindow::Quit();
}
bool
TermWindow::QuitRequested(void)
TermWindow::QuitRequested()
{
return BWindow::QuitRequested();
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
////////////////////////////////////////////////////////////////////////////
// int GetTimeZone (void)
// Get Machine Timezone.
////////////////////////////////////////////////////////////////////////////
//! Get Machine Timezone.
int
TermWindow::GetTimeZone()
{

View File

@ -50,28 +50,27 @@ class FindWindow;
class TermWindow : public BWindow {
public:
TermWindow(BRect frame, const char* title, int gPfd);
~TermWindow();
virtual ~TermWindow();
void Quit (void);
bool QuitRequested (void);
void TermWinActivate (void);
status_t GetSupportedSuites (BMessage *msg);
BHandler* ResolveSpecifier (BMessage *msg, int32 index,
BMessage *specifier, int32 form,
const char *property);
void TermWinActivate();
private:
void InitWindow (void);
void SetupMenu (void);
// void colRequested (void);
void MessageReceived (BMessage *message);
void WindowActivated (bool);
int GetTimeZone (void);
void MenusBeginning(void);
// void doShowHelp (uint32 command);
// Printing
status_t DoPageSetup (void);
void DoPrint (void);
protected:
virtual void MessageReceived(BMessage *message);
virtual void WindowActivated(bool);
virtual void MenusBeginning(void);
virtual bool QuitRequested();
status_t GetSupportedSuites(BMessage *msg);
BHandler* ResolveSpecifier(BMessage *msg, int32 index,
BMessage *specifier, int32 form,
const char *property);
private:
void InitWindow();
void SetupMenu();
int GetTimeZone();
status_t DoPageSetup();
void DoPrint();
/*
* data member