Skip to content

Commit c40dc95

Browse files
committed
Removed AUTO_ENTER and AUTOCOMPLETE defines; removed more C leftovers; removed annoying indent correction that makes life impossible; removed more dead code; refactored find message
1 parent 2b5bf64 commit c40dc95

File tree

7 files changed

+49
-155
lines changed

7 files changed

+49
-155
lines changed

src/propelleride/SpinParser.cpp

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ QStringList SpinParser::spinFileTree(QString file, QString libpath)
6868
spinFiles.append(file.mid(file.lastIndexOf("/")+1));
6969
QStringList keys = db.keys();
7070

71-
#if defined(SPIN_AUTOCOMPLETE)
72-
makeTags(file);
73-
#endif
74-
7571
QStringList nodes;
7672
foreach(key, keys) {
7773
value = db[key];
@@ -101,34 +97,6 @@ QStringList SpinParser::spinFileTree(QString file, QString libpath)
10197
return spinFiles;
10298
}
10399

104-
void SpinParser::makeTags(QString file)
105-
{
106-
#if 0
107-
// not actually used?
108-
QStringList keys = db.keys();
109-
110-
QString tagheader = \
111-
"!_TAG_FILE_FORMAT 1 /original ctags format/\n"
112-
"!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/\n"
113-
"!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/\n"
114-
"!_TAG_PROGRAM_NAME Exuberant Ctags //\n"
115-
"!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/\n"
116-
"!_TAG_PROGRAM_VERSION 5.8 //\n";
117-
118-
QString path = file.mid(0,file.lastIndexOf("/")+1);
119-
QFile tags(path+"tags");
120-
if(tags.open(QFile::WriteOnly | QFile::Text)) {
121-
tags.write(tagheader.toLatin1());
122-
foreach(QString key, keys) {
123-
QStringList tl = db[key].split("\t");
124-
QString ts = tl[0]+"\t"+tl[1]+"\t/^"+tl[2]+"$/";
125-
tags.write(ts.toLatin1()+"\n");
126-
}
127-
tags.close();
128-
}
129-
#endif
130-
}
131-
132100
QString SpinParser::tagItem(QStringList tabs, int field)
133101
{
134102
QString s;
@@ -712,37 +680,6 @@ void SpinParser::findSpinTags (QString fileName, QString objnode)
712680
//qDebug() << shortFileName(fileName) << objnode << "Section " << ": " << line;
713681
}
714682

715-
#if !defined(SPIN_AUTOCOMPLETE)
716-
/* In Spin, keywords always are at the start of the line. */
717-
SpinKind type = K_NONE;
718-
KeyWord kw = spin_keywords[1]; // K_OBJECT is not 1, but OBJ keyword is.
719-
line = line.trimmed();
720-
QRegExp tokens("\\b(con|obj|pri|pub|dat|var)\\b");
721-
tokens.setCaseSensitivity(Qt::CaseInsensitive);
722-
if(line.indexOf(tokens) == 0) {
723-
// if line has obj at position 0, get the type and store it
724-
// else set to some other type so we stop looking for objects
725-
if(line.indexOf("obj",0,Qt::CaseInsensitive) == 0)
726-
type = (SpinKind) match_keyword (line.toLatin1(), &kw, tag);
727-
else
728-
type = this->K_CONST;
729-
730-
// keep state until it changes from K_NONE
731-
if(type != K_NONE) {
732-
state = type;
733-
}
734-
}
735-
736-
//printf ("state %d\n", state);
737-
switch(state) {
738-
case K_OBJECT:
739-
match_object(line);
740-
break;
741-
default:
742-
tag = "";
743-
break;
744-
}
745-
#else
746683
/* In Spin, keywords always are at the start of the line. */
747684
SpinKind type = K_NONE;
748685
foreach(KeyWord kw, spin_keywords) {
@@ -785,7 +722,6 @@ void SpinParser::findSpinTags (QString fileName, QString objnode)
785722
tag = "";
786723
break;
787724
}
788-
#endif
789725
}
790726
}
791727

src/propelleride/SpinParser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class SpinParser
3535
K_KINDS
3636
} SpinKind;
3737

38-
void makeTags(QString file);
39-
4038
/*
4139
* Parse and get a spin project tree list.
4240
* All object instances will be listed with sub-objects.

src/propelleride/editor.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,19 @@ void Editor::keyPressEvent (QKeyEvent *e)
124124
useSpinSuggestion(key);
125125
}
126126
else {
127-
#ifdef ENABLE_AUTO_ENTER
128-
if(autoEnterColumn() == 0)
127+
if(autoIndent() == 0)
129128
QPlainTextEdit::keyPressEvent(e);
130-
#endif
131129
}
132130
}
133-
#ifdef ENABLE_AUTO_ENTER
134131
else if(key == Qt::Key_BraceRight) {
135132
if(braceMatchColumn() == 0)
136133
QPlainTextEdit::keyPressEvent(e);;
137134
}
138-
#endif
139135
/* if F1 get word under mouse and pass to findSymbolHelp. no word is ok too. */
140136
else if(key == Qt::Key_F1) {
141137
contextHelp();
142138
QPlainTextEdit::keyPressEvent(e);
143139
}
144-
#if defined(SPIN_AUTOCOMPLETE)
145140
#ifdef SPIN_AUTOCON
146141
/* #-auto complete */
147142
else if(key == Qt::Key_NumberSign) {
@@ -164,7 +159,7 @@ void Editor::keyPressEvent (QKeyEvent *e)
164159
QPlainTextEdit::keyPressEvent(e);
165160
}
166161
}
167-
#endif
162+
168163
/* if TAB key do block move */
169164
else if(key == Qt::Key_Tab || key == Qt::Key_Backtab) {
170165
if(QToolTip::isVisible() && propDialog->getSpinSuggestEnable()) {
@@ -429,7 +424,7 @@ void Editor::mouseDoubleClickEvent (QMouseEvent *e)
429424
mousepos = e->pos();
430425
}
431426

432-
int Editor::autoEnterColumn()
427+
int Editor::autoIndent()
433428
{
434429
QTextCursor cur = this->textCursor();
435430
if(cur.selectedText().length() > 0) {
@@ -446,18 +441,6 @@ int Editor::autoEnterColumn()
446441
QRegExp sections("\\b(con|dat|pub|pri|obj|var)\\b");
447442
sections.setCaseSensitivity(Qt::CaseInsensitive);
448443

449-
if((text.length() == 0 && col == 0) || text.indexOf(sections) == 0) {
450-
cur.beginEditBlock();
451-
cur.insertBlock();
452-
for(int n = propDialog->getTabSpaces(); n > 0; n--) {
453-
cur.insertText(" ");
454-
}
455-
this->setTextCursor(cur);
456-
/* end a single undo/redo operation */
457-
cur.endEditBlock();
458-
return 1;
459-
}
460-
461444
// handle indent for spin
462445
int stop = -1;
463446
int indent = -1;

src/propelleride/editor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Editor : public QPlainTextEdit
4141
inline void setCodeType(CodeType type) { codeType = type; }
4242

4343
private:
44-
int autoEnterColumn();
44+
int autoIndent();
4545
int braceMatchColumn();
4646
bool isCommentOpen(int line);
4747
bool isSpinCommentOpen(int line);

src/propelleride/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public slots:
198198
QPushButton *regexButton;
199199
QString findText;
200200
QString replaceText;
201+
bool showFindMessage(QString type);
201202

202203
QHBoxLayout *findLayout;
203204
QLineEdit *findEdit;

src/propelleride/mainwindow/find.cpp

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ QFrame *MainWindow::newFindFrame(QSplitter *split)
2525
findLayout->setContentsMargins(11, 11, 11, 11);
2626
findLayout->setObjectName(QStringLiteral("findLayout"));
2727
findLayout->setContentsMargins(4, 4, 4, 0);
28-
28+
2929
/* "Find:" */
3030
findLabel = new QLabel();
3131
findLabel->setObjectName(QStringLiteral("findLabel"));
@@ -48,37 +48,37 @@ QFrame *MainWindow::newFindFrame(QSplitter *split)
4848
findPreviousBtn = new QToolButton();
4949
findPreviousBtn->setObjectName(QStringLiteral("findPreviousBtn"));
5050
findPreviousBtn->setStyleSheet("QToolButton {\
51-
background: url(:/icons/find-previous.png) center no-repeat;\
52-
width: 24;\
53-
height: 24;\
54-
border-width: 0;\
55-
border: none;\
56-
}\
57-
QToolButton:pressed {\
58-
background: url(:/icons/find-previous-pressed.png) center no-repeat;\
59-
border-width: 0;\
60-
border: none;\
61-
}\
62-
");
51+
background: url(:/icons/find-previous.png) center no-repeat;\
52+
width: 24;\
53+
height: 24;\
54+
border-width: 0;\
55+
border: none;\
56+
}\
57+
QToolButton:pressed {\
58+
background: url(:/icons/find-previous-pressed.png) center no-repeat;\
59+
border-width: 0;\
60+
border: none;\
61+
}\
62+
");
6363
findLayout->addWidget(findPreviousBtn);
6464
connect(findPreviousBtn,SIGNAL(clicked()),this,SLOT(findPrevClicked()));
6565

6666
/* find-next button */
6767
findNextBtn = new QToolButton();
6868
findNextBtn->setObjectName(QStringLiteral("findNextBtn"));
6969
findNextBtn->setStyleSheet("QToolButton {\
70-
background: url(:/icons/find-next.png) center no-repeat;\
71-
width: 24;\
72-
height: 24;\
73-
border-width: 0;\
74-
border: none;\
75-
}\
76-
QToolButton:pressed {\
77-
background: url(:/icons/find-next-pressed.png) center no-repeat;\
78-
border-width: 0;\
79-
border: none;\
80-
}\
81-
");
70+
background: url(:/icons/find-next.png) center no-repeat;\
71+
width: 24;\
72+
height: 24;\
73+
border-width: 0;\
74+
border: none;\
75+
}\
76+
QToolButton:pressed {\
77+
background: url(:/icons/find-next-pressed.png) center no-repeat;\
78+
border-width: 0;\
79+
border: none;\
80+
}\
81+
");
8282
findLayout->addWidget(findNextBtn);
8383
connect(findNextBtn,SIGNAL(clicked()),this,SLOT(findNextClicked()));
8484

@@ -150,7 +150,7 @@ QFrame *MainWindow::newFindFrame(QSplitter *split)
150150
replaceAllBtn->setObjectName(QStringLiteral("replaceAllBtn"));
151151
replaceLayout->addWidget(replaceAllBtn);
152152
connect(replaceAllBtn,SIGNAL(clicked()),this,SLOT(replaceAllClicked()));
153-
153+
154154
/* add replace feature to the layout */
155155
verticalLayout->addLayout(replaceLayout);
156156

@@ -199,13 +199,8 @@ void MainWindow::showFindFrame()
199199
clearFindText();
200200
}
201201

202-
if (findFrame->isVisible()) {
203-
findFrame->setVisible(false);
204-
}
205-
else {
206-
findEdit->setFocus();
207-
findFrame->setVisible(true);
208-
}
202+
findEdit->setFocus();
203+
findFrame->setVisible(true);
209204
}
210205

211206
void MainWindow::hideFindFrame()
@@ -373,12 +368,6 @@ void MainWindow::findPrevClicked()
373368

374369
if(count > 0) {
375370
QTextCursor cur = editor->textCursor();
376-
// the following code was setting the cursor left by 1
377-
//int len = cur.selectedText().length();
378-
//cur.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor);
379-
//cur.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor);
380-
//cur.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor,len);
381-
//editor->setTextCursor(cur);
382371
findPosition = editor->textCursor().position();
383372
}
384373
}
@@ -407,9 +396,7 @@ void MainWindow::replaceClicked()
407396
hide();
408397
}
409398
}
410-
/*
411-
* If find text is highlighted, replace and find again.
412-
*/
399+
413400
void MainWindow::replaceNextClicked()
414401
{
415402
Editor *editor = getEditor(editorTabs->currentIndex());
@@ -427,9 +414,6 @@ void MainWindow::replaceNextClicked()
427414
}
428415
}
429416

430-
/*
431-
* If find text is highlighted, replace and find again.
432-
*/
433417
void MainWindow::replacePrevClicked()
434418
{
435419
Editor *editor = getEditor(editorTabs->currentIndex());
@@ -485,7 +469,7 @@ void MainWindow::replaceAllClicked()
485469
editor->textCursor().endEditBlock();
486470

487471
QMessageBox::information(this, tr("Replace Done"),
488-
tr("Replaced %1 instances of \"%2\".").arg(count).arg(text));
472+
tr("Replaced %1 instances of \"%2\".").arg(count).arg(text));
489473
}
490474

491475
QString MainWindow::getReplaceText()
@@ -497,11 +481,15 @@ void MainWindow::clearReplaceText()
497481
replaceEdit->clear();
498482
}
499483

500-
bool MainWindow::showBeginMessage(QString type)
484+
485+
bool MainWindow::showFindMessage(QString text)
501486
{
502-
QMessageBox::StandardButton ret = QMessageBox::information(
503-
this, type, type+tr(" from beginning?"),
504-
QMessageBox::Cancel, QMessageBox::Ok);
487+
QMessageBox msgBox;
488+
msgBox.setText(text);
489+
msgBox.setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
490+
msgBox.setDefaultButton(QMessageBox::Ok);
491+
int ret = msgBox.exec();
492+
505493
if(ret == QMessageBox::Cancel) {
506494
return false;
507495
}
@@ -514,19 +502,12 @@ bool MainWindow::showBeginMessage(QString type)
514502
return true;
515503
}
516504

505+
bool MainWindow::showBeginMessage(QString type)
506+
{
507+
return showFindMessage(type+tr(" from beginning?"));
508+
}
509+
517510
bool MainWindow::showEndMessage(QString type)
518511
{
519-
QMessageBox::StandardButton ret = QMessageBox::information(
520-
this, type, type+tr(" from end?"),
521-
QMessageBox::Cancel, QMessageBox::Ok);
522-
if(ret == QMessageBox::Cancel) {
523-
return false;
524-
}
525-
Editor *editor = getEditor(editorTabs->currentIndex());
526-
if(editor == NULL)
527-
return false;
528-
QTextCursor cur = editor->textCursor();
529-
cur.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
530-
editor->setTextCursor(cur);
531-
return true;
512+
return showFindMessage(type+tr(" from end?"));
532513
}

src/propelleride/propelleride.pro

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,3 @@ win32 {
7777
LIBS += -L$$PWD -lz
7878
RC_FILE = propelleride.rc
7979
}
80-
81-
# ENABLE_AUTO_ENTER turns on AUTO-INDENT
82-
DEFINES += ENABLE_AUTO_ENTER
83-
# SPIN_AUTOCOMPLETE turns on spinny-sense
84-
DEFINES += SPIN_AUTOCOMPLETE

0 commit comments

Comments
 (0)