COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Classes | Public Slots | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
PythonConsole Class Reference

The python console send python command to the server in form of python "fragment" the term "fragment" is used to describe a single python statement wich mean one instruction without tabulation (that instruction may have children instruction) Example of python fragment: for i in range(0,5): print i. More...

#include <PythonConsole.hpp>

Inherits PythonCodeContainer.

Classes

class  python_command
 used to store the pending command on the command stack More...
 

Public Slots

void execute_code (QString code, bool immediate, QVector< int > break_lines)
 parse and append the code to the console More...
 
void execute_code (QString code)
 reduiced call, used in signal conversion More...
 

Public Member Functions

 PythonConsole (QWidget *parent, MainWindow *main_window)
 Construct a python console. More...
 
void create_python_area (QWidget *widget)
 called by the parent to create the splitter with the scope values More...
 
bool is_stopped ()
 to check if the console can execute command (like for documentation request) More...
 
const QListWidget * get_history_list_widget ()
 give acces to history_list_widget used in PythonCodeContainer to retrieve history from drag and drop More...
 
int get_debug_arrow_block ()
 return the block number where the debug arrow is, -1 if the execution is not breaked More...
 
void send_toggle_break_point (int fragment_block, int line_number)
 ask to the script engine to toggle the break point on the given fragment at the given line number More...
 
- Public Member Functions inherited from PythonCodeContainer
 PythonCodeContainer (QWidget *parent=0)
 constructor More...
 
void repaint_border_area (QPaintEvent *event)
 called by the border area on repaint event, display the line numbers from QTextBlock::userState More...
 

Protected Member Functions

void key_press_event (QKeyEvent *)
 called by PythonCodeContainer when the key event is not managed by him More...
 
void new_line (int indent_number)
 called at each new line More...
 
void border_click (const QPoint &pos)
 called when the user click on the border area to toggle a break point More...
 
bool editable_zone (const QTextCursor &cursor)
 called by PythonCodeContainer to know if the zone is editable More...
 
void insert_text (const QString &text)
 called by PythonCodeContainer when a text need to be inserted More...
 
- Protected Member Functions inherited from PythonCodeContainer
void toggle_break_point (int fragment_block, int line_number, bool send=true)
 Send a toggle break command to the script engine. More...
 
void keyPressEvent (QKeyEvent *e)
 manage some typing behaviour then call key_press_event to propagate the event to the inherited class More...
 
void resizeEvent (QResizeEvent *e)
 repaint the border area More...
 
void mouseMoveEvent (QMouseEvent *e)
 start a timer when the mouse is on a word, the timer will make a request_documentation for this word More...
 
void leaveEvent (QEvent *)
 stop the documentation timer More...
 
QMimeData * createMimeDataFromSelection () const
 create a mimeData with a preview of the selected text More...
 
bool canInsertFromMimeData (const QMimeData *source) const
 allow to drop text mimeData and QListWidgetItem mimeData More...
 
void insertFromMimeData (const QMimeData *source)
 call insert_text with the extracted mimeData More...
 

Private Slots

void display_debug_trace (int fragment, int line)
 called by NScriptEngine when the execution is breaked, the debug arrow will be showed at More...
 
void change_code_fragment (int fragment, int new_fragment)
 change the fragment index with the new one, used in multi-client communication More...
 
void reset_debug_trace ()
 clear the debug arrow More...
 
void insert_output (QString output, int fragment=-1)
 insert output for a particular fragment More...
 
void insert_log (const QString &)
 called by the log manager, the log will be shown at the last fragment More...
 
void line_by_line_activated (bool)
 active the line by line execution, called by the toolbar More...
 
void stop_continue_pressed ()
 if the script engine is executing some this will ask to stop the execution if the script engine where breaked this will continue the execution More...
 
void break_pressed ()
 if the script engine is stopped this will ask to go out of the current fragment, usefull for infinite loop by example More...
 
void execution_stopped (int fragment, int line)
 
void stream_next_command ()
 if they are some commands on the command stack this function will execute then one by one More...
 
void push_history_to_script_editor ()
 append all the history on a new PythonScriptEditor More...
 
void scope_double_click (const QModelIndex &index)
 when the user double click on the scope this will append the symbole to the PythonConsole More...
 
void history_double_click (const QModelIndex &index)
 when the user double click on the history this will append the command to the PythonConsole More...
 
void cursor_position_changed ()
 
void append_false_code (QString code)
 append a command on the PythonConsole as if this command where executed but it is just for display purpose , the code is not actually executed More...
 

Private Member Functions

void print_next_prompt ()
 display the next prompt after executing the last one More...
 
void execute_input (QTextCursor &)
 execute the current statement More...
 
void set_input (const QString &)
 replace the current prompted code with the given text More...
 
void select_input (QTextCursor &)
 select the current prompted code with the on the given text cursor More...
 
void fix_prompt ()
 correct the block state on the current prompt More...
 
void add_history_draggable_item (const QString &text)
 add to the history a new entry More...
 
void register_fragment (QString code, int block_number, QVector< int > break_point)
 Send the python code fragment to the script engine. More...
 

Private Attributes

int fragment_generator
 used to generate the fragment index More...
 
QMap< int, int > blocks_fragment
 store the fragment number for each block More...
 
QMap< int, int > fragment_container
 store the block number for each fragment More...
 
int input_block
 Index of the block that contains the current prompt. More...
 
int input_start_in_text
 position in character where the last prompt start More...
 
int debug_arrow
 block number of the debug arrow, -1 for no arrow More...
 
QAction * line_by_line
 toolbar line by line action More...
 
QAction * stop_continue
 toolbar stop continue action More...
 
QAction * break_action
 toolbar break action More...
 
QStringList history
 store the history, used when up key and down key are pressed More...
 
int history_index
 store the current history index when using the up and down keys More...
 
QString tmp_command
 store a temporary command when some code need to be executed and they where some code on the current prompt More...
 
QIcon icon_stop
 used to change the icon on the stop_continue action More...
 
QIcon icon_continue
 
QQueue< python_commandcommand_stack
 store the pending commands More...
 
QVector< int > temporary_break_points
 store the break points of the input, in order to send them when the execution is asked More...
 
QTimer auto_execution_timer
 a little weird but it is for avoid cross call when they are pending commands on the command stack More...
 
bool stopped
 store the state of the execution More...
 
bool text_being_entered
 ... More...
 
MainWindowmain_window
 used to add a PythonCodeEditor from the PythonConsole More...
 
CustomListWidgethistory_list_widget
 to acces to the history list widget More...
 

Additional Inherited Members

- Public Types inherited from PythonCodeContainer
enum  line_type { PROMPT_1 = 100000, PROMPT_2 = 100001, LINE_NUMBER = 100002 }
 Use to manage userData in a QTextBlock. More...
 
- Protected Slots inherited from PythonCodeContainer
void update_border_area (const QRect &, int)
 connected to the scrollbar signal of the code zone, ask to the border area to do a repaint More...
 
void keywords_changed (const QStringList &add, const QStringList &sub)
 
void insert_completion (QString)
 
void request_documentation ()
 
void popup_documentation (const QString &documentation)
 
- Protected Attributes inherited from PythonCodeContainer
int border_width
 
QPoint offset_border
 
QToolBar * tool_bar
 
QVector< int > break_points
 
PythonSyntaxeHighlighterhighlighter
 
- Static Protected Attributes inherited from PythonCodeContainer
static PythonConsolepython_console =NULL
 
static QStandardItemModel python_dictionary
 
static QTreeView * python_scope_values =NULL
 

Detailed Description

The python console send python command to the server in form of python "fragment" the term "fragment" is used to describe a single python statement wich mean one instruction without tabulation (that instruction may have children instruction) Example of python fragment: for i in range(0,5): print i.

Definition at line 47 of file PythonConsole.hpp.

Constructor & Destructor Documentation

PythonConsole ( QWidget *  parent,
MainWindow main_window 
)

Construct a python console.

Parameters
parentParent widget.
main_windowUsed to create a new script editor from the console

Definition at line 38 of file PythonConsole.cpp.

Member Function Documentation

void add_history_draggable_item ( const QString &  text)
private

add to the history a new entry

Definition at line 678 of file PythonConsole.cpp.

void append_false_code ( QString  code)
privateslot

append a command on the PythonConsole as if this command where executed but it is just for display purpose , the code is not actually executed

Definition at line 582 of file PythonConsole.cpp.

void border_click ( const QPoint &  pos)
protectedvirtual

called when the user click on the border area to toggle a break point

Implements PythonCodeContainer.

Definition at line 337 of file PythonConsole.cpp.

void break_pressed ( )
privateslot

if the script engine is stopped this will ask to go out of the current fragment, usefull for infinite loop by example

Definition at line 636 of file PythonConsole.cpp.

void change_code_fragment ( int  fragment,
int  new_fragment 
)
privateslot

change the fragment index with the new one, used in multi-client communication

Definition at line 188 of file PythonConsole.cpp.

void create_python_area ( QWidget *  widget)

called by the parent to create the splitter with the scope values

Definition at line 91 of file PythonConsole.cpp.

void cursor_position_changed ( )
privateslot

Definition at line 118 of file PythonConsole.cpp.

void display_debug_trace ( int  fragment,
int  line 
)
privateslot

called by NScriptEngine when the execution is breaked, the debug arrow will be showed at

Definition at line 153 of file PythonConsole.cpp.

bool editable_zone ( const QTextCursor &  cursor)
protectedvirtual

called by PythonCodeContainer to know if the zone is editable

Implements PythonCodeContainer.

Definition at line 280 of file PythonConsole.cpp.

void execute_code ( QString  code,
bool  immediate,
QVector< int >  break_lines 
)
slot

parse and append the code to the console

Parameters
codeThe code to execute, can be a single command or a complete script
immediatedetermine if the console must execute immediatly the command or let the user press enter after each commmands

Definition at line 389 of file PythonConsole.cpp.

void execute_code ( QString  code)
slot

reduiced call, used in signal conversion

Definition at line 442 of file PythonConsole.cpp.

void execute_input ( QTextCursor &  c)
private

execute the current statement

Definition at line 365 of file PythonConsole.cpp.

void execution_stopped ( int  fragment,
int  line 
)
privateslot

Definition at line 645 of file PythonConsole.cpp.

void fix_prompt ( )
private

correct the block state on the current prompt

Definition at line 298 of file PythonConsole.cpp.

int get_debug_arrow_block ( )

return the block number where the debug arrow is, -1 if the execution is not breaked

Definition at line 148 of file PythonConsole.cpp.

const QListWidget * get_history_list_widget ( )

give acces to history_list_widget used in PythonCodeContainer to retrieve history from drag and drop

Definition at line 692 of file PythonConsole.cpp.

void history_double_click ( const QModelIndex &  index)
privateslot

when the user double click on the history this will append the command to the PythonConsole

Definition at line 686 of file PythonConsole.cpp.

void insert_log ( const QString &  output)
privateslot

called by the log manager, the log will be shown at the last fragment

Definition at line 555 of file PythonConsole.cpp.

void insert_output ( QString  output,
int  fragment = -1 
)
privateslot

insert output for a particular fragment

Definition at line 475 of file PythonConsole.cpp.

void insert_text ( const QString &  text)
protectedvirtual

called by PythonCodeContainer when a text need to be inserted

Implements PythonCodeContainer.

Definition at line 286 of file PythonConsole.cpp.

bool is_stopped ( )

to check if the console can execute command (like for documentation request)

Definition at line 292 of file PythonConsole.cpp.

void key_press_event ( QKeyEvent *  e)
protectedvirtual

called by PythonCodeContainer when the key event is not managed by him

Implements PythonCodeContainer.

Definition at line 203 of file PythonConsole.cpp.

void line_by_line_activated ( bool  activated)
privateslot

active the line by line execution, called by the toolbar

Definition at line 611 of file PythonConsole.cpp.

void new_line ( int  indent_number)
protectedvirtual

called at each new line

Reimplemented from PythonCodeContainer.

Definition at line 316 of file PythonConsole.cpp.

void print_next_prompt ( )
private

display the next prompt after executing the last one

void push_history_to_script_editor ( )
privateslot

append all the history on a new PythonScriptEditor

Definition at line 657 of file PythonConsole.cpp.

void register_fragment ( QString  code,
int  block_number,
QVector< int >  break_point 
)
private

Send the python code fragment to the script engine.

Definition at line 171 of file PythonConsole.cpp.

void reset_debug_trace ( )
privateslot

clear the debug arrow

Definition at line 179 of file PythonConsole.cpp.

void scope_double_click ( const QModelIndex &  index)
privateslot

when the user double click on the scope this will append the symbole to the PythonConsole

Definition at line 664 of file PythonConsole.cpp.

void select_input ( QTextCursor &  cursor)
private

select the current prompted code with the on the given text cursor

Definition at line 604 of file PythonConsole.cpp.

void send_toggle_break_point ( int  fragment_block,
int  line_number 
)

ask to the script engine to toggle the break point on the given fragment at the given line number

Definition at line 199 of file PythonConsole.cpp.

void set_input ( const QString &  )
private

replace the current prompted code with the given text

void stop_continue_pressed ( )
privateslot

if the script engine is executing some this will ask to stop the execution if the script engine where breaked this will continue the execution

Definition at line 627 of file PythonConsole.cpp.

void stream_next_command ( )
privateslot

if they are some commands on the command stack this function will execute then one by one

Definition at line 448 of file PythonConsole.cpp.

Member Data Documentation

QTimer auto_execution_timer
private

a little weird but it is for avoid cross call when they are pending commands on the command stack

Definition at line 176 of file PythonConsole.hpp.

QMap<int,int> blocks_fragment
private

store the fragment number for each block

Definition at line 120 of file PythonConsole.hpp.

QAction* break_action
private

toolbar break action

Definition at line 162 of file PythonConsole.hpp.

QQueue<python_command> command_stack
private

store the pending commands

Definition at line 172 of file PythonConsole.hpp.

int debug_arrow
private

block number of the debug arrow, -1 for no arrow

Definition at line 128 of file PythonConsole.hpp.

QMap<int,int> fragment_container
private

store the block number for each fragment

Definition at line 122 of file PythonConsole.hpp.

int fragment_generator
private

used to generate the fragment index

Definition at line 118 of file PythonConsole.hpp.

QStringList history
private

store the history, used when up key and down key are pressed

Definition at line 164 of file PythonConsole.hpp.

int history_index
private

store the current history index when using the up and down keys

Definition at line 166 of file PythonConsole.hpp.

CustomListWidget* history_list_widget
private

to acces to the history list widget

Definition at line 184 of file PythonConsole.hpp.

QIcon icon_continue
private

Definition at line 170 of file PythonConsole.hpp.

QIcon icon_stop
private

used to change the icon on the stop_continue action

Definition at line 170 of file PythonConsole.hpp.

int input_block
private

Index of the block that contains the current prompt.

Definition at line 124 of file PythonConsole.hpp.

int input_start_in_text
private

position in character where the last prompt start

Definition at line 126 of file PythonConsole.hpp.

QAction* line_by_line
private

toolbar line by line action

Definition at line 158 of file PythonConsole.hpp.

MainWindow* main_window
private

used to add a PythonCodeEditor from the PythonConsole

Definition at line 182 of file PythonConsole.hpp.

QAction* stop_continue
private

toolbar stop continue action

Definition at line 160 of file PythonConsole.hpp.

bool stopped
private

store the state of the execution

Definition at line 178 of file PythonConsole.hpp.

QVector<int> temporary_break_points
private

store the break points of the input, in order to send them when the execution is asked

Definition at line 174 of file PythonConsole.hpp.

bool text_being_entered
private

...

Definition at line 180 of file PythonConsole.hpp.

QString tmp_command
private

store a temporary command when some code need to be executed and they where some code on the current prompt

Definition at line 168 of file PythonConsole.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin