Removed old and unused files
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18519 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files or portions
|
|
||||||
* thereof (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so, subject
|
|
||||||
* to the following conditions:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice
|
|
||||||
* in the binary, as well as this list of conditions and the following
|
|
||||||
* disclaimer in the documentation and/or other materials provided with
|
|
||||||
* the distribution.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "TermApp.h"
|
|
||||||
#include "PrefHandler.h"
|
|
||||||
|
|
||||||
/* global varriables */
|
|
||||||
int pfd; /* pesudo tty fd */
|
|
||||||
int pfd_no; /* pfd number */
|
|
||||||
|
|
||||||
PrefHandler *gTermPref; /* Preference temporary */
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// main (int argc, char **argv)
|
|
||||||
// main routine of MuTerminal.
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
TermApp app;
|
|
||||||
app.Run ();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,334 +0,0 @@
|
|||||||
#include <Autolock.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <Point.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
|
|
||||||
#include <Constants.h>
|
|
||||||
#include <TerminalApp.h>
|
|
||||||
#include <TerminalWindow.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
|
|
||||||
TerminalApp * terminal_app;
|
|
||||||
|
|
||||||
TerminalApp::TerminalApp()
|
|
||||||
: BApplication(APP_SIGNATURE)
|
|
||||||
{
|
|
||||||
fWindowOpened = false;
|
|
||||||
fArgvOkay = true;
|
|
||||||
terminal_app = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
TerminalApp::~TerminalApp()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TerminalApp::DispatchMessage(BMessage *msg, BHandler *handler)
|
|
||||||
{
|
|
||||||
if ( msg->what == B_ARGV_RECEIVED ) {
|
|
||||||
int32 argc;
|
|
||||||
if (msg->FindInt32("argc",&argc) != B_OK) {
|
|
||||||
argc = 0;
|
|
||||||
}
|
|
||||||
char ** argv = new (char*)[argc];
|
|
||||||
for (int arg = 0; (arg < argc) ; arg++) {
|
|
||||||
BString string;
|
|
||||||
if (msg->FindString("argv",arg,&string) != B_OK) {
|
|
||||||
argv[arg] = "";
|
|
||||||
} else {
|
|
||||||
char * chars = new char[string.Length()];
|
|
||||||
strcpy(chars,string.String());
|
|
||||||
argv[arg] = chars;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const char * cwd;
|
|
||||||
if (msg->FindString("cwd",&cwd) != B_OK) {
|
|
||||||
cwd = "";
|
|
||||||
}
|
|
||||||
ArgvReceived(argc, argv, cwd);
|
|
||||||
} else {
|
|
||||||
BApplication::DispatchMessage(msg,handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalApp::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
default:
|
|
||||||
BApplication::MessageReceived(message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalApp::OpenTerminal(BMessage * message)
|
|
||||||
{
|
|
||||||
TerminalWindow * terminal = new TerminalWindow(message);
|
|
||||||
fWindowOpened = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <Roster.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalApp::RefsReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
int32 i = 0;
|
|
||||||
entry_ref ref;
|
|
||||||
if (IsLaunching()) {
|
|
||||||
// peel off the first ref and open it ourselves
|
|
||||||
if (message->FindRef("refs",i++,&ref) == B_OK) {
|
|
||||||
BMessage file(OPEN_TERMINAL);
|
|
||||||
file.AddRef("refs",&ref);
|
|
||||||
OpenTerminal(&file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// handle any other refs by launching them as separate apps
|
|
||||||
while (message->FindRef("refs",i++,&ref) == B_OK) {
|
|
||||||
BMessage * file = new BMessage(OPEN_TERMINAL);
|
|
||||||
file->AddRef("refs",&ref);
|
|
||||||
be_roster->Launch(APP_SIGNATURE,file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalApp::PrintUsage(const char * execname) {
|
|
||||||
if (execname == 0) {
|
|
||||||
execname = "Terminal";
|
|
||||||
}
|
|
||||||
fprintf(stderr,"Usage: %s [OPTIONS] [SHELL]\n",execname);
|
|
||||||
fprintf(stderr,"Open a terminal window.\n");
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
fprintf(stderr," -curbg COLOR use COLOR as the cursor background color\n");
|
|
||||||
fprintf(stderr," -curfg COLOR use COLOR as the cursor foreground (text) color\n");
|
|
||||||
fprintf(stderr," -bg COLOR use COLOR as the background color\n");
|
|
||||||
fprintf(stderr," -fg COLOR use COLOR as the foreground (text) color\n");
|
|
||||||
fprintf(stderr," -g, -geom NxM use geometry N columns by M rows\n");
|
|
||||||
fprintf(stderr," -h, -help print this help\n");
|
|
||||||
fprintf(stderr," -m, -meta pass through the META key to the shell\n");
|
|
||||||
fprintf(stderr," -p, -pref FILE use FILE as a Terminal preference file\n");
|
|
||||||
fprintf(stderr," -selbg COLOR use COLOR as the selection background color\n");
|
|
||||||
fprintf(stderr," -selfg COLOR use COLOR as the selection foreground (text) color\n");
|
|
||||||
fprintf(stderr," -t, -title TITLE use TITLE as the window title\n");
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
fprintf(stderr,"Report bugs to [email protected]\n");
|
|
||||||
fprintf(stderr,"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct option curbg_opt = { "curbg", required_argument, 0, 1 } ;
|
|
||||||
struct option curfg_opt = { "curfg", required_argument, 0, 2 } ;
|
|
||||||
struct option bg_opt = { "bg", required_argument, 0, 3 } ;
|
|
||||||
struct option fg_opt = { "fg", required_argument, 0, 4 } ;
|
|
||||||
struct option geom_opt = { "geom", required_argument, 0, 'g' } ;
|
|
||||||
struct option help_opt = { "help", no_argument, 0, 'h' } ;
|
|
||||||
struct option meta_opt = { "meta", no_argument, 0, 'm' } ;
|
|
||||||
struct option pref_opt = { "pref", required_argument, 0, 'p' } ;
|
|
||||||
struct option selbg_opt = { "selbg", required_argument, 0, 5 } ;
|
|
||||||
struct option selfg_opt = { "selfg", required_argument, 0, 6 } ;
|
|
||||||
struct option title_opt = { "title", required_argument, 0, 't' } ;
|
|
||||||
|
|
||||||
struct option options[] =
|
|
||||||
{ curbg_opt, curfg_opt, bg_opt, fg_opt,
|
|
||||||
geom_opt, help_opt, meta_opt, pref_opt,
|
|
||||||
selbg_opt, selfg_opt, title_opt, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
status_t
|
|
||||||
string2color (const char * name, rgb_color * color) {
|
|
||||||
if (!name || !color) {
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
if (strcmp("black",name) == 0) {
|
|
||||||
color->red = 0;
|
|
||||||
color->green = 0;
|
|
||||||
color->blue = 0;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
if (strcmp("red",name) == 0) {
|
|
||||||
color->red = 128;
|
|
||||||
color->green = 0;
|
|
||||||
color->blue = 0;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement the arguments for Terminal
|
|
||||||
void
|
|
||||||
TerminalApp::ArgvReceived(int32 argc, char * const argv[], const char * cwd)
|
|
||||||
{
|
|
||||||
BMessage terminal(OPEN_TERMINAL);
|
|
||||||
fArgvOkay = false;
|
|
||||||
if (argc > 1) {
|
|
||||||
if (argv[1][0] == '-') {
|
|
||||||
const char * execname = (argc >= 1 ? argv[0] : "");
|
|
||||||
const char * title = 0;
|
|
||||||
int indexptr = 0;
|
|
||||||
int ch;
|
|
||||||
char * const * optargv = argv;
|
|
||||||
while ((ch = getopt_long_only(argc, optargv, "hg:mp:t:", options, &indexptr)) != -1) {
|
|
||||||
switch (ch) {
|
|
||||||
case 'h':
|
|
||||||
PrintUsage(execname);
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
case 'g':
|
|
||||||
printf("geometry is %s = ",optarg);
|
|
||||||
int m, n;
|
|
||||||
if ((sscanf(optarg,"%ldx%ld%s",&m,&n) != 2) || (m < 0) || (n < 0)) {
|
|
||||||
printf("??\n");
|
|
||||||
printf("geometry must be of the format MxN where M and N are positive integers\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("%ld,%ld\n",m,n);
|
|
||||||
terminal.AddInt32("columns",m);
|
|
||||||
terminal.AddInt32("rows",n);
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
printf("pass meta through to shell\n");
|
|
||||||
terminal.AddBool("meta",true);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
printf("title is %s\n",optarg);
|
|
||||||
terminal.AddString("title",optarg);
|
|
||||||
break;
|
|
||||||
case 'p': {
|
|
||||||
printf("prefs file is %s\n",optarg);
|
|
||||||
BPath pref;
|
|
||||||
if (optarg[0] == '/') {
|
|
||||||
pref.SetTo(optarg);
|
|
||||||
} else {
|
|
||||||
pref.SetTo(cwd,optarg);
|
|
||||||
}
|
|
||||||
entry_ref ref;
|
|
||||||
switch (get_ref_for_path(pref.Path(),&ref)) {
|
|
||||||
case B_OK:
|
|
||||||
break;
|
|
||||||
case B_ENTRY_NOT_FOUND:
|
|
||||||
printf("could not find entry for prefs file '%s'\n",optarg);
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
case B_NO_MEMORY:
|
|
||||||
printf("not enough memory in get_ref_for_path\n");
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("unknown error in get_ref_for_path\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddRef("refs",&ref);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ':':
|
|
||||||
switch (optopt) {
|
|
||||||
case 't':
|
|
||||||
printf("-t option must be specified with a title\n");
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("-%c missing argument\n", optopt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '?':
|
|
||||||
// getopt prints error message
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
switch (options[indexptr].val) {
|
|
||||||
case 1: { // curbg
|
|
||||||
printf("curbg = %s\n",optarg);
|
|
||||||
rgb_color color;
|
|
||||||
if (string2color(optarg,&color) != B_OK) {
|
|
||||||
printf("invalid color specifier for curbg\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddData("curbg",B_RGB_32_BIT_TYPE,
|
|
||||||
&color,sizeof(color),true,1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2: { // curfg
|
|
||||||
printf("curfg = %s\n",optarg);
|
|
||||||
rgb_color color;
|
|
||||||
if (string2color(optarg,&color) != B_OK) {
|
|
||||||
printf("invalid color specifier for curfg\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddData("curfg",B_RGB_32_BIT_TYPE,
|
|
||||||
&color,sizeof(color),true,1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3: { // bg
|
|
||||||
printf("bg = %s\n",optarg);
|
|
||||||
rgb_color color;
|
|
||||||
if (string2color(optarg,&color) != B_OK) {
|
|
||||||
printf("invalid color specifier for bg\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddData("bg",B_RGB_32_BIT_TYPE,
|
|
||||||
&color,sizeof(color),true,1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4: { // fg
|
|
||||||
printf("fg = %s\n",optarg);
|
|
||||||
rgb_color color;
|
|
||||||
if (string2color(optarg,&color) != B_OK) {
|
|
||||||
printf("invalid color specifier for fg\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddData("fg",B_RGB_32_BIT_TYPE,
|
|
||||||
&color,sizeof(color),true,1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5: { // selbg
|
|
||||||
printf("selbg = %s\n",optarg);
|
|
||||||
rgb_color color;
|
|
||||||
if (string2color(optarg,&color) != B_OK) {
|
|
||||||
printf("invalid color specifier for selbg\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddData("selbg",B_RGB_32_BIT_TYPE,
|
|
||||||
&color,sizeof(color),true,1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6: { // selfg
|
|
||||||
printf("selfg = %s\n",optarg);
|
|
||||||
rgb_color color;
|
|
||||||
if (string2color(optarg,&color) != B_OK) {
|
|
||||||
printf("invalid color specifier for selfg\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
terminal.AddData("selfg",B_RGB_32_BIT_TYPE,
|
|
||||||
&color,sizeof(color),true,1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("invalid indexptr %ld\n",indexptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (optind < argc) {
|
|
||||||
printf("adding string %s\n",argv[optind]);
|
|
||||||
terminal.AddString("argv",argv[optind++]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OpenTerminal(&terminal);
|
|
||||||
fArgvOkay = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalApp::ReadyToRun()
|
|
||||||
{
|
|
||||||
if (!fArgvOkay) {
|
|
||||||
Quit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!fWindowOpened) {
|
|
||||||
OpenTerminal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#ifndef TERMINAL_APP_H
|
|
||||||
#define TERMINAL_APP_H
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
|
|
||||||
class TerminalWindow;
|
|
||||||
|
|
||||||
class TerminalApp
|
|
||||||
: public BApplication
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TerminalApp();
|
|
||||||
virtual ~TerminalApp();
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
virtual void ArgvReceived(int32 argc, char * const argv[], const char * cwd);
|
|
||||||
virtual void RefsReceived(BMessage *message);
|
|
||||||
virtual void ReadyToRun();
|
|
||||||
|
|
||||||
virtual void DispatchMessage(BMessage *an_event, BHandler *handler);
|
|
||||||
|
|
||||||
void OpenTerminal(BMessage * message = 0);
|
|
||||||
private:
|
|
||||||
void PrintUsage(const char * execname);
|
|
||||||
bool fWindowOpened;
|
|
||||||
bool fArgvOkay;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern TerminalApp * terminal_app;
|
|
||||||
|
|
||||||
#endif // TERMINAL_APP_H
|
|
||||||
|
|
||||||
@@ -1,420 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Autolock.h>
|
|
||||||
#include <Clipboard.h>
|
|
||||||
#include <Debug.h>
|
|
||||||
#include <Dragger.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <Menu.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <OS.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <PrintJob.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <Shelf.h>
|
|
||||||
#include <StorageDefs.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <TranslationUtils.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include <Constants.h>
|
|
||||||
#include <TerminalApp.h>
|
|
||||||
#include <TerminalWindow.h>
|
|
||||||
|
|
||||||
|
|
||||||
BRect terminalWindowBounds(0,0,560,390);
|
|
||||||
|
|
||||||
TerminalWindow::TerminalWindow(BMessage * settings)
|
|
||||||
: BWindow(terminalWindowBounds.OffsetBySelf(7,26),
|
|
||||||
"Terminal",B_DOCUMENT_WINDOW,0)
|
|
||||||
{
|
|
||||||
fInitStatus = B_ERROR;
|
|
||||||
int id = 1;
|
|
||||||
|
|
||||||
fInitStatus = InitWindow(id++);
|
|
||||||
Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
TerminalWindow::~TerminalWindow()
|
|
||||||
{
|
|
||||||
delete fLogToFilePanel;
|
|
||||||
delete fWriteSelectionPanel;
|
|
||||||
delete fSaveAsSettingsFilePanel;
|
|
||||||
// if (fSaveMessage)
|
|
||||||
// delete fSaveMessage;
|
|
||||||
// if (fPrintSettings)
|
|
||||||
// delete fPrintSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TerminalWindow::InitCheck(void)
|
|
||||||
{
|
|
||||||
return fInitStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TerminalWindow::InitWindow(int32 id, entry_ref * settingsRef)
|
|
||||||
{
|
|
||||||
BView * view = new BView(Bounds(),"view",B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW);
|
|
||||||
AddChild(view);
|
|
||||||
rgb_color white = {255,255,255,0};
|
|
||||||
view->SetViewColor(white);
|
|
||||||
BShelf * shelf = new BShelf(view);
|
|
||||||
|
|
||||||
status_t ignore = RestoreSettings(settingsRef);
|
|
||||||
|
|
||||||
BString unTitled;
|
|
||||||
unTitled.SetTo("Terminal ");
|
|
||||||
unTitled << id;
|
|
||||||
SetTitle(unTitled.String());
|
|
||||||
|
|
||||||
// Add menubar
|
|
||||||
fMenuBar = new BMenuBar(BRect(0,0,0,0),"menubar");
|
|
||||||
|
|
||||||
AddChild(fMenuBar);
|
|
||||||
|
|
||||||
// Add shell view and scroll view
|
|
||||||
BRect shellFrame;
|
|
||||||
shellFrame.top = fMenuBar->Bounds().Height();
|
|
||||||
shellFrame.right = Bounds().Width() - B_V_SCROLL_BAR_WIDTH;
|
|
||||||
shellFrame.left = 0;
|
|
||||||
shellFrame.bottom = Bounds().Height();
|
|
||||||
|
|
||||||
fShellView = new BView(shellFrame,"shellview",B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW);
|
|
||||||
rgb_color red = {170,80,80,0};
|
|
||||||
fShellView->SetViewColor(red);
|
|
||||||
|
|
||||||
if (BDragger::AreDraggersDrawn()) {
|
|
||||||
fShellView->ResizeBy(0,-8);
|
|
||||||
}
|
|
||||||
|
|
||||||
fScrollView = new BScrollView("scrollview", fShellView, B_FOLLOW_ALL,
|
|
||||||
B_FRAME_EVENTS|B_WILL_DRAW, false, true, B_NO_BORDER);
|
|
||||||
view->AddChild(fScrollView);
|
|
||||||
|
|
||||||
// add dragger view
|
|
||||||
BRect draggerFrame;
|
|
||||||
draggerFrame.top = shellFrame.bottom - 8;
|
|
||||||
draggerFrame.right = shellFrame.right;
|
|
||||||
draggerFrame.left = shellFrame.right - 7;
|
|
||||||
draggerFrame.bottom = Bounds().Height();
|
|
||||||
|
|
||||||
BDragger * dragger = new BDragger(draggerFrame,fScrollView,B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM,B_FRAME_EVENTS|B_WILL_DRAW);
|
|
||||||
if (!BDragger::AreDraggersDrawn()) {
|
|
||||||
dragger->Hide();
|
|
||||||
}
|
|
||||||
view->AddChild(dragger);
|
|
||||||
|
|
||||||
// BRect blankFrame;
|
|
||||||
// blankFrame.top = shellFrame.bottom;
|
|
||||||
// blankFrame.right = draggerFrame.left;
|
|
||||||
// blankFrame.left = 0;
|
|
||||||
// blankFrame.bottom = draggerFrame.bottom;
|
|
||||||
// BView * blankView = new BView(blankFrame,"blankview",B_FOLLOW_ALL|B_WILL_DRAW,B_FRAME_EVENTS);
|
|
||||||
// view->AddChild(blankView);
|
|
||||||
fShellView->MakeFocus(true);
|
|
||||||
|
|
||||||
// Terminal menu
|
|
||||||
fTerminal = new BMenu("Terminal");
|
|
||||||
fMenuBar->AddItem(fTerminal);
|
|
||||||
|
|
||||||
fSwitchTerminals = new BMenuItem("Switch Terminals", new BMessage(TERMINAL_SWITCH_TERMINAL), 'G');
|
|
||||||
fTerminal->AddItem(fSwitchTerminals);
|
|
||||||
fSwitchTerminals->SetTrigger('T');
|
|
||||||
|
|
||||||
fStartNewTerminal = new BMenuItem("Start New Terminal", new BMessage(TERMINAL_START_NEW_TERMINAL), 'N');
|
|
||||||
fTerminal->AddItem(fStartNewTerminal);
|
|
||||||
|
|
||||||
fLogToFile = new BMenuItem("Log to File...", new BMessage(TERMINAL_LOG_TO_FILE));
|
|
||||||
fTerminal->AddItem(fLogToFile);
|
|
||||||
|
|
||||||
// Edit menu
|
|
||||||
fEdit = new BMenu("Edit");
|
|
||||||
fMenuBar->AddItem(fEdit);
|
|
||||||
|
|
||||||
fCopy = new BMenuItem("Copy", new BMessage(B_COPY), 'C');
|
|
||||||
fEdit->AddItem(fCopy);
|
|
||||||
fCopy->SetEnabled(false);
|
|
||||||
|
|
||||||
fPaste = new BMenuItem("Paste", new BMessage(B_PASTE), 'V');
|
|
||||||
fEdit->AddItem(fPaste);
|
|
||||||
|
|
||||||
fEdit->AddSeparatorItem();
|
|
||||||
|
|
||||||
fSelectAll = new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A');
|
|
||||||
fEdit->AddItem(fSelectAll);
|
|
||||||
|
|
||||||
fWriteSelection = new BMenuItem("Write Selection...", new BMessage(EDIT_WRITE_SELECTION));
|
|
||||||
fEdit->AddItem(fWriteSelection);
|
|
||||||
|
|
||||||
fClearAll = new BMenuItem("Clear All", new BMessage(EDIT_CLEAR_ALL), 'L');
|
|
||||||
fEdit->AddItem(fClearAll);
|
|
||||||
|
|
||||||
fEdit->AddSeparatorItem();
|
|
||||||
|
|
||||||
fFind = new BMenuItem("Find...", new BMessage(EDIT_FIND),'F');
|
|
||||||
fEdit->AddItem(fFind);
|
|
||||||
|
|
||||||
fFindBackward = new BMenuItem("Find Backward",new BMessage(EDIT_FIND_BACKWARD),'[');
|
|
||||||
fEdit->AddItem(fFindBackward);
|
|
||||||
|
|
||||||
fFindForward = new BMenuItem("Find Forward", new BMessage(EDIT_FIND_FORWARD),']');
|
|
||||||
fEdit->AddItem(fFindForward);
|
|
||||||
|
|
||||||
// Settings menu
|
|
||||||
fSettings = new BMenu("Settings");
|
|
||||||
fMenuBar->AddItem(fSettings);
|
|
||||||
|
|
||||||
fWindowSize = new BMenu("Window Size");
|
|
||||||
fWindowSize->SetRadioMode(true);
|
|
||||||
fSettings->AddItem(fWindowSize);
|
|
||||||
|
|
||||||
BMenuItem * menuItem;
|
|
||||||
BMessage * itemMessage;
|
|
||||||
fWindowSize->AddItem(menuItem = new BMenuItem("80x24", itemMessage = new BMessage(SETTINGS_WINDOW_SIZE)));
|
|
||||||
itemMessage->AddInt32("columns", 80);
|
|
||||||
itemMessage->AddInt32("lines", 24);
|
|
||||||
menuItem->SetMarked(true);
|
|
||||||
|
|
||||||
fWindowSize->AddItem(menuItem = new BMenuItem("80x25", itemMessage = new BMessage(SETTINGS_WINDOW_SIZE)));
|
|
||||||
itemMessage->AddInt32("columns", 80);
|
|
||||||
itemMessage->AddInt32("lines", 25);
|
|
||||||
|
|
||||||
fWindowSize->AddItem(menuItem = new BMenuItem("80x40", itemMessage = new BMessage(SETTINGS_WINDOW_SIZE)));
|
|
||||||
itemMessage->AddInt32("columns", 80);
|
|
||||||
itemMessage->AddInt32("lines", 40);
|
|
||||||
|
|
||||||
fWindowSize->AddItem(menuItem = new BMenuItem("132x24", itemMessage = new BMessage(SETTINGS_WINDOW_SIZE)));
|
|
||||||
itemMessage->AddInt32("columns", 132);
|
|
||||||
itemMessage->AddInt32("lines", 24);
|
|
||||||
|
|
||||||
fWindowSize->AddItem(menuItem = new BMenuItem("132x25", itemMessage = new BMessage(SETTINGS_WINDOW_SIZE)));
|
|
||||||
itemMessage->AddInt32("columns", 132);
|
|
||||||
itemMessage->AddInt32("lines", 25);
|
|
||||||
|
|
||||||
// //Available fonts
|
|
||||||
// font_family plain_family;
|
|
||||||
// font_style plain_style;
|
|
||||||
// be_plain_font->GetFamilyAndStyle(&plain_family,&plain_style);
|
|
||||||
// fCurrentFontItem = 0;
|
|
||||||
//
|
|
||||||
// int32 numFamilies = count_font_families();
|
|
||||||
// for ( int32 i = 0; i < numFamilies; i++ ) {
|
|
||||||
// font_family localfamily;
|
|
||||||
// if ( get_font_family ( i, &localfamily ) == B_OK ) {
|
|
||||||
// subMenu=new BMenu(localfamily);
|
|
||||||
// subMenu->SetRadioMode(true);
|
|
||||||
// fFontMenu->AddItem(menuItem = new BMenuItem(subMenu, new BMessage(FONT_FAMILY)));
|
|
||||||
// if (!strcmp(plain_family,localfamily)) {
|
|
||||||
// menuItem->SetMarked(true);
|
|
||||||
// fCurrentFontItem = menuItem;
|
|
||||||
// }
|
|
||||||
// int32 numStyles=count_font_styles(localfamily);
|
|
||||||
// for(int32 j = 0;j<numStyles;j++){
|
|
||||||
// font_style style;
|
|
||||||
// uint32 flags;
|
|
||||||
// if( get_font_style(localfamily,j,&style,&flags)==B_OK){
|
|
||||||
// subMenu->AddItem(menuItem = new BMenuItem(style, new BMessage(FONT_STYLE)));
|
|
||||||
// if (!strcmp(plain_style,style)) {
|
|
||||||
// menuItem->SetMarked(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// build file panels lazily
|
|
||||||
fLogToFilePanel = 0;
|
|
||||||
fWriteSelectionPanel = 0;
|
|
||||||
fSaveAsSettingsFilePanel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TerminalWindow::RestoreSettings(entry_ref * settingsRef)
|
|
||||||
{
|
|
||||||
status_t result = B_OK;
|
|
||||||
BFile settingsFile;
|
|
||||||
if (settingsRef != 0) {
|
|
||||||
result = settingsFile.SetTo(settingsRef,B_READ_ONLY);
|
|
||||||
if (result != B_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
char settingsDirectory[B_PATH_NAME_LENGTH];
|
|
||||||
result = find_directory(B_USER_SETTINGS_DIRECTORY,0,true,
|
|
||||||
settingsDirectory,B_PATH_NAME_LENGTH);
|
|
||||||
if (result != B_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
BPath settingsFilePath(settingsDirectory,"Terminal");
|
|
||||||
result = settingsFilePath.InitCheck();
|
|
||||||
if (result != B_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = settingsFile.SetTo(settingsFilePath.Path(),B_READ_ONLY);
|
|
||||||
if (result != B_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO : actually read the settings file
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch (message->what){
|
|
||||||
case TERMINAL_START_NEW_TERMINAL:
|
|
||||||
StartNewTerminal(message);
|
|
||||||
break;
|
|
||||||
case TERMINAL_SWITCH_TERMINAL:
|
|
||||||
SwitchTerminals(message);
|
|
||||||
break;
|
|
||||||
case ENABLE_ITEMS:
|
|
||||||
EnableEditItems(message);
|
|
||||||
break;
|
|
||||||
case DISABLE_ITEMS:
|
|
||||||
DisableEditItems(message);
|
|
||||||
break;
|
|
||||||
case B_COPY:
|
|
||||||
EditCopy(message);
|
|
||||||
break;
|
|
||||||
case B_PASTE:
|
|
||||||
EditPaste(message);
|
|
||||||
break;
|
|
||||||
case EDIT_CLEAR_ALL:
|
|
||||||
EditClearAll(message);
|
|
||||||
break;
|
|
||||||
// case FONT_SIZE:
|
|
||||||
// {
|
|
||||||
// float fontSize;
|
|
||||||
// message->FindFloat("size",&fontSize);
|
|
||||||
// SetFontSize(fontSize);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case FONT_FAMILY:
|
|
||||||
// {
|
|
||||||
// const char * fontFamily = 0, * fontStyle = 0;
|
|
||||||
// void * ptr;
|
|
||||||
// if (message->FindPointer("source",&ptr) == B_OK) {
|
|
||||||
// fCurrentFontItem = static_cast<BMenuItem*>(ptr);
|
|
||||||
// fontFamily = fCurrentFontItem->Label();
|
|
||||||
// }
|
|
||||||
// SetFontStyle(fontFamily, fontStyle);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case FONT_STYLE:
|
|
||||||
// {
|
|
||||||
// const char * fontFamily = 0, * fontStyle = 0;
|
|
||||||
// void * ptr;
|
|
||||||
// if (message->FindPointer("source",&ptr) == B_OK) {
|
|
||||||
// BMenuItem * item = static_cast<BMenuItem*>(ptr);
|
|
||||||
// fontStyle = item->Label();
|
|
||||||
// BMenu * menu = item->Menu();
|
|
||||||
// if (menu != 0) {
|
|
||||||
// fCurrentFontItem = menu->Superitem();
|
|
||||||
// if (fCurrentFontItem != 0) {
|
|
||||||
// fontFamily = fCurrentFontItem->Label();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// SetFontStyle(fontFamily, fontStyle);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
default:
|
|
||||||
BWindow::MessageReceived(message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::MenusBeginning()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::Quit()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
BAutolock lock(terminal_app);
|
|
||||||
terminal_app->Quit();
|
|
||||||
}
|
|
||||||
BWindow::Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TerminalWindow::QuitRequested()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::StartNewTerminal(BMessage * message)
|
|
||||||
{
|
|
||||||
status_t result = be_roster->Launch(APP_SIGNATURE);
|
|
||||||
if (result != B_OK) {
|
|
||||||
// TODO: notify user
|
|
||||||
debugger("TerminalWindow::StartNewTerminal failed in Launch");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::SwitchTerminals(BMessage * message)
|
|
||||||
{
|
|
||||||
status_t result;
|
|
||||||
thread_id id = find_thread(NULL);
|
|
||||||
thread_info info;
|
|
||||||
result = get_thread_info(id,&info);
|
|
||||||
if (result != B_OK) {
|
|
||||||
// TODO: notify user
|
|
||||||
debugger("TerminalWindow::SwitchTerminals failed in get_thread_info");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BList teams;
|
|
||||||
be_roster->GetAppList(APP_SIGNATURE,&teams);
|
|
||||||
int32 index = teams.IndexOf((void*)info.team);
|
|
||||||
if (index < -1) {
|
|
||||||
// TODO: notify user
|
|
||||||
debugger("TerminalWindow::SwitchTerminals failed in IndexOf");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
index = (index+teams.CountItems()-1)%teams.CountItems();
|
|
||||||
team_id next = (team_id)teams.ItemAt(index);
|
|
||||||
result = be_roster->ActivateApp(next);
|
|
||||||
} while (result != B_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::EnableEditItems(BMessage * message)
|
|
||||||
{
|
|
||||||
fCopy->SetEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::DisableEditItems(BMessage * message)
|
|
||||||
{
|
|
||||||
fCopy->SetEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::EditCopy(BMessage * message)
|
|
||||||
{
|
|
||||||
// fTextView->Copy(be_clipboard);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::EditPaste(BMessage * message)
|
|
||||||
{
|
|
||||||
// fTextView->Paste(be_clipboard);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TerminalWindow::EditClearAll(BMessage * message)
|
|
||||||
{
|
|
||||||
// fTextView->SelectAll();
|
|
||||||
// fTextView->Clear();
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
#ifndef TERMINAL_WINDOW_H
|
|
||||||
#define TERMINAL_WINDOW_H
|
|
||||||
|
|
||||||
#include <FilePanel.h>
|
|
||||||
#include <MenuBar.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Rect.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <TextView.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <Message.h>
|
|
||||||
|
|
||||||
class TerminalTextView;
|
|
||||||
|
|
||||||
class TerminalWindow
|
|
||||||
: public BWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TerminalWindow(BMessage * settings = 0);
|
|
||||||
virtual ~TerminalWindow();
|
|
||||||
|
|
||||||
virtual void Quit(void);
|
|
||||||
virtual bool QuitRequested(void);
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
|
||||||
virtual void MenusBeginning(void);
|
|
||||||
virtual status_t InitCheck(void);
|
|
||||||
|
|
||||||
private:
|
|
||||||
status_t InitWindow(int32 id, entry_ref * settingsRef = 0);
|
|
||||||
status_t RestoreSettings(entry_ref * settingsRef = 0);
|
|
||||||
|
|
||||||
// message received helpers
|
|
||||||
void StartNewTerminal(BMessage * message);
|
|
||||||
void SwitchTerminals(BMessage * message);
|
|
||||||
void EnableEditItems(BMessage * message);
|
|
||||||
void DisableEditItems(BMessage * message);
|
|
||||||
void EditCopy(BMessage * message);
|
|
||||||
void EditPaste(BMessage * message);
|
|
||||||
void EditClearAll(BMessage * message);
|
|
||||||
|
|
||||||
// Menu variables
|
|
||||||
BMenuBar *fMenuBar;
|
|
||||||
|
|
||||||
BMenu *fTerminal;
|
|
||||||
// ----------------------------------
|
|
||||||
BMenuItem *fSwitchTerminals;
|
|
||||||
BMenuItem *fStartNewTerminal;
|
|
||||||
BMenuItem *fLogToFile;
|
|
||||||
|
|
||||||
BMenu *fEdit;
|
|
||||||
// ----------------------------------
|
|
||||||
BMenuItem *fCopy;
|
|
||||||
BMenuItem *fPaste;
|
|
||||||
// ----------------------------------
|
|
||||||
BMenuItem *fSelectAll;
|
|
||||||
BMenuItem *fWriteSelection;
|
|
||||||
BMenuItem *fClearAll;
|
|
||||||
// ----------------------------------
|
|
||||||
BMenuItem *fFind;
|
|
||||||
BMenuItem *fFindBackward;
|
|
||||||
BMenuItem *fFindForward;
|
|
||||||
|
|
||||||
BMenu *fSettings;
|
|
||||||
// ----------------------------------
|
|
||||||
BMenu *fWindowSize;
|
|
||||||
BMenu *fFont;
|
|
||||||
BMenuItem *fFontSize;
|
|
||||||
BMenu *fFontEncoding;
|
|
||||||
BMenuItem *fTabWidth;
|
|
||||||
BMenuItem *fColor;
|
|
||||||
// ----------------------------------
|
|
||||||
BMenuItem *fSaveAsDefault;
|
|
||||||
BMenuItem *fSaveAsSettingsFile;
|
|
||||||
|
|
||||||
// Main views
|
|
||||||
BView *fShellView;
|
|
||||||
BScrollView *fScrollView;
|
|
||||||
|
|
||||||
// File panels
|
|
||||||
BFilePanel *fLogToFilePanel;
|
|
||||||
BMenu *fLogToFilePanelEncodingMenu;
|
|
||||||
BFilePanel *fWriteSelectionPanel;
|
|
||||||
BMenu *fWriteSelectionPanelEncodingMenu;
|
|
||||||
BFilePanel *fSaveAsSettingsFilePanel;
|
|
||||||
BMenu *fSaveAsSettingsFilePanelEncodingMenu;
|
|
||||||
|
|
||||||
BTextControl *fSavePanelTextView;
|
|
||||||
|
|
||||||
status_t fInitStatus;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TERMINAL_WINDOW_H
|
|
||||||
Reference in New Issue
Block a user