kate Library API Documentation

kateview.cpp

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