2 * Copyright 2001-2010, Haiku.
3 * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
4 * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files or portions
8 * thereof (the "Software"), to deal in the Software without restriction,
9 * including without limitation the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject
12 * to the following conditions:
14 * * Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright notice
18 * in the binary, as well as this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided with
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 #include <MessageRunner.h>
39 #include "SmartTabView.h"
40 #include "SetTitleDialog.h"
41 #include "TerminalRoster.h"
52 class TermViewContainerView
;
55 class TermWindow
: public BWindow
, private SmartTabView::Listener
,
56 private TermView::Listener
, private SetTitleDialog::Listener
,
57 private TerminalRoster::Listener
{
59 TermWindow(const BString
& title
,
61 virtual ~TermWindow();
63 void SessionChanged();
65 static void MakeEncodingMenu(BMenu
*);
66 static void MakeWindowSizeMenu(BMenu
*);
69 virtual bool QuitRequested();
70 virtual void MessageReceived(BMessage
* message
);
71 virtual void WindowActivated(bool activated
);
72 virtual void MenusBeginning();
73 virtual void Zoom(BPoint leftTop
, float width
, float height
);
74 virtual void FrameResized(float newWidth
, float newHeight
);
75 virtual void WorkspacesChanged(uint32 oldWorkspaces
,
76 uint32 newWorkspaces
);
77 virtual void WorkspaceActivated(int32 workspace
,
79 virtual void Minimize(bool minimize
);
82 // SmartTabView::Listener
83 virtual void TabSelected(SmartTabView
* tabView
, int32 index
);
84 virtual void TabDoubleClicked(SmartTabView
* tabView
,
85 BPoint point
, int32 index
);
86 virtual void TabMiddleClicked(SmartTabView
* tabView
,
87 BPoint point
, int32 index
);
88 virtual void TabRightClicked(SmartTabView
* tabView
,
89 BPoint point
, int32 index
);
92 virtual void NotifyTermViewQuit(TermView
* view
,
94 virtual void SetTermViewTitle(TermView
* view
,
96 virtual void PreviousTermView(TermView
* view
);
97 virtual void NextTermView(TermView
* view
);
99 // SetTitleDialog::Listener
100 virtual void TitleChanged(SetTitleDialog
* dialog
,
101 const BString
& title
,
102 bool titleUserDefined
);
103 virtual void SetTitleDialogDone(SetTitleDialog
* dialog
);
105 // TerminalRoster::Listener
106 virtual void TerminalInfosUpdated(TerminalRoster
* roster
);
112 bool patternUserDefined
;
116 SessionID(int32 id
= -1);
117 SessionID(const BMessage
& message
,
120 bool IsValid() const { return fID
>= 0; }
122 status_t
AddToMessage(BMessage
& message
,
123 const char* field
) const;
125 bool operator==(const SessionID
& other
) const
126 { return fID
== other
.fID
; }
127 bool operator!=(const SessionID
& other
) const
128 { return !(*this == other
); }
137 void _SetTermColors(TermViewContainerView
* termView
);
140 static BMenu
* _MakeFontSizeMenu(uint32 command
,
142 void _UpdateSwitchTerminalsMenuItem();
144 status_t
_GetWindowPositionFile(BFile
* file
,
146 status_t
_LoadWindowPosition(BRect
* frame
,
148 status_t
_SaveWindowPosition();
150 void _GetPreferredFont(BFont
&font
);
151 status_t
_DoPageSetup();
155 void _AddTab(Arguments
* args
,
156 const BString
& currentDirectory
158 void _RemoveTab(int32 index
);
159 void _NavigateTab(int32 index
, int32 direction
,
162 bool _CanClose(int32 index
);
164 TermViewContainerView
* _ActiveTermViewContainerView() const;
165 TermViewContainerView
* _TermViewContainerViewAt(int32 index
) const;
166 TermView
* _ActiveTermView() const;
167 TermView
* _TermViewAt(int32 index
) const;
168 int32
_IndexOfTermView(TermView
* termView
) const;
169 inline Session
* _SessionAt(int32 index
) const;
170 Session
* _SessionForID(const SessionID
& sessionID
) const;
171 inline int32
_IndexOfSession(Session
* session
) const;
173 void _CheckChildren();
174 void _ResizeView(TermView
* view
);
176 void _TitleSettingsChanged();
177 void _UpdateTitles();
178 void _UpdateSessionTitle(int32 index
);
179 void _OpenSetTabTitleDialog(int32 index
);
180 void _OpenSetWindowTitleDialog();
181 void _FinishTitleDialog();
183 void _SwitchTerminal();
184 team_id
_FindSwitchTerminalTarget();
186 SessionID
_NewSessionID();
187 int32
_NewSessionIndex();
189 void _MoveWindowInScreen(BWindow
* window
);
192 TerminalRoster fTerminalRoster
;
195 BString fSessionTitlePattern
;
196 BMessageRunner fTitleUpdateRunner
;
199 int32 fNextSessionID
;
201 SmartTabView
* fTabView
;
204 BMenuItem
* fSwitchTerminalsMenuItem
;
205 BMenu
* fEncodingMenu
;
206 BMenu
* fFontSizeMenu
;
208 BMessage
* fPrintSettings
;
209 PrefWindow
* fPrefWindow
;
210 FindWindow
* fFindPanel
;
212 window_look fSavedLook
;
214 SetTitleDialog
* fSetWindowTitleDialog
;
215 SetTitleDialog
* fSetTabTitleDialog
;
216 SessionID fSetTabTitleSession
;
218 // Saved search parameters
220 BMenuItem
* fFindNextMenuItem
;
221 BMenuItem
* fFindPreviousMenuItem
;
222 BMenuItem
* fIncreaseFontSizeMenuItem
;
223 BMenuItem
* fDecreaseFontSizeMenuItem
;
234 #endif // TERM_WINDOW_H