OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
console.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_CONSOLE_H
2 #define MWGUI_CONSOLE_H
3 
4 #include <list>
5 #include <string>
6 #include <vector>
7 
15 
16 #include "../mwscript/compilercontext.hpp"
17 #include "../mwscript/interpretercontext.hpp"
18 
19 #include "referenceinterface.hpp"
20 #include "windowbase.hpp"
21 
22 namespace MWGui
23 {
25  {
26  public:
28  void setSelectedObject(const MWWorld::Ptr& object);
29 
30  MyGUI::EditBox* mCommandLine;
31  MyGUI::EditBox* mHistory;
32 
33  typedef std::list<std::string> StringList;
34 
35  // History of previous entered commands
37  StringList::iterator mCurrent;
38  std::string mEditString;
39 
40  Console(int w, int h, bool consoleOnlyScripts);
41 
42  virtual void open();
43  virtual void close();
44 
45  virtual void exit();
46 
47  void setFont(const std::string &fntName);
48 
49  void onResChange(int width, int height);
50 
51  // Print a message to the console, in specified color.
52  void print(const std::string &msg, const std::string& color = "#FFFFFF");
53 
54  // These are pre-colored versions that you should use.
55 
57  void printOK(const std::string &msg);
58 
60  void printError(const std::string &msg);
61 
62  void execute (const std::string& command);
63 
64  void executeFile (const std::string& path);
65 
66  virtual void resetReference ();
67 
68  protected:
69 
70  virtual void onReferenceUnavailable();
71 
72  private:
73 
74  void keyPress(MyGUI::Widget* _sender,
75  MyGUI::KeyCode key,
76  MyGUI::Char _char);
77 
78  void acceptCommand(MyGUI::EditBox* _sender);
79 
80  std::string complete( std::string input, std::vector<std::string> &matches );
81 
84  std::vector<std::string> mNames;
86 
87  bool compile (const std::string& cmd, Compiler::Output& output);
88 
90  virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
91 
93  virtual void report (const std::string& message, Type type);
94 
99  void listNames();
100  };
101 }
102 #endif
void setFont(const std::string &fntName)
Definition: console.cpp:167
Type
Definition: errorhandler.hpp:23
void message(CodeContainer &code, Literals &literals, const std::string &message, int buttons)
Definition: generator.cpp:537
void printOK(const std::string &msg)
Output from successful console command.
Definition: console.cpp:178
bool mConsoleOnlyScripts
Definition: console.hpp:85
Definition: output.hpp:14
std::vector< std::string > mNames
Definition: console.hpp:84
void acceptCommand(MyGUI::EditBox *_sender)
Definition: console.cpp:286
virtual void onReferenceUnavailable()
called when reference has become unavailable
Definition: console.cpp:449
void execute(const std::string &command)
Definition: console.cpp:188
void print(const std::string &msg, const std::string &color="#FFFFFF")
Definition: console.cpp:173
Location of a token in a source file.
Definition: tokenloc.hpp:10
virtual void report(const std::string &message, const Compiler::TokenLoc &loc, Type type)
Report error to the user.
Definition: console.cpp:73
std::string mEditString
Definition: console.hpp:38
std::string complete(std::string input, std::vector< std::string > &matches)
Definition: console.cpp:306
std::list< std::string > StringList
Definition: console.hpp:33
virtual void resetReference()
Definition: console.cpp:454
void setSelectedObject(const MWWorld::Ptr &object)
Set the implicit object for script execution.
Definition: console.cpp:425
Error handling.
Definition: errorhandler.hpp:14
Collection of compiler extensions.
Definition: extensions.hpp:39
Compiler::Extensions mExtensions
Definition: console.hpp:82
StringList mCommandHistory
Definition: console.hpp:36
MyGUI::EditBox * mCommandLine
Definition: console.hpp:30
void listNames()
Definition: console.cpp:87
virtual void open()
Notify that window has been made visible.
Definition: console.cpp:148
MWScript::CompilerContext mCompilerContext
Definition: console.hpp:83
void printError(const std::string &msg)
Error message.
Definition: console.cpp:183
StringList::iterator mCurrent
Definition: console.hpp:37
MyGUI::EditBox * mHistory
Definition: console.hpp:31
Definition: windowbase.hpp:16
virtual void close()
Notify that window has been hidden.
Definition: console.cpp:155
void onResChange(int width, int height)
Definition: console.cpp:420
this class is intended for GUI interfaces that access an MW-Reference for example dialogue window acc...
Definition: referenceinterface.hpp:12
bool compile(const std::string &cmd, Compiler::Output &output)
Definition: console.cpp:44
void executeFile(const std::string &path)
Definition: console.cpp:214
Definition: console.hpp:24
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void keyPress(MyGUI::Widget *_sender, MyGUI::KeyCode key, MyGUI::Char _char)
Definition: console.cpp:230
Console(int w, int h, bool consoleOnlyScripts)
Definition: console.cpp:124
virtual void exit()
Gracefully exits the window.
Definition: console.cpp:162
KeyCode
Keyboard scan codes.
Definition: OISCompat.hpp:10
Definition: compilercontext.hpp:8