Skip to content

Commit

Permalink
Show help text in statusTip for command completion
Browse files Browse the repository at this point in the history
do not do command completion in LaTeX cells
  • Loading branch information
hkiel committed Dec 8, 2016
1 parent a21855e commit 29e5dff
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 85 deletions.
2 changes: 1 addition & 1 deletion OMNotebook/OMNotebookGUI/commands.xml
Expand Up @@ -55,7 +55,7 @@
<field name="$0">var</field>
<helptext>Plot a variable from the most recently simulated model. Ex: plot(x).</helptext>
</command>
<command name="plot($0)">
<command name="plot({$0})">
<field name="$0">vars</field>
<helptext>Plot variables from the most recently simulated model given as a vector. Ex: plot({x,y}).</helptext>
</command>
Expand Down
18 changes: 11 additions & 7 deletions OMNotebook/OMNotebookGUI/graphcell.cpp
Expand Up @@ -214,9 +214,9 @@ namespace IAEX {
emit command();
}
}
// COMMAND COMPLETION- NEXT FIELD, key: CTRL + TAB
else if( event->modifiers() == Qt::ControlModifier &&
event->key() == Qt::Key_Tab )
// COMMAND COMPLETION- NEXT FIELD, key: CTRL + TAB || SHIFT + SPACE
else if( (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Tab ) ||
(event->modifiers() == Qt::ShiftModifier && event->key() == Qt::Key_Space ) )
{

event->accept();
Expand Down Expand Up @@ -1540,8 +1540,10 @@ namespace IAEX {
CommandCompletion *commandcompletion = CommandCompletion::instance( "commands.xml" );
QTextCursor cursor = input_->textCursor();

if( commandcompletion->insertCommand( cursor ))
if( commandcompletion->insertCommand( cursor )) {
input_->setTextCursor( cursor );
emit newState(commandcompletion->helpCommand().toLatin1().data());
}
}

/*!
Expand All @@ -1553,12 +1555,14 @@ namespace IAEX {
*/
void GraphCell::nextCommand()
{
qDebug("Next Command");
//qDebug("Next Command");
CommandCompletion *commandcompletion = CommandCompletion::instance( "commands.xml" );
QTextCursor cursor = input_->textCursor();

if( commandcompletion->nextCommand( cursor ))
if( commandcompletion->nextCommand( cursor )) {
input_->setTextCursor( cursor );
emit newState(commandcompletion->helpCommand().toLatin1().data());
}
}

/*!
Expand All @@ -1569,7 +1573,7 @@ namespace IAEX {
*/
void GraphCell::nextField()
{
qDebug("Next Field");
//qDebug("Next Field");
CommandCompletion *commandcompletion = CommandCompletion::instance( "commands.xml" );
QTextCursor cursor = input_->textCursor();

Expand Down
71 changes: 0 additions & 71 deletions OMNotebook/OMNotebookGUI/latexcell.cpp
Expand Up @@ -80,7 +80,6 @@

#include "treeview.h"
#include "stylesheet.h"
#include "commandcompletion.h"
#include "omcinteractiveenvironment.h"
#include "indent.h"

Expand Down Expand Up @@ -178,31 +177,6 @@ namespace IAEX {
event->accept();
emit eval();
}
// COMMAND COMPLETION, key: SHIFT + TAB (= BACKTAB) || CTRL + SPACE
else if( (event->modifiers() == Qt::ShiftModifier && event->key() == Qt::Key_Backtab ) ||
(event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Space) )
{

event->accept();
if( inCommand )
{
emit nextCommand();
}
else
{
inCommand = true;
emit command();
}
}
// COMMAND COMPLETION- NEXT FIELD, key: CTRL + TAB
else if( event->modifiers() == Qt::ControlModifier &&
event->key() == Qt::Key_Tab )
{

event->accept();
inCommand = false;
emit nextField();
}
// BACKSPACE, DELETE
else if( event->key() == Qt::Key_Backspace ||
event->key() == Qt::Key_Delete )
Expand Down Expand Up @@ -499,10 +473,6 @@ namespace IAEX {
connect( input_, SIGNAL( clickOnCell() ), this, SLOT( clickEvent() ));
connect( input_, SIGNAL( wheelMove(QWheelEvent*) ), this, SLOT( wheelEvent(QWheelEvent*) ));
connect( input_, SIGNAL( eval() ), this, SLOT( eval() ));
connect( input_, SIGNAL( command() ), this, SLOT( command() ));
connect( input_, SIGNAL( nextCommand() ), this, SLOT( nextCommand() ));
connect( input_, SIGNAL( nextField() ), this, SLOT( nextField() ));
connect( input_, SIGNAL( nextField() ), this, SLOT( nextField() ));

//connect( input_, SIGNAL( textChanged() ), this, SLOT( addToHighlighter() ));
connect( input_, SIGNAL( currentCharFormatChanged(const QTextCharFormat &) ),
Expand Down Expand Up @@ -1250,47 +1220,6 @@ void LatexCell::setState(int state_)
}
}

/*!
*\brief Get/Insert the command that match the last word in the
* input editor.
*/
void LatexCell::command()
{
CommandCompletion *commandcompletion = CommandCompletion::instance( "commands.xml" );
QTextCursor cursor = input_->textCursor();

if( commandcompletion->insertCommand( cursor ))
input_->setTextCursor( cursor );
}

/*!
*\brief Get/Insert the next command that match the last word in
* the input editor.
*/
void LatexCell::nextCommand()
{
CommandCompletion *commandcompletion = CommandCompletion::instance( "commands.xml" );
QTextCursor cursor = input_->textCursor();

if( commandcompletion->nextCommand( cursor ))
input_->setTextCursor( cursor );

}

/*!
*\brief Select the next field in the command, if any exists
*/
void LatexCell::nextField()
{
CommandCompletion *commandcompletion = CommandCompletion::instance( "commands.xml" );
QTextCursor cursor = input_->textCursor();

if( commandcompletion->nextField( cursor ))
input_->setTextCursor( cursor );

}


/*!
* \brief set the correct style if the charFormat is changed and the
* cell is empty. This is done because otherwise the style is lost if
Expand Down
6 changes: 0 additions & 6 deletions OMNotebook/OMNotebookGUI/latexcell.h
Expand Up @@ -95,9 +95,6 @@ namespace IAEX

public slots:
void eval();
void command();
void nextCommand();
void nextField();
void clickEvent();
void clickEventOutput();
void contentChanged();
Expand Down Expand Up @@ -179,9 +176,6 @@ namespace IAEX
signals:
void clickOnCell();
void wheelMove( QWheelEvent* );
void command();
void nextCommand();
void nextField();
void eval();
void forwardAction( int );
void updatePos(int, int);
Expand Down

0 comments on commit 29e5dff

Please sign in to comment.