27 #include "kateview.moc"
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"
49 #include <tdetexteditor/plugin.h>
51 #include <tdeparts/event.h>
53 #include <tdeio/netaccess.h>
55 #include <tdeconfig.h>
58 #include <tdeapplication.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>
68 #include <klibloader.h>
69 #include <kencodingfiledialog.h>
70 #include <tdemultipledrag.h>
71 #include <tdetempfile.h>
72 #include <ksavefile.h>
75 #include <tqfileinfo.h>
78 #include <tqpopupmenu.h>
80 #include <tqclipboard.h>
81 #include <tqstylesheet.h>
84 KateView::KateView( KateDocument *doc, TQWidget *parent,
const char * name )
87 , m_search( new KateSearch( this ) )
88 , m_spell( new KateSpell( this ) )
89 , m_bookmarks( new KateBookmarks( this ) )
95 , m_updatingDocumentConfig (false)
96 , selectStart (m_doc, true)
97 , selectEnd (m_doc, true)
104 , m_imComposeEvent( false )
106 KateFactory::self()->registerView(
this );
107 m_config =
new KateViewConfig (
this);
111 m_grid =
new TQGridLayout (
this, 3, 3);
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 );
119 m_viewInternal =
new KateViewInternal(
this, doc );
120 m_grid->addWidget (m_viewInternal, 0, 1);
122 setClipboardInterfaceDCOPSuffix (viewDCOPSuffix());
123 setCodeCompletionInterfaceDCOPSuffix (viewDCOPSuffix());
124 setDynWordWrapInterfaceDCOPSuffix (viewDCOPSuffix());
125 setPopupMenuInterfaceDCOPSuffix (viewDCOPSuffix());
126 setSessionConfigInterfaceDCOPSuffix (viewDCOPSuffix());
127 setViewCursorInterfaceDCOPSuffix (viewDCOPSuffix());
128 setViewStatusMsgInterfaceDCOPSuffix (viewDCOPSuffix());
130 setInstance( KateFactory::self()->
instance() );
131 doc->addView(
this );
133 setFocusProxy( m_viewInternal );
134 setFocusPolicy( TQWidget::StrongFocus );
136 if (!doc->singleViewMode()) {
137 setXMLFile(
"katepartui.rc" );
139 if( doc->readOnly() )
140 setXMLFile(
"katepartreadonlyui.rc" );
142 setXMLFile(
"katepartui.rc" );
149 setupCodeCompletion();
152 m_doc->enableAllPluginsGUI (
this);
157 m_startingUp =
false;
168 KateView::~KateView()
170 if (!m_doc->singleViewMode())
171 m_doc->disableAllPluginsGUI (
this);
173 m_doc->removeView(
this );
184 KateFactory::self()->deregisterView (
this);
187 void KateView::setupConnections()
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()));
201 if ( m_doc->browserView() )
203 connect(
this, TQ_SIGNAL(dropEventPass(TQDropEvent*)),
204 this, TQ_SLOT(slotDropEventPass(TQDropEvent*)) );
208 void KateView::setupActions()
213 m_toggleWriteLock = 0;
216 a->
setWhatsThis(i18n(
"Cut the selected text and move it to the clipboard"));
219 a->
setWhatsThis(i18n(
"Paste previously copied or cut clipboard contents"));
222 a->
setWhatsThis(i18n(
"Use this command to copy the currently selected text to the system clipboard."));
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."));
227 if (!m_doc->readOnly())
233 a->
setWhatsThis(i18n(
"Revert the most recent editing actions"));
236 a->
setWhatsThis(i18n(
"Revert the most recent undo operation"));
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."));
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."));
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."));
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."));
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."));
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."));
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") );
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.") );
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.") );
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.") );
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."));
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."));
297 m_cut->setEnabled (
false);
298 m_paste->setEnabled (
false);
307 a->
setWhatsThis(i18n(
"Reload the current document from disk."));
310 a->
setWhatsThis(i18n(
"Save the current document to disk, with a name of your choice."));
313 a->
setWhatsThis(i18n(
"This command opens a dialog and lets you choose a line that you want the cursor to move to."));
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."));
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);
322 KateViewFileTypeAction *ftm =
new KateViewFileTypeAction (i18n(
"&Filetype"),ac,
"set_filetype");
323 ftm->updateMenu (m_doc);
325 KateViewSchemaAction *schemaMenu =
new KateViewSchemaAction (i18n(
"&Schema"),ac,
"view_schemas");
326 schemaMenu->updateMenu (
this);
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."));
337 a->
setWhatsThis(i18n(
"Select the entire text of the current document."));
340 a->
setWhatsThis(i18n(
"If you have selected something within the current document, this will no longer be selected."));
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."));
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."));
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."));
355 i18n(
"Overwr&ite Mode"), Key_Insert,
356 this, TQ_SLOT(toggleInsert()),
358 a->
setWhatsThis(i18n(
"Choose whether you want the text you type to be inserted or to overwrite existing text."));
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."));
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"));
370 connect(m_setDynWrapIndicators, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(setDynWrapIndicators(
int)));
372 list2.append(i18n(
"&Off"));
373 list2.append(i18n(
"Follow &Line Numbers"));
374 list2.append(i18n(
"&Always On"));
375 m_setDynWrapIndicators->setItems(list2);
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."));
385 i18n(
"Show &Icon Border"), Key_F6,
386 this, TQ_SLOT(toggleIconBorder()),
389 a->
setWhatsThis(i18n(
"Show/hide the icon border.<BR><BR> The icon border shows bookmark symbols, for instance."));
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."));
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."));
407 i18n(
"Show Static &Word Wrap Marker"), 0,
408 this, TQ_SLOT( toggleWWMarker() ),
409 ac,
"view_word_wrap_marker" );
411 "Show/hide the Word Wrap Marker, a vertical line drawn at the word "
412 "wrap column as defined in the editing properties" ));
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."));
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"));
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)));
432 new KateViewEncodingAction (m_doc,
this, i18n(
"E&ncoding"), ac,
"set_encoding");
434 m_search->createActions( ac );
435 m_spell->createActions( ac );
436 m_bookmarks->createActions( ac );
438 slotSelectionChanged ();
440 connect (
this, TQ_SIGNAL(selectionChanged()),
this, TQ_SLOT(slotSelectionChanged()));
443 void KateView::setupEditActions()
449 i18n(
"Move Word Left"), CTRL + Key_Left,
450 this,TQ_SLOT(wordLeft()),
453 i18n(
"Select Character Left"), SHIFT + Key_Left,
454 this,TQ_SLOT(shiftCursorLeft()),
455 ac,
"select_char_left" );
457 i18n(
"Select Word Left"), SHIFT + CTRL + Key_Left,
458 this, TQ_SLOT(shiftWordLeft()),
459 ac,
"select_word_left" );
462 i18n(
"Move Word Right"), CTRL + Key_Right,
463 this, TQ_SLOT(wordRight()),
466 i18n(
"Select Character Right"), SHIFT + Key_Right,
467 this, TQ_SLOT(shiftCursorRight()),
468 ac,
"select_char_right" );
470 i18n(
"Select Word Right"), SHIFT + CTRL + Key_Right,
471 this,TQ_SLOT(shiftWordRight()),
472 ac,
"select_word_right" );
475 i18n(
"Move to Beginning of Line"), Key_Home,
476 this, TQ_SLOT(
home()),
477 ac,
"beginning_of_line" );
480 this, TQ_SLOT(top()),
481 ac,
"beginning_of_document" );
483 i18n(
"Select to Beginning of Line"), SHIFT + Key_Home,
484 this, TQ_SLOT(shiftHome()),
485 ac,
"select_beginning_of_line" );
487 i18n(
"Select to Beginning of Document"), SHIFT + CTRL + Key_Home,
488 this, TQ_SLOT(shiftTop()),
489 ac,
"select_beginning_of_document" );
492 i18n(
"Move to End of Line"), Key_End,
493 this, TQ_SLOT(
end()),
497 this, TQ_SLOT(bottom()),
498 ac,
"end_of_document" );
500 i18n(
"Select to End of Line"), SHIFT + Key_End,
501 this, TQ_SLOT(shiftEnd()),
502 ac,
"select_end_of_line" );
504 i18n(
"Select to End of Document"), SHIFT + CTRL + Key_End,
505 this, TQ_SLOT(shiftBottom()),
506 ac,
"select_end_of_document" );
509 i18n(
"Select to Previous Line"), SHIFT + Key_Up,
510 this, TQ_SLOT(shiftUp()),
511 ac,
"select_line_up" );
513 i18n(
"Scroll Line Up"),
"", CTRL + Key_Up,
514 this, TQ_SLOT(scrollUp()),
515 ac,
"scroll_line_up" );
517 new TDEAction(i18n(
"Move to Next Line"), Key_Down,
this, TQ_SLOT(down()),
518 ac,
"move_line_down");
520 new TDEAction(i18n(
"Move to Previous Line"), Key_Up,
this, TQ_SLOT(
up()),
523 new TDEAction(i18n(
"Move Character Right"), Key_Right,
this,
524 TQ_SLOT(cursorRight()), ac,
"move_cursor_right");
526 new TDEAction(i18n(
"Move Character Left"), Key_Left,
this, TQ_SLOT(cursorLeft()),
527 ac,
"move_cusor_left");
530 i18n(
"Select to Next Line"), SHIFT + Key_Down,
531 this, TQ_SLOT(shiftDown()),
532 ac,
"select_line_down" );
534 i18n(
"Scroll Line Down"), CTRL + Key_Down,
535 this, TQ_SLOT(scrollDown()),
536 ac,
"scroll_line_down" );
540 this, TQ_SLOT(pageUp()),
541 ac,
"scroll_page_up" );
543 i18n(
"Select Page Up"), SHIFT + Key_PageUp,
544 this, TQ_SLOT(shiftPageUp()),
545 ac,
"select_page_up" );
547 i18n(
"Move to Top of View"), CTRL + Key_PageUp,
548 this, TQ_SLOT(topOfView()),
549 ac,
"move_top_of_view" );
551 i18n(
"Select to Top of View"), CTRL + SHIFT + Key_PageUp,
552 this, TQ_SLOT(shiftTopOfView()),
553 ac,
"select_top_of_view" );
557 this, TQ_SLOT(pageDown()),
558 ac,
"scroll_page_down" );
560 i18n(
"Select Page Down"), SHIFT + Key_PageDown,
561 this, TQ_SLOT(shiftPageDown()),
562 ac,
"select_page_down" );
564 i18n(
"Move to Bottom of View"), CTRL + Key_PageDown,
565 this, TQ_SLOT(bottomOfView()),
566 ac,
"move_bottom_of_view" );
568 i18n(
"Select to Bottom of View"), CTRL + SHIFT + Key_PageDown,
569 this, TQ_SLOT(shiftBottomOfView()),
570 ac,
"select_bottom_of_view" );
572 i18n(
"Move to Matching Bracket"), CTRL + Key_6,
573 this, TQ_SLOT(toMatchingBracket()),
574 ac,
"to_matching_bracket" );
576 i18n(
"Select to Matching Bracket"), SHIFT + CTRL + Key_6,
577 this, TQ_SLOT(shiftToMatchingBracket()),
578 ac,
"select_matching_bracket" );
581 if ( !m_doc->readOnly() )
584 i18n(
"Transpose Characters"), CTRL + Key_T,
585 this, TQ_SLOT(transpose()),
586 ac,
"transpose_char" );
589 i18n(
"Delete Line"), CTRL + Key_K,
590 this, TQ_SLOT(killLine()),
595 this, TQ_SLOT(deleteWordLeft()),
596 ac,
"delete_word_left" );
600 this, TQ_SLOT(deleteWordRight()),
601 ac,
"delete_word_right" );
603 new TDEAction(i18n(
"Delete Next Character"), Key_Delete,
604 this, TQ_SLOT(keyDelete()),
605 ac,
"delete_next_character");
608 this, TQ_SLOT(backspace()),
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()) );
620 m_editActions->readShortcutSettings(
"Katepart Shortcuts" );
630 void KateView::setupCodeFolding()
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");
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()));
650 void KateView::slotExpandToplevel()
652 m_doc->foldingTree()->expandToplevelNodes(m_doc->numLines());
655 void KateView::slotCollapseLocal()
657 int realLine = m_doc->foldingTree()->collapseOne(cursorLine());
661 setCursorPositionInternal(realLine, cursorColumn(), tabWidth(),
false);
664 void KateView::slotExpandLocal()
666 m_doc->foldingTree()->expandOne(cursorLine(), m_doc->numLines());
669 void KateView::setupCodeCompletion()
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*)));
684 void KateView::slotGotFocus()
686 m_editActions->accel()->setEnabled(
true );
691 void KateView::slotLostFocus()
693 m_editActions->accel()->setEnabled(
false );
696 void KateView::setDynWrapIndicators(
int mode)
698 config()->setDynWordWrapIndicators (mode);
701 void KateView::slotStatusMsg ()
704 if (m_doc->isReadWrite())
706 if (m_doc->config()->configFlags() & KateDocument::cfOvr)
707 ovrstr = i18n(
" OVR ");
709 ovrstr = i18n(
" INS ");
712 ovrstr = i18n(
" R/O ");
714 uint r = cursorLine() + 1;
715 uint c = cursorColumn() + 1;
720 TQString modstr = m_doc->isModified() ? TQString (
" * ") : TQString (
" ");
721 TQString blockstr = blockSelectionMode() ? i18n(
" BLK ") : i18n(
" NORM ");
723 emit viewStatusMsg (s1 + s2 +
" " + ovrstr + blockstr + modstr);
726 void KateView::slotSelectionTypeChanged()
728 m_toggleBlockSelection->setChecked( blockSelectionMode() );
733 bool KateView::isOverwriteMode()
const
735 return m_doc->config()->configFlags() & KateDocument::cfOvr;
738 void KateView::reloadFile()
744 void KateView::slotUpdate()
751 void KateView::slotReadWriteChanged ()
753 if ( m_toggleWriteLock )
754 m_toggleWriteLock->setChecked( ! m_doc->isReadWrite() );
756 m_cut->setEnabled (m_doc->isReadWrite());
757 m_paste->setEnabled (m_doc->isReadWrite());
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";
769 for (uint z = 0; z < l.size(); z++)
770 if ((a = actionCollection()->
action( l[z].ascii() )))
774 void KateView::slotNewUndo()
776 if (m_doc->readOnly())
779 if ((m_doc->undoCount() > 0) != m_editUndo->isEnabled())
780 m_editUndo->setEnabled(m_doc->undoCount() > 0);
782 if ((m_doc->redoCount() > 0) != m_editRedo->isEnabled())
783 m_editRedo->setEnabled(m_doc->redoCount() > 0);
786 void KateView::slotDropEventPass( TQDropEvent * ev )
796 void KateView::contextMenuEvent( TQContextMenuEvent *ev )
798 if ( !m_doc || !m_doc->browserExtension() )
800 emit m_doc->browserExtension()->popupMenu( ev->globalPos(), m_doc->url(),
801 TQString::fromLatin1(
"text/plain" ) );
805 bool KateView::setCursorPositionInternal( uint line, uint col, uint tabwidth,
bool calledExternally )
812 TQString line_str = m_doc->textLine( line );
816 for (z = 0; z < line_str.length() && z < col; z++) {
817 if (line_str[z] == TQChar(
'\t')) x += tabwidth - (x % tabwidth);
else x++;
820 m_viewInternal->updateCursor(
KateTextCursor( line, x ),
false,
true, calledExternally );
825 void KateView::setOverwriteMode(
bool b )
827 if ( isOverwriteMode() && !b )
828 m_doc->setConfigFlags( m_doc->config()->configFlags() ^ KateDocument::cfOvr );
830 m_doc->setConfigFlags( m_doc->config()->configFlags() | KateDocument::cfOvr );
832 m_toggleInsert->setChecked (isOverwriteMode ());
835 void KateView::toggleInsert()
837 m_doc->setConfigFlags(m_doc->config()->configFlags() ^ KateDocument::cfOvr);
838 m_toggleInsert->setChecked (isOverwriteMode ());
843 bool KateView::canDiscard()
845 return m_doc->closeURL();
855 if( !m_doc->url().isValid() || !doc()->isReadWrite() )
867 KEncodingFileDialog::Result res=KEncodingFileDialog::getSaveURLAndEncoding(doc()->config()->encoding(),
868 m_doc->url().url(),TQString::null,
this,i18n(
"Save File"));
872 if( res.URLs.isEmpty() || !checkOverwrite( res.URLs.first() ) )
875 m_doc->config()->setEncoding( res.encoding );
877 if( m_doc->saveAs( res.URLs.first() ) )
883 bool KateView::checkOverwrite(
KURL u )
888 TQFileInfo info( u.
path() );
892 return KMessageBox::Continue
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" ) )
901 void KateView::slotSaveCanceled(
const TQString& error )
903 if ( !error.isEmpty() )
907 void KateView::gotoLine()
909 KateGotoLineDialog *dlg =
new KateGotoLineDialog (
this, m_viewInternal->getCursor().line() + 1, m_doc->numLines());
911 if (dlg->exec() == TQDialog::Accepted)
912 gotoLineNumber( dlg->getLine() - 1 );
917 void KateView::gotoLineNumber(
int line )
920 if ( !config()->persistentSelection() )
922 setCursorPositionInternal ( line, 0, 1 );
925 void KateView::joinLines()
927 int first = selStartLine();
928 int last = selEndLine();
932 first = cursorLine();
935 m_doc->joinLines( first, last );
938 void KateView::readSessionConfig(
TDEConfig *config)
943 void KateView::writeSessionConfig(
TDEConfig *config)
945 config->
writeEntry(
"CursorLine",m_viewInternal->cursor.line());
946 config->
writeEntry(
"CursorColumn",m_viewInternal->cursor.col());
949 int KateView::getEol()
951 return m_doc->config()->eol();
954 void KateView::setEol(
int eol)
956 if (!doc()->isReadWrite())
959 if (m_updatingDocumentConfig)
962 m_doc->config()->setEol (eol);
965 void KateView::setIconBorder(
bool enable )
967 config()->setIconBar (enable);
970 void KateView::toggleIconBorder()
972 config()->setIconBar (!config()->iconBar());
975 void KateView::setLineNumbersOn(
bool enable )
977 config()->setLineNumbers (enable);
980 void KateView::toggleLineNumbersOn()
982 config()->setLineNumbers (!config()->lineNumbers());
985 void KateView::setScrollBarMarks(
bool enable )
987 config()->setScrollBarMarks (enable);
990 void KateView::toggleScrollBarMarks()
992 config()->setScrollBarMarks (!config()->scrollBarMarks());
995 void KateView::toggleDynWordWrap()
997 config()->setDynWordWrap( !config()->dynWordWrap() );
1000 void KateView::setDynWordWrap(
bool b )
1002 config()->setDynWordWrap( b );
1005 void KateView::toggleWWMarker()
1007 m_renderer->config()->setWordWrapMarker (!m_renderer->config()->wordWrapMarker());
1010 void KateView::setFoldingMarkersOn(
bool enable )
1012 config()->setFoldingBar ( enable );
1015 void KateView::toggleFoldingMarkers()
1017 config()->setFoldingBar ( !config()->foldingBar() );
1020 bool KateView::iconBorder() {
1021 return m_viewInternal->leftBorder->iconBorderOn();
1024 bool KateView::lineNumbersOn() {
1025 return m_viewInternal->leftBorder->lineNumbersOn();
1028 bool KateView::scrollBarMarks() {
1029 return m_viewInternal->m_lineScroll->showMarks();
1032 int KateView::dynWrapIndicators() {
1033 return m_viewInternal->leftBorder->dynWrapIndicators();
1036 bool KateView::foldingMarkersOn() {
1037 return m_viewInternal->leftBorder->foldingMarkersOn();
1040 void KateView::showCmdLine (
bool enabled )
1042 if (enabled == m_cmdLineOn)
1049 m_cmdLine =
new KateCmdLine (
this);
1050 m_grid->addMultiCellWidget (m_cmdLine, 2, 2, 0, 2);
1054 m_cmdLine->setFocus();
1061 m_cmdLineOn = enabled;
1064 void KateView::toggleCmdLine ()
1066 m_config->setCmdLine (!m_config->cmdLine ());
1069 void KateView::toggleWriteLock()
1071 m_doc->setReadWrite( ! m_doc->isReadWrite() );
1074 void KateView::enableTextHints(
int timeout)
1076 m_viewInternal->enableTextHints(timeout);
1079 void KateView::disableTextHints()
1081 m_viewInternal->disableTextHints();
1084 void KateView::applyWordWrap ()
1087 m_doc->wrapText (selectStart.line(), selectEnd.line());
1089 m_doc->wrapText (0, m_doc->lastLine());
1092 void KateView::slotNeedTextHint(
int line,
int col, TQString &text)
1094 text=TQString(
"test %1 %2").arg(line).arg(col);
1097 void KateView::find()
1102 void KateView::find(
const TQString& pattern,
long flags,
bool add )
1104 m_search->find( pattern, flags, add );
1107 void KateView::replace()
1109 m_search->replace();
1112 void KateView::replace(
const TQString &pattern,
const TQString &replacement,
long flags )
1114 m_search->replace( pattern, replacement, flags );
1117 void KateView::findAgain(
bool back )
1119 m_search->findAgain( back );
1122 void KateView::slotSelectionChanged ()
1124 m_copy->setEnabled (hasSelection());
1125 m_copyHTML->setEnabled (hasSelection());
1126 m_deSelect->setEnabled (hasSelection());
1128 if (m_doc->readOnly())
1131 m_cut->setEnabled (hasSelection());
1133 m_spell->updateActions ();
1136 void KateView::switchToCmdLine ()
1139 m_config->setCmdLine (
true);
1141 if (m_cmdLine->hasFocus()) {
1146 m_cmdLine->setFocus ();
1149 void KateView::showArgHint( TQStringList arg1,
const TQString& arg2,
const TQString& arg3 )
1151 m_codeCompletion->showArgHint( arg1, arg2, arg3 );
1154 void KateView::showCompletionBox( TQValueList<KTextEditor::CompletionEntry> arg1,
int offset,
bool cs )
1156 emit aboutToShowCompletionBox();
1157 m_codeCompletion->showCompletionBox( arg1, offset, cs );
1165 void KateView::updateConfig ()
1170 m_editActions->readShortcutSettings(
"Katepart Shortcuts" );
1173 if (m_hasWrap != config()->dynWordWrap()) {
1174 m_viewInternal->prepareForDynWrapChange();
1176 m_hasWrap = config()->dynWordWrap();
1178 m_viewInternal->dynWrapChanged();
1180 m_setDynWrapIndicators->setEnabled(config()->dynWordWrap());
1181 m_toggleDynWrap->setChecked( config()->dynWordWrap() );
1184 m_viewInternal->leftBorder->setDynWrapIndicators( config()->dynWordWrapIndicators() );
1185 m_setDynWrapIndicators->setCurrentItem( config()->dynWordWrapIndicators() );
1188 m_viewInternal->leftBorder->setLineNumbersOn( config()->lineNumbers() );
1189 m_toggleLineNumbers->setChecked( config()->lineNumbers() );
1192 m_viewInternal->leftBorder->setIconBorderOn( config()->iconBar() );
1193 m_toggleIconBar->setChecked( config()->iconBar() );
1196 m_viewInternal->m_lineScroll->setShowMarks( config()->scrollBarMarks() );
1197 m_toggleScrollBarMarks->setChecked( config()->scrollBarMarks() );
1200 showCmdLine (config()->cmdLine());
1204 m_toggleBlockSelection->setChecked( blockSelectionMode() );
1205 m_toggleInsert->setChecked( isOverwriteMode() );
1207 updateFoldingConfig ();
1210 m_bookmarks->setSorting( (KateBookmarks::Sorting) config()->bookmarkSort() );
1212 m_viewInternal->setAutoCenterLines(config()->autoCenterLines ());
1215 void KateView::updateDocumentConfig()
1220 m_updatingDocumentConfig =
true;
1222 m_setEndOfLine->setCurrentItem (m_doc->config()->eol());
1224 m_updatingDocumentConfig =
false;
1226 m_viewInternal->updateView (
true);
1228 m_renderer->setTabWidth (m_doc->config()->tabWidth());
1229 m_renderer->setIndentWidth (m_doc->config()->indentationWidth());
1232 void KateView::updateRendererConfig()
1237 m_toggleWWMarker->setChecked( m_renderer->config()->wordWrapMarker() );
1240 m_viewInternal->updateView (
true);
1241 m_viewInternal->repaint ();
1244 m_viewInternal->leftBorder->updateFont();
1245 m_viewInternal->leftBorder->repaint ();
1251 void KateView::updateFoldingConfig ()
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() );
1261 l <<
"folding_toplevel" <<
"folding_expandtoplevel"
1262 <<
"folding_collapselocal" <<
"folding_expandlocal";
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());
1271 void KateView::editStart ()
1273 m_viewInternal->editStart ();
1276 void KateView::editEnd (
int editTagLineStart,
int editTagLineEnd,
bool tagFrom)
1278 m_viewInternal->editEnd (editTagLineStart, editTagLineEnd, tagFrom);
1283 m_viewInternal->editSetCursor (cursor);
1290 return m_viewInternal->tagLine (virtualCursor);
1293 bool KateView::tagLines (
int start,
int end,
bool realLines)
1295 return m_viewInternal->tagLines (start, end, realLines);
1300 return m_viewInternal->tagLines (start, end, realCursors);
1303 void KateView::tagAll ()
1305 m_viewInternal->tagAll ();
1308 void KateView::clear ()
1310 m_viewInternal->clear ();
1313 void KateView::repaintText (
bool paintOnlyDirty)
1315 m_viewInternal->paintText(0,0,m_viewInternal->width(),m_viewInternal->height(), paintOnlyDirty);
1318 void KateView::updateView (
bool changed)
1320 m_viewInternal->updateView (changed);
1321 m_viewInternal->leftBorder->update();
1326 void KateView::slotHlChanged()
1328 KateHighlighting *hl = m_doc->highlight();
1329 bool ok ( !hl->getCommentStart(0).isEmpty() || !hl->getCommentSingleLineStart(0).isEmpty() );
1331 if (actionCollection()->
action(
"tools_comment"))
1332 actionCollection()->action(
"tools_comment")->setEnabled( ok );
1334 if (actionCollection()->
action(
"tools_uncomment"))
1335 actionCollection()->action(
"tools_uncomment")->setEnabled( ok );
1338 updateFoldingConfig ();
1341 uint KateView::cursorColumn()
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();
1359 selectStart.setPos(start);
1360 selectEnd.setPos(end);
1362 selectStart.setPos(end);
1363 selectEnd.setPos(start);
1366 tagSelection(oldSelectStart, oldSelectEnd);
1370 emit selectionChanged ();
1371 emit m_doc->selectionChanged ();
1376 bool KateView::setSelection( uint startLine, uint startCol, uint endLine, uint endCol )
1379 clearSelection(
false,
false);
1384 void KateView::syncSelectionCache()
1386 m_viewInternal->selStartCached = selectStart;
1387 m_viewInternal->selEndCached = selectEnd;
1388 m_viewInternal->selectAnchor = selectEnd;
1391 bool KateView::clearSelection()
1393 return clearSelection(
true);
1396 bool KateView::clearSelection(
bool redraw,
bool finishedChangingSelection)
1398 if( !hasSelection() )
1404 selectStart.setPos(-1, -1);
1405 selectEnd.setPos(-1, -1);
1407 tagSelection(oldSelectStart, oldSelectEnd);
1409 oldSelectStart = selectStart;
1410 oldSelectEnd = selectEnd;
1415 if (finishedChangingSelection)
1417 emit selectionChanged();
1418 emit m_doc->selectionChanged ();
1424 bool KateView::hasSelection()
const
1426 return selectStart != selectEnd;
1429 TQString KateView::selection()
const
1431 int sc = selectStart.col();
1432 int ec = selectEnd.col();
1443 return m_doc->text (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
1446 bool KateView::removeSelectedText ()
1448 if (!hasSelection())
1451 m_doc->editStart ();
1453 int sc = selectStart.col();
1454 int ec = selectEnd.col();
1466 m_doc->removeText (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
1469 clearSelection(
false);
1476 bool KateView::selectAll()
1478 setBlockSelectionMode (
false);
1480 return setSelection (0, 0, m_doc->lastLine(), m_doc->lineLength(m_doc->lastLine()));
1483 bool KateView::lineColSelected (
int line,
int col)
1485 if ( (!blockSelect) && (col < 0) )
1491 return cursor.line() >= selectStart.line() && cursor.line() <= selectEnd.line() && cursor.col() >= selectStart.col() && cursor.col() < selectEnd.col();
1493 return (cursor >= selectStart) && (cursor < selectEnd);
1496 bool KateView::lineSelected (
int line)
1498 return (!blockSelect)
1500 && (line < selectEnd.line());
1503 bool KateView::lineEndSelected (
int line,
int endCol)
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)));
1510 bool KateView::lineHasSelected (
int line)
1512 return (selectStart < selectEnd)
1513 && (line >= selectStart.line())
1514 && (line <= selectEnd.line());
1517 bool KateView::lineIsSelection (
int line)
1519 return (line == selectStart.line() && line == selectEnd.line());
1524 if (hasSelection()) {
1525 if (oldSelectStart.line() == -1) {
1529 tagLines(selectStart, selectEnd,
true);
1531 }
else if (blockSelectionMode() && (oldSelectStart.col() != selectStart.col() || oldSelectEnd.col() != selectEnd.col())) {
1533 tagLines(selectStart, selectEnd,
true);
1534 tagLines(oldSelectStart, oldSelectEnd,
true);
1537 if (oldSelectStart != selectStart) {
1538 if (oldSelectStart < selectStart)
1539 tagLines(oldSelectStart, selectStart,
true);
1541 tagLines(selectStart, oldSelectStart,
true);
1544 if (oldSelectEnd != selectEnd) {
1545 if (oldSelectEnd < selectEnd)
1546 tagLines(oldSelectEnd, selectEnd,
true);
1548 tagLines(selectEnd, oldSelectEnd,
true);
1554 tagLines(oldSelectStart, oldSelectEnd,
true);
1560 int start,
end, len;
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;
1573 setSelection (cursor.line(), start, cursor.line(), end);
1578 if (cursor.line()+1 >= m_doc->numLines())
1579 setSelection (cursor.line(), 0, cursor.line(), m_doc->lineLength(cursor.line()));
1581 setSelection (cursor.line(), 0, cursor.line()+1, 0);
1584 void KateView::selectLength(
const KateTextCursor& cursor,
int length )
1593 start = cursor.col();
1594 end = start + length;
1595 if (end <= start)
return;
1597 setSelection (cursor.line(), start, cursor.line(), end);
1600 void KateView::paste()
1602 m_doc->paste(
this );
1603 emit selectionChanged();
1604 m_viewInternal->repaint();
1607 void KateView::cut()
1609 if (!hasSelection())
1613 removeSelectedText();
1616 void KateView::copy()
const
1618 if (!hasSelection())
1621 TQApplication::clipboard()->setText(selection ());
1624 void KateView::copyHTML()
1626 if (!hasSelection())
1631 TQTextDrag *htmltextdrag =
new TQTextDrag(selectionAsHtml()) ;
1632 htmltextdrag->setSubtype(
"html");
1637 TQApplication::clipboard()->setData(drag);
1640 TQString KateView::selectionAsHtml()
1642 int sc = selectStart.col();
1643 int ec = selectEnd.col();
1655 return textAsHtml (selectStart.line(), sc, selectEnd.line(), ec, blockSelect);
1658 TQString KateView::textAsHtml ( uint startLine, uint startCol, uint endLine, uint endCol,
bool blockwise)
1661 if ( blockwise && (startCol > endCol) )
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;
1674 ts <<
"<body>" <<
endl;
1675 textAsHtmlStream(startLine, startCol, endLine, endCol, blockwise, &ts);
1677 ts <<
"</body>" <<
endl;
1678 ts <<
"</html>" <<
endl;
1683 void KateView::textAsHtmlStream ( uint startLine, uint startCol, uint endLine, uint endCol,
bool blockwise, TQTextStream *ts)
1685 if ( (blockwise || startLine == endLine) && (startCol > endCol) )
1688 if (startLine == endLine)
1694 (*ts) <<
"<pre>" <<
endl;
1696 lineAsHTML(textLine, startCol, endCol-startCol, ts);
1700 (*ts) <<
"<pre>" <<
endl;
1702 for (uint i = startLine; (i <= endLine) && (i < m_doc->numLines()); i++)
1709 lineAsHTML(textLine, startCol, textLine->length()-startCol, ts);
1710 else if (i == endLine)
1711 lineAsHTML(textLine, 0, endCol, ts);
1713 lineAsHTML(textLine, 0, textLine->length(), ts);
1717 lineAsHTML( textLine, startCol, endCol-startCol, ts);
1729 void KateView::lineAsHTML (
KateTextLine::Ptr line, uint startCol, uint length, TQTextStream *outputStream)
1735 TQMap<uchar,TQString> stylecache;
1741 for (uint curPos=startCol;curPos<(length+startCol);curPos++)
1743 if ( curPos == 0 || line->attribute( curPos ) != line->attribute( curPos - 1 ) &&
1748 (*outputStream) << textcache;
1749 textcache.truncate(0);
1751 if ( curPos > startCol )
1752 (*outputStream) <<
"</span>";
1754 charAttributes = m_renderer->attribute(line->attribute(curPos));
1756 if ( ! stylecache.contains( line->attribute(curPos) ) )
1758 TQString textdecoration;
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);
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()));
1780 stylecache[line->attribute(curPos)] = style;
1782 (*outputStream)<<
"<span style=\""
1783 << stylecache[line->attribute(curPos)]
1787 TQString s( line->getChar(curPos) );
1788 if ( s ==
"&" ) s =
"&";
1789 else if ( s ==
"<" ) s =
"<";
1790 else if ( s ==
">" ) s =
">";
1791 textcache.append( s );
1794 (*outputStream) << textcache <<
"</span>";
1797 void KateView::exportAsHTML ()
1799 KURL url = KFileDialog::getSaveURL(m_doc->docName(),
"text/html",0,i18n(
"Export File as HTML"));
1808 filename = url.
path();
1810 filename = tmp.
name();
1815 TQTextStream *outputStream = savefile->
textStream();
1817 outputStream->setEncoding(TQTextStream::UnicodeUTF8);
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;
1827 (*outputStream) <<
"<title>" << m_doc->docName () <<
"</title>" <<
endl;
1828 (*outputStream) <<
"</head>" <<
endl;
1829 (*outputStream) <<
"<body>" <<
endl;
1831 textAsHtmlStream(0,0, m_doc->lastLine(), m_doc->lineLength(m_doc->lastLine()),
false, outputStream);
1833 (*outputStream) <<
"</body>" <<
endl;
1834 (*outputStream) <<
"</html>" <<
endl;
1847 TDEIO::NetAccess::upload( filename, url, 0 );
1853 bool KateView::blockSelectionMode ()
1858 bool KateView::setBlockSelectionMode (
bool on)
1860 if (on != blockSelect)
1867 clearSelection(
false,
false);
1869 setSelection(oldSelectStart, oldSelectEnd);
1871 slotSelectionTypeChanged();
1877 bool KateView::toggleBlockSelectionMode ()
1879 m_toggleBlockSelection->setChecked (!blockSelect);
1880 return setBlockSelectionMode (!blockSelect);
1883 bool KateView::wrapCursor ()
1885 return !blockSelectionMode() && (m_doc->configFlags() & KateDocument::cfWrapCursor);
1891 void KateView::setIMSelectionValue( uint imStartLine, uint imStart, uint imEnd,
1892 uint imSelStart, uint imSelEnd,
bool imComposeEvent )
1894 m_imStartLine = imStartLine;
1895 m_imStart = imStart;
1897 m_imSelStart = imSelStart;
1898 m_imSelEnd = imSelEnd;
1899 m_imComposeEvent = imComposeEvent;
1902 bool KateView::isIMSelection(
int _line,
int _column )
1904 return ( (
int( m_imStartLine ) == _line ) && ( m_imSelStart < m_imSelEnd ) && ( _column >=
int( m_imSelStart ) ) &&
1905 ( _column <
int( m_imSelEnd ) ) );
1908 bool KateView::isIMEdit(
int _line,
int _column )
1910 return ( (
int( m_imStartLine ) == _line ) && ( m_imStart < m_imEnd ) && ( _column >=
int( m_imStart ) ) &&
1911 ( _column <
int( m_imEnd ) ) );
1914 void KateView::getIMSelectionValue( uint *imStartLine, uint *imStart, uint *imEnd,
1915 uint *imSelStart, uint *imSelEnd )
1917 *imStartLine = m_imStartLine;
1918 *imStart = m_imStart;
1920 *imSelStart = m_imSelStart;
1921 *imSelEnd = m_imSelEnd;
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
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)
void addDragObject(TQDragObject *dragObject)
static BrowserExtension * childObject(TQObject *obj)
void openURLRequest(const KURL &url, const KParts::URLArgs &args=KParts::URLArgs())
TQTextStream * textStream()
static bool decode(const TQMimeSource *e, KURL::List &urls)
The Attribute class incorporates all text decorations supported by Kate.
Handles all of the work of rendering the text (used for the views and printing)
Simple cursor class with no document pointer.
This action provides a list of available indenters and gets plugged into the KateView's TDEActionColl...
The Kate::View text editor interface.
saveResult
Return values for "save" related commands.
void setEnabled(bool bEnabled)
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)
virtual bool setShortcut(const TDEShortcut &)
virtual void setWhatsThis(const TQString &text)
virtual void setEnabled(bool enable)
virtual const TDEShortcut & shortcut() const
int readNumEntry(const TQString &pKey, int nDefault=0) const
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
static TDELocale * locale()
bool append(const KKeySequence &keySeq)
void setCheckedState(const KGuiItem &checkedItem)
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
kndbgstream & flush(kndbgstream &s)
TDEAction * selectAll(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * deselect(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * save(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * gotoLine(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * undo(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * redo(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * cut(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * pasteText(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * saveAs(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * copy(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * print(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
Kate namespace All classes in this namespace must stay BC during one major release series (e....
const TDEShortcut & copy()
const TDEShortcut & next()
const TDEShortcut & paste()
const TDEShortcut & prior()
TQString name(StdAccel id)
const TDEShortcut & cut()
const TDEShortcut & end()
const TDEShortcut & redo()
const TDEShortcut & deleteWordBack()
const TDEShortcut & save()
const TDEShortcut & undo()
const TDEShortcut & home()
const TDEShortcut & print()
TQString action(StdAccel id)
const TDEShortcut & gotoLine()
const TDEShortcut & deleteWordForward()
const TDEShortcut & reload()
const TDEShortcut & selectAll()