Exemplo n.º 1
0
void GUIconsole::AddText(const std::string& text)
{
	//CInfoConsole::AddText(text);
	curLine+=text;

	size_t lf;
	long time=CurrentTime()+lifetime;
	while((lf=curLine.find('\n'))!=string::npos)   
	{
		lines.push_back(ConsoleLine(curLine.substr(0, lf), time));
		curLine=curLine.substr(lf+1, string::npos);
	}

	lines.push_back(ConsoleLine(curLine, time));
	curLine="";

	while(lines.size()>(numLines-1))
	{
		lines.pop_front();
	}
}
Exemplo n.º 2
0
void Rocket_AddConsoleText(Str::StringRef text)
{
    // HACK: Ugly way to force pre-engine-upgrade behavior. TODO: Make it work without this hack
    static char buffer[ MAX_STRING_CHARS ];
    Q_strncpyz( buffer, text.c_str(), sizeof(buffer) );

    if ( !Q_stricmp( "\n", buffer ) )
    {
        return;
    }

    RocketConsoleTextElement::lines.push_front( ConsoleLine( Rocket::Core::String( va( "%s\n", buffer ) ) ) );
}
Exemplo n.º 3
0
std::vector<std::string> PyInterpreter::Complete(const std::string& cmd, int max_options)
{
    std::vector<std::string> ret;
    PyErr_Clear();

    if(pycomplete) {
        for(int i=0; i < max_options; ++i) {
#if PY_MAJOR_VERSION >= 3
            PyUniqueObj args = PyTuple_Pack( 2, PyUnicode_FromString(cmd.c_str()), PyLong_FromSize_t(i) );
            PyUniqueObj result = PyObject_CallObject(pycomplete, args);
            if (result && PyUnicode_Check(result)) {
                std::string res_str(PyUnicode_AsUTF8(result));
#else
            PyUniqueObj args = PyTuple_Pack(2, PyString_FromString(cmd.c_str()), PyInt_FromSize_t(i));
            PyUniqueObj result = PyObject_CallObject(pycomplete, args);
            if (result && PyString_Check(result)) {
                std::string res_str(PyString_AsString(result));
#endif
                if( res_str.find("__")==std::string::npos ||
                    cmd.find("__")!=std::string::npos ||
                    (cmd.size() > 0 && cmd[cmd.size()-1] == '_')
                ) {
                    ret.push_back( res_str );
                }
            }else{
                break;
            }
        }
    }

    return ret;
}

void PyInterpreter::PushCommand(const std::string& cmd)
{
    PyUniqueObj obj = EvalExec(cmd);
    if(obj && obj != Py_None) {
        const std::string output = ToString(obj);
        line_queue.push(
            ConsoleLine(output, ConsoleLineTypeOutput)
        );
    }
}
Exemplo n.º 4
0
void ConsoleLineBuffer::append(QByteArray data)
{
    bool bLineCompleted = false;

    int currentLines = list_.count();
    int numLines = data.count('\n');

    if (numLines > 0)
    {
        beginInsertRows(QModelIndex(), currentLines, currentLines + numLines -1);
    }

    for (int i = 0; i < data.size(); ++i)
    {
        const char c = data.at(i);
        appendToLastLine(c);

        if (c == '\n')
        {
            bLineCompleted = true;
            refreshSingleHighlighting(list_.last());
            writeLineToLogFile(list_.last());
            list_.append(ConsoleLine());
        }
    }

    if (numLines > 0)
    {
        endInsertRows();
    }

    if (!bLineCompleted)
    {
        QModelIndex index = createIndex(list_.count(), 0);
        emit dataChanged(index, index);
    }
}
Exemplo n.º 5
0
void ConsoleLineBuffer::createNewLine()
{
    beginInsertRows(QModelIndex(), list_.count(), list_.count());
    list_.append(ConsoleLine());
    endInsertRows();
}