• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
kateview.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
3  Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
4  Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org>
5  Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
6  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License version 2 as published by the Free Software Foundation.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #define DEBUGACCELS
24 
25 //BEGIN includes
26 #include "kateview.h"
27 #include "kateview.moc"
28 
29 #include "kateviewinternal.h"
30 #include "kateviewhelpers.h"
31 #include "katerenderer.h"
32 #include "katedocument.h"
33 #include "katedocumenthelpers.h"
34 #include "katefactory.h"
35 #include "katehighlight.h"
36 #include "katedialogs.h"
37 #include "katetextline.h"
38 #include "katecodefoldinghelpers.h"
39 #include "katecodecompletion.h"
40 #include "katesearch.h"
41 #include "kateschema.h"
42 #include "katebookmarks.h"
43 #include "katesearch.h"
44 #include "kateconfig.h"
45 #include "katefiletype.h"
46 #include "kateautoindent.h"
47 #include "katespell.h"
48 
49 #include <tdetexteditor/plugin.h>
50 
51 #include <tdeparts/event.h>
52 
53 #include <tdeio/netaccess.h>
54 
55 #include <tdeconfig.h>
56 #include <kurldrag.h>
57 #include <kdebug.h>
58 #include <tdeapplication.h>
59 #include <kcursor.h>
60 #include <tdelocale.h>
61 #include <tdeglobal.h>
62 #include <kcharsets.h>
63 #include <tdemessagebox.h>
64 #include <tdeaction.h>
65 #include <kstdaction.h>
66 #include <kxmlguifactory.h>
67 #include <tdeaccel.h>
68 #include <klibloader.h>
69 #include <kencodingfiledialog.h>
70 #include <tdemultipledrag.h>
71 #include <tdetempfile.h>
72 #include <ksavefile.h>
73 
74 #include <tqfont.h>
75 #include <tqfileinfo.h>
76 #include <tqstyle.h>
77 #include <tqevent.h>
78 #include <tqpopupmenu.h>
79 #include <tqlayout.h>
80 #include <tqclipboard.h>
81 #include <tqstylesheet.h>
82 //END includes
83 
84 KateView::KateView( KateDocument *doc, TQWidget *parent, const char * name )
85  : Kate::View( doc, parent, name )
86  , m_doc( doc )
87  , m_search( new KateSearch( this ) )
88  , m_spell( new KateSpell( this ) )
89  , m_bookmarks( new KateBookmarks( this ) )
90  , m_cmdLine (0)
91  , m_cmdLineOn (false)
92  , m_active( false )
93  , m_hasWrap( false )
94  , m_startingUp (true)
95  , m_updatingDocumentConfig (false)
96  , selectStart (m_doc, true)
97  , selectEnd (m_doc, true)
98  , blockSelect (false)
99  , m_imStartLine( 0 )
100  , m_imStart( 0 )
101  , m_imEnd( 0 )
102  , m_imSelStart( 0 )
103  , m_imSelEnd( 0 )
104  , m_imComposeEvent( false )
105 {
106  KateFactory::self()->registerView( this );
107  m_config = new KateViewConfig (this);
108 
109  m_renderer = new KateRenderer(doc, this);
110 
111  m_grid = new TQGridLayout (this, 3, 3);
112 
113  m_grid->setRowStretch ( 0, 10 );
114  m_grid->setRowStretch ( 1, 0 );
115  m_grid->setColStretch ( 0, 0 );
116  m_grid->setColStretch ( 1, 10 );
117  m_grid->setColStretch ( 2, 0 );
118 
119  m_viewInternal = new KateViewInternal( this, doc );
120  m_grid->addWidget (m_viewInternal, 0, 1);
121 
122  setClipboardInterfaceDCOPSuffix (viewDCOPSuffix());
123  setCodeCompletionInterfaceDCOPSuffix (viewDCOPSuffix());
124  setDynWordWrapInterfaceDCOPSuffix (viewDCOPSuffix());
125  setPopupMenuInterfaceDCOPSuffix (viewDCOPSuffix());
126  setSessionConfigInterfaceDCOPSuffix (viewDCOPSuffix());
127  setViewCursorInterfaceDCOPSuffix (viewDCOPSuffix());
128  setViewStatusMsgInterfaceDCOPSuffix (viewDCOPSuffix());
129 
130  setInstance( KateFactory::self()->instance() );
131  doc->addView( this );
132 
133  setFocusProxy( m_viewInternal );
134  setFocusPolicy( TQWidget::StrongFocus );
135 
136  if (!doc->singleViewMode()) {
137  setXMLFile( "katepartui.rc" );
138  } else {
139  if( doc->readOnly() )
140  setXMLFile( "katepartreadonlyui.rc" );
141  else
142  setXMLFile( "katepartui.rc" );
143  }
144 
145  setupConnections();
146  setupActions();
147  setupEditActions();
148  setupCodeFolding();
149  setupCodeCompletion();
150 
151  // enable the plugins of this view
152  m_doc->enableAllPluginsGUI (this);
153 
154  // update the enabled state of the undo/redo actions...
155  slotNewUndo();
156 
157  m_startingUp = false;
158  updateConfig ();
159 
160  slotHlChanged();
161  /*test texthint
162  connect(this,TQ_SIGNAL(needTextHint(int, int, TQString &)),
163  this,TQ_SLOT(slotNeedTextHint(int, int, TQString &)));
164  enableTextHints(1000);
165  test texthint*/
166 }
167 
168 KateView::~KateView()
169 {
170  if (!m_doc->singleViewMode())
171  m_doc->disableAllPluginsGUI (this);
172 
173  m_doc->removeView( this );
174 
175  // its a TQObject. don't double-delete
176  //delete m_viewInternal;
177  //delete m_codeCompletion;
178 
179  delete m_renderer;
180  m_renderer = 0;
181 
182  delete m_config;
183  m_config = 0;
184  KateFactory::self()->deregisterView (this);
185 }
186 
187 void KateView::setupConnections()
188 {
189  connect( m_doc, TQ_SIGNAL(undoChanged()),
190  this, TQ_SLOT(slotNewUndo()) );
191  connect( m_doc, TQ_SIGNAL(hlChanged()),
192  this, TQ_SLOT(slotHlChanged()) );
193  connect( m_doc, TQ_SIGNAL(canceled(const TQString&)),
194  this, TQ_SLOT(slotSaveCanceled(const TQString&)) );
195  connect( m_viewInternal, TQ_SIGNAL(dropEventPass(TQDropEvent*)),
196  this, TQ_SIGNAL(dropEventPass(TQDropEvent*)) );
197  connect(this,TQ_SIGNAL(cursorPositionChanged()),this,TQ_SLOT(slotStatusMsg()));
198  connect(this,TQ_SIGNAL(newStatus()),this,TQ_SLOT(slotStatusMsg()));
199  connect(m_doc, TQ_SIGNAL(undoChanged()), this, TQ_SLOT(slotStatusMsg()));
200 
201  if ( m_doc->browserView() )
202  {
203  connect( this, TQ_SIGNAL(dropEventPass(TQDropEvent*)),
204  this, TQ_SLOT(slotDropEventPass(TQDropEvent*)) );
205  }
206 }
207 
208 void KateView::setupActions()
209 {
210  TDEActionCollection *ac = this->actionCollection ();
211  TDEAction *a;
212 
213  m_toggleWriteLock = 0;
214 
215  m_cut = a=KStdAction::cut(this, TQ_SLOT(cut()), ac);
216  a->setWhatsThis(i18n("Cut the selected text and move it to the clipboard"));
217 
218  m_paste = a=KStdAction::pasteText(this, TQ_SLOT(paste()), ac);
219  a->setWhatsThis(i18n("Paste previously copied or cut clipboard contents"));
220 
221  m_copy = a=KStdAction::copy(this, TQ_SLOT(copy()), ac);
222  a->setWhatsThis(i18n( "Use this command to copy the currently selected text to the system clipboard."));
223 
224  m_copyHTML = a = new TDEAction(i18n("Copy as &HTML"), "edit-copy", 0, this, TQ_SLOT(copyHTML()), ac, "edit_copy_html");
225  a->setWhatsThis(i18n( "Use this command to copy the currently selected text as HTML to the system clipboard."));
226 
227  if (!m_doc->readOnly())
228  {
229  a=KStdAction::save(this, TQ_SLOT(save()), ac);
230  a->setWhatsThis(i18n("Save the current document"));
231 
232  a=m_editUndo = KStdAction::undo(m_doc, TQ_SLOT(undo()), ac);
233  a->setWhatsThis(i18n("Revert the most recent editing actions"));
234 
235  a=m_editRedo = KStdAction::redo(m_doc, TQ_SLOT(redo()), ac);
236  a->setWhatsThis(i18n("Revert the most recent undo operation"));
237 
238  (new TDEAction(i18n("&Word Wrap Document"), "", 0, this, TQ_SLOT(applyWordWrap()), ac, "tools_apply_wordwrap"))->setWhatsThis(
239  i18n("Use this command to wrap all lines of the current document which are longer than the width of the"
240  " current view, to fit into this view.<br><br> This is a static word wrap, meaning it is not updated"
241  " when the view is resized."));
242 
243  // setup Tools menu
244  a=new TDEAction(i18n("&Indent"), "format-indent-more", TQt::CTRL+TQt::Key_I, this, TQ_SLOT(indent()), ac, "tools_indent");
245  a->setWhatsThis(i18n("Use this to indent a selected block of text.<br><br>"
246  "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
247  a=new TDEAction(i18n("&Unindent"), "format-indent-less", TQt::CTRL+TQt::SHIFT+TQt::Key_I, this, TQ_SLOT(unIndent()), ac, "tools_unindent");
248  a->setWhatsThis(i18n("Use this to unindent a selected block of text."));
249 
250  a=new TDEAction(i18n("&Clean Indentation"), 0, this, TQ_SLOT(cleanIndent()), ac, "tools_cleanIndent");
251  a->setWhatsThis(i18n("Use this to clean the indentation of a selected block of text (only tabs/only spaces)<br><br>"
252  "You can configure whether tabs should be honored and used or replaced with spaces, in the configuration dialog."));
253 
254  a=new TDEAction(i18n("&Align"), 0, this, TQ_SLOT(align()), ac, "tools_align");
255  a->setWhatsThis(i18n("Use this to align the current line or block of text to its proper indent level."));
256 
257  a=new TDEAction(i18n("C&omment"), CTRL+TQt::Key_D, this, TQ_SLOT(comment()),
258  ac, "tools_comment");
259  a->setWhatsThis(i18n("This command comments out the current line or a selected block of text.<BR><BR>"
260  "The characters for single/multiple line comments are defined within the language's highlighting."));
261 
262  a=new TDEAction(i18n("Unco&mment"), CTRL+SHIFT+TQt::Key_D, this, TQ_SLOT(uncomment()),
263  ac, "tools_uncomment");
264  a->setWhatsThis(i18n("This command removes comments from the current line or a selected block of text.<BR><BR>"
265  "The characters for single/multiple line comments are defined within the language's highlighting."));
266  a = m_toggleWriteLock = new TDEToggleAction(
267  i18n("&Read Only Mode"), 0, 0,
268  this, TQ_SLOT( toggleWriteLock() ),
269  ac, "tools_toggle_write_lock" );
270  a->setWhatsThis( i18n("Lock/unlock the document for writing") );
271 
272  a = new TDEAction( i18n("Uppercase"), CTRL + TQt::Key_U, this,
273  TQ_SLOT(uppercase()), ac, "tools_uppercase" );
274  a->setWhatsThis( i18n("Convert the selection to uppercase, or the character to the "
275  "right of the cursor if no text is selected.") );
276 
277  a = new TDEAction( i18n("Lowercase"), CTRL + SHIFT + TQt::Key_U, this,
278  TQ_SLOT(lowercase()), ac, "tools_lowercase" );
279  a->setWhatsThis( i18n("Convert the selection to lowercase, or the character to the "
280  "right of the cursor if no text is selected.") );
281 
282  a = new TDEAction( i18n("Capitalize"), CTRL + ALT + TQt::Key_U, this,
283  TQ_SLOT(capitalize()), ac, "tools_capitalize" );
284  a->setWhatsThis( i18n("Capitalize the selection, or the word under the "
285  "cursor if no text is selected.") );
286 
287  a = new TDEAction( i18n("Delete Line"), 0, this,
288  TQ_SLOT( killLine() ), ac, "tools_delete_line");
289  a->setWhatsThis(i18n("Use this to delete the current line."));
290 
291  a = new TDEAction( i18n("Join Lines"), CTRL + TQt::Key_J, this,
292  TQ_SLOT( joinLines() ), ac, "tools_join_lines" );
293  a->setWhatsThis(i18n("Use this to join lines together."));
294  }
295  else
296  {
297  m_cut->setEnabled (false);
298  m_paste->setEnabled (false);
299  m_editUndo = 0;
300  m_editRedo = 0;
301  }
302 
303  a=KStdAction::print( m_doc, TQ_SLOT(print()), ac );
304  a->setWhatsThis(i18n("Print the current document."));
305 
306  a=new TDEAction(i18n("Reloa&d"), "reload", TDEStdAccel::reload(), this, TQ_SLOT(reloadFile()), ac, "file_reload");
307  a->setWhatsThis(i18n("Reload the current document from disk."));
308 
309  a=KStdAction::saveAs(this, TQ_SLOT(saveAs()), ac);
310  a->setWhatsThis(i18n("Save the current document to disk, with a name of your choice."));
311 
312  a=KStdAction::gotoLine(this, TQ_SLOT(gotoLine()), ac);
313  a->setWhatsThis(i18n("This command opens a dialog and lets you choose a line that you want the cursor to move to."));
314 
315  a=new TDEAction(i18n("&Configure Editor..."), 0, m_doc, TQ_SLOT(configDialog()),ac, "set_confdlg");
316  a->setWhatsThis(i18n("Configure various aspects of this editor."));
317 
318  KateViewHighlightAction *menu = new KateViewHighlightAction (i18n("&Highlighting"), ac, "set_highlight");
319  menu->setWhatsThis(i18n("Here you can choose how the current document should be highlighted."));
320  menu->updateMenu (m_doc);
321 
322  KateViewFileTypeAction *ftm = new KateViewFileTypeAction (i18n("&Filetype"),ac,"set_filetype");
323  ftm->updateMenu (m_doc);
324 
325  KateViewSchemaAction *schemaMenu = new KateViewSchemaAction (i18n("&Schema"),ac,"view_schemas");
326  schemaMenu->updateMenu (this);
327 
328  // indentation menu
329  new KateViewIndentationAction (m_doc, i18n("&Indentation"),ac,"tools_indentation");
330 
331  // html export
332  a = new TDEAction(i18n("E&xport as HTML..."), 0, 0, this, TQ_SLOT(exportAsHTML()), ac, "file_export_html");
333  a->setWhatsThis(i18n("This command allows you to export the current document"
334  " with all highlighting information into a HTML document."));
335 
336  m_selectAll = a=KStdAction::selectAll(this, TQ_SLOT(selectAll()), ac);
337  a->setWhatsThis(i18n("Select the entire text of the current document."));
338 
339  m_deSelect = a=KStdAction::deselect(this, TQ_SLOT(clearSelection()), ac);
340  a->setWhatsThis(i18n("If you have selected something within the current document, this will no longer be selected."));
341 
342  a=new TDEAction(i18n("Enlarge Font"), "zoom-in", 0, m_viewInternal, TQ_SLOT(slotIncFontSizes()), ac, "incFontSizes");
343  a->setWhatsThis(i18n("This increases the display font size."));
344 
345  a=new TDEAction(i18n("Shrink Font"), "zoom-out", 0, m_viewInternal, TQ_SLOT(slotDecFontSizes()), ac, "decFontSizes");
346  a->setWhatsThis(i18n("This decreases the display font size."));
347 
348  a= m_toggleBlockSelection = new TDEToggleAction(
349  i18n("Bl&ock Selection Mode"), CTRL + SHIFT + Key_B,
350  this, TQ_SLOT(toggleBlockSelectionMode()),
351  ac, "set_verticalSelect");
352  a->setWhatsThis(i18n("This command allows switching between the normal (line based) selection mode and the block selection mode."));
353 
354  a= m_toggleInsert = new TDEToggleAction(
355  i18n("Overwr&ite Mode"), Key_Insert,
356  this, TQ_SLOT(toggleInsert()),
357  ac, "set_insert" );
358  a->setWhatsThis(i18n("Choose whether you want the text you type to be inserted or to overwrite existing text."));
359 
360  TDEToggleAction *toggleAction;
361  a= m_toggleDynWrap = toggleAction = new TDEToggleAction(
362  i18n("&Dynamic Word Wrap"), Key_F10,
363  this, TQ_SLOT(toggleDynWordWrap()),
364  ac, "view_dynamic_word_wrap" );
365  a->setWhatsThis(i18n("If this option is checked, the text lines will be wrapped at the view border on the screen."));
366 
367  a= m_setDynWrapIndicators = new TDESelectAction(i18n("Dynamic Word Wrap Indicators"), 0, ac, "dynamic_word_wrap_indicators");
368  a->setWhatsThis(i18n("Choose when the Dynamic Word Wrap Indicators should be displayed"));
369 
370  connect(m_setDynWrapIndicators, TQ_SIGNAL(activated(int)), this, TQ_SLOT(setDynWrapIndicators(int)));
371  TQStringList list2;
372  list2.append(i18n("&Off"));
373  list2.append(i18n("Follow &Line Numbers"));
374  list2.append(i18n("&Always On"));
375  m_setDynWrapIndicators->setItems(list2);
376 
377  a= toggleAction=m_toggleFoldingMarkers = new TDEToggleAction(
378  i18n("Show Folding &Markers"), Key_F9,
379  this, TQ_SLOT(toggleFoldingMarkers()),
380  ac, "view_folding_markers" );
381  a->setWhatsThis(i18n("You can choose if the codefolding marks should be shown, if codefolding is possible."));
382  toggleAction->setCheckedState(i18n("Hide Folding &Markers"));
383 
384  a= m_toggleIconBar = toggleAction = new TDEToggleAction(
385  i18n("Show &Icon Border"), Key_F6,
386  this, TQ_SLOT(toggleIconBorder()),
387  ac, "view_border");
388  a=toggleAction;
389  a->setWhatsThis(i18n("Show/hide the icon border.<BR><BR> The icon border shows bookmark symbols, for instance."));
390  toggleAction->setCheckedState(i18n("Hide &Icon Border"));
391 
392  a= toggleAction=m_toggleLineNumbers = new TDEToggleAction(
393  i18n("Show &Line Numbers"), Key_F11,
394  this, TQ_SLOT(toggleLineNumbersOn()),
395  ac, "view_line_numbers" );
396  a->setWhatsThis(i18n("Show/hide the line numbers on the left hand side of the view."));
397  toggleAction->setCheckedState(i18n("Hide &Line Numbers"));
398 
399  a= m_toggleScrollBarMarks = toggleAction = new TDEToggleAction(
400  i18n("Show Scroll&bar Marks"), 0,
401  this, TQ_SLOT(toggleScrollBarMarks()),
402  ac, "view_scrollbar_marks");
403  a->setWhatsThis(i18n("Show/hide the marks on the vertical scrollbar.<BR><BR>The marks, for instance, show bookmarks."));
404  toggleAction->setCheckedState(i18n("Hide Scroll&bar Marks"));
405 
406  a = toggleAction = m_toggleWWMarker = new TDEToggleAction(
407  i18n("Show Static &Word Wrap Marker"), 0,
408  this, TQ_SLOT( toggleWWMarker() ),
409  ac, "view_word_wrap_marker" );
410  a->setWhatsThis( i18n(
411  "Show/hide the Word Wrap Marker, a vertical line drawn at the word "
412  "wrap column as defined in the editing properties" ));
413  toggleAction->setCheckedState(i18n("Hide Static &Word Wrap Marker"));
414 
415  a= m_switchCmdLine = new TDEAction(
416  i18n("Switch to Command Line"), Key_F7,
417  this, TQ_SLOT(switchToCmdLine()),
418  ac, "switch_to_cmd_line" );
419  a->setWhatsThis(i18n("Show/hide the command line on the bottom of the view."));
420 
421  a=m_setEndOfLine = new TDESelectAction(i18n("&End of Line"), 0, ac, "set_eol");
422  a->setWhatsThis(i18n("Choose which line endings should be used, when you save the document"));
423  TQStringList list;
424  list.append("&UNIX");
425  list.append("&Windows/DOS");
426  list.append("&Macintosh");
427  m_setEndOfLine->setItems(list);
428  m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
429  connect(m_setEndOfLine, TQ_SIGNAL(activated(int)), this, TQ_SLOT(setEol(int)));
430 
431  // encoding menu
432  new KateViewEncodingAction (m_doc, this, i18n("E&ncoding"), ac, "set_encoding");
433 
434  m_search->createActions( ac );
435  m_spell->createActions( ac );
436  m_bookmarks->createActions( ac );
437 
438  slotSelectionChanged ();
439 
440  connect (this, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(slotSelectionChanged()));
441 }
442 
443 void KateView::setupEditActions()
444 {
445  m_editActions = new TDEActionCollection( m_viewInternal, this, "edit_actions" );
446  TDEActionCollection* ac = m_editActions;
447 
448  new TDEAction(
449  i18n("Move Word Left"), CTRL + Key_Left,
450  this,TQ_SLOT(wordLeft()),
451  ac, "word_left" );
452  new TDEAction(
453  i18n("Select Character Left"), SHIFT + Key_Left,
454  this,TQ_SLOT(shiftCursorLeft()),
455  ac, "select_char_left" );
456  new TDEAction(
457  i18n("Select Word Left"), SHIFT + CTRL + Key_Left,
458  this, TQ_SLOT(shiftWordLeft()),
459  ac, "select_word_left" );
460 
461  new TDEAction(
462  i18n("Move Word Right"), CTRL + Key_Right,
463  this, TQ_SLOT(wordRight()),
464  ac, "word_right" );
465  new TDEAction(
466  i18n("Select Character Right"), SHIFT + Key_Right,
467  this, TQ_SLOT(shiftCursorRight()),
468  ac, "select_char_right" );
469  new TDEAction(
470  i18n("Select Word Right"), SHIFT + CTRL + Key_Right,
471  this,TQ_SLOT(shiftWordRight()),
472  ac, "select_word_right" );
473 
474  new TDEAction(
475  i18n("Move to Beginning of Line"), Key_Home,
476  this, TQ_SLOT(home()),
477  ac, "beginning_of_line" );
478  new TDEAction(
479  i18n("Move to Beginning of Document"), TDEStdAccel::home(),
480  this, TQ_SLOT(top()),
481  ac, "beginning_of_document" );
482  new TDEAction(
483  i18n("Select to Beginning of Line"), SHIFT + Key_Home,
484  this, TQ_SLOT(shiftHome()),
485  ac, "select_beginning_of_line" );
486  new TDEAction(
487  i18n("Select to Beginning of Document"), SHIFT + CTRL + Key_Home,
488  this, TQ_SLOT(shiftTop()),
489  ac, "select_beginning_of_document" );
490 
491  new TDEAction(
492  i18n("Move to End of Line"), Key_End,
493  this, TQ_SLOT(end()),
494  ac, "end_of_line" );
495  new TDEAction(
496  i18n("Move to End of Document"), TDEStdAccel::end(),
497  this, TQ_SLOT(bottom()),
498  ac, "end_of_document" );
499  new TDEAction(
500  i18n("Select to End of Line"), SHIFT + Key_End,
501  this, TQ_SLOT(shiftEnd()),
502  ac, "select_end_of_line" );
503  new TDEAction(
504  i18n("Select to End of Document"), SHIFT + CTRL + Key_End,
505  this, TQ_SLOT(shiftBottom()),
506  ac, "select_end_of_document" );
507 
508  new TDEAction(
509  i18n("Select to Previous Line"), SHIFT + Key_Up,
510  this, TQ_SLOT(shiftUp()),
511  ac, "select_line_up" );
512  new TDEAction(
513  i18n("Scroll Line Up"),"", CTRL + Key_Up,
514  this, TQ_SLOT(scrollUp()),
515  ac, "scroll_line_up" );
516 
517  new TDEAction(i18n("Move to Next Line"), Key_Down, this, TQ_SLOT(down()),
518  ac, "move_line_down");
519 
520  new TDEAction(i18n("Move to Previous Line"), Key_Up, this, TQ_SLOT(up()),
521  ac, "move_line_up");
522 
523  new TDEAction(i18n("Move Character Right"), Key_Right, this,
524  TQ_SLOT(cursorRight()), ac, "move_cursor_right");
525 
526  new TDEAction(i18n("Move Character Left"), Key_Left, this, TQ_SLOT(cursorLeft()),
527  ac, "move_cusor_left");
528 
529  new TDEAction(
530  i18n("Select to Next Line"), SHIFT + Key_Down,
531  this, TQ_SLOT(shiftDown()),
532  ac, "select_line_down" );
533  new TDEAction(
534  i18n("Scroll Line Down"), CTRL + Key_Down,
535  this, TQ_SLOT(scrollDown()),
536  ac, "scroll_line_down" );
537 
538  new TDEAction(
539  i18n("Scroll Page Up"), TDEStdAccel::prior(),
540  this, TQ_SLOT(pageUp()),
541  ac, "scroll_page_up" );
542  new TDEAction(
543  i18n("Select Page Up"), SHIFT + Key_PageUp,
544  this, TQ_SLOT(shiftPageUp()),
545  ac, "select_page_up" );
546  new TDEAction(
547  i18n("Move to Top of View"), CTRL + Key_PageUp,
548  this, TQ_SLOT(topOfView()),
549  ac, "move_top_of_view" );
550  new TDEAction(
551  i18n("Select to Top of View"), CTRL + SHIFT + Key_PageUp,
552  this, TQ_SLOT(shiftTopOfView()),
553  ac, "select_top_of_view" );
554 
555  new TDEAction(
556  i18n("Scroll Page Down"), TDEStdAccel::next(),
557  this, TQ_SLOT(pageDown()),
558  ac, "scroll_page_down" );
559  new TDEAction(
560  i18n("Select Page Down"), SHIFT + Key_PageDown,
561  this, TQ_SLOT(shiftPageDown()),
562  ac, "select_page_down" );
563  new TDEAction(
564  i18n("Move to Bottom of View"), CTRL + Key_PageDown,
565  this, TQ_SLOT(bottomOfView()),
566  ac, "move_bottom_of_view" );
567  new TDEAction(
568  i18n("Select to Bottom of View"), CTRL + SHIFT + Key_PageDown,
569  this, TQ_SLOT(shiftBottomOfView()),
570  ac, "select_bottom_of_view" );
571  new TDEAction(
572  i18n("Move to Matching Bracket"), CTRL + Key_6,
573  this, TQ_SLOT(toMatchingBracket()),
574  ac, "to_matching_bracket" );
575  new TDEAction(
576  i18n("Select to Matching Bracket"), SHIFT + CTRL + Key_6,
577  this, TQ_SLOT(shiftToMatchingBracket()),
578  ac, "select_matching_bracket" );
579 
580  // anders: shortcuts doing any changes should not be created in browserextension
581  if ( !m_doc->readOnly() )
582  {
583  new TDEAction(
584  i18n("Transpose Characters"), CTRL + Key_T,
585  this, TQ_SLOT(transpose()),
586  ac, "transpose_char" );
587 
588  new TDEAction(
589  i18n("Delete Line"), CTRL + Key_K,
590  this, TQ_SLOT(killLine()),
591  ac, "delete_line" );
592 
593  new TDEAction(
594  i18n("Delete Word Left"), TDEStdAccel::deleteWordBack(),
595  this, TQ_SLOT(deleteWordLeft()),
596  ac, "delete_word_left" );
597 
598  new TDEAction(
599  i18n("Delete Word Right"), TDEStdAccel::deleteWordForward(),
600  this, TQ_SLOT(deleteWordRight()),
601  ac, "delete_word_right" );
602 
603  new TDEAction(i18n("Delete Next Character"), Key_Delete,
604  this, TQ_SLOT(keyDelete()),
605  ac, "delete_next_character");
606 
607  TDEAction *a = new TDEAction(i18n("Backspace"), Key_Backspace,
608  this, TQ_SLOT(backspace()),
609  ac, "backspace");
610  TDEShortcut cut = a->shortcut();
611  cut.append( KKey( SHIFT + Key_Backspace ) );
612  a->setShortcut( cut );
613  }
614 
615  connect( this, TQ_SIGNAL(gotFocus(Kate::View*)),
616  this, TQ_SLOT(slotGotFocus()) );
617  connect( this, TQ_SIGNAL(lostFocus(Kate::View*)),
618  this, TQ_SLOT(slotLostFocus()) );
619 
620  m_editActions->readShortcutSettings( "Katepart Shortcuts" );
621 
622  if( hasFocus() )
623  slotGotFocus();
624  else
625  slotLostFocus();
626 
627 
628 }
629 
630 void KateView::setupCodeFolding()
631 {
632  TDEActionCollection *ac=this->actionCollection();
633  new TDEAction( i18n("Collapse Toplevel"), CTRL+SHIFT+Key_Minus,
634  m_doc->foldingTree(),TQ_SLOT(collapseToplevelNodes()),ac,"folding_toplevel");
635  new TDEAction( i18n("Expand Toplevel"), CTRL+SHIFT+Key_Plus,
636  this,TQ_SLOT(slotExpandToplevel()),ac,"folding_expandtoplevel");
637  new TDEAction( i18n("Collapse One Local Level"), CTRL+Key_Minus,
638  this,TQ_SLOT(slotCollapseLocal()),ac,"folding_collapselocal");
639  new TDEAction( i18n("Expand One Local Level"), CTRL+Key_Plus,
640  this,TQ_SLOT(slotExpandLocal()),ac,"folding_expandlocal");
641 
642 #ifdef DEBUGACCELS
643  TDEAccel* debugAccels = new TDEAccel(this,this);
644  debugAccels->insert("KATE_DUMP_REGION_TREE",i18n("Show the code folding region tree"),"","Ctrl+Shift+Alt+D",m_doc,TQ_SLOT(dumpRegionTree()));
645  debugAccels->insert("KATE_TEMPLATE_TEST",i18n("Basic template code test"),"","Ctrl+Shift+Alt+T",m_doc,TQ_SLOT(testTemplateCode()));
646  debugAccels->setEnabled(true);
647 #endif
648 }
649 
650 void KateView::slotExpandToplevel()
651 {
652  m_doc->foldingTree()->expandToplevelNodes(m_doc->numLines());
653 }
654 
655 void KateView::slotCollapseLocal()
656 {
657  int realLine = m_doc->foldingTree()->collapseOne(cursorLine());
658  if (realLine != -1)
659  // TODO rodda: fix this to only set line and allow internal view to chose column
660  // Explicitly call internal because we want this to be registered as an internal call
661  setCursorPositionInternal(realLine, cursorColumn(), tabWidth(), false);
662 }
663 
664 void KateView::slotExpandLocal()
665 {
666  m_doc->foldingTree()->expandOne(cursorLine(), m_doc->numLines());
667 }
668 
669 void KateView::setupCodeCompletion()
670 {
671  m_codeCompletion = new KateCodeCompletion(this);
672  connect( m_codeCompletion, TQ_SIGNAL(completionAborted()),
673  this, TQ_SIGNAL(completionAborted()));
674  connect( m_codeCompletion, TQ_SIGNAL(completionDone()),
675  this, TQ_SIGNAL(completionDone()));
676  connect( m_codeCompletion, TQ_SIGNAL(argHintHidden()),
677  this, TQ_SIGNAL(argHintHidden()));
678  connect( m_codeCompletion, TQ_SIGNAL(completionDone(KTextEditor::CompletionEntry)),
679  this, TQ_SIGNAL(completionDone(KTextEditor::CompletionEntry)));
680  connect( m_codeCompletion, TQ_SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,TQString*)),
681  this, TQ_SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,TQString*)));
682 }
683 
684 void KateView::slotGotFocus()
685 {
686  m_editActions->accel()->setEnabled( true );
687 
688  slotStatusMsg ();
689 }
690 
691 void KateView::slotLostFocus()
692 {
693  m_editActions->accel()->setEnabled( false );
694 }
695 
696 void KateView::setDynWrapIndicators(int mode)
697 {
698  config()->setDynWordWrapIndicators (mode);
699 }
700 
701 void KateView::slotStatusMsg ()
702 {
703  TQString ovrstr;
704  if (m_doc->isReadWrite())
705  {
706  if (m_doc->config()->configFlags() & KateDocument::cfOvr)
707  ovrstr = i18n(" OVR ");
708  else
709  ovrstr = i18n(" INS ");
710  }
711  else
712  ovrstr = i18n(" R/O ");
713 
714  uint r = cursorLine() + 1;
715  uint c = cursorColumn() + 1;
716 
717  TQString s1 = i18n(" Line: %1").arg(TDEGlobal::locale()->formatNumber(r, 0));
718  TQString s2 = i18n(" Col: %1").arg(TDEGlobal::locale()->formatNumber(c, 0));
719 
720  TQString modstr = m_doc->isModified() ? TQString (" * ") : TQString (" ");
721  TQString blockstr = blockSelectionMode() ? i18n(" BLK ") : i18n(" NORM ");
722 
723  emit viewStatusMsg (s1 + s2 + " " + ovrstr + blockstr + modstr);
724 }
725 
726 void KateView::slotSelectionTypeChanged()
727 {
728  m_toggleBlockSelection->setChecked( blockSelectionMode() );
729 
730  emit newStatus();
731 }
732 
733 bool KateView::isOverwriteMode() const
734 {
735  return m_doc->config()->configFlags() & KateDocument::cfOvr;
736 }
737 
738 void KateView::reloadFile()
739 {
740  m_doc->reloadFile();
741  emit newStatus();
742 }
743 
744 void KateView::slotUpdate()
745 {
746  emit newStatus();
747 
748  slotNewUndo();
749 }
750 
751 void KateView::slotReadWriteChanged ()
752 {
753  if ( m_toggleWriteLock )
754  m_toggleWriteLock->setChecked( ! m_doc->isReadWrite() );
755 
756  m_cut->setEnabled (m_doc->isReadWrite());
757  m_paste->setEnabled (m_doc->isReadWrite());
758 
759  TQStringList l;
760 
761  l << "edit_replace" << "set_insert" << "tools_spelling" << "tools_indent"
762  << "tools_unindent" << "tools_cleanIndent" << "tools_align" << "tools_comment"
763  << "tools_uncomment" << "tools_uppercase" << "tools_lowercase"
764  << "tools_capitalize" << "tools_delete_line" << "tools_join_lines"
765  << "tools_apply_wordwrap" << "edit_undo" << "edit_redo" << "tools_spelling_from_cursor"
766  << "tools_spelling_selection";
767 
768  TDEAction *a = 0;
769  for (uint z = 0; z < l.size(); z++)
770  if ((a = actionCollection()->action( l[z].ascii() )))
771  a->setEnabled (m_doc->isReadWrite());
772 }
773 
774 void KateView::slotNewUndo()
775 {
776  if (m_doc->readOnly())
777  return;
778 
779  if ((m_doc->undoCount() > 0) != m_editUndo->isEnabled())
780  m_editUndo->setEnabled(m_doc->undoCount() > 0);
781 
782  if ((m_doc->redoCount() > 0) != m_editRedo->isEnabled())
783  m_editRedo->setEnabled(m_doc->redoCount() > 0);
784 }
785 
786 void KateView::slotDropEventPass( TQDropEvent * ev )
787 {
788  KURL::List lstDragURLs;
789  bool ok = KURLDrag::decode( ev, lstDragURLs );
790 
791  KParts::BrowserExtension * ext = KParts::BrowserExtension::childObject( doc() );
792  if ( ok && ext )
793  emit ext->openURLRequest( lstDragURLs.first() );
794 }
795 
796 void KateView::contextMenuEvent( TQContextMenuEvent *ev )
797 {
798  if ( !m_doc || !m_doc->browserExtension() )
799  return;
800  emit m_doc->browserExtension()->popupMenu( /*this, */ev->globalPos(), m_doc->url(),
801  TQString::fromLatin1( "text/plain" ) );
802  ev->accept();
803 }
804 
805 bool KateView::setCursorPositionInternal( uint line, uint col, uint tabwidth, bool calledExternally )
806 {
807  KateTextLine::Ptr l = m_doc->kateTextLine( line );
808 
809  if (!l)
810  return false;
811 
812  TQString line_str = m_doc->textLine( line );
813 
814  uint z;
815  uint x = 0;
816  for (z = 0; z < line_str.length() && z < col; z++) {
817  if (line_str[z] == TQChar('\t')) x += tabwidth - (x % tabwidth); else x++;
818  }
819 
820  m_viewInternal->updateCursor( KateTextCursor( line, x ), false, true, calledExternally );
821 
822  return true;
823 }
824 
825 void KateView::setOverwriteMode( bool b )
826 {
827  if ( isOverwriteMode() && !b )
828  m_doc->setConfigFlags( m_doc->config()->configFlags() ^ KateDocument::cfOvr );
829  else
830  m_doc->setConfigFlags( m_doc->config()->configFlags() | KateDocument::cfOvr );
831 
832  m_toggleInsert->setChecked (isOverwriteMode ());
833 }
834 
835 void KateView::toggleInsert()
836 {
837  m_doc->setConfigFlags(m_doc->config()->configFlags() ^ KateDocument::cfOvr);
838  m_toggleInsert->setChecked (isOverwriteMode ());
839 
840  emit newStatus();
841 }
842 
843 bool KateView::canDiscard()
844 {
845  return m_doc->closeURL();
846 }
847 
848 void KateView::flush()
849 {
850  m_doc->closeURL();
851 }
852 
853 KateView::saveResult KateView::save()
854 {
855  if( !m_doc->url().isValid() || !doc()->isReadWrite() )
856  return saveAs();
857 
858  if( m_doc->save() )
859  return SAVE_OK;
860 
861  return SAVE_ERROR;
862 }
863 
864 KateView::saveResult KateView::saveAs()
865 {
866 
867  KEncodingFileDialog::Result res=KEncodingFileDialog::getSaveURLAndEncoding(doc()->config()->encoding(),
868  m_doc->url().url(),TQString::null,this,i18n("Save File"));
869 
870 // kdDebug()<<"urllist is emtpy?"<<res.URLs.isEmpty()<<endl;
871 // kdDebug()<<"url is:"<<res.URLs.first()<<endl;
872  if( res.URLs.isEmpty() || !checkOverwrite( res.URLs.first() ) )
873  return SAVE_CANCEL;
874 
875  m_doc->config()->setEncoding( res.encoding );
876 
877  if( m_doc->saveAs( res.URLs.first() ) )
878  return SAVE_OK;
879 
880  return SAVE_ERROR;
881 }
882 
883 bool KateView::checkOverwrite( KURL u )
884 {
885  if( !u.isLocalFile() )
886  return true;
887 
888  TQFileInfo info( u.path() );
889  if( !info.exists() )
890  return true;
891 
892  return KMessageBox::Continue
893  == KMessageBox::warningContinueCancel
894  ( this,
895  i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?" ).arg( info.fileName() ),
896  i18n( "Overwrite File?" ),
897  KGuiItem( i18n( "&Overwrite" ), "document-save", i18n( "Overwrite the file" ) )
898  );
899 }
900 
901 void KateView::slotSaveCanceled( const TQString& error )
902 {
903  if ( !error.isEmpty() ) // happens when cancelling a job
904  KMessageBox::error( this, error );
905 }
906 
907 void KateView::gotoLine()
908 {
909  KateGotoLineDialog *dlg = new KateGotoLineDialog (this, m_viewInternal->getCursor().line() + 1, m_doc->numLines());
910 
911  if (dlg->exec() == TQDialog::Accepted)
912  gotoLineNumber( dlg->getLine() - 1 );
913 
914  delete dlg;
915 }
916 
917 void KateView::gotoLineNumber( int line )
918 {
919  // clear selection, unless we are in persistent selection mode
920  if ( !config()->persistentSelection() )
921  clearSelection();
922  setCursorPositionInternal ( line, 0, 1 );
923 }
924 
925 void KateView::joinLines()
926 {
927  int first = selStartLine();
928  int last = selEndLine();
929  //int left = m_doc->textLine( last ).length() - m_doc->selEndCol();
930  if ( first == last )
931  {
932  first = cursorLine();
933  last = first + 1;
934  }
935  m_doc->joinLines( first, last );
936 }
937 
938 void KateView::readSessionConfig(TDEConfig *config)
939 {
940  setCursorPositionInternal (config->readNumEntry("CursorLine"), config->readNumEntry("CursorColumn"), 1);
941 }
942 
943 void KateView::writeSessionConfig(TDEConfig *config)
944 {
945  config->writeEntry("CursorLine",m_viewInternal->cursor.line());
946  config->writeEntry("CursorColumn",m_viewInternal->cursor.col());
947 }
948 
949 int KateView::getEol()
950 {
951  return m_doc->config()->eol();
952 }
953 
954 void KateView::setEol(int eol)
955 {
956  if (!doc()->isReadWrite())
957  return;
958 
959  if (m_updatingDocumentConfig)
960  return;
961 
962  m_doc->config()->setEol (eol);
963 }
964 
965 void KateView::setIconBorder( bool enable )
966 {
967  config()->setIconBar (enable);
968 }
969 
970 void KateView::toggleIconBorder()
971 {
972  config()->setIconBar (!config()->iconBar());
973 }
974 
975 void KateView::setLineNumbersOn( bool enable )
976 {
977  config()->setLineNumbers (enable);
978 }
979 
980 void KateView::toggleLineNumbersOn()
981 {
982  config()->setLineNumbers (!config()->lineNumbers());
983 }
984 
985 void KateView::setScrollBarMarks( bool enable )
986 {
987  config()->setScrollBarMarks (enable);
988 }
989 
990 void KateView::toggleScrollBarMarks()
991 {
992  config()->setScrollBarMarks (!config()->scrollBarMarks());
993 }
994 
995 void KateView::toggleDynWordWrap()
996 {
997  config()->setDynWordWrap( !config()->dynWordWrap() );
998 }
999 
1000 void KateView::setDynWordWrap( bool b )
1001 {
1002  config()->setDynWordWrap( b );
1003 }
1004 
1005 void KateView::toggleWWMarker()
1006 {
1007  m_renderer->config()->setWordWrapMarker (!m_renderer->config()->wordWrapMarker());
1008 }
1009 
1010 void KateView::setFoldingMarkersOn( bool enable )
1011 {
1012  config()->setFoldingBar ( enable );
1013 }
1014 
1015 void KateView::toggleFoldingMarkers()
1016 {
1017  config()->setFoldingBar ( !config()->foldingBar() );
1018 }
1019 
1020 bool KateView::iconBorder() {
1021  return m_viewInternal->leftBorder->iconBorderOn();
1022 }
1023 
1024 bool KateView::lineNumbersOn() {
1025  return m_viewInternal->leftBorder->lineNumbersOn();
1026 }
1027 
1028 bool KateView::scrollBarMarks() {
1029  return m_viewInternal->m_lineScroll->showMarks();
1030 }
1031 
1032 int KateView::dynWrapIndicators() {
1033  return m_viewInternal->leftBorder->dynWrapIndicators();
1034 }
1035 
1036 bool KateView::foldingMarkersOn() {
1037  return m_viewInternal->leftBorder->foldingMarkersOn();
1038 }
1039 
1040 void KateView::showCmdLine ( bool enabled )
1041 {
1042  if (enabled == m_cmdLineOn)
1043  return;
1044 
1045  if (enabled)
1046  {
1047  if (!m_cmdLine)
1048  {
1049  m_cmdLine = new KateCmdLine (this);
1050  m_grid->addMultiCellWidget (m_cmdLine, 2, 2, 0, 2);
1051  }
1052 
1053  m_cmdLine->show ();
1054  m_cmdLine->setFocus();
1055  }
1056  else {
1057  m_cmdLine->hide ();
1058  //m_toggleCmdLine->setChecked(false);
1059  }
1060 
1061  m_cmdLineOn = enabled;
1062 }
1063 
1064 void KateView::toggleCmdLine ()
1065 {
1066  m_config->setCmdLine (!m_config->cmdLine ());
1067 }
1068 
1069 void KateView::toggleWriteLock()
1070 {
1071  m_doc->setReadWrite( ! m_doc->isReadWrite() );
1072 }
1073 
1074 void KateView::enableTextHints(int timeout)
1075 {
1076  m_viewInternal->enableTextHints(timeout);
1077 }
1078 
1079 void KateView::disableTextHints()
1080 {
1081  m_viewInternal->disableTextHints();
1082 }
1083 
1084 void KateView::applyWordWrap ()
1085 {
1086  if (hasSelection())
1087  m_doc->wrapText (selectStart.line(), selectEnd.line());
1088  else
1089  m_doc->wrapText (0, m_doc->lastLine());
1090 }
1091 
1092 void KateView::slotNeedTextHint(int line, int col, TQString &text)
1093 {
1094  text=TQString("test %1 %2").arg(line).arg(col);
1095 }
1096 
1097 void KateView::find()
1098 {
1099  m_search->find();
1100 }
1101 
1102 void KateView::find( const TQString& pattern, long flags, bool add )
1103 {
1104  m_search->find( pattern, flags, add );
1105 }
1106 
1107 void KateView::replace()
1108 {
1109  m_search->replace();
1110 }
1111 
1112 void KateView::replace( const TQString &pattern, const TQString &replacement, long flags )
1113 {
1114  m_search->replace( pattern, replacement, flags );
1115 }
1116 
1117 void KateView::findAgain( bool back )
1118 {
1119  m_search->findAgain( back );
1120 }
1121 
1122 void KateView::slotSelectionChanged ()
1123 {
1124  m_copy->setEnabled (hasSelection());
1125  m_copyHTML->setEnabled (hasSelection());
1126  m_deSelect->setEnabled (hasSelection());
1127 
1128  if (m_doc->readOnly())
1129  return;
1130 
1131  m_cut->setEnabled (hasSelection());
1132 
1133  m_spell->updateActions ();
1134 }
1135 
1136 void KateView::switchToCmdLine ()
1137 {
1138  if (!m_cmdLineOn)
1139  m_config->setCmdLine (true);
1140  else {
1141  if (m_cmdLine->hasFocus()) {
1142  this->setFocus();
1143  return;
1144  }
1145  }
1146  m_cmdLine->setFocus ();
1147 }
1148 
1149 void KateView::showArgHint( TQStringList arg1, const TQString& arg2, const TQString& arg3 )
1150 {
1151  m_codeCompletion->showArgHint( arg1, arg2, arg3 );
1152 }
1153 
1154 void KateView::showCompletionBox( TQValueList<KTextEditor::CompletionEntry> arg1, int offset, bool cs )
1155 {
1156  emit aboutToShowCompletionBox();
1157  m_codeCompletion->showCompletionBox( arg1, offset, cs );
1158 }
1159 
1160 KateRenderer *KateView::renderer ()
1161 {
1162  return m_renderer;
1163 }
1164 
1165 void KateView::updateConfig ()
1166 {
1167  if (m_startingUp)
1168  return;
1169 
1170  m_editActions->readShortcutSettings( "Katepart Shortcuts" );
1171 
1172  // dyn. word wrap & markers
1173  if (m_hasWrap != config()->dynWordWrap()) {
1174  m_viewInternal->prepareForDynWrapChange();
1175 
1176  m_hasWrap = config()->dynWordWrap();
1177 
1178  m_viewInternal->dynWrapChanged();
1179 
1180  m_setDynWrapIndicators->setEnabled(config()->dynWordWrap());
1181  m_toggleDynWrap->setChecked( config()->dynWordWrap() );
1182  }
1183 
1184  m_viewInternal->leftBorder->setDynWrapIndicators( config()->dynWordWrapIndicators() );
1185  m_setDynWrapIndicators->setCurrentItem( config()->dynWordWrapIndicators() );
1186 
1187  // line numbers
1188  m_viewInternal->leftBorder->setLineNumbersOn( config()->lineNumbers() );
1189  m_toggleLineNumbers->setChecked( config()->lineNumbers() );
1190 
1191  // icon bar
1192  m_viewInternal->leftBorder->setIconBorderOn( config()->iconBar() );
1193  m_toggleIconBar->setChecked( config()->iconBar() );
1194 
1195  // scrollbar marks
1196  m_viewInternal->m_lineScroll->setShowMarks( config()->scrollBarMarks() );
1197  m_toggleScrollBarMarks->setChecked( config()->scrollBarMarks() );
1198 
1199  // cmd line
1200  showCmdLine (config()->cmdLine());
1201  //m_toggleCmdLine->setChecked( config()->cmdLine() );
1202 
1203  // misc edit
1204  m_toggleBlockSelection->setChecked( blockSelectionMode() );
1205  m_toggleInsert->setChecked( isOverwriteMode() );
1206 
1207  updateFoldingConfig ();
1208 
1209  // bookmark
1210  m_bookmarks->setSorting( (KateBookmarks::Sorting) config()->bookmarkSort() );
1211 
1212  m_viewInternal->setAutoCenterLines(config()->autoCenterLines ());
1213 }
1214 
1215 void KateView::updateDocumentConfig()
1216 {
1217  if (m_startingUp)
1218  return;
1219 
1220  m_updatingDocumentConfig = true;
1221 
1222  m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
1223 
1224  m_updatingDocumentConfig = false;
1225 
1226  m_viewInternal->updateView (true);
1227 
1228  m_renderer->setTabWidth (m_doc->config()->tabWidth());
1229  m_renderer->setIndentWidth (m_doc->config()->indentationWidth());
1230 }
1231 
1232 void KateView::updateRendererConfig()
1233 {
1234  if (m_startingUp)
1235  return;
1236 
1237  m_toggleWWMarker->setChecked( m_renderer->config()->wordWrapMarker() );
1238 
1239  // update the text area
1240  m_viewInternal->updateView (true);
1241  m_viewInternal->repaint ();
1242 
1243  // update the left border right, for example linenumbers
1244  m_viewInternal->leftBorder->updateFont();
1245  m_viewInternal->leftBorder->repaint ();
1246 
1247 // @@ showIndentLines is not cached anymore.
1248 // m_renderer->setShowIndentLines (m_renderer->config()->showIndentationLines());
1249 }
1250 
1251 void KateView::updateFoldingConfig ()
1252 {
1253  // folding bar
1254  bool doit = config()->foldingBar() && m_doc->highlight() && m_doc->highlight()->allowsFolding();
1255  m_viewInternal->leftBorder->setFoldingMarkersOn(doit);
1256  m_toggleFoldingMarkers->setChecked( doit );
1257  m_toggleFoldingMarkers->setEnabled( m_doc->highlight() && m_doc->highlight()->allowsFolding() );
1258 
1259  TQStringList l;
1260 
1261  l << "folding_toplevel" << "folding_expandtoplevel"
1262  << "folding_collapselocal" << "folding_expandlocal";
1263 
1264  TDEAction *a = 0;
1265  for (uint z = 0; z < l.size(); z++)
1266  if ((a = actionCollection()->action( l[z].ascii() )))
1267  a->setEnabled (m_doc->highlight() && m_doc->highlight()->allowsFolding());
1268 }
1269 
1270 //BEGIN EDIT STUFF
1271 void KateView::editStart ()
1272 {
1273  m_viewInternal->editStart ();
1274 }
1275 
1276 void KateView::editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom)
1277 {
1278  m_viewInternal->editEnd (editTagLineStart, editTagLineEnd, tagFrom);
1279 }
1280 
1281 void KateView::editSetCursor (const KateTextCursor &cursor)
1282 {
1283  m_viewInternal->editSetCursor (cursor);
1284 }
1285 //END
1286 
1287 //BEGIN TAG & CLEAR
1288 bool KateView::tagLine (const KateTextCursor& virtualCursor)
1289 {
1290  return m_viewInternal->tagLine (virtualCursor);
1291 }
1292 
1293 bool KateView::tagLines (int start, int end, bool realLines)
1294 {
1295  return m_viewInternal->tagLines (start, end, realLines);
1296 }
1297 
1298 bool KateView::tagLines (KateTextCursor start, KateTextCursor end, bool realCursors)
1299 {
1300  return m_viewInternal->tagLines (start, end, realCursors);
1301 }
1302 
1303 void KateView::tagAll ()
1304 {
1305  m_viewInternal->tagAll ();
1306 }
1307 
1308 void KateView::clear ()
1309 {
1310  m_viewInternal->clear ();
1311 }
1312 
1313 void KateView::repaintText (bool paintOnlyDirty)
1314 {
1315  m_viewInternal->paintText(0,0,m_viewInternal->width(),m_viewInternal->height(), paintOnlyDirty);
1316 }
1317 
1318 void KateView::updateView (bool changed)
1319 {
1320  m_viewInternal->updateView (changed);
1321  m_viewInternal->leftBorder->update();
1322 }
1323 
1324 //END
1325 
1326 void KateView::slotHlChanged()
1327 {
1328  KateHighlighting *hl = m_doc->highlight();
1329  bool ok ( !hl->getCommentStart(0).isEmpty() || !hl->getCommentSingleLineStart(0).isEmpty() );
1330 
1331  if (actionCollection()->action("tools_comment"))
1332  actionCollection()->action("tools_comment")->setEnabled( ok );
1333 
1334  if (actionCollection()->action("tools_uncomment"))
1335  actionCollection()->action("tools_uncomment")->setEnabled( ok );
1336 
1337  // show folding bar if "view defaults" says so, otherwise enable/disable only the menu entry
1338  updateFoldingConfig ();
1339 }
1340 
1341 uint KateView::cursorColumn()
1342 {
1343  uint r = m_doc->currentColumn(m_viewInternal->getCursor());
1344  if ( !( m_doc->config()->configFlags() & KateDocumentConfig::cfWrapCursor ) &&
1345  (uint)m_viewInternal->getCursor().col() > m_doc->textLine( m_viewInternal->getCursor().line() ).length() )
1346  r += m_viewInternal->getCursor().col() - m_doc->textLine( m_viewInternal->getCursor().line() ).length();
1347 
1348  return r;
1349 }
1350 
1351 //BEGIN KTextEditor::SelectionInterface stuff
1352 
1353 bool KateView::setSelection( const KateTextCursor& start, const KateTextCursor& end )
1354 {
1355  KateTextCursor oldSelectStart = selectStart;
1356  KateTextCursor oldSelectEnd = selectEnd;
1357 
1358  if (start <= end) {
1359  selectStart.setPos(start);
1360  selectEnd.setPos(end);
1361  } else {
1362  selectStart.setPos(end);
1363  selectEnd.setPos(start);
1364  }
1365 
1366  tagSelection(oldSelectStart, oldSelectEnd);
1367 
1368  repaintText(true);
1369 
1370  emit selectionChanged ();
1371  emit m_doc->selectionChanged ();
1372 
1373  return true;
1374 }
1375 
1376 bool KateView::setSelection( uint startLine, uint startCol, uint endLine, uint endCol )
1377 {
1378  if (hasSelection())
1379  clearSelection(false, false);
1380 
1381  return setSelection( KateTextCursor(startLine, startCol), KateTextCursor(endLine, endCol) );
1382 }
1383 
1384 void KateView::syncSelectionCache()
1385 {
1386  m_viewInternal->selStartCached = selectStart;
1387  m_viewInternal->selEndCached = selectEnd;
1388  m_viewInternal->selectAnchor = selectEnd;
1389 }
1390 
1391 bool KateView::clearSelection()
1392 {
1393  return clearSelection(true);
1394 }
1395 
1396 bool KateView::clearSelection(bool redraw, bool finishedChangingSelection)
1397 {
1398  if( !hasSelection() )
1399  return false;
1400 
1401  KateTextCursor oldSelectStart = selectStart;
1402  KateTextCursor oldSelectEnd = selectEnd;
1403 
1404  selectStart.setPos(-1, -1);
1405  selectEnd.setPos(-1, -1);
1406 
1407  tagSelection(oldSelectStart, oldSelectEnd);
1408 
1409  oldSelectStart = selectStart;
1410  oldSelectEnd = selectEnd;
1411 
1412  if (redraw)
1413  repaintText(true);
1414 
1415  if (finishedChangingSelection)
1416  {
1417  emit selectionChanged();
1418  emit m_doc->selectionChanged ();
1419  }
1420 
1421  return true;
1422 }
1423 
1424 bool KateView::hasSelection() const
1425 {
1426  return selectStart != selectEnd;
1427 }
1428 
1429 TQString KateView::selection() const
1430 {
1431  int sc = selectStart.col();
1432  int ec = selectEnd.col();
1433 
1434  if ( blockSelect )
1435  {
1436  if (sc > ec)
1437  {
1438  uint tmp = sc;
1439  sc = ec;
1440  ec = tmp;
1441  }
1442  }
1443  return m_doc->text (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
1444 }
1445 
1446 bool KateView::removeSelectedText ()
1447 {
1448  if (!hasSelection())
1449  return false;
1450 
1451  m_doc->editStart ();
1452 
1453  int sc = selectStart.col();
1454  int ec = selectEnd.col();
1455 
1456  if ( blockSelect )
1457  {
1458  if (sc > ec)
1459  {
1460  uint tmp = sc;
1461  sc = ec;
1462  ec = tmp;
1463  }
1464  }
1465 
1466  m_doc->removeText (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
1467 
1468  // don't redraw the cleared selection - that's done in editEnd().
1469  clearSelection(false);
1470 
1471  m_doc->editEnd ();
1472 
1473  return true;
1474 }
1475 
1476 bool KateView::selectAll()
1477 {
1478  setBlockSelectionMode (false);
1479 
1480  return setSelection (0, 0, m_doc->lastLine(), m_doc->lineLength(m_doc->lastLine()));
1481 }
1482 
1483 bool KateView::lineColSelected (int line, int col)
1484 {
1485  if ( (!blockSelect) && (col < 0) )
1486  col = 0;
1487 
1488  KateTextCursor cursor(line, col);
1489 
1490  if (blockSelect)
1491  return cursor.line() >= selectStart.line() && cursor.line() <= selectEnd.line() && cursor.col() >= selectStart.col() && cursor.col() < selectEnd.col();
1492  else
1493  return (cursor >= selectStart) && (cursor < selectEnd);
1494 }
1495 
1496 bool KateView::lineSelected (int line)
1497 {
1498  return (!blockSelect)
1499  && (selectStart <= KateTextCursor(line, 0))
1500  && (line < selectEnd.line());
1501 }
1502 
1503 bool KateView::lineEndSelected (int line, int endCol)
1504 {
1505  return (!blockSelect)
1506  && (line > selectStart.line() || (line == selectStart.line() && (selectStart.col() < endCol || endCol == -1)))
1507  && (line < selectEnd.line() || (line == selectEnd.line() && (endCol <= selectEnd.col() && endCol != -1)));
1508 }
1509 
1510 bool KateView::lineHasSelected (int line)
1511 {
1512  return (selectStart < selectEnd)
1513  && (line >= selectStart.line())
1514  && (line <= selectEnd.line());
1515 }
1516 
1517 bool KateView::lineIsSelection (int line)
1518 {
1519  return (line == selectStart.line() && line == selectEnd.line());
1520 }
1521 
1522 void KateView::tagSelection(const KateTextCursor &oldSelectStart, const KateTextCursor &oldSelectEnd)
1523 {
1524  if (hasSelection()) {
1525  if (oldSelectStart.line() == -1) {
1526  // We have to tag the whole lot if
1527  // 1) we have a selection, and:
1528  // a) it's new; or
1529  tagLines(selectStart, selectEnd, true);
1530 
1531  } else if (blockSelectionMode() && (oldSelectStart.col() != selectStart.col() || oldSelectEnd.col() != selectEnd.col())) {
1532  // b) we're in block selection mode and the columns have changed
1533  tagLines(selectStart, selectEnd, true);
1534  tagLines(oldSelectStart, oldSelectEnd, true);
1535 
1536  } else {
1537  if (oldSelectStart != selectStart) {
1538  if (oldSelectStart < selectStart)
1539  tagLines(oldSelectStart, selectStart, true);
1540  else
1541  tagLines(selectStart, oldSelectStart, true);
1542  }
1543 
1544  if (oldSelectEnd != selectEnd) {
1545  if (oldSelectEnd < selectEnd)
1546  tagLines(oldSelectEnd, selectEnd, true);
1547  else
1548  tagLines(selectEnd, oldSelectEnd, true);
1549  }
1550  }
1551 
1552  } else {
1553  // No more selection, clean up
1554  tagLines(oldSelectStart, oldSelectEnd, true);
1555  }
1556 }
1557 
1558 void KateView::selectWord( const KateTextCursor& cursor )
1559 {
1560  int start, end, len;
1561 
1562  KateTextLine::Ptr textLine = m_doc->plainKateTextLine(cursor.line());
1563 
1564  if (!textLine)
1565  return;
1566 
1567  len = textLine->length();
1568  start = end = cursor.col();
1569  while (start > 0 && m_doc->highlight()->isInWord(textLine->getChar(start - 1), textLine->attribute(start - 1))) start--;
1570  while (end < len && m_doc->highlight()->isInWord(textLine->getChar(end), textLine->attribute(start - 1))) end++;
1571  if (end <= start) return;
1572 
1573  setSelection (cursor.line(), start, cursor.line(), end);
1574 }
1575 
1576 void KateView::selectLine( const KateTextCursor& cursor )
1577 {
1578  if (cursor.line()+1 >= m_doc->numLines())
1579  setSelection (cursor.line(), 0, cursor.line(), m_doc->lineLength(cursor.line()));
1580  else
1581  setSelection (cursor.line(), 0, cursor.line()+1, 0);
1582 }
1583 
1584 void KateView::selectLength( const KateTextCursor& cursor, int length )
1585 {
1586  int start, end;
1587 
1588  KateTextLine::Ptr textLine = m_doc->plainKateTextLine(cursor.line());
1589 
1590  if (!textLine)
1591  return;
1592 
1593  start = cursor.col();
1594  end = start + length;
1595  if (end <= start) return;
1596 
1597  setSelection (cursor.line(), start, cursor.line(), end);
1598 }
1599 
1600 void KateView::paste()
1601 {
1602  m_doc->paste( this );
1603  emit selectionChanged();
1604  m_viewInternal->repaint();
1605 }
1606 
1607 void KateView::cut()
1608 {
1609  if (!hasSelection())
1610  return;
1611 
1612  copy();
1613  removeSelectedText();
1614 }
1615 
1616 void KateView::copy() const
1617 {
1618  if (!hasSelection())
1619  return;
1620 
1621  TQApplication::clipboard()->setText(selection ());
1622 }
1623 
1624 void KateView::copyHTML()
1625 {
1626  if (!hasSelection())
1627  return;
1628 
1629  KMultipleDrag *drag = new KMultipleDrag();
1630 
1631  TQTextDrag *htmltextdrag = new TQTextDrag(selectionAsHtml()) ;
1632  htmltextdrag->setSubtype("html");
1633 
1634  drag->addDragObject( htmltextdrag);
1635  drag->addDragObject( new TQTextDrag( selection()));
1636 
1637  TQApplication::clipboard()->setData(drag);
1638 }
1639 
1640 TQString KateView::selectionAsHtml()
1641 {
1642  int sc = selectStart.col();
1643  int ec = selectEnd.col();
1644 
1645  if ( blockSelect )
1646  {
1647  if (sc > ec)
1648  {
1649  uint tmp = sc;
1650  sc = ec;
1651  ec = tmp;
1652  }
1653  }
1654 
1655  return textAsHtml (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
1656 }
1657 
1658 TQString KateView::textAsHtml ( uint startLine, uint startCol, uint endLine, uint endCol, bool blockwise)
1659 {
1660  kdDebug(13020) << "textAsHtml" << endl;
1661  if ( blockwise && (startCol > endCol) )
1662  return TQString ();
1663 
1664  TQString s;
1665  TQTextStream ts( &s, IO_WriteOnly );
1666  ts.setEncoding(TQTextStream::UnicodeUTF8);
1667  ts << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">" << endl;
1668  ts << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl;
1669  ts << "<head>" << endl;
1670  ts << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" << endl;
1671  ts << "<meta name=\"Generator\" content=\"Kate, the KDE Advanced Text Editor\" />" << endl;
1672  ts << "</head>" << endl;
1673 
1674  ts << "<body>" << endl;
1675  textAsHtmlStream(startLine, startCol, endLine, endCol, blockwise, &ts);
1676 
1677  ts << "</body>" << endl;
1678  ts << "</html>" << endl;
1679  kdDebug(13020) << "html is: " << s << endl;
1680  return s;
1681 }
1682 
1683 void KateView::textAsHtmlStream ( uint startLine, uint startCol, uint endLine, uint endCol, bool blockwise, TQTextStream *ts)
1684 {
1685  if ( (blockwise || startLine == endLine) && (startCol > endCol) )
1686  return;
1687 
1688  if (startLine == endLine)
1689  {
1690  KateTextLine::Ptr textLine = m_doc->kateTextLine(startLine);
1691  if ( !textLine )
1692  return;
1693 
1694  (*ts) << "<pre>" << endl;
1695 
1696  lineAsHTML(textLine, startCol, endCol-startCol, ts);
1697  }
1698  else
1699  {
1700  (*ts) << "<pre>" << endl;
1701 
1702  for (uint i = startLine; (i <= endLine) && (i < m_doc->numLines()); i++)
1703  {
1704  KateTextLine::Ptr textLine = m_doc->kateTextLine(i);
1705 
1706  if ( !blockwise )
1707  {
1708  if (i == startLine)
1709  lineAsHTML(textLine, startCol, textLine->length()-startCol, ts);
1710  else if (i == endLine)
1711  lineAsHTML(textLine, 0, endCol, ts);
1712  else
1713  lineAsHTML(textLine, 0, textLine->length(), ts);
1714  }
1715  else
1716  {
1717  lineAsHTML( textLine, startCol, endCol-startCol, ts);
1718  }
1719 
1720  if ( i < endLine )
1721  (*ts) << "\n"; //we are inside a <pre>, so a \n is a new line
1722  }
1723  }
1724  (*ts) << "</pre>";
1725 }
1726 
1727 // fully rewritten to use only inline CSS and support all used attribs.
1728 // anders, 2005-11-01 23:39:43
1729 void KateView::lineAsHTML (KateTextLine::Ptr line, uint startCol, uint length, TQTextStream *outputStream)
1730 {
1731  if(length == 0)
1732  return;
1733 
1734  // do not recalculate the style strings again and again
1735  TQMap<uchar,TQString> stylecache;
1736  // do not insert equally styled characters one by one
1737  TQString textcache;
1738 
1739  KateAttribute *charAttributes = 0;
1740 
1741  for (uint curPos=startCol;curPos<(length+startCol);curPos++)
1742  {
1743  if ( curPos == 0 || line->attribute( curPos ) != line->attribute( curPos - 1 ) &&
1744  // Since many highlight files contains itemdatas that have the exact
1745  // same styles, join those to keep the HTML text size down
1746  KateAttribute(*charAttributes) != KateAttribute(*m_renderer->attribute(line->attribute(curPos))) )
1747  {
1748  (*outputStream) << textcache;
1749  textcache.truncate(0);
1750 
1751  if ( curPos > startCol )
1752  (*outputStream) << "</span>";
1753 
1754  charAttributes = m_renderer->attribute(line->attribute(curPos));
1755 
1756  if ( ! stylecache.contains( line->attribute(curPos) ) )
1757  {
1758  TQString textdecoration;
1759  TQString style;
1760 
1761  if ( charAttributes->bold() )
1762  style.append("font-weight: bold;");
1763  if ( charAttributes->italic() )
1764  style.append("font-style: italic;");
1765  if ( charAttributes->underline() )
1766  textdecoration = "underline";
1767  if ( charAttributes->overline() )
1768  textdecoration.append(" overline" );
1769  if ( charAttributes->strikeOut() )
1770  textdecoration.append(" line-trough" );
1771  if ( !textdecoration.isEmpty() )
1772  style.append("text-decoration: %1;").arg(textdecoration);
1773  // TQColor::name() returns a string in the form "#RRGGBB" in Qt 3.
1774  // NOTE Qt 4 returns "#AARRGGBB"
1775  if ( charAttributes->itemSet(KateAttribute::BGColor) )
1776  style.append(TQString("background-color: %1;").arg(charAttributes->bgColor().name()));
1777  if ( charAttributes->itemSet(KateAttribute::TextColor) )
1778  style.append(TQString("color: %1;").arg(charAttributes->textColor().name()));
1779 
1780  stylecache[line->attribute(curPos)] = style;
1781  }
1782  (*outputStream)<<"<span style=\""
1783  << stylecache[line->attribute(curPos)]
1784  << "\">";
1785  }
1786 
1787  TQString s( line->getChar(curPos) );
1788  if ( s == "&" ) s = "&amp;";
1789  else if ( s == "<" ) s = "&lt;";
1790  else if ( s == ">" ) s = "&gt;";
1791  textcache.append( s );
1792  }
1793 
1794  (*outputStream) << textcache << "</span>";
1795 }
1796 
1797 void KateView::exportAsHTML ()
1798 {
1799  KURL url = KFileDialog::getSaveURL(m_doc->docName(),"text/html",0,i18n("Export File as HTML"));
1800 
1801  if ( url.isEmpty() )
1802  return;
1803 
1804  TQString filename;
1805  KTempFile tmp; // ### only used for network export
1806 
1807  if ( url.isLocalFile() )
1808  filename = url.path();
1809  else
1810  filename = tmp.name();
1811 
1812  KSaveFile *savefile=new KSaveFile(filename);
1813  if (!savefile->status())
1814  {
1815  TQTextStream *outputStream = savefile->textStream();
1816 
1817  outputStream->setEncoding(TQTextStream::UnicodeUTF8);
1818 
1819  // let's write the HTML header :
1820  (*outputStream) << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
1821  (*outputStream) << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">" << endl;
1822  (*outputStream) << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl;
1823  (*outputStream) << "<head>" << endl;
1824  (*outputStream) << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />" << endl;
1825  (*outputStream) << "<meta name=\"Generator\" content=\"Kate, the KDE Advanced Text Editor\" />" << endl;
1826  // for the title, we write the name of the file (/usr/local/emmanuel/myfile.cpp -> myfile.cpp)
1827  (*outputStream) << "<title>" << m_doc->docName () << "</title>" << endl;
1828  (*outputStream) << "</head>" << endl;
1829  (*outputStream) << "<body>" << endl;
1830 
1831  textAsHtmlStream(0,0, m_doc->lastLine(), m_doc->lineLength(m_doc->lastLine()), false, outputStream);
1832 
1833  (*outputStream) << "</body>" << endl;
1834  (*outputStream) << "</html>" << endl;
1835 
1836 
1837  savefile->close();
1838  //if (!savefile->status()) --> Error
1839  }
1840 // else
1841 // {/*ERROR*/}
1842  delete savefile;
1843 
1844  if ( url.isLocalFile() )
1845  return;
1846 
1847  TDEIO::NetAccess::upload( filename, url, 0 );
1848 }
1849 //END
1850 
1851 //BEGIN KTextEditor::BlockSelectionInterface stuff
1852 
1853 bool KateView::blockSelectionMode ()
1854 {
1855  return blockSelect;
1856 }
1857 
1858 bool KateView::setBlockSelectionMode (bool on)
1859 {
1860  if (on != blockSelect)
1861  {
1862  blockSelect = on;
1863 
1864  KateTextCursor oldSelectStart = selectStart;
1865  KateTextCursor oldSelectEnd = selectEnd;
1866 
1867  clearSelection(false, false);
1868 
1869  setSelection(oldSelectStart, oldSelectEnd);
1870 
1871  slotSelectionTypeChanged();
1872  }
1873 
1874  return true;
1875 }
1876 
1877 bool KateView::toggleBlockSelectionMode ()
1878 {
1879  m_toggleBlockSelection->setChecked (!blockSelect);
1880  return setBlockSelectionMode (!blockSelect);
1881 }
1882 
1883 bool KateView::wrapCursor ()
1884 {
1885  return !blockSelectionMode() && (m_doc->configFlags() & KateDocument::cfWrapCursor);
1886 }
1887 
1888 //END
1889 
1890 //BEGIN IM INPUT STUFF
1891 void KateView::setIMSelectionValue( uint imStartLine, uint imStart, uint imEnd,
1892  uint imSelStart, uint imSelEnd, bool imComposeEvent )
1893 {
1894  m_imStartLine = imStartLine;
1895  m_imStart = imStart;
1896  m_imEnd = imEnd;
1897  m_imSelStart = imSelStart;
1898  m_imSelEnd = imSelEnd;
1899  m_imComposeEvent = imComposeEvent;
1900 }
1901 
1902 bool KateView::isIMSelection( int _line, int _column )
1903 {
1904  return ( ( int( m_imStartLine ) == _line ) && ( m_imSelStart < m_imSelEnd ) && ( _column >= int( m_imSelStart ) ) &&
1905  ( _column < int( m_imSelEnd ) ) );
1906 }
1907 
1908 bool KateView::isIMEdit( int _line, int _column )
1909 {
1910  return ( ( int( m_imStartLine ) == _line ) && ( m_imStart < m_imEnd ) && ( _column >= int( m_imStart ) ) &&
1911  ( _column < int( m_imEnd ) ) );
1912 }
1913 
1914 void KateView::getIMSelectionValue( uint *imStartLine, uint *imStart, uint *imEnd,
1915  uint *imSelStart, uint *imSelEnd )
1916 {
1917  *imStartLine = m_imStartLine;
1918  *imStart = m_imStart;
1919  *imEnd = m_imEnd;
1920  *imSelStart = m_imSelStart;
1921  *imSelEnd = m_imSelEnd;
1922 }
1923 //END IM INPUT STUFF
KGuiItem
KKey
KMessageBox::error
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
KMessageBox::warningContinueCancel
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
KMultipleDrag
KMultipleDrag::addDragObject
void addDragObject(TQDragObject *dragObject)
KParts::BrowserExtension
KParts::BrowserExtension::childObject
static BrowserExtension * childObject(TQObject *obj)
KParts::BrowserExtension::openURLRequest
void openURLRequest(const KURL &url, const KParts::URLArgs &args=KParts::URLArgs())
KSaveFile
KSaveFile::status
int status() const
KSaveFile::close
bool close()
KSaveFile::textStream
TQTextStream * textStream()
KTempFile
KTempFile::name
TQString name() const
KURLDrag::decode
static bool decode(const TQMimeSource *e, KURL::List &urls)
KURL::List
KURL
KURL::path
TQString path() const
KURL::isEmpty
bool isEmpty() const
KURL::isLocalFile
bool isLocalFile() const
KateAttribute
The Attribute class incorporates all text decorations supported by Kate.
Definition: kateattribute.h:33
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:43
KateTextCursor
Simple cursor class with no document pointer.
Definition: katecursor.h:34
KateViewIndentationAction
This action provides a list of available indenters and gets plugged into the KateView's TDEActionColl...
Definition: kateautoindent.h:196
Kate::View
The Kate::View text editor interface.
Definition: view.h:45
Kate::View::saveResult
saveResult
Return values for "save" related commands.
Definition: view.h:52
TDEAccel
TDEAccel::setEnabled
void setEnabled(bool bEnabled)
TDEAccel::insert
TDEAccelAction * insert(const TQString &sAction, const TQString &sLabel, const TQString &sWhatsThis, const TDEShortcut &cutDef, const TQObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true)
TDEActionCollection
TDEAction
TDEAction::setShortcut
virtual bool setShortcut(const TDEShortcut &)
TDEAction::setWhatsThis
virtual void setWhatsThis(const TQString &text)
TDEAction::setEnabled
virtual void setEnabled(bool enable)
TDEAction::shortcut
virtual const TDEShortcut & shortcut() const
TDEConfigBase::readNumEntry
int readNumEntry(const TQString &pKey, int nDefault=0) const
TDEConfigBase::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
TDEConfig
TDEGlobal::locale
static TDELocale * locale()
TDESelectAction
TDESharedPtr
TDEShortcut
TDEShortcut::append
bool append(const KKeySequence &keySeq)
TDEToggleAction
TDEToggleAction::setCheckedState
void setCheckedState(const KGuiItem &checkedItem)
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
flush
kndbgstream & flush(kndbgstream &s)
KNotifyClient::instance
TDEInstance * instance()
KStdAction::selectAll
TDEAction * selectAll(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::deselect
TDEAction * deselect(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::save
TDEAction * save(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::gotoLine
TDEAction * gotoLine(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::undo
TDEAction * undo(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::redo
TDEAction * redo(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::cut
TDEAction * cut(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::pasteText
TDEAction * pasteText(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::saveAs
TDEAction * saveAs(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::copy
TDEAction * copy(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
KStdAction::print
TDEAction * print(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
Kate
Kate namespace All classes in this namespace must stay BC during one major release series (e....
Definition: document.h:51
TDEStdAccel::copy
const TDEShortcut & copy()
TDEStdAccel::next
const TDEShortcut & next()
TDEStdAccel::paste
const TDEShortcut & paste()
TDEStdAccel::prior
const TDEShortcut & prior()
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::cut
const TDEShortcut & cut()
TDEStdAccel::end
const TDEShortcut & end()
TDEStdAccel::redo
const TDEShortcut & redo()
TDEStdAccel::deleteWordBack
const TDEShortcut & deleteWordBack()
TDEStdAccel::save
const TDEShortcut & save()
TDEStdAccel::undo
const TDEShortcut & undo()
TDEStdAccel::home
const TDEShortcut & home()
TDEStdAccel::print
const TDEShortcut & print()
TDEStdAccel::action
TQString action(StdAccel id)
TDEStdAccel::gotoLine
const TDEShortcut & gotoLine()
TDEStdAccel::deleteWordForward
const TDEShortcut & deleteWordForward()
TDEStdAccel::reload
const TDEShortcut & reload()
TDEStdAccel::selectAll
const TDEShortcut & selectAll()
TDEStdAccel::up
const TDEShortcut & up()
tdelocale.h

kate

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

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.1
This website is maintained by Timothy Pearson.