* 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:
parent
39fbf5509b
commit
c2f7e34f8d
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku.
|
||||
* Copyright 2001-2008, Haiku.
|
||||
* Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
|
||||
* 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
|
||||
* a copy of this software and associated documentation files or portions
|
||||
@ -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,7 +1,7 @@
|
||||
/*
|
||||
* 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.
|
||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||
*
|
||||
* Distributed under the terms of the MIT license.
|
||||
* Authors:
|
||||
@ -25,29 +25,31 @@ class BClipboard;
|
||||
class BMessageRunner;
|
||||
class BScrollBar;
|
||||
class BString;
|
||||
class BStringView;
|
||||
class Shell;
|
||||
class TermBuffer;
|
||||
class ResizeWindow;
|
||||
|
||||
class TermView : public BView {
|
||||
public:
|
||||
TermView(BRect frame, int32 argc, const char **argv, int32 historySize);
|
||||
TermView(int rows, int columns, int32 argc, const char **argv,
|
||||
int32 historySize);
|
||||
TermView(BMessage *archive);
|
||||
TermView(BMessage *archive);
|
||||
~TermView();
|
||||
|
||||
static BArchivable* Instantiate(BMessage* data);
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
|
||||
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
|
||||
const char *TerminalName() const;
|
||||
|
||||
inline TerminalBuffer* TextBuffer() const { return fTextBuffer; }
|
||||
|
||||
|
||||
void GetTermFont(BFont *font) const;
|
||||
void SetTermFont(const BFont *font);
|
||||
|
||||
|
||||
void GetFontSize(int *width, int *height);
|
||||
BRect SetTermSize(int rows, int cols, bool resize);
|
||||
|
||||
@ -66,11 +68,11 @@ public:
|
||||
virtual void NotifyQuit(int32 reason);
|
||||
|
||||
// edit functions
|
||||
void Copy(BClipboard *clipboard);
|
||||
void Copy(BClipboard *clipboard);
|
||||
void Paste(BClipboard *clipboard);
|
||||
void SelectAll();
|
||||
void Clear();
|
||||
|
||||
void Clear();
|
||||
|
||||
// Other
|
||||
void GetFrameSize(float *width, float *height);
|
||||
bool Find(const BString &str, bool forwardSearch, bool matchCase, bool matchWord);
|
||||
@ -86,7 +88,7 @@ protected:
|
||||
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 *);
|
||||
virtual void MouseUp(BPoint where);
|
||||
@ -120,8 +122,8 @@ private:
|
||||
void _DrawLinePart(int32 x1, int32 y1, uint16 attr, char *buf,
|
||||
int32 width, bool mouse, bool cursor, BView *inView);
|
||||
void _DrawCursor();
|
||||
void _InvalidateTextRange(TermPos start, TermPos end);
|
||||
|
||||
void _InvalidateTextRange(TermPos start, TermPos end);
|
||||
|
||||
bool _IsCursorVisible() const;
|
||||
void _BlinkCursor();
|
||||
void _ActivateCursor(bool invalidate);
|
||||
@ -135,21 +137,21 @@ private:
|
||||
|
||||
void _WritePTY(const char* text, int32 numBytes);
|
||||
|
||||
// Comunicate Input Method
|
||||
// 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);
|
||||
|
||||
|
||||
// selection
|
||||
void _Select(TermPos start, TermPos end, bool inclusive,
|
||||
bool setInitialSelection);
|
||||
void _ExtendSelection(TermPos, bool inclusive, bool useInitialSelection);
|
||||
void _Deselect();
|
||||
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 _AutoScrollUpdate();
|
||||
@ -171,7 +173,8 @@ private:
|
||||
BMessageRunner *fWinchRunner;
|
||||
BMessageRunner *fCursorBlinkRunner;
|
||||
BMessageRunner *fAutoScrollRunner;
|
||||
|
||||
BMessageRunner *fResizeRunner;
|
||||
BStringView *fResizeView;
|
||||
CharClassifier *fCharClassifier;
|
||||
|
||||
// Font and Width
|
||||
@ -209,7 +212,7 @@ private:
|
||||
rgb_color fTextForeColor, fTextBackColor;
|
||||
rgb_color fCursorForeColor, fCursorBackColor;
|
||||
rgb_color fSelectForeColor, fSelectBackColor;
|
||||
|
||||
|
||||
// Scroll Region
|
||||
float fScrollOffset;
|
||||
int32 fScrBufSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user