* When resizing the Terminal, we now show a small BStringView that displays the
current size of the Terminal in characters. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28125 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2008, 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.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files or portions
|
* a copy of this software and associated documentation files or portions
|
||||||
@@ -66,31 +66,31 @@ const uint32 M_GET_DEVICE_NUM = 'Mgdn';
|
|||||||
|
|
||||||
|
|
||||||
// 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';
|
||||||
const ulong PSET__HFONT_SIZE = 'phfs';
|
const ulong PSET__HFONT_SIZE = 'phfs';
|
||||||
const ulong PSET_FORE_COLOR = 'pfcl';
|
const ulong PSET_FORE_COLOR = 'pfcl';
|
||||||
const ulong PSET_BACK_COLOR = 'pbcl';
|
const ulong PSET_BACK_COLOR = 'pbcl';
|
||||||
const ulong PSET__CODING = 'pcod';
|
const ulong PSET__CODING = 'pcod';
|
||||||
|
|
||||||
// Terminal Size Messages
|
// Terminal Size Messages
|
||||||
const uint32 EIGHTYTWENTYFOUR = 'etfo';
|
const uint32 EIGHTYTWENTYFOUR = 'etfo';
|
||||||
const uint32 EIGHTYTWENTYFIVE = 'etfv';
|
const uint32 EIGHTYTWENTYFIVE = 'etfv';
|
||||||
const uint32 EIGHTYFORTY = 'efor';
|
const uint32 EIGHTYFORTY = 'efor';
|
||||||
const uint32 ONETHREETWOTWENTYFOUR = 'hunf';
|
const uint32 ONETHREETWOTWENTYFOUR = 'hunf';
|
||||||
const uint32 ONETHREETWOTWENTYFIVE = 'hunv';
|
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';
|
||||||
const uint32 MSG_CHECK_CHILDREN = 'ckch';
|
const uint32 MSG_CHECK_CHILDREN = 'ckch';
|
||||||
const uint32 MSG_PREVIOUS_TAB = 'ptab';
|
const uint32 MSG_PREVIOUS_TAB = 'ptab';
|
||||||
const uint32 MSG_NEXT_TAB = 'ntab';
|
const uint32 MSG_NEXT_TAB = 'ntab';
|
||||||
|
const uint32 MSG_REMOVE_RESIZE_VIEW_IF_NEEDED = 'rmrv';
|
||||||
const uint32 MSG_TERMINAL_BUFFER_CHANGED = 'bufc';
|
const uint32 MSG_TERMINAL_BUFFER_CHANGED = 'bufc';
|
||||||
const uint32 MSG_SET_TERMNAL_TITLE = 'sett';
|
const uint32 MSG_SET_TERMNAL_TITLE = 'sett';
|
||||||
const uint32 MSG_QUIT_TERMNAL = 'qutt';
|
const uint32 MSG_QUIT_TERMNAL = 'qutt';
|
||||||
|
|
||||||
// Preference Read/Write Keys
|
// Preference Read/Write Keys
|
||||||
const char* const PREF_HALF_FONT_FAMILY = "Half Font Family";
|
const char* const PREF_HALF_FONT_FAMILY = "Half Font Family";
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <StringView.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "CodeConv.h"
|
#include "CodeConv.h"
|
||||||
@@ -115,8 +116,7 @@ restrict_value(const Type& value, const Type& min, const Type& max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TermView::CharClassifier : public TerminalCharClassifier
|
class TermView::CharClassifier : public TerminalCharClassifier {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CharClassifier(const char* specialWordChars)
|
CharClassifier(const char* specialWordChars)
|
||||||
:
|
:
|
||||||
@@ -144,6 +144,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
inline int32
|
inline int32
|
||||||
TermView::_LineAt(float y)
|
TermView::_LineAt(float y)
|
||||||
{
|
{
|
||||||
@@ -198,6 +201,8 @@ TermView::TermView(BRect frame, int32 argc, const char **argv, int32 historySize
|
|||||||
fWinchRunner(NULL),
|
fWinchRunner(NULL),
|
||||||
fCursorBlinkRunner(NULL),
|
fCursorBlinkRunner(NULL),
|
||||||
fAutoScrollRunner(NULL),
|
fAutoScrollRunner(NULL),
|
||||||
|
fResizeRunner(NULL),
|
||||||
|
fResizeView(NULL),
|
||||||
fCharClassifier(NULL),
|
fCharClassifier(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
fFontHeight(0),
|
fFontHeight(0),
|
||||||
@@ -241,6 +246,8 @@ TermView::TermView(int rows, int columns, int32 argc, const char **argv, int32 h
|
|||||||
fWinchRunner(NULL),
|
fWinchRunner(NULL),
|
||||||
fCursorBlinkRunner(NULL),
|
fCursorBlinkRunner(NULL),
|
||||||
fAutoScrollRunner(NULL),
|
fAutoScrollRunner(NULL),
|
||||||
|
fResizeRunner(NULL),
|
||||||
|
fResizeView(NULL),
|
||||||
fCharClassifier(NULL),
|
fCharClassifier(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
fFontHeight(0),
|
fFontHeight(0),
|
||||||
@@ -296,6 +303,8 @@ TermView::TermView(BMessage *archive)
|
|||||||
fWinchRunner(NULL),
|
fWinchRunner(NULL),
|
||||||
fCursorBlinkRunner(NULL),
|
fCursorBlinkRunner(NULL),
|
||||||
fAutoScrollRunner(NULL),
|
fAutoScrollRunner(NULL),
|
||||||
|
fResizeRunner(NULL),
|
||||||
|
fResizeView(NULL),
|
||||||
fCharClassifier(NULL),
|
fCharClassifier(NULL),
|
||||||
fFontWidth(0),
|
fFontWidth(0),
|
||||||
fFontHeight(0),
|
fFontHeight(0),
|
||||||
@@ -983,6 +992,9 @@ TermView::DetachedFromWindow()
|
|||||||
delete fCursorBlinkRunner;
|
delete fCursorBlinkRunner;
|
||||||
fCursorBlinkRunner = NULL;
|
fCursorBlinkRunner = NULL;
|
||||||
|
|
||||||
|
delete fResizeRunner;
|
||||||
|
fResizeRunner = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
BAutolock _(fTextBuffer);
|
BAutolock _(fTextBuffer);
|
||||||
fTextBuffer->UnsetListener();
|
fTextBuffer->UnsetListener();
|
||||||
@@ -1313,6 +1325,28 @@ TermView::FrameResized(float width, float height)
|
|||||||
if (columns == fTermColumns && rows == fTermRows)
|
if (columns == fTermColumns && rows == fTermRows)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool hasResizeView = fResizeRunner != NULL;
|
||||||
|
if (!hasResizeView) {
|
||||||
|
// show the current size in a view
|
||||||
|
fResizeView = new BStringView(BRect(100, 100, 300, 140), "size", "");
|
||||||
|
fResizeView->SetAlignment(B_ALIGN_CENTER);
|
||||||
|
fResizeView->SetFont(be_bold_font);
|
||||||
|
|
||||||
|
BMessage message(MSG_REMOVE_RESIZE_VIEW_IF_NEEDED);
|
||||||
|
fResizeRunner = new(std::nothrow) BMessageRunner(BMessenger(this),
|
||||||
|
&message, 25000LL);
|
||||||
|
}
|
||||||
|
|
||||||
|
BString text;
|
||||||
|
text << columns << " x " << rows;
|
||||||
|
fResizeView->SetText(text.String());
|
||||||
|
fResizeView->GetPreferredSize(&width, &height);
|
||||||
|
fResizeView->ResizeTo(width * 1.5, height * 1.5);
|
||||||
|
fResizeView->MoveTo((Bounds().Width() - fResizeView->Bounds().Width()) / 2,
|
||||||
|
(Bounds().Height()- fResizeView->Bounds().Height()) / 2);
|
||||||
|
if (!hasResizeView)
|
||||||
|
AddChild(fResizeView);
|
||||||
|
|
||||||
SetTermSize(rows, columns, false);
|
SetTermSize(rows, columns, false);
|
||||||
|
|
||||||
fFrameResized = true;
|
fFrameResized = true;
|
||||||
@@ -1480,6 +1514,24 @@ TermView::MessageReceived(BMessage *msg)
|
|||||||
SetTitle(title);
|
SetTitle(title);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case MSG_REMOVE_RESIZE_VIEW_IF_NEEDED:
|
||||||
|
{
|
||||||
|
uint32 buttons;
|
||||||
|
GetMouse(NULL, &buttons, false);
|
||||||
|
if (buttons != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (fResizeView != NULL) {
|
||||||
|
fResizeView->RemoveSelf();
|
||||||
|
delete fResizeView;
|
||||||
|
fResizeView = NULL;
|
||||||
|
}
|
||||||
|
delete fResizeRunner;
|
||||||
|
fResizeRunner = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_QUIT_TERMNAL:
|
case MSG_QUIT_TERMNAL:
|
||||||
{
|
{
|
||||||
int32 reason;
|
int32 reason;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2008, 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.
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -25,29 +25,31 @@ class BClipboard;
|
|||||||
class BMessageRunner;
|
class BMessageRunner;
|
||||||
class BScrollBar;
|
class BScrollBar;
|
||||||
class BString;
|
class BString;
|
||||||
|
class BStringView;
|
||||||
class Shell;
|
class Shell;
|
||||||
class TermBuffer;
|
class TermBuffer;
|
||||||
|
class ResizeWindow;
|
||||||
|
|
||||||
class TermView : public BView {
|
class TermView : public BView {
|
||||||
public:
|
public:
|
||||||
TermView(BRect frame, int32 argc, const char **argv, int32 historySize);
|
TermView(BRect frame, int32 argc, const char **argv, int32 historySize);
|
||||||
TermView(int rows, int columns, int32 argc, const char **argv,
|
TermView(int rows, int columns, int32 argc, const char **argv,
|
||||||
int32 historySize);
|
int32 historySize);
|
||||||
TermView(BMessage *archive);
|
TermView(BMessage *archive);
|
||||||
~TermView();
|
~TermView();
|
||||||
|
|
||||||
static BArchivable* Instantiate(BMessage* data);
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||||
|
|
||||||
virtual void GetPreferredSize(float *width, float *height);
|
virtual void GetPreferredSize(float *width, float *height);
|
||||||
|
|
||||||
const char *TerminalName() const;
|
const char *TerminalName() const;
|
||||||
|
|
||||||
inline TerminalBuffer* TextBuffer() const { return fTextBuffer; }
|
inline TerminalBuffer* TextBuffer() const { return fTextBuffer; }
|
||||||
|
|
||||||
void GetTermFont(BFont *font) const;
|
void GetTermFont(BFont *font) const;
|
||||||
void SetTermFont(const BFont *font);
|
void SetTermFont(const BFont *font);
|
||||||
|
|
||||||
void GetFontSize(int *width, int *height);
|
void GetFontSize(int *width, int *height);
|
||||||
BRect SetTermSize(int rows, int cols, bool resize);
|
BRect SetTermSize(int rows, int cols, bool resize);
|
||||||
|
|
||||||
@@ -66,11 +68,11 @@ public:
|
|||||||
virtual void NotifyQuit(int32 reason);
|
virtual void NotifyQuit(int32 reason);
|
||||||
|
|
||||||
// edit functions
|
// edit functions
|
||||||
void Copy(BClipboard *clipboard);
|
void Copy(BClipboard *clipboard);
|
||||||
void Paste(BClipboard *clipboard);
|
void Paste(BClipboard *clipboard);
|
||||||
void SelectAll();
|
void SelectAll();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
void GetFrameSize(float *width, float *height);
|
void GetFrameSize(float *width, float *height);
|
||||||
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
||||||
@@ -86,7 +88,7 @@ protected:
|
|||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void WindowActivated(bool active);
|
virtual void WindowActivated(bool active);
|
||||||
virtual void KeyDown(const char*, int32);
|
virtual void KeyDown(const char*, int32);
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseMoved(BPoint, uint32, const BMessage *);
|
virtual void MouseMoved(BPoint, uint32, const BMessage *);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
@@ -120,8 +122,8 @@ private:
|
|||||||
void _DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
void _DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
||||||
int32 width, bool mouse, bool cursor, BView *inView);
|
int32 width, bool mouse, bool cursor, BView *inView);
|
||||||
void _DrawCursor();
|
void _DrawCursor();
|
||||||
void _InvalidateTextRange(TermPos start, TermPos end);
|
void _InvalidateTextRange(TermPos start, TermPos end);
|
||||||
|
|
||||||
bool _IsCursorVisible() const;
|
bool _IsCursorVisible() const;
|
||||||
void _BlinkCursor();
|
void _BlinkCursor();
|
||||||
void _ActivateCursor(bool invalidate);
|
void _ActivateCursor(bool invalidate);
|
||||||
@@ -135,21 +137,21 @@ private:
|
|||||||
|
|
||||||
void _WritePTY(const char* text, int32 numBytes);
|
void _WritePTY(const char* text, int32 numBytes);
|
||||||
|
|
||||||
// Comunicate Input Method
|
// Comunicate Input Method
|
||||||
// void _DoIMStart (BMessage* message);
|
// void _DoIMStart (BMessage* message);
|
||||||
// void _DoIMStop (BMessage* message);
|
// void _DoIMStop (BMessage* message);
|
||||||
// void _DoIMChange (BMessage* message);
|
// void _DoIMChange (BMessage* message);
|
||||||
// void _DoIMLocation (BMessage* message);
|
// void _DoIMLocation (BMessage* message);
|
||||||
// void _DoIMConfirm (void);
|
// void _DoIMConfirm (void);
|
||||||
// void _ConfirmString(const char *, int32);
|
// void _ConfirmString(const char *, int32);
|
||||||
|
|
||||||
// selection
|
// selection
|
||||||
void _Select(TermPos start, TermPos end, bool inclusive,
|
void _Select(TermPos start, TermPos end, bool inclusive,
|
||||||
bool setInitialSelection);
|
bool setInitialSelection);
|
||||||
void _ExtendSelection(TermPos, bool inclusive, bool useInitialSelection);
|
void _ExtendSelection(TermPos, bool inclusive, bool useInitialSelection);
|
||||||
void _Deselect();
|
void _Deselect();
|
||||||
bool _HasSelection() const;
|
bool _HasSelection() const;
|
||||||
void _SelectWord(BPoint where, bool extend, bool useInitialSelection);
|
void _SelectWord(BPoint where, bool extend, bool useInitialSelection);
|
||||||
void _SelectLine(BPoint where, bool extend, bool useInitialSelection);
|
void _SelectLine(BPoint where, bool extend, bool useInitialSelection);
|
||||||
|
|
||||||
void _AutoScrollUpdate();
|
void _AutoScrollUpdate();
|
||||||
@@ -171,7 +173,8 @@ private:
|
|||||||
BMessageRunner *fWinchRunner;
|
BMessageRunner *fWinchRunner;
|
||||||
BMessageRunner *fCursorBlinkRunner;
|
BMessageRunner *fCursorBlinkRunner;
|
||||||
BMessageRunner *fAutoScrollRunner;
|
BMessageRunner *fAutoScrollRunner;
|
||||||
|
BMessageRunner *fResizeRunner;
|
||||||
|
BStringView *fResizeView;
|
||||||
CharClassifier *fCharClassifier;
|
CharClassifier *fCharClassifier;
|
||||||
|
|
||||||
// Font and Width
|
// Font and Width
|
||||||
@@ -209,7 +212,7 @@ private:
|
|||||||
rgb_color fTextForeColor, fTextBackColor;
|
rgb_color fTextForeColor, fTextBackColor;
|
||||||
rgb_color fCursorForeColor, fCursorBackColor;
|
rgb_color fCursorForeColor, fCursorBackColor;
|
||||||
rgb_color fSelectForeColor, fSelectBackColor;
|
rgb_color fSelectForeColor, fSelectBackColor;
|
||||||
|
|
||||||
// Scroll Region
|
// Scroll Region
|
||||||
float fScrollOffset;
|
float fScrollOffset;
|
||||||
int32 fScrBufSize;
|
int32 fScrBufSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user