* 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,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku.
|
||||
* Copyright 2001-2008, Haiku.
|
||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
||||
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
@@ -66,31 +66,31 @@ const uint32 M_GET_DEVICE_NUM = 'Mgdn';
|
||||
|
||||
|
||||
// Preference Message
|
||||
const ulong PSET__COLS = 'pcol';
|
||||
const ulong PSET__ROWS = 'prow';
|
||||
const ulong PSET__HFONT = 'phfn';
|
||||
const ulong PSET__HFONT_SIZE = 'phfs';
|
||||
const ulong PSET_FORE_COLOR = 'pfcl';
|
||||
const ulong PSET_BACK_COLOR = 'pbcl';
|
||||
const ulong PSET__CODING = 'pcod';
|
||||
const ulong PSET__COLS = 'pcol';
|
||||
const ulong PSET__ROWS = 'prow';
|
||||
const ulong PSET__HFONT = 'phfn';
|
||||
const ulong PSET__HFONT_SIZE = 'phfs';
|
||||
const ulong PSET_FORE_COLOR = 'pfcl';
|
||||
const ulong PSET_BACK_COLOR = 'pbcl';
|
||||
const ulong PSET__CODING = 'pcod';
|
||||
|
||||
// Terminal Size Messages
|
||||
const uint32 EIGHTYTWENTYFOUR = 'etfo';
|
||||
const uint32 EIGHTYTWENTYFIVE = 'etfv';
|
||||
const uint32 EIGHTYFORTY = 'efor';
|
||||
const uint32 ONETHREETWOTWENTYFOUR = 'hunf';
|
||||
const uint32 ONETHREETWOTWENTYFIVE = 'hunv';
|
||||
const uint32 FULLSCREEN = 'fscr';
|
||||
const uint32 EIGHTYTWENTYFOUR = 'etfo';
|
||||
const uint32 EIGHTYTWENTYFIVE = 'etfv';
|
||||
const uint32 EIGHTYFORTY = 'efor';
|
||||
const uint32 ONETHREETWOTWENTYFOUR = 'hunf';
|
||||
const uint32 ONETHREETWOTWENTYFIVE = 'hunv';
|
||||
const uint32 FULLSCREEN = 'fscr';
|
||||
|
||||
const uint32 MSG_FONT_CHANGED = 'fntc';
|
||||
const uint32 SAVE_AS_DEFAULT = 'sadf';
|
||||
const uint32 MSG_CHECK_CHILDREN = 'ckch';
|
||||
const uint32 MSG_PREVIOUS_TAB = 'ptab';
|
||||
const uint32 MSG_NEXT_TAB = 'ntab';
|
||||
|
||||
const uint32 MSG_TERMINAL_BUFFER_CHANGED = 'bufc';
|
||||
const uint32 MSG_SET_TERMNAL_TITLE = 'sett';
|
||||
const uint32 MSG_QUIT_TERMNAL = 'qutt';
|
||||
const uint32 MSG_FONT_CHANGED = 'fntc';
|
||||
const uint32 SAVE_AS_DEFAULT = 'sadf';
|
||||
const uint32 MSG_CHECK_CHILDREN = 'ckch';
|
||||
const uint32 MSG_PREVIOUS_TAB = 'ptab';
|
||||
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_SET_TERMNAL_TITLE = 'sett';
|
||||
const uint32 MSG_QUIT_TERMNAL = 'qutt';
|
||||
|
||||
// Preference Read/Write Keys
|
||||
const char* const PREF_HALF_FONT_FAMILY = "Half Font Family";
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <Roster.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
#include <Window.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:
|
||||
CharClassifier(const char* specialWordChars)
|
||||
:
|
||||
@@ -144,6 +144,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
inline int32
|
||||
TermView::_LineAt(float y)
|
||||
{
|
||||
@@ -198,6 +201,8 @@ TermView::TermView(BRect frame, int32 argc, const char **argv, int32 historySize
|
||||
fWinchRunner(NULL),
|
||||
fCursorBlinkRunner(NULL),
|
||||
fAutoScrollRunner(NULL),
|
||||
fResizeRunner(NULL),
|
||||
fResizeView(NULL),
|
||||
fCharClassifier(NULL),
|
||||
fFontWidth(0),
|
||||
fFontHeight(0),
|
||||
@@ -241,6 +246,8 @@ TermView::TermView(int rows, int columns, int32 argc, const char **argv, int32 h
|
||||
fWinchRunner(NULL),
|
||||
fCursorBlinkRunner(NULL),
|
||||
fAutoScrollRunner(NULL),
|
||||
fResizeRunner(NULL),
|
||||
fResizeView(NULL),
|
||||
fCharClassifier(NULL),
|
||||
fFontWidth(0),
|
||||
fFontHeight(0),
|
||||
@@ -296,6 +303,8 @@ TermView::TermView(BMessage *archive)
|
||||
fWinchRunner(NULL),
|
||||
fCursorBlinkRunner(NULL),
|
||||
fAutoScrollRunner(NULL),
|
||||
fResizeRunner(NULL),
|
||||
fResizeView(NULL),
|
||||
fCharClassifier(NULL),
|
||||
fFontWidth(0),
|
||||
fFontHeight(0),
|
||||
@@ -983,6 +992,9 @@ TermView::DetachedFromWindow()
|
||||
delete fCursorBlinkRunner;
|
||||
fCursorBlinkRunner = NULL;
|
||||
|
||||
delete fResizeRunner;
|
||||
fResizeRunner = NULL;
|
||||
|
||||
{
|
||||
BAutolock _(fTextBuffer);
|
||||
fTextBuffer->UnsetListener();
|
||||
@@ -1313,6 +1325,28 @@ TermView::FrameResized(float width, float height)
|
||||
if (columns == fTermColumns && rows == fTermRows)
|
||||
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);
|
||||
|
||||
fFrameResized = true;
|
||||
@@ -1480,6 +1514,24 @@ TermView::MessageReceived(BMessage *msg)
|
||||
SetTitle(title);
|
||||
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:
|
||||
{
|
||||
int32 reason;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku.
|
||||
* Copyright 2001-2008, Haiku.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
@@ -25,8 +25,10 @@ class BClipboard;
|
||||
class BMessageRunner;
|
||||
class BScrollBar;
|
||||
class BString;
|
||||
class BStringView;
|
||||
class Shell;
|
||||
class TermBuffer;
|
||||
class ResizeWindow;
|
||||
|
||||
class TermView : public BView {
|
||||
public:
|
||||
@@ -171,7 +173,8 @@ private:
|
||||
BMessageRunner *fWinchRunner;
|
||||
BMessageRunner *fCursorBlinkRunner;
|
||||
BMessageRunner *fAutoScrollRunner;
|
||||
|
||||
BMessageRunner *fResizeRunner;
|
||||
BStringView *fResizeView;
|
||||
CharClassifier *fCharClassifier;
|
||||
|
||||
// Font and Width
|
||||
|
||||
Reference in New Issue
Block a user