HaikuDepot: notify work status from main window
[haiku.git] / src / apps / terminal / TermViewStates.h
blob1aa0ba07ff63d2ae1a37f44d3e28d9a2d8e2eb7c
1 /*
2 * Copyright 2001-2013, Haiku, Inc.
3 * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
4 * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
6 * Distributed under the terms of the MIT license.
7 * Authors:
8 * Stefano Ceccherini, stefano.ceccherini@gmail.com
9 * Kian Duffy, myob@users.sourceforge.net
10 * Ingo Weinhold, ingo_weinhold@gmx.de
11 * Siarzhuk Zharski, zharik@gmx.li
13 #ifndef TERMVIEW_STATES_H
14 #define TERMVIEW_STATES_H
17 #include "HyperLink.h"
18 #include "TerminalCharClassifier.h"
19 #include "TermView.h"
22 class TermView::State {
23 public:
24 State(TermView* view);
25 virtual ~State();
27 virtual void Entered();
28 virtual void Exited();
30 virtual bool MessageReceived(BMessage* message);
31 // returns true, if handled
33 virtual void ModifiersChanged(int32 oldModifiers,
34 int32 modifiers);
35 virtual void KeyDown(const char* bytes, int32 numBytes);
37 virtual void MouseDown(BPoint where, int32 buttons,
38 int32 modifiers);
39 virtual void MouseMoved(BPoint where, uint32 transit,
40 const BMessage* dragMessage, int32 modifiers);
41 virtual void MouseUp(BPoint where, int32 buttons);
43 virtual void WindowActivated(bool active);
45 virtual void VisibleTextBufferChanged();
47 protected:
48 TermView* fView;
52 class TermView::StandardBaseState : public TermView::State {
53 public:
54 StandardBaseState(TermView* view);
56 protected:
57 bool _StandardMouseMoved(BPoint where,
58 int32 modifiers);
62 class TermView::DefaultState : public TermView::StandardBaseState {
63 public:
64 DefaultState(TermView* view);
66 virtual void ModifiersChanged(int32 oldModifiers,
67 int32 modifiers);
69 virtual void KeyDown(const char* bytes, int32 numBytes);
71 virtual void MouseDown(BPoint where, int32 buttons,
72 int32 modifiers);
73 virtual void MouseMoved(BPoint where, uint32 transit,
74 const BMessage* dragMessage, int32 modifiers);
76 virtual void WindowActivated(bool active);
78 private:
79 bool _CheckEnterHyperLinkState(int32 modifiers);
83 class TermView::SelectState : public TermView::StandardBaseState {
84 public:
85 SelectState(TermView* view);
87 void Prepare(BPoint where, int32 modifiers);
89 virtual bool MessageReceived(BMessage* message);
91 virtual void MouseMoved(BPoint where, uint32 transit,
92 const BMessage* dragMessage, int32 modifiers);
93 virtual void MouseUp(BPoint where, int32 buttons);
95 private:
96 void _AutoScrollUpdate();
98 private:
99 int32 fSelectGranularity;
100 bool fCheckMouseTracking;
101 bool fMouseTracking;
105 class TermView::HyperLinkState : public TermView::State,
106 private TermViewHighlighter {
107 public:
108 HyperLinkState(TermView* view);
110 virtual void Entered();
111 virtual void Exited();
113 virtual void ModifiersChanged(int32 oldModifiers,
114 int32 modifiers);
116 virtual void MouseDown(BPoint where, int32 buttons,
117 int32 modifiers);
118 virtual void MouseMoved(BPoint where, uint32 transit,
119 const BMessage* dragMessage, int32 modifiers);
121 virtual void WindowActivated(bool active);
123 virtual void VisibleTextBufferChanged();
125 private:
126 // TermViewHighlighter
127 virtual rgb_color ForegroundColor();
128 virtual rgb_color BackgroundColor();
129 virtual uint32 AdjustTextAttributes(uint32 attributes);
131 private:
132 struct CharPosition {
133 int32 index;
134 TermPos position;
137 private:
138 bool _GetHyperLinkAt(BPoint where,
139 bool pathPrefixOnly, HyperLink& _link,
140 TermPos& _start, TermPos& _end);
141 bool _EntryExists(const BString& path,
142 BString& _actualPath) const;
144 void _UpdateHighlight();
145 void _UpdateHighlight(BPoint where, int32 modifiers);
146 void _ActivateHighlight(const TermPos& start,
147 const TermPos& end);
148 void _DeactivateHighlight();
150 private:
151 DefaultCharClassifier fURLCharClassifier;
152 DefaultCharClassifier fPathComponentCharClassifier;
153 BString fCurrentDirectory;
154 TermViewHighlight fHighlight;
155 bool fHighlightActive;
159 class TermView::HyperLinkMenuState : public TermView::State {
160 public:
161 HyperLinkMenuState(TermView* view);
163 void Prepare(BPoint point, const HyperLink& link);
165 virtual void Exited();
167 virtual bool MessageReceived(BMessage* message);
169 private:
170 class PopUpMenu;
172 private:
173 HyperLink fLink;
177 #endif // TERMVIEW_STATES_H