• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • view
kateview.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2009 Michel Ludwig <michel.ludwig@kdemail.net>
3  Copyright (C) 2007 Mirko Stocker <me@misto.ch>
4  Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
5  Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
6  Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org>
7  Copyright (C) 2001-2010 Joseph Wenninger <jowenn@kde.org>
8  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Library General Public
12  License version 2 as published by the Free Software Foundation.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Library General Public License for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with this library; see the file COPYING.LIB. If not, write to
21  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  Boston, MA 02110-1301, USA.
23 */
24 
25 //BEGIN includes
26 #include "kateview.h"
27 #include "kateview.moc"
28 
29 #include "kateviewinternal.h"
30 #include "kateviewhelpers.h"
31 #include "katerenderer.h"
32 #include "katedocument.h"
33 #include "kateundomanager.h"
34 #include "katedocumenthelpers.h"
35 #include "kateglobal.h"
36 #include "kateviglobal.h"
37 #include "katehighlight.h"
38 #include "katehighlightmenu.h"
39 #include "katedialogs.h"
40 #include "katetextline.h"
41 #include "kateschema.h"
42 #include "katebookmarks.h"
43 #include "kateconfig.h"
44 #include "katemodemenu.h"
45 #include "kateautoindent.h"
46 #include "katecompletionwidget.h"
47 #include "katesearchbar.h"
48 #include "kateviemulatedcommandbar.h"
49 #include "katepartpluginmanager.h"
50 #include "katewordcompletion.h"
51 #include "katekeywordcompletion.h"
52 #include "katelayoutcache.h"
53 #include "spellcheck/spellcheck.h"
54 #include "spellcheck/spellcheckdialog.h"
55 #include "spellcheck/spellingmenu.h"
56 #include "katebuffer.h"
57 #include "script/katescriptmanager.h"
58 #include "script/katescriptaction.h"
59 #include "snippet/katesnippetglobal.h"
60 #include "snippet/snippetcompletionmodel.h"
61 #include "katemessagewidget.h"
62 #include "katetemplatehandler.h"
63 
64 #include <ktexteditor/messageinterface.h>
65 
66 #include <kparts/event.h>
67 
68 #include <kconfig.h>
69 #include <kdebug.h>
70 #include <kapplication.h>
71 #include <kcursor.h>
72 #include <kicon.h>
73 #include <klocale.h>
74 #include <kglobal.h>
75 #include <kcharsets.h>
76 #include <kmessagebox.h>
77 #include <kaction.h>
78 #include <kstandardaction.h>
79 #include <kxmlguifactory.h>
80 #include <kxmlguiclient.h>
81 #include <kencodingfiledialog.h>
82 #include <kstandardshortcut.h>
83 #include <kmenu.h>
84 #include <ktoggleaction.h>
85 #include <kselectaction.h>
86 #include <kactioncollection.h>
87 #include <kdeversion.h>
88 
89 #include <QtGui/QFont>
90 #include <QtCore/QFileInfo>
91 #include <QtGui/QStyle>
92 #include <QtGui/QKeyEvent>
93 #include <QtGui/QLayout>
94 #include <QtCore/QMimeData>
95 
96 //#define VIEW_RANGE_DEBUG
97 
98 //END includes
99 
100 namespace {
101 
102 bool hasCommentInFirstLine(KateDocument* doc)
103 {
104  const Kate::TextLine& line = doc->kateTextLine(0);
105  Q_ASSERT(line);
106  return doc->isComment(0, line->firstChar());
107 }
108 
109 }
110 
111 void KateView::blockFix(KTextEditor::Range& range)
112 {
113  if (range.start().column() > range.end().column())
114  {
115  int tmp = range.start().column();
116  range.start().setColumn(range.end().column());
117  range.end().setColumn(tmp);
118  }
119 }
120 
121 KateView::KateView( KateDocument *doc, QWidget *parent )
122  : KTextEditor::View( parent )
123  , m_completionWidget(0)
124  , m_annotationModel(0)
125  , m_hasWrap( false )
126  , m_doc( doc )
127  , m_textFolding (doc->buffer())
128  , m_config( new KateViewConfig( this ) )
129  , m_renderer( new KateRenderer( doc, m_textFolding, this ) )
130  , m_viewInternal( new KateViewInternal( this ) )
131  , m_spell( new KateSpellCheckDialog( this ) )
132  , m_bookmarks( new KateBookmarks( this ) )
133  , m_startingUp (true)
134  , m_updatingDocumentConfig (false)
135  , m_selection (m_doc->buffer(), KTextEditor::Range::invalid(), Kate::TextRange::ExpandLeft, Kate::TextRange::AllowEmpty)
136  , blockSelect (false)
137  , m_bottomViewBar (0)
138  , m_topViewBar (0)
139  , m_cmdLine (0)
140  , m_searchBar (0)
141  , m_viModeEmulatedCommandBar(0)
142  , m_gotoBar (0)
143  , m_dictionaryBar(NULL)
144  , m_spellingMenu( new KateSpellingMenu( this ) )
145  , m_userContextMenuSet( false )
146  , m_delayedUpdateTriggered (false)
147  , m_lineToUpdateMin (-1)
148  , m_lineToUpdateMax (-1)
149  , m_floatTopMessageWidget (0)
150  , m_floatBottomMessageWidget (0)
151 {
152  // queued connect to collapse view updates for range changes, INIT THIS EARLY ENOUGH!
153  connect(this, SIGNAL(delayedUpdateOfView()), this, SLOT(slotDelayedUpdateOfView()), Qt::QueuedConnection);
154 
155  setComponentData ( KateGlobal::self()->componentData () );
156 
157  // selection if for this view only and will invalidate if becoming empty
158  m_selection.setView (this);
159 
160  // use z depth defined in moving ranges interface
161  m_selection.setZDepth (-100000.0);
162 
163  KateGlobal::self()->registerView( this );
164 
165  KTextEditor::ViewBarContainer *viewBarContainer=qobject_cast<KTextEditor::ViewBarContainer*>( KateGlobal::self()->container() );
166  QWidget *bottomBarParent=viewBarContainer?viewBarContainer->getViewBarParent(this,KTextEditor::ViewBarContainer::BottomBar):0;
167  QWidget *topBarParent=viewBarContainer?viewBarContainer->getViewBarParent(this,KTextEditor::ViewBarContainer::TopBar):0;
168 
169  m_bottomViewBar=new KateViewBar (bottomBarParent!=0,KTextEditor::ViewBarContainer::BottomBar,bottomBarParent?bottomBarParent:this,this);
170  m_topViewBar=new KateViewBar (topBarParent!=0,KTextEditor::ViewBarContainer::TopBar,topBarParent?topBarParent:this,this);
171 
172  // ugly workaround:
173  // Force the layout to be left-to-right even on RTL deskstop, as discussed
174  // on the mailing list. This will cause the lines and icons panel to be on
175  // the left, even for Arabic/Hebrew/Farsi/whatever users.
176  setLayoutDirection ( Qt::LeftToRight );
177 
178  // layouting ;)
179  m_vBox = new QVBoxLayout (this);
180  m_vBox->setMargin (0);
181  m_vBox->setSpacing (0);
182 
183  // add top viewbar...
184  if (topBarParent)
185  viewBarContainer->addViewBarToLayout(this,m_topViewBar,KTextEditor::ViewBarContainer::TopBar);
186  else
187  m_vBox->addWidget(m_topViewBar);
188 
189  m_bottomViewBar->installEventFilter(m_viewInternal);
190 
191  // add KateMessageWidget for KTE::MessageInterface immediately above view
192  m_topMessageWidget = new KateMessageWidget(this);
193  m_vBox->addWidget(m_topMessageWidget);
194  m_topMessageWidget->hide();
195 
196  // add hbox: KateIconBorder | KateViewInternal | KateScrollBar
197  QHBoxLayout *hbox = new QHBoxLayout ();
198  m_vBox->addLayout (hbox, 100);
199  hbox->setMargin (0);
200  hbox->setSpacing (0);
201 
202  QStyleOption option;
203  option.initFrom(this);
204 
205  if (style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &option, this)) {
206  QHBoxLayout *extrahbox = new QHBoxLayout ();
207  QFrame * frame = new QFrame(this);
208  extrahbox->setMargin (0);
209  extrahbox->setSpacing (0);
210  extrahbox->addWidget (m_viewInternal->m_leftBorder);
211  extrahbox->addWidget (m_viewInternal);
212  frame->setLayout (extrahbox);
213  hbox->addWidget (frame);
214  hbox->addSpacing (style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &option, this));
215  frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
216  }
217  else {
218  hbox->addWidget (m_viewInternal->m_leftBorder);
219  hbox->addWidget (m_viewInternal);
220  }
221  hbox->addWidget (m_viewInternal->m_lineScroll);
222 
223  if (style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &option, this)) {
224  m_vBox->addSpacing (style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &option, this));
225  }
226 
227  // add hbox: ColumnsScrollBar | Dummy
228  hbox = new QHBoxLayout ();
229  m_vBox->addLayout (hbox);
230  hbox->setMargin (0);
231  hbox->setSpacing (0);
232 
233  hbox->addWidget (m_viewInternal->m_columnScroll);
234  hbox->addWidget (m_viewInternal->m_dummy);
235 
236  // add KateMessageWidget for KTE::MessageInterface immediately above view
237  m_bottomMessageWidget = new KateMessageWidget(this);
238  m_vBox->addWidget(m_bottomMessageWidget);
239  m_bottomMessageWidget->hide();
240 
241  // add bottom viewbar...
242  if (bottomBarParent)
243  viewBarContainer->addViewBarToLayout(this,m_bottomViewBar,KTextEditor::ViewBarContainer::BottomBar);
244  else
245  m_vBox->addWidget(m_bottomViewBar);
246 
247  // add layout for floating message widgets to KateViewInternal
248  m_notificationLayout = new QVBoxLayout(m_viewInternal);
249  m_notificationLayout->setContentsMargins(20, 20, 20, 20);
250  m_viewInternal->setLayout(m_notificationLayout);
251 
252  // this really is needed :)
253  m_viewInternal->updateView ();
254 
255  doc->addView( this );
256 
257  setFocusProxy( m_viewInternal );
258  setFocusPolicy( Qt::StrongFocus );
259 
260  // default ui file with all features
261  QString uifile = "katepartui.rc";
262 
263  // simple mode
264  if (doc->simpleMode ())
265  uifile = "katepartsimpleui.rc";
266 
267  setXMLFile( uifile );
268 
269  setupConnections();
270  setupActions();
271 
272  // auto word completion
273  new KateWordCompletionView (this, actionCollection ());
274 
275  // enable the plugins of this view
276  KatePartPluginManager::self()->addView(this);
277 
278  // update the enabled state of the undo/redo actions...
279  slotUpdateUndo();
280 
281  m_startingUp = false;
282  updateConfig ();
283 
284  slotHlChanged();
285  KCursor::setAutoHideCursor( m_viewInternal, true );
286 
287  if ( viInputMode() /* && FIXME: HAEHH? !config()->viInputModeHideStatusBar() */ ) {
288  deactivateEditActions();
289  }
290 
291  // user interaction (scrollling) starts notification auto-hide timer
292  connect(this, SIGNAL(displayRangeChanged(KateView*)), m_topMessageWidget, SLOT(startAutoHideTimer()));
293  connect(this, SIGNAL(displayRangeChanged(KateView*)), m_bottomMessageWidget, SLOT(startAutoHideTimer()));
294 
295  // user interaction (cursor navigation) starts notification auto-hide timer
296  connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View*, const KTextEditor::Cursor&)), m_topMessageWidget, SLOT(startAutoHideTimer()));
297  connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View*, const KTextEditor::Cursor&)), m_bottomMessageWidget, SLOT(startAutoHideTimer()));
298 
299  // folding restoration on reload
300  connect(m_doc, SIGNAL(aboutToReload(KTextEditor::Document*)), SLOT(saveFoldingState()));
301  connect(m_doc, SIGNAL(reloaded(KTextEditor::Document*)), SLOT(applyFoldingState()));
302 }
303 
304 KateView::~KateView()
305 {
306  // invalidate update signal
307  m_delayedUpdateTriggered = false;
308 
309  // remove from xmlgui factory, to be safe
310  if (factory())
311  factory()->removeClient (this);
312 
313  KTextEditor::ViewBarContainer *viewBarContainer=qobject_cast<KTextEditor::ViewBarContainer*>( KateGlobal::self()->container() );
314  if (viewBarContainer) {
315  viewBarContainer->deleteViewBarForView(this,KTextEditor::ViewBarContainer::BottomBar);
316  m_bottomViewBar=0;
317  viewBarContainer->deleteViewBarForView(this,KTextEditor::ViewBarContainer::TopBar);
318  m_topViewBar=0;
319  }
320 
321  KatePartPluginManager::self()->removeView(this);
322 
323  m_doc->removeView( this );
324 
325  delete m_viewInternal;
326 
327  delete m_renderer;
328 
329  delete m_config;
330 
331  KateGlobal::self()->deregisterView (this);
332 }
333 
334 void KateView::setupConnections()
335 {
336  connect( m_doc, SIGNAL(undoChanged()),
337  this, SLOT(slotUpdateUndo()) );
338  connect( m_doc, SIGNAL(highlightingModeChanged(KTextEditor::Document*)),
339  this, SLOT(slotHlChanged()) );
340  connect( m_doc, SIGNAL(canceled(QString)),
341  this, SLOT(slotSaveCanceled(QString)) );
342  connect( m_viewInternal, SIGNAL(dropEventPass(QDropEvent*)),
343  this, SIGNAL(dropEventPass(QDropEvent*)) );
344 
345  connect( m_doc, SIGNAL(annotationModelChanged(KTextEditor::AnnotationModel*,KTextEditor::AnnotationModel*)),
346  m_viewInternal->m_leftBorder, SLOT(annotationModelChanged(KTextEditor::AnnotationModel*,KTextEditor::AnnotationModel*)) );
347 
348  if ( m_doc->browserView() )
349  {
350  connect( this, SIGNAL(dropEventPass(QDropEvent*)),
351  this, SLOT(slotDropEventPass(QDropEvent*)) );
352  }
353 }
354 
355 void KateView::setupActions()
356 {
357  KActionCollection *ac = actionCollection ();
358  KAction *a;
359 
360  m_toggleWriteLock = 0;
361 
362  m_cut = a = ac->addAction(KStandardAction::Cut, this, SLOT(cut()));
363  a->setWhatsThis(i18n("Cut the selected text and move it to the clipboard"));
364 
365  m_paste = a = ac->addAction(KStandardAction::PasteText, this, SLOT(paste()));
366  a->setWhatsThis(i18n("Paste previously copied or cut clipboard contents"));
367 
368  m_copy = a = ac->addAction(KStandardAction::Copy, this, SLOT(copy()));
369  a->setWhatsThis(i18n( "Use this command to copy the currently selected text to the system clipboard."));
370 
371  m_pasteMenu = ac->addAction("edit_paste_menu", new KatePasteMenu (i18n("Clipboard &History"), this));
372  connect (KateGlobal::self(), SIGNAL(clipboardHistoryChanged()), this, SLOT(slotClipboardHistoryChanged()));
373 
374  if (!m_doc->readOnly())
375  {
376  a = ac->addAction(KStandardAction::Save, m_doc, SLOT(documentSave()));
377  a->setWhatsThis(i18n("Save the current document"));
378 
379  a = m_editUndo = ac->addAction(KStandardAction::Undo, m_doc, SLOT(undo()));
380  a->setWhatsThis(i18n("Revert the most recent editing actions"));
381 
382  a = m_editRedo = ac->addAction(KStandardAction::Redo, m_doc, SLOT(redo()));
383  a->setWhatsThis(i18n("Revert the most recent undo operation"));
384 
385  // Tools > Scripts
386  KateScriptActionMenu* scriptActionMenu = new KateScriptActionMenu(this, i18n("&Scripts"));
387  ac->addAction("tools_scripts", scriptActionMenu);
388 
389  a = ac->addAction("tools_apply_wordwrap");
390  a->setText(i18n("Apply &Word Wrap"));
391  a->setWhatsThis(i18n("Use this command to wrap all lines of the current document which are longer than the width of the"
392  " current view, to fit into this view.<br /><br /> This is a static word wrap, meaning it is not updated"
393  " when the view is resized."));
394  connect(a, SIGNAL(triggered(bool)), SLOT(applyWordWrap()));
395 
396  a = ac->addAction("tools_cleanIndent");
397  a->setText(i18n("&Clean Indentation"));
398  a->setWhatsThis(i18n("Use this to clean the indentation of a selected block of text (only tabs/only spaces).<br /><br />"
399  "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
400  connect(a, SIGNAL(triggered(bool)), SLOT(cleanIndent()));
401 
402  a = ac->addAction("tools_align");
403  a->setText(i18n("&Align"));
404  a->setWhatsThis(i18n("Use this to align the current line or block of text to its proper indent level."));
405  connect(a, SIGNAL(triggered(bool)), SLOT(align()));
406 
407  a = ac->addAction("tools_comment");
408  a->setText(i18n("C&omment"));
409  a->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_D));
410  a->setWhatsThis(i18n("This command comments out the current line or a selected block of text.<br /><br />"
411  "The characters for single/multiple line comments are defined within the language's highlighting."));
412  connect(a, SIGNAL(triggered(bool)), SLOT(comment()));
413 
414  a = ac->addAction("tools_uncomment");
415  a->setText(i18n("Unco&mment"));
416  a->setShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_D));
417  a->setWhatsThis(i18n("This command removes comments from the current line or a selected block of text.<br /><br />"
418  "The characters for single/multiple line comments are defined within the language's highlighting."));
419  connect(a, SIGNAL(triggered(bool)), SLOT(uncomment()));
420 
421  a = ac->addAction("tools_toggle_comment");
422  a->setText(i18n("Toggle Comment"));
423  connect(a, SIGNAL(triggered(bool)), SLOT(toggleComment()));
424 
425  a = m_toggleWriteLock = new KToggleAction(i18n("&Read Only Mode"), this);
426  a->setWhatsThis( i18n("Lock/unlock the document for writing") );
427  a->setChecked( !m_doc->isReadWrite() );
428  connect(a, SIGNAL(triggered(bool)), SLOT(toggleWriteLock()));
429  ac->addAction("tools_toggle_write_lock", a);
430 
431  a = ac->addAction("tools_uppercase");
432  a->setText(i18n("Uppercase"));
433  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U));
434  a->setWhatsThis( i18n("Convert the selection to uppercase, or the character to the "
435  "right of the cursor if no text is selected.") );
436  connect(a, SIGNAL(triggered(bool)), SLOT(uppercase()));
437 
438  a = ac->addAction( "tools_lowercase" );
439  a->setText( i18n("Lowercase") );
440  a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_U));
441  a->setWhatsThis( i18n("Convert the selection to lowercase, or the character to the "
442  "right of the cursor if no text is selected.") );
443  connect(a, SIGNAL(triggered(bool)), SLOT(lowercase()));
444 
445  a = ac->addAction( "tools_capitalize" );
446  a->setText( i18n("Capitalize") );
447  a->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_U));
448  a->setWhatsThis( i18n("Capitalize the selection, or the word under the "
449  "cursor if no text is selected.") );
450  connect(a, SIGNAL(triggered(bool)), SLOT(capitalize()));
451 
452  a = ac->addAction( "tools_join_lines" );
453  a->setText( i18n("Join Lines") );
454  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_J));
455  connect(a, SIGNAL(triggered(bool)), SLOT(joinLines()));
456 
457  a = ac->addAction( "tools_invoke_code_completion" );
458  a->setText( i18n("Invoke Code Completion") );
459  a->setWhatsThis(i18n("Manually invoke command completion, usually by using a shortcut bound to this action."));
460  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Space));
461  connect(a, SIGNAL(triggered(bool)), SLOT(userInvokedCompletion()));
462 
463  a = ac->addAction( "tools_create_snippet" );
464  a->setIcon (KIcon("document-new"));
465  a->setText( i18n("Create Snippet") );
466  connect(a, SIGNAL(triggered(bool)), SLOT(createSnippet()));
467 
468  a = ac->addAction( "tools_snippets" );
469  a->setText( i18n("Snippets...") );
470  connect(a, SIGNAL(triggered(bool)), SLOT(showSnippetsDialog()));
471  }
472  else
473  {
474  m_cut->setEnabled (false);
475  m_paste->setEnabled (false);
476  m_pasteMenu->setEnabled (false);
477  m_editUndo = 0;
478  m_editRedo = 0;
479  }
480 
481  a = ac->addAction( KStandardAction::Print, m_doc, SLOT(print()) );
482  a->setWhatsThis(i18n("Print the current document."));
483 
484  a = ac->addAction( "file_reload" );
485  a->setIcon(KIcon("view-refresh"));
486  a->setText(i18n("Reloa&d"));
487  a->setShortcuts(KStandardShortcut::reload());
488  a->setWhatsThis(i18n("Reload the current document from disk."));
489  connect(a, SIGNAL(triggered(bool)), SLOT(reloadFile()));
490 
491  a = ac->addAction( KStandardAction::SaveAs, m_doc, SLOT(documentSaveAs()) );
492  a->setWhatsThis(i18n("Save the current document to disk, with a name of your choice."));
493 
494  a = ac->addAction( KStandardAction::GotoLine, this, SLOT(gotoLine()) );
495  a->setWhatsThis(i18n("This command opens a dialog and lets you choose a line that you want the cursor to move to."));
496 
497  a = ac->addAction(QLatin1String("modified_line_up"));
498  a->setText(i18n("Move to Previous Modified Line"));
499  a->setWhatsThis(i18n("Move upwards to the previous modified line."));
500  connect(a, SIGNAL(triggered(bool)), SLOT(toPrevModifiedLine()));
501 
502  a = ac->addAction(QLatin1String("modified_line_down"));
503  a->setText(i18n("Move to Next Modified Line"));
504  a->setWhatsThis(i18n("Move downwards to the next modified line."));
505  connect(a, SIGNAL(triggered(bool)), SLOT(toNextModifiedLine()));
506 
507  a = ac->addAction("set_confdlg");
508  a->setText(i18n("&Configure Editor..."));
509  a->setWhatsThis(i18n("Configure various aspects of this editor."));
510  connect(a, SIGNAL(triggered(bool)), SLOT(slotConfigDialog()));
511 
512  KateModeMenu *ftm = new KateModeMenu (i18n("&Mode"), this);
513  ac->addAction("tools_mode", ftm);
514  ftm->setWhatsThis(i18n("Here you can choose which mode should be used for the current document. This will influence the highlighting and folding being used, for example."));
515  ftm->updateMenu (m_doc);
516 
517  KateHighlightingMenu *menu = new KateHighlightingMenu (i18n("&Highlighting"), this);
518  ac->addAction("tools_highlighting", menu);
519  menu->setWhatsThis(i18n("Here you can choose how the current document should be highlighted."));
520  menu->updateMenu (m_doc);
521 
522  KateViewSchemaAction *schemaMenu = new KateViewSchemaAction (i18n("&Schema"), this);
523  ac->addAction("view_schemas", schemaMenu);
524  schemaMenu->updateMenu (this);
525 
526  // indentation menu
527  KateViewIndentationAction *indentMenu = new KateViewIndentationAction(m_doc, i18n("&Indentation"), this);
528  ac->addAction("tools_indentation", indentMenu);
529 
530  m_selectAll = a= ac->addAction( KStandardAction::SelectAll, this, SLOT(selectAll()) );
531  a->setWhatsThis(i18n("Select the entire text of the current document."));
532 
533  m_deSelect = a= ac->addAction( KStandardAction::Deselect, this, SLOT(clearSelection()) );
534  a->setWhatsThis(i18n("If you have selected something within the current document, this will no longer be selected."));
535 
536  a = ac->addAction("view_inc_font_sizes");
537  a->setIcon(KIcon("zoom-in"));
538  a->setText(i18n("Enlarge Font"));
539  a->setShortcut(KStandardShortcut::zoomIn());
540  a->setWhatsThis(i18n("This increases the display font size."));
541  connect(a, SIGNAL(triggered(bool)), m_viewInternal, SLOT(slotIncFontSizes()));
542 
543  a = ac->addAction("view_dec_font_sizes");
544  a->setIcon(KIcon("zoom-out"));
545  a->setText(i18n("Shrink Font"));
546  a->setShortcut(KStandardShortcut::zoomOut());
547  a->setWhatsThis(i18n("This decreases the display font size."));
548  connect(a, SIGNAL(triggered(bool)), m_viewInternal, SLOT(slotDecFontSizes()));
549 
550  a = m_toggleBlockSelection = new KToggleAction(i18n("Bl&ock Selection Mode"), this);
551  ac->addAction("set_verticalSelect", a);
552  a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
553  a->setWhatsThis(i18n("This command allows switching between the normal (line based) selection mode and the block selection mode."));
554  connect(a, SIGNAL(triggered(bool)), SLOT(toggleBlockSelection()));
555 
556  a = m_toggleInsert = new KToggleAction(i18n("Overwr&ite Mode"), this);
557  ac->addAction("set_insert", a);
558  a->setShortcut(QKeySequence(Qt::Key_Insert));
559  a->setWhatsThis(i18n("Choose whether you want the text you type to be inserted or to overwrite existing text."));
560  connect(a, SIGNAL(triggered(bool)), SLOT(toggleInsert()));
561 
562  KToggleAction *toggleAction;
563  a = m_toggleDynWrap = toggleAction = new KToggleAction(i18n("&Dynamic Word Wrap"), this);
564  ac->addAction("view_dynamic_word_wrap", a);
565  a->setShortcut(QKeySequence(Qt::Key_F10));
566  a->setWhatsThis(i18n("If this option is checked, the text lines will be wrapped at the view border on the screen."));
567  connect(a, SIGNAL(triggered(bool)), SLOT(toggleDynWordWrap()));
568 
569  a = m_setDynWrapIndicators = new KSelectAction(i18n("Dynamic Word Wrap Indicators"), this);
570  ac->addAction("dynamic_word_wrap_indicators", a);
571  a->setWhatsThis(i18n("Choose when the Dynamic Word Wrap Indicators should be displayed"));
572 
573  connect(m_setDynWrapIndicators, SIGNAL(triggered(int)), this, SLOT(setDynWrapIndicators(int)));
574  QStringList list2;
575  list2.append(i18n("&Off"));
576  list2.append(i18n("Follow &Line Numbers"));
577  list2.append(i18n("&Always On"));
578  m_setDynWrapIndicators->setItems(list2);
579  m_setDynWrapIndicators->setEnabled(m_toggleDynWrap->isChecked()); // only synced on real change, later
580 
581  a = toggleAction = m_toggleFoldingMarkers = new KToggleAction(i18n("Show Folding &Markers"), this);
582  ac->addAction("view_folding_markers", a);
583  a->setShortcut(QKeySequence(Qt::Key_F9));
584  a->setWhatsThis(i18n("You can choose if the codefolding marks should be shown, if codefolding is possible."));
585  connect(a, SIGNAL(triggered(bool)), SLOT(toggleFoldingMarkers()));
586 
587  a = m_toggleIconBar = toggleAction = new KToggleAction(i18n("Show &Icon Border"), this);
588  ac->addAction("view_border", a);
589  a->setShortcut(QKeySequence(Qt::Key_F6));
590  a->setWhatsThis(i18n("Show/hide the icon border.<br /><br />The icon border shows bookmark symbols, for instance."));
591  connect(a, SIGNAL(triggered(bool)), SLOT(toggleIconBorder()));
592 
593  a = toggleAction = m_toggleLineNumbers = new KToggleAction(i18n("Show &Line Numbers"), this);
594  ac->addAction("view_line_numbers", a);
595  a->setShortcut(QKeySequence(Qt::Key_F11));
596  a->setWhatsThis(i18n("Show/hide the line numbers on the left hand side of the view."));
597  connect(a, SIGNAL(triggered(bool)), SLOT(toggleLineNumbersOn()));
598 
599  a = m_toggleScrollBarMarks = toggleAction = new KToggleAction(i18n("Show Scroll&bar Marks"), this);
600  ac->addAction("view_scrollbar_marks", a);
601  a->setWhatsThis(i18n("Show/hide the marks on the vertical scrollbar.<br /><br />The marks show bookmarks, for instance."));
602  connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMarks()));
603 
604  a = m_toggleScrollBarMiniMap = toggleAction = new KToggleAction(i18n("Show Scrollbar Mini-Map"), this);
605  ac->addAction("view_scrollbar_minimap", a);
606  a->setWhatsThis(i18n("Show/hide the mini-map on the vertical scrollbar.<br /><br />The mini-map shows an overview of the whole document."));
607  connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMiniMap()));
608 
609 // a = m_toggleScrollBarMiniMapAll = toggleAction = new KToggleAction(i18n("Show the whole document in the Mini-Map"), this);
610 // ac->addAction("view_scrollbar_minimap_all", a);
611 // a->setWhatsThis(i18n("Display the whole document in the mini-map.<br /><br />With this option set the whole document will be visible in the mini-map."));
612 // connect(a, SIGNAL(triggered(bool)), SLOT(toggleScrollBarMiniMapAll()));
613 // connect(m_toggleScrollBarMiniMap, SIGNAL(triggered(bool)), m_toggleScrollBarMiniMapAll, SLOT(setEnabled(bool)));
614 
615  a = toggleAction = m_toggleWWMarker = new KToggleAction(i18n("Show Static &Word Wrap Marker"), this);
616  ac->addAction("view_word_wrap_marker", a);
617  a->setWhatsThis( i18n(
618  "Show/hide the Word Wrap Marker, a vertical line drawn at the word "
619  "wrap column as defined in the editing properties" ));
620  connect(a, SIGNAL(triggered(bool)), SLOT(toggleWWMarker()));
621 
622  a = m_switchCmdLine = ac->addAction("switch_to_cmd_line");
623  a->setText(i18n("Switch to Command Line"));
624  a->setShortcut(QKeySequence(Qt::Key_F7));
625  a->setWhatsThis(i18n("Show/hide the command line on the bottom of the view."));
626  connect(a, SIGNAL(triggered(bool)), SLOT(switchToCmdLine()));
627 
628  a = m_viInputModeAction = new KToggleAction(i18n("&VI Input Mode"), this);
629  ac->addAction("view_vi_input_mode", a);
630  a->setShortcut(QKeySequence(Qt::CTRL + Qt::META + Qt::Key_V));
631  a->setWhatsThis( i18n("Activate/deactivate VI input mode" ));
632  connect(a, SIGNAL(triggered(bool)), SLOT(toggleViInputMode()));
633 
634  a = m_setEndOfLine = new KSelectAction(i18n("&End of Line"), this);
635  ac->addAction("set_eol", a);
636  a->setWhatsThis(i18n("Choose which line endings should be used, when you save the document"));
637  QStringList list;
638  list.append(i18nc("@item:inmenu End of Line", "&UNIX"));
639  list.append(i18nc("@item:inmenu End of Line", "&Windows/DOS"));
640  list.append(i18nc("@item:inmenu End of Line", "&Macintosh"));
641  m_setEndOfLine->setItems(list);
642  m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
643  connect(m_setEndOfLine, SIGNAL(triggered(int)), this, SLOT(setEol(int)));
644 
645  a=m_addBom=new KToggleAction(i18n("Add &Byte Order Mark (BOM)"),this);
646  m_addBom->setChecked(m_doc->config()->bom());
647  ac->addAction("add_bom",a);
648  a->setWhatsThis(i18n("Enable/disable adding of byte order markers for UTF-8/UTF-16 encoded files while saving"));
649  connect(m_addBom,SIGNAL(triggered(bool)),this,SLOT(setAddBom(bool)));
650  // encoding menu
651  KateViewEncodingAction *encodingAction = new KateViewEncodingAction(m_doc, this, i18n("E&ncoding"), this);
652  ac->addAction("set_encoding", encodingAction);
653 
654  a = ac->addAction( KStandardAction::Find, this, SLOT(find()) );
655  a->setWhatsThis(i18n("Look up the first occurrence of a piece of text or regular expression."));
656  addAction(a);
657 
658  a = ac->addAction("edit_find_selected");
659  a->setText(i18n("Find Selected"));
660  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H));
661  a->setWhatsThis(i18n("Finds next occurrence of selected text."));
662  connect(a, SIGNAL(triggered(bool)), SLOT(findSelectedForwards()));
663 
664  a = ac->addAction("edit_find_selected_backwards");
665  a->setText(i18n("Find Selected Backwards"));
666  a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_H));
667  a->setWhatsThis(i18n("Finds previous occurrence of selected text."));
668  connect(a, SIGNAL(triggered(bool)), SLOT(findSelectedBackwards()));
669 
670  a = ac->addAction( KStandardAction::FindNext, this, SLOT(findNext()) );
671  a->setWhatsThis(i18n("Look up the next occurrence of the search phrase."));
672  addAction(a);
673 
674  a = ac->addAction( KStandardAction::FindPrev, "edit_find_prev", this, SLOT(findPrevious()) );
675  a->setWhatsThis(i18n("Look up the previous occurrence of the search phrase."));
676  addAction(a);
677 
678  a = ac->addAction( KStandardAction::Replace, this, SLOT(replace()) );
679  a->setWhatsThis(i18n("Look up a piece of text or regular expression and replace the result with some given text."));
680 
681  m_spell->createActions( ac );
682  m_toggleOnTheFlySpellCheck = new KToggleAction(i18n("Automatic Spell Checking"), this);
683  m_toggleOnTheFlySpellCheck->setWhatsThis(i18n("Enable/disable automatic spell checking"));
684  m_toggleOnTheFlySpellCheck->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
685  connect(m_toggleOnTheFlySpellCheck, SIGNAL(triggered(bool)), SLOT(toggleOnTheFlySpellCheck(bool)));
686  ac->addAction("tools_toggle_automatic_spell_checking", m_toggleOnTheFlySpellCheck);
687 
688  a = ac->addAction("tools_change_dictionary");
689  a->setText(i18n("Change Dictionary..."));
690  a->setWhatsThis(i18n("Change the dictionary that is used for spell checking."));
691  connect(a, SIGNAL(triggered()), SLOT(changeDictionary()));
692 
693  a = ac->addAction("tools_clear_dictionary_ranges");
694  a->setText(i18n("Clear Dictionary Ranges"));
695  a->setVisible(false);
696  a->setWhatsThis(i18n("Remove all the separate dictionary ranges that were set for spell checking."));
697  connect(a, SIGNAL(triggered()), m_doc, SLOT(clearDictionaryRanges()));
698  connect(m_doc, SIGNAL(dictionaryRangesPresent(bool)), a, SLOT(setVisible(bool)));
699 
700  m_spellingMenu->createActions( ac );
701 
702  if (!m_doc->simpleMode ())
703  m_bookmarks->createActions( ac );
704 
705  slotSelectionChanged ();
706 
707  //Now setup the editing actions before adding the associated
708  //widget and setting the shortcut context
709  setupEditActions();
710  setupCodeFolding();
711  slotClipboardHistoryChanged ();
712 
713  ac->addAssociatedWidget(m_viewInternal);
714 
715  foreach (QAction* action, ac->actions())
716  action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
717 
718  connect (this, SIGNAL(selectionChanged(KTextEditor::View*)), this, SLOT(slotSelectionChanged()));
719 }
720 
721 void KateView::createSnippet ()
722 {
723  KateGlobal::self()->snippetGlobal()->createSnippet (this);
724 }
725 
726 void KateView::showSnippetsDialog ()
727 {
728  KateGlobal::self()->snippetGlobal()->showDialog (this);
729 }
730 
731 void KateView::slotConfigDialog ()
732 {
733  KateGlobal::self ()->configDialog (this);
734 
735  // write config to global settings, else simple programs don't get config saved ever
736  // like Konqueror, Dolphin, ...
737  KateGlobal::self ()->writeConfig (KGlobal::config().data());
738 }
739 
740 void KateView::setupEditActions()
741 {
742  //If you add an editing action to this
743  //function make sure to include the line
744  //m_editActions << a after creating the action
745  KActionCollection* ac = actionCollection();
746 
747  KAction* a = ac->addAction("word_left");
748  a->setText(i18n("Move Word Left"));
749  a->setShortcuts(KStandardShortcut::backwardWord());
750  connect(a, SIGNAL(triggered(bool)), SLOT(wordLeft()));
751  m_editActions << a;
752 
753  a = ac->addAction("select_char_left");
754  a->setText(i18n("Select Character Left"));
755  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Left));
756  connect(a, SIGNAL(triggered(bool)), SLOT(shiftCursorLeft()));
757  m_editActions << a;
758 
759  a = ac->addAction("select_word_left");
760  a->setText(i18n("Select Word Left"));
761  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_Left));
762  connect(a, SIGNAL(triggered(bool)), SLOT(shiftWordLeft()));
763  m_editActions << a;
764 
765  a = ac->addAction("word_right");
766  a->setText(i18n("Move Word Right"));
767  a->setShortcuts(KStandardShortcut::forwardWord());
768  connect(a, SIGNAL(triggered(bool)), SLOT(wordRight()));
769  m_editActions << a;
770 
771  a = ac->addAction("select_char_right");
772  a->setText(i18n("Select Character Right"));
773  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Right));
774  connect(a, SIGNAL(triggered(bool)), SLOT(shiftCursorRight()));
775  m_editActions << a;
776 
777  a = ac->addAction("select_word_right");
778  a->setText(i18n("Select Word Right"));
779  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_Right));
780  connect(a, SIGNAL(triggered(bool)), SLOT(shiftWordRight()));
781  m_editActions << a;
782 
783  a = ac->addAction("beginning_of_line");
784  a->setText(i18n("Move to Beginning of Line"));
785  a->setShortcuts(KStandardShortcut::beginningOfLine());
786  connect(a, SIGNAL(triggered(bool)), SLOT(home()));
787  m_editActions << a;
788 
789  a = ac->addAction("beginning_of_document");
790  a->setText(i18n("Move to Beginning of Document"));
791  a->setShortcuts(KStandardShortcut::begin());
792  connect(a, SIGNAL(triggered(bool)), SLOT(top()));
793  m_editActions << a;
794 
795  a = ac->addAction("select_beginning_of_line");
796  a->setText(i18n("Select to Beginning of Line"));
797  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Home));
798  connect(a, SIGNAL(triggered(bool)), SLOT(shiftHome()));
799  m_editActions << a;
800 
801  a = ac->addAction("select_beginning_of_document");
802  a->setText(i18n("Select to Beginning of Document"));
803  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_Home));
804  connect(a, SIGNAL(triggered(bool)), SLOT(shiftTop()));
805  m_editActions << a;
806 
807 
808  a = ac->addAction("end_of_line");
809  a->setText(i18n("Move to End of Line"));
810  a->setShortcuts(KStandardShortcut::endOfLine());
811  connect(a, SIGNAL(triggered(bool)), SLOT(end()));
812  m_editActions << a;
813 
814  a = ac->addAction("end_of_document");
815  a->setText(i18n("Move to End of Document"));
816  a->setShortcuts(KStandardShortcut::end());
817  connect(a, SIGNAL(triggered(bool)), SLOT(bottom()));
818  m_editActions << a;
819 
820  a = ac->addAction("select_end_of_line");
821  a->setText(i18n("Select to End of Line"));
822  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_End));
823  connect(a, SIGNAL(triggered(bool)), SLOT(shiftEnd()));
824  m_editActions << a;
825 
826  a = ac->addAction("select_end_of_document");
827  a->setText(i18n("Select to End of Document"));
828  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_End));
829  connect(a, SIGNAL(triggered(bool)), SLOT(shiftBottom()));
830  m_editActions << a;
831 
832 
833  a = ac->addAction("select_line_up");
834  a->setText(i18n("Select to Previous Line"));
835  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Up));
836  connect(a, SIGNAL(triggered(bool)), SLOT(shiftUp()));
837  m_editActions << a;
838 
839  a = ac->addAction("scroll_line_up");
840  a->setText(i18n("Scroll Line Up"));
841  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
842  connect(a, SIGNAL(triggered(bool)), SLOT(scrollUp()));
843  m_editActions << a;
844 
845 
846  a = ac->addAction("move_line_down");
847  a->setText(i18n("Move to Next Line"));
848  a->setShortcut(QKeySequence(Qt::Key_Down));
849  connect(a, SIGNAL(triggered(bool)), SLOT(down()));
850  m_editActions << a;
851 
852 
853  a = ac->addAction("move_line_up");
854  a->setText(i18n("Move to Previous Line"));
855  a->setShortcut(QKeySequence(Qt::Key_Up));
856  connect(a, SIGNAL(triggered(bool)), SLOT(up()));
857  m_editActions << a;
858 
859 
860  a = ac->addAction("move_cursor_right");
861  a->setText(i18n("Move Cursor Right"));
862  a->setShortcut(QKeySequence(Qt::Key_Right));
863  connect(a, SIGNAL(triggered(bool)), SLOT(cursorRight()));
864  m_editActions << a;
865 
866 
867  a = ac->addAction("move_cusor_left");
868  a->setText(i18n("Move Cursor Left"));
869  a->setShortcut(QKeySequence(Qt::Key_Left));
870  connect(a, SIGNAL(triggered(bool)), SLOT(cursorLeft()));
871  m_editActions << a;
872 
873 
874  a = ac->addAction("select_line_down");
875  a->setText(i18n("Select to Next Line"));
876  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Down));
877  connect(a, SIGNAL(triggered(bool)), SLOT(shiftDown()));
878  m_editActions << a;
879 
880  a = ac->addAction("scroll_line_down");
881  a->setText(i18n("Scroll Line Down"));
882  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
883  connect(a, SIGNAL(triggered(bool)), SLOT(scrollDown()));
884  m_editActions << a;
885 
886 
887  a = ac->addAction("scroll_page_up");
888  a->setText(i18n("Scroll Page Up"));
889  a->setShortcuts(KStandardShortcut::prior());
890  connect(a, SIGNAL(triggered(bool)), SLOT(pageUp()));
891  m_editActions << a;
892 
893  a = ac->addAction("select_page_up");
894  a->setText(i18n("Select Page Up"));
895  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_PageUp));
896  connect(a, SIGNAL(triggered(bool)), SLOT(shiftPageUp()));
897  m_editActions << a;
898 
899  a = ac->addAction("move_top_of_view");
900  a->setText(i18n("Move to Top of View"));
901  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp));
902  connect(a, SIGNAL(triggered(bool)), SLOT(topOfView()));
903  m_editActions << a;
904 
905  a = ac->addAction("select_top_of_view");
906  a->setText(i18n("Select to Top of View"));
907  a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_PageUp));
908  connect(a, SIGNAL(triggered(bool)), SLOT(shiftTopOfView()));
909  m_editActions << a;
910 
911 
912  a = ac->addAction("scroll_page_down");
913  a->setText(i18n("Scroll Page Down"));
914  a->setShortcuts(KStandardShortcut::next());
915  connect(a, SIGNAL(triggered(bool)), SLOT(pageDown()));
916  m_editActions << a;
917 
918  a = ac->addAction("select_page_down");
919  a->setText(i18n("Select Page Down"));
920  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_PageDown));
921  connect(a, SIGNAL(triggered(bool)), SLOT(shiftPageDown()));
922  m_editActions << a;
923 
924  a = ac->addAction("move_bottom_of_view");
925  a->setText(i18n("Move to Bottom of View"));
926  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown));
927  connect(a, SIGNAL(triggered(bool)), SLOT(bottomOfView()));
928  m_editActions << a;
929 
930  a = ac->addAction("select_bottom_of_view");
931  a->setText(i18n("Select to Bottom of View"));
932  a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_PageDown));
933  connect(a, SIGNAL(triggered(bool)), SLOT(shiftBottomOfView()));
934  m_editActions << a;
935 
936  a = ac->addAction("to_matching_bracket");
937  a->setText(i18n("Move to Matching Bracket"));
938  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_6));
939  connect(a, SIGNAL(triggered(bool)), SLOT(toMatchingBracket()));
940  m_editActions << a;
941 
942  a = ac->addAction("select_matching_bracket");
943  a->setText(i18n("Select to Matching Bracket"));
944  a->setShortcut(QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_6));
945  connect(a, SIGNAL(triggered(bool)), SLOT(shiftToMatchingBracket()));
946  m_editActions << a;
947 
948 
949  // anders: shortcuts doing any changes should not be created in browserextension
950  if ( !m_doc->readOnly() )
951  {
952  a = ac->addAction("transpose_char");
953  a->setText(i18n("Transpose Characters"));
954  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
955  connect(a, SIGNAL(triggered(bool)), SLOT(transpose()));
956  m_editActions << a;
957 
958  a = ac->addAction("delete_line");
959  a->setText(i18n("Delete Line"));
960  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
961  connect(a, SIGNAL(triggered(bool)), SLOT(killLine()));
962  m_editActions << a;
963 
964  a = ac->addAction("delete_word_left");
965  a->setText(i18n("Delete Word Left"));
966  a->setShortcuts(KStandardShortcut::deleteWordBack());
967  connect(a, SIGNAL(triggered(bool)), SLOT(deleteWordLeft()));
968  m_editActions << a;
969 
970  a = ac->addAction("delete_word_right");
971  a->setText(i18n("Delete Word Right"));
972  a->setShortcuts(KStandardShortcut::deleteWordForward());
973  connect(a, SIGNAL(triggered(bool)), SLOT(deleteWordRight()));
974  m_editActions << a;
975 
976  a = ac->addAction("delete_next_character");
977  a->setText(i18n("Delete Next Character"));
978  a->setShortcut(QKeySequence(Qt::Key_Delete));
979  connect(a, SIGNAL(triggered(bool)), SLOT(keyDelete()));
980  m_editActions << a;
981 
982  a = ac->addAction("backspace");
983  a->setText(i18n("Backspace"));
984  QList<QKeySequence> scuts;
985  scuts << QKeySequence(Qt::Key_Backspace)
986  << QKeySequence(Qt::SHIFT + Qt::Key_Backspace);
987  a->setShortcuts(scuts);
988  connect(a, SIGNAL(triggered(bool)), SLOT(backspace()));
989  m_editActions << a;
990 
991  a = ac->addAction("insert_tabulator");
992  a->setText(i18n("Insert Tab"));
993  connect(a, SIGNAL(triggered(bool)), SLOT(insertTab()));
994  m_editActions << a;
995 
996  a = ac->addAction("smart_newline");
997  a->setText(i18n("Insert Smart Newline"));
998  a->setWhatsThis(i18n("Insert newline including leading characters of the current line which are not letters or numbers."));
999  scuts.clear();
1000  scuts << QKeySequence(Qt::SHIFT + Qt::Key_Return)
1001  << QKeySequence(Qt::SHIFT + Qt::Key_Enter);
1002  a->setShortcuts(scuts);
1003  connect(a, SIGNAL(triggered(bool)), SLOT(smartNewline()));
1004  m_editActions << a;
1005 
1006  a = ac->addAction("tools_indent");
1007  a->setIcon(KIcon("format-indent-more"));
1008  a->setText(i18n("&Indent"));
1009  a->setWhatsThis(i18n("Use this to indent a selected block of text.<br /><br />"
1010  "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
1011  a->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_I));
1012  connect(a, SIGNAL(triggered(bool)), SLOT(indent()));
1013 
1014  a = ac->addAction("tools_unindent");
1015  a->setIcon(KIcon("format-indent-less"));
1016  a->setText(i18n("&Unindent"));
1017  a->setWhatsThis(i18n("Use this to unindent a selected block of text."));
1018  a->setShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_I));
1019  connect(a, SIGNAL(triggered(bool)), SLOT(unIndent()));
1020  }
1021 
1022  if( hasFocus() )
1023  slotGotFocus();
1024  else
1025  slotLostFocus();
1026 }
1027 
1028 void KateView::setupCodeFolding()
1029 {
1030  //FIXME: FOLDING
1031  KActionCollection *ac=this->actionCollection();
1032 
1033  KAction* a;
1034 
1035  a = ac->addAction("folding_toplevel");
1036  a->setText(i18n("Fold Toplevel Nodes"));
1037  a->setShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_Minus));
1038  connect(a, SIGNAL(triggered(bool)), SLOT(slotFoldToplevelNodes()));
1039 
1040  /*a = ac->addAction("folding_expandtoplevel");
1041  a->setText(i18n("Unfold Toplevel Nodes"));
1042  a->setShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_Plus));
1043  connect(a, SIGNAL(triggered(bool)), m_doc->foldingTree(), SLOT(expandToplevelNodes()));
1044 
1045  a = ac->addAction("folding_expandall");
1046  a->setText(i18n("Unfold All Nodes"));
1047  connect(a, SIGNAL(triggered(bool)), m_doc->foldingTree(), SLOT(expandAll()));
1048 
1049  a = ac->addAction("folding_collapse_dsComment");
1050  a->setText(i18n("Fold Multiline Comments"));
1051  connect(a, SIGNAL(triggered(bool)), m_doc->foldingTree(), SLOT(collapseAll_dsComments()));
1052 */
1053  a = ac->addAction("folding_collapselocal");
1054  a->setText(i18n("Fold Current Node"));
1055  connect(a, SIGNAL(triggered(bool)), SLOT(slotCollapseLocal()));
1056 
1057  a = ac->addAction("folding_expandlocal");
1058  a->setText(i18n("Unfold Current Node"));
1059  connect(a, SIGNAL(triggered(bool)), SLOT(slotExpandLocal()));
1060 }
1061 
1062 void KateView::slotFoldToplevelNodes()
1063 {
1064  // FIXME: more performant implementation
1065  for (int line = 0; line < doc()->lines(); ++line) {
1066  if (textFolding().isLineVisible(line)) {
1067  foldLine(line);
1068  }
1069  }
1070 }
1071 
1072 void KateView::slotCollapseLocal()
1073 {
1074  foldLine (cursorPosition().line());
1075 }
1076 
1077 void KateView::slotExpandLocal()
1078 {
1079  unfoldLine (cursorPosition().line());
1080 }
1081 
1082 void KateView::slotCollapseLevel()
1083 {
1084  //FIXME: FOLDING
1085 #if 0
1086  if (!sender()) return;
1087  QAction *action = qobject_cast<QAction*>(sender());
1088  if (!action) return;
1089 
1090  const int level = action->data().toInt();
1091  Q_ASSERT(level > 0);
1092  m_doc->foldingTree()->collapseLevel(level);
1093 #endif
1094 }
1095 
1096 void KateView::slotExpandLevel()
1097 {
1098  //FIXME: FOLDING
1099 #if 0
1100  if (!sender()) return;
1101  QAction *action = qobject_cast<QAction*>(sender());
1102  if (!action) return;
1103 
1104  const int level = action->data().toInt();
1105  Q_ASSERT(level > 0);
1106  m_doc->foldingTree()->expandLevel(level);
1107 #endif
1108 }
1109 
1110 void KateView::foldLine (int startLine)
1111 {
1112  // only for valid lines
1113  if (startLine < 0)
1114  return;
1115 
1116  // try to fold all known ranges
1117  QVector<QPair<qint64, Kate::TextFolding::FoldingRangeFlags> > startingRanges = textFolding().foldingRangesStartingOnLine (startLine);
1118  for (int i = 0; i < startingRanges.size(); ++i)
1119  textFolding().foldRange (startingRanges[i].first);
1120 
1121  // try if the highlighting can help us and create a fold
1122  textFolding().newFoldingRange (doc()->buffer().computeFoldingRangeForStartLine (startLine), Kate::TextFolding::Folded);
1123 }
1124 
1125 void KateView::unfoldLine (int startLine)
1126 {
1127  // only for valid lines
1128  if (startLine < 0)
1129  return;
1130 
1131  // try to unfold all known ranges
1132  QVector<QPair<qint64, Kate::TextFolding::FoldingRangeFlags> > startingRanges = textFolding().foldingRangesStartingOnLine (startLine);
1133  for (int i = 0; i < startingRanges.size(); ++i)
1134  textFolding().unfoldRange (startingRanges[i].first);
1135 }
1136 
1137 KTextEditor::View::EditMode KateView::viewEditMode() const
1138 {
1139  if (viInputMode())
1140  return EditViMode;
1141 
1142  return isOverwriteMode() ? EditOverwrite : EditInsert;
1143 }
1144 
1145 QString KateView::viewMode () const
1146 {
1150  QString currentMode = isOverwriteMode() ? i18n("OVR") : i18n ("INS");
1151 
1155  if (viInputMode()) {
1156  currentMode = KateViInputModeManager::modeToString (getCurrentViMode());
1157 
1158  if (m_viewInternal->getViInputModeManager()->isRecordingMacro())
1159  {
1160  currentMode += " (" + i18n("recording") + ") ";
1161  }
1162 
1166  QString cmd = m_viewInternal->getViInputModeManager()->getVerbatimKeys();
1167  if (!cmd.isEmpty())
1168  currentMode.append (QString (" <em>%1</em>").arg (cmd));
1169 
1173  currentMode = QString ("<b>%1</b>").arg (currentMode);
1174  }
1175 
1179  if (!m_doc->isReadWrite())
1180  currentMode = i18n ("%1 (R/O)", currentMode);
1181 
1185  return currentMode;
1186 }
1187 
1188 void KateView::slotGotFocus()
1189 {
1190  //kDebug(13020) << "KateView::slotGotFocus";
1191 
1192  if ( !viInputMode() ) {
1193  activateEditActions();
1194  }
1195  emit focusIn ( this );
1196 }
1197 
1198 void KateView::slotLostFocus()
1199 {
1200  //kDebug(13020) << "KateView::slotLostFocus";
1201 
1202  if ( !viInputMode() ) {
1203  deactivateEditActions();
1204  }
1205 
1206  emit focusOut ( this );
1207 }
1208 
1209 void KateView::setDynWrapIndicators(int mode)
1210 {
1211  config()->setDynWordWrapIndicators (mode);
1212 }
1213 
1214 bool KateView::isOverwriteMode() const
1215 {
1216  return m_doc->config()->ovr();
1217 }
1218 
1219 void KateView::reloadFile()
1220 {
1221  // bookmarks and cursor positions are temporarily saved by the document
1222  m_doc->documentReload();
1223 }
1224 
1225 void KateView::slotReadWriteChanged ()
1226 {
1227  if ( m_toggleWriteLock )
1228  m_toggleWriteLock->setChecked( ! m_doc->isReadWrite() );
1229 
1230  m_cut->setEnabled (m_doc->isReadWrite() && (selection() || m_config->smartCopyCut()));
1231  m_paste->setEnabled (m_doc->isReadWrite());
1232  m_pasteMenu->setEnabled (m_doc->isReadWrite() && !KateGlobal::self()->clipboardHistory().isEmpty());
1233  m_setEndOfLine->setEnabled (m_doc->isReadWrite());
1234 
1235  QStringList l;
1236 
1237  l << "edit_replace" << "tools_spelling" << "tools_indent"
1238  << "tools_unindent" << "tools_cleanIndent" << "tools_align" << "tools_comment"
1239  << "tools_uncomment" << "tools_toggle_comment" << "tools_uppercase" << "tools_lowercase"
1240  << "tools_capitalize" << "tools_join_lines" << "tools_apply_wordwrap"
1241  << "tools_spelling_from_cursor"
1242  << "tools_spelling_selection" << "tools_create_snippet";
1243 
1244  QAction *a = 0;
1245  for (int z = 0; z < l.size(); z++)
1246  if ((a = actionCollection()->action( l[z].toAscii().constData() )))
1247  a->setEnabled (m_doc->isReadWrite());
1248  slotUpdateUndo();
1249 
1250  // inform search bar
1251  if (m_searchBar)
1252  m_searchBar->slotReadWriteChanged ();
1253 
1254  // => view mode changed
1255  emit viewModeChanged(this);
1256  emit viewEditModeChanged(this,viewEditMode());
1257 }
1258 
1259 void KateView::slotClipboardHistoryChanged ()
1260 {
1261  m_pasteMenu->setEnabled (m_doc->isReadWrite() && !KateGlobal::self()->clipboardHistory().isEmpty());
1262 }
1263 
1264 void KateView::slotUpdateUndo()
1265 {
1266  if (m_doc->readOnly())
1267  return;
1268 
1269  m_editUndo->setEnabled(m_doc->isReadWrite() && m_doc->undoCount() > 0);
1270  m_editRedo->setEnabled(m_doc->isReadWrite() && m_doc->redoCount() > 0);
1271 }
1272 
1273 void KateView::slotDropEventPass( QDropEvent * ev )
1274 {
1275  const KUrl::List lstDragURLs=KUrl::List::fromMimeData(ev->mimeData());
1276  bool ok = !lstDragURLs.isEmpty();
1277 
1278  KParts::BrowserExtension * ext = KParts::BrowserExtension::childObject( doc() );
1279  if ( ok && ext )
1280  emit ext->openUrlRequest( lstDragURLs.first() );
1281 }
1282 
1283 void KateView::contextMenuEvent( QContextMenuEvent *ev )
1284 {
1285  if ( !m_doc || !m_doc->browserExtension() )
1286  return;
1287  KParts::OpenUrlArguments args;
1288  args.setMimeType( QLatin1String("text/plain") );
1289  emit m_doc->browserExtension()->popupMenu( ev->globalPos(), m_doc->url(), S_IFREG, args );
1290  ev->accept();
1291 }
1292 
1293 bool KateView::setCursorPositionInternal( const KTextEditor::Cursor& position, uint tabwidth, bool calledExternally )
1294 {
1295  Kate::TextLine l = m_doc->kateTextLine( position.line() );
1296 
1297  if (!l)
1298  return false;
1299 
1300  QString line_str = m_doc->line( position.line() );
1301 
1302  int x = 0;
1303  int z = 0;
1304  for (; z < line_str.length() && z < position.column(); z++) {
1305  if (line_str[z] == QChar('\t')) x += tabwidth - (x % tabwidth); else x++;
1306  }
1307 
1308  if (blockSelection())
1309  if (z < position.column())
1310  x += position.column() - z;
1311 
1312  m_viewInternal->updateCursor( KTextEditor::Cursor(position.line(), x), false, true, calledExternally );
1313 
1314  return true;
1315 }
1316 
1317 void KateView::toggleInsert()
1318 {
1319  m_doc->config()->setOvr(!m_doc->config()->ovr());
1320  m_toggleInsert->setChecked (isOverwriteMode ());
1321 
1322  emit viewModeChanged(this);
1323  emit viewEditModeChanged(this,viewEditMode());
1324 }
1325 
1326 void KateView::slotSaveCanceled( const QString& error )
1327 {
1328  if ( !error.isEmpty() ) // happens when canceling a job
1329  KMessageBox::error( this, error );
1330 }
1331 
1332 void KateView::gotoLine()
1333 {
1334  gotoBar()->updateData();
1335  bottomViewBar()->showBarWidget(gotoBar());
1336 }
1337 
1338 void KateView::changeDictionary()
1339 {
1340  dictionaryBar()->updateData();
1341  bottomViewBar()->showBarWidget(dictionaryBar());
1342 }
1343 
1344 void KateView::joinLines()
1345 {
1346  int first = selectionRange().start().line();
1347  int last = selectionRange().end().line();
1348  //int left = m_doc->line( last ).length() - m_doc->selEndCol();
1349  if ( first == last )
1350  {
1351  first = cursorPosition().line();
1352  last = first + 1;
1353  }
1354  m_doc->joinLines( first, last );
1355 }
1356 
1357 void KateView::readSessionConfig(const KConfigGroup& config)
1358 {
1359  // cursor position
1360  setCursorPositionInternal(KTextEditor::Cursor(config.readEntry("CursorLine",0), config.readEntry("CursorColumn",0)));
1361 
1362  // TODO: text folding state
1363 // m_savedFoldingState = config.readEntry("TextFolding", QVariantList());
1364 // applyFoldingState ();
1365 
1366  // save vi registers and jump list
1367  getViInputModeManager()->readSessionConfig( config );
1368 }
1369 
1370 void KateView::writeSessionConfig(KConfigGroup& config)
1371 {
1372  // cursor position
1373  config.writeEntry("CursorLine",m_viewInternal->m_cursor.line());
1374  config.writeEntry("CursorColumn",m_viewInternal->m_cursor.column());
1375 
1376  // TODO: text folding state
1377 // saveFoldingState();
1378 // config.writeEntry("TextFolding", m_savedFoldingState);
1379 // m_savedFoldingState.clear ();
1380 
1381  // save vi registers and jump list
1382  getViInputModeManager()->writeSessionConfig( config );
1383 }
1384 
1385 int KateView::getEol() const
1386 {
1387  return m_doc->config()->eol();
1388 }
1389 
1390 void KateView::setEol(int eol)
1391 {
1392  if (!doc()->isReadWrite())
1393  return;
1394 
1395  if (m_updatingDocumentConfig)
1396  return;
1397 
1398  if (eol != m_doc->config()->eol()) {
1399  m_doc->setModified(true); // mark modified (bug #143120)
1400  m_doc->config()->setEol (eol);
1401  }
1402 }
1403 
1404 void KateView::setAddBom(bool enabled)
1405 {
1406  if (!doc()->isReadWrite())
1407  return;
1408 
1409  if (m_updatingDocumentConfig)
1410  return;
1411 
1412  m_doc->config()->setBom (enabled);
1413  m_doc->bomSetByUser();
1414 }
1415 
1416 void KateView::setIconBorder( bool enable )
1417 {
1418  config()->setIconBar (enable);
1419 }
1420 
1421 void KateView::toggleIconBorder()
1422 {
1423  config()->setIconBar (!config()->iconBar());
1424 }
1425 
1426 void KateView::setLineNumbersOn( bool enable )
1427 {
1428  config()->setLineNumbers (enable);
1429 }
1430 
1431 void KateView::toggleLineNumbersOn()
1432 {
1433  config()->setLineNumbers (!config()->lineNumbers());
1434 }
1435 
1436 void KateView::setScrollBarMarks( bool enable )
1437 {
1438  config()->setScrollBarMarks (enable);
1439 }
1440 
1441 void KateView::toggleScrollBarMarks()
1442 {
1443  config()->setScrollBarMarks (!config()->scrollBarMarks());
1444 }
1445 
1446 void KateView::setScrollBarMiniMap( bool enable )
1447 {
1448  config()->setScrollBarMiniMap (enable);
1449 }
1450 
1451 void KateView::toggleScrollBarMiniMap()
1452 {
1453  config()->setScrollBarMiniMap (!config()->scrollBarMiniMap());
1454 }
1455 
1456 void KateView::setScrollBarMiniMapAll( bool enable )
1457 {
1458  config()->setScrollBarMiniMapAll (enable);
1459 }
1460 
1461 void KateView::toggleScrollBarMiniMapAll()
1462 {
1463  config()->setScrollBarMiniMapAll (!config()->scrollBarMiniMapAll());
1464 }
1465 
1466 void KateView::setScrollBarMiniMapWidth( int width )
1467 {
1468  config()->setScrollBarMiniMapWidth (width);
1469 }
1470 
1471 void KateView::toggleDynWordWrap()
1472 {
1473  config()->setDynWordWrap( !config()->dynWordWrap() );
1474 }
1475 
1476 void KateView::toggleWWMarker()
1477 {
1478  m_renderer->config()->setWordWrapMarker (!m_renderer->config()->wordWrapMarker());
1479 }
1480 
1481 void KateView::setFoldingMarkersOn( bool enable )
1482 {
1483  config()->setFoldingBar ( enable );
1484 }
1485 
1486 void KateView::toggleFoldingMarkers()
1487 {
1488  config()->setFoldingBar ( !config()->foldingBar() );
1489 }
1490 
1491 bool KateView::iconBorder() {
1492  return m_viewInternal->m_leftBorder->iconBorderOn();
1493 }
1494 
1495 bool KateView::lineNumbersOn() {
1496  return m_viewInternal->m_leftBorder->lineNumbersOn();
1497 }
1498 
1499 bool KateView::scrollBarMarks() {
1500  return m_viewInternal->m_lineScroll->showMarks();
1501 }
1502 
1503 bool KateView::scrollBarMiniMap() {
1504  return m_viewInternal->m_lineScroll->showMiniMap();
1505 }
1506 
1507 int KateView::dynWrapIndicators() {
1508  return m_viewInternal->m_leftBorder->dynWrapIndicators();
1509 }
1510 
1511 bool KateView::foldingMarkersOn() {
1512  return m_viewInternal->m_leftBorder->foldingMarkersOn();
1513 }
1514 
1515 void KateView::toggleWriteLock()
1516 {
1517  m_doc->setReadWrite( ! m_doc->isReadWrite() );
1518 }
1519 
1520 void KateView::enableTextHints(int timeout)
1521 {
1522  m_viewInternal->enableTextHints(timeout);
1523 }
1524 
1525 void KateView::disableTextHints()
1526 {
1527  m_viewInternal->disableTextHints();
1528 }
1529 
1530 bool KateView::viInputMode() const
1531 {
1532  return m_viewInternal->m_viInputMode;
1533 }
1534 
1535 bool KateView::viInputModeStealKeys() const
1536 {
1537  return m_viewInternal->m_viInputModeStealKeys;
1538 }
1539 
1540 bool KateView::viRelativeLineNumbers() const
1541 {
1542  return m_viewInternal->m_viRelLineNumbers;
1543 }
1544 
1545 void KateView::toggleViInputMode()
1546 {
1547  config()->setViInputMode (!config()->viInputMode());
1548 
1549  if ( viInputMode() ) {
1550  m_viewInternal->getViInputModeManager()->viEnterNormalMode();
1551  deactivateEditActions();
1552  } else { // disabling the vi input mode
1553  activateEditActions();
1554  }
1555 
1556  emit viewModeChanged(this);
1557  emit viewEditModeChanged(this,viewEditMode());
1558 }
1559 
1560 void KateView::showViModeEmulatedCommandBar()
1561 {
1562  if (viInputMode() && config()->viInputModeEmulateCommandBar()) {
1563  bottomViewBar()->addBarWidget(viModeEmulatedCommandBar());
1564  bottomViewBar()->showBarWidget(viModeEmulatedCommandBar());
1565  }
1566 }
1567 
1568 void KateView::updateViModeBarMode()
1569 {
1570  // view mode changed => status bar in container apps might change!
1571  emit viewModeChanged (this);
1572  emit viewEditModeChanged(this,viewEditMode());
1573 }
1574 
1575 void KateView::updateViModeBarCmd()
1576 {
1577  // view mode changed => status bar in container apps might change!
1578  emit viewModeChanged (this);
1579  emit viewEditModeChanged(this,viewEditMode());
1580 }
1581 
1582 ViMode KateView::getCurrentViMode() const
1583 {
1584  return m_viewInternal->getCurrentViMode();
1585 }
1586 
1587 KateViInputModeManager* KateView::getViInputModeManager()
1588 {
1589  return m_viewInternal->getViInputModeManager();
1590 }
1591 
1592 KateViInputModeManager* KateView::resetViInputModeManager()
1593 {
1594  return m_viewInternal->resetViInputModeManager();
1595 }
1596 
1597 void KateView::find()
1598 {
1599  const bool INIT_HINT_AS_INCREMENTAL = false;
1600  KateSearchBar * const bar = searchBar(INIT_HINT_AS_INCREMENTAL);
1601  bar->enterIncrementalMode();
1602  bottomViewBar()->addBarWidget(bar);
1603  bottomViewBar()->showBarWidget(bar);
1604  bar->setFocus();
1605 }
1606 
1607 void KateView::findSelectedForwards()
1608 {
1609  KateSearchBar::nextMatchForSelection(this, KateSearchBar::SearchForward);
1610 }
1611 
1612 void KateView::findSelectedBackwards()
1613 {
1614  KateSearchBar::nextMatchForSelection(this, KateSearchBar::SearchBackward);
1615 }
1616 
1617 void KateView::replace()
1618 {
1619  const bool INIT_HINT_AS_POWER = true;
1620  KateSearchBar * const bar = searchBar(INIT_HINT_AS_POWER);
1621  bar->enterPowerMode();
1622  bottomViewBar()->addBarWidget(bar);
1623  bottomViewBar()->showBarWidget(bar);
1624  bar->setFocus();
1625 }
1626 
1627 void KateView::findNext()
1628 {
1629  searchBar()->findNext();
1630 }
1631 
1632 void KateView::findPrevious()
1633 {
1634  searchBar()->findPrevious();
1635 }
1636 
1637 void KateView::slotSelectionChanged ()
1638 {
1639  m_copy->setEnabled (selection() || m_config->smartCopyCut());
1640  m_deSelect->setEnabled (selection());
1641 
1642  if (m_doc->readOnly())
1643  return;
1644 
1645  m_cut->setEnabled (selection() || m_config->smartCopyCut() );
1646 
1647  actionCollection()->action ("tools_create_snippet")->setEnabled (selection());
1648 
1649  m_spell->updateActions ();
1650 }
1651 
1652 void KateView::switchToCmdLine ()
1653 {
1654  // if the user has selected text, insert the selection's range (start line to end line) in the
1655  // command line when opened
1656  if (selectionRange().start().line() != -1 && selectionRange().end().line() != -1) {
1657  cmdLineBar()->setText(QString::number(selectionRange().start().line()+1)+','
1658  +QString::number(selectionRange().end().line()+1));
1659  }
1660  bottomViewBar()->showBarWidget(cmdLineBar());
1661  cmdLineBar()->setFocus ();
1662 }
1663 
1664 KateRenderer *KateView::renderer ()
1665 {
1666  return m_renderer;
1667 }
1668 
1669 void KateView::updateConfig ()
1670 {
1671  if (m_startingUp)
1672  return;
1673 
1674  // dyn. word wrap & markers
1675  if (m_hasWrap != config()->dynWordWrap()) {
1676  m_viewInternal->prepareForDynWrapChange();
1677 
1678  m_hasWrap = config()->dynWordWrap();
1679 
1680  m_viewInternal->dynWrapChanged();
1681 
1682  m_setDynWrapIndicators->setEnabled(config()->dynWordWrap());
1683  m_toggleDynWrap->setChecked( config()->dynWordWrap() );
1684  }
1685 
1686  m_viewInternal->m_leftBorder->setDynWrapIndicators( config()->dynWordWrapIndicators() );
1687  m_setDynWrapIndicators->setCurrentItem( config()->dynWordWrapIndicators() );
1688 
1689  // line numbers
1690  m_viewInternal->m_leftBorder->setLineNumbersOn( config()->lineNumbers() );
1691  m_toggleLineNumbers->setChecked( config()->lineNumbers() );
1692 
1693  // icon bar
1694  m_viewInternal->m_leftBorder->setIconBorderOn( config()->iconBar() );
1695  m_toggleIconBar->setChecked( config()->iconBar() );
1696 
1697  // scrollbar marks
1698  m_viewInternal->m_lineScroll->setShowMarks( config()->scrollBarMarks() );
1699  m_toggleScrollBarMarks->setChecked( config()->scrollBarMarks() );
1700 
1701  // scrollbar mini-map
1702  m_viewInternal->m_lineScroll->setShowMiniMap( config()->scrollBarMiniMap() );
1703  m_toggleScrollBarMiniMap->setChecked( config()->scrollBarMiniMap() );
1704 
1705  // scrollbar mini-map - (whole document)
1706  m_viewInternal->m_lineScroll->setMiniMapAll( config()->scrollBarMiniMapAll() );
1707  //m_toggleScrollBarMiniMapAll->setChecked( config()->scrollBarMiniMapAll() );
1708 
1709  // scrollbar mini-map.width
1710  m_viewInternal->m_lineScroll->setMiniMapWidth( config()->scrollBarMiniMapWidth() );
1711 
1712  // misc edit
1713  m_toggleBlockSelection->setChecked( blockSelection() );
1714  m_toggleInsert->setChecked( isOverwriteMode() );
1715 
1716  // vi modes
1717  m_viInputModeAction->setChecked( config()->viInputMode() );
1718 
1719  updateFoldingConfig ();
1720 
1721  // bookmark
1722  m_bookmarks->setSorting( (KateBookmarks::Sorting) config()->bookmarkSort() );
1723 
1724  m_viewInternal->setAutoCenterLines(config()->autoCenterLines ());
1725 
1726  // vi input mode
1727  m_viewInternal->m_viInputMode = config()->viInputMode();
1728 
1729  // whether vi input mode should override actions or not
1730  m_viewInternal->m_viInputModeStealKeys = config()->viInputModeStealKeys();
1731 
1732  // whether relative line numbers should be used or not.
1733  m_viewInternal->m_leftBorder->setViRelLineNumbersOn(config()->viRelativeLineNumbers());
1734 
1735  reflectOnTheFlySpellCheckStatus(m_doc->isOnTheFlySpellCheckingEnabled());
1736 
1737  // register/unregister word completion...
1738  unregisterCompletionModel (KateGlobal::self()->wordCompletionModel());
1739  unregisterCompletionModel (KateGlobal::self()->keywordCompletionModel());
1740  if (config()->wordCompletion ())
1741  registerCompletionModel (KateGlobal::self()->wordCompletionModel());
1742  if (config()->keywordCompletion ())
1743  registerCompletionModel (KateGlobal::self()->keywordCompletionModel());
1744 
1745  // add snippet completion, later with option
1746  unregisterCompletionModel (KateGlobal::self()->snippetGlobal()->completionModel());
1747  if (1)
1748  registerCompletionModel (KateGlobal::self()->snippetGlobal()->completionModel());
1749 
1750  m_cut->setEnabled(m_doc->isReadWrite() && (selection() || m_config->smartCopyCut()));
1751  m_copy->setEnabled(selection() || m_config->smartCopyCut());
1752 
1753  // now redraw...
1754  m_viewInternal->cache()->clear();
1755  tagAll ();
1756  updateView (true);
1757 
1758  if (hasCommentInFirstLine(m_doc)) {
1759  if (config()->foldFirstLine()) {
1760  foldLine(0);
1761  } else {
1762  unfoldLine(0);
1763  }
1764  }
1765 
1766  emit configChanged();
1767 }
1768 
1769 void KateView::updateDocumentConfig()
1770 {
1771  if (m_startingUp)
1772  return;
1773 
1774  m_updatingDocumentConfig = true;
1775 
1776  m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
1777 
1778  m_addBom->setChecked(m_doc->config()->bom());
1779 
1780  m_updatingDocumentConfig = false;
1781 
1782  // maybe block selection or wrap-cursor mode changed
1783  ensureCursorColumnValid();
1784 
1785  // first change this
1786  m_renderer->setTabWidth (m_doc->config()->tabWidth());
1787  m_renderer->setIndentWidth (m_doc->config()->indentationWidth());
1788 
1789  // now redraw...
1790  m_viewInternal->cache()->clear();
1791  tagAll ();
1792  updateView (true);
1793 }
1794 
1795 void KateView::updateRendererConfig()
1796 {
1797  if (m_startingUp)
1798  return;
1799 
1800  m_toggleWWMarker->setChecked( m_renderer->config()->wordWrapMarker() );
1801 
1802  m_viewInternal->updateBracketMarkAttributes();
1803  m_viewInternal->updateBracketMarks();
1804 
1805  if (m_searchBar) {
1806  m_searchBar->updateHighlightColors();
1807  }
1808 
1809  // now redraw...
1810  m_viewInternal->cache()->clear();
1811  tagAll ();
1812  m_viewInternal->updateView (true);
1813 
1814  // update the left border right, for example linenumbers
1815  m_viewInternal->m_leftBorder->updateFont();
1816  m_viewInternal->m_leftBorder->repaint ();
1817 
1818  m_viewInternal->m_lineScroll->queuePixmapUpdate ();
1819 
1820 // @@ showIndentLines is not cached anymore.
1821 // m_renderer->setShowIndentLines (m_renderer->config()->showIndentationLines());
1822  emit configChanged();
1823 }
1824 
1825 void KateView::updateFoldingConfig ()
1826 {
1827  // folding bar
1828  m_viewInternal->m_leftBorder->setFoldingMarkersOn(config()->foldingBar());
1829  m_toggleFoldingMarkers->setChecked( config()->foldingBar() );
1830 
1831 #if 0
1832  // FIXME: FOLDING
1833  QStringList l;
1834 
1835  l << "folding_toplevel" << "folding_expandtoplevel"
1836  << "folding_collapselocal" << "folding_expandlocal";
1837 
1838  QAction *a = 0;
1839  for (int z = 0; z < l.size(); z++)
1840  if ((a = actionCollection()->action( l[z].toAscii().constData() )))
1841  a->setEnabled (m_doc->highlight() && m_doc->highlight()->allowsFolding());
1842 #endif
1843 }
1844 
1845 void KateView::ensureCursorColumnValid()
1846 {
1847  KTextEditor::Cursor c = m_viewInternal->getCursor();
1848 
1849  // make sure the cursor is valid:
1850  // - in block selection mode or if wrap cursor is off, the column is arbitrary
1851  // - otherwise: it's bounded by the line length
1852  if (!blockSelection() && wrapCursor()
1853  && (!c.isValid() || c.column() > m_doc->lineLength(c.line())))
1854  {
1855  c.setColumn(m_doc->kateTextLine(cursorPosition().line())->length());
1856  setCursorPosition(c);
1857  }
1858 }
1859 
1860 //BEGIN EDIT STUFF
1861 void KateView::editStart ()
1862 {
1863  m_viewInternal->editStart ();
1864 }
1865 
1866 void KateView::editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom)
1867 {
1868  m_viewInternal->editEnd (editTagLineStart, editTagLineEnd, tagFrom);
1869 }
1870 
1871 void KateView::editSetCursor (const KTextEditor::Cursor &cursor)
1872 {
1873  m_viewInternal->editSetCursor (cursor);
1874 }
1875 //END
1876 
1877 //BEGIN TAG & CLEAR
1878 bool KateView::tagLine (const KTextEditor::Cursor& virtualCursor)
1879 {
1880  return m_viewInternal->tagLine (virtualCursor);
1881 }
1882 
1883 bool KateView::tagRange(const KTextEditor::Range& range, bool realLines)
1884 {
1885  return m_viewInternal->tagRange(range, realLines);
1886 }
1887 
1888 bool KateView::tagLines (int start, int end, bool realLines)
1889 {
1890  return m_viewInternal->tagLines (start, end, realLines);
1891 }
1892 
1893 bool KateView::tagLines (KTextEditor::Cursor start, KTextEditor::Cursor end, bool realCursors)
1894 {
1895  return m_viewInternal->tagLines (start, end, realCursors);
1896 }
1897 
1898 void KateView::tagAll ()
1899 {
1900  m_viewInternal->tagAll ();
1901 }
1902 
1903 void KateView::clear ()
1904 {
1905  m_viewInternal->clear ();
1906 }
1907 
1908 void KateView::repaintText (bool paintOnlyDirty)
1909 {
1910  if (paintOnlyDirty)
1911  m_viewInternal->updateDirty();
1912  else
1913  m_viewInternal->update();
1914 }
1915 
1916 void KateView::updateView (bool changed)
1917 {
1918  //kDebug(13020) << "KateView::updateView";
1919 
1920  m_viewInternal->updateView (changed);
1921  m_viewInternal->m_leftBorder->update();
1922 }
1923 
1924 //END
1925 
1926 void KateView::slotHlChanged()
1927 {
1928  KateHighlighting *hl = m_doc->highlight();
1929  bool ok ( !hl->getCommentStart(0).isEmpty() || !hl->getCommentSingleLineStart(0).isEmpty() );
1930 
1931  if (actionCollection()->action("tools_comment"))
1932  actionCollection()->action("tools_comment")->setEnabled( ok );
1933 
1934  if (actionCollection()->action("tools_uncomment"))
1935  actionCollection()->action("tools_uncomment")->setEnabled( ok );
1936 
1937  if (actionCollection()->action("tools_toggle_comment"))
1938  actionCollection()->action("tools_toggle_comment")->setEnabled( ok );
1939 
1940  // show folding bar if "view defaults" says so, otherwise enable/disable only the menu entry
1941  updateFoldingConfig ();
1942 }
1943 
1944 int KateView::virtualCursorColumn() const
1945 {
1946  return m_doc->toVirtualColumn(m_viewInternal->getCursor());
1947 }
1948 
1949 void KateView::notifyMousePositionChanged(const KTextEditor::Cursor& newPosition)
1950 {
1951  emit mousePositionChanged(this, newPosition);
1952 }
1953 
1954 //BEGIN KTextEditor::SelectionInterface stuff
1955 
1956 bool KateView::setSelection( const KTextEditor::Range &selection )
1957 {
1961  if (selection == m_selection)
1962  return true;
1963 
1967  KTextEditor::Range oldSelection = m_selection;
1968 
1972  m_selection.setRange (selection.isEmpty() ? KTextEditor::Range::invalid() : selection);
1973 
1977  tagSelection(oldSelection);
1978  repaintText(true);
1979 
1983  emit selectionChanged (this);
1984 
1988  return true;
1989 }
1990 
1991 bool KateView::clearSelection()
1992 {
1993  return clearSelection (true);
1994 }
1995 
1996 bool KateView::clearSelection(bool redraw, bool finishedChangingSelection)
1997 {
2001  if( !selection() )
2002  return false;
2003 
2007  KTextEditor::Range oldSelection = m_selection;
2008 
2012  m_selection.setRange (KTextEditor::Range::invalid());
2013 
2017  tagSelection(oldSelection);
2018  if (redraw)
2019  repaintText(true);
2020 
2024  if (finishedChangingSelection)
2025  emit selectionChanged (this);
2026 
2030  return true;
2031 }
2032 
2033 bool KateView::selection() const
2034 {
2035  if (!wrapCursor())
2036  return m_selection != KTextEditor::Range::invalid();
2037  else
2038  return m_selection.toRange().isValid();
2039 }
2040 
2041 QString KateView::selectionText() const
2042 {
2043  return m_doc->text(m_selection, blockSelect);
2044 }
2045 
2046 bool KateView::removeSelectedText()
2047 {
2048  if (!selection())
2049  return false;
2050 
2051  m_doc->editStart ();
2052 
2053  // Optimization: clear selection before removing text
2054  KTextEditor::Range selection = m_selection;
2055 
2056  m_doc->removeText(selection, blockSelect);
2057 
2058  // don't redraw the cleared selection - that's done in editEnd().
2059  if (blockSelect) {
2060  int selectionColumn = qMin(m_doc->toVirtualColumn(selection.start()), m_doc->toVirtualColumn(selection.end()));
2061  KTextEditor::Range newSelection = selection;
2062  newSelection.start().setColumn(m_doc->fromVirtualColumn(newSelection.start().line(), selectionColumn));
2063  newSelection.end().setColumn(m_doc->fromVirtualColumn(newSelection.end().line(), selectionColumn));
2064  setSelection(newSelection);
2065  setCursorPositionInternal(newSelection.start());
2066  }
2067  else
2068  clearSelection(false);
2069 
2070  m_doc->editEnd ();
2071 
2072  return true;
2073 }
2074 
2075 bool KateView::selectAll()
2076 {
2077  setBlockSelection (false);
2078  top();
2079  shiftBottom();
2080  return true;
2081 }
2082 
2083 bool KateView::cursorSelected(const KTextEditor::Cursor& cursor)
2084 {
2085  KTextEditor::Cursor ret = cursor;
2086  if ( (!blockSelect) && (ret.column() < 0) )
2087  ret.setColumn(0);
2088 
2089  if (blockSelect)
2090  return cursor.line() >= m_selection.start().line() && ret.line() <= m_selection.end().line()
2091  && ret.column() >= m_selection.start().column() && ret.column() <= m_selection.end().column();
2092  else
2093  return m_selection.toRange().contains(cursor) || m_selection.end() == cursor;
2094 }
2095 
2096 bool KateView::lineSelected (int line)
2097 {
2098  return !blockSelect && m_selection.toRange().containsLine(line);
2099 }
2100 
2101 bool KateView::lineEndSelected (const KTextEditor::Cursor& lineEndPos)
2102 {
2103  return (!blockSelect)
2104  && (lineEndPos.line() > m_selection.start().line() || (lineEndPos.line() == m_selection.start().line() && (m_selection.start().column() < lineEndPos.column() || lineEndPos.column() == -1)))
2105  && (lineEndPos.line() < m_selection.end().line() || (lineEndPos.line() == m_selection.end().line() && (lineEndPos.column() <= m_selection.end().column() && lineEndPos.column() != -1)));
2106 }
2107 
2108 bool KateView::lineHasSelected (int line)
2109 {
2110  return selection() && m_selection.toRange().containsLine(line);
2111 }
2112 
2113 bool KateView::lineIsSelection (int line)
2114 {
2115  return (line == m_selection.start().line() && line == m_selection.end().line());
2116 }
2117 
2118 void KateView::tagSelection(const KTextEditor::Range &oldSelection)
2119 {
2120  if (selection()) {
2121  if (oldSelection.start().line() == -1) {
2122  // We have to tag the whole lot if
2123  // 1) we have a selection, and:
2124  // a) it's new; or
2125  tagLines(m_selection, true);
2126 
2127  } else if (blockSelection() && (oldSelection.start().column() != m_selection.start().column() || oldSelection.end().column() != m_selection.end().column())) {
2128  // b) we're in block selection mode and the columns have changed
2129  tagLines(m_selection, true);
2130  tagLines(oldSelection, true);
2131 
2132  } else {
2133  if (oldSelection.start() != m_selection.start()) {
2134  if (oldSelection.start() < m_selection.start())
2135  tagLines(oldSelection.start(), m_selection.start(), true);
2136  else
2137  tagLines(m_selection.start(), oldSelection.start(), true);
2138  }
2139 
2140  if (oldSelection.end() != m_selection.end()) {
2141  if (oldSelection.end() < m_selection.end())
2142  tagLines(oldSelection.end(), m_selection.end(), true);
2143  else
2144  tagLines(m_selection.end(), oldSelection.end(), true);
2145  }
2146  }
2147 
2148  } else {
2149  // No more selection, clean up
2150  tagLines(oldSelection, true);
2151  }
2152 }
2153 
2154 void KateView::selectWord( const KTextEditor::Cursor& cursor )
2155 {
2156  // TODO: KDE5: reuse KateDocument::getWord() or rather KTextEditor::Document::wordRangeAt()
2157  // avoid code duplication of selectWord() here, and KateDocument::getWord()
2158  int start, end, len;
2159 
2160  Kate::TextLine textLine = m_doc->plainKateTextLine(cursor.line());
2161 
2162  if (!textLine)
2163  return;
2164 
2165  len = textLine->length();
2166  start = end = cursor.column();
2167  while (start > 0 && m_doc->highlight()->isInWord(textLine->at(start - 1), textLine->attribute(start - 1))) start--;
2168  while (end < len && m_doc->highlight()->isInWord(textLine->at(end), textLine->attribute(start - 1))) end++;
2169  if (end <= start) return;
2170 
2171  setSelection (KTextEditor::Range(cursor.line(), start, cursor.line(), end));
2172 }
2173 
2174 void KateView::selectLine( const KTextEditor::Cursor& cursor )
2175 {
2176  int line = cursor.line();
2177  if ( line+1 >= m_doc->lines() )
2178  setSelection (KTextEditor::Range(line, 0, line, m_doc->lineLength(line)));
2179  else
2180  setSelection (KTextEditor::Range(line, 0, line+1, 0));
2181 }
2182 
2183 void KateView::cut()
2184 {
2185  if (!selection() && !m_config->smartCopyCut())
2186  return;
2187 
2188  copy();
2189  if (!selection())
2190  selectLine(m_viewInternal->m_cursor);
2191  removeSelectedText();
2192 }
2193 
2194 void KateView::copy() const
2195 {
2196  QString text = selectionText();
2197 
2198  if (!selection()) {
2199  if (!m_config->smartCopyCut())
2200  return;
2201  text = m_doc->line(m_viewInternal->m_cursor.line()) + '\n';
2202  m_viewInternal->moveEdge(KateViewInternal::left, false);
2203  }
2204 
2205  // copy to clipboard and our history!
2206  KateGlobal::self()->copyToClipboard (text);
2207 }
2208 
2209 void KateView::applyWordWrap ()
2210 {
2211  if (selection())
2212  m_doc->wrapText (selectionRange().start().line(), selectionRange().end().line());
2213  else
2214  m_doc->wrapText (0, m_doc->lastLine());
2215 }
2216 
2217 //END
2218 
2219 //BEGIN KTextEditor::BlockSelectionInterface stuff
2220 
2221 bool KateView::blockSelection () const
2222 {
2223  return blockSelect;
2224 }
2225 
2226 bool KateView::setBlockSelection (bool on)
2227 {
2228  if (on != blockSelect)
2229  {
2230  blockSelect = on;
2231 
2232  KTextEditor::Range oldSelection = m_selection;
2233 
2234  const bool hadSelection = clearSelection(false, false);
2235 
2236  setSelection(oldSelection);
2237 
2238  m_toggleBlockSelection->setChecked( blockSelection() );
2239 
2240  // when leaving block selection mode, if cursor is at an invalid position or past the end of the
2241  // line, move the cursor to the last column of the current line unless cursor wrapping is off
2242  ensureCursorColumnValid();
2243 
2244  if (!hadSelection) {
2245  // emit selectionChanged() according to the KTextEditor::View api
2246  // documentation also if there is no selection around. This is needed,
2247  // as e.g. the Kate App status bar uses this signal to update the state
2248  // of the selection mode (block selection, line based selection)
2249  emit selectionChanged(this);
2250  }
2251  }
2252 
2253  return true;
2254 }
2255 
2256 bool KateView::toggleBlockSelection ()
2257 {
2258  m_toggleBlockSelection->setChecked (!blockSelect);
2259  return setBlockSelection (!blockSelect);
2260 }
2261 
2262 bool KateView::wrapCursor () const
2263 {
2264  return !blockSelection();
2265 }
2266 
2267 //END
2268 
2269 
2270 void KateView::slotTextInserted ( KTextEditor::View *view, const KTextEditor::Cursor &position, const QString &text)
2271 {
2272  emit textInserted ( view, position, text);
2273 }
2274 
2275 bool KateView::insertTemplateTextImplementation ( const KTextEditor::Cursor& c,
2276  const QString &templateString,
2277  const QMap<QString,QString> &initialValues)
2278 {
2279  return insertTemplateTextImplementation(c, templateString, initialValues, 0);
2280 }
2281 
2282 bool KateView::insertTemplateTextImplementation ( const KTextEditor::Cursor& c,
2283  const QString &templateString,
2284  const QMap<QString,QString> &initialValues,
2285  KTextEditor::TemplateScript* templateScript)
2286 {
2290  if (templateString.isEmpty())
2291  return false;
2292 
2296  if (!m_doc->isReadWrite())
2297  return false;
2298 
2302  KateTemplateScript* kateTemplateScript = KateGlobal::self()->scriptManager()->templateScript(templateScript);
2303 
2307  new KateTemplateHandler(this, c, templateString, initialValues, m_doc->undoManager(), kateTemplateScript);
2308  return true;
2309 }
2310 
2311 
2312 bool KateView::tagLines( KTextEditor::Range range, bool realRange )
2313 {
2314  return tagLines(range.start(), range.end(), realRange);
2315 }
2316 
2317 void KateView::deactivateEditActions()
2318 {
2319  foreach(QAction *action, m_editActions)
2320  action->setEnabled(false);
2321 }
2322 
2323 void KateView::activateEditActions()
2324 {
2325  foreach(QAction *action, m_editActions)
2326  action->setEnabled(true);
2327 }
2328 
2329 bool KateView::mouseTrackingEnabled( ) const
2330 {
2331  // FIXME support
2332  return true;
2333 }
2334 
2335 bool KateView::setMouseTrackingEnabled( bool )
2336 {
2337  // FIXME support
2338  return true;
2339 }
2340 
2341 bool KateView::isCompletionActive( ) const
2342 {
2343  return completionWidget()->isCompletionActive();
2344 }
2345 
2346 KateCompletionWidget* KateView::completionWidget() const
2347 {
2348  if (!m_completionWidget)
2349  m_completionWidget = new KateCompletionWidget(const_cast<KateView*>(this));
2350 
2351  return m_completionWidget;
2352 }
2353 
2354 void KateView::startCompletion( const KTextEditor::Range & word, KTextEditor::CodeCompletionModel * model )
2355 {
2356  completionWidget()->startCompletion(word, model);
2357 }
2358 
2359 void KateView::abortCompletion( )
2360 {
2361  completionWidget()->abortCompletion();
2362 }
2363 
2364 void KateView::forceCompletion( )
2365 {
2366  completionWidget()->execute();
2367 }
2368 
2369 void KateView::registerCompletionModel(KTextEditor::CodeCompletionModel* model)
2370 {
2371  completionWidget()->registerCompletionModel(model);
2372 }
2373 
2374 void KateView::unregisterCompletionModel(KTextEditor::CodeCompletionModel* model)
2375 {
2376  completionWidget()->unregisterCompletionModel(model);
2377 }
2378 
2379 bool KateView::isAutomaticInvocationEnabled() const
2380 {
2381  return m_config->automaticCompletionInvocation();
2382 }
2383 
2384 void KateView::setAutomaticInvocationEnabled(bool enabled)
2385 {
2386  config()->setAutomaticCompletionInvocation(enabled);
2387 }
2388 
2389 void KateView::sendCompletionExecuted(const KTextEditor::Cursor& position, KTextEditor::CodeCompletionModel* model, const QModelIndex& index)
2390 {
2391  emit completionExecuted(this, position, model, index);
2392 }
2393 
2394 void KateView::sendCompletionAborted()
2395 {
2396  emit completionAborted(this);
2397 }
2398 
2399 void KateView::paste(const QString *textToPaste)
2400 {
2401  const bool completionEnabled = isAutomaticInvocationEnabled();
2402  if (completionEnabled) {
2403  setAutomaticInvocationEnabled(false);
2404  }
2405 
2406  m_doc->paste( this, textToPaste ? *textToPaste : QApplication::clipboard()->text(QClipboard::Clipboard) );
2407 
2408  if (completionEnabled) {
2409  setAutomaticInvocationEnabled(true);
2410  }
2411 }
2412 
2413 void KateView::setCaretStyle( KateRenderer::caretStyles style, bool repaint )
2414 {
2415  m_viewInternal->setCaretStyle( style, repaint );
2416 }
2417 
2418 bool KateView::setCursorPosition( KTextEditor::Cursor position )
2419 {
2420  return setCursorPositionInternal( position, 1, true );
2421 }
2422 
2423 KTextEditor::Cursor KateView::cursorPosition( ) const
2424 {
2425  return m_viewInternal->getCursor();
2426 }
2427 
2428 KTextEditor::Cursor KateView::cursorPositionVirtual( ) const
2429 {
2430  return KTextEditor::Cursor (m_viewInternal->getCursor().line(), virtualCursorColumn());
2431 }
2432 
2433 QPoint KateView::cursorToCoordinate( const KTextEditor::Cursor & cursor ) const
2434 {
2435  return m_viewInternal->cursorToCoordinate(cursor);
2436 }
2437 
2438 KTextEditor::Cursor KateView::coordinatesToCursor(const QPoint& coords) const
2439 {
2440  return m_viewInternal->coordinatesToCursor(coords);
2441 }
2442 
2443 QPoint KateView::cursorPositionCoordinates( ) const
2444 {
2445  return m_viewInternal->cursorCoordinates();
2446 }
2447 
2448 bool KateView::setCursorPositionVisual( const KTextEditor::Cursor & position )
2449 {
2450  return setCursorPositionInternal( position, m_doc->config()->tabWidth(), true );
2451 }
2452 
2453 QString KateView::currentTextLine( )
2454 {
2455  return m_doc->line( cursorPosition().line() );
2456 }
2457 
2458 QString KateView::searchPattern() const
2459 {
2460  if (hasSearchBar()) {
2461  return m_searchBar->searchPattern();
2462  } else {
2463  return QString();
2464  }
2465 }
2466 
2467 QString KateView::replacementPattern() const
2468 {
2469  if (hasSearchBar()) {
2470  return m_searchBar->replacementPattern();
2471  } else {
2472  return QString();
2473  }
2474 }
2475 
2476 void KateView::setSearchPattern(const QString &searchPattern)
2477 {
2478  searchBar()->setSearchPattern(searchPattern);
2479 }
2480 
2481 void KateView::setReplacementPattern(const QString &replacementPattern)
2482 {
2483  searchBar()->setReplacementPattern(replacementPattern);
2484 }
2485 
2486 void KateView::indent( )
2487 {
2488  KTextEditor::Cursor c(cursorPosition().line(), 0);
2489  KTextEditor::Range r = selection() ? selectionRange() : KTextEditor::Range(c, c);
2490  m_doc->indent( r, 1 );
2491 }
2492 
2493 void KateView::unIndent( )
2494 {
2495  KTextEditor::Cursor c(cursorPosition().line(), 0);
2496  KTextEditor::Range r = selection() ? selectionRange() : KTextEditor::Range(c, c);
2497  m_doc->indent( r, -1 );
2498 }
2499 
2500 void KateView::cleanIndent( )
2501 {
2502  KTextEditor::Cursor c(cursorPosition().line(), 0);
2503  KTextEditor::Range r = selection() ? selectionRange() : KTextEditor::Range(c, c);
2504  m_doc->indent( r, 0 );
2505 }
2506 
2507 void KateView::align( )
2508 {
2509  // no selection: align current line; selection: use selection range
2510  const int line = cursorPosition().line();
2511  KTextEditor::Range alignRange(KTextEditor::Cursor (line,0), KTextEditor::Cursor (line,0));
2512  if (selection()) {
2513  alignRange = selectionRange();
2514  }
2515 
2516  m_doc->align( this, alignRange );
2517 }
2518 
2519 void KateView::comment( )
2520 {
2521  m_selection.setInsertBehaviors(Kate::TextRange::ExpandLeft | Kate::TextRange::ExpandRight);
2522  m_doc->comment( this, cursorPosition().line(), cursorPosition().column(), 1 );
2523  m_selection.setInsertBehaviors(Kate::TextRange::ExpandRight);
2524 }
2525 
2526 void KateView::uncomment( )
2527 {
2528  m_doc->comment( this, cursorPosition().line(), cursorPosition().column(),-1 );
2529 }
2530 
2531 void KateView::toggleComment( )
2532 {
2533  m_selection.setInsertBehaviors(Kate::TextRange::ExpandLeft | Kate::TextRange::ExpandRight);
2534  m_doc->comment( this, cursorPosition().line(), cursorPosition().column(), 0 );
2535  m_selection.setInsertBehaviors(Kate::TextRange::ExpandRight);
2536 }
2537 
2538 void KateView::uppercase( )
2539 {
2540  m_doc->transform( this, m_viewInternal->m_cursor, KateDocument::Uppercase );
2541 }
2542 
2543 void KateView::killLine( )
2544 {
2545  if (m_selection.isEmpty()) {
2546  m_doc->removeLine(cursorPosition().line());
2547  } else {
2548  m_doc->editStart();
2549  for (int line = m_selection.end().line(); line >= m_selection.start().line(); line--) {
2550  m_doc->removeLine(line);
2551  }
2552  m_doc->editEnd();
2553  }
2554 }
2555 
2556 void KateView::lowercase( )
2557 {
2558  m_doc->transform( this, m_viewInternal->m_cursor, KateDocument::Lowercase );
2559 }
2560 
2561 void KateView::capitalize( )
2562 {
2563  m_doc->editStart();
2564  m_doc->transform( this, m_viewInternal->m_cursor, KateDocument::Lowercase );
2565  m_doc->transform( this, m_viewInternal->m_cursor, KateDocument::Capitalize );
2566  m_doc->editEnd();
2567 }
2568 
2569 void KateView::keyReturn( )
2570 {
2571  m_viewInternal->doReturn();
2572 }
2573 
2574 void KateView::smartNewline( )
2575 {
2576  m_viewInternal->doSmartNewline();
2577 }
2578 
2579 void KateView::backspace( )
2580 {
2581  m_viewInternal->doBackspace();
2582 }
2583 
2584 void KateView::insertTab( )
2585 {
2586  m_viewInternal->doTabulator();
2587 }
2588 
2589 void KateView::deleteWordLeft( )
2590 {
2591  m_viewInternal->doDeletePrevWord();
2592 }
2593 
2594 void KateView::keyDelete( )
2595 {
2596  m_viewInternal->doDelete();
2597 }
2598 
2599 void KateView::deleteWordRight( )
2600 {
2601  m_viewInternal->doDeleteNextWord();
2602 }
2603 
2604 void KateView::transpose( )
2605 {
2606  m_viewInternal->doTranspose();
2607 }
2608 
2609 void KateView::cursorLeft( )
2610 {
2611  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2612  m_viewInternal->cursorNextChar();
2613  else
2614  m_viewInternal->cursorPrevChar();
2615 }
2616 
2617 void KateView::shiftCursorLeft( )
2618 {
2619  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2620  m_viewInternal->cursorNextChar(true);
2621  else
2622  m_viewInternal->cursorPrevChar(true);
2623 }
2624 
2625 void KateView::cursorRight( )
2626 {
2627  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2628  m_viewInternal->cursorPrevChar();
2629  else
2630  m_viewInternal->cursorNextChar();
2631 }
2632 
2633 void KateView::shiftCursorRight( )
2634 {
2635  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2636  m_viewInternal->cursorPrevChar(true);
2637  else
2638  m_viewInternal->cursorNextChar(true);
2639 }
2640 
2641 void KateView::wordLeft( )
2642 {
2643  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2644  m_viewInternal->wordNext();
2645  else
2646  m_viewInternal->wordPrev();
2647 }
2648 
2649 void KateView::shiftWordLeft( )
2650 {
2651  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2652  m_viewInternal->wordNext(true);
2653  else
2654  m_viewInternal->wordPrev(true);
2655 }
2656 
2657 void KateView::wordRight( )
2658 {
2659  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2660  m_viewInternal->wordPrev();
2661  else
2662  m_viewInternal->wordNext();
2663 }
2664 
2665 void KateView::shiftWordRight( )
2666 {
2667  if (m_viewInternal->m_view->currentTextLine().isRightToLeft())
2668  m_viewInternal->wordPrev(true);
2669  else
2670  m_viewInternal->wordNext(true);
2671 }
2672 
2673 void KateView::home( )
2674 {
2675  m_viewInternal->home();
2676 }
2677 
2678 void KateView::shiftHome( )
2679 {
2680  m_viewInternal->home(true);
2681 }
2682 
2683 void KateView::end( )
2684 {
2685  m_viewInternal->end();
2686 }
2687 
2688 void KateView::shiftEnd( )
2689 {
2690  m_viewInternal->end(true);
2691 }
2692 
2693 void KateView::up( )
2694 {
2695  m_viewInternal->cursorUp();
2696 }
2697 
2698 void KateView::shiftUp( )
2699 {
2700  m_viewInternal->cursorUp(true);
2701 }
2702 
2703 void KateView::down( )
2704 {
2705  m_viewInternal->cursorDown();
2706 }
2707 
2708 void KateView::shiftDown( )
2709 {
2710  m_viewInternal->cursorDown(true);
2711 }
2712 
2713 void KateView::scrollUp( )
2714 {
2715  m_viewInternal->scrollUp();
2716 }
2717 
2718 void KateView::scrollDown( )
2719 {
2720  m_viewInternal->scrollDown();
2721 }
2722 
2723 void KateView::topOfView( )
2724 {
2725  m_viewInternal->topOfView();
2726 }
2727 
2728 void KateView::shiftTopOfView( )
2729 {
2730  m_viewInternal->topOfView(true);
2731 }
2732 
2733 void KateView::bottomOfView( )
2734 {
2735  m_viewInternal->bottomOfView();
2736 }
2737 
2738 void KateView::shiftBottomOfView( )
2739 {
2740  m_viewInternal->bottomOfView(true);
2741 }
2742 
2743 void KateView::pageUp( )
2744 {
2745  m_viewInternal->pageUp();
2746 }
2747 
2748 void KateView::shiftPageUp( )
2749 {
2750  m_viewInternal->pageUp(true);
2751 }
2752 
2753 void KateView::pageDown( )
2754 {
2755  m_viewInternal->pageDown();
2756 }
2757 
2758 void KateView::shiftPageDown( )
2759 {
2760  m_viewInternal->pageDown(true);
2761 }
2762 
2763 void KateView::top( )
2764 {
2765  m_viewInternal->top_home();
2766 }
2767 
2768 void KateView::shiftTop( )
2769 {
2770  m_viewInternal->top_home(true);
2771 }
2772 
2773 void KateView::bottom( )
2774 {
2775  m_viewInternal->bottom_end();
2776 }
2777 
2778 void KateView::shiftBottom( )
2779 {
2780  m_viewInternal->bottom_end(true);
2781 }
2782 
2783 void KateView::toMatchingBracket( )
2784 {
2785  m_viewInternal->cursorToMatchingBracket();
2786 }
2787 
2788 void KateView::shiftToMatchingBracket( )
2789 {
2790  m_viewInternal->cursorToMatchingBracket(true);
2791 }
2792 
2793 void KateView::toPrevModifiedLine()
2794 {
2795  const int startLine = m_viewInternal->m_cursor.line() - 1;
2796  const int line = m_doc->findModifiedLine(startLine, false);
2797  if (line >= 0) {
2798  KTextEditor::Cursor c(line, 0);
2799  m_viewInternal->updateSelection(c, false);
2800  m_viewInternal->updateCursor(c);
2801  }
2802 }
2803 
2804 void KateView::toNextModifiedLine()
2805 {
2806  const int startLine = m_viewInternal->m_cursor.line() + 1;
2807  const int line = m_doc->findModifiedLine(startLine, true);
2808  if (line >= 0) {
2809  KTextEditor::Cursor c(line, 0);
2810  m_viewInternal->updateSelection(c, false);
2811  m_viewInternal->updateCursor(c);
2812  }
2813 }
2814 
2815 const KTextEditor::Range & KateView::selectionRange( ) const
2816 {
2817  // update the cache
2818  m_holdSelectionRangeForAPI = m_selection;
2819 
2820  // return cached value, has right type!
2821  return m_holdSelectionRangeForAPI;
2822 }
2823 
2824 KTextEditor::Document * KateView::document( ) const
2825 {
2826  return m_doc;
2827 }
2828 
2829 void KateView::setContextMenu( QMenu * menu )
2830 {
2831  if (m_contextMenu) {
2832  disconnect(m_contextMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowContextMenu()));
2833  disconnect(m_contextMenu, SIGNAL(aboutToHide()), this, SLOT(aboutToHideContextMenu()));
2834  }
2835  m_contextMenu = menu;
2836  m_userContextMenuSet=true;
2837 
2838  if (m_contextMenu) {
2839  connect(m_contextMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowContextMenu()));
2840  connect(m_contextMenu, SIGNAL(aboutToHide()), this, SLOT(aboutToHideContextMenu()));
2841  }
2842 }
2843 
2844 QMenu *KateView::contextMenu( ) const
2845 {
2846  if (m_userContextMenuSet)
2847  return m_contextMenu;
2848  else
2849  {
2850  KXMLGUIClient* client = const_cast<KateView*>(this);
2851  while (client->parentClient())
2852  client = client->parentClient();
2853 
2854  //kDebug() << "looking up all menu containers";
2855  if (client->factory()){
2856  QList<QWidget*> conts = client->factory()->containers("menu");
2857  foreach (QWidget *w, conts)
2858  {
2859  if (w->objectName() == "ktexteditor_popup")
2860  {//perhaps optimize this block
2861  QMenu* menu=(QMenu*)w;
2862  disconnect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowContextMenu()));
2863  disconnect(menu, SIGNAL(aboutToHide()), this, SLOT(aboutToHideContextMenu()));
2864  connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowContextMenu()));
2865  connect(menu, SIGNAL(aboutToHide()), this, SLOT(aboutToHideContextMenu()));
2866  return menu;
2867  }
2868  }
2869  }
2870  }
2871  return 0;
2872 }
2873 
2874 QMenu * KateView::defaultContextMenu(QMenu* menu) const
2875 {
2876  if (!menu)
2877  menu = new KMenu(const_cast<KateView*>(this));
2878 
2879  menu->addAction(m_editUndo);
2880  menu->addAction(m_editRedo);
2881  menu->addSeparator();
2882  menu->addAction(m_cut);
2883  menu->addAction(m_copy);
2884  menu->addAction(m_paste);
2885  menu->addSeparator();
2886  menu->addAction(m_selectAll);
2887  menu->addAction(m_deSelect);
2888  if (QAction *spellingSuggestions = actionCollection()->action("spelling_suggestions")) {
2889  menu->addSeparator();
2890  menu->addAction(spellingSuggestions);
2891  }
2892  if (QAction* bookmark = actionCollection()->action("bookmarks")) {
2893  menu->addSeparator();
2894  menu->addAction(bookmark);
2895  }
2896  return menu;
2897 }
2898 
2899 void KateView::aboutToShowContextMenu( )
2900 {
2901  QMenu* menu = qobject_cast<QMenu*>(sender());
2902 
2903  if (menu) {
2904  emit contextMenuAboutToShow(this, menu);
2905  }
2906 }
2907 
2908 void KateView::aboutToHideContextMenu( )
2909 {
2910  m_spellingMenu->setUseMouseForMisspelledRange(false);
2911 }
2912 
2913 // BEGIN ConfigInterface stff
2914 QStringList KateView::configKeys() const
2915 {
2916  return QStringList() << "icon-bar" << "line-numbers" << "dynamic-word-wrap"
2917  << "background-color" << "selection-color"
2918  << "search-highlight-color" << "replace-highlight-color"
2919  << "folding-bar" << "icon-border-color" << "folding-marker-color"
2920  << "line-number-color" << "modification-markers";
2921 }
2922 
2923 QVariant KateView::configValue(const QString &key)
2924 {
2925  if (key == "icon-bar")
2926  return config()->iconBar();
2927  else if (key == "line-numbers")
2928  return config()->lineNumbers();
2929  else if (key == "dynamic-word-wrap")
2930  return config()->dynWordWrap();
2931  else if (key == "background-color")
2932  return renderer()->config()->backgroundColor();
2933  else if (key == "selection-color")
2934  return renderer()->config()->selectionColor();
2935  else if (key == "search-highlight-color")
2936  return renderer()->config()->searchHighlightColor();
2937  else if (key == "replace-highlight-color")
2938  return renderer()->config()->replaceHighlightColor();
2939  else if (key == "default-mark-type")
2940  return config()->defaultMarkType();
2941  else if (key == "allow-mark-menu")
2942  return config()->allowMarkMenu();
2943  else if (key == "folding-bar")
2944  return config()->foldingBar();
2945  else if (key == "icon-border-color")
2946  return renderer()->config()->iconBarColor();
2947  else if (key == "folding-marker-color")
2948  return renderer()->config()->foldingColor();
2949  else if (key == "line-number-color")
2950  return renderer()->config()->lineNumberColor();
2951  else if (key == "modification-markers")
2952  return config()->lineModification();
2953 
2954  // return invalid variant
2955  return QVariant();
2956 }
2957 
2958 void KateView::setConfigValue(const QString &key, const QVariant &value)
2959 {
2960  if ( value.canConvert(QVariant::Color) ) {
2961  if (key == "background-color")
2962  renderer()->config()->setBackgroundColor(value.value<QColor>());
2963  else if (key == "selection-color")
2964  renderer()->config()->setSelectionColor(value.value<QColor>());
2965  else if (key == "search-highlight-color")
2966  renderer()->config()->setSearchHighlightColor(value.value<QColor>());
2967  else if (key == "replace-highlight-color")
2968  renderer()->config()->setReplaceHighlightColor(value.value<QColor>());
2969  else if (key == "icon-border-color")
2970  renderer()->config()->setIconBarColor(value.value<QColor>());
2971  else if (key == "folding-marker-color")
2972  renderer()->config()->setFoldingColor(value.value<QColor>());
2973  else if (key == "line-number-color")
2974  renderer()->config()->setLineNumberColor(value.value<QColor>());
2975  } else if ( value.type() == QVariant::Bool ) {
2976  // Note explicit type check above. If we used canConvert, then
2977  // values of type UInt will be trapped here.
2978  if (key == "icon-bar")
2979  config()->setIconBar(value.toBool());
2980  else if (key == "line-numbers")
2981  config()->setLineNumbers(value.toBool());
2982  else if (key == "dynamic-word-wrap")
2983  config()->setDynWordWrap(value.toBool());
2984  else if (key == "allow-mark-menu")
2985  config()->setAllowMarkMenu(value.toBool());
2986  else if (key == "folding-bar")
2987  config()->setFoldingBar(value.toBool());
2988  else if (key == "modification-markers")
2989  config()->setLineModification(value.toBool());
2990  } else if ( value.canConvert(QVariant::UInt) ) {
2991  if (key == "default-mark-type")
2992  config()->setDefaultMarkType(value.toUInt());
2993  }
2994 }
2995 
2996 // END ConfigInterface
2997 
2998 void KateView::userInvokedCompletion()
2999 {
3000  completionWidget()->userInvokedCompletion();
3001 }
3002 
3003 KateViewBar *KateView::topViewBar() const
3004 {
3005  return m_topViewBar;
3006 }
3007 
3008 KateViewBar *KateView::bottomViewBar() const
3009 {
3010  return m_bottomViewBar;
3011 }
3012 
3013 KateCommandLineBar *KateView::cmdLineBar ()
3014 {
3015  if (!m_cmdLine) {
3016  m_cmdLine = new KateCommandLineBar (this, bottomViewBar());
3017  bottomViewBar()->addBarWidget(m_cmdLine);
3018  }
3019 
3020  return m_cmdLine;
3021 }
3022 
3023 KateSearchBar *KateView::searchBar (bool initHintAsPower)
3024 {
3025  if (!m_searchBar) {
3026  m_searchBar = new KateSearchBar(initHintAsPower, this, KateViewConfig::global());
3027  }
3028  return m_searchBar;
3029 }
3030 
3031 KateGotoBar *KateView::gotoBar ()
3032 {
3033  if (!m_gotoBar) {
3034  m_gotoBar = new KateGotoBar (this);
3035  bottomViewBar()->addBarWidget(m_gotoBar);
3036  }
3037 
3038  return m_gotoBar;
3039 }
3040 
3041 KateDictionaryBar *KateView::dictionaryBar ()
3042 {
3043  if(!m_dictionaryBar) {
3044  m_dictionaryBar = new KateDictionaryBar(this);
3045  bottomViewBar()->addBarWidget(m_dictionaryBar);
3046  }
3047 
3048  return m_dictionaryBar;
3049 }
3050 
3051 KateViEmulatedCommandBar* KateView::viModeEmulatedCommandBar()
3052 {
3053  if (!m_viModeEmulatedCommandBar) {
3054  m_viModeEmulatedCommandBar = new KateViEmulatedCommandBar(this, this);
3055  m_viModeEmulatedCommandBar->hide ();
3056  }
3057 
3058  return m_viModeEmulatedCommandBar;
3059 }
3060 
3061 void KateView::setAnnotationModel( KTextEditor::AnnotationModel* model )
3062 {
3063  KTextEditor::AnnotationModel* oldmodel = m_annotationModel;
3064  m_annotationModel = model;
3065  m_viewInternal->m_leftBorder->annotationModelChanged(oldmodel, m_annotationModel);
3066 }
3067 
3068 KTextEditor::AnnotationModel* KateView::annotationModel() const
3069 {
3070  return m_annotationModel;
3071 }
3072 
3073 void KateView::setAnnotationBorderVisible( bool visible )
3074 {
3075  m_viewInternal->m_leftBorder->setAnnotationBorderOn( visible );
3076 }
3077 
3078 bool KateView::isAnnotationBorderVisible() const
3079 {
3080  return m_viewInternal->m_leftBorder->annotationBorderOn();
3081 }
3082 
3083 KTextEditor::Range KateView::visibleRange()
3084 {
3085  //ensure that the view is up-to-date, otherwise 'endPos()' might fail!
3086  m_viewInternal->updateView();
3087  return KTextEditor::Range(m_viewInternal->toRealCursor(m_viewInternal->startPos()),
3088  m_viewInternal->toRealCursor(m_viewInternal->endPos()));
3089 }
3090 
3091 void KateView::toggleOnTheFlySpellCheck(bool b)
3092 {
3093  m_doc->onTheFlySpellCheckingEnabled(b);
3094 }
3095 
3096 void KateView::reflectOnTheFlySpellCheckStatus(bool enabled)
3097 {
3098  m_spellingMenu->setVisible(enabled);
3099  m_toggleOnTheFlySpellCheck->setChecked(enabled);
3100 }
3101 
3102 KateSpellingMenu* KateView::spellingMenu()
3103 {
3104  return m_spellingMenu;
3105 }
3106 
3107 void KateView::notifyAboutRangeChange (int startLine, int endLine, bool rangeWithAttribute)
3108 {
3109 #ifdef VIEW_RANGE_DEBUG
3110  // output args
3111  kDebug() << "trigger attribute changed from" << startLine << "to" << endLine << "rangeWithAttribute" << rangeWithAttribute;
3112 #endif
3113 
3114  // first call:
3115  if (!m_delayedUpdateTriggered) {
3116  m_delayedUpdateTriggered = true;
3117  m_lineToUpdateMin = -1;
3118  m_lineToUpdateMax = -1;
3119 
3120  // only set initial line range, if range with attribute!
3121  if (rangeWithAttribute) {
3122  m_lineToUpdateMin = startLine;
3123  m_lineToUpdateMax = endLine;
3124  }
3125 
3126  // emit queued signal and be done
3127  emit delayedUpdateOfView ();
3128  return;
3129  }
3130 
3131  // ignore lines if no attribute
3132  if (!rangeWithAttribute)
3133  return;
3134 
3135  // update line range
3136  if (startLine != -1 && (m_lineToUpdateMin == -1 || startLine < m_lineToUpdateMin))
3137  m_lineToUpdateMin = startLine;
3138 
3139  if (endLine != -1 && endLine > m_lineToUpdateMax)
3140  m_lineToUpdateMax = endLine;
3141 }
3142 
3143 void KateView::slotDelayedUpdateOfView ()
3144 {
3145  if (!m_delayedUpdateTriggered)
3146  return;
3147 
3148 #ifdef VIEW_RANGE_DEBUG
3149  // output args
3150  kDebug() << "delayed attribute changed from" << m_lineToUpdateMin << "to" << m_lineToUpdateMax;
3151 #endif
3152 
3153  // update ranges in
3154  updateRangesIn (KTextEditor::Attribute::ActivateMouseIn);
3155  updateRangesIn (KTextEditor::Attribute::ActivateCaretIn);
3156 
3157  // update view, if valid line range, else only feedback update wanted anyway
3158  if (m_lineToUpdateMin != -1 && m_lineToUpdateMax != -1) {
3159  tagLines (m_lineToUpdateMin, m_lineToUpdateMax, true);
3160  updateView (true);
3161  }
3162 
3163  // reset flags
3164  m_delayedUpdateTriggered = false;
3165  m_lineToUpdateMin = -1;
3166  m_lineToUpdateMax = -1;
3167 }
3168 
3169 void KateView::updateRangesIn (KTextEditor::Attribute::ActivationType activationType)
3170 {
3171  // new ranges with cursor in, default none
3172  QSet<Kate::TextRange *> newRangesIn;
3173 
3174  // on which range set we work?
3175  QSet<Kate::TextRange *> &oldSet = (activationType == KTextEditor::Attribute::ActivateMouseIn) ? m_rangesMouseIn : m_rangesCaretIn;
3176 
3177  // which cursor position to honor?
3178  KTextEditor::Cursor currentCursor = (activationType == KTextEditor::Attribute::ActivateMouseIn) ? m_viewInternal->getMouse() : m_viewInternal->getCursor ();
3179 
3180  // first: validate the remembered ranges
3181  QSet<Kate::TextRange *> validRanges;
3182  foreach (Kate::TextRange *range, oldSet)
3183  if (m_doc->buffer().rangePointerValid(range))
3184  validRanges.insert (range);
3185 
3186  // cursor valid? else no new ranges can be found
3187  if (currentCursor.isValid () && currentCursor.line() < m_doc->buffer().lines()) {
3188  // now: get current ranges for the line of cursor with an attribute
3189  QList<Kate::TextRange *> rangesForCurrentCursor = m_doc->buffer().rangesForLine (currentCursor.line(), this, false);
3190 
3191  // match which ranges really fit the given cursor
3192  foreach (Kate::TextRange *range, rangesForCurrentCursor) {
3193  // range has no dynamic attribute of right type and no feedback object
3194  if ((!range->attribute() || !range->attribute()->dynamicAttribute (activationType)) && !range->feedback())
3195  continue;
3196 
3197  // range doesn't contain cursor, not interesting
3198  if ((range->start().insertBehavior() == KTextEditor::MovingCursor::StayOnInsert)
3199  ? (currentCursor < range->start().toCursor ()) : (currentCursor <= range->start().toCursor ()))
3200  continue;
3201 
3202  if ((range->end().insertBehavior() == KTextEditor::MovingCursor::StayOnInsert)
3203  ? (range->end().toCursor () <= currentCursor) : (range->end().toCursor () < currentCursor))
3204  continue;
3205 
3206  // range contains cursor, was it already in old set?
3207  if (validRanges.contains (range)) {
3208  // insert in new, remove from old, be done with it
3209  newRangesIn.insert (range);
3210  validRanges.remove (range);
3211  continue;
3212  }
3213 
3214  // oh, new range, trigger update and insert into new set
3215  newRangesIn.insert (range);
3216 
3217  if (range->attribute() && range->attribute()->dynamicAttribute (activationType))
3218  notifyAboutRangeChange (range->start().line(), range->end().line(), true);
3219 
3220  // feedback
3221  if (range->feedback ()) {
3222  if (activationType == KTextEditor::Attribute::ActivateMouseIn)
3223  range->feedback ()->mouseEnteredRange (range, this);
3224  else
3225  range->feedback ()->caretEnteredRange (range, this);
3226  }
3227 
3228 #ifdef VIEW_RANGE_DEBUG
3229  // found new range for activation
3230  kDebug() << "activated new range" << range << "by" << activationType;
3231 #endif
3232  }
3233  }
3234 
3235  // now: notify for left ranges!
3236  foreach (Kate::TextRange *range, validRanges) {
3237  // range valid + right dynamic attribute, trigger update
3238  if (range->toRange().isValid() && range->attribute() && range->attribute()->dynamicAttribute (activationType))
3239  notifyAboutRangeChange (range->start().line(), range->end().line(), true);
3240 
3241  // feedback
3242  if (range->feedback ()) {
3243  if (activationType == KTextEditor::Attribute::ActivateMouseIn)
3244  range->feedback ()->mouseExitedRange (range, this);
3245  else
3246  range->feedback ()->caretExitedRange (range, this);
3247  }
3248  }
3249 
3250  // set new ranges
3251  oldSet = newRangesIn;
3252 }
3253 
3254 void KateView::postMessage(KTextEditor::Message* message,
3255  QList<QSharedPointer<QAction> > actions)
3256 {
3257  // just forward to KateMessageWidget :-)
3258  if (message->position() == KTextEditor::Message::AboveView) {
3259  m_topMessageWidget->postMessage(message, actions);
3260  } else if (message->position() == KTextEditor::Message::BelowView) {
3261  m_bottomMessageWidget->postMessage(message, actions);
3262  } else if (message->position() == KTextEditor::Message::TopInView) {
3263  if (!m_floatTopMessageWidget) {
3264  m_floatTopMessageWidget = new KateMessageWidget(m_viewInternal, true);
3265  m_notificationLayout->insertWidget(0, m_floatTopMessageWidget, 0, Qt::AlignTop | Qt::AlignRight);
3266  connect(this, SIGNAL(displayRangeChanged(KateView*)), m_floatTopMessageWidget, SLOT(startAutoHideTimer()));
3267  connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View*, const KTextEditor::Cursor&)), m_floatTopMessageWidget, SLOT(startAutoHideTimer()));
3268  }
3269  m_floatTopMessageWidget->postMessage(message, actions);
3270  } else if (message->position() == KTextEditor::Message::BottomInView) {
3271  if (!m_floatBottomMessageWidget) {
3272  m_floatBottomMessageWidget = new KateMessageWidget(m_viewInternal, true);
3273  m_notificationLayout->addWidget(m_floatBottomMessageWidget, 0, Qt::AlignBottom | Qt::AlignRight);
3274  connect(this, SIGNAL(displayRangeChanged(KateView*)), m_floatBottomMessageWidget, SLOT(startAutoHideTimer()));
3275  connect(this, SIGNAL(cursorPositionChanged(KTextEditor::View*, const KTextEditor::Cursor&)), m_floatBottomMessageWidget, SLOT(startAutoHideTimer()));
3276  }
3277  m_floatBottomMessageWidget->postMessage(message, actions);
3278  }
3279 }
3280 
3281 void KateView::saveFoldingState ()
3282 {
3283  m_savedFoldingState = m_textFolding.exportFoldingRanges ();
3284 }
3285 
3286 void KateView::applyFoldingState ()
3287 {
3288  m_textFolding.importFoldingRanges (m_savedFoldingState);
3289  m_savedFoldingState.clear ();
3290 }
3291 
3292 // kate: space-indent on; indent-width 2; replace-tabs on;
KateViewInternal::editEnd
void editEnd(int editTagLineStart, int editTagLineEnd, bool tagFrom)
Definition: kateviewinternal.cpp:3391
KateView::foldingMarkersOn
bool foldingMarkersOn()
Definition: kateview.cpp:1511
KateView::findSelectedBackwards
void findSelectedBackwards()
Definition: kateview.cpp:1612
KateDocument::line
virtual QString line(int line) const
Definition: katedocument.cpp:447
KateDocument::align
void align(KateView *view, const KTextEditor::Range &range)
Definition: katedocument.cpp:2909
QVariant::canConvert
bool canConvert(Type t) const
KateViewInternal::cursorPrevChar
void cursorPrevChar(bool sel=false)
Definition: kateviewinternal.cpp:1092
KateDocument::buffer
KateBuffer & buffer()
Get access to buffer of this document.
Definition: katedocument.h:946
KateView::updateViModeBarMode
void updateViModeBarMode()
Update vi mode statusbar according to the current mode.
Definition: kateview.cpp:1568
KateScrollBar::showMiniMap
bool showMiniMap()
Definition: kateviewhelpers.h:77
KateViInputModeManager::getVerbatimKeys
const QString getVerbatimKeys() const
Definition: kateviinputmodemanager.cpp:566
KateGlobal::writeConfig
void writeConfig(KConfig *config=0)
Write editor configuration to given config object.
Definition: kateglobal.cpp:277
KateView::getEol
int getEol() const
Definition: kateview.cpp:1385
QList::clear
void clear()
KateViInputModeManager::viEnterNormalMode
void viEnterNormalMode()
set normal mode to be the active vi mode and perform the needed setup work
Definition: kateviinputmodemanager.cpp:484
KateDocument::config
KateDocumentConfig * config()
Configuration.
Definition: katedocument.h:1009
KateView::m_spellingMenu
KateSpellingMenu * m_spellingMenu
Definition: kateview.h:762
QModelIndex
KateView::shiftDown
void shiftDown()
Definition: kateview.cpp:2708
KateView::tagLines
bool tagLines(int start, int end, bool realLines=false)
Definition: kateview.cpp:1888
KateView::userInvokedCompletion
void userInvokedCompletion()
Definition: kateview.cpp:2998
KateView::defaultContextMenu
QMenu * defaultContextMenu(QMenu *menu=0L) const
Definition: kateview.cpp:2874
KateViewInternal::doReturn
void doReturn()
Definition: kateviewinternal.cpp:795
KateView::shiftHome
void shiftHome()
Definition: kateview.cpp:2678
QWidget
KateSpellCheckDialog::updateActions
void updateActions()
Definition: spellcheckdialog.cpp:79
KateViewInternal::doBackspace
void doBackspace()
Definition: kateviewinternal.cpp:827
katehighlight.h
katetextline.h
KateSearchBar::setReplacementPattern
void setReplacementPattern(const QString &replacementPattern)
Set the current replacement pattern.
Definition: katesearchbar.cpp:225
Kate::TextRange::feedback
KTextEditor::MovingRangeFeedback * feedback() const
Gets the active MovingRangeFeedback for this range.
Definition: katetextrange.h:195
kateview.h
kateviemulatedcommandbar.h
KateView::dynWrapIndicators
int dynWrapIndicators()
Definition: kateview.cpp:1507
QString::append
QString & append(QChar ch)
QAction::setShortcutContext
void setShortcutContext(Qt::ShortcutContext context)
KateRendererConfig::selectionColor
const QColor & selectionColor() const
Definition: kateconfig.cpp:2348
Kate::Script::i18n
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
QLayout::setContentsMargins
void setContentsMargins(int left, int top, int right, int bottom)
KateIconBorder::updateFont
void updateFont()
Definition: kateviewhelpers.cpp:1421
KateScrollBar::queuePixmapUpdate
void queuePixmapUpdate()
Definition: kateviewhelpers.h:86
KateRendererConfig::wordWrapMarker
bool wordWrapMarker() const
Definition: kateconfig.cpp:2306
KateView::clearSelection
bool clearSelection()
Definition: kateview.cpp:1991
KateViewBar::addBarWidget
void addBarWidget(KateViewBarWidget *newBarWidget)
Adds a widget to this viewbar.
Definition: kateviewhelpers.cpp:2478
KateSearchBar::setSearchPattern
void setSearchPattern(const QString &searchPattern)
Set the current search pattern.
Definition: katesearchbar.cpp:951
KateView::scrollBarMarks
bool scrollBarMarks()
Definition: kateview.cpp:1499
KateView::toggleBlockSelection
bool toggleBlockSelection()
Definition: kateview.cpp:2256
KateViewInternal::startPos
KTextEditor::Cursor startPos() const
Definition: kateviewinternal.h:125
KateView::end
void end()
Definition: kateview.cpp:2683
KateView::sendCompletionExecuted
void sendCompletionExecuted(const KTextEditor::Cursor &position, KTextEditor::CodeCompletionModel *model, const QModelIndex &index)
Definition: kateview.cpp:2389
Kate::TextRange::start
const KTextEditor::MovingCursor & start() const
Retrieve start cursor of this range, read-only.
Definition: katetextrange.h:119
KateView::selectWord
void selectWord(const KTextEditor::Cursor &cursor)
Definition: kateview.cpp:2154
QDropEvent::mimeData
const QMimeData * mimeData() const
katehighlightmenu.h
KateViewInternal::topOfView
void topOfView(bool sel=false)
Definition: kateviewinternal.cpp:1497
KateView::renderer
KateRenderer * renderer()
Definition: kateview.cpp:1664
KateViewInternal::tagRange
bool tagRange(const KTextEditor::Range &range, bool realCursors)
Definition: kateviewinternal.cpp:2106
KateView::comment
void comment()
Definition: kateview.cpp:2519
KateView::document
KTextEditor::Document * document() const
Definition: kateview.cpp:2824
KateView::isCompletionActive
virtual bool isCompletionActive() const
Definition: kateview.cpp:2341
katerenderer.h
KateGlobal::container
QObject * container()
Get the currently associated Container object.
Definition: kateglobal.cpp:519
spellcheckdialog.h
KateView::bottomViewBar
KateViewBar * bottomViewBar() const
Definition: kateview.cpp:3008
KateView::selectAll
bool selectAll()
Definition: kateview.cpp:2075
KateScrollBar::showMarks
bool showMarks()
Definition: kateviewhelpers.h:74
KateDocument::setReadWrite
virtual void setReadWrite(bool rw=true)
Definition: katedocument.cpp:2469
KateDocument::removeLine
virtual bool removeLine(int line)
Definition: katedocument.cpp:727
KateDocumentConfig::ovr
bool ovr() const
Definition: kateconfig.cpp:800
KateDocument::highlight
KateHighlighting * highlight() const
Definition: katedocument.cpp:4701
KateView::slotExpandLevel
void slotExpandLevel()
Definition: kateview.cpp:1096
KateViewConfig::smartCopyCut
bool smartCopyCut() const
Definition: kateconfig.cpp:1976
KateView::cleanIndent
void cleanIndent()
Definition: kateview.cpp:2500
KateView::disableTextHints
void disableTextHints()
Definition: kateview.cpp:1525
KateRendererConfig::replaceHighlightColor
const QColor & replaceHighlightColor() const
Definition: kateconfig.cpp:2708
KateView::bottom
void bottom()
Definition: kateview.cpp:2773
Kate::TextCursor::column
int column() const
Retrieve the column on which this cursor is situated.
Definition: katetextcursor.h:141
KateIconBorder::setAnnotationBorderOn
void setAnnotationBorderOn(bool enable)
Definition: kateviewhelpers.cpp:1303
KateRendererConfig::setFoldingColor
void setFoldingColor(const QColor &col)
Definition: kateconfig.cpp:2537
KateView::startCompletion
virtual void startCompletion(const KTextEditor::Range &word, KTextEditor::CodeCompletionModel *model)
Definition: kateview.cpp:2354
KateView::dynWordWrap
bool dynWordWrap() const
Definition: kateview.h:244
Kate::Script::i18nc
QScriptValue i18nc(QScriptContext *context, QScriptEngine *engine)
i18nc("context", "text", arguments [optional])
Definition: katescripthelpers.cpp:210
KateView::shiftBottom
void shiftBottom()
Definition: kateview.cpp:2778
KateView::deleteWordLeft
void deleteWordLeft()
Definition: kateview.cpp:2589
Kate::TextBuffer::rangePointerValid
bool rangePointerValid(TextRange *range) const
Check if the given range pointer is still valid.
Definition: katetextbuffer.h:429
KateGlobal::deregisterView
void deregisterView(KateView *view)
unregister view at the factory
Definition: kateglobal.cpp:494
KateDocumentConfig::setOvr
void setOvr(bool on)
Definition: kateconfig.cpp:787
KateView::setDynWrapIndicators
void setDynWrapIndicators(int mode)
Definition: kateview.cpp:1209
KateView::enableTextHints
void enableTextHints(int timeout)
Definition: kateview.cpp:1520
KateGlobal::configDialog
void configDialog(QWidget *parent)
Shows a config dialog for the part, changes will be applied to the editor, but not saved anywhere aut...
Definition: kateglobal.cpp:306
QChar
KateViewConfig::lineModification
bool lineModification() const
Definition: kateconfig.cpp:1636
KateView::backspace
void backspace()
Definition: kateview.cpp:2579
KateViewInternal::bottomOfView
void bottomOfView(bool sel=false)
Definition: kateviewinternal.cpp:1504
KateDocument::paste
void paste(KateView *view, const QString &text)
Definition: katedocument.cpp:2829
KateView::setCaretStyle
void setCaretStyle(KateRenderer::caretStyles style, bool repaint=false)
Set the caret's style.
Definition: kateview.cpp:2413
KateDocument::lineLength
virtual int lineLength(int line) const
Definition: katedocument.cpp:758
QAction::data
QVariant data() const
KateDocument::simpleMode
static bool simpleMode()
Definition: katedocument.cpp:4786
katekeywordcompletion.h
KateViewConfig::setIconBar
void setIconBar(bool on)
Definition: kateconfig.cpp:1602
kateautoindent.h
KateViewInternal::clear
void clear()
Definition: kateviewinternal.cpp:3271
KateSearchBar::searchPattern
QString searchPattern() const
Definition: katesearchbar.cpp:964
KateView::replacementPattern
QString replacementPattern() const
The current replacement string.
Definition: kateview.cpp:2467
KateCommandLineBar::setText
void setText(const QString &text, bool selected=true)
Definition: kateviewhelpers.cpp:839
KateViewConfig::setScrollBarMiniMapAll
void setScrollBarMiniMapAll(bool on)
Definition: kateconfig.cpp:1539
KateView::toggleScrollBarMarks
void toggleScrollBarMarks()
Definition: kateview.cpp:1441
KateViewInternal::top_home
void top_home(bool sel=false)
Definition: kateviewinternal.cpp:1673
KateViewConfig::setLineModification
void setLineModification(bool on)
Definition: kateconfig.cpp:1644
KateHighlighting::getCommentStart
QString getCommentStart(int attrib=0) const
Definition: katehighlight.cpp:1157
KateViewInternal::editSetCursor
void editSetCursor(const KTextEditor::Cursor &cursor)
Definition: kateviewinternal.cpp:3445
KateSpellingMenu::createActions
void createActions(KActionCollection *ac)
Definition: spellingmenu.cpp:95
KateModeMenu
Definition: katemodemenu.h:33
KateView::isAutomaticInvocationEnabled
virtual bool isAutomaticInvocationEnabled() const
Definition: kateview.cpp:2379
QMap< QString, QString >
KateView::setAddBom
void setAddBom(bool enabled)
Definition: kateview.cpp:1404
KateDocument::onTheFlySpellCheckingEnabled
void onTheFlySpellCheckingEnabled(bool enable)
Definition: katedocument.cpp:5148
KateView::shiftWordLeft
void shiftWordLeft()
Definition: kateview.cpp:2649
KateViewInternal::pageUp
void pageUp(bool sel=false, bool half=false)
Definition: kateviewinternal.cpp:1544
KateSearchBar
Definition: katesearchbar.h:47
QMenu::addAction
void addAction(QAction *action)
KateView::toggleWriteLock
void toggleWriteLock()
Definition: kateview.cpp:1515
KateViewInternal::cursorToCoordinate
QPoint cursorToCoordinate(const KTextEditor::Cursor &cursor, bool realCursor=true, bool includeBorder=true) const
Definition: kateviewinternal.cpp:739
KateView::toggleScrollBarMiniMapAll
void toggleScrollBarMiniMapAll()
Definition: kateview.cpp:1461
katedocument.h
KateTemplateHandler
Inserts a template and offers advanced snippet features, like navigation and mirroring.
Definition: katetemplatehandler.h:73
KateView::mouseTrackingEnabled
virtual bool mouseTrackingEnabled() const
Definition: kateview.cpp:2329
KateDocument::documentReload
virtual bool documentReload()
Reloads the current document from disk if possible.
Definition: katedocument.cpp:3806
KateView::wordRight
void wordRight()
Definition: kateview.cpp:2657
KateView::repaintText
void repaintText(bool paintOnlyDirty=false)
Definition: kateview.cpp:1908
KateHighlightingMenu::updateMenu
void updateMenu(KateDocument *doc)
Definition: katehighlightmenu.cpp:66
KateView::lineNumbersOn
bool lineNumbersOn()
Definition: kateview.cpp:1495
KateView::searchPattern
QString searchPattern() const
The current search pattern.
Definition: kateview.cpp:2458
KateView::shiftTopOfView
void shiftTopOfView()
Definition: kateview.cpp:2728
KateView::gotoLine
void gotoLine()
Definition: kateview.cpp:1332
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KateRendererConfig::iconBarColor
const QColor & iconBarColor() const
Definition: kateconfig.cpp:2508
KateDocument::addView
void addView(KTextEditor::View *)
Definition: katedocument.cpp:2524
KateSearchBar::SearchBackward
Definition: katesearchbar.h:73
KateView::showViModeEmulatedCommandBar
void showViModeEmulatedCommandBar()
Definition: kateview.cpp:1560
KateView::readSessionConfig
void readSessionConfig(const KConfigGroup &)
Definition: kateview.cpp:1357
QHBoxLayout
KateView::slotExpandLocal
void slotExpandLocal()
Definition: kateview.cpp:1077
QVariant::value
T value() const
KateView::scrollUp
void scrollUp()
Definition: kateview.cpp:2713
KateGlobal::copyToClipboard
void copyToClipboard(const QString &text)
Copy text to clipboard an remember it in the history.
Definition: kateglobal.cpp:550
KateDictionaryBar::updateData
void updateData()
Definition: katedialogs.cpp:1471
KateView::tagLine
bool tagLine(const KTextEditor::Cursor &virtualCursor)
Definition: kateview.cpp:1878
KateGotoBar
Definition: katedialogs.h:115
KateView::contextMenu
QMenu * contextMenu() const
Definition: kateview.cpp:2844
KateGlobal::self
static KateGlobal * self()
Kate Part Internal stuff ;)
Definition: kateglobal.cpp:465
KateView::forceCompletion
virtual void forceCompletion()
Definition: kateview.cpp:2364
KateViewInternal::wordNext
void wordNext(bool sel=false)
Definition: kateviewinternal.cpp:1148
KateDocument::undoManager
KateUndoManager * undoManager()
Definition: katedocument.h:338
KateView::slotClipboardHistoryChanged
void slotClipboardHistoryChanged()
Definition: kateview.cpp:1259
QPoint
KateView::shiftCursorRight
void shiftCursorRight()
Definition: kateview.cpp:2633
KateRendererConfig::setSelectionColor
void setSelectionColor(const QColor &col)
Definition: kateconfig.cpp:2356
KateLayoutCache::clear
void clear()
Definition: katelayoutcache.cpp:517
QSet::insert
const_iterator insert(const T &value)
KateView::toggleOnTheFlySpellCheck
void toggleOnTheFlySpellCheck(bool b)
Definition: kateview.cpp:3091
QFrame::setFrameStyle
void setFrameStyle(int style)
KateViewInternal::scrollDown
void scrollDown()
Definition: kateviewinternal.cpp:1530
KateIconBorder::lineNumbersOn
bool lineNumbersOn() const
Definition: kateviewhelpers.h:175
KateSearchBar::enterIncrementalMode
void enterIncrementalMode()
Definition: katesearchbar.cpp:1427
KateView::textFolding
Kate::TextFolding & textFolding()
Folding handler for this view.
Definition: kateview.h:574
QBoxLayout::addSpacing
void addSpacing(int size)
katedialogs.h
KateRendererConfig::foldingColor
const QColor & foldingColor() const
Definition: kateconfig.cpp:2529
KateViewInternal::doSmartNewline
void doSmartNewline()
Definition: kateviewinternal.cpp:802
KateView::smartNewline
void smartNewline()
Definition: kateview.cpp:2574
KateIconBorder::foldingMarkersOn
bool foldingMarkersOn() const
Definition: kateviewhelpers.h:177
KateView::setCursorPosition
bool setCursorPosition(KTextEditor::Cursor position)
Definition: kateview.cpp:2418
KateView::toggleDynWordWrap
void toggleDynWordWrap()
Definition: kateview.cpp:1471
KateView::annotationModel
KTextEditor::AnnotationModel * annotationModel() const
Definition: kateview.cpp:3068
KateView::home
void home()
Definition: kateview.cpp:2673
KateDocument::bomSetByUser
void bomSetByUser()
Set that the BOM marker is forced via the tool menu.
Definition: katedocument.cpp:1536
KateView::m_completionWidget
KateCompletionWidget * m_completionWidget
Definition: kateview.h:229
KatePartPluginManager::removeView
void removeView(KTextEditor::View *view)
Definition: katepartpluginmanager.cpp:136
KateView::toggleScrollBarMiniMap
void toggleScrollBarMiniMap()
Definition: kateview.cpp:1451
QContextMenuEvent::globalPos
const QPoint & globalPos() const
KateSpellCheckDialog
Definition: spellcheckdialog.h:49
KateDocument::plainKateTextLine
Kate::TextLine plainKateTextLine(uint i)
Definition: katedocument.cpp:4712
KateView::findSelectedForwards
void findSelectedForwards()
Definition: kateview.cpp:1607
KateDocument::indent
void indent(KTextEditor::Range range, int change)
Definition: katedocument.cpp:2899
KateView::tagRange
bool tagRange(const KTextEditor::Range &range, bool realLines=false)
Definition: kateview.cpp:1883
KateBookmarks
Definition: katebookmarks.h:34
KateView::registerCompletionModel
virtual void registerCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: kateview.cpp:2369
KateView::toggleWWMarker
void toggleWWMarker()
Definition: kateview.cpp:1476
KateDocument::fromVirtualColumn
int fromVirtualColumn(int line, int column) const
Definition: katedocument.cpp:2580
QWidget::update
void update()
spellcheck.h
KateGlobal::clipboardHistory
const QStringList & clipboardHistory() const
Clipboard history, filled with text we ever copied to clipboard via copyToClipboard.
Definition: kateglobal.h:430
KateView::wordLeft
void wordLeft()
Definition: kateview.cpp:2641
KateViewConfig::foldingBar
bool foldingBar() const
Definition: kateconfig.cpp:1615
KateViewConfig::setScrollBarMarks
void setScrollBarMarks(bool on)
Definition: kateconfig.cpp:1497
KateView::top
void top()
Definition: kateview.cpp:2763
KateSnippetGlobal::showDialog
void showDialog(KateView *view)
Show the snippet dialog, used by most simple apps using just KatePart.
Definition: katesnippetglobal.cpp:61
KateView::getViInputModeManager
KateViInputModeManager * getViInputModeManager()
Definition: kateview.cpp:1587
KateViewInternal::doDeletePrevWord
void doDeletePrevWord()
Definition: kateviewinternal.cpp:842
katebookmarks.h
KateDocument::comment
void comment(KateView *view, uint line, uint column, int change)
Definition: katedocument.cpp:3302
Kate::TextFolding::foldRange
bool foldRange(qint64 id)
Fold the given range.
Definition: katetextfolding.cpp:168
QList::size
int size() const
KateView::cursorSelected
bool cursorSelected(const KTextEditor::Cursor &cursor)
Definition: kateview.cpp:2083
kateviewhelpers.h
katebuffer.h
Kate::TextFolding::unfoldRange
bool unfoldRange(qint64 id, bool remove=false)
Unfold the given range.
Definition: katetextfolding.cpp:191
KateDocument::lastLine
int lastLine() const
gets the last line number (lines() - 1)
Definition: katedocument.h:691
KateView::shiftUp
void shiftUp()
Definition: kateview.cpp:2698
KateViewInternal::tagLines
bool tagLines(int start, int end, bool realLines=false)
Definition: kateviewinternal.cpp:2020
KateRendererConfig::lineNumberColor
const QColor & lineNumberColor() const
Definition: kateconfig.cpp:2582
KateViewInternal::doDeleteNextWord
void doDeleteNextWord()
Definition: kateviewinternal.cpp:853
KateSpellCheckDialog::createActions
void createActions(KActionCollection *)
Definition: spellcheckdialog.cpp:62
KateView::setLineNumbersOn
void setLineNumbersOn(bool enable)
Definition: kateview.cpp:1426
KateViewSchemaAction
Definition: kateschema.h:80
KateCompletionWidget::unregisterCompletionModel
void unregisterCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: katecompletionwidget.cpp:1220
KateView::setScrollBarMiniMapWidth
void setScrollBarMiniMapWidth(int width)
Definition: kateview.cpp:1466
KateView::iconBorder
bool iconBorder()
Definition: kateview.cpp:1491
KateHighlightingMenu
Definition: katehighlightmenu.h:30
QStyleOption::initFrom
void initFrom(const QWidget *widget)
KateView::selectionRange
virtual const KTextEditor::Range & selectionRange() const
Definition: kateview.cpp:2815
KSelectAction
KateView::keyReturn
void keyReturn()
Definition: kateview.cpp:2569
KateView::slotUpdateUndo
void slotUpdateUndo()
Definition: kateview.cpp:1264
KateView::visibleRange
KTextEditor::Range visibleRange()
Definition: kateview.cpp:3083
KateViewInternal::cursorToMatchingBracket
void cursorToMatchingBracket(bool sel=false)
Definition: kateviewinternal.cpp:1487
KateDocument::Lowercase
Definition: katedocument.h:734
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:50
QStyleOption
KateView::displayRangeChanged
void displayRangeChanged(KateView *view)
KateView::completionWidget
KateCompletionWidget * completionWidget() const
Definition: kateview.cpp:2346
KateView::toPrevModifiedLine
void toPrevModifiedLine()
Definition: kateview.cpp:2793
KateIconBorder::setIconBorderOn
void setIconBorderOn(bool enable)
Definition: kateviewhelpers.cpp:1291
QString::isRightToLeft
bool isRightToLeft() const
KateView::toNextModifiedLine
void toNextModifiedLine()
Definition: kateview.cpp:2804
KateView::replace
void replace()
Definition: kateview.cpp:1617
KateView::toggleViInputMode
void toggleViInputMode()
Definition: kateview.cpp:1545
KateIconBorder::setFoldingMarkersOn
void setFoldingMarkersOn(bool enable)
Definition: kateviewhelpers.cpp:1377
KateView::setConfigValue
void setConfigValue(const QString &key, const QVariant &value)
Definition: kateview.cpp:2958
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
KateViewConfig::setViInputMode
void setViInputMode(bool on)
Definition: kateconfig.cpp:1806
katemodemenu.h
QString::number
QString number(int n, int base)
KateGlobal::registerView
void registerView(KateView *view)
register view at the factory this allows us to loop over all views for example on config changes ...
Definition: kateglobal.cpp:488
KateView::updateRendererConfig
void updateRendererConfig()
Definition: kateview.cpp:1795
KateView::up
void up()
Definition: kateview.cpp:2693
KateView::viewEditMode
EditMode viewEditMode() const
Definition: kateview.cpp:1137
QList::append
void append(const T &value)
Kate::TextFolding::foldingRangesStartingOnLine
QVector< QPair< qint64, FoldingRangeFlags > > foldingRangesStartingOnLine(int line) const
Queries which folding ranges start at the given line and returns the id + flags for all of them...
Definition: katetextfolding.cpp:476
KateCompletionWidget
This is the code completion's main widget, and also contains the core interface logic.
Definition: katecompletionwidget.h:55
KateView::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *)
Definition: kateview.cpp:1283
QVariant::toUInt
uint toUInt(bool *ok) const
KateViewInternal::cursorNextChar
void cursorNextChar(bool sel=false)
Definition: kateviewinternal.cpp:1100
KateView::transpose
void transpose()
Definition: kateview.cpp:2604
KateView::keyDelete
void keyDelete()
Definition: kateview.cpp:2594
KateView::scrollBarMiniMap
bool scrollBarMiniMap()
Definition: kateview.cpp:1503
KateBookmarks::createActions
void createActions(KActionCollection *)
Definition: katebookmarks.cpp:60
QWidget::setLayout
void setLayout(QLayout *layout)
QObject::installEventFilter
void installEventFilter(QObject *filterObj)
katesnippetglobal.h
QVariant::toInt
int toInt(bool *ok) const
KateView::dictionaryBar
KateDictionaryBar * dictionaryBar()
Definition: kateview.cpp:3041
KateDocument::wrapText
bool wrapText(int startLine, int endLine)
Remove a line.
Definition: katedocument.cpp:855
kateschema.h
KateRenderer::config
KateRendererConfig * config() const
Configuration.
Definition: katerenderer.h:362
QSharedPointer
KateView::slotCollapseLevel
void slotCollapseLevel()
Definition: kateview.cpp:1082
KateView::setSelection
virtual bool setSelection(const KTextEditor::Range &selection)
Definition: kateview.cpp:1956
QApplication::clipboard
QClipboard * clipboard()
KateViewInternal::cursorUp
void cursorUp(bool sel=false)
Definition: kateviewinternal.cpp:1433
KateDocument::transform
void transform(KateView *view, const KTextEditor::Cursor &, TextTransform)
Handling uppercase, lowercase and capitalize for the view.
Definition: katedocument.cpp:3384
KateView::deleteWordRight
void deleteWordRight()
Definition: kateview.cpp:2599
katepartpluginmanager.h
KateView::uppercase
void uppercase()
Uppercases selected text, or an alphabetic character next to the cursor.
Definition: kateview.cpp:2538
QContextMenuEvent
KateSearchBar::updateHighlightColors
void updateHighlightColors()
Definition: katesearchbar.cpp:1562
KateView::lineIsSelection
bool lineIsSelection(int line)
Definition: kateview.cpp:2113
KateView::configChanged
void configChanged()
KateView::shiftCursorLeft
void shiftCursorLeft()
Definition: kateview.cpp:2617
KateView::editEnd
void editEnd(int editTagLineStart, int editTagLineEnd, bool tagFrom)
Definition: kateview.cpp:1866
QWidget::setFocus
void setFocus()
katelayoutcache.h
KateGlobal::snippetGlobal
KateSnippetGlobal * snippetGlobal()
global instance of the snippet handling lazy constructed on first use to allow it to use the session ...
Definition: kateglobal.cpp:253
KateView::scrollBarMiniMapAll
bool scrollBarMiniMapAll()
KateViewInternal::left
Definition: kateviewinternal.h:73
KateIconBorder::setDynWrapIndicators
void setDynWrapIndicators(int state)
Definition: kateviewhelpers.cpp:1364
kateglobal.h
KateViewInternal::tagAll
void tagAll()
Definition: kateviewinternal.cpp:2111
KateView::unregisterCompletionModel
virtual void unregisterCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: kateview.cpp:2374
KateView::cursorToCoordinate
QPoint cursorToCoordinate(const KTextEditor::Cursor &cursor) const
Definition: kateview.cpp:2433
KateViewConfig::viInputModeStealKeys
bool viInputModeStealKeys() const
Definition: kateconfig.cpp:1824
QDropEvent
KateView::topOfView
void topOfView()
Definition: kateview.cpp:2723
KateView::postMessage
void postMessage(KTextEditor::Message *message, QList< QSharedPointer< QAction > > actions)
Used by Document::postMessage().
Definition: kateview.cpp:3254
KateView::writeSessionConfig
void writeSessionConfig(KConfigGroup &)
Definition: kateview.cpp:1370
Kate::TextRange::setView
void setView(KTextEditor::View *view)
Sets the currently active view for this range.
Definition: katetextrange.cpp:243
QList::isEmpty
bool isEmpty() const
KateView::lineSelected
bool lineSelected(int line)
Definition: kateview.cpp:2096
QObject::objectName
objectName
KateViewInternal
Definition: kateviewinternal.h:58
QString::isEmpty
bool isEmpty() const
KateView::toggleComment
void toggleComment()
Definition: kateview.cpp:2531
KateDocumentConfig::eol
int eol() const
Definition: kateconfig.cpp:883
KateIconBorder::setViRelLineNumbersOn
void setViRelLineNumbersOn(bool enable)
Definition: kateviewhelpers.cpp:1341
KateSpellingMenu::setVisible
void setVisible(bool b)
Definition: spellingmenu.cpp:82
KateMessageWidget
This class implements a message widget based on KMessageWidget.
Definition: katemessagewidget.h:42
KateView::shiftToMatchingBracket
void shiftToMatchingBracket()
Definition: kateview.cpp:2788
KateIconBorder::iconBorderOn
bool iconBorderOn() const
Definition: kateviewhelpers.h:174
KateSearchBar::findPrevious
void findPrevious()
Definition: katesearchbar.cpp:268
KateSearchBar::slotReadWriteChanged
void slotReadWriteChanged()
Definition: katesearchbar.cpp:1638
KateDocument::lines
virtual int lines() const
Definition: katedocument.cpp:753
Kate::TextCursor::line
int line() const
Retrieve the line on which this cursor is situated.
Definition: katetextcursor.cpp:132
Kate::TextRange::toRange
const KTextEditor::Range toRange() const
Convert this clever range into a dumb one.
Definition: katetextrange.h:143
KateViewInternal::getMouse
KTextEditor::Cursor getMouse() const
Definition: kateviewinternal.h:192
KateView::insertTemplateTextImplementation
virtual bool insertTemplateTextImplementation(const KTextEditor::Cursor &, const QString &templateString, const QMap< QString, QString > &initialValues)
Definition: kateview.cpp:2275
KateView::cmdLineBar
KateCommandLineBar * cmdLineBar()
Definition: kateview.cpp:3013
QVBoxLayout
KateRendererConfig::setLineNumberColor
void setLineNumberColor(const QColor &col)
Definition: kateconfig.cpp:2590
KateView::completionExecuted
void completionExecuted(KTextEditor::View *view, const KTextEditor::Cursor &position, KTextEditor::CodeCompletionModel *model, const QModelIndex &)
KateViewSchemaAction::updateMenu
void updateMenu(KateView *view)
Definition: kateschema.cpp:88
KateSpellingMenu
Definition: spellingmenu.h:40
katecompletionwidget.h
KateView::toggleInsert
void toggleInsert()
Definition: kateview.cpp:1317
KateView::shiftPageUp
void shiftPageUp()
Definition: kateview.cpp:2748
KateCompletionWidget::registerCompletionModel
void registerCompletionModel(KTextEditor::CodeCompletionModel *model)
Definition: katecompletionwidget.cpp:1203
KateViewInternal::setCaretStyle
void setCaretStyle(KateRenderer::caretStyles style, bool repaint=false)
Set the caret's style.
Definition: kateviewinternal.cpp:1835
kateviewinternal.h
KateViewConfig::lineNumbers
bool lineNumbers() const
Definition: kateconfig.cpp:1468
katesearchbar.h
KateView::toggleIconBorder
void toggleIconBorder()
Definition: kateview.cpp:1421
KateView::insertTab
void insertTab()
Definition: kateview.cpp:2584
QSet< Kate::TextRange * >
KateDocument::undoCount
uint undoCount() const
Definition: katedocument.cpp:1365
Kate::TextFolding::Folded
Range is folded away.
Definition: katetextfolding.h:69
KateViewInternal::end
void end(bool sel=false)
Definition: kateviewinternal.cpp:1232
KateViInputModeManager::writeSessionConfig
void writeSessionConfig(KConfigGroup &config)
Definition: kateviinputmodemanager.cpp:624
KateView::blockSelection
virtual bool blockSelection() const
Definition: kateview.cpp:2221
KateScrollBar::setMiniMapAll
void setMiniMapAll(bool b)
Definition: kateviewhelpers.h:81
ViMode
ViMode
The four vi modes supported by Kate's vi input mode.
Definition: kateviinputmodemanager.h:48
KateRendererConfig::setBackgroundColor
void setBackgroundColor(const QColor &col)
Definition: kateconfig.cpp:2335
QMenu::addSeparator
QAction * addSeparator()
KateView::setReplacementPattern
void setReplacementPattern(const QString &replacementPattern)
Set the current replacement pattern.
Definition: kateview.cpp:2481
KateView::find
void find()
Definition: kateview.cpp:1597
QString
KateViewInternal::editStart
void editStart()
Definition: kateviewinternal.cpp:3379
KateView::foldLine
void foldLine(int startLine)
Try to fold starting at the given line.
Definition: kateview.cpp:1110
QList
QWidget::hide
void hide()
KateViewConfig::setDefaultMarkType
void setDefaultMarkType(uint type)
Definition: kateconfig.cpp:1754
katedocumenthelpers.h
KateDocument::setModified
virtual void setModified(bool m)
Definition: katedocument.cpp:2484
QColor
KateView::configKeys
QStringList configKeys() const
Definition: kateview.cpp:2914
KateView::shiftWordRight
void shiftWordRight()
Definition: kateview.cpp:2665
KateView::killLine
void killLine()
Definition: kateview.cpp:2543
katetemplatehandler.h
KateView::updateConfig
void updateConfig()
Definition: kateview.cpp:1669
KateView::updateRangesIn
void updateRangesIn(KTextEditor::Attribute::ActivationType activationType)
check if ranges changed for mouse in and caret in
Definition: kateview.cpp:3169
KateSearchBar::replacementPattern
QString replacementPattern() const
Definition: katesearchbar.cpp:236
KateView::clear
void clear()
Definition: kateview.cpp:1903
KateView::activateEditActions
void activateEditActions()
Definition: kateview.cpp:2323
KateView::findNext
void findNext()
Definition: kateview.cpp:1627
QLayout::setMargin
void setMargin(int margin)
KateViewInternal::doTabulator
void doTabulator()
Definition: kateviewinternal.cpp:832
KateViewInternal::doDelete
void doDelete()
Definition: kateviewinternal.cpp:822
katewordcompletion.h
KateView::selection
virtual bool selection() const
Definition: kateview.cpp:2033
KateView::setScrollBarMiniMapAll
void setScrollBarMiniMapAll(bool enable)
Definition: kateview.cpp:1456
KateView::delayedUpdateOfView
void delayedUpdateOfView()
Delayed update for view after text ranges changed.
KateSearchBar::SearchForward
Definition: katesearchbar.h:72
KateDocument::Uppercase
Definition: katedocument.h:734
QStringList
KateView::blockFix
static void blockFix(KTextEditor::Range &range)
Definition: kateview.cpp:111
KateView::showSnippetsDialog
void showSnippetsDialog()
Definition: kateview.cpp:726
KatePartPluginManager::self
static KatePartPluginManager * self()
Definition: katepartpluginmanager.cpp:70
KateView::dropEventPass
void dropEventPass(QDropEvent *)
KateViewConfig::iconBar
bool iconBar() const
Definition: kateconfig.cpp:1594
KateIconBorder::annotationModelChanged
void annotationModelChanged(KTextEditor::AnnotationModel *oldmodel, KTextEditor::AnnotationModel *newmodel)
Definition: kateviewhelpers.cpp:2232
KateRendererConfig::setWordWrapMarker
void setWordWrapMarker(bool on)
Definition: kateconfig.cpp:2314
KateView
Definition: kateview.h:77
KateIconBorder::setLineNumbersOn
void setLineNumbersOn(bool enable)
Definition: kateviewhelpers.cpp:1328
KateView::align
void align()
Definition: kateview.cpp:2507
KateView::editStart
void editStart()
Definition: kateview.cpp:1861
KateView::setEol
void setEol(int eol)
Definition: kateview.cpp:1390
KateView::unfoldLine
void unfoldLine(int startLine)
Try to unfold all foldings starting at the given line.
Definition: kateview.cpp:1125
KateView::spellingMenu
KateSpellingMenu * spellingMenu()
Definition: kateview.cpp:3102
KateRenderer::setIndentWidth
void setIndentWidth(int indentWidth)
Sets the width of the tab.
Definition: katerenderer.cpp:130
KateViewInternal::updateDirty
void updateDirty()
Definition: kateviewinternal.cpp:2900
KateView::toggleLineNumbersOn
void toggleLineNumbersOn()
Definition: kateview.cpp:1431
QMenu
QEvent::accept
void accept()
KateView::slotTextInserted
void slotTextInserted(KTextEditor::View *view, const KTextEditor::Cursor &position, const QString &text)
Definition: kateview.cpp:2270
KateView::setSearchPattern
void setSearchPattern(const QString &searchPattern)
Set the current search pattern.
Definition: kateview.cpp:2476
KateView::updateView
void updateView(bool changed=false)
Definition: kateview.cpp:1916
KateView::setMouseTrackingEnabled
virtual bool setMouseTrackingEnabled(bool enable)
Definition: kateview.cpp:2335
KateView::cursorRight
void cursorRight()
Definition: kateview.cpp:2625
KateDocument
Definition: katedocument.h:74
KateViewConfig::setAutomaticCompletionInvocation
void setAutomaticCompletionInvocation(bool on)
Definition: kateconfig.cpp:1889
KateView::joinLines
void joinLines()
Joins lines touched by the selection.
Definition: kateview.cpp:1344
KateView::selectLine
void selectLine(const KTextEditor::Cursor &cursor)
Definition: kateview.cpp:2174
KateViewIndentationAction
This action provides a list of available indenters and gets plugged into the KateView's KActionCollec...
Definition: kateautoindent.h:235
KateView::isAnnotationBorderVisible
bool isAnnotationBorderVisible() const
Definition: kateview.cpp:3078
KateView::cursorLeft
void cursorLeft()
Definition: kateview.cpp:2609
KateViewInternal::doTranspose
void doTranspose()
Definition: kateviewinternal.cpp:837
KateViewConfig::allowMarkMenu
bool allowMarkMenu() const
Definition: kateconfig.cpp:1767
KateView::down
void down()
Definition: kateview.cpp:2703
KateViInputModeManager::readSessionConfig
void readSessionConfig(const KConfigGroup &config)
Definition: kateviinputmodemanager.cpp:588
KateCompletionWidget::userInvokedCompletion
void userInvokedCompletion()
Definition: katecompletionwidget.cpp:1322
QFrame
KateViewInternal::wordPrev
void wordPrev(bool sel=false)
Definition: kateviewinternal.cpp:1105
KateViewInternal::pageDown
void pageDown(bool sel=false, bool half=false)
Definition: kateviewinternal.cpp:1586
KateRenderer::setTabWidth
void setTabWidth(int tabWidth)
Sets the width of the tab.
Definition: katerenderer.cpp:115
KateViewConfig::setFoldingBar
void setFoldingBar(bool on)
Definition: kateconfig.cpp:1623
KateScriptActionMenu
Tools > Scripts menu This menu is filled with the command line scripts exported via the scripting sup...
Definition: katescriptaction.h:55
KateIconBorder::annotationBorderOn
bool annotationBorderOn() const
Definition: kateviewhelpers.h:178
KateBookmarks::Sorting
Sorting
Definition: katebookmarks.h:39
KateSearchBar::nextMatchForSelection
static void nextMatchForSelection(KateView *view, SearchDirection searchDirection)
Definition: katesearchbar.cpp:1237
KateCommandLineBar
Definition: kateviewhelpers.h:414
KateDocument::kateTextLine
Kate::TextLine kateTextLine(uint i)
Definition: katedocument.cpp:4706
QSet::contains
bool contains(const T &value) const
KateRenderer::caretStyles
caretStyles
Style of Caret.
Definition: katerenderer.h:69
KateView::slotFoldToplevelNodes
void slotFoldToplevelNodes()
Definition: kateview.cpp:1062
KateView::reloadFile
void reloadFile()
Definition: kateview.cpp:1219
KateView::pageUp
void pageUp()
Definition: kateview.cpp:2743
Kate::TextFolding::isLineVisible
bool isLineVisible(int line, qint64 *foldedRangeId=0) const
Query if a given line is visible.
Definition: katetextfolding.cpp:281
KateView::capitalize
void capitalize()
Capitalizes the selection (makes each word start with an uppercase) or the word under the cursor...
Definition: kateview.cpp:2561
QWidget::repaint
void repaint()
KateRendererConfig::setSearchHighlightColor
void setSearchHighlightColor(const QColor &col)
Definition: kateconfig.cpp:2695
KateDictionaryBar
Definition: katedialogs.h:135
KateDocumentConfig::indentationWidth
int indentationWidth() const
Definition: kateconfig.cpp:468
KateView::cursorPosition
KTextEditor::Cursor cursorPosition() const
Definition: kateview.cpp:2423
KateView::KateView
KateView(KateDocument *doc, QWidget *parent)
Definition: kateview.cpp:121
KateView::cursorPositionVirtual
KTextEditor::Cursor cursorPositionVirtual() const
Definition: kateview.cpp:2428
KateGotoBar::updateData
void updateData()
Definition: katedialogs.cpp:1408
KateDocument::isComment
bool isComment(int line, int column)
Definition: katedocument.cpp:5511
KateMessageWidget::postMessage
void postMessage(KTextEditor::Message *message, QList< QSharedPointer< QAction > > actions)
Post a new incoming message.
Definition: katemessagewidget.cpp:186
Kate::TextRange::setInsertBehaviors
void setInsertBehaviors(InsertBehaviors insertBehaviors)
Set insert behaviors.
Definition: katetextrange.cpp:68
KateCompletionWidget::isCompletionActive
bool isCompletionActive() const
Definition: katecompletionwidget.cpp:748
KateView::setAnnotationModel
void setAnnotationModel(KTextEditor::AnnotationModel *model)
Definition: kateview.cpp:3061
KateView::removeSelectedText
bool removeSelectedText()
Definition: kateview.cpp:2046
KateViewInternal::getCursor
KTextEditor::Cursor getCursor() const
Definition: kateviewinternal.h:191
Kate::TextBuffer::rangesForLine
QList< TextRange * > rangesForLine(int line, KTextEditor::View *view, bool rangesWithAttributeOnly) const
Return the ranges which affect the given line.
Definition: katetextbuffer.cpp:872
Kate::TextRange::end
const KTextEditor::MovingCursor & end() const
Retrieve end cursor of this range, read-only.
Definition: katetextrange.h:131
KateIconBorder::dynWrapIndicators
int dynWrapIndicators() const
Definition: kateviewhelpers.h:168
Kate::TextBuffer::lines
int lines() const
Lines currently stored in this buffer.
Definition: katetextbuffer.h:189
KateDocumentConfig::setEol
void setEol(int mode)
Definition: kateconfig.cpp:903
KateSearchBar::enterPowerMode
void enterPowerMode()
Definition: katesearchbar.cpp:1285
KatePartPluginManager::addView
void addView(KTextEditor::View *view)
Definition: katepartpluginmanager.cpp:124
QSet::remove
bool remove(const T &value)
QVector
KateViewConfig::automaticCompletionInvocation
bool automaticCompletionInvocation() const
Definition: kateconfig.cpp:1881
KateView::viInputMode
bool viInputMode() const
Definition: kateview.cpp:1530
KateWordCompletionView
Definition: katewordcompletion.h:85
spellingmenu.h
KateView::tagSelection
void tagSelection(const KTextEditor::Range &oldSelection)
Definition: kateview.cpp:2118
KateViewInternal::prepareForDynWrapChange
void prepareForDynWrapChange()
Definition: kateviewinternal.cpp:247
KateViewConfig::viInputMode
bool viInputMode() const
Definition: kateconfig.cpp:1798
KateView::updateViModeBarCmd
void updateViModeBarCmd()
Update vi mode statusbar with the (partial) vi command being typed.
Definition: kateview.cpp:1575
KateViewBar::showBarWidget
void showBarWidget(KateViewBarWidget *barWidget)
Shows barWidget that was previously added with addBarWidget.
Definition: kateviewhelpers.cpp:2542
KateView::uncomment
void uncomment()
Definition: kateview.cpp:2526
KateView::setAnnotationBorderVisible
void setAnnotationBorderVisible(bool visible)
Definition: kateview.cpp:3073
KateHighlighting::getCommentSingleLineStart
QString getCommentSingleLineStart(int attrib=0) const
Definition: katehighlight.cpp:1167
QLatin1String
QKeySequence
KateView::viModeEmulatedCommandBar
KateViEmulatedCommandBar * viModeEmulatedCommandBar()
Definition: kateview.cpp:3051
KateView::m_toggleOnTheFlySpellCheck
KToggleAction * m_toggleOnTheFlySpellCheck
Definition: kateview.h:761
KateView::viewMode
QString viewMode() const
Definition: kateview.cpp:1145
KateView::getCurrentViMode
ViMode getCurrentViMode() const
Definition: kateview.cpp:1582
KateView::resetViInputModeManager
KateViInputModeManager * resetViInputModeManager()
Replace ViInputModeManager by new one.
Definition: kateview.cpp:1592
KateViewInternal::endPos
KTextEditor::Cursor endPos() const
Definition: kateviewinternal.cpp:285
KateView::toMatchingBracket
void toMatchingBracket()
Definition: kateview.cpp:2783
snippetcompletionmodel.h
KateModeMenu::updateMenu
void updateMenu(KTextEditor::Document *doc)
Definition: katemodemenu.cpp:73
KateView::~KateView
~KateView()
Definition: kateview.cpp:304
KateDocument::editEnd
void editEnd()
End a editor operation.
Definition: katedocument.cpp:796
KateSpellingMenu::setUseMouseForMisspelledRange
void setUseMouseForMisspelledRange(bool b)
This method has to be called before the menu is shown in response to a context menu event...
Definition: spellingmenu.cpp:161
KateHighlighting
Definition: katehighlight.h:119
KateViewInternal::disableTextHints
void disableTextHints()
Definition: kateviewinternal.cpp:3370
KateView::switchToCmdLine
void switchToCmdLine()
Definition: kateview.cpp:1652
KateView::findPrevious
void findPrevious()
Definition: kateview.cpp:1632
QAction
KAction
KateCompletionWidget::startCompletion
void startCompletion(KTextEditor::CodeCompletionModel::InvocationType invocationType, const QList< KTextEditor::CodeCompletionModel * > &models=QList< KTextEditor::CodeCompletionModel * >())
Definition: katecompletionwidget.cpp:286
KateView::notifyAboutRangeChange
void notifyAboutRangeChange(int startLine, int endLine, bool rangeWithAttribute)
Attribute of a range changed or range with attribute changed in given line range. ...
Definition: kateview.cpp:3107
KateView::cut
void cut()
Definition: kateview.cpp:2183
Kate::TextRange::setRange
void setRange(const KTextEditor::Range &range)
Set the range of this range.
Definition: katetextrange.cpp:122
KateView::sendCompletionAborted
void sendCompletionAborted()
Definition: kateview.cpp:2394
KateView::deactivateEditActions
void deactivateEditActions()
Definition: kateview.cpp:2317
KateRendererConfig::searchHighlightColor
const QColor & searchHighlightColor() const
Definition: kateconfig.cpp:2687
KateViInputModeManager::isRecordingMacro
bool isRecordingMacro()
Definition: kateviinputmodemanager.cpp:341
KateViewInternal::home
void home(bool sel=false)
Definition: kateviewinternal.cpp:1197
KateView::selectionText
virtual QString selectionText() const
Definition: kateview.cpp:2041
KateDocument::isOnTheFlySpellCheckingEnabled
bool isOnTheFlySpellCheckingEnabled() const
Definition: katedocument.cpp:5167
KateViInputModeManager::modeToString
static QString modeToString(ViMode mode)
convert mode to string representation for user
Definition: kateviinputmodemanager.cpp:886
Kate::TextRange::setZDepth
void setZDepth(qreal zDepth)
Set the current Z-depth of this range.
Definition: katetextrange.cpp:306
KatePasteMenu
Definition: kateviewhelpers.h:482
QString::length
int length() const
KateRendererConfig::backgroundColor
const QColor & backgroundColor() const
Definition: kateconfig.cpp:2327
KateView::ensureCursorColumnValid
void ensureCursorColumnValid()
Definition: kateview.cpp:1845
KateDocument::text
virtual QString text(const KTextEditor::Range &range, bool blockwise=false) const
Definition: katedocument.cpp:337
QVariant::toBool
bool toBool() const
KateView::wrapCursor
bool wrapCursor() const
Definition: kateview.cpp:2262
KateView::setCursorPositionVisual
bool setCursorPositionVisual(const KTextEditor::Cursor &position)
Definition: kateview.cpp:2448
KateView::bottomOfView
void bottomOfView()
Definition: kateview.cpp:2733
KateScrollBar::setMiniMapWidth
void setMiniMapWidth(int width)
Definition: kateviewhelpers.h:84
Kate::TextFolding::newFoldingRange
qint64 newFoldingRange(const KTextEditor::Range &range, FoldingRangeFlags flags=FoldingRangeFlags())
Create a new folding range.
Definition: katetextfolding.cpp:99
KateView::lineHasSelected
bool lineHasSelected(int line)
Definition: kateview.cpp:2108
kateundomanager.h
KateView::setScrollBarMiniMap
void setScrollBarMiniMap(bool enable)
Definition: kateview.cpp:1446
KateView::virtualCursorColumn
int virtualCursorColumn() const
Return the virtual cursor column, each tab is expanded into the document's tabWidth characters...
Definition: kateview.cpp:1944
KateViewConfig::setLineNumbers
void setLineNumbers(bool on)
Definition: kateconfig.cpp:1476
KateViewConfig::dynWordWrap
bool dynWordWrap() const
Definition: kateconfig.cpp:1405
KateView::toggleFoldingMarkers
void toggleFoldingMarkers()
Definition: kateview.cpp:1486
KateView::setScrollBarMarks
void setScrollBarMarks(bool enable)
Definition: kateview.cpp:1436
KateRendererConfig::setIconBarColor
void setIconBarColor(const QColor &col)
Definition: kateconfig.cpp:2516
KateView::setBlockSelection
virtual bool setBlockSelection(bool on)
Definition: kateview.cpp:2226
KateBookmarks::setSorting
void setSorting(Sorting s)
Definition: katebookmarks.h:46
KateScrollBar::setShowMiniMap
void setShowMiniMap(bool b)
Definition: kateviewhelpers.cpp:131
KateScrollBar::setShowMarks
void setShowMarks(bool b)
Definition: kateviewhelpers.h:75
KateView::doc
KateDocument * doc()
accessor to katedocument pointer
Definition: kateview.h:553
KateDocument::toVirtualColumn
int toVirtualColumn(int line, int column) const
Definition: katedocument.cpp:2565
KateView::abortCompletion
virtual void abortCompletion()
Definition: kateview.cpp:2359
KateView::configValue
QVariant configValue(const QString &key)
Definition: kateview.cpp:2923
QBoxLayout::insertWidget
void insertWidget(int index, QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
KateSnippetGlobal::createSnippet
void createSnippet(KateView *view)
Create snippet for given view, e.g.
Definition: katesnippetglobal.cpp:132
KateViewConfig::defaultMarkType
uint defaultMarkType() const
Definition: kateconfig.cpp:1746
KateViewInternal::enableTextHints
void enableTextHints(int timeout)
Definition: kateviewinternal.cpp:3359
KateView::tagAll
void tagAll()
Definition: kateview.cpp:1898
KateView::viInputModeStealKeys
bool viInputModeStealKeys() const
Definition: kateview.cpp:1535
KateDocument::Capitalize
Definition: katedocument.h:734
KateView::editSetCursor
void editSetCursor(const KTextEditor::Cursor &cursor)
Definition: kateview.cpp:1871
KateViewConfig
Definition: kateconfig.h:381
KateDocument::readOnly
bool readOnly() const
Definition: katedocument.h:138
KateViewConfig::setScrollBarMiniMapWidth
void setScrollBarMiniMapWidth(int width)
Definition: kateconfig.cpp:1560
KateViewInternal::tagLine
bool tagLine(const KTextEditor::Cursor &virtualCursor)
Definition: kateviewinternal.cpp:2004
katescriptaction.h
KateView::isOverwriteMode
bool isOverwriteMode() const
Return values for "save" related commands.
Definition: kateview.cpp:1214
KateDocument::redoCount
uint redoCount() const
Definition: katedocument.cpp:1370
KateView::reflectOnTheFlySpellCheckStatus
void reflectOnTheFlySpellCheckStatus(bool enabled)
Definition: kateview.cpp:3096
KateView::coordinatesToCursor
KTextEditor::Cursor coordinatesToCursor(const QPoint &coord) const
Definition: kateview.cpp:2438
Kate::TextRange::attribute
KTextEditor::Attribute::Ptr attribute() const
Gets the active Attribute for this range.
Definition: katetextrange.h:173
KateViewEncodingAction
Definition: kateviewhelpers.h:250
KateViewInternal::cursorDown
void cursorDown(bool sel=false)
Definition: kateviewinternal.cpp:1460
KateView::slotCollapseLocal
void slotCollapseLocal()
Definition: kateview.cpp:1072
KateRendererConfig::setReplaceHighlightColor
void setReplaceHighlightColor(const QColor &col)
Definition: kateconfig.cpp:2716
KateView::lineEndSelected
bool lineEndSelected(const KTextEditor::Cursor &lineEndPos)
Definition: kateview.cpp:2101
KateView::slotReadWriteChanged
void slotReadWriteChanged()
Definition: kateview.cpp:1225
katescriptmanager.h
KateView::createSnippet
void createSnippet()
Definition: kateview.cpp:721
KateDocument::editStart
void editStart()
Enclose editor actions with editStart() and editEnd() to group them.
Definition: katedocument.cpp:776
KateViewConfig::setAllowMarkMenu
void setAllowMarkMenu(bool allow)
Definition: kateconfig.cpp:1772
QVariant::type
Type type() const
KateView::shiftBottomOfView
void shiftBottomOfView()
Definition: kateview.cpp:2738
KateDocument::removeView
void removeView(KTextEditor::View *)
removes the view from the list of views.
Definition: katedocument.cpp:2541
KateView::cursorPositionCoordinates
QPoint cursorPositionCoordinates() const
Definition: kateview.cpp:2443
KateViewConfig::setDynWordWrap
void setDynWordWrap(bool wrap)
Definition: kateconfig.cpp:1413
KateViewBar
Definition: kateviewhelpers.h:325
KateDocumentConfig::setBom
void setBom(bool bom)
Definition: kateconfig.cpp:916
KateView::shiftTop
void shiftTop()
Definition: kateview.cpp:2768
KateView::currentTextLine
QString currentTextLine()
Definition: kateview.cpp:2453
KateView::viRelativeLineNumbers
bool viRelativeLineNumbers() const
Definition: kateview.cpp:1540
KateCompletionWidget::abortCompletion
void abortCompletion()
Definition: katecompletionwidget.cpp:753
QVector::size
int size() const
KateSearchBar::findNext
void findNext()
Definition: katesearchbar.cpp:254
katemessagewidget.h
KateTemplateScript
Definition: katetemplatescript.h:28
KateDocumentConfig::tabWidth
int tabWidth() const
Definition: kateconfig.cpp:444
Kate::TextFolding::importFoldingRanges
void importFoldingRanges(const QVariantList &folds)
Import the folding ranges given as a QVariantList like read from configs.
Definition: katetextfolding.cpp:905
KateView::config
KateViewConfig * config()
Configuration.
Definition: kateview.h:653
KateHighlighting::isInWord
bool isInWord(QChar c, int attrib=0) const
Definition: katehighlight.cpp:1122
KateView::setIconBorder
void setIconBorder(bool enable)
Definition: kateview.cpp:1416
KateView::setFoldingMarkersOn
void setFoldingMarkersOn(bool enable)
Definition: kateview.cpp:1481
kateviglobal.h
KateHighlighting::allowsFolding
bool allowsFolding()
Definition: katehighlight.h:408
KateView::updateDocumentConfig
void updateDocumentConfig()
Definition: kateview.cpp:1769
kateconfig.h
KateView::scrollDown
void scrollDown()
Definition: kateview.cpp:2718
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Kate::TextFolding::exportFoldingRanges
QVariantList exportFoldingRanges() const
Return the current known folding ranges a QVariantList to store in configs.
Definition: katetextfolding.cpp:874
KateDocument::joinLines
void joinLines(uint first, uint last)
Unwrap a range of lines.
Definition: katedocument.cpp:3497
KateView::setCursorPositionInternal
bool setCursorPositionInternal(const KTextEditor::Cursor &position, uint tabwidth=1, bool calledExternally=false)
Definition: kateview.cpp:1293
KateViewInternal::cursorCoordinates
QPoint cursorCoordinates(bool includeBorder=true) const
Definition: kateviewinternal.cpp:767
Kate::TextRange
Class representing a 'clever' text range.
Definition: katetextrange.h:46
KateViewInternal::scrollUp
void scrollUp()
Definition: kateviewinternal.cpp:1524
KateView::lowercase
void lowercase()
Lowercases selected text, or an alphabetic character next to the cursor.
Definition: kateview.cpp:2556
KateDocument::findModifiedLine
int findModifiedLine(int startLine, bool down)
Definition: katedocument.cpp:5517
KateView::changeDictionary
void changeDictionary()
Definition: kateview.cpp:1338
KateView::completionAborted
void completionAborted(KTextEditor::View *view)
KateViEmulatedCommandBar
A KateViewBarWidget that attempts to emulate some of the features of Vim's own command bar...
Definition: kateviemulatedcommandbar.h:40
KateView::setContextMenu
void setContextMenu(QMenu *menu)
Definition: kateview.cpp:2829
KateDocument::removeText
virtual bool removeText(const KTextEditor::Range &range, bool block=false)
Definition: katedocument.cpp:633
QAction::setEnabled
void setEnabled(bool)
KateView::shiftPageDown
void shiftPageDown()
Definition: kateview.cpp:2758
KateViewInternal::bottom_end
void bottom_end(bool sel=false)
Definition: kateviewinternal.cpp:1685
KateCompletionWidget::execute
void execute()
Definition: katecompletionwidget.cpp:797
QBoxLayout::setSpacing
void setSpacing(int spacing)
KateViewInternal::dynWrapChanged
void dynWrapChanged()
Definition: kateviewinternal.cpp:253
KateViewConfig::setScrollBarMiniMap
void setScrollBarMiniMap(bool on)
Definition: kateconfig.cpp:1518
KateDocument::browserView
bool browserView() const
Definition: katedocument.h:139
KateViewConfig::setDynWordWrapIndicators
void setDynWordWrapIndicators(int mode)
Definition: kateconfig.cpp:1434
KateView::pageDown
void pageDown()
Definition: kateview.cpp:2753
KateViewInternal::coordinatesToCursor
KTextEditor::Cursor coordinatesToCursor(const QPoint &coord, bool includeBorder=true) const
Definition: kateviewinternal.cpp:2791
KateView::paste
void paste(const QString *textToPaste=0)
Definition: kateview.cpp:2399
KateView::topViewBar
KateViewBar * topViewBar() const
Accessors to the bars...
Definition: kateview.cpp:3003
KateView::copy
void copy() const
Definition: kateview.cpp:2194
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
KateGlobal::scriptManager
KateScriptManager * scriptManager()
Global script collection.
Definition: kateglobal.h:321
KateDocumentConfig::bom
bool bom() const
Definition: kateconfig.cpp:929
KateViewConfig::global
static KateViewConfig * global()
Definition: kateconfig.h:402
KateView::shiftEnd
void shiftEnd()
Definition: kateview.cpp:2688
KateScriptManager::templateScript
KateTemplateScript * templateScript(KTextEditor::TemplateScript *templateScript)
Definition: katescriptmanager.cpp:410
QVariant
KateView::unIndent
void unIndent()
Definition: kateview.cpp:2493
KateView::setAutomaticInvocationEnabled
virtual void setAutomaticInvocationEnabled(bool enabled=true)
Definition: kateview.cpp:2384
KateView::indent
void indent()
Definition: kateview.cpp:2486
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal