TermView doesn't know about PrefHandler anymore (again), so that, in case

it's used as replicant (but I think it won't work anymore, yet),
it doesn't influence the global settings.
TermWindow saves the preferences on quit, if the PrefWindow was never
instantiated. This allows the window size to be saved also when it's
resized manually (not via menu).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34165 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2009-11-20 20:34:03 +00:00
parent bf00b7798c
commit 17ecdb5b2f
4 changed files with 37 additions and 5 deletions

View File

@ -47,7 +47,6 @@
#include "CodeConv.h"
#include "Globals.h"
#include "PrefHandler.h"
#include "Shell.h"
#include "TermConst.h"
#include "TerminalCharClassifier.h"
@ -469,6 +468,20 @@ TermView::GetFontSize(int* _width, int* _height)
}
int
TermView::Rows() const
{
return fRows;
}
int
TermView::Columns() const
{
return fColumns;
}
//! Set number of rows and columns in terminal
BRect
TermView::SetTermSize(int rows, int columns, bool resize)
@ -479,9 +492,6 @@ TermView::SetTermSize(int rows, int columns, bool resize)
if (columns > 0)
fColumns = columns;
PrefHandler::Default()->setInt32(PREF_COLS, fColumns);
PrefHandler::Default()->setInt32(PREF_ROWS, fRows);
// To keep things simple, get rid of the selection first.
_Deselect();

View File

@ -51,6 +51,8 @@ public:
void SetTermFont(const BFont* font);
void GetFontSize(int* width, int* height);
int Rows() const;
int Columns() const;
BRect SetTermSize(int rows, int cols, bool resize);
void SetTextColor(rgb_color fore, rgb_color back);

View File

@ -162,8 +162,16 @@ TermWindow::TermWindow(BRect frame, const char* title, Arguments *args)
TermWindow::~TermWindow()
{
// If there's no prefwindow, save the preferences by ourselves.
// For example, this saves the columns/rows number.
// TODO: Code duplication. Exterminate
if (fPrefWindow)
fPrefWindow->PostMessage(B_QUIT_REQUESTED);
else {
BPath path;
if (PrefHandler::GetDefaultPath(path) == B_OK)
PrefHandler::Default()->SaveAsText(path.Path(), PREFFILE_MIMETYPE);
}
if (fFindPanel && fFindPanel->Lock()) {
fFindPanel->Quit();
@ -902,6 +910,17 @@ TermWindow::Zoom(BPoint leftTop, float width, float height)
}
void
TermWindow::FrameResized(float newWidth, float newHeight)
{
BWindow::FrameResized(newWidth, newHeight);
TermView *view = _ActiveTermView();
PrefHandler::Default()->setInt32(PREF_COLS, view->Columns());
PrefHandler::Default()->setInt32(PREF_ROWS, view->Rows());
}
void
TermWindow::_ResizeView(TermView *view)
{

View File

@ -60,6 +60,7 @@ protected:
virtual void WindowActivated(bool);
virtual void MenusBeginning();
virtual void Zoom(BPoint leftTop, float width, float height);
virtual void FrameResized(float newWidth, float newHeight);
private:
struct Session;