File indexing completed on 2024-05-05 09:18:26
0001 /****************************************************************************** 0002 Copyright (C) 2006-2008 by Michel Ludwig (michel.ludwig@kdemail.net) 0003 2011-2012 by Holger Danielsson (holger.danielsson@versanet.de) 0004 ******************************************************************************/ 0005 0006 /************************************************************************** 0007 * * 0008 * This program is free software; you can redistribute it and/or modify * 0009 * it under the terms of the GNU General Public License as published by * 0010 * the Free Software Foundation; either version 2 of the License, or * 0011 * (at your option) any later version. * 0012 * * 0013 ***************************************************************************/ 0014 0015 #ifndef KILE_SCRIPT_VIEW_H 0016 #define KILE_SCRIPT_VIEW_H 0017 0018 #include <QObject> 0019 #include <QMap> 0020 #include <QScriptable> 0021 0022 #include <KTextEditor/Cursor> 0023 #include <KTextEditor/Range> 0024 #include <KTextEditor/View> 0025 #include <KActionCollection> 0026 0027 #include "editorextension.h" 0028 0029 namespace KileScript { 0030 0031 class KileScriptView : public QObject, protected QScriptable 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 KileScriptView (QObject *parent, KileDocument::EditorExtension *editor); 0037 virtual ~KileScriptView() {} 0038 0039 void setView(KTextEditor::View *view); 0040 KTextEditor::View *view() const; 0041 0042 // cursor 0043 Q_INVOKABLE KTextEditor::Cursor cursorPosition (); 0044 Q_INVOKABLE void setCursorPosition(int line, int column); 0045 Q_INVOKABLE void setCursorPosition(const KTextEditor::Cursor& cursor); 0046 0047 Q_INVOKABLE void backspace(); 0048 0049 Q_INVOKABLE void cursorLeft(); 0050 Q_INVOKABLE void cursorRight(); 0051 Q_INVOKABLE void cursorUp(); 0052 Q_INVOKABLE void cursorDown(); 0053 0054 Q_INVOKABLE int cursorLine(); 0055 Q_INVOKABLE int cursorColumn(); 0056 Q_INVOKABLE void setCursorLine(int l); 0057 Q_INVOKABLE void setCursorColumn(int c); 0058 0059 Q_INVOKABLE KTextEditor::Cursor virtualCursorPosition(); 0060 0061 // selection 0062 Q_INVOKABLE bool hasSelection(); 0063 Q_INVOKABLE QString selectedText(); 0064 Q_INVOKABLE KTextEditor::Range selectionRange(); 0065 Q_INVOKABLE void setSelection(const KTextEditor::Range& range); 0066 Q_INVOKABLE void selectAll(); 0067 0068 Q_INVOKABLE void clearSelection(); 0069 Q_INVOKABLE void removeSelectedText(); 0070 0071 // line 0072 Q_INVOKABLE void selectLine(); 0073 Q_INVOKABLE void selectLine(int line); 0074 Q_INVOKABLE void selectLines(int from, int to); 0075 0076 // word 0077 Q_INVOKABLE void selectWord(); 0078 0079 // latex command 0080 Q_INVOKABLE void selectLatexCommand(); 0081 0082 // environment 0083 Q_INVOKABLE void selectEnvironment(bool inside = false); 0084 0085 // texgroup 0086 Q_INVOKABLE void selectTexgroup(bool inside = true); 0087 0088 // mathgroup 0089 Q_INVOKABLE void selectMathgroup(); 0090 0091 // paragraph 0092 Q_INVOKABLE void selectParagraph(bool wholeLines = true); 0093 0094 private: 0095 KTextEditor::View *m_view; 0096 KileDocument::EditorExtension *m_editor; 0097 0098 }; 0099 0100 } 0101 0102 #endif