Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rogloh and avsa242 changes #52

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ language: cpp
addons:
apt:
packages:
- fakeroot
- help2man
- lintian
- cppcheck
Expand All @@ -19,6 +20,7 @@ matrix:

include:
- os: osx
osx_image: xcode10
compiler: clang
env:
PLATFORM=osx
Expand Down Expand Up @@ -46,8 +48,19 @@ matrix:
PLATFORM=rpi
MNT=/home/travis/mnt

before_install: "if [ -f ./.travis/before_install.sh ] ; then ./.travis/before_install.sh ; fi"
install: "if [ -f ./.travis/install.sh ] ; then ./.travis/install.sh ; fi"
before_install:
- if [ -f ./.travis/before_install.sh ] ; then ./.travis/before_install.sh ; fi

install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
travis_wait brew upgrade --cleanup;
travis_wait brew upgrade --cleanup &&
travis_wait brew install modules &&
brew info modules &&
source /usr/local/opt/modules/init/bash &&
export TRAVIS_PYTHON_VERSION=2.7.15;
fi
- if [ -f ./.travis/install.sh ] ; then ./.travis/install.sh ; fi
before_script: "if [ -f ./.travis/before_script.sh ] ; then ./.travis/before_script.sh ; fi"
script: "if [ -f ./.travis/script.sh ] ; then ./.travis/script.sh ; fi"
after_script: "if [ -f ./.travis/after_script.sh ] ; then ./.travis/after_script.sh ; fi"
Expand Down
6 changes: 4 additions & 2 deletions src/propelleride/compilers/externalcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ QString ExternalCompiler::build(QString filename,
QString basefile = infile;
basefile.chop(pattern_in.size());

QString outfile = basefile.append(pattern_out);
QString retfile = basefile.append(pattern_ret);
QString outfile = basefile;
QString retfile = basefile;

outfile += pattern_out;
retfile += pattern_ret;

QString exepath = getExecutablePath();

Expand Down
2 changes: 1 addition & 1 deletion src/propelleride/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char *argv[])
#ifdef VERSION
qApp->setApplicationVersion(VERSION);
#else
qApp->setApplicationVersion("0.0.0 (dev)");
qApp->setApplicationVersion("0.0.0 (git)");
#endif

QString description = QObject::tr("An easy-to-use, cross-platform IDE for the Parallax Propeller");
Expand Down
87 changes: 80 additions & 7 deletions src/propelleride/views/editorview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,74 @@ class LineNumberArea : public QWidget
EditorView * codeEditor;
};

// Attempt to filter and support useful characters within code completion dialog
class MyFilter : public QObject
{
public:
MyFilter(QComboBox *p, int *key) :QObject()
{
parent = p;
lastkey = key;
}

protected:
bool eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
// add special key handling here
//qDebug() << "key event" ;
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
int index = parent->view()->currentIndex().row();
//qDebug() << "key index = " << *lastkey;
*lastkey = 0;
Qt::Key key = (Qt::Key)ke->key();
if ((key >= Qt::Key_0 && key <= Qt::Key_9) ||
key == Qt::Key_Dollar || key == Qt::Key_Percent || key == Qt::Key_Ampersand ||
key == Qt::Key_Greater || key == Qt::Key_Less || key == Qt::Key_At || key == Qt::Key_ParenLeft)
{
*lastkey = (int)key;
emit parent->activated(0);
return true;
}
if (key == Qt::Key_Period || key == Qt::Key_NumberSign)
{
emit parent->activated(0);
return true;
}
if (key == Qt::Key_Space || key == Qt::Key_Return || key == Qt::Key_Tab)
{
if (index < 0) // protect ourselves in case of empty list?
index = 0;
emit parent->activated(index);
return true;
}
}
return QObject::eventFilter(obj, event);
}
private:
QComboBox *parent;
int *lastkey;
};

class MyComboBox : public QComboBox
{
public:
MyComboBox(EditorView *editor) : QComboBox(editor)
{
codeEditor = editor;
filt = new MyFilter(this, &lastkey);
view()->installEventFilter(filt);
}
~MyComboBox() {delete filt;}

virtual int getLastKey() { return lastkey;}
private:
EditorView *codeEditor;
MyFilter *filt;
int lastkey;
};


EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent)
{
Expand Down Expand Up @@ -64,7 +132,7 @@ EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent)
connect(this, SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool)));

// this must be a pointer otherwise we can't control the position.
cbAuto = new QComboBox(this);
cbAuto = new MyComboBox(this);
cbAuto->setMaxVisibleItems(10);
cbAuto->hide();
}
Expand Down Expand Up @@ -195,7 +263,7 @@ QPoint EditorView::keyPopPoint(QTextCursor cursor)
int ht = fontMetrics().height();
int wd = fontMetrics().width(' ');
int col = cursor.columnNumber();
int row = cursor.blockNumber() + 1; // show just below line
int row = cursor.blockNumber() + 2; // show just below line

QTextBlock block = firstVisibleBlock();
int top = block.firstLineNumber();
Expand Down Expand Up @@ -385,22 +453,27 @@ void EditorView::finishAutoComplete(int index)
{
disconnect(cbAuto,SIGNAL(activated(int)),this,SLOT(finishAutoComplete(int)));

qDebug() << "finishAutocomplete " << index;
QString text = selectAutoComplete();
qDebug() << "finishAutocomplete text is:" << text;

QString s = cbAuto->itemText(index);
QTextCursor cur = this->textCursor();

// we depend on index item 0 to be the auto-start key
if(index != 0)
{
if (text.length() > 0)
//if (text.length() > 0)
cur.insertText(cbAuto->itemText(0)+s.trimmed());
else
cur.insertText(s.trimmed());
//else
//cur.insertText(s.trimmed());
}
else
{
cur.insertText(cbAuto->itemText(0));
if (((MyComboBox *)cbAuto)->getLastKey())
cur.insertText(cbAuto->itemText(0) + (char)(((MyComboBox *)cbAuto)->getLastKey()));
else
cur.insertText(cbAuto->itemText(0));
}

if(s.indexOf("(") > 0)
Expand All @@ -412,7 +485,7 @@ void EditorView::finishAutoComplete(int index)
}

this->setTextCursor(cur);
cbAuto->hide();
cbAuto->hidePopup();// modified
}

void EditorView::dedent()
Expand Down
Loading