Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members

# KJSEmbed::JSConsoleWidget Class Reference

A QWidget that provides a console for executing Javascript commands. More...

`#include <jsconsolewidget.h>`

List of all members.

## Public Slots

KJSEmbed::KJSEmbedPart * | jscript () const
KTextEdit * | messages () const
KPopupTitle * | title () const
QHBox * | commandBox () const
void | invoke ()
virtual bool | execute (const QString &cmd)
bool | execute (const QString &cmd, const KJS::Value &self)
virtual void | println (const QString &text)
virtual void | warn (const QString &text)
virtual bool | run (const QString &shellCmd)

## Public Methods

| JSConsoleWidget (KJSEmbedPart *js, QWidget *parent=0, const char *name=0)
virtual | ~JSConsoleWidget ()

## Protected Slots

void | childExited ()
void | receivedStdOutput (KProcess *, char *, int)
void | receivedStdError (KProcess *, char *, int)

## Protected Methods

void | createView ()

## Detailed Description

A QWidget that provides a console for executing Javascript commands.

Creating a JS console is easy, as you can see below:

       KJS::Object global( new KJS::ObjectImp() );
       KJS::Interpreter *js = new KJS::Interpreter( global );
       KJSEmbed::JSConsoleWidget *win = new KJSEmbed::JSConsoleWidget( js );
       win->addBindings( js->globalExec(), global );

This example creates a console for a JS interpreter and adds a print function to the interpreter.

Version:

Id:
  jsconsolewidget.h,v 1.12 2003/10/12 00:05:52 rich Exp

Author:
  Richard Moore, rich@kde.org

## Constructor & Destructor Documentation

KJSEmbed::JSConsoleWidget::JSConsoleWidget | ( | KJSEmbedPart * | js,
|  | QWidget * | parent = 0,
|  | const char * | name = 0
| ) |

virtual KJSEmbed::JSConsoleWidget::~JSConsoleWidget | ( |  | ) | `[virtual]`

## Member Function Documentation

void KJSEmbed::JSConsoleWidget::childExited | ( |  | ) | `[protected, slot]`

| Called when the process exits.

QHBox* KJSEmbed::JSConsoleWidget::commandBox | ( |  | ) | const`[inline, slot]`

| Returns the QHBox used to layout the entry part of the console. This can be used by clients to hide and show the interactive parts of the console, or to add new buttons etc.

void KJSEmbed::JSConsoleWidget::createView | ( |  | ) | `[protected]`

| Creates the console view.

bool KJSEmbed::JSConsoleWidget::execute | ( | const QString & | cmd,
|  | const KJS::Value & | self
| ) | `[slot]`

virtual bool KJSEmbed::JSConsoleWidget::execute | ( | const QString & | cmd | ) | `[virtual, slot]`

| Invokes the specified command string.

void KJSEmbed::JSConsoleWidget::invoke | ( |  | ) | `[slot]`

| Invokes the content of the command entry field.

KJSEmbed::KJSEmbedPart* KJSEmbed::JSConsoleWidget::jscript | ( |  | ) | const`[inline, slot]`

| Returns the KJSEmbedPart the console is using.

KTextEdit* KJSEmbed::JSConsoleWidget::messages | ( |  | ) | const`[inline, slot]`

| Returns the message widget.

virtual void KJSEmbed::JSConsoleWidget::println | ( | const QString & | text | ) | `[virtual, slot]`

| Prints the specified string to the console.

void KJSEmbed::JSConsoleWidget::receivedStdError | ( | KProcess * | ,
|  | char * | ,
|  | int |
| ) | `[protected, slot]`

| Called when the process sends message to stderr.

void KJSEmbed::JSConsoleWidget::receivedStdOutput | ( | KProcess * | ,
|  | char * | ,
|  | int |
| ) | `[protected, slot]`

| Called when the process sends message to stdout.

virtual bool KJSEmbed::JSConsoleWidget::run | ( | const QString & | shellCmd | ) | `[virtual, slot]`

Runs the specified command using KShellProcess.

The output of the command is displayed in the console. Any output sent to stdout is displayed as normal text, anything sent to stderr is displayed as a warning. Once the command has finished the exit status is printed if it is non-zero.

Note that there is no extra layer of security to prevent this method being called from a script because in general a script that can access this object can also write content to a file then execute the file. If you intend to run untrusted scripts, it is your responsibility to ensure that you only expose safe objects and methods to the interpreter.

KPopupTitle* KJSEmbed::JSConsoleWidget::title | ( |  | ) | const`[inline, slot]`

| Returns the title widget.

virtual void KJSEmbed::JSConsoleWidget::warn | ( | const QString & | text | ) | `[virtual, slot]`

| Prints the specified string to the console as a warning, the default implementation prints the text in red.

The documentation for this class was generated from the following file:

- jsconsolewidget.h