| # kate Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kateview.cpp

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
    00003    Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
    00004    Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org>
    00005    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
    00006    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
    00007
    00008    This library is free software; you can redistribute it and/or
    00009    modify it under the terms of the GNU Library General Public
    00010    License version 2 as published by the Free Software Foundation.
    00011
    00012    This library is distributed in the hope that it will be useful,
    00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015    Library General Public License for more details.
    00016
    00017    You should have received a copy of the GNU Library General Public License
    00018    along with this library; see the file COPYING.LIB.  If not, write to
    00019    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00020    Boston, MA 02111-1307, USA.
    00021 */
    00022
    00023 //BEGIN includes
    00024 #include "kateview.h"
    00025 #include "kateview.moc"
    00026
    00027 #include "kateviewinternal.h"
    00028 #include "kateviewhelpers.h"
    00029 #include "katerenderer.h"
    00030 #include "katedocument.h"
    00031 #include "katedocumenthelpers.h"
    00032 #include "katefactory.h"
    00033 #include "katehighlight.h"
    00034 #include "katedialogs.h"
    00035 #include "katetextline.h"
    00036 #include "katecodefoldinghelpers.h"
    00037 #include "katecodecompletion.h"
    00038 #include "katesearch.h"
    00039 #include "kateschema.h"
    00040 #include "katebookmarks.h"
    00041 #include "katesearch.h"
    00042 #include "kateconfig.h"
    00043 #include "katefiletype.h"
    00044 #include "kateautoindent.h"
    00045
    00046 #include <ktexteditor/plugin.h>
    00047
    00048 #include <kparts/event.h>
    00049
    00050 #include <kconfig.h>
    00051 #include <kurldrag.h>
    00052 #include <kdebug.h>
    00053 #include <kapplication.h>
    00054 #include <kcursor.h>
    00055 #include <klocale.h>
    00056 #include <kglobal.h>
    00057 #include <kcharsets.h>
    00058 #include <kmessagebox.h>
    00059 #include <kaction.h>
    00060 #include <kstdaction.h>
    00061 #include <kxmlguifactory.h>
    00062 #include <kaccel.h>
    00063 #include <klibloader.h>
    00064 #include <kencodingfiledialog.h>
    00065
    00066 #include <qfont.h>
    00067 #include <qfileinfo.h>
    00068 #include <qstyle.h>
    00069 #include <qevent.h>
    00070 #include <qpopupmenu.h>
    00071 #include <qlayout.h>
    00072 #include <qclipboard.h>
    00073 //END includes
    00074
    00075 KateView::KateView( KateDocument *doc, QWidget *parent, const char * name )
    00076     : Kate::View( doc, parent, name )
    00077     , m_doc( doc )
    00078     , m_search( new KateSearch( this ) )
    00079     , m_bookmarks( new KateBookmarks( this ) )
    00080     , m_cmdLine (0)
    00081     , m_cmdLineOn (false)
    00082     , m_active( false )
    00083     , m_hasWrap( false )
    00084     , m_startingUp (true)
    00085     , m_updatingDocumentConfig (false)
    00086 {
    00087   KateFactory::self()->registerView( this );
    00088   m_config = new KateViewConfig (this);
    00089
    00090   m_renderer = new KateRenderer(doc, this);
    00091
    00092   m_grid = new QGridLayout (this, 3, 3);
    00093
    00094   m_grid->setRowStretch ( 0, 10 );
    00095   m_grid->setRowStretch ( 1, 0 );
    00096   m_grid->setColStretch ( 0, 0 );
    00097   m_grid->setColStretch ( 1, 10 );
    00098   m_grid->setColStretch ( 2, 0 );
    00099
    00100   m_viewInternal = new KateViewInternal( this, doc );
    00101   m_grid->addWidget (m_viewInternal, 0, 1);
    00102
    00103   setClipboardInterfaceDCOPSuffix (viewDCOPSuffix());
    00104   setCodeCompletionInterfaceDCOPSuffix (viewDCOPSuffix());
    00105   setDynWordWrapInterfaceDCOPSuffix (viewDCOPSuffix());
    00106   setPopupMenuInterfaceDCOPSuffix (viewDCOPSuffix());
    00107   setSessionConfigInterfaceDCOPSuffix (viewDCOPSuffix());
    00108   setViewCursorInterfaceDCOPSuffix (viewDCOPSuffix());
    00109   setViewStatusMsgInterfaceDCOPSuffix (viewDCOPSuffix());
    00110
    00111   setInstance( KateFactory::self()->instance() );
    00112   doc->addView( this );
    00113
    00114   setFocusProxy( m_viewInternal );
    00115   setFocusPolicy( StrongFocus );
    00116
    00117   if (!doc->singleViewMode()) {
    00118     setXMLFile( "katepartui.rc" );
    00119   } else {
    00120     if( doc->readOnly() )
    00121       setXMLFile( "katepartreadonlyui.rc" );
    00122     else
    00123       setXMLFile( "katepartui.rc" );
    00124   }
    00125
    00126   setupConnections();
    00127   setupActions();
    00128   setupEditActions();
    00129   setupCodeFolding();
    00130   setupCodeCompletion();
    00131
    00132   // enable the plugins of this view
    00133   m_doc->enableAllPluginsGUI (this);
    00134
    00135   // update the enabled state of the undo/redo actions...
    00136   slotNewUndo();
    00137
    00138   m_startingUp = false;
    00139   updateConfig ();
    00140
    00141   m_viewInternal->show ();
    00142   slotHlChanged();
    00143   /*test texthint
    00144   connect(this,SIGNAL(needTextHint(int, int, QString &)),
    00145   this,SLOT(slotNeedTextHint(int, int, QString &)));
    00146   enableTextHints(1000);
    00147   test texthint*/
    00148 }
    00149
    00150 KateView::~KateView()
    00151 {
    00152   if (!m_doc->singleViewMode())
    00153     m_doc->disableAllPluginsGUI (this);
    00154
    00155   m_doc->removeView( this );
    00156
    00157   delete m_viewInternal;
    00158   delete m_codeCompletion;
    00159
    00160   delete m_renderer;
    00161
    00162   delete m_config;
    00163   KateFactory::self()->deregisterView (this);
    00164 }
    00165
    00166 void KateView::setupConnections()
    00167 {
    00168   connect( m_doc, SIGNAL(undoChanged()),
    00169            this, SLOT(slotNewUndo()) );
    00170   connect( m_doc, SIGNAL(hlChanged()),
    00171            this, SLOT(slotHlChanged()) );
    00172   connect( m_doc, SIGNAL(canceled(const QString&)),
    00173            this, SLOT(slotSaveCanceled(const QString&)) );
    00174   connect( m_viewInternal, SIGNAL(dropEventPass(QDropEvent*)),
    00175            this,           SIGNAL(dropEventPass(QDropEvent*)) );
    00176   connect(this,SIGNAL(cursorPositionChanged()),this,SLOT(slotStatusMsg()));
    00177   connect(this,SIGNAL(newStatus()),this,SLOT(slotStatusMsg()));
    00178   connect(m_doc, SIGNAL(undoChanged()), this, SLOT(slotStatusMsg()));
    00179
    00180   if ( m_doc->browserView() )
    00181   {
    00182     connect( this, SIGNAL(dropEventPass(QDropEvent*)),
    00183              this, SLOT(slotDropEventPass(QDropEvent*)) );
    00184   }
    00185 }
    00186
    00187 void KateView::setupActions()
    00188 {
    00189   KActionCollection *ac = this->actionCollection ();
    00190   KAction *a;
    00191
    00192   m_toggleWriteLock = 0;
    00193
    00194   m_cut = a=KStdAction::cut(this, SLOT(cut()), ac);
    00195   a->setWhatsThis(i18n("Cut the selected text and move it to the clipboard"));
    00196
    00197   m_paste = a=KStdAction::pasteText(this, SLOT(paste()), ac);
    00198   a->setWhatsThis(i18n("Paste previously copied or cut clipboard contents"));
    00199
    00200   m_copy = a=KStdAction::copy(this, SLOT(copy()), ac);
    00201   a->setWhatsThis(i18n( "Use this command to copy the currently selected text to the system clipboard."));
    00202
    00203
    00204   if (!m_doc->readOnly())
    00205   {
    00206     KStdAction::spelling( m_doc, SLOT(spellcheck()), ac );
    00207     a = new KAction( i18n("Spelling (from cursor)..."), "spellcheck", 0, this, SLOT(spellcheckFromCursor()), ac, "tools_spelling_from_cursor" );
    00208     a->setWhatsThis(i18n("Check the document's spelling from the cursor and forward"));
    00209
    00210     m_spellcheckSelection = new KAction( i18n("Spellcheck Selection..."), "spellcheck", 0, this, SLOT(spellcheckSelection()), ac, "tools_spelling_selection" );
    00211     m_spellcheckSelection->setWhatsThis(i18n("Check spelling of the selected text"));
    00212
    00213     a=KStdAction::save(this, SLOT(save()), ac);
    00214     a->setWhatsThis(i18n("Save the current document"));
    00215
    00216     a=m_editUndo = KStdAction::undo(m_doc, SLOT(undo()), ac);
    00217     a->setWhatsThis(i18n("Revert the most recent editing actions"));
    00218
    00219     a=m_editRedo = KStdAction::redo(m_doc, SLOT(redo()), ac);
    00220     a->setWhatsThis(i18n("Revert the most recent undo operation"));
    00221
    00222     (new KAction(i18n("&Word Wrap Document"), "", 0, m_doc, SLOT(applyWordWrap()), ac, "tools_apply_wordwrap"))->setWhatsThis(
    00223   i18n("Use this command to wrap all lines of the current document which are longer than the width of the"
    00224     " current view, to fit into this view.<br><br> This is a static word wrap, meaning it is not updated"
    00225     " when the view is resized."));
    00226
    00227     // setup Tools menu
    00228     a=new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), ac, "tools_indent");
    00229     a->setWhatsThis(i18n("Use this to indent a selected block of text.<br><br>"
    00230         "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
    00231     a=new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::SHIFT+Qt::Key_I, this, SLOT(unIndent()), ac, "tools_unindent");
    00232     a->setWhatsThis(i18n("Use this to unindent a selected block of text."));
    00233
    00234     a=new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), ac, "tools_cleanIndent");
    00235     a->setWhatsThis(i18n("Use this to clean the indentation of a selected block of text (only tabs/only spaces)<br><br>"
    00236         "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
    00237
    00238     a=new KAction(i18n("&Align"), 0, this, SLOT(align()), ac, "tools_align");
    00239     a->setWhatsThis(i18n("Use this to align the current line or block of text to its proper indent level."));
    00240
    00241     a=new KAction(i18n("C&omment"), CTRL+Qt::Key_D, this, SLOT(comment()),
    00242         ac, "tools_comment");
    00243     a->setWhatsThis(i18n("This command comments out the current line or a selected block of text.<BR><BR>"
    00244         "The characters for single/multiple line comments are defined within the language's highlighting."));
    00245
    00246     a=new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_D, this, SLOT(uncomment()),
    00247                                  ac, "tools_uncomment");
    00248     a->setWhatsThis(i18n("This command removes comments from the current line or a selected block of text.<BR><BR>"
    00249     "The characters for single/multiple line comments are defined within the language's highlighting."));
    00250     a = m_toggleWriteLock = new KToggleAction(
    00251                 i18n("&Read Only Mode"), 0, 0,
    00252                 this, SLOT( toggleWriteLock() ),
    00253                 ac, "tools_toggle_write_lock" );
    00254     a->setWhatsThis( i18n("Lock/unlock the document for writing") );
    00255
    00256     a = new KAction( i18n("Uppercase"), CTRL + Qt::Key_U, this,
    00257       SLOT(uppercase()), ac, "tools_uppercase" );
    00258     a->setWhatsThis( i18n("Convert the selection to uppercase, or the character to the "
    00259       "right of the cursor if no text is selected.") );
    00260
    00261     a = new KAction( i18n("Lowercase"), CTRL + SHIFT + Qt::Key_U, this,
    00262       SLOT(lowercase()), ac, "tools_lowercase" );
    00263     a->setWhatsThis( i18n("Convert the selection to lowercase, or the character to the "
    00264       "right of the cursor if no text is selected.") );
    00265
    00266     a = new KAction( i18n("Capitalize"), CTRL + ALT + Qt::Key_U, this,
    00267       SLOT(capitalize()), ac, "tools_capitalize" );
    00268     a->setWhatsThis( i18n("Capitalize the selection, or the word under the "
    00269       "cursor if no text is selected.") );
    00270
    00271     a = new KAction( i18n("Join Lines"), CTRL + Qt::Key_J, this,
    00272       SLOT( joinLines() ), ac, "tools_join_lines" );
    00273   }
    00274   else
    00275   {
    00276     m_cut->setEnabled (false);
    00277     m_paste->setEnabled (false);
    00278     m_editUndo = 0;
    00279     m_editRedo = 0;
    00280   }
    00281
    00282   a=KStdAction::print( m_doc, SLOT(print()), ac );
    00283   a->setWhatsThis(i18n("Print the current document."));
    00284
    00285   a=new KAction(i18n("Reloa&d"), "reload", KStdAccel::reload(), this, SLOT(reloadFile()), ac, "file_reload");
    00286   a->setWhatsThis(i18n("Reload the current document from disk."));
    00287
    00288   a=KStdAction::saveAs(this, SLOT(saveAs()), ac);
    00289   a->setWhatsThis(i18n("Save the current document to disk, with a name of your choice."));
    00290
    00291   a=KStdAction::gotoLine(this, SLOT(gotoLine()), ac);
    00292   a->setWhatsThis(i18n("This command opens a dialog and lets you choose a line that you want the cursor to move to."));
    00293
    00294   a=new KAction(i18n("&Configure Editor..."), 0, m_doc, SLOT(configDialog()),ac, "set_confdlg");
    00295   a->setWhatsThis(i18n("Configure various aspects of this editor."));
    00296
    00297   m_setHighlight = m_doc->hlActionMenu (i18n("&Highlighting"),ac,"set_highlight");
    00298
    00299   m_setFileType = new KateViewFileTypeAction (i18n("&Filetype"),ac,"set_filetype");
    00300   m_setFileType->updateMenu (m_doc);
    00301
    00302   m_schemaMenu = new KateViewSchemaAction (i18n("&Schema"),ac,"view_schemas");
    00303   m_schemaMenu->updateMenu (this);
    00304
    00305   // indentation menu
    00306   new KateViewIndentationAction (m_doc, i18n("&Indentation"),ac,"tools_indentation");
    00307
    00308   m_doc->exportActionMenu (i18n("E&xport"),ac,"file_export");
    00309
    00310   m_selectAll = a=KStdAction::selectAll(m_doc, SLOT(selectAll()), ac);
    00311   a->setWhatsThis(i18n("Select the entire text of the current document."));
    00312
    00313   m_deSelect = a=KStdAction::deselect(m_doc, SLOT(clearSelection()), ac);
    00314   a->setWhatsThis(i18n("If you have selected something within the current document, this will no longer be selected."));
    00315
    00316   a=new KAction(i18n("Enlarge Font"), "viewmag+", 0, m_viewInternal, SLOT(slotIncFontSizes()), ac, "incFontSizes");
    00317   a->setWhatsThis(i18n("This increases the display font size."));
    00318
    00319   a=new KAction(i18n("Shrink Font"), "viewmag-", 0, m_viewInternal, SLOT(slotDecFontSizes()), ac, "decFontSizes");
    00320   a->setWhatsThis(i18n("This decreases the display font size."));
    00321
    00322   a= m_toggleBlockSelection = new KToggleAction(
    00323     i18n("Bl&ock Selection Mode"), CTRL + SHIFT + Key_B,
    00324     this, SLOT(toggleBlockSelectionMode()),
    00325     ac, "set_verticalSelect");
    00326   a->setWhatsThis(i18n("This command allows switching between the normal (line based) selection mode and the block selection mode."));
    00327
    00328   a= m_toggleInsert = new KToggleAction(
    00329     i18n("Overwr&ite Mode"), Key_Insert,
    00330     this, SLOT(toggleInsert()),
    00331     ac, "set_insert" );
    00332   a->setWhatsThis(i18n("Choose whether you want the text you type to be inserted or to overwrite existing text."));
    00333
    00334   KToggleAction *toggleAction;
    00335    a= m_toggleDynWrap = toggleAction = new KToggleAction(
    00336     i18n("&Dynamic Word Wrap"), Key_F10,
    00337     this, SLOT(toggleDynWordWrap()),
    00338     ac, "view_dynamic_word_wrap" );
    00339   a->setWhatsThis(i18n("If this option is checked, the text lines will be wrapped at the view border on the screen."));
    00340
    00341   a= m_setDynWrapIndicators = new KSelectAction(i18n("Dynamic Word Wrap Indicators"), 0, ac, "dynamic_word_wrap_indicators");
    00342   a->setWhatsThis(i18n("Choose when the Dynamic Word Wrap Indicators should be displayed"));
    00343
    00344   connect(m_setDynWrapIndicators, SIGNAL(activated(int)), this, SLOT(setDynWrapIndicators(int)));
    00345   QStringList list2;
    00346   list2.append(i18n("&Off"));
    00347   list2.append(i18n("Follow &Line Numbers"));
    00348   list2.append(i18n("&Always On"));
    00349   m_setDynWrapIndicators->setItems(list2);
    00350
    00351   a= toggleAction=m_toggleFoldingMarkers = new KToggleAction(
    00352     i18n("Show Folding &Markers"), Key_F9,
    00353     this, SLOT(toggleFoldingMarkers()),
    00354     ac, "view_folding_markers" );
    00355   a->setWhatsThis(i18n("You can choose if the codefolding marks should be shown, if codefolding is possible."));
    00356   toggleAction->setCheckedState(i18n("Hide Folding &Markers"));
    00357
    00358    a= m_toggleIconBar = toggleAction = new KToggleAction(
    00359     i18n("Show &Icon Border"), Key_F6,
    00360     this, SLOT(toggleIconBorder()),
    00361     ac, "view_border");
    00362   a=toggleAction;
    00363   a->setWhatsThis(i18n("Show/hide the icon border.<BR><BR> The icon border shows bookmark symbols, for instance."));
    00364   toggleAction->setCheckedState(i18n("Hide &Icon Border"));
    00365
    00366   a= toggleAction=m_toggleLineNumbers = new KToggleAction(
    00367      i18n("Show &Line Numbers"), Key_F11,
    00368      this, SLOT(toggleLineNumbersOn()),
    00369      ac, "view_line_numbers" );
    00370   a->setWhatsThis(i18n("Show/hide the line numbers on the left hand side of the view."));
    00371   toggleAction->setCheckedState(i18n("Hide &Line Numbers"));
    00372
    00373   a= m_toggleScrollBarMarks = toggleAction = new KToggleAction(
    00374      i18n("Show Scroll&bar Marks"), 0,
    00375      this, SLOT(toggleScrollBarMarks()),
    00376      ac, "view_scrollbar_marks");
    00377   a->setWhatsThis(i18n("Show/hide the marks on the vertical scrollbar.<BR><BR>The marks, for instance, show bookmarks."));
    00378   toggleAction->setCheckedState(i18n("Hide Scroll&bar Marks"));
    00379
    00380   a = toggleAction = m_toggleWWMarker = new KToggleAction(
    00381         i18n("Show Static &Word Wrap Marker"), 0,
    00382         this, SLOT( toggleWWMarker() ),
    00383         ac, "view_word_wrap_marker" );
    00384   a->setWhatsThis( i18n(
    00385         "Show/hide the Word Wrap Marker, a vertical line drawn at the word "
    00386         "wrap column as defined in the editing properties" ));
    00387   toggleAction->setCheckedState(i18n("Hide Static &Word Wrap Marker"));
    00388
    00389   a= m_switchCmdLine = new KAction(
    00390      i18n("Switch to Command Line"), Key_F7,
    00391      this, SLOT(switchToCmdLine()),
    00392      ac, "switch_to_cmd_line" );
    00393   a->setWhatsThis(i18n("Show/hide the command line on the bottom of the view."));
    00394
    00395   a=m_setEndOfLine = new KSelectAction(i18n("&End of Line"), 0, ac, "set_eol");
    00396   a->setWhatsThis(i18n("Choose which line endings should be used, when you save the document"));
    00397   QStringList list;
    00398   list.append("&UNIX");
    00399   list.append("&Windows/DOS");
    00400   list.append("&Macintosh");
    00401   m_setEndOfLine->setItems(list);
    00402   m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
    00403   connect(m_setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int)));
    00404
    00405   // encoding menu
    00406   new KateViewEncodingAction (m_doc, this, i18n("E&ncoding"), ac, "set_encoding");
    00407
    00408   m_search->createActions( ac );
    00409   m_bookmarks->createActions( ac );
    00410
    00411   selectionChanged ();
    00412
    00413   connect (m_doc, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
    00414 }
    00415
    00416 void KateView::setupEditActions()
    00417 {
    00418   m_editActions = new KActionCollection( m_viewInternal, this, "edit_actions" );
    00419   KActionCollection* ac = m_editActions;
    00420
    00421   new KAction(
    00422     i18n("Move Word Left"),                         CTRL + Key_Left,
    00423     this,SLOT(wordLeft()),
    00424     ac, "word_left" );
    00425   new KAction(
    00426     i18n("Select Character Left"),          SHIFT +        Key_Left,
    00427     this,SLOT(shiftCursorLeft()),
    00428     ac, "select_char_left" );
    00429   new KAction(
    00430     i18n("Select Word Left"),               SHIFT + CTRL + Key_Left,
    00431     this, SLOT(shiftWordLeft()),
    00432     ac, "select_word_left" );
    00433
    00434   new KAction(
    00435     i18n("Move Word Right"),                        CTRL + Key_Right,
    00436     this, SLOT(wordRight()),
    00437     ac, "word_right" );
    00438   new KAction(
    00439     i18n("Select Character Right"),         SHIFT        + Key_Right,
    00440     this, SLOT(shiftCursorRight()),
    00441     ac, "select_char_right" );
    00442   new KAction(
    00443     i18n("Select Word Right"),              SHIFT + CTRL + Key_Right,
    00444     this,SLOT(shiftWordRight()),
    00445     ac, "select_word_right" );
    00446
    00447   new KAction(
    00448     i18n("Move to Beginning of Line"),                      Key_Home,
    00449     this, SLOT(home()),
    00450     ac, "beginning_of_line" );
    00451   new KAction(
    00452     i18n("Move to Beginning of Document"),           KStdAccel::home(),
    00453     this, SLOT(top()),
    00454     ac, "beginning_of_document" );
    00455   new KAction(
    00456     i18n("Select to Beginning of Line"),     SHIFT +        Key_Home,
    00457     this, SLOT(shiftHome()),
    00458     ac, "select_beginning_of_line" );
    00459   new KAction(
    00460     i18n("Select to Beginning of Document"), SHIFT + CTRL + Key_Home,
    00461     this, SLOT(shiftTop()),
    00462     ac, "select_beginning_of_document" );
    00463
    00464   new KAction(
    00465     i18n("Move to End of Line"),                            Key_End,
    00466     this, SLOT(end()),
    00467     ac, "end_of_line" );
    00468   new KAction(
    00469     i18n("Move to End of Document"),                 KStdAccel::end(),
    00470     this, SLOT(bottom()),
    00471     ac, "end_of_document" );
    00472   new KAction(
    00473     i18n("Select to End of Line"),           SHIFT +        Key_End,
    00474     this, SLOT(shiftEnd()),
    00475     ac, "select_end_of_line" );
    00476   new KAction(
    00477     i18n("Select to End of Document"),       SHIFT + CTRL + Key_End,
    00478     this, SLOT(shiftBottom()),
    00479     ac, "select_end_of_document" );
    00480
    00481   new KAction(
    00482     i18n("Select to Previous Line"),                SHIFT + Key_Up,
    00483     this, SLOT(shiftUp()),
    00484     ac, "select_line_up" );
    00485   new KAction(
    00486     i18n("Scroll Line Up"),"",              CTRL +          Key_Up,
    00487     this, SLOT(scrollUp()),
    00488     ac, "scroll_line_up" );
    00489
    00490   new KAction(i18n("Move to Next Line"), Key_Down, this, SLOT(down()),
    00491           ac, "move_line_down");
    00492
    00493   new KAction(i18n("Move to Previous Line"), Key_Up, this, SLOT(up()),
    00494           ac, "move_line_up");
    00495
    00496   new KAction(i18n("Move Character Right"), Key_Right, this,
    00497           SLOT(cursorRight()), ac, "move_cursor_right");
    00498
    00499   new KAction(i18n("Move Character Left"), Key_Left, this, SLOT(cursorLeft()),
    00500           ac, "move_cusor_left");
    00501
    00502   new KAction(
    00503     i18n("Select to Next Line"),                    SHIFT + Key_Down,
    00504     this, SLOT(shiftDown()),
    00505     ac, "select_line_down" );
    00506   new KAction(
    00507     i18n("Scroll Line Down"),               CTRL +          Key_Down,
    00508     this, SLOT(scrollDown()),
    00509     ac, "scroll_line_down" );
    00510
    00511   new KAction(
    00512     i18n("Scroll Page Up"),                         KStdAccel::prior(),
    00513     this, SLOT(pageUp()),
    00514     ac, "scroll_page_up" );
    00515   new KAction(
    00516     i18n("Select Page Up"),                         SHIFT + Key_PageUp,
    00517     this, SLOT(shiftPageUp()),
    00518     ac, "select_page_up" );
    00519   new KAction(
    00520     i18n("Move to Top of View"),             CTRL +         Key_PageUp,
    00521     this, SLOT(topOfView()),
    00522     ac, "move_top_of_view" );
    00523   new KAction(
    00524     i18n("Select to Top of View"),             CTRL + SHIFT +  Key_PageUp,
    00525     this, SLOT(shiftTopOfView()),
    00526     ac, "select_top_of_view" );
    00527
    00528   new KAction(
    00529     i18n("Scroll Page Down"),                          KStdAccel::next(),
    00530     this, SLOT(pageDown()),
    00531     ac, "scroll_page_down" );
    00532   new KAction(
    00533     i18n("Select Page Down"),                       SHIFT + Key_PageDown,
    00534     this, SLOT(shiftPageDown()),
    00535     ac, "select_page_down" );
    00536   new KAction(
    00537     i18n("Move to Bottom of View"),          CTRL +         Key_PageDown,
    00538     this, SLOT(bottomOfView()),
    00539     ac, "move_bottom_of_view" );
    00540   new KAction(
    00541     i18n("Select to Bottom of View"),         CTRL + SHIFT + Key_PageDown,
    00542     this, SLOT(shiftBottomOfView()),
    00543     ac, "select_bottom_of_view" );
    00544   new KAction(
    00545     i18n("Move to Matching Bracket"),               CTRL + Key_6,
    00546     this, SLOT(toMatchingBracket()),
    00547     ac, "to_matching_bracket" );
    00548   new KAction(
    00549     i18n("Select to Matching Bracket"),      SHIFT + CTRL + Key_6,
    00550     this, SLOT(shiftToMatchingBracket()),
    00551     ac, "select_matching_bracket" );
    00552
    00553 /*
    00554   new KAction(
    00555     i18n("Switch to Command Line"),          Qt::Key_F7,
    00556     this, SLOT(switchToCmdLine()),
    00557     ac, "switch_to_cmd_line" );*/
    00558
    00559   // anders: shortcuts doing any changes should not be created in browserextension
    00560   if ( !m_doc->readOnly() )
    00561   {
    00562     new KAction(
    00563       i18n("Transpose Characters"),           CTRL + Key_T,
    00564       this, SLOT(transpose()),
    00565       ac, "transpose_char" );
    00566
    00567     new KAction(
    00568       i18n("Delete Line"),                    CTRL + Key_K,
    00569       this, SLOT(killLine()),
    00570       ac, "delete_line" );
    00571
    00572     new KAction(
    00573       i18n("Delete Word Left"),               KStdAccel::deleteWordBack(),
    00574       this, SLOT(deleteWordLeft()),
    00575       ac, "delete_word_left" );
    00576
    00577     new KAction(
    00578       i18n("Delete Word Right"),              KStdAccel::deleteWordForward(),
    00579       this, SLOT(deleteWordRight()),
    00580       ac, "delete_word_right" );
    00581
    00582     new KAction(i18n("Delete Next Character"), Key_Delete,
    00583                 this, SLOT(keyDelete()),
    00584                 ac, "delete_next_character");
    00585
    00586     new KAction(i18n("Backspace"), Key_Backspace,
    00587                 this, SLOT(backspace()),
    00588                 ac, "backspace");
    00589   }
    00590
    00591   connect( this, SIGNAL(gotFocus(Kate::View*)),
    00592            this, SLOT(slotGotFocus()) );
    00593   connect( this, SIGNAL(lostFocus(Kate::View*)),
    00594            this, SLOT(slotLostFocus()) );
    00595
    00596   m_editActions->readShortcutSettings( "Katepart Shortcuts" );
    00597
    00598   if( hasFocus() )
    00599     slotGotFocus();
    00600   else
    00601     slotLostFocus();
    00602
    00603
    00604 }
    00605
    00606 void KateView::setupCodeFolding()
    00607 {
    00608   KActionCollection *ac=this->actionCollection();
    00609   new KAction( i18n("Collapse Toplevel"), CTRL+SHIFT+Key_Minus,
    00610        m_doc->foldingTree(),SLOT(collapseToplevelNodes()),ac,"folding_toplevel");
    00611   new KAction( i18n("Expand Toplevel"), CTRL+SHIFT+Key_Plus,
    00612        this,SLOT(slotExpandToplevel()),ac,"folding_expandtoplevel");
    00613   new KAction( i18n("Collapse One Local Level"), CTRL+Key_Minus,
    00614        this,SLOT(slotCollapseLocal()),ac,"folding_collapselocal");
    00615   new KAction( i18n("Expand One Local Level"), CTRL+Key_Plus,
    00616        this,SLOT(slotExpandLocal()),ac,"folding_expandlocal");
    00617 #if 0
    00618   KAccel* debugAccels = new KAccel(this,this);
    00619   debugAccels->insert("KATE_DUMP_REGION_TREE",i18n("Show the code folding region tree"),"","Ctrl+Shift+Alt+D",m_doc,SLOT(dumpRegionTree()));
    00620   debugAccels->insert("KATE_TEMPLATE_TEST",i18n("Basic template code test"),"","Ctrl+Shift+Alt+T",m_doc,SLOT(testTemplateCode()));
    00621   debugAccels->setEnabled(true);
    00622 #endif
    00623 }
    00624
    00625 void KateView::slotExpandToplevel()
    00626 {
    00627   m_doc->foldingTree()->expandToplevelNodes(m_doc->numLines());
    00628 }
    00629
    00630 void KateView::slotCollapseLocal()
    00631 {
    00632   int realLine = m_doc->foldingTree()->collapseOne(cursorLine());
    00633   if (realLine != -1)
    00634     // TODO rodda: fix this to only set line and allow internal view to chose column
    00635     // Explicitly call internal because we want this to be registered as an internal call
    00636     setCursorPositionInternal(realLine, cursorColumn(), tabWidth(), false);
    00637 }
    00638
    00639 void KateView::slotExpandLocal()
    00640 {
    00641   m_doc->foldingTree()->expandOne(cursorLine(), m_doc->numLines());
    00642 }
    00643
    00644 void KateView::setupCodeCompletion()
    00645 {
    00646   m_codeCompletion = new KateCodeCompletion(this);
    00647   connect( m_codeCompletion, SIGNAL(completionAborted()),
    00648            this,             SIGNAL(completionAborted()));
    00649   connect( m_codeCompletion, SIGNAL(completionDone()),
    00650            this,             SIGNAL(completionDone()));
    00651   connect( m_codeCompletion, SIGNAL(argHintHidden()),
    00652            this,             SIGNAL(argHintHidden()));
    00653   connect( m_codeCompletion, SIGNAL(completionDone(KTextEditor::CompletionEntry)),
    00654            this,             SIGNAL(completionDone(KTextEditor::CompletionEntry)));
    00655   connect( m_codeCompletion, SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,QString*)),
    00656            this,             SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,QString*)));
    00657 }
    00658
    00659 void KateView::slotGotFocus()
    00660 {
    00661   m_editActions->accel()->setEnabled( true );
    00662
    00663   slotStatusMsg ();
    00664 }
    00665
    00666 void KateView::slotLostFocus()
    00667 {
    00668   m_editActions->accel()->setEnabled( false );
    00669 }
    00670
    00671 void KateView::setDynWrapIndicators(int mode)
    00672 {
    00673   config()->setDynWordWrapIndicators (mode);
    00674 }
    00675
    00676 void KateView::slotStatusMsg ()
    00677 {
    00678   QString ovrstr;
    00679   if (m_doc->isReadWrite())
    00680   {
    00681     if (m_doc->config()->configFlags() & KateDocument::cfOvr)
    00682       ovrstr = i18n(" OVR ");
    00683     else
    00684       ovrstr = i18n(" INS ");
    00685   }
    00686   else
    00687     ovrstr = i18n(" R/O ");
    00688
    00689   uint r = cursorLine() + 1;
    00690   uint c = cursorColumn() + 1;
    00691
    00692   QString s1 = i18n(" Line: %1").arg(KGlobal::locale()->formatNumber(r, 0));
    00693   QString s2 = i18n(" Col: %1").arg(KGlobal::locale()->formatNumber(c, 0));
    00694
    00695   QString modstr = m_doc->isModified() ? QString (" * ") : QString ("   ");
    00696   QString blockstr = m_doc->blockSelectionMode() ? i18n(" BLK ") : i18n(" NORM ");
    00697
    00698   emit viewStatusMsg (s1 + s2 + " " + ovrstr + blockstr + modstr);
    00699 }
    00700
    00701 void KateView::slotSelectionTypeChanged()
    00702 {
    00703   m_toggleBlockSelection->setChecked( m_doc->blockSelectionMode() );
    00704
    00705   emit newStatus();
    00706 }
    00707
    00708 bool KateView::isOverwriteMode() const
    00709 {
    00710   return m_doc->config()->configFlags() & KateDocument::cfOvr;
    00711 }
    00712
    00713 void KateView::reloadFile()
    00714 {
    00715   // save cursor position
    00716   uint cl = cursorLine();
    00717   uint cc = cursorColumn();
    00718
    00719   // save bookmarks
    00720   m_doc->reloadFile();
    00721
    00722   if (m_doc->numLines() >= cl)
    00723     // Explicitly call internal function because we want this to be registered as a non-external call
    00724     setCursorPositionInternal( cl, cc, tabWidth(), false );
    00725
    00726   emit newStatus();
    00727 }
    00728
    00729 void KateView::slotUpdate()
    00730 {
    00731   emit newStatus();
    00732
    00733   slotNewUndo();
    00734 }
    00735
    00736 void KateView::slotReadWriteChanged ()
    00737 {
    00738   if ( m_toggleWriteLock )
    00739     m_toggleWriteLock->setChecked( ! m_doc->isReadWrite() );
    00740
    00741   m_cut->setEnabled (m_doc->isReadWrite());
    00742   m_paste->setEnabled (m_doc->isReadWrite());
    00743
    00744   QStringList l;
    00745
    00746   l << "edit_replace" << "set_insert" << "tools_spelling" << "tools_indent"
    00747       << "tools_unindent" << "tools_cleanIndent" << "tools_align"  << "tools_comment"
    00748       << "tools_uncomment" << "tools_uppercase" << "tools_lowercase"
    00749       << "tools_capitalize" << "tools_join_lines" << "tools_apply_wordwrap"
    00750       << "edit_undo" << "edit_redo" << "tools_spelling_from_cursor"
    00751       << "tools_spelling_selection";
    00752
    00753   KAction *a = 0;
    00754   for (uint z = 0; z < l.size(); z++)
    00755     if ((a = actionCollection()->action( l[z].ascii() )))
    00756       a->setEnabled (m_doc->isReadWrite());
    00757 }
    00758
    00759 void KateView::slotNewUndo()
    00760 {
    00761   if (m_doc->readOnly())
    00762     return;
    00763
    00764   if ((m_doc->undoCount() > 0) != m_editUndo->isEnabled())
    00765     m_editUndo->setEnabled(m_doc->undoCount() > 0);
    00766
    00767   if ((m_doc->redoCount() > 0) != m_editRedo->isEnabled())
    00768     m_editRedo->setEnabled(m_doc->redoCount() > 0);
    00769 }
    00770
    00771 void KateView::slotDropEventPass( QDropEvent * ev )
    00772 {
    00773   KURL::List lstDragURLs;
    00774   bool ok = KURLDrag::decode( ev, lstDragURLs );
    00775
    00776   KParts::BrowserExtension * ext = KParts::BrowserExtension::childObject( doc() );
    00777   if ( ok && ext )
    00778     emit ext->openURLRequest( lstDragURLs.first() );
    00779 }
    00780
    00781 void KateView::contextMenuEvent( QContextMenuEvent *ev )
    00782 {
    00783   if ( !m_doc || !m_doc->browserExtension()  )
    00784     return;
    00785   emit m_doc->browserExtension()->popupMenu( /*this, */ev->globalPos(), m_doc->url(),
    00786                                         QString::fromLatin1( "text/plain" ) );
    00787   ev->accept();
    00788 }
    00789
    00790 bool KateView::setCursorPositionInternal( uint line, uint col, uint tabwidth, bool calledExternally )
    00791 {
    00792   KateTextLine::Ptr l = m_doc->kateTextLine( line );
    00793
    00794   if (!l)
    00795     return false;
    00796
    00797   QString line_str = m_doc->textLine( line );
    00798
    00799   uint z;
    00800   uint x = 0;
    00801   for (z = 0; z < line_str.length() && z < col; z++) {
    00802     if (line_str[z] == QChar('\t')) x += tabwidth - (x % tabwidth); else x++;
    00803   }
    00804
    00805   m_viewInternal->updateCursor( KateTextCursor( line, x ), false, true, calledExternally );
    00806
    00807   return true;
    00808 }
    00809
    00810 void KateView::toggleBlockSelectionMode()
    00811 {
    00812   m_doc->toggleBlockSelectionMode();
    00813   m_toggleBlockSelection->setChecked (m_doc->blockSelectionMode());
    00814 }
    00815
    00816 void KateView::setOverwriteMode( bool b )
    00817 {
    00818   if ( isOverwriteMode() && !b )
    00819     m_doc->setConfigFlags( m_doc->config()->configFlags() ^ KateDocument::cfOvr );
    00820   else
    00821     m_doc->setConfigFlags( m_doc->config()->configFlags() | KateDocument::cfOvr );
    00822
    00823   m_toggleInsert->setChecked (isOverwriteMode ());
    00824 }
    00825
    00826 void KateView::toggleInsert()
    00827 {
    00828   m_doc->setConfigFlags(m_doc->config()->configFlags() ^ KateDocument::cfOvr);
    00829   m_toggleInsert->setChecked (isOverwriteMode ());
    00830
    00831   emit newStatus();
    00832 }
    00833
    00834 bool KateView::canDiscard()
    00835 {
    00836   return m_doc->closeURL();
    00837 }
    00838
    00839 void KateView::flush()
    00840 {
    00841   m_doc->closeURL();
    00842 }
    00843
    00844 KateView::saveResult KateView::save()
    00845 {
    00846   if( !m_doc->url().isValid() || !doc()->isReadWrite() )
    00847     return saveAs();
    00848
    00849   if( m_doc->save() )
    00850     return SAVE_OK;
    00851
    00852   return SAVE_ERROR;
    00853 }
    00854
    00855 KateView::saveResult KateView::saveAs()
    00856 {
    00857
    00858   KEncodingFileDialog::Result res=KEncodingFileDialog::getSaveURLAndEncoding(doc()->config()->encoding(),
    00859                 m_doc->url().url(),QString::null,this,i18n("Save File"));
    00860
    00861 //   kdDebug()<<"urllist is emtpy?"<<res.URLs.isEmpty()<<endl;
    00862 //   kdDebug()<<"url is:"<<res.URLs.first()<<endl;
    00863   if( res.URLs.isEmpty() || !checkOverwrite( res.URLs.first() ) )
    00864     return SAVE_CANCEL;
    00865
    00866   m_doc->setEncoding( res.encoding );
    00867
    00868   if( m_doc->saveAs( res.URLs.first() ) )
    00869     return SAVE_OK;
    00870
    00871   return SAVE_ERROR;
    00872 }
    00873
    00874 bool KateView::checkOverwrite( KURL u )
    00875 {
    00876   if( !u.isLocalFile() )
    00877     return true;
    00878
    00879   QFileInfo info( u.path() );
    00880   if( !info.exists() )
    00881     return true;
    00882
    00883   return KMessageBox::Yes
    00884          == KMessageBox::warningYesNo
    00885               ( this,
    00886                 i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?" ).arg( info.fileName() ),
    00887                 i18n( "Overwrite File?" ),
    00888                 KGuiItem( i18n( "&Overwrite" ), "filesave", i18n( "Overwrite the file" ) ),
    00889                 KStdGuiItem::cancel()
    00890               );
    00891 }
    00892
    00893 void KateView::slotSaveCanceled( const QString& error )
    00894 {
    00895   if ( !error.isEmpty() ) // happens when cancelling a job
    00896     KMessageBox::error( this, error );
    00897 }
    00898
    00899 void KateView::gotoLine()
    00900 {
    00901   KateGotoLineDialog *dlg = new KateGotoLineDialog (this, m_viewInternal->getCursor().line() + 1, m_doc->numLines());
    00902
    00903   if (dlg->exec() == QDialog::Accepted)
    00904     gotoLineNumber( dlg->getLine() - 1 );
    00905
    00906   delete dlg;
    00907 }
    00908
    00909 void KateView::gotoLineNumber( int line )
    00910 {
    00911   // clear selection, unless we are in persistent selection mode
    00912   if ( ! (m_doc->config()->configFlags() & KateDocumentConfig::cfPersistent) )
    00913     m_doc->clearSelection();
    00914   setCursorPositionInternal ( line, 0, 1 );
    00915 }
    00916
    00917 void KateView::joinLines()
    00918 {
    00919   int first = m_doc->selStartLine();
    00920   int last = m_doc->selEndLine();
    00921   //int left = m_doc->textLine( last ).length() - m_doc->selEndCol();
    00922   if ( first == last )
    00923   {
    00924     first = cursorLine();
    00925     last = first + 1;
    00926   }
    00927   m_doc->joinLines( first, last );
    00928 }
    00929
    00930 void KateView::readSessionConfig(KConfig *config)
    00931 {
    00932   setCursorPositionInternal (config->readNumEntry("CursorLine"), config->readNumEntry("CursorColumn"), 1);
    00933 }
    00934
    00935 void KateView::writeSessionConfig(KConfig *config)
    00936 {
    00937   config->writeEntry("CursorLine",m_viewInternal->cursor.line());
    00938   config->writeEntry("CursorColumn",m_viewInternal->cursor.col());
    00939 }
    00940
    00941 int KateView::getEol()
    00942 {
    00943   return m_doc->config()->eol();
    00944 }
    00945
    00946 void KateView::setEol(int eol)
    00947 {
    00948   if (!doc()->isReadWrite())
    00949     return;
    00950
    00951   if (m_updatingDocumentConfig)
    00952     return;
    00953
    00954   m_doc->config()->setEol (eol);
    00955 }
    00956
    00957 void KateView::setIconBorder( bool enable )
    00958 {
    00959   config()->setIconBar (enable);
    00960 }
    00961
    00962 void KateView::toggleIconBorder()
    00963 {
    00964   config()->setIconBar (!config()->iconBar());
    00965 }
    00966
    00967 void KateView::setLineNumbersOn( bool enable )
    00968 {
    00969   config()->setLineNumbers (enable);
    00970 }
    00971
    00972 void KateView::toggleLineNumbersOn()
    00973 {
    00974   config()->setLineNumbers (!config()->lineNumbers());
    00975 }
    00976
    00977 void KateView::setScrollBarMarks( bool enable )
    00978 {
    00979   config()->setScrollBarMarks (enable);
    00980 }
    00981
    00982 void KateView::toggleScrollBarMarks()
    00983 {
    00984   config()->setScrollBarMarks (!config()->scrollBarMarks());
    00985 }
    00986
    00987 void KateView::toggleDynWordWrap()
    00988 {
    00989   config()->setDynWordWrap( !config()->dynWordWrap() );
    00990 }
    00991
    00992 void KateView::setDynWordWrap( bool b )
    00993 {
    00994   config()->setDynWordWrap( b );
    00995 }
    00996
    00997 void KateView::toggleWWMarker()
    00998 {
    00999   m_renderer->config()->setWordWrapMarker (!m_renderer->config()->wordWrapMarker());
    01000 }
    01001
    01002 void KateView::setFoldingMarkersOn( bool enable )
    01003 {
    01004   config()->setFoldingBar ( enable );
    01005 }
    01006
    01007 void KateView::toggleFoldingMarkers()
    01008 {
    01009   config()->setFoldingBar ( !config()->foldingBar() );
    01010 }
    01011
    01012 bool KateView::iconBorder() {
    01013   return m_viewInternal->leftBorder->iconBorderOn();
    01014 }
    01015
    01016 bool KateView::lineNumbersOn() {
    01017   return m_viewInternal->leftBorder->lineNumbersOn();
    01018 }
    01019
    01020 bool KateView::scrollBarMarks() {
    01021   return m_viewInternal->m_lineScroll->showMarks();
    01022 }
    01023
    01024 int KateView::dynWrapIndicators() {
    01025   return m_viewInternal->leftBorder->dynWrapIndicators();
    01026 }
    01027
    01028 bool KateView::foldingMarkersOn() {
    01029   return m_viewInternal->leftBorder->foldingMarkersOn();
    01030 }
    01031
    01032 void KateView::showCmdLine ( bool enabled )
    01033 {
    01034   if (enabled == m_cmdLineOn)
    01035     return;
    01036
    01037   if (enabled)
    01038   {
    01039     if (!m_cmdLine)
    01040     {
    01041       m_cmdLine = new KateCmdLine (this);
    01042       m_grid->addMultiCellWidget (m_cmdLine, 2, 2, 0, 2);
    01043     }
    01044
    01045     m_cmdLine->show ();
    01046     m_cmdLine->setFocus();
    01047   }
    01048   else {
    01049     m_cmdLine->hide ();
    01050     //m_toggleCmdLine->setChecked(false);
    01051   }
    01052
    01053   m_cmdLineOn = enabled;
    01054 }
    01055
    01056 void KateView::toggleCmdLine ()
    01057 {
    01058   m_config->setCmdLine (!m_config->cmdLine ());
    01059 }
    01060
    01061 void KateView::toggleWriteLock()
    01062 {
    01063   m_doc->setReadWrite( ! m_doc->isReadWrite() );
    01064 }
    01065
    01066 void KateView::enableTextHints(int timeout)
    01067 {
    01068   m_viewInternal->enableTextHints(timeout);
    01069 }
    01070
    01071 void KateView::disableTextHints()
    01072 {
    01073   m_viewInternal->disableTextHints();
    01074 }
    01075
    01076 void KateView::slotNeedTextHint(int line, int col, QString &text)
    01077 {
    01078   text=QString("test %1 %2").arg(line).arg(col);
    01079 }
    01080
    01081 void KateView::find()
    01082 {
    01083   m_search->find();
    01084 }
    01085
    01086 void KateView::find( const QString& pattern, long flags, bool add )
    01087 {
    01088   m_search->find( pattern, flags, add );
    01089 }
    01090
    01091 void KateView::replace()
    01092 {
    01093   m_search->replace();
    01094 }
    01095
    01096 void KateView::replace( const QString &pattern, const QString &replacement, long flags )
    01097 {
    01098   m_search->replace( pattern, replacement, flags );
    01099 }
    01100
    01101 void KateView::findAgain( bool back )
    01102 {
    01103   m_search->findAgain( back );
    01104 }
    01105
    01106 void KateView::selectionChanged ()
    01107 {
    01108   if (m_doc->hasSelection())
    01109   {
    01110     m_copy->setEnabled (true);
    01111     m_deSelect->setEnabled (true);
    01112   }
    01113   else
    01114   {
    01115     m_copy->setEnabled (false);
    01116     m_deSelect->setEnabled (false);
    01117   }
    01118
    01119   if (m_doc->readOnly())
    01120     return;
    01121
    01122   bool b = m_doc->hasSelection();
    01123   m_cut->setEnabled (b);
    01124   m_spellcheckSelection->setEnabled(b);
    01125 }
    01126
    01127 void KateView::switchToCmdLine ()
    01128 {
    01129   if (!m_cmdLineOn)
    01130     m_config->setCmdLine (true);
    01131   else {
    01132     if (m_cmdLine->hasFocus()) {
    01133         this->setFocus();
    01134         return;
    01135     }
    01136   }
    01137   m_cmdLine->setFocus ();
    01138 }
    01139
    01140 void KateView::showArgHint( QStringList arg1, const QString& arg2, const QString& arg3 )
    01141 {
    01142   m_codeCompletion->showArgHint( arg1, arg2, arg3 );
    01143 }
    01144
    01145 void KateView::showCompletionBox( QValueList<KTextEditor::CompletionEntry> arg1, int offset, bool cs )
    01146 {
    01147   emit aboutToShowCompletionBox();
    01148   m_codeCompletion->showCompletionBox( arg1, offset, cs );
    01149 }
    01150
    01151 KateRenderer *KateView::renderer ()
    01152 {
    01153   return m_renderer;
    01154 }
    01155
    01156 void KateView::updateConfig ()
    01157 {
    01158   if (m_startingUp)
    01159     return;
    01160
    01161   m_editActions->readShortcutSettings( "Katepart Shortcuts" );
    01162
    01163   // dyn. word wrap & markers
    01164   if (m_hasWrap != config()->dynWordWrap()) {
    01165     m_viewInternal->prepareForDynWrapChange();
    01166
    01167     m_hasWrap = config()->dynWordWrap();
    01168
    01169     m_viewInternal->dynWrapChanged();
    01170
    01171     m_setDynWrapIndicators->setEnabled(config()->dynWordWrap());
    01172     m_toggleDynWrap->setChecked( config()->dynWordWrap() );
    01173   }
    01174
    01175   m_viewInternal->leftBorder->setDynWrapIndicators( config()->dynWordWrapIndicators() );
    01176   m_setDynWrapIndicators->setCurrentItem( config()->dynWordWrapIndicators() );
    01177
    01178   // line numbers
    01179   m_viewInternal->leftBorder->setLineNumbersOn( config()->lineNumbers() );
    01180   m_toggleLineNumbers->setChecked( config()->lineNumbers() );
    01181
    01182   // icon bar
    01183   m_viewInternal->leftBorder->setIconBorderOn( config()->iconBar() );
    01184   m_toggleIconBar->setChecked( config()->iconBar() );
    01185
    01186   // scrollbar marks
    01187   m_viewInternal->m_lineScroll->setShowMarks( config()->scrollBarMarks() );
    01188   m_toggleScrollBarMarks->setChecked( config()->scrollBarMarks() );
    01189
    01190   // cmd line
    01191   showCmdLine (config()->cmdLine());
    01192   //m_toggleCmdLine->setChecked( config()->cmdLine() );
    01193
    01194   // misc edit
    01195   m_toggleBlockSelection->setChecked( m_doc->blockSelectionMode() );
    01196   m_toggleInsert->setChecked( isOverwriteMode() );
    01197
    01198   updateFoldingConfig ();
    01199
    01200   // bookmark
    01201   m_bookmarks->setSorting( (KateBookmarks::Sorting) config()->bookmarkSort() );
    01202
    01203   m_viewInternal->setAutoCenterLines(config()->autoCenterLines ());
    01204 }
    01205
    01206 void KateView::updateDocumentConfig()
    01207 {
    01208   if (m_startingUp)
    01209     return;
    01210
    01211   m_updatingDocumentConfig = true;
    01212
    01213   m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
    01214
    01215   m_updatingDocumentConfig = false;
    01216
    01217   m_viewInternal->updateView (true);
    01218
    01219   m_renderer->setTabWidth (m_doc->config()->tabWidth());
    01220 }
    01221
    01222 void KateView::updateRendererConfig()
    01223 {
    01224   if (m_startingUp)
    01225     return;
    01226
    01227   m_toggleWWMarker->setChecked( m_renderer->config()->wordWrapMarker()  );
    01228
    01229   // update the text area
    01230   m_viewInternal->updateView (true);
    01231   m_viewInternal->repaint ();
    01232
    01233   // update the left border right, for example linenumbers
    01234   m_viewInternal->leftBorder->updateFont();
    01235   m_viewInternal->leftBorder->repaint ();
    01236 }
    01237
    01238 void KateView::updateFoldingConfig ()
    01239 {
    01240   // folding bar
    01241   bool doit = config()->foldingBar() && m_doc->highlight() && m_doc->highlight()->allowsFolding();
    01242   m_viewInternal->leftBorder->setFoldingMarkersOn(doit);
    01243   m_toggleFoldingMarkers->setChecked( doit );
    01244   m_toggleFoldingMarkers->setEnabled( m_doc->highlight() && m_doc->highlight()->allowsFolding() );
    01245
    01246   QStringList l;
    01247
    01248   l << "folding_toplevel" << "folding_expandtoplevel"
    01249     << "folding_collapselocal" << "folding_expandlocal";
    01250
    01251   KAction *a = 0;
    01252   for (uint z = 0; z < l.size(); z++)
    01253     if ((a = actionCollection()->action( l[z].ascii() )))
    01254       a->setEnabled (m_doc->highlight() && m_doc->highlight()->allowsFolding());
    01255 }
    01256
    01257 //BEGIN EDIT STUFF
    01258 void KateView::editStart ()
    01259 {
    01260   m_viewInternal->editStart ();
    01261 }
    01262
    01263 void KateView::editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom)
    01264 {
    01265   m_viewInternal->editEnd (editTagLineStart, editTagLineEnd, tagFrom);
    01266 }
    01267
    01268 void KateView::editSetCursor (const KateTextCursor &cursor)
    01269 {
    01270   m_viewInternal->editSetCursor (cursor);
    01271 }
    01272 //END
    01273
    01274 //BEGIN TAG & CLEAR
    01275 bool KateView::tagLine (const KateTextCursor& virtualCursor)
    01276 {
    01277   return m_viewInternal->tagLine (virtualCursor);
    01278 }
    01279
    01280 bool KateView::tagLines (int start, int end, bool realLines)
    01281 {
    01282   return m_viewInternal->tagLines (start, end, realLines);
    01283 }
    01284
    01285 bool KateView::tagLines (KateTextCursor start, KateTextCursor end, bool realCursors)
    01286 {
    01287   return m_viewInternal->tagLines (start, end, realCursors);
    01288 }
    01289
    01290 void KateView::tagAll ()
    01291 {
    01292   m_viewInternal->tagAll ();
    01293 }
    01294
    01295 void KateView::clear ()
    01296 {
    01297   m_viewInternal->clear ();
    01298 }
    01299
    01300 void KateView::repaintText (bool paintOnlyDirty)
    01301 {
    01302   m_viewInternal->paintText(0,0,m_viewInternal->width(),m_viewInternal->height(), paintOnlyDirty);
    01303 }
    01304
    01305 void KateView::updateView (bool changed)
    01306 {
    01307   m_viewInternal->updateView (changed);
    01308   m_viewInternal->leftBorder->update();
    01309 }
    01310
    01311 //END
    01312
    01313 void KateView::slotHlChanged()
    01314 {
    01315   KateHighlighting *hl = m_doc->highlight();
    01316   bool ok ( !hl->getCommentStart(0).isEmpty() || !hl->getCommentSingleLineStart(0).isEmpty() );
    01317
    01318   if (actionCollection()->action("tools_comment"))
    01319     actionCollection()->action("tools_comment")->setEnabled( ok );
    01320
    01321   if (actionCollection()->action("tools_uncomment"))
    01322     actionCollection()->action("tools_uncomment")->setEnabled( ok );
    01323
    01324   // show folding bar if "view defaults" says so, otherwise enable/disable only the menu entry
    01325   updateFoldingConfig ();
    01326 }
    01327
    01328 uint KateView::cursorColumn()
    01329 {
    01330   uint r = m_doc->currentColumn(m_viewInternal->getCursor());
    01331   if ( !( m_doc->config()->configFlags() & KateDocumentConfig::cfWrapCursor ) &&
    01332        (uint)m_viewInternal->getCursor().col() > m_doc->textLine( m_viewInternal->getCursor().line() ).length()  )
    01333     r += m_viewInternal->getCursor().col() - m_doc->textLine( m_viewInternal->getCursor().line() ).length();
    01334
    01335   return r;
    01336 }
    01337
    01338 void KateView::spellcheckFromCursor()
    01339 {
    01340   m_doc->spellcheck( m_viewInternal->getCursor() );
    01341 }
    01342
    01343 void KateView::spellcheckSelection()
    01344 {
    01345   KateTextCursor from( m_doc->selStartLine(), m_doc->selStartCol() );
    01346   KateTextCursor to( m_doc->selEndLine(), m_doc->selEndCol() );
    01347   m_doc->spellcheck( from, to );
    01348 }
    01349
    01350 // kate: space-indent on; indent-width 2; replace-tabs on;

This file is part of the documentation for kate Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:36:39 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003