diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index c0487fe4c1..7dc56efc45 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -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(); diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h index a355c19735..225aa1e784 100644 --- a/src/apps/terminal/TermView.h +++ b/src/apps/terminal/TermView.h @@ -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); diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 0b1050a738..f908a46ffe 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -162,9 +162,17 @@ 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(); fFindPanel = NULL; @@ -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) { diff --git a/src/apps/terminal/TermWindow.h b/src/apps/terminal/TermWindow.h index 72b8703292..0656b6bb01 100644 --- a/src/apps/terminal/TermWindow.h +++ b/src/apps/terminal/TermWindow.h @@ -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;