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.
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"
22 class TermView::State
{
24 State(TermView
* view
);
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
,
35 virtual void KeyDown(const char* bytes
, int32 numBytes
);
37 virtual void MouseDown(BPoint where
, int32 buttons
,
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();
52 class TermView::StandardBaseState
: public TermView::State
{
54 StandardBaseState(TermView
* view
);
57 bool _StandardMouseMoved(BPoint where
,
62 class TermView::DefaultState
: public TermView::StandardBaseState
{
64 DefaultState(TermView
* view
);
66 virtual void ModifiersChanged(int32 oldModifiers
,
69 virtual void KeyDown(const char* bytes
, int32 numBytes
);
71 virtual void MouseDown(BPoint where
, int32 buttons
,
73 virtual void MouseMoved(BPoint where
, uint32 transit
,
74 const BMessage
* dragMessage
, int32 modifiers
);
76 virtual void WindowActivated(bool active
);
79 bool _CheckEnterHyperLinkState(int32 modifiers
);
83 class TermView::SelectState
: public TermView::StandardBaseState
{
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
);
96 void _AutoScrollUpdate();
99 int32 fSelectGranularity
;
100 bool fCheckMouseTracking
;
105 class TermView::HyperLinkState
: public TermView::State
,
106 private TermViewHighlighter
{
108 HyperLinkState(TermView
* view
);
110 virtual void Entered();
111 virtual void Exited();
113 virtual void ModifiersChanged(int32 oldModifiers
,
116 virtual void MouseDown(BPoint where
, int32 buttons
,
118 virtual void MouseMoved(BPoint where
, uint32 transit
,
119 const BMessage
* dragMessage
, int32 modifiers
);
121 virtual void WindowActivated(bool active
);
123 virtual void VisibleTextBufferChanged();
126 // TermViewHighlighter
127 virtual rgb_color
ForegroundColor();
128 virtual rgb_color
BackgroundColor();
129 virtual uint32
AdjustTextAttributes(uint32 attributes
);
132 struct CharPosition
{
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
,
148 void _DeactivateHighlight();
151 DefaultCharClassifier fURLCharClassifier
;
152 DefaultCharClassifier fPathComponentCharClassifier
;
153 BString fCurrentDirectory
;
154 TermViewHighlight fHighlight
;
155 bool fHighlightActive
;
159 class TermView::HyperLinkMenuState
: public TermView::State
{
161 HyperLinkMenuState(TermView
* view
);
163 void Prepare(BPoint point
, const HyperLink
& link
);
165 virtual void Exited();
167 virtual bool MessageReceived(BMessage
* message
);
177 #endif // TERMVIEW_STATES_H