File: qeditorinputbinding.h

package info (click to toggle)
texstudio 2.11.2%2Bdebian-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 41,292 kB
  • ctags: 12,405
  • sloc: cpp: 93,072; xml: 10,217; ansic: 4,153; sh: 145; makefile: 56
file content (134 lines) | stat: -rw-r--r-- 3,644 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/****************************************************************************
**
** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
**
** This file is part of the Edyuk project <http://edyuk.org>
** 
** This file may be used under the terms of the GNU General Public License
** version 3 as published by the Free Software Foundation and appearing in the
** file GPL.txt included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef _QEDITOR_INPUT_BINDING_H_
#define _QEDITOR_INPUT_BINDING_H_

#include "mostQtHeaders.h"

#include "qeditorinputbindinginterface.h"

#include "qdocumentcursor.h"

class QCE_EXPORT QEditorInputBinding : public QEditorInputBindingInterface
{
	public:
		class Command
		{
			public:
				virtual ~Command() {}
				
				virtual void exec(QEditor *e) = 0;
		};
		
		class MotionCommand : public Command
		{
			public:
				MotionCommand(QDocumentCursor::MoveOperation op, QDocumentCursor::MoveMode m, int n = 1);
				
				virtual void exec(QEditor *e);
				
			private:
				int count;
				QDocumentCursor::MoveMode mode;
				QDocumentCursor::MoveOperation operation;
		};
		
		class EditCommand : public Command
		{
			public:
				enum Operation
				{
					ClearSelection,
					SelectWord,
					SelectLine,
					SelectDocument,
					
					DeleteChar,
					DeletePreviousChar,
					DeleteSelection,
					DeleteLine,
					
					InsertLine,
					InsertClipBoard,
				};
				
				EditCommand(Operation op);
				
				virtual void exec(QEditor *e);
				
			private:
				Operation operation;
		};
		
		class WriteCommand : public Command
		{
			public:
				WriteCommand(const QString& t);
				
				virtual void exec(QEditor *e);
				
			private:
				QString text;
		};
		
		class GroupCommand : public Command
		{
			public:
				void addCommand(Command *c);
				
				virtual void exec(QEditor *e);
				
			private:
				QList<Command*> commands;
		};
		
		QEditorInputBinding();
		~QEditorInputBinding();
		
		void setMapping(const QKeySequence& ks, Command *cmd);
		
		virtual bool isExclusive() const;
		
		virtual bool keyPressEvent(QKeyEvent *event, QEditor *editor);
		virtual void postKeyPressEvent(QKeyEvent *event, QEditor *editor);
		
		virtual bool keyReleaseEvent(QKeyEvent *event, QEditor *editor);
		virtual void postKeyReleaseEvent(QKeyEvent *event, QEditor *editor);

		virtual bool inputMethodEvent(QInputMethodEvent* event, QEditor *editor);
		virtual void postInputMethodEvent(QInputMethodEvent *event, QEditor *editor);
		
		virtual bool mouseMoveEvent(QMouseEvent *event, QEditor *editor);
		virtual void postMouseMoveEvent(QMouseEvent *event, QEditor *editor);
		
		virtual bool mousePressEvent(QMouseEvent *event, QEditor *editor);
		virtual void postMousePressEvent(QMouseEvent *event, QEditor *editor);
		
		virtual bool mouseReleaseEvent(QMouseEvent *event, QEditor *editor);
		virtual void postMouseReleaseEvent(QMouseEvent *event, QEditor *editor);
		
		virtual bool mouseDoubleClickEvent(QMouseEvent *event, QEditor *editor);
		virtual void postMouseDoubleClickEvent(QMouseEvent *event, QEditor *editor);
		
		virtual bool contextMenuEvent(QContextMenuEvent *event, QEditor *editor);
		
	private:
		QVector<int> m_index;
		QVector<Command*> m_actions;
		QVector<QKeySequence> m_keys;
};

#endif // _QEDITOR_INPUT_BINDING_H_