Skip to content

Commit

Permalink
improve auto indentation
Browse files Browse the repository at this point in the history
remove debugging output
  • Loading branch information
hkiel committed Jan 18, 2018
1 parent 4a5e0fc commit 914a7dc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 45 deletions.
34 changes: 20 additions & 14 deletions OMNotebook/OMNotebookGUI/indent.cpp
Expand Up @@ -114,7 +114,7 @@ void Indent::ISM::newToken(QString s, QString s2)
lMod = true;
break;
}
lMod = false;
//lMod = false;

if(s2 == "if" || s == "if" )
{
Expand All @@ -124,59 +124,65 @@ void Indent::ISM::newToken(QString s, QString s2)
equation = false;

state = 1;
// lMod = true;
++level;
lMod = true;
}
else if(s == "when" || s == "for")
{
loopBlock = true;
++level;
state = 1;

}
break;

case 1:
if(loopBlock && (s == "then" || s == "loop"))
{
// ++level;
// lMod = true;
nextMod = +1;
lMod = true;
// nextMod = +1;
state = 0;
}
else if(s == "then" )
{
// ++level;
lMod = true;
if(equation || equationSection)
state = 2;
else
state = 3;
// lMod = true;
nextMod = +1;
}

break;

case 2:
if(s == "elseif" || (s == "else" && s2 == "if" && (skipNext = true)))
{
// lMod = true;;
--level;
lMod = true;
// --level;
// nextMod = -1;
state = 1;
break;
}
else if(s2 == "else")
{
// lMod = true;
}
else if(s == "else")
{
lMod = true;

}
else if(s == "end" && s2.left(2)=="if")
{
// lMod = true;
level--;
state = 0;
skipNext = true;
}
else
{
// lMod = false;
//--level;
//nextMod = -1;
//state = 0;
}
if (equation && s.right(1)==";") {
nextMod = -1;
state = 0;
}
Expand Down
43 changes: 12 additions & 31 deletions OMNotebook/OMNotebookGUI/notebook.cpp
Expand Up @@ -3891,18 +3891,15 @@ void NotebookWindow::setAutoIndent(bool b)

void NotebookWindow::eval()
{
if(GraphCell *g = dynamic_cast<GraphCell*>(subject_->getCursor()->currentCell()))
{
if(GraphCell *g = dynamic_cast<GraphCell*>(subject_->getCursor()->currentCell())) {
g->eval();
}

if(LatexCell *g = dynamic_cast<LatexCell*>(subject_->getCursor()->currentCell()))
{
if(LatexCell *g = dynamic_cast<LatexCell*>(subject_->getCursor()->currentCell())) {
g->eval();
}

if(InputCell *g = dynamic_cast<InputCell*>(subject_->getCursor()->currentCell()))
{
if(InputCell *g = dynamic_cast<InputCell*>(subject_->getCursor()->currentCell())) {
g->eval();
}
}
Expand Down Expand Up @@ -4191,51 +4188,35 @@ void NotebookWindow::shiftcellsDown()

void NotebookWindow::evalall()
{
bool value =subject_->isEmpty();
if (value==false)
{
if (subject_->isEmpty()==false) {
Cell* current=subject_->getMainCell()->child();
QVector<Cell*> cellcount=SearchCells(current);

for (int i =0;i<cellcount.size();i++)
{
if(GraphCell *g = dynamic_cast<GraphCell*>(cellcount[i]))
{
for (int i =0;i<cellcount.size();i++) {
if(GraphCell *g = dynamic_cast<GraphCell*>(cellcount[i])) {
g->eval();
cout << "eva graph cell"<<endl;
}
if(InputCell *g = dynamic_cast<InputCell*>(cellcount[i]))
{
cout << "eva input cell"<<endl;
if(InputCell *g = dynamic_cast<InputCell*>(cellcount[i])) {
g->eval();
}
}
}
else
{
} else {
qDebug()<<"The Document is Empty";
}
}

void NotebookWindow::evalallLatex()
{
bool value =subject_->isEmpty();
if (value==false)
{
if (subject_->isEmpty()==false) {
Cell* current=subject_->getMainCell()->child();
QVector<Cell*> cellcount=SearchCells(current);

for (int i =0;i<cellcount.size();i++)
{
if(LatexCell *g = dynamic_cast<LatexCell*>(cellcount[i]))
{
cout << "eva latex cell"<<endl;
for (int i =0;i<cellcount.size();i++) {
if(LatexCell *g = dynamic_cast<LatexCell*>(cellcount[i])) {
g->eval(true);
}
}
}
else
{
} else {
qDebug()<<"The Document is Empty";
}
}
Expand Down

0 comments on commit 914a7dc

Please sign in to comment.