* 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
+35 -98
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,91 +1722,50 @@ 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;
} }
inPos = BPointToCurPos(where); inPos = BPointToCurPos(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;
@@ -1894,16 +1840,7 @@ 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);
} }
+239 -311
View File
@@ -1,4 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku.
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net> * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
* 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.
//
TermView (BRect frame, CodeConv *inCodeConv, int fd);
~TermView ();
// void SetTermFont(const BFont *halfFont, const BFont *fullFont);
// Initializer, Set function void GetFontSize(int *width, int *height);
// BRect SetTermSize(int rows, int cols, bool flag);
void SetTermFont(const BFont *halfFont, const BFont *fullFont); void SetTermColor();
void GetFontSize (int *width, int *height); void SetMouseCursor();
BRect SetTermSize (int rows, int cols, bool flag); // void SetIMAware (bool);
void SetTermColor (void); void SetScrollBar(BScrollBar *scrbar);
void SetMouseButton (void); BScrollBar *ScrollBar() const { return fScrollBar; };
void SetMouseCursor (void);
// void SetIMAware (bool);
void SetScrollBar (BScrollBar *scrbar);
BScrollBar *ScrollBar () const { return fScrollBar; };
// // Output Charactor
// Output Charactor. void PutChar(uchar *string, ushort attr, int width);
// void PutCR(void);
void PutChar (uchar *string, ushort attr, int width); void PutLF(void);
void PutCR (void); void PutNL(int num);
void PutLF (void); void SetInsertMode(int flag);
void PutNL (int num); void InsertSpace(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);
// int TermDraw(const CurPos &start, const CurPos &end);
// Delete Charactor. int TermDrawRegion(CurPos start, CurPos end);
// int TermDrawSelectedRegion(CurPos start, CurPos end);
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); // Delete Charactor
void RestoreCursor (void); void EraseBelow();
void DeleteChar(int num);
// void DeleteColumns();
// Move Cursor void DeleteLine(int num);
//
void MoveCurRight (int num);
void MoveCurLeft (int num);
void MoveCurUp (int num);
void MoveCurDown (int num);
// // Get and Set Cursor position
// Cursor setting. void SetCurPos(int x, int y);
// void SetCurX(int x);
void DrawCursor (void); void SetCurY(int y);
void BlinkCursor (void);
void SetCurDraw (bool flag);
void SetCurBlinking (bool flag);
// void GetCurPos(CurPos *inCurPos);
// Scroll region. int GetCurX();
// int GetCurY();
void ScrollRegion (int top, int bot, int dir, int num);
void SetScrollRegion (int top, int bot);
void ScrollAtCursor (void);
// void SaveCursor();
// Other. void RestoreCursor();
//
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);
/* // Move Cursor
* PRIVATE MEMBER. void MoveCurRight(int num);
*/ void MoveCurLeft(int num);
void MoveCurUp(int num);
void MoveCurDown(int num);
private: // Cursor setting
/* void DrawCursor();
* static Functions (Thread functions). void BlinkCursor();
*/ void SetCurDraw(bool flag);
void SetCurBlinking(bool flag);
static int32 ViewThread (void *); // Scroll region
static int32 MouseTracking (void *); void ScrollRegion(int top, int bot, int dir, int num);
void SetScrollRegion(int top, int bot);
void ScrollAtCursor();
/* // Other
* Hook Functions. void UpdateSIGWINCH();
*/ void DeviceStatusReport(int);
void AttachedToWindow (void); void UpdateLine();
void Draw (BRect updateRect); void ScrollScreen();
void WindowActivated (bool active); void ScrollScreenDraw();
void KeyDown (const char*, int32); void GetFrameSize(float *width, float *height);
void MouseDown (BPoint where); void GetFontInfo(int *, int*);
void MouseMoved (BPoint, uint32, const BMessage *); bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
void GetSelection(BString &str);
void FrameResized(float width, float height);
void MessageReceived(BMessage* message);
/* protected:
* Private Member Functions. 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 *);
thread_id InitViewThread (void); virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage* message);
inline void DrawLines (int , int, ushort, uchar *, int, int, int, BView *); private:
static int32 ViewThread(void *);
static int32 MouseTracking(void *);
void DoPrint(BRect updateRect); 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);
void ResizeScrBarRange (void); // edit menu function.
void DoCopy();
void DoFileDrop(entry_ref &ref); void DoPaste();
void DoSelectAll();
// edit menu function. void DoClearAll();
void DoCopy (void);
void DoPaste (void);
void DoSelectAll (void);
void DoClearAll (void);
int SubstMetaChar (const char *p, char *q); int SubstMetaChar (const char *p, char *q);
void WritePTY (const uchar *text, int num_byteses); 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 // Comunicate Input Method
void Select (CurPos start, CurPos end); // void DoIMStart (BMessage* message);
void AddSelectRegion (CurPos); // void DoIMStop (BMessage* message);
void ResizeSelectRegion (CurPos); // 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 *);
void DeSelect(void); // mouse operation
int32 SetupMouseButton(const char *bname);
// select word function // Mouse select
void SelectWord (BPoint where, int mod); void Select(CurPos start, CurPos end);
void SelectLine (BPoint where, int mod); void AddSelectRegion(CurPos);
void ResizeSelectRegion(CurPos);
// point and text offset conversion. void DeSelect();
CurPos BPointToCurPos (const BPoint &p);
BPoint CurPosToBPoint (const CurPos &pos);
bool CheckSelectedRegion (const CurPos &pos); // select word function
void SelectWord(BPoint where, int mod);
void SelectLine(BPoint where, int mod);
inline void SendDataToDrawEngine (int, int, int, int); // point and text offset conversion.
CurPos BPointToCurPos(const BPoint &p);
/* BPoint CurPosToBPoint(const CurPos &pos);
* DATA Member.
*/
int fTerminalFd; bool CheckSelectedRegion(const CurPos &pos);
// inline void SendDataToDrawEngine(int, int, int, int);
// Font and Width.
//
BFont fHalfFont;
BFont fFullFont;
int fFontWidth; int fTerminalFd;
int fFontHeight;
int fFontAscent; // Font and Width
struct escapement_delta fEscapement; BFont fHalfFont;
BFont fFullFont;
// int fFontWidth;
// Flags. int fFontHeight;
// int fFontAscent;
struct escapement_delta fEscapement;
// Update flag (Set on PutChar). // Flags
bool fUpdateFlag;
// Terminal insertmode flag (use PutChar). // Update flag (Set on PutChar).
bool fInsertModeFlag; bool fUpdateFlag;
// Scroll count, range. // Terminal insertmode flag (use PutChar).
int fScrollUpCount; bool fInsertModeFlag;
int fScrollBarRange;
// Frame Resized flag. // Scroll count, range.
bool fFrameResized; int fScrollUpCount;
int fScrollBarRange;
// Cursor Blinking, draw flag.
bool fCursorDrawFlag;
bool fCursorStatus;
bool fCursorBlinkingFlag;
bool fCursorRedrawFlag;
int fCursorHeight;
// terminal text attribute flag. // Frame Resized flag.
bool fInverseFlag; bool fFrameResized;
bool fBoldFlag;
bool fUnderlineFlag;
//
// Cursor position.
//
CurPos fCurPos;
CurPos fCurStack;
int fBufferStartPos; // Cursor Blinking, draw flag.
bool fCursorDrawFlag;
bool fCursorStatus;
bool fCursorBlinkingFlag;
bool fCursorRedrawFlag;
// int fCursorHeight;
// Terminal rows and columns.
//
int fTermRows;
int fTermColumns;
// // terminal text attribute flag.
// Terminal view pointer. bool fInverseFlag;
// bool fBoldFlag;
int fTop; bool fUnderlineFlag;
// // Cursor position.
// Object pointer. CurPos fCurPos;
// CurPos fCurStack;
TermBuffer *fTextBuffer;
CodeConv *fCodeConv;
BScrollBar *fScrollBar;
//
// Offscreen Bitmap and View.
//
BRect fSrcRect; int fBufferStartPos;
BRect fDstRect;
//
// Color and Attribute.
//
// text fore and back color // Terminal rows and columns.
rgb_color fTextForeColor, fTextBackColor; int fTermRows;
int fTermColumns;
// cursor fore and back color // Terminal view pointer.
rgb_color fCursorForeColor, fCursorBackColor; int fTop;
// selected region color // Object pointer.
rgb_color fSelectForeColor, fSelectBackColor;
uchar fTermAttr;
// TermBuffer *fTextBuffer;
// Scroll Region CodeConv *fCodeConv;
// BScrollBar *fScrollBar;
int fScrTop;
int fScrBot;
int fScrBufSize;
bool fScrRegionSet;
BPopUpMenu *fPopMenu; // Offscreen Bitmap and View.
BMenu *fPopEncoding;
BMenu *fPopSize;
// mouse
int32 mSelectButton;
int32 mSubMenuButton;
int32 mPasteMenuButton;
bool fMouseImage; BRect fSrcRect;
BRect fDstRect;
BPoint fPreviousMousePoint; // Color and Attribute.
// view selection rgb_color fTextForeColor, fTextBackColor;
CurPos fSelStart; rgb_color fCursorForeColor, fCursorBackColor;
CurPos fSelEnd; rgb_color fSelectForeColor, fSelectBackColor;
bool fSelected; uchar fTermAttr;
bool fMouseTracking;
// thread ID / flags.
thread_id fViewThread;
thread_id fMouseThread;
bool fQuitting;
// DrawEngine parameter. // Scroll Region
sem_id fDrawRectSem; int fScrTop;
sDrawRect fDrawRectBuffer[RECT_BUF_SIZE]; int fScrBot;
int fDrawRect_p; int fScrBufSize;
bool fScrRegionSet;
// Input Method parameter. // mouse
int fIMViewPtr; int32 mSelectButton;
CurPos fIMStartPos; int32 mSubMenuButton;
CurPos fIMEndPos; int32 mPasteMenuButton;
BString fIMString;
bool fIMflag;
BMessenger fIMMessenger;
int32 fImCodeState; 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;
}; };