* Removed useless context menu.

* Removed useless mouse button preferences.
* The secondary and tertiary buttons now both paste the selection (or clipboard data)
  into the Terminal, this fixes bug #1159.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20772 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-04-20 16:09:27 +00:00
parent 15b4543f2c
commit ef502a7eb3
4 changed files with 313 additions and 486 deletions
+1 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2006, Haiku, Inc. All Rights Reserved.
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Copyright (c) 2004 Daniel Furrer <[email protected]>
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
@@ -55,9 +55,6 @@ static const pref_defaults kTermDefaults[] = {
{ 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"},
+38 -73
View File
@@ -1,4 +1,5 @@
/*
* Copyright 2001-2007, Haiku.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
@@ -30,27 +31,16 @@
#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"
//////////////////////////////////////////////////////////////////////////////
// Signature of R5's Terminal. Needed for proper drop-in window count support
//////////////////////////////////////////////////////////////////////////////
#define R5_TERM_SIGNATURE "application/x-vnd.Be-SHEL"
//////////////////////////////////////////////////////////////////////////////
// Message constants for menu items.
//////////////////////////////////////////////////////////////////////////////
// Message constants for menu items
// Menu Message.
//
// Menu Message
const uint32 MENU_SWITCH_TERM = 'MSWT';
const uint32 MENU_NEW_TERM = 'MNTE';
const uint32 MENU_PREF_OPEN = 'MPre';
@@ -69,13 +59,11 @@ const uint32 MENU_SHOW_COLOR = 'Mcol';
const uint32 M_GET_DEVICE_NUM = 'Mgdn';
// Message Runner.
// Message Runner
const uint32 MSGRUN_CURSOR = 'Rcur';
const uint32 MSGRUN_WINDOW = 'Rwin';
// Preference Message.
//
// Preference Message
const ulong PSET__COLS = 'pcol';
const ulong PSET__ROWS = 'prow';
const ulong PSET__HFONT = 'phfn';
@@ -95,52 +83,43 @@ const uint32 ONETHREETWOTWENTYFIVE = 'hunv';
const uint32 FULLSCREEN = 'fscr';
const uint32 MSG_FONT_CHANGED = 'fntc';
const uint32 SAVE_AS_DEFAULT = 'sadf';
////////////////////////////////////////////////////////////////////////////
// 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_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_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_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_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_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_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_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";
const char * const PREF_TEXT_ENCODING = "Text encoding";
const char * const PREF_GUI_LANGUAGE = "Language";
////////////////////////////////////////////////////////////////////////////
// Color type
////////////////////////////////////////////////////////////////////////////
enum {
TEXT_FOREGROUND_COLOR,
TEXT_BACKGROUND_COLOR,
@@ -148,26 +127,21 @@ enum {
SELECTION_BACKGROUND_COLOR
};
////////////////////////////////////////////////////////////////////////////
// Preference Folder and setting path
////////////////////////////////////////////////////////////////////////////
const int32 DEFAULT = -1;
////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////
/* Font Width */
// Font Width
const int HALF_WIDTH = 1;
const int FULL_WIDTH = 2;
/* Scroll direction flag */
// Scroll direction flag
enum{
SCRUP,
SCRDOWN
};
/* Insert mode flag */
// Insert mode flag
#define MODE_OVER 0
#define MODE_INSERT 1
@@ -179,15 +153,12 @@ const float VIEW_OFFSET = 3;
fFontWidth * (fCurPos.x + 1) - 1, \
fFontHeight * fCurPos.y + fTop + fCursorHeight - 1)
////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////
/* Define TermBuffer internal code */
// Define TermBuffer internal code
#define NO_CHAR 0x00
#define A_CHAR 0x01
#define IN_STRING 0xFF
/* TermBuffer extended attribute */
// TermBuffer extended attribute
#define A_WIDTH 0x8000
#define BOLD 0x4000
#define UNDERLINE 0x2000
@@ -216,20 +187,14 @@ const float VIEW_OFFSET = 3;
#define FORECOLORED(x) ((x) << 3)
#define BACKCOLORED(x) ((x) << 0)
////////////////////////////////////////////////////////////////////////////
// TypeDefs
////////////////////////////////////////////////////////////////////////////
typedef unsigned short ushort;
typedef struct
{
typedef struct {
int x1;
int y1;
int x2;
int y2;
}
sDrawRect;
} sDrawRect;
#endif //TERMCONST_H_INCLUDED
#endif // TERMCONST_H_INCLUDED
+27 -90
View File
@@ -10,6 +10,20 @@
*/
#include "TermView.h"
#include "TermWindow.h"
#include "TermApp.h"
#include "TermParse.h"
#include "TermBuffer.h"
#include "CodeConv.h"
#include "VTkeymap.h"
#include "TermConst.h"
#include "PrefHandler.h"
#include "MenuUtil.h"
#include "PrefView.h"
#include "spawn.h"
#include <Autolock.h>
#include <Beep.h>
#include <Clipboard.h>
@@ -29,19 +43,6 @@
#include <new>
#include "TermView.h"
#include "TermWindow.h"
#include "TermApp.h"
#include "TermParse.h"
#include "TermBuffer.h"
#include "CodeConv.h"
#include "VTkeymap.h"
#include "TermConst.h"
#include "PrefHandler.h"
#include "MenuUtil.h"
#include "PrefView.h"
#include "spawn.h"
using std::nothrow;
// defined VTKeyTbl.c
@@ -93,9 +94,6 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv, int fd)
fScrBot(fTermRows - 1),
fScrBufSize(gTermPref->getInt32(PREF_HISTORY_SIZE)),
fScrRegionSet(0),
fPopMenu(NULL),
fPopEncoding(NULL),
fPopSize(NULL),
fSelected(false),
fMouseTracking(false),
fViewThread(-1),
@@ -105,20 +103,19 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv, int fd)
fDrawRect_p(0),
fIMflag(false)
{
// Cursor reset.
// Reset cursor
fCurPos.Set(0, 0);
fCurStack.Set(0, 0);
fPreviousMousePoint.Set(0, 0);
fSelStart.Set(-1, -1);
fSelEnd.Set(-1, -1);
SetMouseButton();
SetMouseCursor();
SetTermFont(be_plain_font, be_plain_font);
//SetIMAware(gTermPref->getInt32(PREF_IM_AWARE));
InitViewThread();
_InitViewThread();
}
@@ -166,16 +163,6 @@ TermView::SetTermSize(int rows, int cols, bool resize)
}
//! Set mouse button assignments
void
TermView::SetMouseButton()
{
mSelectButton = SetupMouseButton(gTermPref->getString(PREF_SELECT_MBUTTON));
mSubMenuButton = SetupMouseButton(gTermPref->getString(PREF_SUBMENU_MBUTTON));
mPasteMenuButton = SetupMouseButton(gTermPref->getString(PREF_PASTE_MBUTTON));
}
//! Sets the mouse cursor image
void
TermView::SetMouseCursor()
@@ -744,7 +731,7 @@ TermView::ScrollAtCursor()
thread_id
TermView::InitViewThread()
TermView::_InitViewThread()
{
// spwan Draw Engine thread.
if (fViewThread < 0) {
@@ -1735,75 +1722,37 @@ TermView::WritePTY(const uchar *text, int numBytes)
}
//! Make encoding pop up menu (make copy of window's one.)
void
TermView::SetupPop(void)
{
fPopMenu = new BPopUpMenu("");
MakeEncodingMenu(fPopMenu, gNowCoding, true);
fPopMenu->SetTargetForItems(Window());
}
// convert button name to number.
int32
TermView::SetupMouseButton(const char *bname)
{
if (!strcmp(bname, "Disable"))
return 0;
if (!strcmp(bname, "Button 1"))
return B_PRIMARY_MOUSE_BUTTON;
if (!strcmp(bname, "Button 2"))
return B_SECONDARY_MOUSE_BUTTON;
if (!strcmp(bname, "Button 3"))
return B_TERTIARY_MOUSE_BUTTON;
return 0; //Disable
}
void
TermView::MouseDown(BPoint where)
{
int32 buttons = 0, clicks = 0;
int32 mod;
BPoint inPoint;
ssize_t num_bytes;
int32 buttons;
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
// paste button
if (buttons == mPasteMenuButton) {
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
if (fSelected) {
// If selected region, copy text from region.
BString copyStr("");
fTextBuffer->GetStringFromRegion(copyStr);
num_bytes = copyStr.Length();
WritePTY((uchar *)copyStr.String(), num_bytes);
// copy text from region
BString copy;
fTextBuffer->GetStringFromRegion(copy);
WritePTY((uchar *)copy.String(), copy.Length());
} else {
// If don't selected, copy text from clipboard.
// copy text from clipboard.
DoPaste();
}
return;
}
// Select Region
if (buttons == mSelectButton) {
if (buttons == B_PRIMARY_MOUSE_BUTTON) {
int32 mod, clicks;
Window()->CurrentMessage()->FindInt32("modifiers", &mod);
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
if (fSelected) {
CurPos inPos, stPos, edPos;
if (fSelStart < fSelEnd) {
stPos = fSelStart;
edPos = fSelEnd;
} else {
stPos = fSelEnd;
edPos = fSelStart;
@@ -1814,12 +1763,9 @@ TermView::MouseDown(BPoint where)
// If mouse pointer is avove selected Region, start Drag'n Copy.
if (inPos > stPos && inPos < edPos) {
if (mod & B_CONTROL_KEY || gTermPref->getInt32(PREF_DRAGN_COPY)) {
BPoint p;
uint32 bt;
do {
GetMouse(&p, &bt);
if (bt == 0) {
@@ -1861,7 +1807,7 @@ TermView::MouseDown(BPoint where)
}
// If mouse has a lot of movement, disable double/triple click.
inPoint = fPreviousMousePoint - where;
BPoint inPoint = fPreviousMousePoint - where;
if (abs((int)inPoint.x) > 16 || abs((int)inPoint.y) > 16)
clicks = 1;
@@ -1895,15 +1841,6 @@ TermView::MouseDown(BPoint where)
return;
}
// Sub menu(coding popup menu)
if (buttons == mSubMenuButton){
ConvertToScreen(&where);
SetupPop();
fPopMenu->Go(where, true);
delete fPopMenu;
return;
}
BView::MouseDown(where);
}
+270 -342
View File
@@ -1,4 +1,5 @@
/*
* Copyright 2001-2007, Haiku.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
@@ -27,16 +28,17 @@
* THE SOFTWARE.
*
*/
#ifndef TERMVIEW_H
#define TERMVIEW_H
#include "CurPos.h"
#include "TermConst.h"
#include "TermWindow.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
@@ -47,44 +49,45 @@
#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,
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;
@@ -93,323 +96,248 @@ class BPopUpMenu;
class BScrollBar;
class BString;
class TermView : public BView
{
public:
//
// Constructor, Destructor, and Initializer.
//
TermView (BRect frame, CodeConv *inCodeConv, int fd);
~TermView ();
//
// Initializer, Set function
//
void SetTermFont(const BFont *halfFont, const 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);
BScrollBar *ScrollBar () const { return fScrollBar; };
//
// 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);
void UpdateLine (void);
void ScrollScreen (void);
void ScrollScreenDraw (void);
void GetFrameSize (float *width, float *height);
void GetFontInfo (int *, int*);
bool Find (const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
void GetSelection (BString &str);
/*
* 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.
*/
int fTerminalFd;
//
// Font and Width.
//
BFont fHalfFont;
BFont fFullFont;
int fFontWidth;
int fFontHeight;
class TermView : public BView {
public:
TermView(BRect frame, CodeConv *inCodeConv, int fd);
~TermView();
void SetTermFont(const BFont *halfFont, const BFont *fullFont);
void GetFontSize(int *width, int *height);
BRect SetTermSize(int rows, int cols, bool flag);
void SetTermColor();
void SetMouseCursor();
// void SetIMAware (bool);
void SetScrollBar(BScrollBar *scrbar);
BScrollBar *ScrollBar() const { return fScrollBar; };
// 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 DeleteChar(int num);
void DeleteColumns();
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();
int GetCurY();
void SaveCursor();
void RestoreCursor();
// Move Cursor
void MoveCurRight(int num);
void MoveCurLeft(int num);
void MoveCurUp(int num);
void MoveCurDown(int num);
// Cursor setting
void DrawCursor();
void BlinkCursor();
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();
// Other
void UpdateSIGWINCH();
void DeviceStatusReport(int);
void UpdateLine();
void ScrollScreen();
void ScrollScreenDraw();
void GetFrameSize(float *width, float *height);
void GetFontInfo(int *, int*);
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
void GetSelection(BString &str);
protected:
virtual void AttachedToWindow(void);
virtual void Draw(BRect updateRect);
virtual void WindowActivated(bool active);
virtual void KeyDown(const char*, int32);
virtual void MouseDown(BPoint where);
virtual void MouseMoved(BPoint, uint32, const BMessage *);
virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage* message);
private:
static int32 ViewThread(void *);
static int32 MouseTracking(void *);
thread_id _InitViewThread(void);
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 DoPaste();
void DoSelectAll();
void DoClearAll();
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
int32 SetupMouseButton(const char *bname);
// Mouse select
void Select(CurPos start, CurPos end);
void AddSelectRegion(CurPos);
void ResizeSelectRegion(CurPos);
void DeSelect();
// 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);
int fTerminalFd;
// 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;
int fFontAscent;
struct escapement_delta fEscapement;
// Terminal rows and columns.
int fTermRows;
int fTermColumns;
//
// Flags.
//
// Terminal view pointer.
int fTop;
// Update flag (Set on PutChar).
bool fUpdateFlag;
// Object pointer.
// Terminal insertmode flag (use PutChar).
bool fInsertModeFlag;
TermBuffer *fTextBuffer;
CodeConv *fCodeConv;
BScrollBar *fScrollBar;
// Scroll count, range.
int fScrollUpCount;
int fScrollBarRange;
// Offscreen Bitmap and View.
// Frame Resized flag.
bool fFrameResized;
BRect fSrcRect;
BRect fDstRect;
// Cursor Blinking, draw flag.
bool fCursorDrawFlag;
bool fCursorStatus;
bool fCursorBlinkingFlag;
bool fCursorRedrawFlag;
// Color and Attribute.
int fCursorHeight;
rgb_color fTextForeColor, fTextBackColor;
rgb_color fCursorForeColor, fCursorBackColor;
rgb_color fSelectForeColor, fSelectBackColor;
uchar fTermAttr;
// terminal text attribute flag.
bool fInverseFlag;
bool fBoldFlag;
bool fUnderlineFlag;
// Scroll Region
int fScrTop;
int fScrBot;
int fScrBufSize;
bool fScrRegionSet;
//
// Cursor position.
//
CurPos fCurPos;
CurPos fCurStack;
// mouse
int32 mSelectButton;
int32 mSubMenuButton;
int32 mPasteMenuButton;
int fBufferStartPos;
//
// Terminal rows and columns.
//
int fTermRows;
int fTermColumns;
//
// Terminal view pointer.
//
int fTop;
//
// Object pointer.
//
TermBuffer *fTextBuffer;
CodeConv *fCodeConv;
BScrollBar *fScrollBar;
bool fMouseImage;
//
// Offscreen Bitmap and View.
//
BPoint fPreviousMousePoint;
BRect fSrcRect;
BRect fDstRect;
// view selection
CurPos fSelStart;
CurPos fSelEnd;
bool fSelected;
bool fMouseTracking;
//
// Color and Attribute.
//
// thread ID / flags.
thread_id fViewThread;
thread_id fMouseThread;
bool fQuitting;
// text fore and back color
rgb_color fTextForeColor, fTextBackColor;
// DrawEngine parameter.
sem_id fDrawRectSem;
sDrawRect fDrawRectBuffer[RECT_BUF_SIZE];
int fDrawRect_p;
// 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;
bool fSelected;
bool fMouseTracking;
// thread ID / flags.
thread_id fViewThread;
thread_id fMouseThread;
bool 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;
// Input Method parameter.
int fIMViewPtr;
CurPos fIMStartPos;
CurPos fIMEndPos;
BString fIMString;
bool fIMflag;
BMessenger fIMMessenger;
int32 fImCodeState;
};