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