* 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) 2004 Daniel Furrer <[email protected]>
* Copyright (c) 2003-4 Kian Duffy <[email protected]> * Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright (c) 1998,99 Kazuho Okui and Takashi Murai. * Copyright (c) 1998,99 Kazuho Okui and Takashi Murai.
@@ -55,9 +55,6 @@ static const pref_defaults kTermDefaults[] = {
{ PREF_TEXT_ENCODING, "UTF-8" }, { 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_MOUSE_IMAGE, "Hand cursor"},
{ PREF_DRAGN_COPY, "0"}, { 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) 2003-4 Kian Duffy <[email protected]>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* *
@@ -30,27 +31,16 @@
#ifndef TERMCONST_H_INCLUDED #ifndef TERMCONST_H_INCLUDED
#define TERMCONST_H_INCLUDED #define TERMCONST_H_INCLUDED
#ifndef NODEBUG
#define MALLOC_DEBUG
#endif
//////////////////////////////////////////////////////////////////////////////
// Application signature (Must same in Muterminal.rsrc)// // Application signature (Must same in Muterminal.rsrc)//
//////////////////////////////////////////////////////////////////////////////
#define TERM_SIGNATURE "application/x-vnd.Haiku-Terminal" #define TERM_SIGNATURE "application/x-vnd.Haiku-Terminal"
#define PREFFILE_MIMETYPE "text/x-terminal-pref" #define PREFFILE_MIMETYPE "text/x-terminal-pref"
//////////////////////////////////////////////////////////////////////////////
// Signature of R5's Terminal. Needed for proper drop-in window count support // Signature of R5's Terminal. Needed for proper drop-in window count support
//////////////////////////////////////////////////////////////////////////////
#define R5_TERM_SIGNATURE "application/x-vnd.Be-SHEL" #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_SWITCH_TERM = 'MSWT';
const uint32 MENU_NEW_TERM = 'MNTE'; const uint32 MENU_NEW_TERM = 'MNTE';
const uint32 MENU_PREF_OPEN = 'MPre'; const uint32 MENU_PREF_OPEN = 'MPre';
@@ -69,13 +59,11 @@ const uint32 MENU_SHOW_COLOR = 'Mcol';
const uint32 M_GET_DEVICE_NUM = 'Mgdn'; const uint32 M_GET_DEVICE_NUM = 'Mgdn';
// Message Runner. // Message Runner
const uint32 MSGRUN_CURSOR = 'Rcur'; const uint32 MSGRUN_CURSOR = 'Rcur';
const uint32 MSGRUN_WINDOW = 'Rwin'; const uint32 MSGRUN_WINDOW = 'Rwin';
// Preference Message. // Preference Message
//
const ulong PSET__COLS = 'pcol'; const ulong PSET__COLS = 'pcol';
const ulong PSET__ROWS = 'prow'; const ulong PSET__ROWS = 'prow';
const ulong PSET__HFONT = 'phfn'; const ulong PSET__HFONT = 'phfn';
@@ -95,52 +83,43 @@ const uint32 ONETHREETWOTWENTYFIVE = 'hunv';
const uint32 FULLSCREEN = 'fscr'; const uint32 FULLSCREEN = 'fscr';
const uint32 MSG_FONT_CHANGED = 'fntc'; const uint32 MSG_FONT_CHANGED = 'fntc';
const uint32 SAVE_AS_DEFAULT = 'sadf'; const uint32 SAVE_AS_DEFAULT = 'sadf';
////////////////////////////////////////////////////////////////////////////
// Preference Read/Write Keys // Preference Read/Write Keys
//////////////////////////////////////////////////////////////////////////// const char* const PREF_HALF_FONT_FAMILY = "Half Font Famly";
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_STYLE = "Half Font Style"; const char* const PREF_HALF_FONT_SIZE = "Half Font Size";
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_FAMILY = "Full Font Famly";
const char * const PREF_FULL_FONT_STYLE = "Full Font Style"; 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_SIZE = "Full Font Size";
const char * const PREF_TEXT_FORE_COLOR = "Text Foreground 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_TEXT_BACK_COLOR = "Text Background Color";
const char * const PREF_SELECT_FORE_COLOR = "Selection Foreground 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_SELECT_BACK_COLOR = "Selection Background Color";
const char * const PREF_CURSOR_FORE_COLOR = "Cursor Foreground 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_CURSOR_BACK_COLOR = "Cursor Background Color";
const char * const PREF_IM_FORE_COLOR = "IM Foreground 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_BACK_COLOR = "IM Background Color";
const char * const PREF_IM_SELECT_COLOR = "IM Selection Color"; const char* const PREF_IM_SELECT_COLOR = "IM Selection Color";
const char * const PREF_DRAGN_COPY = "Drag'n Copy"; const char* const PREF_DRAGN_COPY = "Drag'n Copy";
const char * const PREF_HISTORY_SIZE = "Histry Size"; const char* const PREF_HISTORY_SIZE = "Histry Size";
const char * const PREF_CURSOR_BLINKING = "Cursor Blinking rate"; const char* const PREF_CURSOR_BLINKING = "Cursor Blinking rate";
const char * const PREF_IM_AWARE = "Input Method Aware"; const char* const PREF_IM_AWARE = "Input Method Aware";
const char * const PREF_MOUSE_IMAGE = "Cursor Image"; const char* const PREF_MOUSE_IMAGE = "Cursor Image";
const char * const PREF_SELECT_MBUTTON = "Select Region Buttion"; const char* const PREF_COLS = "Cols";
const char * const PREF_SUBMENU_MBUTTON = "Submenu Mouse Button"; const char* const PREF_ROWS = "Rows";
const char * const PREF_PASTE_MBUTTON = "Paste Mouse Button"; const char* const PREF_SHELL = "Shell";
const char * const PREF_COLS = "Cols"; const char* const PREF_TEXT_ENCODING = "Text encoding";
const char * const PREF_ROWS = "Rows"; const char* const PREF_GUI_LANGUAGE = "Language";
const char * const PREF_SHELL = "Shell";
const char * const PREF_TEXT_ENCODING = "Text encoding";
const char * const PREF_GUI_LANGUAGE = "Language";
////////////////////////////////////////////////////////////////////////////
// Color type // Color type
////////////////////////////////////////////////////////////////////////////
enum { enum {
TEXT_FOREGROUND_COLOR, TEXT_FOREGROUND_COLOR,
TEXT_BACKGROUND_COLOR, TEXT_BACKGROUND_COLOR,
@@ -148,26 +127,21 @@ enum {
SELECTION_BACKGROUND_COLOR SELECTION_BACKGROUND_COLOR
}; };
////////////////////////////////////////////////////////////////////////////
// Preference Folder and setting path // Preference Folder and setting path
////////////////////////////////////////////////////////////////////////////
const int32 DEFAULT = -1; const int32 DEFAULT = -1;
//////////////////////////////////////////////////////////////////////////// // Font Width
//
////////////////////////////////////////////////////////////////////////////
/* Font Width */
const int HALF_WIDTH = 1; const int HALF_WIDTH = 1;
const int FULL_WIDTH = 2; const int FULL_WIDTH = 2;
/* Scroll direction flag */ // Scroll direction flag
enum{ enum{
SCRUP, SCRUP,
SCRDOWN SCRDOWN
}; };
/* Insert mode flag */ // Insert mode flag
#define MODE_OVER 0 #define MODE_OVER 0
#define MODE_INSERT 1 #define MODE_INSERT 1
@@ -179,15 +153,12 @@ const float VIEW_OFFSET = 3;
fFontWidth * (fCurPos.x + 1) - 1, \ fFontWidth * (fCurPos.x + 1) - 1, \
fFontHeight * fCurPos.y + fTop + fCursorHeight - 1) fFontHeight * fCurPos.y + fTop + fCursorHeight - 1)
//////////////////////////////////////////////////////////////////////////// // Define TermBuffer internal code
//
////////////////////////////////////////////////////////////////////////////
/* Define TermBuffer internal code */
#define NO_CHAR 0x00 #define NO_CHAR 0x00
#define A_CHAR 0x01 #define A_CHAR 0x01
#define IN_STRING 0xFF #define IN_STRING 0xFF
/* TermBuffer extended attribute */ // TermBuffer extended attribute
#define A_WIDTH 0x8000 #define A_WIDTH 0x8000
#define BOLD 0x4000 #define BOLD 0x4000
#define UNDERLINE 0x2000 #define UNDERLINE 0x2000
@@ -216,20 +187,14 @@ const float VIEW_OFFSET = 3;
#define FORECOLORED(x) ((x) << 3) #define FORECOLORED(x) ((x) << 3)
#define BACKCOLORED(x) ((x) << 0) #define BACKCOLORED(x) ((x) << 0)
////////////////////////////////////////////////////////////////////////////
// TypeDefs // TypeDefs
////////////////////////////////////////////////////////////////////////////
typedef unsigned short ushort; typedef unsigned short ushort;
typedef struct typedef struct {
{
int x1; int x1;
int y1; int y1;
int x2; int x2;
int y2; 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 <Autolock.h>
#include <Beep.h> #include <Beep.h>
#include <Clipboard.h> #include <Clipboard.h>
@@ -29,19 +43,6 @@
#include <new> #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; using std::nothrow;
// defined VTKeyTbl.c // defined VTKeyTbl.c
@@ -93,9 +94,6 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv, int fd)
fScrBot(fTermRows - 1), fScrBot(fTermRows - 1),
fScrBufSize(gTermPref->getInt32(PREF_HISTORY_SIZE)), fScrBufSize(gTermPref->getInt32(PREF_HISTORY_SIZE)),
fScrRegionSet(0), fScrRegionSet(0),
fPopMenu(NULL),
fPopEncoding(NULL),
fPopSize(NULL),
fSelected(false), fSelected(false),
fMouseTracking(false), fMouseTracking(false),
fViewThread(-1), fViewThread(-1),
@@ -105,20 +103,19 @@ TermView::TermView(BRect frame, CodeConv *inCodeConv, int fd)
fDrawRect_p(0), fDrawRect_p(0),
fIMflag(false) fIMflag(false)
{ {
// Cursor reset. // Reset cursor
fCurPos.Set(0, 0); fCurPos.Set(0, 0);
fCurStack.Set(0, 0); fCurStack.Set(0, 0);
fPreviousMousePoint.Set(0, 0); fPreviousMousePoint.Set(0, 0);
fSelStart.Set(-1, -1); fSelStart.Set(-1, -1);
fSelEnd.Set(-1, -1); fSelEnd.Set(-1, -1);
SetMouseButton();
SetMouseCursor(); SetMouseCursor();
SetTermFont(be_plain_font, be_plain_font); SetTermFont(be_plain_font, be_plain_font);
//SetIMAware(gTermPref->getInt32(PREF_IM_AWARE)); //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 //! Sets the mouse cursor image
void void
TermView::SetMouseCursor() TermView::SetMouseCursor()
@@ -744,7 +731,7 @@ TermView::ScrollAtCursor()
thread_id thread_id
TermView::InitViewThread() TermView::_InitViewThread()
{ {
// spwan Draw Engine thread. // spwan Draw Engine thread.
if (fViewThread < 0) { 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 void
TermView::MouseDown(BPoint where) TermView::MouseDown(BPoint where)
{ {
int32 buttons = 0, clicks = 0; int32 buttons;
int32 mod;
BPoint inPoint;
ssize_t num_bytes;
Window()->CurrentMessage()->FindInt32("buttons", &buttons); Window()->CurrentMessage()->FindInt32("buttons", &buttons);
// paste button // paste button
if (buttons == mPasteMenuButton) { if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
if (fSelected) { if (fSelected) {
// If selected region, copy text from region. // copy text from region
BString copyStr(""); BString copy;
fTextBuffer->GetStringFromRegion(copy);
fTextBuffer->GetStringFromRegion(copyStr); WritePTY((uchar *)copy.String(), copy.Length());
num_bytes = copyStr.Length();
WritePTY((uchar *)copyStr.String(), num_bytes);
} else { } else {
// If don't selected, copy text from clipboard. // copy text from clipboard.
DoPaste(); DoPaste();
} }
return; return;
} }
// Select Region // Select Region
if (buttons == mSelectButton) { if (buttons == B_PRIMARY_MOUSE_BUTTON) {
int32 mod, clicks;
Window()->CurrentMessage()->FindInt32("modifiers", &mod); Window()->CurrentMessage()->FindInt32("modifiers", &mod);
Window()->CurrentMessage()->FindInt32("clicks", &clicks); Window()->CurrentMessage()->FindInt32("clicks", &clicks);
if (fSelected) { if (fSelected) {
CurPos inPos, stPos, edPos; CurPos inPos, stPos, edPos;
if (fSelStart < fSelEnd) { if (fSelStart < fSelEnd) {
stPos = fSelStart; stPos = fSelStart;
edPos = fSelEnd; edPos = fSelEnd;
} else { } else {
stPos = fSelEnd; stPos = fSelEnd;
edPos = fSelStart; edPos = fSelStart;
@@ -1814,12 +1763,9 @@ TermView::MouseDown(BPoint where)
// If mouse pointer is avove selected Region, start Drag'n Copy. // If mouse pointer is avove selected Region, start Drag'n Copy.
if (inPos > stPos && inPos < edPos) { if (inPos > stPos && inPos < edPos) {
if (mod & B_CONTROL_KEY || gTermPref->getInt32(PREF_DRAGN_COPY)) { if (mod & B_CONTROL_KEY || gTermPref->getInt32(PREF_DRAGN_COPY)) {
BPoint p; BPoint p;
uint32 bt; uint32 bt;
do { do {
GetMouse(&p, &bt); GetMouse(&p, &bt);
if (bt == 0) { if (bt == 0) {
@@ -1861,7 +1807,7 @@ TermView::MouseDown(BPoint where)
} }
// If mouse has a lot of movement, disable double/triple click. // 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) if (abs((int)inPoint.x) > 16 || abs((int)inPoint.y) > 16)
clicks = 1; clicks = 1;
@@ -1895,15 +1841,6 @@ TermView::MouseDown(BPoint where)
return; return;
} }
// Sub menu(coding popup menu)
if (buttons == mSubMenuButton){
ConvertToScreen(&where);
SetupPop();
fPopMenu->Go(where, true);
delete fPopMenu;
return;
}
BView::MouseDown(where); BView::MouseDown(where);
} }
+270 -342
View File
@@ -1,4 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku.
* Copyright (c) 2003-4 Kian Duffy <[email protected]> * Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* *
@@ -27,16 +28,17 @@
* THE SOFTWARE. * THE SOFTWARE.
* *
*/ */
#ifndef TERMVIEW_H #ifndef TERMVIEW_H
#define TERMVIEW_H #define TERMVIEW_H
#include "CurPos.h"
#include "TermConst.h"
#include "TermWindow.h"
#include <View.h> #include <View.h>
#include <String.h> #include <String.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include "TermConst.h"
#include "TermWindow.h"
#include "CurPos.h"
/* Cursor Blinking flag */ /* Cursor Blinking flag */
#define CUROFF 0 #define CUROFF 0
@@ -47,44 +49,45 @@
#define RECT_BUF_SIZE 32 #define RECT_BUF_SIZE 32
const unsigned char M_ADD_CURSOR [] = { const unsigned char M_ADD_CURSOR [] = {
16, // Size 16, // Size
1, // Color depth 1, // Color depth
0, // Hot spot y 0, // Hot spot y
1, // Hot spot x 1, // Hot spot x
// Cursor image
0x70, 0x00, // Cursor image
0x48, 0x00, 0x70, 0x00,
0x48, 0x00, 0x48, 0x00,
0x27, 0xc0, 0x48, 0x00,
0x24, 0xb8, 0x27, 0xc0,
0x12, 0x54, 0x24, 0xb8,
0x10, 0x02, 0x12, 0x54,
0x78, 0x02, 0x10, 0x02,
0x98, 0x02, 0x78, 0x02,
0x84, 0x02, 0x98, 0x02,
0x60, 0x02, 0x84, 0x02,
0x18, 0x12, 0x60, 0x02,
0x04, 0x10, 0x18, 0x12,
0x02, 0x7c, 0x04, 0x10,
0x00, 0x10, 0x02, 0x7c,
0x00, 0x10, 0x00, 0x10,
// Mask image 0x00, 0x10,
0x70, 0x00, // Mask image
0x78, 0x00, 0x70, 0x00,
0x78, 0x00, 0x78, 0x00,
0x3f, 0xc0, 0x78, 0x00,
0x3f, 0xf8, 0x3f, 0xc0,
0x1f, 0xfc, 0x3f, 0xf8,
0x1f, 0xfe, 0x1f, 0xfc,
0x7f, 0xfe, 0x1f, 0xfe,
0xff, 0xfe, 0x7f, 0xfe,
0xff, 0xfe, 0xff, 0xfe,
0x7f, 0xfe, 0xff, 0xfe,
0x1f, 0xfe, 0x7f, 0xfe,
0x07, 0xfc, 0x1f, 0xfe,
0x03, 0xfc, 0x07, 0xfc,
0x00, 0x10, 0x03, 0xfc,
0x00, 0x10, 0x00, 0x10,
0x00, 0x10,
}; };
class TermBuffer; class TermBuffer;
@@ -93,323 +96,248 @@ class BPopUpMenu;
class BScrollBar; class BScrollBar;
class BString; class BString;
class TermView : public BView class TermView : public BView {
{ public:
public: TermView(BRect frame, CodeConv *inCodeConv, int fd);
// ~TermView();
// Constructor, Destructor, and Initializer.
// void SetTermFont(const BFont *halfFont, const BFont *fullFont);
TermView (BRect frame, CodeConv *inCodeConv, int fd); void GetFontSize(int *width, int *height);
~TermView (); BRect SetTermSize(int rows, int cols, bool flag);
void SetTermColor();
// void SetMouseCursor();
// Initializer, Set function // void SetIMAware (bool);
// void SetScrollBar(BScrollBar *scrbar);
void SetTermFont(const BFont *halfFont, const BFont *fullFont); BScrollBar *ScrollBar() const { return fScrollBar; };
void GetFontSize (int *width, int *height);
BRect SetTermSize (int rows, int cols, bool flag); // Output Charactor
void SetTermColor (void); void PutChar(uchar *string, ushort attr, int width);
void SetMouseButton (void); void PutCR(void);
void SetMouseCursor (void); void PutLF(void);
// void SetIMAware (bool); void PutNL(int num);
void SetScrollBar (BScrollBar *scrbar); void SetInsertMode(int flag);
BScrollBar *ScrollBar () const { return fScrollBar; }; void InsertSpace(int num);
// int TermDraw(const CurPos &start, const CurPos &end);
// Output Charactor. int TermDrawRegion(CurPos start, CurPos end);
// int TermDrawSelectedRegion(CurPos start, CurPos end);
void PutChar (uchar *string, ushort attr, int width);
void PutCR (void); // Delete Charactor
void PutLF (void); void EraseBelow();
void PutNL (int num); void DeleteChar(int num);
void SetInsertMode (int flag); void DeleteColumns();
void InsertSpace (int num); void DeleteLine(int num);
int TermDraw (const CurPos &start, const CurPos &end); // Get and Set Cursor position
int TermDrawRegion (CurPos start, CurPos end); void SetCurPos(int x, int y);
int TermDrawSelectedRegion (CurPos start, CurPos end); void SetCurX(int x);
void SetCurY(int y);
//
// Delete Charactor. void GetCurPos(CurPos *inCurPos);
// int GetCurX();
void EraseBelow (void); int GetCurY();
void DeleteChar (int num);
void DeleteColumns (void); void SaveCursor();
void DeleteLine (int num); void RestoreCursor();
// // Move Cursor
// Get and Set Cursor position. void MoveCurRight(int num);
// void MoveCurLeft(int num);
void SetCurPos (int x, int y); void MoveCurUp(int num);
void SetCurX (int x); void MoveCurDown(int num);
void SetCurY (int y);
// Cursor setting
void GetCurPos (CurPos *inCurPos); void DrawCursor();
int GetCurX (void); void BlinkCursor();
int GetCurY (void); void SetCurDraw(bool flag);
void SetCurBlinking(bool flag);
void SaveCursor (void);
void RestoreCursor (void); // Scroll region
void ScrollRegion(int top, int bot, int dir, int num);
// void SetScrollRegion(int top, int bot);
// Move Cursor void ScrollAtCursor();
//
void MoveCurRight (int num); // Other
void MoveCurLeft (int num); void UpdateSIGWINCH();
void MoveCurUp (int num); void DeviceStatusReport(int);
void MoveCurDown (int num); void UpdateLine();
void ScrollScreen();
// void ScrollScreenDraw();
// Cursor setting. void GetFrameSize(float *width, float *height);
// void GetFontInfo(int *, int*);
void DrawCursor (void); bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
void BlinkCursor (void); void GetSelection(BString &str);
void SetCurDraw (bool flag);
void SetCurBlinking (bool flag); protected:
virtual void AttachedToWindow(void);
// virtual void Draw(BRect updateRect);
// Scroll region. virtual void WindowActivated(bool active);
// virtual void KeyDown(const char*, int32);
void ScrollRegion (int top, int bot, int dir, int num); virtual void MouseDown(BPoint where);
void SetScrollRegion (int top, int bot); virtual void MouseMoved(BPoint, uint32, const BMessage *);
void ScrollAtCursor (void);
virtual void FrameResized(float width, float height);
// virtual void MessageReceived(BMessage* message);
// Other.
// private:
void UpdateSIGWINCH(); static int32 ViewThread(void *);
void DeviceStatusReport (int); static int32 MouseTracking(void *);
void UpdateLine (void);
void ScrollScreen (void); thread_id _InitViewThread(void);
void ScrollScreenDraw (void); void DrawLines(int , int, ushort, uchar *, int, int, int, BView *);
void GetFrameSize (float *width, float *height); void DoPrint(BRect updateRect);
void GetFontInfo (int *, int*); void ResizeScrBarRange (void);
bool Find (const BString &str, bool forwardSearch, bool matchCase, bool matchWord); void DoFileDrop(entry_ref &ref);
void GetSelection (BString &str);
// edit menu function.
/* void DoCopy();
* PRIVATE MEMBER. void DoPaste();
*/ void DoSelectAll();
void DoClearAll();
private:
/* int SubstMetaChar (const char *p, char *q);
* static Functions (Thread functions). void WritePTY (const uchar *text, int num_byteses);
*/
// Comunicate Input Method
static int32 ViewThread (void *); // void DoIMStart (BMessage* message);
static int32 MouseTracking (void *); // void DoIMStop (BMessage* message);
// void DoIMChange (BMessage* message);
/* // void DoIMLocation (BMessage* message);
* Hook Functions. // void DoIMConfirm (void);
*/ void ConfirmString (const char *, int32);
void AttachedToWindow (void); int32 GetCharFromUTF8String (const char *, char *);
void Draw (BRect updateRect); int32 GetWidthFromUTF8String (const char *);
void WindowActivated (bool active);
void KeyDown (const char*, int32); // mouse operation
void MouseDown (BPoint where); int32 SetupMouseButton(const char *bname);
void MouseMoved (BPoint, uint32, const BMessage *);
// Mouse select
void FrameResized(float width, float height); void Select(CurPos start, CurPos end);
void MessageReceived(BMessage* message); void AddSelectRegion(CurPos);
void ResizeSelectRegion(CurPos);
/*
* Private Member Functions. void DeSelect();
*/
// select word function
thread_id InitViewThread (void); void SelectWord(BPoint where, int mod);
void SelectLine(BPoint where, int mod);
inline void DrawLines (int , int, ushort, uchar *, int, int, int, BView *);
// point and text offset conversion.
void DoPrint(BRect updateRect); CurPos BPointToCurPos(const BPoint &p);
BPoint CurPosToBPoint(const CurPos &pos);
void ResizeScrBarRange (void);
bool CheckSelectedRegion(const CurPos &pos);
void DoFileDrop(entry_ref &ref); inline void SendDataToDrawEngine(int, int, int, int);
// edit menu function. int fTerminalFd;
void DoCopy (void);
void DoPaste (void); // Font and Width
void DoSelectAll (void); BFont fHalfFont;
void DoClearAll (void); BFont fFullFont;
int fFontWidth;
int SubstMetaChar (const char *p, char *q); int fFontHeight;
void WritePTY (const uchar *text, int num_byteses); int fFontAscent;
struct escapement_delta fEscapement;
// Comunicate Input Method
// void DoIMStart (BMessage* message); // Flags
// void DoIMStop (BMessage* message);
// void DoIMChange (BMessage* message); // Update flag (Set on PutChar).
// void DoIMLocation (BMessage* message); bool fUpdateFlag;
// void DoIMConfirm (void);
void ConfirmString (const char *, int32); // Terminal insertmode flag (use PutChar).
int32 GetCharFromUTF8String (const char *, char *); bool fInsertModeFlag;
int32 GetWidthFromUTF8String (const char *);
// Scroll count, range.
// mouse operation int fScrollUpCount;
void SetupPop (void); int fScrollBarRange;
int32 SetupMouseButton (const char *bname);
// Frame Resized flag.
// Mouse select bool fFrameResized;
void Select (CurPos start, CurPos end);
void AddSelectRegion (CurPos); // Cursor Blinking, draw flag.
void ResizeSelectRegion (CurPos); bool fCursorDrawFlag;
bool fCursorStatus;
void DeSelect(void); bool fCursorBlinkingFlag;
bool fCursorRedrawFlag;
// select word function
void SelectWord (BPoint where, int mod); int fCursorHeight;
void SelectLine (BPoint where, int mod);
// terminal text attribute flag.
// point and text offset conversion. bool fInverseFlag;
CurPos BPointToCurPos (const BPoint &p); bool fBoldFlag;
BPoint CurPosToBPoint (const CurPos &pos); bool fUnderlineFlag;
bool CheckSelectedRegion (const CurPos &pos); // Cursor position.
CurPos fCurPos;
inline void SendDataToDrawEngine (int, int, int, int); CurPos fCurStack;
/* int fBufferStartPos;
* DATA Member.
*/
int fTerminalFd;
//
// Font and Width.
//
BFont fHalfFont;
BFont fFullFont;
int fFontWidth;
int fFontHeight;
int fFontAscent; // Terminal rows and columns.
struct escapement_delta fEscapement; int fTermRows;
int fTermColumns;
// // Terminal view pointer.
// Flags. int fTop;
//
// Update flag (Set on PutChar). // Object pointer.
bool fUpdateFlag;
// Terminal insertmode flag (use PutChar). TermBuffer *fTextBuffer;
bool fInsertModeFlag; CodeConv *fCodeConv;
BScrollBar *fScrollBar;
// Scroll count, range. // Offscreen Bitmap and View.
int fScrollUpCount;
int fScrollBarRange;
// Frame Resized flag. BRect fSrcRect;
bool fFrameResized; BRect fDstRect;
// Cursor Blinking, draw flag. // Color and Attribute.
bool fCursorDrawFlag;
bool fCursorStatus;
bool fCursorBlinkingFlag;
bool fCursorRedrawFlag;
int fCursorHeight; rgb_color fTextForeColor, fTextBackColor;
rgb_color fCursorForeColor, fCursorBackColor;
rgb_color fSelectForeColor, fSelectBackColor;
uchar fTermAttr;
// terminal text attribute flag. // Scroll Region
bool fInverseFlag; int fScrTop;
bool fBoldFlag; int fScrBot;
bool fUnderlineFlag; int fScrBufSize;
bool fScrRegionSet;
// // mouse
// Cursor position. int32 mSelectButton;
// int32 mSubMenuButton;
CurPos fCurPos; int32 mPasteMenuButton;
CurPos fCurStack;
int fBufferStartPos; bool fMouseImage;
//
// Terminal rows and columns.
//
int fTermRows;
int fTermColumns;
//
// Terminal view pointer.
//
int fTop;
//
// Object pointer.
//
TermBuffer *fTextBuffer;
CodeConv *fCodeConv;
BScrollBar *fScrollBar;
// BPoint fPreviousMousePoint;
// Offscreen Bitmap and View.
//
BRect fSrcRect; // view selection
BRect fDstRect; CurPos fSelStart;
CurPos fSelEnd;
bool fSelected;
bool fMouseTracking;
// // thread ID / flags.
// Color and Attribute. thread_id fViewThread;
// thread_id fMouseThread;
bool fQuitting;
// text fore and back color // DrawEngine parameter.
rgb_color fTextForeColor, fTextBackColor; sem_id fDrawRectSem;
sDrawRect fDrawRectBuffer[RECT_BUF_SIZE];
int fDrawRect_p;
// cursor fore and back color // Input Method parameter.
rgb_color fCursorForeColor, fCursorBackColor; int fIMViewPtr;
CurPos fIMStartPos;
// selected region color CurPos fIMEndPos;
rgb_color fSelectForeColor, fSelectBackColor; BString fIMString;
bool fIMflag;
uchar fTermAttr; BMessenger fIMMessenger;
//
// 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;
int32 fImCodeState;
}; };