Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr

This commit is contained in:
David Shah 2018-06-29 12:02:44 +02:00
commit 17d6586189
3 changed files with 51 additions and 14 deletions

View File

@ -52,7 +52,8 @@ void PythonConsole::keyPressEvent( QKeyEvent* e )
if ( ! canGoLeft( ) )
return;
}
if (!cursorIsOnInputLine()) return;
if (textCursor().columnNumber() < PythonConsole::PROMPT.size()) return;
QTextEdit::keyPressEvent( e );
}
@ -292,3 +293,30 @@ void PythonConsole::moveCursorToEnd( )
cursor.movePosition( QTextCursor::End );
setTextCursor( cursor );
}
void PythonConsole::insertFromMimeData(const QMimeData *src)
{
if (src->hasText()) {
QStringList list = src->text().split("\n",QString::KeepEmptyParts);
bool lastends = src->text().endsWith("\n");
for (int i=0;i<list.size();i++)
{
QString line = list.at(i);
displayString(line);
if (!lastends && (i==list.size()-1)) break;
m_parseHelper.process( line.toStdString( ) );
if ( m_parseHelper.buffered( ) )
{
append("");
displayPrompt( );
}
if ( line.size( ) )
{
m_historyBuffer.push_back( line.toStdString( ) );
m_historyIt = m_historyBuffer.end();
}
moveCursorToEnd( );
}
}
}

View File

@ -25,6 +25,7 @@ SOFTWARE.
#define PYCONSOLE_H
#include <QColor>
#include <QTextEdit>
#include <QMimeData>
#include "ParseHelper.h"
#include "ParseListener.h"
@ -47,6 +48,8 @@ class PythonConsole : public QTextEdit, ParseListener
virtual void handleReturnKeyPress();
virtual void insertFromMimeData(const QMimeData *src);
/**
Handle a compilable chunk of Python user input.
*/

View File

@ -1,18 +1,20 @@
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(PYTHON_CONSOLE_SRC
../3rdparty/python-console/ColumnFormatter.cpp
../3rdparty/python-console/ParseHelper.cpp
../3rdparty/python-console/ParseHelper.BlockParseState.cpp
../3rdparty/python-console/ParseHelper.BracketParseState.cpp
../3rdparty/python-console/ParseHelper.ContinuationParseState.cpp
../3rdparty/python-console/ParseMessage.cpp
../3rdparty/python-console/modified/pyredirector.cc
../3rdparty/python-console/modified/pyinterpreter.cc
../3rdparty/python-console/modified/pyconsole.cc
)
if (BUILD_PYTHON)
set(PYTHON_CONSOLE_SRC
../3rdparty/python-console/ColumnFormatter.cpp
../3rdparty/python-console/ParseHelper.cpp
../3rdparty/python-console/ParseHelper.BlockParseState.cpp
../3rdparty/python-console/ParseHelper.BracketParseState.cpp
../3rdparty/python-console/ParseHelper.ContinuationParseState.cpp
../3rdparty/python-console/ParseMessage.cpp
../3rdparty/python-console/modified/pyredirector.cc
../3rdparty/python-console/modified/pyinterpreter.cc
../3rdparty/python-console/modified/pyconsole.cc
)
endif()
aux_source_directory(. GUI_SOURCE_FILES)
aux_source_directory(${family}/ GUI_SOURCE_FILES)
@ -25,6 +27,10 @@ set(GUI_LIBRARY_FILES_${ufamily} Qt5::Widgets Qt5::OpenGL ${OPENGL_LIBRARIES} Qt
add_library(gui_${family} STATIC ${GUI_SOURCE_FILES} ${PYTHON_CONSOLE_SRC} ${GUI_RESOURCE_FILES})
target_include_directories(gui_${family} PRIVATE ../${family} ${family} ../3rdparty/QtPropertyBrowser/src ../3rdparty/python-console ../3rdparty/python-console/modified)
target_include_directories(gui_${family} PRIVATE ../${family} ${family} ../3rdparty/QtPropertyBrowser/src)
if (BUILD_PYTHON)
target_include_directories(gui_${family} PRIVATE ../3rdparty/python-console ../3rdparty/python-console/modified)
endif()
target_compile_definitions(gui_${family} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS)
target_link_libraries(gui_${family} Qt5::Widgets)