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

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.8.8
This website is maintained by Timothy Pearson.