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

kate

  • kate
  • app
kateconsole.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
4 Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "kateconsole.h"
22#include "kateconsole.moc"
23
24#include "katemain.h"
25#include "katemdi.h"
26#include "katemainwindow.h"
27#include "kateviewmanager.h"
28
29#include <kate/view.h>
30#include <kate/document.h>
31
32#include <kde_terminal_interface.h>
33
34#include <tdeparts/part.h>
35
36#include <kurl.h>
37#include <klibloader.h>
38#include <tdelocale.h>
39#include <kdebug.h>
40#include <tdemessagebox.h>
41
42KateConsole::KateConsole (KateMainWindow *mw, KateMDI::ToolView* parent)
43 : TQVBox (parent)
44 , m_part (0)
45 , m_mw (mw)
46 , m_toolView (parent)
47{
48}
49
50KateConsole::~KateConsole ()
51{
52 if (m_part)
53 disconnect ( m_part, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotDestroyed()) );
54}
55
56void KateConsole::loadConsoleIfNeeded()
57{
58 if (m_part) return;
59
60 if (!topLevelWidget() || !parentWidget()) return;
61 if (!topLevelWidget() || !isVisibleTo(topLevelWidget())) return;
62
63 KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
64
65 if (!factory) return;
66
67 m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,"libkonsolepart", "KParts::ReadOnlyPart"));
68
69 if (!m_part) return;
70
71 setFocusProxy(m_part->widget());
72
73 TDEGlobal::locale()->insertCatalogue("konsole");
74
75 m_part->widget()->show();
76
77 connect ( m_part, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotDestroyed()) );
78
79 if (m_mw->viewManager()->activeView())
80 if (m_mw->viewManager()->activeView()->getDoc()->url().isValid())
81 cd(KURL( m_mw->viewManager()->activeView()->getDoc()->url().path() ));
82}
83
84void KateConsole::slotDestroyed ()
85{
86 m_part = 0;
87
88 // hide the dockwidget
89 if (parentWidget())
90 {
91 m_mw->hideToolView (m_toolView);
92 m_mw->centralWidget()->setFocus ();
93 }
94}
95
96void KateConsole::showEvent(TQShowEvent *)
97{
98 if (m_part) return;
99
100 loadConsoleIfNeeded();
101}
102
103void KateConsole::cd (const KURL &url)
104{
105 loadConsoleIfNeeded();
106
107 if (!m_part) return;
108
109 m_part->openURL (url);
110}
111
112void KateConsole::sendInput( const TQString& text )
113{
114 loadConsoleIfNeeded();
115
116 if (!m_part) return;
117
118 TerminalInterface *t = static_cast<TerminalInterface*>( m_part->tqt_cast( "TerminalInterface" ) );
119
120 if (!t) return;
121
122 t->sendInput (text);
123}
124
125void KateConsole::slotPipeToConsole ()
126{
127 if (KMessageBox::warningContinueCancel
128 (m_mw
129 , i18n ("Do you really want to pipe the text to the console? This will execute any contained commands with your user rights.")
130 , i18n ("Pipe to Console?")
131 , i18n("Pipe to Console"), "Pipe To Console Warning") != KMessageBox::Continue)
132 return;
133
134 Kate::View *v = m_mw->viewManager()->activeView();
135
136 if (!v)
137 return;
138
139 if (v->getDoc()->hasSelection ())
140 sendInput (v->getDoc()->selection());
141 else
142 sendInput (v->getDoc()->text());
143}
KateConsole::showEvent
void showEvent(TQShowEvent *ev)
the konsole get shown
Definition: kateconsole.cpp:96
KateConsole::cd
void cd(const KURL &url)
cd to dir
Definition: kateconsole.cpp:103
KateConsole::sendInput
void sendInput(const TQString &text)
send given text to console
Definition: kateconsole.cpp:112
KateConsole::KateConsole
KateConsole(KateMainWindow *mw, KateMDI::ToolView *parent)
construct us
Definition: kateconsole.cpp:42
KateConsole::~KateConsole
~KateConsole()
destruct us
Definition: kateconsole.cpp:50
KateConsole::slotPipeToConsole
void slotPipeToConsole()
pipe current document to console
Definition: kateconsole.cpp:125

kate

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

kate

Skip menu "kate"
  • kate
  • libkonq
  • twin
  •   lib
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.