This file is indexed.

/usr/include/BALL/VIEW/WIDGETS/pyWidget.h is in libballview1.4-dev 1.4.3~beta1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#ifndef BALL_VIEW_WIDGETS_PYWIDGET_H
#define BALL_VIEW_WIDGETS_PYWIDGET_H

#ifndef BALL_COMMON_H
#	include <BALL/common.h>
#endif

#ifndef BALL_DATATYPE_STRING_H
#	include <BALL/DATATYPE/string.h>
#endif

#ifndef BALL_VIEW_WIDGETS_DOCKWIDGET_H
#	include <BALL/VIEW/WIDGETS/dockWidget.h>
#endif

#ifndef BALL_VIEW_WIDGETS_TEXTEDITORWIDGET_H
#	include <BALL/VIEW/WIDGETS/textEditorWidget.h>
#endif

#include <QtGui/QDragEnterEvent>
#include <QtGui/QKeyEvent>
#include <QtGui/QDropEvent>
#include <QtGui/QLineEdit>
#include <QtGui/QComboBox>
#include <QtGui/QTabWidget>
#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QValidator>
#include <QtCore/QStringList>

#include <QtCore/QThread>

// currently doesnt work right
#undef BALL_QT_HAS_THREADS

namespace BALL
{
	namespace VIEW
	{

class PythonSettings;
class Preferences;

class RunPythonThread;

/** Class for syntax highlighting of Python code.
		\ingroup ViewWidgets
*/
class BALL_VIEW_EXPORT PythonHighlighter
	: public QSyntaxHighlighter
{
	public:

	PythonHighlighter();

	~PythonHighlighter() {};

	void compilePattern();
	void highlightBlock(const QString& text);

	QStringList python_keywords;
	QStringList BALL_keywords;
	QTextCharFormat my_class_format;
	QTextCharFormat python_format;
	QTextCharFormat string_format;
	QTextCharFormat comment_format;
	vector<QRegExp> python_patterns;
	vector<QRegExp> BALL_patterns;
	QRegExp 				string_pattern;
	QRegExp 				comment_pattern;
};

/** Class for validating (and potentially fixing) entered python code.
		\ingroup ViewWidgets
*/
class BALL_VIEW_EXPORT PythonValidator
	: public QValidator
{
	public:
		PythonValidator(QObject* parent = 0);
		virtual ~PythonValidator();
		
		virtual State validate(QString& input, int& pos) const;		
};

class BALL_VIEW_EXPORT RunPythonThread
	: public QThread
{
	public:
		RunPythonThread();

		///
		virtual void run();

		bool state;
		String input;
		String output;
};

///
struct BALL_VIEW_EXPORT Hotkey
{

	public:

	static Hotkey createHotkey(String modifier, String key, String command, 
														 bool& ok, String comment = "");

	///
	bool operator == (const Hotkey& hotkey) const;

	///
	bool operator == (const QKeyEvent& e) const;

	/// 
	const Hotkey& operator = (const Hotkey& s);

	/// Needed for MSVC
	bool operator < (const Hotkey& key) { return this < &key;}

	///
	bool set(const String& data);

	///
	void get(String& data) const;

	String 								comment;
	String 								action;
	Qt::KeyboardModifiers button_state;
	Qt::Key 							key;
};

/** Python Widget
		This class is a Window for a Python interpreter interface.
		So it is possible to access all data in the running application in realtime with the script language.
		PyWidget also has the capablities to run a Python script from a file at startup, or on demand from the user.
		\ingroup ViewWidgets
*/
class BALL_VIEW_EXPORT PyWidget
	: public DockWidget
{
	class MyLineEdit
		: public QLineEdit
	{
		public:
			MyLineEdit(QWidget* parent)
				: QLineEdit(parent) {};

			void setPyWidget(PyWidget* pw) { pw_ = pw;}

		protected:

			virtual void keyPressEvent(QKeyEvent* event);

			PyWidget* pw_;
	};

	class MyTextEdit
		: public TextEditorWidget
	{
		public:
			MyTextEdit(QWidget* parent)
				: TextEditorWidget(parent) {};

			void setPyWidget(PyWidget* pw) { pw_ = pw;}

		protected:

			virtual void keyPressEvent(QKeyEvent* event);

			PyWidget* pw_;
	};

	friend class MyLineEdit;

	Q_OBJECT

	public:
	
	BALL_EMBEDDABLE(PyWidget, Embeddable)

	/**	@name	Constructors and Destructors
	*/
	//@{

	/** Standard constructor.
			If the widget is part of a BALL \link MainControl MainControl \endlink widget, 
			it inserts a menu entry <tt>Tools|Restart Python</tt> into the menu bar.
			\param parent the parent widget
			\param name the widget name
	*/
	PyWidget(QWidget* parent = 0, const char* name = 0);

	/// only needed for Pyhon Interface
	PyWidget(const PyWidget& p);

	///
	~PyWidget();
	
	/// Is full Python support available?
	bool isValid() const 
		{ return valid_;}

	/**	@name	ModularWidget related methods
	*/
	//@{

	/**	Setup the menu entries.
	*/
	virtual void initializeWidget(MainControl& main_control);

	/**	Remove menu entries.
	*/
	virtual void finalizeWidget(MainControl& main_control);
	
	///
	void initializePreferencesTab(Preferences &preferences);
	
	///
	void finalizePreferencesTab(Preferences &preferences);

	///
	virtual void applyPreferences();
	
	/// Open a dialog to select a script
	virtual void scriptDialog(bool run = false);

	///
	bool toAbortScript();

	/** Map a key to a command
	 		Modifier can be: "", Ctrl, Shift
			Key should be F2 - F12
	*/
	void map(String modifier, String key, String command, String comment = "");

	/// see above
	void unmap(String modifier, String key);

	///
	void insertHotkey(const Hotkey& hotkey);

	///
	void removeHotkey(const Hotkey& hotkey);

	///
	void reactTo(const QKeyEvent& e);

	/** Test if this ModularWidget can handle a given file format.
	 		(Overloaded from ModularWidget)
			@param fileform short string with the file extension (e.g. PDB)
			@see openFile
	*/
	virtual bool canHandle(const String& fileformat) const;

	/** Tell this ModularWidget to open a given file.
	 		(Overloaded from ModularWidget)
			@see canHandle
	*/
	virtual bool openFile(const String& filename);

	/** Run a Python script from a given file
	 		@param is_current states wheter this file is currently loaded in the editor
	*/
	bool openFile(const String& filename, bool run, bool is_current = false);

	//
	bool runString(String command);

	//
	String getCurrentLine() const;

	//
	void dump(std::ostream& s, Size depth) const;

	//
	void showClassDocu(String classname, String member);

	//
	virtual void fetchPreferences(INIFile& inifile);
	
	//
	virtual void writePreferences(INIFile& inifile);

	//
	void checkMenu(MainControl& main_control);

	///
	QString getCurrentScript();

	///
	bool isInDirectMode() const;

	public slots:

	//
	void showEditContextMenu(const QPoint& point);

	//
	void showContextMenu(const QPoint& point);

	//
	void showCompletion();

	//
	void clear();

	//
	void exportHistory();

	//
	void abortScript();

	// Show the docu for the current line
	void showDocumentation();

	///
	bool runCurrentScript();

	///
	void loadScript();
	
	///
	void execScript();

	///
	void saveScript();

	///
	void clearScript();

	virtual void hotkeyItem();

	virtual void modifyHotkeys();

	void appendText(const String& text, bool output = false, bool state_message = false);

	bool getMembers(const String& classname, QStringList& sl, const String& prefix);

	protected slots:

	virtual bool returnPressed();

	virtual bool completionSelected_();

	virtual void showHelp_();

	virtual void printCursorPosition_();

	virtual void createScript_();

	virtual void clearHistory_();

	protected:

	bool getClassAndMember_(String toc);

	void setError_(bool state);

	/** Start the interpreter.
			This method initializes the interpreter if it is not yet running. 
			An already running interpreter is reinitialized.
			This method calls <tt>PyInitialize()</tt> to create an interpreter.
	*/
	virtual void startInterpreter();

	virtual void paste();

	/// Parse a and execute a given string. If silent_ is set to true, no prompts are being printed.
	bool parseLine_(String line);

	void appendToHistory_(const String& line);
	
	/**	Print prompt.
			Determine the correct type of prompt and append it 
			to the current text. The cursor is placed after
			the prompt and <tt>textChanged</tt> is emitted.
	*/
	void newPrompt_();

	bool testMultilineStart_(const String& line);

	//_
	const char* getPrompt_() const;

	//_
	bool storeScript_();

	//_ Wrapper for multi and single threading call
	String runCommand_(const String& command, bool& state);

	void appendText_(TextEditorWidget* te, String text);

	/**	Replace the line the cursor is in with a line from the history.
			Used to display text from the history (cursor down/up).
			The previous content of the line is stored in
			<tt>current_line_</tt> if this is the first time the history
			function is used for this specific line.
	*/	
	void retrieveHistoryLine_(Position index);

	virtual void contentsDragEnterEvent(QDragEnterEvent* e);

	virtual void contentsDropEvent(QDropEvent* e);

	bool keyPressed(QKeyEvent* e);

	void createMenuHelpEntry_(QMenu* menu, TextEditorWidget* text_edit, const QPoint& point);

	void findError_(String result);

	String getCurrentWord_(QTextCursor& text_cursor);

	QComboBox* getCompletionBox_();

	std::list<Hotkey>::iterator findKey_(Hotkey& hotkey);

	TextEditorWidget* 				text_edit_, *script_output_;
	MyTextEdit* 			script_edit_;
	QTabWidget* 			tab_widget_;
	PythonHighlighter highlighter_1_, highlighter_2_;
	PythonValidator   validator_;
	MyLineEdit* 			line_edit_;
	QComboBox* 				combo_box_, *editor_combo_box_;
	std::list<Hotkey>	hotkeys_;
	// 								we use an own working dir to find Python Scripts
	String 						working_dir_;
	bool 							valid_;
	bool 							started_startup_script_;
	Preferences* 			preferences_;

	Position 					current_line_;
	bool							multi_line_mode_;
	Size 							multi_lines_;
	String						multi_line_text_;
	vector<String>		history_;
	vector<bool> 			results_;
	Position					history_position_;
	String 						startup_script_;
	PythonSettings* 	python_settings_;
	RunPythonThread* 	thread_;
	bool 							stop_script_;
	Size              complete_prefix_;
	String 						class_, member_;
	Position 					intend_;
	bool 							running_;
	bool 							silent_, full_silent_;
	bool 							script_mode_;
	String 						current_script_;
};

	} // namespaces	
} // namespaces
	
#endif // BALL_VIEW_WIDGETS_PYWIDGET_H