* 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) 2003-4 Kian Duffy <[email protected]>
|
||||||
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
*
|
*
|
||||||
@@ -87,7 +87,7 @@ 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';
|
||||||
|
|||||||
@@ -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,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
@@ -25,8 +25,10 @@ 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:
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user