• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Kate

kateview.cpp

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #define DEBUGACCELS
00024 
00025 //BEGIN includes
00026 #include "kateview.h"
00027 #include "kateview.moc"
00028 
00029 #include "kateviewinternal.h"
00030 #include "kateviewhelpers.h"
00031 #include "katerenderer.h"
00032 #include "katedocument.h"
00033 #include "katedocumenthelpers.h"
00034 #include "katefactory.h"
00035 #include "katehighlight.h"
00036 #include "katedialogs.h"
00037 #include "katetextline.h"
00038 #include "katecodefoldinghelpers.h"
00039 #include "katecodecompletion.h"
00040 #include "katesearch.h"
00041 #include "kateschema.h"
00042 #include "katebookmarks.h"
00043 #include "katesearch.h"
00044 #include "kateconfig.h"
00045 #include "katefiletype.h"
00046 #include "kateautoindent.h"
00047 #include "katespell.h"
00048 
00049 #include <ktexteditor/plugin.h>
00050 
00051 #include <kparts/event.h>
00052 
00053 #include <kio/netaccess.h>
00054 
00055 #include <kconfig.h>
00056 #include <kurldrag.h>
00057 #include <kdebug.h>
00058 #include <kapplication.h>
00059 #include <kcursor.h>
00060 #include <klocale.h>
00061 #include <kglobal.h>
00062 #include <kcharsets.h>
00063 #include <kmessagebox.h>
00064 #include <kaction.h>
00065 #include <kstdaction.h>
00066 #include <kxmlguifactory.h>
00067 #include <kaccel.h>
00068 #include <klibloader.h>
00069 #include <kencodingfiledialog.h>
00070 #include <kmultipledrag.h>
00071 #include <ktempfile.h>
00072 #include <ksavefile.h>
00073 
00074 #include <qfont.h>
00075 #include <qfileinfo.h>
00076 #include <qstyle.h>
00077 #include <qevent.h>
00078 #include <qpopupmenu.h>
00079 #include <qlayout.h>
00080 #include <qclipboard.h>
00081 #include <qstylesheet.h>
00082 //END includes
00083 
00084 KateView::KateView( KateDocument *doc, QWidget *parent, const char * name )
00085     : Kate::View( doc, parent, name )
00086     , m_doc( doc )
00087     , m_search( new KateSearch( this ) )
00088     , m_spell( new KateSpell( this ) )
00089     , m_bookmarks( new KateBookmarks( this ) )
00090     , m_cmdLine (0)
00091     , m_cmdLineOn (false)
00092     , m_active( false )
00093     , m_hasWrap( false )
00094     , m_startingUp (true)
00095     , m_updatingDocumentConfig (false)
00096     , selectStart (m_doc, true)
00097     , selectEnd (m_doc, true)
00098     , blockSelect (false)
00099     , m_imStartLine( 0 )
00100     , m_imStart( 0 )
00101     , m_imEnd( 0 )
00102     , m_imSelStart( 0 )
00103     , m_imSelEnd( 0 )
00104     , m_imComposeEvent( false )
00105 {
00106   KateFactory::self()->registerView( this );
00107   m_config = new KateViewConfig (this);
00108 
00109   m_renderer = new KateRenderer(doc, this);
00110 
00111   m_grid = new QGridLayout (this, 3, 3);
00112 
00113   m_grid->setRowStretch ( 0, 10 );
00114   m_grid->setRowStretch ( 1, 0 );
00115   m_grid->setColStretch ( 0, 0 );
00116   m_grid->setColStretch ( 1, 10 );
00117   m_grid->setColStretch ( 2, 0 );
00118 
00119   m_viewInternal = new KateViewInternal( this, doc );
00120   m_grid->addWidget (m_viewInternal, 0, 1);
00121 
00122   setClipboardInterfaceDCOPSuffix (viewDCOPSuffix());
00123   setCodeCompletionInterfaceDCOPSuffix (viewDCOPSuffix());
00124   setDynWordWrapInterfaceDCOPSuffix (viewDCOPSuffix());
00125   setPopupMenuInterfaceDCOPSuffix (viewDCOPSuffix());
00126   setSessionConfigInterfaceDCOPSuffix (viewDCOPSuffix());
00127   setViewCursorInterfaceDCOPSuffix (viewDCOPSuffix());
00128   setViewStatusMsgInterfaceDCOPSuffix (viewDCOPSuffix());
00129 
00130   setInstance( KateFactory::self()->instance() );
00131   doc->addView( this );
00132 
00133   setFocusProxy( m_viewInternal );
00134   setFocusPolicy( StrongFocus );
00135 
00136   if (!doc->singleViewMode()) {
00137     setXMLFile( "katepartui.rc" );
00138   } else {
00139     if( doc->readOnly() )
00140       setXMLFile( "katepartreadonlyui.rc" );
00141     else
00142       setXMLFile( "katepartui.rc" );
00143   }
00144 
00145   setupConnections();
00146   setupActions();
00147   setupEditActions();
00148   setupCodeFolding();
00149   setupCodeCompletion();
00150 
00151   // enable the plugins of this view
00152   m_doc->enableAllPluginsGUI (this);
00153 
00154   // update the enabled state of the undo/redo actions...
00155   slotNewUndo();
00156 
00157   m_startingUp = false;
00158   updateConfig ();
00159 
00160   slotHlChanged();
00161   /*test texthint
00162   connect(this,SIGNAL(needTextHint(int, int, QString &)),
00163   this,SLOT(slotNeedTextHint(int, int, QString &)));
00164   enableTextHints(1000);
00165   test texthint*/
00166 }
00167 
00168 KateView::~KateView()
00169 {
00170   if (!m_doc->singleViewMode())
00171     m_doc->disableAllPluginsGUI (this);
00172 
00173   m_doc->removeView( this );
00174 
00175   // its a QObject. don't double-delete
00176   //delete m_viewInternal;
00177   //delete m_codeCompletion;
00178 
00179   delete m_renderer;
00180   m_renderer = 0;
00181 
00182   delete m_config;
00183   m_config = 0;
00184   KateFactory::self()->deregisterView (this);
00185 }
00186 
00187 void KateView::setupConnections()
00188 {
00189   connect( m_doc, SIGNAL(undoChanged()),
00190            this, SLOT(slotNewUndo()) );
00191   connect( m_doc, SIGNAL(hlChanged()),
00192            this, SLOT(slotHlChanged()) );
00193   connect( m_doc, SIGNAL(canceled(const QString&)),
00194            this, SLOT(slotSaveCanceled(const QString&)) );
00195   connect( m_viewInternal, SIGNAL(dropEventPass(QDropEvent*)),
00196            this,           SIGNAL(dropEventPass(QDropEvent*)) );
00197   connect(this,SIGNAL(cursorPositionChanged()),this,SLOT(slotStatusMsg()));
00198   connect(this,SIGNAL(newStatus()),this,SLOT(slotStatusMsg()));
00199   connect(m_doc, SIGNAL(undoChanged()), this, SLOT(slotStatusMsg()));
00200 
00201   if ( m_doc->browserView() )
00202   {
00203     connect( this, SIGNAL(dropEventPass(QDropEvent*)),
00204              this, SLOT(slotDropEventPass(QDropEvent*)) );
00205   }
00206 }
00207 
00208 void KateView::setupActions()
00209 {
00210   KActionCollection *ac = this->actionCollection ();
00211   KAction *a;
00212 
00213   m_toggleWriteLock = 0;
00214 
00215   m_cut = a=KStdAction::cut(this, SLOT(cut()), ac);
00216   a->setWhatsThis(i18n("Cut the selected text and move it to the clipboard"));
00217 
00218   m_paste = a=KStdAction::pasteText(this, SLOT(paste()), ac);
00219   a->setWhatsThis(i18n("Paste previously copied or cut clipboard contents"));
00220 
00221   m_copy = a=KStdAction::copy(this, SLOT(copy()), ac);
00222   a->setWhatsThis(i18n( "Use this command to copy the currently selected text to the system clipboard."));
00223 
00224   m_copyHTML = a = new KAction(i18n("Copy as &HTML"), "editcopy", 0, this, SLOT(copyHTML()), ac, "edit_copy_html");
00225   a->setWhatsThis(i18n( "Use this command to copy the currently selected text as HTML to the system clipboard."));
00226 
00227   if (!m_doc->readOnly())
00228   {
00229     a=KStdAction::save(this, SLOT(save()), ac);
00230     a->setWhatsThis(i18n("Save the current document"));
00231 
00232     a=m_editUndo = KStdAction::undo(m_doc, SLOT(undo()), ac);
00233     a->setWhatsThis(i18n("Revert the most recent editing actions"));
00234 
00235     a=m_editRedo = KStdAction::redo(m_doc, SLOT(redo()), ac);
00236     a->setWhatsThis(i18n("Revert the most recent undo operation"));
00237 
00238     (new KAction(i18n("&Word Wrap Document"), "", 0, this, SLOT(applyWordWrap()), ac, "tools_apply_wordwrap"))->setWhatsThis(
00239   i18n("Use this command to wrap all lines of the current document which are longer than the width of the"
00240     " current view, to fit into this view.<br><br> This is a static word wrap, meaning it is not updated"
00241     " when the view is resized."));
00242 
00243     // setup Tools menu
00244     a=new KAction(i18n("&Indent"), "indent", Qt::CTRL+Qt::Key_I, this, SLOT(indent()), ac, "tools_indent");
00245     a->setWhatsThis(i18n("Use this to indent a selected block of text.<br><br>"
00246         "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
00247     a=new KAction(i18n("&Unindent"), "unindent", Qt::CTRL+Qt::SHIFT+Qt::Key_I, this, SLOT(unIndent()), ac, "tools_unindent");
00248     a->setWhatsThis(i18n("Use this to unindent a selected block of text."));
00249 
00250     a=new KAction(i18n("&Clean Indentation"), 0, this, SLOT(cleanIndent()), ac, "tools_cleanIndent");
00251     a->setWhatsThis(i18n("Use this to clean the indentation of a selected block of text (only tabs/only spaces)<br><br>"
00252         "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
00253 
00254     a=new KAction(i18n("&Align"), 0, this, SLOT(align()), ac, "tools_align");
00255     a->setWhatsThis(i18n("Use this to align the current line or block of text to its proper indent level."));
00256 
00257     a=new KAction(i18n("C&omment"), CTRL+Qt::Key_D, this, SLOT(comment()),
00258         ac, "tools_comment");
00259     a->setWhatsThis(i18n("This command comments out the current line or a selected block of text.<BR><BR>"
00260         "The characters for single/multiple line comments are defined within the language's highlighting."));
00261 
00262     a=new KAction(i18n("Unco&mment"), CTRL+SHIFT+Qt::Key_D, this, SLOT(uncomment()),
00263                                  ac, "tools_uncomment");
00264     a->setWhatsThis(i18n("This command removes comments from the current line or a selected block of text.<BR><BR>"
00265     "The characters for single/multiple line comments are defined within the language's highlighting."));
00266     a = m_toggleWriteLock = new KToggleAction(
00267                 i18n("&Read Only Mode"), 0, 0,
00268                 this, SLOT( toggleWriteLock() ),
00269                 ac, "tools_toggle_write_lock" );
00270     a->setWhatsThis( i18n("Lock/unlock the document for writing") );
00271 
00272     a = new KAction( i18n("Uppercase"), CTRL + Qt::Key_U, this,
00273       SLOT(uppercase()), ac, "tools_uppercase" );
00274     a->setWhatsThis( i18n("Convert the selection to uppercase, or the character to the "
00275       "right of the cursor if no text is selected.") );
00276 
00277     a = new KAction( i18n("Lowercase"), CTRL + SHIFT + Qt::Key_U, this,
00278       SLOT(lowercase()), ac, "tools_lowercase" );
00279     a->setWhatsThis( i18n("Convert the selection to lowercase, or the character to the "
00280       "right of the cursor if no text is selected.") );
00281 
00282     a = new KAction( i18n("Capitalize"), CTRL + ALT + Qt::Key_U, this,
00283       SLOT(capitalize()), ac, "tools_capitalize" );
00284     a->setWhatsThis( i18n("Capitalize the selection, or the word under the "
00285       "cursor if no text is selected.") );
00286 
00287     a = new KAction( i18n("Join Lines"), CTRL + Qt::Key_J, this,
00288       SLOT( joinLines() ), ac, "tools_join_lines" );
00289   }
00290   else
00291   {
00292     m_cut->setEnabled (false);
00293     m_paste->setEnabled (false);
00294     m_editUndo = 0;
00295     m_editRedo = 0;
00296   }
00297 
00298   a=KStdAction::print( m_doc, SLOT(print()), ac );
00299   a->setWhatsThis(i18n("Print the current document."));
00300 
00301   a=new KAction(i18n("Reloa&d"), "reload", KStdAccel::reload(), this, SLOT(reloadFile()), ac, "file_reload");
00302   a->setWhatsThis(i18n("Reload the current document from disk."));
00303 
00304   a=KStdAction::saveAs(this, SLOT(saveAs()), ac);
00305   a->setWhatsThis(i18n("Save the current document to disk, with a name of your choice."));
00306 
00307   a=KStdAction::gotoLine(this, SLOT(gotoLine()), ac);
00308   a->setWhatsThis(i18n("This command opens a dialog and lets you choose a line that you want the cursor to move to."));
00309 
00310   a=new KAction(i18n("&Configure Editor..."), 0, m_doc, SLOT(configDialog()),ac, "set_confdlg");
00311   a->setWhatsThis(i18n("Configure various aspects of this editor."));
00312 
00313   KateViewHighlightAction *menu = new KateViewHighlightAction (i18n("&Highlighting"), ac, "set_highlight");
00314   menu->setWhatsThis(i18n("Here you can choose how the current document should be highlighted."));
00315   menu->updateMenu (m_doc);
00316 
00317   KateViewFileTypeAction *ftm = new KateViewFileTypeAction (i18n("&Filetype"),ac,"set_filetype");
00318   ftm->updateMenu (m_doc);
00319 
00320   KateViewSchemaAction *schemaMenu = new KateViewSchemaAction (i18n("&Schema"),ac,"view_schemas");
00321   schemaMenu->updateMenu (this);
00322 
00323   // indentation menu
00324   new KateViewIndentationAction (m_doc, i18n("&Indentation"),ac,"tools_indentation");
00325 
00326   // html export
00327   a = new KAction(i18n("E&xport as HTML..."), 0, 0, this, SLOT(exportAsHTML()), ac, "file_export_html");
00328   a->setWhatsThis(i18n("This command allows you to export the current document"
00329                       " with all highlighting information into a HTML document."));
00330 
00331   m_selectAll = a=KStdAction::selectAll(this, SLOT(selectAll()), ac);
00332   a->setWhatsThis(i18n("Select the entire text of the current document."));
00333 
00334   m_deSelect = a=KStdAction::deselect(this, SLOT(clearSelection()), ac);
00335   a->setWhatsThis(i18n("If you have selected something within the current document, this will no longer be selected."));
00336 
00337   a=new KAction(i18n("Enlarge Font"), "viewmag+", 0, m_viewInternal, SLOT(slotIncFontSizes()), ac, "incFontSizes");
00338   a->setWhatsThis(i18n("This increases the display font size."));
00339 
00340   a=new KAction(i18n("Shrink Font"), "viewmag-", 0, m_viewInternal, SLOT(slotDecFontSizes()), ac, "decFontSizes");
00341   a->setWhatsThis(i18n("This decreases the display font size."));
00342 
00343   a= m_toggleBlockSelection = new KToggleAction(
00344     i18n("Bl&ock Selection Mode"), CTRL + SHIFT + Key_B,
00345     this, SLOT(toggleBlockSelectionMode()),
00346     ac, "set_verticalSelect");
00347   a->setWhatsThis(i18n("This command allows switching between the normal (line based) selection mode and the block selection mode."));
00348 
00349   a= m_toggleInsert = new KToggleAction(
00350     i18n("Overwr&ite Mode"), Key_Insert,
00351     this, SLOT(toggleInsert()),
00352     ac, "set_insert" );
00353   a->setWhatsThis(i18n("Choose whether you want the text you type to be inserted or to overwrite existing text."));
00354 
00355   KToggleAction *toggleAction;
00356    a= m_toggleDynWrap = toggleAction = new KToggleAction(
00357     i18n("&Dynamic Word Wrap"), Key_F10,
00358     this, SLOT(toggleDynWordWrap()),
00359     ac, "view_dynamic_word_wrap" );
00360   a->setWhatsThis(i18n("If this option is checked, the text lines will be wrapped at the view border on the screen."));
00361 
00362   a= m_setDynWrapIndicators = new KSelectAction(i18n("Dynamic Word Wrap Indicators"), 0, ac, "dynamic_word_wrap_indicators");
00363   a->setWhatsThis(i18n("Choose when the Dynamic Word Wrap Indicators should be displayed"));
00364 
00365   connect(m_setDynWrapIndicators, SIGNAL(activated(int)), this, SLOT(setDynWrapIndicators(int)));
00366   QStringList list2;
00367   list2.append(i18n("&Off"));
00368   list2.append(i18n("Follow &Line Numbers"));
00369   list2.append(i18n("&Always On"));
00370   m_setDynWrapIndicators->setItems(list2);
00371 
00372   a= toggleAction=m_toggleFoldingMarkers = new KToggleAction(
00373     i18n("Show Folding &Markers"), Key_F9,
00374     this, SLOT(toggleFoldingMarkers()),
00375     ac, "view_folding_markers" );
00376   a->setWhatsThis(i18n("You can choose if the codefolding marks should be shown, if codefolding is possible."));
00377   toggleAction->setCheckedState(i18n("Hide Folding &Markers"));
00378 
00379    a= m_toggleIconBar = toggleAction = new KToggleAction(
00380     i18n("Show &Icon Border"), Key_F6,
00381     this, SLOT(toggleIconBorder()),
00382     ac, "view_border");
00383   a=toggleAction;
00384   a->setWhatsThis(i18n("Show/hide the icon border.<BR><BR> The icon border shows bookmark symbols, for instance."));
00385   toggleAction->setCheckedState(i18n("Hide &Icon Border"));
00386 
00387   a= toggleAction=m_toggleLineNumbers = new KToggleAction(
00388      i18n("Show &Line Numbers"), Key_F11,
00389      this, SLOT(toggleLineNumbersOn()),
00390      ac, "view_line_numbers" );
00391   a->setWhatsThis(i18n("Show/hide the line numbers on the left hand side of the view."));
00392   toggleAction->setCheckedState(i18n("Hide &Line Numbers"));
00393 
00394   a= m_toggleScrollBarMarks = toggleAction = new KToggleAction(
00395      i18n("Show Scroll&bar Marks"), 0,
00396      this, SLOT(toggleScrollBarMarks()),
00397      ac, "view_scrollbar_marks");
00398   a->setWhatsThis(i18n("Show/hide the marks on the vertical scrollbar.<BR><BR>The marks, for instance, show bookmarks."));
00399   toggleAction->setCheckedState(i18n("Hide Scroll&bar Marks"));
00400 
00401   a = toggleAction = m_toggleWWMarker = new KToggleAction(
00402         i18n("Show Static &Word Wrap Marker"), 0,
00403         this, SLOT( toggleWWMarker() ),
00404         ac, "view_word_wrap_marker" );
00405   a->setWhatsThis( i18n(
00406         "Show/hide the Word Wrap Marker, a vertical line drawn at the word "
00407         "wrap column as defined in the editing properties" ));
00408   toggleAction->setCheckedState(i18n("Hide Static &Word Wrap Marker"));
00409 
00410   a= m_switchCmdLine = new KAction(
00411      i18n("Switch to Command Line"), Key_F7,
00412      this, SLOT(switchToCmdLine()),
00413      ac, "switch_to_cmd_line" );
00414   a->setWhatsThis(i18n("Show/hide the command line on the bottom of the view."));
00415 
00416   a=m_setEndOfLine = new KSelectAction(i18n("&End of Line"), 0, ac, "set_eol");
00417   a->setWhatsThis(i18n("Choose which line endings should be used, when you save the document"));
00418   QStringList list;
00419   list.append("&UNIX");
00420   list.append("&Windows/DOS");
00421   list.append("&Macintosh");
00422   m_setEndOfLine->setItems(list);
00423   m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
00424   connect(m_setEndOfLine, SIGNAL(activated(int)), this, SLOT(setEol(int)));
00425 
00426   // encoding menu
00427   new KateViewEncodingAction (m_doc, this, i18n("E&ncoding"), ac, "set_encoding");
00428 
00429   m_search->createActions( ac );
00430   m_spell->createActions( ac );
00431   m_bookmarks->createActions( ac );
00432 
00433   slotSelectionChanged ();
00434 
00435   connect (this, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
00436 }
00437 
00438 void KateView::setupEditActions()
00439 {
00440   m_editActions = new KActionCollection( m_viewInternal, this, "edit_actions" );
00441   KActionCollection* ac = m_editActions;
00442 
00443   new KAction(
00444     i18n("Move Word Left"),                         CTRL + Key_Left,
00445     this,SLOT(wordLeft()),
00446     ac, "word_left" );
00447   new KAction(
00448     i18n("Select Character Left"),          SHIFT +        Key_Left,
00449     this,SLOT(shiftCursorLeft()),
00450     ac, "select_char_left" );
00451   new KAction(
00452     i18n("Select Word Left"),               SHIFT + CTRL + Key_Left,
00453     this, SLOT(shiftWordLeft()),
00454     ac, "select_word_left" );
00455 
00456   new KAction(
00457     i18n("Move Word Right"),                        CTRL + Key_Right,
00458     this, SLOT(wordRight()),
00459     ac, "word_right" );
00460   new KAction(
00461     i18n("Select Character Right"),         SHIFT        + Key_Right,
00462     this, SLOT(shiftCursorRight()),
00463     ac, "select_char_right" );
00464   new KAction(
00465     i18n("Select Word Right"),              SHIFT + CTRL + Key_Right,
00466     this,SLOT(shiftWordRight()),
00467     ac, "select_word_right" );
00468 
00469   new KAction(
00470     i18n("Move to Beginning of Line"),                      Key_Home,
00471     this, SLOT(home()),
00472     ac, "beginning_of_line" );
00473   new KAction(
00474     i18n("Move to Beginning of Document"),           KStdAccel::home(),
00475     this, SLOT(top()),
00476     ac, "beginning_of_document" );
00477   new KAction(
00478     i18n("Select to Beginning of Line"),     SHIFT +        Key_Home,
00479     this, SLOT(shiftHome()),
00480     ac, "select_beginning_of_line" );
00481   new KAction(
00482     i18n("Select to Beginning of Document"), SHIFT + CTRL + Key_Home,
00483     this, SLOT(shiftTop()),
00484     ac, "select_beginning_of_document" );
00485 
00486   new KAction(
00487     i18n("Move to End of Line"),                            Key_End,
00488     this, SLOT(end()),
00489     ac, "end_of_line" );
00490   new KAction(
00491     i18n("Move to End of Document"),                 KStdAccel::end(),
00492     this, SLOT(bottom()),
00493     ac, "end_of_document" );
00494   new KAction(
00495     i18n("Select to End of Line"),           SHIFT +        Key_End,
00496     this, SLOT(shiftEnd()),
00497     ac, "select_end_of_line" );
00498   new KAction(
00499     i18n("Select to End of Document"),       SHIFT + CTRL + Key_End,
00500     this, SLOT(shiftBottom()),
00501     ac, "select_end_of_document" );
00502 
00503   new KAction(
00504     i18n("Select to Previous Line"),                SHIFT + Key_Up,
00505     this, SLOT(shiftUp()),
00506     ac, "select_line_up" );
00507   new KAction(
00508     i18n("Scroll Line Up"),"",              CTRL +          Key_Up,
00509     this, SLOT(scrollUp()),
00510     ac, "scroll_line_up" );
00511 
00512   new KAction(i18n("Move to Next Line"), Key_Down, this, SLOT(down()),
00513           ac, "move_line_down");
00514 
00515   new KAction(i18n("Move to Previous Line"), Key_Up, this, SLOT(up()),
00516           ac, "move_line_up");
00517 
00518   new KAction(i18n("Move Character Right"), Key_Right, this,
00519           SLOT(cursorRight()), ac, "move_cursor_right");
00520 
00521   new KAction(i18n("Move Character Left"), Key_Left, this, SLOT(cursorLeft()),
00522           ac, "move_cusor_left");
00523 
00524   new KAction(
00525     i18n("Select to Next Line"),                    SHIFT + Key_Down,
00526     this, SLOT(shiftDown()),
00527     ac, "select_line_down" );
00528   new KAction(
00529     i18n("Scroll Line Down"),               CTRL +          Key_Down,
00530     this, SLOT(scrollDown()),
00531     ac, "scroll_line_down" );
00532 
00533   new KAction(
00534     i18n("Scroll Page Up"),                         KStdAccel::prior(),
00535     this, SLOT(pageUp()),
00536     ac, "scroll_page_up" );
00537   new KAction(
00538     i18n("Select Page Up"),                         SHIFT + Key_PageUp,
00539     this, SLOT(shiftPageUp()),
00540     ac, "select_page_up" );
00541   new KAction(
00542     i18n("Move to Top of View"),             CTRL +         Key_PageUp,
00543     this, SLOT(topOfView()),
00544     ac, "move_top_of_view" );
00545   new KAction(
00546     i18n("Select to Top of View"),             CTRL + SHIFT +  Key_PageUp,
00547     this, SLOT(shiftTopOfView()),
00548     ac, "select_top_of_view" );
00549 
00550   new KAction(
00551     i18n("Scroll Page Down"),                          KStdAccel::next(),
00552     this, SLOT(pageDown()),
00553     ac, "scroll_page_down" );
00554   new KAction(
00555     i18n("Select Page Down"),                       SHIFT + Key_PageDown,
00556     this, SLOT(shiftPageDown()),
00557     ac, "select_page_down" );
00558   new KAction(
00559     i18n("Move to Bottom of View"),          CTRL +         Key_PageDown,
00560     this, SLOT(bottomOfView()),
00561     ac, "move_bottom_of_view" );
00562   new KAction(
00563     i18n("Select to Bottom of View"),         CTRL + SHIFT + Key_PageDown,
00564     this, SLOT(shiftBottomOfView()),
00565     ac, "select_bottom_of_view" );
00566   new KAction(
00567     i18n("Move to Matching Bracket"),               CTRL + Key_6,
00568     this, SLOT(toMatchingBracket()),
00569     ac, "to_matching_bracket" );
00570   new KAction(
00571     i18n("Select to Matching Bracket"),      SHIFT + CTRL + Key_6,
00572     this, SLOT(shiftToMatchingBracket()),
00573     ac, "select_matching_bracket" );
00574 
00575   // anders: shortcuts doing any changes should not be created in browserextension
00576   if ( !m_doc->readOnly() )
00577   {
00578     new KAction(
00579       i18n("Transpose Characters"),           CTRL + Key_T,
00580       this, SLOT(transpose()),
00581       ac, "transpose_char" );
00582 
00583     new KAction(
00584       i18n("Delete Line"),                    CTRL + Key_K,
00585       this, SLOT(killLine()),
00586       ac, "delete_line" );
00587 
00588     new KAction(
00589       i18n("Delete Word Left"),               KStdAccel::deleteWordBack(),
00590       this, SLOT(deleteWordLeft()),
00591       ac, "delete_word_left" );
00592 
00593     new KAction(
00594       i18n("Delete Word Right"),              KStdAccel::deleteWordForward(),
00595       this, SLOT(deleteWordRight()),
00596       ac, "delete_word_right" );
00597 
00598     new KAction(i18n("Delete Next Character"), Key_Delete,
00599                 this, SLOT(keyDelete()),
00600                 ac, "delete_next_character");
00601 
00602     KAction *a = new KAction(i18n("Backspace"), Key_Backspace,
00603                 this, SLOT(backspace()),
00604                 ac, "backspace");
00605     KShortcut cut = a->shortcut();
00606     cut.append( KKey( SHIFT + Key_Backspace ) );
00607     a->setShortcut( cut );
00608   }
00609 
00610   connect( this, SIGNAL(gotFocus(Kate::View*)),
00611            this, SLOT(slotGotFocus()) );
00612   connect( this, SIGNAL(lostFocus(Kate::View*)),
00613            this, SLOT(slotLostFocus()) );
00614 
00615   m_editActions->readShortcutSettings( "Katepart Shortcuts" );
00616 
00617   if( hasFocus() )
00618     slotGotFocus();
00619   else
00620     slotLostFocus();
00621 
00622 
00623 }
00624 
00625 void KateView::setupCodeFolding()
00626 {
00627   KActionCollection *ac=this->actionCollection();
00628   new KAction( i18n("Collapse Toplevel"), CTRL+SHIFT+Key_Minus,
00629        m_doc->foldingTree(),SLOT(collapseToplevelNodes()),ac,"folding_toplevel");
00630   new KAction( i18n("Expand Toplevel"), CTRL+SHIFT+Key_Plus,
00631        this,SLOT(slotExpandToplevel()),ac,"folding_expandtoplevel");
00632   new KAction( i18n("Collapse One Local Level"), CTRL+Key_Minus,
00633        this,SLOT(slotCollapseLocal()),ac,"folding_collapselocal");
00634   new KAction( i18n("Expand One Local Level"), CTRL+Key_Plus,
00635        this,SLOT(slotExpandLocal()),ac,"folding_expandlocal");
00636 
00637 #ifdef DEBUGACCELS
00638   KAccel* debugAccels = new KAccel(this,this);
00639   debugAccels->insert("KATE_DUMP_REGION_TREE",i18n("Show the code folding region tree"),"","Ctrl+Shift+Alt+D",m_doc,SLOT(dumpRegionTree()));
00640   debugAccels->insert("KATE_TEMPLATE_TEST",i18n("Basic template code test"),"","Ctrl+Shift+Alt+T",m_doc,SLOT(testTemplateCode()));
00641   debugAccels->setEnabled(true);
00642 #endif
00643 }
00644 
00645 void KateView::slotExpandToplevel()
00646 {
00647   m_doc->foldingTree()->expandToplevelNodes(m_doc->numLines());
00648 }
00649 
00650 void KateView::slotCollapseLocal()
00651 {
00652   int realLine = m_doc->foldingTree()->collapseOne(cursorLine());
00653   if (realLine != -1)
00654     // TODO rodda: fix this to only set line and allow internal view to chose column
00655     // Explicitly call internal because we want this to be registered as an internal call
00656     setCursorPositionInternal(realLine, cursorColumn(), tabWidth(), false);
00657 }
00658 
00659 void KateView::slotExpandLocal()
00660 {
00661   m_doc->foldingTree()->expandOne(cursorLine(), m_doc->numLines());
00662 }
00663 
00664 void KateView::setupCodeCompletion()
00665 {
00666   m_codeCompletion = new KateCodeCompletion(this);
00667   connect( m_codeCompletion, SIGNAL(completionAborted()),
00668            this,             SIGNAL(completionAborted()));
00669   connect( m_codeCompletion, SIGNAL(completionDone()),
00670            this,             SIGNAL(completionDone()));
00671   connect( m_codeCompletion, SIGNAL(argHintHidden()),
00672            this,             SIGNAL(argHintHidden()));
00673   connect( m_codeCompletion, SIGNAL(completionDone(KTextEditor::CompletionEntry)),
00674            this,             SIGNAL(completionDone(KTextEditor::CompletionEntry)));
00675   connect( m_codeCompletion, SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,QString*)),
00676            this,             SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,QString*)));
00677 }
00678 
00679 void KateView::slotGotFocus()
00680 {
00681   m_editActions->accel()->setEnabled( true );
00682 
00683   slotStatusMsg ();
00684 }
00685 
00686 void KateView::slotLostFocus()
00687 {
00688   m_editActions->accel()->setEnabled( false );
00689 }
00690 
00691 void KateView::setDynWrapIndicators(int mode)
00692 {
00693   config()->setDynWordWrapIndicators (mode);
00694 }
00695 
00696 void KateView::slotStatusMsg ()
00697 {
00698   QString ovrstr;
00699   if (m_doc->isReadWrite())
00700   {
00701     if (m_doc->config()->configFlags() & KateDocument::cfOvr)
00702       ovrstr = i18n(" OVR ");
00703     else
00704       ovrstr = i18n(" INS ");
00705   }
00706   else
00707     ovrstr = i18n(" R/O ");
00708 
00709   uint r = cursorLine() + 1;
00710   uint c = cursorColumn() + 1;
00711 
00712   QString s1 = i18n(" Line: %1").arg(KGlobal::locale()->formatNumber(r, 0));
00713   QString s2 = i18n(" Col: %1").arg(KGlobal::locale()->formatNumber(c, 0));
00714 
00715   QString modstr = m_doc->isModified() ? QString (" * ") : QString ("   ");
00716   QString blockstr = blockSelectionMode() ? i18n(" BLK ") : i18n(" NORM ");
00717 
00718   emit viewStatusMsg (s1 + s2 + " " + ovrstr + blockstr + modstr);
00719 }
00720 
00721 void KateView::slotSelectionTypeChanged()
00722 {
00723   m_toggleBlockSelection->setChecked( blockSelectionMode() );
00724 
00725   emit newStatus();
00726 }
00727 
00728 bool KateView::isOverwriteMode() const
00729 {
00730   return m_doc->config()->configFlags() & KateDocument::cfOvr;
00731 }
00732 
00733 void KateView::reloadFile()
00734 {
00735   m_doc->reloadFile();
00736   emit newStatus();
00737 }
00738 
00739 void KateView::slotUpdate()
00740 {
00741   emit newStatus();
00742 
00743   slotNewUndo();
00744 }
00745 
00746 void KateView::slotReadWriteChanged ()
00747 {
00748   if ( m_toggleWriteLock )
00749     m_toggleWriteLock->setChecked( ! m_doc->isReadWrite() );
00750 
00751   m_cut->setEnabled (m_doc->isReadWrite());
00752   m_paste->setEnabled (m_doc->isReadWrite());
00753 
00754   QStringList l;
00755 
00756   l << "edit_replace" << "set_insert" << "tools_spelling" << "tools_indent"
00757       << "tools_unindent" << "tools_cleanIndent" << "tools_align"  << "tools_comment"
00758       << "tools_uncomment" << "tools_uppercase" << "tools_lowercase"
00759       << "tools_capitalize" << "tools_join_lines" << "tools_apply_wordwrap"
00760       << "edit_undo" << "edit_redo" << "tools_spelling_from_cursor"
00761       << "tools_spelling_selection";
00762 
00763   KAction *a = 0;
00764   for (uint z = 0; z < l.size(); z++)
00765     if ((a = actionCollection()->action( l[z].ascii() )))
00766       a->setEnabled (m_doc->isReadWrite());
00767 }
00768 
00769 void KateView::slotNewUndo()
00770 {
00771   if (m_doc->readOnly())
00772     return;
00773 
00774   if ((m_doc->undoCount() > 0) != m_editUndo->isEnabled())
00775     m_editUndo->setEnabled(m_doc->undoCount() > 0);
00776 
00777   if ((m_doc->redoCount() > 0) != m_editRedo->isEnabled())
00778     m_editRedo->setEnabled(m_doc->redoCount() > 0);
00779 }
00780 
00781 void KateView::slotDropEventPass( QDropEvent * ev )
00782 {
00783   KURL::List lstDragURLs;
00784   bool ok = KURLDrag::decode( ev, lstDragURLs );
00785 
00786   KParts::BrowserExtension * ext = KParts::BrowserExtension::childObject( doc() );
00787   if ( ok && ext )
00788     emit ext->openURLRequest( lstDragURLs.first() );
00789 }
00790 
00791 void KateView::contextMenuEvent( QContextMenuEvent *ev )
00792 {
00793   if ( !m_doc || !m_doc->browserExtension()  )
00794     return;
00795   emit m_doc->browserExtension()->popupMenu( /*this, */ev->globalPos(), m_doc->url(),
00796                                         QString::fromLatin1( "text/plain" ) );
00797   ev->accept();
00798 }
00799 
00800 bool KateView::setCursorPositionInternal( uint line, uint col, uint tabwidth, bool calledExternally )
00801 {
00802   KateTextLine::Ptr l = m_doc->kateTextLine( line );
00803 
00804   if (!l)
00805     return false;
00806 
00807   QString line_str = m_doc->textLine( line );
00808 
00809   uint z;
00810   uint x = 0;
00811   for (z = 0; z < line_str.length() && z < col; z++) {
00812     if (line_str[z] == QChar('\t')) x += tabwidth - (x % tabwidth); else x++;
00813   }
00814 
00815   m_viewInternal->updateCursor( KateTextCursor( line, x ), false, true, calledExternally );
00816 
00817   return true;
00818 }
00819 
00820 void KateView::setOverwriteMode( bool b )
00821 {
00822   if ( isOverwriteMode() && !b )
00823     m_doc->setConfigFlags( m_doc->config()->configFlags() ^ KateDocument::cfOvr );
00824   else
00825     m_doc->setConfigFlags( m_doc->config()->configFlags() | KateDocument::cfOvr );
00826 
00827   m_toggleInsert->setChecked (isOverwriteMode ());
00828 }
00829 
00830 void KateView::toggleInsert()
00831 {
00832   m_doc->setConfigFlags(m_doc->config()->configFlags() ^ KateDocument::cfOvr);
00833   m_toggleInsert->setChecked (isOverwriteMode ());
00834 
00835   emit newStatus();
00836 }
00837 
00838 bool KateView::canDiscard()
00839 {
00840   return m_doc->closeURL();
00841 }
00842 
00843 void KateView::flush()
00844 {
00845   m_doc->closeURL();
00846 }
00847 
00848 KateView::saveResult KateView::save()
00849 {
00850   if( !m_doc->url().isValid() || !doc()->isReadWrite() )
00851     return saveAs();
00852 
00853   if( m_doc->save() )
00854     return SAVE_OK;
00855 
00856   return SAVE_ERROR;
00857 }
00858 
00859 KateView::saveResult KateView::saveAs()
00860 {
00861 
00862   KEncodingFileDialog::Result res=KEncodingFileDialog::getSaveURLAndEncoding(doc()->config()->encoding(),
00863                 m_doc->url().url(),QString::null,this,i18n("Save File"));
00864 
00865 //   kdDebug()<<"urllist is emtpy?"<<res.URLs.isEmpty()<<endl;
00866 //   kdDebug()<<"url is:"<<res.URLs.first()<<endl;
00867   if( res.URLs.isEmpty() || !checkOverwrite( res.URLs.first() ) )
00868     return SAVE_CANCEL;
00869 
00870   m_doc->config()->setEncoding( res.encoding );
00871 
00872   if( m_doc->saveAs( res.URLs.first() ) )
00873     return SAVE_OK;
00874 
00875   return SAVE_ERROR;
00876 }
00877 
00878 bool KateView::checkOverwrite( KURL u )
00879 {
00880   if( !u.isLocalFile() )
00881     return true;
00882 
00883   QFileInfo info( u.path() );
00884   if( !info.exists() )
00885     return true;
00886 
00887   return KMessageBox::Continue
00888          == KMessageBox::warningContinueCancel
00889               ( this,
00890                 i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?" ).arg( info.fileName() ),
00891                 i18n( "Overwrite File?" ),
00892                 KGuiItem( i18n( "&Overwrite" ), "filesave", i18n( "Overwrite the file" ) )
00893               );
00894 }
00895 
00896 void KateView::slotSaveCanceled( const QString& error )
00897 {
00898   if ( !error.isEmpty() ) // happens when cancelling a job
00899     KMessageBox::error( this, error );
00900 }
00901 
00902 void KateView::gotoLine()
00903 {
00904   KateGotoLineDialog *dlg = new KateGotoLineDialog (this, m_viewInternal->getCursor().line() + 1, m_doc->numLines());
00905 
00906   if (dlg->exec() == QDialog::Accepted)
00907     gotoLineNumber( dlg->getLine() - 1 );
00908 
00909   delete dlg;
00910 }
00911 
00912 void KateView::gotoLineNumber( int line )
00913 {
00914   // clear selection, unless we are in persistent selection mode
00915   if ( !config()->persistentSelection() )
00916     clearSelection();
00917   setCursorPositionInternal ( line, 0, 1 );
00918 }
00919 
00920 void KateView::joinLines()
00921 {
00922   int first = selStartLine();
00923   int last = selEndLine();
00924   //int left = m_doc->textLine( last ).length() - m_doc->selEndCol();
00925   if ( first == last )
00926   {
00927     first = cursorLine();
00928     last = first + 1;
00929   }
00930   m_doc->joinLines( first, last );
00931 }
00932 
00933 void KateView::readSessionConfig(KConfig *config)
00934 {
00935   setCursorPositionInternal (config->readNumEntry("CursorLine"), config->readNumEntry("CursorColumn"), 1);
00936 }
00937 
00938 void KateView::writeSessionConfig(KConfig *config)
00939 {
00940   config->writeEntry("CursorLine",m_viewInternal->cursor.line());
00941   config->writeEntry("CursorColumn",m_viewInternal->cursor.col());
00942 }
00943 
00944 int KateView::getEol()
00945 {
00946   return m_doc->config()->eol();
00947 }
00948 
00949 void KateView::setEol(int eol)
00950 {
00951   if (!doc()->isReadWrite())
00952     return;
00953 
00954   if (m_updatingDocumentConfig)
00955     return;
00956 
00957   m_doc->config()->setEol (eol);
00958 }
00959 
00960 void KateView::setIconBorder( bool enable )
00961 {
00962   config()->setIconBar (enable);
00963 }
00964 
00965 void KateView::toggleIconBorder()
00966 {
00967   config()->setIconBar (!config()->iconBar());
00968 }
00969 
00970 void KateView::setLineNumbersOn( bool enable )
00971 {
00972   config()->setLineNumbers (enable);
00973 }
00974 
00975 void KateView::toggleLineNumbersOn()
00976 {
00977   config()->setLineNumbers (!config()->lineNumbers());
00978 }
00979 
00980 void KateView::setScrollBarMarks( bool enable )
00981 {
00982   config()->setScrollBarMarks (enable);
00983 }
00984 
00985 void KateView::toggleScrollBarMarks()
00986 {
00987   config()->setScrollBarMarks (!config()->scrollBarMarks());
00988 }
00989 
00990 void KateView::toggleDynWordWrap()
00991 {
00992   config()->setDynWordWrap( !config()->dynWordWrap() );
00993 }
00994 
00995 void KateView::setDynWordWrap( bool b )
00996 {
00997   config()->setDynWordWrap( b );
00998 }
00999 
01000 void KateView::toggleWWMarker()
01001 {
01002   m_renderer->config()->setWordWrapMarker (!m_renderer->config()->wordWrapMarker());
01003 }
01004 
01005 void KateView::setFoldingMarkersOn( bool enable )
01006 {
01007   config()->setFoldingBar ( enable );
01008 }
01009 
01010 void KateView::toggleFoldingMarkers()
01011 {
01012   config()->setFoldingBar ( !config()->foldingBar() );
01013 }
01014 
01015 bool KateView::iconBorder() {
01016   return m_viewInternal->leftBorder->iconBorderOn();
01017 }
01018 
01019 bool KateView::lineNumbersOn() {
01020   return m_viewInternal->leftBorder->lineNumbersOn();
01021 }
01022 
01023 bool KateView::scrollBarMarks() {
01024   return m_viewInternal->m_lineScroll->showMarks();
01025 }
01026 
01027 int KateView::dynWrapIndicators() {
01028   return m_viewInternal->leftBorder->dynWrapIndicators();
01029 }
01030 
01031 bool KateView::foldingMarkersOn() {
01032   return m_viewInternal->leftBorder->foldingMarkersOn();
01033 }
01034 
01035 void KateView::showCmdLine ( bool enabled )
01036 {
01037   if (enabled == m_cmdLineOn)
01038     return;
01039 
01040   if (enabled)
01041   {
01042     if (!m_cmdLine)
01043     {
01044       m_cmdLine = new KateCmdLine (this);
01045       m_grid->addMultiCellWidget (m_cmdLine, 2, 2, 0, 2);
01046     }
01047 
01048     m_cmdLine->show ();
01049     m_cmdLine->setFocus();
01050   }
01051   else {
01052     m_cmdLine->hide ();
01053     //m_toggleCmdLine->setChecked(false);
01054   }
01055 
01056   m_cmdLineOn = enabled;
01057 }
01058 
01059 void KateView::toggleCmdLine ()
01060 {
01061   m_config->setCmdLine (!m_config->cmdLine ());
01062 }
01063 
01064 void KateView::toggleWriteLock()
01065 {
01066   m_doc->setReadWrite( ! m_doc->isReadWrite() );
01067 }
01068 
01069 void KateView::enableTextHints(int timeout)
01070 {
01071   m_viewInternal->enableTextHints(timeout);
01072 }
01073 
01074 void KateView::disableTextHints()
01075 {
01076   m_viewInternal->disableTextHints();
01077 }
01078 
01079 void KateView::applyWordWrap ()
01080 {
01081   if (hasSelection())
01082     m_doc->wrapText (selectStart.line(), selectEnd.line());
01083   else
01084     m_doc->wrapText (0, m_doc->lastLine());
01085 }
01086 
01087 void KateView::slotNeedTextHint(int line, int col, QString &text)
01088 {
01089   text=QString("test %1 %2").arg(line).arg(col);
01090 }
01091 
01092 void KateView::find()
01093 {
01094   m_search->find();
01095 }
01096 
01097 void KateView::find( const QString& pattern, long flags, bool add )
01098 {
01099   m_search->find( pattern, flags, add );
01100 }
01101 
01102 void KateView::replace()
01103 {
01104   m_search->replace();
01105 }
01106 
01107 void KateView::replace( const QString &pattern, const QString &replacement, long flags )
01108 {
01109   m_search->replace( pattern, replacement, flags );
01110 }
01111 
01112 void KateView::findAgain( bool back )
01113 {
01114   m_search->findAgain( back );
01115 }
01116 
01117 void KateView::slotSelectionChanged ()
01118 {
01119   m_copy->setEnabled (hasSelection());
01120   m_copyHTML->setEnabled (hasSelection());
01121   m_deSelect->setEnabled (hasSelection());
01122 
01123   if (m_doc->readOnly())
01124     return;
01125 
01126   m_cut->setEnabled (hasSelection());
01127 
01128   m_spell->updateActions ();
01129 }
01130 
01131 void KateView::switchToCmdLine ()
01132 {
01133   if (!m_cmdLineOn)
01134     m_config->setCmdLine (true);
01135   else {
01136     if (m_cmdLine->hasFocus()) {
01137         this->setFocus();
01138         return;
01139     }
01140   }
01141   m_cmdLine->setFocus ();
01142 }
01143 
01144 void KateView::showArgHint( QStringList arg1, const QString& arg2, const QString& arg3 )
01145 {
01146   m_codeCompletion->showArgHint( arg1, arg2, arg3 );
01147 }
01148 
01149 void KateView::showCompletionBox( QValueList<KTextEditor::CompletionEntry> arg1, int offset, bool cs )
01150 {
01151   emit aboutToShowCompletionBox();
01152   m_codeCompletion->showCompletionBox( arg1, offset, cs );
01153 }
01154 
01155 KateRenderer *KateView::renderer ()
01156 {
01157   return m_renderer;
01158 }
01159 
01160 void KateView::updateConfig ()
01161 {
01162   if (m_startingUp)
01163     return;
01164 
01165   m_editActions->readShortcutSettings( "Katepart Shortcuts" );
01166 
01167   // dyn. word wrap & markers
01168   if (m_hasWrap != config()->dynWordWrap()) {
01169     m_viewInternal->prepareForDynWrapChange();
01170 
01171     m_hasWrap = config()->dynWordWrap();
01172 
01173     m_viewInternal->dynWrapChanged();
01174 
01175     m_setDynWrapIndicators->setEnabled(config()->dynWordWrap());
01176     m_toggleDynWrap->setChecked( config()->dynWordWrap() );
01177   }
01178 
01179   m_viewInternal->leftBorder->setDynWrapIndicators( config()->dynWordWrapIndicators() );
01180   m_setDynWrapIndicators->setCurrentItem( config()->dynWordWrapIndicators() );
01181 
01182   // line numbers
01183   m_viewInternal->leftBorder->setLineNumbersOn( config()->lineNumbers() );
01184   m_toggleLineNumbers->setChecked( config()->lineNumbers() );
01185 
01186   // icon bar
01187   m_viewInternal->leftBorder->setIconBorderOn( config()->iconBar() );
01188   m_toggleIconBar->setChecked( config()->iconBar() );
01189 
01190   // scrollbar marks
01191   m_viewInternal->m_lineScroll->setShowMarks( config()->scrollBarMarks() );
01192   m_toggleScrollBarMarks->setChecked( config()->scrollBarMarks() );
01193 
01194   // cmd line
01195   showCmdLine (config()->cmdLine());
01196   //m_toggleCmdLine->setChecked( config()->cmdLine() );
01197 
01198   // misc edit
01199   m_toggleBlockSelection->setChecked( blockSelectionMode() );
01200   m_toggleInsert->setChecked( isOverwriteMode() );
01201 
01202   updateFoldingConfig ();
01203 
01204   // bookmark
01205   m_bookmarks->setSorting( (KateBookmarks::Sorting) config()->bookmarkSort() );
01206 
01207   m_viewInternal->setAutoCenterLines(config()->autoCenterLines ());
01208 }
01209 
01210 void KateView::updateDocumentConfig()
01211 {
01212   if (m_startingUp)
01213     return;
01214 
01215   m_updatingDocumentConfig = true;
01216 
01217   m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
01218 
01219   m_updatingDocumentConfig = false;
01220 
01221   m_viewInternal->updateView (true);
01222 
01223   m_renderer->setTabWidth (m_doc->config()->tabWidth());
01224   m_renderer->setIndentWidth (m_doc->config()->indentationWidth());
01225 }
01226 
01227 void KateView::updateRendererConfig()
01228 {
01229   if (m_startingUp)
01230     return;
01231 
01232   m_toggleWWMarker->setChecked( m_renderer->config()->wordWrapMarker()  );
01233 
01234   // update the text area
01235   m_viewInternal->updateView (true);
01236   m_viewInternal->repaint ();
01237 
01238   // update the left border right, for example linenumbers
01239   m_viewInternal->leftBorder->updateFont();
01240   m_viewInternal->leftBorder->repaint ();
01241 
01242 // @@ showIndentLines is not cached anymore.
01243 //  m_renderer->setShowIndentLines (m_renderer->config()->showIndentationLines());
01244 }
01245 
01246 void KateView::updateFoldingConfig ()
01247 {
01248   // folding bar
01249   bool doit = config()->foldingBar() && m_doc->highlight() && m_doc->highlight()->allowsFolding();
01250   m_viewInternal->leftBorder->setFoldingMarkersOn(doit);
01251   m_toggleFoldingMarkers->setChecked( doit );
01252   m_toggleFoldingMarkers->setEnabled( m_doc->highlight() && m_doc->highlight()->allowsFolding() );
01253 
01254   QStringList l;
01255 
01256   l << "folding_toplevel" << "folding_expandtoplevel"
01257     << "folding_collapselocal" << "folding_expandlocal";
01258 
01259   KAction *a = 0;
01260   for (uint z = 0; z < l.size(); z++)
01261     if ((a = actionCollection()->action( l[z].ascii() )))
01262       a->setEnabled (m_doc->highlight() && m_doc->highlight()->allowsFolding());
01263 }
01264 
01265 //BEGIN EDIT STUFF
01266 void KateView::editStart ()
01267 {
01268   m_viewInternal->editStart ();
01269 }
01270 
01271 void KateView::editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom)
01272 {
01273   m_viewInternal->editEnd (editTagLineStart, editTagLineEnd, tagFrom);
01274 }
01275 
01276 void KateView::editSetCursor (const KateTextCursor &cursor)
01277 {
01278   m_viewInternal->editSetCursor (cursor);
01279 }
01280 //END
01281 
01282 //BEGIN TAG & CLEAR
01283 bool KateView::tagLine (const KateTextCursor& virtualCursor)
01284 {
01285   return m_viewInternal->tagLine (virtualCursor);
01286 }
01287 
01288 bool KateView::tagLines (int start, int end, bool realLines)
01289 {
01290   return m_viewInternal->tagLines (start, end, realLines);
01291 }
01292 
01293 bool KateView::tagLines (KateTextCursor start, KateTextCursor end, bool realCursors)
01294 {
01295   return m_viewInternal->tagLines (start, end, realCursors);
01296 }
01297 
01298 void KateView::tagAll ()
01299 {
01300   m_viewInternal->tagAll ();
01301 }
01302 
01303 void KateView::clear ()
01304 {
01305   m_viewInternal->clear ();
01306 }
01307 
01308 void KateView::repaintText (bool paintOnlyDirty)
01309 {
01310   m_viewInternal->paintText(0,0,m_viewInternal->width(),m_viewInternal->height(), paintOnlyDirty);
01311 }
01312 
01313 void KateView::updateView (bool changed)
01314 {
01315   m_viewInternal->updateView (changed);
01316   m_viewInternal->leftBorder->update();
01317 }
01318 
01319 //END
01320 
01321 void KateView::slotHlChanged()
01322 {
01323   KateHighlighting *hl = m_doc->highlight();
01324   bool ok ( !hl->getCommentStart(0).isEmpty() || !hl->getCommentSingleLineStart(0).isEmpty() );
01325 
01326   if (actionCollection()->action("tools_comment"))
01327     actionCollection()->action("tools_comment")->setEnabled( ok );
01328 
01329   if (actionCollection()->action("tools_uncomment"))
01330     actionCollection()->action("tools_uncomment")->setEnabled( ok );
01331 
01332   // show folding bar if "view defaults" says so, otherwise enable/disable only the menu entry
01333   updateFoldingConfig ();
01334 }
01335 
01336 uint KateView::cursorColumn()
01337 {
01338   uint r = m_doc->currentColumn(m_viewInternal->getCursor());
01339   if ( !( m_doc->config()->configFlags() & KateDocumentConfig::cfWrapCursor ) &&
01340        (uint)m_viewInternal->getCursor().col() > m_doc->textLine( m_viewInternal->getCursor().line() ).length()  )
01341     r += m_viewInternal->getCursor().col() - m_doc->textLine( m_viewInternal->getCursor().line() ).length();
01342 
01343   return r;
01344 }
01345 
01346 //BEGIN KTextEditor::SelectionInterface stuff
01347 
01348 bool KateView::setSelection( const KateTextCursor& start, const KateTextCursor& end )
01349 {
01350   KateTextCursor oldSelectStart = selectStart;
01351   KateTextCursor oldSelectEnd = selectEnd;
01352 
01353   if (start <= end) {
01354     selectStart.setPos(start);
01355     selectEnd.setPos(end);
01356   } else {
01357     selectStart.setPos(end);
01358     selectEnd.setPos(start);
01359   }
01360 
01361   tagSelection(oldSelectStart, oldSelectEnd);
01362 
01363   repaintText(true);
01364 
01365   emit selectionChanged ();
01366   emit m_doc->selectionChanged ();
01367 
01368   return true;
01369 }
01370 
01371 bool KateView::setSelection( uint startLine, uint startCol, uint endLine, uint endCol )
01372 {
01373   if (hasSelection())
01374     clearSelection(false, false);
01375 
01376   return setSelection( KateTextCursor(startLine, startCol), KateTextCursor(endLine, endCol) );
01377 }
01378 
01379 void KateView::syncSelectionCache()
01380 {
01381   m_viewInternal->selStartCached = selectStart;
01382   m_viewInternal->selEndCached = selectEnd;
01383   m_viewInternal->selectAnchor = selectEnd;
01384 }
01385 
01386 bool KateView::clearSelection()
01387 {
01388   return clearSelection(true);
01389 }
01390 
01391 bool KateView::clearSelection(bool redraw, bool finishedChangingSelection)
01392 {
01393   if( !hasSelection() )
01394     return false;
01395 
01396   KateTextCursor oldSelectStart = selectStart;
01397   KateTextCursor oldSelectEnd = selectEnd;
01398 
01399   selectStart.setPos(-1, -1);
01400   selectEnd.setPos(-1, -1);
01401 
01402   tagSelection(oldSelectStart, oldSelectEnd);
01403 
01404   oldSelectStart = selectStart;
01405   oldSelectEnd = selectEnd;
01406 
01407   if (redraw)
01408     repaintText(true);
01409 
01410   if (finishedChangingSelection)
01411   {
01412     emit selectionChanged();
01413     emit m_doc->selectionChanged ();
01414   }
01415 
01416   return true;
01417 }
01418 
01419 bool KateView::hasSelection() const
01420 {
01421   return selectStart != selectEnd;
01422 }
01423 
01424 QString KateView::selection() const
01425 {
01426   int sc = selectStart.col();
01427   int ec = selectEnd.col();
01428 
01429   if ( blockSelect )
01430   {
01431     if (sc > ec)
01432     {
01433       uint tmp = sc;
01434       sc = ec;
01435       ec = tmp;
01436     }
01437   }
01438   return m_doc->text (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
01439 }
01440 
01441 bool KateView::removeSelectedText ()
01442 {
01443   if (!hasSelection())
01444     return false;
01445 
01446   m_doc->editStart ();
01447 
01448   int sc = selectStart.col();
01449   int ec = selectEnd.col();
01450 
01451   if ( blockSelect )
01452   {
01453     if (sc > ec)
01454     {
01455       uint tmp = sc;
01456       sc = ec;
01457       ec = tmp;
01458     }
01459   }
01460 
01461   m_doc->removeText (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
01462 
01463   // don't redraw the cleared selection - that's done in editEnd().
01464   clearSelection(false);
01465 
01466   m_doc->editEnd ();
01467 
01468   return true;
01469 }
01470 
01471 bool KateView::selectAll()
01472 {
01473   setBlockSelectionMode (false);
01474 
01475   return setSelection (0, 0, m_doc->lastLine(), m_doc->lineLength(m_doc->lastLine()));
01476 }
01477 
01478 bool KateView::lineColSelected (int line, int col)
01479 {
01480   if ( (!blockSelect) && (col < 0) )
01481     col = 0;
01482 
01483   KateTextCursor cursor(line, col);
01484 
01485   if (blockSelect)
01486     return cursor.line() >= selectStart.line() && cursor.line() <= selectEnd.line() && cursor.col() >= selectStart.col() && cursor.col() < selectEnd.col();
01487   else
01488     return (cursor >= selectStart) && (cursor < selectEnd);
01489 }
01490 
01491 bool KateView::lineSelected (int line)
01492 {
01493   return (!blockSelect)
01494     && (selectStart <= KateTextCursor(line, 0))
01495     && (line < selectEnd.line());
01496 }
01497 
01498 bool KateView::lineEndSelected (int line, int endCol)
01499 {
01500   return (!blockSelect)
01501     && (line > selectStart.line() || (line == selectStart.line() && (selectStart.col() < endCol || endCol == -1)))
01502     && (line < selectEnd.line() || (line == selectEnd.line() && (endCol <= selectEnd.col() && endCol != -1)));
01503 }
01504 
01505 bool KateView::lineHasSelected (int line)
01506 {
01507   return (selectStart < selectEnd)
01508     && (line >= selectStart.line())
01509     && (line <= selectEnd.line());
01510 }
01511 
01512 bool KateView::lineIsSelection (int line)
01513 {
01514   return (line == selectStart.line() && line == selectEnd.line());
01515 }
01516 
01517 void KateView::tagSelection(const KateTextCursor &oldSelectStart, const KateTextCursor &oldSelectEnd)
01518 {
01519   if (hasSelection()) {
01520     if (oldSelectStart.line() == -1) {
01521       // We have to tag the whole lot if
01522       // 1) we have a selection, and:
01523       //  a) it's new; or
01524       tagLines(selectStart, selectEnd, true);
01525 
01526     } else if (blockSelectionMode() && (oldSelectStart.col() != selectStart.col() || oldSelectEnd.col() != selectEnd.col())) {
01527       //  b) we're in block selection mode and the columns have changed
01528       tagLines(selectStart, selectEnd, true);
01529       tagLines(oldSelectStart, oldSelectEnd, true);
01530 
01531     } else {
01532       if (oldSelectStart != selectStart) {
01533         if (oldSelectStart < selectStart)
01534           tagLines(oldSelectStart, selectStart, true);
01535         else
01536           tagLines(selectStart, oldSelectStart, true);
01537       }
01538 
01539       if (oldSelectEnd != selectEnd) {
01540         if (oldSelectEnd < selectEnd)
01541           tagLines(oldSelectEnd, selectEnd, true);
01542         else
01543           tagLines(selectEnd, oldSelectEnd, true);
01544       }
01545     }
01546 
01547   } else {
01548     // No more selection, clean up
01549     tagLines(oldSelectStart, oldSelectEnd, true);
01550   }
01551 }
01552 
01553 void KateView::selectWord( const KateTextCursor& cursor )
01554 {
01555   int start, end, len;
01556 
01557   KateTextLine::Ptr textLine = m_doc->plainKateTextLine(cursor.line());
01558 
01559   if (!textLine)
01560     return;
01561 
01562   len = textLine->length();
01563   start = end = cursor.col();
01564   while (start > 0 && m_doc->highlight()->isInWord(textLine->getChar(start - 1), textLine->attribute(start - 1))) start--;
01565   while (end < len && m_doc->highlight()->isInWord(textLine->getChar(end), textLine->attribute(start - 1))) end++;
01566   if (end <= start) return;
01567 
01568   setSelection (cursor.line(), start, cursor.line(), end);
01569 }
01570 
01571 void KateView::selectLine( const KateTextCursor& cursor )
01572 {
01573   if (cursor.line()+1 >= m_doc->numLines())
01574     setSelection (cursor.line(), 0, cursor.line(), m_doc->lineLength(cursor.line()));
01575   else
01576     setSelection (cursor.line(), 0, cursor.line()+1, 0);
01577 }
01578 
01579 void KateView::selectLength( const KateTextCursor& cursor, int length )
01580 {
01581   int start, end;
01582 
01583   KateTextLine::Ptr textLine = m_doc->plainKateTextLine(cursor.line());
01584 
01585   if (!textLine)
01586     return;
01587 
01588   start = cursor.col();
01589   end = start + length;
01590   if (end <= start) return;
01591 
01592   setSelection (cursor.line(), start, cursor.line(), end);
01593 }
01594 
01595 void KateView::paste()
01596 {
01597   m_doc->paste( this );
01598   emit selectionChanged();
01599   m_viewInternal->repaint();
01600 }
01601 
01602 void KateView::cut()
01603 {
01604   if (!hasSelection())
01605     return;
01606 
01607   copy();
01608   removeSelectedText();
01609 }
01610 
01611 void KateView::copy() const
01612 {
01613   if (!hasSelection())
01614     return;
01615 
01616   QApplication::clipboard()->setText(selection ());
01617 }
01618 
01619 void KateView::copyHTML()
01620 {
01621   if (!hasSelection())
01622     return;
01623 
01624   KMultipleDrag *drag = new KMultipleDrag();
01625 
01626   QTextDrag *htmltextdrag = new QTextDrag(selectionAsHtml()) ;
01627   htmltextdrag->setSubtype("html");
01628 
01629   drag->addDragObject( htmltextdrag);
01630   drag->addDragObject( new QTextDrag( selection()));
01631 
01632   QApplication::clipboard()->setData(drag);
01633 }
01634 
01635 QString KateView::selectionAsHtml()
01636 {
01637   int sc = selectStart.col();
01638   int ec = selectEnd.col();
01639 
01640   if ( blockSelect )
01641   {
01642     if (sc > ec)
01643     {
01644       uint tmp = sc;
01645       sc = ec;
01646       ec = tmp;
01647     }
01648   }
01649 
01650   return textAsHtml (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
01651 }
01652 
01653 QString KateView::textAsHtml ( uint startLine, uint startCol, uint endLine, uint endCol, bool blockwise)
01654 {
01655   kdDebug(13020) << "textAsHtml" << endl;
01656   if ( blockwise && (startCol > endCol) )
01657     return QString ();
01658 
01659   QString s;
01660   QTextStream ts( &s, IO_WriteOnly );
01661   ts.setEncoding(QTextStream::UnicodeUTF8);
01662   ts << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">" << endl;
01663   ts << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl;
01664   ts << "<head>" << endl;
01665   ts << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" << endl;
01666   ts << "<meta name=\"Generator\" content=\"Kate, the KDE Advanced Text Editor\" />" << endl;
01667   ts << "</head>" << endl;
01668 
01669   ts << "<body>" << endl;
01670   textAsHtmlStream(startLine, startCol, endLine, endCol, blockwise, &ts);
01671 
01672   ts << "</body>" << endl;
01673   ts << "</html>" << endl;
01674   kdDebug(13020) << "html is: " << s << endl;
01675   return s;
01676 }
01677 
01678 void KateView::textAsHtmlStream ( uint startLine, uint startCol, uint endLine, uint endCol, bool blockwise, QTextStream *ts)
01679 {
01680   if ( (blockwise || startLine == endLine) && (startCol > endCol) )
01681     return;
01682 
01683   if (startLine == endLine)
01684   {
01685     KateTextLine::Ptr textLine = m_doc->kateTextLine(startLine);
01686     if ( !textLine )
01687       return;
01688 
01689     (*ts) << "<pre>" << endl;
01690 
01691     lineAsHTML(textLine, startCol, endCol-startCol, ts);
01692   }
01693   else
01694   {
01695     (*ts) << "<pre>" << endl;
01696 
01697     for (uint i = startLine; (i <= endLine) && (i < m_doc->numLines()); i++)
01698     {
01699       KateTextLine::Ptr textLine = m_doc->kateTextLine(i);
01700 
01701       if ( !blockwise )
01702       {
01703         if (i == startLine)
01704           lineAsHTML(textLine, startCol, textLine->length()-startCol, ts);
01705         else if (i == endLine)
01706           lineAsHTML(textLine, 0, endCol, ts);
01707         else
01708           lineAsHTML(textLine, 0, textLine->length(), ts);
01709       }
01710       else
01711       {
01712         lineAsHTML( textLine, startCol, endCol-startCol, ts);
01713       }
01714 
01715       if ( i < endLine )
01716         (*ts) << "\n";    //we are inside a <pre>, so a \n is a new line
01717     }
01718   }
01719   (*ts) << "</pre>";
01720 }
01721 
01722 // fully rewritten to use only inline CSS and support all used attribs.
01723 // anders, 2005-11-01 23:39:43
01724 void KateView::lineAsHTML (KateTextLine::Ptr line, uint startCol, uint length, QTextStream *outputStream)
01725 {
01726   if(length == 0)
01727     return;
01728 
01729   // do not recalculate the style strings again and again
01730   QMap<uchar,QString> stylecache;
01731   // do not insert equally styled characters one by one
01732   QString textcache;
01733 
01734   KateAttribute *charAttributes = 0;
01735 
01736   for (uint curPos=startCol;curPos<(length+startCol);curPos++)
01737   {
01738     if ( curPos == 0 || line->attribute( curPos ) != line->attribute( curPos - 1 ) &&
01739          // Since many highlight files contains itemdatas that have the exact
01740          // same styles, join those to keep the HTML text size down
01741          KateAttribute(*charAttributes) != KateAttribute(*m_renderer->attribute(line->attribute(curPos))) )
01742     {
01743       (*outputStream) << textcache;
01744       textcache.truncate(0);
01745 
01746       if ( curPos > startCol )
01747         (*outputStream) << "</span>";
01748 
01749       charAttributes = m_renderer->attribute(line->attribute(curPos));
01750 
01751       if ( ! stylecache.contains( line->attribute(curPos) ) )
01752       {
01753         QString textdecoration;
01754         QString style;
01755 
01756         if ( charAttributes->bold() )
01757           style.append("font-weight: bold;");
01758         if ( charAttributes->italic() )
01759           style.append("font-style: italic;");
01760         if ( charAttributes->underline() )
01761           textdecoration = "underline";
01762         if ( charAttributes->overline() )
01763           textdecoration.append(" overline" );
01764         if ( charAttributes->strikeOut() )
01765           textdecoration.append(" line-trough" );
01766         if ( !textdecoration.isEmpty() )
01767           style.append("text-decoration: %1;").arg(textdecoration);
01768         // QColor::name() returns a string in the form "#RRGGBB" in Qt 3.
01769         // NOTE Qt 4 returns "#AARRGGBB"
01770         if ( charAttributes->itemSet(KateAttribute::BGColor) )
01771           style.append(QString("background-color: %1;").arg(charAttributes->bgColor().name()));
01772         if ( charAttributes->itemSet(KateAttribute::TextColor) )
01773           style.append(QString("color: %1;").arg(charAttributes->textColor().name()));
01774 
01775         stylecache[line->attribute(curPos)] = style;
01776       }
01777       (*outputStream)<<"<span style=\""
01778           << stylecache[line->attribute(curPos)]
01779           << "\">";
01780     }
01781 
01782     QString s( line->getChar(curPos) );
01783     if ( s == "&" ) s = "&amp;";
01784     else if ( s == "<" ) s = "&lt;";
01785     else if ( s == ">" ) s = "&gt;";
01786     textcache.append( s );
01787   }
01788 
01789   (*outputStream) << textcache << "</span>";
01790 }
01791 
01792 void KateView::exportAsHTML ()
01793 {
01794   KURL url = KFileDialog::getSaveURL(m_doc->docName(),"text/html",0,i18n("Export File as HTML"));
01795 
01796   if ( url.isEmpty() )
01797     return;
01798 
01799   QString filename;
01800   KTempFile tmp; // ### only used for network export
01801 
01802   if ( url.isLocalFile() )
01803     filename = url.path();
01804   else
01805     filename = tmp.name();
01806 
01807   KSaveFile *savefile=new KSaveFile(filename);
01808   if (!savefile->status())
01809   {
01810     QTextStream *outputStream = savefile->textStream();
01811 
01812     outputStream->setEncoding(QTextStream::UnicodeUTF8);
01813 
01814     // let's write the HTML header :
01815     (*outputStream) << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
01816     (*outputStream) << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">" << endl;
01817     (*outputStream) << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl;
01818     (*outputStream) << "<head>" << endl;
01819     (*outputStream) << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" << endl;
01820     (*outputStream) << "<meta name=\"Generator\" content=\"Kate, the KDE Advanced Text Editor\" />" << endl;
01821     // for the title, we write the name of the file (/usr/local/emmanuel/myfile.cpp -> myfile.cpp)
01822     (*outputStream) << "<title>" << m_doc->docName () << "</title>" << endl;
01823     (*outputStream) << "</head>" << endl;
01824     (*outputStream) << "<body>" << endl;
01825 
01826     textAsHtmlStream(0,0, m_doc->lastLine(), m_doc->lineLength(m_doc->lastLine()), false, outputStream);
01827 
01828     (*outputStream) << "</body>" << endl;
01829     (*outputStream) << "</html>" << endl;
01830 
01831 
01832     savefile->close();
01833     //if (!savefile->status()) --> Error
01834   }
01835 //     else
01836 //       {/*ERROR*/}
01837   delete savefile;
01838 
01839   if ( url.isLocalFile() )
01840       return;
01841 
01842   KIO::NetAccess::upload( filename, url, 0 );
01843 }
01844 //END
01845 
01846 //BEGIN KTextEditor::BlockSelectionInterface stuff
01847 
01848 bool KateView::blockSelectionMode ()
01849 {
01850   return blockSelect;
01851 }
01852 
01853 bool KateView::setBlockSelectionMode (bool on)
01854 {
01855   if (on != blockSelect)
01856   {
01857     blockSelect = on;
01858 
01859     KateTextCursor oldSelectStart = selectStart;
01860     KateTextCursor oldSelectEnd = selectEnd;
01861 
01862     clearSelection(false, false);
01863 
01864     setSelection(oldSelectStart, oldSelectEnd);
01865 
01866     slotSelectionTypeChanged();
01867   }
01868 
01869   return true;
01870 }
01871 
01872 bool KateView::toggleBlockSelectionMode ()
01873 {
01874   m_toggleBlockSelection->setChecked (!blockSelect);
01875   return setBlockSelectionMode (!blockSelect);
01876 }
01877 
01878 bool KateView::wrapCursor ()
01879 {
01880   return !blockSelectionMode() && (m_doc->configFlags() & KateDocument::cfWrapCursor);
01881 }
01882 
01883 //END
01884 
01885 //BEGIN IM INPUT STUFF
01886 void KateView::setIMSelectionValue( uint imStartLine, uint imStart, uint imEnd,
01887                                         uint imSelStart, uint imSelEnd, bool imComposeEvent )
01888 {
01889   m_imStartLine = imStartLine;
01890   m_imStart = imStart;
01891   m_imEnd = imEnd;
01892   m_imSelStart = imSelStart;
01893   m_imSelEnd = imSelEnd;
01894   m_imComposeEvent = imComposeEvent;
01895 }
01896 
01897 bool KateView::isIMSelection( int _line, int _column )
01898 {
01899   return ( ( int( m_imStartLine ) == _line ) && ( m_imSelStart < m_imSelEnd ) && ( _column >= int( m_imSelStart ) ) &&
01900     ( _column < int( m_imSelEnd ) ) );
01901 }
01902 
01903 bool KateView::isIMEdit( int _line, int _column )
01904 {
01905   return ( ( int( m_imStartLine ) == _line ) && ( m_imStart < m_imEnd ) && ( _column >= int( m_imStart ) ) &&
01906     ( _column < int( m_imEnd ) ) );
01907 }
01908 
01909 void KateView::getIMSelectionValue( uint *imStartLine, uint *imStart, uint *imEnd,
01910                                         uint *imSelStart, uint *imSelEnd )
01911 {
01912   *imStartLine = m_imStartLine;
01913   *imStart = m_imStart;
01914   *imEnd = m_imEnd;
01915   *imSelStart = m_imSelStart;
01916   *imSelEnd = m_imSelEnd;
01917 }
01918 //END IM INPUT STUFF
01919 
01920 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal