add MYOB's MuTerm adaptation
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8317 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3b48bd6d4c
commit
9105df34ca
@ -13,3 +13,5 @@ App Terminal :
|
||||
;
|
||||
|
||||
LinkSharedOSLibs Terminal : be translation tracker ;
|
||||
|
||||
SubInclude OBOS_TOP src apps terminal MYOB ;
|
||||
|
93
src/apps/terminal/MYOB/AboutWindow.cpp
Normal file
93
src/apps/terminal/MYOB/AboutWindow.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
*
|
||||
* 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 <Application.h>
|
||||
#include <StringView.h>
|
||||
#include "AboutWindow.h"
|
||||
|
||||
|
||||
// Set up the window
|
||||
|
||||
|
||||
aboutWindow::aboutWindow(const char *)
|
||||
: BWindow(BRect(100,100,390,230), "About", B_TITLED_WINDOW, B_NOT_RESIZABLE)
|
||||
{
|
||||
|
||||
// Set up the main view
|
||||
BView* icon = new BView(BRect(0,0,390,230), "File Info", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
|
||||
|
||||
// Set up the colour of the panel and set it to being displayed
|
||||
AddChild(icon);
|
||||
|
||||
Show();
|
||||
|
||||
|
||||
text1 = new BStringView(BRect(15,10,390,30), "text", "OpenBeOS Terminal", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
AddChild(text1);
|
||||
|
||||
text2 = new BStringView(BRect(15,30,390,50), "text", "Based on MuTerminal 2.3", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
AddChild(text2);
|
||||
|
||||
text3 = new BStringView(BRect(15,50,390,70), "text", "By Kazuho Okui and Takashi Murai", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
AddChild(text3);
|
||||
|
||||
text4 = new BStringView(BRect(15,70,390,90), "text", "OpenBeOS Modifications by Cian Duffy", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
AddChild(text4);
|
||||
|
||||
|
||||
|
||||
|
||||
// Set up the BMessage handlers
|
||||
}
|
||||
|
||||
void
|
||||
aboutWindow::MessageReceived(BMessage* msg)
|
||||
{
|
||||
|
||||
switch(msg->what)
|
||||
{
|
||||
|
||||
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Quit Button implementation
|
||||
|
||||
|
||||
void aboutWindow::Quit()
|
||||
{
|
||||
|
||||
BWindow::Quit();
|
||||
}
|
||||
|
||||
|
||||
|
51
src/apps/terminal/MYOB/AboutWindow.h
Normal file
51
src/apps/terminal/MYOB/AboutWindow.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
class aboutWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
aboutWindow(const char *);
|
||||
|
||||
|
||||
void MessageReceived(BMessage* msg);
|
||||
void Quit();
|
||||
|
||||
private:
|
||||
// Private classes to Be classes
|
||||
BWindow* handler;
|
||||
BStringView* text1;
|
||||
BStringView* text2;
|
||||
BStringView* text3;
|
||||
BStringView* text4;
|
||||
|
||||
};
|
202
src/apps/terminal/MYOB/AppearPrefView.cpp
Normal file
202
src/apps/terminal/MYOB/AppearPrefView.cpp
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <View.h>
|
||||
#include <Button.h>
|
||||
#include <MenuField.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <TextControl.h>
|
||||
#include <Beep.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AppearPrefView.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "TermWindow.h"
|
||||
#include "TermConst.h"
|
||||
#include "MenuUtil.h"
|
||||
#include "TTextControl.h"
|
||||
|
||||
#define MAX_FONT_SIZE 32
|
||||
#define MIN_FONT_SIZE 6
|
||||
|
||||
AppearancePrefView::AppearancePrefView (BRect frame, const char *name,
|
||||
TermWindow *window)
|
||||
:PrefView (frame, name)
|
||||
{
|
||||
const char *color_tbl[]=
|
||||
{
|
||||
PREF_TEXT_FORE_COLOR,
|
||||
PREF_TEXT_BACK_COLOR,
|
||||
PREF_CURSOR_FORE_COLOR,
|
||||
PREF_CURSOR_BACK_COLOR,
|
||||
PREF_SELECT_FORE_COLOR,
|
||||
PREF_SELECT_BACK_COLOR,
|
||||
NULL
|
||||
};
|
||||
|
||||
fTermWindow = window;
|
||||
|
||||
mHalfFont = new BMenuField(BRect(0,0,220,20), "halffont", "Half Size Font", MakeFontMenu(MSG_HALF_FONT_CHANGED, gTermPref->getString(PREF_HALF_FONT_FAMILY)), B_WILL_DRAW);
|
||||
AddChild(mHalfFont);
|
||||
mHalfFont->SetDivider (120);
|
||||
|
||||
mHalfSize = new TTextControl(BRect(220, 0, 300, 20), "halfsize", "Size", "", new BMessage(MSG_HALF_SIZE_CHANGED));
|
||||
AddChild(mHalfSize);
|
||||
mHalfSize->SetText(gTermPref->getString(PREF_HALF_FONT_SIZE));
|
||||
mHalfSize->SetDivider (50);
|
||||
|
||||
mFullFont = new BMenuField(BRect(0,30,220,50), "fullfont", "Full Size Font", MakeFontMenu(MSG_FULL_FONT_CHANGED, gTermPref->getString(PREF_FULL_FONT_FAMILY)), B_WILL_DRAW);
|
||||
AddChild(mFullFont);
|
||||
mFullFont->SetDivider (120);
|
||||
|
||||
mFullSize = new TTextControl(BRect(220, 30, 300, 50), "fullsize", "Size", "", new BMessage(MSG_FULL_SIZE_CHANGED));
|
||||
AddChild(mFullSize);
|
||||
mFullSize->SetText(gTermPref->getString(PREF_FULL_FONT_SIZE));
|
||||
mFullSize->SetDivider (50);
|
||||
|
||||
mColorField = new BMenuField(BRect(0,60,200,80), NULL, NULL, MakeMenu (MSG_COLOR_FIELD_CHANGED, color_tbl, color_tbl[0]), B_WILL_DRAW);
|
||||
AddChild(mColorField);
|
||||
|
||||
mColorCtl = SetupBColorControl(BPoint(20, 85), B_CELLS_32x8, 6, MSG_COLOR_CHANGED);
|
||||
mColorCtl->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AppearancePrefView::Revert (void)
|
||||
{
|
||||
|
||||
mHalfSize->SetText (gTermPref->getString (PREF_HALF_FONT_SIZE));
|
||||
mFullSize->SetText (gTermPref->getString (PREF_FULL_FONT_SIZE));
|
||||
mColorField->Menu()->ItemAt(0)->SetMarked (true);
|
||||
mColorCtl->SetValue (gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||
|
||||
mHalfFont->Menu()->FindItem (gTermPref->getString(PREF_HALF_FONT_FAMILY))->SetMarked(true);
|
||||
mFullFont->Menu()->FindItem (gTermPref->getString(PREF_FULL_FONT_FAMILY))->SetMarked(true);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SaveIfModified (void)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
AppearancePrefView::SaveIfModified (void)
|
||||
{
|
||||
BMessenger messenger (fTermWindow);
|
||||
|
||||
if (mHalfSize->IsModified()) {
|
||||
gTermPref->setString (PREF_HALF_FONT_SIZE, mHalfSize->Text());
|
||||
messenger.SendMessage (MSG_HALF_SIZE_CHANGED);
|
||||
mHalfSize->ModifiedText (false);
|
||||
}
|
||||
if (mFullSize->IsModified()) {
|
||||
gTermPref->setString (PREF_FULL_FONT_SIZE, mFullSize->Text());
|
||||
messenger.SendMessage (MSG_FULL_SIZE_CHANGED);
|
||||
mFullSize->ModifiedText (false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
AppearancePrefView::AttachedToWindow (void)
|
||||
{
|
||||
mHalfSize->SetTarget (this);
|
||||
mFullSize->SetTarget (this);
|
||||
mHalfFont->Menu()->SetTargetForItems(this);
|
||||
mFullFont->Menu()->SetTargetForItems(this);
|
||||
|
||||
mColorCtl->SetTarget (this);
|
||||
mColorField->Menu()->SetTargetForItems(this);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AppearancePrefView::MessageReceived (BMessage *msg)
|
||||
{
|
||||
bool modified = false;
|
||||
int size;
|
||||
|
||||
switch (msg->what) {
|
||||
case MSG_HALF_FONT_CHANGED:
|
||||
gTermPref->setString (PREF_HALF_FONT_FAMILY, mHalfFont->Menu()->FindMarked()->Label());
|
||||
modified = true;
|
||||
break;
|
||||
|
||||
case MSG_HALF_SIZE_CHANGED:
|
||||
size = atoi (mHalfSize->Text());
|
||||
if (size > MAX_FONT_SIZE || size < MIN_FONT_SIZE) {
|
||||
mHalfSize->SetText (gTermPref->getString (PREF_HALF_FONT_SIZE));
|
||||
beep ();
|
||||
} else {
|
||||
gTermPref->setString (PREF_HALF_FONT_SIZE, mHalfSize->Text());
|
||||
modified = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case MSG_FULL_FONT_CHANGED:
|
||||
gTermPref->setString (PREF_FULL_FONT_FAMILY, mFullFont->Menu()->FindMarked()->Label());
|
||||
modified = true;
|
||||
break;
|
||||
|
||||
case MSG_FULL_SIZE_CHANGED:
|
||||
size = atoi (mHalfSize->Text());
|
||||
if (size > MAX_FONT_SIZE || size < MIN_FONT_SIZE) {
|
||||
mFullSize->SetText (gTermPref->getString (PREF_FULL_FONT_SIZE));
|
||||
beep ();
|
||||
} else {
|
||||
gTermPref->setString (PREF_FULL_FONT_SIZE, mFullSize->Text());
|
||||
}
|
||||
modified = true;
|
||||
break;
|
||||
|
||||
case MSG_COLOR_CHANGED:
|
||||
gTermPref->setRGB(mColorField->Menu()->FindMarked()->Label(), mColorCtl->ValueAsColor());
|
||||
modified = true;
|
||||
break;
|
||||
|
||||
case MSG_COLOR_FIELD_CHANGED:
|
||||
mColorCtl->SetValue(gTermPref->getRGB (mColorField->Menu()->FindMarked()->Label()));
|
||||
break;
|
||||
|
||||
default:
|
||||
PrefView::MessageReceived(msg);
|
||||
return; // Oh !
|
||||
}
|
||||
|
||||
if(modified){
|
||||
fTermWindow->PostMessage (msg);
|
||||
(this->Window())->PostMessage(MSG_PREF_MODIFIED);
|
||||
}
|
||||
}
|
67
src/apps/terminal/MYOB/AppearPrefView.h
Normal file
67
src/apps/terminal/MYOB/AppearPrefView.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AppearancePrefView_H_INCLUDED
|
||||
#define ApperaancePrefView_H_INCLUDED
|
||||
|
||||
#include "PrefView.h"
|
||||
|
||||
class TermWindow;
|
||||
class TTextControl;
|
||||
|
||||
class AppearancePrefView : public PrefView
|
||||
{
|
||||
public:
|
||||
AppearancePrefView(BRect r,
|
||||
const char *name,
|
||||
TermWindow *window);
|
||||
|
||||
virtual void Revert (void);
|
||||
virtual void SaveIfModified (void);
|
||||
virtual void MessageReceived (BMessage *);
|
||||
virtual void AttachedToWindow (void);
|
||||
|
||||
private:
|
||||
TTextControl *mHalfSize;
|
||||
TTextControl *mFullSize;
|
||||
BMenuField *mHalfFont;
|
||||
BMenuField *mFullFont;
|
||||
|
||||
BMenuField *mColorField;
|
||||
BColorControl *mColorCtl;
|
||||
|
||||
int mSubMenu_button;
|
||||
int mPaste_button;
|
||||
|
||||
TermWindow *fTermWindow;
|
||||
|
||||
};
|
||||
|
||||
#endif //AppearancePrefView_H_INCLUDED
|
22
src/apps/terminal/MYOB/Changelog
Normal file
22
src/apps/terminal/MYOB/Changelog
Normal file
@ -0,0 +1,22 @@
|
||||
Changed licence from GPL to BSD, as allowed by original authors.
|
||||
Removed multi-language support. This will need to be rebuilt to whatever system OpenBeOS uses.
|
||||
Moved Carachter Encodings menu to the "Right Place" for BeOS 5
|
||||
Started re-building the colours menu in the "Right Place"
|
||||
Silenced all build warnings on R5
|
||||
Fixed all but one build error on Dano and Zeta, and silenced all warnings
|
||||
|
||||
|
||||
Began removing (serious) traces of the RAD (Interface Elements) tool used to draw the GUI. This makes R1 binary and source compatiblity higher, and assists in moving stuff around the place. As the Interface Elements project file wasn't included in the first place, theres absolutely no point in leaving the cruft there.
|
||||
|
||||
|
||||
Stuff already done thats better than R5:
|
||||
Terminal window supports scrolling
|
||||
|
||||
TODO:
|
||||
Make a Jamfile
|
||||
Make Find work
|
||||
Fix titling (-t works already, its the Terminal 1, 2, 3, etc...)
|
||||
Fix the Colour menu
|
||||
Move Fonts and font sizes to the "Right Place"
|
||||
Kill the Preferences Panel
|
||||
Move to .rdef source resources
|
244
src/apps/terminal/MYOB/CodeConv.cpp
Normal file
244
src/apps/terminal/MYOB/CodeConv.cpp
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
MuTerminal Code Conversion class (MC3).
|
||||
|
||||
version 1.1 Internal coding system is UTF8.
|
||||
|
||||
Code conversion member functions are convert character code and calc
|
||||
font width.
|
||||
|
||||
Available coding systems.
|
||||
|
||||
ISO-8859-1 ... 10
|
||||
Shift JIS
|
||||
EUC-jp
|
||||
UTF8
|
||||
|
||||
************************************************************************/
|
||||
|
||||
#include <support/UTF8.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "CodeConv.h"
|
||||
|
||||
extern char utf8_width_table[]; /* define UTF8WidthTbl.c */
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CodeConv::CodeConv (void)
|
||||
{
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Destructor
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CodeConv::~CodeConv (void)
|
||||
{
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// UTF8GetFontWidth (const uchar *string)
|
||||
// get font width in coding.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
CodeConv::UTF8GetFontWidth (const uchar *string)
|
||||
{
|
||||
uchar width, point;
|
||||
ushort unicode, offset;
|
||||
|
||||
offset = unicode = UTF8toUnicode (string);
|
||||
width = utf8_width_table [unicode >> 3];
|
||||
offset = offset & 0x07;
|
||||
|
||||
point = 0x80 >> offset;
|
||||
|
||||
return ((width & point) > 0 ) ? 2 : 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ConvertFromInternal (const uchar *src, uchar *dst, int coding)
|
||||
// Convert internal coding from src coding.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
CodeConv::ConvertFromInternal (const uchar *src, uchar *dst, int coding)
|
||||
{
|
||||
const uchar *src_p = src;
|
||||
long srclen = 0, dstlen = 0;
|
||||
long state = 0;
|
||||
int theCoding;
|
||||
|
||||
if (coding == M_UTF8) return 0;
|
||||
|
||||
theCoding = coding_translation_table[coding];
|
||||
|
||||
while (*src_p++) srclen++;
|
||||
|
||||
dstlen = srclen * 256;
|
||||
|
||||
convert_from_utf8 (theCoding,
|
||||
(char *)src, &srclen,
|
||||
(char *)dst, &dstlen,
|
||||
&state, '?');
|
||||
|
||||
if (coding == M_ISO_2022_JP && state != 0) {
|
||||
const char *end_of_jis = "(B";
|
||||
strncpy ((char *)dst+dstlen, end_of_jis, 3);
|
||||
dstlen += 3;
|
||||
}
|
||||
|
||||
dst[dstlen] = '\0';
|
||||
|
||||
return dstlen;
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ConvertToInternal (const uchar *src, uchar *dst, int coding)
|
||||
// Convert internal coding to src coding.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
CodeConv::ConvertToInternal (const uchar *src, uchar *dst, int coding)
|
||||
{
|
||||
const uchar *src_p = src;
|
||||
long srclen = 0, dstlen = 4;
|
||||
long state = 0;
|
||||
int theCoding;
|
||||
|
||||
|
||||
if (coding == M_UTF8) return;
|
||||
|
||||
#if 0
|
||||
#ifndef __INTEL__
|
||||
if (coding = M_EUC_JP) {
|
||||
uchar buf[2];
|
||||
memcpy (buf, src, 2);
|
||||
euc_to_sjis (buf);
|
||||
srclen = 2;
|
||||
convert_to_utf8 (B_SJIS_CONVERSION, (char*) buf, &srclen,
|
||||
(char *)dst, &dstlen,
|
||||
&state, '?');
|
||||
dst[dstlen] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
theCoding = coding_translation_table[coding];
|
||||
|
||||
while (*src_p++) srclen++;
|
||||
|
||||
convert_to_utf8 (theCoding,
|
||||
(char *)src, &srclen,
|
||||
(char *)dst, &dstlen,
|
||||
&state, '?');
|
||||
|
||||
dst[dstlen] = '\0';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Private member functions.
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// UTF8toUnicode (uchar *utf8)
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
unsigned short
|
||||
CodeConv::UTF8toUnicode (const uchar *utf8)
|
||||
{
|
||||
uchar tmp;
|
||||
unsigned short unicode = 0x0000;
|
||||
|
||||
tmp = *utf8 & 0xe0;
|
||||
|
||||
if (tmp < 0x80) {
|
||||
unicode = (unsigned short) *utf8;
|
||||
}
|
||||
else if (tmp < 0xe0) {
|
||||
unicode = (unsigned short) *utf8++ & 0x1f;
|
||||
unicode = unicode << 6;
|
||||
unicode = unicode | ((unsigned short) *utf8 & 0x3f);
|
||||
}
|
||||
else if (tmp < 0xf0) {
|
||||
unicode = (unsigned short) *utf8++ & 0x0f;
|
||||
unicode = unicode << 6;
|
||||
unicode = unicode | ((unsigned short) *utf8++ & 0x3f);
|
||||
unicode = unicode << 6;
|
||||
unicode = unicode | ((unsigned short) *utf8 & 0x3f);
|
||||
}
|
||||
|
||||
return unicode;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// euc_to_sjis
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
CodeConv::euc_to_sjis (uchar *buf)
|
||||
{
|
||||
int gl, gr;
|
||||
int p;
|
||||
int c1, c2;
|
||||
|
||||
gl = *buf & 0x7F;
|
||||
gr = *(buf + 1) & 0x7F;
|
||||
gl -= 0x21;
|
||||
gr -= 0x21;
|
||||
|
||||
p = gl * 94 + gr;
|
||||
|
||||
c1 = p / 188;
|
||||
c2 = p % 188;
|
||||
|
||||
if (c1 >= 31) {
|
||||
c1 = c1 - 31 + 0xE0;
|
||||
}
|
||||
else {
|
||||
c1 += 0x81;
|
||||
}
|
||||
|
||||
if (c2 >= 63) {
|
||||
c2 = c2 - 63 + 0x80;
|
||||
}
|
||||
else {
|
||||
c2 += 0x40;
|
||||
}
|
||||
|
||||
*buf++ = c1;
|
||||
*buf = c2;
|
||||
|
||||
return;
|
||||
}
|
83
src/apps/terminal/MYOB/CodeConv.h
Normal file
83
src/apps/terminal/MYOB/CodeConv.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CODECONV_H
|
||||
#define CODECONV_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include "Coding.h"
|
||||
|
||||
#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80)
|
||||
|
||||
/*
|
||||
* Coding system define.
|
||||
*/
|
||||
class CodeConv
|
||||
{
|
||||
/*
|
||||
* Constructor and Destuructor.
|
||||
*/
|
||||
public:
|
||||
CodeConv (void);
|
||||
~CodeConv (void);
|
||||
|
||||
/*
|
||||
* Public member functions.
|
||||
*/
|
||||
int UTF8GetFontWidth (const uchar *string);
|
||||
|
||||
/* internal(UTF8) -> coding */
|
||||
int ConvertFromInternal (const uchar *src, uchar *dst, int coding);
|
||||
|
||||
/* coding -> internal(UTF8) */
|
||||
void ConvertToInternal (const uchar *src, uchar *dst, int coding);
|
||||
|
||||
/*
|
||||
* PRIVATE MEMBER.
|
||||
*/
|
||||
|
||||
private:
|
||||
/*
|
||||
* Private member functions.
|
||||
*/
|
||||
|
||||
void euc_to_sjis (uchar *buf);
|
||||
|
||||
unsigned short UTF8toUnicode (const uchar *utf8);
|
||||
|
||||
/*
|
||||
* DATA Member.
|
||||
*/
|
||||
|
||||
int fNowCoding;
|
||||
|
||||
};
|
||||
|
||||
#endif /* CODECONV_H */
|
124
src/apps/terminal/MYOB/Coding.h
Normal file
124
src/apps/terminal/MYOB/Coding.h
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CODING__H_
|
||||
#define _CODING__H_
|
||||
|
||||
#include <UTF8.h>
|
||||
|
||||
enum {
|
||||
M_ISO_8859_1, /* ISO-8859 */
|
||||
M_ISO_8859_2,
|
||||
M_ISO_8859_3,
|
||||
M_ISO_8859_4,
|
||||
M_ISO_8859_5,
|
||||
M_ISO_8859_6,
|
||||
M_ISO_8859_7,
|
||||
M_ISO_8859_8,
|
||||
M_ISO_8859_9,
|
||||
M_ISO_8859_10,
|
||||
|
||||
M_MAC_ROMAN, /* Macintosh Roman */
|
||||
|
||||
M_ISO_2022_JP,
|
||||
M_SJIS, /* Japanese */
|
||||
M_EUC_JP,
|
||||
M_EUC_KR,
|
||||
|
||||
// M_EUC_TW, /* Chinese */
|
||||
// M_BIG5,
|
||||
// M_ISO_2022_CN,
|
||||
|
||||
// M_EUC_KR, /* Koeran */
|
||||
// M_ISO_2022_KR,
|
||||
|
||||
M_UTF8 /* UTF-8 */
|
||||
};
|
||||
|
||||
const uint32 coding_translation_table[] = {
|
||||
B_ISO1_CONVERSION, /* ISO 8859-1 */
|
||||
B_ISO2_CONVERSION, /* ISO 8859-2 */
|
||||
B_ISO3_CONVERSION, /* ISO 8859-3 */
|
||||
B_ISO4_CONVERSION, /* ISO 8859-4 */
|
||||
B_ISO5_CONVERSION, /* ISO 8859-5 */
|
||||
B_ISO6_CONVERSION, /* ISO 8859-6 */
|
||||
B_ISO7_CONVERSION, /* ISO 8859-7 */
|
||||
B_ISO8_CONVERSION, /* ISO 8859-8 */
|
||||
B_ISO9_CONVERSION, /* ISO 8859-9 */
|
||||
B_ISO10_CONVERSION, /* ISO 8859-10 */
|
||||
B_MAC_ROMAN_CONVERSION, /* Macintosh Roman */
|
||||
B_JIS_CONVERSION, /* JIS X 0208-1990 */
|
||||
B_SJIS_CONVERSION, /* Shift-JIS */
|
||||
B_EUC_CONVERSION, /* EUC Packed Japanese */
|
||||
B_EUC_KR_CONVERSION /* EUC Korean */
|
||||
};
|
||||
|
||||
struct etable
|
||||
{
|
||||
const char *name; // long name for menu item.
|
||||
const char *shortname; // short name (use for command-line etc.)
|
||||
const char shortcut; // short cut key code
|
||||
const uint32 op; // encodeing opcode
|
||||
};
|
||||
|
||||
/*
|
||||
* encoding_table ... use encoding menu, message, and preference keys.
|
||||
*/
|
||||
const etable encoding_table[]=
|
||||
{
|
||||
{"ISO-8859-1", "8859-1", '1', M_ISO_8859_1},
|
||||
{"ISO-8859-2", "8859-2", '2', M_ISO_8859_2},
|
||||
{"ISO-8859-3", "8859-3", '3', M_ISO_8859_3},
|
||||
{"ISO-8859-4", "8859-4", '4', M_ISO_8859_4},
|
||||
{"ISO-8859-5", "8859-5", '5', M_ISO_8859_5},
|
||||
{"ISO-8859-6", "8859-6", '6', M_ISO_8859_6},
|
||||
{"ISO-8859-7", "8859-7", '7', M_ISO_8859_7},
|
||||
{"ISO-8859-8", "8859-8", '8', M_ISO_8859_8},
|
||||
{"ISO-8859-9", "8859-9", '9', M_ISO_8859_9},
|
||||
{"ISO-8859-10", "8859-10", '0', M_ISO_8859_10},
|
||||
{"MacRoman", "MacRoman",'M', M_MAC_ROMAN},
|
||||
{"JIS", "JIS", 'J', M_ISO_2022_JP},
|
||||
{"Shift-JIS", "SJIS", 'S', M_SJIS},
|
||||
{"EUC-jp", "EUCJ", 'E', M_EUC_JP},
|
||||
{"EUC-kr", "EUCK", 'K', M_EUC_KR},
|
||||
{"UTF-8", "UTF8", 'U', M_UTF8},
|
||||
|
||||
/* Not Implement.
|
||||
{"EUC-tw", "EUCT", "T", M_EUC_TW},
|
||||
{"Big5", "Big5", 'B', M_BIG5},
|
||||
{"ISO-2022-cn", "ISOC", 'C', M_ISO_2022_CN},
|
||||
{"ISO-2022-kr", "ISOK", 'R', M_ISO_2022_KR},
|
||||
*/
|
||||
|
||||
{NULL, NULL, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
#endif /* _CODING_H_ */
|
171
src/apps/terminal/MYOB/ColorWindow.cpp
Normal file
171
src/apps/terminal/MYOB/ColorWindow.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Application.h>
|
||||
#include <StringView.h>
|
||||
#include <ColorControl.h>
|
||||
#include "ColorWindow.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "PrefView.h"
|
||||
#include <PopUpMenu.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuField.h>
|
||||
#include <Window.h>
|
||||
#include <MenuItem.h>
|
||||
#include "TermConst.h"
|
||||
#include "TermWindow.h"
|
||||
#include "TermView.h"
|
||||
#include "TermBuffer.h"
|
||||
#include "MenuUtil.h"
|
||||
#include "TTextControl.h"
|
||||
|
||||
|
||||
|
||||
// Set up the window
|
||||
|
||||
|
||||
colWindow::colWindow(const char *)
|
||||
: BWindow(BRect(100,100,390,230), "Colors for Terminal", B_TITLED_WINDOW, B_NOT_RESIZABLE)
|
||||
{
|
||||
|
||||
// Set up the main view
|
||||
BView* icon = new BView(BRect(0,0,390,230), "Colors", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
|
||||
|
||||
|
||||
// Set up the colour of the panel and set it to being displayed
|
||||
AddChild(icon);
|
||||
icon->SetViewColor(216,216,216);
|
||||
|
||||
Show();
|
||||
|
||||
BMenuItem *menuItem;
|
||||
fWorkspaceMenu = new BPopUpMenu("pick one");
|
||||
fWorkspaceMenu->AddItem(menuItem = new BMenuItem("Text Foreground Color", new BMessage(MSG_COLOR_FIELD_CHANGED)));
|
||||
fWorkspaceMenu->AddItem(menuItem = new BMenuItem("Text Background Color", new BMessage(MSG_COLOR_FIELD_CHANGED)));
|
||||
fWorkspaceMenu->AddItem(menuItem = new BMenuItem("Cursor Foreground Color", new BMessage(MSG_COLOR_FIELD_CHANGED)));
|
||||
fWorkspaceMenu->AddItem(menuItem = new BMenuItem("Cursor Background Color", new BMessage(MSG_COLOR_FIELD_CHANGED)));
|
||||
fWorkspaceMenu->AddItem(menuItem = new BMenuItem("Selection Foreground Color", new BMessage(MSG_COLOR_FIELD_CHANGED)));
|
||||
fWorkspaceMenu->AddItem(menuItem = new BMenuItem("Selection Background Color", new BMessage(MSG_COLOR_FIELD_CHANGED)));
|
||||
//fWorkspaceMenu->AddSeparatorItem();
|
||||
BMenuField *workspaceMenuField = new BMenuField(BRect(10,10,160,30), "workspaceMenuField", NULL, fWorkspaceMenu, true);
|
||||
icon->AddChild(workspaceMenuField);
|
||||
workspaceMenuField->Menu()->ItemAt(0)->SetMarked (true);
|
||||
//rightbox->SetLabel(workspaceMenuField);
|
||||
|
||||
// const char *color_tbl[]=
|
||||
// {
|
||||
// PREF_TEXT_FORE_COLOR,
|
||||
// PREF_TEXT_BACK_COLOR,
|
||||
// PREF_CURSOR_FORE_COLOR,
|
||||
// PREF_CURSOR_BACK_COLOR,
|
||||
// PREF_SELECT_FORE_COLOR,
|
||||
// PREF_SELECT_BACK_COLOR,
|
||||
// NULL
|
||||
//};
|
||||
|
||||
// fTermWindow = window;
|
||||
|
||||
//
|
||||
// Color Control
|
||||
//
|
||||
// mColorField = SetupMenuField (IERECT(0, 60, 200, 20),
|
||||
// "",
|
||||
// MakeMenu (MSG_COLOR_FIELD_CHANGED,
|
||||
// color_tbl,
|
||||
// color_tbl[0]));
|
||||
|
||||
// mColorCtl = SetupBColorControl(BPoint(20, 85),
|
||||
// B_CELLS_32x8,
|
||||
// 6,
|
||||
// MSG_COLOR_CHANGED);
|
||||
|
||||
BColorControl* controller = new BColorControl(BPoint(10, 45), B_CELLS_32x8, 6, "Terminal Color Controller", new BMessage(MSG_COLOR_CHANGED));
|
||||
|
||||
icon->AddChild(controller);
|
||||
controller->SetValue(gTermPref->getRGB(PREF_TEXT_FORE_COLOR));
|
||||
|
||||
|
||||
|
||||
// Set up the BMessage handlers
|
||||
}
|
||||
|
||||
void
|
||||
colWindow::AttachedToWindow (void)
|
||||
{
|
||||
// mHalfSize->SetTarget (this);
|
||||
// mFullSize->SetTarget (this);
|
||||
// mHalfFont->Menu()->SetTargetForItems(this);
|
||||
//mFullFont->Menu()->SetTargetForItems(this);
|
||||
|
||||
controller->SetTarget (this);
|
||||
workspaceMenuField->Menu()->SetTargetForItems(this);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
colWindow::MessageReceived(BMessage* msg)
|
||||
{
|
||||
bool modified = false;
|
||||
switch(msg->what)
|
||||
{
|
||||
|
||||
case MSG_COLOR_CHANGED:
|
||||
gTermPref->setRGB(workspaceMenuField->Menu()->FindMarked()->Label(),
|
||||
controller->ValueAsColor());
|
||||
modified = true;
|
||||
break;
|
||||
|
||||
case MSG_COLOR_FIELD_CHANGED:
|
||||
controller->SetValue
|
||||
(gTermPref->getRGB (workspaceMenuField->Menu()->FindMarked()->Label()));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
if(modified){
|
||||
fTermWindow->PostMessage (msg);
|
||||
// (this->Window())->PostMessage(MSG_PREF_MODIFIED);
|
||||
}
|
||||
}
|
||||
// Quit Button implementation
|
||||
|
||||
|
||||
void colWindow::Quit()
|
||||
{
|
||||
|
||||
BWindow::Quit();
|
||||
}
|
||||
|
||||
|
57
src/apps/terminal/MYOB/ColorWindow.h
Normal file
57
src/apps/terminal/MYOB/ColorWindow.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Window.h>
|
||||
#include <View.h>
|
||||
#include "PrefView.h"
|
||||
#include "MenuUtil.h"
|
||||
#include "TermWindow.h"
|
||||
|
||||
class colWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
colWindow(const char *);
|
||||
|
||||
|
||||
void MessageReceived(BMessage* msg);
|
||||
//virtual void SaveIfModified (void);
|
||||
void AttachedToWindow();
|
||||
void Quit();
|
||||
|
||||
private:
|
||||
// Private classes to Be classes
|
||||
BWindow* handler;
|
||||
BMenuField *workspaceMenuField;
|
||||
BPopUpMenu *fWorkspaceMenu;
|
||||
BColorControl *controller;
|
||||
TermWindow *fTermWindow;
|
||||
|
||||
};
|
42
src/apps/terminal/MYOB/Constants.h
Normal file
42
src/apps/terminal/MYOB/Constants.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*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
|
183
src/apps/terminal/MYOB/CurPos.cpp
Normal file
183
src/apps/terminal/MYOB/CurPos.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 "CurPos.h"
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* Constructor and Destructor
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
CurPos::CurPos()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CurPos::CurPos(int32 X, int32 Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
|
||||
CurPos::CurPos(const CurPos& cp)
|
||||
{
|
||||
x = cp.x;
|
||||
y = cp.y;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator =
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CurPos &
|
||||
CurPos::operator=(const CurPos& from)
|
||||
{
|
||||
x = from.x;
|
||||
y = from.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Set Function.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
CurPos::Set(int32 X, int32 Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator !=
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
CurPos::operator!=(const CurPos& from) const
|
||||
{
|
||||
return ((x != from.x) || (y != from.y));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator ==
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
CurPos::operator==(const CurPos& from) const
|
||||
{
|
||||
return ((x == from.x) && (y == from.y));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator +
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CurPos
|
||||
CurPos::operator+(const CurPos& from) const
|
||||
{
|
||||
return CurPos(x + from.x, y + from.y);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator -
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
CurPos
|
||||
CurPos::operator- (const CurPos& from) const
|
||||
{
|
||||
return CurPos(x - from.x, y - from.y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator >
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
CurPos::operator> (const CurPos& from) const
|
||||
{
|
||||
if (y > from.y) {
|
||||
return true;
|
||||
} else if (y == from.y && x > from.x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator >=
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
CurPos::operator>= (const CurPos& from) const
|
||||
{
|
||||
if (y > from.y) {
|
||||
return true;
|
||||
} else if (y == from.y && x >= from.x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator <
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
CurPos::operator< (const CurPos& from) const
|
||||
{
|
||||
if (y < from.y) {
|
||||
return true;
|
||||
} else if (y == from.y && x < from.x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CurPos
|
||||
// Operator <=
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
CurPos::operator<= (const CurPos& from) const
|
||||
{
|
||||
if (y < from.y) {
|
||||
return true;
|
||||
} else if (y == from.y && x <= from.x) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
60
src/apps/terminal/MYOB/CurPos.h
Normal file
60
src/apps/terminal/MYOB/CurPos.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CURPOS_H_INCLUDED
|
||||
#define CURPOS_H_INCLUDED
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class CurPos
|
||||
{
|
||||
public:
|
||||
int32 x;
|
||||
int32 y;
|
||||
|
||||
CurPos();
|
||||
CurPos(int32 X, int32 Y);
|
||||
CurPos(const CurPos& cp);
|
||||
|
||||
void Set(int32 X, int32 Y);
|
||||
|
||||
CurPos &operator= (const CurPos &from);
|
||||
CurPos operator+ (const CurPos&) const;
|
||||
CurPos operator- (const CurPos&) const;
|
||||
bool operator!= (const CurPos&) const;
|
||||
bool operator== (const CurPos&) const;
|
||||
bool operator> (const CurPos&) const;
|
||||
bool operator>= (const CurPos&) const;
|
||||
bool operator< (const CurPos&) const;
|
||||
bool operator<= (const CurPos&) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /* CURPOS_H_INCLUDED */
|
87
src/apps/terminal/MYOB/FindDlg.cpp
Normal file
87
src/apps/terminal/MYOB/FindDlg.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Window.h>
|
||||
#include <Rect.h>
|
||||
#include <TextControl.h>
|
||||
#include <Button.h>
|
||||
#include <Message.h>
|
||||
#include <stdio.h>
|
||||
#include <File.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "FindDlg.h"
|
||||
#include "TermApp.h"
|
||||
#include "MenuUtil.h"
|
||||
#include "PrefHandler.h"
|
||||
|
||||
// message define
|
||||
|
||||
const uint32 FPANEL_HIDE = 'Fhid';
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// FindDlg
|
||||
// Constructer
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
FindDlg::FindDlg (BRect frame, TermWindow *win)
|
||||
: BWindow(frame, "Find",
|
||||
B_FLOATING_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
||||
{
|
||||
PrefHandler title;
|
||||
LoadLocaleFile (&title);
|
||||
|
||||
fWindow = win;
|
||||
this->SetTitle (title.getString ("Find"));
|
||||
|
||||
AddShortcut ((ulong)'Q', (ulong)B_COMMAND_KEY, new BMessage (FPANEL_HIDE));
|
||||
AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage (FPANEL_HIDE));
|
||||
|
||||
BRect r (10, 10, 120, 20);
|
||||
|
||||
BTextControl *text_ctl = new BTextControl (r, "text", NULL, NULL, NULL);
|
||||
AddChild (text_ctl);
|
||||
|
||||
r.Set (100, 40, 130, 60);
|
||||
BButton *button = new BButton (r, NULL, "Find", new BMessage (MSG_FIND_START));
|
||||
AddChild (button);
|
||||
|
||||
}
|
||||
|
||||
FindDlg::~FindDlg (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
FindDlg::Quit (void)
|
||||
{
|
||||
BWindow::Quit ();
|
||||
}
|
||||
|
62
src/apps/terminal/MYOB/FindDlg.h
Normal file
62
src/apps/terminal/MYOB/FindDlg.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef FINDDLG_H_INCLUDED
|
||||
#define FINDDLG_H_INCLUDED
|
||||
|
||||
#include <Window.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include "CurPos.h"
|
||||
|
||||
const ulong MSG_FIND_START = 'msac';
|
||||
|
||||
class BRect;
|
||||
class BBitmap;
|
||||
class BMessage;
|
||||
class TermWindow;
|
||||
|
||||
class FindDlg : public BWindow
|
||||
{
|
||||
public:
|
||||
FindDlg(BRect frame, TermWindow *win);
|
||||
~FindDlg ();
|
||||
|
||||
void Find (CurPos *start, CurPos *end);
|
||||
|
||||
private:
|
||||
virtual void Quit (void);
|
||||
|
||||
BString *fFindString;
|
||||
TermWindow *fWindow;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* FINDDLG_H_INCLUDED */
|
30
src/apps/terminal/MYOB/Jamfile
Normal file
30
src/apps/terminal/MYOB/Jamfile
Normal file
@ -0,0 +1,30 @@
|
||||
SubDir OBOS_TOP src apps terminal MYOB ;
|
||||
|
||||
AddResources Terminal2 : Terminal.rsrc ;
|
||||
|
||||
App Terminal2 : AboutWindow.cpp
|
||||
AppearPrefView.cpp
|
||||
CodeConv.cpp
|
||||
CurPos.cpp
|
||||
MenuUtil.cpp
|
||||
# MousePrefView.cpp
|
||||
Terminal.cpp
|
||||
PrefDlg.cpp
|
||||
PrefHandler.cpp
|
||||
PrefView.cpp
|
||||
ShellPrefView.cpp
|
||||
spawn.cpp
|
||||
TermApp.cpp
|
||||
TermBaseView.cpp
|
||||
TermBuffer.cpp
|
||||
TermParse.cpp
|
||||
TermView.cpp
|
||||
TermWindow.cpp
|
||||
TTextControl.cpp
|
||||
UTF8WidthTbl.c
|
||||
VTKeyTbl.c
|
||||
VTPrsTbl.c
|
||||
;
|
||||
|
||||
LinkSharedOSLibs Terminal2 : be tracker textencoding game ;
|
||||
|
175
src/apps/terminal/MYOB/MenuUtil.cpp
Normal file
175
src/apps/terminal/MYOB/MenuUtil.cpp
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Menu.h>
|
||||
#include <string.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Font.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MenuUtil.h"
|
||||
#include "TermConst.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "Coding.h"
|
||||
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
#define LOCALE_FILE_DIR PREF_FOLDER"menu/"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
BPopUpMenu *
|
||||
MakeFontMenu(ulong msg, const char *defaultFontName)
|
||||
{
|
||||
BPopUpMenu *menu = new BPopUpMenu("font");
|
||||
int32 numFamilies = count_font_families();
|
||||
|
||||
for ( int32 i = 0; i < numFamilies; i++ ) {
|
||||
font_family family;
|
||||
uint32 flags;
|
||||
|
||||
if ( get_font_family(i, &family, &flags) == B_OK ) {
|
||||
menu->AddItem(new BMenuItem(family, new BMessage(msg)));
|
||||
if(!strcmp(defaultFontName, family)){
|
||||
(menu->ItemAt(i))->SetMarked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
BPopUpMenu *
|
||||
MakeMenu(ulong msg, const char **items, const char *defaultItemName)
|
||||
{
|
||||
BPopUpMenu *menu = new BPopUpMenu("");
|
||||
|
||||
int32 i = 0;
|
||||
while(*items) {
|
||||
menu->AddItem(new BMenuItem(*items, new BMessage(msg)));
|
||||
if(!strcmp(*items, defaultItemName)){
|
||||
(menu->ItemAt(i))->SetMarked(true);
|
||||
}
|
||||
items++;
|
||||
i++;
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
longname2op(const char *longname)
|
||||
{
|
||||
int op = M_UTF8;
|
||||
const etable *s = encoding_table;
|
||||
|
||||
for (int i = 0; s->name; s++, i++){
|
||||
if(!strcmp(s->name, longname)) {
|
||||
op = s->op;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
const char*
|
||||
op2longname(int op)
|
||||
{
|
||||
return encoding_table[op].name;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
MakeEncodingMenu(BMenu *eMenu, int coding, bool flag)
|
||||
{
|
||||
const etable *e = encoding_table;
|
||||
int i = 0;
|
||||
while(e->name){
|
||||
BMessage *msg = new BMessage(MENU_ENCODING);
|
||||
msg->AddInt32("op", (int32)e->op);
|
||||
if (flag) {
|
||||
eMenu->AddItem(new BMenuItem(e->name, msg, e->shortcut));
|
||||
}
|
||||
else {
|
||||
eMenu->AddItem(new BMenuItem(e->name, msg));
|
||||
}
|
||||
|
||||
if ( i == coding) {
|
||||
(eMenu->ItemAt(i))->SetMarked(true);
|
||||
}
|
||||
e++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
LoadLocaleFile (PrefHandler *pref)
|
||||
{
|
||||
|
||||
const char *locale;
|
||||
char buf[B_PATH_NAME_LENGTH];
|
||||
status_t sts;
|
||||
|
||||
/*
|
||||
* Open menu localize file.
|
||||
*/
|
||||
locale = gTermPref->getString (PREF_GUI_LANGUAGE);
|
||||
sprintf (buf, "%s%s", LOCALE_FILE_DIR, locale);
|
||||
|
||||
sts = pref->OpenText (buf);
|
||||
|
||||
if (sts == B_ERROR)
|
||||
pref->OpenText (LOCALE_FILE_DEFAULT);
|
||||
|
||||
return;
|
||||
|
||||
}
|
58
src/apps/terminal/MYOB/MenuUtil.h
Normal file
58
src/apps/terminal/MYOB/MenuUtil.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MENUUTIL_H_INCLUDED
|
||||
#define MENUUTIL_H_INCLUDED
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
class BPopUpMenu;
|
||||
class BMenu;
|
||||
class PrefHandler;
|
||||
|
||||
|
||||
BPopUpMenu * MakeFontMenu(ulong msg, const char *defaultFontName);
|
||||
BPopUpMenu * MakeMenu(ulong msg, const char **items,
|
||||
const char *defaultItemName);
|
||||
|
||||
int longname2op(const char *longname);
|
||||
const char* op2longname(int op);
|
||||
void MakeEncodingMenu(BMenu *eMenu, int coding, bool flag);
|
||||
void LoadLocaleFile (PrefHandler *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //MENUUTIL_H_INCLUDED
|
346
src/apps/terminal/MYOB/PrefDlg.cpp
Normal file
346
src/apps/terminal/MYOB/PrefDlg.cpp
Normal file
@ -0,0 +1,346 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Box.h>
|
||||
#include <Button.h>
|
||||
#include <TabView.h>
|
||||
#include <FilePanel.h>
|
||||
#include <Screen.h>
|
||||
#include <Alert.h>
|
||||
#include <storage/Path.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "PrefHandler.h"
|
||||
#include "PrefDlg.h"
|
||||
#include "TermConst.h"
|
||||
#include "TermView.h"
|
||||
#include "TermWindow.h"
|
||||
#include "MenuUtil.h"
|
||||
|
||||
#include "AppearPrefView.h"
|
||||
#include "ShellPrefView.h"
|
||||
#include "PrefView.h"
|
||||
#include "spawn.h"
|
||||
|
||||
|
||||
// Gloval Preference Handler
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// PrefDlg
|
||||
// Constructer
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
PrefDlg::PrefDlg(TermWindow *inWindow)
|
||||
: BWindow(CenteredRect(BRect(0, 0, 350, 250)), "Preference",
|
||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
|
||||
{
|
||||
|
||||
fTermWindow = inWindow;
|
||||
fPrefTemp = new PrefHandler(gTermPref);
|
||||
fDirty = false;
|
||||
fSavePanel = NULL;
|
||||
|
||||
SetupContent();
|
||||
Show();
|
||||
|
||||
AddShortcut ((ulong)'Q', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||
AddShortcut ((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// PrefDlg
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
PrefDlg::~PrefDlg (void)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// SetupContent()
|
||||
// Set up content of window.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::SetupContent()
|
||||
{
|
||||
BRect r;
|
||||
|
||||
Lock();
|
||||
|
||||
BView *top = new BView(Bounds(), "topview", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild (top);
|
||||
|
||||
//
|
||||
// Tab View
|
||||
//
|
||||
r = top->Bounds();
|
||||
r.bottom -= 40;
|
||||
r.InsetBy (0, 5);
|
||||
|
||||
fTabView = new BTabView(r, "tab_view", B_WIDTH_FROM_WIDEST);
|
||||
fTabView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
r = fTabView->Bounds();
|
||||
r.InsetBy(10,10);
|
||||
r.bottom -= fTabView->TabHeight();
|
||||
|
||||
fTabView->AddTab(new AppearancePrefView (r, "Appearance", fTermWindow));
|
||||
fTabView->AddTab(new ShellPrefView (r, "Shell", fTermWindow));
|
||||
|
||||
//
|
||||
// OK, Apply and Cancel button.
|
||||
//
|
||||
|
||||
fSaveAsFileButton = new BButton(BRect(50,215,150,20), "okbutton", "Save", new BMessage(MSG_SAVEAS_PRESSED), B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
top->AddChild(fSaveAsFileButton);
|
||||
fRevertButton = new BButton(BRect(180,215,250,20), "applybutton", "Cancel", new BMessage(MSG_REVERT_PRESSED), B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
top->AddChild(fRevertButton);
|
||||
fSaveButton = new BButton(BRect(260,215,330,20), "cancelbutton", "OK", new BMessage(MSG_SAVE_PRESSED), B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
top->AddChild(fSaveButton);
|
||||
|
||||
|
||||
top->AddChild (fTabView);
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// if OK button pressed
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::Quit()
|
||||
{
|
||||
fTermWindow->PostMessage(MSG_PREF_CLOSED);
|
||||
delete fPrefTemp;
|
||||
delete fSavePanel;
|
||||
BWindow::Quit();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// QuitRequested
|
||||
// if close box checked and perf is changed..
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
PrefDlg::QuitRequested ()
|
||||
{
|
||||
if(!fDirty) return true;
|
||||
|
||||
BAlert *alert = new BAlert("",
|
||||
"Save changes to this preference panel?",
|
||||
"Cancel", "Don't save",
|
||||
"Save",
|
||||
B_WIDTH_AS_USUAL,
|
||||
B_OFFSET_SPACING,
|
||||
B_WARNING_ALERT);
|
||||
alert->SetShortcut(0, B_ESCAPE);
|
||||
int32 button_index = alert->Go();
|
||||
|
||||
switch (button_index) {
|
||||
|
||||
case 0: // Cancel
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 2: // Save
|
||||
this->doSave();
|
||||
break;
|
||||
|
||||
case 1: // Don't Save
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// if SaveAs button pressed
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::doSaveAs (void)
|
||||
{
|
||||
for (int32 i = 0; i < fTabView->CountTabs(); i++) {
|
||||
// PrefView *aView = (PrefView *)fTabView->ViewForTab(i);
|
||||
// aView->SaveIfModified ();
|
||||
}
|
||||
|
||||
if(!fSavePanel){
|
||||
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
|
||||
}
|
||||
|
||||
fSavePanel->Show();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::SaveRequested(BMessage *msg)
|
||||
{
|
||||
entry_ref dirref;
|
||||
const char *filename;
|
||||
|
||||
msg->FindRef("directory", &dirref);
|
||||
msg->FindString("name", &filename);
|
||||
BDirectory dir(&dirref);
|
||||
BPath path(&dir, filename);
|
||||
|
||||
gTermPref->SaveAsText (path.Path(), PREFFILE_MIMETYPE, TERM_SIGNATURE);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// if OK button pressed
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::doSave (void)
|
||||
{
|
||||
for (int32 i = 0; i < fTabView->CountTabs(); i++) {
|
||||
// PrefView *aView = (PrefView *)fTabView->ViewForTab(i);
|
||||
// aView->SaveIfModified ();
|
||||
}
|
||||
|
||||
delete fPrefTemp;
|
||||
fPrefTemp = new PrefHandler (gTermPref);
|
||||
|
||||
gTermPref->SaveAsText (TERM_PREF, PREFFILE_MIMETYPE);
|
||||
|
||||
fDirty = false;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// if cancel button pressed
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::doRevert (void)
|
||||
{
|
||||
BMessenger messenger (fTermWindow);
|
||||
|
||||
delete gTermPref;
|
||||
gTermPref = new PrefHandler (fPrefTemp);
|
||||
|
||||
messenger.SendMessage (MSG_HALF_FONT_CHANGED);
|
||||
messenger.SendMessage (MSG_COLOR_CHANGED);
|
||||
messenger.SendMessage (MSG_ROWS_CHANGED);
|
||||
messenger.SendMessage (MSG_INPUT_METHOD_CHANGED);
|
||||
|
||||
this->DisableUpdates();
|
||||
this->Lock();
|
||||
for (int32 i = 0; i < fTabView->CountTabs(); i++) {
|
||||
// PrefView *aView = (PrefView *)fTabView->ViewForTab(i);
|
||||
// aView->Revert ();
|
||||
}
|
||||
this->Unlock();
|
||||
this->EnableUpdates();
|
||||
|
||||
fDirty = false;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefDlg::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case MSG_SAVE_PRESSED:
|
||||
doSave();
|
||||
Quit();
|
||||
break;
|
||||
|
||||
case MSG_SAVEAS_PRESSED:
|
||||
doSaveAs();
|
||||
break;
|
||||
|
||||
case MSG_REVERT_PRESSED:
|
||||
doRevert();
|
||||
break;
|
||||
|
||||
case MSG_PREF_MODIFIED:
|
||||
fDirty = true;
|
||||
break;
|
||||
|
||||
case B_SAVE_REQUESTED:
|
||||
this->SaveRequested(msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// SetupBox
|
||||
// make Box
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
BBox *
|
||||
PrefDlg::SetupBox(BRect r, const char *label, BView *parent)
|
||||
{
|
||||
BBox *b;
|
||||
|
||||
b = new BBox(r);
|
||||
b->SetLabel(label);
|
||||
parent->AddChild(b);
|
||||
return b;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// SetupButton
|
||||
// make Button
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//BButton *
|
||||
//PrefDlg::SetupButton(BRect r, const char *label, ulong msg, BView *parent, bool defaultButton)
|
||||
//{
|
||||
// BButton *b;
|
||||
//
|
||||
// b = new BButton(r, "", label, new BMessage(msg));
|
||||
// parent->AddChild(b);
|
||||
//
|
||||
// if (defaultButton)
|
||||
// (parent->Window())->SetDefaultButton(b);
|
||||
//
|
||||
// return b;
|
||||
//}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Ajust Input Rect to locate center of Screen.
|
||||
// ( static member function. )
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
BRect
|
||||
PrefDlg::CenteredRect(BRect r)
|
||||
{
|
||||
BRect screenRect = BScreen().Frame();
|
||||
|
||||
screenRect.InsetBy(10,10);
|
||||
|
||||
float x = screenRect.left + (screenRect.Width() - r.Width()) / 2;
|
||||
float y = screenRect.top + (screenRect.Height() - r.Height()) / 3;
|
||||
|
||||
r.OffsetTo(x, y);
|
||||
|
||||
return r;
|
||||
}
|
92
src/apps/terminal/MYOB/PrefDlg.h
Normal file
92
src/apps/terminal/MYOB/PrefDlg.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef PREFDLG_H_INCLUDED
|
||||
#define PREFDLG_H_INCLUDED
|
||||
|
||||
#include <Box.h>
|
||||
#include <Window.h>
|
||||
#include "PrefHandler.h"
|
||||
|
||||
// local message, so these are in .cpp files....
|
||||
const ulong MSG_SAVE_PRESSED = 'okok';
|
||||
const ulong MSG_SAVEAS_PRESSED = 'canl';
|
||||
const ulong MSG_REVERT_PRESSED = 'revt';
|
||||
const ulong MSG_PREF_CLOSED = 'mspc';
|
||||
|
||||
|
||||
// Notify PrefDlg closed to TermWindow
|
||||
|
||||
class BRect;
|
||||
class BMessage;
|
||||
class BTextControl;
|
||||
class TermWindow;
|
||||
class PrefView;
|
||||
class BButton;
|
||||
class PrefHandler;
|
||||
class BFilePanel;
|
||||
|
||||
class PrefDlg : public BWindow
|
||||
{
|
||||
public:
|
||||
PrefDlg(TermWindow *inWindow);
|
||||
~PrefDlg ();
|
||||
|
||||
void Quit();
|
||||
|
||||
private:
|
||||
void doSave (void);
|
||||
void doSaveAs (void);
|
||||
void doRevert (void);
|
||||
void SaveRequested(BMessage *msg);
|
||||
|
||||
bool QuitRequested ();
|
||||
void MessageReceived (BMessage *msg);
|
||||
|
||||
void SetupContent();
|
||||
|
||||
BBox* SetupBox(BRect r, const char *label, BView *parent);
|
||||
BButton* SetupButton(BRect r, const char *label, ulong msg,
|
||||
BView *parent, bool defaultButton=false);
|
||||
|
||||
static BRect CenteredRect(BRect r);
|
||||
|
||||
private:
|
||||
TermWindow *fTermWindow;
|
||||
BTabView *fTabView;
|
||||
PrefHandler *fPrefTemp;
|
||||
BFilePanel *fSavePanel;
|
||||
BButton *fSaveAsFileButton;
|
||||
BButton *fRevertButton;
|
||||
BButton *fSaveButton;
|
||||
|
||||
bool fDirty;
|
||||
};
|
||||
|
||||
#endif //PREFDLG_H_INCLUDED
|
311
src/apps/terminal/MYOB/PrefHandler.cpp
Normal file
311
src/apps/terminal/MYOB/PrefHandler.cpp
Normal file
@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Message.h>
|
||||
#include <File.h>
|
||||
#include <Entry.h>
|
||||
#include <NodeInfo.h>
|
||||
|
||||
#include "PrefHandler.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
PrefHandler::PrefHandler()
|
||||
{
|
||||
mPrefContainer.what = 'Pref';
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
PrefHandler::PrefHandler(const PrefHandler* p)
|
||||
{
|
||||
mPrefContainer = p->mPrefContainer;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
PrefHandler::~PrefHandler()
|
||||
{
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
status_t
|
||||
PrefHandler::Open(const char *path, const prefDefaults *defaults)
|
||||
{
|
||||
BEntry ent(path);
|
||||
if(ent.Exists()){
|
||||
return loadFromFile(&ent);
|
||||
}else{
|
||||
return loadFromDefault(defaults);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
status_t
|
||||
PrefHandler::OpenText(const char *path, const prefDefaults *defaults)
|
||||
{
|
||||
BEntry ent(path);
|
||||
if(ent.Exists()){
|
||||
return loadFromTextFile(path);
|
||||
}else{
|
||||
return loadFromDefault(defaults);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
status_t
|
||||
PrefHandler::Save(const char *path)
|
||||
{
|
||||
status_t sts;
|
||||
BFile file(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
sts = mPrefContainer.Flatten(&file);
|
||||
return sts;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefHandler::SaveAsText(const char *path, const char *mimetype,
|
||||
const char *signature)
|
||||
{
|
||||
BFile file(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
type_code type;
|
||||
char *key;
|
||||
char buf[256];
|
||||
|
||||
for (int32 i = 0; mPrefContainer.GetInfo(B_STRING_TYPE, i, &key, &type) == B_OK; i++){
|
||||
int len = sprintf(buf, "\"%s\" , \"%s\"\n", key, this->getString(key));
|
||||
file.Write(buf, len);
|
||||
}
|
||||
|
||||
if(mimetype != NULL){
|
||||
BNodeInfo info(&file);
|
||||
info.SetType(mimetype);
|
||||
info.SetPreferredApp (signature);
|
||||
}
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
int32
|
||||
PrefHandler::getInt32(const char *key)
|
||||
{
|
||||
return atoi(mPrefContainer.FindString(key));
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
float
|
||||
PrefHandler::getFloat(const char *key)
|
||||
{
|
||||
return atof(mPrefContainer.FindString(key));
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
const char*
|
||||
PrefHandler::getString(const char *key)
|
||||
{
|
||||
const char *buf;
|
||||
|
||||
buf = mPrefContainer.FindString(key);
|
||||
if (buf == NULL)
|
||||
buf = "Error!";
|
||||
|
||||
return buf;
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
PrefHandler::getBool(const char *key)
|
||||
{
|
||||
const char *s = mPrefContainer.FindString(key);
|
||||
if (!strcmp(s, PREF_TRUE)) return true;
|
||||
return false;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// getRGB
|
||||
// Returns RGB data from given key.
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
rgb_color
|
||||
PrefHandler::getRGB(const char *key)
|
||||
{
|
||||
int r, g, b;
|
||||
rgb_color col;
|
||||
const char *s = mPrefContainer.FindString(key);
|
||||
sscanf(s, "%d, %d, %d", &r, &g, &b);
|
||||
col.red = r;
|
||||
col.green = g;
|
||||
col.blue = b;
|
||||
col.alpha = 0;
|
||||
return col;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// setInt32
|
||||
// Setting Int32 data with key.
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefHandler::setInt32(const char *key, int32 data)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "%d", (int)data);
|
||||
this->setString(key, buf);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// setFloat
|
||||
// Setting Float data with key
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefHandler::setFloat(const char *key, float data)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "%g", data);
|
||||
this->setString(key, buf);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// setBool
|
||||
// Setting Bool data with key
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefHandler::setBool(const char *key, bool data)
|
||||
{
|
||||
if(data){
|
||||
this->setString(key, PREF_TRUE);
|
||||
}else{
|
||||
this->setString(key, PREF_FALSE);
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// this->setString
|
||||
// Setting CString data with key
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefHandler::setString(const char *key, const char *data)
|
||||
{
|
||||
mPrefContainer.RemoveName(key);
|
||||
mPrefContainer.AddString(key, data);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// setRGB
|
||||
// Setting RGB data with key
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
PrefHandler::setRGB(const char *key, const rgb_color data)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "%d, %d, %d", data.red, data.green, data.blue);
|
||||
this->setString(key, buf);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// IsEmpty
|
||||
// Check any peference stored or not.
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
PrefHandler::IsEmpty() const
|
||||
{
|
||||
return mPrefContainer.IsEmpty();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
status_t
|
||||
PrefHandler::loadFromFile(BEntry *ent)
|
||||
{
|
||||
BFile file (ent, B_READ_ONLY);
|
||||
mPrefContainer.MakeEmpty();
|
||||
return mPrefContainer.Unflatten(&file);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
status_t
|
||||
PrefHandler::loadFromDefault(const prefDefaults* defaluts)
|
||||
{
|
||||
if(defaluts == NULL) return B_ERROR;
|
||||
|
||||
while(defaluts->key){
|
||||
this->setString(defaluts->key, defaluts->item);
|
||||
++defaluts;
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Text is "key","Content"
|
||||
// Comment : Start with '#'
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
status_t
|
||||
PrefHandler::loadFromTextFile(const char * path)
|
||||
{
|
||||
char buf[1024];
|
||||
char key[B_FIELD_NAME_LENGTH], data[512];
|
||||
int n;
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(path, "r");
|
||||
|
||||
while(fgets(buf, sizeof(buf), fp) != NULL){
|
||||
if (*buf == '#') continue;
|
||||
n = sscanf(buf, "%*[\"]%[^\"]%*[\"]%*[^\"]%*[\"]%[^\"]", key, data);
|
||||
if (n == 2) this->setString(key, data);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return B_OK;
|
||||
}
|
88
src/apps/terminal/MYOB/PrefHandler.h
Normal file
88
src/apps/terminal/MYOB/PrefHandler.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef PREFHANDLER_H_INCLUDED
|
||||
#define PREFHANDLER_H_INCLUDED
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <Errors.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Message.h>
|
||||
|
||||
struct prefDefaults
|
||||
{
|
||||
const char *key;
|
||||
char *item;
|
||||
};
|
||||
|
||||
#define PREF_TRUE "true"
|
||||
#define PREF_FALSE "false"
|
||||
|
||||
class BMessage;
|
||||
class BEntry;
|
||||
|
||||
class PrefHandler{
|
||||
public:
|
||||
PrefHandler();
|
||||
PrefHandler(const PrefHandler* p);
|
||||
|
||||
~PrefHandler();
|
||||
|
||||
status_t Open(const char *name, const prefDefaults *defaults = NULL);
|
||||
status_t OpenText(const char *path, const prefDefaults *defaults = NULL);
|
||||
status_t Save(const char *name);
|
||||
void SaveAsText(const char *path, const char *minmtype = NULL,
|
||||
const char *signature = NULL);
|
||||
|
||||
int32 getInt32(const char *key);
|
||||
float getFloat(const char *key);
|
||||
const char* getString(const char *key);
|
||||
bool getBool(const char *key);
|
||||
rgb_color getRGB(const char *key);
|
||||
|
||||
void setInt32(const char *key, int32 data);
|
||||
void setFloat(const char *key, float data);
|
||||
void setString(const char *key, const char *data);
|
||||
void setBool(const char *key, bool data);
|
||||
void setRGB(const char *key, const rgb_color data);
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
private:
|
||||
status_t loadFromFile(BEntry *ent);
|
||||
status_t loadFromDefault(const prefDefaults* defaluts = NULL);
|
||||
status_t loadFromTextFile(const char * path);
|
||||
|
||||
|
||||
BMessage mPrefContainer;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //PREFHANDLER_H_INCLUDED
|
122
src/apps/terminal/MYOB/PrefView.cpp
Normal file
122
src/apps/terminal/MYOB/PrefView.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <Box.h>
|
||||
#include <Button.h>
|
||||
#include <RadioButton.h>
|
||||
#include <ColorControl.h>
|
||||
#include <StringView.h>
|
||||
#include <TextControl.h>
|
||||
#include <CheckBox.h>
|
||||
#include <MenuField.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "PrefHandler.h"
|
||||
#include "TermConst.h"
|
||||
#include "PrefView.h"
|
||||
#include "TTextControl.h"
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* PUBLIC MEMBER FUNCTIONS.
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// PrefView ()
|
||||
// Constructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
PrefView::PrefView (BRect frame, const char *name)
|
||||
:BView (frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
fLabel.SetTo(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ~PrefView ()
|
||||
// Destructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
PrefView::~PrefView()
|
||||
{
|
||||
|
||||
}
|
||||
const char *
|
||||
PrefView::ViewLabel (void) const
|
||||
{
|
||||
return fLabel.String();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CanApply()
|
||||
// Determines whether view can respont Apply command or not.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
PrefView::CanApply ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
PrefView::MessageReceived (BMessage *msg)
|
||||
{
|
||||
TTextControl *textctl;
|
||||
|
||||
switch (msg->what) {
|
||||
case MSG_TEXT_MODIFIED:
|
||||
if (msg->FindPointer ("source", (void**)&textctl) == B_OK) {
|
||||
textctl->ModifiedText (true);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived (msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// SetupBColorControl
|
||||
// Make BColorControl.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
BColorControl *
|
||||
PrefView::SetupBColorControl(BPoint p, color_control_layout layout, float cell_size, ulong msg)
|
||||
{
|
||||
BColorControl *col;
|
||||
|
||||
col = new BColorControl( p, layout, cell_size, "", new BMessage(msg));
|
||||
AddChild(col);
|
||||
return col;
|
||||
}
|
||||
|
86
src/apps/terminal/MYOB/PrefView.h
Normal file
86
src/apps/terminal/MYOB/PrefView.h
Normal file
@ -0,0 +1,86 @@
|
||||
/* Hey Emacs, this file is -*- c++ -*-
|
||||
|
||||
Multilingual Terminal Emulator "MuTerminal".
|
||||
|
||||
Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. ALL RIGHT RESERVED
|
||||
|
||||
This file is part of MuTerminal.
|
||||
|
||||
MuTerminal is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
PrefView.h,v 2.8 1999/10/02 15:17:30 kaz Exp
|
||||
PrefView.h,v: Interface for Preference Tab Container View.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PREFVIEW_H_INCLUDED
|
||||
#define PREFVIEW_H_INCLUDED
|
||||
#include <View.h>
|
||||
#include <ColorControl.h>
|
||||
#include <String.h>
|
||||
|
||||
class PrefHandler;
|
||||
class BRect;
|
||||
class BBox;
|
||||
class TTextControl;
|
||||
class BStringView;
|
||||
class BRadioButton;
|
||||
class BButton;
|
||||
class BCheckBox;
|
||||
class BMenuField;
|
||||
|
||||
enum {
|
||||
PREF_APP_VIEW,
|
||||
PREF_SHELL_VIEW,
|
||||
PREF_LANG_VIEW
|
||||
};
|
||||
|
||||
//
|
||||
// Appearance Message
|
||||
//
|
||||
const ulong MSG_HALF_FONT_CHANGED = 'mchf';
|
||||
const ulong MSG_HALF_SIZE_CHANGED = 'mchs';
|
||||
const ulong MSG_FULL_FONT_CHANGED = 'mcff';
|
||||
const ulong MSG_FULL_SIZE_CHANGED = 'mcfs';
|
||||
const ulong MSG_COLOR_FIELD_CHANGED = 'mccf';
|
||||
const ulong MSG_COLOR_CHANGED = 'mcbc';
|
||||
|
||||
//
|
||||
// ShellMessage
|
||||
//
|
||||
const ulong MSG_COLS_CHANGED = 'mccl';
|
||||
const ulong MSG_ROWS_CHANGED = 'mcrw';
|
||||
const ulong MSG_HISTORY_CHANGED = 'mhst';
|
||||
|
||||
const ulong MSG_LANG_CHANGED = 'mclg';
|
||||
const ulong MSG_INPUT_METHOD_CHANGED = 'mcim';
|
||||
|
||||
//
|
||||
// TextControl Modification Message.
|
||||
//
|
||||
const ulong MSG_TEXT_MODIFIED = 'tcmm';
|
||||
const ulong MSG_PREF_MODIFIED = 'mpmo';
|
||||
|
||||
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
class PrefView : public BView
|
||||
{
|
||||
public:
|
||||
PrefView (BRect frame, const char *name);
|
||||
virtual ~PrefView();
|
||||
const char * ViewLabel (void) const;
|
||||
virtual bool CanApply ();
|
||||
virtual void MessageReceived (BMessage *msg);
|
||||
|
||||
BColorControl* SetupBColorControl (BPoint p, color_control_layout layout, float cell_size, ulong msg);
|
||||
|
||||
private:
|
||||
BString fLabel;
|
||||
|
||||
};
|
||||
|
||||
#endif //PREFVIEW_H_INCLUDED
|
83
src/apps/terminal/MYOB/README.GPL_to_OBOS
Normal file
83
src/apps/terminal/MYOB/README.GPL_to_OBOS
Normal file
@ -0,0 +1,83 @@
|
||||
April 21, 2003 - MuTerminal goes from GPL to OBOS!
|
||||
|
||||
Thanks to the effort of BiPolar and the generosity of Kazuho Okui and
|
||||
Takashi Murai we have had donated to OBOS the sources for MuTerminal.
|
||||
MuTerminal was formerly under the GPL license. The complete MuTerminal
|
||||
package as it was originally released on April 2, 2000 (version 2.3) is
|
||||
preserved in this directory in the original form that I obtained from
|
||||
bebits.
|
||||
|
||||
To simplify integration I have performed some code reorganization and
|
||||
the initial check-in is not the same as the version 2.3 which is saved
|
||||
in the muterm-2.3.zip. As such, please do not remove the muterm-2.3.zip
|
||||
as it is an important checkpoint. (and also stands as a thank-you to
|
||||
Kazuho Okui and Takashi Murai)
|
||||
|
||||
Andrew Bachmann
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
To: kaz@naan.net
|
||||
From: "BiPolar" <BiPolar@SoftHome.net>
|
||||
Subject: about MuTerminal
|
||||
Date: Tue, 22 Apr 2003 00:32:27 -0300 ART
|
||||
|
||||
Hello!
|
||||
|
||||
I am a (very) happy user of your mighty program: Muterminal 2.0 for
|
||||
BeOS.
|
||||
My name is Oscar Lesta. I'm Argentinian (just to inform you, not to
|
||||
make you feel sorry for me, he he!).
|
||||
|
||||
I've being using MuTerminal for a while (I have even made some small
|
||||
changes in the GUI, hiding/unhiding of the scrollbar, rearrangement of
|
||||
menu items, fixed some localization issues and things like that) and I
|
||||
think that it is a great replacement for Be's original Terminal app.
|
||||
|
||||
I really don't know if you are still developing this program, but I
|
||||
have to ask you:
|
||||
Is there any chance of that you change the license from GPL to MIT/BSD?
|
||||
|
||||
If you do so, then the OpenBeOS Team (http://open-beos.sourceforge.net)
|
||||
could use your app as a Terminal Replacement in the future release of
|
||||
their O.S.
|
||||
|
||||
In case you aren't developing it anymore: maybe you can "donate" your
|
||||
code to beunited.org (http://www.beunited.org). They are making
|
||||
standars for BeOS compatible O.S., and continuing the development of
|
||||
several applications for BeOS that original authors have donated to the
|
||||
BeOS Community.
|
||||
|
||||
About the license: I understand that part of your code depends on
|
||||
libconv, which is under GPL, but that part can be replaced with they
|
||||
counterpart from OpenBeOS, with is under a MIT/BSD like license.
|
||||
|
||||
Thanks for your time, and thanks again for MuTerm!
|
||||
|
||||
Your,
|
||||
|
||||
Oscar.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
To: BiPolar <BiPolar@SoftHome.net>
|
||||
From: Kazuho Okui <kaz@naan.jp>
|
||||
Subject: Re: about MuTerminal
|
||||
Date: Tue, 22 Apr 2003 13:46:47 +0900
|
||||
|
||||
Hi,
|
||||
|
||||
Now, Muterm's licence is GPL, but, I'm not use other GPL code in Muterm.
|
||||
So, I can change Muterm`s licence to MIT/BSD/AS IS and other.
|
||||
|
||||
If you (and OpenBeOS team) adopt Muterm to default terminal on OpenBeOS,
|
||||
I will welcome it.
|
||||
|
||||
I want you to leave only the credit of me and Takashi Murai in that case.
|
||||
|
||||
Please contact me, if some may otherwise be able to be helped. However,
|
||||
since my work is busy recently, I think that coding is hardly made.
|
||||
|
||||
Thanks,
|
||||
--
|
||||
Kazuho Okui<kaz@naan.jp>
|
213
src/apps/terminal/MYOB/ShellPrefView.cpp
Normal file
213
src/apps/terminal/MYOB/ShellPrefView.cpp
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <View.h>
|
||||
#include <Button.h>
|
||||
#include <MenuField.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <TextControl.h>
|
||||
#include <stdlib.h>
|
||||
#include <Beep.h>
|
||||
|
||||
#include "ShellPrefView.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "TermWindow.h"
|
||||
#include "TermBuffer.h"
|
||||
#include "TermConst.h"
|
||||
#include "MenuUtil.h"
|
||||
#include "TTextControl.h"
|
||||
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// AparancePrefView ()
|
||||
// Constructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
ShellPrefView::ShellPrefView (BRect frame, const char *name,
|
||||
TermWindow *window)
|
||||
:PrefView (frame, name)
|
||||
{
|
||||
fTermWindow = window;
|
||||
|
||||
mCols = new TTextControl(BRect(0, 0, 160, 20), "cols", "Columns", "", new BMessage(MSG_COLS_CHANGED));
|
||||
AddChild(mCols);
|
||||
mCols->SetText(gTermPref->getString(PREF_COLS));
|
||||
|
||||
mRows = new TTextControl(BRect(0, 30, 160, 50), "rows", "Rows", "", new BMessage(MSG_ROWS_CHANGED));
|
||||
AddChild(mRows);
|
||||
mRows->SetText(gTermPref->getString(PREF_ROWS));
|
||||
|
||||
mHistory = new TTextControl(BRect(0, 60, 160, 80), "history", "History", "", new BMessage(MSG_HISTORY_CHANGED));
|
||||
AddChild(mHistory);
|
||||
mHistory->SetText (gTermPref->getString (PREF_HISTORY_SIZE));
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
ShellPrefView::Revert (void)
|
||||
{
|
||||
mCols->SetText (gTermPref->getString (PREF_COLS));
|
||||
mRows->SetText (gTermPref->getString (PREF_ROWS));
|
||||
mHistory->SetText (gTermPref->getString (PREF_HISTORY_SIZE));
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SaveIfModified (void)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
ShellPrefView::SaveIfModified (void)
|
||||
{
|
||||
BMessenger messenger (fTermWindow);
|
||||
|
||||
if (mCols->IsModified()) {
|
||||
gTermPref->setString (PREF_COLS, mCols->Text());
|
||||
messenger.SendMessage (MSG_COLS_CHANGED);
|
||||
mCols->ModifiedText (false);
|
||||
}
|
||||
if (mRows->IsModified()) {
|
||||
gTermPref->setString (PREF_ROWS, mRows->Text());
|
||||
messenger.SendMessage (MSG_ROWS_CHANGED);
|
||||
mRows->ModifiedText (false);
|
||||
}
|
||||
//if (mShell->IsModified())
|
||||
// gTermPref->setString (PREF_SHELL, mShell->Text());
|
||||
|
||||
if (mHistory->IsModified()) {
|
||||
int size;
|
||||
size = atoi(mHistory->Text());
|
||||
if (size < 512) mHistory->SetText("512");
|
||||
if (size > 1048575) mHistory->SetText("1048575");
|
||||
gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text());
|
||||
}
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
ShellPrefView::SetControlLabels (PrefHandler &Labels)
|
||||
{
|
||||
mCols->SetLabel("Columns");
|
||||
mRows->SetLabel("Rows");
|
||||
// mShell->SetLabel("Shell");
|
||||
mHistory->SetLabel("History Size");
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* PRIVATE MEMBER FUNCTIONS
|
||||
*
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
ShellPrefView::AttachedToWindow (void)
|
||||
{
|
||||
mCols->SetTarget (this);
|
||||
mRows->SetTarget (this);
|
||||
|
||||
// mShell->SetTarget (this);
|
||||
mHistory->SetTarget (this);
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
ShellPrefView::MessageReceived (BMessage *msg)
|
||||
{
|
||||
bool modified = false;
|
||||
int size;
|
||||
|
||||
switch (msg->what) {
|
||||
|
||||
case MSG_COLS_CHANGED:
|
||||
size = atoi (mCols->Text());
|
||||
if (size >= MAX_COLS || size < MIN_COLS) {
|
||||
mCols->SetText (gTermPref->getString (PREF_COLS));
|
||||
beep ();
|
||||
} else {
|
||||
gTermPref->setString (PREF_COLS, mCols->Text());
|
||||
modified = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MSG_ROWS_CHANGED:
|
||||
size = atoi (mRows->Text());
|
||||
if (size >= MAX_COLS || size < MIN_COLS) {
|
||||
mRows->SetText (gTermPref->getString (PREF_ROWS));
|
||||
beep ();
|
||||
} else {
|
||||
gTermPref->setString (PREF_ROWS, mRows->Text());
|
||||
modified = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// case MSG_SHELL_CHANGED:
|
||||
// gTermPref->setString (PREF_SHELL, mShell->Text());
|
||||
// (this->Window())->PostMessage(MSG_PREF_MODIFIED);
|
||||
// break;
|
||||
|
||||
case MSG_HISTORY_CHANGED:
|
||||
size = atoi(mHistory->Text());
|
||||
|
||||
if (size < 512 || size > 1048575) {
|
||||
mHistory->SetText(gTermPref->getString (PREF_HISTORY_SIZE));
|
||||
beep ();
|
||||
} else {
|
||||
gTermPref->setString (PREF_HISTORY_SIZE, mHistory->Text());
|
||||
(this->Window())->PostMessage(MSG_PREF_MODIFIED);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
PrefView::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
if(modified){
|
||||
fTermWindow->PostMessage (msg);
|
||||
(this->Window())->PostMessage(MSG_PREF_MODIFIED);
|
||||
}
|
||||
}
|
63
src/apps/terminal/MYOB/ShellPrefView.h
Normal file
63
src/apps/terminal/MYOB/ShellPrefView.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ShellPrefView__H_INCLUDED
|
||||
#define ShellPrefView__H_INCLUDED
|
||||
|
||||
#include "PrefView.h"
|
||||
|
||||
class TermWindow;
|
||||
class TTextControl;
|
||||
|
||||
class ShellPrefView : public PrefView
|
||||
{
|
||||
public:
|
||||
ShellPrefView (BRect r, const char *name, TermWindow *window);
|
||||
|
||||
virtual void SaveIfModified (void);
|
||||
|
||||
void Revert (void);
|
||||
void SetControlLabels (PrefHandler &Labels);
|
||||
|
||||
void AttachedToWindow (void);
|
||||
void MessageReceived (BMessage *);
|
||||
|
||||
private:
|
||||
TTextControl *mCols;
|
||||
TTextControl *mRows;
|
||||
|
||||
TTextControl *mShell;
|
||||
TTextControl *mHistory;
|
||||
|
||||
TermWindow *fTermWindow;
|
||||
|
||||
};
|
||||
|
||||
#endif //ShellPrefView_H_INCLUDED
|
84
src/apps/terminal/MYOB/TTextControl.cpp
Normal file
84
src/apps/terminal/MYOB/TTextControl.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <TextControl.h>
|
||||
#include "TTextControl.h"
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* CONSTRUCTOR and DESTRUCTOR
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// TTextControl ()
|
||||
// Constructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TTextControl::TTextControl (BRect r, const char *name,
|
||||
const char *label, const char *text,
|
||||
BMessage *msg)
|
||||
:BTextControl (r, name, label, text, msg)
|
||||
{
|
||||
mModified = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ~TTextControl ()
|
||||
// Destructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TTextControl::~TTextControl ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* PUBLIC MEMBER FUNCTIONS.
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ModifiedText (int)
|
||||
// Dispatch modification message.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TTextControl::ModifiedText (int flag)
|
||||
{
|
||||
mModified = flag;
|
||||
return;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// IsModified (void)
|
||||
// Dispatch modification message.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
TTextControl::IsModified (void)
|
||||
{
|
||||
return mModified;
|
||||
}
|
||||
|
59
src/apps/terminal/MYOB/TTextControl.h
Normal file
59
src/apps/terminal/MYOB/TTextControl.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TTEXTCTL_H_INCLUDED
|
||||
#define TTEXTCTL_H_INCLUDED
|
||||
#include <TextControl.h>
|
||||
|
||||
class TTextControl : public BTextControl
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Constructor and Desctructor
|
||||
//
|
||||
TTextControl (BRect, const char *, const char *,
|
||||
const char *, BMessage *);
|
||||
~TTextControl ();
|
||||
|
||||
//
|
||||
// public member functions.
|
||||
//
|
||||
void ModifiedText (int);
|
||||
int IsModified (void);
|
||||
|
||||
private:
|
||||
//
|
||||
// Data member.
|
||||
//
|
||||
int mModified;
|
||||
|
||||
};
|
||||
|
||||
#endif /* TTEXT_CTL_H_INCLUDED */
|
850
src/apps/terminal/MYOB/TermApp.cpp
Normal file
850
src/apps/terminal/MYOB/TermApp.cpp
Normal file
@ -0,0 +1,850 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <bsd_mem.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <storage/Path.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Roster.h>
|
||||
#include <Alert.h>
|
||||
#include <Screen.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "TermApp.h"
|
||||
#include "TermWindow.h"
|
||||
#include "TermConst.h"
|
||||
#include "spawn.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "CodeConv.h"
|
||||
|
||||
extern PrefHandler *gTermPref; /* Preference temporary */
|
||||
extern char gWindowName[];
|
||||
|
||||
bool usage_requested = false;
|
||||
bool geometry_requested = false;
|
||||
bool color_requested = false;
|
||||
|
||||
/* function prototype. */
|
||||
int argmatch (char **, int, char *, char *, int, char **, int *);
|
||||
void sort_args (int, char **);
|
||||
int text_to_rgb (char *, rgb_color *, char *);
|
||||
|
||||
// message
|
||||
const ulong MSG_ACTIVATE_TERM = 'msat';
|
||||
const ulong MSG_TERM_IS_MINIMIZE = 'mtim';
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermApp::TermApp (void)
|
||||
:BApplication( TERM_SIGNATURE )
|
||||
{
|
||||
|
||||
BList teams;
|
||||
|
||||
be_roster->GetAppList(TERM_SIGNATURE, &teams);
|
||||
int window_num = teams.CountItems();
|
||||
|
||||
int i = window_num / 16;
|
||||
int j = window_num % 16;
|
||||
|
||||
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 ();
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermApp::~TermApp (void)
|
||||
{
|
||||
/* delete (gTermPref); */
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Startup preference settings.
|
||||
*/
|
||||
const prefDefaults termDefaults[] ={
|
||||
{ PREF_COLS, "80" },
|
||||
{ PREF_ROWS, "25" },
|
||||
|
||||
{ PREF_HALF_FONT_FAMILY, "Courier10 BT" },
|
||||
{ PREF_HALF_FONT_SIZE, "12" },
|
||||
{ PREF_FULL_FONT_FAMILY, "Haru Tohaba" },
|
||||
{ PREF_FULL_FONT_SIZE, "12" },
|
||||
|
||||
{ PREF_TEXT_FORE_COLOR, " 0, 0, 0" },
|
||||
{ PREF_TEXT_BACK_COLOR, "255, 255, 255" },
|
||||
{ PREF_SELECT_FORE_COLOR, "255, 255, 255" },
|
||||
{ PREF_SELECT_BACK_COLOR, " 0, 0, 0" },
|
||||
{ PREF_CURSOR_FORE_COLOR, "255, 255, 255" },
|
||||
{ PREF_CURSOR_BACK_COLOR, " 0, 0, 0" },
|
||||
|
||||
{ PREF_IM_FORE_COLOR, " 0, 0, 0" },
|
||||
{ PREF_IM_BACK_COLOR, "152, 203, 255" },
|
||||
{ PREF_IM_SELECT_COLOR, "255, 152, 152" },
|
||||
|
||||
{ PREF_SHELL, "/bin/sh -login" },
|
||||
{ PREF_HISTORY_SIZE, "500" },
|
||||
|
||||
{ PREF_TEXT_ENCODING, "UTF-8" },
|
||||
|
||||
{ PREF_SELECT_MBUTTON, "Button 1"},
|
||||
{ PREF_PASTE_MBUTTON, "Button 2"},
|
||||
{ PREF_SUBMENU_MBUTTON, "Button 3"},
|
||||
{ PREF_MOUSE_IMAGE, "Hand cursor"},
|
||||
{ PREF_DRAGN_COPY, "0"},
|
||||
|
||||
{ PREF_GUI_LANGUAGE, "English"},
|
||||
{ PREF_IM_AWARE, "0"},
|
||||
{ NULL, NULL},
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::ReadyToRun (void)
|
||||
{
|
||||
//Prevent opeing window when option -h is given.
|
||||
if (usage_requested) return;
|
||||
|
||||
const char *command = NULL;
|
||||
const char *encoding;
|
||||
int rows, cols;
|
||||
|
||||
// gTermPref is not empty when App opened by pref file
|
||||
if (gTermPref->IsEmpty()){
|
||||
gTermPref->OpenText(TERM_PREF, termDefaults);
|
||||
}
|
||||
|
||||
encoding = gTermPref->getString (PREF_TEXT_ENCODING);
|
||||
|
||||
/* Get encoding name (setenv TTYPE in spawn_shell functions). */
|
||||
const etable *p = encoding_table;
|
||||
while (p->name) {
|
||||
if (!strcmp (p->name, encoding)) {
|
||||
encoding = p->shortname;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (CommandLine.Length() > 0){
|
||||
command = CommandLine.String();
|
||||
}else{
|
||||
command = gTermPref->getString (PREF_SHELL);
|
||||
}
|
||||
|
||||
if (geometry_requested) {
|
||||
gTermPref->setInt32 (PREF_ROWS, fRows);
|
||||
gTermPref->setInt32 (PREF_COLS, fCols);
|
||||
}
|
||||
|
||||
rows = gTermPref->getInt32 (PREF_ROWS);
|
||||
cols = gTermPref->getInt32 (PREF_COLS);
|
||||
|
||||
pfd = spawn_shell (rows, cols, command, encoding);
|
||||
|
||||
/* failed spawn, print stdout and open alert panel. */
|
||||
if (pfd == -1 ) {
|
||||
(new BAlert ("alert",
|
||||
"Terminal Error!!\nCan't execute shell.",
|
||||
"Abort", NULL, NULL,
|
||||
B_WIDTH_FROM_LABEL, B_INFO_ALERT))->Go(NULL);
|
||||
this->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
|
||||
MakeTermWindow (fTermFrame);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::Quit (void)
|
||||
{
|
||||
if(!usage_requested){
|
||||
int status;
|
||||
|
||||
kill (-sh_pid, SIGHUP);
|
||||
wait (&status);
|
||||
}
|
||||
|
||||
delete gTermPref;
|
||||
|
||||
BApplication::Quit();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// MessageReceived
|
||||
// Dispatches message.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::MessageReceived (BMessage* msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
case MENU_NEW_TREM:
|
||||
this->RunNewTerm ();
|
||||
break;
|
||||
|
||||
case MENU_SWITCH_TERM:
|
||||
this->SwitchTerm();
|
||||
break;
|
||||
|
||||
case MSG_ACTIVATE_TERM:
|
||||
fTermWindow->TermWinActivate();
|
||||
break;
|
||||
|
||||
case MSG_TERM_IS_MINIMIZE:
|
||||
{
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddBool("result", fTermWindow->IsMinimized());
|
||||
msg->SendReply(&reply);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BApplication::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct standard_args
|
||||
{
|
||||
char *name;
|
||||
char *longname;
|
||||
int priority;
|
||||
int nargs;
|
||||
const char *prefname;
|
||||
};
|
||||
|
||||
struct standard_args standard_args[] =
|
||||
{
|
||||
{ "-h", "--help", 90, 0, NULL },
|
||||
{ "-p", "--preference", 80, 1, NULL },
|
||||
{ "-t", "--title", 70, 1, NULL },
|
||||
{ "-geom", "--geometry", 50, 1, NULL },
|
||||
{ "-fg", "--text-fore-color", 40, 1, PREF_TEXT_FORE_COLOR },
|
||||
{ "-bg", "--text-back-color", 35, 1, PREF_TEXT_BACK_COLOR },
|
||||
{ "-curfg", "--cursor-fore-color", 30, 1, PREF_CURSOR_FORE_COLOR },
|
||||
{ "-curbg", "--cursor-back-color", 25, 1, PREF_CURSOR_BACK_COLOR },
|
||||
{ "-selfg", "--select-fore-color", 20, 1, PREF_SELECT_FORE_COLOR },
|
||||
{ "-selbg", "--select-back-color", 15, 1, PREF_SELECT_BACK_COLOR },
|
||||
{ "-imfg", "--im-fore-color", 10, 1, PREF_IM_FORE_COLOR },
|
||||
{ "-imbg", "--im-back-color", 5, 1, PREF_IM_BACK_COLOR },
|
||||
{ "-imsel", "--im-select-color", 0, 1, PREF_IM_SELECT_COLOR },
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ArgvReceived
|
||||
// terminal option '--help' view help screen */
|
||||
// checking args
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::ArgvReceived(int32 argc, char **argv)
|
||||
{
|
||||
int skip_args = 0;
|
||||
char *value = 0;
|
||||
rgb_color color;
|
||||
|
||||
if (argc > 1) {
|
||||
|
||||
sort_args (argc, argv);
|
||||
argc = 0;
|
||||
while (argv[argc]) argc++;
|
||||
|
||||
/* Print usage. */
|
||||
if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args)) {
|
||||
this->Usage (argv[0]);
|
||||
usage_requested = true;
|
||||
this->PostMessage (B_QUIT_REQUESTED);
|
||||
}
|
||||
|
||||
/* Load preference file. */
|
||||
if (argmatch (argv, argc, "-p", "--preference", 4, &value, &skip_args)) {
|
||||
gTermPref->OpenText(value);
|
||||
}
|
||||
|
||||
|
||||
/* Set window title. */
|
||||
if (argmatch (argv ,argc, "-t", "--title", 3, &value, &skip_args)) {
|
||||
strcpy (gWindowName, value);
|
||||
|
||||
}
|
||||
|
||||
/* Set window geometry. */
|
||||
if (argmatch (argv, argc, "-geom", "--geometry", 4, &value, &skip_args)) {
|
||||
int width, height, xpos, ypos;
|
||||
|
||||
sscanf (value, "%dx%d+%d+%d", &width, &height, &xpos, &ypos);
|
||||
if (width < 0 || height < 0 || xpos < 0 || ypos < 0 ||
|
||||
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;
|
||||
this->PostMessage (B_QUIT_REQUESTED);
|
||||
}
|
||||
fCols = width;
|
||||
fRows = height;
|
||||
fTermFrame.Set(xpos, ypos, xpos + 50, ypos + 50);
|
||||
geometry_requested = true;
|
||||
}
|
||||
|
||||
/* Open '/etc/rgb.txt' file. */
|
||||
BFile inFile;
|
||||
status_t sts;
|
||||
off_t size = 0;
|
||||
|
||||
sts = inFile.SetTo("/etc/rgb.txt", B_READ_ONLY);
|
||||
if (sts != B_OK) {
|
||||
fprintf (stderr, "%s: Can't open /etc/rgb.txt file.\n", argv[0]);
|
||||
usage_requested = true;
|
||||
this->PostMessage (B_QUIT_REQUESTED);
|
||||
}
|
||||
|
||||
inFile.GetSize (&size);
|
||||
char *buffer = new char [size];
|
||||
inFile.Read (buffer, size);
|
||||
|
||||
/* Set window, cursor, area and IM color. */
|
||||
for (int i = 4; i < 13; i++) {
|
||||
if (argmatch (argv, argc,
|
||||
standard_args[i].name,
|
||||
standard_args[i].longname,
|
||||
9, &value, &skip_args)) {
|
||||
|
||||
if (text_to_rgb (value, &color, buffer)) {
|
||||
if (gTermPref->IsEmpty()){
|
||||
gTermPref->OpenText(TERM_PREF, termDefaults);
|
||||
}
|
||||
gTermPref->setRGB (standard_args[i].prefname, color);
|
||||
}
|
||||
else {
|
||||
fprintf (stderr, "%s: invalid color string -- %s\n", argv[0], value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete buffer;
|
||||
|
||||
skip_args++;
|
||||
|
||||
if (skip_args < argc) {
|
||||
/* Check invalid options */
|
||||
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;
|
||||
this->PostMessage (B_QUIT_REQUESTED);
|
||||
}
|
||||
|
||||
CommandLine += argv[skip_args++];
|
||||
while (skip_args < argc) {
|
||||
CommandLine += ' ';
|
||||
CommandLine += argv[skip_args++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//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)
|
||||
{
|
||||
// Works Only Launced by Double-Click file, or Drags file to App.
|
||||
if (!(this->IsLaunching())){
|
||||
return;
|
||||
}
|
||||
|
||||
entry_ref ref;
|
||||
if ( message->FindRef("refs", 0, &ref) != B_OK )
|
||||
return;
|
||||
|
||||
BFile file;
|
||||
if ( file.SetTo(&ref, B_READ_WRITE) != B_OK )
|
||||
return;
|
||||
|
||||
BNodeInfo info(&file);
|
||||
char mimetype[B_MIME_TYPE_LENGTH];
|
||||
info.GetType(mimetype);
|
||||
|
||||
// if App opened by Pref file
|
||||
if (!strcmp(mimetype, PREFFILE_MIMETYPE)){
|
||||
BEntry ent(&ref);
|
||||
BPath path(&ent);
|
||||
gTermPref->OpenText(path.Path());
|
||||
return;
|
||||
}
|
||||
// if App opened by Shell Script
|
||||
if (!strcmp(mimetype, "text/x-haiku-shscript")){
|
||||
// Not implemented.
|
||||
// beep();
|
||||
return;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
TermApp::MakeTermWindow (BRect &frame)
|
||||
{
|
||||
|
||||
/* Create Window Object. */
|
||||
|
||||
fTermWindow = new TermWindow (frame);
|
||||
|
||||
fTermWindow->Show ();
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// RunNewTerm
|
||||
// Launch New Terminal.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::RunNewTerm (void)
|
||||
{
|
||||
be_roster->Launch (TERM_SIGNATURE);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ActivateTermWindow
|
||||
// Activate TermWindow (not Pref...)
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::ActivateTermWindow(team_id id)
|
||||
{
|
||||
BMessenger app(TERM_SIGNATURE, id);
|
||||
|
||||
if (app.IsTargetLocal()){
|
||||
fTermWindow->Activate();
|
||||
}else{
|
||||
app.SendMessage(MSG_ACTIVATE_TERM);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SwitchTerm
|
||||
// Switch to other running terminal
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermApp::SwitchTerm()
|
||||
{
|
||||
team_id myId = be_app->Team(); // My id
|
||||
BList teams;
|
||||
be_roster->GetAppList(TERM_SIGNATURE, &teams);
|
||||
int32 numTerms = teams.CountItems();
|
||||
if (numTerms <= 1 ) return; //Can't Switch !!
|
||||
|
||||
// Find posion of mine in app teams.
|
||||
int32 i;
|
||||
|
||||
for(i = 0; i < numTerms; i++){
|
||||
if(myId == reinterpret_cast<team_id>(teams.ItemAt(i))) break;
|
||||
}
|
||||
|
||||
do{
|
||||
if(--i < 0) i = numTerms - 1;
|
||||
}while(IsMinimize(reinterpret_cast<team_id>(teams.ItemAt(i))));
|
||||
|
||||
// Activare switched terminal.
|
||||
ActivateTermWindow(reinterpret_cast<team_id>(teams.ItemAt(i)));
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// IsMinimize
|
||||
// Check Specified Terminal Window is Minimized or not.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
TermApp::IsMinimize(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;
|
||||
|
||||
reply.FindBool("result", &hidden);
|
||||
|
||||
return hidden;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ShowHTML(const char *url)
|
||||
// show specified url by Netpositive.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//#ifndef B_NETPOSITIVE_APP_SIGNATURE
|
||||
//#define B_NETPOSITIVE_APP_SIGNATURE "application/x-vnd.Be-NPOS"
|
||||
//#endif
|
||||
//
|
||||
//void
|
||||
//TermApp::ShowHTML(BMessage *msg)
|
||||
//{
|
||||
// const char *url;
|
||||
// msg->FindString("Url", &url);
|
||||
// BMessage message;
|
||||
//
|
||||
// message.what = B_NETPOSITIVE_OPEN_URL;
|
||||
// message.AddString("be:url", url);
|
||||
|
||||
// be_roster->Launch(B_NETPOSITIVE_APP_SIGNATURE, &message);
|
||||
// while(!(be_roster->IsRunning(B_NETPOSITIVE_APP_SIGNATURE)))
|
||||
// snooze(10000);
|
||||
//
|
||||
// // Activate net+
|
||||
// be_roster->ActivateApp(be_roster->TeamFor(B_NETPOSITIVE_APP_SIGNATURE));
|
||||
//}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Usage
|
||||
// Display usage to stderr
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define PR(a) fprintf(stderr, a)
|
||||
void
|
||||
TermApp::Usage (char *name)
|
||||
{
|
||||
fprintf (stderr, "\n");
|
||||
fprintf (stderr, "Haiku Terminal\n");
|
||||
fprintf (stderr, "Copyright 2004 Haiku, Inc.\n");
|
||||
fprintf (stderr, "Parts Copyrigth (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");
|
||||
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");
|
||||
PR("\n");
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// text_to_rgb
|
||||
// Convert string to rgb_color structure.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
text_to_rgb (char *name, rgb_color *color, char *buffer)
|
||||
{
|
||||
if (name[0] != '#') {
|
||||
/* Convert from /etc/rgb.txt. */
|
||||
BString inStr (buffer);
|
||||
int32 point, offset = 0;
|
||||
|
||||
/* Search color name */
|
||||
do {
|
||||
point = inStr.FindFirst (name, offset);
|
||||
if (point < 0)
|
||||
return false;
|
||||
offset = point + 1;
|
||||
} while (*(buffer + point -1) != '\t');
|
||||
|
||||
char *p = buffer + point;
|
||||
|
||||
while (*p != '\n') p--;
|
||||
p++;
|
||||
|
||||
if (sscanf (p, "%d %d %d",
|
||||
(int *)&color->red,
|
||||
(int *)&color->green,
|
||||
(int *)&color->blue) == EOF)
|
||||
return false;
|
||||
color->alpha = 0;
|
||||
}
|
||||
else if (name[0] == '#') {
|
||||
/* Convert from #RRGGBB format */
|
||||
sscanf (name, "#%2x%2x%2x",
|
||||
(int *)&color->red,
|
||||
(int *)&color->green,
|
||||
(int *)&color->blue);
|
||||
color->alpha = 0;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// argmatch
|
||||
// This routine copy from GNU Emacs.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
argmatch (char **argv, int argc, char *sstr, char *lstr,
|
||||
int minlen, char **valptr, int *skipptr)
|
||||
{
|
||||
char *p = 0;
|
||||
int arglen;
|
||||
char *arg;
|
||||
|
||||
/* Don't access argv[argc]; give up in advance. */
|
||||
if (argc <= *skipptr + 1)
|
||||
return 0;
|
||||
|
||||
arg = argv[*skipptr+1];
|
||||
if (arg == NULL)
|
||||
return 0;
|
||||
if (strcmp (arg, sstr) == 0)
|
||||
{
|
||||
if (valptr != NULL)
|
||||
{
|
||||
*valptr = argv[*skipptr+2];
|
||||
*skipptr += 2;
|
||||
}
|
||||
else
|
||||
*skipptr += 1;
|
||||
return 1;
|
||||
}
|
||||
arglen = (valptr != NULL && (p = index (arg, '=')) != NULL
|
||||
? p - arg : strlen (arg));
|
||||
if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
|
||||
return 0;
|
||||
else if (valptr == NULL)
|
||||
{
|
||||
*skipptr += 1;
|
||||
return 1;
|
||||
}
|
||||
else if (p != NULL)
|
||||
{
|
||||
*valptr = p+1;
|
||||
*skipptr += 1;
|
||||
return 1;
|
||||
}
|
||||
else if (argv[*skipptr+2] != NULL)
|
||||
{
|
||||
*valptr = argv[*skipptr+2];
|
||||
*skipptr += 2;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// sort_args
|
||||
// This routine copy from GNU Emacs.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
sort_args (int argc, char **argv)
|
||||
{
|
||||
char **newargv = (char **) malloc (sizeof (char *) * argc);
|
||||
/* For each element of argv,
|
||||
the corresponding element of options is:
|
||||
0 for an option that takes no arguments,
|
||||
1 for an option that takes one argument, etc.
|
||||
-1 for an ordinary non-option argument. */
|
||||
int *options = (int *) malloc (sizeof (int) * argc);
|
||||
int *priority = (int *) malloc (sizeof (int) * argc);
|
||||
int to = 1;
|
||||
int incoming_used = 1;
|
||||
int from;
|
||||
int i;
|
||||
//int end_of_options = argc;
|
||||
|
||||
/* Categorize all the options,
|
||||
and figure out which argv elts are option arguments. */
|
||||
for (from = 1; from < argc; from++)
|
||||
{
|
||||
options[from] = -1;
|
||||
priority[from] = 0;
|
||||
if (argv[from][0] == '-')
|
||||
{
|
||||
int match, thislen;
|
||||
char *equals;
|
||||
|
||||
/* If we have found "--", don't consider
|
||||
any more arguments as options. */
|
||||
if (argv[from][1] == '-' && argv[from][2] == 0)
|
||||
{
|
||||
/* Leave the "--", and everything following it, at the end. */
|
||||
for (; from < argc; from++)
|
||||
{
|
||||
priority[from] = -100;
|
||||
options[from] = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Look for a match with a known old-fashioned option. */
|
||||
for (i = 0;
|
||||
i < (int)(sizeof (standard_args) / sizeof (standard_args[0]));
|
||||
i++)
|
||||
if (!strcmp (argv[from], standard_args[i].name))
|
||||
{
|
||||
options[from] = standard_args[i].nargs;
|
||||
priority[from] = standard_args[i].priority;
|
||||
if (from + standard_args[i].nargs >= argc)
|
||||
fprintf (stderr, "Option `%s' requires an argument\n", argv[from]);
|
||||
from += standard_args[i].nargs;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Look for a match with a known long option.
|
||||
MATCH is -1 if no match so far, -2 if two or more matches so far,
|
||||
>= 0 (the table index of the match) if just one match so far. */
|
||||
if (argv[from][1] == '-')
|
||||
{
|
||||
match = -1;
|
||||
thislen = strlen (argv[from]);
|
||||
equals = index (argv[from], '=');
|
||||
if (equals != 0)
|
||||
thislen = equals - argv[from];
|
||||
|
||||
for (i = 0;
|
||||
i < (int )(sizeof (standard_args) / sizeof (standard_args[0]));
|
||||
i++)
|
||||
if (standard_args[i].longname
|
||||
&& !strncmp (argv[from], standard_args[i].longname,
|
||||
thislen))
|
||||
{
|
||||
if (match == -1)
|
||||
match = i;
|
||||
else
|
||||
match = -2;
|
||||
}
|
||||
|
||||
/* If we found exactly one match, use that. */
|
||||
if (match >= 0)
|
||||
{
|
||||
options[from] = standard_args[match].nargs;
|
||||
priority[from] = standard_args[match].priority;
|
||||
/* If --OPTION=VALUE syntax is used,
|
||||
this option uses just one argv element. */
|
||||
if (equals != 0)
|
||||
options[from] = 0;
|
||||
if (from + options[from] >= argc)
|
||||
fprintf (stderr, "Option `%s' requires an argument\n", argv[from]);
|
||||
from += options[from];
|
||||
}
|
||||
}
|
||||
done: ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the arguments, in order of decreasing priority, to NEW. */
|
||||
newargv[0] = argv[0];
|
||||
while (incoming_used < argc)
|
||||
{
|
||||
int best = -1;
|
||||
int best_priority = -9999;
|
||||
|
||||
/* Find the highest priority remaining option.
|
||||
If several have equal priority, take the first of them. */
|
||||
for (from = 1; from < argc; from++)
|
||||
{
|
||||
if (argv[from] != 0 && priority[from] > best_priority)
|
||||
{
|
||||
best_priority = priority[from];
|
||||
best = from;
|
||||
}
|
||||
/* Skip option arguments--they are tied to the options. */
|
||||
if (options[from] > 0)
|
||||
from += options[from];
|
||||
}
|
||||
|
||||
if (best < 0)
|
||||
abort ();
|
||||
|
||||
/* Copy the highest priority remaining option, with its args, to NEW.
|
||||
Unless it is a duplicate of the previous one. */
|
||||
if (! (options[best] == 0
|
||||
&& ! strcmp (newargv[to - 1], argv[best])))
|
||||
{
|
||||
newargv[to++] = argv[best];
|
||||
for (i = 0; i < options[best]; i++)
|
||||
newargv[to++] = argv[best + i + 1];
|
||||
}
|
||||
|
||||
incoming_used += 1 + (options[best] > 0 ? options[best] : 0);
|
||||
|
||||
/* Clear out this option in ARGV. */
|
||||
argv[best] = 0;
|
||||
for (i = 0; i < options[best]; i++)
|
||||
argv[best + i + 1] = 0;
|
||||
}
|
||||
|
||||
/* If duplicate options were deleted, fill up extra space with null ptrs. */
|
||||
while (to < argc)
|
||||
newargv[to++] = 0;
|
||||
|
||||
bcopy (newargv, argv, sizeof (char *) * argc);
|
||||
|
||||
free (options);
|
||||
free (newargv);
|
||||
free (priority);
|
||||
}
|
88
src/apps/terminal/MYOB/TermApp.h
Normal file
88
src/apps/terminal/MYOB/TermApp.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TERMAPP_H
|
||||
#define TERMAPP_H
|
||||
|
||||
#include <app/Application.h>
|
||||
#include <String.h>
|
||||
|
||||
extern int pfd;
|
||||
extern char *ptyname;
|
||||
|
||||
class TermWindow;
|
||||
class TermParse;
|
||||
class BRect;
|
||||
class AboutDlg;
|
||||
|
||||
class TermApp : public BApplication
|
||||
{
|
||||
public:
|
||||
TermApp (void);
|
||||
~TermApp (void);
|
||||
|
||||
private:
|
||||
/*
|
||||
* Hook functions
|
||||
*/
|
||||
void ReadyToRun (void);
|
||||
void Quit (void);
|
||||
void MessageReceived (BMessage* msg);
|
||||
void RefsReceived(BMessage *message);
|
||||
void ArgvReceived(int32 argc, char **argv);
|
||||
|
||||
/*
|
||||
* Public Member functions.
|
||||
*/
|
||||
void MakeTermWindow (BRect &frame);
|
||||
void RunNewTerm (void);
|
||||
void SwitchTerm(void);
|
||||
void ActivateTermWindow(team_id id);
|
||||
|
||||
void Usage(char *name);
|
||||
|
||||
private:
|
||||
bool IsMinimize (team_id);
|
||||
|
||||
int fRows, fCols, fXpos, fYpos;
|
||||
rgb_color fFg, fBg, fCurFg, fCurBg, fSelFg, fSelbg;
|
||||
rgb_color fImfg, fImbg, fImSel;
|
||||
|
||||
TermWindow *fTermWindow;
|
||||
TermParse *fTermParse;
|
||||
BRect fTermFrame;
|
||||
AboutDlg *fAboutPanel;
|
||||
|
||||
BString CommandLine;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
82
src/apps/terminal/MYOB/TermBaseView.cpp
Normal file
82
src/apps/terminal/MYOB/TermBaseView.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 "TermBaseView.h"
|
||||
#include "TermView.h"
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* CONSTRUCTOR and DESTRUCTOR
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// TermBaseView ()
|
||||
// Constructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermBaseView::TermBaseView (BRect frame, TermView *inTermView)
|
||||
:BView (frame, "baseview", B_FOLLOW_ALL_SIDES,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS)
|
||||
{
|
||||
|
||||
fTermView = inTermView;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ~TermBaseView ()
|
||||
// Destructor.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermBaseView::~TermBaseView ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* PUBLIC MEMBER FUNCTIONS.
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// FrameResized (float, float)
|
||||
// Dispatch frame resize event.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBaseView::FrameResized (float width, float height)
|
||||
{
|
||||
int font_width, font_height;
|
||||
int cols, rows;
|
||||
|
||||
fTermView->GetFontInfo (&font_width, &font_height);
|
||||
|
||||
cols = (int)(width - VIEW_OFFSET * 2) / font_width;
|
||||
rows = (int)(height - VIEW_OFFSET * 2)/ font_height;
|
||||
|
||||
fTermView->ResizeTo (cols * font_width - 1, rows * font_height - 1);
|
||||
|
||||
}
|
46
src/apps/terminal/MYOB/TermBaseView.h
Normal file
46
src/apps/terminal/MYOB/TermBaseView.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* Hey Emacs, this file is -*- c++ -*-
|
||||
|
||||
Multilingual Terminal Emulator "MuTerminal".
|
||||
|
||||
Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. ALL RIGHT RESERVED
|
||||
|
||||
This file is part of MuTerminal.
|
||||
|
||||
MuTerminal is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
TermBaseView.h,v 2.3 1999/10/13 15:00:59 kaz Exp
|
||||
TermBaseView.h,v: Interface for BView sub class.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TERMBASEVIEW_H_INCLUDED
|
||||
#define TERMBASEVIEW_H_INCLUDED
|
||||
#include <View.h>
|
||||
|
||||
class TermView;
|
||||
|
||||
class TermBaseView : public BView
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Constructor and Desctructor
|
||||
//
|
||||
TermBaseView (BRect frame, TermView *);
|
||||
~TermBaseView ();
|
||||
|
||||
private:
|
||||
//
|
||||
// Hook Functions.
|
||||
//
|
||||
void SetBaseColor (rgb_color);
|
||||
|
||||
void FrameResized (float, float);
|
||||
|
||||
TermView *fTermView;
|
||||
|
||||
};
|
||||
|
||||
#endif /* TERMBASEVIEW_H_INCLUDED */
|
647
src/apps/terminal/MYOB/TermBuffer.cpp
Normal file
647
src/apps/terminal/MYOB/TermBuffer.cpp
Normal file
@ -0,0 +1,647 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
MuTerminal Internal Buffer Format.
|
||||
|
||||
a. 4bytes character buffer.
|
||||
|
||||
3bytes character buffer (UTF8).
|
||||
1byte status buffer.
|
||||
|
||||
b. 2bytes extended buffer.
|
||||
|
||||
2byte attribute buffer.
|
||||
|
||||
< attribute buffer> <------- character buffer -------->
|
||||
WBURMfbF rrfffbbb / ssssssss 11111111 22222222 33333333
|
||||
|||||||| || | | | | | |
|
||||
|||||||| || | | status utf8 1st utf8 2nd utf8 3rd
|
||||
|||||||| || | |
|
||||
|||||||| || | \--> background color
|
||||
|||||||| || \-----> foreground color
|
||||
|||||||| |\-------> dumped CR
|
||||
|||||||| \--------> Reserve
|
||||
||||||||
|
||||
||||||||
|
||||
|||||||\----------> Font information (Not use)
|
||||
||||||\-----------> background color flag
|
||||
|||||\------------> foreground color flag
|
||||
||||\-------------> mouse selected
|
||||
|||\--------------> reverse attr
|
||||
||\---------------> underline attr
|
||||
|\----------------> bold attr
|
||||
\-----------------> character width
|
||||
|
||||
c. 2byte status buffer.
|
||||
|
||||
0x00 (A_CHAR): character available.
|
||||
0x01 (NO_CHAR): buffer is empty.
|
||||
0xFF (IN_STRING): before buffer is full width character (never draw).
|
||||
|
||||
**Language environment. (Not impliment)
|
||||
|
||||
--- half width character set ---
|
||||
0 ... Wesern (Latin1 / ISO-8859-1, MacRoman)
|
||||
1 ... Central European(Latin2 / ISO-8859-2)
|
||||
2 ... Turkish (Latin3 / ISO-8859-3)
|
||||
3 ... Baltic (Latin4 / ISO-8859-4)
|
||||
4 ... Cyrillic (Cyrillic / ISO-8859-5)
|
||||
5 ... Greek (Greek / ISO-8859-7)
|
||||
6 ... Trukish (Latin5 / ISO-8859-9)
|
||||
|
||||
--- full width character set ---
|
||||
7 ... Japanese (EUC, SJIS, ISO-2022-jp / JIS X 0201, 0208, 0212)
|
||||
8 ... Chinese (Big5, EUC-tw, ISO-2022-cn / GB2312, CNS-11643-1...7)
|
||||
9 ... Korean (EUC-kr, ISO-2022-kr / KS C 5601)
|
||||
|
||||
--- Universal character set ---
|
||||
10 ... Unicode (UTF8)
|
||||
|
||||
* Varriables is set CodeConv class.
|
||||
* Unicode character width sets CodeConv::UTF8FontWidth member.
|
||||
|
||||
JIS X 0201 (half width kana ideograph) character use 1 column,
|
||||
but it font is full width font on preference panel.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <bsd_mem.h>
|
||||
|
||||
#include "TermBuffer.h"
|
||||
#include "TermConst.h"
|
||||
#include "CurPos.h"
|
||||
#include "PrefHandler.h"
|
||||
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TermBuffer class
|
||||
// Constructor and Destructor.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermBuffer::TermBuffer(int rows, int cols)
|
||||
{
|
||||
mColSize = MAX_COLS;
|
||||
mNowColSize = cols;
|
||||
mRowSize = rows;
|
||||
|
||||
mRowOffset = 0;
|
||||
|
||||
//buffer_size = ARRAY_SIZE;
|
||||
buffer_size = gTermPref->getInt32 (PREF_HISTORY_SIZE);
|
||||
|
||||
/* Allocate buffer */
|
||||
mBase = (term_buffer**) malloc (sizeof (term_buffer*) * buffer_size);
|
||||
|
||||
for(int i = 0; i < buffer_size; i++){
|
||||
mBase[i] = (term_buffer *) calloc (mColSize + 1, sizeof (term_buffer));
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// TermBuffer Destructer.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermBuffer::~TermBuffer()
|
||||
{
|
||||
for(int i = 0; i < buffer_size; i++){
|
||||
free (mBase[i]);
|
||||
}
|
||||
|
||||
free(mBase);
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// int GetChar (row, col, *buf, attr)
|
||||
// Get chracter from TermBuffer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/* This function moved to header file for effeciency */
|
||||
int
|
||||
TermBuffer::GetChar (int row, int col, uchar *buf, ushort *attr)
|
||||
{
|
||||
term_buffer *ptr;
|
||||
|
||||
ptr = (mBase[row % buffer_size] + col);
|
||||
|
||||
if (ptr->status == A_CHAR)
|
||||
memcpy (buf, (char *)(ptr->code), 4);
|
||||
|
||||
*attr = ptr->attr;
|
||||
|
||||
return ptr->status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// int GetString (row, col, *buf, attr)
|
||||
// Get String (length = num) from given position.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
TermBuffer::GetString (int row, int col, int num,
|
||||
uchar *buf, ushort *attr)
|
||||
{
|
||||
int count = 0, all_count = 0;
|
||||
term_buffer *ptr;
|
||||
|
||||
ptr = (mBase[row % buffer_size]);
|
||||
ptr += col;
|
||||
*attr = ptr->attr;
|
||||
|
||||
if (ptr->status == NO_CHAR) {
|
||||
/*
|
||||
* Buffer is empty and No selected by mouse.
|
||||
*/
|
||||
do {
|
||||
if (col >= mNowColSize) return -1;
|
||||
|
||||
col++;
|
||||
ptr++;
|
||||
count--;
|
||||
if (ptr->status == A_CHAR)
|
||||
return count;
|
||||
|
||||
if (mSelStart.y == row) {
|
||||
if (col == mSelStart.x)
|
||||
return count;
|
||||
}
|
||||
if (mSelEnd.y == row) {
|
||||
if (col - 1 == mSelEnd.x)
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
}while (col <= num);
|
||||
return count;
|
||||
}
|
||||
else if (IS_WIDTH(ptr->attr)) {
|
||||
memcpy (buf, (char *)ptr->code, 4);
|
||||
return 2;
|
||||
}
|
||||
|
||||
while (col <= num) {
|
||||
memcpy (buf, ptr->code, 4);
|
||||
all_count++;
|
||||
|
||||
if (*buf == 0) {
|
||||
*buf = ' ';
|
||||
*(buf + 1) = '\0';
|
||||
}
|
||||
if (ptr->attr != (ptr + 1)->attr){
|
||||
return all_count;
|
||||
}
|
||||
|
||||
buf = (uchar *)index ((char *)buf, 0x00);
|
||||
ptr++;
|
||||
col++;
|
||||
|
||||
if (mSelStart.y == row) {
|
||||
if (col == mSelStart.x)
|
||||
return all_count;
|
||||
}
|
||||
if (mSelEnd.y == row) {
|
||||
if (col - 1 == mSelEnd.x)
|
||||
return all_count;
|
||||
}
|
||||
}
|
||||
|
||||
return all_count;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// void WriteChar (const CurPos &, const uchar *, ushort)
|
||||
// Write character at cursor point.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::WriteChar (const CurPos &pos, const uchar *u, ushort attr)
|
||||
{
|
||||
term_buffer *ptr;
|
||||
|
||||
const int row = pos.y;
|
||||
const int col = pos.x;
|
||||
|
||||
ptr = (mBase[ROW(row)] + col);
|
||||
memcpy ((char *)ptr->code, u, 4);
|
||||
if (IS_WIDTH(attr))
|
||||
(ptr + 1)->status = IN_STRING;
|
||||
|
||||
ptr->status = A_CHAR;
|
||||
ptr->attr = attr;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// void WriteCR (const CurPos &)
|
||||
// Write CR status to buffer attribute.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::WriteCR (const CurPos &pos)
|
||||
{
|
||||
int row = pos.y;
|
||||
int col = pos.x;
|
||||
|
||||
term_buffer *ptr = (mBase[ROW(row)] + col);
|
||||
ptr->attr |= DUMPCR;
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// InsertSpace (const CurPos &, int)
|
||||
// Insert num space at cursor point.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::InsertSpace (const CurPos &pos, int num)
|
||||
{
|
||||
const int row = pos.y;
|
||||
const int col = pos.x;
|
||||
|
||||
for (int i = mNowColSize - num; i >= col; i--) {
|
||||
*(mBase[ROW(row)] + i + num) = *(mBase[ROW(row)] + i);
|
||||
}
|
||||
|
||||
memset(mBase[ROW(row)] + col, 0, num * sizeof(term_buffer));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// void DeleteChar (const CurPos &, int)
|
||||
// Delete num character at cursor point.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::DeleteChar(const CurPos &pos, int num)
|
||||
{
|
||||
const int row = pos.y;
|
||||
const int col = pos.x;
|
||||
|
||||
term_buffer *ptr = mBase[ROW(row)];
|
||||
size_t movesize = mNowColSize - (col + num);
|
||||
|
||||
memmove (ptr + col, ptr + col + num, movesize * sizeof(term_buffer));
|
||||
memset (ptr + (mNowColSize - num), 0, num * sizeof(term_buffer));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// EraseBelow (const CurPos &)
|
||||
// Erase below character from cursor position.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::EraseBelow(const CurPos &pos)
|
||||
{
|
||||
const int row = pos.y;
|
||||
const int col = pos.x;
|
||||
|
||||
memset (mBase[ROW(row)] + col, 0, (mColSize - col ) * sizeof (term_buffer));
|
||||
|
||||
for (int i = row; i < mRowSize; i++)
|
||||
EraseLine (i);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ScrollRegion (int, int, int, int)
|
||||
// Scroll terminal buffer region.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::ScrollRegion(int top, int bot, int dir, int num)
|
||||
{
|
||||
|
||||
if(dir == SCRUP){
|
||||
for(int i = 0; i < num; i++){
|
||||
|
||||
term_buffer *ptr = mBase[ROW(top)];
|
||||
|
||||
for(int j = top; j < bot; j++){
|
||||
mBase[ROW(j)] = mBase[ROW(j+1)];
|
||||
}
|
||||
mBase[ROW(bot)] = ptr;
|
||||
|
||||
EraseLine(bot);
|
||||
}
|
||||
}else{
|
||||
// scroll up
|
||||
for(int i = 0; i < num; i++){
|
||||
term_buffer *ptr = mBase[ROW(bot)];
|
||||
|
||||
for(int j = bot; j > top; j--){
|
||||
mBase[ROW(j)] = mBase[ROW(j-1)];
|
||||
}
|
||||
mBase[ROW(top)] = ptr;
|
||||
|
||||
EraseLine(top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ScrollLine (void)
|
||||
// Scroll terminal buffer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::ScrollLine(void)
|
||||
{
|
||||
for (int i = mRowSize; i < mRowSize * 2; i++) {
|
||||
EraseLine (i);
|
||||
}
|
||||
|
||||
mRowOffset++;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ResizeTo (int, int, int)
|
||||
// Resize terminal buffer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::ResizeTo(int newRows, int newCols, int offset)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
if (newCols > mColSize) {
|
||||
for (i = 0; i < buffer_size; i++) {
|
||||
mBase[i] = (ulong *) realloc (mBase[i], sizeof(ulong) * newCols);
|
||||
base = mBase[i] + mColSize;
|
||||
for (j= 0; j < newCols - mColSize; j++) {
|
||||
*base++ = 0;
|
||||
}
|
||||
}
|
||||
mColSize = newCols;
|
||||
}
|
||||
#endif
|
||||
if ( newRows <= mRowSize) {
|
||||
for (i = newRows; i <= mRowSize; i++) {
|
||||
EraseLine (i);
|
||||
}
|
||||
} else {
|
||||
for (i = mRowSize; i <= newRows * 2; i++) {
|
||||
EraseLine (i);
|
||||
}
|
||||
}
|
||||
|
||||
mNowColSize = newCols;
|
||||
mRowOffset += offset;
|
||||
mRowSize = newRows;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GetArraySize (void)
|
||||
// Get buffer size.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int32
|
||||
TermBuffer::GetArraySize (void)
|
||||
{
|
||||
return buffer_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* PRIVATE MEMBER FUNCTIONS.
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// EraseLine (int)
|
||||
// Erase one column.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::EraseLine (int row)
|
||||
{
|
||||
memset (mBase[ROW(row)], 0, mColSize * sizeof (term_buffer));
|
||||
|
||||
return;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ClearAll()
|
||||
// Clear contents of TermBuffer.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::ClearAll (void)
|
||||
{
|
||||
for(int i = 0; i < buffer_size; i++){
|
||||
memset (mBase[i], 0, mColSize * sizeof (term_buffer));
|
||||
}
|
||||
mRowOffset = 0;
|
||||
this->DeSelect ();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Select()
|
||||
// Mark Text Selected to given range.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::Select(const CurPos &start, const CurPos &end)
|
||||
{
|
||||
|
||||
if (end < start) {
|
||||
mSelStart = end;
|
||||
mSelEnd = start;
|
||||
}
|
||||
else {
|
||||
mSelStart = start;
|
||||
mSelEnd = end;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DeSelect()
|
||||
// Mark Text UnSelected to given range.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::DeSelect (void)
|
||||
{
|
||||
|
||||
mSelStart.Set (-1, -1);
|
||||
mSelEnd.Set (-1, -1);
|
||||
return;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CheckSelectedRegion (CurPos &)
|
||||
// Check cursor position which be including selected area.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
TermBuffer::CheckSelectedRegion (const CurPos &pos)
|
||||
{
|
||||
|
||||
if (mSelStart.y == pos.y || mSelEnd.y == pos.y) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// FindWord (CurPos &, CurPos *, CurPos *)
|
||||
// Find word from TermBuffer
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
TermBuffer::FindWord(const CurPos &pos, CurPos *start, CurPos *end)
|
||||
{
|
||||
uchar buf[5];
|
||||
ushort attr;
|
||||
int x, y, start_x;
|
||||
|
||||
y = pos.y;
|
||||
|
||||
// Search start point
|
||||
for(x = pos.x - 1; x >= 0; x--){
|
||||
if((this->GetChar (y, x, buf, &attr) == NO_CHAR) || (*buf == ' ')){
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
start_x = x;
|
||||
|
||||
// Search end point
|
||||
for(x = pos.x; x < mColSize; x++){
|
||||
if((this->GetChar (y, x, buf, &attr) == NO_CHAR) || (*buf == ' ')){
|
||||
--x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (start_x > x) return false;
|
||||
|
||||
mSelStart.Set(start_x, y);
|
||||
if (start != NULL){
|
||||
start->Set(start_x, y);
|
||||
}
|
||||
|
||||
mSelEnd.Set(x, y);
|
||||
if (end != NULL){
|
||||
end->Set(x, y);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GetCharFromRegion (int, int, BString)
|
||||
// Get one character from selected region.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::GetCharFromRegion (int x, int y, BString &str)
|
||||
{
|
||||
uchar buf[5];
|
||||
ushort attr;
|
||||
int status;
|
||||
|
||||
status = GetChar(y, x, buf, &attr);
|
||||
|
||||
switch(status){
|
||||
case NO_CHAR:
|
||||
if (IS_CR (attr)) {
|
||||
str += '\n';
|
||||
} else {
|
||||
str += ' ';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IN_STRING:
|
||||
break;
|
||||
|
||||
default:
|
||||
str += (const char *)&buf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// AvoidWaste (BString str)
|
||||
// Delete useless char at end of line, and convert LF code.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
inline void
|
||||
TermBuffer::AvoidWaste (BString &str)
|
||||
{
|
||||
int32 len, point;
|
||||
|
||||
start:
|
||||
len = str.Length() - 1;
|
||||
point = str.FindLast (' ');
|
||||
|
||||
if (len > 0 && len == point) {
|
||||
str.RemoveLast (" ");
|
||||
goto start;
|
||||
}
|
||||
|
||||
// str += '\n';
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GetStringFromRegion (BString str)
|
||||
// Get string from selected region.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermBuffer::GetStringFromRegion(BString &str)
|
||||
{
|
||||
int y;
|
||||
|
||||
if(mSelStart.y == mSelEnd.y){
|
||||
y = mSelStart.y;
|
||||
for(int x = mSelStart.x ; x <= mSelEnd.x; x++){
|
||||
GetCharFromRegion (x, y, str);
|
||||
}
|
||||
}else{
|
||||
y = mSelStart.y;
|
||||
for(int x = mSelStart.x ; x < mNowColSize; x++){
|
||||
GetCharFromRegion (x, y, str);
|
||||
}
|
||||
AvoidWaste (str);
|
||||
|
||||
for(y = mSelStart.y + 1 ; y < mSelEnd.y; y++){
|
||||
for(int x = 0 ; x < mNowColSize; x++){
|
||||
GetCharFromRegion (x, y, str);
|
||||
}
|
||||
AvoidWaste (str);
|
||||
}
|
||||
y = mSelEnd.y;
|
||||
for(int x = 0 ; x <= mSelEnd.x; x++){
|
||||
GetCharFromRegion (x, y, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
137
src/apps/terminal/MYOB/TermBuffer.h
Normal file
137
src/apps/terminal/MYOB/TermBuffer.h
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef TERMBUFFER_H_INCLUDED
|
||||
#define TERMBUFFER_H_INCLUDED
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include "TermConst.h"
|
||||
#include "CurPos.h"
|
||||
|
||||
// Scroll direction
|
||||
const int array_up = 0;
|
||||
const int array_down = 1;
|
||||
|
||||
#define ARRAY_SIZE 512
|
||||
|
||||
#define MIN_COLS 10
|
||||
#define MAX_COLS 256
|
||||
|
||||
#define ROW(x) (((x) + mRowOffset) % buffer_size)
|
||||
|
||||
typedef struct term_buffer
|
||||
{
|
||||
uchar code[4];
|
||||
int16 attr;
|
||||
int16 status;
|
||||
} term_buffer;
|
||||
|
||||
class CurPos;
|
||||
class BString;
|
||||
|
||||
class TermBuffer
|
||||
{
|
||||
public:
|
||||
TermBuffer(int row, int col);
|
||||
~TermBuffer();
|
||||
|
||||
//
|
||||
// Get and Put charactor.
|
||||
//
|
||||
int GetChar (int row, int col, uchar *u, ushort *attr);
|
||||
|
||||
int GetString (int row, int col, int num, uchar *u, ushort *attr);
|
||||
void GetStringFromRegion (BString ©Str);
|
||||
|
||||
void WriteChar (const CurPos &pos, const uchar *u, ushort attr);
|
||||
void WriteCR (const CurPos &pos);
|
||||
void InsertSpace (const CurPos &pos, int num);
|
||||
|
||||
//
|
||||
// Delete Charactor.
|
||||
//
|
||||
void DeleteChar (const CurPos &pos, int num);
|
||||
void EraseBelow (const CurPos &pos);
|
||||
|
||||
//
|
||||
// Movement and Scroll buffer.
|
||||
//
|
||||
void ScrollRegion (int top, int bot, int dir, int num);
|
||||
void ScrollLine (void);
|
||||
|
||||
//
|
||||
// Resize buffer.
|
||||
//
|
||||
void ResizeTo(int newRows, int newCols, int offset);
|
||||
|
||||
//
|
||||
// Clear contents of TermBuffer.
|
||||
//
|
||||
void ClearAll (void);
|
||||
|
||||
// Set / Unset Selection
|
||||
void Select (const CurPos &start, const CurPos &end);
|
||||
void DeSelect (void);
|
||||
|
||||
int CheckSelectedRegion (const CurPos &pos);
|
||||
bool FindWord (const CurPos &pos, CurPos *start, CurPos *end);
|
||||
|
||||
void GetCharFromRegion (int x, int y, BString &str);
|
||||
void AvoidWaste (BString &str);
|
||||
|
||||
int32 GetArraySize (void);
|
||||
|
||||
/*
|
||||
* PRIVATE MEMBER FUNCTIONS.
|
||||
*/
|
||||
private:
|
||||
|
||||
//
|
||||
// Erase 1 column.
|
||||
//
|
||||
void EraseLine (int row);
|
||||
|
||||
/*
|
||||
* DATA MEMBER.
|
||||
*/
|
||||
term_buffer **mBase;
|
||||
|
||||
int mColSize;
|
||||
int mRowSize;
|
||||
int mNowColSize;
|
||||
int mRowOffset;
|
||||
|
||||
CurPos mSelStart;
|
||||
CurPos mSelEnd;
|
||||
|
||||
int buffer_size;
|
||||
|
||||
};
|
||||
|
||||
#endif //TERMARAY_H_INCLUDED
|
220
src/apps/terminal/MYOB/TermConst.h
Normal file
220
src/apps/terminal/MYOB/TermConst.h
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef TERMCONST_H_INCLUDED
|
||||
#define TERMCONST_H_INCLUDED
|
||||
|
||||
#ifndef NODEBUG
|
||||
#define MALLOC_DEBUG
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Application signature (Must same in Muterminal.rsrc)//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#define TERM_SIGNATURE "application/x-vnd.Haiku-Terminal"
|
||||
#define PREFFILE_MIMETYPE "text/x-terminal-pref"
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Message constants for menu items.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Menu Message.
|
||||
//
|
||||
const uint32 MENU_SWITCH_TERM = 'MSWT';
|
||||
const uint32 MENU_NEW_TREM = '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';
|
||||
const uint32 MENU_SHOW_GPL = 'Mgpl';
|
||||
const uint32 MENU_ENCODING = 'Menc';
|
||||
const uint32 MENU_PAGE_SETUP = 'Mpst';
|
||||
const uint32 MENU_PRINT = 'Mpnt';
|
||||
const uint32 MENU_FIND_STRING = 'Mfnd';
|
||||
const uint32 MENU_FIND_AGAIN = 'Mfag';
|
||||
const uint32 MENU_SHOW_COLOR = 'Mcol';
|
||||
const uint32 MENU_SHOW_ABOUT = 'MSab';
|
||||
|
||||
const uint32 M_GET_DEVICE_NUM = 'Mgdn';
|
||||
|
||||
// Message Runner.
|
||||
|
||||
const uint32 MSGRUN_CURSOR = 'Rcur';
|
||||
const uint32 MSGRUN_WINDOW = 'Rwin';
|
||||
|
||||
// Preference Message.
|
||||
//
|
||||
const ulong PSET__COLS = 'pcol';
|
||||
const ulong PSET__ROWS = 'prow';
|
||||
const ulong PSET__HFONT = 'phfn';
|
||||
const ulong PSET__FFONT = 'pffn';
|
||||
const ulong PSET__HFONT_SIZE = 'phfs';
|
||||
const ulong PSET__FFONT_SIZE = 'pffs';
|
||||
const ulong PSET_FORE_COLOR = 'pfcl';
|
||||
const ulong PSET_BACK_COLOR = 'pbcl';
|
||||
const ulong PSET__CODING = 'pcod';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Preference Read/Write Keys
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
const char * const PREF_HALF_FONT_FAMILY = "Half Font Famly";
|
||||
const char * const PREF_HALF_FONT_STYLE = "Half Font Style";
|
||||
const char * const PREF_HALF_FONT_SIZE = "Half Font Size";
|
||||
|
||||
const char * const PREF_FULL_FONT_FAMILY = "Full Font Famly";
|
||||
const char * const PREF_FULL_FONT_STYLE = "Full Font Style";
|
||||
const char * const PREF_FULL_FONT_SIZE = "Full Font Size";
|
||||
|
||||
const char * const PREF_TEXT_FORE_COLOR = "Text Foreground Color";
|
||||
const char * const PREF_TEXT_BACK_COLOR = "Text Background Color";
|
||||
const char * const PREF_SELECT_FORE_COLOR = "Selection Foreground Color";
|
||||
const char * const PREF_SELECT_BACK_COLOR = "Selection Background Color";
|
||||
const char * const PREF_CURSOR_FORE_COLOR = "Cursor Foreground Color";
|
||||
const char * const PREF_CURSOR_BACK_COLOR = "Cursor Background Color";
|
||||
|
||||
const char * const PREF_IM_FORE_COLOR = "IM Foreground Color";
|
||||
const char * const PREF_IM_BACK_COLOR = "IM Background Color";
|
||||
const char * const PREF_IM_SELECT_COLOR = "IM Selection Color";
|
||||
const char * const PREF_DRAGN_COPY = "Drag'n Copy";
|
||||
|
||||
const char * const PREF_HISTORY_SIZE = "Histry Size";
|
||||
const char * const PREF_CURSOR_BLINKING = "Cursor Blinking rate";
|
||||
|
||||
const char * const PREF_IM_AWARE = "Input Method Aware";
|
||||
const char * const PREF_MOUSE_IMAGE = "Cursor Image";
|
||||
|
||||
const char * const PREF_SELECT_MBUTTON = "Select Region Buttion";
|
||||
const char * const PREF_SUBMENU_MBUTTON = "Submenu Mouse Button";
|
||||
const char * const PREF_PASTE_MBUTTON = "Paste Mouse Button";
|
||||
|
||||
const char * const PREF_COLS = "Cols";
|
||||
const char * const PREF_ROWS = "Rows";
|
||||
const char * const PREF_SHELL = "Shell";
|
||||
|
||||
const char * const PREF_TEXT_ENCODING = "Text encoding";
|
||||
const char * const PREF_GUI_LANGUAGE = "Language";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Color type
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
enum {
|
||||
TEXT_FOREGROUND_COLOR,
|
||||
TEXT_BACKGROUND_COLOR,
|
||||
SELECTION_FOREGROUND_COLOR,
|
||||
SELECTION_BACKGROUND_COLOR
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Preference Folder and setting path
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#define PREF_FOLDER "/boot/home/config/settings/MuTerminal/"
|
||||
const char * const TERM_PREF = PREF_FOLDER "setting.mp";
|
||||
const char * const LOCALE_FILE_DEFAULT = PREF_FOLDER "menu/en";
|
||||
|
||||
const int32 DEFAULT = -1;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/* Font Width */
|
||||
const int HALF_WIDTH = 1;
|
||||
const int FULL_WIDTH = 2;
|
||||
|
||||
/* Scroll direction flag */
|
||||
enum{
|
||||
SCRUP,
|
||||
SCRDOWN
|
||||
};
|
||||
|
||||
/* Insert mode flag */
|
||||
#define MODE_OVER 0
|
||||
#define MODE_INSERT 1
|
||||
|
||||
const float VIEW_OFFSET = 3;
|
||||
|
||||
#define CURSOR_RECT \
|
||||
BRect r (fFontWidth * fCurPos.x, \
|
||||
fFontHeight * fCurPos.y + fTop, \
|
||||
fFontWidth * (fCurPos.x + 1) - 1, \
|
||||
fFontHeight * fCurPos.y + fTop + fCursorHeight - 1)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/* Define TermBuffer internal code */
|
||||
#define NO_CHAR 0x00
|
||||
#define A_CHAR 0x01
|
||||
#define IN_STRING 0xFF
|
||||
|
||||
/* TermBuffer extended attribute */
|
||||
#define A_WIDTH 0x8000
|
||||
#define BOLD 0x4000
|
||||
#define UNDERLINE 0x2000
|
||||
#define INVERSE 0x1000
|
||||
#define MOUSE 0x0800
|
||||
#define FORESET 0x0400
|
||||
#define BACKSET 0x0200
|
||||
#define FONT 0x0100
|
||||
#define RESERVE 0x0080
|
||||
#define DUMPCR 0x0040
|
||||
#define FORECOLOR 0x0038
|
||||
#define BACKCOLOR 0x0007
|
||||
|
||||
#define IS_WIDTH(x) (((x) & A_WIDTH) )
|
||||
#define IS_BOLD(x) (((x) & BOLD) )
|
||||
#define IS_UNDER(x) (((x) & UNDERLINE) )
|
||||
#define IS_INVERSE(x) (((x) & INVERSE) )
|
||||
#define IS_MOUSE(x) (((x) & MOUSE) )
|
||||
#define IS_FORESET(x) (((x) & FORESET) )
|
||||
#define IS_BACKSET(x) (((x) & BACKSET) )
|
||||
#define IS_FONT(x) (((x) & FONT) )
|
||||
#define IS_CR(x) (((x) & DUMPCR) )
|
||||
#define IS_FORECOLOR(x) (((x) & FORECOLOR) >> 3)
|
||||
#define IS_BACKCOLOR(x) (((x) & BACKCOLOR) )
|
||||
|
||||
#define FORECOLORED(x) ((x) << 3)
|
||||
#define BACKCOLORED(x) ((x) << 0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// TypeDefs
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
typedef unsigned short ushort;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x1;
|
||||
int y1;
|
||||
int x2;
|
||||
int y2;
|
||||
}
|
||||
sDrawRect;
|
||||
|
||||
|
||||
|
||||
#endif //TERMCONST_H_INCLUDED
|
852
src/apps/terminal/MYOB/TermParse.cpp
Normal file
852
src/apps/terminal/MYOB/TermParse.cpp
Normal file
@ -0,0 +1,852 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <app/Application.h>
|
||||
#include <support/Beep.h>
|
||||
#include <Message.h>
|
||||
#include <MessageRunner.h>
|
||||
|
||||
|
||||
#include "TermParse.h"
|
||||
#include "TermView.h"
|
||||
#include "VTparse.h"
|
||||
#include "TermConst.h"
|
||||
#include "CodeConv.h"
|
||||
|
||||
extern int pfd; // defined Muterminal.cpp
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// PtyReader ... Get character from pty device.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
int32
|
||||
TermParse::PtyReader (void *data)
|
||||
{
|
||||
int nread;
|
||||
uint read_p = 0;
|
||||
|
||||
TermParse *theObj = (TermParse *) data;
|
||||
|
||||
uchar buf [READ_BUF_SIZE];
|
||||
|
||||
while (theObj->fQuitting) {
|
||||
/*
|
||||
* If Pty Buffer nearly full, snooze this thread, and continue.
|
||||
*/
|
||||
if ((read_p - theObj->fParser_p) > READ_BUF_SIZE - 16) {
|
||||
theObj->fLockFlag = READ_BUF_SIZE / 2;
|
||||
acquire_sem (theObj->fReaderLocker);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read PTY.
|
||||
*/
|
||||
nread = read (pfd, buf,
|
||||
READ_BUF_SIZE - (read_p - theObj->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 >= left) {
|
||||
memcpy (theObj->fReadBuf + mod, buf, left);
|
||||
memcpy (theObj->fReadBuf, buf + left, nread - left);
|
||||
}
|
||||
else {
|
||||
memcpy (theObj->fReadBuf + mod, buf, nread);
|
||||
}
|
||||
read_p += nread;
|
||||
|
||||
/*
|
||||
* Release semaphore. Number of semaphore counter is nread.
|
||||
*/
|
||||
release_sem_etc (theObj->fReaderSem, nread, 0);
|
||||
|
||||
}
|
||||
theObj->fReaderThread = -1;
|
||||
exit_thread (B_OK);
|
||||
return B_OK;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetReaderBuf ... Get char pty reader buffer.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uchar
|
||||
TermParse::GetReaderBuf (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
switch (acquire_sem_etc (fReaderSem, 1, B_TIMEOUT, (bigtime_t)10000.0)) {
|
||||
case B_NO_ERROR:
|
||||
break;
|
||||
case B_TIMED_OUT:
|
||||
default:
|
||||
fViewObj->ScrollAtCursor();
|
||||
fViewObj->UpdateLine();
|
||||
|
||||
// Reset cursor blinking time and turn on cursor blinking.
|
||||
fCursorUpdate->SetInterval (1000000);
|
||||
fViewObj->SetCurDraw (CURON);
|
||||
|
||||
// wait new input from pty.
|
||||
acquire_sem (fReaderSem);
|
||||
break;
|
||||
}
|
||||
|
||||
c = fReadBuf[fParser_p % READ_BUF_SIZE];
|
||||
fParser_p++;
|
||||
/*
|
||||
* If PtyReader thread locked, decliment counter and unlock thread.
|
||||
*/
|
||||
if (fLockFlag != 0) {
|
||||
fLockFlag--;
|
||||
if (fLockFlag == 0) {
|
||||
release_sem (fReaderLocker);
|
||||
}
|
||||
}
|
||||
|
||||
fViewObj->SetCurDraw (CUROFF);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// InitTermParse ... Initialize and spawn EscParse thread.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
status_t
|
||||
TermParse::InitTermParse (TermView *inViewObj, CodeConv *inConvObj)
|
||||
{
|
||||
|
||||
fViewObj = inViewObj;
|
||||
fConvObj = inConvObj;
|
||||
|
||||
fCursorUpdate = new BMessageRunner (BMessenger (fViewObj),
|
||||
new BMessage (MSGRUN_CURSOR),
|
||||
1000000);
|
||||
|
||||
if (fParseThread < 0)
|
||||
fParseThread =
|
||||
spawn_thread (EscParse, "EscParse", B_DISPLAY_PRIORITY, this);
|
||||
else
|
||||
return B_BAD_THREAD_ID;
|
||||
|
||||
return (resume_thread ( fParseThread));
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// InitPtyReader ... Initialize and spawn PtyReader thread.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
thread_id
|
||||
TermParse::InitPtyReader (TermWindow *inWinObj)
|
||||
{
|
||||
|
||||
fWinObj = inWinObj;
|
||||
|
||||
if (fReaderThread < 0)
|
||||
fReaderThread =
|
||||
spawn_thread (PtyReader, "PtyReader", B_NORMAL_PRIORITY, this);
|
||||
else
|
||||
return B_BAD_THREAD_ID;
|
||||
|
||||
fReaderSem = create_sem (0, "pty_reader_sem");
|
||||
fReaderLocker = create_sem (0, "pty_locker_sem");
|
||||
|
||||
resume_thread (fReaderThread);
|
||||
|
||||
return (fReaderThread);
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructer and Destructer.
|
||||
*/
|
||||
|
||||
TermParse::TermParse (void)
|
||||
{
|
||||
|
||||
fParseThread = -1;
|
||||
fReaderThread = -1;
|
||||
fLockFlag = 0;
|
||||
fParser_p = 0;
|
||||
fQuitting = 1;
|
||||
|
||||
}
|
||||
|
||||
TermParse::~TermParse (void)
|
||||
{
|
||||
//status_t sts;
|
||||
|
||||
fQuitting = 0;
|
||||
kill_thread(fParseThread);
|
||||
|
||||
kill_thread(fReaderThread);
|
||||
delete_sem (fReaderSem);
|
||||
delete_sem (fReaderLocker);
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// EscParse ... Escape sequence parse and character encoding.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern int utf8_groundtable[]; /* UTF8 Ground table */
|
||||
extern int cs96_groundtable[]; /* CS96 Ground table */
|
||||
extern int iso8859_groundtable[]; /* ISO8859 & EUC Ground table */
|
||||
extern int sjis_groundtable[]; /* Shift-JIS Ground table */
|
||||
|
||||
extern int esctable[]; /* ESC */
|
||||
extern int csitable[]; /* ESC [ */
|
||||
extern int dectable[]; /* ESC [ ? */
|
||||
extern int scrtable[]; /* ESC # */
|
||||
extern int igntable[]; /* ignore table */
|
||||
extern int iestable[]; /* ignore ESC table */
|
||||
extern int eigtable[]; /* ESC ignore table */
|
||||
extern int mbcstable[]; /* ESC $ */
|
||||
|
||||
|
||||
/* MuTerminal coding system (global varriable) */
|
||||
int gNowCoding = M_UTF8;
|
||||
|
||||
#define DEFAULT -1
|
||||
#define NPARAM 10 // Max parameters
|
||||
|
||||
int32
|
||||
TermParse::EscParse (void *data)
|
||||
{
|
||||
int tmp;
|
||||
int top, bot;
|
||||
int cs96;
|
||||
uchar curess = 0;
|
||||
|
||||
TermParse *theObj = (TermParse *) data;
|
||||
|
||||
TermView *viewObj = theObj->fViewObj;
|
||||
CodeConv *convObj = theObj->fConvObj;
|
||||
|
||||
uchar cbuf[4], dstbuf[4];
|
||||
uchar *ptr;
|
||||
|
||||
int *parsestate, *groundtable;
|
||||
int now_coding = -1;
|
||||
|
||||
uchar c;
|
||||
ushort attr = BACKCOLOR;
|
||||
|
||||
int param[NPARAM];
|
||||
int nparam = 1;
|
||||
|
||||
int row, col;
|
||||
int width;
|
||||
|
||||
/* default coding system is UTF8 */
|
||||
groundtable = utf8_groundtable;
|
||||
parsestate = groundtable;
|
||||
|
||||
while (theObj->fQuitting) {
|
||||
c = theObj->GetReaderBuf ();
|
||||
|
||||
if (now_coding != gNowCoding) {
|
||||
/*
|
||||
* Change coding, change parse table.
|
||||
*/
|
||||
switch (gNowCoding) {
|
||||
case M_UTF8:
|
||||
groundtable = utf8_groundtable;
|
||||
break;
|
||||
case M_ISO_8859_1:
|
||||
case M_ISO_8859_2:
|
||||
case M_ISO_8859_3:
|
||||
case M_ISO_8859_4:
|
||||
case M_ISO_8859_5:
|
||||
case M_ISO_8859_6:
|
||||
case M_ISO_8859_7:
|
||||
case M_ISO_8859_8:
|
||||
case M_ISO_8859_9:
|
||||
case M_ISO_8859_10:
|
||||
groundtable = iso8859_groundtable;
|
||||
break;
|
||||
case M_SJIS:
|
||||
groundtable = sjis_groundtable;
|
||||
break;
|
||||
case M_EUC_JP:
|
||||
case M_EUC_KR:
|
||||
case M_ISO_2022_JP:
|
||||
groundtable = iso8859_groundtable;
|
||||
break;
|
||||
}
|
||||
parsestate = groundtable;
|
||||
now_coding = gNowCoding;
|
||||
}
|
||||
|
||||
switch (parsestate[c]) {
|
||||
|
||||
case CASE_PRINT:
|
||||
cbuf[0] = (uchar) c;
|
||||
cbuf[1] = '\0';
|
||||
width = HALF_WIDTH;
|
||||
viewObj->PutChar (cbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_PRINT_GR:
|
||||
/* case iso8859 gr character, or euc */
|
||||
ptr = cbuf;
|
||||
if (now_coding == M_EUC_JP || now_coding == M_EUC_KR ||
|
||||
now_coding == M_ISO_2022_JP) {
|
||||
|
||||
switch (parsestate[curess]) {
|
||||
case CASE_SS2: /* JIS X 0201 */
|
||||
*ptr++ = curess;
|
||||
*ptr++ = c;
|
||||
*ptr = 0;
|
||||
width = 1;
|
||||
curess = 0;
|
||||
break;
|
||||
|
||||
case CASE_SS3: /* JIS X 0212 */
|
||||
*ptr++ = curess;
|
||||
*ptr++ = c;
|
||||
*ptr++ = theObj->GetReaderBuf ();
|
||||
*ptr = 0;
|
||||
width = 2;
|
||||
curess = 0;
|
||||
break;
|
||||
|
||||
default: /* JIS X 0208 */
|
||||
*ptr++ = c;
|
||||
*ptr++ = theObj->GetReaderBuf ();
|
||||
*ptr = 0;
|
||||
width = 2;
|
||||
break;
|
||||
}
|
||||
} else { /* ISO-8859-1...10 and MacRoman */
|
||||
*ptr++ = c;
|
||||
*ptr = 0;
|
||||
width = 1;
|
||||
}
|
||||
if (now_coding != M_ISO_2022_JP) {
|
||||
convObj->ConvertToInternal (cbuf, dstbuf, now_coding);
|
||||
}
|
||||
else {
|
||||
convObj->ConvertToInternal (cbuf, dstbuf, M_EUC_JP);
|
||||
}
|
||||
|
||||
viewObj->PutChar (dstbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_PRINT_CS96:
|
||||
cbuf[0] = c | 0x80;
|
||||
cbuf[1] = theObj->GetReaderBuf() | 0x80;
|
||||
cbuf[2] = 0;
|
||||
width = 2;
|
||||
convObj->ConvertToInternal (cbuf, dstbuf, M_EUC_JP);
|
||||
viewObj->PutChar (dstbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_LF:
|
||||
viewObj->PutLF ();
|
||||
break;
|
||||
|
||||
case CASE_CR:
|
||||
viewObj->PutCR ();
|
||||
break;
|
||||
|
||||
case CASE_SJIS_KANA:
|
||||
cbuf[0] = (uchar) c;
|
||||
cbuf[1] = '\0';
|
||||
convObj->ConvertToInternal (cbuf, dstbuf, now_coding);
|
||||
width = 1;
|
||||
viewObj->PutChar (dstbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_SJIS_INSTRING:
|
||||
cbuf[0] = (uchar) c;
|
||||
cbuf[1] = theObj->GetReaderBuf ();
|
||||
cbuf[2] = '\0';
|
||||
convObj->ConvertToInternal (cbuf, dstbuf, now_coding);
|
||||
width = 2;
|
||||
viewObj->PutChar (dstbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_UTF8_2BYTE:
|
||||
cbuf[0] = (uchar) c;
|
||||
c =theObj->GetReaderBuf ();
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[1] = (uchar) c;
|
||||
cbuf[2] = '\0';
|
||||
width = convObj->UTF8GetFontWidth (cbuf);
|
||||
viewObj->PutChar (cbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_UTF8_3BYTE:
|
||||
cbuf[0] = (uchar) c;
|
||||
c =theObj->GetReaderBuf ();
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[1] = (uchar) c;
|
||||
|
||||
c =theObj->GetReaderBuf ();
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[2] = (uchar) c;
|
||||
|
||||
cbuf[3] = '\0';
|
||||
width = convObj->UTF8GetFontWidth (cbuf);
|
||||
viewObj->PutChar (cbuf, attr, width);
|
||||
break;
|
||||
|
||||
case CASE_MBCS:
|
||||
/* ESC $ */
|
||||
parsestate = mbcstable;
|
||||
break;
|
||||
|
||||
case CASE_GSETS:
|
||||
/* ESC $ ? */
|
||||
parsestate = cs96_groundtable;
|
||||
cs96 = 1;
|
||||
break;
|
||||
|
||||
case CASE_SCS_STATE:
|
||||
cs96 = 0;
|
||||
theObj->GetReaderBuf ();
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_GROUND_STATE:
|
||||
/* exit ignore mode */
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_BELL:
|
||||
beep();
|
||||
break;
|
||||
|
||||
case CASE_BS:
|
||||
viewObj->MoveCurLeft (1);
|
||||
break;
|
||||
|
||||
case CASE_TAB:
|
||||
tmp = viewObj->GetCurX ();
|
||||
tmp %= 8;
|
||||
viewObj->MoveCurRight (8-tmp);
|
||||
break;
|
||||
|
||||
case CASE_ESC:
|
||||
/* escape */
|
||||
parsestate = esctable;
|
||||
break;
|
||||
|
||||
case CASE_IGNORE_STATE:
|
||||
/* Ies: ignore anything else */
|
||||
parsestate = igntable;
|
||||
break;
|
||||
|
||||
case CASE_IGNORE_ESC:
|
||||
/* Ign: escape */
|
||||
parsestate = iestable;
|
||||
break;
|
||||
|
||||
case CASE_IGNORE:
|
||||
/* Ignore character */
|
||||
break;
|
||||
|
||||
case CASE_SI:
|
||||
break;
|
||||
|
||||
case CASE_SO:
|
||||
break;
|
||||
|
||||
case CASE_SCR_STATE: // ESC #
|
||||
/* enter scr state */
|
||||
parsestate = scrtable;
|
||||
break;
|
||||
|
||||
case CASE_ESC_IGNORE:
|
||||
/* unknown escape sequence */
|
||||
parsestate = eigtable;
|
||||
break;
|
||||
|
||||
case CASE_ESC_DIGIT: // ESC [ number
|
||||
/* digit in csi or dec mode */
|
||||
if((row = param[nparam - 1]) == DEFAULT)
|
||||
row = 0;
|
||||
param[nparam - 1] = 10 * row + (c - '0');
|
||||
break;
|
||||
|
||||
case CASE_ESC_SEMI: // ESC ;
|
||||
/* semicolon in csi or dec mode */
|
||||
if (nparam < NPARAM)
|
||||
param[nparam++] = DEFAULT;
|
||||
break;
|
||||
|
||||
case CASE_DEC_STATE:
|
||||
/* enter dec mode */
|
||||
parsestate = dectable;
|
||||
break;
|
||||
|
||||
case CASE_ICH: // ESC [@ insert charactor
|
||||
/* ICH */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->InsertSpace (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CUU: // ESC [A cursor up, up arrow key.
|
||||
/* CUU */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->MoveCurUp (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CUD: // ESC [B cursor down, down arrow key.
|
||||
/* CUD */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->MoveCurDown (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CUF: // ESC [C cursor forword
|
||||
/* CUF */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->MoveCurRight (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CUB: // ESC [D cursor backword
|
||||
/* CUB */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->MoveCurLeft (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CUP: // ESC [...H move cursor
|
||||
/* CUP | HVP */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
if(nparam < 2 || (col = param[1]) < 1)
|
||||
col = 1;
|
||||
|
||||
viewObj->SetCurPos (col - 1, row - 1 );
|
||||
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_ED: // ESC [ ...J clear screen
|
||||
/* ED */
|
||||
switch (param[0]) {
|
||||
case DEFAULT:
|
||||
case 0:
|
||||
viewObj->EraseBelow ();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
viewObj->SetCurPos (0, 0);
|
||||
viewObj->EraseBelow ();
|
||||
break;
|
||||
}
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_EL: // delete line
|
||||
/* EL */
|
||||
viewObj->DeleteColumns ();
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_IL:
|
||||
/* IL */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->PutNL (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DL:
|
||||
/* DL */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->DeleteLine (row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DCH:
|
||||
/* DCH */
|
||||
if((row = param[0]) < 1)
|
||||
row = 1;
|
||||
viewObj->DeleteChar(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_SET:
|
||||
/* SET */
|
||||
viewObj->SetInsertMode (MODE_INSERT);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_RST:
|
||||
/* RST */
|
||||
viewObj->SetInsertMode (MODE_OVER);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_SGR:
|
||||
/* SGR */
|
||||
for (row=0; row<nparam; ++row) {
|
||||
switch (param[row]) {
|
||||
case DEFAULT:
|
||||
case 0: /* Reset attribute */
|
||||
attr = 0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case 5: /* Bold */
|
||||
attr |= BOLD;
|
||||
break;
|
||||
|
||||
case 4: /* Underline */
|
||||
attr |= UNDERLINE;
|
||||
break;
|
||||
|
||||
case 7: /* Inverse */
|
||||
attr |= INVERSE;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
case 33:
|
||||
case 34:
|
||||
case 35:
|
||||
case 36:
|
||||
case 37:
|
||||
attr &= ~FORECOLOR;
|
||||
attr |= FORECOLORED(param[row] - 30);
|
||||
attr |= FORESET;
|
||||
break;
|
||||
|
||||
case 39:
|
||||
attr &= ~FORESET;
|
||||
break;
|
||||
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
attr &= ~BACKCOLOR;
|
||||
attr |= BACKCOLORED(param[row] - 40);
|
||||
attr |= BACKSET;
|
||||
break;
|
||||
|
||||
case 49:
|
||||
attr &= ~BACKSET;
|
||||
break;
|
||||
}
|
||||
}
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CPR:
|
||||
// Q & D hack by Y.Hayakawa (hida@sawada.riec.tohoku.ac.jp)
|
||||
// 21-JUL-99
|
||||
viewObj->DeviceStatusReport(param[0]) ;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DECSTBM:
|
||||
/* DECSTBM - set scrolling region */
|
||||
|
||||
if((top = param[0]) < 1)
|
||||
top = 1;
|
||||
|
||||
if(nparam < 2) {
|
||||
bot = -1;
|
||||
}
|
||||
else {
|
||||
bot = param[1];
|
||||
}
|
||||
|
||||
top--;
|
||||
bot --;
|
||||
|
||||
if (bot > top) {
|
||||
viewObj->SetScrollRegion (top, bot);
|
||||
}
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DECREQTPARM:
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DECSET:
|
||||
/* DECSET */
|
||||
// dpmodes(term, bitset);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DECRST:
|
||||
/* DECRST */
|
||||
// dpmodes(term, bitclr);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DECALN:
|
||||
/* DECALN */
|
||||
// if(screen->cursor_state)
|
||||
// HideCursor();
|
||||
// ScrnRefresh(screen, 0, 0, screen->max_row + 1,
|
||||
// screen->max_col + 1, False);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
// case CASE_GSETS:
|
||||
// screen->gsets[scstype] = GSET(c) | cs96;
|
||||
// parsestate = groundtable;
|
||||
// break;
|
||||
|
||||
case CASE_DECSC:
|
||||
/* DECSC */
|
||||
viewObj->SaveCursor ();
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_DECRC:
|
||||
/* DECRC */
|
||||
viewObj->RestoreCursor ();
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_HTS:
|
||||
/* HTS */
|
||||
// TabSet(term->tabs, screen->cur_col);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_RI:
|
||||
/* RI */
|
||||
viewObj->ScrollRegion (-1, -1, SCRDOWN, 1);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_SS2:
|
||||
/* SS2 */
|
||||
curess = c;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_SS3:
|
||||
/* SS3 */
|
||||
curess = c;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_CSI_STATE:
|
||||
/* enter csi state */
|
||||
nparam = 1;
|
||||
param[0] = DEFAULT;
|
||||
parsestate = csitable;
|
||||
break;
|
||||
|
||||
case CASE_OSC:
|
||||
/* Operating System Command: ESC ] */
|
||||
// do_osc(finput);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_RIS: // ESC c ... Reset terminal.
|
||||
break;
|
||||
|
||||
case CASE_LS2:
|
||||
/* LS2 */
|
||||
// screen->curgl = 2;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_LS3:
|
||||
/* LS3 */
|
||||
// screen->curgl = 3;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_LS3R:
|
||||
/* LS3R */
|
||||
// screen->curgr = 3;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_LS2R:
|
||||
/* LS2R */
|
||||
// screen->curgr = 2;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
case CASE_LS1R:
|
||||
/* LS1R */
|
||||
// screen->curgr = 1;
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
theObj->fParseThread = -1;
|
||||
exit_thread (B_OK);
|
||||
return B_OK;
|
||||
}
|
||||
|
97
src/apps/terminal/MYOB/TermParse.h
Normal file
97
src/apps/terminal/MYOB/TermParse.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TERMPARSE_H
|
||||
#define TERMPARSE_H
|
||||
|
||||
#include <kernel/OS.h>
|
||||
#include <MessageRunner.h>
|
||||
#include "TermConst.h"
|
||||
|
||||
class TermView;
|
||||
class CodeConv;
|
||||
class TermWindow;
|
||||
|
||||
//PtyReader buffer size.
|
||||
#define READ_BUF_SIZE 2048
|
||||
|
||||
class TermParse : public BHandler
|
||||
{
|
||||
public:
|
||||
TermParse (void);
|
||||
~TermParse (void);
|
||||
|
||||
// Initialize TermParse and PtyReader thread.
|
||||
status_t InitTermParse (TermView *inViewObj, CodeConv *inConvObj);
|
||||
thread_id InitPtyReader (TermWindow *inWinObj);
|
||||
|
||||
// Delete TermParse and PtyReader thread.
|
||||
status_t AbortTermParse (void);
|
||||
status_t AbortPtyReader (void);
|
||||
|
||||
|
||||
private:
|
||||
//
|
||||
// Hook Functions.
|
||||
//
|
||||
|
||||
|
||||
// Escape Sequance parse thread.
|
||||
static int32 EscParse (void *);
|
||||
|
||||
// Pty device reader thread.
|
||||
static int32 PtyReader (void *);
|
||||
|
||||
// Reading ReadBuf at one Char.
|
||||
uchar GetReaderBuf (void);
|
||||
|
||||
TermView *fViewObj;
|
||||
TermWindow *fWinObj;
|
||||
CodeConv *fConvObj;
|
||||
|
||||
thread_id fParseThread;
|
||||
sem_id fParseSem;
|
||||
|
||||
thread_id fReaderThread;
|
||||
sem_id fReaderSem;
|
||||
sem_id fReaderLocker;
|
||||
|
||||
BMessageRunner *fCursorUpdate;
|
||||
|
||||
uint fParser_p; /* EscParse reading buffer pointer */
|
||||
int fLockFlag; /* PtyReader lock flag */
|
||||
|
||||
bool fQuitting;
|
||||
|
||||
uchar fReadBuf[READ_BUF_SIZE]; /* Reading buffer */
|
||||
|
||||
};
|
||||
|
||||
#endif // TERMPARSE_H
|
152
src/apps/terminal/MYOB/TermPrint.cpp
Normal file
152
src/apps/terminal/MYOB/TermPrint.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <PrintJob.h>
|
||||
|
||||
#include "TermView.h"
|
||||
|
||||
BMessage *setup = NULL;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DoPageSetUp ()
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermView::DoPageSetup()
|
||||
{
|
||||
BPrintJob job("Page Setup");
|
||||
|
||||
if (setup) {
|
||||
job.SetSettings(setup);
|
||||
}
|
||||
|
||||
if (job.ConfigPage() == B_OK) {
|
||||
delete setup;
|
||||
setup = job.Settings();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DoPrint ()
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermView::DoPrint()
|
||||
{
|
||||
status_t result = B_OK;
|
||||
BPrintJob job("document's name");
|
||||
|
||||
// If we have no setup message, we should call ConfigPage()
|
||||
// You must use the same instance of the BPrintJob object
|
||||
// (you can't call the previous "PageSetup()" function, since it
|
||||
// creates its own BPrintJob object).
|
||||
|
||||
if (!setup) {
|
||||
result = job.ConfigPage();
|
||||
if (result == B_OK) {
|
||||
// Get the user Settings
|
||||
setup = job.Settings();
|
||||
}
|
||||
}
|
||||
|
||||
if (result == B_OK) {
|
||||
// Setup the driver with user settings
|
||||
job.SetSettings(setup);
|
||||
|
||||
result = job.ConfigJob();
|
||||
if (result == B_OK) {
|
||||
// WARNING: here, setup CANNOT be NULL.
|
||||
if (setup == NULL) {
|
||||
// something's wrong, handle the error and bail out
|
||||
}
|
||||
delete setup;
|
||||
|
||||
// Get the user Settings
|
||||
setup = job.Settings();
|
||||
|
||||
// Now you have to calculate the number of pages
|
||||
// (note: page are zero-based)
|
||||
int32 firstPage = job.FirstPage();
|
||||
int32 lastPage = job.LastPage();
|
||||
|
||||
// Verify the range is correct
|
||||
// 0 ... LONG_MAX -> Print all the document
|
||||
// n ... LONG_MAX -> Print from page n to the end
|
||||
// n ... m -> Print from page n to page m
|
||||
|
||||
// if (lastPage > your_document_last_page)
|
||||
// last_page = your_document_last_page;
|
||||
|
||||
int32 nbPages = lastPage - firstPage + 1;
|
||||
|
||||
// Verify the range is correct
|
||||
if (nbPages <= 0)
|
||||
return; // ERROR;
|
||||
|
||||
// Now you can print the page
|
||||
job.BeginJob();
|
||||
|
||||
// Print all pages
|
||||
bool can_continue = job.CanContinue();
|
||||
|
||||
for (int i=firstPage ; can_continue && i<=lastPage ; i++) {
|
||||
// Draw all the needed views
|
||||
//job.DrawView(this, this->Bounds(), pointOnPage);
|
||||
|
||||
// If the document have a lot of pages, you can update a BStatusBar, here
|
||||
// or else what you want...
|
||||
//update_status_bar(i-firstPage, nbPages);
|
||||
|
||||
// Spool the page
|
||||
job.SpoolPage();
|
||||
|
||||
// Cancel the job if needed.
|
||||
// You can for exemple verify if the user pressed the ESC key
|
||||
// or (SHIFT + '.')...
|
||||
//if (user_has_canceled) {
|
||||
// tell the print_server to cancel the printjob
|
||||
//job.CancelJob();
|
||||
//can_continue = false;
|
||||
//break;
|
||||
//}
|
||||
|
||||
// Verify that there was no error (disk full for exemple)
|
||||
can_continue = job.CanContinue();
|
||||
}
|
||||
|
||||
// Now, you just have to commit the job!
|
||||
if (can_continue)
|
||||
job.CommitJob();
|
||||
else
|
||||
result = B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
2635
src/apps/terminal/MYOB/TermView.cpp
Normal file
2635
src/apps/terminal/MYOB/TermView.cpp
Normal file
File diff suppressed because it is too large
Load Diff
412
src/apps/terminal/MYOB/TermView.h
Normal file
412
src/apps/terminal/MYOB/TermView.h
Normal file
@ -0,0 +1,412 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TERMVIEW_H
|
||||
#define TERMVIEW_H
|
||||
|
||||
#include <View.h>
|
||||
#include <String.h>
|
||||
#include <MessageRunner.h>
|
||||
#include "TermConst.h"
|
||||
#include "TermWindow.h"
|
||||
#include "CurPos.h"
|
||||
|
||||
/* Cursor Blinking flag */
|
||||
#define CUROFF 0
|
||||
#define CURON 1
|
||||
|
||||
#define VIEW_THR_CODE 'vtcd'
|
||||
#define MOUSE_THR_CODE 'mtcd'
|
||||
#define RECT_BUF_SIZE 32
|
||||
|
||||
const unsigned char M_ADD_CURSOR [] = {
|
||||
16, // Size
|
||||
1, // Color depth
|
||||
0, // Hot spot y
|
||||
1, // Hot spot x
|
||||
// Cursor image
|
||||
0x70, 0x00,
|
||||
0x48, 0x00,
|
||||
0x48, 0x00,
|
||||
0x27, 0xc0,
|
||||
0x24, 0xb8,
|
||||
0x12, 0x54,
|
||||
0x10, 0x02,
|
||||
0x78, 0x02,
|
||||
0x98, 0x02,
|
||||
0x84, 0x02,
|
||||
0x60, 0x02,
|
||||
0x18, 0x12,
|
||||
0x04, 0x10,
|
||||
0x02, 0x7c,
|
||||
0x00, 0x10,
|
||||
0x00, 0x10,
|
||||
// Mask image
|
||||
0x70, 0x00,
|
||||
0x78, 0x00,
|
||||
0x78, 0x00,
|
||||
0x3f, 0xc0,
|
||||
0x3f, 0xf8,
|
||||
0x1f, 0xfc,
|
||||
0x1f, 0xfe,
|
||||
0x7f, 0xfe,
|
||||
0xff, 0xfe,
|
||||
0xff, 0xfe,
|
||||
0x7f, 0xfe,
|
||||
0x1f, 0xfe,
|
||||
0x07, 0xfc,
|
||||
0x03, 0xfc,
|
||||
0x00, 0x10,
|
||||
0x00, 0x10,
|
||||
};
|
||||
|
||||
class TermBuffer;
|
||||
class CodeConv;
|
||||
class BPopUpMenu;
|
||||
class BScrollBar;
|
||||
class BString;
|
||||
|
||||
class TermView : public BView
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Constructor, Destructor, and Initializer.
|
||||
//
|
||||
TermView (BRect frame, CodeConv *inCodeConv);
|
||||
~TermView ();
|
||||
|
||||
//
|
||||
// Initializer, Set function
|
||||
//
|
||||
void SetTermFont(BFont *halfFont, BFont *fullFont);
|
||||
void GetFontSize (int *width, int *height);
|
||||
BRect SetTermSize (int rows, int cols, bool flag);
|
||||
void SetTermColor (void);
|
||||
void SetMouseButton (void);
|
||||
void SetMouseCursor (void);
|
||||
// void SetIMAware (bool);
|
||||
void SetScrollBar (BScrollBar *scrbar);
|
||||
|
||||
//
|
||||
// Output Charactor.
|
||||
//
|
||||
void PutChar (uchar *string, ushort attr, int width);
|
||||
void PutCR (void);
|
||||
void PutLF (void);
|
||||
void PutNL (int num);
|
||||
void SetInsertMode (int flag);
|
||||
void InsertSpace (int num);
|
||||
|
||||
int TermDraw (const CurPos &start, const CurPos &end);
|
||||
int TermDrawRegion (CurPos start, CurPos end);
|
||||
int TermDrawSelectedRegion (CurPos start, CurPos end);
|
||||
|
||||
//
|
||||
// Delete Charactor.
|
||||
//
|
||||
void EraseBelow (void);
|
||||
void DeleteChar (int num);
|
||||
void DeleteColumns (void);
|
||||
void DeleteLine (int num);
|
||||
|
||||
//
|
||||
// Get and Set Cursor position.
|
||||
//
|
||||
void SetCurPos (int x, int y);
|
||||
void SetCurX (int x);
|
||||
void SetCurY (int y);
|
||||
|
||||
void GetCurPos (CurPos *inCurPos);
|
||||
int GetCurX (void);
|
||||
int GetCurY (void);
|
||||
|
||||
void SaveCursor (void);
|
||||
void RestoreCursor (void);
|
||||
|
||||
//
|
||||
// Move Cursor
|
||||
//
|
||||
void MoveCurRight (int num);
|
||||
void MoveCurLeft (int num);
|
||||
void MoveCurUp (int num);
|
||||
void MoveCurDown (int num);
|
||||
|
||||
//
|
||||
// Cursor setting.
|
||||
//
|
||||
void DrawCursor (void);
|
||||
void BlinkCursor (void);
|
||||
void SetCurDraw (bool flag);
|
||||
void SetCurBlinking (bool flag);
|
||||
|
||||
//
|
||||
// Scroll region.
|
||||
//
|
||||
void ScrollRegion (int top, int bot, int dir, int num);
|
||||
void SetScrollRegion (int top, int bot);
|
||||
void ScrollAtCursor (void);
|
||||
|
||||
//
|
||||
// Other.
|
||||
//
|
||||
void UpdateSIGWINCH();
|
||||
void DeviceStatusReport (int);
|
||||
inline void UpdateLine (void);
|
||||
void ScrollScreen (void);
|
||||
void ScrollScreenDraw (void);
|
||||
void GetFrameSize (float *width, float *height);
|
||||
void GetFontInfo (int *, int*);
|
||||
|
||||
/*
|
||||
* PRIVATE MEMBER.
|
||||
*/
|
||||
|
||||
private:
|
||||
/*
|
||||
* static Functions (Thread functions).
|
||||
*/
|
||||
|
||||
static int32 ViewThread (void *);
|
||||
static int32 MouseTracking (void *);
|
||||
|
||||
/*
|
||||
* Hook Functions.
|
||||
*/
|
||||
void AttachedToWindow (void);
|
||||
void Draw (BRect updateRect);
|
||||
void WindowActivated (bool active);
|
||||
void KeyDown (const char*, int32);
|
||||
void MouseDown (BPoint where);
|
||||
void MouseMoved (BPoint, uint32, const BMessage *);
|
||||
|
||||
void FrameResized(float width, float height);
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
/*
|
||||
* Private Member Functions.
|
||||
*/
|
||||
|
||||
thread_id InitViewThread (void);
|
||||
|
||||
inline void DrawLines (int , int, ushort, uchar *, int, int, int, BView *);
|
||||
|
||||
void DoPrint(BRect updateRect);
|
||||
|
||||
void ResizeScrBarRange (void);
|
||||
|
||||
void DoFileDrop(entry_ref &ref);
|
||||
|
||||
// edit menu function.
|
||||
void DoCopy (void);
|
||||
void DoPaste (void);
|
||||
void DoSelectAll (void);
|
||||
void DoClearAll (void);
|
||||
|
||||
int SubstMetaChar (const char *p, char *q);
|
||||
void WritePTY (const uchar *text, int num_byteses);
|
||||
|
||||
// Comunicate Input Method
|
||||
// void DoIMStart (BMessage* message);
|
||||
// void DoIMStop (BMessage* message);
|
||||
// void DoIMChange (BMessage* message);
|
||||
// void DoIMLocation (BMessage* message);
|
||||
// void DoIMConfirm (void);
|
||||
void ConfirmString (const char *, int32);
|
||||
int32 GetCharFromUTF8String (const char *, char *);
|
||||
int32 GetWidthFromUTF8String (const char *);
|
||||
|
||||
// mouse operation
|
||||
void SetupPop (void);
|
||||
int32 SetupMouseButton (const char *bname);
|
||||
|
||||
// Mouse select
|
||||
void Select (CurPos start, CurPos end);
|
||||
void AddSelectRegion (CurPos);
|
||||
void ResizeSelectRegion (CurPos);
|
||||
|
||||
void DeSelect(void);
|
||||
|
||||
// select word function
|
||||
void SelectWord (BPoint where, int mod);
|
||||
void SelectLine (BPoint where, int mod);
|
||||
|
||||
// point and text offset conversion.
|
||||
CurPos BPointToCurPos (const BPoint &p);
|
||||
BPoint CurPosToBPoint (const CurPos &pos);
|
||||
|
||||
bool CheckSelectedRegion (const CurPos &pos);
|
||||
|
||||
inline void SendDataToDrawEngine (int, int, int, int);
|
||||
|
||||
/*
|
||||
* DATA Member.
|
||||
*/
|
||||
|
||||
//
|
||||
// Font and Width.
|
||||
//
|
||||
BFont fHalfFont;
|
||||
BFont fFullFont;
|
||||
|
||||
int fFontWidth;
|
||||
int fFontHeight;
|
||||
|
||||
int fFontAscent;
|
||||
struct escapement_delta fEscapement;
|
||||
|
||||
//
|
||||
// Flags.
|
||||
//
|
||||
|
||||
// Update flag (Set on PutChar).
|
||||
bool fUpdateFlag;
|
||||
|
||||
// Terminal insertmode flag (use PutChar).
|
||||
bool fInsertModeFlag;
|
||||
|
||||
// Scroll count, range.
|
||||
int fScrollUpCount;
|
||||
int fScrollBarRange;
|
||||
|
||||
// Frame Resized flag.
|
||||
bool fFrameResized;
|
||||
|
||||
// Cursor Blinking, draw flag.
|
||||
bool fCursorDrawFlag;
|
||||
bool fCursorStatus;
|
||||
bool fCursorBlinkingFlag;
|
||||
bool fCursorRedrawFlag;
|
||||
|
||||
int fCursorHeight;
|
||||
|
||||
// terminal text attribute flag.
|
||||
bool fInverseFlag;
|
||||
bool fBoldFlag;
|
||||
bool fUnderlineFlag;
|
||||
|
||||
//
|
||||
// Cursor position.
|
||||
//
|
||||
CurPos fCurPos;
|
||||
CurPos fCurStack;
|
||||
|
||||
int fBufferStartPos;
|
||||
|
||||
//
|
||||
// Terminal rows and columns.
|
||||
//
|
||||
int fTermRows;
|
||||
int fTermColumns;
|
||||
|
||||
//
|
||||
// Terminal view pointer.
|
||||
//
|
||||
int fTop;
|
||||
|
||||
//
|
||||
// Object pointer.
|
||||
//
|
||||
TermBuffer *fTextBuffer;
|
||||
CodeConv *fCodeConv;
|
||||
BScrollBar *fScrollBar;
|
||||
|
||||
//
|
||||
// Offscreen Bitmap and View.
|
||||
//
|
||||
|
||||
BRect fSrcRect;
|
||||
BRect fDstRect;
|
||||
|
||||
//
|
||||
// Color and Attribute.
|
||||
//
|
||||
|
||||
// text fore and back color
|
||||
rgb_color fTextForeColor, fTextBackColor;
|
||||
|
||||
// cursor fore and back color
|
||||
rgb_color fCursorForeColor, fCursorBackColor;
|
||||
|
||||
// selected region color
|
||||
rgb_color fSelectForeColor, fSelectBackColor;
|
||||
|
||||
uchar fTermAttr;
|
||||
|
||||
//
|
||||
// Scroll Region
|
||||
//
|
||||
int fScrTop;
|
||||
int fScrBot;
|
||||
int fScrBufSize;
|
||||
bool fScrRegionSet;
|
||||
|
||||
BPopUpMenu *fPopMenu;
|
||||
BMenu *fPopEncoding;
|
||||
BMenu *fPopSize;
|
||||
|
||||
// mouse
|
||||
int32 mSelectButton;
|
||||
int32 mSubMenuButton;
|
||||
int32 mPasteMenuButton;
|
||||
|
||||
bool fMouseImage;
|
||||
|
||||
BPoint fPreviousMousePoint;
|
||||
|
||||
// view selection
|
||||
CurPos fSelStart;
|
||||
CurPos fSelEnd;
|
||||
int fSelected;
|
||||
int fMouseTracking;
|
||||
|
||||
// thread ID / flags.
|
||||
thread_id fViewThread;
|
||||
thread_id fMouseThread;
|
||||
int fQuitting;
|
||||
|
||||
// DrawEngine parameter.
|
||||
sem_id fDrawRectSem;
|
||||
sDrawRect fDrawRectBuffer[RECT_BUF_SIZE];
|
||||
int fDrawRect_p;
|
||||
|
||||
// Input Method parameter.
|
||||
int fIMViewPtr;
|
||||
CurPos fIMStartPos;
|
||||
CurPos fIMEndPos;
|
||||
BString fIMString;
|
||||
bool fIMflag;
|
||||
BMessenger fIMMessenger;
|
||||
|
||||
int32 fImCodeState;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //TERMVIEW_H
|
682
src/apps/terminal/MYOB/TermWindow.cpp
Normal file
682
src/apps/terminal/MYOB/TermWindow.cpp
Normal file
@ -0,0 +1,682 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <app/Application.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <TextControl.h>
|
||||
#include <PrintJob.h>
|
||||
#include <Alert.h>
|
||||
#include <float.h>
|
||||
#include <WindowScreen.h>
|
||||
#include <PropertyInfo.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "TermApp.h"
|
||||
#include "TermParse.h"
|
||||
#include "TermWindow.h"
|
||||
#include "TermView.h"
|
||||
#include "TermBuffer.h"
|
||||
#include "TermBaseView.h"
|
||||
#include "CodeConv.h"
|
||||
#include "TermConst.h"
|
||||
#include "PrefDlg.h"
|
||||
#include "PrefView.h"
|
||||
#include "PrefHandler.h"
|
||||
#include "MenuUtil.h"
|
||||
#include "spawn.h"
|
||||
#include "ColorWindow.h"
|
||||
#include "AboutWindow.h"
|
||||
|
||||
// Gloval Preference Handler
|
||||
extern PrefHandler *gTermPref;
|
||||
//
|
||||
// help and GPL URL
|
||||
//
|
||||
#define URL_PREFIX "file:///boot/home/config/settings/MuTerminal/help/"
|
||||
#define INDEX_FILE "/index.html"
|
||||
#define GPL_FILE "/gpl.html"
|
||||
#define CHLP_FILE "file:///boot/beos/documentation/Shell%20Tools/index.html"
|
||||
|
||||
extern int gNowCoding; /* defined TermParce.cpp */
|
||||
char gWindowName[256] = "Terminal";
|
||||
|
||||
void SetCoding (int);
|
||||
|
||||
/*
|
||||
*
|
||||
* CONSTRUCTOR and DESTRUCTOR
|
||||
*
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// TermWindow Constructer
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermWindow::TermWindow( BRect frame)
|
||||
: BWindow (frame, NULL, B_DOCUMENT_WINDOW,
|
||||
B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE)
|
||||
{
|
||||
InitWindow();
|
||||
SetWindowTitle();
|
||||
fPrintSettings = NULL;
|
||||
fPrefWindow = NULL;
|
||||
fFindPanel = NULL;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Desctuctor
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
TermWindow::~TermWindow()
|
||||
{
|
||||
if (fWindowUpdate != NULL)
|
||||
delete (fWindowUpdate);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* PUBLIC MEMBER FUNCTIONS.
|
||||
*
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Init Window (void)
|
||||
// Initialize Window object.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
TermWindow::InitWindow(void)
|
||||
{
|
||||
// make menu bar
|
||||
SetupMenu();
|
||||
|
||||
// Setup font.
|
||||
|
||||
BFont halfFont;
|
||||
BFont fullFont;
|
||||
|
||||
halfFont.SetFamilyAndStyle (gTermPref->getString(PREF_HALF_FONT_FAMILY),
|
||||
NULL);
|
||||
halfFont.SetSize (gTermPref->getFloat(PREF_HALF_FONT_SIZE));
|
||||
halfFont.SetSpacing (B_FIXED_SPACING);
|
||||
|
||||
fullFont.SetFamilyAndStyle (gTermPref->getString(PREF_FULL_FONT_FAMILY),
|
||||
NULL);
|
||||
fullFont.SetSize (gTermPref->getFloat(PREF_FULL_FONT_SIZE));
|
||||
fullFont.SetSpacing (B_FIXED_SPACING);
|
||||
|
||||
// Make Terminal text view.
|
||||
|
||||
BRect textframe = Bounds();
|
||||
textframe.top = fMenubar->Bounds().bottom + 1.0;
|
||||
|
||||
fCodeConv = new CodeConv ();
|
||||
fTermView = new TermView(Bounds(), fCodeConv);
|
||||
|
||||
/*
|
||||
* MuTerm has two views. BaseView is window base view.
|
||||
* TermView is character Terminal view on BaseView. It has paste
|
||||
* on BaseView shift as VIEW_OFFSET.
|
||||
*/
|
||||
fBaseView = new TermBaseView (textframe, fTermView);
|
||||
|
||||
//
|
||||
//Initialize TermView. (font, size and color)
|
||||
//
|
||||
fTermView->SetTermFont (&halfFont, &fullFont);
|
||||
BRect r = fTermView->SetTermSize (gTermPref->getInt32 (PREF_ROWS),
|
||||
gTermPref->getInt32 (PREF_COLS),
|
||||
1);
|
||||
|
||||
int width, height;
|
||||
|
||||
fTermView->GetFontSize (&width, &height);
|
||||
SetSizeLimits (MIN_COLS * width, MAX_COLS * width,
|
||||
MIN_COLS * height, MAX_COLS * height);
|
||||
|
||||
|
||||
fTermView->SetTermColor ();
|
||||
fBaseView->SetViewColor (gTermPref->getRGB (PREF_TEXT_BACK_COLOR));
|
||||
|
||||
// Add offset to baseview.
|
||||
r.InsetBy (-VIEW_OFFSET, -VIEW_OFFSET);
|
||||
|
||||
//
|
||||
// Resize Window
|
||||
//
|
||||
ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH,
|
||||
r.Height()+fMenubar->Bounds().Height());
|
||||
|
||||
fBaseView-> ResizeTo (r.Width(), r.Height());
|
||||
fBaseView->AddChild (fTermView);
|
||||
fTermView->MoveBy (VIEW_OFFSET, VIEW_OFFSET);
|
||||
|
||||
//
|
||||
// Make Scroll Bar.
|
||||
//
|
||||
BRect scr(0, 0,
|
||||
B_V_SCROLL_BAR_WIDTH,
|
||||
r.Height() - B_H_SCROLL_BAR_HEIGHT + 1);
|
||||
|
||||
scr.OffsetBy (r.Width() + 1 , fMenubar->Bounds().Height());
|
||||
|
||||
BScrollBar *scrbar =
|
||||
new BScrollBar (scr, "scrollbar", fTermView, 0, 0, B_VERTICAL);
|
||||
|
||||
fTermView->SetScrollBar (scrbar);
|
||||
|
||||
this->AddChild (scrbar);
|
||||
this->AddChild (fBaseView);
|
||||
|
||||
|
||||
// scrview->SetTarget (fTermView);
|
||||
|
||||
// Set fEditmenu's target to fTermView. (Oh!...)
|
||||
fEditmenu->SetTargetForItems(fTermView);
|
||||
|
||||
//
|
||||
// Initialize TermParse
|
||||
//
|
||||
gNowCoding = longname2op(gTermPref->getString(PREF_TEXT_ENCODING));
|
||||
fTermParse = new TermParse ();
|
||||
fTermParse->InitPtyReader (this);
|
||||
fTermParse->InitTermParse(fTermView, fCodeConv);
|
||||
|
||||
// Set Coding.
|
||||
|
||||
// Initialize MessageRunner.
|
||||
fWindowUpdate = new BMessageRunner (BMessenger (this),
|
||||
new BMessage (MSGRUN_WINDOW),
|
||||
500000);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// void MenusBeginning (void)
|
||||
// Dispatch MenuBegininng
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::MenusBeginning(void)
|
||||
{
|
||||
// Syncronize Encode Menu Pop-up menu and Preference.
|
||||
(fEncodingmenu->FindItem(op2longname(gNowCoding)))->SetMarked(true);
|
||||
BWindow::MenusBeginning();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SetupMenu(void)
|
||||
// Makes Menu Bar.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::SetupMenu(void)
|
||||
{
|
||||
PrefHandler menuText;
|
||||
|
||||
LoadLocaleFile (&menuText);
|
||||
|
||||
// Menu bar object.
|
||||
fMenubar = new BMenuBar(Bounds(), "mbar");
|
||||
|
||||
/*
|
||||
* Make Fiile Menu.
|
||||
*/
|
||||
fFilemenu = new BMenu("Terminal");
|
||||
fFilemenu->AddItem(new BMenuItem("Switch Terminals", new BMessage(MENU_SWITCH_TERM),'G'));
|
||||
fFilemenu->AddItem(new BMenuItem("Start New Terminal", new BMessage(MENU_NEW_TREM), 'N'));
|
||||
fFilemenu->AddSeparatorItem();
|
||||
fFilemenu->AddItem(new BMenuItem("Preferences", new BMessage(MENU_PREF_OPEN)));
|
||||
fFilemenu->AddSeparatorItem();
|
||||
fFilemenu->AddItem(new BMenuItem("Page Setup", new BMessage(MENU_PAGE_SETUP)));
|
||||
fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT), 'P'));
|
||||
fFilemenu->AddSeparatorItem();
|
||||
fFilemenu->AddItem(new BMenuItem("Quit", new BMessage(MENU_FILE_QUIT), 'Q'));
|
||||
fMenubar->AddItem(fFilemenu);
|
||||
|
||||
/*
|
||||
* Make Edit Menu.
|
||||
*/
|
||||
fEditmenu = new BMenu ("Edit");
|
||||
fEditmenu->AddItem (new BMenuItem ("Copy", new BMessage (B_COPY),'C'));
|
||||
fEditmenu->AddItem (new BMenuItem ("Paste", new BMessage (B_PASTE),'V'));
|
||||
fEditmenu->AddSeparatorItem ();
|
||||
fEditmenu->AddItem (new BMenuItem ("Select All", new BMessage (B_SELECT_ALL), 'A'));
|
||||
fEditmenu->AddItem (new BMenuItem ("Clear All", new BMessage (MENU_CLEAR_ALL)));
|
||||
fEditmenu->AddSeparatorItem ();
|
||||
fEditmenu->AddItem (new BMenuItem ("Find", new BMessage (MENU_FIND_STRING),'F'));
|
||||
fEditmenu->AddItem (new BMenuItem ("Find Again", new BMessage (MENU_FIND_AGAIN), '['));
|
||||
fMenubar->AddItem (fEditmenu);
|
||||
|
||||
|
||||
/*
|
||||
* Make Help Menu.
|
||||
*/
|
||||
fHelpmenu = new BMenu("Settings");
|
||||
fEncodingmenu = new BMenu("Font Encoding");
|
||||
fEncodingmenu->SetRadioMode(true);
|
||||
MakeEncodingMenu(fEncodingmenu, gNowCoding, true);
|
||||
fHelpmenu->AddItem(fEncodingmenu);
|
||||
fHelpmenu->AddItem(new BMenuItem("About Terminal", new BMessage(MENU_SHOW_ABOUT)));
|
||||
fMenubar->AddItem(fHelpmenu);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AddChild(fMenubar);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// MessageReceived (BMessage *)
|
||||
// Dispatch Mesasge.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
int32 coding_id;
|
||||
BRect r;
|
||||
BFont halfFont;
|
||||
BFont fullFont;
|
||||
|
||||
|
||||
switch(message->what) {
|
||||
|
||||
case MENU_SWITCH_TERM:
|
||||
be_app->PostMessage(MENU_SWITCH_TERM);
|
||||
break;
|
||||
|
||||
case MENU_NEW_TREM:
|
||||
be_app->PostMessage(MENU_NEW_TREM);
|
||||
break;
|
||||
|
||||
case MENU_PREF_OPEN:
|
||||
if (!fPrefWindow){
|
||||
fPrefWindow = new PrefDlg(this);
|
||||
}else{
|
||||
fPrefWindow->Activate();
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_SHOW_ABOUT:
|
||||
aboutRequested();
|
||||
break;
|
||||
|
||||
case MSG_PREF_CLOSED:
|
||||
fPrefWindow = NULL;
|
||||
break;
|
||||
|
||||
case MENU_FILE_QUIT:
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
case MENU_ENCODING:
|
||||
message->FindInt32 ("op", &coding_id);
|
||||
gNowCoding = coding_id;
|
||||
SetCoding (coding_id);
|
||||
this->SetWindowTitle ();
|
||||
break;
|
||||
|
||||
/*
|
||||
* Extended B_SET_PROPERTY. Dispatch this message,
|
||||
* Set coding ID.
|
||||
*/
|
||||
case B_SET_PROPERTY:
|
||||
{
|
||||
int32 i;
|
||||
BMessage spe;
|
||||
message->GetCurrentSpecifier(&i, &spe);
|
||||
if (!strcmp("encode", spe.FindString("property", i))){
|
||||
message->FindInt32 ("data", &coding_id);
|
||||
gNowCoding = coding_id;
|
||||
SetCoding (coding_id);
|
||||
|
||||
message->SendReply(B_REPLY);
|
||||
}else{
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extended B_GET_PROPERTY. Dispatch this message,
|
||||
* reply now coding ID.
|
||||
*/
|
||||
case B_GET_PROPERTY:
|
||||
{
|
||||
int32 i;
|
||||
BMessage spe;
|
||||
message->GetCurrentSpecifier(&i, &spe);
|
||||
if (!strcmp("encode", spe.FindString("property", i))){
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddInt32("result", gNowCoding);
|
||||
message->SendReply(&reply);
|
||||
}else if (!strcmp("tty", spe.FindString("property", i))){
|
||||
BMessage reply(B_REPLY);
|
||||
reply.AddString("result", &tty_name[8]);
|
||||
message->SendReply(&reply);
|
||||
}else{
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Message from Preference panel.
|
||||
*/
|
||||
case MSG_ROWS_CHANGED:
|
||||
case MSG_COLS_CHANGED:
|
||||
r = fTermView->SetTermSize (gTermPref->getInt32 (PREF_ROWS),
|
||||
gTermPref->getInt32 (PREF_COLS),
|
||||
0);
|
||||
|
||||
ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH + VIEW_OFFSET * 2,
|
||||
r.Height()+fMenubar->Bounds().Height() + VIEW_OFFSET *2);
|
||||
break;
|
||||
|
||||
case MSG_HALF_FONT_CHANGED:
|
||||
case MSG_FULL_FONT_CHANGED:
|
||||
case MSG_HALF_SIZE_CHANGED:
|
||||
case MSG_FULL_SIZE_CHANGED:
|
||||
|
||||
halfFont.SetFamilyAndStyle (gTermPref->getString(PREF_HALF_FONT_FAMILY),
|
||||
NULL);
|
||||
halfFont.SetSize (gTermPref->getFloat(PREF_HALF_FONT_SIZE));
|
||||
halfFont.SetSpacing (B_FIXED_SPACING);
|
||||
|
||||
fullFont.SetFamilyAndStyle (gTermPref->getString(PREF_FULL_FONT_FAMILY),
|
||||
NULL);
|
||||
fullFont.SetSize (gTermPref->getFloat(PREF_FULL_FONT_SIZE));
|
||||
fullFont.SetSpacing (B_FIXED_SPACING);
|
||||
|
||||
fTermView->SetTermFont (&halfFont, &fullFont);
|
||||
r = fTermView->SetTermSize (0, 0, 0);
|
||||
|
||||
int width, height;
|
||||
|
||||
fTermView->GetFontSize (&width, &height);
|
||||
|
||||
SetSizeLimits (MIN_COLS * width, MAX_COLS * width,
|
||||
MIN_COLS * height, MAX_COLS * height);
|
||||
|
||||
|
||||
|
||||
ResizeTo (r.Width()+ B_V_SCROLL_BAR_WIDTH + VIEW_OFFSET * 2,
|
||||
r.Height()+fMenubar->Bounds().Height() + VIEW_OFFSET * 2);
|
||||
|
||||
fTermView->Invalidate();
|
||||
break;
|
||||
|
||||
case MSG_COLOR_CHANGED:
|
||||
fBaseView->SetViewColor (gTermPref->getRGB (PREF_TEXT_BACK_COLOR));
|
||||
fTermView->SetTermColor ();
|
||||
fBaseView->Invalidate();
|
||||
fTermView->Invalidate();
|
||||
break;
|
||||
|
||||
case MENU_PAGE_SETUP:
|
||||
DoPageSetup ();
|
||||
break;
|
||||
case MENU_PRINT:
|
||||
DoPrint ();
|
||||
break;
|
||||
|
||||
case MSGRUN_WINDOW:
|
||||
fTermView->UpdateSIGWINCH ();
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// WindowActivated (bool)
|
||||
// Dispatch Mesasge.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::WindowActivated (bool )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Quit (void)
|
||||
// Quit Application.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//void
|
||||
//TermWindow::colRequested() {
|
||||
// colWindow *colW=new colWindow("Colours for Terminal");
|
||||
// colW->Show();
|
||||
// }
|
||||
|
||||
void
|
||||
TermWindow::aboutRequested() {
|
||||
aboutWindow *aboutW=new aboutWindow("About");
|
||||
aboutW->Show();
|
||||
}
|
||||
|
||||
void
|
||||
TermWindow::Quit (void)
|
||||
{
|
||||
delete fTermParse;
|
||||
delete fCodeConv;
|
||||
if(fPrefWindow) fPrefWindow->PostMessage (B_QUIT_REQUESTED);
|
||||
be_app->PostMessage (B_QUIT_REQUESTED, be_app);
|
||||
BWindow::Quit ();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// QuitRequested (void)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
TermWindow::QuitRequested (void)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// int GetTimeZone (void)
|
||||
// Get Machine Timezone.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
TermWindow::GetTimeZone ()
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tm;
|
||||
|
||||
gettimeofday (&tv, &tm);
|
||||
|
||||
return -tm.tz_minuteswest / 60;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// void SetWindowTitle (void)
|
||||
// set window title bar (pty device name, and coding)
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "spawn.h"
|
||||
|
||||
void
|
||||
TermWindow::SetWindowTitle (void)
|
||||
{
|
||||
char windowname[256];
|
||||
sprintf(windowname, gWindowName
|
||||
|
||||
);
|
||||
this->SetTitle (windowname);
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GetSupoprtedSuites (BMessage *)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::TermWinActivate (void)
|
||||
{
|
||||
|
||||
this->Activate();
|
||||
|
||||
if (focus_follows_mouse()) {
|
||||
BPoint aMouseLoc = this->Frame().LeftTop();
|
||||
set_mouse_position(int32(aMouseLoc.x + 16), int32(aMouseLoc.y + 2));
|
||||
be_app->SetCursor(B_HAND_CURSOR);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GetSupoprtedSuites (BMessage *)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
status_t
|
||||
TermWindow::GetSupportedSuites(BMessage *msg)
|
||||
{
|
||||
static property_info prop_list[] = {
|
||||
{ "encode",
|
||||
{B_GET_PROPERTY, 0},
|
||||
{B_DIRECT_SPECIFIER, 0},
|
||||
"get muterminal encode"},
|
||||
{ "encode",
|
||||
{B_SET_PROPERTY, 0},
|
||||
{B_DIRECT_SPECIFIER, 0},
|
||||
"set muterminal encode"},
|
||||
{ "tty",
|
||||
{B_GET_PROPERTY, 0},
|
||||
{B_DIRECT_SPECIFIER, 0},
|
||||
"get tty_name."},
|
||||
{ 0 }
|
||||
|
||||
};
|
||||
msg->AddString("suites", "suite/vnd.naan-termwindow");
|
||||
BPropertyInfo prop_info(prop_list);
|
||||
msg->AddFlat("messages", &prop_info);
|
||||
return BWindow::GetSupportedSuites(msg);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ResolveSpecifier
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
BHandler*
|
||||
TermWindow::ResolveSpecifier(BMessage *msg, int32 index,
|
||||
BMessage *specifier, int32 form,
|
||||
const char *property)
|
||||
{
|
||||
if ( (strcmp(property, "encode") == 0)
|
||||
&& ((msg->what == B_SET_PROPERTY) || (msg->what == B_GET_PROPERTY) ))
|
||||
return this;
|
||||
else if ( (strcmp(property, "tty") == 0)
|
||||
&& (msg->what == B_GET_PROPERTY) )
|
||||
return this;
|
||||
|
||||
return BWindow::ResolveSpecifier(msg, index, specifier, form, property);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SetCoding
|
||||
// Set coding utility functions.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void SetCoding (int coding)
|
||||
{
|
||||
const etable *p = encoding_table;
|
||||
p += coding;
|
||||
|
||||
gNowCoding = coding;
|
||||
|
||||
return;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DoPageSetUp ()
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
status_t
|
||||
TermWindow::DoPageSetup()
|
||||
{
|
||||
status_t rv;
|
||||
BPrintJob job("PageSetup");
|
||||
|
||||
/* display the page configure panel */
|
||||
rv = job.ConfigPage();
|
||||
|
||||
/* save a pointer to the settings */
|
||||
fPrintSettings = job.Settings();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DoPrint ()
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
TermWindow::DoPrint()
|
||||
{
|
||||
#if B_BEOS_VERSION < 0x0460
|
||||
BPrintJob job("Print");
|
||||
|
||||
if((! fPrintSettings) && (DoPageSetup() != B_NO_ERROR)) {
|
||||
(new BAlert("Cancel", "Print cancelled.", "OK"))->Go();
|
||||
return;
|
||||
}
|
||||
|
||||
job.SetSettings(new BMessage(fPrintSettings));
|
||||
|
||||
BRect pageRect = job.PrintableRect();
|
||||
BRect curPageRect = pageRect;
|
||||
|
||||
int pHeight = (int)pageRect.Height();
|
||||
int pWidth = (int)pageRect.Width();
|
||||
float w,h;
|
||||
fTermView->GetFrameSize (&w, &h);
|
||||
int xPages = (int)ceil(w / pWidth);
|
||||
int yPages = (int)ceil(h / pHeight);
|
||||
|
||||
/* engage the print server */
|
||||
job.BeginJob();
|
||||
|
||||
/* loop through and draw each page, and write to spool */
|
||||
for(int x = 0; x < xPages; x++)
|
||||
for(int y = 0; y < yPages; y++){
|
||||
curPageRect.OffsetTo(x * pWidth, y * pHeight);
|
||||
job.DrawView(fTermView, curPageRect, BPoint(0, 0));
|
||||
job.SpoolPage();
|
||||
|
||||
if(!job.CanContinue()){
|
||||
(new BAlert("Cancel", "Print job cancelled", "OK"))->Go();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* commit the job, send the spool file */
|
||||
job.CommitJob();
|
||||
#endif
|
||||
}
|
93
src/apps/terminal/MYOB/TermWindow.h
Normal file
93
src/apps/terminal/MYOB/TermWindow.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef TERMWIN_H
|
||||
#define TERMWIN_H
|
||||
|
||||
#include <Menu.h>
|
||||
#include <Window.h>
|
||||
#include <MessageRunner.h>
|
||||
|
||||
class BFont;
|
||||
class TermView;
|
||||
class TermParse;
|
||||
class CodeConv;
|
||||
class PrefDlg;
|
||||
class PrefDlg2;
|
||||
class FindDlg;
|
||||
|
||||
|
||||
class TermWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
TermWindow (BRect frame);
|
||||
~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);
|
||||
|
||||
private:
|
||||
void InitWindow (void);
|
||||
void SetupMenu (void);
|
||||
// void colRequested (void);
|
||||
void aboutRequested (void);
|
||||
void MessageReceived (BMessage *message);
|
||||
void WindowActivated (bool);
|
||||
int GetTimeZone (void);
|
||||
void SetWindowTitle (void);
|
||||
void MenusBeginning(void);
|
||||
// void doShowHelp (uint32 command);
|
||||
// Printing
|
||||
status_t DoPageSetup (void);
|
||||
void DoPrint (void);
|
||||
|
||||
/*
|
||||
* data member
|
||||
*/
|
||||
TermParse *fTermParse;
|
||||
BMenuBar *fMenubar;
|
||||
BMenu *fFilemenu, *fEditmenu, *fEncodingmenu, *fHelpmenu, *fFontMenu;
|
||||
TermView *fTermView;
|
||||
BView *fBaseView;
|
||||
CodeConv *fCodeConv;
|
||||
BMessage *fPrintSettings;
|
||||
PrefDlg *fPrefWindow;
|
||||
PrefDlg2 *fPrefWindow2;
|
||||
FindDlg *fFindPanel;
|
||||
|
||||
BMessageRunner *fWindowUpdate;
|
||||
|
||||
};
|
||||
|
||||
#endif // TERMWIN_H
|
53
src/apps/terminal/MYOB/Terminal.cpp
Normal file
53
src/apps/terminal/MYOB/Terminal.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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;
|
||||
}
|
112
src/apps/terminal/MYOB/Terminal.icons.rdef
Normal file
112
src/apps/terminal/MYOB/Terminal.icons.rdef
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
** 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"
|
||||
};
|
BIN
src/apps/terminal/MYOB/Terminal.proj
Normal file
BIN
src/apps/terminal/MYOB/Terminal.proj
Normal file
Binary file not shown.
36
src/apps/terminal/MYOB/Terminal.rdef
Normal file
36
src/apps/terminal/MYOB/Terminal.rdef
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
** 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"
|
||||
};
|
BIN
src/apps/terminal/MYOB/Terminal.rsrc
Normal file
BIN
src/apps/terminal/MYOB/Terminal.rsrc
Normal file
Binary file not shown.
28
src/apps/terminal/MYOB/Terminal.version.rdef
Normal file
28
src/apps/terminal/MYOB/Terminal.version.rdef
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
** 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"
|
||||
};
|
334
src/apps/terminal/MYOB/TerminalApp.cpp
Normal file
334
src/apps/terminal/MYOB/TerminalApp.cpp
Normal file
@ -0,0 +1,334 @@
|
||||
#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 shatty@myrealbox.com\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();
|
||||
}
|
||||
}
|
33
src/apps/terminal/MYOB/TerminalApp.h
Normal file
33
src/apps/terminal/MYOB/TerminalApp.h
Normal file
@ -0,0 +1,33 @@
|
||||
#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
|
||||
|
420
src/apps/terminal/MYOB/TerminalWindow.cpp
Normal file
420
src/apps/terminal/MYOB/TerminalWindow.cpp
Normal file
@ -0,0 +1,420 @@
|
||||
#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();
|
||||
}
|
92
src/apps/terminal/MYOB/TerminalWindow.h
Normal file
92
src/apps/terminal/MYOB/TerminalWindow.h
Normal file
@ -0,0 +1,92 @@
|
||||
#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
|
159
src/apps/terminal/MYOB/ToggleScrollView.cpp
Normal file
159
src/apps/terminal/MYOB/ToggleScrollView.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
#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;
|
||||
}
|
61
src/apps/terminal/MYOB/ToggleScrollView.h
Normal file
61
src/apps/terminal/MYOB/ToggleScrollView.h
Normal file
@ -0,0 +1,61 @@
|
||||
#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
|
8228
src/apps/terminal/MYOB/UTF8WidthTbl.c
Normal file
8228
src/apps/terminal/MYOB/UTF8WidthTbl.c
Normal file
File diff suppressed because it is too large
Load Diff
63
src/apps/terminal/MYOB/VTKeyTbl.c
Normal file
63
src/apps/terminal/MYOB/VTKeyTbl.c
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 "VTkeymap.h"
|
||||
|
||||
int function_keycode_table[] =
|
||||
{
|
||||
F1_KEY,
|
||||
F2_KEY,
|
||||
F3_KEY,
|
||||
F4_KEY,
|
||||
F5_KEY,
|
||||
F6_KEY,
|
||||
F7_KEY,
|
||||
F8_KEY,
|
||||
F9_KEY,
|
||||
F10_KEY,
|
||||
F11_KEY,
|
||||
F12_KEY,
|
||||
};
|
||||
|
||||
char *function_key_char_table [] =
|
||||
{
|
||||
"[11~",
|
||||
"[12~",
|
||||
"[13~",
|
||||
"[14~",
|
||||
"[15~",
|
||||
"[16~",
|
||||
"[17~",
|
||||
"[18~",
|
||||
"[19~",
|
||||
"[20~",
|
||||
"[21~",
|
||||
"[22~",
|
||||
};
|
4710
src/apps/terminal/MYOB/VTPrsTbl.c
Normal file
4710
src/apps/terminal/MYOB/VTPrsTbl.c
Normal file
File diff suppressed because it is too large
Load Diff
81
src/apps/terminal/MYOB/VTkeymap.h
Normal file
81
src/apps/terminal/MYOB/VTkeymap.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#define CASE_IGNORE 0
|
||||
#define CASE_FUNCTION 1
|
||||
#define CASE_UP_ARROW 2
|
||||
#define CASE_DOWN_ARROW 3
|
||||
#define CASE_RIGHT_ARROW 4
|
||||
#define CASE_LEFT_ARROW 5
|
||||
#define CASE_RET_ENTR 6
|
||||
|
||||
#define F1_KEY 0x02
|
||||
#define F2_KEY 0x03
|
||||
#define F3_KEY 0x04
|
||||
#define F4_KEY 0x05
|
||||
#define F5_KEY 0x06
|
||||
#define F6_KEY 0x07
|
||||
#define F7_KEY 0x08
|
||||
#define F8_KEY 0x09
|
||||
#define F9_KEY 0x0a
|
||||
#define F10_KEY 0x0b
|
||||
#define F11_KEY 0x0c
|
||||
#define F12_KEY 0x0d
|
||||
|
||||
#define RETURN_KEY 0x47
|
||||
#define ENTER_KEY 0x5b
|
||||
|
||||
#define LEFT_ARROW_KEY 0x61
|
||||
#define RIGHT_ARROW_KEY 0x63
|
||||
#define UP_ARROW_KEY 0x57
|
||||
#define DOWN_ARROW_KEY 0x62
|
||||
|
||||
#define HOME_KEY 0x20
|
||||
#define INSERT_KEY 0x1f
|
||||
#define END_KEY 0x35
|
||||
#define PAGE_UP_KEY 0x21
|
||||
#define PAGE_DOWN_KEY 0x36
|
||||
|
||||
|
||||
|
||||
#define LEFT_ARROW_KEY_CODE "[D"
|
||||
#define RIGHT_ARROW_KEY_CODE "[C"
|
||||
#define UP_ARROW_KEY_CODE "[A"
|
||||
#define DOWN_ARROW_KEY_CODE "[B"
|
||||
|
||||
#define HOME_KEY_CODE "[@"
|
||||
#define INSERT_KEY_CODE "[2~"
|
||||
#define END_KEY_CODE "[["
|
||||
#define PAGE_UP_KEY_CODE "[5~"
|
||||
#define PAGE_DOWN_KEY_CODE "[6~"
|
||||
|
||||
//#define IS_DOWN_KEY(x) (info.key_states[(x) / 8] & key_state_table[(x) % 8])
|
||||
#define IS_DOWN_KEY(x) \
|
||||
(info.key_states[(x) >> 3] & (1 << (7 - ((x) % 8))))
|
118
src/apps/terminal/MYOB/VTparse.h
Normal file
118
src/apps/terminal/MYOB/VTparse.h
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define CASE_GROUND_STATE 0
|
||||
#define CASE_IGNORE_STATE 1
|
||||
#define CASE_IGNORE_ESC 2
|
||||
#define CASE_IGNORE 3
|
||||
#define CASE_BELL 4
|
||||
#define CASE_BS 5
|
||||
#define CASE_CR 6
|
||||
#define CASE_ESC 7
|
||||
#define CASE_VMOT 8
|
||||
#define CASE_TAB 9
|
||||
#define CASE_LF 10
|
||||
#define CASE_SI 11
|
||||
#define CASE_SO 12
|
||||
#define CASE_SP 13
|
||||
#define CASE_SCR_STATE 14
|
||||
#define CASE_SCS0_STATE 15
|
||||
#define CASE_SCS1_STATE 16
|
||||
#define CASE_SCS2_STATE 17
|
||||
#define CASE_SCS3_STATE 18
|
||||
#define CASE_ESC_IGNORE 19
|
||||
#define CASE_ESC_DIGIT 20
|
||||
#define CASE_ESC_SEMI 21
|
||||
#define CASE_DEC_STATE 22
|
||||
#define CASE_ICH 23
|
||||
#define CASE_CUU 24
|
||||
#define CASE_CUD 25
|
||||
#define CASE_CUF 26
|
||||
#define CASE_CUB 27
|
||||
#define CASE_CUP 28
|
||||
#define CASE_ED 29
|
||||
#define CASE_EL 30
|
||||
#define CASE_IL 31
|
||||
#define CASE_DL 32
|
||||
#define CASE_DCH 33
|
||||
#define CASE_DA1 34
|
||||
#define CASE_TRACK_MOUSE 35
|
||||
#define CASE_TBC 36
|
||||
#define CASE_SET 37
|
||||
#define CASE_RST 38
|
||||
#define CASE_SGR 39
|
||||
#define CASE_CPR 40
|
||||
#define CASE_DECSTBM 41
|
||||
#define CASE_DECREQTPARM 42
|
||||
#define CASE_DECSET 43
|
||||
#define CASE_DECRST 44
|
||||
#define CASE_DECALN 45
|
||||
#define CASE_GSETS 46
|
||||
#define CASE_DECSC 47
|
||||
#define CASE_DECRC 48
|
||||
#define CASE_DECKPAM 49
|
||||
#define CASE_DECKPNM 50
|
||||
#define CASE_IND 51
|
||||
#define CASE_NEL 52
|
||||
#define CASE_HTS 53
|
||||
#define CASE_RI 54
|
||||
#define CASE_SS2 55
|
||||
#define CASE_SS3 56
|
||||
#define CASE_CSI_STATE 57
|
||||
#define CASE_OSC 58
|
||||
#define CASE_RIS 59
|
||||
#define CASE_LS2 60
|
||||
#define CASE_LS3 61
|
||||
#define CASE_LS3R 62
|
||||
#define CASE_LS2R 63
|
||||
#define CASE_LS1R 64
|
||||
#define CASE_PRINT 65
|
||||
#define CASE_XTERM_SAVE 66
|
||||
#define CASE_XTERM_RESTORE 67
|
||||
#define CASE_XTERM_TITLE 68
|
||||
#define CASE_DECID 69
|
||||
#define CASE_HP_MEM_LOCK 70
|
||||
#define CASE_HP_MEM_UNLOCK 71
|
||||
#define CASE_HP_BUGGY_LL 72
|
||||
#define CASE_TO_STATUS 73
|
||||
#define CASE_FROM_STATUS 74
|
||||
#define CASE_SHOW_STATUS 75
|
||||
#define CASE_HIDE_STATUS 76
|
||||
#define CASE_ERASE_STATUS 77
|
||||
#define CASE_MBCS 78
|
||||
#define CASE_SCS_STATE 79
|
||||
#define CASE_UTF8_2BYTE 80
|
||||
#define CASE_UTF8_3BYTE 81
|
||||
#define CASE_UTF8_INSTRING 82
|
||||
#define CASE_SJIS_INSTRING 83
|
||||
#define CASE_SJIS_KANA 84
|
||||
#define CASE_PRINT_GR 85
|
||||
#define CASE_PRINT_CS96 86
|
473
src/apps/terminal/MYOB/spawn.cpp
Normal file
473
src/apps/terminal/MYOB/spawn.cpp
Normal file
@ -0,0 +1,473 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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 <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <kernel/OS.h>
|
||||
|
||||
#include "TermConst.h"
|
||||
#include "spawn.h"
|
||||
#include "PrefHandler.h"
|
||||
|
||||
extern PrefHandler *gTermPref;
|
||||
|
||||
/* default shell command and options. */
|
||||
#define SHELL_COMMAND "/bin/sh -login"
|
||||
extern char **environ;
|
||||
|
||||
char spawn_alert_msg [] = \
|
||||
"alert --stop " \
|
||||
"'MuTerminal Error!!\n\
|
||||
Cannot execute shell [%s].\n\
|
||||
Check \"Shell\" in preferance panel.' "\
|
||||
"'Exec /bin/sh' 'Abort'";
|
||||
|
||||
/*
|
||||
* Set environment varriable.
|
||||
*/
|
||||
|
||||
void
|
||||
Setenv (const char *var, const char *value)
|
||||
{
|
||||
int envindex = 0;
|
||||
const int len = strlen(var);
|
||||
const int val_len = strlen (value);
|
||||
|
||||
while (environ [envindex] != NULL) {
|
||||
if (strncmp (environ [envindex], var, len) == 0) {
|
||||
/* found it */
|
||||
environ[envindex] = (char *)malloc ((unsigned)len + val_len + 1);
|
||||
sprintf (environ [envindex], "%s%s", var, value);
|
||||
return;
|
||||
}
|
||||
envindex ++;
|
||||
}
|
||||
|
||||
environ [envindex] = (char *) malloc ((unsigned)len + val_len + 1);
|
||||
sprintf (environ [envindex], "%s%s", var, value);
|
||||
environ [++envindex] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* reapchild. Child process is out there, let's catch its terminaltion.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* spawn_shell(): spawn child process, create pty master/slave device and
|
||||
* execute SHELL program.
|
||||
*/
|
||||
|
||||
/* This pipe use handshake on exec. */
|
||||
int pc_pipe[2]; /* this pipe is used for parent to child transfer */
|
||||
int cp_pipe[2]; /* this pipe is used for child to parent transfer */
|
||||
|
||||
/* handshake interface */
|
||||
typedef struct
|
||||
{
|
||||
int status; /* status of child */
|
||||
char msg[256]; /* error message */
|
||||
int row; /* terminal rows */
|
||||
int col; /* Terminal columns */
|
||||
} handshake_t;
|
||||
|
||||
/* status of handshake */
|
||||
#define PTY_OK 0 /* pty open and set termios OK */
|
||||
#define PTY_NG 1 /* pty open or set termios NG */
|
||||
#define PTY_WS 2 /* pty need WINSIZE (row and col ) */
|
||||
|
||||
/* global varriables */
|
||||
|
||||
pid_t sh_pid;
|
||||
char tty_name[16];
|
||||
int pfd_num = 0;
|
||||
|
||||
int
|
||||
spawn_shell (int row, int col, const char *command, const char *coding)
|
||||
{
|
||||
int done = 0;
|
||||
char *s;
|
||||
char *t = 0;
|
||||
pid_t pgrp;
|
||||
|
||||
int master = 0;
|
||||
int slave;
|
||||
struct termio tio;
|
||||
struct winsize ws;
|
||||
|
||||
handshake_t handshake;
|
||||
|
||||
char pty_name[16];
|
||||
|
||||
int i = 0;
|
||||
time_t now_time_t;
|
||||
struct tm *now_time;
|
||||
int now_hour;
|
||||
|
||||
char *args[16];
|
||||
char com_line[256];
|
||||
char *ptr;
|
||||
|
||||
char err_msg[256];
|
||||
|
||||
signal (SIGTTOU, SIG_IGN);
|
||||
|
||||
/*
|
||||
* Get a psuedo-tty. We do this by cycling through all the possible
|
||||
* names. The oparationg system will not allow us to open a master
|
||||
* which is already in use, so we simply go until the open successed.
|
||||
*/
|
||||
|
||||
for (s = PTYCHAR1; *s != 0; s++) {
|
||||
for (t = PTYCHAR2; *t != 0; t++) {
|
||||
sprintf (pty_name, PTYDEV, *s, *t);
|
||||
if ((master = open (pty_name, O_RDWR)) >= 0)
|
||||
goto out;
|
||||
pfd_num++;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
/*
|
||||
* If s and t are NULL, we ran out of pseudo ttys before we found
|
||||
* one we can use
|
||||
*/
|
||||
if ((*s == 0) && (*t == 0)) {
|
||||
printf ("don't found pesudo ttys.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Change "/dev/pt/XX (master) to "/dev/tt/XX" (slave). */
|
||||
|
||||
sprintf (pty_name,"%c%c", *s, *t);
|
||||
sprintf (tty_name, TTYDEV, *s, *t);
|
||||
|
||||
/*
|
||||
* Get the modes of the current terminal. We will duplicates these
|
||||
* on the pseudo terminal.
|
||||
*/
|
||||
|
||||
/* Create pipe that be use to handshake */
|
||||
if ( pipe (pc_pipe) || pipe (cp_pipe)) {
|
||||
printf ("Could not create handshake pipe.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If set prosess group ID is MuTerminal process ID, MuTerminal
|
||||
* ignore SIGINT for exec Terminal.
|
||||
*
|
||||
* pgrp = getpid ();
|
||||
* setpgid (0, pgrp);
|
||||
*/
|
||||
|
||||
/* Fork a child process. */
|
||||
if ((sh_pid=fork()) < 0) {
|
||||
close (master);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sh_pid == 0) {
|
||||
/*
|
||||
* Now in child process.
|
||||
*/
|
||||
|
||||
/* close master pty and control tty. */
|
||||
// close (tty);
|
||||
// for (i = 0; i <= 2; i++)
|
||||
// close (i);
|
||||
|
||||
/*
|
||||
* Make our controlling tty the pseudo tty. This hapens because
|
||||
* we cleared our original controlling terminal above.
|
||||
*/
|
||||
|
||||
close (cp_pipe[0]);
|
||||
close (pc_pipe[1]);
|
||||
|
||||
/* Set process session leader */
|
||||
if ((pgrp = setsid()) < 0) {
|
||||
handshake.status = PTY_NG;
|
||||
sprintf (handshake.msg, "could not set session leader.");
|
||||
write (cp_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* change pty owner and asscess mode. */
|
||||
chown (tty_name, getuid(), getgid());
|
||||
chmod (tty_name, S_IRUSR | S_IWUSR);
|
||||
|
||||
/* open slave pty */
|
||||
if ((slave = open (tty_name, O_RDWR)) < 0) {
|
||||
handshake.status = PTY_NG;
|
||||
sprintf (handshake.msg, "can't open tty (%s).", tty_name);
|
||||
write (cp_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* get tty termios (don't necessary). */
|
||||
tcgetattr (slave, &tio);
|
||||
|
||||
/* set signal default */
|
||||
signal (SIGCHLD, SIG_DFL);
|
||||
signal (SIGHUP, SIG_DFL);
|
||||
signal (SIGQUIT, SIG_DFL);
|
||||
signal (SIGTERM, SIG_DFL);
|
||||
signal (SIGINT, SIG_DFL);
|
||||
signal (SIGTTOU, SIG_DFL);
|
||||
|
||||
/*
|
||||
* Set Terminal interface.
|
||||
*/
|
||||
|
||||
tio.c_line = 0;
|
||||
|
||||
tio.c_lflag |= ECHOE;
|
||||
|
||||
/* input: nl->nl, cr->nl */
|
||||
tio.c_iflag &= ~(INLCR|IGNCR);
|
||||
tio.c_iflag |= ICRNL;
|
||||
tio.c_iflag &= ~ISTRIP;
|
||||
|
||||
/* output: cr->cr, nl in not retrun, no delays, ln->cr/ln */
|
||||
tio.c_oflag &= ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
|
||||
tio.c_oflag |= ONLCR;
|
||||
tio.c_oflag |= OPOST;
|
||||
|
||||
|
||||
/* baud rate is 19200 (equal beterm) */
|
||||
tio.c_cflag &= ~(CBAUD);
|
||||
tio.c_cflag |= B19200;
|
||||
|
||||
tio.c_cflag &= ~CSIZE;
|
||||
tio.c_cflag |= CS8;
|
||||
tio.c_cflag |= CREAD;
|
||||
|
||||
tio.c_cflag |= HUPCL;
|
||||
tio.c_iflag &= ~(IGNBRK|BRKINT);
|
||||
|
||||
/*
|
||||
* enable signals, canonical processing (erase, kill, etc), echo.
|
||||
*/
|
||||
tio.c_lflag |= ISIG|ICANON|ECHO|ECHOE|ECHONL;
|
||||
tio.c_lflag &= ~ECHOK;
|
||||
|
||||
tio.c_lflag &= ~IEXTEN;
|
||||
|
||||
|
||||
/* set control charactors. */
|
||||
tio.c_cc[VINTR] = 'C' & 0x1f; /* '^C' */
|
||||
tio.c_cc[VQUIT] = CQUIT; /* '^\' */
|
||||
tio.c_cc[VERASE] = 0x08; /* '^H' */
|
||||
tio.c_cc[VKILL] = 'U' & 0x1f; /* '^U' */
|
||||
tio.c_cc[VEOF] = CEOF; /* '^D' */
|
||||
tio.c_cc[VEOL] = CEOL; /* '^@' */
|
||||
tio.c_cc[VMIN] = 4;
|
||||
tio.c_cc[VTIME] = 0;
|
||||
tio.c_cc[VEOL2] = CEOL; /* '^@' */
|
||||
tio.c_cc[VSWTCH] = CSWTCH; /* '^@' */
|
||||
tio.c_cc[VSTART] = CSTART; /* '^S' */
|
||||
tio.c_cc[VSTOP] = CSTOP; /* '^Q' */
|
||||
tio.c_cc[VSUSP] = CSUSP; /* '^@' */
|
||||
|
||||
/*
|
||||
* change control tty.
|
||||
*/
|
||||
|
||||
dup2 (slave, 0);
|
||||
dup2 (slave, 1);
|
||||
dup2 (slave, 2);
|
||||
|
||||
/* close old slave fd. */
|
||||
if (slave > 2)
|
||||
close (slave);
|
||||
|
||||
/*
|
||||
* set terminal interface.
|
||||
*/
|
||||
if (tcsetattr (0, TCSANOW, &tio) == -1) {
|
||||
handshake.status = PTY_NG;
|
||||
sprintf (handshake.msg, "failed set terminal interface (TERMIOS).");
|
||||
write (cp_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* set window size.
|
||||
*/
|
||||
|
||||
handshake.status = PTY_WS;
|
||||
write (cp_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
read (pc_pipe[0], (char *)&handshake, sizeof (handshake));
|
||||
|
||||
if (handshake.status != PTY_WS) {
|
||||
handshake.status = PTY_NG;
|
||||
sprintf (handshake.msg, "missmatch handshake.");
|
||||
write (cp_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
ws.ws_row = handshake.row;
|
||||
ws.ws_col = handshake.col;
|
||||
|
||||
ioctl (0, TIOCSWINSZ, &ws);
|
||||
|
||||
/*
|
||||
* Set process group ID to process, and Terminal Process group ID
|
||||
* to this process group ID (equal process ID).
|
||||
*/
|
||||
|
||||
pgrp = getpid ();
|
||||
setpgid (pgrp, pgrp);
|
||||
tcsetpgrp (0, pgrp);
|
||||
|
||||
/* mark the pipes as close on exec */
|
||||
fcntl( cp_pipe[1], F_SETFD, 1);
|
||||
fcntl( pc_pipe[0], F_SETFD, 1);
|
||||
|
||||
/* pty open and set termios successful. */
|
||||
handshake.status = PTY_OK;
|
||||
write (cp_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
|
||||
/*
|
||||
* setenv TERM and TTY.
|
||||
*/
|
||||
Setenv ("TERM=", "xterm");
|
||||
Setenv ("TTY=",tty_name);
|
||||
Setenv ("TTYPE=", coding);
|
||||
|
||||
/*
|
||||
* If don't set command args, exec SHELL_COMMAND.
|
||||
*/
|
||||
if (command == NULL) {
|
||||
command = SHELL_COMMAND;
|
||||
}
|
||||
|
||||
memcpy (com_line, command, 256);
|
||||
ptr = com_line;
|
||||
|
||||
/*
|
||||
* split up the arguments in the command into an artv-like structure.
|
||||
*/
|
||||
|
||||
while (*ptr) {
|
||||
/* Skip white space */
|
||||
while ((*ptr == ' ') || (*ptr == '\t'))
|
||||
*ptr++ = 0;
|
||||
args[i++] = ptr;
|
||||
|
||||
/* Skip over this word to next white space. */
|
||||
while ((*ptr != 0) && (*ptr != ' ') && (*ptr != '\t'))
|
||||
ptr++;
|
||||
}
|
||||
|
||||
args[i] = NULL;
|
||||
|
||||
Setenv ("SHELL=", *args);
|
||||
|
||||
/*
|
||||
* Print Welcome MuTerm World! Message.
|
||||
* (But, Only print message when MuTerminal coding is UTF8.)
|
||||
*/
|
||||
now_time_t = time(NULL);
|
||||
now_time = localtime (&now_time_t);
|
||||
|
||||
if (now_time->tm_hour >= 5 && now_time->tm_hour < 11) {
|
||||
now_hour = 0;
|
||||
} else if (now_time->tm_hour >= 11 && now_time->tm_hour <= 18 ) {
|
||||
now_hour = 1;
|
||||
} else {
|
||||
now_hour = 2;
|
||||
}
|
||||
|
||||
execve (*args, args, environ);
|
||||
|
||||
/*
|
||||
* Exec failed.
|
||||
*/
|
||||
sleep (1);
|
||||
sprintf (err_msg, spawn_alert_msg, com_line);
|
||||
|
||||
if (system (err_msg) == 0)
|
||||
execl ("/bin/sh", "/bin/sh", "-login", NULL);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* In parent Process, Set up the input and output file pointers so
|
||||
* that they can write and read the pseudo terminal.
|
||||
*/
|
||||
|
||||
/* close childs's side of the pipe */
|
||||
close (cp_pipe[1]);
|
||||
close (pc_pipe[0]);
|
||||
|
||||
/*
|
||||
* close parent control tty.
|
||||
*/
|
||||
|
||||
while (!done) {
|
||||
read (cp_pipe[0], (char *)&handshake, sizeof (handshake));
|
||||
|
||||
switch (handshake.status) {
|
||||
case PTY_OK:
|
||||
done = 1;
|
||||
break;
|
||||
|
||||
case PTY_NG:
|
||||
printf ("%s\n", handshake.msg);
|
||||
done = -1;
|
||||
break;
|
||||
|
||||
case PTY_WS:
|
||||
handshake.row = row;
|
||||
handshake.col = col;
|
||||
handshake.status = PTY_WS;
|
||||
write (pc_pipe[1], (char *)&handshake, sizeof (handshake));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (done > 0) ? master : -1;
|
||||
}
|
||||
|
107
src/apps/terminal/MYOB/spawn.h
Normal file
107
src/apps/terminal/MYOB/spawn.h
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SPAWN_H
|
||||
#define SPAWN_H
|
||||
|
||||
/*
|
||||
* allow for mobility of the pty master/slave directories
|
||||
*/
|
||||
|
||||
#define PTYDEV "/dev/pt/%c%c"
|
||||
#define TTYDEV "/dev/tt/%c%c"
|
||||
|
||||
#define PTYCHAR1 "pqrs"
|
||||
#define PTYCHAR2 "0123456789abcdef"
|
||||
|
||||
#define TTYFORMAT "/dev/tt/%d"
|
||||
#define PTYFORMAT "/dev/pt/%d"
|
||||
|
||||
#define MAXPTTYS 16 * 4
|
||||
|
||||
#ifndef CEOF
|
||||
#define CEOF ('D'&037)
|
||||
#endif
|
||||
#ifndef CSUSP
|
||||
#define CSUSP ('@'&037)
|
||||
#endif
|
||||
#ifndef CQUIT
|
||||
#define CQUIT ('\\'&037)
|
||||
#endif
|
||||
#ifndef CEOL
|
||||
#define CEOL 0
|
||||
#endif
|
||||
#ifndef CSTOP
|
||||
#define CSTOP ('Q'&037)
|
||||
#endif
|
||||
#ifndef CSTART
|
||||
#define CSTART ('S'&037)
|
||||
#endif
|
||||
#ifndef CSWTCH
|
||||
#define CSWTCH 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ANSI emulation.
|
||||
*/
|
||||
#define INQ 0x05
|
||||
#define FF 0x0C /* C0, C1 control names */
|
||||
#define LS1 0x0E
|
||||
#define LS0 0x0F
|
||||
#define CAN 0x18
|
||||
#define SUB 0x1A
|
||||
#define ESC 0x1B
|
||||
#define US 0x1F
|
||||
#define DEL 0x7F
|
||||
#define HTS ('H'+0x40)
|
||||
#define SS2 0x8E
|
||||
#define SS3 0x8F
|
||||
#define DCS 0x90
|
||||
#define OLDID 0x9A /* ESC Z */
|
||||
#define CSI 0x9B
|
||||
#define ST 0x9C
|
||||
#define OSC 0x9D
|
||||
#define PM 0x9E
|
||||
#define APC 0x9F
|
||||
#define RDEL 0xFF
|
||||
|
||||
/*
|
||||
* Prototype:
|
||||
*/
|
||||
|
||||
int spawn_shell (int, int, const char *, const char *);
|
||||
void Setenv (const char *, const char *);
|
||||
|
||||
extern pid_t sh_pid; /* shell process ID */
|
||||
extern char tty_name[]; /* tty device file name */
|
||||
extern int pfd_num; /* number of pfd */
|
||||
|
||||
|
||||
#endif /* SPAWN_H */
|
Loading…
Reference in New Issue
Block a user