BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / terminal / TermWindow.h
blobf99157b833b9fdb79b450c9da27350ab96706154
1 /*
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
20 * the distribution.
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
28 * THE SOFTWARE.
31 #ifndef TERM_WINDOW_H
32 #define TERM_WINDOW_H
35 #include <MessageRunner.h>
36 #include <String.h>
37 #include <Window.h>
39 #include "SmartTabView.h"
40 #include "SetTitleDialog.h"
41 #include "TerminalRoster.h"
42 #include "TermView.h"
45 class Arguments;
46 class BFile;
47 class BFont;
48 class BMenu;
49 class BMenuBar;
50 class FindWindow;
51 class PrefWindow;
52 class TermViewContainerView;
55 class TermWindow : public BWindow, private SmartTabView::Listener,
56 private TermView::Listener, private SetTitleDialog::Listener,
57 private TerminalRoster::Listener {
58 public:
59 TermWindow(const BString& title,
60 Arguments* args);
61 virtual ~TermWindow();
63 void SessionChanged();
65 static void MakeEncodingMenu(BMenu*);
66 static void MakeWindowSizeMenu(BMenu*);
68 protected:
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,
78 bool state);
79 virtual void Minimize(bool minimize);
81 private:
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);
91 // TermView::Listener
92 virtual void NotifyTermViewQuit(TermView* view,
93 int32 reason);
94 virtual void SetTermViewTitle(TermView* view,
95 const char* title);
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);
108 private:
109 struct Title {
110 BString title;
111 BString pattern;
112 bool patternUserDefined;
115 struct SessionID {
116 SessionID(int32 id = -1);
117 SessionID(const BMessage& message,
118 const char* field);
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); }
130 private:
131 int32 fID;
134 struct Session;
136 private:
137 void _SetTermColors(TermViewContainerView* termView);
138 void _InitWindow();
139 void _SetupMenu();
140 static BMenu* _MakeFontSizeMenu(uint32 command,
141 uint8 defaultSize);
142 void _UpdateSwitchTerminalsMenuItem();
144 status_t _GetWindowPositionFile(BFile* file,
145 uint32 openMode);
146 status_t _LoadWindowPosition(BRect* frame,
147 uint32* workspaces);
148 status_t _SaveWindowPosition();
150 void _GetPreferredFont(BFont &font);
151 status_t _DoPageSetup();
152 void _DoPrint();
154 void _NewTab();
155 void _AddTab(Arguments* args,
156 const BString& currentDirectory
157 = BString());
158 void _RemoveTab(int32 index);
159 void _NavigateTab(int32 index, int32 direction,
160 bool move);
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);
191 private:
192 TerminalRoster fTerminalRoster;
194 Title fTitle;
195 BString fSessionTitlePattern;
196 BMessageRunner fTitleUpdateRunner;
198 BList fSessions;
199 int32 fNextSessionID;
201 SmartTabView* fTabView;
203 BMenuBar* fMenuBar;
204 BMenuItem* fSwitchTerminalsMenuItem;
205 BMenu* fEncodingMenu;
206 BMenu* fFontSizeMenu;
208 BMessage* fPrintSettings;
209 PrefWindow* fPrefWindow;
210 FindWindow* fFindPanel;
211 BRect fSavedFrame;
212 window_look fSavedLook;
214 SetTitleDialog* fSetWindowTitleDialog;
215 SetTitleDialog* fSetTabTitleDialog;
216 SessionID fSetTabTitleSession;
218 // Saved search parameters
219 BString fFindString;
220 BMenuItem* fFindNextMenuItem;
221 BMenuItem* fFindPreviousMenuItem;
222 BMenuItem* fIncreaseFontSizeMenuItem;
223 BMenuItem* fDecreaseFontSizeMenuItem;
225 bool fFindSelection;
226 bool fForwardSearch;
227 bool fMatchCase;
228 bool fMatchWord;
230 bool fFullScreen;
234 #endif // TERM_WINDOW_H