pConsole.sip 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. class pConsole : QPlainTextEdit
  2. {
  3. %TypeHeaderCode
  4. #include <gui/consolemanager/pConsole.h>
  5. %End
  6. public:
  7. enum ColorType {
  8. Command,
  9. Error,
  10. Output,
  11. Completion
  12. };
  13. pConsole( QWidget* parent = 0 );
  14. pConsole( const QString& promptText, QWidget* parent = 0 );
  15. virtual ~pConsole();
  16. QString prompt() const;
  17. void setPrompt( const QString& prompt );
  18. bool isPromptVisible() const;
  19. void setPromptVisible( bool visible );
  20. QStringList history() const;
  21. void setHistory( const QStringList& history );
  22. QColor color( pConsole::ColorType type ) const;
  23. void setColor( pConsole::ColorType type, const QColor& color );
  24. void executeCommand( const QString& command, bool writeCommand = true, bool showPrompt = true );
  25. bool saveScript( const QString& fileName );
  26. bool loadScript( const QString& fileName );
  27. void clear();
  28. void reset( const QString& promptText = QString::null );
  29. pConsoleCommand::List availableCommands() const;
  30. void setAvailableCommands( const pConsoleCommand::List& commands );
  31. void addAvailableCommand( pConsoleCommand* command );
  32. void removeAvailableCommand( pConsoleCommand* command );
  33. protected:
  34. virtual void keyPressEvent( QKeyEvent* event );
  35. virtual void mousePressEvent( QMouseEvent* event );
  36. virtual void mouseReleaseEvent( QMouseEvent* event );
  37. virtual void contextMenuEvent( QContextMenuEvent* event );
  38. virtual bool isCommandComplete( const QString& command );
  39. virtual QString interpretCommand( const QString& command, int* exitCode );
  40. virtual QStringList autoCompleteCommand( const QString& command );
  41. bool replaceCommand( const QString& command );
  42. QString currentCommand() const;
  43. void focusCommand();
  44. void useColor( pConsole::ColorType type );
  45. void displayPrompt();
  46. bool showHistoryItem( int index );
  47. signals:
  48. void commandExecuted( const QString& command, int exitCode );
  49. };