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