Example #1
0
void Console::output(QString s)
{
	textCursor().insertBlock();
	QTextCharFormat format;
	format.setForeground(Qt::white);
	textCursor().setBlockCharFormat(format);
	textCursor().insertText(s);
	insertPrompt();
	isLocked = false;
}
void Console::CommandFinished(const QString &)
{
    insertPrompt();
    scrollDown();
    if (_keep_currentCommand)
    {
        textCursor().insertText(_currentCommand.replace("?", ""));
        _keep_currentCommand = false;
    }
    this->_currentCommand = "";
    isLocked = false;
}
Example #3
0
void Console::onEnter()
{
	if(textCursor().positionInBlock() == prompt.length())
	{
	insertPrompt();
	return;
	}
	QString cmd = textCursor().block().text().mid(prompt.length());
	isLocked = true;
	historyAdd(cmd);
	emit onCommand(cmd);
}
Example #4
0
Console::Console(QWidget *parent) :
	QPlainTextEdit(parent)
{
    prompt = "=> ";

    QPalette p = palette();
    p.setColor(QPalette::Base, Qt::black);
    p.setColor(QPalette::Text, Qt::green);
    setPalette(p);
 ///std::cout<<"Console::!";
    history = new QStringList;
    historyPos = 0;
    insertPrompt(false);
    isLocked = false;
}
Example #5
0
Console::Console(QWidget *parent) :
	QPlainTextEdit(parent)
{
	prompt = "molcad> ";

	QPalette p = palette();
	p.setColor(QPalette::Base, Qt::black);
	p.setColor(QPalette::Text, Qt::green);
	setPalette(p);

	history = new QStringList;
	historyPos = 0;
	insertPrompt(false);
	isLocked = false;
	//this->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
}
void Console::output(QString s)
{
    textCursor().insertBlock();
    QTextCharFormat format;
    format.setForeground(Qt::white);
    textCursor().setBlockCharFormat(format);

    QString log;
    log.append(QTime::currentTime().toString());
    log.append("\n");
    log.append(s);

    textCursor().insertText(log);
    insertPrompt();
    isLocked = false;
}
Console::Console(QWidget *parent) :QPlainTextEdit(parent)
{
    prompt = "> ";

    QPalette p = palette();
    p.setColor(QPalette::Base, Qt::black);
    p.setColor(QPalette::Text, Qt::green);
    setPalette(p);

    history = new QStringList;
    historyPos = 0;
    insertPrompt(false);
    isLocked = false;
    isConnected = false;
    _keep_currentCommand = false;

//    connect(this, SIGNAL(onBreak(QString)), this, SLOT(CommandFinished()));
//    connect(this, SIGNAL(Finished(QString)), this, SLOT(CommandFinished()));
}
void Console::onEnter()
{
    if(textCursor().position() == prompt.length())
    {
        insertPrompt();
        return;
    }
    QString cmd = textCursor().block().text().mid(prompt.length()).simplified();
    isLocked = true;
    historyAdd(cmd);
    QTextCharFormat format;
    format.setForeground(Qt::green);
    textCursor().setBlockCharFormat(format);
    this->_currentCommand = cmd;


    if (cmd.startsWith("connect") && !isConnected)
    {
        cmdConnect(cmd.section(" ",1));
    }
    else if (cmd.startsWith("clear"))
    {
        cmdClear();
    }
    else
    {
        if (isConnected) {
            emit onCommand(cmd);
        }
        else
        {
            ConsoleWriteRequest(cmd + ": command unknown");
            CommandFinished();
        }
    }
}
void Console::cmdClear()
{
    clear();
    insertPrompt();
    isLocked = false;
}
Example #10
0
void Console::setPrompt(QString prompt) {
    this->prompt = prompt;
    insertPrompt();
}