* Removed the old "andrew" code. IIRC it was a start to rework Terminal, but
it's so outdated by now, that it's hardly of any use now. Of course, it's still in the SVN history if you want to have a look at it :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28138 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,42 +0,0 @@
|
|||||||
/*Terminal: constants*/
|
|
||||||
#ifndef CONSTANTS_H
|
|
||||||
#define CONSTANTS_H
|
|
||||||
|
|
||||||
#include <GraphicsDefs.h>
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
|
|
||||||
#define APP_SIGNATURE "application/x-vnd.obos.terminal"
|
|
||||||
|
|
||||||
const float TEXT_INSET = 3.0;
|
|
||||||
|
|
||||||
// Application messages
|
|
||||||
|
|
||||||
const uint32 OPEN_TERMINAL ='OTRM';
|
|
||||||
|
|
||||||
// Messages for menu commands
|
|
||||||
|
|
||||||
// Terminal
|
|
||||||
const uint32 TERMINAL_SWITCH_TERMINAL ='TSWT';
|
|
||||||
const uint32 TERMINAL_START_NEW_TERMINAL='TSNT';
|
|
||||||
const uint32 TERMINAL_LOG_TO_FILE ='TLTF';
|
|
||||||
// Edit
|
|
||||||
const uint32 EDIT_WRITE_SELECTION ='EWSL';
|
|
||||||
const uint32 EDIT_CLEAR_ALL ='ECLA';
|
|
||||||
const uint32 EDIT_FIND ='EFND';
|
|
||||||
const uint32 EDIT_FIND_BACKWARD ='EFBK';
|
|
||||||
const uint32 EDIT_FIND_FORWARD ='EFFD';
|
|
||||||
// Settings
|
|
||||||
const uint32 SETTINGS_WINDOW_SIZE ='SWSZ';
|
|
||||||
const uint32 SETTINGS_FONT ='SFNT';
|
|
||||||
const uint32 SETTINGS_FONT_SIZE ='SFSZ';
|
|
||||||
const uint32 SETTINGS_FONT_ENCODING ='SFEN';
|
|
||||||
const uint32 SETTINGS_TAB_WIDTH ='STBW';
|
|
||||||
const uint32 SETTINGS_COLOR ='SCLR';
|
|
||||||
const uint32 SETTINGS_SAVE_AS_DEFAULT ='SSAD';
|
|
||||||
const uint32 SETTINGS_SAVE_AS_SETTINGS ='SSAS';
|
|
||||||
|
|
||||||
// Edit menu toggle
|
|
||||||
const uint32 ENABLE_ITEMS ='EDON';
|
|
||||||
const uint32 DISABLE_ITEMS ='EDOF';
|
|
||||||
|
|
||||||
#endif // CONSTANTS_H
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#include <TerminalApp.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
TerminalApp terminal;
|
|
||||||
terminal.Run();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
** Terminal.icons.rdef
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource(2, "BEOS:L:application/x-vnd.Be-pref") #'ICON' array {
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF00FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF00FAF8FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF00FAF8F8F8FAFA00FFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF001B0FF8F8F8F800FFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF001B0F0F0FF8F80000FFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF001B0F3F3F0E0F1C190000FFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F0E0F1A190000FFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFF00001B0F3F3F3F3F3F3F0E0F1A190000FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF003F001B0F3F3F3F3F3F3F3F3F0E0F1A00FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFF003F3F001B0F3F3F3F3F3F3F3F3F3F171900FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFF003F3F3F001B0F3F3F3F3F3F3F3F3F3F171900FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFF003F3FFE3F001B183F3F3F3F3F3F3F3F3F171900FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFF003F0000003F3F00001717183F3F3F3F3F3F171900FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF003F00191A1900003F3F000017173F3F3F3F3F17190000FFFFFFFF"
|
|
||||||
$"FFFFFFFF003F00191A0E3F191A00003F3F000017173F3F3F171900FE0000FFFF"
|
|
||||||
$"FFFFFF003F00191A0E3F190F3F191A00003F3F0000171718171A003FFEFE00FF"
|
|
||||||
$"FFFF003F3F000E0F1A190F3F190F3F191A00003F3F000017171A00FEFE00FFFF"
|
|
||||||
$"FF003FFEFEFE00000E0F1A190F3F190F3F191A00003F3F00001900FE000A0B0A"
|
|
||||||
$"0000FEFEFEFEFEFE29000E0F1A190F3F190F191A000F3F003F000000000A0BFF"
|
|
||||||
$"FF0A0000FEFEFEFEFEFE00000E0F1A610F3F190F00000F003FFD006262000AFF"
|
|
||||||
$"FFFF0A000000FDFDFDFDFDFD00000E0F1A610F000F0F003FFD006262FC00000A"
|
|
||||||
$"FFFFFF0A00890000FDFDFDFDFDFD00000E0F290F0FFDFDFD00620F00000A0B0A"
|
|
||||||
$"FFFFFFFF0A0089890000FCFCFCFCFCFC00000E0FFCFCFC006200000A0BFFFFFF"
|
|
||||||
$"FFFFFFFFFF0A006289890100FBFBFBFBFBFBFBFBFBFB0000000A0BFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFF0A00626289890100FAFAFAFAFAFAFA00000A0BFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFF0A00FC626289890000FAFAFAFA000A0BFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFF0A00FCFC626289890000FA000A0BFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFF0A00FCFCFCFC00000A000B0AFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF0A00FC00000A0B0A0B0BFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFF0A000B0AFFFFFF0AFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFF0AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource large_icon array {
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF00FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF00FAF8FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF00FAF8F8F8FAFA0000FFFFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF00FAF8F8F8F8F8FAFA00FFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001BF8F8F8F8F8F8F800FFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F0F0FF8F8F8F800FFFFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F0E0FF8F80000FFFFFFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F0E0F1C1C0000FFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F0E0F1C1C0000FFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F3F3F0E0F1C1C0000FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F0E0F1A190000FFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F0E1A1900FFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B0F3F3F3F3F3F3F3F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFF001B183F3F3F3F3F3F3F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFFFFFFFF0000FFFFFF001B1C17183F3F3F3F3F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFFFFFF00191A0000FFFF00001B1C17183F3F3F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFFFF00191A191A190000FFFF0000191A17173F3F3F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FFFF00191A190F3F191A190000FFFF0000191A17173F3F3F3F3F171900FFFFFF"
|
|
||||||
$"FF00191A0E3F191A0E3F191A190000FFFF0000191A17173F3F3F171900FFFFFF"
|
|
||||||
$"00191A191A190F3F191A0E3F191A190000FFFF0000191A17173F171900FFFFFF"
|
|
||||||
$"000E0F1A191A191A0F3F191A0E3F191A190000FFFF0000191A17171A00FFFFFF"
|
|
||||||
$"FF00000E0F1A191A191A0F3F191A0E3F191A190000FFFF0000191A1900FFFFFF"
|
|
||||||
$"FFFFFF00000E0F1A191A191A0F3F191A0E3F191A19000FFFFF00001900FFFFFF"
|
|
||||||
$"FFFFFFFFFF00000E0F1A191A191A0F3F191A191A0E000F0F0F000F0000FFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFF00000E0F1A191A191A0F191A0F0E00000FFF000F0FFFFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFF00000E0F1A191A191A0F0F000E0F000EFF00000EFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFF00000E0F1A190F0F000F0FFF000EFFFFFF000EFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFF00000E0F0F000F0FFFFFFF000000000FFFFFFF"
|
|
||||||
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000E0FFFFFFFFFFF0E0E0FFFFFFFFF"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(2, "BEOS:M:application/x-vnd.Be-pref") #'MICN' array {
|
|
||||||
$"FFFFFFFFFF0000FFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00F80000FFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00F8F800FFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF0017F8170000FFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00173F3F17170000FFFFFF"
|
|
||||||
$"FFFFFFFF0000173F3F3F3F1700FFFFFF"
|
|
||||||
$"FFFFFF0000000017173F3F1700FFFFFF"
|
|
||||||
$"FFFF0000193F000000171718000000FF"
|
|
||||||
$"FF00000E0F1A3F3F00000017003F0000"
|
|
||||||
$"00FEFE00000E0F1A3F3F00000000000A"
|
|
||||||
$"0B0000FDFD00000E0F0F00FD00890000"
|
|
||||||
$"FF0A000000FDFA000000FA0089000A0B"
|
|
||||||
$"FFFF0A00890000FAFAFA0000000AFFFF"
|
|
||||||
$"FFFFFF0A00628900FA000A0BFFFFFFFF"
|
|
||||||
$"FFFFFFFF0A000000000B0AFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF0A000BFF0AFFFFFFFFFFFF"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource mini_icon array {
|
|
||||||
$"FFFFFFFFFF0000FFFFFFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00F80000FFFFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00F8F8F800FFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00191A1900FFFFFFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00193F191A0000FFFFFFFF"
|
|
||||||
$"FFFFFFFFFF00193F3F3F191A0000FFFF"
|
|
||||||
$"FFFFFFFFFF00193F3F3F3F3F191700FF"
|
|
||||||
$"FFFFFFFFFF00193F3F3F3F3F3F1700FF"
|
|
||||||
$"FFFF0000FF0017173F3F3F3F3F1700FF"
|
|
||||||
$"FF00191A0000191A17173F3F3F1700FF"
|
|
||||||
$"00191A191A1900001A1917183F1700FF"
|
|
||||||
$"000E0F1A191A191A0000191A171800FF"
|
|
||||||
$"FF00000E0F1A191A191A0000191A00FF"
|
|
||||||
$"FFFFFF00000E0F1A190F0F00000000FF"
|
|
||||||
$"FFFFFFFFFF00000E0F0F0000FF000EFF"
|
|
||||||
$"FFFFFFFFFFFFFF0000000EFF00000EFF"
|
|
||||||
};
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
** Terminal.rdef
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* BEOS:APP_SIG :
|
|
||||||
application:/x-vnd.obos.app-name
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource app_signature "application/x-vnd.obos.terminal";
|
|
||||||
|
|
||||||
/* BEOS:APP_FLAGS :
|
|
||||||
00000000 = SINGLE LAUNCH
|
|
||||||
00000001 = MULTIPLE LAUNCH
|
|
||||||
00000002 = EXCLUSIVE LAUNCH
|
|
||||||
00000004 = BACKGROUND APP + SINGLE LAUNCH
|
|
||||||
00000005 = BACKGROUND APP + MULTIPLE LAUNCH
|
|
||||||
00000006 = BACKGROUND APP + EXCLUSIVE LAUNCH
|
|
||||||
00000008 = ARGV_ONLY + SINGLE LAUNCH
|
|
||||||
00000009 = ARGV_ONLY + MULTIPLE LAUNCH
|
|
||||||
0000000A = ARGV_ONLY + EXCLUSIVE LAUNCH
|
|
||||||
0000000C = ARGV_ONLY + BACKGROUND APP + SINGLE LAUNCH
|
|
||||||
0000000D = ARGV_ONLY + BACKGROUND APP + MULTIPLE LAUNCH
|
|
||||||
0000000E = ARGV_ONLY + BACKGROUND APP + EXCLUSIVE LAUNCH
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource app_flags B_MULTIPLE_LAUNCH;
|
|
||||||
|
|
||||||
/* BEOS:FILE_TYPES :
|
|
||||||
"types" = "text/plain",
|
|
||||||
"types" = ....
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource file_types message {
|
|
||||||
"types" = "application/x-vnd.Be-pref"
|
|
||||||
};
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
** Terminal.version.rdef
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
BEOS:APP_VERSION resources have a specific format, see also
|
|
||||||
<be/storage/AppFileInfo.h:26>
|
|
||||||
|
|
||||||
But thanks to the rc resource compiler, you don't have to worry
|
|
||||||
about any of that ;-)
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource app_version {
|
|
||||||
|
|
||||||
major = 1,
|
|
||||||
middle = 0,
|
|
||||||
minor = 0,
|
|
||||||
|
|
||||||
/* 0 = development 1 = alpha 2 = beta
|
|
||||||
3 = gamma 4 = golden master 5 = final */
|
|
||||||
variety = 0,
|
|
||||||
|
|
||||||
internal = 1,
|
|
||||||
|
|
||||||
short_info = "R1.0.0d1",
|
|
||||||
long_info = "OpenBeOS 1.0.0d1 ©2002 OpenBeOS Project"
|
|
||||||
};
|
|
||||||
@@ -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);
|
|
||||||
(void)terminal;
|
|
||||||
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] : "");
|
|
||||||
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,"%dx%d",&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("%d,%d\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 %d\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,35 +0,0 @@
|
|||||||
#ifndef TERMINAL_APP_H
|
|
||||||
#define TERMINAL_APP_H
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
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 ArgvReceived(int32 argc, char **argv) { assert(false); }
|
|
||||||
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,423 +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);
|
|
||||||
RestoreSettings(settingsRef);
|
|
||||||
|
|
||||||
BString unTitled;
|
|
||||||
unTitled.SetTo("Terminal ");
|
|
||||||
unTitled << id;
|
|
||||||
SetTitle(unTitled.String());
|
|
||||||
|
|
||||||
// Add menubar
|
|
||||||
fMenuBar = new BMenuBar(BRect(0,0,0,0),"menubar");
|
|
||||||
|
|
||||||
view->AddChild(fMenuBar);
|
|
||||||
|
|
||||||
// Add shell view and scroll view
|
|
||||||
BRect shellFrame;
|
|
||||||
shellFrame.top = fMenuBar->Bounds().Height()+1;
|
|
||||||
shellFrame.right = view->Bounds().Width() - B_V_SCROLL_BAR_WIDTH;
|
|
||||||
shellFrame.left = 0;
|
|
||||||
shellFrame.bottom = view->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("New Terminal" B_UTF8_ELLIPSIS, new BMessage(TERMINAL_START_NEW_TERMINAL), 'N');
|
|
||||||
fTerminal->AddItem(fStartNewTerminal);
|
|
||||||
|
|
||||||
fLogToFile = new BMenuItem("Log to File" B_UTF8_ELLIPSIS, 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" B_UTF8_ELLIPSIS, 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" B_UTF8_ELLIPSIS, 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;
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
#include <ScrollBar.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include "ToggleScrollView.h"
|
|
||||||
|
|
||||||
ToggleScrollView::ToggleScrollView(const char * name, BView * target,
|
|
||||||
uint32 flags = 0,
|
|
||||||
bool horizontal = false, bool vertical = false,
|
|
||||||
border_style border = B_FANCY_BORDER,
|
|
||||||
bool auto_hide_horizontal = false,
|
|
||||||
bool auto_hide_vertical = false)
|
|
||||||
: BView(target->Bounds(),name,target->ResizingMode(),flags)
|
|
||||||
{
|
|
||||||
_name = name; _target = target; _flags = flags;
|
|
||||||
_horizontal = horizontal; _vertical = vertical; _border = border;
|
|
||||||
_auto_hide_horizontal = auto_hide_horizontal;
|
|
||||||
_auto_hide_vertical = auto_hide_vertical;
|
|
||||||
_target = ResizeTarget(_target,_horizontal,_vertical);
|
|
||||||
fScrollView = new BScrollView(_name,_target,_target->ResizingMode(),_flags,_horizontal,_vertical,_border);
|
|
||||||
AddChild(fScrollView);
|
|
||||||
}
|
|
||||||
|
|
||||||
ToggleScrollView::~ToggleScrollView()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BArchivable *
|
|
||||||
ToggleScrollView::Instantiate(BMessage *data) { }
|
|
||||||
|
|
||||||
status_t
|
|
||||||
ToggleScrollView::Archive(BMessage *data, bool deep = true) const { }
|
|
||||||
|
|
||||||
BScrollBar *
|
|
||||||
ToggleScrollView::ScrollBar(orientation flag) const {
|
|
||||||
return fScrollView->ScrollBar(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// extension to BScrollView API
|
|
||||||
void
|
|
||||||
ToggleScrollView::ToggleScrollBar(bool horizontal = false, bool vertical = false) {
|
|
||||||
if (!horizontal && !vertical) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float delta_x = 0, delta_y = 0;
|
|
||||||
if (vertical) {
|
|
||||||
if (ScrollBar(B_VERTICAL) != 0) {
|
|
||||||
delta_x = B_V_SCROLL_BAR_WIDTH;
|
|
||||||
} else {
|
|
||||||
delta_x = -B_V_SCROLL_BAR_WIDTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (horizontal) {
|
|
||||||
if (ScrollBar(B_HORIZONTAL) != 0) {
|
|
||||||
delta_y = B_H_SCROLL_BAR_HEIGHT;
|
|
||||||
} else {
|
|
||||||
delta_y = -B_H_SCROLL_BAR_HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_target->ResizeBy(delta_x,delta_y);
|
|
||||||
BScrollView * oldView = fScrollView;
|
|
||||||
if (oldView) {
|
|
||||||
oldView->RemoveChild(_target);
|
|
||||||
RemoveChild(oldView);
|
|
||||||
delete oldView;
|
|
||||||
}
|
|
||||||
fScrollView = new BScrollView(_name,_target,_target->ResizingMode(),_horizontal,_vertical,_border);
|
|
||||||
AddChild(fScrollView);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ToggleScrollView::SetBorder(border_style border) {
|
|
||||||
fScrollView->SetBorder(border);
|
|
||||||
}
|
|
||||||
|
|
||||||
border_style
|
|
||||||
ToggleScrollView::Border() const {
|
|
||||||
return fScrollView->Border();
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t
|
|
||||||
ToggleScrollView::SetBorderHighlighted(bool state) {
|
|
||||||
return fScrollView->SetBorderHighlighted(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
ToggleScrollView::IsBorderHighlighted() const {
|
|
||||||
return fScrollView->IsBorderHighlighted();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ToggleScrollView::SetTarget(BView *new_target) {
|
|
||||||
if (new_target != fScrollView->Target()) {
|
|
||||||
_target = new_target;
|
|
||||||
ResizeTarget(_target,_horizontal,_vertical);
|
|
||||||
fScrollView->SetTarget(_target);
|
|
||||||
SetResizingMode(_target->ResizingMode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BView *
|
|
||||||
ToggleScrollView::Target() const {
|
|
||||||
return fScrollView->Target();
|
|
||||||
}
|
|
||||||
|
|
||||||
BHandler *
|
|
||||||
ToggleScrollView::ResolveSpecifier(BMessage *msg,
|
|
||||||
int32 index,
|
|
||||||
BMessage *specifier,
|
|
||||||
int32 form,
|
|
||||||
const char *property) {
|
|
||||||
return fScrollView->ResolveSpecifier(msg,index,specifier,form,property);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ToggleScrollView::ResizeToPreferred() {
|
|
||||||
fScrollView->ResizeToPreferred();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ToggleScrollView::GetPreferredSize(float *width, float *height) {
|
|
||||||
fScrollView->GetPreferredSize(width,height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ToggleScrollView::MakeFocus(bool state = true) {
|
|
||||||
fScrollView->MakeFocus(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// overloaded functions
|
|
||||||
void
|
|
||||||
ToggleScrollView::SetFlags(uint32 flags)
|
|
||||||
{
|
|
||||||
_flags = flags;
|
|
||||||
fScrollView->SetFlags(_flags);
|
|
||||||
BView::SetFlags(_flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ToggleScrollView::SetResizingMode(uint32 mode)
|
|
||||||
{
|
|
||||||
_target->SetResizingMode(mode);
|
|
||||||
fScrollView->SetResizingMode(mode);
|
|
||||||
BView::SetResizingMode(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// private
|
|
||||||
BView *
|
|
||||||
ToggleScrollView::ResizeTarget(BView * target, bool horizontal, bool vertical)
|
|
||||||
{
|
|
||||||
float delta_x = 0, delta_y = 0;
|
|
||||||
if (vertical) {
|
|
||||||
delta_x = -B_V_SCROLL_BAR_WIDTH;
|
|
||||||
}
|
|
||||||
if (horizontal) {
|
|
||||||
delta_y = -B_H_SCROLL_BAR_HEIGHT;
|
|
||||||
}
|
|
||||||
target->ResizeBy(delta_x,delta_y);
|
|
||||||
target->FrameResized(target->Bounds().Width(),target->Bounds().Height());
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
#ifndef TOGGLE_SCROLL_VIEW_H
|
|
||||||
#define TOGGLE_SCROLL_VIEW_H
|
|
||||||
|
|
||||||
#include <ScrollView.h>
|
|
||||||
|
|
||||||
class ToggleScrollView : public BView {
|
|
||||||
public:
|
|
||||||
ToggleScrollView(const char * name, BView * target,
|
|
||||||
uint32 flags = 0,
|
|
||||||
bool horizontal = false, bool vertical = false,
|
|
||||||
border_style border = B_FANCY_BORDER,
|
|
||||||
bool auto_hide_horizontal = false,
|
|
||||||
bool auto_hide_vertical = false);
|
|
||||||
virtual ~ToggleScrollView();
|
|
||||||
static BArchivable *Instantiate(BMessage *data);
|
|
||||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
|
||||||
|
|
||||||
virtual BScrollBar *ScrollBar(orientation flag) const;
|
|
||||||
// extension to BScrollView API
|
|
||||||
virtual void ToggleScrollBar(bool horizontal = false,
|
|
||||||
bool vertical = false);
|
|
||||||
|
|
||||||
virtual void SetBorder(border_style border);
|
|
||||||
virtual border_style Border() const;
|
|
||||||
|
|
||||||
virtual status_t SetBorderHighlighted(bool state);
|
|
||||||
virtual bool IsBorderHighlighted() const;
|
|
||||||
|
|
||||||
virtual void SetTarget(BView *new_target);
|
|
||||||
virtual BView *Target() const;
|
|
||||||
|
|
||||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
|
||||||
int32 index,
|
|
||||||
BMessage *specifier,
|
|
||||||
int32 form,
|
|
||||||
const char *property);
|
|
||||||
|
|
||||||
virtual void ResizeToPreferred();
|
|
||||||
virtual void GetPreferredSize(float *width, float *height);
|
|
||||||
virtual void MakeFocus(bool state = true);
|
|
||||||
|
|
||||||
// overloaded functions
|
|
||||||
virtual void SetFlags(uint32 flags);
|
|
||||||
virtual void SetResizingMode(uint32 mode);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static BView * ResizeTarget(BView * target, bool horizontal, bool vertical);
|
|
||||||
|
|
||||||
const char * _name;
|
|
||||||
BView * _target;
|
|
||||||
uint32 _flags;
|
|
||||||
bool _horizontal;
|
|
||||||
bool _vertical;
|
|
||||||
border_style _border;
|
|
||||||
bool _auto_hide_horizontal;
|
|
||||||
bool _auto_hide_vertical;
|
|
||||||
BScrollView * fScrollView;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TOGGLE_SCROLL_VIEW_H
|
|
||||||
Reference in New Issue
Block a user