File indexing completed on 2024-04-21 15:55:23
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 #include "kilescriptview.h" 0016 #include "kiledebug.h" 0017 0018 0019 namespace KileScript { 0020 0021 0022 KileScriptView::KileScriptView(QObject *parent, KileDocument::EditorExtension *editor) 0023 : QObject(parent), m_view(0), m_editor(editor) 0024 { 0025 } 0026 0027 ////////////////////////////////// view ////////////////////////////////////// 0028 0029 void KileScriptView::setView (KTextEditor::View *view) 0030 { 0031 m_view = view; 0032 } 0033 0034 KTextEditor::View *KileScriptView::view() const 0035 { 0036 return m_view; 0037 } 0038 0039 ////////////////////////////////// cursor ////////////////////////////////////// 0040 0041 void KileScriptView::backspace() 0042 { 0043 QAction *action = m_view->action("backspace"); 0044 if(action) { 0045 action->trigger(); 0046 } 0047 } 0048 0049 KTextEditor::Cursor KileScriptView::cursorPosition() 0050 { 0051 return m_view->cursorPosition(); 0052 } 0053 0054 void KileScriptView::setCursorPosition(int line, int column) 0055 { 0056 setCursorPosition( KTextEditor::Cursor(line, column) ); 0057 } 0058 0059 void KileScriptView::setCursorPosition (const KTextEditor::Cursor& cursor) 0060 { 0061 m_view->setCursorPosition(cursor); 0062 } 0063 0064 KTextEditor::Cursor KileScriptView::virtualCursorPosition() 0065 { 0066 return m_view->cursorPositionVirtual(); 0067 } 0068 0069 void KileScriptView::cursorLeft() 0070 { 0071 m_editor->moveCursorLeft(m_view); 0072 } 0073 0074 void KileScriptView::cursorRight() 0075 { 0076 m_editor->moveCursorRight(m_view); 0077 } 0078 0079 void KileScriptView::cursorUp() 0080 { 0081 m_editor->moveCursorUp(m_view); 0082 } 0083 0084 void KileScriptView::cursorDown() 0085 { 0086 m_editor->moveCursorDown(m_view); 0087 } 0088 0089 int KileScriptView::cursorLine() 0090 { 0091 return m_view->cursorPosition().line(); 0092 } 0093 0094 int KileScriptView::cursorColumn() 0095 { 0096 return m_view->cursorPosition().column(); 0097 } 0098 0099 void KileScriptView::setCursorLine(int l) 0100 { 0101 KTextEditor::Cursor cursor = m_view->cursorPosition(); 0102 cursor.setLine(l); 0103 m_view->setCursorPosition(cursor); 0104 } 0105 0106 void KileScriptView::setCursorColumn(int c) 0107 { 0108 KTextEditor::Cursor cursor = m_view->cursorPosition(); 0109 cursor.setColumn(c); 0110 m_view->setCursorPosition(cursor); 0111 } 0112 0113 ////////////////////////////////// selection ////////////////////////////////////// 0114 0115 bool KileScriptView::hasSelection() 0116 { 0117 return m_view->selection(); 0118 } 0119 0120 QString KileScriptView::selectedText() 0121 { 0122 return m_view->selectionText(); 0123 } 0124 0125 KTextEditor::Range KileScriptView::selectionRange() 0126 { 0127 return m_view->selectionRange(); 0128 } 0129 0130 void KileScriptView::setSelection(const KTextEditor::Range& range) 0131 { 0132 m_view->setSelection(range); 0133 } 0134 0135 void KileScriptView::selectAll() 0136 { 0137 m_view->setSelection( m_view->document()->documentRange() ); 0138 } 0139 0140 void KileScriptView::clearSelection() 0141 { 0142 m_view->removeSelection(); 0143 } 0144 0145 void KileScriptView::removeSelectedText() 0146 { 0147 m_view->removeSelectionText(); 0148 } 0149 0150 /////////////////////////////// line ////////////////////////////// 0151 0152 void KileScriptView::selectLine() 0153 { 0154 m_editor->selectLine(m_view); 0155 } 0156 0157 void KileScriptView::selectLine(int line) 0158 { 0159 m_editor->selectLine(line,m_view); 0160 } 0161 0162 void KileScriptView::selectLines(int from, int to) 0163 { 0164 m_editor->selectLines(from,to,m_view); 0165 } 0166 0167 /////////////////////////////// word ////////////////////////////// 0168 0169 void KileScriptView::selectWord() 0170 { 0171 m_editor->selectWord(KileDocument::EditorExtension::smLetter,m_view); 0172 } 0173 0174 /////////////////////////////// latex command ////////////////////////////// 0175 0176 void KileScriptView::selectLatexCommand() 0177 { 0178 m_editor->selectWord(KileDocument::EditorExtension::smTex,m_view); 0179 } 0180 0181 /////////////////////////////// environment ////////////////////////////// 0182 0183 void KileScriptView::selectEnvironment(bool inside) 0184 { 0185 m_editor->selectEnvironment(inside,m_view); 0186 } 0187 0188 ////////////////////////////////// TexGroup ////////////////////////////////////// 0189 0190 void KileScriptView::selectTexgroup(bool inside) 0191 { 0192 return m_editor->selectTexgroup(inside,m_view); 0193 } 0194 0195 ////////////////////////////////// MathGroup ////////////////////////////////////// 0196 0197 void KileScriptView::selectMathgroup() 0198 { 0199 m_editor->selectMathgroup(m_view); 0200 } 0201 0202 ////////////////////////////////// Paragraph ////////////////////////////////////// 0203 0204 void KileScriptView::selectParagraph(bool wholeLines) 0205 { 0206 m_editor->selectParagraph(m_view, wholeLines); 0207 } 0208 0209 } 0210 0211 0212